diff --git a/apps/common/main/resources/less/asc-mixins.less b/apps/common/main/resources/less/asc-mixins.less index bac76454f..440c1eaee 100644 --- a/apps/common/main/resources/less/asc-mixins.less +++ b/apps/common/main/resources/less/asc-mixins.less @@ -95,8 +95,8 @@ .pixel-ratio__1_5 { @ratio: 1.5; - @one-px: 1px / @ratio; - @two-px: 2px / @ratio; + @one-px: (1px / @ratio); + @two-px: (2px / @ratio); --pixel-ratio-factor: @ratio; --scaled-one-pixel: @one-px; @@ -108,8 +108,8 @@ .pixel-ratio__1_25 { @ratio: 1.25; - @one-px: 1px / @ratio; - @two-px: 2px / @ratio; + @one-px: (1px / @ratio); + @two-px: (2px / @ratio); --pixel-ratio-factor: @ratio; --scaled-one-pixel: @one-px; @@ -118,8 +118,8 @@ .pixel-ratio__1_75 { @ratio: 1.75; - @one-px: 1px / @ratio; - @two-px: 2px / @ratio; + @one-px: (1px / @ratio); + @two-px: (2px / @ratio); --pixel-ratio-factor: @ratio; --scaled-one-pixel: @one-px; diff --git a/vendor/less/README.md b/vendor/less/README.md index 41a585400..a4f22dede 100644 --- a/vendor/less/README.md +++ b/vendor/less/README.md @@ -1,25 +1,15 @@

- -

optionalDependency Status Twitter Follow

+ +

+ Github Actions CI + Downloads + + Twitter Follow +


Chat with Less.js users and contributors

-

Sauce Test Status

- -# [Less.js](http://lesscss.org) - -> The **dynamic** stylesheet language. [http://lesscss.org](http://lesscss.org). - -This is the JavaScript, official, stable version of Less. - - -## Getting Started - -Options for adding Less.js to your project: - -* Install with [npm](https://npmjs.org): `npm install less` -* [Download the latest release][download] -* Clone the repo: `git clone https://github.com/less/less.js.git` +This is the Less.js monorepo, managed via [Lerna](https://lerna.js.org/). ## More information @@ -47,6 +37,14 @@ Read [Developing Less](http://lesscss.org/usage/#developing-less). ## Release History See the [changelog](CHANGELOG.md) +## Contributors + +### Code Contributors + +This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)]. + + + ## [License](LICENSE) Copyright (c) 2009-2017 [Alexis Sellier](http://cloudhead.io) & The Core Less Team diff --git a/vendor/less/dist/less-2.7.1.js b/vendor/less/dist/less-2.7.1.js deleted file mode 100644 index 556e2b564..000000000 --- a/vendor/less/dist/less-2.7.1.js +++ /dev/null @@ -1,10839 +0,0 @@ -/*! - * Less - Leaner CSS v2.7.1 - * http://lesscss.org - * - * Copyright (c) 2009-2016, Alexis Sellier - * Licensed under the Apache-2.0 License. - * - */ - - /** * @license Apache-2.0 - */ - -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.less = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0) || - options.isFileProtocol ? 'development' - : 'production'); - - var dumpLineNumbers = /!dumpLineNumbers:(comments|mediaquery|all)/.exec(window.location.hash); - if (dumpLineNumbers) { - options.dumpLineNumbers = dumpLineNumbers[1]; - } - - if (options.useFileCache === undefined) { - options.useFileCache = true; - } - - if (options.onReady === undefined) { - options.onReady = true; - } - -}; - -},{"./browser":3,"./utils":10}],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 */ - -// shim Promise if required -require('promise/polyfill.js'); - -var options = window.less || {}; -require("./add-default-options")(window, options); - -var less = module.exports = require("./index")(window, options); - -window.less = less; - -var css, head, style; - -// Always restore page visibility -function resolveOrReject(data) { - if (data.filename) { - console.warn(data); - } - if (!options.async) { - head.removeChild(style); - } -} - -if (options.onReady) { - if (/!watch/.test(window.location.hash)) { - less.watch(); - } - // Simulate synchronous stylesheet loading by blocking page rendering - if (!options.async) { - css = 'body { display: none !important }'; - head = document.head || document.getElementsByTagName('head')[0]; - style = document.createElement('style'); - - style.type = 'text/css'; - if (style.styleSheet) { - style.styleSheet.cssText = css; - } else { - style.appendChild(document.createTextNode(css)); - } - - head.appendChild(style); - } - less.registerStylesheetsImmediately(); - 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){ -var utils = require("./utils"); -module.exports = { - createCSS: function (document, styles, sheet) { - // Strip the query-string - var href = sheet.href || ''; - - // If there is no title set, use the filename, minus the extension - var id = 'less:' + (sheet.title || utils.extractId(href)); - - // If this has already been inserted into the DOM, we may need to replace it - var oldStyleNode = document.getElementById(id); - var keepOldStyleNode = false; - - // Create a new stylesheet node for insertion or (if necessary) replacement - var styleNode = document.createElement('style'); - styleNode.setAttribute('type', 'text/css'); - if (sheet.media) { - styleNode.setAttribute('media', sheet.media); - } - styleNode.id = id; - - if (!styleNode.styleSheet) { - styleNode.appendChild(document.createTextNode(styles)); - - // If new contents match contents of oldStyleNode, don't replace oldStyleNode - keepOldStyleNode = (oldStyleNode !== null && oldStyleNode.childNodes.length > 0 && styleNode.childNodes.length > 0 && - oldStyleNode.firstChild.nodeValue === styleNode.firstChild.nodeValue); - } - - var head = document.getElementsByTagName('head')[0]; - - // If there is no oldStyleNode, just append; otherwise, only append if we need - // to replace oldStyleNode with an updated stylesheet - if (oldStyleNode === null || keepOldStyleNode === false) { - var nextEl = sheet && sheet.nextSibling || null; - if (nextEl) { - nextEl.parentNode.insertBefore(styleNode, nextEl); - } else { - head.appendChild(styleNode); - } - } - if (oldStyleNode && keepOldStyleNode === false) { - oldStyleNode.parentNode.removeChild(oldStyleNode); - } - - // For IE. - // This needs to happen *after* the style element is added to the DOM, otherwise IE 7 and 8 may crash. - // See http://social.msdn.microsoft.com/Forums/en-US/7e081b65-878a-4c22-8e68-c10d39c2ed32/internet-explorer-crashes-appending-style-element-to-head - if (styleNode.styleSheet) { - try { - styleNode.styleSheet.cssText = styles; - } catch (e) { - throw new Error("Couldn't reassign styleSheet.cssText."); - } - } - }, - currentScript: function(window) { - var document = window.document; - return document.currentScript || (function() { - var scripts = document.getElementsByTagName("script"); - return scripts[scripts.length - 1]; - })(); - } -}; - -},{"./utils":10}],4:[function(require,module,exports){ -// Cache system is a bit outdated and could do with work - -module.exports = function(window, options, logger) { - var cache = null; - if (options.env !== 'development') { - try { - cache = (typeof window.localStorage === 'undefined') ? null : window.localStorage; - } catch (_) {} - } - return { - setCSS: function(path, lastModified, modifyVars, styles) { - if (cache) { - logger.info('saving ' + path + ' to cache.'); - try { - cache.setItem(path, styles); - cache.setItem(path + ':timestamp', lastModified); - if (modifyVars) { - cache.setItem(path + ':vars', JSON.stringify(modifyVars)); - } - } catch(e) { - //TODO - could do with adding more robust error handling - logger.error('failed to save "' + path + '" to local storage for caching.'); - } - } - }, - getCSS: function(path, webInfo, modifyVars) { - var css = cache && cache.getItem(path), - timestamp = cache && cache.getItem(path + ':timestamp'), - vars = cache && cache.getItem(path + ':vars'); - - modifyVars = modifyVars || {}; - - if (timestamp && webInfo.lastModified && - (new Date(webInfo.lastModified).valueOf() === - new Date(timestamp).valueOf()) && - (!modifyVars && !vars || JSON.stringify(modifyVars) === vars)) { - // Use local copy - return css; - } - } - }; -}; - -},{}],5:[function(require,module,exports){ -var utils = require("./utils"), - browser = require("./browser"); - -module.exports = function(window, less, options) { - - function errorHTML(e, rootHref) { - var id = 'less-error-message:' + utils.extractId(rootHref || ""); - var template = '
  • {content}
  • '; - var elem = window.document.createElement('div'), timer, content, errors = []; - var filename = e.filename || rootHref; - var filenameNoPath = filename.match(/([^\/]+(\?.*)?)$/)[1]; - - elem.id = id; - elem.className = "less-error-message"; - - content = '

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

    ' + '

    in ' + filenameNoPath + " "; - - var errorline = function (e, i, classname) { - if (e.extract[i] !== undefined) { - errors.push(template.replace(/\{line\}/, (parseInt(e.line, 10) || 0) + (i - 1)) - .replace(/\{class\}/, classname) - .replace(/\{content\}/, e.extract[i])); - } - }; - - if (e.extract) { - errorline(e, 0, ''); - errorline(e, 1, 'line'); - errorline(e, 2, ''); - content += 'on line ' + e.line + ', column ' + (e.column + 1) + ':

    ' + - ''; - } - if (e.stack && (e.extract || options.logLevel >= 4)) { - content += '
    Stack Trace
    ' + e.stack.split('\n').slice(1).join('
    '); - } - elem.innerHTML = content; - - // CSS for error messages - browser.createCSS(window.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' }); - - elem.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(';'); - - if (options.env === 'development') { - timer = setInterval(function () { - var document = window.document, - body = document.body; - if (body) { - if (document.getElementById(id)) { - body.replaceChild(elem, document.getElementById(id)); - } else { - body.insertBefore(elem, body.firstChild); - } - clearInterval(timer); - } - }, 10); - } - } - - function removeErrorHTML(path) { - var node = window.document.getElementById('less-error-message:' + utils.extractId(path)); - if (node) { - node.parentNode.removeChild(node); - } - } - - function removeErrorConsole(path) { - //no action - } - - function removeError(path) { - if (!options.errorReporting || options.errorReporting === "html") { - removeErrorHTML(path); - } else if (options.errorReporting === "console") { - removeErrorConsole(path); - } else if (typeof options.errorReporting === 'function') { - options.errorReporting("remove", path); - } - } - - function errorConsole(e, rootHref) { - var template = '{line} {content}'; - 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 + " "; - - var errorline = function (e, i, classname) { - if (e.extract[i] !== undefined) { - errors.push(template.replace(/\{line\}/, (parseInt(e.line, 10) || 0) + (i - 1)) - .replace(/\{class\}/, classname) - .replace(/\{content\}/, e.extract[i])); - } - }; - - if (e.extract) { - errorline(e, 0, ''); - errorline(e, 1, 'line'); - errorline(e, 2, ''); - content += 'on line ' + e.line + ', column ' + (e.column + 1) + ':\n' + - errors.join('\n'); - } - if (e.stack && (e.extract || options.logLevel >= 4)) { - content += '\nStack Trace\n' + e.stack; - } - less.logger.error(content); - } - - function error(e, rootHref) { - if (!options.errorReporting || options.errorReporting === "html") { - errorHTML(e, rootHref); - } else if (options.errorReporting === "console") { - errorConsole(e, rootHref); - } else if (typeof options.errorReporting === 'function') { - options.errorReporting("add", e, rootHref); - } - } - - return { - add: error, - remove: removeError - }; -}; - -},{"./browser":3,"./utils":10}],6:[function(require,module,exports){ -/*global window, XMLHttpRequest */ - -module.exports = function(options, logger) { - - var AbstractFileManager = require("../less/environment/abstract-file-manager.js"); - - 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; - } - } - } - - var FileManager = function() { - }; - - FileManager.prototype = new AbstractFileManager(); - - FileManager.prototype.alwaysMakePathsAbsolute = function alwaysMakePathsAbsolute() { - return true; - }; - FileManager.prototype.join = function join(basePath, laterPath) { - if (!basePath) { - return laterPath; - } - return this.extractUrlParts(laterPath, basePath).path; - }; - FileManager.prototype.doXHR = function doXHR(url, type, callback, errback) { - - var xhr = getXMLHttpRequest(); - var async = options.isFileProtocol ? options.fileAsync : true; - - if (typeof xhr.overrideMimeType === 'function') { - xhr.overrideMimeType('text/css'); - } - logger.debug("XHR: Getting '" + url + "'"); - xhr.open('GET', url, async); - xhr.setRequestHeader('Accept', type || 'text/x-less, text/css; q=0.9, */*; q=0.5'); - xhr.send(null); - - function handleResponse(xhr, callback, errback) { - if (xhr.status >= 200 && xhr.status < 300) { - callback(xhr.responseText, - xhr.getResponseHeader("Last-Modified")); - } else if (typeof errback === 'function') { - errback(xhr.status, url); - } - } - - if (options.isFileProtocol && !options.fileAsync) { - if (xhr.status === 0 || (xhr.status >= 200 && xhr.status < 300)) { - callback(xhr.responseText); - } else { - errback(xhr.status, url); - } - } else if (async) { - xhr.onreadystatechange = function () { - if (xhr.readyState == 4) { - handleResponse(xhr, callback, errback); - } - }; - } else { - handleResponse(xhr, callback, errback); - } - }; - FileManager.prototype.supports = function(filename, currentDirectory, options, environment) { - return true; - }; - - FileManager.prototype.clearFileCache = function() { - fileCache = {}; - }; - - FileManager.prototype.loadFile = function loadFile(filename, currentDirectory, options, environment, callback) { - if (currentDirectory && !this.isPathAbsolute(filename)) { - filename = currentDirectory + 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}); - } - return; - } - - this.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 }); - }); - }; - - return FileManager; -}; - -},{"../less/environment/abstract-file-manager.js":15}],7:[function(require,module,exports){ -module.exports = function() { - - var functionRegistry = require("./../less/functions/function-registry"); - - function imageSize() { - throw { - type: "Runtime", - message: "Image size functions are not supported in browser version of less" - }; - } - - var imageFunctions = { - "image-size": function(filePathNode) { - imageSize(this, filePathNode); - return -1; - }, - "image-width": function(filePathNode) { - imageSize(this, filePathNode); - return -1; - }, - "image-height": function(filePathNode) { - imageSize(this, filePathNode); - return -1; - } - }; - - functionRegistry.addMultiple(imageFunctions); -}; - -},{"./../less/functions/function-registry":22}],8:[function(require,module,exports){ -// -// index.js -// Should expose the additional browser functions on to the less object -// -var addDataAttr = require("./utils").addDataAttr, - browser = require("./browser"); - -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; - - 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 - 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; - } - - // only really needed for phantom - function bind(func, thisArg) { - var curryArgs = Array.prototype.slice.call(arguments, 2); - return function() { - var args = curryArgs.concat(Array.prototype.slice.call(arguments, 0)); - return func.apply(thisArg, args); - }; - } - - function loadStyles(modifyVars) { - var styles = document.getElementsByTagName('style'), - style; - - for (var i = 0; i < styles.length; i++) { - style = styles[i]; - if (style.type.match(typePattern)) { - var instanceOptions = clone(options); - instanceOptions.modifyVars = modifyVars; - var lessText = style.innerHTML || ''; - instanceOptions.filename = document.location.href.replace(/#.*$/, ''); - - /*jshint loopfunc:true */ - // use closure to store current style - less.render(lessText, instanceOptions, - bind(function(style, e, result) { - if (e) { - errors.add(e, "inline"); - } else { - style.type = 'text/css'; - if (style.styleSheet) { - style.styleSheet.cssText = result.css; - } else { - style.innerHTML = result.css; - } - } - }, null, style)); - } - } - } - - function loadStyleSheet(sheet, callback, reload, remaining, modifyVars) { - - var instanceOptions = clone(options); - addDataAttr(instanceOptions, sheet); - instanceOptions.mime = sheet.type; - - if (modifyVars) { - instanceOptions.modifyVars = modifyVars; - } - - function loadInitialFileCallback(loadedFile) { - - var data = loadedFile.contents, - path = loadedFile.filename, - webInfo = loadedFile.webInfo; - - var newFileInfo = { - currentDirectory: fileManager.getPath(path), - filename: path, - rootFilename: path, - relativeUrls: instanceOptions.relativeUrls}; - - newFileInfo.entryPath = newFileInfo.currentDirectory; - newFileInfo.rootpath = instanceOptions.rootpath || newFileInfo.currentDirectory; - - if (webInfo) { - webInfo.remaining = remaining; - - var css = cache.getCSS(path, webInfo, instanceOptions.modifyVars); - if (!reload && css) { - webInfo.local = true; - callback(null, css, data, sheet, webInfo, path); - return; - } - - } - - //TODO add tests around how this behaves when reloading - errors.remove(path); - - instanceOptions.rootFileInfo = newFileInfo; - less.render(data, instanceOptions, function(e, result) { - if (e) { - 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); - }); - } - - function loadStyleSheets(callback, reload, modifyVars) { - for (var i = 0; i < less.sheets.length; i++) { - loadStyleSheet(less.sheets[i], callback, reload, less.sheets.length - (i + 1), modifyVars); - } - } - - function initRunningMode() { - if (less.env === 'development') { - less.watchTimer = setInterval(function () { - if (less.watchMode) { - fileManager.clearFileCache(); - loadStyleSheets(function (e, css, _, sheet, webInfo) { - if (e) { - errors.add(e, e.href || sheet.href); - } else if (css) { - browser.createCSS(window.document, css, sheet); - } - }); - } - }, options.poll); - } - } - - // - // Watch mode - // - less.watch = function () { - if (!less.watchMode ) { - less.env = 'development'; - initRunningMode(); - } - this.watchMode = true; - return true; - }; - - less.unwatch = function () {clearInterval(less.watchTimer); this.watchMode = false; return false; }; - - // - // Synchronously get all tags with the 'rel' attribute set to - // "stylesheet/less". - // - less.registerStylesheetsImmediately = function() { - var links = document.getElementsByTagName('link'); - less.sheets = []; - - for (var i = 0; i < links.length; i++) { - if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) && - (links[i].type.match(typePattern)))) { - less.sheets.push(links[i]); - } - } - }; - - // - // Asynchronously get all tags with the 'rel' attribute set to - // "stylesheet/less", returning a Promise. - // - less.registerStylesheets = function() { - return new Promise(function(resolve, reject) { - less.registerStylesheetsImmediately(); - resolve(); - }); - }; - - // - // With this function, it's possible to alter variables and re-render - // CSS without reloading less-files - // - less.modifyVars = function(record) { - return less.refresh(true, record, false); - }; - - less.refresh = function (reload, modifyVars, clearFileCache) { - if ((reload || clearFileCache) && clearFileCache !== false) { - fileManager.clearFileCache(); - } - return new Promise(function (resolve, reject) { - var startTime, endTime, totalMilliseconds, remainingSheets; - startTime = endTime = new Date(); - - // Set counter for remaining unprocessed sheets - remainingSheets = less.sheets.length; - - if (remainingSheets === 0) { - - endTime = new Date(); - totalMilliseconds = endTime - startTime; - less.logger.info("Less has finished and no sheets were loaded."); - resolve({ - startTime: startTime, - endTime: endTime, - totalMilliseconds: totalMilliseconds, - sheets: less.sheets.length - }); - - } else { - // Relies on less.sheets array, callback seems to be guaranteed to be called for every element of the array - loadStyleSheets(function (e, css, _, sheet, webInfo) { - if (e) { - errors.add(e, e.href || sheet.href); - reject(e); - return; - } - if (webInfo.local) { - less.logger.info("Loading " + sheet.href + " from cache."); - } else { - less.logger.info("Rendered " + sheet.href + " successfully."); - } - browser.createCSS(window.document, css, sheet); - less.logger.info("CSS for " + sheet.href + " generated in " + (new Date() - endTime) + 'ms'); - - // Count completed sheet - remainingSheets--; - - // Check if the last remaining sheet was processed and then call the promise - if (remainingSheets === 0) { - totalMilliseconds = new Date() - startTime; - less.logger.info("Less has finished. CSS generated in " + totalMilliseconds + 'ms'); - resolve({ - startTime: startTime, - endTime: endTime, - totalMilliseconds: totalMilliseconds, - sheets: less.sheets.length - }); - } - endTime = new Date(); - }, reload, modifyVars); - } - - loadStyles(modifyVars); - }); - }; - - less.refreshStyles = loadStyles; - 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){ -module.exports = function(less, options) { - - var logLevel_debug = 4, - logLevel_info = 3, - logLevel_warn = 2, - logLevel_error = 1; - - // The amount of logging in the javascript console. - // 3 - Debug, information and errors - // 2 - Information and errors - // 1 - Errors - // 0 - None - // Defaults to 2 - options.logLevel = typeof options.logLevel !== 'undefined' ? options.logLevel : (options.env === 'development' ? logLevel_info : logLevel_error); - - if (!options.loggers) { - options.loggers = [{ - debug: function(msg) { - if (options.logLevel >= logLevel_debug) { - console.log(msg); - } - }, - info: function(msg) { - if (options.logLevel >= logLevel_info) { - console.log(msg); - } - }, - warn: function(msg) { - if (options.logLevel >= logLevel_warn) { - console.warn(msg); - } - }, - error: function(msg) { - if (options.logLevel >= logLevel_error) { - console.error(msg); - } - } - }]; - } - for (var i = 0; i < options.loggers.length; i++) { - less.logger.addListener(options.loggers[i]); - } -}; - -},{}],10:[function(require,module,exports){ -module.exports = { - extractId: function(href) { - return href.replace(/^[a-z-]+:\/+?[^\/]+/, '') // Remove protocol & domain - .replace(/[\?\&]livereload=\w+/, '') // Remove LiveReload cachebuster - .replace(/^\//, '') // Remove root / - .replace(/\.[a-zA-Z]+$/, '') // Remove simple extension - .replace(/[^\.\w-]+/g, '-') // Replace illegal characters - .replace(/\./g, ':'); // Replace dots with colons(for valid id) - }, - addDataAttr: function(options, tag) { - for (var opt in tag.dataset) { - if (tag.dataset.hasOwnProperty(opt)) { - if (opt === "env" || opt === "dumpLineNumbers" || opt === "rootpath" || opt === "errorReporting") { - options[opt] = tag.dataset[opt]; - } else { - try { - options[opt] = JSON.parse(tag.dataset[opt]); - } - catch(_) {} - } - } - } - } -}; - -},{}],11:[function(require,module,exports){ -var contexts = {}; -module.exports = contexts; - -var copyFromOriginal = function copyFromOriginal(original, destination, propertiesToCopy) { - if (!original) { return; } - - for (var i = 0; i < propertiesToCopy.length; i++) { - if (original.hasOwnProperty(propertiesToCopy[i])) { - destination[propertiesToCopy[i]] = original[propertiesToCopy[i]]; - } - } -}; - -/* - parse is used whilst parsing - */ -var parseCopyProperties = [ - // options - 'paths', // option - unmodified - paths to search for imports on - 'relativeUrls', // option - whether to adjust URL's to be relative - 'rootpath', // option - rootpath to append to URL's - 'strictImports', // option - - 'insecure', // option - whether to allow imports from insecure ssl hosts - 'dumpLineNumbers', // option - whether to dump line numbers - 'compress', // option - whether to compress - 'syncImport', // option - whether to import synchronously - 'chunkInput', // option - whether to chunk input. more performant but causes parse issues. - 'mime', // browser only - mime type for sheet import - 'useFileCache', // browser only - whether to use the per file session cache - // context - 'processImports', // option & context - whether to process imports. if false then imports will not be imported. - // Used by the import manager to stop multiple import visitors being created. - 'pluginManager' // Used as the plugin manager for the session -]; - -contexts.Parse = function(options) { - copyFromOriginal(options, this, parseCopyProperties); - - if (typeof this.paths === "string") { this.paths = [this.paths]; } -}; - -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 - ]; - -contexts.Eval = function(options, frames) { - copyFromOriginal(options, this, evalCopyProperties); - - if (typeof this.paths === "string") { this.paths = [this.paths]; } - - this.frames = frames || []; - this.importantScope = this.importantScope || []; -}; - -contexts.Eval.prototype.inParenthesis = function () { - if (!this.parensStack) { - this.parensStack = []; - } - this.parensStack.push(true); -}; - -contexts.Eval.prototype.outOfParenthesis = function () { - this.parensStack.pop(); -}; - -contexts.Eval.prototype.isMathOn = function () { - return this.strictMath ? (this.parensStack && this.parensStack.length) : true; -}; - -contexts.Eval.prototype.isPathRelative = function (path) { - return !/^(?:[a-z-]+:|\/|#)/i.test(path); -}; - -contexts.Eval.prototype.normalizePath = function( path ) { - var - segments = path.split("/").reverse(), - segment; - - path = []; - while (segments.length !== 0 ) { - segment = segments.pop(); - switch( segment ) { - case ".": - break; - case "..": - if ((path.length === 0) || (path[path.length - 1] === "..")) { - path.push( segment ); - } else { - path.pop(); - } - break; - default: - path.push( segment ); - break; - } - } - - return path.join("/"); -}; - -//todo - do the same for the toCSS ? - -},{}],12:[function(require,module,exports){ -module.exports = { - 'aliceblue':'#f0f8ff', - 'antiquewhite':'#faebd7', - 'aqua':'#00ffff', - 'aquamarine':'#7fffd4', - 'azure':'#f0ffff', - 'beige':'#f5f5dc', - 'bisque':'#ffe4c4', - 'black':'#000000', - 'blanchedalmond':'#ffebcd', - 'blue':'#0000ff', - 'blueviolet':'#8a2be2', - 'brown':'#a52a2a', - 'burlywood':'#deb887', - 'cadetblue':'#5f9ea0', - 'chartreuse':'#7fff00', - 'chocolate':'#d2691e', - 'coral':'#ff7f50', - 'cornflowerblue':'#6495ed', - 'cornsilk':'#fff8dc', - 'crimson':'#dc143c', - 'cyan':'#00ffff', - 'darkblue':'#00008b', - 'darkcyan':'#008b8b', - 'darkgoldenrod':'#b8860b', - 'darkgray':'#a9a9a9', - 'darkgrey':'#a9a9a9', - 'darkgreen':'#006400', - 'darkkhaki':'#bdb76b', - 'darkmagenta':'#8b008b', - 'darkolivegreen':'#556b2f', - 'darkorange':'#ff8c00', - 'darkorchid':'#9932cc', - 'darkred':'#8b0000', - 'darksalmon':'#e9967a', - 'darkseagreen':'#8fbc8f', - 'darkslateblue':'#483d8b', - 'darkslategray':'#2f4f4f', - 'darkslategrey':'#2f4f4f', - 'darkturquoise':'#00ced1', - 'darkviolet':'#9400d3', - 'deeppink':'#ff1493', - 'deepskyblue':'#00bfff', - 'dimgray':'#696969', - 'dimgrey':'#696969', - 'dodgerblue':'#1e90ff', - 'firebrick':'#b22222', - 'floralwhite':'#fffaf0', - 'forestgreen':'#228b22', - 'fuchsia':'#ff00ff', - 'gainsboro':'#dcdcdc', - 'ghostwhite':'#f8f8ff', - 'gold':'#ffd700', - 'goldenrod':'#daa520', - 'gray':'#808080', - 'grey':'#808080', - 'green':'#008000', - 'greenyellow':'#adff2f', - 'honeydew':'#f0fff0', - 'hotpink':'#ff69b4', - 'indianred':'#cd5c5c', - 'indigo':'#4b0082', - 'ivory':'#fffff0', - 'khaki':'#f0e68c', - 'lavender':'#e6e6fa', - 'lavenderblush':'#fff0f5', - 'lawngreen':'#7cfc00', - 'lemonchiffon':'#fffacd', - 'lightblue':'#add8e6', - 'lightcoral':'#f08080', - 'lightcyan':'#e0ffff', - 'lightgoldenrodyellow':'#fafad2', - 'lightgray':'#d3d3d3', - 'lightgrey':'#d3d3d3', - 'lightgreen':'#90ee90', - 'lightpink':'#ffb6c1', - 'lightsalmon':'#ffa07a', - 'lightseagreen':'#20b2aa', - 'lightskyblue':'#87cefa', - 'lightslategray':'#778899', - 'lightslategrey':'#778899', - 'lightsteelblue':'#b0c4de', - 'lightyellow':'#ffffe0', - 'lime':'#00ff00', - 'limegreen':'#32cd32', - 'linen':'#faf0e6', - 'magenta':'#ff00ff', - 'maroon':'#800000', - 'mediumaquamarine':'#66cdaa', - 'mediumblue':'#0000cd', - 'mediumorchid':'#ba55d3', - 'mediumpurple':'#9370d8', - 'mediumseagreen':'#3cb371', - 'mediumslateblue':'#7b68ee', - 'mediumspringgreen':'#00fa9a', - 'mediumturquoise':'#48d1cc', - 'mediumvioletred':'#c71585', - 'midnightblue':'#191970', - 'mintcream':'#f5fffa', - 'mistyrose':'#ffe4e1', - 'moccasin':'#ffe4b5', - 'navajowhite':'#ffdead', - 'navy':'#000080', - 'oldlace':'#fdf5e6', - 'olive':'#808000', - 'olivedrab':'#6b8e23', - 'orange':'#ffa500', - 'orangered':'#ff4500', - 'orchid':'#da70d6', - 'palegoldenrod':'#eee8aa', - 'palegreen':'#98fb98', - 'paleturquoise':'#afeeee', - 'palevioletred':'#d87093', - 'papayawhip':'#ffefd5', - 'peachpuff':'#ffdab9', - 'peru':'#cd853f', - 'pink':'#ffc0cb', - 'plum':'#dda0dd', - 'powderblue':'#b0e0e6', - 'purple':'#800080', - 'rebeccapurple':'#663399', - 'red':'#ff0000', - 'rosybrown':'#bc8f8f', - 'royalblue':'#4169e1', - 'saddlebrown':'#8b4513', - 'salmon':'#fa8072', - 'sandybrown':'#f4a460', - 'seagreen':'#2e8b57', - 'seashell':'#fff5ee', - 'sienna':'#a0522d', - 'silver':'#c0c0c0', - 'skyblue':'#87ceeb', - 'slateblue':'#6a5acd', - 'slategray':'#708090', - 'slategrey':'#708090', - 'snow':'#fffafa', - 'springgreen':'#00ff7f', - 'steelblue':'#4682b4', - 'tan':'#d2b48c', - 'teal':'#008080', - 'thistle':'#d8bfd8', - 'tomato':'#ff6347', - 'turquoise':'#40e0d0', - 'violet':'#ee82ee', - 'wheat':'#f5deb3', - 'white':'#ffffff', - 'whitesmoke':'#f5f5f5', - 'yellow':'#ffff00', - 'yellowgreen':'#9acd32' -}; -},{}],13:[function(require,module,exports){ -module.exports = { - colors: require("./colors"), - unitConversions: require("./unit-conversions") -}; - -},{"./colors":12,"./unit-conversions":14}],14:[function(require,module,exports){ -module.exports = { - length: { - 'm': 1, - 'cm': 0.01, - 'mm': 0.001, - 'in': 0.0254, - 'px': 0.0254 / 96, - 'pt': 0.0254 / 72, - 'pc': 0.0254 / 72 * 12 - }, - duration: { - 's': 1, - 'ms': 0.001 - }, - angle: { - 'rad': 1 / (2 * Math.PI), - 'deg': 1 / 360, - 'grad': 1 / 400, - 'turn': 1 - } -}; -},{}],15:[function(require,module,exports){ -var abstractFileManager = function() { -}; - -abstractFileManager.prototype.getPath = function (filename) { - var j = filename.lastIndexOf('?'); - if (j > 0) { - filename = filename.slice(0, j); - } - j = filename.lastIndexOf('/'); - if (j < 0) { - j = filename.lastIndexOf('\\'); - } - if (j < 0) { - return ""; - } - return filename.slice(0, j + 1); -}; - -abstractFileManager.prototype.tryAppendExtension = function(path, ext) { - return /(\.[a-z]*$)|([\?;].*)$/.test(path) ? path : path + ext; -}; - -abstractFileManager.prototype.tryAppendLessExtension = function(path) { - return this.tryAppendExtension(path, '.less'); -}; - -abstractFileManager.prototype.supportsSync = function() { - return false; -}; - -abstractFileManager.prototype.alwaysMakePathsAbsolute = function() { - return false; -}; - -abstractFileManager.prototype.isPathAbsolute = function(filename) { - return (/^(?:[a-z-]+:|\/|\\|#)/i).test(filename); -}; - -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 - - var urlParts = this.extractUrlParts(url), - baseUrlParts = this.extractUrlParts(baseUrl), - i, max, urlDirectories, baseUrlDirectories, diff = ""; - if (urlParts.hostPart !== baseUrlParts.hostPart) { - return ""; - } - max = Math.max(baseUrlParts.directories.length, urlParts.directories.length); - for (i = 0; i < max; i++) { - if (baseUrlParts.directories[i] !== urlParts.directories[i]) { break; } - } - baseUrlDirectories = baseUrlParts.directories.slice(i); - urlDirectories = urlParts.directories.slice(i); - for (i = 0; i < baseUrlDirectories.length - 1; i++) { - diff += "../"; - } - for (i = 0; i < urlDirectories.length - 1; i++) { - diff += urlDirectories[i] + "/"; - } - return diff; -}; -// helper function, not part of API -abstractFileManager.prototype.extractUrlParts = function extractUrlParts(url, baseUrl) { - // urlParts[1] = protocol://hostname/ OR / - // urlParts[2] = / if path relative to host base - // urlParts[3] = directories - // urlParts[4] = filename - // urlParts[5] = parameters - - var urlPartsRegex = /^((?:[a-z-]+:)?\/{2}(?:[^\/\?#]*\/)|([\/\\]))?((?:[^\/\\\?#]*[\/\\])*)([^\/\\\?#]*)([#\?].*)?$/i, - urlParts = url.match(urlPartsRegex), - returner = {}, directories = [], i, baseUrlParts; - - if (!urlParts) { - throw new Error("Could not parse sheet href - '" + url + "'"); - } - - // Stylesheets in IE don't always return the full path - if (baseUrl && (!urlParts[1] || urlParts[2])) { - baseUrlParts = baseUrl.match(urlPartsRegex); - if (!baseUrlParts) { - throw new Error("Could not parse page url - '" + baseUrl + "'"); - } - urlParts[1] = urlParts[1] || baseUrlParts[1] || ""; - if (!urlParts[2]) { - urlParts[3] = baseUrlParts[3] + urlParts[3]; - } - } - - if (urlParts[3]) { - directories = 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; - } - } - - for (i = 0; i < directories.length; i++) { - if (directories[i] === ".." && i > 0) { - directories.splice(i - 1, 2); - i -= 2; - } - } - } - - returner.hostPart = urlParts[1]; - returner.directories = directories; - returner.path = (urlParts[1] || "") + directories.join("/"); - returner.fileUrl = returner.path + (urlParts[4] || ""); - returner.url = returner.fileUrl + (urlParts[5] || ""); - return returner; -}; - -module.exports = abstractFileManager; - -},{}],16:[function(require,module,exports){ -var logger = require("../logger"); -var environment = function(externalEnvironment, fileManagers) { - this.fileManagers = fileManagers || []; - externalEnvironment = externalEnvironment || {}; - - var optionalFunctions = ["encodeBase64", "mimeLookup", "charsetLookup", "getSourceMapGenerator"], - requiredFunctions = [], - functions = requiredFunctions.concat(optionalFunctions); - - for (var i = 0; i < functions.length; i++) { - var propName = functions[i], - environmentFunc = externalEnvironment[propName]; - if (environmentFunc) { - this[propName] = environmentFunc.bind(externalEnvironment); - } else if (i < requiredFunctions.length) { - this.warn("missing required function in environment - " + propName); - } - } -}; - -environment.prototype.getFileManager = function (filename, currentDirectory, options, environment, isSync) { - - if (!filename) { - logger.warn("getFileManager called with no filename.. Please report this issue. continuing."); - } - if (currentDirectory == null) { - logger.warn("getFileManager called with null directory.. Please report this issue. continuing."); - } - - var fileManagers = this.fileManagers; - if (options.pluginManager) { - fileManagers = [].concat(fileManagers).concat(options.pluginManager.getFileManagers()); - } - for (var i = fileManagers.length - 1; i >= 0 ; i--) { - var fileManager = fileManagers[i]; - if (fileManager[isSync ? "supportsSync" : "supports"](filename, currentDirectory, options, environment)) { - return fileManager; - } - } - return null; -}; - -environment.prototype.addFileManager = function (fileManager) { - this.fileManagers.push(fileManager); -}; - -environment.prototype.clearFileManagers = function () { - this.fileManagers = []; -}; - -module.exports = environment; - -},{"../logger":33}],17:[function(require,module,exports){ -var Color = require("../tree/color"), - functionRegistry = require("./function-registry"); - -// Color Blending -// ref: http://www.w3.org/TR/compositing-1 - -function colorBlend(mode, color1, color2) { - var ab = color1.alpha, cb, // backdrop - as = color2.alpha, cs, // source - ar, cr, r = []; // result - - ar = as + ab * (1 - as); - for (var i = 0; i < 3; i++) { - cb = color1.rgb[i] / 255; - cs = color2.rgb[i] / 255; - cr = mode(cb, cs); - if (ar) { - cr = (as * cs + ab * (cb - - as * (cb + cs - cr))) / ar; - } - r[i] = cr * 255; - } - - return new Color(r, ar); -} - -var colorBlendModeFunctions = { - multiply: function(cb, cs) { - return cb * cs; - }, - screen: function(cb, cs) { - return cb + cs - cb * cs; - }, - overlay: function(cb, cs) { - cb *= 2; - return (cb <= 1) ? - colorBlendModeFunctions.multiply(cb, cs) : - colorBlendModeFunctions.screen(cb - 1, cs); - }, - softlight: function(cb, cs) { - var d = 1, e = cb; - if (cs > 0.5) { - e = 1; - d = (cb > 0.25) ? Math.sqrt(cb) - : ((16 * cb - 12) * cb + 4) * cb; - } - return cb - (1 - 2 * cs) * e * (d - cb); - }, - hardlight: function(cb, cs) { - return colorBlendModeFunctions.overlay(cs, cb); - }, - difference: function(cb, cs) { - return Math.abs(cb - cs); - }, - exclusion: function(cb, cs) { - return cb + cs - 2 * cb * cs; - }, - - // non-w3c functions: - average: function(cb, cs) { - return (cb + cs) / 2; - }, - negation: function(cb, cs) { - return 1 - Math.abs(cb + cs - 1); - } -}; - -for (var f in colorBlendModeFunctions) { - if (colorBlendModeFunctions.hasOwnProperty(f)) { - colorBlend[f] = colorBlend.bind(null, colorBlendModeFunctions[f]); - } -} - -functionRegistry.addMultiple(colorBlend); - -},{"../tree/color":50,"./function-registry":22}],18:[function(require,module,exports){ -var Dimension = require("../tree/dimension"), - Color = require("../tree/color"), - Quoted = require("../tree/quoted"), - Anonymous = require("../tree/anonymous"), - functionRegistry = require("./function-registry"), - colorFunctions; - -function clamp(val) { - return Math.min(1, Math.max(0, val)); -} -function hsla(color) { - return colorFunctions.hsla(color.h, color.s, color.l, color.a); -} -function number(n) { - if (n instanceof Dimension) { - return parseFloat(n.unit.is('%') ? n.value / 100 : n.value); - } else if (typeof n === 'number') { - return n; - } else { - throw { - type: "Argument", - message: "color functions take numbers as parameters" - }; - } -} -function scaled(n, size) { - if (n instanceof Dimension && n.unit.is('%')) { - return parseFloat(n.value * size / 100); - } else { - return number(n); - } -} -colorFunctions = { - rgb: function (r, g, b) { - return colorFunctions.rgba(r, g, b, 1.0); - }, - rgba: function (r, g, b, a) { - var rgb = [r, g, b].map(function (c) { return scaled(c, 255); }); - a = number(a); - return new Color(rgb, a); - }, - hsl: function (h, s, l) { - return colorFunctions.hsla(h, s, l, 1.0); - }, - hsla: function (h, s, l, a) { - - var m1, m2; - - function hue(h) { - h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h); - if (h * 6 < 1) { - return m1 + (m2 - m1) * h * 6; - } - else if (h * 2 < 1) { - return m2; - } - else if (h * 3 < 2) { - return m1 + (m2 - m1) * (2 / 3 - h) * 6; - } - else { - return m1; - } - } - - h = (number(h) % 360) / 360; - s = clamp(number(s)); l = clamp(number(l)); a = clamp(number(a)); - - m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s; - m1 = l * 2 - m2; - - return colorFunctions.rgba(hue(h + 1 / 3) * 255, - hue(h) * 255, - hue(h - 1 / 3) * 255, - a); - }, - - hsv: function(h, s, v) { - return colorFunctions.hsva(h, s, v, 1.0); - }, - - hsva: function(h, s, v, a) { - h = ((number(h) % 360) / 360) * 360; - s = number(s); v = number(v); a = number(a); - - var i, f; - i = Math.floor((h / 60) % 6); - f = (h / 60) - i; - - var vs = [v, - v * (1 - s), - v * (1 - f * s), - v * (1 - (1 - f) * s)]; - var perm = [[0, 3, 1], - [2, 0, 1], - [1, 0, 3], - [1, 2, 0], - [3, 1, 0], - [0, 1, 2]]; - - return colorFunctions.rgba(vs[perm[i][0]] * 255, - vs[perm[i][1]] * 255, - vs[perm[i][2]] * 255, - a); - }, - - hue: function (color) { - return new Dimension(color.toHSL().h); - }, - saturation: function (color) { - return new Dimension(color.toHSL().s * 100, '%'); - }, - lightness: function (color) { - return new Dimension(color.toHSL().l * 100, '%'); - }, - hsvhue: function(color) { - return new Dimension(color.toHSV().h); - }, - hsvsaturation: function (color) { - return new Dimension(color.toHSV().s * 100, '%'); - }, - hsvvalue: function (color) { - return new Dimension(color.toHSV().v * 100, '%'); - }, - red: function (color) { - return new Dimension(color.rgb[0]); - }, - green: function (color) { - return new Dimension(color.rgb[1]); - }, - blue: function (color) { - return new Dimension(color.rgb[2]); - }, - alpha: function (color) { - return new Dimension(color.toHSL().a); - }, - luma: function (color) { - return new Dimension(color.luma() * color.alpha * 100, '%'); - }, - luminance: function (color) { - var luminance = - (0.2126 * color.rgb[0] / 255) + - (0.7152 * color.rgb[1] / 255) + - (0.0722 * color.rgb[2] / 255); - - return new Dimension(luminance * color.alpha * 100, '%'); - }, - saturate: function (color, amount, method) { - // filter: saturate(3.2); - // should be kept as is, so check for color - if (!color.rgb) { - return null; - } - var hsl = color.toHSL(); - - if (typeof method !== "undefined" && method.value === "relative") { - hsl.s += hsl.s * amount.value / 100; - } - else { - hsl.s += amount.value / 100; - } - hsl.s = clamp(hsl.s); - return hsla(hsl); - }, - desaturate: function (color, amount, method) { - var hsl = color.toHSL(); - - if (typeof method !== "undefined" && method.value === "relative") { - hsl.s -= hsl.s * amount.value / 100; - } - else { - hsl.s -= amount.value / 100; - } - hsl.s = clamp(hsl.s); - return hsla(hsl); - }, - lighten: function (color, amount, method) { - var hsl = color.toHSL(); - - if (typeof method !== "undefined" && method.value === "relative") { - hsl.l += hsl.l * amount.value / 100; - } - else { - hsl.l += amount.value / 100; - } - hsl.l = clamp(hsl.l); - return hsla(hsl); - }, - darken: function (color, amount, method) { - var hsl = color.toHSL(); - - if (typeof method !== "undefined" && method.value === "relative") { - hsl.l -= hsl.l * amount.value / 100; - } - else { - hsl.l -= amount.value / 100; - } - hsl.l = clamp(hsl.l); - return hsla(hsl); - }, - fadein: function (color, amount, method) { - var hsl = color.toHSL(); - - if (typeof method !== "undefined" && method.value === "relative") { - hsl.a += hsl.a * amount.value / 100; - } - else { - hsl.a += amount.value / 100; - } - hsl.a = clamp(hsl.a); - return hsla(hsl); - }, - fadeout: function (color, amount, method) { - var hsl = color.toHSL(); - - if (typeof method !== "undefined" && method.value === "relative") { - hsl.a -= hsl.a * amount.value / 100; - } - else { - hsl.a -= amount.value / 100; - } - hsl.a = clamp(hsl.a); - return hsla(hsl); - }, - fade: function (color, amount) { - var hsl = color.toHSL(); - - hsl.a = amount.value / 100; - hsl.a = clamp(hsl.a); - return hsla(hsl); - }, - spin: function (color, amount) { - var hsl = color.toHSL(); - var hue = (hsl.h + amount.value) % 360; - - hsl.h = hue < 0 ? 360 + hue : hue; - - return hsla(hsl); - }, - // - // Copyright (c) 2006-2009 Hampton Catlin, Natalie Weizenbaum, and Chris Eppstein - // http://sass-lang.com - // - mix: function (color1, color2, weight) { - if (!color1.toHSL || !color2.toHSL) { - console.log(color2.type); - console.dir(color2); - } - if (!weight) { - weight = new Dimension(50); - } - var p = weight.value / 100.0; - var w = p * 2 - 1; - var a = color1.toHSL().a - color2.toHSL().a; - - var w1 = (((w * a == -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0; - var w2 = 1 - w1; - - var rgb = [color1.rgb[0] * w1 + color2.rgb[0] * w2, - color1.rgb[1] * w1 + color2.rgb[1] * w2, - color1.rgb[2] * w1 + color2.rgb[2] * w2]; - - var alpha = color1.alpha * p + color2.alpha * (1 - p); - - return new Color(rgb, alpha); - }, - greyscale: function (color) { - return colorFunctions.desaturate(color, new Dimension(100)); - }, - 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()); - }, - color: function(c) { - if ((c instanceof Quoted) && - (/^#([a-f0-9]{6}|[a-f0-9]{3})$/i.test(c.value))) { - return new Color(c.value.slice(1)); - } - if ((c instanceof Color) || (c = Color.fromKeyword(c.value))) { - c.value = undefined; - return c; - } - throw { - type: "Argument", - message: "argument must be a color keyword or 3/6 digit hex e.g. #FFF" - }; - }, - tint: function(color, amount) { - return colorFunctions.mix(colorFunctions.rgb(255, 255, 255), color, amount); - }, - shade: function(color, amount) { - return colorFunctions.mix(colorFunctions.rgb(0, 0, 0), color, amount); - } -}; -functionRegistry.addMultiple(colorFunctions); - -},{"../tree/anonymous":46,"../tree/color":50,"../tree/dimension":56,"../tree/quoted":73,"./function-registry":22}],19:[function(require,module,exports){ -module.exports = function(environment) { - var Quoted = require("../tree/quoted"), - URL = require("../tree/url"), - functionRegistry = require("./function-registry"), - fallback = function(functionThis, node) { - return new URL(node, functionThis.index, functionThis.currentFileInfo).eval(functionThis.context); - }, - logger = require('../logger'); - - functionRegistry.add("data-uri", function(mimetypeNode, filePathNode) { - - if (!filePathNode) { - filePathNode = mimetypeNode; - mimetypeNode = null; - } - - var mimetype = mimetypeNode && mimetypeNode.value; - var filePath = filePathNode.value; - var currentFileInfo = this.currentFileInfo; - var currentDirectory = currentFileInfo.relativeUrls ? - currentFileInfo.currentDirectory : currentFileInfo.entryPath; - - var fragmentStart = filePath.indexOf('#'); - var fragment = ''; - if (fragmentStart !== -1) { - fragment = filePath.slice(fragmentStart); - filePath = filePath.slice(0, fragmentStart); - } - - var fileManager = environment.getFileManager(filePath, currentDirectory, this.context, environment, true); - - if (!fileManager) { - return fallback(this, filePathNode); - } - - var useBase64 = false; - - // detect the mimetype if not given - if (!mimetypeNode) { - - mimetype = environment.mimeLookup(filePath); - - if (mimetype === "image/svg+xml") { - useBase64 = false; - } else { - // use base 64 unless it's an ASCII or UTF-8 format - var charset = environment.charsetLookup(mimetype); - useBase64 = ['US-ASCII', 'UTF-8'].indexOf(charset) < 0; - } - if (useBase64) { mimetype += ';base64'; } - } - else { - useBase64 = /;base64$/.test(mimetype); - } - - var fileSync = fileManager.loadFileSync(filePath, currentDirectory, this.context, environment); - if (!fileSync.contents) { - logger.warn("Skipped data-uri embedding of " + filePath + " because file not found"); - return fallback(this, filePathNode || mimetypeNode); - } - var buf = fileSync.contents; - if (useBase64 && !environment.encodeBase64) { - return fallback(this, filePathNode); - } - - buf = useBase64 ? environment.encodeBase64(buf) : encodeURIComponent(buf); - - var uri = "data:" + mimetype + ',' + buf + fragment; - - // IE8 cannot handle a data-uri larger than 32,768 characters. If this is exceeded - // and the --ieCompat flag is enabled, return a normal url() instead. - var DATA_URI_MAX = 32768; - if (uri.length >= DATA_URI_MAX) { - - if (this.context.ieCompat !== false) { - logger.warn("Skipped data-uri embedding of " + filePath + " because its size (" + uri.length + - " characters) exceeds IE8-safe " + DATA_URI_MAX + " characters!"); - - return fallback(this, filePathNode || mimetypeNode); - } - } - - return new URL(new Quoted('"' + uri + '"', uri, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo); - }); -}; - -},{"../logger":33,"../tree/quoted":73,"../tree/url":80,"./function-registry":22}],20:[function(require,module,exports){ -var Keyword = require("../tree/keyword"), - functionRegistry = require("./function-registry"); - -var defaultFunc = { - eval: function () { - var v = this.value_, e = this.error_; - if (e) { - throw e; - } - if (v != null) { - return v ? Keyword.True : Keyword.False; - } - }, - value: function (v) { - this.value_ = v; - }, - error: function (e) { - this.error_ = e; - }, - reset: function () { - this.value_ = this.error_ = null; - } -}; - -functionRegistry.add("default", defaultFunc.eval.bind(defaultFunc)); - -module.exports = defaultFunc; - -},{"../tree/keyword":65,"./function-registry":22}],21:[function(require,module,exports){ -var Expression = require("../tree/expression"); - -var functionCaller = function(name, context, index, currentFileInfo) { - this.name = name.toLowerCase(); - this.index = index; - this.context = context; - this.currentFileInfo = currentFileInfo; - - this.func = context.frames[0].functionRegistry.get(this.name); -}; -functionCaller.prototype.isValid = function() { - return Boolean(this.func); -}; -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)) { - args = args.filter(function (item) { - if (item.type === "Comment") { - return false; - } - return true; - }) - .map(function(item) { - if (item.type === "Expression") { - var subNodes = item.value.filter(function (item) { - if (item.type === "Comment") { - return false; - } - return true; - }); - if (subNodes.length === 1) { - return subNodes[0]; - } else { - return new Expression(subNodes); - } - } - return item; - }); - } - - return this.func.apply(this, args); -}; - -module.exports = functionCaller; - -},{"../tree/expression":59}],22:[function(require,module,exports){ -function makeRegistry( base ) { - return { - _data: {}, - add: function(name, func) { - // precautionary case conversion, as later querying of - // the registry by function-caller uses lower case as well. - name = name.toLowerCase(); - - if (this._data.hasOwnProperty(name)) { - //TODO warn - } - this._data[name] = func; - }, - addMultiple: function(functions) { - Object.keys(functions).forEach( - function(name) { - this.add(name, functions[name]); - }.bind(this)); - }, - get: function(name) { - return this._data[name] || ( base && base.get( name )); - }, - inherit : function() { - return makeRegistry( this ); - } - }; -} - -module.exports = makeRegistry( null ); -},{}],23:[function(require,module,exports){ -module.exports = function(environment) { - var functions = { - functionRegistry: require("./function-registry"), - functionCaller: require("./function-caller") - }; - - //register functions - require("./default"); - require("./color"); - require("./color-blending"); - require("./data-uri")(environment); - require("./math"); - require("./number"); - require("./string"); - require("./svg")(environment); - require("./types"); - - 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){ -var Dimension = require("../tree/dimension"); - -var MathHelper = function() { -}; -MathHelper._math = function (fn, unit, n) { - if (!(n instanceof Dimension)) { - throw { type: "Argument", message: "argument must be a number" }; - } - if (unit == null) { - unit = n.unit; - } else { - n = n.unify(); - } - return new Dimension(fn(parseFloat(n.value)), unit); -}; -module.exports = MathHelper; -},{"../tree/dimension":56}],25:[function(require,module,exports){ -var functionRegistry = require("./function-registry"), - mathHelper = require("./math-helper.js"); - -var mathFunctions = { - // name, unit - ceil: null, - floor: null, - sqrt: null, - abs: null, - tan: "", - sin: "", - cos: "", - atan: "rad", - asin: "rad", - acos: "rad" -}; - -for (var f in mathFunctions) { - if (mathFunctions.hasOwnProperty(f)) { - mathFunctions[f] = mathHelper._math.bind(null, Math[f], mathFunctions[f]); - } -} - -mathFunctions.round = function (n, f) { - var fraction = typeof f === "undefined" ? 0 : f.value; - return mathHelper._math(function(num) { return num.toFixed(fraction); }, null, n); -}; - -functionRegistry.addMultiple(mathFunctions); - -},{"./function-registry":22,"./math-helper.js":24}],26:[function(require,module,exports){ -var Dimension = require("../tree/dimension"), - Anonymous = require("../tree/anonymous"), - functionRegistry = require("./function-registry"), - mathHelper = require("./math-helper.js"); - -var minMax = function (isMin, args) { - args = Array.prototype.slice.call(args); - switch(args.length) { - case 0: throw { type: "Argument", message: "one or more arguments required" }; - } - var i, j, current, currentUnified, referenceUnified, unit, unitStatic, unitClone, - order = [], // elems only contains original argument values. - values = {}; // key is the unit.toString() for unified Dimension values, - // value is the index into the order array. - for (i = 0; i < args.length; i++) { - current = args[i]; - if (!(current instanceof Dimension)) { - if (Array.isArray(args[i].value)) { - Array.prototype.push.apply(args, Array.prototype.slice.call(args[i].value)); - } - continue; - } - currentUnified = current.unit.toString() === "" && unitClone !== undefined ? new Dimension(current.value, unitClone).unify() : current.unify(); - unit = currentUnified.unit.toString() === "" && unitStatic !== undefined ? unitStatic : currentUnified.unit.toString(); - unitStatic = unit !== "" && unitStatic === undefined || unit !== "" && order[0].unify().unit.toString() === "" ? unit : unitStatic; - unitClone = unit !== "" && unitClone === undefined ? current.unit.toString() : unitClone; - j = values[""] !== undefined && unit !== "" && unit === unitStatic ? values[""] : values[unit]; - if (j === undefined) { - if (unitStatic !== undefined && unit !== unitStatic) { - throw{ type: "Argument", message: "incompatible types" }; - } - values[unit] = order.length; - order.push(current); - continue; - } - referenceUnified = order[j].unit.toString() === "" && unitClone !== undefined ? new Dimension(order[j].value, unitClone).unify() : order[j].unify(); - if ( isMin && currentUnified.value < referenceUnified.value || - !isMin && currentUnified.value > referenceUnified.value) { - order[j] = current; - } - } - if (order.length == 1) { - return order[0]; - } - args = order.map(function (a) { return a.toCSS(this.context); }).join(this.context.compress ? "," : ", "); - return new Anonymous((isMin ? "min" : "max") + "(" + args + ")"); -}; -functionRegistry.addMultiple({ - min: function () { - return minMax(true, arguments); - }, - max: function () { - return minMax(false, arguments); - }, - convert: function (val, unit) { - return val.convertTo(unit.value); - }, - pi: function () { - return new Dimension(Math.PI); - }, - mod: function(a, b) { - return new Dimension(a.value % b.value, a.unit); - }, - pow: function(x, y) { - if (typeof x === "number" && typeof y === "number") { - x = new Dimension(x); - y = new Dimension(y); - } else if (!(x instanceof Dimension) || !(y instanceof Dimension)) { - throw { type: "Argument", message: "arguments must be numbers" }; - } - - return new Dimension(Math.pow(x.value, y.value), x.unit); - }, - percentage: function (n) { - var result = mathHelper._math(function(num) { - return num * 100; - }, '%', n); - - return result; - } -}); - -},{"../tree/anonymous":46,"../tree/dimension":56,"./function-registry":22,"./math-helper.js":24}],27:[function(require,module,exports){ -var Quoted = require("../tree/quoted"), - Anonymous = require("../tree/anonymous"), - JavaScript = require("../tree/javascript"), - functionRegistry = require("./function-registry"); - -functionRegistry.addMultiple({ - e: function (str) { - return new Anonymous(str instanceof JavaScript ? str.evaluated : str.value); - }, - escape: function (str) { - return new Anonymous( - encodeURI(str.value).replace(/=/g, "%3D").replace(/:/g, "%3A").replace(/#/g, "%23").replace(/;/g, "%3B") - .replace(/\(/g, "%28").replace(/\)/g, "%29")); - }, - replace: function (string, pattern, replacement, flags) { - var result = string.value; - replacement = (replacement.type === "Quoted") ? - replacement.value : replacement.toCSS(); - result = result.replace(new RegExp(pattern.value, flags ? flags.value : ''), replacement); - return new Quoted(string.quote || '', result, string.escaped); - }, - '%': 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 */ - result = result.replace(/%[sda]/i, function(token) { - var value = ((args[i].type === "Quoted") && - token.match(/s/i)) ? args[i].value : args[i].toCSS(); - return token.match(/[A-Z]$/) ? encodeURIComponent(value) : value; - }); - } - result = result.replace(/%%/g, '%'); - return new Quoted(string.quote || '', result, string.escaped); - } -}); - -},{"../tree/anonymous":46,"../tree/javascript":63,"../tree/quoted":73,"./function-registry":22}],28:[function(require,module,exports){ -module.exports = function(environment) { - var Dimension = require("../tree/dimension"), - Color = require("../tree/color"), - Expression = require("../tree/expression"), - Quoted = require("../tree/quoted"), - URL = require("../tree/url"), - functionRegistry = require("./function-registry"); - - functionRegistry.add("svg-gradient", function(direction) { - - var stops, - gradientDirectionSvg, - gradientType = "linear", - rectangleDimension = 'x="0" y="0" width="1" height="1"', - renderEnv = {compress: false}, - returner, - directionValue = direction.toCSS(renderEnv), - 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" }; - } - - if (arguments.length == 2) { - if (arguments[1].value.length < 2) { - throwArgumentDescriptor(); - } - stops = arguments[1].value; - } else if (arguments.length < 3) { - throwArgumentDescriptor(); - } else { - stops = Array.prototype.slice.call(arguments, 1); - } - - switch (directionValue) { - case "to bottom": - gradientDirectionSvg = 'x1="0%" y1="0%" x2="0%" y2="100%"'; - break; - case "to right": - gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="0%"'; - break; - case "to bottom right": - gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="100%"'; - break; - case "to top right": - gradientDirectionSvg = 'x1="0%" y1="100%" x2="100%" y2="0%"'; - break; - case "ellipse": - case "ellipse at center": - gradientType = "radial"; - gradientDirectionSvg = 'cx="50%" cy="50%" r="75%"'; - rectangleDimension = 'x="-50" y="-50" width="101" height="101"'; - break; - default: - throw { type: "Argument", message: "svg-gradient direction must be 'to bottom', 'to right'," + - " 'to bottom right', 'to top right' or 'ellipse at center'" }; - } - returner = '' + - '' + - '<' + gradientType + 'Gradient id="gradient" gradientUnits="userSpaceOnUse" ' + gradientDirectionSvg + '>'; - - for (i = 0; i < stops.length; i+= 1) { - if (stops[i] instanceof Expression) { - color = stops[i].value[0]; - position = stops[i].value[1]; - } else { - color = stops[i]; - position = undefined; - } - - if (!(color instanceof Color) || (!((i === 0 || i + 1 === stops.length) && position === undefined) && !(position instanceof Dimension))) { - throwArgumentDescriptor(); - } - positionValue = position ? position.toCSS(renderEnv) : i === 0 ? "0%" : "100%"; - alpha = color.alpha; - returner += ''; - } - returner += '' + - ''; - - returner = encodeURIComponent(returner); - - returner = "data:image/svg+xml," + returner; - return new URL(new Quoted("'" + returner + "'", returner, false, 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(require,module,exports){ -var Keyword = require("../tree/keyword"), - DetachedRuleset = require("../tree/detached-ruleset"), - Dimension = require("../tree/dimension"), - Color = require("../tree/color"), - Quoted = require("../tree/quoted"), - Anonymous = require("../tree/anonymous"), - URL = require("../tree/url"), - Operation = require("../tree/operation"), - functionRegistry = require("./function-registry"); - -var isa = function (n, Type) { - return (n instanceof Type) ? Keyword.True : Keyword.False; - }, - isunit = function (n, unit) { - if (unit === undefined) { - throw { type: "Argument", message: "missing the required second argument to isunit." }; - } - unit = typeof unit.value === "string" ? unit.value : unit; - if (typeof unit !== "string") { - throw { type: "Argument", message: "Second argument to isunit should be a unit or a string." }; - } - return (n instanceof Dimension) && n.unit.is(unit) ? Keyword.True : Keyword.False; - }, - getItemsFromNode = function(node) { - // handle non-array values as an array of length 1 - // return 'undefined' if index is invalid - var items = Array.isArray(node.value) ? - node.value : Array(node); - - return items; - }; -functionRegistry.addMultiple({ - isruleset: function (n) { - return isa(n, DetachedRuleset); - }, - iscolor: function (n) { - return isa(n, Color); - }, - isnumber: function (n) { - return isa(n, Dimension); - }, - isstring: function (n) { - return isa(n, Quoted); - }, - iskeyword: function (n) { - return isa(n, Keyword); - }, - isurl: function (n) { - return isa(n, URL); - }, - ispixel: function (n) { - return isunit(n, 'px'); - }, - ispercentage: function (n) { - return isunit(n, '%'); - }, - isem: function (n) { - return isunit(n, 'em'); - }, - isunit: isunit, - unit: function (val, unit) { - if (!(val instanceof Dimension)) { - throw { type: "Argument", - message: "the first argument to unit must be a number" + - (val instanceof Operation ? ". Have you forgotten parenthesis?" : "") }; - } - if (unit) { - if (unit instanceof Keyword) { - unit = unit.value; - } else { - unit = unit.toCSS(); - } - } else { - unit = ""; - } - return new Dimension(val.value, unit); - }, - "get-unit": function (n) { - return new Anonymous(n.unit); - }, - extract: function(values, index) { - index = index.value - 1; // (1-based index) - - return getItemsFromNode(values)[index]; - }, - length: function(values) { - return new Dimension(getItemsFromNode(values).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(require,module,exports){ -var contexts = require("./contexts"), - Parser = require('./parser/parser'), - FunctionImporter = require('./plugins/function-importer'); - -module.exports = function(environment) { - - // FileInfo = { - // 'relativeUrls' - option - whether to adjust URL's to be relative - // 'filename' - full resolved filename of current file - // 'rootpath' - path to append to normal URLs for this node - // 'currentDirectory' - path to the current file, absolute - // 'rootFilename' - filename of the base file - // '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) { - this.rootFilename = rootFileInfo.filename; - this.paths = context.paths || []; // Search paths, when importing - this.contents = {}; // map - filename to contents of all the files - this.contentsIgnoredChars = {}; // map - filename to lines at the beginning of each file to ignore - this.mime = context.mime; - this.error = null; - this.context = context; - // Deprecated? Unused outside of here, could be useful. - 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 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; - this.queue.push(path); - - var fileParsedFunc = function (e, root, fullPath) { - importManager.queue.splice(importManager.queue.indexOf(path), 1); // Remove the path from the queue - - var importedEqualsRoot = fullPath === importManager.rootFilename; - if (importOptions.optional && e) { - callback(null, {rules:[]}, false, null); - } - else { - importManager.files[fullPath] = root; - if (e && !importManager.error) { importManager.error = e; } - callback(e, root, importedEqualsRoot, fullPath); - } - }; - - var newFileInfo = { - relativeUrls: this.context.relativeUrls, - entryPath: currentFileInfo.entryPath, - rootpath: currentFileInfo.rootpath, - rootFilename: currentFileInfo.rootFilename - }; - - var fileManager = environment.getFileManager(path, currentFileInfo.currentDirectory, this.context, environment); - - if (!fileManager) { - fileParsedFunc({ message: "Could not find a file-manager for " + path }); - return; - } - - if (tryAppendLessExtension) { - path = fileManager.tryAppendExtension(path, importOptions.plugin ? ".js" : ".less"); - } - - var loadFileCallback = function(loadedFile) { - var resolvedFilename = loadedFile.filename, - contents = loadedFile.contents.replace(/^\uFEFF/, ''); - - // Pass on an updated rootpath if path of imported file is relative and file - // is in a (sub|sup) directory - // - // Examples: - // - If path of imported file is 'module/nav/nav.less' and rootpath is 'less/', - // then rootpath should become 'less/module/nav/' - // - If path of imported file is '../mixins.less' and rootpath is 'less/', - // then rootpath should become 'less/../' - newFileInfo.currentDirectory = fileManager.getPath(resolvedFilename); - if (newFileInfo.relativeUrls) { - newFileInfo.rootpath = fileManager.join( - (importManager.context.rootpath || ""), - fileManager.pathDiff(newFileInfo.currentDirectory, newFileInfo.entryPath)); - - if (!fileManager.isPathAbsolute(newFileInfo.rootpath) && fileManager.alwaysMakePathsAbsolute()) { - newFileInfo.rootpath = fileManager.join(newFileInfo.entryPath, newFileInfo.rootpath); - } - } - newFileInfo.filename = resolvedFilename; - - var newEnv = new contexts.Parse(importManager.context); - - newEnv.processImports = false; - importManager.contents[resolvedFilename] = contents; - - if (currentFileInfo.reference || importOptions.reference) { - newFileInfo.reference = true; - } - - if (importOptions.plugin) { - new FunctionImporter(newEnv, newFileInfo).eval(contents, function (e, root) { - fileParsedFunc(e, root, resolvedFilename); - }); - } else if (importOptions.inline) { - fileParsedFunc(null, contents, resolvedFilename); - } else { - new Parser(newEnv, importManager, newFileInfo).parse(contents, function (e, root) { - fileParsedFunc(e, root, resolvedFilename); - }); - } - }; - - var promise = fileManager.loadFile(path, currentFileInfo.currentDirectory, this.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){ -module.exports = function(environment, fileManagers) { - var SourceMapOutput, SourceMapBuilder, ParseTree, ImportManager, Environment; - - var less = { - version: [2, 7, 1], - data: require('./data'), - tree: require('./tree'), - Environment: (Environment = require("./environment/environment")), - AbstractFileManager: require("./environment/abstract-file-manager"), - environment: (environment = new Environment(environment, fileManagers)), - visitors: require('./visitors'), - Parser: require('./parser/parser'), - functions: require('./functions')(environment), - contexts: require("./contexts"), - SourceMapOutput: (SourceMapOutput = require('./source-map-output')(environment)), - SourceMapBuilder: (SourceMapBuilder = require('./source-map-builder')(SourceMapOutput, environment)), - ParseTree: (ParseTree = require('./parse-tree')(SourceMapBuilder)), - ImportManager: (ImportManager = require('./import-manager')(environment)), - render: require("./render")(environment, ParseTree, ImportManager), - parse: require("./parse")(environment, ParseTree, ImportManager), - LessError: require('./less-error'), - transformTree: require('./transform-tree'), - utils: require('./utils'), - PluginManager: require('./plugin-manager'), - logger: require('./logger') - }; - - return less; -}; - -},{"./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 LessError = module.exports = function LessError(e, importManager, currentFilename) { - - Error.call(this); - - var filename = e.filename || currentFilename; - - if (importManager && filename) { - var input = importManager.contents[filename], - loc = utils.getLocation(e.index, input), - line = loc.line, - col = loc.column, - callLine = e.call && utils.getLocation(e.call, input).line, - lines = input.split('\n'); - - this.type = e.type || 'Syntax'; - this.filename = filename; - this.index = e.index; - this.line = typeof line === 'number' ? line + 1 : null; - this.callLine = callLine + 1; - this.callExtract = lines[callLine]; - this.column = col; - this.extract = [ - lines[line - 1], - lines[line], - lines[line + 1] - ]; - } - this.message = e.message; - this.stack = e.stack; -}; - -if (typeof Object.create === 'undefined') { - var F = function () {}; - F.prototype = Error.prototype; - LessError.prototype = new F(); -} else { - LessError.prototype = Object.create(Error.prototype); -} - -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) { - this._listeners.splice(i, 1); - return; - } - } - }, - _fireEvent: function(type, msg) { - for (var i = 0; i < this._listeners.length; i++) { - var logFunction = this._listeners[i][type]; - if (logFunction) { - logFunction(msg); - } - } - }, - _listeners: [] -}; - -},{}],34:[function(require,module,exports){ -var LessError = require('./less-error'), - transformTree = require("./transform-tree"), - logger = require("./logger"); - -module.exports = function(SourceMapBuilder) { - var ParseTree = function(root, imports) { - this.root = root; - this.imports = imports; - }; - - ParseTree.prototype.toCSS = function(options) { - var evaldRoot, result = {}, sourceMapBuilder; - try { - evaldRoot = transformTree(this.root, options); - } catch (e) { - throw new LessError(e, this.imports); - } - - try { - var compress = Boolean(options.compress); - if (compress) { - logger.warn("The compress option has been deprecated. We recommend you use a dedicated css minifier, for instance see less-plugin-clean-css."); - } - - var toCSSOptions = { - compress: compress, - dumpLineNumbers: options.dumpLineNumbers, - strictUnits: Boolean(options.strictUnits), - numPrecision: 8}; - - if (options.sourceMap) { - sourceMapBuilder = new SourceMapBuilder(options.sourceMap); - result.css = sourceMapBuilder.toCSS(evaldRoot, toCSSOptions, this.imports); - } else { - result.css = evaldRoot.toCSS(toCSSOptions); - } - } catch (e) { - throw new LessError(e, this.imports); - } - - if (options.pluginManager) { - var postProcessors = options.pluginManager.getPostProcessors(); - for (var i = 0; i < postProcessors.length; i++) { - result.css = postProcessors[i].process(result.css, { sourceMap: sourceMapBuilder, options: options, imports: this.imports }); - } - } - if (options.sourceMap) { - result.map = sourceMapBuilder.getExternalSourceMap(); - } - - result.imports = []; - for (var file in this.imports.files) { - if (this.imports.files.hasOwnProperty(file) && file !== this.imports.rootFilename) { - result.imports.push(file); - } - } - return result; - }; - return ParseTree; -}; - -},{"./less-error":32,"./logger":33,"./transform-tree":44}],35:[function(require,module,exports){ -var PromiseConstructor, - contexts = require("./contexts"), - Parser = require('./parser/parser'), - PluginManager = require('./plugin-manager'); - -module.exports = function(environment, ParseTree, ImportManager) { - var parse = function (input, options, callback) { - options = options || {}; - - if (typeof options === 'function') { - callback = options; - options = {}; - } - - if (!callback) { - if (!PromiseConstructor) { - PromiseConstructor = typeof Promise === 'undefined' ? require('promise') : Promise; - } - var self = this; - return new PromiseConstructor(function (resolve, reject) { - parse.call(self, input, options, function(err, output) { - if (err) { - reject(err); - } else { - resolve(output); - } - }); - }); - } else { - var context, - rootFileInfo, - pluginManager = new PluginManager(this); - - pluginManager.addPlugins(options.plugins); - options.pluginManager = pluginManager; - - context = new contexts.Parse(options); - - if (options.rootFileInfo) { - rootFileInfo = options.rootFileInfo; - } else { - var filename = options.filename || "input"; - var entryPath = filename.replace(/[^\/\\]*$/, ""); - rootFileInfo = { - filename: filename, - relativeUrls: context.relativeUrls, - rootpath: context.rootpath || "", - currentDirectory: entryPath, - entryPath: entryPath, - rootFilename: filename - }; - // add in a missing trailing slash - if (rootFileInfo.rootpath && rootFileInfo.rootpath.slice(-1) !== "/") { - rootFileInfo.rootpath += "/"; - } - } - - var imports = new ImportManager(context, rootFileInfo); - - new Parser(context, imports, rootFileInfo) - .parse(input, function (e, root) { - 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){ -// Split the input into chunks. -module.exports = function (input, fail) { - var len = input.length, level = 0, parenLevel = 0, - lastOpening, lastOpeningParen, lastMultiComment, lastMultiCommentEndBrace, - chunks = [], emitFrom = 0, - chunkerCurrentIndex, currentChunkStartIndex, cc, cc2, matched; - - function emitChunk(force) { - var len = chunkerCurrentIndex - emitFrom; - if (((len < 512) && !force) || !len) { - return; - } - chunks.push(input.slice(emitFrom, chunkerCurrentIndex + 1)); - emitFrom = chunkerCurrentIndex + 1; - } - - for (chunkerCurrentIndex = 0; chunkerCurrentIndex < len; chunkerCurrentIndex++) { - cc = input.charCodeAt(chunkerCurrentIndex); - if (((cc >= 97) && (cc <= 122)) || (cc < 34)) { - // a-z or whitespace - continue; - } - - switch (cc) { - case 40: // ( - parenLevel++; - lastOpeningParen = chunkerCurrentIndex; - continue; - case 41: // ) - if (--parenLevel < 0) { - return fail("missing opening `(`", chunkerCurrentIndex); - } - continue; - case 59: // ; - if (!parenLevel) { emitChunk(); } - continue; - case 123: // { - level++; - lastOpening = chunkerCurrentIndex; - continue; - case 125: // } - if (--level < 0) { - return fail("missing opening `{`", chunkerCurrentIndex); - } - if (!level && !parenLevel) { emitChunk(); } - continue; - case 92: // \ - if (chunkerCurrentIndex < len - 1) { chunkerCurrentIndex++; continue; } - return fail("unescaped `\\`", chunkerCurrentIndex); - case 34: - case 39: - case 96: // ", ' and ` - matched = 0; - currentChunkStartIndex = chunkerCurrentIndex; - for (chunkerCurrentIndex = chunkerCurrentIndex + 1; chunkerCurrentIndex < len; chunkerCurrentIndex++) { - cc2 = input.charCodeAt(chunkerCurrentIndex); - if (cc2 > 96) { continue; } - if (cc2 == cc) { matched = 1; break; } - if (cc2 == 92) { // \ - if (chunkerCurrentIndex == len - 1) { - return fail("unescaped `\\`", chunkerCurrentIndex); - } - chunkerCurrentIndex++; - } - } - if (matched) { continue; } - return fail("unmatched `" + String.fromCharCode(cc) + "`", currentChunkStartIndex); - case 47: // /, check for comment - if (parenLevel || (chunkerCurrentIndex == len - 1)) { continue; } - cc2 = input.charCodeAt(chunkerCurrentIndex + 1); - if (cc2 == 47) { - // //, find lnfeed - for (chunkerCurrentIndex = chunkerCurrentIndex + 2; chunkerCurrentIndex < len; chunkerCurrentIndex++) { - cc2 = input.charCodeAt(chunkerCurrentIndex); - if ((cc2 <= 13) && ((cc2 == 10) || (cc2 == 13))) { break; } - } - } else if (cc2 == 42) { - // /*, find */ - lastMultiComment = currentChunkStartIndex = chunkerCurrentIndex; - for (chunkerCurrentIndex = chunkerCurrentIndex + 2; chunkerCurrentIndex < len - 1; chunkerCurrentIndex++) { - cc2 = input.charCodeAt(chunkerCurrentIndex); - if (cc2 == 125) { lastMultiCommentEndBrace = chunkerCurrentIndex; } - if (cc2 != 42) { continue; } - if (input.charCodeAt(chunkerCurrentIndex + 1) == 47) { break; } - } - if (chunkerCurrentIndex == len - 1) { - return fail("missing closing `*/`", currentChunkStartIndex); - } - chunkerCurrentIndex++; - } - continue; - case 42: // *, check for unmatched */ - if ((chunkerCurrentIndex < len - 1) && (input.charCodeAt(chunkerCurrentIndex + 1) == 47)) { - return fail("unmatched `/*`", chunkerCurrentIndex); - } - continue; - } - } - - if (level !== 0) { - if ((lastMultiComment > lastOpening) && (lastMultiCommentEndBrace > lastMultiComment)) { - return fail("missing closing `}` or `*/`", lastOpening); - } else { - return fail("missing closing `}`", lastOpening); - } - } else if (parenLevel !== 0) { - return fail("missing closing `)`", lastOpeningParen); - } - - emitChunk(true); - return chunks; -}; - -},{}],37:[function(require,module,exports){ -var chunker = require('./chunker'); - -module.exports = function() { - 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 - chunks, // chunkified input - current, // current chunk - currentPos, // index of current chunk, in `input` - parserInput = {}; - - var CHARCODE_SPACE = 32, - CHARCODE_TAB = 9, - CHARCODE_LF = 10, - CHARCODE_CR = 13, - CHARCODE_PLUS = 43, - CHARCODE_COMMA = 44, - CHARCODE_FORWARD_SLASH = 47, - CHARCODE_9 = 57; - - function skipWhitespace(length) { - var oldi = parserInput.i, oldj = j, - curr = parserInput.i - currentPos, - endIndex = parserInput.i + current.length - curr, - mem = (parserInput.i += length), - inp = input, - c, nextChar, comment; - - for (; parserInput.i < endIndex; parserInput.i++) { - c = inp.charCodeAt(parserInput.i); - - if (parserInput.autoCommentAbsorb && c === CHARCODE_FORWARD_SLASH) { - nextChar = inp.charAt(parserInput.i + 1); - if (nextChar === '/') { - comment = {index: parserInput.i, isLineComment: true}; - var nextNewLine = inp.indexOf("\n", parserInput.i + 2); - if (nextNewLine < 0) { - nextNewLine = endIndex; - } - parserInput.i = nextNewLine; - comment.text = inp.substr(comment.index, parserInput.i - comment.index); - parserInput.commentStore.push(comment); - continue; - } else if (nextChar === '*') { - var nextStarSlash = inp.indexOf("*/", parserInput.i + 2); - if (nextStarSlash >= 0) { - comment = { - index: parserInput.i, - text: inp.substr(parserInput.i, nextStarSlash + 2 - parserInput.i), - isLineComment: false - }; - parserInput.i += comment.text.length - 1; - parserInput.commentStore.push(comment); - continue; - } - } - break; - } - - if ((c !== CHARCODE_SPACE) && (c !== CHARCODE_LF) && (c !== CHARCODE_TAB) && (c !== CHARCODE_CR)) { - break; - } - } - - current = current.slice(length + parserInput.i - mem + curr); - currentPos = parserInput.i; - - if (!current.length) { - if (j < chunks.length - 1) { - current = chunks[++j]; - skipWhitespace(0); // skip space at the beginning of a chunk - return true; // things changed - } - parserInput.finished = true; - } - - return oldi !== parserInput.i || oldj !== j; - } - - parserInput.save = function() { - currentPos = parserInput.i; - saveStack.push( { current: current, i: parserInput.i, j: j }); - }; - parserInput.restore = function(possibleErrorMessage) { - - if (parserInput.i > furthest || (parserInput.i === furthest && possibleErrorMessage && !furthestPossibleErrorMessage)) { - furthest = parserInput.i; - furthestPossibleErrorMessage = possibleErrorMessage; - } - var state = saveStack.pop(); - current = state.current; - currentPos = parserInput.i = state.i; - j = state.j; - }; - parserInput.forget = function() { - saveStack.pop(); - }; - parserInput.isWhitespace = function (offset) { - var pos = parserInput.i + (offset || 0), - code = input.charCodeAt(pos); - return (code === CHARCODE_SPACE || code === CHARCODE_CR || code === CHARCODE_TAB || code === CHARCODE_LF); - }; - - // Specialization of $(tok) - parserInput.$re = function(tok) { - if (parserInput.i > currentPos) { - current = current.slice(parserInput.i - currentPos); - currentPos = parserInput.i; - } - - var m = tok.exec(current); - if (!m) { - return null; - } - - skipWhitespace(m[0].length); - if (typeof m === "string") { - return m; - } - - return m.length === 1 ? m[0] : m; - }; - - parserInput.$char = function(tok) { - if (input.charAt(parserInput.i) !== tok) { - return null; - } - skipWhitespace(1); - return tok; - }; - - parserInput.$str = function(tok) { - var tokLength = tok.length; - - // https://jsperf.com/string-startswith/21 - for (var i = 0; i < tokLength; i++) { - if (input.charAt(parserInput.i + i) !== tok.charAt(i)) { - return null; - } - } - - skipWhitespace(tokLength); - return tok; - }; - - parserInput.$quoted = function() { - - var startChar = input.charAt(parserInput.i); - if (startChar !== "'" && startChar !== '"') { - return; - } - var length = input.length, - currentPosition = parserInput.i; - - for (var i = 1; i + currentPosition < length; i++) { - var nextChar = input.charAt(i + currentPosition); - switch(nextChar) { - case "\\": - i++; - continue; - case "\r": - case "\n": - break; - case startChar: - var str = input.substr(currentPosition, i + 1); - skipWhitespace(i + 1); - return str; - default: - } - } - return null; - }; - - parserInput.autoCommentAbsorb = true; - parserInput.commentStore = []; - parserInput.finished = false; - - // Same as $(), but don't change the state of the parser, - // just return the match. - parserInput.peek = function(tok) { - if (typeof tok === 'string') { - // https://jsperf.com/string-startswith/21 - for (var i = 0; i < tok.length; i++) { - if (input.charAt(parserInput.i + i) !== tok.charAt(i)) { - return false; - } - } - return true; - } else { - return tok.test(current); - } - }; - - // Specialization of peek() - // TODO remove or change some currentChar calls to peekChar - parserInput.peekChar = function(tok) { - return input.charAt(parserInput.i) === tok; - }; - - parserInput.currentChar = function() { - return input.charAt(parserInput.i); - }; - - parserInput.getInput = function() { - return input; - }; - - parserInput.peekNotNumeric = function() { - var c = input.charCodeAt(parserInput.i); - //Is the first char of the dimension 0-9, '.', '+' or '-' - return (c > CHARCODE_9 || c < CHARCODE_PLUS) || c === CHARCODE_FORWARD_SLASH || c === CHARCODE_COMMA; - }; - - parserInput.start = function(str, chunkInput, failFunction) { - input = str; - parserInput.i = j = currentPos = furthest = 0; - - // chunking apparently makes things quicker (but my tests indicate - // it might actually make things slower in node at least) - // and it is a non-perfect parse - it can't recognise - // unquoted urls, meaning it can't distinguish comments - // meaning comments with quotes or {}() in them get 'counted' - // and then lead to parse errors. - // In addition if the chunking chunks in the wrong place we might - // not be able to parse a parser statement in one go - // this is officially deprecated but can be switched on via an option - // in the case it causes too much performance issues. - if (chunkInput) { - chunks = chunker(str, failFunction); - } else { - chunks = [str]; - } - - current = chunks[0]; - - skipWhitespace(0); - }; - - parserInput.end = function() { - var message, - isFinished = parserInput.i >= input.length; - - if (parserInput.i < furthest) { - message = furthestPossibleErrorMessage; - parserInput.i = furthest; - } - return { - isFinished: isFinished, - furthest: parserInput.i, - furthestPossibleErrorMessage: message, - furthestReachedEnd: parserInput.i >= input.length - 1, - furthestChar: input[parserInput.i] - }; - }; - - return parserInput; -}; - -},{"./chunker":36}],38:[function(require,module,exports){ -var LessError = require('../less-error'), - tree = require("../tree"), - visitors = require("../visitors"), - getParserInput = require("./parser-input"), - utils = require("../utils"); - -// -// less.js - parser -// -// A relatively straight-forward predictive parser. -// There is no tokenization/lexing stage, the input is parsed -// in one sweep. -// -// To make the parser fast enough to run in the browser, several -// optimization had to be made: -// -// - Matching and slicing on a huge input is often cause of slowdowns. -// The solution is to chunkify the input into smaller strings. -// The chunks are stored in the `chunks` var, -// `j` holds the current chunk index, and `currentPos` holds -// the index of the current chunk in relation to `input`. -// This gives us an almost 4x speed-up. -// -// - In many cases, we don't need to match individual tokens; -// for example, if a value doesn't hold any variables, operations -// or dynamic references, the parser can effectively 'skip' it, -// treating it as a literal. -// An example would be '1px solid #000' - which evaluates to itself, -// we don't need to know what the individual components are. -// The drawback, of course is that you don't get the benefits of -// syntax-checking on the CSS. This gives us a 50% speed-up in the parser, -// and a smaller speed-up in the code-gen. -// -// -// 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(); - - function error(msg, type) { - throw new LessError( - { - index: parserInput.i, - filename: fileInfo.filename, - type: type || 'Syntax', - message: msg - }, - imports - ); - } - - function expect(arg, msg, index) { - // some older browsers return typeof 'function' for RegExp - var result = (arg instanceof Function) ? arg.call(parsers) : parserInput.$re(arg); - if (result) { - return result; - } - error(msg || (typeof arg === 'string' ? "expected '" + arg + "' got '" + parserInput.currentChar() + "'" - : "unexpected token")); - } - - // Specialization of expect() - function expectChar(arg, msg) { - if (parserInput.$char(arg)) { - return arg; - } - error(msg || "expected '" + arg + "' got '" + parserInput.currentChar() + "'"); - } - - function getDebugInfo(index) { - var filename = fileInfo.filename; - - return { - lineNumber: utils.getLocation(index, parserInput.getInput()).line + 1, - fileName: filename - }; - } - - // - // The Parser - // - return { - - // - // Parse an input string into an abstract syntax tree, - // @param str A string containing 'less' markup - // @param callback call `callback` when done. - // @param [additionalData] An optional map which can contains vars - a map (key, value) of variables to apply - // - parse: function (str, callback, additionalData) { - var root, error = null, globalVars, modifyVars, ignored, preText = ""; - - globalVars = (additionalData && additionalData.globalVars) ? Parser.serializeVars(additionalData.globalVars) + '\n' : ''; - modifyVars = (additionalData && additionalData.modifyVars) ? '\n' + Parser.serializeVars(additionalData.modifyVars) : ''; - - if (context.pluginManager) { - var preProcessors = context.pluginManager.getPreProcessors(); - for (var i = 0; i < preProcessors.length; i++) { - str = preProcessors[i].process(str, { context: context, imports: imports, fileInfo: fileInfo }); - } - } - - if (globalVars || (additionalData && additionalData.banner)) { - preText = ((additionalData && additionalData.banner) ? additionalData.banner : "") + globalVars; - ignored = imports.contentsIgnoredChars; - ignored[fileInfo.filename] = ignored[fileInfo.filename] || 0; - ignored[fileInfo.filename] += preText.length; - } - - str = str.replace(/\r\n?/g, '\n'); - // Remove potential UTF Byte Order Mark - str = preText + str.replace(/^\uFEFF/, '') + modifyVars; - imports.contents[fileInfo.filename] = str; - - // Start with the primary rule. - // The whole syntax tree is held under a Ruleset node, - // with the `root` property set to true, so no `{}` are - // output. The callback is called when the input is parsed. - try { - parserInput.start(str, context.chunkInput, function fail(msg, index) { - throw new LessError({ - index: index, - type: 'Parse', - message: msg, - filename: fileInfo.filename - }, imports); - }); - - root = new(tree.Ruleset)(null, this.parsers.primary()); - root.root = true; - root.firstRoot = true; - } catch (e) { - return callback(new LessError(e, imports, fileInfo.filename)); - } - - // If `i` is smaller than the `input.length - 1`, - // it means the parser wasn't able to parse the whole - // string, so we've got a parsing error. - // - // We try to extract a \n delimited string, - // showing the line where the parse error occurred. - // We split it up into two parts (the part which parsed, - // and the part which didn't), so we can color them differently. - var endInfo = parserInput.end(); - if (!endInfo.isFinished) { - - var message = endInfo.furthestPossibleErrorMessage; - - if (!message) { - message = "Unrecognised input"; - if (endInfo.furthestChar === '}') { - message += ". Possibly missing opening '{'"; - } else if (endInfo.furthestChar === ')') { - message += ". Possibly missing opening '('"; - } else if (endInfo.furthestReachedEnd) { - message += ". Possibly missing something"; - } - } - - error = new LessError({ - type: "Parse", - message: message, - index: endInfo.furthest, - filename: fileInfo.filename - }, imports); - } - - var finish = function (e) { - e = error || e || imports.error; - - if (e) { - if (!(e instanceof LessError)) { - e = new LessError(e, imports, fileInfo.filename); - } - - return callback(e); - } - else { - return callback(null, root); - } - }; - - if (context.processImports !== false) { - new visitors.ImportVisitor(imports, finish) - .run(root); - } else { - return finish(); - } - }, - - // - // Here in, the parsing rules/functions - // - // The basic structure of the syntax tree generated is as follows: - // - // Ruleset -> Rule -> Value -> Expression -> Entity - // - // Here's some Less code: - // - // .class { - // color: #fff; - // border: 1px solid #000; - // width: @w + 4px; - // > .child {...} - // } - // - // 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]]])) - // Ruleset (Selector [Element '>', '.child'], [...]) - // ]) - // - // In general, most rules will try to parse a token with the `$re()` function, and if the return - // value is truly, will return a new node, of the relevant type. Sometimes, we need to check - // first, before parsing, that's when we use `peek()`. - // - parsers: parsers = { - // - // The `primary` rule is the *entry* and *exit* point of the parser. - // The rules here can appear at any level of the parse tree. - // - // The recursive nature of the grammar is an interplay between the `block` - // rule, which represents `{ ... }`, the `ruleset` rule, and this `primary` rule, - // as represented by this simplified grammar: - // - // primary → (ruleset | rule)+ - // ruleset → selector+ block - // block → '{' primary '}' - // - // Only at one point is the primary rule not called from the - // block rule: at the root level. - // - primary: function () { - var mixin = this.mixin, root = [], node; - - while (true) { - while (true) { - node = this.comment(); - if (!node) { break; } - root.push(node); - } - // always process comments before deciding if finished - if (parserInput.finished) { - break; - } - if (parserInput.peek('}')) { - break; - } - - node = this.extendRule(); - if (node) { - root = root.concat(node); - continue; - } - - node = mixin.definition() || this.rule() || this.ruleset() || - mixin.call() || this.rulesetCall() || this.entities.call() || this.directive(); - if (node) { - root.push(node); - } else { - var foundSemiColon = false; - while (parserInput.$char(";")) { - foundSemiColon = true; - } - if (!foundSemiColon) { - break; - } - } - } - - return root; - }, - - // comments are collected by the main parsing mechanism and then assigned to nodes - // where the current structure allows it - comment: function () { - if (parserInput.commentStore.length) { - var comment = parserInput.commentStore.shift(); - return new(tree.Comment)(comment.text, comment.isLineComment, comment.index, fileInfo); - } - }, - - // - // Entities are tokens which can be found inside an Expression - // - entities: { - // - // A string, which supports escaping " and ' - // - // "milky way" 'he\'s the one!' - // - quoted: function () { - var str, index = parserInput.i, isEscaped = false; - - parserInput.save(); - if (parserInput.$char("~")) { - isEscaped = true; - } - str = parserInput.$quoted(); - if (!str) { - parserInput.restore(); - return; - } - parserInput.forget(); - - return new(tree.Quoted)(str.charAt(0), str.substr(1, str.length - 2), isEscaped, index, fileInfo); - }, - - // - // A catch-all word, such as: - // - // black border-collapse - // - keyword: function () { - var k = parserInput.$char("%") || parserInput.$re(/^[_A-Za-z-][_A-Za-z0-9-]*/); - if (k) { - return tree.Color.fromKeyword(k) || new(tree.Keyword)(k); - } - }, - - // - // A function call - // - // 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; - - // http://jsperf.com/case-insensitive-regex-vs-strtolower-then-regex/18 - if (parserInput.peek(/^url\(/i)) { - return; - } - - parserInput.save(); - - name = parserInput.$re(/^([\w-]+|%|progid:[\w\.]+)\(/); - if (!name) { parserInput.forget(); return; } - - name = name[1]; - nameLC = name.toLowerCase(); - - if (nameLC === 'alpha') { - alpha = parsers.alpha(); - if (alpha) { - parserInput.forget(); - return alpha; - } - } - - args = this.arguments(); - - 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(); - - while (true) { - - arg = parsers.detachedRuleset() || this.assignment() || parsers.expression(); - - if (!arg) { - break; - } - - value = arg; - - if (arg.value && arg.value.length == 1) { - value = arg.value[0]; - } - - if (value) { - expressions.push(value); - } - - argsComma.push(value); - - if (parserInput.$char(',')) { - continue; - } - - if (parserInput.$char(';') || isSemiColonSeparated) { - - isSemiColonSeparated = true; - - if (expressions.length > 1) { - value = new(tree.Value)(expressions); - } - argsSemiColon.push(value); - - expressions = []; - } - } - - parserInput.forget(); - return isSemiColonSeparated ? argsSemiColon : argsComma; - }, - literal: function () { - return this.dimension() || - this.color() || - this.quoted() || - this.unicodeDescriptor(); - }, - - // Assignments are argument entities for calls. - // They are present in ie filter properties as shown below. - // - // filter: progid:DXImageTransform.Microsoft.Alpha( *opacity=50* ) - // - - assignment: function () { - var key, value; - parserInput.save(); - key = parserInput.$re(/^\w+(?=\s?=)/i); - if (!key) { - parserInput.restore(); - return; - } - if (!parserInput.$char('=')) { - parserInput.restore(); - return; - } - value = parsers.entity(); - if (value) { - parserInput.forget(); - return new(tree.Assignment)(key, value); - } else { - parserInput.restore(); - } - }, - - // - // Parse url() tokens - // - // We use a specific rule for urls, because they don't really behave like - // standard function calls. The difference is that the argument doesn't have - // to be enclosed within a string, so it can't be parsed as an Expression. - // - url: function () { - var value, index = parserInput.i; - - parserInput.autoCommentAbsorb = false; - - if (!parserInput.$str("url(")) { - parserInput.autoCommentAbsorb = true; - return; - } - - value = this.quoted() || this.variable() || - parserInput.$re(/^(?:(?:\\[\(\)'"])|[^\(\)'"])+/) || ""; - - parserInput.autoCommentAbsorb = true; - - expectChar(')'); - - return new(tree.URL)((value.value != null || value instanceof tree.Variable) ? - value : new(tree.Anonymous)(value), index, fileInfo); - }, - - // - // A Variable entity, such as `@fink`, in - // - // width: @fink + 2px - // - // We use a different parser for variable definitions, - // see `parsers.variable`. - // - variable: function () { - var name, index = parserInput.i; - - if (parserInput.currentChar() === '@' && (name = parserInput.$re(/^@@?[\w-]+/))) { - return new(tree.Variable)(name, index, fileInfo); - } - }, - - // A variable entity using the protective {} e.g. @{var} - variableCurly: function () { - var curly, index = parserInput.i; - - if (parserInput.currentChar() === '@' && (curly = parserInput.$re(/^@\{([\w-]+)\}/))) { - return new(tree.Variable)("@" + curly[1], index, fileInfo); - } - }, - - // - // A Hexadecimal color - // - // #4F3C2F - // - // `rgb` and `hsl` colors are parsed through the `entities.call` parser. - // - color: function () { - var rgb; - - if (parserInput.currentChar() === '#' && (rgb = parserInput.$re(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/))) { - // strip colons, brackets, whitespaces and other characters that should not - // definitely be part of color string - var colorCandidateString = rgb.input.match(/^#([\w]+).*/); - colorCandidateString = colorCandidateString[1]; - if (!colorCandidateString.match(/^[A-Fa-f0-9]+$/)) { // verify if candidate consists only of allowed HEX characters - error("Invalid HEX color code"); - } - return new(tree.Color)(rgb[1], undefined, '#' + colorCandidateString); - } - }, - - colorKeyword: function () { - parserInput.save(); - var autoCommentAbsorb = parserInput.autoCommentAbsorb; - parserInput.autoCommentAbsorb = false; - var k = parserInput.$re(/^[_A-Za-z-][_A-Za-z0-9-]+/); - parserInput.autoCommentAbsorb = autoCommentAbsorb; - if (!k) { - parserInput.forget(); - return; - } - parserInput.restore(); - var color = tree.Color.fromKeyword(k); - if (color) { - parserInput.$str(k); - return color; - } - }, - - // - // A Dimension, that is, a number and a unit - // - // 0.5em 95% - // - dimension: function () { - if (parserInput.peekNotNumeric()) { - return; - } - - var value = parserInput.$re(/^([+-]?\d*\.?\d+)(%|[a-z_]+)?/i); - if (value) { - return new(tree.Dimension)(value[1], value[2]); - } - }, - - // - // A unicode descriptor, as is used in unicode-range - // - // U+0?? or U+00A1-00A9 - // - unicodeDescriptor: function () { - var ud; - - ud = parserInput.$re(/^U\+[0-9a-fA-F?]+(\-[0-9a-fA-F?]+)?/); - if (ud) { - return new(tree.UnicodeDescriptor)(ud[0]); - } - }, - - // - // JavaScript code to be evaluated - // - // `window.location.href` - // - javascript: function () { - var js, index = parserInput.i; - - parserInput.save(); - - var escape = parserInput.$char("~"); - var jsQuote = parserInput.$char("`"); - - if (!jsQuote) { - parserInput.restore(); - return; - } - - js = parserInput.$re(/^[^`]*`/); - if (js) { - parserInput.forget(); - return new(tree.JavaScript)(js.substr(0, js.length - 1), Boolean(escape), index, fileInfo); - } - parserInput.restore("invalid javascript definition"); - } - }, - - // - // The variable part of a variable definition. Used in the `rule` parser - // - // @fink: - // - variable: function () { - var name; - - if (parserInput.currentChar() === '@' && (name = parserInput.$re(/^(@[\w-]+)\s*:/))) { return name[1]; } - }, - - // - // The variable part of a variable definition. Used in the `rule` parser - // - // @fink(); - // - rulesetCall: function () { - var name; - - if (parserInput.currentChar() === '@' && (name = parserInput.$re(/^(@[\w-]+)\(\s*\)\s*;/))) { - return new tree.RulesetCall(name[1]); - } - }, - - // - // extend syntax - used to extend selectors - // - extend: function(isRule) { - var elements, e, index = parserInput.i, option, extendList, extend; - - if (!parserInput.$str(isRule ? "&:extend(" : ":extend(")) { - return; - } - - do { - option = null; - elements = null; - while (! (option = parserInput.$re(/^(all)(?=\s*(\)|,))/))) { - e = this.element(); - if (!e) { - break; - } - if (elements) { - elements.push(e); - } else { - elements = [ e ]; - } - } - - option = option && option[1]; - if (!elements) { - error("Missing target selector for :extend()."); - } - extend = new(tree.Extend)(new(tree.Selector)(elements), option, index, fileInfo); - if (extendList) { - extendList.push(extend); - } else { - extendList = [ extend ]; - } - } while (parserInput.$char(",")); - - expect(/^\)/); - - if (isRule) { - expect(/^;/); - } - - return extendList; - }, - - // - // extendRule - used in a rule to extend all the parent selectors - // - extendRule: function() { - return this.extend(true); - }, - - // - // Mixins - // - mixin: { - // - // A Mixin call, with an optional argument list - // - // #mixins > .square(#fff); - // .rounded(4px, black); - // .button; - // - // The `while` loop is there because mixins can be - // namespaced, but we only support the child and descendant - // selector for now. - // - call: function () { - var s = parserInput.currentChar(), important = false, index = parserInput.i, elemIndex, - elements, elem, e, c, args; - - if (s !== '.' && s !== '#') { return; } - - parserInput.save(); // stop us absorbing part of an invalid selector - - while (true) { - elemIndex = parserInput.i; - e = parserInput.$re(/^[#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/); - if (!e) { - break; - } - elem = new(tree.Element)(c, e, elemIndex, fileInfo); - if (elements) { - elements.push(elem); - } else { - elements = [ elem ]; - } - c = parserInput.$char('>'); - } - - if (elements) { - if (parserInput.$char('(')) { - args = this.args(true).args; - expectChar(')'); - } - - if (parsers.important()) { - important = true; - } - - if (parsers.end()) { - parserInput.forget(); - return new(tree.mixin.Call)(elements, args, index, fileInfo, important); - } - } - - parserInput.restore(); - }, - args: function (isCall) { - var entities = parsers.entities, - returner = { args:null, variadic: false }, - expressions = [], argsSemiColon = [], argsComma = [], - isSemiColonSeparated, expressionContainsNamed, name, nameLoop, - value, arg, expand; - - parserInput.save(); - - while (true) { - if (isCall) { - arg = parsers.detachedRuleset() || parsers.expression(); - } else { - parserInput.commentStore.length = 0; - if (parserInput.$str("...")) { - returner.variadic = true; - if (parserInput.$char(";") && !isSemiColonSeparated) { - isSemiColonSeparated = true; - } - (isSemiColonSeparated ? argsSemiColon : argsComma) - .push({ variadic: true }); - break; - } - arg = entities.variable() || entities.literal() || entities.keyword(); - } - - if (!arg) { - break; - } - - nameLoop = null; - if (arg.throwAwayComments) { - arg.throwAwayComments(); - } - value = arg; - var val = null; - - if (isCall) { - // Variable - if (arg.value && arg.value.length == 1) { - val = arg.value[0]; - } - } else { - val = arg; - } - - if (val && val instanceof tree.Variable) { - if (parserInput.$char(':')) { - if (expressions.length > 0) { - if (isSemiColonSeparated) { - error("Cannot mix ; and , as delimiter types"); - } - expressionContainsNamed = true; - } - - value = parsers.detachedRuleset() || parsers.expression(); - - if (!value) { - if (isCall) { - error("could not understand value for named argument"); - } else { - parserInput.restore(); - returner.args = []; - return returner; - } - } - nameLoop = (name = val.name); - } else if (parserInput.$str("...")) { - if (!isCall) { - returner.variadic = true; - if (parserInput.$char(";") && !isSemiColonSeparated) { - isSemiColonSeparated = true; - } - (isSemiColonSeparated ? argsSemiColon : argsComma) - .push({ name: arg.name, variadic: true }); - break; - } else { - expand = true; - } - } else if (!isCall) { - name = nameLoop = val.name; - value = null; - } - } - - if (value) { - expressions.push(value); - } - - argsComma.push({ name:nameLoop, value:value, expand:expand }); - - if (parserInput.$char(',')) { - continue; - } - - if (parserInput.$char(';') || isSemiColonSeparated) { - - if (expressionContainsNamed) { - error("Cannot mix ; and , as delimiter types"); - } - - isSemiColonSeparated = true; - - if (expressions.length > 1) { - value = new(tree.Value)(expressions); - } - argsSemiColon.push({ name:name, value:value, expand:expand }); - - name = null; - expressions = []; - expressionContainsNamed = false; - } - } - - parserInput.forget(); - returner.args = isSemiColonSeparated ? argsSemiColon : argsComma; - return returner; - }, - // - // A Mixin definition, with a list of parameters - // - // .rounded (@radius: 2px, @color) { - // ... - // } - // - // Until we have a finer grained state-machine, we have to - // do a look-ahead, to make sure we don't have a mixin call. - // See the `rule` function for more information. - // - // We start by matching `.rounded (`, and then proceed on to - // the argument list, which has optional default values. - // We store the parameters in `params`, with a `value` key, - // if there is a value, such as in the case of `@radius`. - // - // Once we've got our params list, and a closing `)`, we parse - // the `{...}` block. - // - definition: function () { - var name, params = [], match, ruleset, cond, variadic = false; - if ((parserInput.currentChar() !== '.' && parserInput.currentChar() !== '#') || - parserInput.peek(/^[^{]*\}/)) { - return; - } - - parserInput.save(); - - match = parserInput.$re(/^([#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+)\s*\(/); - if (match) { - name = match[1]; - - var argInfo = this.args(false); - params = argInfo.args; - variadic = argInfo.variadic; - - // .mixincall("@{a}"); - // looks a bit like a mixin definition.. - // also - // .mixincall(@a: {rule: set;}); - // so we have to be nice and restore - if (!parserInput.$char(')')) { - parserInput.restore("Missing closing ')'"); - return; - } - - parserInput.commentStore.length = 0; - - if (parserInput.$str("when")) { // Guard - cond = expect(parsers.conditions, 'expected condition'); - } - - ruleset = parsers.block(); - - if (ruleset) { - parserInput.forget(); - return new(tree.mixin.Definition)(name, params, ruleset, cond, variadic); - } else { - parserInput.restore(); - } - } else { - parserInput.forget(); - } - } - }, - - // - // Entities are the smallest recognized token, - // and can be found inside a rule's value. - // - entity: function () { - var entities = this.entities; - - return this.comment() || entities.literal() || entities.variable() || entities.url() || - entities.call() || entities.keyword() || entities.javascript(); - }, - - // - // A Rule 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. - // - end: function () { - return parserInput.$char(';') || parserInput.peek('}'); - }, - - // - // IE's alpha function - // - // alpha(opacity=88) - // - alpha: function () { - var value; - - // http://jsperf.com/case-insensitive-regex-vs-strtolower-then-regex/18 - if (! parserInput.$re(/^opacity=/i)) { return; } - value = parserInput.$re(/^\d+/); - if (!value) { - value = expect(this.entities.variable, "Could not parse alpha"); - } - expectChar(')'); - return new(tree.Alpha)(value); - }, - - // - // A Selector Element - // - // div - // + h1 - // #socks - // input[type="text"] - // - // Elements are the building blocks for Selectors, - // they are made out of a `Combinator` (see combinator rule), - // and an element name, such as a tag a class, or `*`. - // - element: function () { - var e, c, v, index = parserInput.i; - - c = this.combinator(); - - e = parserInput.$re(/^(?:\d+\.\d+|\d+)%/) || - parserInput.$re(/^(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/) || - parserInput.$char('*') || parserInput.$char('&') || this.attribute() || - parserInput.$re(/^\([^&()@]+\)/) || parserInput.$re(/^[\.#:](?=@)/) || - this.entities.variableCurly(); - - if (! e) { - parserInput.save(); - if (parserInput.$char('(')) { - if ((v = this.selector()) && parserInput.$char(')')) { - e = new(tree.Paren)(v); - parserInput.forget(); - } else { - parserInput.restore("Missing closing ')'"); - } - } else { - parserInput.forget(); - } - } - - if (e) { return new(tree.Element)(c, e, index, fileInfo); } - }, - - // - // Combinators combine elements together, in a Selector. - // - // Because our parser isn't white-space sensitive, special care - // has to be taken, when parsing the descendant combinator, ` `, - // as it's an empty space. We have to check the previous character - // in the input, to see if it's a ` ` character. More info on how - // we deal with this in *combinator.js*. - // - combinator: function () { - var c = parserInput.currentChar(); - - if (c === '/') { - parserInput.save(); - var slashedCombinator = parserInput.$re(/^\/[a-z]+\//i); - if (slashedCombinator) { - parserInput.forget(); - return new(tree.Combinator)(slashedCombinator); - } - parserInput.restore(); - } - - if (c === '>' || c === '+' || c === '~' || c === '|' || c === '^') { - parserInput.i++; - if (c === '^' && parserInput.currentChar() === '^') { - c = '^^'; - parserInput.i++; - } - while (parserInput.isWhitespace()) { parserInput.i++; } - return new(tree.Combinator)(c); - } else if (parserInput.isWhitespace(-1)) { - return new(tree.Combinator)(" "); - } else { - return new(tree.Combinator)(null); - } - }, - // - // 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 - // - // .class > div + h1 - // li a:hover - // - // Selectors are made out of one or more Elements, see above. - // - selector: function (isLess) { - var index = parserInput.i, elements, extendList, c, e, allExtends, when, condition; - - while ((isLess && (extendList = this.extend())) || (isLess && (when = parserInput.$str("when"))) || (e = this.element())) { - if (when) { - condition = expect(this.conditions, 'expected condition'); - } else if (condition) { - error("CSS guard can only be used at the end of selector"); - } else if (extendList) { - if (allExtends) { - allExtends = allExtends.concat(extendList); - } else { - allExtends = extendList; - } - } else { - if (allExtends) { error("Extend can only be used at the end of selector"); } - c = parserInput.currentChar(); - if (elements) { - elements.push(e); - } else { - elements = [ e ]; - } - e = null; - } - if (c === '{' || c === '}' || c === ';' || c === ',' || c === ')') { - break; - } - } - - if (elements) { return new(tree.Selector)(elements, allExtends, condition, index, 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; } - - var entities = this.entities, - key, val, op; - - if (!(key = entities.variableCurly())) { - key = expect(/^(?:[_A-Za-z0-9-\*]*\|)?(?:[_A-Za-z0-9-]|\\.)+/); - } - - op = parserInput.$re(/^[|~*$^]?=/); - if (op) { - val = entities.quoted() || parserInput.$re(/^[0-9]+%/) || parserInput.$re(/^[\w-]+/) || entities.variableCurly(); - } - - expectChar(']'); - - return new(tree.Attribute)(key, op, val); - }, - - // - // The `block` rule is used by `ruleset` and `mixin.definition`. - // It's a wrapper around the `primary` rule, with added `{}`. - // - block: function () { - var content; - if (parserInput.$char('{') && (content = this.primary()) && parserInput.$char('}')) { - return content; - } - }, - - blockRuleset: function() { - var block = this.block(); - - if (block) { - block = new tree.Ruleset(null, block); - } - return block; - }, - - detachedRuleset: function() { - var blockRuleset = this.blockRuleset(); - if (blockRuleset) { - return new tree.DetachedRuleset(blockRuleset); - } - }, - - // - // div, .class, body > p {...} - // - ruleset: function () { - var selectors, s, rules, debugInfo; - - parserInput.save(); - - if (context.dumpLineNumbers) { - debugInfo = getDebugInfo(parserInput.i); - } - - while (true) { - s = this.lessSelector(); - if (!s) { - break; - } - if (selectors) { - selectors.push(s); - } else { - selectors = [ s ]; - } - parserInput.commentStore.length = 0; - if (s.condition && selectors.length > 1) { - error("Guards are only currently allowed on a single selector."); - } - if (! parserInput.$char(',')) { break; } - if (s.condition) { - error("Guards are only currently allowed on a single selector."); - } - parserInput.commentStore.length = 0; - } - - if (selectors && (rules = this.block())) { - parserInput.forget(); - var ruleset = new(tree.Ruleset)(selectors, rules, context.strictImports); - if (context.dumpLineNumbers) { - ruleset.debugInfo = debugInfo; - } - return ruleset; - } else { - parserInput.restore(); - } - }, - rule: function (tryAnonymous) { - var name, value, startOfRule = parserInput.i, c = parserInput.currentChar(), important, merge, isVariable; - - if (c === '.' || c === '#' || c === '&' || c === ':') { return; } - - parserInput.save(); - - name = this.variable() || this.ruleProperty(); - if (name) { - isVariable = typeof name === "string"; - - if (isVariable) { - value = this.detachedRuleset(); - } - - parserInput.commentStore.length = 0; - if (!value) { - // a name returned by this.ruleProperty() is always an array of the form: - // [string-1, ..., string-n, ""] or [string-1, ..., string-n, "+"] - // 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(); - } - 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(); - } - - important = this.important(); - } - - if (value && this.end()) { - parserInput.forget(); - return new (tree.Rule)(name, value, important, merge, startOfRule, fileInfo); - } else { - parserInput.restore(); - if (value && !tryAnonymous) { - return this.rule(true); - } - } - } else { - parserInput.forget(); - } - }, - anonymousValue: function () { - var match = parserInput.$re(/^([^@+\/'"*`(;{}-]*);/); - if (match) { - return new(tree.Anonymous)(match[1]); - } - }, - - // - // An @import directive - // - // @import "lib"; - // - // 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. - // - "import": function () { - var path, features, index = parserInput.i; - - var dir = parserInput.$re(/^@import?\s+/); - - if (dir) { - var options = (dir ? this.importOptions() : null) || {}; - - if ((path = this.entities.quoted() || this.entities.url())) { - features = this.mediaFeatures(); - - if (!parserInput.$char(';')) { - parserInput.i = index; - error("missing semi-colon or unrecognised media features on import"); - } - features = features && new(tree.Value)(features); - return new(tree.Import)(path, features, options, index, fileInfo); - } - else { - parserInput.i = index; - error("malformed import statement"); - } - } - }, - - importOptions: function() { - var o, options = {}, optionName, value; - - // list of options, surrounded by parens - if (! parserInput.$char('(')) { return null; } - do { - o = this.importOption(); - if (o) { - optionName = o; - value = true; - switch(optionName) { - case "css": - optionName = "less"; - value = false; - break; - case "once": - optionName = "multiple"; - value = false; - break; - } - options[optionName] = value; - if (! parserInput.$char(',')) { break; } - } - } while (o); - expectChar(')'); - return options; - }, - - importOption: function() { - var opt = parserInput.$re(/^(less|css|multiple|once|inline|reference|optional)/); - if (opt) { - return opt[1]; - } - }, - - mediaFeature: function () { - var entities = this.entities, nodes = [], e, p; - parserInput.save(); - do { - e = entities.keyword() || entities.variable(); - if (e) { - nodes.push(e); - } else if (parserInput.$char('(')) { - p = this.property(); - 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))); - } else if (e) { - nodes.push(new(tree.Paren)(e)); - } else { - error("badly formed media feature definition"); - } - } else { - error("Missing closing ')'", "Parse"); - } - } - } while (e); - - parserInput.forget(); - if (nodes.length > 0) { - return new(tree.Expression)(nodes); - } - }, - - mediaFeatures: function () { - var entities = this.entities, features = [], e; - do { - e = this.mediaFeature(); - if (e) { - features.push(e); - if (! parserInput.$char(',')) { break; } - } else { - e = entities.variable(); - if (e) { - features.push(e); - if (! parserInput.$char(',')) { break; } - } - } - } while (e); - - return features.length > 0 ? features : null; - }, - - media: function () { - var features, rules, media, debugInfo, index = parserInput.i; - - if (context.dumpLineNumbers) { - debugInfo = getDebugInfo(index); - } - - parserInput.save(); - - if (parserInput.$str("@media")) { - features = this.mediaFeatures(); - - rules = this.block(); - - if (!rules) { - error("media definitions require block statements after any features"); - } - - parserInput.forget(); - - media = new(tree.Media)(rules, features, index, fileInfo); - if (context.dumpLineNumbers) { - media.debugInfo = debugInfo; - } - - return media; - } - - parserInput.restore(); - }, - - // - // A @plugin directive, used to import compiler extensions dynamically. - // - // @plugin "lib"; - // - // 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: function () { - var path, - index = parserInput.i, - dir = parserInput.$re(/^@plugin?\s+/); - - if (dir) { - var options = { plugin : true }; - - if ((path = this.entities.quoted() || this.entities.url())) { - - if (!parserInput.$char(';')) { - parserInput.i = index; - error("missing semi-colon on plugin"); - } - - return new(tree.Import)(path, null, options, index, fileInfo); - } - else { - parserInput.i = index; - error("malformed plugin statement"); - } - } - }, - - // - // A CSS Directive - // - // @charset "utf-8"; - // - directive: function () { - var index = parserInput.i, name, value, rules, nonVendorSpecificName, - hasIdentifier, hasExpression, hasUnknown, hasBlock = true, isRooted = true; - - if (parserInput.currentChar() !== '@') { return; } - - value = this['import']() || this.plugin() || this.media(); - if (value) { - return value; - } - - parserInput.save(); - - name = parserInput.$re(/^@[a-z-]+/); - - if (!name) { return; } - - nonVendorSpecificName = name; - if (name.charAt(1) == '-' && name.indexOf('-', 2) > 0) { - nonVendorSpecificName = "@" + name.slice(name.indexOf('-', 2) + 1); - } - - switch(nonVendorSpecificName) { - case "@charset": - hasIdentifier = true; - hasBlock = false; - break; - case "@namespace": - hasExpression = true; - hasBlock = false; - break; - case "@keyframes": - case "@counter-style": - hasIdentifier = true; - break; - case "@document": - case "@supports": - hasUnknown = true; - isRooted = false; - break; - default: - hasUnknown = true; - break; - } - - parserInput.commentStore.length = 0; - - if (hasIdentifier) { - value = this.entity(); - if (!value) { - error("expected " + name + " identifier"); - } - } else if (hasExpression) { - value = this.expression(); - if (!value) { - error("expected " + name + " expression"); - } - } else if (hasUnknown) { - value = (parserInput.$re(/^[^{;]+/) || '').trim(); - hasBlock = (parserInput.currentChar() == '{'); - if (value) { - value = new(tree.Anonymous)(value); - } - } - - if (hasBlock) { - rules = this.blockRuleset(); - } - - if (rules || (!hasBlock && value && parserInput.$char(';'))) { - parserInput.forget(); - return new (tree.Directive)(name, value, rules, index, fileInfo, - context.dumpLineNumbers ? getDebugInfo(index) : null, - isRooted - ); - } - - parserInput.restore("directive options not recognised"); - }, - - // - // A Value is a comma-delimited list of Expressions - // - // font-family: Baskerville, Georgia, serif; - // - // In a Rule, a Value represents everything after the `:`, - // and before the `;`. - // - value: function () { - var e, expressions = []; - - do { - e = this.expression(); - if (e) { - expressions.push(e); - if (! parserInput.$char(',')) { break; } - } - } while (e); - - if (expressions.length > 0) { - return new(tree.Value)(expressions); - } - }, - important: function () { - if (parserInput.currentChar() === '!') { - return parserInput.$re(/^! *important/); - } - }, - sub: function () { - var a, e; - - parserInput.save(); - if (parserInput.$char('(')) { - a = this.addition(); - if (a && parserInput.$char(')')) { - parserInput.forget(); - e = new(tree.Expression)([a]); - e.parens = true; - return e; - } - parserInput.restore("Expected ')'"); - return; - } - parserInput.restore(); - }, - multiplication: function () { - var m, a, op, operation, isSpaced; - m = this.operand(); - if (m) { - isSpaced = parserInput.isWhitespace(-1); - while (true) { - if (parserInput.peek(/^\/[*\/]/)) { - break; - } - - parserInput.save(); - - op = parserInput.$char('/') || parserInput.$char('*'); - - if (!op) { parserInput.forget(); break; } - - a = this.operand(); - - if (!a) { parserInput.restore(); break; } - parserInput.forget(); - - m.parensInOp = true; - a.parensInOp = true; - operation = new(tree.Operation)(op, [operation || m, a], isSpaced); - isSpaced = parserInput.isWhitespace(-1); - } - return operation || m; - } - }, - addition: function () { - var m, a, op, operation, isSpaced; - m = this.multiplication(); - if (m) { - isSpaced = parserInput.isWhitespace(-1); - while (true) { - op = parserInput.$re(/^[-+]\s+/) || (!isSpaced && (parserInput.$char('+') || parserInput.$char('-'))); - if (!op) { - break; - } - a = this.multiplication(); - if (!a) { - break; - } - - m.parensInOp = true; - a.parensInOp = true; - operation = new(tree.Operation)(op, [operation || m, a], isSpaced); - isSpaced = parserInput.isWhitespace(-1); - } - return operation || m; - } - }, - conditions: function () { - var a, b, index = parserInput.i, condition; - - a = this.condition(); - if (a) { - while (true) { - if (!parserInput.peek(/^,\s*(not\s*)?\(/) || !parserInput.$char(',')) { - break; - } - b = this.condition(); - if (!b) { - break; - } - condition = new(tree.Condition)('or', condition || a, b, index); - } - return condition || a; - } - }, - condition: function () { - var result, logical, next; - function or() { - return parserInput.$str("or"); - } - - result = this.conditionAnd(this); - if (!result) { - return ; - } - logical = or(); - if (logical) { - next = this.condition(); - if (next) { - result = new(tree.Condition)(logical, result, next); - } else { - return ; - } - } - return result; - }, - conditionAnd: function () { - var result, logical, next; - function insideCondition(me) { - return me.negatedCondition() || me.parenthesisCondition(); - } - function and() { - return parserInput.$str("and"); - } - - result = insideCondition(this); - if (!result) { - return ; - } - logical = and(); - if (logical) { - next = this.conditionAnd(); - if (next) { - result = new(tree.Condition)(logical, result, next); - } else { - return ; - } - } - return result; - }, - negatedCondition: function () { - if (parserInput.$str("not")) { - var result = this.parenthesisCondition(); - if (result) { - result.negate = !result.negate; - } - return result; - } - }, - parenthesisCondition: function () { - function tryConditionFollowedByParenthesis(me) { - var body; - parserInput.save(); - body = me.condition(); - if (!body) { - parserInput.restore(); - return ; - } - if (!parserInput.$char(')')) { - parserInput.restore(); - return ; - } - parserInput.forget(); - return body; - } - - var body; - parserInput.save(); - if (!parserInput.$str("(")) { - parserInput.restore(); - return ; - } - body = tryConditionFollowedByParenthesis(this); - if (body) { - parserInput.forget(); - return body; - } - - body = this.atomicCondition(); - if (!body) { - parserInput.restore(); - return ; - } - if (!parserInput.$char(')')) { - parserInput.restore("expected ')' got '" + parserInput.currentChar() + "'"); - return ; - } - parserInput.forget(); - return body; - }, - atomicCondition: function () { - var entities = this.entities, index = parserInput.i, a, b, c, op; - - a = this.addition() || entities.keyword() || entities.quoted(); - if (a) { - if (parserInput.$char('>')) { - if (parserInput.$char('=')) { - op = ">="; - } else { - op = '>'; - } - } else - if (parserInput.$char('<')) { - if (parserInput.$char('=')) { - op = "<="; - } else { - op = '<'; - } - } else - if (parserInput.$char('=')) { - if (parserInput.$char('>')) { - op = "=>"; - } else if (parserInput.$char('<')) { - op = '=<'; - } else { - op = '='; - } - } - if (op) { - b = this.addition() || entities.keyword() || entities.quoted(); - if (b) { - c = new(tree.Condition)(op, a, b, index, false); - } else { - error('expected expression'); - } - } else { - c = new(tree.Condition)('=', a, new(tree.Keyword)('true'), index, false); - } - return c; - } - }, - - // - // An operand is anything that can be part of an operation, - // such as a Color, or a Variable - // - operand: function () { - var entities = this.entities, negate; - - if (parserInput.peek(/^-[@\(]/)) { - negate = parserInput.$char('-'); - } - - var o = this.sub() || entities.dimension() || - entities.color() || entities.variable() || - entities.call() || entities.colorKeyword(); - - if (negate) { - o.parensInOp = true; - o = new(tree.Negative)(o); - } - - return o; - }, - - // - // Expressions either represent mathematical operations, - // or white-space delimited Entities. - // - // 1px solid black - // @var * 2 - // - expression: function () { - var entities = [], e, delim; - - do { - e = this.comment(); - if (e) { - entities.push(e); - continue; - } - e = this.addition() || this.entity(); - if (e) { - entities.push(e); - // operations do not allow keyword "/" dimension (e.g. small/20px) so we support that here - if (!parserInput.peek(/^\/[\/*]/)) { - delim = parserInput.$char('/'); - if (delim) { - entities.push(new(tree.Anonymous)(delim)); - } - } - } - } while (e); - if (entities.length > 0) { - return new(tree.Expression)(entities); - } - }, - property: function () { - var name = parserInput.$re(/^(\*?-?[_a-zA-Z0-9-]+)\s*:/); - if (name) { - return name[1]; - } - }, - ruleProperty: function () { - var name = [], index = [], s, k; - - parserInput.save(); - - var simpleProperty = parserInput.$re(/^([_a-zA-Z0-9-]+)\s*:/); - if (simpleProperty) { - name = [new(tree.Keyword)(simpleProperty[1])]; - parserInput.forget(); - return name; - } - - function match(re) { - var i = parserInput.i, - chunk = parserInput.$re(re); - if (chunk) { - index.push(i); - return name.push(chunk[1]); - } - } - - match(/^(\*?)/); - while (true) { - if (!match(/^((?:[\w-]+)|(?:@\{[\w-]+\}))/)) { - break; - } - } - - if ((name.length > 1) && match(/^((?:\+_|\+)?)\s*:/)) { - parserInput.forget(); - - // at last, we have the complete match now. move forward, - // convert name particles to tree objects and return: - if (name[0] === '') { - name.shift(); - index.shift(); - } - for (k = 0; k < name.length; k++) { - s = name[k]; - name[k] = (s.charAt(0) !== '@') ? - new(tree.Keyword)(s) : - new(tree.Variable)('@' + s.slice(2, -1), - index[k], fileInfo); - } - return name; - } - parserInput.restore(); - } - } - }; -}; -Parser.serializeVars = function(vars) { - var s = ''; - - for (var name in vars) { - if (Object.hasOwnProperty.call(vars, name)) { - var value = vars[name]; - s += ((name[0] === '@') ? '' : '@') + name + ': ' + value + - ((String(value).slice(-1) === ';') ? '' : ';'); - } - } - - return s; -}; - -module.exports = Parser; - -},{"../less-error":32,"../tree":62,"../utils":83,"../visitors":87,"./parser-input":37}],39:[function(require,module,exports){ -/** - * Plugin Manager - */ -var PluginManager = function(less) { - this.less = less; - this.visitors = []; - this.preProcessors = []; - this.postProcessors = []; - this.installedPlugins = []; - this.fileManagers = []; -}; -/** - * Adds all the plugins in the array - * @param {Array} plugins - */ -PluginManager.prototype.addPlugins = function(plugins) { - if (plugins) { - for (var i = 0; i < plugins.length; i++) { - this.addPlugin(plugins[i]); - } - } -}; -/** - * - * @param plugin - */ -PluginManager.prototype.addPlugin = function(plugin) { - this.installedPlugins.push(plugin); - plugin.install(this.less, this); -}; -/** - * Adds a visitor. The visitor object has options on itself to determine - * when it should run. - * @param visitor - */ -PluginManager.prototype.addVisitor = function(visitor) { - this.visitors.push(visitor); -}; -/** - * Adds a pre processor object - * @param {object} preProcessor - * @param {number} priority - guidelines 1 = before import, 1000 = import, 2000 = after import - */ -PluginManager.prototype.addPreProcessor = function(preProcessor, priority) { - var indexToInsertAt; - for (indexToInsertAt = 0; indexToInsertAt < this.preProcessors.length; indexToInsertAt++) { - if (this.preProcessors[indexToInsertAt].priority >= priority) { - break; - } - } - this.preProcessors.splice(indexToInsertAt, 0, {preProcessor: preProcessor, priority: priority}); -}; -/** - * Adds a post processor object - * @param {object} postProcessor - * @param {number} priority - guidelines 1 = before compression, 1000 = compression, 2000 = after compression - */ -PluginManager.prototype.addPostProcessor = function(postProcessor, priority) { - var indexToInsertAt; - for (indexToInsertAt = 0; indexToInsertAt < this.postProcessors.length; indexToInsertAt++) { - if (this.postProcessors[indexToInsertAt].priority >= priority) { - break; - } - } - this.postProcessors.splice(indexToInsertAt, 0, {postProcessor: postProcessor, priority: priority}); -}; -/** - * - * @param manager - */ -PluginManager.prototype.addFileManager = function(manager) { - this.fileManagers.push(manager); -}; -/** - * - * @returns {Array} - * @private - */ -PluginManager.prototype.getPreProcessors = function() { - var preProcessors = []; - for (var i = 0; i < this.preProcessors.length; i++) { - preProcessors.push(this.preProcessors[i].preProcessor); - } - return preProcessors; -}; -/** - * - * @returns {Array} - * @private - */ -PluginManager.prototype.getPostProcessors = function() { - var postProcessors = []; - for (var i = 0; i < this.postProcessors.length; i++) { - postProcessors.push(this.postProcessors[i].postProcessor); - } - return postProcessors; -}; -/** - * - * @returns {Array} - * @private - */ -PluginManager.prototype.getVisitors = function() { - return this.visitors; -}; -/** - * - * @returns {Array} - * @private - */ -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 }); -}; - -},{"../less-error":32,"../tree":62}],41:[function(require,module,exports){ -var PromiseConstructor; - -module.exports = function(environment, ParseTree, ImportManager) { - var render = function (input, options, callback) { - if (typeof options === 'function') { - callback = options; - options = {}; - } - - if (!callback) { - if (!PromiseConstructor) { - PromiseConstructor = typeof Promise === 'undefined' ? require('promise') : Promise; - } - var self = this; - return new PromiseConstructor(function (resolve, reject) { - render.call(self, input, options, function(err, output) { - if (err) { - reject(err); - } else { - resolve(output); - } - }); - }); - } else { - this.parse(input, options, function(err, root, imports, options) { - if (err) { return callback(err); } - - var result; - try { - var parseTree = new ParseTree(root, imports); - result = parseTree.toCSS(options); - } - catch (err) { return callback(err); } - - callback(null, result); - }); - } - }; - - return render; -}; - -},{"promise":undefined}],42:[function(require,module,exports){ -module.exports = function (SourceMapOutput, environment) { - - var SourceMapBuilder = function (options) { - this.options = options; - }; - - SourceMapBuilder.prototype.toCSS = function(rootNode, options, imports) { - var sourceMapOutput = new SourceMapOutput( - { - contentsIgnoredCharsMap: imports.contentsIgnoredChars, - rootNode: rootNode, - contentsMap: imports.contents, - sourceMapFilename: this.options.sourceMapFilename, - sourceMapURL: this.options.sourceMapURL, - outputFilename: this.options.sourceMapOutputFilename, - sourceMapBasepath: this.options.sourceMapBasepath, - sourceMapRootpath: this.options.sourceMapRootpath, - outputSourceFiles: this.options.outputSourceFiles, - sourceMapGenerator: this.options.sourceMapGenerator, - sourceMapFileInline: this.options.sourceMapFileInline - }); - - var css = sourceMapOutput.toCSS(options); - this.sourceMap = sourceMapOutput.sourceMap; - this.sourceMapURL = sourceMapOutput.sourceMapURL; - if (this.options.sourceMapInputFilename) { - this.sourceMapInputFilename = sourceMapOutput.normalizeFilename(this.options.sourceMapInputFilename); - } - return css + this.getCSSAppendage(); - }; - - SourceMapBuilder.prototype.getCSSAppendage = function() { - - var sourceMapURL = this.sourceMapURL; - if (this.options.sourceMapFileInline) { - if (this.sourceMap === undefined) { - return ""; - } - sourceMapURL = "data:application/json;base64," + environment.encodeBase64(this.sourceMap); - } - - if (sourceMapURL) { - return "/*# sourceMappingURL=" + sourceMapURL + " */"; - } - return ""; - }; - - SourceMapBuilder.prototype.getExternalSourceMap = function() { - return this.sourceMap; - }; - SourceMapBuilder.prototype.setExternalSourceMap = function(sourceMap) { - this.sourceMap = sourceMap; - }; - - SourceMapBuilder.prototype.isInline = function() { - return this.options.sourceMapFileInline; - }; - SourceMapBuilder.prototype.getSourceMapURL = function() { - return this.sourceMapURL; - }; - SourceMapBuilder.prototype.getOutputFilename = function() { - return this.options.sourceMapOutputFilename; - }; - SourceMapBuilder.prototype.getInputFilename = function() { - return this.sourceMapInputFilename; - }; - - return SourceMapBuilder; -}; - -},{}],43:[function(require,module,exports){ -module.exports = function (environment) { - - var SourceMapOutput = function (options) { - this._css = []; - this._rootNode = options.rootNode; - this._contentsMap = options.contentsMap; - this._contentsIgnoredCharsMap = options.contentsIgnoredCharsMap; - if (options.sourceMapFilename) { - this._sourceMapFilename = options.sourceMapFilename.replace(/\\/g, '/'); - } - this._outputFilename = options.outputFilename; - this.sourceMapURL = options.sourceMapURL; - if (options.sourceMapBasepath) { - this._sourceMapBasepath = options.sourceMapBasepath.replace(/\\/g, '/'); - } - if (options.sourceMapRootpath) { - this._sourceMapRootpath = options.sourceMapRootpath.replace(/\\/g, '/'); - if (this._sourceMapRootpath.charAt(this._sourceMapRootpath.length - 1) !== '/') { - this._sourceMapRootpath += '/'; - } - } else { - this._sourceMapRootpath = ""; - } - this._outputSourceFiles = options.outputSourceFiles; - this._sourceMapGeneratorConstructor = environment.getSourceMapGenerator(); - - this._lineNumber = 0; - 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); - } - } - return (this._sourceMapRootpath || "") + filename; - }; - - SourceMapOutput.prototype.add = function(chunk, fileInfo, index, mapLines) { - - //ignore adding empty strings - if (!chunk) { - return; - } - - var lines, - sourceLines, - columns, - sourceColumns, - i; - - if (fileInfo) { - var inputSource = this._contentsMap[fileInfo.filename]; - - // remove vars/banner added to the top of the file - if (this._contentsIgnoredCharsMap[fileInfo.filename]) { - // adjust the index - index -= this._contentsIgnoredCharsMap[fileInfo.filename]; - if (index < 0) { index = 0; } - // adjust the source - inputSource = inputSource.slice(this._contentsIgnoredCharsMap[fileInfo.filename]); - } - inputSource = inputSource.substring(0, index); - sourceLines = inputSource.split("\n"); - sourceColumns = sourceLines[sourceLines.length - 1]; - } - - lines = chunk.split("\n"); - columns = lines[lines.length - 1]; - - if (fileInfo) { - if (!mapLines) { - this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + 1, column: this._column}, - original: { line: sourceLines.length, column: sourceColumns.length}, - source: this.normalizeFilename(fileInfo.filename)}); - } else { - for (i = 0; i < lines.length; i++) { - this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + i + 1, column: i === 0 ? this._column : 0}, - original: { line: sourceLines.length + i, column: i === 0 ? sourceColumns.length : 0}, - source: this.normalizeFilename(fileInfo.filename)}); - } - } - } - - if (lines.length === 1) { - this._column += columns.length; - } else { - this._lineNumber += lines.length - 1; - this._column = columns.length; - } - - this._css.push(chunk); - }; - - SourceMapOutput.prototype.isEmpty = function() { - return this._css.length === 0; - }; - - SourceMapOutput.prototype.toCSS = function(context) { - this._sourceMapGenerator = new this._sourceMapGeneratorConstructor({ file: this._outputFilename, sourceRoot: null }); - - if (this._outputSourceFiles) { - for (var filename in this._contentsMap) { - if (this._contentsMap.hasOwnProperty(filename)) { - var source = this._contentsMap[filename]; - if (this._contentsIgnoredCharsMap[filename]) { - source = source.slice(this._contentsIgnoredCharsMap[filename]); - } - this._sourceMapGenerator.setSourceContent(this.normalizeFilename(filename), source); - } - } - } - - this._rootNode.genCSS(context, this); - - if (this._css.length > 0) { - var sourceMapURL, - sourceMapContent = JSON.stringify(this._sourceMapGenerator.toJSON()); - - if (this.sourceMapURL) { - sourceMapURL = this.sourceMapURL; - } else if (this._sourceMapFilename) { - sourceMapURL = this._sourceMapFilename; - } - this.sourceMapURL = sourceMapURL; - - this.sourceMap = sourceMapContent; - } - - return this._css.join(''); - }; - - return SourceMapOutput; -}; - -},{}],44:[function(require,module,exports){ -var contexts = require("./contexts"), - visitor = require("./visitors"), - tree = require("./tree"); - -module.exports = function(root, options) { - options = options || {}; - var evaldRoot, - variables = options.variables, - evalEnv = new contexts.Eval(options); - - // - // Allows setting variables with a hash, so: - // - // `{ color: new tree.Color('#f01') }` will become: - // - // new tree.Rule('@color', - // new tree.Value([ - // new tree.Expression([ - // new tree.Color('#f01') - // ]) - // ]) - // ) - // - if (typeof variables === 'object' && !Array.isArray(variables)) { - variables = Object.keys(variables).map(function (k) { - var value = variables[k]; - - 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); - }); - evalEnv.frames = [new tree.Ruleset(null, variables)]; - } - - var preEvalVisitors = [], - visitors = [ - new visitor.JoinSelectorVisitor(), - new visitor.MarkVisibleSelectorsVisitor(true), - new visitor.ExtendVisitor(), - new visitor.ToCSSVisitor({compress: Boolean(options.compress)}) - ], i; - - 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); - } - } - } - } - - for (i = 0; i < preEvalVisitors.length; i++) { - preEvalVisitors[i].run(root); - } - - evaldRoot = root.eval(evalEnv); - - for (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); - } - - output.add(")"); -}; - -module.exports = Alpha; - -},{"./node":70}],46:[function(require,module,exports){ -var Node = require("./node"); - -var Anonymous = function (value, index, currentFileInfo, mapLines, rulesetLike, visibilityInfo) { - this.value = value; - this.index = index; - this.mapLines = mapLines; - this.currentFileInfo = currentFileInfo; - this.rulesetLike = (typeof rulesetLike === 'undefined') ? false : rulesetLike; - this.allowRoot = true; - this.copyVisibilityInfo(visibilityInfo); -}; -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()); -}; -Anonymous.prototype.compare = function (other) { - return other.toCSS && this.toCSS() === other.toCSS() ? 0 : undefined; -}; -Anonymous.prototype.isRulesetLike = function() { - return this.rulesetLike; -}; -Anonymous.prototype.genCSS = function (context, output) { - output.add(this.value, this.currentFileInfo, this.index, this.mapLines); -}; -module.exports = Anonymous; - -},{"./node":70}],47:[function(require,module,exports){ -var Node = require("./node"); - -var Assignment = function (key, val) { - this.key = key; - this.value = val; -}; - -Assignment.prototype = new Node(); -Assignment.prototype.type = "Assignment"; -Assignment.prototype.accept = function (visitor) { - this.value = visitor.visit(this.value); -}; -Assignment.prototype.eval = function (context) { - if (this.value.eval) { - return new Assignment(this.key, this.value.eval(context)); - } - return this; -}; -Assignment.prototype.genCSS = function (context, output) { - output.add(this.key + '='); - if (this.value.genCSS) { - this.value.genCSS(context, output); - } else { - output.add(this.value); - } -}; -module.exports = Assignment; - -},{"./node":70}],48:[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)); -}; -Attribute.prototype.toCSS = function (context) { - var value = this.key.toCSS ? this.key.toCSS(context) : this.key; - - if (this.op) { - value += this.op; - value += (this.value.toCSS ? this.value.toCSS(context) : this.value); - } - - return '[' + value + ']'; -}; -module.exports = Attribute; - -},{"./node":70}],49:[function(require,module,exports){ -var Node = require("./node"), - FunctionCaller = require("../functions/function-caller"); -// -// A function call node. -// -var Call = function (name, args, index, currentFileInfo) { - this.name = name; - this.args = args; - this.index = index; - this.currentFileInfo = currentFileInfo; -}; -Call.prototype = new Node(); -Call.prototype.type = "Call"; -Call.prototype.accept = function (visitor) { - if (this.args) { - this.args = visitor.visitArray(this.args); - } -}; -// -// When evaluating a function call, -// we either find the function in the functionRegistry, -// in which case we call it, passing the evaluated arguments, -// if this returns null or we cannot find the function, we -// simply print it out as it appeared originally [2]. -// -// The reason why we evaluate the arguments, is in the case where -// we try to pass a variable to a function, like: `saturate(@color)`. -// 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); - - 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 }; - } - - if (result != null) { - result.index = this.index; - result.currentFileInfo = this.currentFileInfo; - return result; - } - } - - return new Call(this.name, args, this.index, this.currentFileInfo); -}; -Call.prototype.genCSS = function (context, output) { - output.add(this.name + "(", this.currentFileInfo, this.index); - - for (var i = 0; i < this.args.length; i++) { - this.args[i].genCSS(context, output); - if (i + 1 < this.args.length) { - output.add(", "); - } - } - - output.add(")"); -}; -module.exports = Call; - -},{"../functions/function-caller":21,"./node":70}],50:[function(require,module,exports){ -var Node = require("./node"), - colors = require("../data/colors"); - -// -// RGB Colors - #ff0014, #eee -// -var Color = function (rgb, a, originalForm) { - // - // The end goal here, is to parse the arguments - // into an integer triplet, such as `128, 255, 0` - // - // This facilitates operations and conversions. - // - if (Array.isArray(rgb)) { - this.rgb = rgb; - } else if (rgb.length == 6) { - this.rgb = rgb.match(/.{2}/g).map(function (c) { - return parseInt(c, 16); - }); - } else { - this.rgb = rgb.split('').map(function (c) { - return parseInt(c + c, 16); - }); - } - this.alpha = typeof a === 'number' ? a : 1; - if (typeof originalForm !== 'undefined') { - this.value = originalForm; - } -}; - -Color.prototype = new Node(); -Color.prototype.type = "Color"; - -function clamp(v, max) { - return Math.min(Math.max(v, 0), max); -} - -function toHex(v) { - return '#' + v.map(function (c) { - c = clamp(Math.round(c), 255); - return (c < 16 ? '0' : '') + c.toString(16); - }).join(''); -} - -Color.prototype.luma = function () { - var r = this.rgb[0] / 255, - g = this.rgb[1] / 255, - b = this.rgb[2] / 255; - - r = (r <= 0.03928) ? r / 12.92 : Math.pow(((r + 0.055) / 1.055), 2.4); - g = (g <= 0.03928) ? g / 12.92 : Math.pow(((g + 0.055) / 1.055), 2.4); - b = (b <= 0.03928) ? b / 12.92 : Math.pow(((b + 0.055) / 1.055), 2.4); - - return 0.2126 * r + 0.7152 * g + 0.0722 * b; -}; -Color.prototype.genCSS = function (context, output) { - output.add(this.toCSS(context)); -}; -Color.prototype.toCSS = function (context, doNotCompress) { - var compress = context && context.compress && !doNotCompress, color, alpha; - - // `value` is set if this color was originally - // converted from a named color string so we need - // to respect this and try to output named color too. - if (this.value) { - return this.value; - } - - // If we have some transparency, the only way to represent it - // is via `rgba`. Otherwise, we use the hex representation, - // which has better compatibility with older browsers. - // Values are capped between `0` and `255`, rounded and zero-padded. - alpha = this.fround(context, this.alpha); - if (alpha < 1) { - return "rgba(" + this.rgb.map(function (c) { - return clamp(Math.round(c), 255); - }).concat(clamp(alpha, 1)) - .join(',' + (compress ? '' : ' ')) + ")"; - } - - color = this.toRGB(); - - if (compress) { - var splitcolor = color.split(''); - - // Convert color to short format - if (splitcolor[1] === splitcolor[2] && splitcolor[3] === splitcolor[4] && splitcolor[5] === splitcolor[6]) { - color = '#' + splitcolor[1] + splitcolor[3] + splitcolor[5]; - } - } - - return color; -}; - -// -// Operations have to be done per-channel, if not, -// channels will spill onto each other. Once we have -// our result, in the form of an integer triplet, -// we create a new Color node to hold the result. -// -Color.prototype.operate = function (context, op, other) { - var rgb = []; - 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]); - } - return new Color(rgb, alpha); -}; -Color.prototype.toRGB = function () { - return toHex(this.rgb); -}; -Color.prototype.toHSL = function () { - var r = this.rgb[0] / 255, - g = this.rgb[1] / 255, - b = this.rgb[2] / 255, - a = this.alpha; - - var max = Math.max(r, g, b), min = Math.min(r, g, b); - var h, s, l = (max + min) / 2, d = max - min; - - if (max === min) { - h = s = 0; - } else { - s = l > 0.5 ? d / (2 - max - min) : d / (max + min); - - 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; - } - h /= 6; - } - 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 -Color.prototype.toHSV = function () { - var r = this.rgb[0] / 255, - g = this.rgb[1] / 255, - b = this.rgb[2] / 255, - a = this.alpha; - - var max = Math.max(r, g, b), min = Math.min(r, g, b); - var h, s, v = max; - - var d = max - min; - if (max === 0) { - s = 0; - } else { - s = d / max; - } - - if (max === min) { - h = 0; - } else { - 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; - } - h /= 6; - } - return { h: h * 360, s: s, v: v, a: a }; -}; -Color.prototype.toARGB = function () { - return toHex([this.alpha * 255].concat(this.rgb)); -}; -Color.prototype.compare = function (x) { - return (x.rgb && - x.rgb[0] === this.rgb[0] && - x.rgb[1] === this.rgb[1] && - x.rgb[2] === this.rgb[2] && - x.alpha === this.alpha) ? 0 : undefined; -}; - -Color.fromKeyword = function(keyword) { - var c, key = keyword.toLowerCase(); - if (colors.hasOwnProperty(key)) { - c = new Color(colors[key].slice(1)); - } - else if (key === "transparent") { - c = new Color([0, 0, 0], 0); - } - - if (c) { - c.value = keyword; - return c; - } -}; -module.exports = Color; - -},{"../data/colors":12,"./node":70}],51:[function(require,module,exports){ -var Node = require("./node"); - -var Combinator = function (value) { - if (value === ' ') { - this.value = ' '; - this.emptyOrWhitespace = true; - } else { - this.value = value ? value.trim() : ""; - this.emptyOrWhitespace = this.value === ""; - } -}; -Combinator.prototype = new Node(); -Combinator.prototype.type = "Combinator"; -var _noSpaceCombinators = { - '': true, - ' ': true, - '|': true -}; -Combinator.prototype.genCSS = function (context, output) { - var spaceOrEmpty = (context.compress || _noSpaceCombinators[this.value]) ? '' : ' '; - output.add(spaceOrEmpty + this.value + spaceOrEmpty); -}; -module.exports = Combinator; - -},{"./node":70}],52:[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.currentFileInfo = 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(this.value); -}; -Comment.prototype.isSilent = function(context) { - var isCompressed = context.compress && this.value[2] !== "!"; - return this.isLineComment || isCompressed; -}; -module.exports = Comment; - -},{"./debug-info":54,"./node":70}],53:[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.negate = negate; -}; -Condition.prototype = new Node(); -Condition.prototype.type = "Condition"; -Condition.prototype.accept = function (visitor) { - this.lvalue = visitor.visit(this.lvalue); - this.rvalue = visitor.visit(this.rvalue); -}; -Condition.prototype.eval = function (context) { - var result = (function (op, a, b) { - switch (op) { - case 'and': return a && b; - case 'or': return a || b; - default: - switch (Node.compare(a, b)) { - case -1: - return op === '<' || op === '=<' || op === '<='; - case 0: - return op === '=' || op === '>=' || op === '=<' || op === '<='; - case 1: - return op === '>' || op === '>='; - default: - return false; - } - } - })(this.op, this.lvalue.eval(context), this.rvalue.eval(context)); - - return this.negate ? !result : result; -}; -module.exports = Condition; - -},{"./node":70}],54:[function(require,module,exports){ -var debugInfo = function(context, ctx, lineSeparator) { - var result = ""; - if (context.dumpLineNumbers && !context.compress) { - switch(context.dumpLineNumbers) { - case 'comments': - result = debugInfo.asComment(ctx); - break; - case 'mediaquery': - result = debugInfo.asMediaQuery(ctx); - break; - case 'all': - result = debugInfo.asComment(ctx) + (lineSeparator || "") + debugInfo.asMediaQuery(ctx); - break; - } - } - return result; -}; - -debugInfo.asComment = function(ctx) { - return '/* line ' + ctx.debugInfo.lineNumber + ', ' + ctx.debugInfo.fileName + ' */\n'; -}; - -debugInfo.asMediaQuery = function(ctx) { - var filenameWithProtocol = ctx.debugInfo.fileName; - if (!/^[a-z]+:\/\//i.test(filenameWithProtocol)) { - filenameWithProtocol = 'file://' + filenameWithProtocol; - } - return '@media -sass-debug-info{filename{font-family:' + - filenameWithProtocol.replace(/([.:\/\\])/g, function (a) { - if (a == '\\') { - a = '\/'; - } - return '\\' + a; - }) + - '}line{font-family:\\00003' + ctx.debugInfo.lineNumber + '}}\n'; -}; - -module.exports = debugInfo; - -},{}],55:[function(require,module,exports){ -var Node = require("./node"), - contexts = require("../contexts"); - -var DetachedRuleset = function (ruleset, frames) { - this.ruleset = ruleset; - this.frames = frames; -}; -DetachedRuleset.prototype = new Node(); -DetachedRuleset.prototype.type = "DetachedRuleset"; -DetachedRuleset.prototype.evalFirst = true; -DetachedRuleset.prototype.accept = function (visitor) { - this.ruleset = visitor.visit(this.ruleset); -}; -DetachedRuleset.prototype.eval = function (context) { - var frames = this.frames || context.frames.slice(0); - return new DetachedRuleset(this.ruleset, frames); -}; -DetachedRuleset.prototype.callEval = function (context) { - return this.ruleset.eval(this.frames ? new contexts.Eval(context, this.frames.concat(context.frames)) : context); -}; -module.exports = DetachedRuleset; - -},{"../contexts":11,"./node":70}],56:[function(require,module,exports){ -var Node = require("./node"), - unitConversions = require("../data/unit-conversions"), - Unit = require("./unit"), - Color = require("./color"); - -// -// A number with a unit -// -var Dimension = function (value, unit) { - this.value = parseFloat(value); - this.unit = (unit && unit instanceof Unit) ? unit : - new Unit(unit ? [unit] : undefined); -}; - -Dimension.prototype = new Node(); -Dimension.prototype.type = "Dimension"; -Dimension.prototype.accept = function (visitor) { - this.unit = visitor.visit(this.unit); -}; -Dimension.prototype.eval = function (context) { - return this; -}; -Dimension.prototype.toColor = function () { - return new Color([this.value, this.value, this.value]); -}; -Dimension.prototype.genCSS = function (context, output) { - if ((context && context.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 value = this.fround(context, this.value), - strValue = String(value); - - if (value !== 0 && value < 0.000001 && value > -0.000001) { - // would be output 1e-6 etc. - strValue = value.toFixed(20).replace(/0+$/, ""); - } - - if (context && context.compress) { - // Zero values doesn't need a unit - if (value === 0 && this.unit.isLength()) { - output.add(strValue); - return; - } - - // Float values doesn't need a leading zero - if (value > 0 && value < 1) { - strValue = (strValue).substr(1); - } - } - - output.add(strValue); - this.unit.genCSS(context, output); -}; - -// In an operation between two Dimensions, -// we default to the first Dimension's unit, -// so `1px + 2` will yield `3px`. -Dimension.prototype.operate = function (context, op, other) { - /*jshint noempty:false */ - var value = this._operate(context, op, this.value, other.value), - unit = this.unit.clone(); - - if (op === '+' || op === '-') { - if (unit.numerator.length === 0 && unit.denominator.length === 0) { - unit = other.unit.clone(); - if (this.unit.backupUnit) { - unit.backupUnit = this.unit.backupUnit; - } - } else if (other.unit.numerator.length === 0 && unit.denominator.length === 0) { - // do nothing - } else { - other = other.convertTo(this.unit.usedUnits()); - - if (context.strictUnits && other.unit.toString() !== unit.toString()) { - throw new Error("Incompatible units. Change the units or use the unit function. Bad units: '" + unit.toString() + - "' and '" + other.unit.toString() + "'."); - } - - value = this._operate(context, op, this.value, other.value); - } - } else if (op === '*') { - unit.numerator = unit.numerator.concat(other.unit.numerator).sort(); - unit.denominator = unit.denominator.concat(other.unit.denominator).sort(); - unit.cancel(); - } else if (op === '/') { - unit.numerator = unit.numerator.concat(other.unit.denominator).sort(); - unit.denominator = unit.denominator.concat(other.unit.numerator).sort(); - unit.cancel(); - } - return new Dimension(value, unit); -}; -Dimension.prototype.compare = function (other) { - var a, b; - - if (!(other instanceof Dimension)) { - return undefined; - } - - if (this.unit.isEmpty() || other.unit.isEmpty()) { - a = this; - b = other; - } else { - a = this.unify(); - b = other.unify(); - if (a.unit.compare(b.unit) !== 0) { - return undefined; - } - } - - return Node.numericCompare(a.value, b.value); -}; -Dimension.prototype.unify = function () { - return this.convertTo({ length: 'px', duration: 's', angle: 'rad' }); -}; -Dimension.prototype.convertTo = function (conversions) { - var value = this.value, unit = this.unit.clone(), - i, groupName, group, targetUnit, derivedConversions = {}, applyUnit; - - if (typeof conversions === 'string') { - for (i in unitConversions) { - if (unitConversions[i].hasOwnProperty(conversions)) { - derivedConversions = {}; - derivedConversions[i] = conversions; - } - } - conversions = derivedConversions; - } - applyUnit = function (atomicUnit, denominator) { - /* jshint loopfunc:true */ - if (group.hasOwnProperty(atomicUnit)) { - if (denominator) { - value = value / (group[atomicUnit] / group[targetUnit]); - } else { - value = value * (group[atomicUnit] / group[targetUnit]); - } - - return targetUnit; - } - - return atomicUnit; - }; - - for (groupName in conversions) { - if (conversions.hasOwnProperty(groupName)) { - targetUnit = conversions[groupName]; - group = unitConversions[groupName]; - - unit.map(applyUnit); - } - } - - unit.cancel(); - - return new Dimension(value, unit); -}; -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){ -var Node = require("./node"), - Paren = require("./paren"), - Combinator = require("./combinator"); - -var Element = function (combinator, value, index, currentFileInfo, info) { - this.combinator = combinator instanceof Combinator ? - combinator : new Combinator(combinator); - - if (typeof value === 'string') { - this.value = value.trim(); - } else if (value) { - this.value = value; - } else { - this.value = ""; - } - this.index = index; - this.currentFileInfo = currentFileInfo; - this.copyVisibilityInfo(info); -}; -Element.prototype = new Node(); -Element.prototype.type = "Element"; -Element.prototype.accept = function (visitor) { - var value = this.value; - this.combinator = visitor.visit(this.combinator); - if (typeof value === "object") { - this.value = visitor.visit(value); - } -}; -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()); -}; -Element.prototype.clone = function () { - return new Element(this.combinator, - this.value, - this.index, - this.currentFileInfo, this.visibilityInfo()); -}; -Element.prototype.genCSS = function (context, output) { - output.add(this.toCSS(context), this.currentFileInfo, this.index); -}; -Element.prototype.toCSS = function (context) { - context = context || {}; - var value = this.value, firstSelector = context.firstSelector; - if (value instanceof Paren) { - // selector in parens should not be affected by outer selector - // flags (breaks only interpolated selectors - see #1973) - context.firstSelector = true; - } - value = value.toCSS ? value.toCSS(context) : value; - context.firstSelector = firstSelector; - if (value === '' && this.combinator.value.charAt(0) === '&') { - return ''; - } else { - return this.combinator.toCSS(context) + value; - } -}; -module.exports = Element; - -},{"./combinator":51,"./node":70,"./paren":72}],59:[function(require,module,exports){ -var Node = require("./node"), - Paren = require("./paren"), - Comment = require("./comment"); - -var Expression = function (value) { - this.value = value; - if (!value) { - throw new Error("Expression requires an array parameter"); - } -}; -Expression.prototype = new Node(); -Expression.prototype.type = "Expression"; -Expression.prototype.accept = function (visitor) { - this.value = visitor.visitArray(this.value); -}; -Expression.prototype.eval = function (context) { - var returnValue, - inParenthesis = this.parens && !this.parensInOp, - doubleParen = false; - if (inParenthesis) { - context.inParenthesis(); - } - if (this.value.length > 1) { - returnValue = new Expression(this.value.map(function (e) { - return e.eval(context); - })); - } else if (this.value.length === 1) { - if (this.value[0].parens && !this.value[0].parensInOp) { - doubleParen = true; - } - returnValue = this.value[0].eval(context); - } else { - returnValue = this; - } - if (inParenthesis) { - context.outOfParenthesis(); - } - if (this.parens && this.parensInOp && !(context.isMathOn()) && !doubleParen) { - returnValue = new Paren(returnValue); - } - return returnValue; -}; -Expression.prototype.genCSS = function (context, output) { - for (var i = 0; i < this.value.length; i++) { - this.value[i].genCSS(context, output); - if (i + 1 < this.value.length) { - output.add(" "); - } - } -}; -Expression.prototype.throwAwayComments = function () { - this.value = this.value.filter(function(v) { - return !(v instanceof Comment); - }); -}; -module.exports = Expression; - -},{"./comment":52,"./node":70,"./paren":72}],60:[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.copyVisibilityInfo(visibilityInfo); - this.allowRoot = true; - - switch(option) { - case "all": - this.allowBefore = true; - this.allowAfter = true; - break; - default: - this.allowBefore = false; - this.allowAfter = false; - break; - } -}; -Extend.next_id = 0; - -Extend.prototype = new Node(); -Extend.prototype.type = "Extend"; -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()); -}; -Extend.prototype.clone = function (context) { - return new Extend(this.selector, this.option, this.index, this.currentFileInfo, this.visibilityInfo()); -}; -//it concatenates (joins) all selectors in selector array -Extend.prototype.findSelfSelectors = function (selectors) { - var selfElements = [], - i, - selectorElements; - - for (i = 0; i < selectors.length; i++) { - selectorElements = selectors[i].elements; - // duplicate the logic in genCSS function inside the selector node. - // future TODO - move both logics into the selector joiner visitor - if (i > 0 && selectorElements.length && selectorElements[0].combinator.value === "") { - selectorElements[0].combinator.value = ' '; - } - selfElements = selfElements.concat(selectors[i].elements); - } - - this.selfSelectors = [new Selector(selfElements)]; - this.selfSelectors[0].copyVisibilityInfo(this.visibilityInfo()); -}; -module.exports = Extend; - -},{"./node":70,"./selector":77}],61:[function(require,module,exports){ -var Node = require("./node"), - Media = require("./media"), - URL = require("./url"), - Quoted = require("./quoted"), - Ruleset = require("./ruleset"), - Anonymous = require("./anonymous"); - -// -// CSS @import node -// -// The general strategy here is that we don't want to wait -// for the parsing to be completed, before we start importing -// the file. That's because in the context of a browser, -// most of the time will be spent waiting for the server to respond. -// -// On creation, we push the import path to our import queue, though -// `import,push`, we also pass it a callback, which it'll call once -// the file has been fetched, and parsed. -// -var Import = function (path, features, options, index, currentFileInfo, visibilityInfo) { - this.options = options; - this.index = index; - 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)) { - this.css = true; - } - } - this.copyVisibilityInfo(visibilityInfo); -}; - -// -// The actual import node doesn't return anything, when converted to CSS. -// The reason is that it's used at the evaluation stage, so that the rules -// it imports can be treated like any other rules. -// -// In `eval`, we make sure all Import nodes get evaluated, recursively, so -// we end up with a flat structure, which can easily be imported in the parent -// ruleset. -// -Import.prototype = new Node(); -Import.prototype.type = "Import"; -Import.prototype.accept = function (visitor) { - if (this.features) { - this.features = visitor.visit(this.features); - } - this.path = visitor.visit(this.path); - if (!this.options.plugin && !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); - this.path.genCSS(context, output); - if (this.features) { - output.add(" "); - this.features.genCSS(context, output); - } - output.add(';'); - } -}; -Import.prototype.getPath = function () { - return (this.path instanceof URL) ? - this.path.value.value : this.path.value; -}; -Import.prototype.isVariableImport = function () { - var path = this.path; - if (path instanceof URL) { - path = path.value; - } - if (path instanceof Quoted) { - return path.containsVariables(); - } - - return true; -}; -Import.prototype.evalForImport = function (context) { - var path = this.path; - - if (path instanceof URL) { - path = path.value; - } - - return new Import(path.eval(context), this.features, this.options, this.index, this.currentFileInfo, this.visibilityInfo()); -}; -Import.prototype.evalPath = function (context) { - var path = this.path.eval(context); - var rootpath = this.currentFileInfo && this.currentFileInfo.rootpath; - - if (!(path instanceof URL)) { - if (rootpath) { - var pathValue = path.value; - // Add the base path if the import is relative - if (pathValue && context.isPathRelative(pathValue)) { - path.value = rootpath + pathValue; - } - } - path.value = context.normalizePath(path.value); - } - - return path; -}; -Import.prototype.eval = function (context) { - var result = this.doEval(context); - if (this.options.reference || this.blocksVisibility()) { - if (result.length || result.length === 0) { - result.forEach(function (node) { - node.addVisibilityBlock(); - } - ); - } else { - result.addVisibilityBlock(); - } - } - return result; -}; -Import.prototype.doEval = function (context) { - var ruleset, registry, - features = this.features && this.features.eval(context); - - if (this.options.plugin) { - registry = context.frames[0] && context.frames[0].functionRegistry; - if ( registry && this.root && this.root.functions ) { - registry.addMultiple( this.root.functions ); - } - return []; - } - - if (this.skip) { - if (typeof this.skip === "function") { - this.skip = this.skip(); - } - if (this.skip) { - return []; - } - } - if (this.options.inline) { - var contents = new Anonymous(this.root, 0, - { - filename: this.importedFilename, - reference: this.path.currentFileInfo && this.path.currentFileInfo.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); - if (!newImport.css && this.error) { - throw this.error; - } - return newImport; - } else { - ruleset = new Ruleset(null, this.root.rules.slice(0)); - ruleset.evalImports(context); - - return this.features ? new Media(ruleset.rules, this.features.value) : ruleset.rules; - } -}; -module.exports = Import; - -},{"./anonymous":46,"./media":66,"./node":70,"./quoted":73,"./ruleset":76,"./url":80}],62:[function(require,module,exports){ -var tree = {}; - -tree.Node = require('./node'); -tree.Alpha = require('./alpha'); -tree.Color = require('./color'); -tree.Directive = require('./directive'); -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.Ruleset = require('./ruleset'); -tree.Element = require('./element'); -tree.Attribute = require('./attribute'); -tree.Combinator = require('./combinator'); -tree.Selector = require('./selector'); -tree.Quoted = require('./quoted'); -tree.Expression = require('./expression'); -tree.Rule = require('./rule'); -tree.Call = require('./call'); -tree.URL = require('./url'); -tree.Import = require('./import'); -tree.mixin = { - Call: require('./mixin-call'), - Definition: require('./mixin-definition') -}; -tree.Comment = require('./comment'); -tree.Anonymous = require('./anonymous'); -tree.Value = require('./value'); -tree.JavaScript = require('./javascript'); -tree.Assignment = require('./assignment'); -tree.Condition = require('./condition'); -tree.Paren = require('./paren'); -tree.Media = require('./media'); -tree.UnicodeDescriptor = require('./unicode-descriptor'); -tree.Negative = require('./negative'); -tree.Extend = require('./extend'); -tree.RulesetCall = require('./ruleset-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){ -var JsEvalNode = require("./js-eval-node"), - Dimension = require("./dimension"), - Quoted = require("./quoted"), - Anonymous = require("./anonymous"); - -var JavaScript = function (string, escaped, index, currentFileInfo) { - this.escaped = escaped; - this.expression = string; - this.index = index; - this.currentFileInfo = currentFileInfo; -}; -JavaScript.prototype = new JsEvalNode(); -JavaScript.prototype.type = "JavaScript"; -JavaScript.prototype.eval = function(context) { - var result = this.evaluateJavaScript(this.expression, context); - - if (typeof result === 'number') { - return new Dimension(result); - } else if (typeof result === 'string') { - return new Quoted('"' + result + '"', result, this.escaped, this.index); - } else if (Array.isArray(result)) { - return new Anonymous(result.join(', ')); - } else { - return new Anonymous(result); - } -}; - -module.exports = JavaScript; - -},{"./anonymous":46,"./dimension":56,"./js-eval-node":64,"./quoted":73}],64:[function(require,module,exports){ -var Node = require("./node"), - Variable = require("./variable"); - -var JsEvalNode = function() { -}; -JsEvalNode.prototype = new Node(); - -JsEvalNode.prototype.evaluateJavaScript = function (expression, context) { - var result, - 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 }; - } - - expression = expression.replace(/@\{([\w-]+)\}/g, function (_, name) { - return that.jsify(new Variable('@' + name, that.index, that.currentFileInfo).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 }; - } - - var variables = context.frames[0].variables(); - for (var k in variables) { - if (variables.hasOwnProperty(k)) { - /*jshint loopfunc:true */ - evalContext[k.slice(1)] = { - value: variables[k].value, - toJS: function () { - return this.value.eval(context).toCSS(); - } - }; - } - } - - try { - result = expression.call(evalContext); - } catch (e) { - throw { message: "JavaScript evaluation error: '" + e.name + ': ' + e.message.replace(/["]/g, "'") + "'" , - filename: this.currentFileInfo.filename, - index: this.index }; - } - return result; -}; -JsEvalNode.prototype.jsify = function (obj) { - if (Array.isArray(obj.value) && (obj.value.length > 1)) { - return '[' + obj.value.map(function (v) { return v.toCSS(); }).join(', ') + ']'; - } else { - return obj.toCSS(); - } -}; - -module.exports = JsEvalNode; - -},{"./node":70,"./variable":82}],65:[function(require,module,exports){ -var Node = require("./node"); - -var Keyword = function (value) { this.value = value; }; -Keyword.prototype = new Node(); -Keyword.prototype.type = "Keyword"; -Keyword.prototype.genCSS = function (context, output) { - if (this.value === '%') { throw { type: "Syntax", message: "Invalid % without number" }; } - output.add(this.value); -}; - -Keyword.True = new Keyword('true'); -Keyword.False = new Keyword('false'); - -module.exports = Keyword; - -},{"./node":70}],66:[function(require,module,exports){ -var Ruleset = require("./ruleset"), - Value = require("./value"), - Selector = require("./selector"), - Anonymous = require("./anonymous"), - Expression = require("./expression"), - Directive = require("./directive"); - -var Media = function (value, features, index, currentFileInfo, visibilityInfo) { - this.index = index; - this.currentFileInfo = currentFileInfo; - - var selectors = (new Selector([], null, null, this.index, this.currentFileInfo)).createEmptySelectors(); - - this.features = new Value(features); - this.rules = [new Ruleset(selectors, value)]; - this.rules[0].allowImports = true; - this.copyVisibilityInfo(visibilityInfo); - this.allowRoot = true; -}; -Media.prototype = new Directive(); -Media.prototype.type = "Media"; -Media.prototype.isRulesetLike = true; -Media.prototype.accept = function (visitor) { - if (this.features) { - this.features = visitor.visit(this.features); - } - if (this.rules) { - this.rules = visitor.visitArray(this.rules); - } -}; -Media.prototype.genCSS = function (context, output) { - output.add('@media ', this.currentFileInfo, this.index); - this.features.genCSS(context, output); - this.outputRuleset(context, output, this.rules); -}; -Media.prototype.eval = function (context) { - if (!context.mediaBlocks) { - context.mediaBlocks = []; - context.mediaPath = []; - } - - var media = new Media(null, [], this.index, this.currentFileInfo, 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; - } - } - - context.mediaPath.push(media); - context.mediaBlocks.push(media); - - this.rules[0].functionRegistry = context.frames[0].functionRegistry.inherit(); - context.frames.unshift(this.rules[0]); - media.rules = [this.rules[0].eval(context)]; - context.frames.shift(); - - context.mediaPath.pop(); - - return context.mediaPath.length === 0 ? media.evalTop(context) : - media.evalNested(context); -}; -Media.prototype.evalTop = function (context) { - var result = this; - - // Render all dependent Media blocks. - if (context.mediaBlocks.length > 1) { - var selectors = (new Selector([], null, null, this.index, this.currentFileInfo)).createEmptySelectors(); - result = new Ruleset(selectors, context.mediaBlocks); - result.multiMedia = true; - result.copyVisibilityInfo(this.visibilityInfo()); - } - - delete context.mediaBlocks; - delete context.mediaPath; - - return result; -}; -Media.prototype.evalNested = function (context) { - var i, value, - path = context.mediaPath.concat([this]); - - // Extract the media-query conditions separated with `,` (OR). - for (i = 0; i < path.length; i++) { - value = path[i].features instanceof Value ? - path[i].features.value : path[i].features; - path[i] = Array.isArray(value) ? value : [value]; - } - - // Trace all permutations to generate the resulting media-query. - // - // (a, b and c) with nested (d, e) -> - // a and d - // a and e - // b and c and d - // b and c and e - this.features = new Value(this.permute(path).map(function (path) { - path = path.map(function (fragment) { - return fragment.toCSS ? fragment : new Anonymous(fragment); - }); - - for (i = path.length - 1; i > 0; i--) { - path.splice(i, 0, new Anonymous("and")); - } - - return new Expression(path); - })); - - // Fake a tree-node that doesn't output anything. - return new Ruleset([], []); -}; -Media.prototype.permute = function (arr) { - if (arr.length === 0) { - return []; - } else if (arr.length === 1) { - return arr[0]; - } else { - var result = []; - var rest = this.permute(arr.slice(1)); - for (var i = 0; i < rest.length; i++) { - for (var j = 0; j < arr[0].length; j++) { - result.push([arr[0][j]].concat(rest[i])); - } - } - return result; - } -}; -Media.prototype.bubbleSelectors = function (selectors) { - if (!selectors) { - return; - } - this.rules = [new Ruleset(selectors.slice(0), [this.rules[0]])]; -}; -module.exports = Media; - -},{"./anonymous":46,"./directive":57,"./expression":59,"./ruleset":76,"./selector":77,"./value":81}],67:[function(require,module,exports){ -var Node = require("./node"), - Selector = require("./selector"), - MixinDefinition = require("./mixin-definition"), - defaultFunc = require("../functions/default"); - -var MixinCall = function (elements, args, index, currentFileInfo, important) { - this.selector = new Selector(elements); - this.arguments = args || []; - this.index = index; - this.currentFileInfo = currentFileInfo; - this.important = important; - this.allowRoot = true; -}; -MixinCall.prototype = new Node(); -MixinCall.prototype.type = "MixinCall"; -MixinCall.prototype.accept = function (visitor) { - if (this.selector) { - this.selector = visitor.visit(this.selector); - } - if (this.arguments.length) { - this.arguments = visitor.visitArray(this.arguments); - } -}; -MixinCall.prototype.eval = function (context) { - var mixins, mixin, mixinPath, args = [], arg, argValue, - rules = [], match = false, i, m, f, isRecursive, isOneFound, - candidates = [], candidate, conditionResult = [], defaultResult, defFalseEitherCase = -1, - defNone = 0, defTrue = 1, defFalse = 2, count, originalRuleset, noArgumentsFilter; - - function calcDefGroup(mixin, mixinPath) { - var f, p, namespace; - - for (f = 0; f < 2; f++) { - conditionResult[f] = true; - defaultFunc.value(f); - for (p = 0; p < mixinPath.length && conditionResult[f]; p++) { - namespace = mixinPath[p]; - if (namespace.matchCondition) { - conditionResult[f] = conditionResult[f] && namespace.matchCondition(null, context); - } - } - if (mixin.matchCondition) { - conditionResult[f] = conditionResult[f] && mixin.matchCondition(args, context); - } - } - if (conditionResult[0] || conditionResult[1]) { - if (conditionResult[0] != conditionResult[1]) { - return conditionResult[1] ? - defTrue : defFalse; - } - - return defNone; - } - return defFalseEitherCase; - } - - for (i = 0; i < this.arguments.length; i++) { - arg = this.arguments[i]; - argValue = arg.value.eval(context); - if (arg.expand && Array.isArray(argValue.value)) { - argValue = argValue.value; - for (m = 0; m < argValue.length; m++) { - args.push({value: argValue[m]}); - } - } else { - args.push({name: arg.name, value: argValue}); - } - } - - noArgumentsFilter = function(rule) {return rule.matchArgs(null, context);}; - - for (i = 0; i < context.frames.length; i++) { - if ((mixins = context.frames[i].find(this.selector, null, noArgumentsFilter)).length > 0) { - isOneFound = true; - - // To make `default()` function independent of definition order we have two "subpasses" here. - // At first we evaluate each guard *twice* (with `default() == true` and `default() == false`), - // and build candidate list with corresponding flags. Then, when we know all possible matches, - // we make a final decision. - - for (m = 0; m < mixins.length; m++) { - mixin = mixins[m].rule; - mixinPath = mixins[m].path; - isRecursive = false; - for (f = 0; f < context.frames.length; f++) { - if ((!(mixin instanceof MixinDefinition)) && mixin === (context.frames[f].originalRuleset || context.frames[f])) { - isRecursive = true; - break; - } - } - if (isRecursive) { - continue; - } - - if (mixin.matchArgs(args, context)) { - candidate = {mixin: mixin, group: calcDefGroup(mixin, mixinPath)}; - - if (candidate.group !== defFalseEitherCase) { - candidates.push(candidate); - } - - match = true; - } - } - - defaultFunc.reset(); - - count = [0, 0, 0]; - for (m = 0; m < candidates.length; m++) { - count[candidates[m].group]++; - } - - if (count[defNone] > 0) { - defaultResult = defFalse; - } else { - defaultResult = defTrue; - 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 }; - } - } - - for (m = 0; m < candidates.length; m++) { - candidate = candidates[m].group; - if ((candidate === defNone) || (candidate === defaultResult)) { - try { - mixin = candidates[m].mixin; - if (!(mixin instanceof MixinDefinition)) { - originalRuleset = mixin.originalRuleset || mixin; - mixin = new MixinDefinition("", [], mixin.rules, null, false, null, originalRuleset.visibilityInfo()); - mixin.originalRuleset = originalRuleset; - } - var newRules = mixin.evalCall(context, args, this.important).rules; - 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 }; - } - } - } - - if (match) { - return rules; - } - } - } - if (isOneFound) { - throw { type: 'Runtime', - message: 'No matching definition was found for `' + this.format(args) + '`', - index: this.index, filename: this.currentFileInfo.filename }; - } else { - throw { type: 'Name', - message: this.selector.toCSS().trim() + " is undefined", - index: this.index, filename: this.currentFileInfo.filename }; - } -}; - -MixinCall.prototype._setVisibilityToReplacement = function (replacement) { - var i, rule; - if (this.blocksVisibility()) { - for (i = 0; i < replacement.length; i++) { - rule = replacement[i]; - rule.addVisibilityBlock(); - } - } -}; -MixinCall.prototype.format = function (args) { - return this.selector.toCSS().trim() + '(' + - (args ? args.map(function (a) { - var argValue = ""; - if (a.name) { - argValue += a.name + ":"; - } - if (a.value.toCSS) { - argValue += a.value.toCSS(); - } else { - argValue += "???"; - } - return argValue; - }).join(', ') : "") + ")"; -}; -module.exports = MixinCall; - -},{"../functions/default":20,"./mixin-definition":68,"./node":70,"./selector":77}],68:[function(require,module,exports){ -var Selector = require("./selector"), - Element = require("./element"), - Ruleset = require("./ruleset"), - Rule = require("./rule"), - Expression = require("./expression"), - contexts = require("../contexts"); - -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.params = params; - this.condition = condition; - this.variadic = variadic; - this.arity = params.length; - this.rules = rules; - this._lookups = {}; - var optionalParameters = []; - this.required = params.reduce(function (count, p) { - if (!p.name || (p.name && !p.value)) { - return count + 1; - } - else { - optionalParameters.push(p.name); - return count; - } - }, 0); - this.optionalParameters = optionalParameters; - this.frames = frames; - this.copyVisibilityInfo(visibilityInfo); - this.allowRoot = true; -}; -Definition.prototype = new Ruleset(); -Definition.prototype.type = "MixinDefinition"; -Definition.prototype.evalFirst = true; -Definition.prototype.accept = function (visitor) { - if (this.params && this.params.length) { - this.params = visitor.visitArray(this.params); - } - this.rules = visitor.visitArray(this.rules); - if (this.condition) { - this.condition = visitor.visit(this.condition); - } -}; -Definition.prototype.evalParams = function (context, mixinEnv, args, evaldArguments) { - /*jshint boss:true */ - var frame = new Ruleset(null, null), - varargs, arg, - params = this.params.slice(0), - i, j, val, name, isNamedFound, argIndex, argsLength = 0; - - if (mixinEnv.frames && mixinEnv.frames[0] && mixinEnv.frames[0].functionRegistry) { - frame.functionRegistry = mixinEnv.frames[0].functionRegistry.inherit(); - } - mixinEnv = new contexts.Eval(mixinEnv, [frame].concat(mixinEnv.frames)); - - if (args) { - args = args.slice(0); - argsLength = args.length; - - for (i = 0; i < argsLength; i++) { - arg = args[i]; - if (name = (arg && arg.name)) { - isNamedFound = false; - 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))); - isNamedFound = true; - break; - } - } - if (isNamedFound) { - args.splice(i, 1); - i--; - continue; - } else { - throw { type: 'Runtime', message: "Named argument for " + this.name + - ' ' + args[i].name + ' not found' }; - } - } - } - } - argIndex = 0; - for (i = 0; i < params.length; i++) { - if (evaldArguments[i]) { continue; } - - arg = args && args[argIndex]; - - if (name = params[i].name) { - if (params[i].variadic) { - varargs = []; - for (j = argIndex; j < argsLength; j++) { - varargs.push(args[j].value.eval(context)); - } - frame.prependRule(new Rule(name, new Expression(varargs).eval(context))); - } else { - val = arg && arg.value; - if (val) { - val = val.eval(context); - } else if (params[i].value) { - val = params[i].value.eval(mixinEnv); - frame.resetCache(); - } else { - throw { type: 'Runtime', message: "wrong number of arguments for " + this.name + - ' (' + argsLength + ' for ' + this.arity + ')' }; - } - - frame.prependRule(new Rule(name, val)); - evaldArguments[i] = val; - } - } - - if (params[i].variadic && args) { - for (j = argIndex; j < argsLength; j++) { - evaldArguments[j] = args[j].value.eval(context); - } - } - argIndex++; - } - - return frame; -}; -Definition.prototype.makeImportant = function() { - var rules = !this.rules ? this.rules : this.rules.map(function (r) { - if (r.makeImportant) { - return r.makeImportant(true); - } else { - return r; - } - }); - var result = new Definition(this.name, this.params, rules, this.condition, this.variadic, this.frames); - 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)); -}; -Definition.prototype.evalCall = function (context, args, important) { - var _arguments = [], - mixinFrames = this.frames ? this.frames.concat(context.frames) : context.frames, - frame = this.evalParams(context, new contexts.Eval(context, mixinFrames), args, _arguments), - rules, ruleset; - - frame.prependRule(new Rule('@arguments', new Expression(_arguments).eval(context))); - - rules = this.rules.slice(0); - - ruleset = new Ruleset(null, rules); - ruleset.originalRuleset = this; - ruleset = ruleset.eval(new contexts.Eval(context, [this, frame].concat(mixinFrames))); - if (important) { - ruleset = ruleset.makeImportant(); - } - return ruleset; -}; -Definition.prototype.matchCondition = function (args, context) { - if (this.condition && !this.condition.eval( - new contexts.Eval(context, - [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 - return false; - } - return true; -}; -Definition.prototype.matchArgs = function (args, context) { - var allArgsCnt = (args && args.length) || 0, len, optionalParameters = this.optionalParameters; - var requiredArgsCnt = !args ? 0 : args.reduce(function (count, p) { - if (optionalParameters.indexOf(p.name) < 0) { - return count + 1; - } else { - return count; - } - }, 0); - - if (! this.variadic) { - if (requiredArgsCnt < this.required) { - return false; - } - if (allArgsCnt > this.params.length) { - return false; - } - } else { - if (requiredArgsCnt < (this.required - 1)) { - return false; - } - } - - // check patterns - len = Math.min(requiredArgsCnt, this.arity); - - for (var i = 0; i < len; i++) { - if (!this.params[i].name && !this.params[i].variadic) { - if (args[i].value.eval(context).toCSS() != this.params[i].value.eval(context).toCSS()) { - return false; - } - } - } - return true; -}; -module.exports = Definition; - -},{"../contexts":11,"./element":58,"./expression":59,"./rule":74,"./ruleset":76,"./selector":77}],69:[function(require,module,exports){ -var Node = require("./node"), - Operation = require("./operation"), - Dimension = require("./dimension"); - -var Negative = function (node) { - this.value = node; -}; -Negative.prototype = new Node(); -Negative.prototype.type = "Negative"; -Negative.prototype.genCSS = function (context, output) { - output.add('-'); - this.value.genCSS(context, output); -}; -Negative.prototype.eval = function (context) { - if (context.isMathOn()) { - return (new Operation('*', [new Dimension(-1), this.value])).eval(context); - } - return new Negative(this.value.eval(context)); -}; -module.exports = Negative; - -},{"./dimension":56,"./node":70,"./operation":71}],70:[function(require,module,exports){ -var Node = function() { -}; -Node.prototype.toCSS = function (context) { - var strs = []; - this.genCSS(context, { - add: function(chunk, fileInfo, index) { - strs.push(chunk); - }, - isEmpty: function () { - return strs.length === 0; - } - }); - return strs.join(''); -}; -Node.prototype.genCSS = function (context, output) { - output.add(this.value); -}; -Node.prototype.accept = function (visitor) { - this.value = visitor.visit(this.value); -}; -Node.prototype.eval = function () { return this; }; -Node.prototype._operate = function (context, op, a, b) { - switch (op) { - case '+': return a + b; - case '-': return a - b; - case '*': return a * b; - case '/': return 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)); -}; -Node.compare = function (a, b) { - /* returns: - -1: a < b - 0: a = b - 1: a > b - and *any* other value for a != b (e.g. undefined, NaN, -2 etc.) */ - - if ((a.compare) && - // for "symmetric results" force toCSS-based comparison - // of Quoted or Anonymous if either value is one of those - !(b.type === "Quoted" || b.type === "Anonymous")) { - return a.compare(b); - } else if (b.compare) { - return -b.compare(a); - } else if (a.type !== b.type) { - return undefined; - } - - a = a.value; - b = b.value; - if (!Array.isArray(a)) { - return a === b ? 0 : undefined; - } - if (a.length !== b.length) { - return undefined; - } - for (var i = 0; i < a.length; i++) { - if (Node.compare(a[i], b[i]) !== 0) { - return undefined; - } - } - return 0; -}; - -Node.numericCompare = function (a, b) { - return a < b ? -1 - : a === b ? 0 - : a > b ? 1 : undefined; -}; -// Returns true if this node represents root of ast imported by reference -Node.prototype.blocksVisibility = function () { - if (this.visibilityBlocks == null) { - this.visibilityBlocks = 0; - } - return this.visibilityBlocks !== 0; -}; -Node.prototype.addVisibilityBlock = function () { - if (this.visibilityBlocks == null) { - this.visibilityBlocks = 0; - } - this.visibilityBlocks = this.visibilityBlocks + 1; -}; -Node.prototype.removeVisibilityBlock = function () { - if (this.visibilityBlocks == null) { - this.visibilityBlocks = 0; - } - 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 -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 -Node.prototype.ensureInvisibility = function () { - this.nodeVisible = false; -}; -// return values: -// false - the node must not be visible -// true - the node must be visible -// undefined or null - the node has the same visibility as its parent -Node.prototype.isVisible = function () { - return this.nodeVisible; -}; -Node.prototype.visibilityInfo = function() { - return { - visibilityBlocks: this.visibilityBlocks, - nodeVisible: this.nodeVisible - }; -}; -Node.prototype.copyVisibilityInfo = function(info) { - if (!info) { - return; - } - this.visibilityBlocks = info.visibilityBlocks; - this.nodeVisible = info.nodeVisible; -}; -module.exports = Node; - -},{}],71:[function(require,module,exports){ -var Node = require("./node"), - Color = require("./color"), - Dimension = require("./dimension"); - -var Operation = function (op, operands, isSpaced) { - this.op = op.trim(); - this.operands = operands; - this.isSpaced = isSpaced; -}; -Operation.prototype = new Node(); -Operation.prototype.type = "Operation"; -Operation.prototype.accept = function (visitor) { - this.operands = visitor.visit(this.operands); -}; -Operation.prototype.eval = function (context) { - var a = this.operands[0].eval(context), - b = this.operands[1].eval(context); - - if (context.isMathOn()) { - if (a instanceof Dimension && b instanceof Color) { - a = a.toColor(); - } - if (b instanceof Dimension && a instanceof Color) { - b = b.toColor(); - } - if (!a.operate) { - throw { type: "Operation", - message: "Operation on an invalid type" }; - } - - return a.operate(context, this.op, b); - } else { - return new Operation(this.op, [a, b], this.isSpaced); - } -}; -Operation.prototype.genCSS = function (context, output) { - this.operands[0].genCSS(context, output); - if (this.isSpaced) { - output.add(" "); - } - output.add(this.op); - if (this.isSpaced) { - output.add(" "); - } - this.operands[1].genCSS(context, output); -}; - -module.exports = Operation; - -},{"./color":50,"./dimension":56,"./node":70}],72:[function(require,module,exports){ -var Node = require("./node"); - -var Paren = function (node) { - this.value = node; -}; -Paren.prototype = new Node(); -Paren.prototype.type = "Paren"; -Paren.prototype.genCSS = function (context, output) { - output.add('('); - this.value.genCSS(context, output); - output.add(')'); -}; -Paren.prototype.eval = function (context) { - return new Paren(this.value.eval(context)); -}; -module.exports = Paren; - -},{"./node":70}],73:[function(require,module,exports){ -var Node = require("./node"), - JsEvalNode = require("./js-eval-node"), - Variable = require("./variable"); - -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; -}; -Quoted.prototype = new JsEvalNode(); -Quoted.prototype.type = "Quoted"; -Quoted.prototype.genCSS = function (context, output) { - if (!this.escaped) { - output.add(this.quote, this.currentFileInfo, this.index); - } - output.add(this.value); - if (!this.escaped) { - output.add(this.quote); - } -}; -Quoted.prototype.containsVariables = function() { - 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 interpolationReplacement = function (_, name) { - var v = new Variable('@' + name, that.index, that.currentFileInfo).eval(context, true); - return (v instanceof Quoted) ? v.value : v.toCSS(); - }; - function iterativeReplace(value, regexp, replacementFnc) { - var evaluatedValue = value; - do { - value = evaluatedValue; - evaluatedValue = value.replace(regexp, replacementFnc); - } 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); -}; -Quoted.prototype.compare = function (other) { - // when comparing quoted strings allow the quote to differ - if (other.type === "Quoted" && !this.escaped && !other.escaped) { - return Node.numericCompare(this.value, other.value); - } else { - return other.toCSS && this.toCSS() === other.toCSS() ? 0 : undefined; - } -}; -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){ -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"), - Selector = require("./selector"), - Element = require("./element"), - Paren = require("./paren"), - contexts = require("../contexts"), - globalFunctionRegistry = require("../functions/function-registry"), - defaultFunc = require("../functions/default"), - getDebugInfo = require("./debug-info"); - -var Ruleset = function (selectors, rules, strictImports, visibilityInfo) { - this.selectors = selectors; - this.rules = rules; - this._lookups = {}; - this.strictImports = strictImports; - this.copyVisibilityInfo(visibilityInfo); - this.allowRoot = true; -}; -Ruleset.prototype = new Node(); -Ruleset.prototype.type = "Ruleset"; -Ruleset.prototype.isRuleset = true; -Ruleset.prototype.isRulesetLike = true; -Ruleset.prototype.accept = function (visitor) { - if (this.paths) { - this.paths = visitor.visitArray(this.paths, true); - } else if (this.selectors) { - this.selectors = visitor.visitArray(this.selectors); - } - if (this.rules && this.rules.length) { - this.rules = visitor.visitArray(this.rules); - } -}; -Ruleset.prototype.eval = function (context) { - var thisSelectors = this.selectors, selectors, - selCnt, selector, i, hasOnePassingSelector = false; - - if (thisSelectors && (selCnt = thisSelectors.length)) { - selectors = []; - 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); - if (selector.evaldCondition) { - hasOnePassingSelector = true; - } - } - defaultFunc.reset(); - } else { - hasOnePassingSelector = true; - } - - var rules = this.rules ? this.rules.slice(0) : null, - ruleset = new Ruleset(selectors, rules, this.strictImports, this.visibilityInfo()), - rule, subRule; - - ruleset.originalRuleset = this; - ruleset.root = this.root; - ruleset.firstRoot = this.firstRoot; - ruleset.allowImports = this.allowImports; - - if (this.debugInfo) { - ruleset.debugInfo = this.debugInfo; - } - - if (!hasOnePassingSelector) { - rules.length = 0; - } - - // inherit a function registry from the frames stack when possible; - // otherwise from the global registry - ruleset.functionRegistry = (function (frames) { - var i = 0, - n = frames.length, - found; - for ( ; i !== n ; ++i ) { - found = frames[ i ].functionRegistry; - if ( found ) { return found; } - } - return globalFunctionRegistry; - }(context.frames)).inherit(); - - // push the current ruleset to the frames stack - var ctxFrames = context.frames; - ctxFrames.unshift(ruleset); - - // currrent selectors - var ctxSelectors = context.selectors; - if (!ctxSelectors) { - context.selectors = ctxSelectors = []; - } - ctxSelectors.unshift(this.selectors); - - // Evaluate imports - if (ruleset.root || ruleset.allowImports || !ruleset.strictImports) { - ruleset.evalImports(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 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) { - // 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 - return !(ruleset.variable(r.name)); - } - 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) { - // 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]; - 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 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); - } - } - } - } - } - - // Pop the stack - ctxFrames.shift(); - ctxSelectors.shift(); - - if (context.mediaBlocks) { - for (i = mediaBlockCount; i < context.mediaBlocks.length; i++) { - context.mediaBlocks[i].bubbleSelectors(selectors); - } - } - - return ruleset; -}; -Ruleset.prototype.evalImports = function(context) { - var rules = this.rules, i, importRules; - if (!rules) { return; } - - for (i = 0; i < rules.length; i++) { - if (rules[i].type === "Import") { - importRules = rules[i].eval(context); - if (importRules && (importRules.length || importRules.length === 0)) { - rules.splice.apply(rules, [i, 1].concat(importRules)); - i+= importRules.length - 1; - } else { - rules.splice(i, 1, importRules); - } - this.resetCache(); - } - } -}; -Ruleset.prototype.makeImportant = function() { - var result = new Ruleset(this.selectors, this.rules.map(function (r) { - if (r.makeImportant) { - return r.makeImportant(); - } else { - return r; - } - }), this.strictImports, this.visibilityInfo()); - - return result; -}; -Ruleset.prototype.matchArgs = function (args) { - return !args || args.length === 0; -}; -// lets you call a css selector with a guard -Ruleset.prototype.matchCondition = function (args, context) { - var lastSelector = this.selectors[this.selectors.length - 1]; - if (!lastSelector.evaldCondition) { - return false; - } - if (lastSelector.condition && - !lastSelector.condition.eval( - new contexts.Eval(context, - context.frames))) { - return false; - } - return true; -}; -Ruleset.prototype.resetCache = function () { - this._rulesets = null; - this._variables = 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) { - hash[r.name] = r; - } - // when evaluating variables in an import statement, imports have not been eval'd - // so we need to go inside import statements. - // guard against root being a string (in the case of inlined less) - if (r.type === "Import" && r.root && r.root.variables) { - var vars = r.root.variables(); - for (var name in vars) { - if (vars.hasOwnProperty(name)) { - hash[name] = vars[name]; - } - } - } - return hash; - }, {}); - } - return this._variables; -}; -Ruleset.prototype.variable = function (name) { - return this.variables()[name]; -}; -Ruleset.prototype.rulesets = function () { - if (!this.rules) { return []; } - - var filtRules = [], rules = this.rules, cnt = rules.length, - i, rule; - - for (i = 0; i < cnt; i++) { - rule = rules[i]; - if (rule.isRuleset) { - filtRules.push(rule); - } - } - - return filtRules; -}; -Ruleset.prototype.prependRule = function (rule) { - var rules = this.rules; - if (rules) { - rules.unshift(rule); - } else { - this.rules = [ rule ]; - } -}; -Ruleset.prototype.find = function (selector, self, filter) { - self = self || this; - var rules = [], match, foundMixins, - key = selector.toCSS(); - - if (key in this._lookups) { return this._lookups[key]; } - - this.rulesets().forEach(function (rule) { - if (rule !== self) { - for (var j = 0; j < rule.selectors.length; j++) { - match = selector.match(rule.selectors[j]); - if (match) { - if (selector.elements.length > match) { - if (!filter || filter(rule)) { - foundMixins = rule.find(new Selector(selector.elements.slice(match)), self, filter); - for (var i = 0; i < foundMixins.length; ++i) { - foundMixins[i].path.push(rule); - } - Array.prototype.push.apply(rules, foundMixins); - } - } else { - rules.push({ rule: rule, path: []}); - } - break; - } - } - } - }); - this._lookups[key] = rules; - return rules; -}; -Ruleset.prototype.genCSS = function (context, output) { - var i, j, - charsetRuleNodes = [], - ruleNodes = [], - debugInfo, // Line number debugging - rule, - path; - - context.tabLevel = (context.tabLevel || 0); - - if (!this.root) { - context.tabLevel++; - } - - var tabRuleStr = context.compress ? '' : Array(context.tabLevel + 1).join(" "), - 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") { - if (importNodeIndex === i) { - importNodeIndex++; - } - ruleNodes.push(rule); - } else if (rule.isCharset && rule.isCharset()) { - ruleNodes.splice(charsetNodeIndex, 0, rule); - charsetNodeIndex++; - importNodeIndex++; - } else if (rule.type === "Import") { - ruleNodes.splice(importNodeIndex, 0, rule); - importNodeIndex++; - } else { - ruleNodes.push(rule); - } - } - ruleNodes = charsetRuleNodes.concat(ruleNodes); - - // If this is the root node, we don't render - // a selector, or {}. - if (!this.root) { - debugInfo = getDebugInfo(context, this, tabSetStr); - - if (debugInfo) { - output.add(debugInfo); - output.add(tabSetStr); - } - - var paths = this.paths, pathCnt = paths.length, - pathSubCnt; - - sep = context.compress ? ',' : (',\n' + tabSetStr); - - for (i = 0; i < pathCnt; i++) { - path = paths[i]; - if (!(pathSubCnt = path.length)) { continue; } - if (i > 0) { output.add(sep); } - - context.firstSelector = true; - path[0].genCSS(context, output); - - context.firstSelector = false; - for (j = 1; j < pathSubCnt; j++) { - path[j].genCSS(context, output); - } - } - - output.add((context.compress ? '{' : ' {\n') + tabRuleStr); - } - - // Compile rules and rulesets - for (i = 0; i < ruleNodes.length; i++) { - rule = ruleNodes[i]; - - if (i + 1 === ruleNodes.length) { - context.lastRule = true; - } - - var currentLastRule = context.lastRule; - if (isRulesetLikeNode(rule)) { - context.lastRule = false; - } - - if (rule.genCSS) { - rule.genCSS(context, output); - } else if (rule.value) { - output.add(rule.value.toString()); - } - - context.lastRule = currentLastRule; - - if (!context.lastRule) { - output.add(context.compress ? '' : ('\n' + tabRuleStr)); - } else { - context.lastRule = false; - } - } - - if (!this.root) { - output.add((context.compress ? '}' : '\n' + tabSetStr + '}')); - context.tabLevel--; - } - - if (!output.isEmpty() && !context.compress && this.firstRoot) { - output.add('\n'); - } -}; - -Ruleset.prototype.joinSelectors = function (paths, context, selectors) { - for (var s = 0; s < selectors.length; s++) { - this.joinSelector(paths, context, selectors[s]); - } -}; - -Ruleset.prototype.joinSelector = function (paths, context, selector) { - - function createParenthesis(elementsToPak, originalElement) { - var replacementParen, j; - if (elementsToPak.length === 0) { - replacementParen = new Paren(elementsToPak[0]); - } else { - var insideParent = []; - for (j = 0; j < elementsToPak.length; j++) { - insideParent.push(new Element(null, elementsToPak[j], originalElement.index, originalElement.currentFileInfo)); - } - replacementParen = new Paren(new Selector(insideParent)); - } - return replacementParen; - } - - function createSelector(containedElement, originalElement) { - var element, selector; - element = new Element(null, containedElement, originalElement.index, originalElement.currentFileInfo); - selector = new Selector([element]); - return selector; - } - - // joins selector path from `beginningPath` with selector path in `addPath` - // `replacedElement` contains element that is being replaced by `addPath` - // returns concatenated path - function addReplacementIntoPath(beginningPath, addPath, replacedElement, originalSelector) { - var newSelectorPath, lastSelector, newJoinedSelector; - // our new selector path - newSelectorPath = []; - - //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); - lastSelector = newSelectorPath.pop(); - newJoinedSelector = originalSelector.createDerived(lastSelector.elements.slice(0)); - } - else { - newJoinedSelector = originalSelector.createDerived([]); - } - - if (addPath.length > 0) { - // /deep/ is a combinator that is valid without anything in front of it - // so if the & does not have a combinator that is "" or " " then - // and there is a combinator on the parent, then grab that. - // this also allows + a { & .b { .a & { ... though not sure why you would want to do that - var combinator = replacedElement.combinator, parentEl = addPath[0].elements[0]; - if (combinator.emptyOrWhitespace && !parentEl.combinator.emptyOrWhitespace) { - 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 = newJoinedSelector.elements.concat(addPath[0].elements.slice(1)); - } - - // now add the joined selector - but only if it is not empty - if (newJoinedSelector.elements.length !== 0) { - newSelectorPath.push(newJoinedSelector); - } - - //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) { - return selector.createDerived(selector.elements, []); - }); - newSelectorPath = newSelectorPath.concat(restOfPath); - } - return newSelectorPath; - } - - // joins selector path from `beginningPath` with every selector path in `addPaths` array - // `replacedElement` contains element that is being replaced by `addPath` - // returns array with all concatenated paths - function addAllReplacementsIntoPath( beginningPath, addPaths, replacedElement, originalSelector, result) { - var j; - for (j = 0; j < beginningPath.length; j++) { - var newSelectorPath = addReplacementIntoPath(beginningPath[j], addPaths, replacedElement, originalSelector); - result.push(newSelectorPath); - } - return result; - } - - function mergeElementsOnToSelectors(elements, selectors) { - var i, sel; - - if (elements.length === 0) { - return ; - } - if (selectors.length === 0) { - selectors.push([ new Selector(elements) ]); - return; - } - - for (i = 0; i < selectors.length; i++) { - sel = selectors[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)); - } - else { - sel.push(new Selector(elements)); - } - } - } - - // replace all parent selectors inside `inSelector` by content of `context` array - // resulting selectors are returned inside `paths` array - // returns true if `inSelector` contained at least one parent selector - function replaceParentSelector(paths, context, inSelector) { - // The paths are [[Selector]] - // The first list is a list of comma separated selectors - // The inner list is a list of inheritance separated selectors - // e.g. - // .a, .b { - // .c { - // } - // } - // == [[.a] [.c]] [[.b] [.c]] - // - var i, j, k, currentElements, newSelectors, selectorsMultiplied, sel, el, hadParentSelector = false, length, lastSelector; - function findNestedSelector(element) { - var maybeSelector; - if (element.value.type !== 'Paren') { - return null; - } - - maybeSelector = element.value.value; - if (maybeSelector.type !== 'Selector') { - return null; - } - - return maybeSelector; - } - - // the elements from the current selector so far - currentElements = []; - // the current list of new selectors to add to the path. - // We will build it up. We initiate it with one empty selector as we "multiply" the new selectors - // by the parents - newSelectors = [ - [] - ]; - - for (i = 0; i < inSelector.elements.length; i++) { - el = inSelector.elements[i]; - // non parent reference elements just get added - if (el.value !== "&") { - var nestedSelector = findNestedSelector(el); - if (nestedSelector != null) { - // merge the current list of non parent selector elements - // on to the current list of selectors to add - mergeElementsOnToSelectors(currentElements, newSelectors); - - 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 - for (k = 0; k < nestedPaths.length; k++) { - var replacementSelector = createSelector(createParenthesis(nestedPaths[k], el), el); - addAllReplacementsIntoPath(newSelectors, [replacementSelector], el, inSelector, replacedNewSelectors); - } - newSelectors = replacedNewSelectors; - currentElements = []; - - } else { - currentElements.push(el); - } - - } else { - hadParentSelector = true; - // the new list of selectors to add - selectorsMultiplied = []; - - // merge the current list of non parent selector elements - // on to the current list of selectors to add - mergeElementsOnToSelectors(currentElements, newSelectors); - - // loop through our current selectors - for (j = 0; j < newSelectors.length; j++) { - sel = newSelectors[j]; - // if we don't have any parent paths, the & might be in a mixin so that it can be used - // whether there are parents or not - if (context.length === 0) { - // 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)); - } - selectorsMultiplied.push(sel); - } - else { - // and the parent selectors - for (k = 0; k < context.length; k++) { - // We need to put the current selectors - // then join the last selector's elements on to the parents selectors - var newSelectorPath = addReplacementIntoPath(sel, context[k], el, inSelector); - // add that to our new set of selectors - selectorsMultiplied.push(newSelectorPath); - } - } - } - - // our new selectors has been multiplied, so reset the state - newSelectors = selectorsMultiplied; - currentElements = []; - } - } - - // if we have any elements left over (e.g. .a& .b == .b) - // add them on to all the current selectors - mergeElementsOnToSelectors(currentElements, newSelectors); - - for (i = 0; i < newSelectors.length; i++) { - length = newSelectors[i].length; - if (length > 0) { - 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()); - } - } - - return hadParentSelector; - } - - function deriveSelector(visibilityInfo, deriveFrom) { - var newSelector = deriveFrom.createDerived(deriveFrom.elements, deriveFrom.extendList, deriveFrom.evaldCondition); - newSelector.copyVisibilityInfo(visibilityInfo); - return newSelector; - } - - // joinSelector code follows - var i, newPaths, hadParentSelector; - - newPaths = []; - hadParentSelector = replaceParentSelector(newPaths, context, selector); - - if (!hadParentSelector) { - 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); - newPaths.push(concatenated); - } - } - else { - newPaths = [[selector]]; - } - } - - for (i = 0; i < newPaths.length; i++) { - paths.push(newPaths[i]); - } - -}; -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){ -var Node = require("./node"), - Element = require("./element"); - -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.copyVisibilityInfo(visibilityInfo); -}; -Selector.prototype = new Node(); -Selector.prototype.type = "Selector"; -Selector.prototype.accept = function (visitor) { - if (this.elements) { - this.elements = visitor.visitArray(this.elements); - } - if (this.extendList) { - this.extendList = visitor.visitArray(this.extendList); - } - if (this.condition) { - this.condition = visitor.visit(this.condition); - } -}; -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; - newSelector.mediaEmpty = this.mediaEmpty; - return newSelector; -}; -Selector.prototype.createEmptySelectors = function() { - var el = new Element('', '&', this.index, this.currentFileInfo), - sels = [new Selector([el], null, null, this.index, this.currentFileInfo)]; - sels[0].mediaEmpty = true; - return sels; -}; -Selector.prototype.match = function (other) { - var elements = this.elements, - len = elements.length, - olen, i; - - other.CacheElements(); - - olen = other._elements.length; - if (olen === 0 || len < olen) { - return 0; - } else { - for (i = 0; i < olen; i++) { - if (elements[i].value !== other._elements[i]) { - return 0; - } - } - } - - return olen; // return number of matched elements -}; -Selector.prototype.CacheElements = function() { - if (this._elements) { - return; - } - - var elements = this.elements.map( function(v) { - return v.combinator.value + (v.value.value || v.value); - }).join("").match(/[,&#\*\.\w-]([\w-]|(\\.))*/g); - - if (elements) { - if (elements[0] === "&") { - elements.shift(); - } - } else { - elements = []; - } - - this._elements = elements; -}; -Selector.prototype.isJustParentSelector = function() { - return !this.mediaEmpty && - this.elements.length === 1 && - this.elements[0].value === '&' && - (this.elements[0].combinator.value === ' ' || this.elements[0].combinator.value === ''); -}; -Selector.prototype.eval = function (context) { - var evaldCondition = this.condition && this.condition.eval(context), - elements = this.elements, extendList = this.extendList; - - elements = elements && elements.map(function (e) { return e.eval(context); }); - extendList = extendList && extendList.map(function(extend) { return extend.eval(context); }); - - return this.createDerived(elements, extendList, evaldCondition); -}; -Selector.prototype.genCSS = function (context, output) { - var i, element; - if ((!context || !context.firstSelector) && this.elements[0].combinator.value === "") { - output.add(' ', this.currentFileInfo, this.index); - } - if (!this._css) { - //TODO caching? speed comparison? - for (i = 0; i < this.elements.length; i++) { - element = this.elements[i]; - element.genCSS(context, output); - } - } -}; -Selector.prototype.getIsOutput = function() { - return this.evaldCondition; -}; -module.exports = Selector; - -},{"./element":58,"./node":70}],78:[function(require,module,exports){ -var Node = require("./node"); - -var UnicodeDescriptor = function (value) { - this.value = value; -}; -UnicodeDescriptor.prototype = new Node(); -UnicodeDescriptor.prototype.type = "UnicodeDescriptor"; - -module.exports = UnicodeDescriptor; - -},{"./node":70}],79:[function(require,module,exports){ -var Node = require("./node"), - unitConversions = require("../data/unit-conversions"); - -var Unit = function (numerator, denominator, backupUnit) { - this.numerator = numerator ? numerator.slice(0).sort() : []; - this.denominator = denominator ? denominator.slice(0).sort() : []; - if (backupUnit) { - this.backupUnit = backupUnit; - } else if (numerator && numerator.length) { - this.backupUnit = numerator[0]; - } -}; - -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); -}; -Unit.prototype.genCSS = function (context, output) { - // Dimension checks the unit is singular and throws an error if in strict math mode. - var strictUnits = context && context.strictUnits; - if (this.numerator.length === 1) { - output.add(this.numerator[0]); // the ideal situation - } else if (!strictUnits && this.backupUnit) { - output.add(this.backupUnit); - } else if (!strictUnits && this.denominator.length) { - output.add(this.denominator[0]); - } -}; -Unit.prototype.toString = function () { - var i, returnStr = this.numerator.join("*"); - for (i = 0; i < this.denominator.length; i++) { - returnStr += "/" + this.denominator[i]; - } - return returnStr; -}; -Unit.prototype.compare = function (other) { - return this.is(other.toString()) ? 0 : undefined; -}; -Unit.prototype.is = function (unitString) { - return this.toString().toUpperCase() === unitString.toUpperCase(); -}; -Unit.prototype.isLength = function () { - return Boolean(this.toCSS().match(/px|em|%|in|cm|mm|pc|pt|ex/)); -}; -Unit.prototype.isEmpty = function () { - return this.numerator.length === 0 && this.denominator.length === 0; -}; -Unit.prototype.isSingular = function() { - return this.numerator.length <= 1 && this.denominator.length === 0; -}; -Unit.prototype.map = function(callback) { - var i; - - for (i = 0; i < this.numerator.length; i++) { - this.numerator[i] = callback(this.numerator[i], false); - } - - for (i = 0; i < this.denominator.length; i++) { - this.denominator[i] = callback(this.denominator[i], true); - } -}; -Unit.prototype.usedUnits = function() { - var group, result = {}, mapUnit, groupName; - - mapUnit = function (atomicUnit) { - /*jshint loopfunc:true */ - if (group.hasOwnProperty(atomicUnit) && !result[groupName]) { - result[groupName] = atomicUnit; - } - - return atomicUnit; - }; - - for (groupName in unitConversions) { - if (unitConversions.hasOwnProperty(groupName)) { - group = unitConversions[groupName]; - - this.map(mapUnit); - } - } - - return result; -}; -Unit.prototype.cancel = function () { - var counter = {}, atomicUnit, i; - - for (i = 0; i < this.numerator.length; i++) { - atomicUnit = this.numerator[i]; - counter[atomicUnit] = (counter[atomicUnit] || 0) + 1; - } - - for (i = 0; i < this.denominator.length; i++) { - atomicUnit = this.denominator[i]; - counter[atomicUnit] = (counter[atomicUnit] || 0) - 1; - } - - this.numerator = []; - this.denominator = []; - - for (atomicUnit in counter) { - if (counter.hasOwnProperty(atomicUnit)) { - var count = counter[atomicUnit]; - - if (count > 0) { - for (i = 0; i < count; i++) { - this.numerator.push(atomicUnit); - } - } else if (count < 0) { - for (i = 0; i < -count; i++) { - this.denominator.push(atomicUnit); - } - } - } - } - - this.numerator.sort(); - this.denominator.sort(); -}; -module.exports = Unit; - -},{"../data/unit-conversions":14,"./node":70}],80:[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.isEvald = isEvald; -}; -URL.prototype = new Node(); -URL.prototype.type = "Url"; -URL.prototype.accept = function (visitor) { - this.value = visitor.visit(this.value); -}; -URL.prototype.genCSS = function (context, output) { - output.add("url("); - this.value.genCSS(context, output); - output.add(")"); -}; -URL.prototype.eval = function (context) { - var val = this.value.eval(context), - rootpath; - - if (!this.isEvald) { - // Add the base path if the URL is relative - rootpath = this.currentFileInfo && this.currentFileInfo.rootpath; - if (rootpath && - typeof val.value === "string" && - context.isPathRelative(val.value)) { - - if (!val.quote) { - rootpath = rootpath.replace(/[\(\)'"\s]/g, function(match) { return "\\" + match; }); - } - val.value = rootpath + val.value; - } - - val.value = context.normalizePath(val.value); - - // Add url args if enabled - if (context.urlArgs) { - if (!val.value.match(/^\s*data:/)) { - var delimiter = val.value.indexOf('?') === -1 ? '?' : '&'; - var urlArgs = delimiter + context.urlArgs; - if (val.value.indexOf('#') !== -1) { - val.value = val.value.replace('#', urlArgs + '#'); - } else { - val.value += urlArgs; - } - } - } - } - - return new URL(val, this.index, this.currentFileInfo, true); -}; -module.exports = URL; - -},{"./node":70}],81:[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"); - } -}; -Value.prototype = new Node(); -Value.prototype.type = "Value"; -Value.prototype.accept = function (visitor) { - if (this.value) { - this.value = visitor.visitArray(this.value); - } -}; -Value.prototype.eval = function (context) { - if (this.value.length === 1) { - return this.value[0].eval(context); - } else { - return new Value(this.value.map(function (v) { - return v.eval(context); - })); - } -}; -Value.prototype.genCSS = function (context, output) { - var i; - for (i = 0; i < this.value.length; i++) { - this.value[i].genCSS(context, output); - if (i + 1 < this.value.length) { - output.add((context && context.compress) ? ',' : ', '); - } - } -}; -module.exports = Value; - -},{"./node":70}],82:[function(require,module,exports){ -var Node = require("./node"); - -var Variable = function (name, index, currentFileInfo) { - this.name = name; - this.index = index; - this.currentFileInfo = currentFileInfo || {}; -}; -Variable.prototype = new Node(); -Variable.prototype.type = "Variable"; -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; - } - - if (this.evaluating) { - throw { type: 'Name', - message: "Recursive variable definition for " + name, - filename: this.currentFileInfo.filename, - index: this.index }; - } - - this.evaluating = true; - - variable = this.find(context.frames, function (frame) { - var v = frame.variable(name); - if (v) { - if (v.important) { - var importantScope = context.importantScope[context.importantScope.length - 1]; - importantScope.important = v.important; - } - return v.value.eval(context); - } - }); - if (variable) { - this.evaluating = false; - return variable; - } else { - throw { type: 'Name', - message: "variable " + name + " is undefined", - filename: this.currentFileInfo.filename, - index: this.index }; - } -}; -Variable.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 = Variable; - -},{"./node":70}],83:[function(require,module,exports){ -module.exports = { - getLocation: function(index, inputStream) { - var n = index + 1, - line = null, - column = -1; - - while (--n >= 0 && inputStream.charAt(n) !== '\n') { - column++; - } - - if (typeof index === 'number') { - line = (inputStream.slice(0, index).match(/\n/g) || "").length; - } - - return { - line: line, - column: column - }; - } -}; - -},{}],84:[function(require,module,exports){ -var tree = require("../tree"), - Visitor = require("./visitor"), - logger = require("../logger"); - -/*jshint loopfunc:true */ - -var ExtendFinderVisitor = function() { - this._visitor = new Visitor(this); - this.contexts = []; - this.allExtendsStack = [[]]; -}; - -ExtendFinderVisitor.prototype = { - run: function (root) { - root = this._visitor.visit(root); - root.allExtends = this.allExtendsStack[0]; - return root; - }, - visitRule: function (ruleNode, visitArgs) { - visitArgs.visitDeeper = false; - }, - visitMixinDefinition: function (mixinDefinitionNode, visitArgs) { - visitArgs.visitDeeper = false; - }, - visitRuleset: function (rulesetNode, visitArgs) { - if (rulesetNode.root) { - return; - } - - var i, j, extend, allSelectorsExtendList = [], extendList; - - // get &:extend(.a); rules which apply to all selectors in this ruleset - var rules = rulesetNode.rules, ruleCnt = rules ? rules.length : 0; - for (i = 0; i < ruleCnt; i++) { - if (rulesetNode.rules[i] instanceof tree.Extend) { - allSelectorsExtendList.push(rules[i]); - rulesetNode.extendOnEveryPath = true; - } - } - - // now find every selector and apply the extends that apply to all extends - // and the ones which apply to an individual extend - var paths = rulesetNode.paths; - for (i = 0; i < paths.length; i++) { - var selectorPath = paths[i], - selector = selectorPath[selectorPath.length - 1], - selExtendList = selector.extendList; - - extendList = selExtendList ? selExtendList.slice(0).concat(allSelectorsExtendList) - : allSelectorsExtendList; - - if (extendList) { - extendList = extendList.map(function(allSelectorsExtend) { - return allSelectorsExtend.clone(); - }); - } - - for (j = 0; j < extendList.length; j++) { - this.foundExtends = true; - extend = extendList[j]; - extend.findSelfSelectors(selectorPath); - extend.ruleset = rulesetNode; - if (j === 0) { extend.firstExtendOnThisSelectorPath = true; } - this.allExtendsStack[this.allExtendsStack.length - 1].push(extend); - } - } - - this.contexts.push(rulesetNode.selectors); - }, - visitRulesetOut: function (rulesetNode) { - if (!rulesetNode.root) { - this.contexts.length = this.contexts.length - 1; - } - }, - visitMedia: function (mediaNode, visitArgs) { - mediaNode.allExtends = []; - this.allExtendsStack.push(mediaNode.allExtends); - }, - visitMediaOut: function (mediaNode) { - this.allExtendsStack.length = this.allExtendsStack.length - 1; - }, - visitDirective: function (directiveNode, visitArgs) { - directiveNode.allExtends = []; - this.allExtendsStack.push(directiveNode.allExtends); - }, - visitDirectiveOut: function (directiveNode) { - this.allExtendsStack.length = this.allExtendsStack.length - 1; - } -}; - -var ProcessExtendsVisitor = function() { - this._visitor = new Visitor(this); -}; - -ProcessExtendsVisitor.prototype = { - run: function(root) { - var extendFinder = new ExtendFinderVisitor(); - this.extendIndices = {}; - extendFinder.run(root); - if (!extendFinder.foundExtends) { return root; } - root.allExtends = root.allExtends.concat(this.doExtendChaining(root.allExtends, root.allExtends)); - this.allExtendsStack = [root.allExtends]; - var newRoot = this._visitor.visit(root); - this.checkExtendsForNonMatched(root.allExtends); - return newRoot; - }, - checkExtendsForNonMatched: function(extendList) { - var indices = this.extendIndices; - extendList.filter(function(extend) { - return !extend.hasFoundMatches && extend.parent_ids.length == 1; - }).forEach(function(extend) { - 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"); - } - }); - }, - doExtendChaining: function (extendsList, extendsListTarget, iterationCount) { - // - // chaining is different from normal extension.. if we extend an extend then we are not just copying, altering - // and pasting the selector we would do normally, but we are also adding an extend with the same target selector - // this means this new extend can then go and alter other extends - // - // this method deals with all the chaining work - without it, extend is flat and doesn't work on other extend selectors - // this is also the most expensive.. and a match on one selector can cause an extension of a selector we had already - // processed if we look at each selector at a time, as is done in visitRuleset - - var extendIndex, targetExtendIndex, matches, extendsToAdd = [], newSelector, extendVisitor = this, selectorPath, - extend, targetExtend, newExtend; - - iterationCount = iterationCount || 0; - - //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. - // the separation into two lists allows us to process a subset of chains with a bigger set, as is the - // case when processing media queries - for (extendIndex = 0; extendIndex < extendsList.length; extendIndex++) { - for (targetExtendIndex = 0; targetExtendIndex < extendsListTarget.length; targetExtendIndex++) { - - extend = extendsList[extendIndex]; - targetExtend = extendsListTarget[targetExtendIndex]; - - // look for circular references - if ( extend.parent_ids.indexOf( targetExtend.object_id ) >= 0 ) { continue; } - - // find a match in the target extends self selector (the bit before :extend) - selectorPath = [targetExtend.selfSelectors[0]]; - matches = extendVisitor.findMatch(extend, selectorPath); - - if (matches.length) { - extend.hasFoundMatches = true; - - // we found a match, so for each self selector.. - extend.selfSelectors.forEach(function(selfSelector) { - var info = targetExtend.visibilityInfo(); - - // process the extend as usual - 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.selfSelectors = newSelector; - - // add the extend onto the list of extends for that selector - newSelector[newSelector.length - 1].extendList = [newExtend]; - - // record that we need to add it. - extendsToAdd.push(newExtend); - newExtend.ruleset = targetExtend.ruleset; - - //remember its parents for circular references - newExtend.parent_ids = newExtend.parent_ids.concat(targetExtend.parent_ids, extend.parent_ids); - - // only process the selector once.. if we have :extend(.a,.b) then multiple - // extends will look at the same selector path, so when extending - // we know that any others will be duplicates in terms of what is added to the css - if (targetExtend.firstExtendOnThisSelectorPath) { - newExtend.firstExtendOnThisSelectorPath = true; - targetExtend.ruleset.paths.push(newSelector); - } - }); - } - } - } - - if (extendsToAdd.length) { - // try to detect circular references to stop a stack overflow. - // may no longer be needed. - this.extendChainCount++; - if (iterationCount > 100) { - var selectorOne = "{unable to calculate}"; - var selectorTwo = "{unable to calculate}"; - try { - selectorOne = extendsToAdd[0].selfSelectors[0].toCSS(); - selectorTwo = extendsToAdd[0].selector.toCSS(); - } - catch(e) {} - throw { message: "extend circular reference detected. One of the circular extends is currently:" + - selectorOne + ":extend(" + selectorTwo + ")"}; - } - - // now process the new extends on the existing rules so that we can handle a extending b extending c extending - // d extending e... - return extendsToAdd.concat(extendVisitor.doExtendChaining(extendsToAdd, extendsListTarget, iterationCount + 1)); - } else { - return extendsToAdd; - } - }, - visitRule: function (ruleNode, visitArgs) { - visitArgs.visitDeeper = false; - }, - visitMixinDefinition: function (mixinDefinitionNode, visitArgs) { - visitArgs.visitDeeper = false; - }, - visitSelector: function (selectorNode, visitArgs) { - visitArgs.visitDeeper = false; - }, - visitRuleset: function (rulesetNode, visitArgs) { - if (rulesetNode.root) { - return; - } - var matches, pathIndex, extendIndex, allExtends = this.allExtendsStack[this.allExtendsStack.length - 1], - selectorsToAdd = [], extendVisitor = this, selectorPath; - - // look at each selector path in the ruleset, find any extend matches and then copy, find and replace - - for (extendIndex = 0; extendIndex < allExtends.length; extendIndex++) { - for (pathIndex = 0; pathIndex < rulesetNode.paths.length; pathIndex++) { - selectorPath = rulesetNode.paths[pathIndex]; - - // extending extends happens initially, before the main pass - if (rulesetNode.extendOnEveryPath) { continue; } - var extendList = selectorPath[selectorPath.length - 1].extendList; - if (extendList && extendList.length) { continue; } - - matches = this.findMatch(allExtends[extendIndex], selectorPath); - - if (matches.length) { - allExtends[extendIndex].hasFoundMatches = true; - - allExtends[extendIndex].selfSelectors.forEach(function(selfSelector) { - var extendedSelectors; - extendedSelectors = extendVisitor.extendSelector(matches, selectorPath, selfSelector, allExtends[extendIndex].isVisible()); - selectorsToAdd.push(extendedSelectors); - }); - } - } - } - rulesetNode.paths = rulesetNode.paths.concat(selectorsToAdd); - }, - findMatch: function (extend, haystackSelectorPath) { - // - // look through the haystack selector path to try and find the needle - extend.selector - // returns an array of selector matches that can then be replaced - // - var haystackSelectorIndex, hackstackSelector, hackstackElementIndex, haystackElement, - targetCombinator, i, - extendVisitor = this, - needleElements = extend.selector.elements, - potentialMatches = [], potentialMatch, matches = []; - - // loop through the haystack elements - for (haystackSelectorIndex = 0; haystackSelectorIndex < haystackSelectorPath.length; haystackSelectorIndex++) { - hackstackSelector = haystackSelectorPath[haystackSelectorIndex]; - - for (hackstackElementIndex = 0; hackstackElementIndex < hackstackSelector.elements.length; hackstackElementIndex++) { - - haystackElement = hackstackSelector.elements[hackstackElementIndex]; - - // if we allow elements before our match we can add a potential match every time. otherwise only at the first element. - if (extend.allowBefore || (haystackSelectorIndex === 0 && hackstackElementIndex === 0)) { - potentialMatches.push({pathIndex: haystackSelectorIndex, index: hackstackElementIndex, matched: 0, - initialCombinator: haystackElement.combinator}); - } - - for (i = 0; i < potentialMatches.length; i++) { - potentialMatch = potentialMatches[i]; - - // selectors add " " onto the first element. When we use & it joins the selectors together, but if we don't - // then each selector in haystackSelectorPath has a space before it added in the toCSS phase. so we need to - // work out what the resulting combinator will be - targetCombinator = haystackElement.combinator.value; - if (targetCombinator === '' && hackstackElementIndex === 0) { - targetCombinator = ' '; - } - - // if we don't match, null our match to indicate failure - if (!extendVisitor.isElementValuesEqual(needleElements[potentialMatch.matched].value, haystackElement.value) || - (potentialMatch.matched > 0 && needleElements[potentialMatch.matched].combinator.value !== targetCombinator)) { - potentialMatch = null; - } else { - potentialMatch.matched++; - } - - // if we are still valid and have finished, test whether we have elements after and whether these are allowed - if (potentialMatch) { - potentialMatch.finished = potentialMatch.matched === needleElements.length; - if (potentialMatch.finished && - (!extend.allowAfter && - (hackstackElementIndex + 1 < hackstackSelector.elements.length || haystackSelectorIndex + 1 < haystackSelectorPath.length))) { - potentialMatch = null; - } - } - // if null we remove, if not, we are still valid, so either push as a valid match or continue - if (potentialMatch) { - if (potentialMatch.finished) { - potentialMatch.length = needleElements.length; - potentialMatch.endPathIndex = haystackSelectorIndex; - potentialMatch.endPathElementIndex = hackstackElementIndex + 1; // index after end of match - potentialMatches.length = 0; // we don't allow matches to overlap, so start matching again - matches.push(potentialMatch); - } - } else { - potentialMatches.splice(i, 1); - i--; - } - } - } - } - return matches; - }, - isElementValuesEqual: function(elementValue1, elementValue2) { - if (typeof elementValue1 === "string" || typeof elementValue2 === "string") { - return elementValue1 === elementValue2; - } - if (elementValue1 instanceof tree.Attribute) { - if (elementValue1.op !== elementValue2.op || elementValue1.key !== elementValue2.key) { - return false; - } - if (!elementValue1.value || !elementValue2.value) { - if (elementValue1.value || elementValue2.value) { - return false; - } - return true; - } - elementValue1 = elementValue1.value.value || elementValue1.value; - elementValue2 = elementValue2.value.value || elementValue2.value; - return elementValue1 === elementValue2; - } - elementValue1 = elementValue1.value; - elementValue2 = elementValue2.value; - if (elementValue1 instanceof tree.Selector) { - if (!(elementValue2 instanceof tree.Selector) || elementValue1.elements.length !== elementValue2.elements.length) { - return false; - } - for (var i = 0; i < elementValue1.elements.length; i++) { - if (elementValue1.elements[i].combinator.value !== elementValue2.elements[i].combinator.value) { - if (i !== 0 || (elementValue1.elements[i].combinator.value || ' ') !== (elementValue2.elements[i].combinator.value || ' ')) { - return false; - } - } - if (!this.isElementValuesEqual(elementValue1.elements[i].value, elementValue2.elements[i].value)) { - return false; - } - } - return true; - } - return false; - }, - extendSelector:function (matches, selectorPath, replacementSelector, isVisible) { - - //for a set of matches, replace each match with the replacement selector - - var currentSelectorPathIndex = 0, - currentSelectorPathElementIndex = 0, - path = [], - matchIndex, - selector, - firstElement, - match, - newElements; - - for (matchIndex = 0; matchIndex < matches.length; matchIndex++) { - match = matches[matchIndex]; - selector = selectorPath[match.pathIndex]; - firstElement = new tree.Element( - match.initialCombinator, - replacementSelector.elements[0].value, - replacementSelector.elements[0].index, - replacementSelector.elements[0].currentFileInfo - ); - - if (match.pathIndex > currentSelectorPathIndex && currentSelectorPathElementIndex > 0) { - path[path.length - 1].elements = path[path.length - 1] - .elements.concat(selectorPath[currentSelectorPathIndex].elements.slice(currentSelectorPathElementIndex)); - currentSelectorPathElementIndex = 0; - currentSelectorPathIndex++; - } - - newElements = selector.elements - .slice(currentSelectorPathElementIndex, match.index) - .concat([firstElement]) - .concat(replacementSelector.elements.slice(1)); - - if (currentSelectorPathIndex === match.pathIndex && matchIndex > 0) { - path[path.length - 1].elements = - path[path.length - 1].elements.concat(newElements); - } else { - path = path.concat(selectorPath.slice(currentSelectorPathIndex, match.pathIndex)); - - path.push(new tree.Selector( - newElements - )); - } - currentSelectorPathIndex = match.endPathIndex; - currentSelectorPathElementIndex = match.endPathElementIndex; - if (currentSelectorPathElementIndex >= selectorPath[currentSelectorPathIndex].elements.length) { - currentSelectorPathElementIndex = 0; - currentSelectorPathIndex++; - } - } - - if (currentSelectorPathIndex < selectorPath.length && currentSelectorPathElementIndex > 0) { - path[path.length - 1].elements = path[path.length - 1] - .elements.concat(selectorPath[currentSelectorPathIndex].elements.slice(currentSelectorPathElementIndex)); - currentSelectorPathIndex++; - } - - path = path.concat(selectorPath.slice(currentSelectorPathIndex, selectorPath.length)); - path = path.map(function (currentValue) { - // we can re-use elements here, because the visibility property matters only for selectors - var derived = currentValue.createDerived(currentValue.elements); - if (isVisible) { - derived.ensureVisibility(); - } else { - derived.ensureInvisibility(); - } - return derived; - }); - return path; - }, - visitMedia: function (mediaNode, visitArgs) { - var newAllExtends = mediaNode.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length - 1]); - newAllExtends = newAllExtends.concat(this.doExtendChaining(newAllExtends, mediaNode.allExtends)); - this.allExtendsStack.push(newAllExtends); - }, - visitMediaOut: function (mediaNode) { - 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)); - this.allExtendsStack.push(newAllExtends); - }, - visitDirectiveOut: function (directiveNode) { - var lastIndex = this.allExtendsStack.length - 1; - this.allExtendsStack.length = lastIndex; - } -}; - -module.exports = ProcessExtendsVisitor; - -},{"../logger":33,"../tree":62,"./visitor":91}],85:[function(require,module,exports){ -function ImportSequencer(onSequencerEmpty) { - this.imports = []; - this.variableImports = []; - this._onSequencerEmpty = onSequencerEmpty; - this._currentDepth = 0; -} - -ImportSequencer.prototype.addImport = function(callback) { - var importSequencer = this, - importItem = { - callback: callback, - args: null, - isReady: false - }; - this.imports.push(importItem); - return function() { - importItem.args = Array.prototype.slice.call(arguments, 0); - importItem.isReady = true; - importSequencer.tryRun(); - }; -}; - -ImportSequencer.prototype.addVariableImport = function(callback) { - this.variableImports.push(callback); -}; - -ImportSequencer.prototype.tryRun = function() { - this._currentDepth++; - try { - while (true) { - while (this.imports.length > 0) { - var importItem = this.imports[0]; - if (!importItem.isReady) { - return; - } - this.imports = this.imports.slice(1); - importItem.callback.apply(null, importItem.args); - } - if (this.variableImports.length === 0) { - break; - } - var variableImport = this.variableImports[0]; - this.variableImports = this.variableImports.slice(1); - variableImport(); - } - } finally { - this._currentDepth--; - } - if (this._currentDepth === 0 && this._onSequencerEmpty) { - this._onSequencerEmpty(); - } -}; - -module.exports = ImportSequencer; - -},{}],86:[function(require,module,exports){ -var contexts = require("../contexts"), - Visitor = require("./visitor"), - ImportSequencer = require("./import-sequencer"); - -var ImportVisitor = function(importer, finish) { - - this._visitor = new Visitor(this); - this._importer = importer; - this._finish = finish; - this.context = new contexts.Eval(); - this.importCount = 0; - this.onceFileDetectionMap = {}; - this.recursionDetector = {}; - this._sequencer = new ImportSequencer(this._onSequencerEmpty.bind(this)); -}; - -ImportVisitor.prototype = { - isReplacing: false, - run: function (root) { - try { - // process the contents - this._visitor.visit(root); - } - catch(e) { - this.error = e; - } - - this.isFinished = true; - this._sequencer.tryRun(); - }, - _onSequencerEmpty: function() { - if (!this.isFinished) { - return; - } - this._finish(this.error); - }, - visitImport: function (importNode, visitArgs) { - var inlineCSS = importNode.options.inline; - - if (!importNode.css || inlineCSS) { - - var context = new contexts.Eval(this.context, this.context.frames.slice(0)); - var importParent = context.frames[0]; - - this.importCount++; - if (importNode.isVariableImport()) { - this._sequencer.addVariableImport(this.processImportNode.bind(this, importNode, context, importParent)); - } else { - this.processImportNode(importNode, context, importParent); - } - } - visitArgs.visitDeeper = false; - }, - processImportNode: function(importNode, context, importParent) { - var evaldImportNode, - inlineCSS = importNode.options.inline; - - try { - evaldImportNode = importNode.evalForImport(context); - } catch(e) { - if (!e.filename) { e.index = importNode.index; e.filename = importNode.currentFileInfo.filename; } - // attempt to eval properly and treat as css - importNode.css = true; - // if that fails, this error will be thrown - importNode.error = e; - } - - if (evaldImportNode && (!evaldImportNode.css || inlineCSS)) { - - if (evaldImportNode.options.multiple) { - context.importMultiple = true; - } - - // try appending if we haven't determined if it is css or not - var tryAppendLessExtension = evaldImportNode.css === undefined; - - for (var i = 0; i < importParent.rules.length; i++) { - if (importParent.rules[i] === importNode) { - importParent.rules[i] = evaldImportNode; - break; - } - } - - var onImported = this.onImported.bind(this, evaldImportNode, context), - sequencedOnImported = this._sequencer.addImport(onImported); - - this._importer.push(evaldImportNode.getPath(), tryAppendLessExtension, evaldImportNode.currentFileInfo, - evaldImportNode.options, sequencedOnImported); - } else { - this.importCount--; - if (this.isFinished) { - this._sequencer.tryRun(); - } - } - }, - onImported: function (importNode, context, e, root, importedAtRoot, fullPath) { - if (e) { - if (!e.filename) { - e.index = importNode.index; e.filename = importNode.currentFileInfo.filename; - } - this.error = e; - } - - var importVisitor = this, - inlineCSS = importNode.options.inline, - isPlugin = importNode.options.plugin, - isOptional = importNode.options.optional, - duplicateImport = importedAtRoot || fullPath in importVisitor.recursionDetector; - - if (!context.importMultiple) { - if (duplicateImport) { - importNode.skip = true; - } else { - importNode.skip = function() { - if (fullPath in importVisitor.onceFileDetectionMap) { - return true; - } - importVisitor.onceFileDetectionMap[fullPath] = true; - return false; - }; - } - } - - if (!fullPath && isOptional) { - importNode.skip = true; - } - - if (root) { - importNode.root = root; - importNode.importedFilename = fullPath; - - if (!inlineCSS && !isPlugin && (context.importMultiple || !duplicateImport)) { - importVisitor.recursionDetector[fullPath] = true; - - var oldContext = this.context; - this.context = context; - try { - this._visitor.visit(root); - } catch (e) { - this.error = e; - } - this.context = oldContext; - } - } - - importVisitor.importCount--; - - if (importVisitor.isFinished) { - importVisitor._sequencer.tryRun(); - } - }, - visitRule: function (ruleNode, visitArgs) { - if (ruleNode.value.type === "DetachedRuleset") { - this.context.frames.unshift(ruleNode); - } else { - visitArgs.visitDeeper = false; - } - }, - visitRuleOut : function(ruleNode) { - if (ruleNode.value.type === "DetachedRuleset") { - this.context.frames.shift(); - } - }, - visitDirective: function (directiveNode, visitArgs) { - this.context.frames.unshift(directiveNode); - }, - visitDirectiveOut: function (directiveNode) { - this.context.frames.shift(); - }, - visitMixinDefinition: function (mixinDefinitionNode, visitArgs) { - this.context.frames.unshift(mixinDefinitionNode); - }, - visitMixinDefinitionOut: function (mixinDefinitionNode) { - this.context.frames.shift(); - }, - visitRuleset: function (rulesetNode, visitArgs) { - this.context.frames.unshift(rulesetNode); - }, - visitRulesetOut: function (rulesetNode) { - this.context.frames.shift(); - }, - visitMedia: function (mediaNode, visitArgs) { - this.context.frames.unshift(mediaNode.rules[0]); - }, - visitMediaOut: function (mediaNode) { - this.context.frames.shift(); - } -}; -module.exports = ImportVisitor; - -},{"../contexts":11,"./import-sequencer":85,"./visitor":91}],87:[function(require,module,exports){ -var visitors = { - Visitor: require("./visitor"), - ImportVisitor: require('./import-visitor'), - MarkVisibleSelectorsVisitor: require("./set-tree-visibility-visitor"), - ExtendVisitor: require('./extend-visitor'), - JoinSelectorVisitor: require('./join-selector-visitor'), - ToCSSVisitor: require('./to-css-visitor') -}; - -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){ -var Visitor = require("./visitor"); - -var JoinSelectorVisitor = function() { - this.contexts = [[]]; - this._visitor = new Visitor(this); -}; - -JoinSelectorVisitor.prototype = { - run: function (root) { - return this._visitor.visit(root); - }, - visitRule: function (ruleNode, visitArgs) { - visitArgs.visitDeeper = false; - }, - visitMixinDefinition: function (mixinDefinitionNode, visitArgs) { - visitArgs.visitDeeper = false; - }, - - visitRuleset: function (rulesetNode, visitArgs) { - var context = this.contexts[this.contexts.length - 1], - paths = [], selectors; - - this.contexts.push(paths); - - if (! rulesetNode.root) { - selectors = rulesetNode.selectors; - if (selectors) { - selectors = selectors.filter(function(selector) { return selector.getIsOutput(); }); - rulesetNode.selectors = selectors.length ? selectors : (selectors = null); - if (selectors) { rulesetNode.joinSelectors(paths, context, selectors); } - } - if (!selectors) { rulesetNode.rules = null; } - rulesetNode.paths = paths; - } - }, - visitRulesetOut: function (rulesetNode) { - this.contexts.length = this.contexts.length - 1; - }, - visitMedia: function (mediaNode, visitArgs) { - var context = this.contexts[this.contexts.length - 1]; - mediaNode.rules[0].root = (context.length === 0 || context[0].multiMedia); - }, - visitDirective: function (directiveNode, 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); - } - } -}; - -module.exports = JoinSelectorVisitor; - -},{"./visitor":91}],89:[function(require,module,exports){ -var SetTreeVisibilityVisitor = function(visible) { - this.visible = visible; -}; -SetTreeVisibilityVisitor.prototype.run = function(root) { - this.visit(root); -}; -SetTreeVisibilityVisitor.prototype.visitArray = function(nodes) { - if (!nodes) { - return nodes; - } - - var cnt = nodes.length, i; - for (i = 0; i < cnt; i++) { - this.visit(nodes[i]); - } - return nodes; -}; -SetTreeVisibilityVisitor.prototype.visit = function(node) { - if (!node) { - return node; - } - if (node.constructor === Array) { - return this.visitArray(node); - } - - if (!node.blocksVisibility || node.blocksVisibility()) { - return node; - } - if (this.visible) { - node.ensureVisibility(); - } else { - node.ensureInvisibility(); - } - - node.accept(this); - return node; -}; -module.exports = SetTreeVisibilityVisitor; -},{}],90:[function(require,module,exports){ -var tree = require("../tree"), - Visitor = require("./visitor"); - -var CSSVisitorUtils = function(context) { - this._visitor = new Visitor(this); - this._context = context; -}; - -CSSVisitorUtils.prototype = { - containsSilentNonBlockedChild: function(bodyRules) { - var rule; - if (bodyRules == null) { - 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 - return true; - } - } - return false; - }, - - keepOnlyVisibleChilds: function(owner) { - if (owner == null || owner.rules == null) { - return ; - } - - 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; - }, - - hasVisibleSelector: function(rulesetNode) { - if (rulesetNode == null || rulesetNode.paths == null) { - return false; - } - return rulesetNode.paths.length > 0; - }, - - resolveVisibility: function (node, originalRules) { - if (!node.blocksVisibility()) { - if (this.isEmpty(node) && !this.containsSilentNonBlockedChild(originalRules)) { - return ; - } - - return node; - } - - var compiledRulesBody = node.rules[0]; - this.keepOnlyVisibleChilds(compiledRulesBody); - - if (this.isEmpty(compiledRulesBody)) { - return ; - } - - node.ensureVisibility(); - node.removeVisibilityBlock(); - - return node; - }, - - isVisibleRuleset: function(rulesetNode) { - if (rulesetNode.firstRoot) { - return true; - } - - if (this.isEmpty(rulesetNode)) { - return false; - } - - if (!rulesetNode.root && !this.hasVisibleSelector(rulesetNode)) { - return false; - } - - return true; - } - -}; - -var ToCSSVisitor = function(context) { - this._visitor = new Visitor(this); - this._context = context; - this.utils = new CSSVisitorUtils(context); -}; - -ToCSSVisitor.prototype = { - isReplacing: true, - run: function (root) { - return this._visitor.visit(root); - }, - - visitRule: function (ruleNode, visitArgs) { - if (ruleNode.blocksVisibility() || ruleNode.variable) { - return; - } - return ruleNode; - }, - - visitMixinDefinition: function (mixinNode, visitArgs) { - // mixin definitions do not get eval'd - this means they keep state - // so we have to clear that state here so it isn't used if toCSS is called twice - mixinNode.frames = []; - }, - - visitExtend: function (extendNode, visitArgs) { - }, - - visitComment: function (commentNode, visitArgs) { - if (commentNode.blocksVisibility() || commentNode.isSilent(this._context)) { - return; - } - return commentNode; - }, - - visitMedia: function(mediaNode, visitArgs) { - var originalRules = mediaNode.rules[0].rules; - mediaNode.accept(this._visitor); - visitArgs.visitDeeper = false; - - return this.utils.resolveVisibility(mediaNode, originalRules); - }, - - visitImport: function (importNode, visitArgs) { - if (importNode.blocksVisibility()) { - return ; - } - return importNode; - }, - - visitDirective: function(directiveNode, visitArgs) { - if (directiveNode.rules && directiveNode.rules.length) { - return this.visitDirectiveWithBody(directiveNode, visitArgs); - } else { - return this.visitDirectiveWithoutBody(directiveNode, visitArgs); - } - }, - - 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; - return bodyRules.length === 1 && (!bodyRules[0].paths || bodyRules[0].paths.length === 0); - } - function getBodyRules(directiveNode) { - var nodeRules = directiveNode.rules; - if (hasFakeRuleset(directiveNode)) { - 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); - visitArgs.visitDeeper = false; - - if (!this.utils.isEmpty(directiveNode)) { - this._mergeRules(directiveNode.rules[0].rules); - } - - return this.utils.resolveVisibility(directiveNode, originalRules); - }, - - visitDirectiveWithoutBody: function(directiveNode, visitArgs) { - if (directiveNode.blocksVisibility()) { - return; - } - - if (directiveNode.name === "@charset") { - // Only output the debug info together with subsequent @charset definitions - // a comment (or @media statement) before the actual @charset directive 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; - return this._visitor.visit(comment); - } - return; - } - this.charset = true; - } - - return directiveNode; - }, - - checkValidNodes: function(rules, isRoot) { - if (!rules) { - return; - } - - for (var i = 0; i < rules.length; i++) { - var ruleNode = rules[i]; - if (isRoot && ruleNode instanceof tree.Rule && !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}; - } - if (ruleNode instanceof tree.Call) { - throw { message: "Function '" + ruleNode.name + "' is undefined", - index: ruleNode.index, filename: ruleNode.currentFileInfo && ruleNode.currentFileInfo.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}; - } - } - }, - - visitRuleset: function (rulesetNode, visitArgs) { - //at this point rulesets are nested into each other - var rule, rulesets = []; - - this.checkValidNodes(rulesetNode.rules, rulesetNode.firstRoot); - - if (! rulesetNode.root) { - //remove invisible paths - this._compileRulesetPaths(rulesetNode); - - // remove rulesets from this ruleset body and compile them separately - var nodeRules = rulesetNode.rules, nodeRuleCnt = nodeRules ? nodeRules.length : 0; - for (var i = 0; i < nodeRuleCnt; ) { - rule = nodeRules[i]; - if (rule && rule.rules) { - // visit because we are moving them out from being a child - rulesets.push(this._visitor.visit(rule)); - nodeRules.splice(i, 1); - nodeRuleCnt--; - continue; - } - i++; - } - // accept the visitor to remove rules and refactor itself - // then we can decide nogw whether we want it or not - // compile body - if (nodeRuleCnt > 0) { - rulesetNode.accept(this._visitor); - } else { - rulesetNode.rules = null; - } - visitArgs.visitDeeper = false; - - } else { //if (! rulesetNode.root) { - rulesetNode.accept(this._visitor); - visitArgs.visitDeeper = false; - } - - if (rulesetNode.rules) { - this._mergeRules(rulesetNode.rules); - this._removeDuplicateRules(rulesetNode.rules); - } - - //now decide whether we keep the ruleset - if (this.utils.isVisibleRuleset(rulesetNode)) { - rulesetNode.ensureVisibility(); - rulesets.splice(0, 0, rulesetNode); - } - - if (rulesets.length === 1) { - return rulesets[0]; - } - return rulesets; - }, - - _compileRulesetPaths: function(rulesetNode) { - if (rulesetNode.paths) { - rulesetNode.paths = rulesetNode.paths - .filter(function(p) { - var i; - if (p[0].elements[0].combinator.value === ' ') { - p[0].elements[0].combinator = new(tree.Combinator)(''); - } - for (i = 0; i < p.length; i++) { - if (p[i].isVisible() && p[i].getIsOutput()) { - return true; - } - } - return false; - }); - } - }, - - _removeDuplicateRules: function(rules) { - if (!rules) { return; } - - // remove duplicates - var ruleCache = {}, - ruleList, rule, i; - - for (i = rules.length - 1; i >= 0 ; i--) { - rule = rules[i]; - if (rule instanceof tree.Rule) { - if (!ruleCache[rule.name]) { - ruleCache[rule.name] = rule; - } else { - ruleList = ruleCache[rule.name]; - if (ruleList instanceof tree.Rule) { - ruleList = ruleCache[rule.name] = [ruleCache[rule.name].toCSS(this._context)]; - } - var ruleCSS = rule.toCSS(this._context); - if (ruleList.indexOf(ruleCSS) !== -1) { - rules.splice(i, 1); - } else { - ruleList.push(ruleCSS); - } - } - } - } - }, - - _mergeRules: function (rules) { - if (!rules) { return; } - - var groups = {}, - parts, - rule, - key; - - 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); - } - - 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 = []; - } - lastSpacedGroup.push(p); - }); - spacedGroups.push(toExpression(lastSpacedGroup)); - rule.value = toValue(spacedGroups); - } - }); - }, - - 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){ -var tree = require("../tree"); - -var _visitArgs = { visitDeeper: true }, - _hasIndexed = false; - -function _noop(node) { - return 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; - } - } - } - return ticker; -} - -var Visitor = function(implementation) { - this._implementation = implementation; - this._visitFnCache = []; - - if (!_hasIndexed) { - indexNodeTypes(tree, 1); - _hasIndexed = true; - } -}; - -Visitor.prototype = { - visit: function(node) { - if (!node) { - return node; - } - - var nodeTypeIndex = node.typeIndex; - if (!nodeTypeIndex) { - return node; - } - - var visitFnCache = this._visitFnCache, - impl = this._implementation, - aryIndx = nodeTypeIndex << 1, - outAryIndex = aryIndx | 1, - func = visitFnCache[aryIndx], - funcOut = visitFnCache[outAryIndex], - visitArgs = _visitArgs, - fnName; - - visitArgs.visitDeeper = true; - - if (!func) { - fnName = "visit" + node.type; - func = impl[fnName] || _noop; - funcOut = impl[fnName + "Out"] || _noop; - visitFnCache[aryIndx] = func; - visitFnCache[outAryIndex] = funcOut; - } - - if (func !== _noop) { - var newNode = func.call(impl, node, visitArgs); - if (impl.isReplacing) { - node = newNode; - } - } - - if (visitArgs.visitDeeper && node && node.accept) { - node.accept(this); - } - - if (funcOut != _noop) { - funcOut.call(impl, node); - } - - return node; - }, - visitArray: function(nodes, nonReplacing) { - if (!nodes) { - return nodes; - } - - var cnt = nodes.length, i; - - // Non-replacing - if (nonReplacing || !this._implementation.isReplacing) { - for (i = 0; i < cnt; i++) { - this.visit(nodes[i]); - } - return nodes; - } - - // Replacing - var out = []; - for (i = 0; i < cnt; i++) { - var evald = this.visit(nodes[i]); - if (evald === undefined) { continue; } - if (!evald.splice) { - out.push(evald); - } else if (evald.length) { - this.flatten(evald, out); - } - } - return out; - }, - flatten: function(arr, out) { - if (!out) { - out = []; - } - - var cnt, i, item, - nestedCnt, j, nestedItem; - - for (i = 0, cnt = arr.length; i < cnt; i++) { - item = arr[i]; - if (item === undefined) { - continue; - } - if (!item.splice) { - out.push(item); - continue; - } - - for (j = 0, nestedCnt = item.length; j < nestedCnt; j++) { - nestedItem = item[j]; - if (nestedItem === undefined) { - continue; - } - if (!nestedItem.splice) { - out.push(nestedItem); - } else if (nestedItem.length) { - this.flatten(nestedItem, out); - } - } - } - - return out; - } -}; -module.exports = Visitor; - -},{"../tree":62}],92:[function(require,module,exports){ -"use strict"; - -// rawAsap provides everything we need except exception management. -var rawAsap = require("./raw"); -// RawTasks are recycled to reduce GC churn. -var freeTasks = []; -// We queue errors to ensure they are thrown in right order (FIFO). -// Array-as-queue is good enough here, since we are just dealing with exceptions. -var pendingErrors = []; -var requestErrorThrow = rawAsap.makeRequestCallFromTimer(throwFirstError); - -function throwFirstError() { - if (pendingErrors.length) { - throw pendingErrors.shift(); - } -} - -/** - * Calls a task as soon as possible after returning, in its own event, with priority - * over other events like animation, reflow, and repaint. An error thrown from an - * event will not interrupt, nor even substantially slow down the processing of - * other events, but will be rather postponed to a lower priority event. - * @param {{call}} task A callable object, typically a function that takes no - * arguments. - */ -module.exports = asap; -function asap(task) { - var rawTask; - if (freeTasks.length) { - rawTask = freeTasks.pop(); - } else { - rawTask = new RawTask(); - } - rawTask.task = task; - rawAsap(rawTask); -} - -// We wrap tasks with recyclable task objects. A task object implements -// `call`, just like a function. -function RawTask() { - this.task = null; -} - -// The sole purpose of wrapping the task is to catch the exception and recycle -// the task object after its single use. -RawTask.prototype.call = function () { - try { - this.task.call(); - } catch (error) { - if (asap.onerror) { - // This hook exists purely for testing purposes. - // Its name will be periodically randomized to break any code that - // depends on its existence. - asap.onerror(error); - } else { - // In a web browser, exceptions are not fatal. However, to avoid - // slowing down the queue of pending tasks, we rethrow the error in a - // lower priority turn. - pendingErrors.push(error); - requestErrorThrow(); - } - } finally { - this.task = null; - freeTasks[freeTasks.length] = this; - } -}; - -},{"./raw":93}],93:[function(require,module,exports){ -(function (global){ -"use strict"; - -// Use the fastest means possible to execute a task in its own turn, with -// priority over other events including IO, animation, reflow, and redraw -// events in browsers. -// -// An exception thrown by a task will permanently interrupt the processing of -// subsequent tasks. The higher level `asap` function ensures that if an -// exception is thrown by a task, that the task queue will continue flushing as -// soon as possible, but if you use `rawAsap` directly, you are responsible to -// either ensure that no exceptions are thrown from your task, or to manually -// call `rawAsap.requestFlush` if an exception is thrown. -module.exports = rawAsap; -function rawAsap(task) { - if (!queue.length) { - requestFlush(); - flushing = true; - } - // Equivalent to push, but avoids a function call. - queue[queue.length] = task; -} - -var queue = []; -// Once a flush has been requested, no further calls to `requestFlush` are -// necessary until the next `flush` completes. -var flushing = false; -// `requestFlush` is an implementation-specific method that attempts to kick -// off a `flush` event as quickly as possible. `flush` will attempt to exhaust -// the event queue before yielding to the browser's own event loop. -var requestFlush; -// The position of the next task to execute in the task queue. This is -// preserved between calls to `flush` so that it can be resumed if -// a task throws an exception. -var index = 0; -// If a task schedules additional tasks recursively, the task queue can grow -// unbounded. To prevent memory exhaustion, the task queue will periodically -// truncate already-completed tasks. -var capacity = 1024; - -// The flush function processes all tasks that have been scheduled with -// `rawAsap` unless and until one of those tasks throws an exception. -// If a task throws an exception, `flush` ensures that its state will remain -// consistent and will resume where it left off when called again. -// However, `flush` does not make any arrangements to be called again if an -// exception is thrown. -function flush() { - while (index < queue.length) { - var currentIndex = index; - // Advance the index before calling the task. This ensures that we will - // begin flushing on the next task the task throws an error. - index = index + 1; - queue[currentIndex].call(); - // Prevent leaking memory for long chains of recursive calls to `asap`. - // If we call `asap` within tasks scheduled by `asap`, the queue will - // grow, but to avoid an O(n) walk for every task we execute, we don't - // shift tasks off the queue after they have been executed. - // Instead, we periodically shift 1024 tasks off the queue. - if (index > capacity) { - // Manually shift all values starting at the index back to the - // beginning of the queue. - for (var scan = 0, newLength = queue.length - index; scan < newLength; scan++) { - queue[scan] = queue[scan + index]; - } - queue.length -= index; - index = 0; - } - } - queue.length = 0; - index = 0; - flushing = false; -} - -// `requestFlush` is implemented using a strategy based on data collected from -// every available SauceLabs Selenium web driver worker at time of writing. -// https://docs.google.com/spreadsheets/d/1mG-5UYGup5qxGdEMWkhP6BWCz053NUb2E1QoUTU16uA/edit#gid=783724593 - -// Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that -// have WebKitMutationObserver but not un-prefixed MutationObserver. -// Must use `global` instead of `window` to work in both frames and web -// workers. `global` is a provision of Browserify, Mr, Mrs, or Mop. -var BrowserMutationObserver = global.MutationObserver || global.WebKitMutationObserver; - -// MutationObservers are desirable because they have high priority and work -// reliably everywhere they are implemented. -// They are implemented in all modern browsers. -// -// - Android 4-4.3 -// - Chrome 26-34 -// - Firefox 14-29 -// - Internet Explorer 11 -// - iPad Safari 6-7.1 -// - iPhone Safari 7-7.1 -// - Safari 6-7 -if (typeof BrowserMutationObserver === "function") { - requestFlush = makeRequestCallFromMutationObserver(flush); - -// MessageChannels are desirable because they give direct access to the HTML -// task queue, are implemented in Internet Explorer 10, Safari 5.0-1, and Opera -// 11-12, and in web workers in many engines. -// Although message channels yield to any queued rendering and IO tasks, they -// would be better than imposing the 4ms delay of timers. -// However, they do not work reliably in Internet Explorer or Safari. - -// Internet Explorer 10 is the only browser that has setImmediate but does -// not have MutationObservers. -// Although setImmediate yields to the browser's renderer, it would be -// preferrable to falling back to setTimeout since it does not have -// the minimum 4ms penalty. -// Unfortunately there appears to be a bug in Internet Explorer 10 Mobile (and -// Desktop to a lesser extent) that renders both setImmediate and -// MessageChannel useless for the purposes of ASAP. -// https://github.com/kriskowal/q/issues/396 - -// Timers are implemented universally. -// We fall back to timers in workers in most engines, and in foreground -// contexts in the following browsers. -// However, note that even this simple case requires nuances to operate in a -// broad spectrum of browsers. -// -// - Firefox 3-13 -// - Internet Explorer 6-9 -// - iPad Safari 4.3 -// - Lynx 2.8.7 -} else { - requestFlush = makeRequestCallFromTimer(flush); -} - -// `requestFlush` requests that the high priority event queue be flushed as -// soon as possible. -// This is useful to prevent an error thrown in a task from stalling the event -// queue if the exception handled by Node.js’s -// `process.on("uncaughtException")` or by a domain. -rawAsap.requestFlush = requestFlush; - -// To request a high priority event, we induce a mutation observer by toggling -// the text of a text node between "1" and "-1". -function makeRequestCallFromMutationObserver(callback) { - var toggle = 1; - var observer = new BrowserMutationObserver(callback); - var node = document.createTextNode(""); - observer.observe(node, {characterData: true}); - return function requestCall() { - toggle = -toggle; - node.data = toggle; - }; -} - -// The message channel technique was discovered by Malte Ubl and was the -// original foundation for this library. -// http://www.nonblocking.io/2011/06/windownexttick.html - -// Safari 6.0.5 (at least) intermittently fails to create message ports on a -// page's first load. Thankfully, this version of Safari supports -// MutationObservers, so we don't need to fall back in that case. - -// function makeRequestCallFromMessageChannel(callback) { -// var channel = new MessageChannel(); -// channel.port1.onmessage = callback; -// return function requestCall() { -// channel.port2.postMessage(0); -// }; -// } - -// For reasons explained above, we are also unable to use `setImmediate` -// under any circumstances. -// Even if we were, there is another bug in Internet Explorer 10. -// It is not sufficient to assign `setImmediate` to `requestFlush` because -// `setImmediate` must be called *by name* and therefore must be wrapped in a -// closure. -// Never forget. - -// function makeRequestCallFromSetImmediate(callback) { -// return function requestCall() { -// setImmediate(callback); -// }; -// } - -// Safari 6.0 has a problem where timers will get lost while the user is -// scrolling. This problem does not impact ASAP because Safari 6.0 supports -// mutation observers, so that implementation is used instead. -// However, if we ever elect to use timers in Safari, the prevalent work-around -// is to add a scroll event listener that calls for a flush. - -// `setTimeout` does not call the passed callback if the delay is less than -// approximately 7 in web workers in Firefox 8 through 18, and sometimes not -// even then. - -function makeRequestCallFromTimer(callback) { - return function requestCall() { - // We dispatch a timeout with a specified delay of 0 for engines that - // can reliably accommodate that request. This will usually be snapped - // to a 4 milisecond delay, but once we're flushing, there's no delay - // between events. - var timeoutHandle = setTimeout(handleTimer, 0); - // However, since this timer gets frequently dropped in Firefox - // workers, we enlist an interval handle that will try to fire - // an event 20 times per second until it succeeds. - var intervalHandle = setInterval(handleTimer, 50); - - function handleTimer() { - // Whichever timer succeeds will cancel both timers and - // execute the callback. - clearTimeout(timeoutHandle); - clearInterval(intervalHandle); - callback(); - } - }; -} - -// This is for `asap.js` only. -// Its name will be periodically randomized to break any code that depends on -// its existence. -rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer; - -// ASAP was originally a nextTick shim included in Q. This was factored out -// into this ASAP package. It was later adapted to RSVP which made further -// amendments. These decisions, particularly to marginalize MessageChannel and -// to capture the MutationObserver implementation in a closure, were integrated -// back into ASAP proper. -// 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){ -'use strict'; - -var asap = require('asap/raw'); - -function noop() {} - -// States: -// -// 0 - pending -// 1 - fulfilled with _value -// 2 - rejected with _value -// 3 - adopted the state of another promise, _value -// -// once the state is no longer pending (0) it is immutable - -// All `_` prefixed properties will be reduced to `_{random number}` -// at build time to obfuscate them and discourage their use. -// We don't use symbols or Object.defineProperty to fully hide them -// because the performance isn't good enough. - - -// to avoid using try/catch inside critical functions, we -// extract them to here. -var LAST_ERROR = null; -var IS_ERROR = {}; -function getThen(obj) { - try { - return obj.then; - } catch (ex) { - LAST_ERROR = ex; - return IS_ERROR; - } -} - -function tryCallOne(fn, a) { - try { - return fn(a); - } catch (ex) { - LAST_ERROR = ex; - return IS_ERROR; - } -} -function tryCallTwo(fn, a, b) { - try { - fn(a, b); - } catch (ex) { - LAST_ERROR = ex; - return IS_ERROR; - } -} - -module.exports = Promise; - -function Promise(fn) { - if (typeof this !== 'object') { - throw new TypeError('Promises must be constructed via new'); - } - if (typeof fn !== 'function') { - throw new TypeError('not a function'); - } - this._45 = 0; - this._81 = 0; - this._65 = null; - this._54 = null; - if (fn === noop) return; - doResolve(fn, this); -} -Promise._10 = null; -Promise._97 = null; -Promise._61 = noop; - -Promise.prototype.then = function(onFulfilled, onRejected) { - if (this.constructor !== Promise) { - return safeThen(this, onFulfilled, onRejected); - } - var res = new Promise(noop); - handle(this, new Handler(onFulfilled, onRejected, res)); - return res; -}; - -function safeThen(self, onFulfilled, onRejected) { - return new self.constructor(function (resolve, reject) { - var res = new Promise(noop); - res.then(resolve, reject); - handle(self, new Handler(onFulfilled, onRejected, res)); - }); -}; -function handle(self, deferred) { - while (self._81 === 3) { - self = self._65; - } - if (Promise._10) { - Promise._10(self); - } - if (self._81 === 0) { - if (self._45 === 0) { - self._45 = 1; - self._54 = deferred; - return; - } - if (self._45 === 1) { - self._45 = 2; - self._54 = [self._54, deferred]; - return; - } - self._54.push(deferred); - return; - } - handleResolved(self, deferred); -} - -function handleResolved(self, deferred) { - asap(function() { - var cb = self._81 === 1 ? deferred.onFulfilled : deferred.onRejected; - if (cb === null) { - if (self._81 === 1) { - resolve(deferred.promise, self._65); - } else { - reject(deferred.promise, self._65); - } - return; - } - var ret = tryCallOne(cb, self._65); - if (ret === IS_ERROR) { - reject(deferred.promise, LAST_ERROR); - } else { - resolve(deferred.promise, ret); - } - }); -} -function resolve(self, newValue) { - // Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure - if (newValue === self) { - return reject( - self, - new TypeError('A promise cannot be resolved with itself.') - ); - } - if ( - newValue && - (typeof newValue === 'object' || typeof newValue === 'function') - ) { - var then = getThen(newValue); - if (then === IS_ERROR) { - return reject(self, LAST_ERROR); - } - if ( - then === self.then && - newValue instanceof Promise - ) { - self._81 = 3; - self._65 = newValue; - finale(self); - return; - } else if (typeof then === 'function') { - doResolve(then.bind(newValue), self); - return; - } - } - self._81 = 1; - self._65 = newValue; - finale(self); -} - -function reject(self, newValue) { - self._81 = 2; - self._65 = newValue; - if (Promise._97) { - Promise._97(self, newValue); - } - finale(self); -} -function finale(self) { - if (self._45 === 1) { - handle(self, self._54); - self._54 = null; - } - if (self._45 === 2) { - for (var i = 0; i < self._54.length; i++) { - handle(self, self._54[i]); - } - self._54 = null; - } -} - -function Handler(onFulfilled, onRejected, promise){ - this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null; - this.onRejected = typeof onRejected === 'function' ? onRejected : null; - this.promise = promise; -} - -/** - * Take a potentially misbehaving resolver function and make sure - * onFulfilled and onRejected are only called once. - * - * Makes no guarantees about asynchrony. - */ -function doResolve(fn, promise) { - var done = false; - var res = tryCallTwo(fn, function (value) { - if (done) return; - done = true; - resolve(promise, value); - }, function (reason) { - if (done) return; - done = true; - reject(promise, reason); - }) - if (!done && res === IS_ERROR) { - done = true; - reject(promise, LAST_ERROR); - } -} - -},{"asap/raw":93}],95:[function(require,module,exports){ -'use strict'; - -//This file contains the ES6 extensions to the core Promises/A+ API - -var Promise = require('./core.js'); - -module.exports = Promise; - -/* Static Functions */ - -var TRUE = valuePromise(true); -var FALSE = valuePromise(false); -var NULL = valuePromise(null); -var UNDEFINED = valuePromise(undefined); -var ZERO = valuePromise(0); -var EMPTYSTRING = valuePromise(''); - -function valuePromise(value) { - var p = new Promise(Promise._61); - p._81 = 1; - p._65 = value; - return p; -} -Promise.resolve = function (value) { - if (value instanceof Promise) return value; - - if (value === null) return NULL; - if (value === undefined) return UNDEFINED; - if (value === true) return TRUE; - if (value === false) return FALSE; - if (value === 0) return ZERO; - if (value === '') return EMPTYSTRING; - - if (typeof value === 'object' || typeof value === 'function') { - try { - var then = value.then; - if (typeof then === 'function') { - return new Promise(then.bind(value)); - } - } catch (ex) { - return new Promise(function (resolve, reject) { - reject(ex); - }); - } - } - return valuePromise(value); -}; - -Promise.all = function (arr) { - var args = Array.prototype.slice.call(arr); - - return new Promise(function (resolve, reject) { - if (args.length === 0) return resolve([]); - var remaining = args.length; - function res(i, val) { - if (val && (typeof val === 'object' || typeof val === 'function')) { - if (val instanceof Promise && val.then === Promise.prototype.then) { - while (val._81 === 3) { - val = val._65; - } - if (val._81 === 1) return res(i, val._65); - if (val._81 === 2) reject(val._65); - val.then(function (val) { - res(i, val); - }, reject); - return; - } else { - var then = val.then; - if (typeof then === 'function') { - var p = new Promise(then.bind(val)); - p.then(function (val) { - res(i, val); - }, reject); - return; - } - } - } - args[i] = val; - if (--remaining === 0) { - resolve(args); - } - } - for (var i = 0; i < args.length; i++) { - res(i, args[i]); - } - }); -}; - -Promise.reject = function (value) { - return new Promise(function (resolve, reject) { - reject(value); - }); -}; - -Promise.race = function (values) { - return new Promise(function (resolve, reject) { - values.forEach(function(value){ - Promise.resolve(value).then(resolve, reject); - }); - }); -}; - -/* Prototype Methods */ - -Promise.prototype['catch'] = function (onRejected) { - return this.then(null, onRejected); -}; - -},{"./core.js":94}],96:[function(require,module,exports){ -// should work in any browser without browserify - -if (typeof Promise.prototype.done !== 'function') { - Promise.prototype.done = function (onFulfilled, onRejected) { - var self = arguments.length ? this.then.apply(this, arguments) : this - self.then(null, function (err) { - setTimeout(function () { - throw err - }, 0) - }) - } -} -},{}],97:[function(require,module,exports){ -// not "use strict" so we can declare global "Promise" - -var asap = require('asap'); - -if (typeof Promise === 'undefined') { - Promise = require('./lib/core.js') - require('./lib/es6-extensions.js') -} - -require('./polyfill-done.js'); - -},{"./lib/core.js":94,"./lib/es6-extensions.js":95,"./polyfill-done.js":96,"asap":92}]},{},[2])(2) -}); \ No newline at end of file diff --git a/vendor/less/dist/less-2.7.1.min.js b/vendor/less/dist/less-2.7.1.min.js deleted file mode 100644 index b271f4f32..000000000 --- a/vendor/less/dist/less-2.7.1.min.js +++ /dev/null @@ -1,17 +0,0 @@ -/*! - * Less - Leaner CSS v2.7.1 - * http://lesscss.org - * - * Copyright (c) 2009-2016, Alexis Sellier - * Licensed under the Apache-2.0 License. - * - */ - - /** * @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;d.length>g;g++)e(d[g]);return e}({1:[function(a,b,c){var d=a("./utils").addDataAttr,e=a("./browser");b.exports=function(a,b){d(b,e.currentScript(a)),void 0===b.isFileProtocol&&(b.isFileProtocol=/^(file|(chrome|safari)(-extension)?|resource|qrc|app):/.test(a.location.protocol)),b.async=b.async||!1,b.fileAsync=b.fileAsync||!1,b.poll=b.poll||(b.isFileProtocol?1e3:1500),b.env=b.env||("127.0.0.1"==a.location.hostname||"0.0.0.0"==a.location.hostname||"localhost"==a.location.hostname||a.location.port&&a.location.port.length>0||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");return c=c||{},f&&b.lastModified&&new Date(b.lastModified).valueOf()===new Date(f).valueOf()&&(!c&&!g||JSON.stringify(c)===g)?e:void 0}}}},{}],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)+":

      "+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.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&&300>b.status?c(b.responseText,b.getResponseHeader("Last-Modified")):"function"==typeof d&&d(b.status,a)}var i=d(),j=b.isFileProtocol?b.fileAsync:!0;"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&&300>i.status?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;d.length>e;e++)if(b=d[e],b.type.match(t)){var f=g(c);f.modifyVars=a;var i=b.innerHTML||"";f.filename=m.location.href.replace(/#.*$/,""),n.render(i,f,h(function(a,b,c){b?r.add(b,"inline"):(a.type="text/css",a.styleSheet?a.styleSheet.cssText=c.css:a.innerHTML=c.css)},null,b))}}function j(a,b,e,h,i){function j(c){var d=c.contents,g=c.filename,i=c.webInfo,j={currentDirectory:q.getPath(g),filename:g,rootFilename:g,relativeUrls:k.relativeUrls};if(j.entryPath=j.currentDirectory,j.rootpath=k.rootpath||j.currentDirectory,i){i.remaining=h;var l=s.getCSS(g,i,k.modifyVars);if(!e&&l)return i.local=!0,void b(null,l,d,a,i,g)}r.remove(g),k.rootFileInfo=j,n.render(d,k,function(c,e){c?(c.href=g,b(c)):(e.css=f(e.css),s.setCSS(a.href,i.lastModified,k.modifyVars,e.css),b(null,e.css,d,a,i,g))})}var k=g(c);d(k,a),k.mime=a.type,i&&(k.modifyVars=i),q.loadFile(a.href,null,k,o,function(a,c){return a?void b(a):void j(c)})}function k(a,b,c){for(var d=0;n.sheets.length>d;d++)j(n.sheets[d],a,b,n.sheets.length-(d+1),c)}function l(){"development"===n.env&&(n.watchTimer=setInterval(function(){n.watchMode&&(q.clearFileCache(),k(function(a,c,d,f,g){a?r.add(a,a.href||f.href):c&&e.createCSS(b.document,c,f)}))},c.poll))}var m=b.document,n=a("../less")();n.options=c;var o=n.environment,p=a("./file-manager")(c,n.logger),q=new p;o.addFileManager(q),n.FileManager=p,a("./log-listener")(n,c);var r=a("./error-reporting")(b,n,c),s=n.cache=c.cache||a("./cache")(b,c,n.logger);a("./image-size")(n.environment),c.functions&&n.functions.functionRegistry.addMultiple(c.functions);var t=/^text\/(x-)?less$/;return n.watch=function(){return n.watchMode||(n.env="development",l()),this.watchMode=!0,!0},n.unwatch=function(){return clearInterval(n.watchTimer),this.watchMode=!1,!1},n.registerStylesheetsImmediately=function(){var a=m.getElementsByTagName("link");n.sheets=[];for(var b=0;a.length>b;b++)("stylesheet/less"===a[b].rel||a[b].rel.match(/stylesheet/)&&a[b].type.match(t))&&n.sheets.push(a[b])},n.registerStylesheets=function(){return new Promise(function(a,b){n.registerStylesheetsImmediately(),a()})},n.modifyVars=function(a){return n.refresh(!0,a,!1)},n.refresh=function(a,c,d){return(a||d)&&d!==!1&&q.clearFileCache(),new Promise(function(d,f){var g,h,j,l;g=h=new Date,l=n.sheets.length,0===l?(h=new Date,j=h-g,n.logger.info("Less has finished and no sheets were loaded."),d({startTime:g,endTime:h,totalMilliseconds:j,sheets:n.sheets.length})):k(function(a,c,i,k,m){return a?(r.add(a,a.href||k.href),void f(a)):(n.logger.info(m.local?"Loading "+k.href+" from cache.":"Rendered "+k.href+" successfully."),e.createCSS(b.document,c,k),n.logger.info("CSS for "+k.href+" generated in "+(new Date-h)+"ms"),l--,0===l&&(j=new Date-g,n.logger.info("Less has finished. CSS generated in "+j+"ms"),d({startTime:g,endTime:h,totalMilliseconds:j,sheets:n.sheets.length})),void(h=new Date))},a,c),i(c)})},n.refreshStyles=i,n}},{"../less":31,"./browser":3,"./cache":4,"./error-reporting":5,"./file-manager":6,"./image-size":7,"./log-listener":9,"./utils":10}],9:[function(a,b,c){b.exports=function(a,b){var c=4,d=3,e=2,f=1;b.logLevel="undefined"!=typeof b.logLevel?b.logLevel:"development"===b.env?d:f,b.loggers||(b.loggers=[{debug:function(a){b.logLevel>=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;b.loggers.length>g;g++)a.logger.addListener(b.loggers[g])}},{}],10:[function(a,b,c){b.exports={extractId:function(a){return a.replace(/^[a-z-]+:\/+?[^\/]+/,"").replace(/[\?\&]livereload=\w+/,"").replace(/^\//,"").replace(/\.[a-zA-Z]+$/,"").replace(/[^\.\w-]+/g,"-").replace(/\./g,":")},addDataAttr:function(a,b){for(var c in b.dataset)if(b.dataset.hasOwnProperty(c))if("env"===c||"dumpLineNumbers"===c||"rootpath"===c||"errorReporting"===c)a[c]=b.dataset[c];else try{a[c]=JSON.parse(b.dataset[c])}catch(d){}}}},{}],11:[function(a,b,c){var d={};b.exports=d;var e=function(a,b,c){if(a)for(var d=0;c.length>d;d++)a.hasOwnProperty(c[d])&&(b[c[d]]=a[c[d]])},f=["paths","relativeUrls","rootpath","strictImports","insecure","dumpLineNumbers","compress","syncImport","chunkInput","mime","useFileCache","processImports","pluginManager"];d.Parse=function(a){e(a,this,f),"string"==typeof this.paths&&(this.paths=[this.paths])};var g=["paths","compress","ieCompat","strictMath","strictUnits","sourceMap","importMultiple","urlArgs","javascriptEnabled","pluginManager","importantScope"];d.Eval=function(a,b){e(a,this,g),"string"==typeof this.paths&&(this.paths=[this.paths]),this.frames=b||[],this.importantScope=this.importantScope||[]},d.Eval.prototype.inParenthesis=function(){this.parensStack||(this.parensStack=[]),this.parensStack.push(!0)},d.Eval.prototype.outOfParenthesis=function(){this.parensStack.pop()},d.Eval.prototype.isMathOn=function(){return this.strictMath?this.parensStack&&this.parensStack.length:!0},d.Eval.prototype.isPathRelative=function(a){return!/^(?:[a-z-]+:|\/|#)/i.test(a)},d.Eval.prototype.normalizePath=function(a){var b,c=a.split("/").reverse();for(a=[];0!==c.length;)switch(b=c.pop()){case".":break;case"..":0===a.length||".."===a[a.length-1]?a.push(b):a.pop();break;default:a.push(b)}return a.join("/")}},{}],12:[function(a,b,c){b.exports={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgrey:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"}},{}],13:[function(a,b,c){b.exports={colors:a("./colors"),unitConversions:a("./unit-conversions")}},{"./colors":12,"./unit-conversions":14}],14:[function(a,b,c){b.exports={length:{m:1,cm:.01,mm:.001,"in":.0254,px:.0254/96,pt:.0254/72,pc:.0254/72*12},duration:{s:1,ms:.001},angle:{rad:1/(2*Math.PI),deg:1/360,grad:.0025,turn:1}}},{}],15:[function(a,b,c){var d=function(){};d.prototype.getPath=function(a){var b=a.lastIndexOf("?");return b>0&&(a=a.slice(0,b)),b=a.lastIndexOf("/"),0>b&&(b=a.lastIndexOf("\\")),0>b?"":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;d>c&&h.directories[c]===g.directories[c];c++);for(f=h.directories.slice(c),e=g.directories.slice(c),c=0;f.length-1>c;c++)i+="../";for(c=0;e.length-1>c;c++)i+=e[c]+"/";return i},d.prototype.extractUrlParts=function(a,b){var c,d,e=/^((?:[a-z-]+:)?\/{2}(?:[^\/\?#]*\/)|([\/\\]))?((?:[^\/\\\?#]*[\/\\])*)([^\/\\\?#]*)([#\?].*)?$/i,f=a.match(e),g={},h=[];if(!f)throw new Error("Could not parse sheet href - '"+a+"'");if(b&&(!f[1]||f[2])){if(d=b.match(e),!d)throw new Error("Could not parse page url - '"+b+"'");f[1]=f[1]||d[1]||"",f[2]||(f[3]=d[3]+f[3])}if(f[3]){for(h=f[3].replace(/\\/g,"/").split("/"),c=0;h.length>c;c++)"."===h[c]&&(h.splice(c,1),c-=1);for(c=0;h.length>c;c++)".."===h[c]&&c>0&&(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;e.length>f;f++){var g=e[f],h=a[g];h?this[g]=h.bind(a):d.length>f&&this.warn("missing required function in environment - "+g)}};e.prototype.getFileManager=function(a,b,c,e,f){a||d.warn("getFileManager called with no filename.. Please report this issue. continuing."),null==b&&d.warn("getFileManager called with null directory.. Please report this issue. continuing.");var g=this.fileManagers;c.pluginManager&&(g=[].concat(g).concat(c.pluginManager.getFileManagers()));for(var h=g.length-1;h>=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;3>l;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,1>=a?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=0>a?a+1:a>1?a-1:a,1>6*a?i+(j-i)*a*6:1>2*a?j:2>3*a?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=.5>=c?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=0>d?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;"undefined"==typeof b&&(b=h.rgba(0,0,0,1)),"undefined"==typeof c&&(c=h.rgba(255,255,255,1));var e,f,g=a.luma(),i=b.luma(),j=c.luma();return e=g>i?(g+.05)/(i+.05):(i+.05)/(g+.05),f=g>j?(g+.05)/(j+.05):(j+.05)/(g+.05),e>f?b:c},argb:function(a){return new l(a.toARGB())},color:function(a){if(a instanceof k&&/^#([a-f0-9]{6}|[a-f0-9]{3})$/i.test(a.value))return new j(a.value.slice(1));if(a instanceof j||(a=j.fromKeyword(a.value)))return a.value=void 0,a;throw{type:"Argument",message:"argument must be a color keyword or 3/6 digit hex e.g. #FFF"}},tint:function(a,b){return h.mix(h.rgb(255,255,255),a,b)},shade:function(a,b){return h.mix(h.rgb(0,0,0),a,b)}},m.addMultiple(h)},{"../tree/anonymous":46,"../tree/color":50,"../tree/dimension":56,"../tree/quoted":73,"./function-registry":22}],19:[function(a,b,c){b.exports=function(b){var c=a("../tree/quoted"),d=a("../tree/url"),e=a("./function-registry"),f=function(a,b){return new d(b,a.index,a.currentFileInfo).eval(a.context)},g=a("../logger");e.add("data-uri",function(a,e){e||(e=a,a=null);var h=a&&a.value,i=e.value,j=this.currentFileInfo,k=j.relativeUrls?j.currentDirectory:j.entryPath,l=i.indexOf("#"),m="";-1!==l&&(m=i.slice(l),i=i.slice(0,l));var n=b.getFileManager(i,k,this.context,b,!0);if(!n)return f(this,e);var o=!1;if(a)o=/;base64$/.test(h);else{if(h=b.mimeLookup(i),"image/svg+xml"===h)o=!1;else{var p=b.charsetLookup(h);o=["US-ASCII","UTF-8"].indexOf(p)<0}o&&(h+=";base64")}var q=n.loadFileSync(i,k,this.context,b);if(!q.contents)return g.warn("Skipped data-uri embedding of "+i+" because file not found"),f(this,e||a);var r=q.contents;if(o&&!b.encodeBase64)return f(this,e);r=o?b.encodeBase64(r):encodeURIComponent(r);var s="data:"+h+","+r+m,t=32768;return s.length>=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;return null!=a?a?d.True:d.False:void 0},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;b.length>c;c++)if(g=b[c],g instanceof d)if(h=""===g.unit.toString()&&void 0!==l?new d(g.value,l).unify():g.unify(),j=""===h.unit.toString()&&void 0!==k?k:h.unit.toString(),k=""!==j&&void 0===k||""!==j&&""===m[0].unify().unit.toString()?j:k,l=""!==j&&void 0===l?g.unit.toString():l,f=void 0!==n[""]&&""!==j&&j===k?n[""]:n[j],void 0!==f)i=""===m[f].unit.toString()&&void 0!==l?new d(m[f].value,l).unify():m[f].unify(),(a&&i.value>h.value||!a&&h.value>i.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;b.length>e;e++)c=c.replace(/%[sda]/i,function(a){var c="Quoted"===b[e].type&&a.match(/s/i)?b[e].value:b[e].toCSS();return a.match(/[A-Z]$/)?encodeURIComponent(c):c});return c=c.replace(/%%/g,"%"),new d(a.quote||"",c,a.escaped); -}})},{"../tree/anonymous":46,"../tree/javascript":63,"../tree/quoted":73,"./function-registry":22}],28:[function(a,b,c){b.exports=function(b){var c=a("../tree/dimension"),d=a("../tree/color"),e=a("../tree/expression"),f=a("../tree/quoted"),g=a("../tree/url"),h=a("./function-registry");h.add("svg-gradient",function(a){function b(){throw{type:"Argument",message:"svg-gradient expects direction, start_color [start_position], [color position,]..., end_color [end_position] or direction, color list"}}var h,i,j,k,l,m,n,o,p="linear",q='x="0" y="0" width="1" height="1"',r={compress:!1},s=a.toCSS(r);switch(2==arguments.length?(2>arguments[1].value.length&&b(),h=arguments[1].value):3>arguments.length?b():h=Array.prototype.slice.call(arguments,1),s){case"to bottom":i='x1="0%" y1="0%" x2="0%" y2="100%"';break;case"to right":i='x1="0%" y1="0%" x2="100%" y2="0%"';break;case"to bottom right":i='x1="0%" y1="0%" x2="100%" y2="100%"';break;case"to top right":i='x1="0%" y1="100%" x2="100%" y2="0%"';break;case"ellipse":case"ellipse at center":p="radial",i='cx="50%" cy="50%" r="75%"',q='x="-50" y="-50" width="101" height="101"';break;default:throw{type:"Argument",message:"svg-gradient direction must be 'to bottom', 'to right', 'to bottom right', 'to top right' or 'ellipse at center'"}}for(j='<'+p+'Gradient id="gradient" gradientUnits="userSpaceOnUse" '+i+">",k=0;h.length>k;k+=1)h[k]instanceof e?(l=h[k].value[0],m=h[k].value[1]):(l=h[k],m=void 0),l instanceof d&&((0===k||k+1===h.length)&&void 0===m||m instanceof c)||b(),n=m?m.toCSS(r):0===k?"0%":"100%",o=l.alpha,j+='o?' stop-opacity="'+o+'"':"")+"/>";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,1],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;this._listeners.length>b;b++)if(this._listeners[b]===a)return void this._listeners.splice(b,1)},_fireEvent:function(a,b){for(var c=0;this._listeners.length>c;c++){var d=this._listeners[c][a];d&&d(b)}},_listeners:[]}},{}],34:[function(a,b,c){var d=a("./less-error"),e=a("./transform-tree"),f=a("./logger");b.exports=function(a){var b=function(a,b){this.root=a,this.imports=b};return b.prototype.toCSS=function(b){var c,g,h={};try{c=e(this.root,b)}catch(i){throw new d(i,this.imports)}try{var j=Boolean(b.compress);j&&f.warn("The compress option has been deprecated. We recommend you use a dedicated css minifier, for instance see less-plugin-clean-css.");var k={compress:j,dumpLineNumbers:b.dumpLineNumbers,strictUnits:Boolean(b.strictUnits),numPrecision:8};b.sourceMap?(g=new a(b.sourceMap),h.css=g.toCSS(c,k,this.imports)):h.css=c.toCSS(k)}catch(i){throw new d(i,this.imports)}if(b.pluginManager)for(var l=b.pluginManager.getPostProcessors(),m=0;l.length>m;m++)h.css=l[m].process(h.css,{sourceMap:g,options:b,imports:this.imports});b.sourceMap&&(h.map=g.getExternalSourceMap()),h.imports=[];for(var n in this.imports.files)this.imports.files.hasOwnProperty(n)&&n!==this.imports.rootFilename&&h.imports.push(n);return h},b}},{"./less-error":32,"./logger":33,"./transform-tree":44}],35:[function(a,b,c){var d,e=a("./contexts"),f=a("./parser/parser"),g=a("./plugin-manager");b.exports=function(b,c,h){var i=function(b,c,j){if(c=c||{},"function"==typeof c&&(j=c,c={}),!j){d||(d="undefined"==typeof Promise?a("promise"):Promise);var k=this;return new d(function(a,d){i.call(k,b,c,function(b,c){b?d(b):a(c)})})}var l,m,n=new g(this);if(n.addPlugins(c.plugins),c.pluginManager=n,l=new e.Parse(c),c.rootFileInfo)m=c.rootFileInfo;else{var o=c.filename||"input",p=o.replace(/[^\/\\]*$/,"");m={filename:o,relativeUrls:l.relativeUrls,rootpath:l.rootpath||"",currentDirectory:p,entryPath:p,rootFilename:o},m.rootpath&&"/"!==m.rootpath.slice(-1)&&(m.rootpath+="/")}var q=new h(l,m);new f(l,q,m).parse(b,function(a,b){return a?j(a):void j(null,b,q,c)},c)};return i}},{"./contexts":11,"./parser/parser":38,"./plugin-manager":39,promise:void 0}],36:[function(a,b,c){b.exports=function(a,b){function c(b){var c=h-q;512>c&&!b||!c||(p.push(a.slice(q,h+1)),q=h+1)}var d,e,f,g,h,i,j,k,l,m=a.length,n=0,o=0,p=[],q=0;for(h=0;m>h;h++)if(j=a.charCodeAt(h),!(j>=97&&122>=j||34>j))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(m-1>h){h++;continue}return b("unescaped `\\`",h);case 34:case 39:case 96:for(l=0,i=h,h+=1;m>h;h++)if(k=a.charCodeAt(h),!(k>96)){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;m>h&&(k=a.charCodeAt(h),!(13>=k)||10!=k&&13!=k);h++);else if(42==k){for(f=i=h,h+=2;m-1>h&&(k=a.charCodeAt(h),125==k&&(g=h),42!=k||47!=a.charCodeAt(h+1));h++);if(h==m-1)return b("missing closing `*/`",i);h++}continue;case 42:if(m-1>h&&47==a.charCodeAt(h+1))return b("unmatched `/*`",h);continue}return 0!==n?f>d&&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;t>k.i;k.i++){if(e=v.charCodeAt(k.i),k.autoCommentAbsorb&&e===r){if(f=v.charAt(k.i+1),"/"===f){j={index:k.i,isLineComment:!0};var w=v.indexOf("\n",k.i+2);0>w&&(w=t),k.i=w,j.text=v.substr(j.index,k.i-j.index),k.commentStore.push(j);continue}if("*"===f){var x=v.indexOf("*/",k.i+2);if(x>=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(g.length-1>c)return h=g[++c],a(0),!0;k.finished=!0}return p!==k.i||q!==c}var b,c,e,f,g,h,i,j=[],k={},l=32,m=9,n=10,o=13,p=43,q=44,r=47,s=57;return k.save=function(){i=k.i,j.push({current:h,i:k.i,j:c})},k.restore=function(a){(k.i>e||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;d>e;e++)if(b.charAt(k.i+e)!==c.charAt(e))return null;return a(d),c},k.$quoted=function(){var c=b.charAt(k.i);if("'"===c||'"'===c){for(var d=b.length,e=k.i,f=1;d>f+e;f++){var g=b.charAt(f+e);switch(g){case"\\":f++;continue;case"\r":case"\n":break;case c:var h=b.substr(e,f+1);return a(f+1),h}}return null}},k.autoCommentAbsorb=!0,k.commentStore=[],k.finished=!1,k.peek=function(a){if("string"==typeof a){for(var c=0;a.length>c;c++)if(b.charAt(k.i+c)!==a.charAt(c))return!1;return!0}return a.test(h)},k.peekChar=function(a){return b.charAt(k.i)===a},k.currentChar=function(){return b.charAt(k.i)},k.getInput=function(){return b},k.peekNotNumeric=function(){var a=b.charCodeAt(k.i);return a>s||p>a||a===r||a===q},k.start=function(f,j,l){b=f,k.i=c=i=e=0,g=j?d(f,l):[f],h=g[0],a(0)},k.end=function(){var a,c=k.i>=b.length;return e>k.i&&(a=f,k.i=e),{isFinished:c,furthest:k.i,furthestPossibleErrorMessage:a,furthestReachedEnd: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;r.length>s;s++)g=r[s].process(g,{context:a,imports:b,fileInfo:c});(l||i&&i.banner)&&(q=(i&&i.banner?i.banner:"")+l,n=b.contentsIgnoredChars,n[c.filename]=n[c.filename]||0,n[c.filename]+=q.length),g=g.replace(/\r\n?/g,"\n"),g=q+g.replace(/^\uFEFF/,"")+m,b.contents[c.filename]=g;try{o.start(g,a.chunkInput,function(a,e){throw new d({index:e,type:"Parse",message:a,filename:c.filename},b)}),k=new e.Ruleset(null,this.parsers.primary()),k.root=!0,k.firstRoot=!0}catch(t){return h(new d(t,b,c.filename))}var u=o.end();if(!u.isFinished){var v=u.furthestPossibleErrorMessage;v||(v="Unrecognised input","}"===u.furthestChar?v+=". Possibly missing opening '{'":")"===u.furthestChar?v+=". Possibly missing opening '('":u.furthestReachedEnd&&(v+=". Possibly missing something")),p=new d({type:"Parse",message:v,index:u.furthest,filename:c.filename},b)}var w=function(a){return a=p||a||b.error,a?(a instanceof d||(a=new d(a,b,c.filename)),h(a)):h(null,k)};return a.processImports===!1?w():void new f.ImportVisitor(b,w).run(k)},parsers:n={primary:function(){for(var a,b=this.mixin,c=[];;){for(;;){if(a=this.comment(),!a)break;c.push(a)}if(o.finished)break;if(o.peek("}"))break;if(a=this.extendRule())c=c.concat(a);else if(a=b.definition()||this.rule()||this.ruleset()||b.call()||this.rulesetCall()||this.entities.call()||this.directive())c.push(a);else{for(var d=!1;o.$char(";");)d=!0;if(!d)break}}return c},comment:function(){if(o.commentStore.length){var a=o.commentStore.shift();return new e.Comment(a.text,a.isLineComment,a.index,c)}},entities:{quoted:function(){var a,b=o.i,d=!1;return o.save(),o.$char("~")&&(d=!0),(a=o.$quoted())?(o.forget(),new e.Quoted(a.charAt(0),a.substr(1,a.length-2),d,b,c)):void o.restore()},keyword:function(){var a=o.$char("%")||o.$re(/^[_A-Za-z-][_A-Za-z0-9-]*/);return a?e.Color.fromKeyword(a)||new e.Keyword(a):void 0},call:function(){var a,b,d,f,g=o.i;if(!o.peek(/^url\(/i))return o.save(),(a=o.$re(/^([\w-]+|%|progid:[\w\.]+)\(/))?(a=a[1],b=a.toLowerCase(),"alpha"===b&&(f=n.alpha())?(o.forget(),f):(d=this.arguments(),o.$char(")")?(o.forget(),new e.Call(a,d,g,c)):void o.restore("Could not parse call arguments or missing ')'"))):void o.forget()},arguments:function(){var a,b,c,d=[],f=[],g=[];for(o.save();;){if(c=n.detachedRuleset()||this.assignment()||n.expression(),!c)break;b=c,c.value&&1==c.value.length&&(b=c.value[0]),b&&g.push(b),f.push(b),o.$char(",")||(o.$char(";")||a)&&(a=!0,g.length>1&&(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;return"@"===o.currentChar()&&(a=o.$re(/^@@?[\w-]+/))?new e.Variable(a,b,c):void 0},variableCurly:function(){var a,b=o.i;return"@"===o.currentChar()&&(a=o.$re(/^@\{([\w-]+)\}/))?new e.Variable("@"+a[1],b,c):void 0},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;return a=o.$re(/^U\+[0-9a-fA-F?]+(\-[0-9a-fA-F?]+)?/),a?new e.UnicodeDescriptor(a[0]):void 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;return"@"===o.currentChar()&&(a=o.$re(/^(@[\w-]+)\s*:/))?a[1]:void 0},rulesetCall:function(){var a;return"@"===o.currentChar()&&(a=o.$re(/^(@[\w-]+)\(\s*\)\s*;/))?new e.RulesetCall(a[1]):void 0},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;return 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?new e.Element(b,a,f,c):void 0},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;return o.$char("{")&&(a=this.primary())&&o.$char("}")?a:void 0},blockRuleset:function(){var a=this.block();return a&&(a=new e.Ruleset(null,a)),a},detachedRuleset:function(){var a=this.blockRuleset();return a?new e.DetachedRuleset(a):void 0},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(/^([^@+\/'"*`(;{}-]*);/);return a?new e.Anonymous(a[1]):void 0},"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)/);return a?a[1]:void 0},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);return o.forget(),f.length>0?new e.Expression(f):void 0},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);return b.length>0?new e.Value(b):void 0},important:function(){return"!"===o.currentChar()?o.$re(/^! *important/):void 0},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;return a=this.addition()||f.keyword()||f.quoted(),a?(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):void 0},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);return c.length>0?new e.Expression(c):void 0},property:function(){var a=o.$re(/^(\*?-?[_a-zA-Z0-9-]+)\s*:/);return a?a[1]:void 0},ruleProperty:function(){function a(a){var b=o.i,c=o.$re(a);return c?(g.push(b),f.push(c[1])):void 0}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;f.length>d;d++)b=f[d],f[d]="@"!==b.charAt(0)?new e.Keyword(b):new e.Variable("@"+b.slice(2,-1),g[d],c);return f}o.restore()}}}};i.serializeVars=function(a){var b="";for(var c in a)if(Object.hasOwnProperty.call(a,c)){var d=a[c];b+=("@"===c[0]?"":"@")+c+": "+d+(";"===String(d).slice(-1)?"":";")}return b},b.exports=i},{"../less-error":32,"../tree":62,"../utils":83,"../visitors":87,"./parser-input":37}],39:[function(a,b,c){var d=function(a){this.less=a,this.visitors=[],this.preProcessors=[],this.postProcessors=[],this.installedPlugins=[],this.fileManagers=[]};d.prototype.addPlugins=function(a){if(a)for(var b=0;a.length>b;b++)this.addPlugin(a[b])},d.prototype.addPlugin=function(a){this.installedPlugins.push(a),a.install(this.less,this)},d.prototype.addVisitor=function(a){this.visitors.push(a)},d.prototype.addPreProcessor=function(a,b){var c;for(c=0;this.preProcessors.length>c&&!(this.preProcessors[c].priority>=b);c++);this.preProcessors.splice(c,0,{preProcessor:a,priority:b})},d.prototype.addPostProcessor=function(a,b){var c;for(c=0;this.postProcessors.length>c&&!(this.postProcessors[c].priority>=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;this.preProcessors.length>b;b++)a.push(this.preProcessors[b].preProcessor);return a},d.prototype.getPostProcessors=function(){for(var a=[],b=0;this.postProcessors.length>b;b++)a.push(this.postProcessors[b].postProcessor);return a},d.prototype.getVisitors=function(){return this.visitors},d.prototype.getFileManagers=function(){return this.fileManagers},b.exports=d},{}],40:[function(a,b,c){var d=a("../less-error"),e=a("../tree"),f=b.exports=function(a,b){this.fileInfo=b};f.prototype.eval=function(a,b){var c,f,g={}; -f={add:function(a,b){g[a]=b},addMultiple:function(a){Object.keys(a).forEach(function(b){g[b]=a[b]})}};try{c=new Function("functions","tree","fileInfo",a),c(f,e,this.fileInfo)}catch(h){b(new d({message:"Plugin evaluation error: '"+h.name+": "+h.message.replace(/["]/g,"'")+"'",filename:this.fileInfo.filename}),null)}b(null,{functions:g})}},{"../less-error":32,"../tree":62}],41:[function(a,b,c){var d;b.exports=function(b,c,e){var f=function(b,e,g){if("function"==typeof e&&(g=e,e={}),!g){d||(d="undefined"==typeof Promise?a("promise"):Promise);var h=this;return new d(function(a,c){f.call(h,b,e,function(b,d){b?c(b):a(d)})})}this.parse(b,e,function(a,b,d,e){if(a)return g(a);var f;try{var h=new c(b,d);f=h.toCSS(e)}catch(a){return g(a)}g(null,f)})};return f}},{promise:void 0}],42:[function(a,b,c){b.exports=function(a,b){var c=function(a){this.options=a};return c.prototype.toCSS=function(b,c,d){var e=new a({contentsIgnoredCharsMap:d.contentsIgnoredChars,rootNode:b,contentsMap:d.contents,sourceMapFilename:this.options.sourceMapFilename,sourceMapURL:this.options.sourceMapURL,outputFilename:this.options.sourceMapOutputFilename,sourceMapBasepath:this.options.sourceMapBasepath,sourceMapRootpath:this.options.sourceMapRootpath,outputSourceFiles:this.options.outputSourceFiles,sourceMapGenerator:this.options.sourceMapGenerator,sourceMapFileInline:this.options.sourceMapFileInline}),f=e.toCSS(c);return this.sourceMap=e.sourceMap,this.sourceMapURL=e.sourceMapURL,this.options.sourceMapInputFilename&&(this.sourceMapInputFilename=e.normalizeFilename(this.options.sourceMapInputFilename)),f+this.getCSSAppendage()},c.prototype.getCSSAppendage=function(){var a=this.sourceMapURL;if(this.options.sourceMapFileInline){if(void 0===this.sourceMap)return"";a="data:application/json;base64,"+b.encodeBase64(this.sourceMap)}return a?"/*# sourceMappingURL="+a+" */":""},c.prototype.getExternalSourceMap=function(){return this.sourceMap},c.prototype.setExternalSourceMap=function(a){this.sourceMap=a},c.prototype.isInline=function(){return this.options.sourceMapFileInline},c.prototype.getSourceMapURL=function(){return this.sourceMapURL},c.prototype.getOutputFilename=function(){return this.options.sourceMapOutputFilename},c.prototype.getInputFilename=function(){return this.sourceMapInputFilename},c}},{}],43:[function(a,b,c){b.exports=function(a){var b=function(b){this._css=[],this._rootNode=b.rootNode,this._contentsMap=b.contentsMap,this._contentsIgnoredCharsMap=b.contentsIgnoredCharsMap,b.sourceMapFilename&&(this._sourceMapFilename=b.sourceMapFilename.replace(/\\/g,"/")),this._outputFilename=b.outputFilename,this.sourceMapURL=b.sourceMapURL,b.sourceMapBasepath&&(this._sourceMapBasepath=b.sourceMapBasepath.replace(/\\/g,"/")),b.sourceMapRootpath?(this._sourceMapRootpath=b.sourceMapRootpath.replace(/\\/g,"/"),"/"!==this._sourceMapRootpath.charAt(this._sourceMapRootpath.length-1)&&(this._sourceMapRootpath+="/")):this._sourceMapRootpath="",this._outputSourceFiles=b.outputSourceFiles,this._sourceMapGeneratorConstructor=a.getSourceMapGenerator(),this._lineNumber=0,this._column=0};return b.prototype.normalizeFilename=function(a){return a=a.replace(/\\/g,"/"),this._sourceMapBasepath&&0===a.indexOf(this._sourceMapBasepath)&&(a=a.substring(this._sourceMapBasepath.length),"\\"!==a.charAt(0)&&"/"!==a.charAt(0)||(a=a.substring(1))),(this._sourceMapRootpath||"")+a},b.prototype.add=function(a,b,c,d){if(a){var e,f,g,h,i;if(b){var j=this._contentsMap[b.filename];this._contentsIgnoredCharsMap[b.filename]&&(c-=this._contentsIgnoredCharsMap[b.filename],0>c&&(c=0),j=j.slice(this._contentsIgnoredCharsMap[b.filename])),j=j.substring(0,c),f=j.split("\n"),h=f[f.length-1]}if(e=a.split("\n"),g=e[e.length-1],b)if(d)for(i=0;e.length>i;i++)this._sourceMapGenerator.addMapping({generated:{line:this._lineNumber+i+1,column:0===i?this._column:0},original:{line:f.length+i,column:0===i?h.length:0},source:this.normalizeFilename(b.filename)});else this._sourceMapGenerator.addMapping({generated:{line:this._lineNumber+1,column:this._column},original:{line:f.length,column:h.length},source:this.normalizeFilename(b.filename)});1===e.length?this._column+=g.length:(this._lineNumber+=e.length-1,this._column=g.length),this._css.push(a)}},b.prototype.isEmpty=function(){return 0===this._css.length},b.prototype.toCSS=function(a){if(this._sourceMapGenerator=new this._sourceMapGeneratorConstructor({file:this._outputFilename,sourceRoot:null}),this._outputSourceFiles)for(var b in this._contentsMap)if(this._contentsMap.hasOwnProperty(b)){var c=this._contentsMap[b];this._contentsIgnoredCharsMap[b]&&(c=c.slice(this._contentsIgnoredCharsMap[b])),this._sourceMapGenerator.setSourceContent(this.normalizeFilename(b),c)}if(this._rootNode.genCSS(a,this),this._css.length>0){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;l.length>i;i++){var m=l[i];m.isPreEvalVisitor?j.push(m):m.isPreVisitor?k.splice(0,0,m):k.push(m)}}for(i=0;j.length>i;i++)j[i].run(a);for(c=a.eval(h),i=0;k.length>i;i++)k[i].run(c);return c}},{"./contexts":11,"./tree":62,"./visitors":87}],45:[function(a,b,c){var d=a("./node"),e=function(a){this.value=a};e.prototype=new d,e.prototype.type="Alpha",e.prototype.accept=function(a){this.value=a.visit(this.value)},e.prototype.eval=function(a){return this.value.eval?new e(this.value.eval(a)):this},e.prototype.genCSS=function(a,b){b.add("alpha(opacity="),this.value.genCSS?this.value.genCSS(a,b):b.add(this.value),b.add(")")},b.exports=e},{"./node":70}],46:[function(a,b,c){var d=a("./node"),e=function(a,b,c,d,e,f){this.value=a,this.index=b,this.mapLines=d,this.currentFileInfo=c,this.rulesetLike="undefined"==typeof e?!1:e,this.allowRoot=!0,this.copyVisibilityInfo(f)};e.prototype=new d,e.prototype.type="Anonymous",e.prototype.eval=function(){return new e(this.value,this.index,this.currentFileInfo,this.mapLines,this.rulesetLike,this.visibilityInfo())},e.prototype.compare=function(a){return a.toCSS&&this.toCSS()===a.toCSS()?0:void 0},e.prototype.isRulesetLike=function(){return this.rulesetLike},e.prototype.genCSS=function(a,b){b.add(this.value,this.currentFileInfo,this.index,this.mapLines)},b.exports=e},{"./node":70}],47:[function(a,b,c){var d=a("./node"),e=function(a,b){this.key=a,this.value=b};e.prototype=new d,e.prototype.type="Assignment",e.prototype.accept=function(a){this.value=a.visit(this.value)},e.prototype.eval=function(a){return this.value.eval?new e(this.key,this.value.eval(a)):this},e.prototype.genCSS=function(a,b){b.add(this.key+"="),this.value.genCSS?this.value.genCSS(a,b):b.add(this.value)},b.exports=e},{"./node":70}],48:[function(a,b,c){var d=a("./node"),e=function(a,b,c){this.key=a,this.op=b,this.value=c};e.prototype=new d,e.prototype.type="Attribute",e.prototype.eval=function(a){return new e(this.key.eval?this.key.eval(a):this.key,this.op,this.value&&this.value.eval?this.value.eval(a):this.value)},e.prototype.genCSS=function(a,b){b.add(this.toCSS(a))},e.prototype.toCSS=function(a){var b=this.key.toCSS?this.key.toCSS(a):this.key;return this.op&&(b+=this.op,b+=this.value.toCSS?this.value.toCSS(a):this.value),"["+b+"]"},b.exports=e},{"./node":70}],49:[function(a,b,c){var d=a("./node"),e=a("../functions/function-caller"),f=function(a,b,c,d){this.name=a,this.args=b,this.index=c,this.currentFileInfo=d};f.prototype=new d,f.prototype.type="Call",f.prototype.accept=function(a){this.args&&(this.args=a.visitArray(this.args))},f.prototype.eval=function(a){var b,c=this.args.map(function(b){return b.eval(a)}),d=new e(this.name,a,this.index,this.currentFileInfo);if(d.isValid()){try{b=d.call(c)}catch(g){throw{type:g.type||"Runtime",message:"error evaluating function `"+this.name+"`"+(g.message?": "+g.message:""),index:this.index,filename:this.currentFileInfo.filename}}if(null!=b)return b.index=this.index,b.currentFileInfo=this.currentFileInfo,b}return new f(this.name,c,this.index,this.currentFileInfo)},f.prototype.genCSS=function(a,b){b.add(this.name+"(",this.currentFileInfo,this.index);for(var c=0;this.args.length>c;c++)this.args[c].genCSS(a,b),this.args.length>c+1&&b.add(", ");b.add(")")},b.exports=f},{"../functions/function-caller":21,"./node":70}],50:[function(a,b,c){function d(a,b){return Math.min(Math.max(a,0),b)}function e(a){return"#"+a.map(function(a){return a=d(Math.round(a),255),(16>a?"0":"")+a.toString(16)}).join("")}var f=a("./node"),g=a("../data/colors"),h=function(a,b,c){this.rgb=Array.isArray(a)?a:6==a.length?a.match(/.{2}/g).map(function(a){return parseInt(a,16)}):a.split("").map(function(a){return parseInt(a+a,16)}),this.alpha="number"==typeof b?b:1,"undefined"!=typeof c&&(this.value=c)};h.prototype=new f,h.prototype.type="Color",h.prototype.luma=function(){var a=this.rgb[0]/255,b=this.rgb[1]/255,c=this.rgb[2]/255;return a=.03928>=a?a/12.92:Math.pow((a+.055)/1.055,2.4),b=.03928>=b?b/12.92:Math.pow((b+.055)/1.055,2.4),c=.03928>=c?c/12.92:Math.pow((c+.055)/1.055,2.4),.2126*a+.7152*b+.0722*c},h.prototype.genCSS=function(a,b){b.add(this.toCSS(a))},h.prototype.toCSS=function(a,b){var c,e,f=a&&a.compress&&!b;if(this.value)return this.value;if(e=this.fround(a,this.alpha),1>e)return"rgba("+this.rgb.map(function(a){return d(Math.round(a),255)}).concat(d(e,1)).join(","+(f?"":" "))+")";if(c=this.toRGB(),f){var g=c.split("");g[1]===g[2]&&g[3]===g[4]&&g[5]===g[6]&&(c="#"+g[1]+g[3]+g[5])}return c},h.prototype.operate=function(a,b,c){for(var d=[],e=this.alpha*(1-c.alpha)+c.alpha,f=0;3>f;f++)d[f]=this._operate(a,b,this.rgb[f],c.rgb[f]);return new h(d,e)},h.prototype.toRGB=function(){return e(this.rgb)},h.prototype.toHSL=function(){var a,b,c=this.rgb[0]/255,d=this.rgb[1]/255,e=this.rgb[2]/255,f=this.alpha,g=Math.max(c,d,e),h=Math.min(c,d,e),i=(g+h)/2,j=g-h;if(g===h)a=b=0;else{switch(b=i>.5?j/(2-g-h):j/(g+h),g){case c:a=(d-e)/j+(e>d?6:0);break;case d:a=(e-c)/j+2;break;case e:a=(c-d)/j+4}a/=6}return{h:360*a,s:b,l:i,a:f}},h.prototype.toHSV=function(){var a,b,c=this.rgb[0]/255,d=this.rgb[1]/255,e=this.rgb[2]/255,f=this.alpha,g=Math.max(c,d,e),h=Math.min(c,d,e),i=g,j=g-h;if(b=0===g?0:j/g,g===h)a=0;else{switch(g){case c:a=(d-e)/j+(e>d?6:0);break;case d:a=(e-c)/j+2;break;case e:a=(c-d)/j+4}a/=6}return{h:360*a,s:b,v:i,a:f}},h.prototype.toARGB=function(){return e([255*this.alpha].concat(this.rgb))},h.prototype.compare=function(a){return a.rgb&&a.rgb[0]===this.rgb[0]&&a.rgb[1]===this.rgb[1]&&a.rgb[2]===this.rgb[2]&&a.alpha===this.alpha?0:void 0},h.fromKeyword=function(a){var b,c=a.toLowerCase();return g.hasOwnProperty(c)?b=new h(g[c].slice(1)):"transparent"===c&&(b=new h([0,0,0],0)),b?(b.value=a,b):void 0},b.exports=h},{"../data/colors":12,"./node":70}],51:[function(a,b,c){var d=a("./node"),e=function(a){" "===a?(this.value=" ",this.emptyOrWhitespace=!0):(this.value=a?a.trim():"",this.emptyOrWhitespace=""===this.value)};e.prototype=new d,e.prototype.type="Combinator";var f={"":!0," ":!0,"|":!0};e.prototype.genCSS=function(a,b){var c=a.compress||f[this.value]?"":" ";b.add(c+this.value+c)},b.exports=e},{"./node":70}],52:[function(a,b,c){var d=a("./node"),e=a("./debug-info"),f=function(a,b,c,d){this.value=a,this.isLineComment=b,this.currentFileInfo=d,this.allowRoot=!0};f.prototype=new d,f.prototype.type="Comment",f.prototype.genCSS=function(a,b){this.debugInfo&&b.add(e(a,this),this.currentFileInfo,this.index),b.add(this.value)},f.prototype.isSilent=function(a){var b=a.compress&&"!"!==this.value[2];return this.isLineComment||b},b.exports=f},{"./debug-info":54,"./node":70}],53:[function(a,b,c){var d=a("./node"),e=function(a,b,c,d,e){this.op=a.trim(),this.lvalue=b,this.rvalue=c,this.index=d,this.negate=e};e.prototype=new d,e.prototype.type="Condition",e.prototype.accept=function(a){this.lvalue=a.visit(this.lvalue),this.rvalue=a.visit(this.rvalue)},e.prototype.eval=function(a){var b=function(a,b,c){switch(a){case"and":return b&&c;case"or":return b||c;default:switch(d.compare(b,c)){case-1:return"<"===a||"=<"===a||"<="===a;case 0:return"="===a||">="===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&&1e-6>c&&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&&1>c&&(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;this.rules.length>j;j++)this.rules[j].allowImports=!0;this.index=d,this.currentFileInfo=f,this.debugInfo=g,this.isRooted=h||!1,this.copyVisibilityInfo(i),this.allowRoot=!0};g.prototype=new d,g.prototype.type="Directive",g.prototype.accept=function(a){var b=this.value,c=this.rules;c&&(this.rules=a.visitArray(c)),b&&(this.value=a.visit(b))},g.prototype.isRulesetLike=function(){return this.rules||!this.isCharset()},g.prototype.isCharset=function(){return"@charset"===this.name},g.prototype.genCSS=function(a,b){var c=this.value,d=this.rules;b.add(this.name,this.currentFileInfo,this.index),c&&(b.add(" "),c.genCSS(a,b)),d?this.outputRuleset(a,b,d):b.add(";")},g.prototype.eval=function(a){var b,c,d=this.value,e=this.rules;return b=a.mediaPath,c=a.mediaBlocks,a.mediaPath=[],a.mediaBlocks=[],d&&(d=d.eval(a)),e&&(e=[e[0].eval(a)],e[0].root=!0),a.mediaPath=b,a.mediaBlocks=c,new g(this.name,d,e,this.index,this.currentFileInfo,this.debugInfo,this.isRooted,this.visibilityInfo())},g.prototype.variable=function(a){return this.rules?f.prototype.variable.call(this.rules[0],a):void 0},g.prototype.find=function(){return this.rules?f.prototype.find.apply(this.rules[0],arguments):void 0},g.prototype.rulesets=function(){return this.rules?f.prototype.rulesets.apply(this.rules[0]):void 0},g.prototype.outputRuleset=function(a,b,c){var d,e=c.length;if(a.tabLevel=(0|a.tabLevel)+1,a.compress){for(b.add("{"),d=0;e>d;d++)c[d].genCSS(a,b);return b.add("}"),void a.tabLevel--}var f="\n"+Array(a.tabLevel).join(" "),g=f+" ";if(e){for(b.add(" {"+g),c[0].genCSS(a,b),d=1;e>d;d++)b.add(g),c[d].genCSS(a,b);b.add(f+"}")}else b.add(" {"+f+"}");a.tabLevel--},b.exports=g},{"./node":70,"./ruleset":76,"./selector":77}],58:[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.currentFileInfo=d,this.copyVisibilityInfo(e)};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.index,this.currentFileInfo,this.visibilityInfo())},g.prototype.clone=function(){return new g(this.combinator,this.value,this.index,this.currentFileInfo,this.visibilityInfo())},g.prototype.genCSS=function(a,b){b.add(this.toCSS(a),this.currentFileInfo,this.index)},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":51,"./node":70,"./paren":72}],59:[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;this.value.length>c;c++)this.value[c].genCSS(a,b),this.value.length>c+1&&b.add(" ")},g.prototype.throwAwayComments=function(){this.value=this.value.filter(function(a){return!(a instanceof f)})},b.exports=g},{"./comment":52,"./node":70,"./paren":72}],60:[function(a,b,c){var d=a("./node"),e=a("./selector"),f=function g(a,b,c,d,e){switch(this.selector=a,this.option=b,this.index=c,this.object_id=g.next_id++,this.parent_ids=[this.object_id],this.currentFileInfo=d||{},this.copyVisibilityInfo(e),this.allowRoot=!0,b){case"all":this.allowBefore=!0,this.allowAfter=!0;break;default:this.allowBefore=!1,this.allowAfter=!1}};f.next_id=0,f.prototype=new d,f.prototype.type="Extend",f.prototype.accept=function(a){this.selector=a.visit(this.selector)},f.prototype.eval=function(a){return new f(this.selector.eval(a),this.option,this.index,this.currentFileInfo,this.visibilityInfo())},f.prototype.clone=function(a){return new f(this.selector,this.option,this.index,this.currentFileInfo,this.visibilityInfo())},f.prototype.findSelfSelectors=function(a){var b,c,d=[];for(b=0;a.length>b;b++)c=a[b].elements,b>0&&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():!0},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;f.length>b;b++)c=f[b].features instanceof e?f[b].features.value:f[b].features,f[b]=Array.isArray(c)?c:[c];return this.features=new e(this.permute(f).map(function(a){for(a=a.map(function(a){return a.toCSS?a:new g(a)}),b=a.length-1;b>0;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;c.length>d;d++)for(var e=0;a[0].length>e;e++)b.push([a[0][e]].concat(c[d]));return b},j.prototype.bubbleSelectors=function(a){a&&(this.rules=[new d(a.slice(0),[this.rules[0]])])},b.exports=j},{"./anonymous":46,"./directive":57,"./expression":59,"./ruleset":76,"./selector":77,"./value":81}],67:[function(a,b,c){var d=a("./node"),e=a("./selector"),f=a("./mixin-definition"),g=a("../functions/default"),h=function(a,b,c,d,f){this.selector=new e(a),this.arguments=b||[],this.index=c,this.currentFileInfo=d,this.important=f,this.allowRoot=!0};h.prototype=new d,h.prototype.type="MixinCall",h.prototype.accept=function(a){this.selector&&(this.selector=a.visit(this.selector)),this.arguments.length&&(this.arguments=a.visitArray(this.arguments))},h.prototype.eval=function(a){function b(b,c){var d,e,f;for(d=0;2>d;d++){for(x[d]=!0,g.value(d),e=0;c.length>e&&x[d];e++)f=c[e],f.matchCondition&&(x[d]=x[d]&&f.matchCondition(null,a));b.matchCondition&&(x[d]=x[d]&&b.matchCondition(t,a))}return x[0]||x[1]?x[0]!=x[1]?x[1]?A:B:z:y}var c,d,e,h,i,j,k,l,m,n,o,p,q,r,s,t=[],u=[],v=!1,w=[],x=[],y=-1,z=0,A=1,B=2;for(j=0;this.arguments.length>j;j++)if(h=this.arguments[j],i=h.value.eval(a),h.expand&&Array.isArray(i.value))for(i=i.value,k=0;i.length>k;k++)t.push({value:i[k]});else t.push({name:h.name,value:i});for(s=function(b){return b.matchArgs(null,a)},j=0;a.frames.length>j;j++)if((c=a.frames[j].find(this.selector,null,s)).length>0){for(n=!0,k=0;c.length>k;k++){for(d=c[k].rule,e=c[k].path,m=!1,l=0;a.frames.length>l;l++)if(!(d instanceof f)&&d===(a.frames[l].originalRuleset||a.frames[l])){m=!0;break}m||d.matchArgs(t,a)&&(o={mixin:d,group:b(d,e)},o.group!==y&&w.push(o),v=!0)}for(g.reset(),q=[0,0,0],k=0;w.length>k;k++)q[w[k].group]++;if(q[z]>0)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;w.length>k;k++)if(o=w[k].group,o===z||o===p)try{d=w[k].mixin,d instanceof f||(r=d.originalRuleset||d,d=new f("",[],d.rules,null,!1,null,r.visibilityInfo()),d.originalRuleset=r);var C=d.evalCall(a,t,this.important).rules; -this._setVisibilityToReplacement(C),Array.prototype.push.apply(u,C)}catch(D){throw{message:D.message,index:this.index,filename:this.currentFileInfo.filename,stack:D.stack}}if(v)return u}throw n?{type:"Runtime",message:"No matching definition was found for `"+this.format(t)+"`",index:this.index,filename:this.currentFileInfo.filename}:{type:"Name",message:this.selector.toCSS().trim()+" is undefined",index:this.index,filename:this.currentFileInfo.filename}},h.prototype._setVisibilityToReplacement=function(a){var b,c;if(this.blocksVisibility())for(b=0;a.length>b;b++)c=a[b],c.addVisibilityBlock()},h.prototype.format=function(a){return this.selector.toCSS().trim()+"("+(a?a.map(function(a){var b="";return a.name&&(b+=a.name+":"),b+=a.value.toCSS?a.value.toCSS():"???"}).join(", "):"")+")"},b.exports=h},{"../functions/default":20,"./mixin-definition":68,"./node":70,"./selector":77}],68:[function(a,b,c){var d=a("./selector"),e=a("./element"),f=a("./ruleset"),g=a("./rule"),h=a("./expression"),i=a("../contexts"),j=function(a,b,c,f,g,h,i){this.name=a,this.selectors=[new d([new e(null,a,this.index,this.currentFileInfo)])],this.params=b,this.condition=f,this.variadic=g,this.arity=b.length,this.rules=c,this._lookups={};var j=[];this.required=b.reduce(function(a,b){return!b.name||b.name&&!b.value?a+1:(j.push(b.name),a)},0),this.optionalParameters=j,this.frames=h,this.copyVisibilityInfo(i),this.allowRoot=!0};j.prototype=new f,j.prototype.type="MixinDefinition",j.prototype.evalFirst=!0,j.prototype.accept=function(a){this.params&&this.params.length&&(this.params=a.visitArray(this.params)),this.rules=a.visitArray(this.rules),this.condition&&(this.condition=a.visit(this.condition))},j.prototype.evalParams=function(a,b,c,d){var e,j,k,l,m,n,o,p,q=new f(null,null),r=this.params.slice(0),s=0;if(b.frames&&b.frames[0]&&b.frames[0].functionRegistry&&(q.functionRegistry=b.frames[0].functionRegistry.inherit()),b=new i.Eval(b,[q].concat(b.frames)),c)for(c=c.slice(0),s=c.length,k=0;s>k;k++)if(j=c[k],n=j&&j.name){for(o=!1,l=0;r.length>l;l++)if(!d[l]&&n===r[l].name){d[l]=j.value.eval(a),q.prependRule(new g(n,j.value.eval(a))),o=!0;break}if(o){c.splice(k,1),k--;continue}throw{type:"Runtime",message:"Named argument for "+this.name+" "+c[k].name+" not found"}}for(p=0,k=0;r.length>k;k++)if(!d[k]){if(j=c&&c[p],n=r[k].name)if(r[k].variadic){for(e=[],l=p;s>l;l++)e.push(c[l].value.eval(a));q.prependRule(new g(n,new h(e).eval(a)))}else{if(m=j&&j.value)m=m.eval(a);else{if(!r[k].value)throw{type:"Runtime",message:"wrong number of arguments for "+this.name+" ("+s+" for "+this.arity+")"};m=r[k].value.eval(b),q.resetCache()}q.prependRule(new g(n,m)),d[k]=m}if(r[k].variadic&&c)for(l=p;s>l;l++)d[l]=c[l].value.eval(a);p++}return q},j.prototype.makeImportant=function(){var a=this.rules?this.rules.map(function(a){return a.makeImportant?a.makeImportant(!0):a}):this.rules,b=new j(this.name,this.params,a,this.condition,this.variadic,this.frames);return b},j.prototype.eval=function(a){return new j(this.name,this.params,this.rules,this.condition,this.variadic,this.frames||a.frames.slice(0))},j.prototype.evalCall=function(a,b,c){var d,e,j=[],k=this.frames?this.frames.concat(a.frames):a.frames,l=this.evalParams(a,new i.Eval(a,k),b,j);return l.prependRule(new g("@arguments",new h(j).eval(a))),d=this.rules.slice(0),e=new f(null,d),e.originalRuleset=this,e=e.eval(new i.Eval(a,[this,l].concat(k))),c&&(e=e.makeImportant()),e},j.prototype.matchCondition=function(a,b){return!this.condition||this.condition.eval(new i.Eval(b,[this.evalParams(b,new i.Eval(b,this.frames?this.frames.concat(b.frames):b.frames),a,[])].concat(this.frames||[]).concat(b.frames)))},j.prototype.matchArgs=function(a,b){var c,d=a&&a.length||0,e=this.optionalParameters,f=a?a.reduce(function(a,b){return e.indexOf(b.name)<0?a+1:a},0):0;if(this.variadic){if(this.required-1>f)return!1}else{if(this.required>f)return!1;if(d>this.params.length)return!1}c=Math.min(f,this.arity);for(var g=0;c>g;g++)if(!this.params[g].name&&!this.params[g].variadic&&a[g].value.eval(b).toCSS()!=this.params[g].value.eval(b).toCSS())return!1;return!0},b.exports=j},{"../contexts":11,"./element":58,"./expression":59,"./rule":74,"./ruleset":76,"./selector":77}],69:[function(a,b,c){var d=a("./node"),e=a("./operation"),f=a("./dimension"),g=function(a){this.value=a};g.prototype=new d,g.prototype.type="Negative",g.prototype.genCSS=function(a,b){b.add("-"),this.value.genCSS(a,b)},g.prototype.eval=function(a){return a.isMathOn()?new e("*",[new f(-1),this.value]).eval(a):new g(this.value.eval(a))},b.exports=g},{"./dimension":56,"./node":70,"./operation":71}],70:[function(a,b,c){var d=function(){};d.prototype.toCSS=function(a){var b=[];return this.genCSS(a,{add:function(a,c,d){b.push(a)},isEmpty:function(){return 0===b.length}}),b.join("")},d.prototype.genCSS=function(a,b){b.add(this.value)},d.prototype.accept=function(a){this.value=a.visit(this.value)},d.prototype.eval=function(){return this},d.prototype._operate=function(a,b,c,d){switch(b){case"+":return c+d;case"-":return c-d;case"*":return c*d;case"/":return c/d}},d.prototype.fround=function(a,b){var c=a&&a.numPrecision;return null==c?b:Number((b+2e-16).toFixed(c))},d.compare=function(a,b){if(a.compare&&"Quoted"!==b.type&&"Anonymous"!==b.type)return a.compare(b);if(b.compare)return-b.compare(a);if(a.type===b.type){if(a=a.value,b=b.value,!Array.isArray(a))return a===b?0:void 0;if(a.length===b.length){for(var c=0;a.length>c;c++)if(0!==d.compare(a[c],b[c]))return;return 0}}},d.numericCompare=function(a,b){return b>a?-1:a===b?0:a>b?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?!0: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;e>c;c++)b[c].eval(a).genCSS(a,f);return d}var e=a("./node"),f=a("./value"),g=a("./keyword"),h=function(a,b,c,d,g,h,i,j){this.name=a,this.value=b instanceof e?b:new f([b]),this.important=c?" "+c.trim():"",this.merge=d,this.index=g,this.currentFileInfo=h,this.inline=i||!1,this.variable=void 0!==j?j:a.charAt&&"@"===a.charAt(0),this.allowRoot=!0};h.prototype=new e,h.prototype.type="Rule",h.prototype.genCSS=function(a,b){b.add(this.name+(a.compress?":":": "),this.currentFileInfo,this.index);try{this.value.genCSS(a,b)}catch(c){throw c.index=this.index,c.filename=this.currentFileInfo.filename,c}b.add(this.important+(this.inline||a.lastRule&&a.compress?"":";"),this.currentFileInfo,this.index)},h.prototype.eval=function(a){var b,c=!1,e=this.name,f=this.variable;"string"!=typeof e&&(e=1===e.length&&e[0]instanceof g?e[0].value:d(a,e),f=!1),"font"!==e||a.strictMath||(c=!0,a.strictMath=!0);try{if(a.importantScope.push({}),b=this.value.eval(a),!this.variable&&"DetachedRuleset"===b.type)throw{message:"Rulesets cannot be evaluated on a property.",index:this.index,filename:this.currentFileInfo.filename};var i=this.important,j=a.importantScope.pop();return!i&&j.important&&(i=j.important),new h(e,b,i,this.merge,this.index,this.currentFileInfo,this.inline,f)}catch(k){throw"number"!=typeof k.index&&(k.index=this.index,k.filename=this.currentFileInfo.filename),k}finally{c&&(a.strictMath=!1)}},h.prototype.makeImportant=function(){return new h(this.name,this.value,"!important",this.merge,this.index,this.currentFileInfo,this.inline)},b.exports=h},{"./keyword":65,"./node":70,"./value":81}],75:[function(a,b,c){var d=a("./node"),e=a("./variable"),f=function(a){this.variable=a,this.allowRoot=!0};f.prototype=new d,f.prototype.type="RulesetCall",f.prototype.eval=function(a){var b=new e(this.variable).eval(a);return b.callEval(a)},b.exports=f},{"./node":70,"./variable":82}],76:[function(a,b,c){var d=a("./node"),e=a("./rule"),f=a("./selector"),g=a("./element"),h=a("./paren"),i=a("../contexts"),j=a("../functions/function-registry"),k=a("../functions/default"),l=a("./debug-info"),m=function(a,b,c,d){this.selectors=a,this.rules=b,this._lookups={},this.strictImports=c,this.copyVisibilityInfo(d),this.allowRoot=!0};m.prototype=new d,m.prototype.type="Ruleset",m.prototype.isRuleset=!0,m.prototype.isRulesetLike=!0,m.prototype.accept=function(a){this.paths?this.paths=a.visitArray(this.paths,!0):this.selectors&&(this.selectors=a.visitArray(this.selectors)),this.rules&&this.rules.length&&(this.rules=a.visitArray(this.rules))},m.prototype.eval=function(a){var b,c,d,f,g=this.selectors,h=!1;if(g&&(c=g.length)){for(b=[],k.error({type:"Syntax",message:"it is currently only allowed in parametric mixin guards,"}),f=0;c>f;f++)d=g[f].eval(a),b.push(d),d.evaldCondition&&(h=!0);k.reset()}else h=!0;var i,l,n=this.rules?this.rules.slice(0):null,o=new m(b,n,this.strictImports,this.visibilityInfo());o.originalRuleset=this,o.root=this.root,o.firstRoot=this.firstRoot,o.allowImports=this.allowImports,this.debugInfo&&(o.debugInfo=this.debugInfo),h||(n.length=0),o.functionRegistry=function(a){for(var b,c=0,d=a.length;c!==d;++c)if(b=a[c].functionRegistry)return b;return j}(a.frames).inherit();var p=a.frames;p.unshift(o);var q=a.selectors;q||(a.selectors=q=[]),q.unshift(this.selectors),(o.root||o.allowImports||!o.strictImports)&&o.evalImports(a);var r=o.rules,s=r?r.length:0;for(f=0;s>f;f++)r[f].evalFirst&&(r[f]=r[f].eval(a));var t=a.mediaBlocks&&a.mediaBlocks.length||0;for(f=0;s>f;f++)"MixinCall"===r[f].type?(n=r[f].eval(a).filter(function(a){return a instanceof e&&a.variable?!o.variable(a.name):!0}),r.splice.apply(r,[f,1].concat(n)),s+=n.length-1,f+=n.length-1,o.resetCache()):"RulesetCall"===r[f].type&&(n=r[f].eval(a).rules.filter(function(a){return!(a instanceof e&&a.variable)}),r.splice.apply(r,[f,1].concat(n)),s+=n.length-1,f+=n.length-1,o.resetCache());for(f=0;r.length>f;f++)i=r[f],i.evalFirst||(r[f]=i=i.eval?i.eval(a):i);for(f=0;r.length>f;f++)if(i=r[f],i instanceof m&&i.selectors&&1===i.selectors.length&&i.selectors[0].isJustParentSelector()){r.splice(f--,1);for(var u=0;i.rules.length>u;u++)l=i.rules[u],l.copyVisibilityInfo(i.visibilityInfo()),l instanceof e&&l.variable||r.splice(++f,0,l)}if(p.shift(),q.shift(),a.mediaBlocks)for(f=t;a.mediaBlocks.length>f;f++)a.mediaBlocks[f].bubbleSelectors(b);return o},m.prototype.evalImports=function(a){var b,c,d=this.rules;if(d)for(b=0;d.length>b;b++)"Import"===d[b].type&&(c=d[b].eval(a),c&&(c.length||0===c.length)?(d.splice.apply(d,[b,1].concat(c)),b+=c.length-1):d.splice(b,1,c),this.resetCache())},m.prototype.makeImportant=function(){var a=new m(this.selectors,this.rules.map(function(a){return a.makeImportant?a.makeImportant():a}),this.strictImports,this.visibilityInfo());return a},m.prototype.matchArgs=function(a){return!a||0===a.length},m.prototype.matchCondition=function(a,b){var c=this.selectors[this.selectors.length-1];return c.evaldCondition?!c.condition||c.condition.eval(new i.Eval(b,b.frames)):!1},m.prototype.resetCache=function(){this._rulesets=null,this._variables=null,this._lookups={}},m.prototype.variables=function(){return this._variables||(this._variables=this.rules?this.rules.reduce(function(a,b){if(b instanceof e&&b.variable===!0&&(a[b.name]=b),"Import"===b.type&&b.root&&b.root.variables){var c=b.root.variables();for(var d in c)c.hasOwnProperty(d)&&(a[d]=c[d])}return a},{}):{}),this._variables},m.prototype.variable=function(a){return this.variables()[a]},m.prototype.rulesets=function(){if(!this.rules)return[];var a,b,c=[],d=this.rules,e=d.length;for(a=0;e>a;a++)b=d[a],b.isRuleset&&c.push(b);return c},m.prototype.prependRule=function(a){var b=this.rules;b?b.unshift(a):this.rules=[a]},m.prototype.find=function(a,b,c){b=b||this;var d,e,g=[],h=a.toCSS();return h in this._lookups?this._lookups[h]:(this.rulesets().forEach(function(h){if(h!==b)for(var i=0;h.selectors.length>i;i++)if(d=a.match(h.selectors[i])){if(a.elements.length>d){if(!c||c(h)){e=h.find(new f(a.elements.slice(d)),b,c);for(var j=0;e.length>j;++j)e[j].path.push(h);Array.prototype.push.apply(g,e)}}else g.push({rule:h,path:[]});break}}),this._lookups[h]=g,g)},m.prototype.genCSS=function(a,b){function c(a){return"boolean"==typeof a.isRulesetLike?a.isRulesetLike:"function"==typeof a.isRulesetLike?a.isRulesetLike():!1}var d,e,f,g,h,i=[],j=[];a.tabLevel=a.tabLevel||0,this.root||a.tabLevel++;var k,m=a.compress?"":Array(a.tabLevel+1).join(" "),n=a.compress?"":Array(a.tabLevel).join(" "),o=0,p=0;for(d=0;this.rules.length>d;d++)g=this.rules[d],"Comment"===g.type?(p===d&&p++,j.push(g)):g.isCharset&&g.isCharset()?(j.splice(o,0,g),o++,p++):"Import"===g.type?(j.splice(p,0,g),p++):j.push(g);if(j=i.concat(j),!this.root){f=l(a,this,n),f&&(b.add(f),b.add(n));var q,r=this.paths,s=r.length;for(k=a.compress?",":",\n"+n,d=0;s>d;d++)if(h=r[d],q=h.length)for(d>0&&b.add(k),a.firstSelector=!0,h[0].genCSS(a,b),a.firstSelector=!1,e=1;q>e;e++)h[e].genCSS(a,b);b.add((a.compress?"{":" {\n")+m)}for(d=0;j.length>d;d++){g=j[d],d+1===j.length&&(a.lastRule=!0);var t=a.lastRule;c(g)&&(a.lastRule=!1),g.genCSS?g.genCSS(a,b):g.value&&b.add(g.value.toString()),a.lastRule=t,a.lastRule?a.lastRule=!1:b.add(a.compress?"":"\n"+m)}this.root||(b.add(a.compress?"}":"\n"+n+"}"),a.tabLevel--),b.isEmpty()||a.compress||!this.firstRoot||b.add("\n")},m.prototype.joinSelectors=function(a,b,c){for(var d=0;c.length>d;d++)this.joinSelector(a,b,c[d])},m.prototype.joinSelector=function(a,b,c){function d(a,b){var c,d;if(0===a.length)c=new h(a[0]);else{var e=[];for(d=0;a.length>d;d++)e.push(new g(null,a[d],b.index,b.currentFileInfo));c=new h(new f(e))}return c}function e(a,b){var c,d;return c=new g(null,a,b.index,b.currentFileInfo),d=new f([c])}function i(a,b,c,d){var e,f,h;if(e=[],a.length>0?(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;a.length>f;f++){var g=i(a[f],b,c,d);e.push(g)}return e}function k(a,b){var c,d;if(0!==a.length){if(0===b.length)return void b.push([new f(a)]);for(c=0;b.length>c;c++)d=b[c],d.length>0?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;c.elements.length>h;h++)if(s=c.elements[h],"&"!==s.value){var w=f(s);if(null!=w){k(o,p);var x,y=[],z=[];for(x=l(y,b,w),v=v||x,n=0;y.length>n;n++){var A=e(d(y[n],s),s);j(p,[A],s,c,z)}p=z,o=[]}else o.push(s)}else{for(v=!0,q=[],k(o,p),m=0;p.length>m;m++)if(r=p[m],0===b.length)r.length>0&&r[0].elements.push(new g(s.combinator,"",s.index,s.currentFileInfo)),q.push(r);else for(n=0;b.length>n;n++){var B=i(r,b[n],s,c);q.push(B)}p=q,o=[]}for(k(o,p),h=0;p.length>h;h++)t=p[h].length,t>0&&(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;b.length>n;n++){var q=b[n].map(m.bind(this,c.visibilityInfo()));q.push(c),o.push(q)}else o=[[c]];for(n=0;o.length>n;n++)a.push(o[n])},b.exports=m},{"../contexts":11,"../functions/default":20,"../functions/function-registry":22,"./debug-info":54,"./element":58,"./node":70,"./paren":72,"./rule":74,"./selector":77}],77:[function(a,b,c){var d=a("./node"),e=a("./element"),f=function(a,b,c,d,e,f){this.elements=a,this.extendList=b,this.condition=c,this.currentFileInfo=e||{},c||(this.evaldCondition=!0),this.copyVisibilityInfo(f)};f.prototype=new d,f.prototype.type="Selector",f.prototype.accept=function(a){this.elements&&(this.elements=a.visitArray(this.elements)),this.extendList&&(this.extendList=a.visitArray(this.extendList)),this.condition&&(this.condition=a.visit(this.condition))},f.prototype.createDerived=function(a,b,c){var d=this.visibilityInfo();c=null!=c?c:this.evaldCondition;var e=new f(a,b||this.extendList,null,this.index,this.currentFileInfo,d);return e.evaldCondition=c,e.mediaEmpty=this.mediaEmpty,e},f.prototype.createEmptySelectors=function(){var a=new e("","&",this.index,this.currentFileInfo),b=[new f([a],null,null,this.index,this.currentFileInfo)];return b[0].mediaEmpty=!0,b},f.prototype.match=function(a){var b,c,d=this.elements,e=d.length;if(a.CacheElements(),b=a._elements.length,0===b||b>e)return 0;for(c=0;b>c;c++)if(d[c].value!==a._elements[c])return 0;return b},f.prototype.CacheElements=function(){if(!this._elements){var a=this.elements.map(function(a){return a.combinator.value+(a.value.value||a.value)}).join("").match(/[,&#\*\.\w-]([\w-]|(\\.))*/g);a?"&"===a[0]&&a.shift():a=[],this._elements=a}},f.prototype.isJustParentSelector=function(){return!this.mediaEmpty&&1===this.elements.length&&"&"===this.elements[0].value&&(" "===this.elements[0].combinator.value||""===this.elements[0].combinator.value)},f.prototype.eval=function(a){var b=this.condition&&this.condition.eval(a),c=this.elements,d=this.extendList;return c=c&&c.map(function(b){return b.eval(a)}),d=d&&d.map(function(b){return b.eval(a)}),this.createDerived(c,d,b)},f.prototype.genCSS=function(a,b){var c,d;if(a&&a.firstSelector||""!==this.elements[0].combinator.value||b.add(" ",this.currentFileInfo,this.index),!this._css)for(c=0;this.elements.length>c;c++)d=this.elements[c],d.genCSS(a,b)},f.prototype.getIsOutput=function(){return this.evaldCondition},b.exports=f},{"./element":58,"./node":70}],78:[function(a,b,c){var d=a("./node"),e=function(a){this.value=a};e.prototype=new d,e.prototype.type="UnicodeDescriptor",b.exports=e},{"./node":70}],79:[function(a,b,c){var d=a("./node"),e=a("../data/unit-conversions"),f=function(a,b,c){this.numerator=a?a.slice(0).sort():[],this.denominator=b?b.slice(0).sort():[],c?this.backupUnit=c:a&&a.length&&(this.backupUnit=a[0])};f.prototype=new d,f.prototype.type="Unit",f.prototype.clone=function(){return new f(this.numerator.slice(0),this.denominator.slice(0),this.backupUnit)},f.prototype.genCSS=function(a,b){var c=a&&a.strictUnits;1===this.numerator.length?b.add(this.numerator[0]):!c&&this.backupUnit?b.add(this.backupUnit):!c&&this.denominator.length&&b.add(this.denominator[0])},f.prototype.toString=function(){var a,b=this.numerator.join("*");for(a=0;this.denominator.length>a;a++)b+="/"+this.denominator[a];return b},f.prototype.compare=function(a){return this.is(a.toString())?0:void 0},f.prototype.is=function(a){return this.toString().toUpperCase()===a.toUpperCase()},f.prototype.isLength=function(){return Boolean(this.toCSS().match(/px|em|%|in|cm|mm|pc|pt|ex/))},f.prototype.isEmpty=function(){return 0===this.numerator.length&&0===this.denominator.length},f.prototype.isSingular=function(){return 1>=this.numerator.length&&0===this.denominator.length},f.prototype.map=function(a){var b;for(b=0;this.numerator.length>b;b++)this.numerator[b]=a(this.numerator[b],!1);for(b=0;this.denominator.length>b;b++)this.denominator[b]=a(this.denominator[b],!0)},f.prototype.usedUnits=function(){var a,b,c,d={};b=function(b){return a.hasOwnProperty(b)&&!d[c]&&(d[c]=b),b};for(c in e)e.hasOwnProperty(c)&&(a=e[c],this.map(b));return d},f.prototype.cancel=function(){var a,b,c={};for(b=0;this.numerator.length>b;b++)a=this.numerator[b],c[a]=(c[a]||0)+1;for(b=0;this.denominator.length>b;b++)a=this.denominator[b],c[a]=(c[a]||0)-1;this.numerator=[],this.denominator=[];for(a in c)if(c.hasOwnProperty(a)){var d=c[a];if(d>0)for(b=0;d>b;b++)this.numerator.push(a);else if(0>d)for(b=0;-d>b;b++)this.denominator.push(a)}this.numerator.sort(),this.denominator.sort()},b.exports=f},{"../data/unit-conversions":14,"./node":70}],80:[function(a,b,c){var d=a("./node"),e=function(a,b,c,d){this.value=a,this.currentFileInfo=c,this.index=b,this.isEvald=d};e.prototype=new d,e.prototype.type="Url",e.prototype.accept=function(a){this.value=a.visit(this.value)},e.prototype.genCSS=function(a,b){b.add("url("),this.value.genCSS(a,b),b.add(")")},e.prototype.eval=function(a){var b,c=this.value.eval(a);if(!this.isEvald&&(b=this.currentFileInfo&&this.currentFileInfo.rootpath,b&&"string"==typeof c.value&&a.isPathRelative(c.value)&&(c.quote||(b=b.replace(/[\(\)'"\s]/g,function(a){return"\\"+a})),c.value=b+c.value),c.value=a.normalizePath(c.value),a.urlArgs&&!c.value.match(/^\s*data:/))){var d=-1===c.value.indexOf("?")?"?":"&",f=d+a.urlArgs;-1!==c.value.indexOf("#")?c.value=c.value.replace("#",f+"#"):c.value+=f}return new e(c,this.index,this.currentFileInfo,!0)},b.exports=e},{"./node":70}],81:[function(a,b,c){var d=a("./node"),e=function(a){if(this.value=a,!a)throw new Error("Value requires an array argument")};e.prototype=new d,e.prototype.type="Value",e.prototype.accept=function(a){this.value&&(this.value=a.visitArray(this.value))},e.prototype.eval=function(a){return 1===this.value.length?this.value[0].eval(a):new e(this.value.map(function(b){return b.eval(a)}))},e.prototype.genCSS=function(a,b){var c;for(c=0;this.value.length>c;c++)this.value[c].genCSS(a,b),this.value.length>c+1&&b.add(a&&a.compress?",":", ")},b.exports=e},{"./node":70}],82:[function(a,b,c){var d=a("./node"),e=function(a,b,c){this.name=a,this.index=b,this.currentFileInfo=c||{}};e.prototype=new d,e.prototype.type="Variable",e.prototype.eval=function(a){var b,c=this.name;if(0===c.indexOf("@@")&&(c="@"+new e(c.slice(1),this.index,this.currentFileInfo).eval(a).value),this.evaluating)throw{type:"Name",message:"Recursive variable definition for "+c,filename:this.currentFileInfo.filename,index:this.index};if(this.evaluating=!0,b=this.find(a.frames,function(b){var d=b.variable(c);if(d){if(d.important){var e=a.importantScope[a.importantScope.length-1];e.important=d.important}return d.value.eval(a)}}))return this.evaluating=!1,b;throw{type:"Name",message:"variable "+c+" is undefined",filename:this.currentFileInfo.filename,index:this.index}},e.prototype.find=function(a,b){for(var c,d=0;a.length>d;d++)if(c=b.call(a,a[d]))return c;return null},b.exports=e},{"./node":70}],83:[function(a,b,c){b.exports={getLocation:function(a,b){for(var c=a+1,d=null,e=-1;--c>=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;j>c;c++)a.rules[c]instanceof d.Extend&&(h.push(i[c]),a.extendOnEveryPath=!0);var k=a.paths;for(c=0;k.length>c;c++){var l=k[c],m=l[l.length-1],n=m.extendList;for(g=n?n.slice(0).concat(h):h,g&&(g=g.map(function(a){return a.clone()})),e=0;g.length>e;e++)this.foundExtends=!0,f=g[e],f.findSelfSelectors(l),f.ruleset=a,0===e&&(f.firstExtendOnThisSelectorPath=!0),this.allExtendsStack[this.allExtendsStack.length-1].push(f)}this.contexts.push(a.selectors)}},visitRulesetOut:function(a){a.root||(this.contexts.length=this.contexts.length-1)},visitMedia:function(a,b){a.allExtends=[],this.allExtendsStack.push(a.allExtends)},visitMediaOut:function(a){this.allExtendsStack.length=this.allExtendsStack.length-1},visitDirective:function(a,b){a.allExtends=[],this.allExtendsStack.push(a.allExtends)},visitDirectiveOut:function(a){this.allExtendsStack.length=this.allExtendsStack.length-1}};var h=function(){this._visitor=new e(this)};h.prototype={run:function(a){var b=new g;if(this.extendIndices={},b.run(a),!b.foundExtends)return a;a.allExtends=a.allExtends.concat(this.doExtendChaining(a.allExtends,a.allExtends)),this.allExtendsStack=[a.allExtends];var c=this._visitor.visit(a);return this.checkExtendsForNonMatched(a.allExtends),c},checkExtendsForNonMatched:function(a){var b=this.extendIndices;a.filter(function(a){return!a.hasFoundMatches&&1==a.parent_ids.length}).forEach(function(a){var c="_unknown_";try{c=a.selector.toCSS({})}catch(d){}b[a.index+" "+c]||(b[a.index+" "+c]=!0,f.warn("extend '"+c+"' has no matches"))})},doExtendChaining:function(a,b,c){var e,f,g,h,i,j,k,l,m=[],n=this;for(c=c||0,e=0;a.length>e;e++)for(f=0;b.length>f;f++)j=a[e],k=b[f],j.parent_ids.indexOf(k.object_id)>=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;g.length>e;e++)for(d=0;a.paths.length>d;d++)if(f=a.paths[d],!a.extendOnEveryPath){var j=f[f.length-1].extendList;j&&j.length||(c=this.findMatch(g[e],f),c.length&&(g[e].hasFoundMatches=!0,g[e].selfSelectors.forEach(function(a){var b;b=i.extendSelector(c,f,a,g[e].isVisible()),h.push(b)})))}a.paths=a.paths.concat(h)}},findMatch:function(a,b){var c,d,e,f,g,h,i,j=this,k=a.selector.elements,l=[],m=[];for(c=0;b.length>c;c++)for(d=b[c],e=0;d.elements.length>e;e++)for(f=d.elements[e],(a.allowBefore||0===c&&0===e)&&l.push({pathIndex:c,index:e,matched:0,initialCombinator:f.combinator}),h=0;l.length>h;h++)i=l[h],g=f.combinator.value,""===g&&0===e&&(g=" "),!j.isElementValuesEqual(k[i.matched].value,f.value)||i.matched>0&&k[i.matched].combinator.value!==g?i=null:i.matched++,i&&(i.finished=i.matched===k.length,i.finished&&!a.allowAfter&&(d.elements.length>e+1||b.length>c+1)&&(i=null)),i?i.finished&&(i.length=k.length,i.endPathIndex=c,i.endPathElementIndex=e+1,l.length=0,m.push(i)):(l.splice(h,1),h--);return m},isElementValuesEqual:function(a,b){if("string"==typeof a||"string"==typeof b)return a===b;if(a instanceof d.Attribute)return a.op!==b.op||a.key!==b.key?!1:a.value&&b.value?(a=a.value.value||a.value,b=b.value.value||b.value,a===b):!a.value&&!b.value;if(a=a.value,b=b.value,a instanceof d.Selector){if(!(b instanceof d.Selector)||a.elements.length!==b.elements.length)return!1;for(var c=0;a.elements.length>c;c++){if(a.elements[c].combinator.value!==b.elements[c].combinator.value&&(0!==c||(a.elements[c].combinator.value||" ")!==(b.elements[c].combinator.value||" ")))return!1;if(!this.isElementValuesEqual(a.elements[c].value,b.elements[c].value))return!1}return!0}return!1},extendSelector:function(a,b,c,e){var f,g,h,i,j,k=0,l=0,m=[];for(f=0;a.length>f;f++)i=a[f],g=b[i.pathIndex],h=new d.Element(i.initialCombinator,c.elements[0].value,c.elements[0].index,c.elements[0].currentFileInfo),i.pathIndex>k&&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 b.length>k&&l>0&&(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;c.rules.length>h;h++)if(c.rules[h]===a){c.rules[h]=d;break}var i=this.onImported.bind(this,d,b),j=this._sequencer.addImport(i);this._importer.push(d.getPath(),g,d.currentFileInfo,d.options,j)}},onImported:function(a,b,c,d,e,f){c&&(c.filename||(c.index=a.index,c.filename=a.currentFileInfo.filename),this.error=c);var g=this,h=a.options.inline,i=a.options.plugin,j=a.options.optional,k=e||f in g.recursionDetector;if(b.importMultiple||(a.skip=k?!0:function(){return f in g.onceFileDetectionMap?!0:(g.onceFileDetectionMap[f]=!0,!1)}),!f&&j&&(a.skip=!0),d&&(a.root=d,a.importedFilename=f,!h&&!i&&(b.importMultiple||!k))){g.recursionDetector[f]=!0;var l=this.context;this.context=b;try{this._visitor.visit(d)}catch(c){this.error=c}this.context=l}g.importCount--,g.isFinished&&g._sequencer.tryRun()},visitRule:function(a,b){"DetachedRuleset"===a.value.type?this.context.frames.unshift(a):b.visitDeeper=!1},visitRuleOut:function(a){"DetachedRuleset"===a.value.type&&this.context.frames.shift()},visitDirective:function(a,b){this.context.frames.unshift(a)},visitDirectiveOut:function(a){this.context.frames.shift()},visitMixinDefinition:function(a,b){this.context.frames.unshift(a)},visitMixinDefinitionOut:function(a){this.context.frames.shift()},visitRuleset:function(a,b){this.context.frames.unshift(a)},visitRulesetOut:function(a){this.context.frames.shift()},visitMedia:function(a,b){this.context.frames.unshift(a.rules[0])},visitMediaOut:function(a){this.context.frames.shift()}},b.exports=g},{"../contexts":11,"./import-sequencer":85,"./visitor":91}],87:[function(a,b,c){var d={Visitor:a("./visitor"),ImportVisitor:a("./import-visitor"),MarkVisibleSelectorsVisitor:a("./set-tree-visibility-visitor"),ExtendVisitor:a("./extend-visitor"),JoinSelectorVisitor:a("./join-selector-visitor"),ToCSSVisitor:a("./to-css-visitor")};b.exports=d},{"./extend-visitor":84,"./import-visitor":86,"./join-selector-visitor":88,"./set-tree-visibility-visitor":89,"./to-css-visitor":90,"./visitor":91}],88:[function(a,b,c){var d=a("./visitor"),e=function(){this.contexts=[[]],this._visitor=new d(this)};e.prototype={run:function(a){return this._visitor.visit(a)},visitRule:function(a,b){b.visitDeeper=!1},visitMixinDefinition:function(a,b){b.visitDeeper=!1},visitRuleset:function(a,b){var c,d=this.contexts[this.contexts.length-1],e=[];this.contexts.push(e),a.root||(c=a.selectors,c&&(c=c.filter(function(a){return a.getIsOutput()}),a.selectors=c.length?c:c=null,c&&a.joinSelectors(e,d,c)),c||(a.rules=null),a.paths=e)},visitRulesetOut:function(a){this.contexts.length=this.contexts.length-1},visitMedia:function(a,b){var c=this.contexts[this.contexts.length-1];a.rules[0].root=0===c.length||c[0].multiMedia},visitDirective:function(a,b){var c=this.contexts[this.contexts.length-1];a.rules&&a.rules.length&&(a.rules[0].root=a.isRooted||0===c.length||null)}},b.exports=e},{"./visitor":91}],89:[function(a,b,c){var d=function(a){this.visible=a};d.prototype.run=function(a){this.visit(a)},d.prototype.visitArray=function(a){if(!a)return a;var b,c=a.length;for(b=0;c>b;b++)this.visit(a[b]);return a},d.prototype.visit=function(a){return a?a.constructor===Array?this.visitArray(a):!a.blocksVisibility||a.blocksVisibility()?a:(this.visible?a.ensureVisibility():a.ensureInvisibility(),a.accept(this),a):a},b.exports=d},{}],90:[function(a,b,c){var d=a("../tree"),e=a("./visitor"),f=function(a){this._visitor=new e(this),this._context=a};f.prototype={containsSilentNonBlockedChild:function(a){var b;if(null==a)return!1;for(var c=0;a.length>c;c++)if(b=a[c],b.isSilent&&b.isSilent(this._context)&&!b.blocksVisibility())return!0;return!1},keepOnlyVisibleChilds:function(a){null!=a&&null!=a.rules&&(a.rules=a.rules.filter(function(a){return a.isVisible()}))},isEmpty:function(a){return null==a||null==a.rules?!0:0===a.rules.length},hasVisibleSelector:function(a){return null==a||null==a.paths?!1:a.paths.length>0},resolveVisibility:function(a,b){if(!a.blocksVisibility()){if(this.isEmpty(a)&&!this.containsSilentNonBlockedChild(b))return;return a}var c=a.rules[0];return this.keepOnlyVisibleChilds(c),this.isEmpty(c)?void 0:(a.ensureVisibility(),a.removeVisibilityBlock(),a)},isVisibleRuleset:function(a){return a.firstRoot?!0:this.isEmpty(a)?!1:!(!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){return a.blocksVisibility()||a.variable?void 0:a},visitMixinDefinition:function(a,b){a.frames=[]},visitExtend:function(a,b){},visitComment:function(a,b){return a.blocksVisibility()||a.isSilent(this._context)?void 0: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){return a.blocksVisibility()?void 0: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;a.length>c;c++){var e=a[c];if(b&&e instanceof d.Rule&&!e.variable)throw{message:"Properties must be inside selector blocks. They cannot be in the root",index:e.index,filename:e.currentFileInfo&&e.currentFileInfo.filename};if(e instanceof d.Call)throw{message:"Function '"+e.name+"' is undefined",index:e.index,filename:e.currentFileInfo&&e.currentFileInfo.filename};if(e.type&&!e.allowRoot)throw{message:e.type+" node returned by a function is not valid here",index:e.index,filename:e.currentFileInfo&&e.currentFileInfo.filename}}},visitRuleset:function(a,b){var c,d=[];if(this.checkValidNodes(a.rules,a.firstRoot),a.root)a.accept(this._visitor),b.visitDeeper=!1;else{this._compileRulesetPaths(a);for(var e=a.rules,f=e?e.length:0,g=0;f>g;)c=e[g],c&&c.rules?(d.push(this._visitor.visit(c)),e.splice(g,1),f--):g++;f>0?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;a.length>b;b++)if(a[b].isVisible()&&a[b].getIsOutput())return!0;return!1}))},_removeDuplicateRules:function(a){if(a){var b,c,e,f={};for(e=a.length-1;e>=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);-1!==b.indexOf(g)?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;a.length>g;g++)c=a[g],c instanceof d.Rule&&c.merge&&(e=[c.name,c.important?"!":""].join(","),f[e]?a.splice(g--,1):f[e]=[],f[e].push(c));Object.keys(f).map(function(a){function e(a){return new d.Expression(a.map(function(a){return a.value}))}function g(a){return new d.Value(a.map(function(a){return a}))}if(b=f[a],b.length>1){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){return a.blocksVisibility()?void 0:(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;d>c;c++)this.visit(a[c]);return a}var e=[];for(c=0;d>c;c++){var f=this.visit(a[c]);void 0!==f&&(f.splice?f.length&&this.flatten(f,e):e.push(f))}return e},flatten:function(a,b){b||(b=[]);var c,d,e,f,g,h;for(d=0,c=a.length;c>d;d++)if(e=a[d],void 0!==e)if(e.splice)for(g=0,f=e.length;f>g;g++)h=e[g],void 0!==h&&(h.splice?h.length&&this.flatten(h,b):b.push(h));else b.push(e);return b}},b.exports=i},{"../tree":62}],92:[function(a,b,c){"use strict";function d(){if(i.length)throw i.shift()}function e(a){var b;b=h.length?h.pop():new f,b.task=a,g(b)}function f(){this.task=null}var g=a("./raw"),h=[],i=[],j=g.makeRequestCallFromTimer(d);b.exports=e,f.prototype.call=function(){try{this.task.call()}catch(a){e.onerror?e.onerror(a):(i.push(a),j())}finally{this.task=null,h[h.length]=this}}},{"./raw":93}],93:[function(a,b,c){(function(a){"use strict";function c(a){h.length||(g(),i=!0),h[h.length]=a}function d(){for(;h.length>j;){var a=j;if(j+=1,h[a].call(),j>k){for(var b=0,c=h.length-j;c>b;b++)h[b]=h[b+j];h.length-=j,j=0}}h.length=0,j=0,i=!1}function e(a){var b=1,c=new l(a),d=document.createTextNode("");return c.observe(d,{characterData:!0}),function(){b=-b,d.data=b}}function f(a){return function(){function b(){clearTimeout(c),clearInterval(d),a()}var c=setTimeout(b,0),d=setInterval(b,50)}}b.exports=c;var g,h=[],i=!1,j=0,k=1024,l=a.MutationObserver||a.WebKitMutationObserver;g="function"==typeof l?e(d):f(d),c.requestFlush=g,c.makeRequestCallFromTimer=f}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],94:[function(a,b,c){"use strict";function d(){}function e(a){try{return a.then}catch(b){return r=b,s}}function f(a,b){try{return a(b)}catch(c){return r=c,s}}function g(a,b,c){try{a(b,c)}catch(d){return r=d,s}}function h(a){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof a)throw new TypeError("not a function");this._45=0,this._81=0,this._65=null,this._54=null,a!==d&&p(a,this)}function i(a,b,c){return new a.constructor(function(e,f){var g=new h(d);g.then(e,f),j(a,new o(b,c,g))})}function j(a,b){for(;3===a._81;)a=a._65;return h._10&&h._10(a),0===a._81?0===a._45?(a._45=1,void(a._54=b)):1===a._45?(a._45=2,void(a._54=[a._54,b])):void a._54.push(b):void k(a,b)}function k(a,b){q(function(){var c=1===a._81?b.onFulfilled:b.onRejected;if(null===c)return void(1===a._81?l(b.promise,a._65):m(b.promise,a._65));var d=f(c,a._65);d===s?m(b.promise,r):l(b.promise,d)})}function l(a,b){if(b===a)return m(a,new TypeError("A promise cannot be resolved with itself."));if(b&&("object"==typeof b||"function"==typeof b)){var c=e(b);if(c===s)return m(a,r);if(c===a.then&&b instanceof h)return a._81=3,a._65=b,void n(a);if("function"==typeof c)return void p(c.bind(b),a)}a._81=1,a._65=b,n(a)}function m(a,b){a._81=2,a._65=b,h._97&&h._97(a,b),n(a)}function n(a){if(1===a._45&&(j(a,a._54),a._54=null),2===a._45){for(var b=0;a._54.length>b;b++)j(a,a._54[b]);a._54=null}}function o(a,b,c){this.onFulfilled="function"==typeof a?a:null,this.onRejected="function"==typeof b?b:null,this.promise=c}function p(a,b){var c=!1,d=g(a,function(a){c||(c=!0,l(b,a))},function(a){c||(c=!0,m(b,a))});c||d!==s||(c=!0,m(b,r))}var q=a("asap/raw"),r=null,s={};b.exports=h,h._10=null,h._97=null,h._61=d,h.prototype.then=function(a,b){if(this.constructor!==h)return i(this,a,b);var c=new h(d);return j(this,new o(a,b,c)),c}},{"asap/raw":93}],95:[function(a,b,c){"use strict";function d(a){var b=new e(e._61);return b._81=1,b._65=a,b}var e=a("./core.js");b.exports=e;var f=d(!0),g=d(!1),h=d(null),i=d(void 0),j=d(0),k=d("");e.resolve=function(a){if(a instanceof e)return a;if(null===a)return h;if(void 0===a)return i;if(a===!0)return f;if(a===!1)return g;if(0===a)return j;if(""===a)return k;if("object"==typeof a||"function"==typeof a)try{var b=a.then;if("function"==typeof b)return new e(b.bind(a))}catch(c){return new e(function(a,b){b(c)})}return d(a)},e.all=function(a){var b=Array.prototype.slice.call(a);return new e(function(a,c){function d(g,h){if(h&&("object"==typeof h||"function"==typeof h)){if(h instanceof e&&h.then===e.prototype.then){for(;3===h._81;)h=h._65;return 1===h._81?d(g,h._65):(2===h._81&&c(h._65),void h.then(function(a){d(g,a)},c))}var i=h.then;if("function"==typeof i){var j=new e(i.bind(h));return void j.then(function(a){d(g,a)},c)}}b[g]=h,0===--f&&a(b)}if(0===b.length)return a([]);for(var f=b.length,g=0;b.length>g;g++)d(g,b[g])})},e.reject=function(a){return new e(function(b,c){c(a)})},e.race=function(a){return new e(function(b,c){a.forEach(function(a){e.resolve(a).then(b,c)})})},e.prototype["catch"]=function(a){return this.then(null,a)}},{"./core.js":94}],96:[function(a,b,c){"function"!=typeof Promise.prototype.done&&(Promise.prototype.done=function(a,b){var c=arguments.length?this.then.apply(this,arguments):this;c.then(null,function(a){setTimeout(function(){throw a},0)})})},{}],97:[function(a,b,c){a("asap");"undefined"==typeof Promise&&(Promise=a("./lib/core.js"),a("./lib/es6-extensions.js")),a("./polyfill-done.js")},{"./lib/core.js":94,"./lib/es6-extensions.js":95,"./polyfill-done.js":96,asap:92}]},{},[2])(2)}); \ No newline at end of file diff --git a/vendor/less/dist/less.cjs.js b/vendor/less/dist/less.cjs.js deleted file mode 100644 index b08dee514..000000000 --- a/vendor/less/dist/less.cjs.js +++ /dev/null @@ -1,13716 +0,0 @@ -'use strict'; - -var path = require('path'); -var url = require('url'); -var CloneHelper = require('clone'); - -var environment = { - encodeBase64: function encodeBase64(str) { - // Avoid Buffer constructor on newer versions of Node.js. - var buffer = Buffer.from ? Buffer.from(str) : new Buffer(str); - return buffer.toString('base64'); - }, - mimeLookup: function mimeLookup(filename) { - return require('mime').lookup(filename); - }, - charsetLookup: function charsetLookup(mime) { - return require('mime').charsets.lookup(mime); - }, - getSourceMapGenerator: function getSourceMapGenerator() { - return require('source-map').SourceMapGenerator; - } -}; - -function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } -} - -function _defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } -} - -function _createClass(Constructor, protoProps, staticProps) { - if (protoProps) _defineProperties(Constructor.prototype, protoProps); - if (staticProps) _defineProperties(Constructor, staticProps); - return Constructor; -} - -function _inherits(subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function"); - } - - subClass.prototype = Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - writable: true, - configurable: true - } - }); - if (superClass) _setPrototypeOf(subClass, superClass); -} - -function _getPrototypeOf(o) { - _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { - return o.__proto__ || Object.getPrototypeOf(o); - }; - return _getPrototypeOf(o); -} - -function _setPrototypeOf(o, p) { - _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { - o.__proto__ = p; - return o; - }; - - return _setPrototypeOf(o, p); -} - -function isNativeReflectConstruct() { - if (typeof Reflect === "undefined" || !Reflect.construct) return false; - if (Reflect.construct.sham) return false; - if (typeof Proxy === "function") return true; - - try { - Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); - return true; - } catch (e) { - return false; - } -} - -function _construct(Parent, args, Class) { - if (isNativeReflectConstruct()) { - _construct = Reflect.construct; - } else { - _construct = function _construct(Parent, args, Class) { - var a = [null]; - a.push.apply(a, args); - var Constructor = Function.bind.apply(Parent, a); - var instance = new Constructor(); - if (Class) _setPrototypeOf(instance, Class.prototype); - return instance; - }; - } - - return _construct.apply(null, arguments); -} - -function _assertThisInitialized(self) { - if (self === void 0) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - - return self; -} - -function _possibleConstructorReturn(self, call) { - if (call && (typeof call === "object" || typeof call === "function")) { - return call; - } - - return _assertThisInitialized(self); -} - -function _toConsumableArray(arr) { - return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); -} - -function _arrayWithoutHoles(arr) { - if (Array.isArray(arr)) { - for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; - - return arr2; - } -} - -function _iterableToArray(iter) { - if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); -} - -function _nonIterableSpread() { - throw new TypeError("Invalid attempt to spread non-iterable instance"); -} - -var fs; - -try { - fs = require('graceful-fs'); -} catch (e) { - fs = require('fs'); -} - -var fs$1 = fs; - -var AbstractFileManager = -/*#__PURE__*/ -function () { - function AbstractFileManager() { - _classCallCheck(this, AbstractFileManager); - } - - _createClass(AbstractFileManager, [{ - key: "getPath", - value: function getPath(filename) { - var j = filename.lastIndexOf('?'); - - if (j > 0) { - filename = filename.slice(0, j); - } - - j = filename.lastIndexOf('/'); - - if (j < 0) { - j = filename.lastIndexOf('\\'); - } - - if (j < 0) { - return ''; - } - - return filename.slice(0, j + 1); - } - }, { - key: "tryAppendExtension", - value: function tryAppendExtension(path, ext) { - return /(\.[a-z]*$)|([\?;].*)$/.test(path) ? path : path + ext; - } - }, { - key: "tryAppendLessExtension", - value: function tryAppendLessExtension(path) { - return this.tryAppendExtension(path, '.less'); - } - }, { - key: "supportsSync", - value: function supportsSync() { - return false; - } - }, { - key: "alwaysMakePathsAbsolute", - value: function alwaysMakePathsAbsolute() { - return false; - } - }, { - key: "isPathAbsolute", - value: function isPathAbsolute(filename) { - return /^(?:[a-z-]+:|\/|\\|#)/i.test(filename); - } // TODO: pull out / replace? - - }, { - key: "join", - value: function join(basePath, laterPath) { - if (!basePath) { - return laterPath; - } - - return basePath + laterPath; - } - }, { - key: "pathDiff", - value: function pathDiff(url, baseUrl) { - // diff between two paths to create a relative path - var urlParts = this.extractUrlParts(url); - var baseUrlParts = this.extractUrlParts(baseUrl); - var i; - var max; - var urlDirectories; - var baseUrlDirectories; - var diff = ''; - - if (urlParts.hostPart !== baseUrlParts.hostPart) { - return ''; - } - - max = Math.max(baseUrlParts.directories.length, urlParts.directories.length); - - for (i = 0; i < max; i++) { - if (baseUrlParts.directories[i] !== urlParts.directories[i]) { - break; - } - } - - baseUrlDirectories = baseUrlParts.directories.slice(i); - urlDirectories = urlParts.directories.slice(i); - - for (i = 0; i < baseUrlDirectories.length - 1; i++) { - diff += '../'; - } - - for (i = 0; i < urlDirectories.length - 1; i++) { - diff += `${urlDirectories[i]}/`; - } - - return diff; - } - }, { - key: "extractUrlParts", - // helper function, not part of API - value: function extractUrlParts(url, baseUrl) { - // urlParts[1] = protocol://hostname/ OR / - // urlParts[2] = / if path relative to host base - // urlParts[3] = directories - // urlParts[4] = filename - // urlParts[5] = parameters - var urlPartsRegex = /^((?:[a-z-]+:)?\/{2}(?:[^\/\?#]*\/)|([\/\\]))?((?:[^\/\\\?#]*[\/\\])*)([^\/\\\?#]*)([#\?].*)?$/i; - var urlParts = url.match(urlPartsRegex); - var returner = {}; - var rawDirectories = []; - var directories = []; - var i; - var baseUrlParts; - - if (!urlParts) { - throw new Error(`Could not parse sheet href - '${url}'`); - } // Stylesheets in IE don't always return the full path - - - if (baseUrl && (!urlParts[1] || urlParts[2])) { - baseUrlParts = baseUrl.match(urlPartsRegex); - - if (!baseUrlParts) { - throw new Error(`Could not parse page url - '${baseUrl}'`); - } - - urlParts[1] = urlParts[1] || baseUrlParts[1] || ''; - - if (!urlParts[2]) { - urlParts[3] = baseUrlParts[3] + urlParts[3]; - } - } - - if (urlParts[3]) { - rawDirectories = urlParts[3].replace(/\\/g, '/').split('/'); // collapse '..' and skip '.' - - for (i = 0; i < rawDirectories.length; i++) { - 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; - } - }]); - - return AbstractFileManager; -}(); - -var FileManager = -/*#__PURE__*/ -function (_AbstractFileManager) { - _inherits(FileManager, _AbstractFileManager); - - function FileManager() { - var _this; - - _classCallCheck(this, FileManager); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(FileManager).call(this)); - _this.contents = {}; - return _this; - } - - _createClass(FileManager, [{ - key: "supports", - value: function supports(filename, currentDirectory, options, environment) { - return true; - } - }, { - key: "supportsSync", - value: function supportsSync(filename, currentDirectory, options, environment) { - return true; - } - }, { - key: "loadFile", - value: function loadFile(filename, currentDirectory, options, environment, callback) { - var fullFilename; - var isAbsoluteFilename = this.isPathAbsolute(filename); - var filenamesTried = []; - var self = this; - var prefix = filename.slice(0, 1); - var explicit = prefix === '.' || prefix === '/'; - var result = null; - var isNodeModule = false; - var npmPrefix = 'npm://'; - options = options || {}; - var paths = isAbsoluteFilename ? [''] : [currentDirectory]; - - if (options.paths) { - paths.push.apply(paths, _toConsumableArray(options.paths)); - } - - if (!isAbsoluteFilename && paths.indexOf('.') === -1) { - paths.push('.'); - } - - var prefixes = options.prefixes || ['']; - var fileParts = this.extractUrlParts(filename); - - if (options.syncImport) { - getFileData(returnData, returnData); - - if (callback) { - callback(result.error, result); - } else { - return result; - } - } else { - // promise is guaranteed to be asyncronous - // which helps as it allows the file handle - // to be closed before it continues with the next file - return new Promise(getFileData); - } - - function returnData(data) { - if (!data.filename) { - result = { - error: data - }; - } else { - result = data; - } - } - - function getFileData(fulfill, reject) { - (function tryPathIndex(i) { - if (i < paths.length) { - (function tryPrefix(j) { - if (j < prefixes.length) { - isNodeModule = false; - fullFilename = fileParts.rawPath + prefixes[j] + fileParts.filename; - - if (paths[i]) { - fullFilename = path.join(paths[i], fullFilename); - } - - if (!explicit && paths[i] === '.') { - try { - fullFilename = require.resolve(fullFilename); - isNodeModule = true; - } catch (e) { - filenamesTried.push(npmPrefix + fullFilename); - tryWithExtension(); - } - } else { - tryWithExtension(); - } - - function tryWithExtension() { - var extFilename = options.ext ? self.tryAppendExtension(fullFilename, options.ext) : fullFilename; - - if (extFilename !== fullFilename && !explicit && paths[i] === '.') { - try { - fullFilename = require.resolve(extFilename); - isNodeModule = true; - } catch (e) { - filenamesTried.push(npmPrefix + extFilename); - fullFilename = extFilename; - } - } else { - fullFilename = extFilename; - } - } - - var modified = false; - - if (self.contents[fullFilename]) { - try { - var stat = fs$1.statSync.apply(this, [fullFilename]); - - if (stat.mtime.getTime() === self.contents[fullFilename].mtime.getTime()) { - fulfill({ - contents: self.contents[fullFilename].data, - filename: fullFilename - }); - } else { - modified = true; - } - } catch (e) { - modified = true; - } - } - - if (modified || !self.contents[fullFilename]) { - var readFileArgs = [fullFilename]; - - if (!options.rawBuffer) { - readFileArgs.push('utf-8'); - } - - if (options.syncImport) { - try { - var data = fs$1.readFileSync.apply(this, readFileArgs); - var stat = fs$1.statSync.apply(this, [fullFilename]); - self.contents[fullFilename] = { - data, - mtime: stat.mtime - }; - fulfill({ - contents: data, - filename: fullFilename - }); - } catch (e) { - filenamesTried.push(isNodeModule ? npmPrefix + fullFilename : fullFilename); - return tryPrefix(j + 1); - } - } else { - readFileArgs.push(function (e, data) { - if (e) { - filenamesTried.push(isNodeModule ? npmPrefix + fullFilename : fullFilename); - return tryPrefix(j + 1); - } - - var stat = fs$1.statSync.apply(this, [fullFilename]); - self.contents[fullFilename] = { - data, - mtime: stat.mtime - }; - fulfill({ - contents: data, - filename: fullFilename - }); - }); - fs$1.readFile.apply(this, readFileArgs); - } - } - } else { - tryPathIndex(i + 1); - } - })(0); - } else { - reject({ - type: 'File', - message: `'${filename}' wasn't found. Tried - ${filenamesTried.join(',')}` - }); - } - })(0); - } - } - }, { - key: "loadFileSync", - value: function loadFileSync(filename, currentDirectory, options, environment) { - options.syncImport = true; - return this.loadFile(filename, currentDirectory, options, environment); - } - }]); - - return FileManager; -}(AbstractFileManager); - -var logger = { - error: function error(msg) { - this._fireEvent('error', msg); - }, - warn: function warn(msg) { - this._fireEvent('warn', msg); - }, - info: function info(msg) { - this._fireEvent('info', msg); - }, - debug: function debug(msg) { - this._fireEvent('debug', msg); - }, - addListener: function addListener(listener) { - this._listeners.push(listener); - }, - removeListener: function removeListener(listener) { - for (var i = 0; i < this._listeners.length; i++) { - if (this._listeners[i] === listener) { - this._listeners.splice(i, 1); - - return; - } - } - }, - _fireEvent: function _fireEvent(type, msg) { - for (var i = 0; i < this._listeners.length; i++) { - var logFunction = this._listeners[i][type]; - - if (logFunction) { - logFunction(msg); - } - } - }, - _listeners: [] -}; - -var isUrlRe = /^(?:https?:)?\/\//i; -var request; - -var UrlFileManager = -/*#__PURE__*/ -function (_AbstractFileManager) { - _inherits(UrlFileManager, _AbstractFileManager); - - function UrlFileManager() { - _classCallCheck(this, UrlFileManager); - - return _possibleConstructorReturn(this, _getPrototypeOf(UrlFileManager).apply(this, arguments)); - } - - _createClass(UrlFileManager, [{ - key: "supports", - value: function supports(filename, currentDirectory, options, environment) { - return isUrlRe.test(filename) || isUrlRe.test(currentDirectory); - } - }, { - key: "loadFile", - value: function loadFile(filename, currentDirectory, options, environment) { - return new Promise(function (fulfill, reject) { - if (request === undefined) { - try { - request = require('request'); - } catch (e) { - request = null; - } - } - - if (!request) { - reject({ - type: 'File', - message: 'optional dependency \'request\' required to import over http(s)\n' - }); - return; - } - - var urlStr = isUrlRe.test(filename) ? filename : url.resolve(currentDirectory, filename); - var urlObj = url.parse(urlStr); - - if (!urlObj.protocol) { - urlObj.protocol = 'http'; - urlStr = urlObj.format(); - } - - request.get({ - uri: urlStr, - strictSSL: !options.insecure - }, function (error, res, body) { - if (error) { - reject({ - type: 'File', - message: `resource '${urlStr}' gave this Error:\n ${error}\n` - }); - return; - } - - if (res && res.statusCode === 404) { - reject({ - type: 'File', - message: `resource '${urlStr}' was not found\n` - }); - return; - } - - if (!body) { - logger.warn(`Warning: Empty body (HTTP ${res.statusCode}) returned by "${urlStr}"`); - } - - fulfill({ - contents: body, - filename: urlStr - }); - }); - }); - } - }]); - - return UrlFileManager; -}(AbstractFileManager); - -var colors = { - 'aliceblue': '#f0f8ff', - 'antiquewhite': '#faebd7', - 'aqua': '#00ffff', - 'aquamarine': '#7fffd4', - 'azure': '#f0ffff', - 'beige': '#f5f5dc', - 'bisque': '#ffe4c4', - 'black': '#000000', - 'blanchedalmond': '#ffebcd', - 'blue': '#0000ff', - 'blueviolet': '#8a2be2', - 'brown': '#a52a2a', - 'burlywood': '#deb887', - 'cadetblue': '#5f9ea0', - 'chartreuse': '#7fff00', - 'chocolate': '#d2691e', - 'coral': '#ff7f50', - 'cornflowerblue': '#6495ed', - 'cornsilk': '#fff8dc', - 'crimson': '#dc143c', - 'cyan': '#00ffff', - 'darkblue': '#00008b', - 'darkcyan': '#008b8b', - 'darkgoldenrod': '#b8860b', - 'darkgray': '#a9a9a9', - 'darkgrey': '#a9a9a9', - 'darkgreen': '#006400', - 'darkkhaki': '#bdb76b', - 'darkmagenta': '#8b008b', - 'darkolivegreen': '#556b2f', - 'darkorange': '#ff8c00', - 'darkorchid': '#9932cc', - 'darkred': '#8b0000', - 'darksalmon': '#e9967a', - 'darkseagreen': '#8fbc8f', - 'darkslateblue': '#483d8b', - 'darkslategray': '#2f4f4f', - 'darkslategrey': '#2f4f4f', - 'darkturquoise': '#00ced1', - 'darkviolet': '#9400d3', - 'deeppink': '#ff1493', - 'deepskyblue': '#00bfff', - 'dimgray': '#696969', - 'dimgrey': '#696969', - 'dodgerblue': '#1e90ff', - 'firebrick': '#b22222', - 'floralwhite': '#fffaf0', - 'forestgreen': '#228b22', - 'fuchsia': '#ff00ff', - 'gainsboro': '#dcdcdc', - 'ghostwhite': '#f8f8ff', - 'gold': '#ffd700', - 'goldenrod': '#daa520', - 'gray': '#808080', - 'grey': '#808080', - 'green': '#008000', - 'greenyellow': '#adff2f', - 'honeydew': '#f0fff0', - 'hotpink': '#ff69b4', - 'indianred': '#cd5c5c', - 'indigo': '#4b0082', - 'ivory': '#fffff0', - 'khaki': '#f0e68c', - 'lavender': '#e6e6fa', - 'lavenderblush': '#fff0f5', - 'lawngreen': '#7cfc00', - 'lemonchiffon': '#fffacd', - 'lightblue': '#add8e6', - 'lightcoral': '#f08080', - 'lightcyan': '#e0ffff', - 'lightgoldenrodyellow': '#fafad2', - 'lightgray': '#d3d3d3', - 'lightgrey': '#d3d3d3', - 'lightgreen': '#90ee90', - 'lightpink': '#ffb6c1', - 'lightsalmon': '#ffa07a', - 'lightseagreen': '#20b2aa', - 'lightskyblue': '#87cefa', - 'lightslategray': '#778899', - 'lightslategrey': '#778899', - 'lightsteelblue': '#b0c4de', - 'lightyellow': '#ffffe0', - 'lime': '#00ff00', - 'limegreen': '#32cd32', - 'linen': '#faf0e6', - 'magenta': '#ff00ff', - 'maroon': '#800000', - 'mediumaquamarine': '#66cdaa', - 'mediumblue': '#0000cd', - 'mediumorchid': '#ba55d3', - 'mediumpurple': '#9370d8', - 'mediumseagreen': '#3cb371', - 'mediumslateblue': '#7b68ee', - 'mediumspringgreen': '#00fa9a', - 'mediumturquoise': '#48d1cc', - 'mediumvioletred': '#c71585', - 'midnightblue': '#191970', - 'mintcream': '#f5fffa', - 'mistyrose': '#ffe4e1', - 'moccasin': '#ffe4b5', - 'navajowhite': '#ffdead', - 'navy': '#000080', - 'oldlace': '#fdf5e6', - 'olive': '#808000', - 'olivedrab': '#6b8e23', - 'orange': '#ffa500', - 'orangered': '#ff4500', - 'orchid': '#da70d6', - 'palegoldenrod': '#eee8aa', - 'palegreen': '#98fb98', - 'paleturquoise': '#afeeee', - 'palevioletred': '#d87093', - 'papayawhip': '#ffefd5', - 'peachpuff': '#ffdab9', - 'peru': '#cd853f', - 'pink': '#ffc0cb', - 'plum': '#dda0dd', - 'powderblue': '#b0e0e6', - 'purple': '#800080', - 'rebeccapurple': '#663399', - 'red': '#ff0000', - 'rosybrown': '#bc8f8f', - 'royalblue': '#4169e1', - 'saddlebrown': '#8b4513', - 'salmon': '#fa8072', - 'sandybrown': '#f4a460', - 'seagreen': '#2e8b57', - 'seashell': '#fff5ee', - 'sienna': '#a0522d', - 'silver': '#c0c0c0', - 'skyblue': '#87ceeb', - 'slateblue': '#6a5acd', - 'slategray': '#708090', - 'slategrey': '#708090', - 'snow': '#fffafa', - 'springgreen': '#00ff7f', - 'steelblue': '#4682b4', - 'tan': '#d2b48c', - 'teal': '#008080', - 'thistle': '#d8bfd8', - 'tomato': '#ff6347', - 'turquoise': '#40e0d0', - 'violet': '#ee82ee', - 'wheat': '#f5deb3', - 'white': '#ffffff', - 'whitesmoke': '#f5f5f5', - 'yellow': '#ffff00', - 'yellowgreen': '#9acd32' -}; - -var unitConversions = { - length: { - 'm': 1, - 'cm': 0.01, - 'mm': 0.001, - 'in': 0.0254, - 'px': 0.0254 / 96, - 'pt': 0.0254 / 72, - 'pc': 0.0254 / 72 * 12 - }, - duration: { - 's': 1, - 'ms': 0.001 - }, - angle: { - 'rad': 1 / (2 * Math.PI), - 'deg': 1 / 360, - 'grad': 1 / 400, - 'turn': 1 - } -}; - -var data = { - colors, - unitConversions -}; - -var Node = -/*#__PURE__*/ -function () { - function Node() { - _classCallCheck(this, Node); - - this.parent = null; - this.visibilityBlocks = undefined; - this.nodeVisible = undefined; - this.rootNode = null; - this.parsed = null; - var self = this; - Object.defineProperty(this, 'currentFileInfo', { - get: function get() { - return self.fileInfo(); - } - }); - Object.defineProperty(this, 'index', { - get: function get() { - return self.getIndex(); - } - }); - } - - _createClass(Node, [{ - key: "setParent", - value: function setParent(nodes, parent) { - function set(node) { - if (node && node instanceof Node) { - node.parent = parent; - } - } - - if (Array.isArray(nodes)) { - nodes.forEach(set); - } else { - set(nodes); - } - } - }, { - key: "getIndex", - value: function getIndex() { - return this._index || this.parent && this.parent.getIndex() || 0; - } - }, { - key: "fileInfo", - value: function fileInfo() { - return this._fileInfo || this.parent && this.parent.fileInfo() || {}; - } - }, { - key: "isRulesetLike", - value: function isRulesetLike() { - return false; - } - }, { - key: "toCSS", - value: function toCSS(context) { - var strs = []; - this.genCSS(context, { - add: function add(chunk, fileInfo, index) { - strs.push(chunk); - }, - isEmpty: function isEmpty() { - return strs.length === 0; - } - }); - return strs.join(''); - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - output.add(this.value); - } - }, { - key: "accept", - value: function accept(visitor) { - this.value = visitor.visit(this.value); - } - }, { - key: "eval", - value: function _eval() { - return this; - } - }, { - key: "_operate", - value: function _operate(context, op, a, b) { - switch (op) { - case '+': - return a + b; - - case '-': - return a - b; - - case '*': - return a * b; - - case '/': - return a / b; - } - } - }, { - key: "fround", - value: function fround(context, value) { - var precision = context && context.numPrecision; // add "epsilon" to ensure numbers like 1.000000005 (represented as 1.000000004999...) are properly rounded: - - return precision ? Number((value + 2e-16).toFixed(precision)) : value; - } // Returns true if this node represents root of ast imported by reference - - }, { - key: "blocksVisibility", - value: function blocksVisibility() { - if (this.visibilityBlocks == null) { - this.visibilityBlocks = 0; - } - - return this.visibilityBlocks !== 0; - } - }, { - key: "addVisibilityBlock", - value: function addVisibilityBlock() { - if (this.visibilityBlocks == null) { - this.visibilityBlocks = 0; - } - - this.visibilityBlocks = this.visibilityBlocks + 1; - } - }, { - key: "removeVisibilityBlock", - value: function removeVisibilityBlock() { - if (this.visibilityBlocks == null) { - this.visibilityBlocks = 0; - } - - 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 - - }, { - key: "ensureVisibility", - value: function ensureVisibility() { - 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 - - }, { - key: "ensureInvisibility", - value: function ensureInvisibility() { - this.nodeVisible = false; - } // return values: - // false - the node must not be visible - // true - the node must be visible - // undefined or null - the node has the same visibility as its parent - - }, { - key: "isVisible", - value: function isVisible() { - return this.nodeVisible; - } - }, { - key: "visibilityInfo", - value: function visibilityInfo() { - return { - visibilityBlocks: this.visibilityBlocks, - nodeVisible: this.nodeVisible - }; - } - }, { - key: "copyVisibilityInfo", - value: function copyVisibilityInfo(info) { - if (!info) { - return; - } - - this.visibilityBlocks = info.visibilityBlocks; - this.nodeVisible = info.nodeVisible; - } - }]); - - return Node; -}(); - -Node.compare = function (a, b) { - /* returns: - -1: a < b - 0: a = b - 1: a > b - and *any* other value for a != b (e.g. undefined, NaN, -2 etc.) */ - if (a.compare && // for "symmetric results" force toCSS-based comparison - // of Quoted or Anonymous if either value is one of those - !(b.type === 'Quoted' || b.type === 'Anonymous')) { - return a.compare(b); - } else if (b.compare) { - return -b.compare(a); - } else if (a.type !== b.type) { - return undefined; - } - - a = a.value; - b = b.value; - - if (!Array.isArray(a)) { - return a === b ? 0 : undefined; - } - - if (a.length !== b.length) { - return undefined; - } - - for (var i = 0; i < a.length; i++) { - if (Node.compare(a[i], b[i]) !== 0) { - return undefined; - } - } - - return 0; -}; - -Node.numericCompare = function (a, b) { - return a < b ? -1 : a === b ? 0 : a > b ? 1 : undefined; -}; - -// RGB Colors - #ff0014, #eee -// - -var Color = -/*#__PURE__*/ -function (_Node) { - _inherits(Color, _Node); - - function Color(rgb, a, originalForm) { - var _this; - - _classCallCheck(this, Color); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Color).call(this)); - - var self = _assertThisInitialized(_this); // - // The end goal here, is to parse the arguments - // into an integer triplet, such as `128, 255, 0` - // - // This facilitates operations and conversions. - // - - - if (Array.isArray(rgb)) { - _this.rgb = rgb; - } else if (rgb.length >= 6) { - _this.rgb = []; - rgb.match(/.{2}/g).map(function (c, i) { - if (i < 3) { - self.rgb.push(parseInt(c, 16)); - } else { - self.alpha = parseInt(c, 16) / 255; - } - }); - } else { - _this.rgb = []; - rgb.split('').map(function (c, i) { - if (i < 3) { - self.rgb.push(parseInt(c + c, 16)); - } else { - self.alpha = parseInt(c + c, 16) / 255; - } - }); - } - - _this.alpha = _this.alpha || (typeof a === 'number' ? a : 1); - - if (typeof originalForm !== 'undefined') { - _this.value = originalForm; - } - - return _this; - } - - _createClass(Color, [{ - key: "luma", - value: function luma() { - var r = this.rgb[0] / 255; - var g = this.rgb[1] / 255; - var b = this.rgb[2] / 255; - r = r <= 0.03928 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4); - g = g <= 0.03928 ? g / 12.92 : Math.pow((g + 0.055) / 1.055, 2.4); - b = b <= 0.03928 ? b / 12.92 : Math.pow((b + 0.055) / 1.055, 2.4); - return 0.2126 * r + 0.7152 * g + 0.0722 * b; - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - output.add(this.toCSS(context)); - } - }, { - key: "toCSS", - value: function toCSS(context, doNotCompress) { - var compress = context && context.compress && !doNotCompress; - var color; - var alpha; - var colorFunction; - var args = []; // `value` is set if this color was originally - // converted from a named color string so we need - // to respect this and try to output named color too. - - alpha = this.fround(context, this.alpha); - - if (this.value) { - if (this.value.indexOf('rgb') === 0) { - if (alpha < 1) { - colorFunction = 'rgba'; - } - } else if (this.value.indexOf('hsl') === 0) { - if (alpha < 1) { - colorFunction = 'hsla'; - } else { - colorFunction = 'hsl'; - } - } else { - return this.value; - } - } else { - if (alpha < 1) { - colorFunction = 'rgba'; - } - } - - switch (colorFunction) { - case 'rgba': - args = this.rgb.map(function (c) { - return clamp(Math.round(c), 255); - }).concat(clamp(alpha, 1)); - break; - - case 'hsla': - args.push(clamp(alpha, 1)); - - case 'hsl': - color = this.toHSL(); - args = [this.fround(context, color.h), `${this.fround(context, color.s * 100)}%`, `${this.fround(context, color.l * 100)}%`].concat(args); - } - - if (colorFunction) { - // Values are capped between `0` and `255`, rounded and zero-padded. - return `${colorFunction}(${args.join(`,${compress ? '' : ' '}`)})`; - } - - color = this.toRGB(); - - if (compress) { - var splitcolor = color.split(''); // Convert color to short format - - if (splitcolor[1] === splitcolor[2] && splitcolor[3] === splitcolor[4] && splitcolor[5] === splitcolor[6]) { - color = `#${splitcolor[1]}${splitcolor[3]}${splitcolor[5]}`; - } - } - - return color; - } // - // Operations have to be done per-channel, if not, - // channels will spill onto each other. Once we have - // our result, in the form of an integer triplet, - // we create a new Color node to hold the result. - // - - }, { - key: "operate", - value: function operate(context, op, other) { - 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]); - } - - return new Color(rgb, alpha); - } - }, { - key: "toRGB", - value: function toRGB() { - return toHex(this.rgb); - } - }, { - key: "toHSL", - value: function toHSL() { - var r = this.rgb[0] / 255; - var g = this.rgb[1] / 255; - var b = this.rgb[2] / 255; - var a = this.alpha; - var max = Math.max(r, g, b); - var min = Math.min(r, g, b); - var h; - var s; - var l = (max + min) / 2; - var d = max - min; - - if (max === min) { - h = s = 0; - } else { - s = l > 0.5 ? d / (2 - max - min) : d / (max + min); - - 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; - } - - h /= 6; - } - - return { - h: h * 360, - s, - l, - a - }; - } // Adapted from http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript - - }, { - key: "toHSV", - value: function toHSV() { - var r = this.rgb[0] / 255; - var g = this.rgb[1] / 255; - var b = this.rgb[2] / 255; - var a = this.alpha; - var max = Math.max(r, g, b); - var min = Math.min(r, g, b); - var h; - var s; - var v = max; - var d = max - min; - - if (max === 0) { - s = 0; - } else { - s = d / max; - } - - if (max === min) { - h = 0; - } else { - 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; - } - - h /= 6; - } - - return { - h: h * 360, - s, - v, - a - }; - } - }, { - key: "toARGB", - value: function toARGB() { - return toHex([this.alpha * 255].concat(this.rgb)); - } - }, { - key: "compare", - value: function compare(x) { - return x.rgb && x.rgb[0] === this.rgb[0] && x.rgb[1] === this.rgb[1] && x.rgb[2] === this.rgb[2] && x.alpha === this.alpha ? 0 : undefined; - } - }]); - - return Color; -}(Node); - -Color.prototype.type = 'Color'; - -function clamp(v, max) { - return Math.min(Math.max(v, 0), max); -} - -function toHex(v) { - return `#${v.map(function (c) { - c = clamp(Math.round(c), 255); - return (c < 16 ? '0' : '') + c.toString(16); - }).join('')}`; -} - -Color.fromKeyword = function (keyword) { - var c; - var key = keyword.toLowerCase(); - - if (colors.hasOwnProperty(key)) { - c = new Color(colors[key].slice(1)); - } else if (key === 'transparent') { - c = new Color([0, 0, 0], 0); - } - - if (c) { - c.value = keyword; - return c; - } -}; - -var Paren = -/*#__PURE__*/ -function (_Node) { - _inherits(Paren, _Node); - - function Paren(node) { - var _this; - - _classCallCheck(this, Paren); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Paren).call(this)); - _this.value = node; - return _this; - } - - _createClass(Paren, [{ - key: "genCSS", - value: function genCSS(context, output) { - output.add('('); - this.value.genCSS(context, output); - output.add(')'); - } - }, { - key: "eval", - value: function _eval(context) { - return new Paren(this.value.eval(context)); - } - }]); - - return Paren; -}(Node); - -Paren.prototype.type = 'Paren'; - -var _noSpaceCombinators = { - '': true, - ' ': true, - '|': true -}; - -var Combinator = -/*#__PURE__*/ -function (_Node) { - _inherits(Combinator, _Node); - - function Combinator(value) { - var _this; - - _classCallCheck(this, Combinator); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Combinator).call(this)); - - if (value === ' ') { - _this.value = ' '; - _this.emptyOrWhitespace = true; - } else { - _this.value = value ? value.trim() : ''; - _this.emptyOrWhitespace = _this.value === ''; - } - - return _this; - } - - _createClass(Combinator, [{ - key: "genCSS", - value: function genCSS(context, output) { - var spaceOrEmpty = context.compress || _noSpaceCombinators[this.value] ? '' : ' '; - output.add(spaceOrEmpty + this.value + spaceOrEmpty); - } - }]); - - return Combinator; -}(Node); - -Combinator.prototype.type = 'Combinator'; - -var Element = -/*#__PURE__*/ -function (_Node) { - _inherits(Element, _Node); - - function Element(combinator, value, isVariable, index, currentFileInfo, visibilityInfo) { - var _this; - - _classCallCheck(this, Element); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Element).call(this)); - _this.combinator = combinator instanceof Combinator ? combinator : new Combinator(combinator); - - if (typeof value === 'string') { - _this.value = value.trim(); - } else if (value) { - _this.value = value; - } else { - _this.value = ''; - } - - _this.isVariable = isVariable; - _this._index = index; - _this._fileInfo = currentFileInfo; - - _this.copyVisibilityInfo(visibilityInfo); - - _this.setParent(_this.combinator, _assertThisInitialized(_this)); - - return _this; - } - - _createClass(Element, [{ - key: "accept", - value: function accept(visitor) { - var value = this.value; - this.combinator = visitor.visit(this.combinator); - - if (typeof value === 'object') { - this.value = visitor.visit(value); - } - } - }, { - key: "eval", - value: function _eval(context) { - return new Element(this.combinator, this.value.eval ? this.value.eval(context) : this.value, this.isVariable, this.getIndex(), this.fileInfo(), this.visibilityInfo()); - } - }, { - key: "clone", - value: function clone() { - return new Element(this.combinator, this.value, this.isVariable, this.getIndex(), this.fileInfo(), this.visibilityInfo()); - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - output.add(this.toCSS(context), this.fileInfo(), this.getIndex()); - } - }, { - key: "toCSS", - value: function toCSS() { - var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var value = this.value; - var firstSelector = context.firstSelector; - - if (value instanceof Paren) { - // selector in parens should not be affected by outer selector - // flags (breaks only interpolated selectors - see #1973) - context.firstSelector = true; - } - - value = value.toCSS ? value.toCSS(context) : value; - context.firstSelector = firstSelector; - - if (value === '' && this.combinator.value.charAt(0) === '&') { - return ''; - } else { - return this.combinator.toCSS(context) + value; - } - } - }]); - - return Element; -}(Node); - -Element.prototype.type = 'Element'; - -var Math$1 = { - ALWAYS: 0, - PARENS_DIVISION: 1, - PARENS: 2, - STRICT_LEGACY: 3 -}; -var RewriteUrls = { - OFF: 0, - LOCAL: 1, - ALL: 2 -}; - -/* jshint proto: true */ -function getLocation(index, inputStream) { - var n = index + 1; - var line = null; - var column = -1; - - while (--n >= 0 && inputStream.charAt(n) !== '\n') { - column++; - } - - if (typeof index === 'number') { - line = (inputStream.slice(0, index).match(/\n/g) || '').length; - } - - return { - line, - column - }; -} -function copyArray(arr) { - var i; - var length = arr.length; - var copy = new Array(length); - - for (i = 0; i < length; i++) { - copy[i] = arr[i]; - } - - return copy; -} -function clone(obj) { - var cloned = {}; - - for (var prop in obj) { - if (obj.hasOwnProperty(prop)) { - cloned[prop] = obj[prop]; - } - } - - return cloned; -} -function defaults(obj1, obj2) { - var newObj = obj2 || {}; - - if (!obj2._defaults) { - newObj = {}; - - var _defaults = CloneHelper(obj1); - - newObj._defaults = _defaults; - var cloned = obj2 ? CloneHelper(obj2) : {}; - Object.assign(newObj, _defaults, cloned); - } - - return newObj; -} -function copyOptions(obj1, obj2) { - if (obj2 && obj2._defaults) { - return obj2; - } - - var opts = defaults(obj1, obj2); - - if (opts.strictMath) { - opts.math = Math$1.STRICT_LEGACY; - } // Back compat with changed relativeUrls option - - - if (opts.relativeUrls) { - opts.rewriteUrls = RewriteUrls.ALL; - } - - if (typeof opts.math === 'string') { - switch (opts.math.toLowerCase()) { - case 'always': - opts.math = Math$1.ALWAYS; - break; - - case 'parens-division': - opts.math = Math$1.PARENS_DIVISION; - break; - - case 'strict': - case 'parens': - opts.math = Math$1.PARENS; - break; - - case 'strict-legacy': - opts.math = Math$1.STRICT_LEGACY; - } - } - - if (typeof opts.rewriteUrls === 'string') { - switch (opts.rewriteUrls.toLowerCase()) { - case 'off': - opts.rewriteUrls = RewriteUrls.OFF; - break; - - case 'local': - opts.rewriteUrls = RewriteUrls.LOCAL; - break; - - case 'all': - opts.rewriteUrls = RewriteUrls.ALL; - break; - } - } - - return opts; -} -function merge(obj1, obj2) { - for (var prop in obj2) { - if (obj2.hasOwnProperty(prop)) { - obj1[prop] = obj2[prop]; - } - } - - return obj1; -} -function flattenArray(arr) { - var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - - for (var i = 0, length = arr.length; i < length; i++) { - var value = arr[i]; - - if (Array.isArray(value)) { - flattenArray(value, result); - } else { - if (value !== undefined) { - result.push(value); - } - } - } - - return result; -} - -var utils = /*#__PURE__*/Object.freeze({ - getLocation: getLocation, - copyArray: copyArray, - clone: clone, - defaults: defaults, - copyOptions: copyOptions, - merge: merge, - flattenArray: flattenArray -}); - -/** - * 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} fileContentMap - An object with file contents in 'contents' property (like importManager) @todo - move to fileManager? - * @param {string} [currentFilename] - */ - -var LessError = function LessError(e, fileContentMap, currentFilename) { - Error.call(this); - var filename = e.filename || currentFilename; - this.message = e.message; - this.stack = e.stack; - - if (fileContentMap && filename) { - var input = fileContentMap.contents[filename]; - var loc = getLocation(e.index, input); - var line = loc.line; - var col = loc.column; - var callLine = e.call && getLocation(e.call, input).line; - var lines = input ? input.split('\n') : ''; - this.type = e.type || 'Syntax'; - 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.extract = [lines[this.line - 2], lines[this.line - 1], lines[this.line]]; - } -}; - -if (typeof Object.create === 'undefined') { - var F = function F() {}; - - F.prototype = Error.prototype; - LessError.prototype = new F(); -} else { - LessError.prototype = Object.create(Error.prototype); -} - -LessError.prototype.constructor = LessError; -/** - * 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 () { - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var message = ''; - var extract = this.extract || []; - var error = []; - - var stylize = function stylize(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; -}; - -var Selector = -/*#__PURE__*/ -function (_Node) { - _inherits(Selector, _Node); - - function Selector(elements, extendList, condition, index, currentFileInfo, visibilityInfo) { - var _this; - - _classCallCheck(this, Selector); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Selector).call(this)); - _this.extendList = extendList; - _this.condition = condition; - _this.evaldCondition = !condition; - _this._index = index; - _this._fileInfo = currentFileInfo; - _this.elements = _this.getElements(elements); - _this.mixinElements_ = undefined; - - _this.copyVisibilityInfo(visibilityInfo); - - _this.setParent(_this.elements, _assertThisInitialized(_this)); - - return _this; - } - - _createClass(Selector, [{ - key: "accept", - value: function accept(visitor) { - if (this.elements) { - this.elements = visitor.visitArray(this.elements); - } - - if (this.extendList) { - this.extendList = visitor.visitArray(this.extendList); - } - - if (this.condition) { - this.condition = visitor.visit(this.condition); - } - } - }, { - key: "createDerived", - value: function createDerived(elements, extendList, 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; - } - }, { - key: "getElements", - value: function getElements(els) { - if (!els) { - return [new Element('', '&', false, this._index, this._fileInfo)]; - } - - 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; - } - }, { - key: "createEmptySelectors", - value: function createEmptySelectors() { - var el = new Element('', '&', false, this._index, this._fileInfo); - var sels = [new Selector([el], null, null, this._index, this._fileInfo)]; - sels[0].mediaEmpty = true; - return sels; - } - }, { - key: "match", - value: function match(other) { - var elements = this.elements; - var len = elements.length; - var olen; - var i; - 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[i]) { - return 0; - } - } - } - - return olen; // return number of matched elements - } - }, { - key: "mixinElements", - value: function mixinElements() { - if (this.mixinElements_) { - return this.mixinElements_; - } - - var elements = this.elements.map(function (v) { - return v.combinator.value + (v.value.value || v.value); - }).join('').match(/[,&#\*\.\w-]([\w-]|(\\.))*/g); - - if (elements) { - if (elements[0] === '&') { - elements.shift(); - } - } else { - elements = []; - } - - return this.mixinElements_ = elements; - } - }, { - key: "isJustParentSelector", - value: function isJustParentSelector() { - return !this.mediaEmpty && this.elements.length === 1 && this.elements[0].value === '&' && (this.elements[0].combinator.value === ' ' || this.elements[0].combinator.value === ''); - } - }, { - key: "eval", - value: function _eval(context) { - var evaldCondition = this.condition && this.condition.eval(context); - var elements = this.elements; - var extendList = this.extendList; - elements = elements && elements.map(function (e) { - return e.eval(context); - }); - extendList = extendList && extendList.map(function (extend) { - return extend.eval(context); - }); - return this.createDerived(elements, extendList, evaldCondition); - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - var i; - var element; - - if ((!context || !context.firstSelector) && this.elements[0].combinator.value === '') { - output.add(' ', this.fileInfo(), this.getIndex()); - } - - for (i = 0; i < this.elements.length; i++) { - element = this.elements[i]; - element.genCSS(context, output); - } - } - }, { - key: "getIsOutput", - value: function getIsOutput() { - return this.evaldCondition; - } - }]); - - return Selector; -}(Node); - -Selector.prototype.type = 'Selector'; - -var Value = -/*#__PURE__*/ -function (_Node) { - _inherits(Value, _Node); - - function Value(value) { - var _this; - - _classCallCheck(this, Value); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Value).call(this)); - - if (!value) { - throw new Error('Value requires an array argument'); - } - - if (!Array.isArray(value)) { - _this.value = [value]; - } else { - _this.value = value; - } - - return _this; - } - - _createClass(Value, [{ - key: "accept", - value: function accept(visitor) { - if (this.value) { - this.value = visitor.visitArray(this.value); - } - } - }, { - key: "eval", - value: function _eval(context) { - if (this.value.length === 1) { - return this.value[0].eval(context); - } else { - return new Value(this.value.map(function (v) { - return v.eval(context); - })); - } - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - var i; - - for (i = 0; i < this.value.length; i++) { - this.value[i].genCSS(context, output); - - if (i + 1 < this.value.length) { - output.add(context && context.compress ? ',' : ', '); - } - } - } - }]); - - return Value; -}(Node); - -Value.prototype.type = 'Value'; - -var Keyword = -/*#__PURE__*/ -function (_Node) { - _inherits(Keyword, _Node); - - function Keyword(value) { - var _this; - - _classCallCheck(this, Keyword); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Keyword).call(this)); - _this.value = value; - return _this; - } - - _createClass(Keyword, [{ - key: "genCSS", - value: function genCSS(context, output) { - if (this.value === '%') { - throw { - type: 'Syntax', - message: 'Invalid % without number' - }; - } - - output.add(this.value); - } - }]); - - return Keyword; -}(Node); - -Keyword.prototype.type = 'Keyword'; -Keyword.True = new Keyword('true'); -Keyword.False = new Keyword('false'); - -var Anonymous = -/*#__PURE__*/ -function (_Node) { - _inherits(Anonymous, _Node); - - function Anonymous(value, index, currentFileInfo, mapLines, rulesetLike, visibilityInfo) { - var _this; - - _classCallCheck(this, Anonymous); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Anonymous).call(this)); - _this.value = value; - _this._index = index; - _this._fileInfo = currentFileInfo; - _this.mapLines = mapLines; - _this.rulesetLike = typeof rulesetLike === 'undefined' ? false : rulesetLike; - _this.allowRoot = true; - - _this.copyVisibilityInfo(visibilityInfo); - - return _this; - } - - _createClass(Anonymous, [{ - key: "eval", - value: function _eval() { - return new Anonymous(this.value, this._index, this._fileInfo, this.mapLines, this.rulesetLike, this.visibilityInfo()); - } - }, { - key: "compare", - value: function compare(other) { - return other.toCSS && this.toCSS() === other.toCSS() ? 0 : undefined; - } - }, { - key: "isRulesetLike", - value: function isRulesetLike() { - return this.rulesetLike; - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - this.nodeVisible = Boolean(this.value); - - if (this.nodeVisible) { - output.add(this.value, this._fileInfo, this._index, this.mapLines); - } - } - }]); - - return Anonymous; -}(Node); - -Anonymous.prototype.type = 'Anonymous'; - -var MATH = Math$1; - -var Declaration = -/*#__PURE__*/ -function (_Node) { - _inherits(Declaration, _Node); - - function Declaration(name, value, important, merge, index, currentFileInfo, inline, variable) { - var _this; - - _classCallCheck(this, Declaration); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Declaration).call(this)); - _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, _assertThisInitialized(_this)); - - return _this; - } - - _createClass(Declaration, [{ - key: "genCSS", - value: function genCSS(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); - } - }, { - key: "eval", - value: function _eval(context) { - var mathBypass = false; - var prevMath; - var name = this.name; - var evaldValue; - var 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 - } // @todo remove when parens-division is default - - - if (name === 'font' && context.math === MATH.ALWAYS) { - mathBypass = true; - prevMath = context.math; - context.math = MATH.PARENS_DIVISION; - } - - 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; - var 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 (mathBypass) { - context.math = prevMath; - } - } - } - }, { - key: "makeImportant", - value: function makeImportant() { - return new Declaration(this.name, this.value, '!important', this.merge, this.getIndex(), this.fileInfo(), this.inline); - } - }]); - - return Declaration; -}(Node); - -function evalName(context, name) { - var value = ''; - var i; - var n = name.length; - var output = { - add: function add(s) { - value += s; - } - }; - - for (i = 0; i < n; i++) { - name[i].eval(context).genCSS(context, output); - } - - return value; -} - -Declaration.prototype.type = 'Declaration'; - -var debugInfo = function debugInfo(context, ctx, lineSeparator) { - var result = ''; - - if (context.dumpLineNumbers && !context.compress) { - switch (context.dumpLineNumbers) { - case 'comments': - result = debugInfo.asComment(ctx); - break; - - case 'mediaquery': - result = debugInfo.asMediaQuery(ctx); - break; - - case 'all': - result = debugInfo.asComment(ctx) + (lineSeparator || '') + debugInfo.asMediaQuery(ctx); - break; - } - } - - return result; -}; - -debugInfo.asComment = function (ctx) { - return `/* line ${ctx.debugInfo.lineNumber}, ${ctx.debugInfo.fileName} */\n`; -}; - -debugInfo.asMediaQuery = function (ctx) { - var filenameWithProtocol = ctx.debugInfo.fileName; - - if (!/^[a-z]+:\/\//i.test(filenameWithProtocol)) { - filenameWithProtocol = `file://${filenameWithProtocol}`; - } - - return `@media -sass-debug-info{filename{font-family:${filenameWithProtocol.replace(/([.:\/\\])/g, function (a) { - if (a == '\\') { - a = '\/'; - } - - return `\\${a}`; - })}}line{font-family:\\00003${ctx.debugInfo.lineNumber}}}\n`; -}; - -var Comment = -/*#__PURE__*/ -function (_Node) { - _inherits(Comment, _Node); - - function Comment(value, isLineComment, index, currentFileInfo) { - var _this; - - _classCallCheck(this, Comment); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Comment).call(this)); - _this.value = value; - _this.isLineComment = isLineComment; - _this._index = index; - _this._fileInfo = currentFileInfo; - _this.allowRoot = true; - return _this; - } - - _createClass(Comment, [{ - key: "genCSS", - value: function genCSS(context, output) { - if (this.debugInfo) { - output.add(debugInfo(context, this), this.fileInfo(), this.getIndex()); - } - - output.add(this.value); - } - }, { - key: "isSilent", - value: function isSilent(context) { - var isCompressed = context.compress && this.value[2] !== '!'; - return this.isLineComment || isCompressed; - } - }]); - - return Comment; -}(Node); - -Comment.prototype.type = 'Comment'; - -var contexts = {}; - -var copyFromOriginal = function copyFromOriginal(original, destination, propertiesToCopy) { - if (!original) { - return; - } - - for (var i = 0; i < propertiesToCopy.length; i++) { - if (original.hasOwnProperty(propertiesToCopy[i])) { - destination[propertiesToCopy[i]] = original[propertiesToCopy[i]]; - } - } -}; -/* - parse is used whilst parsing - */ - - -var parseCopyProperties = [// options -'paths', // option - unmodified - paths to search for imports on -'rewriteUrls', // option - whether to adjust URL's to be relative -'rootpath', // option - rootpath to append to URL's -'strictImports', // option - -'insecure', // option - whether to allow imports from insecure ssl hosts -'dumpLineNumbers', // option - whether to dump line numbers -'compress', // option - whether to compress -'syncImport', // option - whether to import synchronously -'chunkInput', // option - whether to chunk input. more performant but causes parse issues. -'mime', // browser only - mime type for sheet import -'useFileCache', // browser only - whether to use the per file session cache -// context -'processImports', // option & context - whether to process imports. if false then imports will not be imported. -// Used by the import manager to stop multiple import visitors being created. -'pluginManager' // Used as the plugin manager for the session -]; - -contexts.Parse = function (options) { - copyFromOriginal(options, this, parseCopyProperties); - - if (typeof this.paths === 'string') { - this.paths = [this.paths]; - } -}; - -var evalCopyProperties = ['paths', // additional include paths -'compress', // whether to compress -'math', // 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 -'rewriteUrls' // option - whether to adjust URL's to be relative -]; - -function isPathRelative(path) { - return !/^(?:[a-z-]+:|\/|#)/i.test(path); -} - -function isPathLocalRelative(path) { - return path.charAt(0) === '.'; -} - -contexts.Eval = -/*#__PURE__*/ -function () { - function _class(options, frames) { - _classCallCheck(this, _class); - - copyFromOriginal(options, this, evalCopyProperties); - - if (typeof this.paths === 'string') { - this.paths = [this.paths]; - } - - this.frames = frames || []; - this.importantScope = this.importantScope || []; - this.inCalc = false; - this.mathOn = true; - } - - _createClass(_class, [{ - key: "enterCalc", - value: function enterCalc() { - if (!this.calcStack) { - this.calcStack = []; - } - - this.calcStack.push(true); - this.inCalc = true; - } - }, { - key: "exitCalc", - value: function exitCalc() { - this.calcStack.pop(); - - if (!this.calcStack) { - this.inCalc = false; - } - } - }, { - key: "inParenthesis", - value: function inParenthesis() { - if (!this.parensStack) { - this.parensStack = []; - } - - this.parensStack.push(true); - } - }, { - key: "outOfParenthesis", - value: function outOfParenthesis() { - this.parensStack.pop(); - } - }, { - key: "isMathOn", - value: function isMathOn(op) { - if (!this.mathOn) { - return false; - } - - if (op === '/' && this.math !== Math$1.ALWAYS && (!this.parensStack || !this.parensStack.length)) { - return false; - } - - if (this.math > Math$1.PARENS_DIVISION) { - return this.parensStack && this.parensStack.length; - } - - return true; - } - }, { - key: "pathRequiresRewrite", - value: function pathRequiresRewrite(path) { - var isRelative = this.rewriteUrls === RewriteUrls.LOCAL ? isPathLocalRelative : isPathRelative; - return isRelative(path); - } - }, { - key: "rewritePath", - value: function rewritePath(path, rootpath) { - var newPath; - rootpath = rootpath || ''; - newPath = this.normalizePath(rootpath + path); // If a path was explicit relative and the rootpath was not an absolute path - // we must ensure that the new path is also explicit relative. - - if (isPathLocalRelative(path) && isPathRelative(rootpath) && isPathLocalRelative(newPath) === false) { - newPath = `./${newPath}`; - } - - return newPath; - } - }, { - key: "normalizePath", - value: function normalizePath(path) { - var segments = path.split('/').reverse(); - var segment; - path = []; - - while (segments.length !== 0) { - segment = segments.pop(); - - switch (segment) { - case '.': - break; - - case '..': - if (path.length === 0 || path[path.length - 1] === '..') { - path.push(segment); - } else { - path.pop(); - } - - break; - - default: - path.push(segment); - break; - } - } - - return path.join('/'); - } - }]); - - return _class; -}(); - -function makeRegistry(base) { - return { - _data: {}, - add: function add(name, func) { - // precautionary case conversion, as later querying of - // the registry by function-caller uses lower case as well. - name = name.toLowerCase(); - - if (this._data.hasOwnProperty(name)) ; - - this._data[name] = func; - }, - addMultiple: function addMultiple(functions) { - var _this = this; - - Object.keys(functions).forEach(function (name) { - _this.add(name, functions[name]); - }); - }, - get: function get(name) { - return this._data[name] || base && base.get(name); - }, - getLocalFunctions: function getLocalFunctions() { - return this._data; - }, - inherit: function inherit() { - return makeRegistry(this); - }, - create: function create(base) { - return makeRegistry(base); - } - }; -} - -var functionRegistry = makeRegistry(null); - -var defaultFunc = { - eval: function _eval() { - var v = this.value_; - var e = this.error_; - - if (e) { - throw e; - } - - if (v != null) { - return v ? Keyword.True : Keyword.False; - } - }, - value: function value(v) { - this.value_ = v; - }, - error: function error(e) { - this.error_ = e; - }, - reset: function reset() { - this.value_ = this.error_ = null; - } -}; - -var Ruleset = -/*#__PURE__*/ -function (_Node) { - _inherits(Ruleset, _Node); - - function Ruleset(selectors, rules, strictImports, visibilityInfo) { - var _this; - - _classCallCheck(this, Ruleset); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Ruleset).call(this)); - _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, _assertThisInitialized(_this)); - - _this.setParent(_this.rules, _assertThisInitialized(_this)); - - return _this; - } - - _createClass(Ruleset, [{ - key: "isRulesetLike", - value: function isRulesetLike() { - return true; - } - }, { - key: "accept", - value: function accept(visitor) { - if (this.paths) { - this.paths = visitor.visitArray(this.paths, true); - } else if (this.selectors) { - this.selectors = visitor.visitArray(this.selectors); - } - - if (this.rules && this.rules.length) { - this.rules = visitor.visitArray(this.rules); - } - } - }, { - key: "eval", - value: function _eval(context) { - var selectors; - var selCnt; - var selector; - var i; - var hasVariable; - var hasOnePassingSelector = false; - - if (this.selectors && (selCnt = this.selectors.length)) { - 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 = this.selectors[i].eval(context); - - for (var j = 0; j < selector.elements.length; j++) { - if (selector.elements[j].isVariable) { - hasVariable = true; - break; - } - } - - selectors[i] = selector; - - if (selector.evaldCondition) { - hasOnePassingSelector = true; - } - } - - if (hasVariable) { - var toParseSelectors = new Array(selCnt); - - for (i = 0; i < selCnt; i++) { - selector = selectors[i]; - toParseSelectors[i] = selector.toCSS(context); - } - - this.parse.parseNode(toParseSelectors.join(','), ["selectors"], selectors[0].getIndex(), selectors[0].fileInfo(), function (err, result) { - if (result) { - selectors = flattenArray(result); - } - }); - } - - defaultFunc.reset(); - } else { - hasOnePassingSelector = true; - } - - var rules = this.rules ? copyArray(this.rules) : null; - var ruleset = new Ruleset(selectors, rules, this.strictImports, this.visibilityInfo()); - var rule; - var subRule; - ruleset.originalRuleset = this; - ruleset.root = this.root; - ruleset.firstRoot = this.firstRoot; - ruleset.allowImports = this.allowImports; - - if (this.debugInfo) { - ruleset.debugInfo = this.debugInfo; - } - - if (!hasOnePassingSelector) { - rules.length = 0; - } // inherit a function registry from the frames stack when possible; - // otherwise from the global registry - - - ruleset.functionRegistry = function (frames) { - var i = 0; - var n = frames.length; - var found; - - for (; i !== n; ++i) { - found = frames[i].functionRegistry; - - if (found) { - return found; - } - } - - return functionRegistry; - }(context.frames).inherit(); // push the current ruleset to the frames stack - - - var ctxFrames = context.frames; - ctxFrames.unshift(ruleset); // currrent selectors - - var ctxSelectors = context.selectors; - - if (!ctxSelectors) { - context.selectors = ctxSelectors = []; - } - - ctxSelectors.unshift(this.selectors); // Evaluate imports - - if (ruleset.root || ruleset.allowImports || !ruleset.strictImports) { - ruleset.evalImports(context); - } // Store the frames around mixin definitions, - // so they can be evaluated like closures when the time comes. - - - 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; 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 - return !ruleset.variable(r.name); - } - - return true; - }); - rsRules.splice.apply(rsRules, _toConsumableArray([i, 1].concat(rules))); - i += rules.length - 1; - ruleset.resetCache(); - } 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, _toConsumableArray([i, 1].concat(rules))); - i += rules.length - 1; - ruleset.resetCache(); - } - } // Evaluate everything else - - - 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; 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] && rule.selectors[0].isJustParentSelector()) { - rsRules.splice(i--, 1); - - 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); - } - } - } - } - } - } // Pop the stack - - - ctxFrames.shift(); - ctxSelectors.shift(); - - if (context.mediaBlocks) { - for (i = mediaBlockCount; i < context.mediaBlocks.length; i++) { - context.mediaBlocks[i].bubbleSelectors(selectors); - } - } - - return ruleset; - } - }, { - key: "evalImports", - value: function evalImports(context) { - var rules = this.rules; - var i; - var importRules; - - if (!rules) { - return; - } - - for (i = 0; i < rules.length; i++) { - if (rules[i].type === 'Import') { - importRules = rules[i].eval(context); - - if (importRules && (importRules.length || importRules.length === 0)) { - rules.splice.apply(rules, _toConsumableArray([i, 1].concat(importRules))); - i += importRules.length - 1; - } else { - rules.splice(i, 1, importRules); - } - - this.resetCache(); - } - } - } - }, { - key: "makeImportant", - value: function makeImportant() { - var result = new Ruleset(this.selectors, this.rules.map(function (r) { - if (r.makeImportant) { - return r.makeImportant(); - } else { - return r; - } - }), this.strictImports, this.visibilityInfo()); - return result; - } - }, { - key: "matchArgs", - value: function matchArgs(args) { - return !args || args.length === 0; - } // lets you call a css selector with a guard - - }, { - key: "matchCondition", - value: function matchCondition(args, context) { - var lastSelector = this.selectors[this.selectors.length - 1]; - - if (!lastSelector.evaldCondition) { - return false; - } - - if (lastSelector.condition && !lastSelector.condition.eval(new contexts.Eval(context, context.frames))) { - return false; - } - - return true; - } - }, { - key: "resetCache", - value: function resetCache() { - this._rulesets = null; - this._variables = null; - this._properties = null; - this._lookups = {}; - } - }, { - key: "variables", - value: function variables() { - if (!this._variables) { - this._variables = !this.rules ? {} : this.rules.reduce(function (hash, r) { - if (r instanceof Declaration && r.variable === true) { - hash[r.name] = r; - } // when evaluating variables in an import statement, imports have not been eval'd - // so we need to go inside import statements. - // guard against root being a string (in the case of inlined less) - - - if (r.type === 'Import' && r.root && r.root.variables) { - var vars = r.root.variables(); - - for (var name in vars) { - if (vars.hasOwnProperty(name)) { - hash[name] = r.root.variable(name); - } - } - } - - return hash; - }, {}); - } - - return this._variables; - } - }, { - key: "properties", - value: function properties() { - 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; - } - }, { - key: "variable", - value: function variable(name) { - var decl = this.variables()[name]; - - if (decl) { - return this.parseValue(decl); - } - } - }, { - key: "property", - value: function property(name) { - var decl = this.properties()[name]; - - if (decl) { - return this.parseValue(decl); - } - } - }, { - key: "lastDeclaration", - value: function lastDeclaration() { - for (var i = this.rules.length; i > 0; i--) { - var decl = this.rules[i - 1]; - - if (decl instanceof Declaration) { - return this.parseValue(decl); - } - } - } - }, { - key: "parseValue", - value: function parseValue(toParse) { - var self = this; - - function transformDeclaration(decl) { - if (decl.value instanceof Anonymous && !decl.parsed) { - if (typeof decl.value.value === 'string') { - 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; - } - }); - } else { - 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; - } - } - }, { - key: "rulesets", - value: function rulesets() { - if (!this.rules) { - return []; - } - - var filtRules = []; - var rules = this.rules; - var i; - var rule; - - for (i = 0; rule = rules[i]; i++) { - if (rule.isRuleset) { - filtRules.push(rule); - } - } - - return filtRules; - } - }, { - key: "prependRule", - value: function prependRule(rule) { - var rules = this.rules; - - if (rules) { - rules.unshift(rule); - } else { - this.rules = [rule]; - } - - this.setParent(rule, this); - } - }, { - key: "find", - value: function find(selector) { - var self = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this; - var filter = arguments.length > 2 ? arguments[2] : undefined; - var rules = []; - var match; - var foundMixins; - var key = selector.toCSS(); - - if (key in this._lookups) { - return this._lookups[key]; - } - - this.rulesets().forEach(function (rule) { - if (rule !== self) { - for (var j = 0; j < rule.selectors.length; j++) { - match = selector.match(rule.selectors[j]); - - if (match) { - if (selector.elements.length > match) { - if (!filter || filter(rule)) { - foundMixins = rule.find(new Selector(selector.elements.slice(match)), self, filter); - - for (var i = 0; i < foundMixins.length; ++i) { - foundMixins[i].path.push(rule); - } - - Array.prototype.push.apply(rules, foundMixins); - } - } else { - rules.push({ - rule, - path: [] - }); - } - - break; - } - } - } - }); - this._lookups[key] = rules; - return rules; - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - var i; - var j; - var charsetRuleNodes = []; - var ruleNodes = []; - var // Line number debugging - debugInfo$1; - var rule; - var path; - context.tabLevel = context.tabLevel || 0; - - if (!this.root) { - context.tabLevel++; - } - - var tabRuleStr = context.compress ? '' : Array(context.tabLevel + 1).join(' '); - var tabSetStr = context.compress ? '' : Array(context.tabLevel).join(' '); - var sep; - var charsetNodeIndex = 0; - var importNodeIndex = 0; - - for (i = 0; rule = this.rules[i]; i++) { - if (rule instanceof Comment) { - if (importNodeIndex === i) { - importNodeIndex++; - } - - ruleNodes.push(rule); - } else if (rule.isCharset && rule.isCharset()) { - ruleNodes.splice(charsetNodeIndex, 0, rule); - charsetNodeIndex++; - importNodeIndex++; - } else if (rule.type === 'Import') { - ruleNodes.splice(importNodeIndex, 0, rule); - importNodeIndex++; - } else { - ruleNodes.push(rule); - } - } - - ruleNodes = charsetRuleNodes.concat(ruleNodes); // If this is the root node, we don't render - // a selector, or {}. - - if (!this.root) { - debugInfo$1 = debugInfo(context, this, tabSetStr); - - if (debugInfo$1) { - output.add(debugInfo$1); - output.add(tabSetStr); - } - - var paths = this.paths; - var pathCnt = paths.length; - var pathSubCnt; - sep = context.compress ? ',' : `,\n${tabSetStr}`; - - for (i = 0; i < pathCnt; i++) { - path = paths[i]; - - if (!(pathSubCnt = path.length)) { - continue; - } - - if (i > 0) { - output.add(sep); - } - - context.firstSelector = true; - path[0].genCSS(context, output); - context.firstSelector = false; - - for (j = 1; j < pathSubCnt; j++) { - path[j].genCSS(context, output); - } - } - - output.add((context.compress ? '{' : ' {\n') + tabRuleStr); - } // Compile rules and rulesets - - - for (i = 0; rule = ruleNodes[i]; i++) { - if (i + 1 === ruleNodes.length) { - context.lastRule = true; - } - - var currentLastRule = context.lastRule; - - if (rule.isRulesetLike(rule)) { - context.lastRule = false; - } - - if (rule.genCSS) { - rule.genCSS(context, output); - } else if (rule.value) { - output.add(rule.value.toString()); - } - - context.lastRule = currentLastRule; - - if (!context.lastRule && rule.isVisible()) { - output.add(context.compress ? '' : `\n${tabRuleStr}`); - } else { - context.lastRule = false; - } - } - - if (!this.root) { - output.add(context.compress ? '}' : `\n${tabSetStr}}`); - context.tabLevel--; - } - - if (!output.isEmpty() && !context.compress && this.firstRoot) { - output.add('\n'); - } - } - }, { - key: "joinSelectors", - value: function joinSelectors(paths, context, selectors) { - for (var s = 0; s < selectors.length; s++) { - this.joinSelector(paths, context, selectors[s]); - } - } - }, { - key: "joinSelector", - value: function joinSelector(paths, context, selector) { - function createParenthesis(elementsToPak, originalElement) { - var replacementParen; - var j; - - if (elementsToPak.length === 0) { - replacementParen = new Paren(elementsToPak[0]); - } else { - var insideParent = new Array(elementsToPak.length); - - for (j = 0; j < elementsToPak.length; j++) { - insideParent[j] = new Element(null, elementsToPak[j], originalElement.isVariable, originalElement._index, originalElement._fileInfo); - } - - replacementParen = new Paren(new Selector(insideParent)); - } - - return replacementParen; - } - - function createSelector(containedElement, originalElement) { - var element; - var selector; - element = new Element(null, containedElement, originalElement.isVariable, originalElement._index, originalElement._fileInfo); - selector = new Selector([element]); - return selector; - } // joins selector path from `beginningPath` with selector path in `addPath` - // `replacedElement` contains element that is being replaced by `addPath` - // returns concatenated path - - - function addReplacementIntoPath(beginningPath, addPath, replacedElement, originalSelector) { - var newSelectorPath; - var lastSelector; - var newJoinedSelector; // our new selector path - - newSelectorPath = []; // 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 = copyArray(beginningPath); - lastSelector = newSelectorPath.pop(); - newJoinedSelector = originalSelector.createDerived(copyArray(lastSelector.elements)); - } else { - newJoinedSelector = originalSelector.createDerived([]); - } - - if (addPath.length > 0) { - // /deep/ is a CSS4 selector - (removed, so should deprecate) - // that is valid without anything in front of it - // so if the & does not have a combinator that is "" or " " then - // and there is a combinator on the parent, then grab that. - // this also allows + a { & .b { .a & { ... though not sure why you would want to do that - var combinator = replacedElement.combinator; - var parentEl = addPath[0].elements[0]; - - if (combinator.emptyOrWhitespace && !parentEl.combinator.emptyOrWhitespace) { - combinator = parentEl.combinator; - } // join the elements so far with the first part of the parent - - - newJoinedSelector.elements.push(new Element(combinator, parentEl.value, replacedElement.isVariable, replacedElement._index, replacedElement._fileInfo)); - newJoinedSelector.elements = newJoinedSelector.elements.concat(addPath[0].elements.slice(1)); - } // now add the joined selector - but only if it is not empty - - - if (newJoinedSelector.elements.length !== 0) { - newSelectorPath.push(newJoinedSelector); - } // 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) { - return selector.createDerived(selector.elements, []); - }); - newSelectorPath = newSelectorPath.concat(restOfPath); - } - - return newSelectorPath; - } // joins selector path from `beginningPath` with every selector path in `addPaths` array - // `replacedElement` contains element that is being replaced by `addPath` - // returns array with all concatenated paths - - - function addAllReplacementsIntoPath(beginningPath, addPaths, replacedElement, originalSelector, result) { - var j; - - for (j = 0; j < beginningPath.length; j++) { - var newSelectorPath = addReplacementIntoPath(beginningPath[j], addPaths, replacedElement, originalSelector); - result.push(newSelectorPath); - } - - return result; - } - - function mergeElementsOnToSelectors(elements, selectors) { - var i; - var sel; - - if (elements.length === 0) { - return; - } - - if (selectors.length === 0) { - selectors.push([new Selector(elements)]); - return; - } - - 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)); - } else { - sel.push(new Selector(elements)); - } - } - } // replace all parent selectors inside `inSelector` by content of `context` array - // resulting selectors are returned inside `paths` array - // returns true if `inSelector` contained at least one parent selector - - - function replaceParentSelector(paths, context, inSelector) { - // The paths are [[Selector]] - // The first list is a list of comma separated selectors - // The inner list is a list of inheritance separated selectors - // e.g. - // .a, .b { - // .c { - // } - // } - // == [[.a] [.c]] [[.b] [.c]] - // - var i; - var j; - var k; - var currentElements; - var newSelectors; - var selectorsMultiplied; - var sel; - var el; - var hadParentSelector = false; - var length; - var lastSelector; - - function findNestedSelector(element) { - var maybeSelector; - - if (!(element.value instanceof Paren)) { - return null; - } - - maybeSelector = element.value.value; - - if (!(maybeSelector instanceof Selector)) { - return null; - } - - return maybeSelector; - } // the elements from the current selector so far - - - currentElements = []; // the current list of new selectors to add to the path. - // We will build it up. We initiate it with one empty selector as we "multiply" the new selectors - // by the parents - - newSelectors = [[]]; - - for (i = 0; el = inSelector.elements[i]; i++) { - // non parent reference elements just get added - if (el.value !== '&') { - var nestedSelector = findNestedSelector(el); - - if (nestedSelector != null) { - // merge the current list of non parent selector elements - // on to the current list of selectors to add - mergeElementsOnToSelectors(currentElements, newSelectors); - var nestedPaths = []; - var replaced = void 0; - var replacedNewSelectors = []; - replaced = replaceParentSelector(nestedPaths, context, nestedSelector); - hadParentSelector = hadParentSelector || replaced; // 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); - } - - newSelectors = replacedNewSelectors; - currentElements = []; - } else { - currentElements.push(el); - } - } else { - hadParentSelector = true; // the new list of selectors to add - - selectorsMultiplied = []; // merge the current list of non parent selector elements - // on to the current list of selectors to add - - mergeElementsOnToSelectors(currentElements, newSelectors); // loop through our current selectors - - for (j = 0; j < newSelectors.length; j++) { - sel = newSelectors[j]; // if we don't have any parent paths, the & might be in a mixin so that it can be used - // whether there are parents or not - - if (context.length === 0) { - // 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.isVariable, el._index, el._fileInfo)); - } - - selectorsMultiplied.push(sel); - } else { - // and the parent selectors - for (k = 0; k < context.length; k++) { - // We need to put the current selectors - // then join the last selector's elements on to the parents selectors - var newSelectorPath = addReplacementIntoPath(sel, context[k], el, inSelector); // add that to our new set of selectors - - selectorsMultiplied.push(newSelectorPath); - } - } - } // our new selectors has been multiplied, so reset the state - - - newSelectors = selectorsMultiplied; - currentElements = []; - } - } // if we have any elements left over (e.g. .a& .b == .b) - // add them on to all the current selectors - - - mergeElementsOnToSelectors(currentElements, newSelectors); - - for (i = 0; i < newSelectors.length; i++) { - length = newSelectors[i].length; - - if (length > 0) { - paths.push(newSelectors[i]); - lastSelector = newSelectors[i][length - 1]; - newSelectors[i][length - 1] = lastSelector.createDerived(lastSelector.elements, inSelector.extendList); - } - } - - return hadParentSelector; - } - - function deriveSelector(visibilityInfo, deriveFrom) { - var newSelector = deriveFrom.createDerived(deriveFrom.elements, deriveFrom.extendList, deriveFrom.evaldCondition); - newSelector.copyVisibilityInfo(visibilityInfo); - return newSelector; - } // joinSelector code follows - - - var i; - var newPaths; - var hadParentSelector; - newPaths = []; - hadParentSelector = replaceParentSelector(newPaths, context, selector); - - if (!hadParentSelector) { - if (context.length > 0) { - newPaths = []; - - for (i = 0; i < context.length; i++) { - var concatenated = context[i].map(deriveSelector.bind(this, selector.visibilityInfo())); - concatenated.push(selector); - newPaths.push(concatenated); - } - } else { - newPaths = [[selector]]; - } - } - - for (i = 0; i < newPaths.length; i++) { - paths.push(newPaths[i]); - } - } - }]); - - return Ruleset; -}(Node); - -Ruleset.prototype.type = 'Ruleset'; -Ruleset.prototype.isRuleset = true; - -var AtRule = -/*#__PURE__*/ -function (_Node) { - _inherits(AtRule, _Node); - - function AtRule(name, value, rules, index, currentFileInfo, debugInfo, isRooted, visibilityInfo) { - var _this; - - _classCallCheck(this, AtRule); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(AtRule).call(this)); - 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, _assertThisInitialized(_this)); - } - - _this._index = index; - _this._fileInfo = currentFileInfo; - _this.debugInfo = debugInfo; - _this.isRooted = isRooted || false; - - _this.copyVisibilityInfo(visibilityInfo); - - _this.allowRoot = true; - return _this; - } - - _createClass(AtRule, [{ - key: "accept", - value: function accept(visitor) { - var value = this.value; - var rules = this.rules; - - if (rules) { - this.rules = visitor.visitArray(rules); - } - - if (value) { - this.value = visitor.visit(value); - } - } - }, { - key: "isRulesetLike", - value: function isRulesetLike() { - return this.rules || !this.isCharset(); - } - }, { - key: "isCharset", - value: function isCharset() { - return '@charset' === this.name; - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - var value = this.value; - var 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(';'); - } - } - }, { - key: "eval", - value: function _eval(context) { - var mediaPathBackup; - var mediaBlocksBackup; - var value = this.value; - var 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()); - } - }, { - key: "variable", - value: function variable(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); - } - } - }, { - key: "find", - value: function find() { - if (this.rules) { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - // 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], args); - } - } - }, { - key: "rulesets", - value: function rulesets() { - 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]); - } - } - }, { - key: "outputRuleset", - value: function outputRuleset(context, output, rules) { - var ruleCnt = rules.length; - var 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(' ')}`; - var 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--; - } - }]); - - return AtRule; -}(Node); - -AtRule.prototype.type = 'AtRule'; - -var DetachedRuleset = -/*#__PURE__*/ -function (_Node) { - _inherits(DetachedRuleset, _Node); - - function DetachedRuleset(ruleset, frames) { - var _this; - - _classCallCheck(this, DetachedRuleset); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(DetachedRuleset).call(this)); - _this.ruleset = ruleset; - _this.frames = frames; - - _this.setParent(_this.ruleset, _assertThisInitialized(_this)); - - return _this; - } - - _createClass(DetachedRuleset, [{ - key: "accept", - value: function accept(visitor) { - this.ruleset = visitor.visit(this.ruleset); - } - }, { - key: "eval", - value: function _eval(context) { - var frames = this.frames || copyArray(context.frames); - return new DetachedRuleset(this.ruleset, frames); - } - }, { - key: "callEval", - value: function callEval(context) { - return this.ruleset.eval(this.frames ? new contexts.Eval(context, this.frames.concat(context.frames)) : context); - } - }]); - - return DetachedRuleset; -}(Node); - -DetachedRuleset.prototype.type = 'DetachedRuleset'; -DetachedRuleset.prototype.evalFirst = true; - -var Unit = -/*#__PURE__*/ -function (_Node) { - _inherits(Unit, _Node); - - function Unit(numerator, denominator, backupUnit) { - var _this; - - _classCallCheck(this, Unit); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Unit).call(this)); - _this.numerator = numerator ? copyArray(numerator).sort() : []; - _this.denominator = denominator ? copyArray(denominator).sort() : []; - - if (backupUnit) { - _this.backupUnit = backupUnit; - } else if (numerator && numerator.length) { - _this.backupUnit = numerator[0]; - } - - return _this; - } - - _createClass(Unit, [{ - key: "clone", - value: function clone() { - return new Unit(copyArray(this.numerator), copyArray(this.denominator), this.backupUnit); - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - // Dimension checks the unit is singular and throws an error if in strict math mode. - var strictUnits = context && context.strictUnits; - - if (this.numerator.length === 1) { - output.add(this.numerator[0]); // the ideal situation - } else if (!strictUnits && this.backupUnit) { - output.add(this.backupUnit); - } else if (!strictUnits && this.denominator.length) { - output.add(this.denominator[0]); - } - } - }, { - key: "toString", - value: function toString() { - var i; - var returnStr = this.numerator.join('*'); - - for (i = 0; i < this.denominator.length; i++) { - returnStr += `/${this.denominator[i]}`; - } - - return returnStr; - } - }, { - key: "compare", - value: function compare(other) { - return this.is(other.toString()) ? 0 : undefined; - } - }, { - key: "is", - value: function is(unitString) { - return this.toString().toUpperCase() === unitString.toUpperCase(); - } - }, { - key: "isLength", - value: function isLength() { - return RegExp('^(px|em|ex|ch|rem|in|cm|mm|pc|pt|ex|vw|vh|vmin|vmax)$', 'gi').test(this.toCSS()); - } - }, { - key: "isEmpty", - value: function isEmpty() { - return this.numerator.length === 0 && this.denominator.length === 0; - } - }, { - key: "isSingular", - value: function isSingular() { - return this.numerator.length <= 1 && this.denominator.length === 0; - } - }, { - key: "map", - value: function map(callback) { - var i; - - for (i = 0; i < this.numerator.length; i++) { - this.numerator[i] = callback(this.numerator[i], false); - } - - for (i = 0; i < this.denominator.length; i++) { - this.denominator[i] = callback(this.denominator[i], true); - } - } - }, { - key: "usedUnits", - value: function usedUnits() { - var group; - var result = {}; - var mapUnit; - var groupName; - - mapUnit = function mapUnit(atomicUnit) { - /* jshint loopfunc:true */ - if (group.hasOwnProperty(atomicUnit) && !result[groupName]) { - result[groupName] = atomicUnit; - } - - return atomicUnit; - }; - - for (groupName in unitConversions) { - if (unitConversions.hasOwnProperty(groupName)) { - group = unitConversions[groupName]; - this.map(mapUnit); - } - } - - return result; - } - }, { - key: "cancel", - value: function cancel() { - var counter = {}; - var atomicUnit; - var i; - - for (i = 0; i < this.numerator.length; i++) { - atomicUnit = this.numerator[i]; - counter[atomicUnit] = (counter[atomicUnit] || 0) + 1; - } - - for (i = 0; i < this.denominator.length; i++) { - atomicUnit = this.denominator[i]; - counter[atomicUnit] = (counter[atomicUnit] || 0) - 1; - } - - this.numerator = []; - this.denominator = []; - - for (atomicUnit in counter) { - if (counter.hasOwnProperty(atomicUnit)) { - var count = counter[atomicUnit]; - - if (count > 0) { - for (i = 0; i < count; i++) { - this.numerator.push(atomicUnit); - } - } else if (count < 0) { - for (i = 0; i < -count; i++) { - this.denominator.push(atomicUnit); - } - } - } - } - - this.numerator.sort(); - this.denominator.sort(); - } - }]); - - return Unit; -}(Node); - -Unit.prototype.type = 'Unit'; - -// A number with a unit -// - -var Dimension = -/*#__PURE__*/ -function (_Node) { - _inherits(Dimension, _Node); - - function Dimension(value, unit) { - var _this; - - _classCallCheck(this, Dimension); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Dimension).call(this)); - _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, _assertThisInitialized(_this)); - - return _this; - } - - _createClass(Dimension, [{ - key: "accept", - value: function accept(visitor) { - this.unit = visitor.visit(this.unit); - } - }, { - key: "eval", - value: function _eval(context) { - return this; - } - }, { - key: "toColor", - value: function toColor() { - return new Color([this.value, this.value, this.value]); - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - if (context && context.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 value = this.fround(context, this.value); - var strValue = String(value); - - if (value !== 0 && value < 0.000001 && value > -0.000001) { - // would be output 1e-6 etc. - strValue = value.toFixed(20).replace(/0+$/, ''); - } - - if (context && context.compress) { - // Zero values doesn't need a unit - if (value === 0 && this.unit.isLength()) { - output.add(strValue); - return; - } // Float values doesn't need a leading zero - - - if (value > 0 && value < 1) { - strValue = strValue.substr(1); - } - } - - output.add(strValue); - this.unit.genCSS(context, output); - } // In an operation between two Dimensions, - // we default to the first Dimension's unit, - // so `1px + 2` will yield `3px`. - - }, { - key: "operate", - value: function operate(context, op, other) { - /* jshint noempty:false */ - var value = this._operate(context, op, this.value, other.value); - - var unit = this.unit.clone(); - - if (op === '+' || op === '-') { - if (unit.numerator.length === 0 && unit.denominator.length === 0) { - unit = other.unit.clone(); - - if (this.unit.backupUnit) { - unit.backupUnit = this.unit.backupUnit; - } - } else if (other.unit.numerator.length === 0 && unit.denominator.length === 0) ; else { - other = other.convertTo(this.unit.usedUnits()); - - if (context.strictUnits && other.unit.toString() !== unit.toString()) { - throw new Error(`Incompatible units. Change the units or use the unit function. ` + `Bad units: '${unit.toString()}' and '${other.unit.toString()}'.`); - } - - value = this._operate(context, op, this.value, other.value); - } - } else if (op === '*') { - unit.numerator = unit.numerator.concat(other.unit.numerator).sort(); - unit.denominator = unit.denominator.concat(other.unit.denominator).sort(); - unit.cancel(); - } else if (op === '/') { - unit.numerator = unit.numerator.concat(other.unit.denominator).sort(); - unit.denominator = unit.denominator.concat(other.unit.numerator).sort(); - unit.cancel(); - } - - return new Dimension(value, unit); - } - }, { - key: "compare", - value: function compare(other) { - var a; - var b; - - if (!(other instanceof Dimension)) { - return undefined; - } - - if (this.unit.isEmpty() || other.unit.isEmpty()) { - a = this; - b = other; - } else { - a = this.unify(); - b = other.unify(); - - if (a.unit.compare(b.unit) !== 0) { - return undefined; - } - } - - return Node.numericCompare(a.value, b.value); - } - }, { - key: "unify", - value: function unify() { - return this.convertTo({ - length: 'px', - duration: 's', - angle: 'rad' - }); - } - }, { - key: "convertTo", - value: function convertTo(conversions) { - var value = this.value; - var unit = this.unit.clone(); - var i; - var groupName; - var group; - var targetUnit; - var derivedConversions = {}; - var applyUnit; - - if (typeof conversions === 'string') { - for (i in unitConversions) { - if (unitConversions[i].hasOwnProperty(conversions)) { - derivedConversions = {}; - derivedConversions[i] = conversions; - } - } - - conversions = derivedConversions; - } - - applyUnit = function applyUnit(atomicUnit, denominator) { - /* jshint loopfunc:true */ - if (group.hasOwnProperty(atomicUnit)) { - if (denominator) { - value = value / (group[atomicUnit] / group[targetUnit]); - } else { - value = value * (group[atomicUnit] / group[targetUnit]); - } - - return targetUnit; - } - - return atomicUnit; - }; - - for (groupName in conversions) { - if (conversions.hasOwnProperty(groupName)) { - targetUnit = conversions[groupName]; - group = unitConversions[groupName]; - unit.map(applyUnit); - } - } - - unit.cancel(); - return new Dimension(value, unit); - } - }]); - - return Dimension; -}(Node); - -Dimension.prototype.type = 'Dimension'; - -var MATH$1 = Math$1; - -var Operation = -/*#__PURE__*/ -function (_Node) { - _inherits(Operation, _Node); - - function Operation(op, operands, isSpaced) { - var _this; - - _classCallCheck(this, Operation); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Operation).call(this)); - _this.op = op.trim(); - _this.operands = operands; - _this.isSpaced = isSpaced; - return _this; - } - - _createClass(Operation, [{ - key: "accept", - value: function accept(visitor) { - this.operands = visitor.visitArray(this.operands); - } - }, { - key: "eval", - value: function _eval(context) { - var a = this.operands[0].eval(context); - var b = this.operands[1].eval(context); - var op; - - if (context.isMathOn(this.op)) { - op = this.op === './' ? '/' : this.op; - - if (a instanceof Dimension && b instanceof Color) { - a = a.toColor(); - } - - if (b instanceof Dimension && a instanceof Color) { - b = b.toColor(); - } - - if (!a.operate) { - if (a instanceof Operation && a.op === '/' && context.math === MATH$1.PARENS_DIVISION) { - return new Operation(this.op, [a, b], this.isSpaced); - } - - throw { - type: 'Operation', - message: 'Operation on an invalid type' - }; - } - - return a.operate(context, op, b); - } else { - return new Operation(this.op, [a, b], this.isSpaced); - } - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - this.operands[0].genCSS(context, output); - - if (this.isSpaced) { - output.add(' '); - } - - output.add(this.op); - - if (this.isSpaced) { - output.add(' '); - } - - this.operands[1].genCSS(context, output); - } - }]); - - return Operation; -}(Node); - -Operation.prototype.type = 'Operation'; - -var MATH$2 = Math$1; - -var Expression = -/*#__PURE__*/ -function (_Node) { - _inherits(Expression, _Node); - - function Expression(value, noSpacing) { - var _this; - - _classCallCheck(this, Expression); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Expression).call(this)); - _this.value = value; - _this.noSpacing = noSpacing; - - if (!value) { - throw new Error('Expression requires an array parameter'); - } - - return _this; - } - - _createClass(Expression, [{ - key: "accept", - value: function accept(visitor) { - this.value = visitor.visitArray(this.value); - } - }, { - key: "eval", - value: function _eval(context) { - var returnValue; - var mathOn = context.isMathOn(); - var inParenthesis = this.parens && (context.math !== MATH$2.STRICT_LEGACY || !this.parensInOp); - var doubleParen = false; - - if (inParenthesis) { - context.inParenthesis(); - } - - if (this.value.length > 1) { - returnValue = new Expression(this.value.map(function (e) { - if (!e.eval) { - return e; - } - - return e.eval(context); - }), this.noSpacing); - } else if (this.value.length === 1) { - if (this.value[0].parens && !this.value[0].parensInOp && !context.inCalc) { - doubleParen = true; - } - - returnValue = this.value[0].eval(context); - } else { - returnValue = this; - } - - if (inParenthesis) { - context.outOfParenthesis(); - } - - if (this.parens && this.parensInOp && !mathOn && !doubleParen && !(returnValue instanceof Dimension)) { - returnValue = new Paren(returnValue); - } - - return returnValue; - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - for (var i = 0; i < this.value.length; i++) { - this.value[i].genCSS(context, output); - - if (!this.noSpacing && i + 1 < this.value.length) { - output.add(' '); - } - } - } - }, { - key: "throwAwayComments", - value: function throwAwayComments() { - this.value = this.value.filter(function (v) { - return !(v instanceof Comment); - }); - } - }]); - - return Expression; -}(Node); - -Expression.prototype.type = 'Expression'; - -var functionCaller = -/*#__PURE__*/ -function () { - function functionCaller(name, context, index, currentFileInfo) { - _classCallCheck(this, functionCaller); - - this.name = name.toLowerCase(); - this.index = index; - this.context = context; - this.currentFileInfo = currentFileInfo; - this.func = context.frames[0].functionRegistry.get(this.name); - } - - _createClass(functionCaller, [{ - key: "isValid", - value: function isValid() { - return Boolean(this.func); - } - }, { - key: "call", - value: function call(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)) { - args = args.filter(function (item) { - if (item.type === 'Comment') { - return false; - } - - return true; - }).map(function (item) { - if (item.type === 'Expression') { - var subNodes = item.value.filter(function (item) { - if (item.type === 'Comment') { - return false; - } - - return true; - }); - - if (subNodes.length === 1) { - return subNodes[0]; - } else { - return new Expression(subNodes); - } - } - - return item; - }); - } - - return this.func.apply(this, _toConsumableArray(args)); - } - }]); - - return functionCaller; -}(); - -// A function call node. -// - -var Call = -/*#__PURE__*/ -function (_Node) { - _inherits(Call, _Node); - - function Call(name, args, index, currentFileInfo) { - var _this; - - _classCallCheck(this, Call); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Call).call(this)); - _this.name = name; - _this.args = args; - _this.calc = name === 'calc'; - _this._index = index; - _this._fileInfo = currentFileInfo; - return _this; - } - - _createClass(Call, [{ - key: "accept", - value: function accept(visitor) { - if (this.args) { - this.args = visitor.visitArray(this.args); - } - } // - // When evaluating a function call, - // we either find the function in the functionRegistry, - // in which case we call it, passing the evaluated arguments, - // if this returns null or we cannot find the function, we - // simply print it out as it appeared originally [2]. - // - // The reason why we evaluate the arguments, is in the case where - // we try to pass a variable to a function, like: `saturate(@color)`. - // The function should receive the value, not the variable. - // - - }, { - key: "eval", - value: function _eval(context) { - /** - * Turn off math for calc(), and switch back on for evaluating nested functions - */ - var currentMathContext = context.mathOn; - context.mathOn = !this.calc; - - if (this.calc || context.inCalc) { - context.enterCalc(); - } - - var args = this.args.map(function (a) { - return a.eval(context); - }); - - if (this.calc || context.inCalc) { - context.exitCalc(); - } - - context.mathOn = currentMathContext; - var result; - var 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.getIndex(), - filename: this.fileInfo().filename, - line: e.lineNumber, - column: e.columnNumber - }; - } - - 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.getIndex(), this.fileInfo()); - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - output.add(`${this.name}(`, this.fileInfo(), this.getIndex()); - - for (var i = 0; i < this.args.length; i++) { - this.args[i].genCSS(context, output); - - if (i + 1 < this.args.length) { - output.add(', '); - } - } - - output.add(')'); - } - }]); - - return Call; -}(Node); - -Call.prototype.type = 'Call'; - -var Variable = -/*#__PURE__*/ -function (_Node) { - _inherits(Variable, _Node); - - function Variable(name, index, currentFileInfo) { - var _this; - - _classCallCheck(this, Variable); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Variable).call(this)); - _this.name = name; - _this._index = index; - _this._fileInfo = currentFileInfo; - return _this; - } - - _createClass(Variable, [{ - key: "eval", - value: function _eval(context) { - var variable; - var name = this.name; - - if (name.indexOf('@@') === 0) { - 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.fileInfo().filename, - index: this.getIndex() - }; - } - - this.evaluating = true; - variable = this.find(context.frames, function (frame) { - var v = frame.variable(name); - - if (v) { - if (v.important) { - var importantScope = context.importantScope[context.importantScope.length - 1]; - importantScope.important = v.important; - } // If in calc, wrap vars in a function call to cascade evaluate args first - - - if (context.inCalc) { - return new Call('_SELF', [v.value]).eval(context); - } else { - return v.value.eval(context); - } - } - }); - - if (variable) { - this.evaluating = false; - return variable; - } else { - throw { - type: 'Name', - message: `variable ${name} is undefined`, - filename: this.fileInfo().filename, - index: this.getIndex() - }; - } - } - }, { - key: "find", - value: function find(obj, fun) { - for (var i = 0, r; i < obj.length; i++) { - r = fun.call(obj, obj[i]); - - if (r) { - return r; - } - } - - return null; - } - }]); - - return Variable; -}(Node); - -Variable.prototype.type = 'Variable'; - -var Property = -/*#__PURE__*/ -function (_Node) { - _inherits(Property, _Node); - - function Property(name, index, currentFileInfo) { - var _this; - - _classCallCheck(this, Property); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Property).call(this)); - _this.name = name; - _this._index = index; - _this._fileInfo = currentFileInfo; - return _this; - } - - _createClass(Property, [{ - key: "eval", - value: function _eval(context) { - var property; - var 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; - var 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 - }; - } - } - }, { - key: "find", - value: function find(obj, fun) { - for (var i = 0, r; i < obj.length; i++) { - r = fun.call(obj, obj[i]); - - if (r) { - return r; - } - } - - return null; - } - }]); - - return Property; -}(Node); - -Property.prototype.type = 'Property'; - -var Attribute = -/*#__PURE__*/ -function (_Node) { - _inherits(Attribute, _Node); - - function Attribute(key, op, value) { - var _this; - - _classCallCheck(this, Attribute); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Attribute).call(this)); - _this.key = key; - _this.op = op; - _this.value = value; - return _this; - } - - _createClass(Attribute, [{ - key: "eval", - value: function _eval(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); - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - output.add(this.toCSS(context)); - } - }, { - key: "toCSS", - value: function toCSS(context) { - var value = this.key.toCSS ? this.key.toCSS(context) : this.key; - - if (this.op) { - value += this.op; - value += this.value.toCSS ? this.value.toCSS(context) : this.value; - } - - return `[${value}]`; - } - }]); - - return Attribute; -}(Node); - -Attribute.prototype.type = 'Attribute'; - -var Quoted = -/*#__PURE__*/ -function (_Node) { - _inherits(Quoted, _Node); - - function Quoted(str, content, escaped, index, currentFileInfo) { - var _this; - - _classCallCheck(this, Quoted); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Quoted).call(this)); - _this.escaped = escaped == null ? true : escaped; - _this.value = content || ''; - _this.quote = str.charAt(0); - _this._index = index; - _this._fileInfo = currentFileInfo; - _this.variableRegex = /@\{([\w-]+)\}/g; - _this.propRegex = /\$\{([\w-]+)\}/g; - _this.allowRoot = escaped; - return _this; - } - - _createClass(Quoted, [{ - key: "genCSS", - value: function genCSS(context, output) { - if (!this.escaped) { - output.add(this.quote, this.fileInfo(), this.getIndex()); - } - - output.add(this.value); - - if (!this.escaped) { - output.add(this.quote); - } - } - }, { - key: "containsVariables", - value: function containsVariables() { - return this.value.match(this.variableRegex); - } - }, { - key: "eval", - value: function _eval(context) { - var that = this; - var value = this.value; - - var variableReplacement = function variableReplacement(_, name) { - var v = new Variable(`@${name}`, that.getIndex(), that.fileInfo()).eval(context, true); - return v instanceof Quoted ? v.value : v.toCSS(); - }; - - var propertyReplacement = function propertyReplacement(_, 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) { - var evaluatedValue = value; - - do { - value = evaluatedValue.toString(); - evaluatedValue = value.replace(regexp, replacementFnc); - } while (value !== evaluatedValue); - - return evaluatedValue; - } - - value = iterativeReplace(value, this.variableRegex, variableReplacement); - value = iterativeReplace(value, this.propRegex, propertyReplacement); - return new Quoted(this.quote + value + this.quote, value, this.escaped, this.getIndex(), this.fileInfo()); - } - }, { - key: "compare", - value: function compare(other) { - // when comparing quoted strings allow the quote to differ - if (other.type === 'Quoted' && !this.escaped && !other.escaped) { - return Node.numericCompare(this.value, other.value); - } else { - return other.toCSS && this.toCSS() === other.toCSS() ? 0 : undefined; - } - } - }]); - - return Quoted; -}(Node); - -Quoted.prototype.type = 'Quoted'; - -var URL = -/*#__PURE__*/ -function (_Node) { - _inherits(URL, _Node); - - function URL(val, index, currentFileInfo, isEvald) { - var _this; - - _classCallCheck(this, URL); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(URL).call(this)); - _this.value = val; - _this._index = index; - _this._fileInfo = currentFileInfo; - _this.isEvald = isEvald; - return _this; - } - - _createClass(URL, [{ - key: "accept", - value: function accept(visitor) { - this.value = visitor.visit(this.value); - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - output.add('url('); - this.value.genCSS(context, output); - output.add(')'); - } - }, { - key: "eval", - value: function _eval(context) { - var val = this.value.eval(context); - var rootpath; - - if (!this.isEvald) { - // Add the rootpath if the URL requires a rewrite - rootpath = this.fileInfo() && this.fileInfo().rootpath; - - if (typeof rootpath === 'string' && typeof val.value === 'string' && context.pathRequiresRewrite(val.value)) { - if (!val.quote) { - rootpath = escapePath(rootpath); - } - - val.value = context.rewritePath(val.value, rootpath); - } else { - val.value = context.normalizePath(val.value); - } // Add url args if enabled - - - if (context.urlArgs) { - if (!val.value.match(/^\s*data:/)) { - var delimiter = val.value.indexOf('?') === -1 ? '?' : '&'; - var urlArgs = delimiter + context.urlArgs; - - if (val.value.indexOf('#') !== -1) { - val.value = val.value.replace('#', `${urlArgs}#`); - } else { - val.value += urlArgs; - } - } - } - } - - return new URL(val, this.getIndex(), this.fileInfo(), true); - } - }]); - - return URL; -}(Node); - -URL.prototype.type = 'Url'; - -function escapePath(path) { - return path.replace(/[\(\)'"\s]/g, function (match) { - return `\\${match}`; - }); -} - -var Media = -/*#__PURE__*/ -function (_AtRule) { - _inherits(Media, _AtRule); - - function Media(value, features, index, currentFileInfo, visibilityInfo) { - var _this; - - _classCallCheck(this, Media); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Media).call(this)); - _this._index = index; - _this._fileInfo = currentFileInfo; - 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, _assertThisInitialized(_this)); - - _this.setParent(_this.features, _assertThisInitialized(_this)); - - _this.setParent(_this.rules, _assertThisInitialized(_this)); - - return _this; - } - - _createClass(Media, [{ - key: "isRulesetLike", - value: function isRulesetLike() { - return true; - } - }, { - key: "accept", - value: function accept(visitor) { - if (this.features) { - this.features = visitor.visit(this.features); - } - - if (this.rules) { - this.rules = visitor.visitArray(this.rules); - } - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - output.add('@media ', this._fileInfo, this._index); - this.features.genCSS(context, output); - this.outputRuleset(context, output, this.rules); - } - }, { - key: "eval", - value: function _eval(context) { - if (!context.mediaBlocks) { - context.mediaBlocks = []; - context.mediaPath = []; - } - - var media = new Media(null, [], this._index, this._fileInfo, this.visibilityInfo()); - - if (this.debugInfo) { - this.rules[0].debugInfo = this.debugInfo; - media.debugInfo = this.debugInfo; - } - - media.features = this.features.eval(context); - context.mediaPath.push(media); - context.mediaBlocks.push(media); - this.rules[0].functionRegistry = context.frames[0].functionRegistry.inherit(); - context.frames.unshift(this.rules[0]); - media.rules = [this.rules[0].eval(context)]; - context.frames.shift(); - context.mediaPath.pop(); - return context.mediaPath.length === 0 ? media.evalTop(context) : media.evalNested(context); - } - }, { - key: "evalTop", - value: function evalTop(context) { - var result = this; // Render all dependent Media blocks. - - if (context.mediaBlocks.length > 1) { - 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; - delete context.mediaPath; - return result; - } - }, { - key: "evalNested", - value: function evalNested(context) { - var i; - var value; - var path = context.mediaPath.concat([this]); // Extract the media-query conditions separated with `,` (OR). - - for (i = 0; i < path.length; i++) { - value = path[i].features instanceof Value ? path[i].features.value : path[i].features; - path[i] = Array.isArray(value) ? value : [value]; - } // Trace all permutations to generate the resulting media-query. - // - // (a, b and c) with nested (d, e) -> - // a and d - // a and e - // b and c and d - // b and c and e - - - this.features = new Value(this.permute(path).map(function (path) { - path = path.map(function (fragment) { - return fragment.toCSS ? fragment : new Anonymous(fragment); - }); - - for (i = path.length - 1; i > 0; i--) { - path.splice(i, 0, new Anonymous('and')); - } - - return new Expression(path); - })); - this.setParent(this.features, this); // Fake a tree-node that doesn't output anything. - - return new Ruleset([], []); - } - }, { - key: "permute", - value: function permute(arr) { - if (arr.length === 0) { - return []; - } else if (arr.length === 1) { - return arr[0]; - } else { - var result = []; - var rest = this.permute(arr.slice(1)); - - for (var i = 0; i < rest.length; i++) { - for (var j = 0; j < arr[0].length; j++) { - result.push([arr[0][j]].concat(rest[i])); - } - } - - return result; - } - } - }, { - key: "bubbleSelectors", - value: function bubbleSelectors(selectors) { - if (!selectors) { - return; - } - - this.rules = [new Ruleset(copyArray(selectors), [this.rules[0]])]; - this.setParent(this.rules, this); - } - }]); - - return Media; -}(AtRule); - -Media.prototype.type = 'Media'; - -// CSS @import node -// -// The general strategy here is that we don't want to wait -// for the parsing to be completed, before we start importing -// the file. That's because in the context of a browser, -// most of the time will be spent waiting for the server to respond. -// -// On creation, we push the import path to our import queue, though -// `import,push`, we also pass it a callback, which it'll call once -// the file has been fetched, and parsed. -// - -var Import = -/*#__PURE__*/ -function (_Node) { - _inherits(Import, _Node); - - function Import(path, features, options, index, currentFileInfo, visibilityInfo) { - var _this; - - _classCallCheck(this, Import); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Import).call(this)); - _this.options = options; - _this._index = index; - _this._fileInfo = currentFileInfo; - _this.path = path; - _this.features = features; - _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)) { - _this.css = true; - } - } - - _this.copyVisibilityInfo(visibilityInfo); - - _this.setParent(_this.features, _assertThisInitialized(_this)); - - _this.setParent(_this.path, _assertThisInitialized(_this)); - - return _this; - } - - _createClass(Import, [{ - key: "accept", - value: function accept(visitor) { - if (this.features) { - this.features = visitor.visit(this.features); - } - - this.path = visitor.visit(this.path); - - if (!this.options.isPlugin && !this.options.inline && this.root) { - this.root = visitor.visit(this.root); - } - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - 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(' '); - this.features.genCSS(context, output); - } - - output.add(';'); - } - } - }, { - key: "getPath", - value: function getPath() { - return this.path instanceof URL ? this.path.value.value : this.path.value; - } - }, { - key: "isVariableImport", - value: function isVariableImport() { - var path = this.path; - - if (path instanceof URL) { - path = path.value; - } - - if (path instanceof Quoted) { - return path.containsVariables(); - } - - return true; - } - }, { - key: "evalForImport", - value: function evalForImport(context) { - var path = this.path; - - if (path instanceof URL) { - path = path.value; - } - - return new Import(path.eval(context), this.features, this.options, this._index, this._fileInfo, this.visibilityInfo()); - } - }, { - key: "evalPath", - value: function evalPath(context) { - var path = this.path.eval(context); - var fileInfo = this._fileInfo; - - if (!(path instanceof URL)) { - // Add the rootpath if the URL requires a rewrite - var pathValue = path.value; - - if (fileInfo && pathValue && context.pathRequiresRewrite(pathValue)) { - path.value = context.rewritePath(pathValue, fileInfo.rootpath); - } else { - path.value = context.normalizePath(path.value); - } - } - - return path; - } - }, { - key: "eval", - value: function _eval(context) { - var result = this.doEval(context); - - if (this.options.reference || this.blocksVisibility()) { - if (result.length || result.length === 0) { - result.forEach(function (node) { - node.addVisibilityBlock(); - }); - } else { - result.addVisibilityBlock(); - } - } - - return result; - } - }, { - key: "doEval", - value: function doEval(context) { - var ruleset; - var registry; - var features = this.features && this.features.eval(context); - - 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 []; - } - - if (this.skip) { - if (typeof this.skip === 'function') { - this.skip = this.skip(); - } - - if (this.skip) { - return []; - } - } - - if (this.options.inline) { - var contents = new Anonymous(this.root, 0, { - 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); - - if (!newImport.css && this.error) { - throw this.error; - } - - return newImport; - } else { - ruleset = new Ruleset(null, copyArray(this.root.rules)); - ruleset.evalImports(context); - return this.features ? new Media(ruleset.rules, this.features.value) : ruleset.rules; - } - } - }]); - - return Import; -}(Node); - -Import.prototype.type = 'Import'; - -var JsEvalNode = -/*#__PURE__*/ -function (_Node) { - _inherits(JsEvalNode, _Node); - - function JsEvalNode() { - _classCallCheck(this, JsEvalNode); - - return _possibleConstructorReturn(this, _getPrototypeOf(JsEvalNode).apply(this, arguments)); - } - - _createClass(JsEvalNode, [{ - key: "evaluateJavaScript", - value: function evaluateJavaScript(expression, context) { - var result; - var that = this; - var evalContext = {}; - - 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.getIndex(), that.fileInfo()).eval(context)); - }); - - try { - expression = new Function(`return (${expression})`); - } catch (e) { - throw { - message: `JavaScript evaluation error: ${e.message} from \`${expression}\``, - 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 */ - evalContext[k.slice(1)] = { - value: variables[k].value, - toJS: function toJS() { - return this.value.eval(context).toCSS(); - } - }; - } - } - - try { - result = expression.call(evalContext); - } catch (e) { - throw { - message: `JavaScript evaluation error: '${e.name}: ${e.message.replace(/["]/g, '\'')}'`, - filename: this.fileInfo().filename, - index: this.getIndex() - }; - } - - return result; - } - }, { - key: "jsify", - value: function jsify(obj) { - if (Array.isArray(obj.value) && obj.value.length > 1) { - return `[${obj.value.map(function (v) { - return v.toCSS(); - }).join(', ')}]`; - } else { - return obj.toCSS(); - } - } - }]); - - return JsEvalNode; -}(Node); - -var JavaScript = -/*#__PURE__*/ -function (_JsEvalNode) { - _inherits(JavaScript, _JsEvalNode); - - function JavaScript(string, escaped, index, currentFileInfo) { - var _this; - - _classCallCheck(this, JavaScript); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(JavaScript).call(this)); - _this.escaped = escaped; - _this.expression = string; - _this._index = index; - _this._fileInfo = currentFileInfo; - return _this; - } - - _createClass(JavaScript, [{ - key: "eval", - value: function _eval(context) { - var result = this.evaluateJavaScript(this.expression, context); - var type = typeof result; - - if (type === 'number' && !isNaN(result)) { - return new Dimension(result); - } else if (type === 'string') { - return new Quoted(`"${result}"`, result, this.escaped, this._index); - } else if (Array.isArray(result)) { - return new Anonymous(result.join(', ')); - } else { - return new Anonymous(result); - } - } - }]); - - return JavaScript; -}(JsEvalNode); - -JavaScript.prototype.type = 'JavaScript'; - -var Assignment = -/*#__PURE__*/ -function (_Node) { - _inherits(Assignment, _Node); - - function Assignment(key, val) { - var _this; - - _classCallCheck(this, Assignment); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Assignment).call(this)); - _this.key = key; - _this.value = val; - return _this; - } - - _createClass(Assignment, [{ - key: "accept", - value: function accept(visitor) { - this.value = visitor.visit(this.value); - } - }, { - key: "eval", - value: function _eval(context) { - if (this.value.eval) { - return new Assignment(this.key, this.value.eval(context)); - } - - return this; - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - output.add(`${this.key}=`); - - if (this.value.genCSS) { - this.value.genCSS(context, output); - } else { - output.add(this.value); - } - } - }]); - - return Assignment; -}(Node); - -Assignment.prototype.type = 'Assignment'; - -var Condition = -/*#__PURE__*/ -function (_Node) { - _inherits(Condition, _Node); - - function Condition(op, l, r, i, negate) { - var _this; - - _classCallCheck(this, Condition); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Condition).call(this)); - _this.op = op.trim(); - _this.lvalue = l; - _this.rvalue = r; - _this._index = i; - _this.negate = negate; - return _this; - } - - _createClass(Condition, [{ - key: "accept", - value: function accept(visitor) { - this.lvalue = visitor.visit(this.lvalue); - this.rvalue = visitor.visit(this.rvalue); - } - }, { - key: "eval", - value: function _eval(context) { - var result = function (op, a, b) { - switch (op) { - case 'and': - return a && b; - - case 'or': - return a || b; - - default: - switch (Node.compare(a, b)) { - case -1: - return op === '<' || op === '=<' || op === '<='; - - case 0: - return op === '=' || op === '>=' || op === '=<' || op === '<='; - - case 1: - return op === '>' || op === '>='; - - default: - return false; - } - - } - }(this.op, this.lvalue.eval(context), this.rvalue.eval(context)); - - return this.negate ? !result : result; - } - }]); - - return Condition; -}(Node); - -Condition.prototype.type = 'Condition'; - -var UnicodeDescriptor = -/*#__PURE__*/ -function (_Node) { - _inherits(UnicodeDescriptor, _Node); - - function UnicodeDescriptor(value) { - var _this; - - _classCallCheck(this, UnicodeDescriptor); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(UnicodeDescriptor).call(this)); - _this.value = value; - return _this; - } - - return UnicodeDescriptor; -}(Node); - -UnicodeDescriptor.prototype.type = 'UnicodeDescriptor'; - -var Negative = -/*#__PURE__*/ -function (_Node) { - _inherits(Negative, _Node); - - function Negative(node) { - var _this; - - _classCallCheck(this, Negative); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Negative).call(this)); - _this.value = node; - return _this; - } - - _createClass(Negative, [{ - key: "genCSS", - value: function genCSS(context, output) { - output.add('-'); - this.value.genCSS(context, output); - } - }, { - key: "eval", - value: function _eval(context) { - if (context.isMathOn()) { - return new Operation('*', [new Dimension(-1), this.value]).eval(context); - } - - return new Negative(this.value.eval(context)); - } - }]); - - return Negative; -}(Node); - -Negative.prototype.type = 'Negative'; - -var Extend = -/*#__PURE__*/ -function (_Node) { - _inherits(Extend, _Node); - - function Extend(selector, option, index, currentFileInfo, visibilityInfo) { - var _this; - - _classCallCheck(this, Extend); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Extend).call(this)); - _this.selector = selector; - _this.option = option; - _this.object_id = Extend.next_id++; - _this.parent_ids = [_this.object_id]; - _this._index = index; - _this._fileInfo = currentFileInfo; - - _this.copyVisibilityInfo(visibilityInfo); - - _this.allowRoot = true; - - switch (option) { - case 'all': - _this.allowBefore = true; - _this.allowAfter = true; - break; - - default: - _this.allowBefore = false; - _this.allowAfter = false; - break; - } - - _this.setParent(_this.selector, _assertThisInitialized(_this)); - - return _this; - } - - _createClass(Extend, [{ - key: "accept", - value: function accept(visitor) { - this.selector = visitor.visit(this.selector); - } - }, { - key: "eval", - value: function _eval(context) { - return new Extend(this.selector.eval(context), this.option, this.getIndex(), this.fileInfo(), this.visibilityInfo()); - } - }, { - key: "clone", - value: function clone(context) { - return new Extend(this.selector, this.option, this.getIndex(), this.fileInfo(), this.visibilityInfo()); - } // it concatenates (joins) all selectors in selector array - - }, { - key: "findSelfSelectors", - value: function findSelfSelectors(selectors) { - var selfElements = []; - var i; - var selectorElements; - - for (i = 0; i < selectors.length; i++) { - selectorElements = selectors[i].elements; // duplicate the logic in genCSS function inside the selector node. - // future TODO - move both logics into the selector joiner visitor - - if (i > 0 && selectorElements.length && selectorElements[0].combinator.value === '') { - selectorElements[0].combinator.value = ' '; - } - - selfElements = selfElements.concat(selectors[i].elements); - } - - this.selfSelectors = [new Selector(selfElements)]; - this.selfSelectors[0].copyVisibilityInfo(this.visibilityInfo()); - } - }]); - - return Extend; -}(Node); - -Extend.next_id = 0; -Extend.prototype.type = 'Extend'; - -var VariableCall = -/*#__PURE__*/ -function (_Node) { - _inherits(VariableCall, _Node); - - function VariableCall(variable, index, currentFileInfo) { - var _this; - - _classCallCheck(this, VariableCall); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(VariableCall).call(this)); - _this.variable = variable; - _this._index = index; - _this._fileInfo = currentFileInfo; - _this.allowRoot = true; - return _this; - } - - _createClass(VariableCall, [{ - key: "eval", - value: function _eval(context) { - var rules; - var detachedRuleset = new Variable(this.variable, this.getIndex(), this.fileInfo()).eval(context); - var error = new LessError({ - message: `Could not evaluate variable call ${this.variable}` - }); - - if (!detachedRuleset.ruleset) { - if (detachedRuleset.rules) { - rules = detachedRuleset; - } else if (Array.isArray(detachedRuleset)) { - rules = new Ruleset('', detachedRuleset); - } else if (Array.isArray(detachedRuleset.value)) { - rules = new Ruleset('', detachedRuleset.value); - } else { - throw error; - } - - detachedRuleset = new DetachedRuleset(rules); - } - - if (detachedRuleset.ruleset) { - return detachedRuleset.callEval(context); - } - - throw error; - } - }]); - - return VariableCall; -}(Node); - -VariableCall.prototype.type = 'VariableCall'; - -var NamespaceValue = -/*#__PURE__*/ -function (_Node) { - _inherits(NamespaceValue, _Node); - - function NamespaceValue(ruleCall, lookups, important, index, fileInfo) { - var _this; - - _classCallCheck(this, NamespaceValue); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(NamespaceValue).call(this)); - _this.value = ruleCall; - _this.lookups = lookups; - _this.important = important; - _this._index = index; - _this._fileInfo = fileInfo; - return _this; - } - - _createClass(NamespaceValue, [{ - key: "eval", - value: function _eval(context) { - var i; - var name; - var rules = this.value.eval(context); - - for (i = 0; i < this.lookups.length; i++) { - name = this.lookups[i]; - /** - * Eval'd DRs return rulesets. - * Eval'd mixins return rules, so let's make a ruleset if we need it. - * We need to do this because of late parsing of values - */ - - if (Array.isArray(rules)) { - rules = new Ruleset([new Selector()], rules); - } - - if (name === '') { - rules = rules.lastDeclaration(); - } else if (name.charAt(0) === '@') { - if (name.charAt(1) === '@') { - name = `@${new Variable(name.substr(1)).eval(context).value}`; - } - - if (rules.variables) { - rules = rules.variable(name); - } - - if (!rules) { - throw { - type: 'Name', - message: `variable ${name} not found`, - filename: this.fileInfo().filename, - index: this.getIndex() - }; - } - } else { - if (name.substring(0, 2) === '$@') { - name = `$${new Variable(name.substr(1)).eval(context).value}`; - } else { - name = name.charAt(0) === '$' ? name : `$${name}`; - } - - if (rules.properties) { - rules = rules.property(name); - } - - if (!rules) { - throw { - type: 'Name', - message: `property "${name.substr(1)}" not found`, - filename: this.fileInfo().filename, - index: this.getIndex() - }; - } // Properties are an array of values, since a ruleset can have multiple props. - // We pick the last one (the "cascaded" value) - - - rules = rules[rules.length - 1]; - } - - if (rules.value) { - rules = rules.eval(context).value; - } - - if (rules.ruleset) { - rules = rules.ruleset.eval(context); - } - } - - return rules; - } - }]); - - return NamespaceValue; -}(Node); - -NamespaceValue.prototype.type = 'NamespaceValue'; - -var Definition = -/*#__PURE__*/ -function (_Ruleset) { - _inherits(Definition, _Ruleset); - - function Definition(name, params, rules, condition, variadic, frames, visibilityInfo) { - var _this; - - _classCallCheck(this, Definition); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Definition).call(this)); - _this.name = name || 'anonymous mixin'; - _this.selectors = [new Selector([new Element(null, name, false, _this._index, _this._fileInfo)])]; - _this.params = params; - _this.condition = condition; - _this.variadic = variadic; - _this.arity = params.length; - _this.rules = rules; - _this._lookups = {}; - var optionalParameters = []; - _this.required = params.reduce(function (count, p) { - if (!p.name || p.name && !p.value) { - return count + 1; - } else { - optionalParameters.push(p.name); - return count; - } - }, 0); - _this.optionalParameters = optionalParameters; - _this.frames = frames; - - _this.copyVisibilityInfo(visibilityInfo); - - _this.allowRoot = true; - return _this; - } - - _createClass(Definition, [{ - key: "accept", - value: function accept(visitor) { - if (this.params && this.params.length) { - this.params = visitor.visitArray(this.params); - } - - this.rules = visitor.visitArray(this.rules); - - if (this.condition) { - this.condition = visitor.visit(this.condition); - } - } - }, { - key: "evalParams", - value: function evalParams(context, mixinEnv, args, evaldArguments) { - /* jshint boss:true */ - var frame = new Ruleset(null, null); - var varargs; - var arg; - var params = copyArray(this.params); - var i; - var j; - var val; - var name; - var isNamedFound; - var argIndex; - var argsLength = 0; - - if (mixinEnv.frames && mixinEnv.frames[0] && mixinEnv.frames[0].functionRegistry) { - frame.functionRegistry = mixinEnv.frames[0].functionRegistry.inherit(); - } - - mixinEnv = new contexts.Eval(mixinEnv, [frame].concat(mixinEnv.frames)); - - if (args) { - args = copyArray(args); - argsLength = args.length; - - for (i = 0; i < argsLength; i++) { - arg = args[i]; - - if (name = arg && arg.name) { - isNamedFound = false; - - for (j = 0; j < params.length; j++) { - if (!evaldArguments[j] && name === params[j].name) { - evaldArguments[j] = arg.value.eval(context); - frame.prependRule(new Declaration(name, arg.value.eval(context))); - isNamedFound = true; - break; - } - } - - if (isNamedFound) { - args.splice(i, 1); - i--; - continue; - } else { - throw { - type: 'Runtime', - message: `Named argument for ${this.name} ${args[i].name} not found` - }; - } - } - } - } - - argIndex = 0; - - for (i = 0; i < params.length; i++) { - if (evaldArguments[i]) { - continue; - } - - arg = args && args[argIndex]; - - if (name = params[i].name) { - if (params[i].variadic) { - varargs = []; - - for (j = argIndex; j < argsLength; j++) { - varargs.push(args[j].value.eval(context)); - } - - frame.prependRule(new Declaration(name, new Expression(varargs).eval(context))); - } else { - val = arg && arg.value; - - if (val) { - // This was a mixin call, pass in a detached ruleset of it's eval'd rules - if (Array.isArray(val)) { - val = new DetachedRuleset(new Ruleset('', val)); - } else { - val = val.eval(context); - } - } else if (params[i].value) { - val = params[i].value.eval(mixinEnv); - frame.resetCache(); - } else { - throw { - type: 'Runtime', - message: `wrong number of arguments for ${this.name} (${argsLength} for ${this.arity})` - }; - } - - frame.prependRule(new Declaration(name, val)); - evaldArguments[i] = val; - } - } - - if (params[i].variadic && args) { - for (j = argIndex; j < argsLength; j++) { - evaldArguments[j] = args[j].value.eval(context); - } - } - - argIndex++; - } - - return frame; - } - }, { - key: "makeImportant", - value: function makeImportant() { - var rules = !this.rules ? this.rules : this.rules.map(function (r) { - if (r.makeImportant) { - return r.makeImportant(true); - } else { - return r; - } - }); - var result = new Definition(this.name, this.params, rules, this.condition, this.variadic, this.frames); - return result; - } - }, { - key: "eval", - value: function _eval(context) { - return new Definition(this.name, this.params, this.rules, this.condition, this.variadic, this.frames || copyArray(context.frames)); - } - }, { - key: "evalCall", - value: function evalCall(context, args, important) { - var _arguments = []; - var mixinFrames = this.frames ? this.frames.concat(context.frames) : context.frames; - var frame = this.evalParams(context, new contexts.Eval(context, mixinFrames), args, _arguments); - var rules; - var ruleset; - frame.prependRule(new Declaration('@arguments', new Expression(_arguments).eval(context))); - rules = copyArray(this.rules); - ruleset = new Ruleset(null, rules); - ruleset.originalRuleset = this; - ruleset = ruleset.eval(new contexts.Eval(context, [this, frame].concat(mixinFrames))); - - if (important) { - ruleset = ruleset.makeImportant(); - } - - return ruleset; - } - }, { - key: "matchCondition", - value: function matchCondition(args, context) { - if (this.condition && !this.condition.eval(new contexts.Eval(context, [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 - return false; - } - - return true; - } - }, { - key: "matchArgs", - value: function matchArgs(args, context) { - var allArgsCnt = args && args.length || 0; - var len; - var optionalParameters = this.optionalParameters; - var requiredArgsCnt = !args ? 0 : args.reduce(function (count, p) { - if (optionalParameters.indexOf(p.name) < 0) { - return count + 1; - } else { - return count; - } - }, 0); - - if (!this.variadic) { - if (requiredArgsCnt < this.required) { - return false; - } - - if (allArgsCnt > this.params.length) { - return false; - } - } else { - if (requiredArgsCnt < this.required - 1) { - return false; - } - } // check patterns - - - len = Math.min(requiredArgsCnt, this.arity); - - for (var i = 0; i < len; i++) { - if (!this.params[i].name && !this.params[i].variadic) { - if (args[i].value.eval(context).toCSS() != this.params[i].value.eval(context).toCSS()) { - return false; - } - } - } - - return true; - } - }]); - - return Definition; -}(Ruleset); - -Definition.prototype.type = 'MixinDefinition'; -Definition.prototype.evalFirst = true; - -var MixinCall = -/*#__PURE__*/ -function (_Node) { - _inherits(MixinCall, _Node); - - function MixinCall(elements, args, index, currentFileInfo, important) { - var _this; - - _classCallCheck(this, MixinCall); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(MixinCall).call(this)); - _this.selector = new Selector(elements); - _this.arguments = args || []; - _this._index = index; - _this._fileInfo = currentFileInfo; - _this.important = important; - _this.allowRoot = true; - - _this.setParent(_this.selector, _assertThisInitialized(_this)); - - return _this; - } - - _createClass(MixinCall, [{ - key: "accept", - value: function accept(visitor) { - if (this.selector) { - this.selector = visitor.visit(this.selector); - } - - if (this.arguments.length) { - this.arguments = visitor.visitArray(this.arguments); - } - } - }, { - key: "eval", - value: function _eval(context) { - var mixins; - var mixin; - var mixinPath; - var args = []; - var arg; - var argValue; - var rules = []; - var match = false; - var i; - var m; - var f; - var isRecursive; - var isOneFound; - var candidates = []; - var candidate; - var conditionResult = []; - var defaultResult; - var defFalseEitherCase = -1; - var defNone = 0; - var defTrue = 1; - var defFalse = 2; - var count; - var originalRuleset; - var noArgumentsFilter; - this.selector = this.selector.eval(context); - - function calcDefGroup(mixin, mixinPath) { - var f; - var p; - var namespace; - - for (f = 0; f < 2; f++) { - conditionResult[f] = true; - defaultFunc.value(f); - - for (p = 0; p < mixinPath.length && conditionResult[f]; p++) { - namespace = mixinPath[p]; - - if (namespace.matchCondition) { - conditionResult[f] = conditionResult[f] && namespace.matchCondition(null, context); - } - } - - if (mixin.matchCondition) { - conditionResult[f] = conditionResult[f] && mixin.matchCondition(args, context); - } - } - - if (conditionResult[0] || conditionResult[1]) { - if (conditionResult[0] != conditionResult[1]) { - return conditionResult[1] ? defTrue : defFalse; - } - - return defNone; - } - - return defFalseEitherCase; - } - - for (i = 0; i < this.arguments.length; i++) { - arg = this.arguments[i]; - argValue = arg.value.eval(context); - - if (arg.expand && Array.isArray(argValue.value)) { - argValue = argValue.value; - - for (m = 0; m < argValue.length; m++) { - args.push({ - value: argValue[m] - }); - } - } else { - args.push({ - name: arg.name, - value: argValue - }); - } - } - - noArgumentsFilter = function noArgumentsFilter(rule) { - return rule.matchArgs(null, context); - }; - - for (i = 0; i < context.frames.length; i++) { - if ((mixins = context.frames[i].find(this.selector, null, noArgumentsFilter)).length > 0) { - isOneFound = true; // To make `default()` function independent of definition order we have two "subpasses" here. - // At first we evaluate each guard *twice* (with `default() == true` and `default() == false`), - // and build candidate list with corresponding flags. Then, when we know all possible matches, - // we make a final decision. - - for (m = 0; m < mixins.length; m++) { - mixin = mixins[m].rule; - mixinPath = mixins[m].path; - isRecursive = false; - - for (f = 0; f < context.frames.length; f++) { - if (!(mixin instanceof Definition) && mixin === (context.frames[f].originalRuleset || context.frames[f])) { - isRecursive = true; - break; - } - } - - if (isRecursive) { - continue; - } - - if (mixin.matchArgs(args, context)) { - candidate = { - mixin, - group: calcDefGroup(mixin, mixinPath) - }; - - if (candidate.group !== defFalseEitherCase) { - candidates.push(candidate); - } - - match = true; - } - } - - defaultFunc.reset(); - count = [0, 0, 0]; - - for (m = 0; m < candidates.length; m++) { - count[candidates[m].group]++; - } - - if (count[defNone] > 0) { - defaultResult = defFalse; - } else { - defaultResult = defTrue; - - if (count[defTrue] + count[defFalse] > 1) { - throw { - type: 'Runtime', - message: `Ambiguous use of \`default()\` found when matching for \`${this.format(args)}\``, - index: this.getIndex(), - filename: this.fileInfo().filename - }; - } - } - - for (m = 0; m < candidates.length; m++) { - candidate = candidates[m].group; - - if (candidate === defNone || candidate === defaultResult) { - try { - mixin = candidates[m].mixin; - - if (!(mixin instanceof Definition)) { - originalRuleset = mixin.originalRuleset || mixin; - mixin = new Definition('', [], mixin.rules, null, false, null, originalRuleset.visibilityInfo()); - mixin.originalRuleset = originalRuleset; - } - - var newRules = mixin.evalCall(context, args, this.important).rules; - - this._setVisibilityToReplacement(newRules); - - Array.prototype.push.apply(rules, newRules); - } catch (e) { - throw { - message: e.message, - index: this.getIndex(), - filename: this.fileInfo().filename, - stack: e.stack - }; - } - } - } - - if (match) { - return rules; - } - } - } - - if (isOneFound) { - throw { - type: 'Runtime', - message: `No matching definition was found for \`${this.format(args)}\``, - index: this.getIndex(), - filename: this.fileInfo().filename - }; - } else { - throw { - type: 'Name', - message: `${this.selector.toCSS().trim()} is undefined`, - index: this.getIndex(), - filename: this.fileInfo().filename - }; - } - } - }, { - key: "_setVisibilityToReplacement", - value: function _setVisibilityToReplacement(replacement) { - var i; - var rule; - - if (this.blocksVisibility()) { - for (i = 0; i < replacement.length; i++) { - rule = replacement[i]; - rule.addVisibilityBlock(); - } - } - } - }, { - key: "format", - value: function format(args) { - return `${this.selector.toCSS().trim()}(${args ? args.map(function (a) { - var argValue = ''; - - if (a.name) { - argValue += `${a.name}:`; - } - - if (a.value.toCSS) { - argValue += a.value.toCSS(); - } else { - argValue += '???'; - } - - return argValue; - }).join(', ') : ''})`; - } - }]); - - return MixinCall; -}(Node); - -MixinCall.prototype.type = 'MixinCall'; - -var tree = { - Node, - Color, - AtRule, - DetachedRuleset, - Operation, - Dimension, - Unit, - Keyword, - Variable, - Property, - Ruleset, - Element, - Attribute, - Combinator, - Selector, - Quoted, - Expression, - Declaration, - Call, - URL, - Import, - Comment, - Anonymous, - Value, - JavaScript, - Assignment, - Condition, - Paren, - Media, - UnicodeDescriptor, - Negative, - Extend, - VariableCall, - NamespaceValue, - mixin: { - Call: MixinCall, - Definition: Definition - } -}; - -var environment$1 = -/*#__PURE__*/ -function () { - function environment(externalEnvironment, fileManagers) { - _classCallCheck(this, environment); - - this.fileManagers = fileManagers || []; - externalEnvironment = externalEnvironment || {}; - var optionalFunctions = ['encodeBase64', 'mimeLookup', 'charsetLookup', 'getSourceMapGenerator']; - var requiredFunctions = []; - var functions = requiredFunctions.concat(optionalFunctions); - - for (var i = 0; i < functions.length; i++) { - var propName = functions[i]; - var environmentFunc = externalEnvironment[propName]; - - if (environmentFunc) { - this[propName] = environmentFunc.bind(externalEnvironment); - } else if (i < requiredFunctions.length) { - this.warn(`missing required function in environment - ${propName}`); - } - } - } - - _createClass(environment, [{ - key: "getFileManager", - value: function getFileManager(filename, currentDirectory, options, environment, isSync) { - if (!filename) { - logger.warn('getFileManager called with no filename.. Please report this issue. continuing.'); - } - - if (currentDirectory == null) { - logger.warn('getFileManager called with null directory.. Please report this issue. continuing.'); - } - - var fileManagers = this.fileManagers; - - if (options.pluginManager) { - fileManagers = [].concat(fileManagers).concat(options.pluginManager.getFileManagers()); - } - - for (var i = fileManagers.length - 1; i >= 0; i--) { - var fileManager = fileManagers[i]; - - if (fileManager[isSync ? 'supportsSync' : 'supports'](filename, currentDirectory, options, environment)) { - return fileManager; - } - } - - return null; - } - }, { - key: "addFileManager", - value: function addFileManager(fileManager) { - this.fileManagers.push(fileManager); - } - }, { - key: "clearFileManagers", - value: function clearFileManagers() { - this.fileManagers = []; - } - }]); - - return environment; -}(); - -var AbstractPluginLoader = -/*#__PURE__*/ -function () { - function AbstractPluginLoader() { - _classCallCheck(this, AbstractPluginLoader); - - // Implemented by Node.js plugin loader - this.require = function () { - return null; - }; - } - - _createClass(AbstractPluginLoader, [{ - key: "evalPlugin", - value: function evalPlugin(contents, context, imports, pluginOptions, fileInfo) { - var loader; - var registry; - var pluginObj; - var localModule; - var pluginManager; - var filename; - var result; - 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) { - result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions); - - if (result) { - return result; - } - - try { - if (pluginObj.use) { - pluginObj.use.call(this.context, pluginObj); - } - } catch (e) { - e.message = e.message || 'Error during @plugin call'; - return new LessError(e, imports, filename); - } - - return pluginObj; - } - } - - localModule = { - exports: {}, - pluginManager, - fileInfo - }; - registry = functionRegistry.create(); - - var registerPlugin = function registerPlugin(obj) { - pluginObj = obj; - }; - - try { - loader = new Function('module', 'require', 'registerPlugin', 'functions', 'tree', 'less', 'fileInfo', contents); - loader(localModule, this.require(filename), registerPlugin, registry, this.less.tree, this.less, fileInfo); - } catch (e) { - return new LessError(e, imports, filename); - } - - if (!pluginObj) { - pluginObj = localModule.exports; - } - - pluginObj = this.validatePlugin(pluginObj, filename, shortname); - - if (pluginObj instanceof LessError) { - return pluginObj; - } - - if (pluginObj) { - pluginObj.imports = imports; - pluginObj.filename = filename; // For < 3.x (or unspecified minVersion) - setOptions() before install() - - if (!pluginObj.minVersion || this.compareVersion('3.0.0', pluginObj.minVersion) < 0) { - result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions); - - if (result) { - return result; - } - } // Run on first load - - - pluginManager.addPlugin(pluginObj, fileInfo.filename, registry); - pluginObj.functions = registry.getLocalFunctions(); // Need to call setOptions again because the pluginObj might have functions - - result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions); - - if (result) { - return result; - } // Run every @plugin call - - - try { - if (pluginObj.use) { - pluginObj.use.call(this.context, pluginObj); - } - } catch (e) { - e.message = e.message || 'Error during @plugin call'; - return new LessError(e, imports, filename); - } - } else { - return new LessError({ - message: 'Not a valid plugin' - }, imports, filename); - } - - return pluginObj; - } - }, { - key: "trySetOptions", - value: function trySetOptions(plugin, filename, name, options) { - if (options && !plugin.setOptions) { - return new LessError({ - message: `Options have been provided but the plugin ${name} does not support any options.` - }); - } - - try { - plugin.setOptions && plugin.setOptions(options); - } catch (e) { - return new LessError(e); - } - } - }, { - key: "validatePlugin", - value: function validatePlugin(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) { - return new LessError({ - message: `Plugin ${name} requires version ${this.versionToString(plugin.minVersion)}` - }); - } - } - - return plugin; - } - - return null; - } - }, { - key: "compareVersion", - value: function compareVersion(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; - } - }, { - key: "versionToString", - value: function versionToString(version) { - var versionString = ''; - - for (var i = 0; i < version.length; i++) { - versionString += (versionString ? '.' : '') + version[i]; - } - - return versionString; - } - }, { - key: "printUsage", - value: function printUsage(plugins) { - for (var i = 0; i < plugins.length; i++) { - var plugin = plugins[i]; - - if (plugin.printUsage) { - plugin.printUsage(); - } - } - } - }]); - - return AbstractPluginLoader; -}(); - -var _visitArgs = { - visitDeeper: true -}; -var _hasIndexed = false; - -function _noop(node) { - return node; -} - -function indexNodeTypes(parent, ticker) { - // add .typeIndex to tree node types for lookup table - var key; - var child; - - 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; -} - -var Visitor = -/*#__PURE__*/ -function () { - function Visitor(implementation) { - _classCallCheck(this, Visitor); - - this._implementation = implementation; - this._visitInCache = {}; - this._visitOutCache = {}; - - if (!_hasIndexed) { - indexNodeTypes(tree, 1); - _hasIndexed = true; - } - } - - _createClass(Visitor, [{ - key: "visit", - value: function visit(node) { - if (!node) { - return node; - } - - var nodeTypeIndex = node.typeIndex; - - if (!nodeTypeIndex) { - // MixinCall args aren't a node type? - if (node.value && node.value.typeIndex) { - this.visit(node.value); - } - - return node; - } - - var impl = this._implementation; - var func = this._visitInCache[nodeTypeIndex]; - var funcOut = this._visitOutCache[nodeTypeIndex]; - var visitArgs = _visitArgs; - var fnName; - visitArgs.visitDeeper = true; - - if (!func) { - fnName = `visit${node.type}`; - func = impl[fnName] || _noop; - funcOut = impl[`${fnName}Out`] || _noop; - this._visitInCache[nodeTypeIndex] = func; - this._visitOutCache[nodeTypeIndex] = funcOut; - } - - if (func !== _noop) { - var newNode = func.call(impl, node, visitArgs); - - if (node && impl.isReplacing) { - node = newNode; - } - } - - if (visitArgs.visitDeeper && node && node.accept) { - node.accept(this); - } - - if (funcOut != _noop) { - funcOut.call(impl, node); - } - - return node; - } - }, { - key: "visitArray", - value: function visitArray(nodes, nonReplacing) { - if (!nodes) { - return nodes; - } - - var cnt = nodes.length; - var i; // Non-replacing - - if (nonReplacing || !this._implementation.isReplacing) { - for (i = 0; i < cnt; i++) { - this.visit(nodes[i]); - } - - return nodes; - } // Replacing - - - var out = []; - - for (i = 0; i < cnt; i++) { - var evald = this.visit(nodes[i]); - - if (evald === undefined) { - continue; - } - - if (!evald.splice) { - out.push(evald); - } else if (evald.length) { - this.flatten(evald, out); - } - } - - return out; - } - }, { - key: "flatten", - value: function flatten(arr, out) { - if (!out) { - out = []; - } - - var cnt; - var i; - var item; - var nestedCnt; - var j; - var nestedItem; - - for (i = 0, cnt = arr.length; i < cnt; i++) { - item = arr[i]; - - if (item === undefined) { - continue; - } - - if (!item.splice) { - out.push(item); - continue; - } - - for (j = 0, nestedCnt = item.length; j < nestedCnt; j++) { - nestedItem = item[j]; - - if (nestedItem === undefined) { - continue; - } - - if (!nestedItem.splice) { - out.push(nestedItem); - } else if (nestedItem.length) { - this.flatten(nestedItem, out); - } - } - } - - return out; - } - }]); - - return Visitor; -}(); - -var ImportSequencer = -/*#__PURE__*/ -function () { - function ImportSequencer(onSequencerEmpty) { - _classCallCheck(this, ImportSequencer); - - this.imports = []; - this.variableImports = []; - this._onSequencerEmpty = onSequencerEmpty; - this._currentDepth = 0; - } - - _createClass(ImportSequencer, [{ - key: "addImport", - value: function addImport(callback) { - var importSequencer = this; - var importItem = { - callback, - args: null, - isReady: false - }; - this.imports.push(importItem); - return function () { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - importItem.args = Array.prototype.slice.call(args, 0); - importItem.isReady = true; - importSequencer.tryRun(); - }; - } - }, { - key: "addVariableImport", - value: function addVariableImport(callback) { - this.variableImports.push(callback); - } - }, { - key: "tryRun", - value: function tryRun() { - this._currentDepth++; - - try { - while (true) { - while (this.imports.length > 0) { - var importItem = this.imports[0]; - - if (!importItem.isReady) { - return; - } - - this.imports = this.imports.slice(1); - importItem.callback.apply(null, importItem.args); - } - - if (this.variableImports.length === 0) { - break; - } - - var variableImport = this.variableImports[0]; - this.variableImports = this.variableImports.slice(1); - variableImport(); - } - } finally { - this._currentDepth--; - } - - if (this._currentDepth === 0 && this._onSequencerEmpty) { - this._onSequencerEmpty(); - } - } - }]); - - return ImportSequencer; -}(); - -var ImportVisitor = function ImportVisitor(importer, finish) { - this._visitor = new Visitor(this); - this._importer = importer; - this._finish = finish; - this.context = new contexts.Eval(); - this.importCount = 0; - this.onceFileDetectionMap = {}; - this.recursionDetector = {}; - this._sequencer = new ImportSequencer(this._onSequencerEmpty.bind(this)); -}; - -ImportVisitor.prototype = { - isReplacing: false, - run: function run(root) { - try { - // process the contents - this._visitor.visit(root); - } catch (e) { - this.error = e; - } - - this.isFinished = true; - - this._sequencer.tryRun(); - }, - _onSequencerEmpty: function _onSequencerEmpty() { - if (!this.isFinished) { - return; - } - - this._finish(this.error); - }, - visitImport: function visitImport(importNode, visitArgs) { - var inlineCSS = importNode.options.inline; - - if (!importNode.css || inlineCSS) { - var context = new contexts.Eval(this.context, copyArray(this.context.frames)); - var importParent = context.frames[0]; - this.importCount++; - - if (importNode.isVariableImport()) { - this._sequencer.addVariableImport(this.processImportNode.bind(this, importNode, context, importParent)); - } else { - this.processImportNode(importNode, context, importParent); - } - } - - visitArgs.visitDeeper = false; - }, - processImportNode: function processImportNode(importNode, context, importParent) { - var evaldImportNode; - var inlineCSS = importNode.options.inline; - - try { - evaldImportNode = importNode.evalForImport(context); - } 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 - - importNode.error = e; - } - - if (evaldImportNode && (!evaldImportNode.css || inlineCSS)) { - if (evaldImportNode.options.multiple) { - context.importMultiple = true; - } // try appending if we haven't determined if it is css or not - - - var tryAppendLessExtension = evaldImportNode.css === undefined; - - for (var i = 0; i < importParent.rules.length; i++) { - if (importParent.rules[i] === importNode) { - importParent.rules[i] = evaldImportNode; - break; - } - } - - var onImported = this.onImported.bind(this, evaldImportNode, context); - - var sequencedOnImported = this._sequencer.addImport(onImported); - - this._importer.push(evaldImportNode.getPath(), tryAppendLessExtension, evaldImportNode.fileInfo(), evaldImportNode.options, sequencedOnImported); - } else { - this.importCount--; - - if (this.isFinished) { - this._sequencer.tryRun(); - } - } - }, - onImported: function onImported(importNode, context, e, root, importedAtRoot, fullPath) { - if (e) { - if (!e.filename) { - e.index = importNode.getIndex(); - e.filename = importNode.fileInfo().filename; - } - - this.error = e; - } - - var importVisitor = this; - var inlineCSS = importNode.options.inline; - var isPlugin = importNode.options.isPlugin; - var isOptional = importNode.options.optional; - var duplicateImport = importedAtRoot || fullPath in importVisitor.recursionDetector; - - if (!context.importMultiple) { - if (duplicateImport) { - importNode.skip = true; - } else { - importNode.skip = function () { - if (fullPath in importVisitor.onceFileDetectionMap) { - return true; - } - - importVisitor.onceFileDetectionMap[fullPath] = true; - return false; - }; - } - } - - if (!fullPath && isOptional) { - importNode.skip = true; - } - - if (root) { - importNode.root = root; - importNode.importedFilename = fullPath; - - if (!inlineCSS && !isPlugin && (context.importMultiple || !duplicateImport)) { - importVisitor.recursionDetector[fullPath] = true; - var oldContext = this.context; - this.context = context; - - try { - this._visitor.visit(root); - } catch (e) { - this.error = e; - } - - this.context = oldContext; - } - } - - importVisitor.importCount--; - - if (importVisitor.isFinished) { - importVisitor._sequencer.tryRun(); - } - }, - visitDeclaration: function visitDeclaration(declNode, visitArgs) { - if (declNode.value.type === 'DetachedRuleset') { - this.context.frames.unshift(declNode); - } else { - visitArgs.visitDeeper = false; - } - }, - visitDeclarationOut: function visitDeclarationOut(declNode) { - if (declNode.value.type === 'DetachedRuleset') { - this.context.frames.shift(); - } - }, - visitAtRule: function visitAtRule(atRuleNode, visitArgs) { - this.context.frames.unshift(atRuleNode); - }, - visitAtRuleOut: function visitAtRuleOut(atRuleNode) { - this.context.frames.shift(); - }, - visitMixinDefinition: function visitMixinDefinition(mixinDefinitionNode, visitArgs) { - this.context.frames.unshift(mixinDefinitionNode); - }, - visitMixinDefinitionOut: function visitMixinDefinitionOut(mixinDefinitionNode) { - this.context.frames.shift(); - }, - visitRuleset: function visitRuleset(rulesetNode, visitArgs) { - this.context.frames.unshift(rulesetNode); - }, - visitRulesetOut: function visitRulesetOut(rulesetNode) { - this.context.frames.shift(); - }, - visitMedia: function visitMedia(mediaNode, visitArgs) { - this.context.frames.unshift(mediaNode.rules[0]); - }, - visitMediaOut: function visitMediaOut(mediaNode) { - this.context.frames.shift(); - } -}; - -var SetTreeVisibilityVisitor = -/*#__PURE__*/ -function () { - function SetTreeVisibilityVisitor(visible) { - _classCallCheck(this, SetTreeVisibilityVisitor); - - this.visible = visible; - } - - _createClass(SetTreeVisibilityVisitor, [{ - key: "run", - value: function run(root) { - this.visit(root); - } - }, { - key: "visitArray", - value: function visitArray(nodes) { - if (!nodes) { - return nodes; - } - - var cnt = nodes.length; - var i; - - for (i = 0; i < cnt; i++) { - this.visit(nodes[i]); - } - - return nodes; - } - }, { - key: "visit", - value: function visit(node) { - if (!node) { - return node; - } - - if (node.constructor === Array) { - return this.visitArray(node); - } - - if (!node.blocksVisibility || node.blocksVisibility()) { - return node; - } - - if (this.visible) { - node.ensureVisibility(); - } else { - node.ensureInvisibility(); - } - - node.accept(this); - return node; - } - }]); - - return SetTreeVisibilityVisitor; -}(); - -/* jshint loopfunc:true */ - -var ExtendFinderVisitor = -/*#__PURE__*/ -function () { - function ExtendFinderVisitor() { - _classCallCheck(this, ExtendFinderVisitor); - - this._visitor = new Visitor(this); - this.contexts = []; - this.allExtendsStack = [[]]; - } - - _createClass(ExtendFinderVisitor, [{ - key: "run", - value: function run(root) { - root = this._visitor.visit(root); - root.allExtends = this.allExtendsStack[0]; - return root; - } - }, { - key: "visitDeclaration", - value: function visitDeclaration(declNode, visitArgs) { - visitArgs.visitDeeper = false; - } - }, { - key: "visitMixinDefinition", - value: function visitMixinDefinition(mixinDefinitionNode, visitArgs) { - visitArgs.visitDeeper = false; - } - }, { - key: "visitRuleset", - value: function visitRuleset(rulesetNode, visitArgs) { - if (rulesetNode.root) { - return; - } - - var i; - var j; - var extend; - var allSelectorsExtendList = []; - var extendList; // get &:extend(.a); rules which apply to all selectors in this ruleset - - var rules = rulesetNode.rules; - var ruleCnt = rules ? rules.length : 0; - - for (i = 0; i < ruleCnt; i++) { - if (rulesetNode.rules[i] instanceof tree.Extend) { - allSelectorsExtendList.push(rules[i]); - rulesetNode.extendOnEveryPath = true; - } - } // now find every selector and apply the extends that apply to all extends - // and the ones which apply to an individual extend - - - var paths = rulesetNode.paths; - - for (i = 0; i < paths.length; i++) { - var selectorPath = paths[i]; - var selector = selectorPath[selectorPath.length - 1]; - var selExtendList = selector.extendList; - extendList = selExtendList ? copyArray(selExtendList).concat(allSelectorsExtendList) : allSelectorsExtendList; - - if (extendList) { - extendList = extendList.map(function (allSelectorsExtend) { - return allSelectorsExtend.clone(); - }); - } - - for (j = 0; j < extendList.length; j++) { - this.foundExtends = true; - extend = extendList[j]; - extend.findSelfSelectors(selectorPath); - extend.ruleset = rulesetNode; - - if (j === 0) { - extend.firstExtendOnThisSelectorPath = true; - } - - this.allExtendsStack[this.allExtendsStack.length - 1].push(extend); - } - } - - this.contexts.push(rulesetNode.selectors); - } - }, { - key: "visitRulesetOut", - value: function visitRulesetOut(rulesetNode) { - if (!rulesetNode.root) { - this.contexts.length = this.contexts.length - 1; - } - } - }, { - key: "visitMedia", - value: function visitMedia(mediaNode, visitArgs) { - mediaNode.allExtends = []; - this.allExtendsStack.push(mediaNode.allExtends); - } - }, { - key: "visitMediaOut", - value: function visitMediaOut(mediaNode) { - this.allExtendsStack.length = this.allExtendsStack.length - 1; - } - }, { - key: "visitAtRule", - value: function visitAtRule(atRuleNode, visitArgs) { - atRuleNode.allExtends = []; - this.allExtendsStack.push(atRuleNode.allExtends); - } - }, { - key: "visitAtRuleOut", - value: function visitAtRuleOut(atRuleNode) { - this.allExtendsStack.length = this.allExtendsStack.length - 1; - } - }]); - - return ExtendFinderVisitor; -}(); - -var ProcessExtendsVisitor = -/*#__PURE__*/ -function () { - function ProcessExtendsVisitor() { - _classCallCheck(this, ProcessExtendsVisitor); - - this._visitor = new Visitor(this); - } - - _createClass(ProcessExtendsVisitor, [{ - key: "run", - value: function run(root) { - var extendFinder = new ExtendFinderVisitor(); - this.extendIndices = {}; - extendFinder.run(root); - - if (!extendFinder.foundExtends) { - return root; - } - - root.allExtends = root.allExtends.concat(this.doExtendChaining(root.allExtends, root.allExtends)); - this.allExtendsStack = [root.allExtends]; - - var newRoot = this._visitor.visit(root); - - this.checkExtendsForNonMatched(root.allExtends); - return newRoot; - } - }, { - key: "checkExtendsForNonMatched", - value: function checkExtendsForNonMatched(extendList) { - var indices = this.extendIndices; - extendList.filter(function (extend) { - return !extend.hasFoundMatches && extend.parent_ids.length == 1; - }).forEach(function (extend) { - 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`); - } - }); - } - }, { - key: "doExtendChaining", - value: function doExtendChaining(extendsList, extendsListTarget, iterationCount) { - // - // chaining is different from normal extension.. if we extend an extend then we are not just copying, altering - // and pasting the selector we would do normally, but we are also adding an extend with the same target selector - // this means this new extend can then go and alter other extends - // - // this method deals with all the chaining work - without it, extend is flat and doesn't work on other extend selectors - // this is also the most expensive.. and a match on one selector can cause an extension of a selector we had already - // processed if we look at each selector at a time, as is done in visitRuleset - var extendIndex; - var targetExtendIndex; - var matches; - var extendsToAdd = []; - var newSelector; - var extendVisitor = this; - var selectorPath; - var extend; - var targetExtend; - var newExtend; - iterationCount = iterationCount || 0; // 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. - // the separation into two lists allows us to process a subset of chains with a bigger set, as is the - // case when processing media queries - - for (extendIndex = 0; extendIndex < extendsList.length; extendIndex++) { - for (targetExtendIndex = 0; targetExtendIndex < extendsListTarget.length; targetExtendIndex++) { - extend = extendsList[extendIndex]; - targetExtend = extendsListTarget[targetExtendIndex]; // look for circular references - - if (extend.parent_ids.indexOf(targetExtend.object_id) >= 0) { - continue; - } // find a match in the target extends self selector (the bit before :extend) - - - selectorPath = [targetExtend.selfSelectors[0]]; - matches = extendVisitor.findMatch(extend, selectorPath); - - if (matches.length) { - extend.hasFoundMatches = true; // we found a match, so for each self selector.. - - extend.selfSelectors.forEach(function (selfSelector) { - var info = targetExtend.visibilityInfo(); // process the extend as usual - - 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.fileInfo(), info); - newExtend.selfSelectors = newSelector; // add the extend onto the list of extends for that selector - - newSelector[newSelector.length - 1].extendList = [newExtend]; // record that we need to add it. - - extendsToAdd.push(newExtend); - newExtend.ruleset = targetExtend.ruleset; // remember its parents for circular references - - newExtend.parent_ids = newExtend.parent_ids.concat(targetExtend.parent_ids, extend.parent_ids); // only process the selector once.. if we have :extend(.a,.b) then multiple - // extends will look at the same selector path, so when extending - // we know that any others will be duplicates in terms of what is added to the css - - if (targetExtend.firstExtendOnThisSelectorPath) { - newExtend.firstExtendOnThisSelectorPath = true; - targetExtend.ruleset.paths.push(newSelector); - } - }); - } - } - } - - if (extendsToAdd.length) { - // try to detect circular references to stop a stack overflow. - // may no longer be needed. - this.extendChainCount++; - - if (iterationCount > 100) { - var selectorOne = '{unable to calculate}'; - var selectorTwo = '{unable to calculate}'; - - try { - selectorOne = extendsToAdd[0].selfSelectors[0].toCSS(); - selectorTwo = extendsToAdd[0].selector.toCSS(); - } catch (e) {} - - throw { - message: `extend circular reference detected. One of the circular extends is currently:${selectorOne}:extend(${selectorTwo})` - }; - } // now process the new extends on the existing rules so that we can handle a extending b extending c extending - // d extending e... - - - return extendsToAdd.concat(extendVisitor.doExtendChaining(extendsToAdd, extendsListTarget, iterationCount + 1)); - } else { - return extendsToAdd; - } - } - }, { - key: "visitDeclaration", - value: function visitDeclaration(ruleNode, visitArgs) { - visitArgs.visitDeeper = false; - } - }, { - key: "visitMixinDefinition", - value: function visitMixinDefinition(mixinDefinitionNode, visitArgs) { - visitArgs.visitDeeper = false; - } - }, { - key: "visitSelector", - value: function visitSelector(selectorNode, visitArgs) { - visitArgs.visitDeeper = false; - } - }, { - key: "visitRuleset", - value: function visitRuleset(rulesetNode, visitArgs) { - if (rulesetNode.root) { - return; - } - - var matches; - var pathIndex; - var extendIndex; - var allExtends = this.allExtendsStack[this.allExtendsStack.length - 1]; - var selectorsToAdd = []; - var extendVisitor = this; - var selectorPath; // look at each selector path in the ruleset, find any extend matches and then copy, find and replace - - for (extendIndex = 0; extendIndex < allExtends.length; extendIndex++) { - for (pathIndex = 0; pathIndex < rulesetNode.paths.length; pathIndex++) { - selectorPath = rulesetNode.paths[pathIndex]; // extending extends happens initially, before the main pass - - if (rulesetNode.extendOnEveryPath) { - continue; - } - - var extendList = selectorPath[selectorPath.length - 1].extendList; - - if (extendList && extendList.length) { - continue; - } - - matches = this.findMatch(allExtends[extendIndex], selectorPath); - - if (matches.length) { - allExtends[extendIndex].hasFoundMatches = true; - allExtends[extendIndex].selfSelectors.forEach(function (selfSelector) { - var extendedSelectors; - extendedSelectors = extendVisitor.extendSelector(matches, selectorPath, selfSelector, allExtends[extendIndex].isVisible()); - selectorsToAdd.push(extendedSelectors); - }); - } - } - } - - rulesetNode.paths = rulesetNode.paths.concat(selectorsToAdd); - } - }, { - key: "findMatch", - value: function findMatch(extend, haystackSelectorPath) { - // - // look through the haystack selector path to try and find the needle - extend.selector - // returns an array of selector matches that can then be replaced - // - var haystackSelectorIndex; - var hackstackSelector; - var hackstackElementIndex; - var haystackElement; - var targetCombinator; - var i; - var extendVisitor = this; - var needleElements = extend.selector.elements; - var potentialMatches = []; - var potentialMatch; - var matches = []; // loop through the haystack elements - - for (haystackSelectorIndex = 0; haystackSelectorIndex < haystackSelectorPath.length; haystackSelectorIndex++) { - hackstackSelector = haystackSelectorPath[haystackSelectorIndex]; - - for (hackstackElementIndex = 0; hackstackElementIndex < hackstackSelector.elements.length; hackstackElementIndex++) { - haystackElement = hackstackSelector.elements[hackstackElementIndex]; // if we allow elements before our match we can add a potential match every time. otherwise only at the first element. - - if (extend.allowBefore || haystackSelectorIndex === 0 && hackstackElementIndex === 0) { - potentialMatches.push({ - pathIndex: haystackSelectorIndex, - index: hackstackElementIndex, - matched: 0, - initialCombinator: haystackElement.combinator - }); - } - - for (i = 0; i < potentialMatches.length; i++) { - potentialMatch = potentialMatches[i]; // selectors add " " onto the first element. When we use & it joins the selectors together, but if we don't - // then each selector in haystackSelectorPath has a space before it added in the toCSS phase. so we need to - // work out what the resulting combinator will be - - targetCombinator = haystackElement.combinator.value; - - if (targetCombinator === '' && hackstackElementIndex === 0) { - targetCombinator = ' '; - } // if we don't match, null our match to indicate failure - - - if (!extendVisitor.isElementValuesEqual(needleElements[potentialMatch.matched].value, haystackElement.value) || potentialMatch.matched > 0 && needleElements[potentialMatch.matched].combinator.value !== targetCombinator) { - potentialMatch = null; - } else { - potentialMatch.matched++; - } // if we are still valid and have finished, test whether we have elements after and whether these are allowed - - - if (potentialMatch) { - potentialMatch.finished = potentialMatch.matched === needleElements.length; - - if (potentialMatch.finished && !extend.allowAfter && (hackstackElementIndex + 1 < hackstackSelector.elements.length || haystackSelectorIndex + 1 < haystackSelectorPath.length)) { - potentialMatch = null; - } - } // if null we remove, if not, we are still valid, so either push as a valid match or continue - - - if (potentialMatch) { - if (potentialMatch.finished) { - potentialMatch.length = needleElements.length; - potentialMatch.endPathIndex = haystackSelectorIndex; - potentialMatch.endPathElementIndex = hackstackElementIndex + 1; // index after end of match - - potentialMatches.length = 0; // we don't allow matches to overlap, so start matching again - - matches.push(potentialMatch); - } - } else { - potentialMatches.splice(i, 1); - i--; - } - } - } - } - - return matches; - } - }, { - key: "isElementValuesEqual", - value: function isElementValuesEqual(elementValue1, elementValue2) { - if (typeof elementValue1 === 'string' || typeof elementValue2 === 'string') { - return elementValue1 === elementValue2; - } - - if (elementValue1 instanceof tree.Attribute) { - if (elementValue1.op !== elementValue2.op || elementValue1.key !== elementValue2.key) { - return false; - } - - if (!elementValue1.value || !elementValue2.value) { - if (elementValue1.value || elementValue2.value) { - return false; - } - - return true; - } - - elementValue1 = elementValue1.value.value || elementValue1.value; - elementValue2 = elementValue2.value.value || elementValue2.value; - return elementValue1 === elementValue2; - } - - elementValue1 = elementValue1.value; - elementValue2 = elementValue2.value; - - if (elementValue1 instanceof tree.Selector) { - if (!(elementValue2 instanceof tree.Selector) || elementValue1.elements.length !== elementValue2.elements.length) { - return false; - } - - for (var i = 0; i < elementValue1.elements.length; i++) { - if (elementValue1.elements[i].combinator.value !== elementValue2.elements[i].combinator.value) { - if (i !== 0 || (elementValue1.elements[i].combinator.value || ' ') !== (elementValue2.elements[i].combinator.value || ' ')) { - return false; - } - } - - if (!this.isElementValuesEqual(elementValue1.elements[i].value, elementValue2.elements[i].value)) { - return false; - } - } - - return true; - } - - return false; - } - }, { - key: "extendSelector", - value: function extendSelector(matches, selectorPath, replacementSelector, isVisible) { - // for a set of matches, replace each match with the replacement selector - var currentSelectorPathIndex = 0; - var currentSelectorPathElementIndex = 0; - var path = []; - var matchIndex; - var selector; - var firstElement; - var match; - var newElements; - - for (matchIndex = 0; matchIndex < matches.length; matchIndex++) { - match = matches[matchIndex]; - selector = selectorPath[match.pathIndex]; - firstElement = new tree.Element(match.initialCombinator, replacementSelector.elements[0].value, replacementSelector.elements[0].isVariable, replacementSelector.elements[0].getIndex(), replacementSelector.elements[0].fileInfo()); - - if (match.pathIndex > currentSelectorPathIndex && currentSelectorPathElementIndex > 0) { - path[path.length - 1].elements = path[path.length - 1].elements.concat(selectorPath[currentSelectorPathIndex].elements.slice(currentSelectorPathElementIndex)); - currentSelectorPathElementIndex = 0; - currentSelectorPathIndex++; - } - - newElements = selector.elements.slice(currentSelectorPathElementIndex, match.index).concat([firstElement]).concat(replacementSelector.elements.slice(1)); - - if (currentSelectorPathIndex === match.pathIndex && matchIndex > 0) { - path[path.length - 1].elements = path[path.length - 1].elements.concat(newElements); - } else { - path = path.concat(selectorPath.slice(currentSelectorPathIndex, match.pathIndex)); - path.push(new tree.Selector(newElements)); - } - - currentSelectorPathIndex = match.endPathIndex; - currentSelectorPathElementIndex = match.endPathElementIndex; - - if (currentSelectorPathElementIndex >= selectorPath[currentSelectorPathIndex].elements.length) { - currentSelectorPathElementIndex = 0; - currentSelectorPathIndex++; - } - } - - if (currentSelectorPathIndex < selectorPath.length && currentSelectorPathElementIndex > 0) { - path[path.length - 1].elements = path[path.length - 1].elements.concat(selectorPath[currentSelectorPathIndex].elements.slice(currentSelectorPathElementIndex)); - currentSelectorPathIndex++; - } - - path = path.concat(selectorPath.slice(currentSelectorPathIndex, selectorPath.length)); - path = path.map(function (currentValue) { - // we can re-use elements here, because the visibility property matters only for selectors - var derived = currentValue.createDerived(currentValue.elements); - - if (isVisible) { - derived.ensureVisibility(); - } else { - derived.ensureInvisibility(); - } - - return derived; - }); - return path; - } - }, { - key: "visitMedia", - value: function visitMedia(mediaNode, visitArgs) { - var newAllExtends = mediaNode.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length - 1]); - newAllExtends = newAllExtends.concat(this.doExtendChaining(newAllExtends, mediaNode.allExtends)); - this.allExtendsStack.push(newAllExtends); - } - }, { - key: "visitMediaOut", - value: function visitMediaOut(mediaNode) { - var lastIndex = this.allExtendsStack.length - 1; - this.allExtendsStack.length = lastIndex; - } - }, { - key: "visitAtRule", - value: function visitAtRule(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); - } - }, { - key: "visitAtRuleOut", - value: function visitAtRuleOut(atRuleNode) { - var lastIndex = this.allExtendsStack.length - 1; - this.allExtendsStack.length = lastIndex; - } - }]); - - return ProcessExtendsVisitor; -}(); - -var JoinSelectorVisitor = -/*#__PURE__*/ -function () { - function JoinSelectorVisitor() { - _classCallCheck(this, JoinSelectorVisitor); - - this.contexts = [[]]; - this._visitor = new Visitor(this); - } - - _createClass(JoinSelectorVisitor, [{ - key: "run", - value: function run(root) { - return this._visitor.visit(root); - } - }, { - key: "visitDeclaration", - value: function visitDeclaration(declNode, visitArgs) { - visitArgs.visitDeeper = false; - } - }, { - key: "visitMixinDefinition", - value: function visitMixinDefinition(mixinDefinitionNode, visitArgs) { - visitArgs.visitDeeper = false; - } - }, { - key: "visitRuleset", - value: function visitRuleset(rulesetNode, visitArgs) { - var context = this.contexts[this.contexts.length - 1]; - var paths = []; - var selectors; - this.contexts.push(paths); - - if (!rulesetNode.root) { - selectors = rulesetNode.selectors; - - if (selectors) { - selectors = selectors.filter(function (selector) { - return selector.getIsOutput(); - }); - rulesetNode.selectors = selectors.length ? selectors : selectors = null; - - if (selectors) { - rulesetNode.joinSelectors(paths, context, selectors); - } - } - - if (!selectors) { - rulesetNode.rules = null; - } - - rulesetNode.paths = paths; - } - } - }, { - key: "visitRulesetOut", - value: function visitRulesetOut(rulesetNode) { - this.contexts.length = this.contexts.length - 1; - } - }, { - key: "visitMedia", - value: function visitMedia(mediaNode, visitArgs) { - var context = this.contexts[this.contexts.length - 1]; - mediaNode.rules[0].root = context.length === 0 || context[0].multiMedia; - } - }, { - key: "visitAtRule", - value: function visitAtRule(atRuleNode, visitArgs) { - var context = this.contexts[this.contexts.length - 1]; - - if (atRuleNode.rules && atRuleNode.rules.length) { - atRuleNode.rules[0].root = atRuleNode.isRooted || context.length === 0 || null; - } - } - }]); - - return JoinSelectorVisitor; -}(); - -var CSSVisitorUtils = -/*#__PURE__*/ -function () { - function CSSVisitorUtils(context) { - _classCallCheck(this, CSSVisitorUtils); - - this._visitor = new Visitor(this); - this._context = context; - } - - _createClass(CSSVisitorUtils, [{ - key: "containsSilentNonBlockedChild", - value: function containsSilentNonBlockedChild(bodyRules) { - var rule; - - 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 atrule contains something that was referenced (likely by extend) - // therefore it needs to be shown in output too - return true; - } - } - - return false; - } - }, { - key: "keepOnlyVisibleChilds", - value: function keepOnlyVisibleChilds(owner) { - if (owner && owner.rules) { - owner.rules = owner.rules.filter(function (thing) { - return thing.isVisible(); - }); - } - } - }, { - key: "isEmpty", - value: function isEmpty(owner) { - return owner && owner.rules ? owner.rules.length === 0 : true; - } - }, { - key: "hasVisibleSelector", - value: function hasVisibleSelector(rulesetNode) { - return rulesetNode && rulesetNode.paths ? rulesetNode.paths.length > 0 : false; - } - }, { - key: "resolveVisibility", - value: function resolveVisibility(node, originalRules) { - if (!node.blocksVisibility()) { - if (this.isEmpty(node) && !this.containsSilentNonBlockedChild(originalRules)) { - return; - } - - return node; - } - - var compiledRulesBody = node.rules[0]; - this.keepOnlyVisibleChilds(compiledRulesBody); - - if (this.isEmpty(compiledRulesBody)) { - return; - } - - node.ensureVisibility(); - node.removeVisibilityBlock(); - return node; - } - }, { - key: "isVisibleRuleset", - value: function isVisibleRuleset(rulesetNode) { - if (rulesetNode.firstRoot) { - return true; - } - - if (this.isEmpty(rulesetNode)) { - return false; - } - - if (!rulesetNode.root && !this.hasVisibleSelector(rulesetNode)) { - return false; - } - - return true; - } - }]); - - return CSSVisitorUtils; -}(); - -var ToCSSVisitor = function ToCSSVisitor(context) { - this._visitor = new Visitor(this); - this._context = context; - this.utils = new CSSVisitorUtils(context); -}; - -ToCSSVisitor.prototype = { - isReplacing: true, - run: function run(root) { - return this._visitor.visit(root); - }, - visitDeclaration: function visitDeclaration(declNode, visitArgs) { - if (declNode.blocksVisibility() || declNode.variable) { - return; - } - - return declNode; - }, - visitMixinDefinition: function visitMixinDefinition(mixinNode, visitArgs) { - // mixin definitions do not get eval'd - this means they keep state - // so we have to clear that state here so it isn't used if toCSS is called twice - mixinNode.frames = []; - }, - visitExtend: function visitExtend(extendNode, visitArgs) {}, - visitComment: function visitComment(commentNode, visitArgs) { - if (commentNode.blocksVisibility() || commentNode.isSilent(this._context)) { - return; - } - - return commentNode; - }, - visitMedia: function visitMedia(mediaNode, visitArgs) { - var originalRules = mediaNode.rules[0].rules; - mediaNode.accept(this._visitor); - visitArgs.visitDeeper = false; - return this.utils.resolveVisibility(mediaNode, originalRules); - }, - visitImport: function visitImport(importNode, visitArgs) { - if (importNode.blocksVisibility()) { - return; - } - - return importNode; - }, - visitAtRule: function visitAtRule(atRuleNode, visitArgs) { - if (atRuleNode.rules && atRuleNode.rules.length) { - return this.visitAtRuleWithBody(atRuleNode, visitArgs); - } else { - return this.visitAtRuleWithoutBody(atRuleNode, visitArgs); - } - }, - visitAnonymous: function visitAnonymous(anonymousNode, visitArgs) { - if (!anonymousNode.blocksVisibility()) { - anonymousNode.accept(this._visitor); - return anonymousNode; - } - }, - visitAtRuleWithBody: function visitAtRuleWithBody(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(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(atRuleNode); - atRuleNode.accept(this._visitor); - visitArgs.visitDeeper = false; - - if (!this.utils.isEmpty(atRuleNode)) { - this._mergeRules(atRuleNode.rules[0].rules); - } - - return this.utils.resolveVisibility(atRuleNode, originalRules); - }, - visitAtRuleWithoutBody: function visitAtRuleWithoutBody(atRuleNode, visitArgs) { - if (atRuleNode.blocksVisibility()) { - return; - } - - if (atRuleNode.name === '@charset') { - // Only output the debug info together with subsequent @charset definitions - // 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 (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; - } - - this.charset = true; - } - - return atRuleNode; - }, - checkValidNodes: function checkValidNodes(rules, isRoot) { - if (!rules) { - return; - } - - for (var i = 0; i < rules.length; i++) { - var ruleNode = rules[i]; - - if (isRoot && ruleNode instanceof tree.Declaration && !ruleNode.variable) { - throw { - message: 'Properties must be inside selector blocks. They cannot be in the root', - index: ruleNode.getIndex(), - filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename - }; - } - - if (ruleNode instanceof tree.Call) { - throw { - message: `Function '${ruleNode.name}' is undefined`, - 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.getIndex(), - filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename - }; - } - } - }, - visitRuleset: function visitRuleset(rulesetNode, visitArgs) { - // at this point rulesets are nested into each other - var rule; - var rulesets = []; - this.checkValidNodes(rulesetNode.rules, rulesetNode.firstRoot); - - if (!rulesetNode.root) { - // remove invisible paths - this._compileRulesetPaths(rulesetNode); // remove rulesets from this ruleset body and compile them separately - - - var nodeRules = rulesetNode.rules; - var nodeRuleCnt = nodeRules ? nodeRules.length : 0; - - for (var i = 0; i < nodeRuleCnt;) { - rule = nodeRules[i]; - - if (rule && rule.rules) { - // visit because we are moving them out from being a child - rulesets.push(this._visitor.visit(rule)); - nodeRules.splice(i, 1); - nodeRuleCnt--; - continue; - } - - i++; - } // accept the visitor to remove rules and refactor itself - // then we can decide nogw whether we want it or not - // compile body - - - if (nodeRuleCnt > 0) { - rulesetNode.accept(this._visitor); - } else { - rulesetNode.rules = null; - } - - visitArgs.visitDeeper = false; - } else { - // if (! rulesetNode.root) { - rulesetNode.accept(this._visitor); - visitArgs.visitDeeper = false; - } - - if (rulesetNode.rules) { - this._mergeRules(rulesetNode.rules); - - this._removeDuplicateRules(rulesetNode.rules); - } // now decide whether we keep the ruleset - - - if (this.utils.isVisibleRuleset(rulesetNode)) { - rulesetNode.ensureVisibility(); - rulesets.splice(0, 0, rulesetNode); - } - - if (rulesets.length === 1) { - return rulesets[0]; - } - - return rulesets; - }, - _compileRulesetPaths: function _compileRulesetPaths(rulesetNode) { - if (rulesetNode.paths) { - rulesetNode.paths = rulesetNode.paths.filter(function (p) { - var i; - - if (p[0].elements[0].combinator.value === ' ') { - p[0].elements[0].combinator = new tree.Combinator(''); - } - - for (i = 0; i < p.length; i++) { - if (p[i].isVisible() && p[i].getIsOutput()) { - return true; - } - } - - return false; - }); - } - }, - _removeDuplicateRules: function _removeDuplicateRules(rules) { - if (!rules) { - return; - } // remove duplicates - - - var ruleCache = {}; - var ruleList; - var rule; - var i; - - for (i = rules.length - 1; i >= 0; i--) { - rule = rules[i]; - - if (rule instanceof tree.Declaration) { - if (!ruleCache[rule.name]) { - ruleCache[rule.name] = rule; - } else { - ruleList = ruleCache[rule.name]; - - if (ruleList instanceof tree.Declaration) { - ruleList = ruleCache[rule.name] = [ruleCache[rule.name].toCSS(this._context)]; - } - - var ruleCSS = rule.toCSS(this._context); - - if (ruleList.indexOf(ruleCSS) !== -1) { - rules.splice(i, 1); - } else { - ruleList.push(ruleCSS); - } - } - } - } - }, - _mergeRules: function _mergeRules(rules) { - if (!rules) { - return; - } - - var groups = {}; - var groupsArr = []; - - for (var i = 0; i < rules.length; i++) { - 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); - } - } - - groupsArr.forEach(function (group) { - if (group.length > 0) { - var result = group[0]; - var space = []; - var comma = [new tree.Expression(space)]; - group.forEach(function (rule) { - if (rule.merge === '+' && space.length > 0) { - comma.push(new tree.Expression(space = [])); - } - - space.push(rule.value); - result.important = result.important || rule.important; - }); - result.value = new tree.Value(comma); - } - }); - } -}; - -var visitors = { - Visitor, - ImportVisitor, - MarkVisibleSelectorsVisitor: SetTreeVisibilityVisitor, - ExtendVisitor: ProcessExtendsVisitor, - JoinSelectorVisitor, - ToCSSVisitor -}; - -// Split the input into chunks. -var chunker = (function (input, fail) { - var len = input.length; - var level = 0; - var parenLevel = 0; - var lastOpening; - var lastOpeningParen; - var lastMultiComment; - var lastMultiCommentEndBrace; - var chunks = []; - var emitFrom = 0; - var chunkerCurrentIndex; - var currentChunkStartIndex; - var cc; - var cc2; - var matched; - - function emitChunk(force) { - var len = chunkerCurrentIndex - emitFrom; - - if (len < 512 && !force || !len) { - return; - } - - chunks.push(input.slice(emitFrom, chunkerCurrentIndex + 1)); - emitFrom = chunkerCurrentIndex + 1; - } - - for (chunkerCurrentIndex = 0; chunkerCurrentIndex < len; chunkerCurrentIndex++) { - cc = input.charCodeAt(chunkerCurrentIndex); - - if (cc >= 97 && cc <= 122 || cc < 34) { - // a-z or whitespace - continue; - } - - switch (cc) { - case 40: - // ( - parenLevel++; - lastOpeningParen = chunkerCurrentIndex; - continue; - - case 41: - // ) - if (--parenLevel < 0) { - return fail('missing opening `(`', chunkerCurrentIndex); - } - - continue; - - case 59: - // ; - if (!parenLevel) { - emitChunk(); - } - - continue; - - case 123: - // { - level++; - lastOpening = chunkerCurrentIndex; - continue; - - case 125: - // } - if (--level < 0) { - return fail('missing opening `{`', chunkerCurrentIndex); - } - - if (!level && !parenLevel) { - emitChunk(); - } - - continue; - - case 92: - // \ - if (chunkerCurrentIndex < len - 1) { - chunkerCurrentIndex++; - continue; - } - - return fail('unescaped `\\`', chunkerCurrentIndex); - - case 34: - case 39: - case 96: - // ", ' and ` - matched = 0; - currentChunkStartIndex = chunkerCurrentIndex; - - for (chunkerCurrentIndex = chunkerCurrentIndex + 1; chunkerCurrentIndex < len; chunkerCurrentIndex++) { - cc2 = input.charCodeAt(chunkerCurrentIndex); - - if (cc2 > 96) { - continue; - } - - if (cc2 == cc) { - matched = 1; - break; - } - - if (cc2 == 92) { - // \ - if (chunkerCurrentIndex == len - 1) { - return fail('unescaped `\\`', chunkerCurrentIndex); - } - - chunkerCurrentIndex++; - } - } - - if (matched) { - continue; - } - - return fail(`unmatched \`${String.fromCharCode(cc)}\``, currentChunkStartIndex); - - case 47: - // /, check for comment - if (parenLevel || chunkerCurrentIndex == len - 1) { - continue; - } - - cc2 = input.charCodeAt(chunkerCurrentIndex + 1); - - if (cc2 == 47) { - // //, find lnfeed - for (chunkerCurrentIndex = chunkerCurrentIndex + 2; chunkerCurrentIndex < len; chunkerCurrentIndex++) { - cc2 = input.charCodeAt(chunkerCurrentIndex); - - if (cc2 <= 13 && (cc2 == 10 || cc2 == 13)) { - break; - } - } - } else if (cc2 == 42) { - // /*, find */ - lastMultiComment = currentChunkStartIndex = chunkerCurrentIndex; - - for (chunkerCurrentIndex = chunkerCurrentIndex + 2; chunkerCurrentIndex < len - 1; chunkerCurrentIndex++) { - cc2 = input.charCodeAt(chunkerCurrentIndex); - - if (cc2 == 125) { - lastMultiCommentEndBrace = chunkerCurrentIndex; - } - - if (cc2 != 42) { - continue; - } - - if (input.charCodeAt(chunkerCurrentIndex + 1) == 47) { - break; - } - } - - if (chunkerCurrentIndex == len - 1) { - return fail('missing closing `*/`', currentChunkStartIndex); - } - - chunkerCurrentIndex++; - } - - continue; - - case 42: - // *, check for unmatched */ - if (chunkerCurrentIndex < len - 1 && input.charCodeAt(chunkerCurrentIndex + 1) == 47) { - return fail('unmatched `/*`', chunkerCurrentIndex); - } - - continue; - } - } - - if (level !== 0) { - if (lastMultiComment > lastOpening && lastMultiCommentEndBrace > lastMultiComment) { - return fail('missing closing `}` or `*/`', lastOpening); - } else { - return fail('missing closing `}`', lastOpening); - } - } else if (parenLevel !== 0) { - return fail('missing closing `)`', lastOpeningParen); - } - - emitChunk(true); - return chunks; -}); - -var getParserInput = (function () { - var // Less input string - input; - var // current chunk - j; - var // holds state for backtracking - saveStack = []; - var // furthest index the parser has gone to - furthest; - var // if this is furthest we got to, this is the probably cause - furthestPossibleErrorMessage; - var // chunkified input - chunks; - var // current chunk - current; - var // index of current chunk, in `input` - currentPos; - var parserInput = {}; - var CHARCODE_SPACE = 32; - var CHARCODE_TAB = 9; - var CHARCODE_LF = 10; - var CHARCODE_CR = 13; - var CHARCODE_PLUS = 43; - var CHARCODE_COMMA = 44; - var CHARCODE_FORWARD_SLASH = 47; - var CHARCODE_9 = 57; - - function skipWhitespace(length) { - var oldi = parserInput.i; - var oldj = j; - var curr = parserInput.i - currentPos; - var endIndex = parserInput.i + current.length - curr; - var mem = parserInput.i += length; - var inp = input; - var c; - var nextChar; - var comment; - - for (; parserInput.i < endIndex; parserInput.i++) { - c = inp.charCodeAt(parserInput.i); - - if (parserInput.autoCommentAbsorb && c === CHARCODE_FORWARD_SLASH) { - nextChar = inp.charAt(parserInput.i + 1); - - if (nextChar === '/') { - comment = { - index: parserInput.i, - isLineComment: true - }; - var nextNewLine = inp.indexOf('\n', parserInput.i + 2); - - if (nextNewLine < 0) { - nextNewLine = endIndex; - } - - parserInput.i = nextNewLine; - comment.text = inp.substr(comment.index, parserInput.i - comment.index); - parserInput.commentStore.push(comment); - continue; - } else if (nextChar === '*') { - var nextStarSlash = inp.indexOf('*/', parserInput.i + 2); - - if (nextStarSlash >= 0) { - comment = { - index: parserInput.i, - text: inp.substr(parserInput.i, nextStarSlash + 2 - parserInput.i), - isLineComment: false - }; - parserInput.i += comment.text.length - 1; - parserInput.commentStore.push(comment); - continue; - } - } - - break; - } - - if (c !== CHARCODE_SPACE && c !== CHARCODE_LF && c !== CHARCODE_TAB && c !== CHARCODE_CR) { - break; - } - } - - current = current.slice(length + parserInput.i - mem + curr); - currentPos = parserInput.i; - - if (!current.length) { - if (j < chunks.length - 1) { - current = chunks[++j]; - skipWhitespace(0); // skip space at the beginning of a chunk - - return true; // things changed - } - - parserInput.finished = true; - } - - return oldi !== parserInput.i || oldj !== j; - } - - parserInput.save = function () { - currentPos = parserInput.i; - saveStack.push({ - current, - i: parserInput.i, - j - }); - }; - - parserInput.restore = function (possibleErrorMessage) { - if (parserInput.i > furthest || parserInput.i === furthest && possibleErrorMessage && !furthestPossibleErrorMessage) { - furthest = parserInput.i; - furthestPossibleErrorMessage = possibleErrorMessage; - } - - var state = saveStack.pop(); - current = state.current; - currentPos = parserInput.i = state.i; - j = state.j; - }; - - parserInput.forget = function () { - saveStack.pop(); - }; - - parserInput.isWhitespace = function (offset) { - var pos = parserInput.i + (offset || 0); - var code = input.charCodeAt(pos); - return code === CHARCODE_SPACE || code === CHARCODE_CR || code === CHARCODE_TAB || code === CHARCODE_LF; - }; // Specialization of $(tok) - - - parserInput.$re = function (tok) { - if (parserInput.i > currentPos) { - current = current.slice(parserInput.i - currentPos); - currentPos = parserInput.i; - } - - var m = tok.exec(current); - - if (!m) { - return null; - } - - skipWhitespace(m[0].length); - - if (typeof m === 'string') { - return m; - } - - return m.length === 1 ? m[0] : m; - }; - - parserInput.$char = function (tok) { - if (input.charAt(parserInput.i) !== tok) { - return null; - } - - skipWhitespace(1); - return tok; - }; - - parserInput.$str = function (tok) { - var tokLength = tok.length; // https://jsperf.com/string-startswith/21 - - for (var i = 0; i < tokLength; i++) { - if (input.charAt(parserInput.i + i) !== tok.charAt(i)) { - return null; - } - } - - skipWhitespace(tokLength); - return tok; - }; - - parserInput.$quoted = function (loc) { - var pos = loc || parserInput.i; - var startChar = input.charAt(pos); - - if (startChar !== '\'' && startChar !== '"') { - return; - } - - var length = input.length; - var currentPosition = pos; - - for (var i = 1; i + currentPosition < length; i++) { - var nextChar = input.charAt(i + currentPosition); - - switch (nextChar) { - case '\\': - i++; - continue; - - case '\r': - case '\n': - break; - - case startChar: - var str = input.substr(currentPosition, i + 1); - - if (!loc && loc !== 0) { - skipWhitespace(i + 1); - return str; - } - - return [startChar, str]; - - default: - } - } - - return null; - }; - /** - * Permissive parsing. Ignores everything except matching {} [] () and quotes - * until matching token (outside of blocks) - */ - - - parserInput.$parseUntil = function (tok) { - var quote = ''; - var returnVal = null; - var inComment = false; - var blockDepth = 0; - var blockStack = []; - var parseGroups = []; - var length = input.length; - var startPos = parserInput.i; - var lastPos = parserInput.i; - var i = parserInput.i; - var loop = true; - var testChar; - - if (typeof tok === 'string') { - testChar = function testChar(char) { - return char === tok; - }; - } else { - testChar = function testChar(char) { - return tok.test(char); - }; - } - - do { - var nextChar = input.charAt(i); - - if (blockDepth === 0 && testChar(nextChar)) { - returnVal = input.substr(lastPos, i - lastPos); - - if (returnVal) { - parseGroups.push(returnVal); - } else { - parseGroups.push(' '); - } - - returnVal = parseGroups; - skipWhitespace(i - startPos); - loop = false; - } else { - if (inComment) { - if (nextChar === '*' && input.charAt(i + 1) === '/') { - i++; - blockDepth--; - inComment = false; - } - - i++; - continue; - } - - switch (nextChar) { - case '\\': - i++; - nextChar = input.charAt(i); - parseGroups.push(input.substr(lastPos, i - lastPos + 1)); - lastPos = i + 1; - break; - - case '/': - if (input.charAt(i + 1) === '*') { - i++; - inComment = true; - blockDepth++; - } - - break; - - case '\'': - case '"': - quote = parserInput.$quoted(i); - - if (quote) { - parseGroups.push(input.substr(lastPos, i - lastPos), quote); - i += quote[1].length - 1; - lastPos = i + 1; - } else { - skipWhitespace(i - startPos); - returnVal = nextChar; - loop = false; - } - - break; - - case '{': - blockStack.push('}'); - blockDepth++; - break; - - case '(': - blockStack.push(')'); - blockDepth++; - break; - - case '[': - blockStack.push(']'); - blockDepth++; - break; - - case '}': - case ')': - case ']': - var expected = blockStack.pop(); - - if (nextChar === expected) { - blockDepth--; - } else { - // move the parser to the error and return expected - skipWhitespace(i - startPos); - returnVal = expected; - loop = false; - } - - } - - i++; - - if (i > length) { - loop = false; - } - } - } while (loop); - - return returnVal ? returnVal : null; - }; - - parserInput.autoCommentAbsorb = true; - parserInput.commentStore = []; - parserInput.finished = false; // Same as $(), but don't change the state of the parser, - // just return the match. - - parserInput.peek = function (tok) { - if (typeof tok === 'string') { - // https://jsperf.com/string-startswith/21 - for (var i = 0; i < tok.length; i++) { - if (input.charAt(parserInput.i + i) !== tok.charAt(i)) { - return false; - } - } - - return true; - } else { - return tok.test(current); - } - }; // Specialization of peek() - // TODO remove or change some currentChar calls to peekChar - - - parserInput.peekChar = function (tok) { - return input.charAt(parserInput.i) === tok; - }; - - parserInput.currentChar = function () { - return input.charAt(parserInput.i); - }; - - parserInput.prevChar = function () { - return input.charAt(parserInput.i - 1); - }; - - parserInput.getInput = function () { - return input; - }; - - parserInput.peekNotNumeric = function () { - var c = input.charCodeAt(parserInput.i); // Is the first char of the dimension 0-9, '.', '+' or '-' - - return c > CHARCODE_9 || c < CHARCODE_PLUS || c === CHARCODE_FORWARD_SLASH || c === CHARCODE_COMMA; - }; - - parserInput.start = function (str, chunkInput, failFunction) { - input = str; - parserInput.i = j = currentPos = furthest = 0; // chunking apparently makes things quicker (but my tests indicate - // it might actually make things slower in node at least) - // and it is a non-perfect parse - it can't recognise - // unquoted urls, meaning it can't distinguish comments - // meaning comments with quotes or {}() in them get 'counted' - // and then lead to parse errors. - // In addition if the chunking chunks in the wrong place we might - // not be able to parse a parser statement in one go - // this is officially deprecated but can be switched on via an option - // in the case it causes too much performance issues. - - if (chunkInput) { - chunks = chunker(str, failFunction); - } else { - chunks = [str]; - } - - current = chunks[0]; - skipWhitespace(0); - }; - - parserInput.end = function () { - var message; - var isFinished = parserInput.i >= input.length; - - if (parserInput.i < furthest) { - message = furthestPossibleErrorMessage; - parserInput.i = furthest; - } - - return { - isFinished, - furthest: parserInput.i, - furthestPossibleErrorMessage: message, - furthestReachedEnd: parserInput.i >= input.length - 1, - furthestChar: input[parserInput.i] - }; - }; - - return parserInput; -}); - -// less.js - parser -// -// A relatively straight-forward predictive parser. -// There is no tokenization/lexing stage, the input is parsed -// in one sweep. -// -// To make the parser fast enough to run in the browser, several -// optimization had to be made: -// -// - Matching and slicing on a huge input is often cause of slowdowns. -// The solution is to chunkify the input into smaller strings. -// The chunks are stored in the `chunks` var, -// `j` holds the current chunk index, and `currentPos` holds -// the index of the current chunk in relation to `input`. -// This gives us an almost 4x speed-up. -// -// - In many cases, we don't need to match individual tokens; -// for example, if a value doesn't hold any variables, operations -// or dynamic references, the parser can effectively 'skip' it, -// treating it as a literal. -// An example would be '1px solid #000' - which evaluates to itself, -// we don't need to know what the individual components are. -// The drawback, of course is that you don't get the benefits of -// syntax-checking on the CSS. This gives us a 50% speed-up in the parser, -// and a smaller speed-up in the code-gen. -// -// -// 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; - var parserInput = getParserInput(); - - function error(msg, type) { - throw new LessError({ - index: parserInput.i, - filename: fileInfo.filename, - type: type || 'Syntax', - message: msg - }, imports); - } - - function expect(arg, msg) { - // some older browsers return typeof 'function' for RegExp - var result = arg instanceof Function ? arg.call(parsers) : parserInput.$re(arg); - - if (result) { - return result; - } - - error(msg || (typeof arg === 'string' ? `expected '${arg}' got '${parserInput.currentChar()}'` : 'unexpected token')); - } // Specialization of expect() - - - function expectChar(arg, msg) { - if (parserInput.$char(arg)) { - return arg; - } - - error(msg || `expected '${arg}' got '${parserInput.currentChar()}'`); - } - - function getDebugInfo(index) { - var filename = fileInfo.filename; - return { - lineNumber: getLocation(index, parserInput.getInput()).line + 1, - fileName: filename - }; - } - /** - * 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; - var 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) { - try { - result._index = i + currentIndex; - result._fileInfo = fileInfo; - } catch (e) {} - - 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, - imports, - fileInfo, - parseNode, - // - // Parse an input string into an abstract syntax tree, - // @param str A string containing 'less' markup - // @param callback call `callback` when done. - // @param [additionalData] An optional map which can contains vars - a map (key, value) of variables to apply - // - parse: function parse(str, callback, additionalData) { - var root; - var error = null; - var globalVars; - var modifyVars; - var ignored; - var preText = ''; - globalVars = additionalData && additionalData.globalVars ? `${Parser.serializeVars(additionalData.globalVars)}\n` : ''; - modifyVars = additionalData && additionalData.modifyVars ? `\n${Parser.serializeVars(additionalData.modifyVars)}` : ''; - - if (context.pluginManager) { - var preProcessors = context.pluginManager.getPreProcessors(); - - for (var i = 0; i < preProcessors.length; i++) { - str = preProcessors[i].process(str, { - context, - imports, - fileInfo - }); - } - } - - if (globalVars || additionalData && additionalData.banner) { - preText = (additionalData && additionalData.banner ? additionalData.banner : '') + globalVars; - ignored = imports.contentsIgnoredChars; - ignored[fileInfo.filename] = ignored[fileInfo.filename] || 0; - ignored[fileInfo.filename] += preText.length; - } - - str = str.replace(/\r\n?/g, '\n'); // Remove potential UTF Byte Order Mark - - str = preText + str.replace(/^\uFEFF/, '') + modifyVars; - imports.contents[fileInfo.filename] = str; // Start with the primary rule. - // The whole syntax tree is held under a Ruleset node, - // with the `root` property set to true, so no `{}` are - // output. The callback is called when the input is parsed. - - try { - parserInput.start(str, context.chunkInput, function fail(msg, index) { - throw new LessError({ - index, - type: 'Parse', - message: msg, - filename: fileInfo.filename - }, imports); - }); - 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)); - } // If `i` is smaller than the `input.length - 1`, - // it means the parser wasn't able to parse the whole - // string, so we've got a parsing error. - // - // We try to extract a \n delimited string, - // showing the line where the parse error occurred. - // We split it up into two parts (the part which parsed, - // and the part which didn't), so we can color them differently. - - - var endInfo = parserInput.end(); - - if (!endInfo.isFinished) { - var message = endInfo.furthestPossibleErrorMessage; - - if (!message) { - message = 'Unrecognised input'; - - if (endInfo.furthestChar === '}') { - message += '. Possibly missing opening \'{\''; - } else if (endInfo.furthestChar === ')') { - message += '. Possibly missing opening \'(\''; - } else if (endInfo.furthestReachedEnd) { - message += '. Possibly missing something'; - } - } - - error = new LessError({ - type: 'Parse', - message, - index: endInfo.furthest, - filename: fileInfo.filename - }, imports); - } - - var finish = function finish(e) { - e = error || e || imports.error; - - if (e) { - if (!(e instanceof LessError)) { - e = new LessError(e, imports, fileInfo.filename); - } - - return callback(e); - } else { - return callback(null, root); - } - }; - - if (context.processImports !== false) { - new visitors.ImportVisitor(imports, finish).run(root); - } else { - return finish(); - } - }, - // - // Here in, the parsing rules/functions - // - // The basic structure of the syntax tree generated is as follows: - // - // Ruleset -> Declaration -> Value -> Expression -> Entity - // - // Here's some Less code: - // - // .class { - // color: #fff; - // border: 1px solid #000; - // width: @w + 4px; - // > .child {...} - // } - // - // And here's what the parse tree might look like: - // - // Ruleset (Selector '.class', [ - // 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'], [...]) - // ]) - // - // In general, most rules will try to parse a token with the `$re()` function, and if the return - // value is truly, will return a new node, of the relevant type. Sometimes, we need to check - // first, before parsing, that's when we use `peek()`. - // - parsers: parsers = { - // - // The `primary` rule is the *entry* and *exit* point of the parser. - // The rules here can appear at any level of the parse tree. - // - // The recursive nature of the grammar is an interplay between the `block` - // rule, which represents `{ ... }`, the `ruleset` rule, and this `primary` rule, - // as represented by this simplified grammar: - // - // primary → (ruleset | declaration)+ - // ruleset → selector+ block - // block → '{' primary '}' - // - // Only at one point is the primary rule not called from the - // block rule: at the root level. - // - primary: function primary() { - var mixin = this.mixin; - var root = []; - var node; - - while (true) { - while (true) { - node = this.comment(); - - if (!node) { - break; - } - - root.push(node); - } // always process comments before deciding if finished - - - if (parserInput.finished) { - break; - } - - if (parserInput.peek('}')) { - break; - } - - node = this.extendRule(); - - if (node) { - root = root.concat(node); - continue; - } - - node = mixin.definition() || this.declaration() || this.ruleset() || mixin.call(false, false) || this.variableCall() || this.entities.call() || this.atrule(); - - if (node) { - root.push(node); - } else { - var foundSemiColon = false; - - while (parserInput.$char(';')) { - foundSemiColon = true; - } - - if (!foundSemiColon) { - break; - } - } - } - - return root; - }, - // comments are collected by the main parsing mechanism and then assigned to nodes - // where the current structure allows it - comment: function comment() { - if (parserInput.commentStore.length) { - var comment = parserInput.commentStore.shift(); - return new tree.Comment(comment.text, comment.isLineComment, comment.index, fileInfo); - } - }, - // - // Entities are tokens which can be found inside an Expression - // - entities: { - mixinLookup: function mixinLookup() { - return parsers.mixin.call(true, true); - }, - // - // A string, which supports escaping " and ' - // - // "milky way" 'he\'s the one!' - // - quoted: function quoted(forceEscaped) { - var str; - var index = parserInput.i; - var isEscaped = false; - parserInput.save(); - - if (parserInput.$char('~')) { - isEscaped = true; - } else if (forceEscaped) { - parserInput.restore(); - return; - } - - str = parserInput.$quoted(); - - if (!str) { - parserInput.restore(); - return; - } - - parserInput.forget(); - return new tree.Quoted(str.charAt(0), str.substr(1, str.length - 2), isEscaped, index, fileInfo); - }, - // - // A catch-all word, such as: - // - // black border-collapse - // - keyword: function keyword() { - var k = parserInput.$char('%') || parserInput.$re(/^\[?(?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+\]?/); - - if (k) { - return tree.Color.fromKeyword(k) || new tree.Keyword(k); - } - }, - // - // A function call - // - // rgb(255, 0, 255) - // - // The arguments are parsed with the `entities.arguments` parser. - // - call: function call() { - var name; - var args; - var func; - var index = parserInput.i; // http://jsperf.com/case-insensitive-regex-vs-strtolower-then-regex/18 - - if (parserInput.peek(/^url\(/i)) { - return; - } - - parserInput.save(); - name = parserInput.$re(/^([\w-]+|%|progid:[\w\.]+)\(/); - - if (!name) { - parserInput.forget(); - return; - } - - name = name[1]; - func = this.customFuncCall(name); - - if (func) { - args = func.parse(); - - if (args && func.stop) { - parserInput.forget(); - return args; - } - } - - args = this.arguments(args); - - if (!parserInput.$char(')')) { - parserInput.restore('Could not parse call arguments or missing \')\''); - return; - } - - parserInput.forget(); - return new tree.Call(name, args, index, fileInfo); - }, - // - // 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(...)`) - // - customFuncCall: function customFuncCall(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, - // parsing function - stop // when true - stop after parse() and return its result, - // otherwise continue for plain args - - }; - } - - function condition() { - return [expect(parsers.condition, 'expected condition')]; - } - }, - arguments: function _arguments(prevArgs) { - var argsComma = prevArgs || []; - var argsSemiColon = []; - var isSemiColonSeparated; - var value; - parserInput.save(); - - while (true) { - if (prevArgs) { - prevArgs = false; - } else { - value = parsers.detachedRuleset() || this.assignment() || parsers.expression(); - - if (!value) { - break; - } - - if (value.value && value.value.length == 1) { - value = value.value[0]; - } - - argsComma.push(value); - } - - if (parserInput.$char(',')) { - continue; - } - - if (parserInput.$char(';') || isSemiColonSeparated) { - isSemiColonSeparated = true; - value = argsComma.length < 1 ? argsComma[0] : new tree.Value(argsComma); - argsSemiColon.push(value); - argsComma = []; - } - } - - parserInput.forget(); - return isSemiColonSeparated ? argsSemiColon : argsComma; - }, - literal: function literal() { - return this.dimension() || this.color() || this.quoted() || this.unicodeDescriptor(); - }, - // Assignments are argument entities for calls. - // They are present in ie filter properties as shown below. - // - // filter: progid:DXImageTransform.Microsoft.Alpha( *opacity=50* ) - // - assignment: function assignment() { - var key; - var value; - parserInput.save(); - key = parserInput.$re(/^\w+(?=\s?=)/i); - - if (!key) { - parserInput.restore(); - return; - } - - if (!parserInput.$char('=')) { - parserInput.restore(); - return; - } - - value = parsers.entity(); - - if (value) { - parserInput.forget(); - return new tree.Assignment(key, value); - } else { - parserInput.restore(); - } - }, - // - // Parse url() tokens - // - // We use a specific rule for urls, because they don't really behave like - // standard function calls. The difference is that the argument doesn't have - // to be enclosed within a string, so it can't be parsed as an Expression. - // - url: function url() { - var value; - var index = parserInput.i; - parserInput.autoCommentAbsorb = false; - - if (!parserInput.$str('url(')) { - parserInput.autoCommentAbsorb = true; - return; - } - - 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 instanceof tree.Property ? value : new tree.Anonymous(value, index), index, fileInfo); - }, - // - // A Variable entity, such as `@fink`, in - // - // width: @fink + 2px - // - // We use a different parser for variable definitions, - // see `parsers.variable`. - // - variable: function variable() { - var ch; - var name; - var index = parserInput.i; - parserInput.save(); - - if (parserInput.currentChar() === '@' && (name = parserInput.$re(/^@@?[\w-]+/))) { - ch = parserInput.currentChar(); - - if (ch === '(' || ch === '[' && !parserInput.prevChar().match(/^\s/)) { - // this may be a VariableCall lookup - var result = parsers.variableCall(name); - - if (result) { - parserInput.forget(); - return result; - } - } - - parserInput.forget(); - return new tree.Variable(name, index, fileInfo); - } - - parserInput.restore(); - }, - // A variable entity using the protective {} e.g. @{var} - variableCurly: function variableCurly() { - var curly; - var index = parserInput.i; - - if (parserInput.currentChar() === '@' && (curly = parserInput.$re(/^@\{([\w-]+)\}/))) { - return new tree.Variable(`@${curly[1]}`, index, fileInfo); - } - }, - // - // A Property accessor, such as `$color`, in - // - // background-color: $color - // - property: function property() { - var name; - var 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 propertyCurly() { - var curly; - var index = parserInput.i; - - if (parserInput.currentChar() === '$' && (curly = parserInput.$re(/^\$\{([\w-]+)\}/))) { - return new tree.Property(`$${curly[1]}`, index, fileInfo); - } - }, - // - // A Hexadecimal color - // - // #4F3C2F - // - // `rgb` and `hsl` colors are parsed through the `entities.call` parser. - // - color: function color() { - var rgb; - parserInput.save(); - - if (parserInput.currentChar() === '#' && (rgb = parserInput.$re(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3,4})([\w.#\[])?/))) { - if (!rgb[2]) { - parserInput.forget(); - return new tree.Color(rgb[1], undefined, rgb[0]); - } - } - - parserInput.restore(); - }, - colorKeyword: function colorKeyword() { - parserInput.save(); - var autoCommentAbsorb = parserInput.autoCommentAbsorb; - parserInput.autoCommentAbsorb = false; - var k = parserInput.$re(/^[_A-Za-z-][_A-Za-z0-9-]+/); - parserInput.autoCommentAbsorb = autoCommentAbsorb; - - if (!k) { - parserInput.forget(); - return; - } - - parserInput.restore(); - var color = tree.Color.fromKeyword(k); - - if (color) { - parserInput.$str(k); - return color; - } - }, - // - // A Dimension, that is, a number and a unit - // - // 0.5em 95% - // - dimension: function dimension() { - if (parserInput.peekNotNumeric()) { - return; - } - - var value = parserInput.$re(/^([+-]?\d*\.?\d+)(%|[a-z_]+)?/i); - - if (value) { - return new tree.Dimension(value[1], value[2]); - } - }, - // - // A unicode descriptor, as is used in unicode-range - // - // U+0?? or U+00A1-00A9 - // - unicodeDescriptor: function unicodeDescriptor() { - var ud; - ud = parserInput.$re(/^U\+[0-9a-fA-F?]+(\-[0-9a-fA-F?]+)?/); - - if (ud) { - return new tree.UnicodeDescriptor(ud[0]); - } - }, - // - // JavaScript code to be evaluated - // - // `window.location.href` - // - javascript: function javascript() { - var js; - var index = parserInput.i; - parserInput.save(); - var escape = parserInput.$char('~'); - var jsQuote = parserInput.$char('`'); - - if (!jsQuote) { - parserInput.restore(); - return; - } - - js = parserInput.$re(/^[^`]*`/); - - if (js) { - parserInput.forget(); - return new tree.JavaScript(js.substr(0, js.length - 1), Boolean(escape), index, fileInfo); - } - - parserInput.restore('invalid javascript definition'); - } - }, - // - // The variable part of a variable definition. Used in the `rule` parser - // - // @fink: - // - variable: function variable() { - var name; - - if (parserInput.currentChar() === '@' && (name = parserInput.$re(/^(@[\w-]+)\s*:/))) { - return name[1]; - } - }, - // - // Call a variable value to retrieve a detached ruleset - // or a value from a detached ruleset's rules. - // - // @fink(); - // @fink; - // color: @fink[@color]; - // - variableCall: function variableCall(parsedName) { - var lookups; - var important; - var i = parserInput.i; - var inValue = !!parsedName; - var name = parsedName; - parserInput.save(); - - if (name || parserInput.currentChar() === '@' && (name = parserInput.$re(/^(@[\w-]+)(\(\s*\))?/))) { - lookups = this.mixin.ruleLookups(); - - if (!lookups && (inValue && parserInput.$str('()') !== '()' || name[2] !== '()')) { - parserInput.restore('Missing \'[...]\' lookup in variable call'); - return; - } - - if (!inValue) { - name = name[1]; - } - - if (lookups && parsers.important()) { - important = true; - } - - var call = new tree.VariableCall(name, i, fileInfo); - - if (!inValue && parsers.end()) { - parserInput.forget(); - return call; - } else { - parserInput.forget(); - return new tree.NamespaceValue(call, lookups, important, i, fileInfo); - } - } - - parserInput.restore(); - }, - // - // extend syntax - used to extend selectors - // - extend: function extend(isRule) { - var elements; - var e; - var index = parserInput.i; - var option; - var extendList; - var extend; - - if (!parserInput.$str(isRule ? '&:extend(' : ':extend(')) { - return; - } - - do { - option = null; - elements = null; - - while (!(option = parserInput.$re(/^(all)(?=\s*(\)|,))/))) { - e = this.element(); - - if (!e) { - break; - } - - if (elements) { - elements.push(e); - } else { - elements = [e]; - } - } - - option = option && option[1]; - - if (!elements) { - error('Missing target selector for :extend().'); - } - - extend = new tree.Extend(new tree.Selector(elements), option, index, fileInfo); - - if (extendList) { - extendList.push(extend); - } else { - extendList = [extend]; - } - } while (parserInput.$char(',')); - - expect(/^\)/); - - if (isRule) { - expect(/^;/); - } - - return extendList; - }, - // - // extendRule - used in a rule to extend all the parent selectors - // - extendRule: function extendRule() { - return this.extend(true); - }, - // - // Mixins - // - mixin: { - // - // A Mixin call, with an optional argument list - // - // #mixins > .square(#fff); - // #mixins.square(#fff); - // .rounded(4px, black); - // .button; - // - // We can lookup / return a value using the lookup syntax: - // - // color: #mixin.square(#fff)[@color]; - // - // The `while` loop is there because mixins can be - // namespaced, but we only support the child and descendant - // selector for now. - // - call: function call(inValue, getLookup) { - var s = parserInput.currentChar(); - var important = false; - var lookups; - var index = parserInput.i; - var elements; - var args; - var hasParens; - - if (s !== '.' && s !== '#') { - return; - } - - parserInput.save(); // stop us absorbing part of an invalid selector - - elements = this.elements(); - - if (elements) { - if (parserInput.$char('(')) { - args = this.args(true).args; - expectChar(')'); - hasParens = true; - } - - if (getLookup !== false) { - lookups = this.ruleLookups(); - } - - if (getLookup === true && !lookups) { - parserInput.restore(); - return; - } - - if (inValue && !lookups && !hasParens) { - // This isn't a valid in-value mixin call - parserInput.restore(); - return; - } - - if (!inValue && parsers.important()) { - important = true; - } - - if (inValue || parsers.end()) { - parserInput.forget(); - var mixin = new tree.mixin.Call(elements, args, index, fileInfo, !lookups && important); - - if (lookups) { - return new tree.NamespaceValue(mixin, lookups, important); - } else { - return mixin; - } - } - } - - parserInput.restore(); - }, - - /** - * Matching elements for mixins - * (Start with . or # and can have > ) - */ - elements: function elements() { - var elements; - var e; - var c; - var elem; - var elemIndex; - var re = /^[#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/; - - while (true) { - elemIndex = parserInput.i; - e = parserInput.$re(re); - - if (!e) { - break; - } - - elem = new tree.Element(c, e, false, elemIndex, fileInfo); - - if (elements) { - elements.push(elem); - } else { - elements = [elem]; - } - - c = parserInput.$char('>'); - } - - return elements; - }, - args: function args(isCall) { - var entities = parsers.entities; - var returner = { - args: null, - variadic: false - }; - var expressions = []; - var argsSemiColon = []; - var argsComma = []; - var isSemiColonSeparated; - var expressionContainsNamed; - var name; - var nameLoop; - var value; - var arg; - var expand; - var hasSep = true; - parserInput.save(); - - while (true) { - if (isCall) { - arg = parsers.detachedRuleset() || parsers.expression(); - } else { - parserInput.commentStore.length = 0; - - if (parserInput.$str('...')) { - returner.variadic = true; - - if (parserInput.$char(';') && !isSemiColonSeparated) { - isSemiColonSeparated = true; - } - - (isSemiColonSeparated ? argsSemiColon : argsComma).push({ - variadic: true - }); - break; - } - - arg = entities.variable() || entities.property() || entities.literal() || entities.keyword() || this.call(true); - } - - if (!arg || !hasSep) { - break; - } - - nameLoop = null; - - if (arg.throwAwayComments) { - arg.throwAwayComments(); - } - - value = arg; - var val = null; - - if (isCall) { - // Variable - if (arg.value && arg.value.length == 1) { - val = arg.value[0]; - } - } else { - val = arg; - } - - if (val && (val instanceof tree.Variable || val instanceof tree.Property)) { - if (parserInput.$char(':')) { - if (expressions.length > 0) { - if (isSemiColonSeparated) { - error('Cannot mix ; and , as delimiter types'); - } - - expressionContainsNamed = true; - } - - value = parsers.detachedRuleset() || parsers.expression(); - - if (!value) { - if (isCall) { - error('could not understand value for named argument'); - } else { - parserInput.restore(); - returner.args = []; - return returner; - } - } - - nameLoop = name = val.name; - } else if (parserInput.$str('...')) { - if (!isCall) { - returner.variadic = true; - - if (parserInput.$char(';') && !isSemiColonSeparated) { - isSemiColonSeparated = true; - } - - (isSemiColonSeparated ? argsSemiColon : argsComma).push({ - name: arg.name, - variadic: true - }); - break; - } else { - expand = true; - } - } else if (!isCall) { - name = nameLoop = val.name; - value = null; - } - } - - if (value) { - expressions.push(value); - } - - argsComma.push({ - name: nameLoop, - value, - expand - }); - - if (parserInput.$char(',')) { - hasSep = true; - continue; - } - - hasSep = parserInput.$char(';') === ';'; - - if (hasSep || isSemiColonSeparated) { - if (expressionContainsNamed) { - error('Cannot mix ; and , as delimiter types'); - } - - isSemiColonSeparated = true; - - if (expressions.length > 1) { - value = new tree.Value(expressions); - } - - argsSemiColon.push({ - name, - value, - expand - }); - name = null; - expressions = []; - expressionContainsNamed = false; - } - } - - parserInput.forget(); - returner.args = isSemiColonSeparated ? argsSemiColon : argsComma; - return returner; - }, - // - // A Mixin definition, with a list of parameters - // - // .rounded (@radius: 2px, @color) { - // ... - // } - // - // Until we have a finer grained state-machine, we have to - // do a look-ahead, to make sure we don't have a mixin call. - // See the `rule` function for more information. - // - // We start by matching `.rounded (`, and then proceed on to - // the argument list, which has optional default values. - // We store the parameters in `params`, with a `value` key, - // if there is a value, such as in the case of `@radius`. - // - // Once we've got our params list, and a closing `)`, we parse - // the `{...}` block. - // - definition: function definition() { - var name; - var params = []; - var match; - var ruleset; - var cond; - var variadic = false; - - if (parserInput.currentChar() !== '.' && parserInput.currentChar() !== '#' || parserInput.peek(/^[^{]*\}/)) { - return; - } - - parserInput.save(); - match = parserInput.$re(/^([#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+)\s*\(/); - - if (match) { - name = match[1]; - var argInfo = this.args(false); - params = argInfo.args; - variadic = argInfo.variadic; // .mixincall("@{a}"); - // looks a bit like a mixin definition.. - // also - // .mixincall(@a: {rule: set;}); - // so we have to be nice and restore - - if (!parserInput.$char(')')) { - parserInput.restore('Missing closing \')\''); - return; - } - - parserInput.commentStore.length = 0; - - if (parserInput.$str('when')) { - // Guard - cond = expect(parsers.conditions, 'expected condition'); - } - - ruleset = parsers.block(); - - if (ruleset) { - parserInput.forget(); - return new tree.mixin.Definition(name, params, ruleset, cond, variadic); - } else { - parserInput.restore(); - } - } else { - parserInput.forget(); - } - }, - ruleLookups: function ruleLookups() { - var rule; - var lookups = []; - - if (parserInput.currentChar() !== '[') { - return; - } - - while (true) { - parserInput.save(); - rule = this.lookupValue(); - - if (!rule && rule !== '') { - parserInput.restore(); - break; - } - - lookups.push(rule); - parserInput.forget(); - } - - if (lookups.length > 0) { - return lookups; - } - }, - lookupValue: function lookupValue() { - parserInput.save(); - - if (!parserInput.$char('[')) { - parserInput.restore(); - return; - } - - var name = parserInput.$re(/^(?:[@$]{0,2})[_a-zA-Z0-9-]*/); - - if (!parserInput.$char(']')) { - parserInput.restore(); - return; - } - - if (name || name === '') { - parserInput.forget(); - return name; - } - - parserInput.restore(); - } - }, - // - // Entities are the smallest recognized token, - // and can be found inside a rule's value. - // - entity: function entity() { - var entities = this.entities; - return this.comment() || entities.literal() || entities.variable() || entities.url() || entities.property() || entities.call() || entities.keyword() || this.mixin.call(true) || entities.javascript(); - }, - // - // 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. - // - end: function end() { - return parserInput.$char(';') || parserInput.peek('}'); - }, - // - // IE's alpha function - // - // alpha(opacity=88) - // - ieAlpha: function ieAlpha() { - var value; // http://jsperf.com/case-insensitive-regex-vs-strtolower-then-regex/18 - - if (!parserInput.$re(/^opacity=/i)) { - return; - } - - value = parserInput.$re(/^\d+/); - - if (!value) { - value = expect(parsers.entities.variable, 'Could not parse alpha'); - value = `@{${value.name.slice(1)}}`; - } - - expectChar(')'); - return new tree.Quoted('', `alpha(opacity=${value})`); - }, - // - // A Selector Element - // - // div - // + h1 - // #socks - // input[type="text"] - // - // Elements are the building blocks for Selectors, - // they are made out of a `Combinator` (see combinator rule), - // and an element name, such as a tag a class, or `*`. - // - element: function element() { - var e; - var c; - var v; - var index = parserInput.i; - c = this.combinator(); - e = parserInput.$re(/^(?:\d+\.\d+|\d+)%/) || parserInput.$re(/^(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/) || parserInput.$char('*') || parserInput.$char('&') || this.attribute() || parserInput.$re(/^\([^&()@]+\)/) || parserInput.$re(/^[\.#:](?=@)/) || this.entities.variableCurly(); - - if (!e) { - parserInput.save(); - - if (parserInput.$char('(')) { - if ((v = this.selector(false)) && parserInput.$char(')')) { - e = new tree.Paren(v); - parserInput.forget(); - } else { - parserInput.restore('Missing closing \')\''); - } - } else { - parserInput.forget(); - } - } - - if (e) { - return new tree.Element(c, e, e instanceof tree.Variable, index, fileInfo); - } - }, - // - // Combinators combine elements together, in a Selector. - // - // Because our parser isn't white-space sensitive, special care - // has to be taken, when parsing the descendant combinator, ` `, - // as it's an empty space. We have to check the previous character - // in the input, to see if it's a ` ` character. More info on how - // we deal with this in *combinator.js*. - // - combinator: function combinator() { - var c = parserInput.currentChar(); - - if (c === '/') { - parserInput.save(); - var slashedCombinator = parserInput.$re(/^\/[a-z]+\//i); - - if (slashedCombinator) { - parserInput.forget(); - return new tree.Combinator(slashedCombinator); - } - - parserInput.restore(); - } - - if (c === '>' || c === '+' || c === '~' || c === '|' || c === '^') { - parserInput.i++; - - if (c === '^' && parserInput.currentChar() === '^') { - c = '^^'; - parserInput.i++; - } - - while (parserInput.isWhitespace()) { - parserInput.i++; - } - - return new tree.Combinator(c); - } else if (parserInput.isWhitespace(-1)) { - return new tree.Combinator(' '); - } else { - return new tree.Combinator(null); - } - }, - // - // A CSS Selector - // with less extensions e.g. the ability to extend and guard - // - // .class > div + h1 - // li a:hover - // - // Selectors are made out of one or more Elements, see above. - // - selector: function selector(isLess) { - var index = parserInput.i; - var elements; - var extendList; - var c; - var e; - var allExtends; - var when; - var 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'); - } else if (condition) { - error('CSS guard can only be used at the end of selector'); - } else if (extendList) { - if (allExtends) { - allExtends = allExtends.concat(extendList); - } else { - allExtends = extendList; - } - } else { - if (allExtends) { - error('Extend can only be used at the end of selector'); - } - - c = parserInput.currentChar(); - - if (elements) { - elements.push(e); - } else { - elements = [e]; - } - - e = null; - } - - if (c === '{' || c === '}' || c === ';' || c === ',' || c === ')') { - break; - } - } - - if (elements) { - return new tree.Selector(elements, allExtends, condition, index, fileInfo); - } - - if (allExtends) { - error('Extend must be used to extend a selector, it cannot be used on its own'); - } - }, - selectors: function selectors() { - var s; - var selectors; - - while (true) { - s = this.selector(); - - if (!s) { - break; - } - - if (selectors) { - selectors.push(s); - } else { - selectors = [s]; - } - - parserInput.commentStore.length = 0; - - if (s.condition && selectors.length > 1) { - error("Guards are only currently allowed on a single selector."); - } - - if (!parserInput.$char(',')) { - break; - } - - if (s.condition) { - error("Guards are only currently allowed on a single selector."); - } - - parserInput.commentStore.length = 0; - } - - return selectors; - }, - attribute: function attribute() { - if (!parserInput.$char('[')) { - return; - } - - var entities = this.entities; - var key; - var val; - var op; - - if (!(key = entities.variableCurly())) { - key = expect(/^(?:[_A-Za-z0-9-\*]*\|)?(?:[_A-Za-z0-9-]|\\.)+/); - } - - op = parserInput.$re(/^[|~*$^]?=/); - - if (op) { - val = entities.quoted() || parserInput.$re(/^[0-9]+%/) || parserInput.$re(/^[\w-]+/) || entities.variableCurly(); - } - - expectChar(']'); - return new tree.Attribute(key, op, val); - }, - // - // The `block` rule is used by `ruleset` and `mixin.definition`. - // It's a wrapper around the `primary` rule, with added `{}`. - // - block: function block() { - var content; - - if (parserInput.$char('{') && (content = this.primary()) && parserInput.$char('}')) { - return content; - } - }, - blockRuleset: function blockRuleset() { - var block = this.block(); - - if (block) { - block = new tree.Ruleset(null, block); - } - - return block; - }, - detachedRuleset: function detachedRuleset() { - var argInfo; - var params; - var variadic; - parserInput.save(); - - if (parserInput.$re(/^[.#]\(/)) { - /** - * DR args currently only implemented for each() function, and not - * yet settable as `@dr: #(@arg) {}` - * This should be done when DRs are merged with mixins. - * See: https://github.com/less/less-meta/issues/16 - */ - argInfo = this.mixin.args(false); - params = argInfo.args; - variadic = argInfo.variadic; - - if (!parserInput.$char(')')) { - parserInput.restore(); - return; - } - } - - var blockRuleset = this.blockRuleset(); - - if (blockRuleset) { - parserInput.forget(); - - if (params) { - return new tree.mixin.Definition(null, params, blockRuleset, null, variadic); - } - - return new tree.DetachedRuleset(blockRuleset); - } - - parserInput.restore(); - }, - // - // div, .class, body > p {...} - // - ruleset: function ruleset() { - var selectors; - var rules; - var debugInfo; - parserInput.save(); - - if (context.dumpLineNumbers) { - debugInfo = getDebugInfo(parserInput.i); - } - - selectors = this.selectors(); - - if (selectors && (rules = this.block())) { - parserInput.forget(); - var ruleset = new tree.Ruleset(selectors, rules, context.strictImports); - - if (context.dumpLineNumbers) { - ruleset.debugInfo = debugInfo; - } - - return ruleset; - } else { - parserInput.restore(); - } - }, - declaration: function declaration() { - var name; - var value; - var index = parserInput.i; - var hasDR; - var c = parserInput.currentChar(); - var important; - var merge; - var isVariable; - - if (c === '.' || c === '#' || c === '&' || c === ':') { - return; - } - - parserInput.save(); - name = this.variable() || this.ruleProperty(); - - if (name) { - isVariable = typeof name === 'string'; - - if (isVariable) { - value = this.detachedRuleset(); - - if (value) { - hasDR = true; - } - } - - parserInput.commentStore.length = 0; - - if (!value) { - // a name returned by this.ruleProperty() is always an array of the form: - // [string-1, ..., string-n, ""] or [string-1, ..., string-n, "+"] - // where each item is a tree.Keyword or tree.Variable - merge = !isVariable && name.length > 1 && name.pop().value; // Custom property values get permissive parsing - - if (name[0].value && name[0].value.slice(0, 2) === '--') { - value = this.permissiveValue(); - } // Try to store values as anonymous - // If we need the value later we'll re-parse it in ruleset.parseValue - else { - 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, index, fileInfo); - } - - if (!value) { - value = this.value(); - } - - if (value) { - important = this.important(); - } else if (isVariable) { - // As a last resort, try permissiveValue - value = this.permissiveValue(); - } - } - - if (value && (this.end() || hasDR)) { - parserInput.forget(); - return new tree.Declaration(name, value, important, merge, index, fileInfo); - } else { - parserInput.restore(); - } - } else { - parserInput.restore(); - } - }, - anonymousValue: function anonymousValue() { - var index = parserInput.i; - var match = parserInput.$re(/^([^.#@\$+\/'"*`(;{}-]*);/); - - if (match) { - return new tree.Anonymous(match[1], index); - } - }, - - /** - * Used for custom properties, at-rules, and variables (as fallback) - * Parses almost anything inside of {} [] () "" blocks - * until it reaches outer-most tokens. - * - * First, it will try to parse comments and entities to reach - * the end. This is mostly like the Expression parser except no - * math is allowed. - */ - permissiveValue: function permissiveValue(untilTokens) { - var i; - var e; - var done; - var value; - var tok = untilTokens || ';'; - var index = parserInput.i; - var result = []; - - function testCurrentChar() { - var char = parserInput.currentChar(); - - if (typeof tok === 'string') { - return char === tok; - } else { - return tok.test(char); - } - } - - if (testCurrentChar()) { - return; - } - - value = []; - - do { - e = this.comment(); - - if (e) { - value.push(e); - continue; - } - - e = this.entity(); - - if (e) { - value.push(e); - } - } while (e); - - done = testCurrentChar(); - - if (value.length > 0) { - value = new tree.Expression(value); - - if (done) { - return value; - } else { - result.push(value); - } // Preserve space before $parseUntil as it will not - - - if (parserInput.prevChar() === ' ') { - result.push(new tree.Anonymous(' ', index)); - } - } - - parserInput.save(); - value = parserInput.$parseUntil(tok); - - if (value) { - if (typeof value === 'string') { - error(`Expected '${value}'`, 'Parse'); - } - - if (value.length === 1 && value[0] === ' ') { - parserInput.forget(); - return new tree.Anonymous('', index); - } - - var item; - - for (i = 0; i < value.length; i++) { - item = value[i]; - - if (Array.isArray(item)) { - // Treat actual quotes as normal quoted values - result.push(new tree.Quoted(item[0], item[1], true, index, fileInfo)); - } else { - if (i === value.length - 1) { - item = item.trim(); - } // Treat like quoted values, but replace vars like unquoted expressions - - - var quote = new tree.Quoted('\'', item, true, index, fileInfo); - quote.variableRegex = /@([\w-]+)/g; - quote.propRegex = /\$([\w-]+)/g; - result.push(quote); - } - } - - parserInput.forget(); - return new tree.Expression(result, true); - } - - parserInput.restore(); - }, - // - // An @import atrule - // - // @import "lib"; - // - // 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. - // - 'import': function _import() { - var path; - var features; - var index = parserInput.i; - var dir = parserInput.$re(/^@import?\s+/); - - if (dir) { - var options = (dir ? this.importOptions() : null) || {}; - - if (path = this.entities.quoted() || this.entities.url()) { - features = this.mediaFeatures(); - - if (!parserInput.$char(';')) { - parserInput.i = index; - error('missing semi-colon or unrecognised media features on import'); - } - - features = features && new tree.Value(features); - return new tree.Import(path, features, options, index, fileInfo); - } else { - parserInput.i = index; - error('malformed import statement'); - } - } - }, - importOptions: function importOptions() { - var o; - var options = {}; - var optionName; - var value; // list of options, surrounded by parens - - if (!parserInput.$char('(')) { - return null; - } - - do { - o = this.importOption(); - - if (o) { - optionName = o; - value = true; - - switch (optionName) { - case 'css': - optionName = 'less'; - value = false; - break; - - case 'once': - optionName = 'multiple'; - value = false; - break; - } - - options[optionName] = value; - - if (!parserInput.$char(',')) { - break; - } - } - } while (o); - - expectChar(')'); - return options; - }, - importOption: function importOption() { - var opt = parserInput.$re(/^(less|css|multiple|once|inline|reference|optional)/); - - if (opt) { - return opt[1]; - } - }, - mediaFeature: function mediaFeature() { - var entities = this.entities; - var nodes = []; - var e; - var p; - parserInput.save(); - - do { - e = entities.keyword() || entities.variable() || entities.mixinLookup(); - - if (e) { - nodes.push(e); - } else if (parserInput.$char('(')) { - p = this.property(); - e = this.value(); - - if (parserInput.$char(')')) { - if (p && e) { - 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 { - error('badly formed media feature definition'); - } - } else { - error('Missing closing \')\'', 'Parse'); - } - } - } while (e); - - parserInput.forget(); - - if (nodes.length > 0) { - return new tree.Expression(nodes); - } - }, - mediaFeatures: function mediaFeatures() { - var entities = this.entities; - var features = []; - var e; - - do { - e = this.mediaFeature(); - - if (e) { - features.push(e); - - if (!parserInput.$char(',')) { - break; - } - } else { - e = entities.variable() || entities.mixinLookup(); - - if (e) { - features.push(e); - - if (!parserInput.$char(',')) { - break; - } - } - } - } while (e); - - return features.length > 0 ? features : null; - }, - media: function media() { - var features; - var rules; - var media; - var debugInfo; - var index = parserInput.i; - - if (context.dumpLineNumbers) { - debugInfo = getDebugInfo(index); - } - - parserInput.save(); - - if (parserInput.$str('@media')) { - features = this.mediaFeatures(); - rules = this.block(); - - if (!rules) { - error('media definitions require block statements after any features'); - } - - parserInput.forget(); - media = new tree.Media(rules, features, index, fileInfo); - - if (context.dumpLineNumbers) { - media.debugInfo = debugInfo; - } - - return media; - } - - parserInput.restore(); - }, - // - // A @plugin directive, used to import plugins dynamically. - // - // @plugin (args) "lib"; - // - plugin: function plugin() { - var path; - var args; - var options; - var index = parserInput.i; - var dir = parserInput.$re(/^@plugin?\s+/); - - if (dir) { - 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'); - } - - return new tree.Import(path, null, options, index, fileInfo); - } else { - parserInput.i = index; - error('malformed @plugin statement'); - } - } - }, - pluginArgs: function pluginArgs() { - // 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 AtRule - // - // @charset "utf-8"; - // - atrule: function atrule() { - var index = parserInput.i; - var name; - var value; - var rules; - var nonVendorSpecificName; - var hasIdentifier; - var hasExpression; - var hasUnknown; - var hasBlock = true; - var isRooted = true; - - if (parserInput.currentChar() !== '@') { - return; - } - - value = this['import']() || this.plugin() || this.media(); - - if (value) { - return value; - } - - parserInput.save(); - name = parserInput.$re(/^@[a-z-]+/); - - if (!name) { - return; - } - - nonVendorSpecificName = name; - - if (name.charAt(1) == '-' && name.indexOf('-', 2) > 0) { - nonVendorSpecificName = `@${name.slice(name.indexOf('-', 2) + 1)}`; - } - - switch (nonVendorSpecificName) { - case '@charset': - hasIdentifier = true; - hasBlock = false; - break; - - case '@namespace': - hasExpression = true; - hasBlock = false; - break; - - case '@keyframes': - case '@counter-style': - hasIdentifier = true; - break; - - case '@document': - case '@supports': - hasUnknown = true; - isRooted = false; - break; - - default: - hasUnknown = true; - break; - } - - parserInput.commentStore.length = 0; - - if (hasIdentifier) { - value = this.entity(); - - if (!value) { - error(`expected ${name} identifier`); - } - } else if (hasExpression) { - value = this.expression(); - - if (!value) { - error(`expected ${name} expression`); - } - } else if (hasUnknown) { - value = this.permissiveValue(/^[{;]/); - hasBlock = parserInput.currentChar() === '{'; - - if (!value) { - if (!hasBlock && parserInput.currentChar() !== ';') { - error(`${name} rule is missing block or ending semi-colon`); - } - } else if (!value.value) { - value = null; - } - } - - if (hasBlock) { - rules = this.blockRuleset(); - } - - if (rules || !hasBlock && value && parserInput.$char(';')) { - parserInput.forget(); - return new tree.AtRule(name, value, rules, index, fileInfo, context.dumpLineNumbers ? getDebugInfo(index) : null, isRooted); - } - - parserInput.restore('at-rule options not recognised'); - }, - // - // A Value is a comma-delimited list of Expressions - // - // font-family: Baskerville, Georgia, serif; - // - // In a Rule, a Value represents everything after the `:`, - // and before the `;`. - // - value: function value() { - var e; - var expressions = []; - var index = parserInput.i; - - do { - e = this.expression(); - - if (e) { - expressions.push(e); - - if (!parserInput.$char(',')) { - break; - } - } - } while (e); - - if (expressions.length > 0) { - return new tree.Value(expressions, index); - } - }, - important: function important() { - if (parserInput.currentChar() === '!') { - return parserInput.$re(/^! *important/); - } - }, - sub: function sub() { - var a; - var e; - parserInput.save(); - - if (parserInput.$char('(')) { - a = this.addition(); - - if (a && parserInput.$char(')')) { - parserInput.forget(); - e = new tree.Expression([a]); - e.parens = true; - return e; - } - - parserInput.restore('Expected \')\''); - return; - } - - parserInput.restore(); - }, - multiplication: function multiplication() { - var m; - var a; - var op; - var operation; - var isSpaced; - m = this.operand(); - - if (m) { - isSpaced = parserInput.isWhitespace(-1); - - while (true) { - if (parserInput.peek(/^\/[*\/]/)) { - break; - } - - parserInput.save(); - op = parserInput.$char('/') || parserInput.$char('*') || parserInput.$str('./'); - - if (!op) { - parserInput.forget(); - break; - } - - a = this.operand(); - - if (!a) { - parserInput.restore(); - break; - } - - parserInput.forget(); - m.parensInOp = true; - a.parensInOp = true; - operation = new tree.Operation(op, [operation || m, a], isSpaced); - isSpaced = parserInput.isWhitespace(-1); - } - - return operation || m; - } - }, - addition: function addition() { - var m; - var a; - var op; - var operation; - var isSpaced; - m = this.multiplication(); - - if (m) { - isSpaced = parserInput.isWhitespace(-1); - - while (true) { - op = parserInput.$re(/^[-+]\s+/) || !isSpaced && (parserInput.$char('+') || parserInput.$char('-')); - - if (!op) { - break; - } - - a = this.multiplication(); - - if (!a) { - break; - } - - m.parensInOp = true; - a.parensInOp = true; - operation = new tree.Operation(op, [operation || m, a], isSpaced); - isSpaced = parserInput.isWhitespace(-1); - } - - return operation || m; - } - }, - conditions: function conditions() { - var a; - var b; - var index = parserInput.i; - var condition; - a = this.condition(true); - - if (a) { - while (true) { - if (!parserInput.peek(/^,\s*(not\s*)?\(/) || !parserInput.$char(',')) { - break; - } - - b = this.condition(true); - - if (!b) { - break; - } - - condition = new tree.Condition('or', condition || a, b, index); - } - - return condition || a; - } - }, - condition: function condition(needsParens) { - var result; - var logical; - var next; - - function or() { - return parserInput.$str('or'); - } - - result = this.conditionAnd(needsParens); - - if (!result) { - return; - } - - logical = or(); - - if (logical) { - next = this.condition(needsParens); - - if (next) { - result = new tree.Condition(logical, result, next); - } else { - return; - } - } - - return result; - }, - conditionAnd: function conditionAnd(needsParens) { - var result; - var logical; - var next; - var self = this; - - function insideCondition() { - var cond = self.negatedCondition(needsParens) || self.parenthesisCondition(needsParens); - - if (!cond && !needsParens) { - return self.atomicCondition(needsParens); - } - - return cond; - } - - function and() { - return parserInput.$str('and'); - } - - result = insideCondition(); - - if (!result) { - return; - } - - logical = and(); - - if (logical) { - next = this.conditionAnd(needsParens); - - if (next) { - result = new tree.Condition(logical, result, next); - } else { - return; - } - } - - return result; - }, - negatedCondition: function negatedCondition(needsParens) { - if (parserInput.$str('not')) { - var result = this.parenthesisCondition(needsParens); - - if (result) { - result.negate = !result.negate; - } - - return result; - } - }, - parenthesisCondition: function parenthesisCondition(needsParens) { - function tryConditionFollowedByParenthesis(me) { - var body; - parserInput.save(); - body = me.condition(needsParens); - - if (!body) { - parserInput.restore(); - return; - } - - if (!parserInput.$char(')')) { - parserInput.restore(); - return; - } - - parserInput.forget(); - return body; - } - - var body; - parserInput.save(); - - if (!parserInput.$str('(')) { - parserInput.restore(); - return; - } - - body = tryConditionFollowedByParenthesis(this); - - if (body) { - parserInput.forget(); - return body; - } - - body = this.atomicCondition(needsParens); - - if (!body) { - parserInput.restore(); - return; - } - - if (!parserInput.$char(')')) { - parserInput.restore(`expected ')' got '${parserInput.currentChar()}'`); - return; - } - - parserInput.forget(); - return body; - }, - atomicCondition: function atomicCondition(needsParens) { - var entities = this.entities; - var index = parserInput.i; - var a; - var b; - var c; - var op; - - function cond() { - return this.addition() || entities.keyword() || entities.quoted() || entities.mixinLookup(); - } - - cond = cond.bind(this); - a = cond(); - - if (a) { - if (parserInput.$char('>')) { - if (parserInput.$char('=')) { - op = '>='; - } else { - op = '>'; - } - } else if (parserInput.$char('<')) { - if (parserInput.$char('=')) { - op = '<='; - } else { - op = '<'; - } - } else if (parserInput.$char('=')) { - if (parserInput.$char('>')) { - op = '=>'; - } else if (parserInput.$char('<')) { - op = '=<'; - } else { - op = '='; - } - } - - if (op) { - b = cond(); - - if (b) { - c = new tree.Condition(op, a, b, index, false); - } else { - error('expected expression'); - } - } else { - c = new tree.Condition('=', a, new tree.Keyword('true'), index, false); - } - - return c; - } - }, - // - // An operand is anything that can be part of an operation, - // such as a Color, or a Variable - // - operand: function operand() { - var entities = this.entities; - var negate; - - if (parserInput.peek(/^-[@\$\(]/)) { - negate = parserInput.$char('-'); - } - - var o = this.sub() || entities.dimension() || entities.color() || entities.variable() || entities.property() || entities.call() || entities.quoted(true) || entities.colorKeyword() || entities.mixinLookup(); - - if (negate) { - o.parensInOp = true; - o = new tree.Negative(o); - } - - return o; - }, - // - // Expressions either represent mathematical operations, - // or white-space delimited Entities. - // - // 1px solid black - // @var * 2 - // - expression: function expression() { - var entities = []; - var e; - var delim; - var index = parserInput.i; - - do { - e = this.comment(); - - if (e) { - entities.push(e); - continue; - } - - e = this.addition() || this.entity(); - - if (e) { - entities.push(e); // operations do not allow keyword "/" dimension (e.g. small/20px) so we support that here - - if (!parserInput.peek(/^\/[\/*]/)) { - delim = parserInput.$char('/'); - - if (delim) { - entities.push(new tree.Anonymous(delim, index)); - } - } - } - } while (e); - - if (entities.length > 0) { - return new tree.Expression(entities); - } - }, - property: function property() { - var name = parserInput.$re(/^(\*?-?[_a-zA-Z0-9-]+)\s*:/); - - if (name) { - return name[1]; - } - }, - ruleProperty: function ruleProperty() { - var name = []; - var index = []; - var s; - var k; - parserInput.save(); - var simpleProperty = parserInput.$re(/^([_a-zA-Z0-9-]+)\s*:/); - - if (simpleProperty) { - name = [new tree.Keyword(simpleProperty[1])]; - parserInput.forget(); - return name; - } - - function match(re) { - var i = parserInput.i; - var chunk = parserInput.$re(re); - - if (chunk) { - index.push(i); - return name.push(chunk[1]); - } - } - - match(/^(\*?)/); - - while (true) { - if (!match(/^((?:[\w-]+)|(?:[@\$]\{[\w-]+\}))/)) { - break; - } - } - - if (name.length > 1 && match(/^((?:\+_|\+)?)\s*:/)) { - parserInput.forget(); // at last, we have the complete match now. move forward, - // convert name particles to tree objects and return: - - if (name[0] === '') { - name.shift(); - index.shift(); - } - - for (k = 0; k < name.length; k++) { - s = name[k]; - name[k] = s.charAt(0) !== '@' && s.charAt(0) !== '$' ? new tree.Keyword(s) : 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; - } - - parserInput.restore(); - } - } - }; -}; - -Parser.serializeVars = function (vars) { - var s = ''; - - for (var name in vars) { - if (Object.hasOwnProperty.call(vars, name)) { - var value = vars[name]; - s += `${(name[0] === '@' ? '' : '@') + name}: ${value}${String(value).slice(-1) === ';' ? '' : ';'}`; - } - } - - return s; -}; - -function boolean(condition) { - return condition ? Keyword.True : Keyword.False; -} - -function If(condition, trueValue, falseValue) { - return condition ? trueValue : falseValue || new Anonymous(); -} - -var boolean$1 = { - boolean, - 'if': If -}; - -var colorFunctions; - -function clamp$1(val) { - return Math.min(1, Math.max(0, val)); -} - -function hsla(origColor, hsl) { - var color = colorFunctions.hsla(hsl.h, hsl.s, hsl.l, hsl.a); - - if (color) { - if (origColor.value && /^(rgb|hsl)/.test(origColor.value)) { - color.value = origColor.value; - } else { - color.value = 'rgb'; - } - - return color; - } -} - -function toHSL(color) { - if (color.toHSL) { - return color.toHSL(); - } else { - throw new Error('Argument cannot be evaluated to a color'); - } -} - -function toHSV(color) { - if (color.toHSV) { - return color.toHSV(); - } else { - throw new Error('Argument cannot be evaluated to a color'); - } -} - -function number(n) { - if (n instanceof Dimension) { - return parseFloat(n.unit.is('%') ? n.value / 100 : n.value); - } else if (typeof n === 'number') { - return n; - } else { - throw { - type: 'Argument', - message: 'color functions take numbers as parameters' - }; - } -} - -function scaled(n, size) { - if (n instanceof Dimension && n.unit.is('%')) { - return parseFloat(n.value * size / 100); - } else { - return number(n); - } -} - -colorFunctions = { - rgb: function rgb(r, g, b) { - var color = colorFunctions.rgba(r, g, b, 1.0); - - if (color) { - color.value = 'rgb'; - return color; - } - }, - rgba: function rgba(r, g, b, a) { - try { - if (r instanceof Color) { - if (g) { - a = number(g); - } else { - a = r.alpha; - } - - return new Color(r.rgb, a, 'rgba'); - } - - var rgb = [r, g, b].map(function (c) { - return scaled(c, 255); - }); - a = number(a); - return new Color(rgb, a, 'rgba'); - } catch (e) {} - }, - hsl: function hsl(h, s, l) { - var color = colorFunctions.hsla(h, s, l, 1.0); - - if (color) { - color.value = 'hsl'; - return color; - } - }, - hsla: function hsla(h, s, l, a) { - try { - if (h instanceof Color) { - if (s) { - a = number(s); - } else { - a = h.alpha; - } - - return new Color(h.rgb, a, 'hsla'); - } - - var m1; - var m2; - - function hue(h) { - h = h < 0 ? h + 1 : h > 1 ? h - 1 : h; - - if (h * 6 < 1) { - return m1 + (m2 - m1) * h * 6; - } else if (h * 2 < 1) { - return m2; - } else if (h * 3 < 2) { - return m1 + (m2 - m1) * (2 / 3 - h) * 6; - } else { - return m1; - } - } - - h = number(h) % 360 / 360; - s = clamp$1(number(s)); - l = clamp$1(number(l)); - a = clamp$1(number(a)); - m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s; - m1 = l * 2 - m2; - var rgb = [hue(h + 1 / 3) * 255, hue(h) * 255, hue(h - 1 / 3) * 255]; - a = number(a); - return new Color(rgb, a, 'hsla'); - } catch (e) {} - }, - hsv: function hsv(h, s, v) { - return colorFunctions.hsva(h, s, v, 1.0); - }, - hsva: function hsva(h, s, v, a) { - h = number(h) % 360 / 360 * 360; - s = number(s); - v = number(v); - a = number(a); - var i; - var f; - i = Math.floor(h / 60 % 6); - f = h / 60 - i; - var vs = [v, v * (1 - s), v * (1 - f * s), v * (1 - (1 - f) * s)]; - var perm = [[0, 3, 1], [2, 0, 1], [1, 0, 3], [1, 2, 0], [3, 1, 0], [0, 1, 2]]; - return colorFunctions.rgba(vs[perm[i][0]] * 255, vs[perm[i][1]] * 255, vs[perm[i][2]] * 255, a); - }, - hue: function hue(color) { - return new Dimension(toHSL(color).h); - }, - saturation: function saturation(color) { - return new Dimension(toHSL(color).s * 100, '%'); - }, - lightness: function lightness(color) { - return new Dimension(toHSL(color).l * 100, '%'); - }, - hsvhue: function hsvhue(color) { - return new Dimension(toHSV(color).h); - }, - hsvsaturation: function hsvsaturation(color) { - return new Dimension(toHSV(color).s * 100, '%'); - }, - hsvvalue: function hsvvalue(color) { - return new Dimension(toHSV(color).v * 100, '%'); - }, - red: function red(color) { - return new Dimension(color.rgb[0]); - }, - green: function green(color) { - return new Dimension(color.rgb[1]); - }, - blue: function blue(color) { - return new Dimension(color.rgb[2]); - }, - alpha: function alpha(color) { - return new Dimension(toHSL(color).a); - }, - luma: function luma(color) { - return new Dimension(color.luma() * color.alpha * 100, '%'); - }, - luminance: function luminance(color) { - var luminance = 0.2126 * color.rgb[0] / 255 + 0.7152 * color.rgb[1] / 255 + 0.0722 * color.rgb[2] / 255; - return new Dimension(luminance * color.alpha * 100, '%'); - }, - saturate: function saturate(color, amount, method) { - // filter: saturate(3.2); - // should be kept as is, so check for color - if (!color.rgb) { - return null; - } - - var hsl = toHSL(color); - - if (typeof method !== 'undefined' && method.value === 'relative') { - hsl.s += hsl.s * amount.value / 100; - } else { - hsl.s += amount.value / 100; - } - - hsl.s = clamp$1(hsl.s); - return hsla(color, hsl); - }, - desaturate: function desaturate(color, amount, method) { - var hsl = toHSL(color); - - if (typeof method !== 'undefined' && method.value === 'relative') { - hsl.s -= hsl.s * amount.value / 100; - } else { - hsl.s -= amount.value / 100; - } - - hsl.s = clamp$1(hsl.s); - return hsla(color, hsl); - }, - lighten: function lighten(color, amount, method) { - var hsl = toHSL(color); - - if (typeof method !== 'undefined' && method.value === 'relative') { - hsl.l += hsl.l * amount.value / 100; - } else { - hsl.l += amount.value / 100; - } - - hsl.l = clamp$1(hsl.l); - return hsla(color, hsl); - }, - darken: function darken(color, amount, method) { - var hsl = toHSL(color); - - if (typeof method !== 'undefined' && method.value === 'relative') { - hsl.l -= hsl.l * amount.value / 100; - } else { - hsl.l -= amount.value / 100; - } - - hsl.l = clamp$1(hsl.l); - return hsla(color, hsl); - }, - fadein: function fadein(color, amount, method) { - var hsl = toHSL(color); - - if (typeof method !== 'undefined' && method.value === 'relative') { - hsl.a += hsl.a * amount.value / 100; - } else { - hsl.a += amount.value / 100; - } - - hsl.a = clamp$1(hsl.a); - return hsla(color, hsl); - }, - fadeout: function fadeout(color, amount, method) { - var hsl = toHSL(color); - - if (typeof method !== 'undefined' && method.value === 'relative') { - hsl.a -= hsl.a * amount.value / 100; - } else { - hsl.a -= amount.value / 100; - } - - hsl.a = clamp$1(hsl.a); - return hsla(color, hsl); - }, - fade: function fade(color, amount) { - var hsl = toHSL(color); - hsl.a = amount.value / 100; - hsl.a = clamp$1(hsl.a); - return hsla(color, hsl); - }, - spin: function spin(color, amount) { - var hsl = toHSL(color); - var hue = (hsl.h + amount.value) % 360; - hsl.h = hue < 0 ? 360 + hue : hue; - return hsla(color, hsl); - }, - // - // Copyright (c) 2006-2009 Hampton Catlin, Natalie Weizenbaum, and Chris Eppstein - // http://sass-lang.com - // - mix: function mix(color1, color2, weight) { - if (!weight) { - weight = new Dimension(50); - } - - var p = weight.value / 100.0; - var w = p * 2 - 1; - var a = toHSL(color1).a - toHSL(color2).a; - var w1 = ((w * a == -1 ? w : (w + a) / (1 + w * a)) + 1) / 2.0; - var w2 = 1 - w1; - var rgb = [color1.rgb[0] * w1 + color2.rgb[0] * w2, color1.rgb[1] * w1 + color2.rgb[1] * w2, color1.rgb[2] * w1 + color2.rgb[2] * w2]; - var alpha = color1.alpha * p + color2.alpha * (1 - p); - return new Color(rgb, alpha); - }, - greyscale: function greyscale(color) { - return colorFunctions.desaturate(color, new Dimension(100)); - }, - contrast: function contrast(color, dark, light, threshold) { - // filter: contrast(3.2); - // should be kept as is, so check for color - if (!color.rgb) { - return null; - } - - if (typeof light === 'undefined') { - light = colorFunctions.rgba(255, 255, 255, 1.0); - } - - if (typeof dark === 'undefined') { - dark = colorFunctions.rgba(0, 0, 0, 1.0); - } // Figure out which is actually light and dark: - - - if (dark.luma() > light.luma()) { - var t = light; - light = dark; - dark = t; - } - - if (typeof threshold === 'undefined') { - threshold = 0.43; - } else { - threshold = number(threshold); - } - - if (color.luma() < threshold) { - return light; - } else { - 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 argb(color) { - return new Anonymous(color.toARGB()); - }, - color: function color(c) { - if (c instanceof Quoted && /^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3,4})$/i.test(c.value)) { - var val = c.value.slice(1); - return new Color(val, undefined, `#${val}`); - } - - if (c instanceof Color || (c = Color.fromKeyword(c.value))) { - c.value = undefined; - return c; - } - - throw { - type: 'Argument', - message: 'argument must be a color keyword or 3|4|6|8 digit hex e.g. #FFF' - }; - }, - tint: function tint(color, amount) { - return colorFunctions.mix(colorFunctions.rgb(255, 255, 255), color, amount); - }, - shade: function shade(color, amount) { - return colorFunctions.mix(colorFunctions.rgb(0, 0, 0), color, amount); - } -}; -var color = colorFunctions; - -// ref: http://www.w3.org/TR/compositing-1 - -function colorBlend(mode, color1, color2) { - var ab = color1.alpha; // result - - var // backdrop - cb; - var as = color2.alpha; - var // source - cs; - var ar; - var cr; - var r = []; - ar = as + ab * (1 - as); - - for (var i = 0; i < 3; i++) { - cb = color1.rgb[i] / 255; - cs = color2.rgb[i] / 255; - cr = mode(cb, cs); - - if (ar) { - cr = (as * cs + ab * (cb - as * (cb + cs - cr))) / ar; - } - - r[i] = cr * 255; - } - - return new Color(r, ar); -} - -var colorBlendModeFunctions = { - multiply: function multiply(cb, cs) { - return cb * cs; - }, - screen: function screen(cb, cs) { - return cb + cs - cb * cs; - }, - overlay: function overlay(cb, cs) { - cb *= 2; - return cb <= 1 ? colorBlendModeFunctions.multiply(cb, cs) : colorBlendModeFunctions.screen(cb - 1, cs); - }, - softlight: function softlight(cb, cs) { - var d = 1; - var e = cb; - - if (cs > 0.5) { - e = 1; - d = cb > 0.25 ? Math.sqrt(cb) : ((16 * cb - 12) * cb + 4) * cb; - } - - return cb - (1 - 2 * cs) * e * (d - cb); - }, - hardlight: function hardlight(cb, cs) { - return colorBlendModeFunctions.overlay(cs, cb); - }, - difference: function difference(cb, cs) { - return Math.abs(cb - cs); - }, - exclusion: function exclusion(cb, cs) { - return cb + cs - 2 * cb * cs; - }, - // non-w3c functions: - average: function average(cb, cs) { - return (cb + cs) / 2; - }, - negation: function negation(cb, cs) { - return 1 - Math.abs(cb + cs - 1); - } -}; - -for (var f in colorBlendModeFunctions) { - if (colorBlendModeFunctions.hasOwnProperty(f)) { - colorBlend[f] = colorBlend.bind(null, colorBlendModeFunctions[f]); - } -} - -var dataUri = (function (environment) { - var fallback = function fallback(functionThis, node) { - return new URL(node, functionThis.index, functionThis.currentFileInfo).eval(functionThis.context); - }; - - return { - 'data-uri': function dataUri(mimetypeNode, filePathNode) { - if (!filePathNode) { - filePathNode = mimetypeNode; - mimetypeNode = null; - } - - var mimetype = mimetypeNode && mimetypeNode.value; - var filePath = filePathNode.value; - var currentFileInfo = this.currentFileInfo; - var currentDirectory = currentFileInfo.rewriteUrls ? currentFileInfo.currentDirectory : currentFileInfo.entryPath; - var fragmentStart = filePath.indexOf('#'); - var fragment = ''; - - if (fragmentStart !== -1) { - fragment = filePath.slice(fragmentStart); - filePath = filePath.slice(0, fragmentStart); - } - - var context = clone(this.context); - context.rawBuffer = true; - var fileManager = environment.getFileManager(filePath, currentDirectory, context, environment, true); - - if (!fileManager) { - return fallback(this, filePathNode); - } - - var useBase64 = false; // detect the mimetype if not given - - if (!mimetypeNode) { - mimetype = environment.mimeLookup(filePath); - - if (mimetype === 'image/svg+xml') { - useBase64 = false; - } else { - // use base 64 unless it's an ASCII or UTF-8 format - var charset = environment.charsetLookup(mimetype); - useBase64 = ['US-ASCII', 'UTF-8'].indexOf(charset) < 0; - } - - if (useBase64) { - mimetype += ';base64'; - } - } else { - useBase64 = /;base64$/.test(mimetype); - } - - 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); - } - - var buf = fileSync.contents; - - if (useBase64 && !environment.encodeBase64) { - return fallback(this, filePathNode); - } - - buf = useBase64 ? environment.encodeBase64(buf) : encodeURIComponent(buf); - var uri = `data:${mimetype},${buf}${fragment}`; - return new URL(new Quoted(`"${uri}"`, uri, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo); - } - }; -}); - -var getItemsFromNode = function getItemsFromNode(node) { - // handle non-array values as an array of length 1 - // return 'undefined' if index is invalid - var items = Array.isArray(node.value) ? node.value : Array(node); - return items; -}; - -var list = { - _SELF: function _SELF(n) { - return n; - }, - extract: function extract(values, index) { - // (1-based index) - index = index.value - 1; - return getItemsFromNode(values)[index]; - }, - length: function length(values) { - return new Dimension(getItemsFromNode(values).length); - }, - - /** - * Creates a Less list of incremental values. - * Modeled after Lodash's range function, also exists natively in PHP - * - * @param {Dimension} [start=1] - * @param {Dimension} end - e.g. 10 or 10px - unit is added to output - * @param {Dimension} [step=1] - */ - range: function range(start, end, step) { - var from; - var to; - var stepValue = 1; - var list = []; - - if (end) { - to = end; - from = start.value; - - if (step) { - stepValue = step.value; - } - } else { - from = 1; - to = start; - } - - for (var i = from; i <= to.value; i += stepValue) { - list.push(new Dimension(i, to.unit)); - } - - return new Expression(list); - }, - each: function each(list, rs) { - var rules = []; - var newRules; - var iterator; - - if (list.value && !(list instanceof Quoted)) { - if (Array.isArray(list.value)) { - iterator = list.value; - } else { - iterator = [list.value]; - } - } else if (list.ruleset) { - iterator = list.ruleset.rules; - } else if (list.rules) { - iterator = list.rules; - } else if (Array.isArray(list)) { - iterator = list; - } else { - iterator = [list]; - } - - var valueName = '@value'; - var keyName = '@key'; - var indexName = '@index'; - - if (rs.params) { - valueName = rs.params[0] && rs.params[0].name; - keyName = rs.params[1] && rs.params[1].name; - indexName = rs.params[2] && rs.params[2].name; - rs = rs.rules; - } else { - rs = rs.ruleset; - } - - for (var i = 0; i < iterator.length; i++) { - var key = void 0; - var value = void 0; - var item = iterator[i]; - - if (item instanceof Declaration) { - key = typeof item.name === 'string' ? item.name : item.name[0].value; - value = item.value; - } else { - key = new Dimension(i + 1); - value = item; - } - - if (item instanceof Comment) { - continue; - } - - newRules = rs.rules.slice(0); - - if (valueName) { - newRules.push(new Declaration(valueName, value, false, false, this.index, this.currentFileInfo)); - } - - if (indexName) { - newRules.push(new Declaration(indexName, new Dimension(i + 1), false, false, this.index, this.currentFileInfo)); - } - - if (keyName) { - newRules.push(new Declaration(keyName, key, false, false, this.index, this.currentFileInfo)); - } - - rules.push(new Ruleset([new Selector([new Element("", '&')])], newRules, rs.strictImports, rs.visibilityInfo())); - } - - return new Ruleset([new Selector([new Element("", '&')])], rules, rs.strictImports, rs.visibilityInfo()).eval(this.context); - } -}; - -var MathHelper = function MathHelper(fn, unit, n) { - if (!(n instanceof Dimension)) { - throw { - type: 'Argument', - message: 'argument must be a number' - }; - } - - if (unit == null) { - unit = n.unit; - } else { - n = n.unify(); - } - - return new Dimension(fn(parseFloat(n.value)), unit); -}; - -var mathFunctions = { - // name, unit - ceil: null, - floor: null, - sqrt: null, - abs: null, - tan: '', - sin: '', - cos: '', - atan: 'rad', - asin: 'rad', - acos: 'rad' -}; - -for (var f$1 in mathFunctions) { - if (mathFunctions.hasOwnProperty(f$1)) { - mathFunctions[f$1] = MathHelper.bind(null, Math[f$1], mathFunctions[f$1]); - } -} - -mathFunctions.round = function (n, f) { - var fraction = typeof f === 'undefined' ? 0 : f.value; - return MathHelper(function (num) { - return num.toFixed(fraction); - }, null, n); -}; - -var minMax = function minMax(isMin, args) { - args = Array.prototype.slice.call(args); - - switch (args.length) { - case 0: - throw { - type: 'Argument', - message: 'one or more arguments required' - }; - } - - var i; // key is the unit.toString() for unified Dimension values, - - var j; - var current; - var currentUnified; - var referenceUnified; - var unit; - var unitStatic; - var unitClone; - var // elems only contains original argument values. - order = []; - var values = {}; // value is the index into the order array. - - for (i = 0; i < args.length; i++) { - current = args[i]; - - if (!(current instanceof Dimension)) { - if (Array.isArray(args[i].value)) { - Array.prototype.push.apply(args, Array.prototype.slice.call(args[i].value)); - } - - continue; - } - - currentUnified = current.unit.toString() === '' && unitClone !== undefined ? new Dimension(current.value, unitClone).unify() : current.unify(); - unit = currentUnified.unit.toString() === '' && unitStatic !== undefined ? unitStatic : currentUnified.unit.toString(); - unitStatic = unit !== '' && unitStatic === undefined || unit !== '' && order[0].unify().unit.toString() === '' ? unit : unitStatic; - unitClone = unit !== '' && unitClone === undefined ? current.unit.toString() : unitClone; - j = values[''] !== undefined && unit !== '' && unit === unitStatic ? values[''] : values[unit]; - - if (j === undefined) { - if (unitStatic !== undefined && unit !== unitStatic) { - throw { - type: 'Argument', - message: 'incompatible types' - }; - } - - values[unit] = order.length; - order.push(current); - continue; - } - - referenceUnified = order[j].unit.toString() === '' && unitClone !== undefined ? new Dimension(order[j].value, unitClone).unify() : order[j].unify(); - - if (isMin && currentUnified.value < referenceUnified.value || !isMin && currentUnified.value > referenceUnified.value) { - order[j] = current; - } - } - - if (order.length == 1) { - return order[0]; - } - - args = order.map(function (a) { - return a.toCSS(this.context); - }).join(this.context.compress ? ',' : ', '); - return new Anonymous(`${isMin ? 'min' : 'max'}(${args})`); -}; - -var number$1 = { - min: function min() { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return minMax(true, args); - }, - max: function max() { - for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - return minMax(false, args); - }, - convert: function convert(val, unit) { - return val.convertTo(unit.value); - }, - pi: function pi() { - return new Dimension(Math.PI); - }, - mod: function mod(a, b) { - return new Dimension(a.value % b.value, a.unit); - }, - pow: function pow(x, y) { - if (typeof x === 'number' && typeof y === 'number') { - x = new Dimension(x); - y = new Dimension(y); - } else if (!(x instanceof Dimension) || !(y instanceof Dimension)) { - throw { - type: 'Argument', - message: 'arguments must be numbers' - }; - } - - return new Dimension(Math.pow(x.value, y.value), x.unit); - }, - percentage: function percentage(n) { - var result = MathHelper(function (num) { - return num * 100; - }, '%', n); - return result; - } -}; - -var string = { - e: function e(str) { - return new Quoted('"', str instanceof JavaScript ? str.evaluated : str.value, true); - }, - escape: function escape(str) { - return new Anonymous(encodeURI(str.value).replace(/=/g, '%3D').replace(/:/g, '%3A').replace(/#/g, '%23').replace(/;/g, '%3B').replace(/\(/g, '%28').replace(/\)/g, '%29')); - }, - replace: function replace(string, pattern, replacement, flags) { - var result = string.value; - replacement = replacement.type === 'Quoted' ? replacement.value : replacement.toCSS(); - result = result.replace(new RegExp(pattern.value, flags ? flags.value : ''), replacement); - return new Quoted(string.quote || '', result, string.escaped); - }, - '%': function _(string - /* arg, arg, ... */ - ) { - var args = Array.prototype.slice.call(arguments, 1); - var result = string.value; - - var _loop = function _loop(i) { - /* 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(); - return token.match(/[A-Z]$/) ? encodeURIComponent(value) : value; - }); - }; - - for (var i = 0; i < args.length; i++) { - _loop(i); - } - - result = result.replace(/%%/g, '%'); - return new Quoted(string.quote || '', result, string.escaped); - } -}; - -var svg = (function (environment) { - return { - 'svg-gradient': function svgGradient(direction) { - var stops; - var gradientDirectionSvg; - var gradientType = 'linear'; - var rectangleDimension = 'x="0" y="0" width="1" height="1"'; - var renderEnv = { - compress: false - }; - var returner; - var directionValue = direction.toCSS(renderEnv); - var i; - var color; - var position; - var positionValue; - var 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' - }; - } - - if (arguments.length == 2) { - if (arguments[1].value.length < 2) { - throwArgumentDescriptor(); - } - - stops = arguments[1].value; - } else if (arguments.length < 3) { - throwArgumentDescriptor(); - } else { - stops = Array.prototype.slice.call(arguments, 1); - } - - switch (directionValue) { - case 'to bottom': - gradientDirectionSvg = 'x1="0%" y1="0%" x2="0%" y2="100%"'; - break; - - case 'to right': - gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="0%"'; - break; - - case 'to bottom right': - gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="100%"'; - break; - - case 'to top right': - gradientDirectionSvg = 'x1="0%" y1="100%" x2="100%" y2="0%"'; - break; - - case 'ellipse': - case 'ellipse at center': - gradientType = 'radial'; - gradientDirectionSvg = 'cx="50%" cy="50%" r="75%"'; - rectangleDimension = 'x="-50" y="-50" width="101" height="101"'; - break; - - default: - throw { - type: 'Argument', - message: 'svg-gradient direction must be \'to bottom\', \'to right\',' + ' \'to bottom right\', \'to top right\' or \'ellipse at center\'' - }; - } - - returner = `<${gradientType}Gradient id="g" ${gradientDirectionSvg}>`; - - for (i = 0; i < stops.length; i += 1) { - if (stops[i] instanceof Expression) { - color = stops[i].value[0]; - position = stops[i].value[1]; - } else { - color = stops[i]; - position = undefined; - } - - if (!(color instanceof Color) || !((i === 0 || i + 1 === stops.length) && position === undefined) && !(position instanceof Dimension)) { - throwArgumentDescriptor(); - } - - positionValue = position ? position.toCSS(renderEnv) : i === 0 ? '0%' : '100%'; - alpha = color.alpha; - returner += ``; - } - - returner += ``; - returner = encodeURIComponent(returner); - returner = `data:image/svg+xml,${returner}`; - return new URL(new Quoted(`'${returner}'`, returner, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo); - } - }; -}); - -var isa = function isa(n, Type) { - return n instanceof Type ? Keyword.True : Keyword.False; -}; - -var isunit = function isunit(n, unit) { - if (unit === undefined) { - throw { - type: 'Argument', - message: 'missing the required second argument to isunit.' - }; - } - - unit = typeof unit.value === 'string' ? unit.value : unit; - - if (typeof unit !== 'string') { - throw { - type: 'Argument', - message: 'Second argument to isunit should be a unit or a string.' - }; - } - - return n instanceof Dimension && n.unit.is(unit) ? Keyword.True : Keyword.False; -}; - -var types = { - isruleset: function isruleset(n) { - return isa(n, DetachedRuleset); - }, - iscolor: function iscolor(n) { - return isa(n, Color); - }, - isnumber: function isnumber(n) { - return isa(n, Dimension); - }, - isstring: function isstring(n) { - return isa(n, Quoted); - }, - iskeyword: function iskeyword(n) { - return isa(n, Keyword); - }, - isurl: function isurl(n) { - return isa(n, URL); - }, - ispixel: function ispixel(n) { - return isunit(n, 'px'); - }, - ispercentage: function ispercentage(n) { - return isunit(n, '%'); - }, - isem: function isem(n) { - return isunit(n, 'em'); - }, - isunit, - unit: function unit(val, _unit) { - if (!(val instanceof Dimension)) { - throw { - type: 'Argument', - message: `the first argument to unit must be a number${val instanceof Operation ? '. Have you forgotten parenthesis?' : ''}` - }; - } - - if (_unit) { - if (_unit instanceof Keyword) { - _unit = _unit.value; - } else { - _unit = _unit.toCSS(); - } - } else { - _unit = ''; - } - - return new Dimension(val.value, _unit); - }, - 'get-unit': function getUnit(n) { - return new Anonymous(n.unit); - } -}; - -var Functions = (function (environment) { - var functions = { - functionRegistry, - functionCaller - }; // register functions - - functionRegistry.addMultiple(boolean$1); - functionRegistry.add('default', defaultFunc.eval.bind(defaultFunc)); - functionRegistry.addMultiple(color); - functionRegistry.addMultiple(colorBlend); - functionRegistry.addMultiple(dataUri(environment)); - functionRegistry.addMultiple(list); - functionRegistry.addMultiple(mathFunctions); - functionRegistry.addMultiple(number$1); - functionRegistry.addMultiple(string); - functionRegistry.addMultiple(svg()); - functionRegistry.addMultiple(types); - return functions; -}); - -var sourceMapOutput = (function (environment) { - var SourceMapOutput = - /*#__PURE__*/ - function () { - function SourceMapOutput(options) { - _classCallCheck(this, SourceMapOutput); - - this._css = []; - this._rootNode = options.rootNode; - this._contentsMap = options.contentsMap; - this._contentsIgnoredCharsMap = options.contentsIgnoredCharsMap; - - if (options.sourceMapFilename) { - this._sourceMapFilename = options.sourceMapFilename.replace(/\\/g, '/'); - } - - this._outputFilename = options.outputFilename; - this.sourceMapURL = options.sourceMapURL; - - if (options.sourceMapBasepath) { - this._sourceMapBasepath = options.sourceMapBasepath.replace(/\\/g, '/'); - } - - if (options.sourceMapRootpath) { - this._sourceMapRootpath = options.sourceMapRootpath.replace(/\\/g, '/'); - - if (this._sourceMapRootpath.charAt(this._sourceMapRootpath.length - 1) !== '/') { - this._sourceMapRootpath += '/'; - } - } else { - this._sourceMapRootpath = ''; - } - - this._outputSourceFiles = options.outputSourceFiles; - this._sourceMapGeneratorConstructor = environment.getSourceMapGenerator(); - this._lineNumber = 0; - this._column = 0; - } - - _createClass(SourceMapOutput, [{ - key: "removeBasepath", - value: function removeBasepath(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; - } - }, { - key: "normalizeFilename", - value: function normalizeFilename(filename) { - filename = filename.replace(/\\/g, '/'); - filename = this.removeBasepath(filename); - return (this._sourceMapRootpath || '') + filename; - } - }, { - key: "add", - value: function add(chunk, fileInfo, index, mapLines) { - // ignore adding empty strings - if (!chunk) { - return; - } - - var lines; - var sourceLines; - var columns; - var sourceColumns; - var i; - - if (fileInfo && fileInfo.filename) { - var inputSource = this._contentsMap[fileInfo.filename]; // remove vars/banner added to the top of the file - - if (this._contentsIgnoredCharsMap[fileInfo.filename]) { - // adjust the index - index -= this._contentsIgnoredCharsMap[fileInfo.filename]; - - if (index < 0) { - index = 0; - } // adjust the source - - - inputSource = inputSource.slice(this._contentsIgnoredCharsMap[fileInfo.filename]); - } // ignore empty content - - - if (inputSource === undefined) { - return; - } - - inputSource = inputSource.substring(0, index); - sourceLines = inputSource.split('\n'); - sourceColumns = sourceLines[sourceLines.length - 1]; - } - - lines = chunk.split('\n'); - columns = lines[lines.length - 1]; - - if (fileInfo && fileInfo.filename) { - if (!mapLines) { - this._sourceMapGenerator.addMapping({ - generated: { - line: this._lineNumber + 1, - column: this._column - }, - original: { - line: sourceLines.length, - column: sourceColumns.length - }, - source: this.normalizeFilename(fileInfo.filename) - }); - } else { - for (i = 0; i < lines.length; i++) { - this._sourceMapGenerator.addMapping({ - generated: { - line: this._lineNumber + i + 1, - column: i === 0 ? this._column : 0 - }, - original: { - line: sourceLines.length + i, - column: i === 0 ? sourceColumns.length : 0 - }, - source: this.normalizeFilename(fileInfo.filename) - }); - } - } - } - - if (lines.length === 1) { - this._column += columns.length; - } else { - this._lineNumber += lines.length - 1; - this._column = columns.length; - } - - this._css.push(chunk); - } - }, { - key: "isEmpty", - value: function isEmpty() { - return this._css.length === 0; - } - }, { - key: "toCSS", - value: function toCSS(context) { - this._sourceMapGenerator = new this._sourceMapGeneratorConstructor({ - file: this._outputFilename, - sourceRoot: null - }); - - if (this._outputSourceFiles) { - for (var filename in this._contentsMap) { - if (this._contentsMap.hasOwnProperty(filename)) { - var source = this._contentsMap[filename]; - - if (this._contentsIgnoredCharsMap[filename]) { - source = source.slice(this._contentsIgnoredCharsMap[filename]); - } - - this._sourceMapGenerator.setSourceContent(this.normalizeFilename(filename), source); - } - } - } - - this._rootNode.genCSS(context, this); - - if (this._css.length > 0) { - var sourceMapURL; - var sourceMapContent = JSON.stringify(this._sourceMapGenerator.toJSON()); - - if (this.sourceMapURL) { - sourceMapURL = this.sourceMapURL; - } else if (this._sourceMapFilename) { - sourceMapURL = this._sourceMapFilename; - } - - this.sourceMapURL = sourceMapURL; - this.sourceMap = sourceMapContent; - } - - return this._css.join(''); - } - }]); - - return SourceMapOutput; - }(); - - return SourceMapOutput; -}); - -var sourceMapBuilder = (function (SourceMapOutput, environment) { - var SourceMapBuilder = - /*#__PURE__*/ - function () { - function SourceMapBuilder(options) { - _classCallCheck(this, SourceMapBuilder); - - this.options = options; - } - - _createClass(SourceMapBuilder, [{ - key: "toCSS", - value: function toCSS(rootNode, options, imports) { - var sourceMapOutput = new SourceMapOutput({ - contentsIgnoredCharsMap: imports.contentsIgnoredChars, - rootNode, - contentsMap: imports.contents, - sourceMapFilename: this.options.sourceMapFilename, - sourceMapURL: this.options.sourceMapURL, - outputFilename: this.options.sourceMapOutputFilename, - sourceMapBasepath: this.options.sourceMapBasepath, - sourceMapRootpath: this.options.sourceMapRootpath, - outputSourceFiles: this.options.outputSourceFiles, - sourceMapGenerator: this.options.sourceMapGenerator, - sourceMapFileInline: this.options.sourceMapFileInline - }); - var css = sourceMapOutput.toCSS(options); - this.sourceMap = sourceMapOutput.sourceMap; - this.sourceMapURL = sourceMapOutput.sourceMapURL; - - 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(); - } - }, { - key: "getCSSAppendage", - value: function getCSSAppendage() { - var sourceMapURL = this.sourceMapURL; - - if (this.options.sourceMapFileInline) { - if (this.sourceMap === undefined) { - return ''; - } - - sourceMapURL = `data:application/json;base64,${environment.encodeBase64(this.sourceMap)}`; - } - - if (sourceMapURL) { - return `/*# sourceMappingURL=${sourceMapURL} */`; - } - - return ''; - } - }, { - key: "getExternalSourceMap", - value: function getExternalSourceMap() { - return this.sourceMap; - } - }, { - key: "setExternalSourceMap", - value: function setExternalSourceMap(sourceMap) { - this.sourceMap = sourceMap; - } - }, { - key: "isInline", - value: function isInline() { - return this.options.sourceMapFileInline; - } - }, { - key: "getSourceMapURL", - value: function getSourceMapURL() { - return this.sourceMapURL; - } - }, { - key: "getOutputFilename", - value: function getOutputFilename() { - return this.options.sourceMapOutputFilename; - } - }, { - key: "getInputFilename", - value: function getInputFilename() { - return this.sourceMapInputFilename; - } - }]); - - return SourceMapBuilder; - }(); - - return SourceMapBuilder; -}); - -var transformTree = (function (root) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var evaldRoot; - var variables = options.variables; - var evalEnv = new contexts.Eval(options); // - // Allows setting variables with a hash, so: - // - // `{ color: new tree.Color('#f01') }` will become: - // - // new tree.Declaration('@color', - // new tree.Value([ - // new tree.Expression([ - // new tree.Color('#f01') - // ]) - // ]) - // ) - // - - if (typeof variables === 'object' && !Array.isArray(variables)) { - variables = Object.keys(variables).map(function (k) { - var value = variables[k]; - - if (!(value instanceof tree.Value)) { - if (!(value instanceof tree.Expression)) { - value = new tree.Expression([value]); - } - - value = new tree.Value([value]); - } - - return new tree.Declaration(`@${k}`, value, false, null, 0); - }); - evalEnv.frames = [new tree.Ruleset(null, variables)]; - } - - var visitors$1 = [new visitors.JoinSelectorVisitor(), new visitors.MarkVisibleSelectorsVisitor(true), new visitors.ExtendVisitor(), new visitors.ToCSSVisitor({ - compress: Boolean(options.compress) - })]; - var preEvalVisitors = []; - var v; - var visitorIterator; - /** - * first() / get() allows visitors to be added while visiting - * - * @todo Add scoping for visitors just like functions for @plugin; right now they're global - */ - - if (options.pluginManager) { - visitorIterator = options.pluginManager.visitor(); - - for (var i = 0; i < 2; i++) { - visitorIterator.first(); - - while (v = visitorIterator.get()) { - if (v.isPreEvalVisitor) { - if (i === 0 || preEvalVisitors.indexOf(v) === -1) { - preEvalVisitors.push(v); - v.run(root); - } - } else { - if (i === 0 || visitors$1.indexOf(v) === -1) { - if (v.isPreVisitor) { - visitors$1.unshift(v); - } else { - visitors$1.push(v); - } - } - } - } - } - } - - evaldRoot = root.eval(evalEnv); - - for (var i = 0; i < visitors$1.length; i++) { - visitors$1[i].run(evaldRoot); - } // Run any remaining visitors added after eval pass - - - if (options.pluginManager) { - visitorIterator.first(); - - while (v = visitorIterator.get()) { - if (visitors$1.indexOf(v) === -1 && preEvalVisitors.indexOf(v) === -1) { - v.run(evaldRoot); - } - } - } - - return evaldRoot; -}); - -var parseTree = (function (SourceMapBuilder) { - var ParseTree = - /*#__PURE__*/ - function () { - function ParseTree(root, imports) { - _classCallCheck(this, ParseTree); - - this.root = root; - this.imports = imports; - } - - _createClass(ParseTree, [{ - key: "toCSS", - value: function toCSS(options) { - var evaldRoot; - var result = {}; - var sourceMapBuilder; - - try { - evaldRoot = transformTree(this.root, options); - } catch (e) { - throw new LessError(e, this.imports); - } - - try { - var compress = Boolean(options.compress); - - if (compress) { - logger.warn('The compress option has been deprecated. ' + 'We recommend you use a dedicated css minifier, for instance see less-plugin-clean-css.'); - } - - var toCSSOptions = { - compress, - dumpLineNumbers: options.dumpLineNumbers, - strictUnits: Boolean(options.strictUnits), - numPrecision: 8 - }; - - if (options.sourceMap) { - sourceMapBuilder = new SourceMapBuilder(options.sourceMap); - result.css = sourceMapBuilder.toCSS(evaldRoot, toCSSOptions, this.imports); - } else { - result.css = evaldRoot.toCSS(toCSSOptions); - } - } catch (e) { - throw new LessError(e, this.imports); - } - - if (options.pluginManager) { - var postProcessors = options.pluginManager.getPostProcessors(); - - for (var i = 0; i < postProcessors.length; i++) { - result.css = postProcessors[i].process(result.css, { - sourceMap: sourceMapBuilder, - options, - imports: this.imports - }); - } - } - - if (options.sourceMap) { - result.map = sourceMapBuilder.getExternalSourceMap(); - } - - result.imports = []; - - for (var file in this.imports.files) { - if (this.imports.files.hasOwnProperty(file) && file !== this.imports.rootFilename) { - result.imports.push(file); - } - } - - return result; - } - }]); - - return ParseTree; - }(); - - return ParseTree; -}); - -var importManager = (function (environment) { - // FileInfo = { - // 'rewriteUrls' - option - whether to adjust URL's to be relative - // 'filename' - full resolved filename of current file - // 'rootpath' - path to append to normal URLs for this node - // 'currentDirectory' - path to the current file, absolute - // 'rootFilename' - filename of the base file - // 'entryPath' - absolute path to the entry file - // 'reference' - whether the file should not be output and only output parts that are referenced - var ImportManager = - /*#__PURE__*/ - function () { - function ImportManager(less, context, rootFileInfo) { - _classCallCheck(this, ImportManager); - - 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 - - this.contentsIgnoredChars = {}; // map - filename to lines at the beginning of each file to ignore - - this.mime = context.mime; - this.error = null; - this.context = context; // Deprecated? Unused outside of here, could be useful. - - 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 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 - */ - - - _createClass(ImportManager, [{ - key: "push", - value: function push(path, tryAppendExtension, currentFileInfo, importOptions, callback) { - var importManager = this; - var pluginLoader = this.context.pluginManager.Loader; - this.queue.push(path); - - var fileParsedFunc = function fileParsedFunc(e, root, fullPath) { - importManager.queue.splice(importManager.queue.indexOf(path), 1); // Remove the path from the queue - - var importedEqualsRoot = fullPath === importManager.rootFilename; - - if (importOptions.optional && e) { - callback(null, { - rules: [] - }, false, null); - logger.info(`The file ${fullPath} was skipped because it was not found and the import was marked optional.`); - } else { - // Inline imports aren't cached here. - // If we start to cache them, please make sure they won't conflict with non-inline imports of the - // same name as they used to do before this comment and the condition below have been added. - if (!importManager.files[fullPath] && !importOptions.inline) { - importManager.files[fullPath] = { - root, - options: importOptions - }; - } - - if (e && !importManager.error) { - importManager.error = e; - } - - callback(e, root, importedEqualsRoot, fullPath); - } - }; - - var newFileInfo = { - rewriteUrls: this.context.rewriteUrls, - entryPath: currentFileInfo.entryPath, - rootpath: currentFileInfo.rootpath, - rootFilename: currentFileInfo.rootFilename - }; - var fileManager = environment.getFileManager(path, currentFileInfo.currentDirectory, this.context, environment); - - if (!fileManager) { - fileParsedFunc({ - message: `Could not find a file-manager for ${path}` - }); - return; - } - - var loadFileCallback = function loadFileCallback(loadedFile) { - var plugin; - var resolvedFilename = loadedFile.filename; - var contents = loadedFile.contents.replace(/^\uFEFF/, ''); // Pass on an updated rootpath if path of imported file is relative and file - // is in a (sub|sup) directory - // - // Examples: - // - If path of imported file is 'module/nav/nav.less' and rootpath is 'less/', - // then rootpath should become 'less/module/nav/' - // - If path of imported file is '../mixins.less' and rootpath is 'less/', - // then rootpath should become 'less/../' - - newFileInfo.currentDirectory = fileManager.getPath(resolvedFilename); - - if (newFileInfo.rewriteUrls) { - newFileInfo.rootpath = fileManager.join(importManager.context.rootpath || '', fileManager.pathDiff(newFileInfo.currentDirectory, newFileInfo.entryPath)); - - if (!fileManager.isPathAbsolute(newFileInfo.rootpath) && fileManager.alwaysMakePathsAbsolute()) { - newFileInfo.rootpath = fileManager.join(newFileInfo.entryPath, newFileInfo.rootpath); - } - } - - newFileInfo.filename = resolvedFilename; - var newEnv = new contexts.Parse(importManager.context); - newEnv.processImports = false; - importManager.contents[resolvedFilename] = contents; - - if (currentFileInfo.reference || importOptions.reference) { - newFileInfo.reference = true; - } - - 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 { - // 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; - var context = clone(this.context); - - if (tryAppendExtension) { - context.ext = importOptions.isPlugin ? '.js' : '.less'; - } - - if (importOptions.isPlugin) { - context.mime = 'application/javascript'; - 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; - }(); - - return ImportManager; -}); - -var Render = (function (environment, ParseTree, ImportManager) { - var render = function render(input, options, callback) { - if (typeof options === 'function') { - callback = options; - options = copyOptions(this.options, {}); - } else { - options = copyOptions(this.options, options || {}); - } - - if (!callback) { - var self = this; - return new Promise(function (resolve, reject) { - render.call(self, input, options, function (err, output) { - if (err) { - reject(err); - } else { - resolve(output); - } - }); - }); - } else { - this.parse(input, options, function (err, root, imports, options) { - if (err) { - return callback(err); - } - - var result; - - try { - var parseTree = new ParseTree(root, imports); - result = parseTree.toCSS(options); - } catch (err) { - return callback(err); - } - - callback(null, result); - }); - } - }; - - return render; -}); - -/** - * Plugin Manager - */ -var PluginManager = -/*#__PURE__*/ -function () { - function PluginManager(less) { - _classCallCheck(this, PluginManager); - - this.less = less; - this.visitors = []; - this.preProcessors = []; - this.postProcessors = []; - this.installedPlugins = []; - this.fileManagers = []; - this.iterator = -1; - this.pluginCache = {}; - this.Loader = new less.PluginLoader(less); - } - /** - * Adds all the plugins in the array - * @param {Array} plugins - */ - - - _createClass(PluginManager, [{ - key: "addPlugins", - value: function addPlugins(plugins) { - if (plugins) { - for (var i = 0; i < plugins.length; i++) { - this.addPlugin(plugins[i]); - } - } - } - /** - * - * @param plugin - * @param {String} filename - */ - - }, { - key: "addPlugin", - value: function addPlugin(plugin, filename, functionRegistry) { - this.installedPlugins.push(plugin); - - if (filename) { - this.pluginCache[filename] = plugin; - } - - if (plugin.install) { - plugin.install(this.less, this, functionRegistry || this.less.functions.functionRegistry); - } - } - /** - * - * @param filename - */ - - }, { - key: "get", - value: function get(filename) { - return this.pluginCache[filename]; - } - /** - * Adds a visitor. The visitor object has options on itself to determine - * when it should run. - * @param visitor - */ - - }, { - key: "addVisitor", - value: function addVisitor(visitor) { - this.visitors.push(visitor); - } - /** - * Adds a pre processor object - * @param {object} preProcessor - * @param {number} priority - guidelines 1 = before import, 1000 = import, 2000 = after import - */ - - }, { - key: "addPreProcessor", - value: function addPreProcessor(preProcessor, priority) { - var indexToInsertAt; - - for (indexToInsertAt = 0; indexToInsertAt < this.preProcessors.length; indexToInsertAt++) { - if (this.preProcessors[indexToInsertAt].priority >= priority) { - break; - } - } - - this.preProcessors.splice(indexToInsertAt, 0, { - preProcessor, - priority - }); - } - /** - * Adds a post processor object - * @param {object} postProcessor - * @param {number} priority - guidelines 1 = before compression, 1000 = compression, 2000 = after compression - */ - - }, { - key: "addPostProcessor", - value: function addPostProcessor(postProcessor, priority) { - var indexToInsertAt; - - for (indexToInsertAt = 0; indexToInsertAt < this.postProcessors.length; indexToInsertAt++) { - if (this.postProcessors[indexToInsertAt].priority >= priority) { - break; - } - } - - this.postProcessors.splice(indexToInsertAt, 0, { - postProcessor, - priority - }); - } - /** - * - * @param manager - */ - - }, { - key: "addFileManager", - value: function addFileManager(manager) { - this.fileManagers.push(manager); - } - /** - * - * @returns {Array} - * @private - */ - - }, { - key: "getPreProcessors", - value: function getPreProcessors() { - var preProcessors = []; - - for (var i = 0; i < this.preProcessors.length; i++) { - preProcessors.push(this.preProcessors[i].preProcessor); - } - - return preProcessors; - } - /** - * - * @returns {Array} - * @private - */ - - }, { - key: "getPostProcessors", - value: function getPostProcessors() { - var postProcessors = []; - - for (var i = 0; i < this.postProcessors.length; i++) { - postProcessors.push(this.postProcessors[i].postProcessor); - } - - return postProcessors; - } - /** - * - * @returns {Array} - * @private - */ - - }, { - key: "getVisitors", - value: function getVisitors() { - return this.visitors; - } - }, { - key: "visitor", - value: function visitor() { - var self = this; - return { - first: function first() { - self.iterator = -1; - return self.visitors[self.iterator]; - }, - get: function get() { - self.iterator += 1; - return self.visitors[self.iterator]; - } - }; - } - /** - * - * @returns {Array} - * @private - */ - - }, { - key: "getFileManagers", - value: function getFileManagers() { - return this.fileManagers; - } - }]); - - return PluginManager; -}(); - -var pm; - -function PluginManagerFactory(less, newFactory) { - if (newFactory || !pm) { - pm = new PluginManager(less); - } - - return pm; -} - -var Parse = (function (environment, ParseTree, ImportManager) { - var parse = function parse(input, options, callback) { - if (typeof options === 'function') { - callback = options; - options = copyOptions(this.options, {}); - } else { - options = copyOptions(this.options, options || {}); - } - - if (!callback) { - var self = this; - return new Promise(function (resolve, reject) { - parse.call(self, input, options, function (err, output) { - if (err) { - reject(err); - } else { - resolve(output); - } - }); - }); - } else { - var context; - var rootFileInfo; - var pluginManager = new PluginManagerFactory(this, !options.reUsePluginManager); - options.pluginManager = pluginManager; - context = new contexts.Parse(options); - - if (options.rootFileInfo) { - rootFileInfo = options.rootFileInfo; - } else { - var filename = options.filename || 'input'; - var entryPath = filename.replace(/[^\/\\]*$/, ''); - rootFileInfo = { - filename, - rewriteUrls: context.rewriteUrls, - rootpath: context.rootpath || '', - currentDirectory: entryPath, - entryPath, - rootFilename: filename - }; // add in a missing trailing slash - - if (rootFileInfo.rootpath && rootFileInfo.rootpath.slice(-1) !== '/') { - rootFileInfo.rootpath += '/'; - } - } - - 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; - var 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); - } - }; - - return parse; -}); - -var createFromEnvironment = (function (environment, fileManagers) { - /** - * @todo - * This original code could be improved quite a bit. - * Many classes / modules currently add side-effects / mutations to passed in objects, - * which makes it hard to refactor and reason about. - */ - environment = new environment$1(environment, fileManagers); - var SourceMapOutput = sourceMapOutput(environment); - var SourceMapBuilder = sourceMapBuilder(SourceMapOutput, environment); - var ParseTree = parseTree(SourceMapBuilder); - var ImportManager = importManager(environment); - var render = Render(environment, ParseTree); - var parse = Parse(environment, ParseTree, ImportManager); - var functions = Functions(environment); - /** - * @todo - * This root properties / methods need to be organized. - * It's not clear what should / must be public and why. - */ - - var initial = { - version: [3, 10, 3], - data, - tree, - Environment: environment$1, - AbstractFileManager, - AbstractPluginLoader, - environment, - visitors, - Parser, - functions, - contexts, - SourceMapOutput, - SourceMapBuilder, - ParseTree, - ImportManager, - render, - parse, - LessError, - transformTree, - utils, - PluginManager: PluginManagerFactory, - logger - }; // Create a public API - - var ctor = function ctor(t) { - return function () { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return _construct(t, args); - }; - }; - - var t; - var 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]); - } - } - } - - return api; -}); - -function createCommonjsModule(fn, module) { - return module = { exports: {} }, fn(module, module.exports), module.exports; -} - -var lesscHelper = createCommonjsModule(function (module, exports) { - // lessc_helper.js - // - // helper functions for lessc - var lessc_helper = { - // Stylize a string - stylize: function stylize(str, style) { - var styles = { - 'reset': [0, 0], - 'bold': [1, 22], - 'inverse': [7, 27], - 'underline': [4, 24], - 'yellow': [33, 39], - 'green': [32, 39], - 'red': [31, 39], - 'grey': [90, 39] - }; - return `\x1b[${styles[style][0]}m${str}\x1b[${styles[style][1]}m`; - }, - // Print command line options - printUsage: function printUsage() { - console.log('usage: lessc [option option=parameter ...] [destination]'); - console.log(''); - console.log('If source is set to `-\' (dash or hyphen-minus), input is read from stdin.'); - console.log(''); - console.log('options:'); - console.log(' -h, --help Prints help (this message) and exit.'); - console.log(' --include-path=PATHS Sets include paths. Separated by `:\'. `;\' also supported on windows.'); - console.log(' -M, --depends Outputs a makefile import dependency list to stdout.'); - console.log(' --no-color Disables colorized output.'); - console.log(' --ie-compat Enables IE8 compatibility checks.'); - console.log(' --js Enables inline JavaScript in less files'); - console.log(' -l, --lint Syntax check only (lint).'); - console.log(' -s, --silent Suppresses output of error messages.'); - console.log(' --strict-imports Forces evaluation of imports.'); - console.log(' --insecure Allows imports from insecure https hosts.'); - console.log(' -v, --version Prints version number and exit.'); - console.log(' --verbose Be verbose.'); - console.log(' --source-map[=FILENAME] Outputs a v3 sourcemap to the filename (or output filename.map).'); - console.log(' --source-map-rootpath=X Adds this path onto the sourcemap filename and less file paths.'); - console.log(' --source-map-basepath=X Sets sourcemap base path, defaults to current working directory.'); - console.log(' --source-map-include-source Puts the less files into the map instead of referencing them.'); - console.log(' --source-map-inline Puts the map (and any less files) as a base64 data uri into the output css file.'); - console.log(' --source-map-url=URL Sets a custom URL to map file, for sourceMappingURL comment'); - console.log(' in generated CSS file.'); - console.log(' -rp, --rootpath=URL Sets rootpath for url rewriting in relative imports and urls'); - console.log(' Works with or without the relative-urls option.'); - console.log(' -ru=, --rewrite-urls= Rewrites URLs to make them relative to the base less file.'); - console.log(' all|local|off \'all\' rewrites all URLs, \'local\' just those starting with a \'.\''); - console.log(''); - console.log(' -m=, --math='); - console.log(' always Less will eagerly perform math operations always.'); - console.log(' parens-division Math performed except for division (/) operator'); - console.log(' parens | strict Math only performed inside parentheses'); - console.log(' strict-legacy Parens required in very strict terms (legacy --strict-math)'); - console.log(''); - console.log(' -su=on|off Allows mixed units, e.g. 1px+1em or 1px*1px which have units'); - console.log(' --strict-units=on|off that cannot be represented.'); - console.log(' --global-var=\'VAR=VALUE\' Defines a variable that can be referenced by the file.'); - console.log(' --modify-var=\'VAR=VALUE\' Modifies a variable already declared in the file.'); - console.log(' --url-args=\'QUERYSTRING\' Adds params into url tokens (e.g. 42, cb=42 or \'a=1&b=2\')'); - console.log(' --plugin=PLUGIN=OPTIONS Loads a plugin. You can also omit the --plugin= if the plugin begins'); - console.log(' less-plugin. E.g. the clean css plugin is called less-plugin-clean-css'); - console.log(' once installed (npm install less-plugin-clean-css), use either with'); - console.log(' --plugin=less-plugin-clean-css or just --clean-css'); - console.log(' specify options afterwards e.g. --plugin=less-plugin-clean-css="advanced"'); - console.log(' or --clean-css="advanced"'); - console.log(''); - console.log('-------------------------- Deprecated ----------------'); - console.log(' -sm=on|off Legacy parens-only math. Use --math'); - console.log(' --strict-math=on|off '); - console.log(''); - console.log(' --line-numbers=TYPE Outputs filename and line numbers.'); - console.log(' TYPE can be either \'comments\', which will output'); - console.log(' the debug info within comments, \'mediaquery\''); - console.log(' that will output the information within a fake'); - console.log(' media query which is compatible with the SASS'); - console.log(' format, and \'all\' which will do both.'); - console.log(' -x, --compress Compresses output by removing some whitespaces.'); - console.log(' We recommend you use a dedicated minifer like less-plugin-clean-css'); - console.log(''); - console.log('Report bugs to: http://github.com/less/less.js/issues'); - console.log('Home page: '); - } - }; // Exports helper functions - - for (var h in lessc_helper) { - if (lessc_helper.hasOwnProperty(h)) { - exports[h] = lessc_helper[h]; - } - } -}); - -/** - * Node Plugin Loader - */ - -var PluginLoader = -/*#__PURE__*/ -function (_AbstractPluginLoader) { - _inherits(PluginLoader, _AbstractPluginLoader); - - function PluginLoader(less) { - var _this; - - _classCallCheck(this, PluginLoader); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(PluginLoader).call(this)); - _this.less = less; - - _this.require = function (prefix) { - prefix = path.dirname(prefix); - return function (id) { - var str = id.substr(0, 2); - - if (str === '..' || str === './') { - return require(path.join(prefix, id)); - } else { - return require(id); - } - }; - }; - - return _this; - } - - _createClass(PluginLoader, [{ - key: "loadPlugin", - value: function loadPlugin(filename, basePath, context, environment, fileManager) { - var prefix = filename.slice(0, 1); - var explicit = prefix === '.' || prefix === '/' || filename.slice(-3).toLowerCase() === '.js'; - - if (!explicit) { - context.prefixes = ['less-plugin-', '']; - } - - return new Promise(function (fulfill, reject) { - fileManager.loadFile(filename, basePath, context, environment).then(function (data) { - try { - fulfill(data); - } catch (e) { - console.log(e); - reject(e); - } - }).catch(function (err) { - reject(err); - }); - }); - } - }]); - - return PluginLoader; -}(AbstractPluginLoader); - -// Export a new default each time -var defaultOptions = (function () { - return { - /* Inline Javascript - @plugin still allowed */ - javascriptEnabled: false, - - /* Outputs a makefile import dependency list to stdout. */ - depends: false, - - /* (DEPRECATED) 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 */ - rewriteUrls: false, - - /* How to process math - * 0 always - eagerly try to solve all operations - * 1 parens-division - require parens for division "/" - * 2 parens | strict - require parens for all operations - * 3 strict-legacy - legacy strict behavior (super-strict) - */ - math: 0, - - /* 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: '' - }; -}); - -var imageSize = (function (environment) { - function _imageSize(functionContext, filePathNode) { - var filePath = filePathNode.value; - var currentFileInfo = functionContext.currentFileInfo; - var currentDirectory = currentFileInfo.rewriteUrls ? currentFileInfo.currentDirectory : currentFileInfo.entryPath; - var fragmentStart = filePath.indexOf('#'); - var fragment = ''; - - if (fragmentStart !== -1) { - fragment = filePath.slice(fragmentStart); - filePath = filePath.slice(0, fragmentStart); - } - - var fileManager = environment.getFileManager(filePath, currentDirectory, functionContext.context, environment, true); - - if (!fileManager) { - throw { - type: 'File', - message: `Can not set up FileManager for ${filePathNode}` - }; - } - - var fileSync = fileManager.loadFileSync(filePath, currentDirectory, functionContext.context, environment); - - if (fileSync.error) { - throw fileSync.error; - } - - var sizeOf = require('image-size'); - - return sizeOf(fileSync.filename); - } - - var imageFunctions = { - 'image-size': function imageSize(filePathNode) { - var size = _imageSize(this, filePathNode); - - return new Expression([new Dimension(size.width, 'px'), new Dimension(size.height, 'px')]); - }, - 'image-width': function imageWidth(filePathNode) { - var size = _imageSize(this, filePathNode); - - return new Dimension(size.width, 'px'); - }, - 'image-height': function imageHeight(filePathNode) { - var size = _imageSize(this, filePathNode); - - return new Dimension(size.height, 'px'); - } - }; - functionRegistry.addMultiple(imageFunctions); -}); - -var less = createFromEnvironment(environment, [new FileManager(), new UrlFileManager()]); // allow people to create less with their own environment - -less.createFromEnvironment = createFromEnvironment; -less.lesscHelper = lesscHelper; -less.PluginLoader = PluginLoader; -less.fs = fs$1; -less.FileManager = FileManager; -less.UrlFileManager = UrlFileManager; // Set up options - -less.options = defaultOptions(); // provide image-size functionality - -imageSize(less.environment); - -module.exports = less; diff --git a/vendor/less/dist/less.js b/vendor/less/dist/less.js index 8219629d3..9731e83dc 100644 --- a/vendor/less/dist/less.js +++ b/vendor/less/dist/less.js @@ -1,14331 +1,11339 @@ /** - * Less - Leaner CSS v3.10.3 + * Less - Leaner CSS v4.1.2 * http://lesscss.org * - * Copyright (c) 2009-2019, Alexis Sellier + * Copyright (c) 2009-2021, Alexis Sellier * Licensed under the Apache-2.0 License. * * @license Apache-2.0 */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global = global || self, global.less = factory()); -}(this, function () { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.less = factory()); +}(this, (function () { 'use strict'; - // Export a new default each time - var defaultOptions = (function () { - return { - /* Inline Javascript - @plugin still allowed */ - javascriptEnabled: false, + // Export a new default each time + function defaultOptions () { + return { + /* Inline Javascript - @plugin still allowed */ + javascriptEnabled: false, + /* Outputs a makefile import dependency list to stdout. */ + depends: false, + /* (DEPRECATED) 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 */ + rewriteUrls: false, + /* How to process math + * 0 always - eagerly try to solve all operations + * 1 parens-division - require parens for division "/" + * 2 parens | strict - require parens for all operations + * 3 strict-legacy - legacy strict behavior (super-strict) + */ + math: 1, + /* 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: '' + }; + } - /* Outputs a makefile import dependency list to stdout. */ - depends: false, + function extractId(href) { + return href.replace(/^[a-z-]+:\/+?[^\/]+/, '') // Remove protocol & domain + .replace(/[\?\&]livereload=\w+/, '') // Remove LiveReload cachebuster + .replace(/^\//, '') // Remove root / + .replace(/\.[a-zA-Z]+$/, '') // Remove simple extension + .replace(/[^\.\w-]+/g, '-') // Replace illegal characters + .replace(/\./g, ':'); // Replace dots with colons(for valid id) + } + function addDataAttr(options, tag) { + for (var opt in tag.dataset) { + if (tag.dataset.hasOwnProperty(opt)) { + if (opt === 'env' || opt === 'dumpLineNumbers' || opt === 'rootpath' || opt === 'errorReporting') { + options[opt] = tag.dataset[opt]; + } + else { + try { + options[opt] = JSON.parse(tag.dataset[opt]); + } + catch (_) { } + } + } + } + } - /* (DEPRECATED) 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 */ - rewriteUrls: false, - - /* How to process math - * 0 always - eagerly try to solve all operations - * 1 parens-division - require parens for division "/" - * 2 parens | strict - require parens for all operations - * 3 strict-legacy - legacy strict behavior (super-strict) - */ - math: 0, - - /* 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: '' + var browser = { + createCSS: function (document, styles, sheet) { + // Strip the query-string + var href = sheet.href || ''; + // If there is no title set, use the filename, minus the extension + var id = "less:" + (sheet.title || extractId(href)); + // If this has already been inserted into the DOM, we may need to replace it + var oldStyleNode = document.getElementById(id); + var keepOldStyleNode = false; + // Create a new stylesheet node for insertion or (if necessary) replacement + var styleNode = document.createElement('style'); + styleNode.setAttribute('type', 'text/css'); + if (sheet.media) { + styleNode.setAttribute('media', sheet.media); + } + styleNode.id = id; + if (!styleNode.styleSheet) { + styleNode.appendChild(document.createTextNode(styles)); + // If new contents match contents of oldStyleNode, don't replace oldStyleNode + keepOldStyleNode = (oldStyleNode !== null && oldStyleNode.childNodes.length > 0 && styleNode.childNodes.length > 0 && + oldStyleNode.firstChild.nodeValue === styleNode.firstChild.nodeValue); + } + var head = document.getElementsByTagName('head')[0]; + // If there is no oldStyleNode, just append; otherwise, only append if we need + // to replace oldStyleNode with an updated stylesheet + if (oldStyleNode === null || keepOldStyleNode === false) { + var nextEl = sheet && sheet.nextSibling || null; + if (nextEl) { + nextEl.parentNode.insertBefore(styleNode, nextEl); + } + else { + head.appendChild(styleNode); + } + } + if (oldStyleNode && keepOldStyleNode === false) { + oldStyleNode.parentNode.removeChild(oldStyleNode); + } + // For IE. + // This needs to happen *after* the style element is added to the DOM, otherwise IE 7 and 8 may crash. + // See http://social.msdn.microsoft.com/Forums/en-US/7e081b65-878a-4c22-8e68-c10d39c2ed32/internet-explorer-crashes-appending-style-element-to-head + if (styleNode.styleSheet) { + try { + styleNode.styleSheet.cssText = styles; + } + catch (e) { + throw new Error('Couldn\'t reassign styleSheet.cssText.'); + } + } + }, + currentScript: function (window) { + var document = window.document; + return document.currentScript || (function () { + var scripts = document.getElementsByTagName('script'); + return scripts[scripts.length - 1]; + })(); + } }; - }); - function extractId(href) { - return href.replace(/^[a-z-]+:\/+?[^\/]+/, '') // Remove protocol & domain - .replace(/[\?\&]livereload=\w+/, '') // Remove LiveReload cachebuster - .replace(/^\//, '') // Remove root / - .replace(/\.[a-zA-Z]+$/, '') // Remove simple extension - .replace(/[^\.\w-]+/g, '-') // Replace illegal characters - .replace(/\./g, ':'); // Replace dots with colons(for valid id) - } - function addDataAttr(options, tag) { - for (var opt in tag.dataset) { - if (tag.dataset.hasOwnProperty(opt)) { - if (opt === 'env' || opt === 'dumpLineNumbers' || opt === 'rootpath' || opt === 'errorReporting') { - options[opt] = tag.dataset[opt]; - } else { - try { - options[opt] = JSON.parse(tag.dataset[opt]); - } catch (_) {} + var addDefaultOptions = (function (window, options) { + // use options from the current script tag data attribues + addDataAttr(options, browser.currentScript(window)); + if (options.isFileProtocol === undefined) { + options.isFileProtocol = /^(file|(chrome|safari)(-extension)?|resource|qrc|app):/.test(window.location.protocol); } - } - } - } - - var browser = { - createCSS: function createCSS(document, styles, sheet) { - // Strip the query-string - var href = sheet.href || ''; // If there is no title set, use the filename, minus the extension - - var id = "less:".concat(sheet.title || extractId(href)); // If this has already been inserted into the DOM, we may need to replace it - - var oldStyleNode = document.getElementById(id); - var keepOldStyleNode = false; // Create a new stylesheet node for insertion or (if necessary) replacement - - var styleNode = document.createElement('style'); - styleNode.setAttribute('type', 'text/css'); - - if (sheet.media) { - styleNode.setAttribute('media', sheet.media); - } - - styleNode.id = id; - - if (!styleNode.styleSheet) { - styleNode.appendChild(document.createTextNode(styles)); // If new contents match contents of oldStyleNode, don't replace oldStyleNode - - keepOldStyleNode = oldStyleNode !== null && oldStyleNode.childNodes.length > 0 && styleNode.childNodes.length > 0 && oldStyleNode.firstChild.nodeValue === styleNode.firstChild.nodeValue; - } - - var head = document.getElementsByTagName('head')[0]; // If there is no oldStyleNode, just append; otherwise, only append if we need - // to replace oldStyleNode with an updated stylesheet - - if (oldStyleNode === null || keepOldStyleNode === false) { - var nextEl = sheet && sheet.nextSibling || null; - - if (nextEl) { - nextEl.parentNode.insertBefore(styleNode, nextEl); - } else { - head.appendChild(styleNode); + // Load styles asynchronously (default: false) + // + // This is set to `false` by default, so that the body + // doesn't start loading before the stylesheets are parsed. + // Setting this to `true` can result in flickering. + // + options.async = options.async || false; + options.fileAsync = options.fileAsync || false; + // Interval between watch polls + options.poll = options.poll || (options.isFileProtocol ? 1000 : 1500); + options.env = options.env || (window.location.hostname == '127.0.0.1' || + window.location.hostname == '0.0.0.0' || + window.location.hostname == 'localhost' || + (window.location.port && + window.location.port.length > 0) || + options.isFileProtocol ? 'development' + : 'production'); + var dumpLineNumbers = /!dumpLineNumbers:(comments|mediaquery|all)/.exec(window.location.hash); + if (dumpLineNumbers) { + options.dumpLineNumbers = dumpLineNumbers[1]; } - } - - if (oldStyleNode && keepOldStyleNode === false) { - oldStyleNode.parentNode.removeChild(oldStyleNode); - } // For IE. - // This needs to happen *after* the style element is added to the DOM, otherwise IE 7 and 8 may crash. - // See http://social.msdn.microsoft.com/Forums/en-US/7e081b65-878a-4c22-8e68-c10d39c2ed32/internet-explorer-crashes-appending-style-element-to-head - - - if (styleNode.styleSheet) { - try { - styleNode.styleSheet.cssText = styles; - } catch (e) { - throw new Error('Couldn\'t reassign styleSheet.cssText.'); + if (options.useFileCache === undefined) { + options.useFileCache = true; + } + if (options.onReady === undefined) { + options.onReady = true; + } + if (options.relativeUrls) { + options.rewriteUrls = 'all'; } - } - }, - currentScript: function currentScript(window) { - var document = window.document; - return document.currentScript || function () { - var scripts = document.getElementsByTagName('script'); - return scripts[scripts.length - 1]; - }(); - } - }; - - var addDefaultOptions = (function (window, options) { - // use options from the current script tag data attribues - addDataAttr(options, browser.currentScript(window)); - - if (options.isFileProtocol === undefined) { - options.isFileProtocol = /^(file|(chrome|safari)(-extension)?|resource|qrc|app):/.test(window.location.protocol); - } // Load styles asynchronously (default: false) - // - // This is set to `false` by default, so that the body - // doesn't start loading before the stylesheets are parsed. - // Setting this to `true` can result in flickering. - // - - - options.async = options.async || false; - options.fileAsync = options.fileAsync || false; // Interval between watch polls - - options.poll = options.poll || (options.isFileProtocol ? 1000 : 1500); - options.env = options.env || (window.location.hostname == '127.0.0.1' || window.location.hostname == '0.0.0.0' || window.location.hostname == 'localhost' || window.location.port && window.location.port.length > 0 || options.isFileProtocol ? 'development' : 'production'); - var dumpLineNumbers = /!dumpLineNumbers:(comments|mediaquery|all)/.exec(window.location.hash); - - if (dumpLineNumbers) { - options.dumpLineNumbers = dumpLineNumbers[1]; - } - - if (options.useFileCache === undefined) { - options.useFileCache = true; - } - - if (options.onReady === undefined) { - options.onReady = true; - } - - if (options.relativeUrls) { - options.rewriteUrls = 'all'; - } - }); - - function _typeof(obj) { - if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { - _typeof = function (obj) { - return typeof obj; - }; - } else { - _typeof = function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; - }; - } - - return _typeof(obj); - } - - function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } - } - - function _defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } - } - - function _createClass(Constructor, protoProps, staticProps) { - if (protoProps) _defineProperties(Constructor.prototype, protoProps); - if (staticProps) _defineProperties(Constructor, staticProps); - return Constructor; - } - - function _inherits(subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function"); - } - - subClass.prototype = Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - writable: true, - configurable: true - } }); - if (superClass) _setPrototypeOf(subClass, superClass); - } - function _getPrototypeOf(o) { - _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { - return o.__proto__ || Object.getPrototypeOf(o); - }; - return _getPrototypeOf(o); - } - - function _setPrototypeOf(o, p) { - _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { - o.__proto__ = p; - return o; + var logger$1 = { + 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; + } + } + }, + _fireEvent: function (type, msg) { + for (var i = 0; i < this._listeners.length; i++) { + var logFunction = this._listeners[i][type]; + if (logFunction) { + logFunction(msg); + } + } + }, + _listeners: [] }; - return _setPrototypeOf(o, p); - } - - function isNativeReflectConstruct() { - if (typeof Reflect === "undefined" || !Reflect.construct) return false; - if (Reflect.construct.sham) return false; - if (typeof Proxy === "function") return true; - - try { - Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); - return true; - } catch (e) { - return false; - } - } - - function _construct(Parent, args, Class) { - if (isNativeReflectConstruct()) { - _construct = Reflect.construct; - } else { - _construct = function _construct(Parent, args, Class) { - var a = [null]; - a.push.apply(a, args); - var Constructor = Function.bind.apply(Parent, a); - var instance = new Constructor(); - if (Class) _setPrototypeOf(instance, Class.prototype); - return instance; - }; - } - - return _construct.apply(null, arguments); - } - - function _assertThisInitialized(self) { - if (self === void 0) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - - return self; - } - - function _possibleConstructorReturn(self, call) { - if (call && (typeof call === "object" || typeof call === "function")) { - return call; - } - - return _assertThisInitialized(self); - } - - function _toConsumableArray(arr) { - return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); - } - - function _arrayWithoutHoles(arr) { - if (Array.isArray(arr)) { - for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; - - return arr2; - } - } - - function _iterableToArray(iter) { - if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); - } - - function _nonIterableSpread() { - throw new TypeError("Invalid attempt to spread non-iterable instance"); - } - - var colors = { - 'aliceblue': '#f0f8ff', - 'antiquewhite': '#faebd7', - 'aqua': '#00ffff', - 'aquamarine': '#7fffd4', - 'azure': '#f0ffff', - 'beige': '#f5f5dc', - 'bisque': '#ffe4c4', - 'black': '#000000', - 'blanchedalmond': '#ffebcd', - 'blue': '#0000ff', - 'blueviolet': '#8a2be2', - 'brown': '#a52a2a', - 'burlywood': '#deb887', - 'cadetblue': '#5f9ea0', - 'chartreuse': '#7fff00', - 'chocolate': '#d2691e', - 'coral': '#ff7f50', - 'cornflowerblue': '#6495ed', - 'cornsilk': '#fff8dc', - 'crimson': '#dc143c', - 'cyan': '#00ffff', - 'darkblue': '#00008b', - 'darkcyan': '#008b8b', - 'darkgoldenrod': '#b8860b', - 'darkgray': '#a9a9a9', - 'darkgrey': '#a9a9a9', - 'darkgreen': '#006400', - 'darkkhaki': '#bdb76b', - 'darkmagenta': '#8b008b', - 'darkolivegreen': '#556b2f', - 'darkorange': '#ff8c00', - 'darkorchid': '#9932cc', - 'darkred': '#8b0000', - 'darksalmon': '#e9967a', - 'darkseagreen': '#8fbc8f', - 'darkslateblue': '#483d8b', - 'darkslategray': '#2f4f4f', - 'darkslategrey': '#2f4f4f', - 'darkturquoise': '#00ced1', - 'darkviolet': '#9400d3', - 'deeppink': '#ff1493', - 'deepskyblue': '#00bfff', - 'dimgray': '#696969', - 'dimgrey': '#696969', - 'dodgerblue': '#1e90ff', - 'firebrick': '#b22222', - 'floralwhite': '#fffaf0', - 'forestgreen': '#228b22', - 'fuchsia': '#ff00ff', - 'gainsboro': '#dcdcdc', - 'ghostwhite': '#f8f8ff', - 'gold': '#ffd700', - 'goldenrod': '#daa520', - 'gray': '#808080', - 'grey': '#808080', - 'green': '#008000', - 'greenyellow': '#adff2f', - 'honeydew': '#f0fff0', - 'hotpink': '#ff69b4', - 'indianred': '#cd5c5c', - 'indigo': '#4b0082', - 'ivory': '#fffff0', - 'khaki': '#f0e68c', - 'lavender': '#e6e6fa', - 'lavenderblush': '#fff0f5', - 'lawngreen': '#7cfc00', - 'lemonchiffon': '#fffacd', - 'lightblue': '#add8e6', - 'lightcoral': '#f08080', - 'lightcyan': '#e0ffff', - 'lightgoldenrodyellow': '#fafad2', - 'lightgray': '#d3d3d3', - 'lightgrey': '#d3d3d3', - 'lightgreen': '#90ee90', - 'lightpink': '#ffb6c1', - 'lightsalmon': '#ffa07a', - 'lightseagreen': '#20b2aa', - 'lightskyblue': '#87cefa', - 'lightslategray': '#778899', - 'lightslategrey': '#778899', - 'lightsteelblue': '#b0c4de', - 'lightyellow': '#ffffe0', - 'lime': '#00ff00', - 'limegreen': '#32cd32', - 'linen': '#faf0e6', - 'magenta': '#ff00ff', - 'maroon': '#800000', - 'mediumaquamarine': '#66cdaa', - 'mediumblue': '#0000cd', - 'mediumorchid': '#ba55d3', - 'mediumpurple': '#9370d8', - 'mediumseagreen': '#3cb371', - 'mediumslateblue': '#7b68ee', - 'mediumspringgreen': '#00fa9a', - 'mediumturquoise': '#48d1cc', - 'mediumvioletred': '#c71585', - 'midnightblue': '#191970', - 'mintcream': '#f5fffa', - 'mistyrose': '#ffe4e1', - 'moccasin': '#ffe4b5', - 'navajowhite': '#ffdead', - 'navy': '#000080', - 'oldlace': '#fdf5e6', - 'olive': '#808000', - 'olivedrab': '#6b8e23', - 'orange': '#ffa500', - 'orangered': '#ff4500', - 'orchid': '#da70d6', - 'palegoldenrod': '#eee8aa', - 'palegreen': '#98fb98', - 'paleturquoise': '#afeeee', - 'palevioletred': '#d87093', - 'papayawhip': '#ffefd5', - 'peachpuff': '#ffdab9', - 'peru': '#cd853f', - 'pink': '#ffc0cb', - 'plum': '#dda0dd', - 'powderblue': '#b0e0e6', - 'purple': '#800080', - 'rebeccapurple': '#663399', - 'red': '#ff0000', - 'rosybrown': '#bc8f8f', - 'royalblue': '#4169e1', - 'saddlebrown': '#8b4513', - 'salmon': '#fa8072', - 'sandybrown': '#f4a460', - 'seagreen': '#2e8b57', - 'seashell': '#fff5ee', - 'sienna': '#a0522d', - 'silver': '#c0c0c0', - 'skyblue': '#87ceeb', - 'slateblue': '#6a5acd', - 'slategray': '#708090', - 'slategrey': '#708090', - 'snow': '#fffafa', - 'springgreen': '#00ff7f', - 'steelblue': '#4682b4', - 'tan': '#d2b48c', - 'teal': '#008080', - 'thistle': '#d8bfd8', - 'tomato': '#ff6347', - 'turquoise': '#40e0d0', - 'violet': '#ee82ee', - 'wheat': '#f5deb3', - 'white': '#ffffff', - 'whitesmoke': '#f5f5f5', - 'yellow': '#ffff00', - 'yellowgreen': '#9acd32' - }; - - var unitConversions = { - length: { - 'm': 1, - 'cm': 0.01, - 'mm': 0.001, - 'in': 0.0254, - 'px': 0.0254 / 96, - 'pt': 0.0254 / 72, - 'pc': 0.0254 / 72 * 12 - }, - duration: { - 's': 1, - 'ms': 0.001 - }, - angle: { - 'rad': 1 / (2 * Math.PI), - 'deg': 1 / 360, - 'grad': 1 / 400, - 'turn': 1 - } - }; - - var data = { - colors: colors, - unitConversions: unitConversions - }; - - var Node = - /*#__PURE__*/ - function () { - function Node() { - _classCallCheck(this, Node); - - this.parent = null; - this.visibilityBlocks = undefined; - this.nodeVisible = undefined; - this.rootNode = null; - this.parsed = null; - var self = this; - Object.defineProperty(this, 'currentFileInfo', { - get: function get() { - return self.fileInfo(); - } - }); - Object.defineProperty(this, 'index', { - get: function get() { - return self.getIndex(); - } - }); - } - - _createClass(Node, [{ - key: "setParent", - value: function setParent(nodes, parent) { - function set(node) { - if (node && node instanceof Node) { - node.parent = parent; - } - } - - if (Array.isArray(nodes)) { - nodes.forEach(set); - } else { - set(nodes); - } - } - }, { - key: "getIndex", - value: function getIndex() { - return this._index || this.parent && this.parent.getIndex() || 0; - } - }, { - key: "fileInfo", - value: function fileInfo() { - return this._fileInfo || this.parent && this.parent.fileInfo() || {}; - } - }, { - key: "isRulesetLike", - value: function isRulesetLike() { - return false; - } - }, { - key: "toCSS", - value: function toCSS(context) { - var strs = []; - this.genCSS(context, { - add: function add(chunk, fileInfo, index) { - strs.push(chunk); - }, - isEmpty: function isEmpty() { - return strs.length === 0; - } - }); - return strs.join(''); - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - output.add(this.value); - } - }, { - key: "accept", - value: function accept(visitor) { - this.value = visitor.visit(this.value); - } - }, { - key: "eval", - value: function _eval() { - return this; - } - }, { - key: "_operate", - value: function _operate(context, op, a, b) { - switch (op) { - case '+': - return a + b; - - case '-': - return a - b; - - case '*': - return a * b; - - case '/': - return a / b; - } - } - }, { - key: "fround", - value: function fround(context, value) { - var precision = context && context.numPrecision; // add "epsilon" to ensure numbers like 1.000000005 (represented as 1.000000004999...) are properly rounded: - - return precision ? Number((value + 2e-16).toFixed(precision)) : value; - } // Returns true if this node represents root of ast imported by reference - - }, { - key: "blocksVisibility", - value: function blocksVisibility() { - if (this.visibilityBlocks == null) { - this.visibilityBlocks = 0; - } - - return this.visibilityBlocks !== 0; - } - }, { - key: "addVisibilityBlock", - value: function addVisibilityBlock() { - if (this.visibilityBlocks == null) { - this.visibilityBlocks = 0; - } - - this.visibilityBlocks = this.visibilityBlocks + 1; - } - }, { - key: "removeVisibilityBlock", - value: function removeVisibilityBlock() { - if (this.visibilityBlocks == null) { - this.visibilityBlocks = 0; - } - - 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 - - }, { - key: "ensureVisibility", - value: function ensureVisibility() { - 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 - - }, { - key: "ensureInvisibility", - value: function ensureInvisibility() { - this.nodeVisible = false; - } // return values: - // false - the node must not be visible - // true - the node must be visible - // undefined or null - the node has the same visibility as its parent - - }, { - key: "isVisible", - value: function isVisible() { - return this.nodeVisible; - } - }, { - key: "visibilityInfo", - value: function visibilityInfo() { - return { - visibilityBlocks: this.visibilityBlocks, - nodeVisible: this.nodeVisible - }; - } - }, { - key: "copyVisibilityInfo", - value: function copyVisibilityInfo(info) { - if (!info) { - return; - } - - this.visibilityBlocks = info.visibilityBlocks; - this.nodeVisible = info.nodeVisible; - } - }]); - - return Node; - }(); - - Node.compare = function (a, b) { - /* returns: - -1: a < b - 0: a = b - 1: a > b - and *any* other value for a != b (e.g. undefined, NaN, -2 etc.) */ - if (a.compare && // for "symmetric results" force toCSS-based comparison - // of Quoted or Anonymous if either value is one of those - !(b.type === 'Quoted' || b.type === 'Anonymous')) { - return a.compare(b); - } else if (b.compare) { - return -b.compare(a); - } else if (a.type !== b.type) { - return undefined; - } - - a = a.value; - b = b.value; - - if (!Array.isArray(a)) { - return a === b ? 0 : undefined; - } - - if (a.length !== b.length) { - return undefined; - } - - for (var i = 0; i < a.length; i++) { - if (Node.compare(a[i], b[i]) !== 0) { - return undefined; - } - } - - return 0; - }; - - Node.numericCompare = function (a, b) { - return a < b ? -1 : a === b ? 0 : a > b ? 1 : undefined; - }; - - // RGB Colors - #ff0014, #eee - // - - var Color = - /*#__PURE__*/ - function (_Node) { - _inherits(Color, _Node); - - function Color(rgb, a, originalForm) { - var _this; - - _classCallCheck(this, Color); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Color).call(this)); - - var self = _assertThisInitialized(_this); // - // The end goal here, is to parse the arguments - // into an integer triplet, such as `128, 255, 0` - // - // This facilitates operations and conversions. - // - - - if (Array.isArray(rgb)) { - _this.rgb = rgb; - } else if (rgb.length >= 6) { - _this.rgb = []; - rgb.match(/.{2}/g).map(function (c, i) { - if (i < 3) { - self.rgb.push(parseInt(c, 16)); - } else { - self.alpha = parseInt(c, 16) / 255; - } - }); - } else { - _this.rgb = []; - rgb.split('').map(function (c, i) { - if (i < 3) { - self.rgb.push(parseInt(c + c, 16)); - } else { - self.alpha = parseInt(c + c, 16) / 255; - } - }); - } - - _this.alpha = _this.alpha || (typeof a === 'number' ? a : 1); - - if (typeof originalForm !== 'undefined') { - _this.value = originalForm; - } - - return _this; - } - - _createClass(Color, [{ - key: "luma", - value: function luma() { - var r = this.rgb[0] / 255; - var g = this.rgb[1] / 255; - var b = this.rgb[2] / 255; - r = r <= 0.03928 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4); - g = g <= 0.03928 ? g / 12.92 : Math.pow((g + 0.055) / 1.055, 2.4); - b = b <= 0.03928 ? b / 12.92 : Math.pow((b + 0.055) / 1.055, 2.4); - return 0.2126 * r + 0.7152 * g + 0.0722 * b; - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - output.add(this.toCSS(context)); - } - }, { - key: "toCSS", - value: function toCSS(context, doNotCompress) { - var compress = context && context.compress && !doNotCompress; - var color; - var alpha; - var colorFunction; - var args = []; // `value` is set if this color was originally - // converted from a named color string so we need - // to respect this and try to output named color too. - - alpha = this.fround(context, this.alpha); - - if (this.value) { - if (this.value.indexOf('rgb') === 0) { - if (alpha < 1) { - colorFunction = 'rgba'; + /** + * @todo Document why this abstraction exists, and the relationship between + * environment, file managers, and plugin manager + */ + var Environment = /** @class */ (function () { + function Environment(externalEnvironment, fileManagers) { + this.fileManagers = fileManagers || []; + externalEnvironment = externalEnvironment || {}; + var optionalFunctions = ['encodeBase64', 'mimeLookup', 'charsetLookup', 'getSourceMapGenerator']; + var requiredFunctions = []; + var functions = requiredFunctions.concat(optionalFunctions); + for (var i = 0; i < functions.length; i++) { + var propName = functions[i]; + var environmentFunc = externalEnvironment[propName]; + if (environmentFunc) { + this[propName] = environmentFunc.bind(externalEnvironment); + } + else if (i < requiredFunctions.length) { + this.warn("missing required function in environment - " + propName); + } } - } else if (this.value.indexOf('hsl') === 0) { - if (alpha < 1) { - colorFunction = 'hsla'; - } else { - colorFunction = 'hsl'; + } + Environment.prototype.getFileManager = function (filename, currentDirectory, options, environment, isSync) { + if (!filename) { + logger$1.warn('getFileManager called with no filename.. Please report this issue. continuing.'); } - } else { - return this.value; - } - } else { - if (alpha < 1) { - colorFunction = 'rgba'; - } - } - - switch (colorFunction) { - case 'rgba': - args = this.rgb.map(function (c) { - return clamp(Math.round(c), 255); - }).concat(clamp(alpha, 1)); - break; - - case 'hsla': - args.push(clamp(alpha, 1)); - - case 'hsl': - color = this.toHSL(); - args = [this.fround(context, color.h), "".concat(this.fround(context, color.s * 100), "%"), "".concat(this.fround(context, color.l * 100), "%")].concat(args); - } - - if (colorFunction) { - // Values are capped between `0` and `255`, rounded and zero-padded. - return "".concat(colorFunction, "(").concat(args.join(",".concat(compress ? '' : ' ')), ")"); - } - - color = this.toRGB(); - - if (compress) { - var splitcolor = color.split(''); // Convert color to short format - - if (splitcolor[1] === splitcolor[2] && splitcolor[3] === splitcolor[4] && splitcolor[5] === splitcolor[6]) { - color = "#".concat(splitcolor[1]).concat(splitcolor[3]).concat(splitcolor[5]); - } - } - - return color; - } // - // Operations have to be done per-channel, if not, - // channels will spill onto each other. Once we have - // our result, in the form of an integer triplet, - // we create a new Color node to hold the result. - // - - }, { - key: "operate", - value: function operate(context, op, other) { - 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]); - } - - return new Color(rgb, alpha); - } - }, { - key: "toRGB", - value: function toRGB() { - return toHex(this.rgb); - } - }, { - key: "toHSL", - value: function toHSL() { - var r = this.rgb[0] / 255; - var g = this.rgb[1] / 255; - var b = this.rgb[2] / 255; - var a = this.alpha; - var max = Math.max(r, g, b); - var min = Math.min(r, g, b); - var h; - var s; - var l = (max + min) / 2; - var d = max - min; - - if (max === min) { - h = s = 0; - } else { - s = l > 0.5 ? d / (2 - max - min) : d / (max + min); - - 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; - } - - h /= 6; - } - - return { - h: h * 360, - s: s, - l: l, - a: a + if (currentDirectory == null) { + logger$1.warn('getFileManager called with null directory.. Please report this issue. continuing.'); + } + var fileManagers = this.fileManagers; + if (options.pluginManager) { + fileManagers = [].concat(fileManagers).concat(options.pluginManager.getFileManagers()); + } + for (var i = fileManagers.length - 1; i >= 0; i--) { + var fileManager = fileManagers[i]; + if (fileManager[isSync ? 'supportsSync' : 'supports'](filename, currentDirectory, options, environment)) { + return fileManager; + } + } + return null; }; - } // Adapted from http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript - - }, { - key: "toHSV", - value: function toHSV() { - var r = this.rgb[0] / 255; - var g = this.rgb[1] / 255; - var b = this.rgb[2] / 255; - var a = this.alpha; - var max = Math.max(r, g, b); - var min = Math.min(r, g, b); - var h; - var s; - var v = max; - var d = max - min; - - if (max === 0) { - s = 0; - } else { - s = d / max; - } - - if (max === min) { - h = 0; - } else { - 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; - } - - h /= 6; - } - - return { - h: h * 360, - s: s, - v: v, - a: a + Environment.prototype.addFileManager = function (fileManager) { + this.fileManagers.push(fileManager); }; - } - }, { - key: "toARGB", - value: function toARGB() { - return toHex([this.alpha * 255].concat(this.rgb)); - } - }, { - key: "compare", - value: function compare(x) { - return x.rgb && x.rgb[0] === this.rgb[0] && x.rgb[1] === this.rgb[1] && x.rgb[2] === this.rgb[2] && x.alpha === this.alpha ? 0 : undefined; - } - }]); + Environment.prototype.clearFileManagers = function () { + this.fileManagers = []; + }; + return Environment; + }()); - return Color; - }(Node); + var colors = { + 'aliceblue': '#f0f8ff', + 'antiquewhite': '#faebd7', + 'aqua': '#00ffff', + 'aquamarine': '#7fffd4', + 'azure': '#f0ffff', + 'beige': '#f5f5dc', + 'bisque': '#ffe4c4', + 'black': '#000000', + 'blanchedalmond': '#ffebcd', + 'blue': '#0000ff', + 'blueviolet': '#8a2be2', + 'brown': '#a52a2a', + 'burlywood': '#deb887', + 'cadetblue': '#5f9ea0', + 'chartreuse': '#7fff00', + 'chocolate': '#d2691e', + 'coral': '#ff7f50', + 'cornflowerblue': '#6495ed', + 'cornsilk': '#fff8dc', + 'crimson': '#dc143c', + 'cyan': '#00ffff', + 'darkblue': '#00008b', + 'darkcyan': '#008b8b', + 'darkgoldenrod': '#b8860b', + 'darkgray': '#a9a9a9', + 'darkgrey': '#a9a9a9', + 'darkgreen': '#006400', + 'darkkhaki': '#bdb76b', + 'darkmagenta': '#8b008b', + 'darkolivegreen': '#556b2f', + 'darkorange': '#ff8c00', + 'darkorchid': '#9932cc', + 'darkred': '#8b0000', + 'darksalmon': '#e9967a', + 'darkseagreen': '#8fbc8f', + 'darkslateblue': '#483d8b', + 'darkslategray': '#2f4f4f', + 'darkslategrey': '#2f4f4f', + 'darkturquoise': '#00ced1', + 'darkviolet': '#9400d3', + 'deeppink': '#ff1493', + 'deepskyblue': '#00bfff', + 'dimgray': '#696969', + 'dimgrey': '#696969', + 'dodgerblue': '#1e90ff', + 'firebrick': '#b22222', + 'floralwhite': '#fffaf0', + 'forestgreen': '#228b22', + 'fuchsia': '#ff00ff', + 'gainsboro': '#dcdcdc', + 'ghostwhite': '#f8f8ff', + 'gold': '#ffd700', + 'goldenrod': '#daa520', + 'gray': '#808080', + 'grey': '#808080', + 'green': '#008000', + 'greenyellow': '#adff2f', + 'honeydew': '#f0fff0', + 'hotpink': '#ff69b4', + 'indianred': '#cd5c5c', + 'indigo': '#4b0082', + 'ivory': '#fffff0', + 'khaki': '#f0e68c', + 'lavender': '#e6e6fa', + 'lavenderblush': '#fff0f5', + 'lawngreen': '#7cfc00', + 'lemonchiffon': '#fffacd', + 'lightblue': '#add8e6', + 'lightcoral': '#f08080', + 'lightcyan': '#e0ffff', + 'lightgoldenrodyellow': '#fafad2', + 'lightgray': '#d3d3d3', + 'lightgrey': '#d3d3d3', + 'lightgreen': '#90ee90', + 'lightpink': '#ffb6c1', + 'lightsalmon': '#ffa07a', + 'lightseagreen': '#20b2aa', + 'lightskyblue': '#87cefa', + 'lightslategray': '#778899', + 'lightslategrey': '#778899', + 'lightsteelblue': '#b0c4de', + 'lightyellow': '#ffffe0', + 'lime': '#00ff00', + 'limegreen': '#32cd32', + 'linen': '#faf0e6', + 'magenta': '#ff00ff', + 'maroon': '#800000', + 'mediumaquamarine': '#66cdaa', + 'mediumblue': '#0000cd', + 'mediumorchid': '#ba55d3', + 'mediumpurple': '#9370d8', + 'mediumseagreen': '#3cb371', + 'mediumslateblue': '#7b68ee', + 'mediumspringgreen': '#00fa9a', + 'mediumturquoise': '#48d1cc', + 'mediumvioletred': '#c71585', + 'midnightblue': '#191970', + 'mintcream': '#f5fffa', + 'mistyrose': '#ffe4e1', + 'moccasin': '#ffe4b5', + 'navajowhite': '#ffdead', + 'navy': '#000080', + 'oldlace': '#fdf5e6', + 'olive': '#808000', + 'olivedrab': '#6b8e23', + 'orange': '#ffa500', + 'orangered': '#ff4500', + 'orchid': '#da70d6', + 'palegoldenrod': '#eee8aa', + 'palegreen': '#98fb98', + 'paleturquoise': '#afeeee', + 'palevioletred': '#d87093', + 'papayawhip': '#ffefd5', + 'peachpuff': '#ffdab9', + 'peru': '#cd853f', + 'pink': '#ffc0cb', + 'plum': '#dda0dd', + 'powderblue': '#b0e0e6', + 'purple': '#800080', + 'rebeccapurple': '#663399', + 'red': '#ff0000', + 'rosybrown': '#bc8f8f', + 'royalblue': '#4169e1', + 'saddlebrown': '#8b4513', + 'salmon': '#fa8072', + 'sandybrown': '#f4a460', + 'seagreen': '#2e8b57', + 'seashell': '#fff5ee', + 'sienna': '#a0522d', + 'silver': '#c0c0c0', + 'skyblue': '#87ceeb', + 'slateblue': '#6a5acd', + 'slategray': '#708090', + 'slategrey': '#708090', + 'snow': '#fffafa', + 'springgreen': '#00ff7f', + 'steelblue': '#4682b4', + 'tan': '#d2b48c', + 'teal': '#008080', + 'thistle': '#d8bfd8', + 'tomato': '#ff6347', + 'turquoise': '#40e0d0', + 'violet': '#ee82ee', + 'wheat': '#f5deb3', + 'white': '#ffffff', + 'whitesmoke': '#f5f5f5', + 'yellow': '#ffff00', + 'yellowgreen': '#9acd32' + }; - Color.prototype.type = 'Color'; - - function clamp(v, max) { - return Math.min(Math.max(v, 0), max); - } - - function toHex(v) { - return "#".concat(v.map(function (c) { - c = clamp(Math.round(c), 255); - return (c < 16 ? '0' : '') + c.toString(16); - }).join('')); - } - - Color.fromKeyword = function (keyword) { - var c; - var key = keyword.toLowerCase(); - - if (colors.hasOwnProperty(key)) { - c = new Color(colors[key].slice(1)); - } else if (key === 'transparent') { - c = new Color([0, 0, 0], 0); - } - - if (c) { - c.value = keyword; - return c; - } - }; - - var Paren = - /*#__PURE__*/ - function (_Node) { - _inherits(Paren, _Node); - - function Paren(node) { - var _this; - - _classCallCheck(this, Paren); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Paren).call(this)); - _this.value = node; - return _this; - } - - _createClass(Paren, [{ - key: "genCSS", - value: function genCSS(context, output) { - output.add('('); - this.value.genCSS(context, output); - output.add(')'); - } - }, { - key: "eval", - value: function _eval(context) { - return new Paren(this.value.eval(context)); - } - }]); - - return Paren; - }(Node); - - Paren.prototype.type = 'Paren'; - - var _noSpaceCombinators = { - '': true, - ' ': true, - '|': true - }; - - var Combinator = - /*#__PURE__*/ - function (_Node) { - _inherits(Combinator, _Node); - - function Combinator(value) { - var _this; - - _classCallCheck(this, Combinator); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Combinator).call(this)); - - if (value === ' ') { - _this.value = ' '; - _this.emptyOrWhitespace = true; - } else { - _this.value = value ? value.trim() : ''; - _this.emptyOrWhitespace = _this.value === ''; - } - - return _this; - } - - _createClass(Combinator, [{ - key: "genCSS", - value: function genCSS(context, output) { - var spaceOrEmpty = context.compress || _noSpaceCombinators[this.value] ? '' : ' '; - output.add(spaceOrEmpty + this.value + spaceOrEmpty); - } - }]); - - return Combinator; - }(Node); - - Combinator.prototype.type = 'Combinator'; - - var Element = - /*#__PURE__*/ - function (_Node) { - _inherits(Element, _Node); - - function Element(combinator, value, isVariable, index, currentFileInfo, visibilityInfo) { - var _this; - - _classCallCheck(this, Element); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Element).call(this)); - _this.combinator = combinator instanceof Combinator ? combinator : new Combinator(combinator); - - if (typeof value === 'string') { - _this.value = value.trim(); - } else if (value) { - _this.value = value; - } else { - _this.value = ''; - } - - _this.isVariable = isVariable; - _this._index = index; - _this._fileInfo = currentFileInfo; - - _this.copyVisibilityInfo(visibilityInfo); - - _this.setParent(_this.combinator, _assertThisInitialized(_this)); - - return _this; - } - - _createClass(Element, [{ - key: "accept", - value: function accept(visitor) { - var value = this.value; - this.combinator = visitor.visit(this.combinator); - - if (_typeof(value) === 'object') { - this.value = visitor.visit(value); + var unitConversions = { + length: { + 'm': 1, + 'cm': 0.01, + 'mm': 0.001, + 'in': 0.0254, + 'px': 0.0254 / 96, + 'pt': 0.0254 / 72, + 'pc': 0.0254 / 72 * 12 + }, + duration: { + 's': 1, + 'ms': 0.001 + }, + angle: { + 'rad': 1 / (2 * Math.PI), + 'deg': 1 / 360, + 'grad': 1 / 400, + 'turn': 1 } - } - }, { - key: "eval", - value: function _eval(context) { - return new Element(this.combinator, this.value.eval ? this.value.eval(context) : this.value, this.isVariable, this.getIndex(), this.fileInfo(), this.visibilityInfo()); - } - }, { - key: "clone", - value: function clone() { - return new Element(this.combinator, this.value, this.isVariable, this.getIndex(), this.fileInfo(), this.visibilityInfo()); - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - output.add(this.toCSS(context), this.fileInfo(), this.getIndex()); - } - }, { - key: "toCSS", - value: function toCSS() { - var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var value = this.value; - var firstSelector = context.firstSelector; + }; - if (value instanceof Paren) { - // selector in parens should not be affected by outer selector - // flags (breaks only interpolated selectors - see #1973) - context.firstSelector = true; + var data = { colors: colors, unitConversions: unitConversions }; + + /** + * The reason why Node is a class and other nodes simply do not extend + * from Node (since we're transpiling) is due to this issue: + * + * https://github.com/less/less.js/issues/3434 + */ + var Node = /** @class */ (function () { + function Node() { + this.parent = null; + this.visibilityBlocks = undefined; + this.nodeVisible = undefined; + this.rootNode = null; + this.parsed = null; } - - value = value.toCSS ? value.toCSS(context) : value; - context.firstSelector = firstSelector; - - if (value === '' && this.combinator.value.charAt(0) === '&') { - return ''; - } else { - return this.combinator.toCSS(context) + value; - } - } - }]); - - return Element; - }(Node); - - Element.prototype.type = 'Element'; - - var Math$1 = { - ALWAYS: 0, - PARENS_DIVISION: 1, - PARENS: 2, - STRICT_LEGACY: 3 - }; - var RewriteUrls = { - OFF: 0, - LOCAL: 1, - ALL: 2 - }; - - function createCommonjsModule(fn, module) { - return module = { exports: {} }, fn(module, module.exports), module.exports; - } - - var clone_1 = createCommonjsModule(function (module) { - var clone = (function() { - - function _instanceof(obj, type) { - return type != null && obj instanceof type; - } - - var nativeMap; - try { - nativeMap = Map; - } catch(_) { - // maybe a reference error because no `Map`. Give it a dummy value that no - // value will ever be an instanceof. - nativeMap = function() {}; - } - - var nativeSet; - try { - nativeSet = Set; - } catch(_) { - nativeSet = function() {}; - } - - var nativePromise; - try { - nativePromise = Promise; - } catch(_) { - nativePromise = function() {}; - } - - /** - * Clones (copies) an Object using deep copying. - * - * This function supports circular references by default, but if you are certain - * there are no circular references in your object, you can save some CPU time - * by calling clone(obj, false). - * - * Caution: if `circular` is false and `parent` contains circular references, - * your program may enter an infinite loop and crash. - * - * @param `parent` - the object to be cloned - * @param `circular` - set to true if the object to be cloned may contain - * circular references. (optional - true by default) - * @param `depth` - set to a number if the object is only to be cloned to - * a particular depth. (optional - defaults to Infinity) - * @param `prototype` - sets the prototype to be used when cloning an object. - * (optional - defaults to parent prototype). - * @param `includeNonEnumerable` - set to true if the non-enumerable properties - * should be cloned as well. Non-enumerable properties on the prototype - * chain will be ignored. (optional - false by default) - */ - function clone(parent, circular, depth, prototype, includeNonEnumerable) { - if (typeof circular === 'object') { - depth = circular.depth; - prototype = circular.prototype; - includeNonEnumerable = circular.includeNonEnumerable; - circular = circular.circular; - } - // maintain two arrays for circular references, where corresponding parents - // and children have the same index - var allParents = []; - var allChildren = []; - - var useBuffer = typeof Buffer != 'undefined'; - - if (typeof circular == 'undefined') - circular = true; - - if (typeof depth == 'undefined') - depth = Infinity; - - // recurse this function so we don't reset allParents and allChildren - function _clone(parent, depth) { - // cloning null always returns null - if (parent === null) - return null; - - if (depth === 0) - return parent; - - var child; - var proto; - if (typeof parent != 'object') { - return parent; - } - - if (_instanceof(parent, nativeMap)) { - child = new nativeMap(); - } else if (_instanceof(parent, nativeSet)) { - child = new nativeSet(); - } else if (_instanceof(parent, nativePromise)) { - child = new nativePromise(function (resolve, reject) { - parent.then(function(value) { - resolve(_clone(value, depth - 1)); - }, function(err) { - reject(_clone(err, depth - 1)); - }); + Object.defineProperty(Node.prototype, "currentFileInfo", { + get: function () { + return this.fileInfo(); + }, + enumerable: false, + configurable: true }); - } else if (clone.__isArray(parent)) { - child = []; - } else if (clone.__isRegExp(parent)) { - child = new RegExp(parent.source, __getRegExpFlags(parent)); - if (parent.lastIndex) child.lastIndex = parent.lastIndex; - } else if (clone.__isDate(parent)) { - child = new Date(parent.getTime()); - } else if (useBuffer && Buffer.isBuffer(parent)) { - if (Buffer.allocUnsafe) { - // Node.js >= 4.5.0 - child = Buffer.allocUnsafe(parent.length); - } else { - // Older Node.js versions - child = new Buffer(parent.length); + Object.defineProperty(Node.prototype, "index", { + get: function () { + return this.getIndex(); + }, + enumerable: false, + configurable: true + }); + 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, { + add: function (chunk, fileInfo, index) { + strs.push(chunk); + }, + isEmpty: function () { + return strs.length === 0; + } + }); + return strs.join(''); + }; + Node.prototype.genCSS = function (context, output) { + output.add(this.value); + }; + Node.prototype.accept = function (visitor) { + this.value = visitor.visit(this.value); + }; + Node.prototype.eval = function () { return this; }; + Node.prototype._operate = function (context, op, a, b) { + switch (op) { + case '+': return a + b; + case '-': return a - b; + case '*': return a * b; + case '/': return 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) ? Number((value + 2e-16).toFixed(precision)) : value; + }; + Node.compare = function (a, b) { + /* returns: + -1: a < b + 0: a = b + 1: a > b + and *any* other value for a != b (e.g. undefined, NaN, -2 etc.) */ + if ((a.compare) && + // for "symmetric results" force toCSS-based comparison + // of Quoted or Anonymous if either value is one of those + !(b.type === 'Quoted' || b.type === 'Anonymous')) { + return a.compare(b); + } + else if (b.compare) { + return -b.compare(a); + } + else if (a.type !== b.type) { + return undefined; + } + a = a.value; + b = b.value; + if (!Array.isArray(a)) { + return a === b ? 0 : undefined; + } + if (a.length !== b.length) { + return undefined; + } + for (var i = 0; i < a.length; i++) { + if (Node.compare(a[i], b[i]) !== 0) { + return undefined; + } + } + return 0; + }; + Node.numericCompare = function (a, b) { + return a < b ? -1 + : a === b ? 0 + : a > b ? 1 : undefined; + }; + // Returns true if this node represents root of ast imported by reference + Node.prototype.blocksVisibility = function () { + if (this.visibilityBlocks == null) { + this.visibilityBlocks = 0; + } + return this.visibilityBlocks !== 0; + }; + Node.prototype.addVisibilityBlock = function () { + if (this.visibilityBlocks == null) { + this.visibilityBlocks = 0; + } + this.visibilityBlocks = this.visibilityBlocks + 1; + }; + Node.prototype.removeVisibilityBlock = function () { + if (this.visibilityBlocks == null) { + this.visibilityBlocks = 0; + } + 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 + 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 + Node.prototype.ensureInvisibility = function () { + this.nodeVisible = false; + }; + // return values: + // false - the node must not be visible + // true - the node must be visible + // undefined or null - the node has the same visibility as its parent + Node.prototype.isVisible = function () { + return this.nodeVisible; + }; + Node.prototype.visibilityInfo = function () { + return { + visibilityBlocks: this.visibilityBlocks, + nodeVisible: this.nodeVisible + }; + }; + Node.prototype.copyVisibilityInfo = function (info) { + if (!info) { + return; + } + this.visibilityBlocks = info.visibilityBlocks; + this.nodeVisible = info.nodeVisible; + }; + return Node; + }()); + + // + // RGB Colors - #ff0014, #eee + // + var Color = function (rgb, a, originalForm) { + var self = this; + // + // The end goal here, is to parse the arguments + // into an integer triplet, such as `128, 255, 0` + // + // This facilitates operations and conversions. + // + if (Array.isArray(rgb)) { + this.rgb = rgb; } - parent.copy(child); - return child; - } else if (_instanceof(parent, Error)) { - child = Object.create(parent); - } else { - if (typeof prototype == 'undefined') { - proto = Object.getPrototypeOf(parent); - child = Object.create(proto); + else if (rgb.length >= 6) { + this.rgb = []; + rgb.match(/.{2}/g).map(function (c, i) { + if (i < 3) { + self.rgb.push(parseInt(c, 16)); + } + else { + self.alpha = (parseInt(c, 16)) / 255; + } + }); } else { - child = Object.create(prototype); - proto = prototype; - } - } - - if (circular) { - var index = allParents.indexOf(parent); - - if (index != -1) { - return allChildren[index]; - } - allParents.push(parent); - allChildren.push(child); - } - - if (_instanceof(parent, nativeMap)) { - parent.forEach(function(value, key) { - var keyChild = _clone(key, depth - 1); - var valueChild = _clone(value, depth - 1); - child.set(keyChild, valueChild); - }); - } - if (_instanceof(parent, nativeSet)) { - parent.forEach(function(value) { - var entryChild = _clone(value, depth - 1); - child.add(entryChild); - }); - } - - for (var i in parent) { - var attrs; - if (proto) { - attrs = Object.getOwnPropertyDescriptor(proto, i); - } - - if (attrs && attrs.set == null) { - continue; - } - child[i] = _clone(parent[i], depth - 1); - } - - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(parent); - for (var i = 0; i < symbols.length; i++) { - // Don't need to worry about cloning a symbol because it is a primitive, - // like a number or string. - var symbol = symbols[i]; - var descriptor = Object.getOwnPropertyDescriptor(parent, symbol); - if (descriptor && !descriptor.enumerable && !includeNonEnumerable) { - continue; - } - child[symbol] = _clone(parent[symbol], depth - 1); - if (!descriptor.enumerable) { - Object.defineProperty(child, symbol, { - enumerable: false + this.rgb = []; + rgb.split('').map(function (c, i) { + if (i < 3) { + self.rgb.push(parseInt(c + c, 16)); + } + else { + self.alpha = (parseInt(c + c, 16)) / 255; + } }); - } } - } - - if (includeNonEnumerable) { - var allPropertyNames = Object.getOwnPropertyNames(parent); - for (var i = 0; i < allPropertyNames.length; i++) { - var propertyName = allPropertyNames[i]; - var descriptor = Object.getOwnPropertyDescriptor(parent, propertyName); - if (descriptor && descriptor.enumerable) { - continue; - } - child[propertyName] = _clone(parent[propertyName], depth - 1); - Object.defineProperty(child, propertyName, { - enumerable: false - }); + this.alpha = this.alpha || (typeof a === 'number' ? a : 1); + if (typeof originalForm !== 'undefined') { + this.value = originalForm; } - } - - return child; - } - - return _clone(parent, depth); - } - - /** - * Simple flat clone using prototype, accepts only objects, usefull for property - * override on FLAT configuration object (no nested props). - * - * USE WITH CAUTION! This may not behave as you wish if you do not know how this - * works. - */ - clone.clonePrototype = function clonePrototype(parent) { - if (parent === null) - return null; - - var c = function () {}; - c.prototype = parent; - return new c(); - }; - - // private utility functions - - function __objToStr(o) { - return Object.prototype.toString.call(o); - } - clone.__objToStr = __objToStr; - - function __isDate(o) { - return typeof o === 'object' && __objToStr(o) === '[object Date]'; - } - clone.__isDate = __isDate; - - function __isArray(o) { - return typeof o === 'object' && __objToStr(o) === '[object Array]'; - } - clone.__isArray = __isArray; - - function __isRegExp(o) { - return typeof o === 'object' && __objToStr(o) === '[object RegExp]'; - } - clone.__isRegExp = __isRegExp; - - function __getRegExpFlags(re) { - var flags = ''; - if (re.global) flags += 'g'; - if (re.ignoreCase) flags += 'i'; - if (re.multiline) flags += 'm'; - return flags; - } - clone.__getRegExpFlags = __getRegExpFlags; - - return clone; - })(); - - if ( module.exports) { - module.exports = clone; - } - }); - - /* jshint proto: true */ - function getLocation(index, inputStream) { - var n = index + 1; - var line = null; - var column = -1; - - while (--n >= 0 && inputStream.charAt(n) !== '\n') { - column++; - } - - if (typeof index === 'number') { - line = (inputStream.slice(0, index).match(/\n/g) || '').length; - } - - return { - line: line, - column: column }; - } - function copyArray(arr) { - var i; - var length = arr.length; - var copy = new Array(length); - - for (i = 0; i < length; i++) { - copy[i] = arr[i]; - } - - return copy; - } - function clone(obj) { - var cloned = {}; - - for (var prop in obj) { - if (obj.hasOwnProperty(prop)) { - cloned[prop] = obj[prop]; - } - } - - return cloned; - } - function defaults(obj1, obj2) { - var newObj = obj2 || {}; - - if (!obj2._defaults) { - newObj = {}; - - var _defaults = clone_1(obj1); - - newObj._defaults = _defaults; - var cloned = obj2 ? clone_1(obj2) : {}; - Object.assign(newObj, _defaults, cloned); - } - - return newObj; - } - function copyOptions(obj1, obj2) { - if (obj2 && obj2._defaults) { - return obj2; - } - - var opts = defaults(obj1, obj2); - - if (opts.strictMath) { - opts.math = Math$1.STRICT_LEGACY; - } // Back compat with changed relativeUrls option - - - if (opts.relativeUrls) { - opts.rewriteUrls = RewriteUrls.ALL; - } - - if (typeof opts.math === 'string') { - switch (opts.math.toLowerCase()) { - case 'always': - opts.math = Math$1.ALWAYS; - break; - - case 'parens-division': - opts.math = Math$1.PARENS_DIVISION; - break; - - case 'strict': - case 'parens': - opts.math = Math$1.PARENS; - break; - - case 'strict-legacy': - opts.math = Math$1.STRICT_LEGACY; - } - } - - if (typeof opts.rewriteUrls === 'string') { - switch (opts.rewriteUrls.toLowerCase()) { - case 'off': - opts.rewriteUrls = RewriteUrls.OFF; - break; - - case 'local': - opts.rewriteUrls = RewriteUrls.LOCAL; - break; - - case 'all': - opts.rewriteUrls = RewriteUrls.ALL; - break; - } - } - - return opts; - } - function merge(obj1, obj2) { - for (var prop in obj2) { - if (obj2.hasOwnProperty(prop)) { - obj1[prop] = obj2[prop]; - } - } - - return obj1; - } - function flattenArray(arr) { - var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - - for (var i = 0, length = arr.length; i < length; i++) { - var value = arr[i]; - - if (Array.isArray(value)) { - flattenArray(value, result); - } else { - if (value !== undefined) { - result.push(value); - } - } - } - - return result; - } - - var utils = /*#__PURE__*/Object.freeze({ - getLocation: getLocation, - copyArray: copyArray, - clone: clone, - defaults: defaults, - copyOptions: copyOptions, - merge: merge, - flattenArray: flattenArray - }); - - /** - * 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} fileContentMap - An object with file contents in 'contents' property (like importManager) @todo - move to fileManager? - * @param {string} [currentFilename] - */ - - var LessError = function LessError(e, fileContentMap, currentFilename) { - Error.call(this); - var filename = e.filename || currentFilename; - this.message = e.message; - this.stack = e.stack; - - if (fileContentMap && filename) { - var input = fileContentMap.contents[filename]; - var loc = getLocation(e.index, input); - var line = loc.line; - var col = loc.column; - var callLine = e.call && getLocation(e.call, input).line; - var lines = input ? input.split('\n') : ''; - this.type = e.type || 'Syntax'; - 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.extract = [lines[this.line - 2], lines[this.line - 1], lines[this.line]]; - } - }; - - if (typeof Object.create === 'undefined') { - var F = function F() {}; - - F.prototype = Error.prototype; - LessError.prototype = new F(); - } else { - LessError.prototype = Object.create(Error.prototype); - } - - LessError.prototype.constructor = LessError; - /** - * 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 () { - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - var message = ''; - var extract = this.extract || []; - var error = []; - - var stylize = function stylize(str) { - return str; - }; - - if (options.stylize) { - var type = _typeof(options.stylize); - - if (type !== 'function') { - throw Error("options.stylize should be a function, got a ".concat(type, "!")); - } - - stylize = options.stylize; - } - - if (this.line !== null) { - if (typeof extract[0] === 'string') { - error.push(stylize("".concat(this.line - 1, " ").concat(extract[0]), 'grey')); - } - - if (typeof extract[1] === 'string') { - var errorTxt = "".concat(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("".concat(this.line + 1, " ").concat(extract[2]), 'grey')); - } - - error = "".concat(error.join('\n') + stylize('', 'reset'), "\n"); - } - - message += stylize("".concat(this.type, "Error: ").concat(this.message), 'red'); - - if (this.filename) { - message += stylize(' in ', 'red') + this.filename; - } - - if (this.line) { - message += stylize(" on line ".concat(this.line, ", column ").concat(this.column + 1, ":"), 'grey'); - } - - message += "\n".concat(error); - - if (this.callLine) { - message += "".concat(stylize('from ', 'red') + (this.filename || ''), "/n"); - message += "".concat(stylize(this.callLine, 'grey'), " ").concat(this.callExtract, "/n"); - } - - return message; - }; - - var Selector = - /*#__PURE__*/ - function (_Node) { - _inherits(Selector, _Node); - - function Selector(elements, extendList, condition, index, currentFileInfo, visibilityInfo) { - var _this; - - _classCallCheck(this, Selector); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Selector).call(this)); - _this.extendList = extendList; - _this.condition = condition; - _this.evaldCondition = !condition; - _this._index = index; - _this._fileInfo = currentFileInfo; - _this.elements = _this.getElements(elements); - _this.mixinElements_ = undefined; - - _this.copyVisibilityInfo(visibilityInfo); - - _this.setParent(_this.elements, _assertThisInitialized(_this)); - - return _this; - } - - _createClass(Selector, [{ - key: "accept", - value: function accept(visitor) { - if (this.elements) { - this.elements = visitor.visitArray(this.elements); - } - - if (this.extendList) { - this.extendList = visitor.visitArray(this.extendList); - } - - if (this.condition) { - this.condition = visitor.visit(this.condition); - } - } - }, { - key: "createDerived", - value: function createDerived(elements, extendList, 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; - } - }, { - key: "getElements", - value: function getElements(els) { - if (!els) { - return [new Element('', '&', false, this._index, this._fileInfo)]; - } - - 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); + Color.prototype = Object.assign(new Node(), { + type: 'Color', + luma: function () { + var r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255; + r = (r <= 0.03928) ? r / 12.92 : Math.pow(((r + 0.055) / 1.055), 2.4); + g = (g <= 0.03928) ? g / 12.92 : Math.pow(((g + 0.055) / 1.055), 2.4); + b = (b <= 0.03928) ? b / 12.92 : Math.pow(((b + 0.055) / 1.055), 2.4); + return 0.2126 * r + 0.7152 * g + 0.0722 * b; + }, + genCSS: function (context, output) { + output.add(this.toCSS(context)); + }, + toCSS: function (context, doNotCompress) { + var compress = context && context.compress && !doNotCompress; + var color; + var alpha; + var colorFunction; + var args = []; + // `value` is set if this color was originally + // converted from a named color string so we need + // to respect this and try to output named color too. + alpha = this.fround(context, this.alpha); + if (this.value) { + if (this.value.indexOf('rgb') === 0) { + if (alpha < 1) { + colorFunction = 'rgba'; + } + } + else if (this.value.indexOf('hsl') === 0) { + if (alpha < 1) { + colorFunction = 'hsla'; + } + else { + colorFunction = 'hsl'; + } + } + else { + return this.value; + } } - - els = result[0].elements; - }); - } - - return els; - } - }, { - key: "createEmptySelectors", - value: function createEmptySelectors() { - var el = new Element('', '&', false, this._index, this._fileInfo); - var sels = [new Selector([el], null, null, this._index, this._fileInfo)]; - sels[0].mediaEmpty = true; - return sels; - } - }, { - key: "match", - value: function match(other) { - var elements = this.elements; - var len = elements.length; - var olen; - var i; - 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[i]) { - return 0; + else { + if (alpha < 1) { + colorFunction = 'rgba'; + } } - } + switch (colorFunction) { + case 'rgba': + args = this.rgb.map(function (c) { + return clamp$1(Math.round(c), 255); + }).concat(clamp$1(alpha, 1)); + break; + case 'hsla': + args.push(clamp$1(alpha, 1)); + case 'hsl': + color = this.toHSL(); + args = [ + this.fround(context, color.h), + this.fround(context, color.s * 100) + "%", + this.fround(context, color.l * 100) + "%" + ].concat(args); + } + if (colorFunction) { + // Values are capped between `0` and `255`, rounded and zero-padded. + return colorFunction + "(" + args.join("," + (compress ? '' : ' ')) + ")"; + } + color = this.toRGB(); + if (compress) { + var splitcolor = color.split(''); + // Convert color to short format + if (splitcolor[1] === splitcolor[2] && splitcolor[3] === splitcolor[4] && splitcolor[5] === splitcolor[6]) { + color = "#" + splitcolor[1] + splitcolor[3] + splitcolor[5]; + } + } + return color; + }, + // + // Operations have to be done per-channel, if not, + // channels will spill onto each other. Once we have + // our result, in the form of an integer triplet, + // we create a new Color node to hold the result. + // + operate: function (context, op, other) { + 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]); + } + return new Color(rgb, alpha); + }, + toRGB: function () { + return toHex(this.rgb); + }, + toHSL: function () { + var r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255, a = this.alpha; + var max = Math.max(r, g, b), min = Math.min(r, g, b); + var h; + var s; + var l = (max + min) / 2; + var d = max - min; + if (max === min) { + h = s = 0; + } + else { + s = l > 0.5 ? d / (2 - max - min) : d / (max + min); + 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; + } + h /= 6; + } + 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 + toHSV: function () { + var r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255, a = this.alpha; + var max = Math.max(r, g, b), min = Math.min(r, g, b); + var h; + var s; + var v = max; + var d = max - min; + if (max === 0) { + s = 0; + } + else { + s = d / max; + } + if (max === min) { + h = 0; + } + else { + 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; + } + h /= 6; + } + return { h: h * 360, s: s, v: v, a: a }; + }, + toARGB: function () { + return toHex([this.alpha * 255].concat(this.rgb)); + }, + compare: function (x) { + return (x.rgb && + x.rgb[0] === this.rgb[0] && + x.rgb[1] === this.rgb[1] && + x.rgb[2] === this.rgb[2] && + x.alpha === this.alpha) ? 0 : undefined; } - - return olen; // return number of matched elements - } - }, { - key: "mixinElements", - value: function mixinElements() { - if (this.mixinElements_) { - return this.mixinElements_; + }); + Color.fromKeyword = function (keyword) { + var c; + var key = keyword.toLowerCase(); + if (colors.hasOwnProperty(key)) { + c = new Color(colors[key].slice(1)); } - - var elements = this.elements.map(function (v) { - return v.combinator.value + (v.value.value || v.value); - }).join('').match(/[,&#\*\.\w-]([\w-]|(\\.))*/g); - - if (elements) { - if (elements[0] === '&') { - elements.shift(); - } - } else { - elements = []; + else if (key === 'transparent') { + c = new Color([0, 0, 0], 0); } - - return this.mixinElements_ = elements; - } - }, { - key: "isJustParentSelector", - value: function isJustParentSelector() { - return !this.mediaEmpty && this.elements.length === 1 && this.elements[0].value === '&' && (this.elements[0].combinator.value === ' ' || this.elements[0].combinator.value === ''); - } - }, { - key: "eval", - value: function _eval(context) { - var evaldCondition = this.condition && this.condition.eval(context); - var elements = this.elements; - var extendList = this.extendList; - elements = elements && elements.map(function (e) { - return e.eval(context); - }); - extendList = extendList && extendList.map(function (extend) { - return extend.eval(context); - }); - return this.createDerived(elements, extendList, evaldCondition); - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - var i; - var element; - - if ((!context || !context.firstSelector) && this.elements[0].combinator.value === '') { - output.add(' ', this.fileInfo(), this.getIndex()); + if (c) { + c.value = keyword; + return c; } - - for (i = 0; i < this.elements.length; i++) { - element = this.elements[i]; - element.genCSS(context, output); - } - } - }, { - key: "getIsOutput", - value: function getIsOutput() { - return this.evaldCondition; - } - }]); - - return Selector; - }(Node); - - Selector.prototype.type = 'Selector'; - - var Value = - /*#__PURE__*/ - function (_Node) { - _inherits(Value, _Node); - - function Value(value) { - var _this; - - _classCallCheck(this, Value); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Value).call(this)); - - if (!value) { - throw new Error('Value requires an array argument'); - } - - if (!Array.isArray(value)) { - _this.value = [value]; - } else { - _this.value = value; - } - - return _this; + }; + function clamp$1(v, max) { + return Math.min(Math.max(v, 0), max); + } + function toHex(v) { + return "#" + v.map(function (c) { + c = clamp$1(Math.round(c), 255); + return (c < 16 ? '0' : '') + c.toString(16); + }).join(''); } - _createClass(Value, [{ - key: "accept", - value: function accept(visitor) { - if (this.value) { - this.value = visitor.visitArray(this.value); + var Paren = function (node) { + this.value = node; + }; + Paren.prototype = Object.assign(new Node(), { + type: 'Paren', + genCSS: function (context, output) { + output.add('('); + this.value.genCSS(context, output); + output.add(')'); + }, + eval: function (context) { + return new Paren(this.value.eval(context)); } - } - }, { - key: "eval", - value: function _eval(context) { - if (this.value.length === 1) { - return this.value[0].eval(context); - } else { - return new Value(this.value.map(function (v) { - return v.eval(context); - })); + }); + + var _noSpaceCombinators = { + '': true, + ' ': true, + '|': true + }; + var Combinator = function (value) { + if (value === ' ') { + this.value = ' '; + this.emptyOrWhitespace = true; } - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - var i; - - for (i = 0; i < this.value.length; i++) { - this.value[i].genCSS(context, output); - - if (i + 1 < this.value.length) { - output.add(context && context.compress ? ',' : ', '); - } + else { + this.value = value ? value.trim() : ''; + this.emptyOrWhitespace = this.value === ''; } - } - }]); - - return Value; - }(Node); - - Value.prototype.type = 'Value'; - - var Keyword = - /*#__PURE__*/ - function (_Node) { - _inherits(Keyword, _Node); - - function Keyword(value) { - var _this; - - _classCallCheck(this, Keyword); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Keyword).call(this)); - _this.value = value; - return _this; - } - - _createClass(Keyword, [{ - key: "genCSS", - value: function genCSS(context, output) { - if (this.value === '%') { - throw { - type: 'Syntax', - message: 'Invalid % without number' - }; + }; + Combinator.prototype = Object.assign(new Node(), { + type: 'Combinator', + genCSS: function (context, output) { + var spaceOrEmpty = (context.compress || _noSpaceCombinators[this.value]) ? '' : ' '; + output.add(spaceOrEmpty + this.value + spaceOrEmpty); } + }); - output.add(this.value); - } - }]); - - return Keyword; - }(Node); - - Keyword.prototype.type = 'Keyword'; - Keyword.True = new Keyword('true'); - Keyword.False = new Keyword('false'); - - var Anonymous = - /*#__PURE__*/ - function (_Node) { - _inherits(Anonymous, _Node); - - function Anonymous(value, index, currentFileInfo, mapLines, rulesetLike, visibilityInfo) { - var _this; - - _classCallCheck(this, Anonymous); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Anonymous).call(this)); - _this.value = value; - _this._index = index; - _this._fileInfo = currentFileInfo; - _this.mapLines = mapLines; - _this.rulesetLike = typeof rulesetLike === 'undefined' ? false : rulesetLike; - _this.allowRoot = true; - - _this.copyVisibilityInfo(visibilityInfo); - - return _this; - } - - _createClass(Anonymous, [{ - key: "eval", - value: function _eval() { - return new Anonymous(this.value, this._index, this._fileInfo, this.mapLines, this.rulesetLike, this.visibilityInfo()); - } - }, { - key: "compare", - value: function compare(other) { - return other.toCSS && this.toCSS() === other.toCSS() ? 0 : undefined; - } - }, { - key: "isRulesetLike", - value: function isRulesetLike() { - return this.rulesetLike; - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - this.nodeVisible = Boolean(this.value); - - if (this.nodeVisible) { - output.add(this.value, this._fileInfo, this._index, this.mapLines); + var Element = function (combinator, value, isVariable, index, currentFileInfo, visibilityInfo) { + this.combinator = combinator instanceof Combinator ? + combinator : new Combinator(combinator); + if (typeof value === 'string') { + this.value = value.trim(); } - } - }]); - - return Anonymous; - }(Node); - - Anonymous.prototype.type = 'Anonymous'; - - var MATH = Math$1; - - var Declaration = - /*#__PURE__*/ - function (_Node) { - _inherits(Declaration, _Node); - - function Declaration(name, value, important, merge, index, currentFileInfo, inline, variable) { - var _this; - - _classCallCheck(this, Declaration); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Declaration).call(this)); - _this.name = name; - _this.value = value instanceof Node ? value : new Value([value ? new Anonymous(value) : null]); - _this.important = important ? " ".concat(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, _assertThisInitialized(_this)); - - return _this; - } - - _createClass(Declaration, [{ - key: "genCSS", - value: function genCSS(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; + else if (value) { + this.value = value; } - - output.add(this.important + (this.inline || context.lastRule && context.compress ? '' : ';'), this._fileInfo, this._index); - } - }, { - key: "eval", - value: function _eval(context) { - var mathBypass = false; - var prevMath; - var name = this.name; - var evaldValue; - var 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 - } // @todo remove when parens-division is default - - - if (name === 'font' && context.math === MATH.ALWAYS) { - mathBypass = true; - prevMath = context.math; - context.math = MATH.PARENS_DIVISION; + else { + this.value = ''; } - - 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; - var 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 (mathBypass) { - context.math = prevMath; - } + this.isVariable = isVariable; + this._index = index; + this._fileInfo = currentFileInfo; + this.copyVisibilityInfo(visibilityInfo); + this.setParent(this.combinator, this); + }; + Element.prototype = Object.assign(new Node(), { + type: 'Element', + accept: function (visitor) { + var value = this.value; + this.combinator = visitor.visit(this.combinator); + if (typeof value === 'object') { + this.value = visitor.visit(value); + } + }, + eval: function (context) { + return new Element(this.combinator, this.value.eval ? this.value.eval(context) : this.value, this.isVariable, this.getIndex(), this.fileInfo(), this.visibilityInfo()); + }, + clone: function () { + return new Element(this.combinator, this.value, this.isVariable, this.getIndex(), this.fileInfo(), this.visibilityInfo()); + }, + genCSS: function (context, output) { + output.add(this.toCSS(context), this.fileInfo(), this.getIndex()); + }, + toCSS: function (context) { + context = context || {}; + var value = this.value; + var firstSelector = context.firstSelector; + if (value instanceof Paren) { + // selector in parens should not be affected by outer selector + // flags (breaks only interpolated selectors - see #1973) + context.firstSelector = true; + } + value = value.toCSS ? value.toCSS(context) : value; + context.firstSelector = firstSelector; + if (value === '' && this.combinator.value.charAt(0) === '&') { + return ''; + } + else { + return this.combinator.toCSS(context) + value; + } } - } - }, { - key: "makeImportant", - value: function makeImportant() { - return new Declaration(this.name, this.value, '!important', this.merge, this.getIndex(), this.fileInfo(), this.inline); - } - }]); + }); - return Declaration; - }(Node); - - function evalName(context, name) { - var value = ''; - var i; - var n = name.length; - var output = { - add: function add(s) { - value += s; - } + var Math$1 = { + ALWAYS: 0, + PARENS_DIVISION: 1, + PARENS: 2 + // removed - STRICT_LEGACY: 3 + }; + var RewriteUrls = { + OFF: 0, + LOCAL: 1, + ALL: 2 }; - for (i = 0; i < n; i++) { - name[i].eval(context).genCSS(context, output); + /** + * Returns the object type of the given payload + * + * @param {*} payload + * @returns {string} + */ + function getType(payload) { + return Object.prototype.toString.call(payload).slice(8, -1); + } + /** + * Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes) + * + * @param {*} payload + * @returns {payload is Record} + */ + function isPlainObject(payload) { + if (getType(payload) !== 'Object') + return false; + return payload.constructor === Object && Object.getPrototypeOf(payload) === Object.prototype; + } + /** + * Returns whether the payload is an array + * + * @param {any} payload + * @returns {payload is any[]} + */ + function isArray(payload) { + return getType(payload) === 'Array'; } - return value; - } + /*! ***************************************************************************** + Copyright (c) Microsoft Corporation. All rights reserved. + Licensed under the Apache License, Version 2.0 (the "License"); you may not use + this file except in compliance with the License. You may obtain a copy of the + License at http://www.apache.org/licenses/LICENSE-2.0 - Declaration.prototype.type = 'Declaration'; + THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED + WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, + MERCHANTABLITY OR NON-INFRINGEMENT. - var debugInfo = function debugInfo(context, ctx, lineSeparator) { - var result = ''; + See the Apache Version 2.0 License for specific language governing permissions + and limitations under the License. + ***************************************************************************** */ - if (context.dumpLineNumbers && !context.compress) { - switch (context.dumpLineNumbers) { - case 'comments': - result = debugInfo.asComment(ctx); - break; - - case 'mediaquery': - result = debugInfo.asMediaQuery(ctx); - break; - - case 'all': - result = debugInfo.asComment(ctx) + (lineSeparator || '') + debugInfo.asMediaQuery(ctx); - break; - } + function __spreadArrays() { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; } - return result; - }; - - debugInfo.asComment = function (ctx) { - return "/* line ".concat(ctx.debugInfo.lineNumber, ", ").concat(ctx.debugInfo.fileName, " */\n"); - }; - - debugInfo.asMediaQuery = function (ctx) { - var filenameWithProtocol = ctx.debugInfo.fileName; - - if (!/^[a-z]+:\/\//i.test(filenameWithProtocol)) { - filenameWithProtocol = "file://".concat(filenameWithProtocol); - } - - return "@media -sass-debug-info{filename{font-family:".concat(filenameWithProtocol.replace(/([.:\/\\])/g, function (a) { - if (a == '\\') { - a = '\/'; - } - - return "\\".concat(a); - }), "}line{font-family:\\00003").concat(ctx.debugInfo.lineNumber, "}}\n"); - }; - - var Comment = - /*#__PURE__*/ - function (_Node) { - _inherits(Comment, _Node); - - function Comment(value, isLineComment, index, currentFileInfo) { - var _this; - - _classCallCheck(this, Comment); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Comment).call(this)); - _this.value = value; - _this.isLineComment = isLineComment; - _this._index = index; - _this._fileInfo = currentFileInfo; - _this.allowRoot = true; - return _this; - } - - _createClass(Comment, [{ - key: "genCSS", - value: function genCSS(context, output) { - if (this.debugInfo) { - output.add(debugInfo(context, this), this.fileInfo(), this.getIndex()); + function assignProp(carry, key, newVal, originalObject, includeNonenumerable) { + var propType = {}.propertyIsEnumerable.call(originalObject, key) + ? 'enumerable' + : 'nonenumerable'; + if (propType === 'enumerable') + carry[key] = newVal; + if (includeNonenumerable && propType === 'nonenumerable') { + Object.defineProperty(carry, key, { + value: newVal, + enumerable: false, + writable: true, + configurable: true, + }); } - - output.add(this.value); - } - }, { - key: "isSilent", - value: function isSilent(context) { - var isCompressed = context.compress && this.value[2] !== '!'; - return this.isLineComment || isCompressed; - } - }]); - - return Comment; - }(Node); - - Comment.prototype.type = 'Comment'; - - var contexts = {}; - - var copyFromOriginal = function copyFromOriginal(original, destination, propertiesToCopy) { - if (!original) { - return; + } + /** + * Copy (clone) an object and all its props recursively to get rid of any prop referenced of the original object. Arrays are also cloned, however objects inside arrays are still linked. + * + * @export + * @template T + * @param {T} target Target can be anything + * @param {Options} [options={}] Options can be `props` or `nonenumerable` + * @returns {T} the target with replaced values + * @export + */ + function copy(target, options) { + if (options === void 0) { options = {}; } + if (isArray(target)) + return target.map(function (i) { return copy(i, options); }); + if (!isPlainObject(target)) + return target; + var props = Object.getOwnPropertyNames(target); + var symbols = Object.getOwnPropertySymbols(target); + return __spreadArrays(props, symbols).reduce(function (carry, key) { + if (isArray(options.props) && !options.props.includes(key)) { + return carry; + } + var val = target[key]; + var newVal = copy(val, options); + assignProp(carry, key, newVal, target, options.nonenumerable); + return carry; + }, {}); } - for (var i = 0; i < propertiesToCopy.length; i++) { - if (original.hasOwnProperty(propertiesToCopy[i])) { - destination[propertiesToCopy[i]] = original[propertiesToCopy[i]]; - } + /* jshint proto: true */ + function getLocation(index, inputStream) { + var n = index + 1; + var line = null; + var column = -1; + while (--n >= 0 && inputStream.charAt(n) !== '\n') { + column++; + } + if (typeof index === 'number') { + line = (inputStream.slice(0, index).match(/\n/g) || '').length; + } + return { + line: line, + column: column + }; } - }; - /* - parse is used whilst parsing - */ - - - var parseCopyProperties = [// options - 'paths', // option - unmodified - paths to search for imports on - 'rewriteUrls', // option - whether to adjust URL's to be relative - 'rootpath', // option - rootpath to append to URL's - 'strictImports', // option - - 'insecure', // option - whether to allow imports from insecure ssl hosts - 'dumpLineNumbers', // option - whether to dump line numbers - 'compress', // option - whether to compress - 'syncImport', // option - whether to import synchronously - 'chunkInput', // option - whether to chunk input. more performant but causes parse issues. - 'mime', // browser only - mime type for sheet import - 'useFileCache', // browser only - whether to use the per file session cache - // context - 'processImports', // option & context - whether to process imports. if false then imports will not be imported. - // Used by the import manager to stop multiple import visitors being created. - 'pluginManager' // Used as the plugin manager for the session - ]; - - contexts.Parse = function (options) { - copyFromOriginal(options, this, parseCopyProperties); - - if (typeof this.paths === 'string') { - this.paths = [this.paths]; + function copyArray(arr) { + var i; + var length = arr.length; + var copy = new Array(length); + for (i = 0; i < length; i++) { + copy[i] = arr[i]; + } + return copy; } - }; - - var evalCopyProperties = ['paths', // additional include paths - 'compress', // whether to compress - 'math', // 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 - 'rewriteUrls' // option - whether to adjust URL's to be relative - ]; - - function isPathRelative(path) { - return !/^(?:[a-z-]+:|\/|#)/i.test(path); - } - - function isPathLocalRelative(path) { - return path.charAt(0) === '.'; - } - - contexts.Eval = - /*#__PURE__*/ - function () { - function _class(options, frames) { - _classCallCheck(this, _class); - - copyFromOriginal(options, this, evalCopyProperties); - - if (typeof this.paths === 'string') { - this.paths = [this.paths]; - } - - this.frames = frames || []; - this.importantScope = this.importantScope || []; - this.inCalc = false; - this.mathOn = true; + function clone(obj) { + var cloned = {}; + for (var prop in obj) { + if (obj.hasOwnProperty(prop)) { + cloned[prop] = obj[prop]; + } + } + return cloned; + } + function defaults(obj1, obj2) { + var newObj = obj2 || {}; + if (!obj2._defaults) { + newObj = {}; + var defaults_1 = copy(obj1); + newObj._defaults = defaults_1; + var cloned = obj2 ? copy(obj2) : {}; + Object.assign(newObj, defaults_1, cloned); + } + return newObj; + } + function copyOptions(obj1, obj2) { + if (obj2 && obj2._defaults) { + return obj2; + } + var opts = defaults(obj1, obj2); + if (opts.strictMath) { + opts.math = Math$1.PARENS; + } + // Back compat with changed relativeUrls option + if (opts.relativeUrls) { + opts.rewriteUrls = RewriteUrls.ALL; + } + if (typeof opts.math === 'string') { + switch (opts.math.toLowerCase()) { + case 'always': + opts.math = Math$1.ALWAYS; + break; + case 'parens-division': + opts.math = Math$1.PARENS_DIVISION; + break; + case 'strict': + case 'parens': + opts.math = Math$1.PARENS; + break; + default: + opts.math = Math$1.PARENS; + } + } + if (typeof opts.rewriteUrls === 'string') { + switch (opts.rewriteUrls.toLowerCase()) { + case 'off': + opts.rewriteUrls = RewriteUrls.OFF; + break; + case 'local': + opts.rewriteUrls = RewriteUrls.LOCAL; + break; + case 'all': + opts.rewriteUrls = RewriteUrls.ALL; + break; + } + } + return opts; + } + function merge(obj1, obj2) { + for (var prop in obj2) { + if (obj2.hasOwnProperty(prop)) { + obj1[prop] = obj2[prop]; + } + } + return obj1; + } + function flattenArray(arr, result) { + if (result === void 0) { result = []; } + for (var i = 0, length_1 = arr.length; i < length_1; i++) { + var value = arr[i]; + if (Array.isArray(value)) { + flattenArray(value, result); + } + else { + if (value !== undefined) { + result.push(value); + } + } + } + return result; } - _createClass(_class, [{ - key: "enterCalc", - value: function enterCalc() { + var utils = /*#__PURE__*/Object.freeze({ + __proto__: null, + getLocation: getLocation, + copyArray: copyArray, + clone: clone, + defaults: defaults, + copyOptions: copyOptions, + merge: merge, + flattenArray: flattenArray + }); + + var anonymousFunc = /(|Function):(\d+):(\d+)/; + /** + * 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} fileContentMap - An object with file contents in 'contents' property (like importManager) @todo - move to fileManager? + * @param {string} [currentFilename] + */ + var LessError = function (e, fileContentMap, currentFilename) { + Error.call(this); + var filename = e.filename || currentFilename; + this.message = e.message; + this.stack = e.stack; + if (fileContentMap && filename) { + var input = fileContentMap.contents[filename]; + var loc = getLocation(e.index, input); + var line = loc.line; + var col = loc.column; + var callLine = e.call && getLocation(e.call, input).line; + var lines = input ? input.split('\n') : ''; + this.type = e.type || 'Syntax'; + 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(anonymousFunc); + /** + * We have to figure out how this environment stringifies anonymous functions + * so we can correctly map plugin errors. + * + * Note, in Node 8, the output of anonymous funcs varied based on parameters + * being present or not, so we inject dummy params. + */ + var func = new Function('a', 'throw new Error()'); + var lineAdjust = 0; + try { + func(); + } + catch (e) { + var match = e.stack.match(anonymousFunc); + var line = parseInt(match[2]); + lineAdjust = 1 - line; + } + if (found) { + if (found[2]) { + this.line = parseInt(found[2]) + lineAdjust; + } + if (found[3]) { + this.column = parseInt(found[3]); + } + } + } + this.callLine = callLine + 1; + this.callExtract = lines[callLine]; + this.extract = [ + lines[this.line - 2], + lines[this.line - 1], + lines[this.line] + ]; + } + }; + if (typeof Object.create === 'undefined') { + var F = function () { }; + F.prototype = Error.prototype; + LessError.prototype = new F(); + } + else { + LessError.prototype = Object.create(Error.prototype); + } + LessError.prototype.constructor = LessError; + /** + * 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; + }; + + var Selector = function (elements, extendList, condition, index, currentFileInfo, visibilityInfo) { + this.extendList = extendList; + this.condition = condition; + 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 = Object.assign(new Node(), { + type: 'Selector', + accept: function (visitor) { + if (this.elements) { + this.elements = visitor.visitArray(this.elements); + } + if (this.extendList) { + this.extendList = visitor.visitArray(this.extendList); + } + if (this.condition) { + this.condition = visitor.visit(this.condition); + } + }, + createDerived: function (elements, extendList, 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; + }, + getElements: function (els) { + if (!els) { + return [new Element('', '&', false, this._index, this._fileInfo)]; + } + 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; + }, + createEmptySelectors: function () { + var el = new Element('', '&', false, this._index, this._fileInfo), sels = [new Selector([el], null, null, this._index, this._fileInfo)]; + sels[0].mediaEmpty = true; + return sels; + }, + match: function (other) { + var elements = this.elements; + var len = elements.length; + var olen; + var i; + 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[i]) { + return 0; + } + } + } + return olen; // return number of matched elements + }, + mixinElements: function () { + if (this.mixinElements_) { + return this.mixinElements_; + } + var elements = this.elements.map(function (v) { + return v.combinator.value + (v.value.value || v.value); + }).join('').match(/[,&#\*\.\w-]([\w-]|(\\.))*/g); + if (elements) { + if (elements[0] === '&') { + elements.shift(); + } + } + else { + elements = []; + } + return (this.mixinElements_ = elements); + }, + isJustParentSelector: function () { + return !this.mediaEmpty && + this.elements.length === 1 && + this.elements[0].value === '&' && + (this.elements[0].combinator.value === ' ' || this.elements[0].combinator.value === ''); + }, + eval: function (context) { + var evaldCondition = this.condition && this.condition.eval(context); + var elements = this.elements; + var extendList = this.extendList; + elements = elements && elements.map(function (e) { return e.eval(context); }); + extendList = extendList && extendList.map(function (extend) { return extend.eval(context); }); + return this.createDerived(elements, extendList, evaldCondition); + }, + genCSS: function (context, output) { + var i, element; + if ((!context || !context.firstSelector) && this.elements[0].combinator.value === '') { + output.add(' ', this.fileInfo(), this.getIndex()); + } + for (i = 0; i < this.elements.length; i++) { + element = this.elements[i]; + element.genCSS(context, output); + } + }, + getIsOutput: function () { + return this.evaldCondition; + } + }); + + var Value = function (value) { + if (!value) { + throw new Error('Value requires an array argument'); + } + if (!Array.isArray(value)) { + this.value = [value]; + } + else { + this.value = value; + } + }; + Value.prototype = Object.assign(new Node(), { + type: 'Value', + accept: function (visitor) { + if (this.value) { + this.value = visitor.visitArray(this.value); + } + }, + eval: function (context) { + if (this.value.length === 1) { + return this.value[0].eval(context); + } + else { + return new Value(this.value.map(function (v) { + return v.eval(context); + })); + } + }, + genCSS: function (context, output) { + var i; + for (i = 0; i < this.value.length; i++) { + this.value[i].genCSS(context, output); + if (i + 1 < this.value.length) { + output.add((context && context.compress) ? ',' : ', '); + } + } + } + }); + + var Keyword = function (value) { + this.value = value; + }; + Keyword.prototype = Object.assign(new Node(), { + type: 'Keyword', + genCSS: function (context, output) { + if (this.value === '%') { + throw { type: 'Syntax', message: 'Invalid % without number' }; + } + output.add(this.value); + } + }); + Keyword.True = new Keyword('true'); + Keyword.False = new Keyword('false'); + + var Anonymous = function (value, index, currentFileInfo, mapLines, rulesetLike, visibilityInfo) { + this.value = value; + this._index = index; + this._fileInfo = currentFileInfo; + this.mapLines = mapLines; + this.rulesetLike = (typeof rulesetLike === 'undefined') ? false : rulesetLike; + this.allowRoot = true; + this.copyVisibilityInfo(visibilityInfo); + }; + Anonymous.prototype = Object.assign(new Node(), { + type: 'Anonymous', + eval: function () { + return new Anonymous(this.value, this._index, this._fileInfo, this.mapLines, this.rulesetLike, this.visibilityInfo()); + }, + compare: function (other) { + return other.toCSS && this.toCSS() === other.toCSS() ? 0 : undefined; + }, + isRulesetLike: function () { + return this.rulesetLike; + }, + genCSS: function (context, output) { + this.nodeVisible = Boolean(this.value); + if (this.nodeVisible) { + output.add(this.value, this._fileInfo, this._index, this.mapLines); + } + } + }); + + var MATH$1 = Math$1; + function evalName(context, name) { + var value = ''; + var i; + var n = name.length; + var output = { add: function (s) { value += s; } }; + for (i = 0; i < n; i++) { + name[i].eval(context).genCSS(context, output); + } + return value; + } + 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); + }; + Declaration.prototype = Object.assign(new Node(), { + type: 'Declaration', + 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); + }, + eval: function (context) { + var mathBypass = false, prevMath, 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 + } + // @todo remove when parens-division is default + if (name === 'font' && context.math === MATH$1.ALWAYS) { + mathBypass = true; + prevMath = context.math; + context.math = MATH$1.PARENS_DIVISION; + } + 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; + var 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 (mathBypass) { + context.math = prevMath; + } + } + }, + makeImportant: function () { + return new Declaration(this.name, this.value, '!important', this.merge, this.getIndex(), this.fileInfo(), this.inline); + } + }); + + var debugInfo = /** @class */ (function () { + function debugInfo(context, ctx, lineSeparator) { + var result = ''; + if (context.dumpLineNumbers && !context.compress) { + switch (context.dumpLineNumbers) { + case 'comments': + result = debugInfo.asComment(ctx); + break; + case 'mediaquery': + result = debugInfo.asMediaQuery(ctx); + break; + case 'all': + result = debugInfo.asComment(ctx) + (lineSeparator || '') + debugInfo.asMediaQuery(ctx); + break; + } + } + return result; + } + debugInfo.asComment = function (ctx) { + return "/* line " + ctx.debugInfo.lineNumber + ", " + ctx.debugInfo.fileName + " */\n"; + }; + debugInfo.asMediaQuery = function (ctx) { + var filenameWithProtocol = ctx.debugInfo.fileName; + if (!/^[a-z]+:\/\//i.test(filenameWithProtocol)) { + filenameWithProtocol = "file://" + filenameWithProtocol; + } + return "@media -sass-debug-info{filename{font-family:" + filenameWithProtocol.replace(/([.:\/\\])/g, function (a) { + if (a == '\\') { + a = '\/'; + } + return "\\" + a; + }) + "}line{font-family:\\00003" + ctx.debugInfo.lineNumber + "}}\n"; + }; + return debugInfo; + }()); + + var Comment = function (value, isLineComment, index, currentFileInfo) { + this.value = value; + this.isLineComment = isLineComment; + this._index = index; + this._fileInfo = currentFileInfo; + this.allowRoot = true; + }; + Comment.prototype = Object.assign(new Node(), { + type: 'Comment', + genCSS: function (context, output) { + if (this.debugInfo) { + output.add(debugInfo(context, this), this.fileInfo(), this.getIndex()); + } + output.add(this.value); + }, + isSilent: function (context) { + var isCompressed = context.compress && this.value[2] !== '!'; + return this.isLineComment || isCompressed; + } + }); + + var contexts = {}; + var copyFromOriginal = function copyFromOriginal(original, destination, propertiesToCopy) { + if (!original) { + return; + } + for (var i = 0; i < propertiesToCopy.length; i++) { + if (original.hasOwnProperty(propertiesToCopy[i])) { + destination[propertiesToCopy[i]] = original[propertiesToCopy[i]]; + } + } + }; + /* + parse is used whilst parsing + */ + var parseCopyProperties = [ + // options + 'paths', + 'rewriteUrls', + 'rootpath', + 'strictImports', + 'insecure', + 'dumpLineNumbers', + 'compress', + 'syncImport', + 'chunkInput', + 'mime', + 'useFileCache', + // context + 'processImports', + // Used by the import manager to stop multiple import visitors being created. + 'pluginManager' // Used as the plugin manager for the session + ]; + contexts.Parse = function (options) { + copyFromOriginal(options, this, parseCopyProperties); + if (typeof this.paths === 'string') { + this.paths = [this.paths]; + } + }; + var evalCopyProperties = [ + 'paths', + 'compress', + 'math', + 'strictUnits', + 'sourceMap', + 'importMultiple', + 'urlArgs', + 'javascriptEnabled', + 'pluginManager', + 'importantScope', + 'rewriteUrls' // option - whether to adjust URL's to be relative + ]; + contexts.Eval = function (options, frames) { + copyFromOriginal(options, this, evalCopyProperties); + if (typeof this.paths === 'string') { + this.paths = [this.paths]; + } + this.frames = frames || []; + this.importantScope = this.importantScope || []; + }; + contexts.Eval.prototype.enterCalc = function () { if (!this.calcStack) { - this.calcStack = []; + this.calcStack = []; } - this.calcStack.push(true); this.inCalc = true; - } - }, { - key: "exitCalc", - value: function exitCalc() { + }; + contexts.Eval.prototype.exitCalc = function () { this.calcStack.pop(); - - if (!this.calcStack) { - this.inCalc = false; + if (!this.calcStack.length) { + this.inCalc = false; } - } - }, { - key: "inParenthesis", - value: function inParenthesis() { + }; + contexts.Eval.prototype.inParenthesis = function () { if (!this.parensStack) { - this.parensStack = []; + this.parensStack = []; } - this.parensStack.push(true); - } - }, { - key: "outOfParenthesis", - value: function outOfParenthesis() { + }; + contexts.Eval.prototype.outOfParenthesis = function () { this.parensStack.pop(); - } - }, { - key: "isMathOn", - value: function isMathOn(op) { + }; + contexts.Eval.prototype.inCalc = false; + contexts.Eval.prototype.mathOn = true; + contexts.Eval.prototype.isMathOn = function (op) { if (!this.mathOn) { - return false; + return false; } - if (op === '/' && this.math !== Math$1.ALWAYS && (!this.parensStack || !this.parensStack.length)) { - return false; + return false; } - if (this.math > Math$1.PARENS_DIVISION) { - return this.parensStack && this.parensStack.length; + return this.parensStack && this.parensStack.length; } - return true; - } - }, { - key: "pathRequiresRewrite", - value: function pathRequiresRewrite(path) { + }; + contexts.Eval.prototype.pathRequiresRewrite = function (path) { var isRelative = this.rewriteUrls === RewriteUrls.LOCAL ? isPathLocalRelative : isPathRelative; return isRelative(path); - } - }, { - key: "rewritePath", - value: function rewritePath(path, rootpath) { + }; + contexts.Eval.prototype.rewritePath = function (path, rootpath) { var newPath; rootpath = rootpath || ''; - newPath = this.normalizePath(rootpath + path); // If a path was explicit relative and the rootpath was not an absolute path + newPath = this.normalizePath(rootpath + path); + // If a path was explicit relative and the rootpath was not an absolute path // we must ensure that the new path is also explicit relative. - - if (isPathLocalRelative(path) && isPathRelative(rootpath) && isPathLocalRelative(newPath) === false) { - newPath = "./".concat(newPath); + if (isPathLocalRelative(path) && + isPathRelative(rootpath) && + isPathLocalRelative(newPath) === false) { + newPath = "./" + newPath; } - return newPath; - } - }, { - key: "normalizePath", - value: function normalizePath(path) { + }; + contexts.Eval.prototype.normalizePath = function (path) { var segments = path.split('/').reverse(); var segment; path = []; - while (segments.length !== 0) { - segment = segments.pop(); - - switch (segment) { - case '.': - break; - - case '..': - if (path.length === 0 || path[path.length - 1] === '..') { - path.push(segment); - } else { - path.pop(); - } - - break; - - default: - path.push(segment); - break; - } + segment = segments.pop(); + switch (segment) { + case '.': + break; + case '..': + if ((path.length === 0) || (path[path.length - 1] === '..')) { + path.push(segment); + } + else { + path.pop(); + } + break; + default: + path.push(segment); + break; + } } - return path.join('/'); - } - }]); - - return _class; - }(); - - function makeRegistry(base) { - return { - _data: {}, - add: function add(name, func) { - // precautionary case conversion, as later querying of - // the registry by function-caller uses lower case as well. - name = name.toLowerCase(); - - if (this._data.hasOwnProperty(name)) ; - - this._data[name] = func; - }, - addMultiple: function addMultiple(functions) { - var _this = this; - - Object.keys(functions).forEach(function (name) { - _this.add(name, functions[name]); - }); - }, - get: function get(name) { - return this._data[name] || base && base.get(name); - }, - getLocalFunctions: function getLocalFunctions() { - return this._data; - }, - inherit: function inherit() { - return makeRegistry(this); - }, - create: function create(base) { - return makeRegistry(base); - } }; - } - - var functionRegistry = makeRegistry(null); - - var defaultFunc = { - eval: function _eval() { - var v = this.value_; - var e = this.error_; - - if (e) { - throw e; - } - - if (v != null) { - return v ? Keyword.True : Keyword.False; - } - }, - value: function value(v) { - this.value_ = v; - }, - error: function error(e) { - this.error_ = e; - }, - reset: function reset() { - this.value_ = this.error_ = null; + function isPathRelative(path) { + return !/^(?:[a-z-]+:|\/|#)/i.test(path); } - }; - - var Ruleset = - /*#__PURE__*/ - function (_Node) { - _inherits(Ruleset, _Node); - - function Ruleset(selectors, rules, strictImports, visibilityInfo) { - var _this; - - _classCallCheck(this, Ruleset); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Ruleset).call(this)); - _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, _assertThisInitialized(_this)); - - _this.setParent(_this.rules, _assertThisInitialized(_this)); - - return _this; + function isPathLocalRelative(path) { + return path.charAt(0) === '.'; } + // todo - do the same for the toCSS ? - _createClass(Ruleset, [{ - key: "isRulesetLike", - value: function isRulesetLike() { - return true; - } - }, { - key: "accept", - value: function accept(visitor) { - if (this.paths) { - this.paths = visitor.visitArray(this.paths, true); - } else if (this.selectors) { - this.selectors = visitor.visitArray(this.selectors); - } - - if (this.rules && this.rules.length) { - this.rules = visitor.visitArray(this.rules); - } - } - }, { - key: "eval", - value: function _eval(context) { - var selectors; - var selCnt; - var selector; - var i; - var hasVariable; - var hasOnePassingSelector = false; - - if (this.selectors && (selCnt = this.selectors.length)) { - 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 = this.selectors[i].eval(context); - - for (var j = 0; j < selector.elements.length; j++) { - if (selector.elements[j].isVariable) { - hasVariable = true; - break; - } + function makeRegistry(base) { + return { + _data: {}, + add: function (name, func) { + // precautionary case conversion, as later querying of + // the registry by function-caller uses lower case as well. + name = name.toLowerCase(); + if (this._data.hasOwnProperty(name)) ; + this._data[name] = func; + }, + addMultiple: function (functions) { + var _this = this; + Object.keys(functions).forEach(function (name) { + _this.add(name, functions[name]); + }); + }, + get: function (name) { + return this._data[name] || (base && base.get(name)); + }, + getLocalFunctions: function () { + return this._data; + }, + inherit: function () { + return makeRegistry(this); + }, + create: function (base) { + return makeRegistry(base); } + }; + } + var functionRegistry = makeRegistry(null); - selectors[i] = selector; - - if (selector.evaldCondition) { - hasOnePassingSelector = true; + var defaultFunc = { + eval: function () { + var v = this.value_; + var e = this.error_; + if (e) { + throw e; } - } - - if (hasVariable) { - var toParseSelectors = new Array(selCnt); - - for (i = 0; i < selCnt; i++) { - selector = selectors[i]; - toParseSelectors[i] = selector.toCSS(context); + if (v != null) { + return v ? Keyword.True : Keyword.False; } - - this.parse.parseNode(toParseSelectors.join(','), ["selectors"], selectors[0].getIndex(), selectors[0].fileInfo(), function (err, result) { - if (result) { - selectors = flattenArray(result); - } - }); - } - - defaultFunc.reset(); - } else { - hasOnePassingSelector = true; + }, + value: function (v) { + this.value_ = v; + }, + error: function (e) { + this.error_ = e; + }, + reset: function () { + this.value_ = this.error_ = null; } + }; - var rules = this.rules ? copyArray(this.rules) : null; - var ruleset = new Ruleset(selectors, rules, this.strictImports, this.visibilityInfo()); - var rule; - var subRule; - ruleset.originalRuleset = this; - ruleset.root = this.root; - ruleset.firstRoot = this.firstRoot; - ruleset.allowImports = this.allowImports; - - if (this.debugInfo) { - ruleset.debugInfo = this.debugInfo; - } - - if (!hasOnePassingSelector) { - rules.length = 0; - } // inherit a function registry from the frames stack when possible; - // otherwise from the global registry - - - ruleset.functionRegistry = function (frames) { - var i = 0; - var n = frames.length; - var found; - - for (; i !== n; ++i) { - found = frames[i].functionRegistry; - - if (found) { - return found; - } - } - - return functionRegistry; - }(context.frames).inherit(); // push the current ruleset to the frames stack - - - var ctxFrames = context.frames; - ctxFrames.unshift(ruleset); // currrent selectors - - var ctxSelectors = context.selectors; - - if (!ctxSelectors) { - context.selectors = ctxSelectors = []; - } - - ctxSelectors.unshift(this.selectors); // Evaluate imports - - if (ruleset.root || ruleset.allowImports || !ruleset.strictImports) { - ruleset.evalImports(context); - } // Store the frames around mixin definitions, - // so they can be evaluated like closures when the time comes. - - - 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; 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 - return !ruleset.variable(r.name); - } - - return true; - }); - rsRules.splice.apply(rsRules, _toConsumableArray([i, 1].concat(rules))); - i += rules.length - 1; - ruleset.resetCache(); - } 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, _toConsumableArray([i, 1].concat(rules))); - i += rules.length - 1; - ruleset.resetCache(); - } - } // Evaluate everything else - - - 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; 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] && rule.selectors[0].isJustParentSelector()) { - rsRules.splice(i--, 1); - - 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); - } - } - } - } - } - } // Pop the stack - - - ctxFrames.shift(); - ctxSelectors.shift(); - - if (context.mediaBlocks) { - for (i = mediaBlockCount; i < context.mediaBlocks.length; i++) { - context.mediaBlocks[i].bubbleSelectors(selectors); - } - } - - return ruleset; - } - }, { - key: "evalImports", - value: function evalImports(context) { - var rules = this.rules; - var i; - var importRules; - - if (!rules) { - return; - } - - for (i = 0; i < rules.length; i++) { - if (rules[i].type === 'Import') { - importRules = rules[i].eval(context); - - if (importRules && (importRules.length || importRules.length === 0)) { - rules.splice.apply(rules, _toConsumableArray([i, 1].concat(importRules))); - i += importRules.length - 1; - } else { - rules.splice(i, 1, importRules); - } - - this.resetCache(); - } - } - } - }, { - key: "makeImportant", - value: function makeImportant() { - var result = new Ruleset(this.selectors, this.rules.map(function (r) { - if (r.makeImportant) { - return r.makeImportant(); - } else { - return r; - } - }), this.strictImports, this.visibilityInfo()); - return result; - } - }, { - key: "matchArgs", - value: function matchArgs(args) { - return !args || args.length === 0; - } // lets you call a css selector with a guard - - }, { - key: "matchCondition", - value: function matchCondition(args, context) { - var lastSelector = this.selectors[this.selectors.length - 1]; - - if (!lastSelector.evaldCondition) { - return false; - } - - if (lastSelector.condition && !lastSelector.condition.eval(new contexts.Eval(context, context.frames))) { - return false; - } - - return true; - } - }, { - key: "resetCache", - value: function resetCache() { - this._rulesets = null; + var Ruleset = function (selectors, rules, strictImports, visibilityInfo) { + this.selectors = selectors; + this.rules = rules; + this._lookups = {}; this._variables = null; this._properties = null; - this._lookups = {}; - } - }, { - key: "variables", - value: function variables() { - if (!this._variables) { - this._variables = !this.rules ? {} : this.rules.reduce(function (hash, r) { - if (r instanceof Declaration && r.variable === true) { - hash[r.name] = r; - } // when evaluating variables in an import statement, imports have not been eval'd - // so we need to go inside import statements. - // guard against root being a string (in the case of inlined less) - - - if (r.type === 'Import' && r.root && r.root.variables) { - var vars = r.root.variables(); - - for (var name in vars) { - if (vars.hasOwnProperty(name)) { - hash[name] = r.root.variable(name); - } - } - } - - return hash; - }, {}); - } - - return this._variables; - } - }, { - key: "properties", - value: function properties() { - 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["$".concat(name)]) { - hash["$".concat(name)] = [r]; - } else { - hash["$".concat(name)].push(r); - } - } - - return hash; - }, {}); - } - - return this._properties; - } - }, { - key: "variable", - value: function variable(name) { - var decl = this.variables()[name]; - - if (decl) { - return this.parseValue(decl); - } - } - }, { - key: "property", - value: function property(name) { - var decl = this.properties()[name]; - - if (decl) { - return this.parseValue(decl); - } - } - }, { - key: "lastDeclaration", - value: function lastDeclaration() { - for (var i = this.rules.length; i > 0; i--) { - var decl = this.rules[i - 1]; - - if (decl instanceof Declaration) { - return this.parseValue(decl); - } - } - } - }, { - key: "parseValue", - value: function parseValue(toParse) { - var self = this; - - function transformDeclaration(decl) { - if (decl.value instanceof Anonymous && !decl.parsed) { - if (typeof decl.value.value === 'string') { - 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; - } - }); - } else { - 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; - } - } - }, { - key: "rulesets", - value: function rulesets() { - if (!this.rules) { - return []; - } - - var filtRules = []; - var rules = this.rules; - var i; - var rule; - - for (i = 0; rule = rules[i]; i++) { - if (rule.isRuleset) { - filtRules.push(rule); - } - } - - return filtRules; - } - }, { - key: "prependRule", - value: function prependRule(rule) { - var rules = this.rules; - - if (rules) { - rules.unshift(rule); - } else { - this.rules = [rule]; - } - - this.setParent(rule, this); - } - }, { - key: "find", - value: function find(selector) { - var self = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this; - var filter = arguments.length > 2 ? arguments[2] : undefined; - var rules = []; - var match; - var foundMixins; - var key = selector.toCSS(); - - if (key in this._lookups) { - return this._lookups[key]; - } - - this.rulesets().forEach(function (rule) { - if (rule !== self) { - for (var j = 0; j < rule.selectors.length; j++) { - match = selector.match(rule.selectors[j]); - - if (match) { - if (selector.elements.length > match) { - if (!filter || filter(rule)) { - foundMixins = rule.find(new Selector(selector.elements.slice(match)), self, filter); - - for (var i = 0; i < foundMixins.length; ++i) { - foundMixins[i].path.push(rule); - } - - Array.prototype.push.apply(rules, foundMixins); - } - } else { - rules.push({ - rule: rule, - path: [] - }); - } - - break; - } - } - } - }); - this._lookups[key] = rules; - return rules; - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - var i; - var j; - var charsetRuleNodes = []; - var ruleNodes = []; - var // Line number debugging - debugInfo$1; - var rule; - var path; - context.tabLevel = context.tabLevel || 0; - - if (!this.root) { - context.tabLevel++; - } - - var tabRuleStr = context.compress ? '' : Array(context.tabLevel + 1).join(' '); - var tabSetStr = context.compress ? '' : Array(context.tabLevel).join(' '); - var sep; - var charsetNodeIndex = 0; - var importNodeIndex = 0; - - for (i = 0; rule = this.rules[i]; i++) { - if (rule instanceof Comment) { - if (importNodeIndex === i) { - importNodeIndex++; - } - - ruleNodes.push(rule); - } else if (rule.isCharset && rule.isCharset()) { - ruleNodes.splice(charsetNodeIndex, 0, rule); - charsetNodeIndex++; - importNodeIndex++; - } else if (rule.type === 'Import') { - ruleNodes.splice(importNodeIndex, 0, rule); - importNodeIndex++; - } else { - ruleNodes.push(rule); - } - } - - ruleNodes = charsetRuleNodes.concat(ruleNodes); // If this is the root node, we don't render - // a selector, or {}. - - if (!this.root) { - debugInfo$1 = debugInfo(context, this, tabSetStr); - - if (debugInfo$1) { - output.add(debugInfo$1); - output.add(tabSetStr); - } - - var paths = this.paths; - var pathCnt = paths.length; - var pathSubCnt; - sep = context.compress ? ',' : ",\n".concat(tabSetStr); - - for (i = 0; i < pathCnt; i++) { - path = paths[i]; - - if (!(pathSubCnt = path.length)) { - continue; - } - - if (i > 0) { - output.add(sep); - } - - context.firstSelector = true; - path[0].genCSS(context, output); - context.firstSelector = false; - - for (j = 1; j < pathSubCnt; j++) { - path[j].genCSS(context, output); - } - } - - output.add((context.compress ? '{' : ' {\n') + tabRuleStr); - } // Compile rules and rulesets - - - for (i = 0; rule = ruleNodes[i]; i++) { - if (i + 1 === ruleNodes.length) { - context.lastRule = true; - } - - var currentLastRule = context.lastRule; - - if (rule.isRulesetLike(rule)) { - context.lastRule = false; - } - - if (rule.genCSS) { - rule.genCSS(context, output); - } else if (rule.value) { - output.add(rule.value.toString()); - } - - context.lastRule = currentLastRule; - - if (!context.lastRule && rule.isVisible()) { - output.add(context.compress ? '' : "\n".concat(tabRuleStr)); - } else { - context.lastRule = false; - } - } - - if (!this.root) { - output.add(context.compress ? '}' : "\n".concat(tabSetStr, "}")); - context.tabLevel--; - } - - if (!output.isEmpty() && !context.compress && this.firstRoot) { - output.add('\n'); - } - } - }, { - key: "joinSelectors", - value: function joinSelectors(paths, context, selectors) { - for (var s = 0; s < selectors.length; s++) { - this.joinSelector(paths, context, selectors[s]); - } - } - }, { - key: "joinSelector", - value: function joinSelector(paths, context, selector) { - function createParenthesis(elementsToPak, originalElement) { - var replacementParen; - var j; - - if (elementsToPak.length === 0) { - replacementParen = new Paren(elementsToPak[0]); - } else { - var insideParent = new Array(elementsToPak.length); - - for (j = 0; j < elementsToPak.length; j++) { - insideParent[j] = new Element(null, elementsToPak[j], originalElement.isVariable, originalElement._index, originalElement._fileInfo); - } - - replacementParen = new Paren(new Selector(insideParent)); - } - - return replacementParen; - } - - function createSelector(containedElement, originalElement) { - var element; - var selector; - element = new Element(null, containedElement, originalElement.isVariable, originalElement._index, originalElement._fileInfo); - selector = new Selector([element]); - return selector; - } // joins selector path from `beginningPath` with selector path in `addPath` - // `replacedElement` contains element that is being replaced by `addPath` - // returns concatenated path - - - function addReplacementIntoPath(beginningPath, addPath, replacedElement, originalSelector) { - var newSelectorPath; - var lastSelector; - var newJoinedSelector; // our new selector path - - newSelectorPath = []; // 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 = copyArray(beginningPath); - lastSelector = newSelectorPath.pop(); - newJoinedSelector = originalSelector.createDerived(copyArray(lastSelector.elements)); - } else { - newJoinedSelector = originalSelector.createDerived([]); - } - - if (addPath.length > 0) { - // /deep/ is a CSS4 selector - (removed, so should deprecate) - // that is valid without anything in front of it - // so if the & does not have a combinator that is "" or " " then - // and there is a combinator on the parent, then grab that. - // this also allows + a { & .b { .a & { ... though not sure why you would want to do that - var combinator = replacedElement.combinator; - var parentEl = addPath[0].elements[0]; - - if (combinator.emptyOrWhitespace && !parentEl.combinator.emptyOrWhitespace) { - combinator = parentEl.combinator; - } // join the elements so far with the first part of the parent - - - newJoinedSelector.elements.push(new Element(combinator, parentEl.value, replacedElement.isVariable, replacedElement._index, replacedElement._fileInfo)); - newJoinedSelector.elements = newJoinedSelector.elements.concat(addPath[0].elements.slice(1)); - } // now add the joined selector - but only if it is not empty - - - if (newJoinedSelector.elements.length !== 0) { - newSelectorPath.push(newJoinedSelector); - } // 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) { - return selector.createDerived(selector.elements, []); - }); - newSelectorPath = newSelectorPath.concat(restOfPath); - } - - return newSelectorPath; - } // joins selector path from `beginningPath` with every selector path in `addPaths` array - // `replacedElement` contains element that is being replaced by `addPath` - // returns array with all concatenated paths - - - function addAllReplacementsIntoPath(beginningPath, addPaths, replacedElement, originalSelector, result) { - var j; - - for (j = 0; j < beginningPath.length; j++) { - var newSelectorPath = addReplacementIntoPath(beginningPath[j], addPaths, replacedElement, originalSelector); - result.push(newSelectorPath); - } - - return result; - } - - function mergeElementsOnToSelectors(elements, selectors) { - var i; - var sel; - - if (elements.length === 0) { - return; - } - - if (selectors.length === 0) { - selectors.push([new Selector(elements)]); - return; - } - - 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)); - } else { - sel.push(new Selector(elements)); - } - } - } // replace all parent selectors inside `inSelector` by content of `context` array - // resulting selectors are returned inside `paths` array - // returns true if `inSelector` contained at least one parent selector - - - function replaceParentSelector(paths, context, inSelector) { - // The paths are [[Selector]] - // The first list is a list of comma separated selectors - // The inner list is a list of inheritance separated selectors - // e.g. - // .a, .b { - // .c { - // } - // } - // == [[.a] [.c]] [[.b] [.c]] - // - var i; - var j; - var k; - var currentElements; - var newSelectors; - var selectorsMultiplied; - var sel; - var el; - var hadParentSelector = false; - var length; - var lastSelector; - - function findNestedSelector(element) { - var maybeSelector; - - if (!(element.value instanceof Paren)) { - return null; - } - - maybeSelector = element.value.value; - - if (!(maybeSelector instanceof Selector)) { - return null; - } - - return maybeSelector; - } // the elements from the current selector so far - - - currentElements = []; // the current list of new selectors to add to the path. - // We will build it up. We initiate it with one empty selector as we "multiply" the new selectors - // by the parents - - newSelectors = [[]]; - - for (i = 0; el = inSelector.elements[i]; i++) { - // non parent reference elements just get added - if (el.value !== '&') { - var nestedSelector = findNestedSelector(el); - - if (nestedSelector != null) { - // merge the current list of non parent selector elements - // on to the current list of selectors to add - mergeElementsOnToSelectors(currentElements, newSelectors); - var nestedPaths = []; - var replaced = void 0; - var replacedNewSelectors = []; - replaced = replaceParentSelector(nestedPaths, context, nestedSelector); - hadParentSelector = hadParentSelector || replaced; // 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); - } - - newSelectors = replacedNewSelectors; - currentElements = []; - } else { - currentElements.push(el); - } - } else { - hadParentSelector = true; // the new list of selectors to add - - selectorsMultiplied = []; // merge the current list of non parent selector elements - // on to the current list of selectors to add - - mergeElementsOnToSelectors(currentElements, newSelectors); // loop through our current selectors - - for (j = 0; j < newSelectors.length; j++) { - sel = newSelectors[j]; // if we don't have any parent paths, the & might be in a mixin so that it can be used - // whether there are parents or not - - if (context.length === 0) { - // 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.isVariable, el._index, el._fileInfo)); - } - - selectorsMultiplied.push(sel); - } else { - // and the parent selectors - for (k = 0; k < context.length; k++) { - // We need to put the current selectors - // then join the last selector's elements on to the parents selectors - var newSelectorPath = addReplacementIntoPath(sel, context[k], el, inSelector); // add that to our new set of selectors - - selectorsMultiplied.push(newSelectorPath); - } - } - } // our new selectors has been multiplied, so reset the state - - - newSelectors = selectorsMultiplied; - currentElements = []; - } - } // if we have any elements left over (e.g. .a& .b == .b) - // add them on to all the current selectors - - - mergeElementsOnToSelectors(currentElements, newSelectors); - - for (i = 0; i < newSelectors.length; i++) { - length = newSelectors[i].length; - - if (length > 0) { - paths.push(newSelectors[i]); - lastSelector = newSelectors[i][length - 1]; - newSelectors[i][length - 1] = lastSelector.createDerived(lastSelector.elements, inSelector.extendList); - } - } - - return hadParentSelector; - } - - function deriveSelector(visibilityInfo, deriveFrom) { - var newSelector = deriveFrom.createDerived(deriveFrom.elements, deriveFrom.extendList, deriveFrom.evaldCondition); - newSelector.copyVisibilityInfo(visibilityInfo); - return newSelector; - } // joinSelector code follows - - - var i; - var newPaths; - var hadParentSelector; - newPaths = []; - hadParentSelector = replaceParentSelector(newPaths, context, selector); - - if (!hadParentSelector) { - if (context.length > 0) { - newPaths = []; - - for (i = 0; i < context.length; i++) { - var concatenated = context[i].map(deriveSelector.bind(this, selector.visibilityInfo())); - concatenated.push(selector); - newPaths.push(concatenated); - } - } else { - newPaths = [[selector]]; - } - } - - for (i = 0; i < newPaths.length; i++) { - paths.push(newPaths[i]); - } - } - }]); - - return Ruleset; - }(Node); - - Ruleset.prototype.type = 'Ruleset'; - Ruleset.prototype.isRuleset = true; - - var AtRule = - /*#__PURE__*/ - function (_Node) { - _inherits(AtRule, _Node); - - function AtRule(name, value, rules, index, currentFileInfo, debugInfo, isRooted, visibilityInfo) { - var _this; - - _classCallCheck(this, AtRule); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(AtRule).call(this)); - 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, _assertThisInitialized(_this)); - } - - _this._index = index; - _this._fileInfo = currentFileInfo; - _this.debugInfo = debugInfo; - _this.isRooted = isRooted || false; - - _this.copyVisibilityInfo(visibilityInfo); - - _this.allowRoot = true; - return _this; - } - - _createClass(AtRule, [{ - key: "accept", - value: function accept(visitor) { - var value = this.value; - var rules = this.rules; - - if (rules) { - this.rules = visitor.visitArray(rules); - } - - if (value) { - this.value = visitor.visit(value); - } - } - }, { - key: "isRulesetLike", - value: function isRulesetLike() { - return this.rules || !this.isCharset(); - } - }, { - key: "isCharset", - value: function isCharset() { - return '@charset' === this.name; - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - var value = this.value; - var 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(';'); - } - } - }, { - key: "eval", - value: function _eval(context) { - var mediaPathBackup; - var mediaBlocksBackup; - var value = this.value; - var 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()); - } - }, { - key: "variable", - value: function variable(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); - } - } - }, { - key: "find", - value: function find() { - if (this.rules) { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - // 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], args); - } - } - }, { - key: "rulesets", - value: function rulesets() { - 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]); - } - } - }, { - key: "outputRuleset", - value: function outputRuleset(context, output, rules) { - var ruleCnt = rules.length; - var 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".concat(Array(context.tabLevel).join(' ')); - var tabRuleStr = "".concat(tabSetStr, " "); - - if (!ruleCnt) { - output.add(" {".concat(tabSetStr, "}")); - } else { - output.add(" {".concat(tabRuleStr)); - rules[0].genCSS(context, output); - - for (i = 1; i < ruleCnt; i++) { - output.add(tabRuleStr); - rules[i].genCSS(context, output); - } - - output.add("".concat(tabSetStr, "}")); - } - - context.tabLevel--; - } - }]); - - return AtRule; - }(Node); - - AtRule.prototype.type = 'AtRule'; - - var DetachedRuleset = - /*#__PURE__*/ - function (_Node) { - _inherits(DetachedRuleset, _Node); - - function DetachedRuleset(ruleset, frames) { - var _this; - - _classCallCheck(this, DetachedRuleset); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(DetachedRuleset).call(this)); - _this.ruleset = ruleset; - _this.frames = frames; - - _this.setParent(_this.ruleset, _assertThisInitialized(_this)); - - return _this; - } - - _createClass(DetachedRuleset, [{ - key: "accept", - value: function accept(visitor) { - this.ruleset = visitor.visit(this.ruleset); - } - }, { - key: "eval", - value: function _eval(context) { - var frames = this.frames || copyArray(context.frames); - return new DetachedRuleset(this.ruleset, frames); - } - }, { - key: "callEval", - value: function callEval(context) { - return this.ruleset.eval(this.frames ? new contexts.Eval(context, this.frames.concat(context.frames)) : context); - } - }]); - - return DetachedRuleset; - }(Node); - - DetachedRuleset.prototype.type = 'DetachedRuleset'; - DetachedRuleset.prototype.evalFirst = true; - - var Unit = - /*#__PURE__*/ - function (_Node) { - _inherits(Unit, _Node); - - function Unit(numerator, denominator, backupUnit) { - var _this; - - _classCallCheck(this, Unit); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Unit).call(this)); - _this.numerator = numerator ? copyArray(numerator).sort() : []; - _this.denominator = denominator ? copyArray(denominator).sort() : []; - - if (backupUnit) { - _this.backupUnit = backupUnit; - } else if (numerator && numerator.length) { - _this.backupUnit = numerator[0]; - } - - return _this; - } - - _createClass(Unit, [{ - key: "clone", - value: function clone() { - return new Unit(copyArray(this.numerator), copyArray(this.denominator), this.backupUnit); - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - // Dimension checks the unit is singular and throws an error if in strict math mode. - var strictUnits = context && context.strictUnits; - - if (this.numerator.length === 1) { - output.add(this.numerator[0]); // the ideal situation - } else if (!strictUnits && this.backupUnit) { - output.add(this.backupUnit); - } else if (!strictUnits && this.denominator.length) { - output.add(this.denominator[0]); - } - } - }, { - key: "toString", - value: function toString() { - var i; - var returnStr = this.numerator.join('*'); - - for (i = 0; i < this.denominator.length; i++) { - returnStr += "/".concat(this.denominator[i]); - } - - return returnStr; - } - }, { - key: "compare", - value: function compare(other) { - return this.is(other.toString()) ? 0 : undefined; - } - }, { - key: "is", - value: function is(unitString) { - return this.toString().toUpperCase() === unitString.toUpperCase(); - } - }, { - key: "isLength", - value: function isLength() { - return RegExp('^(px|em|ex|ch|rem|in|cm|mm|pc|pt|ex|vw|vh|vmin|vmax)$', 'gi').test(this.toCSS()); - } - }, { - key: "isEmpty", - value: function isEmpty() { - return this.numerator.length === 0 && this.denominator.length === 0; - } - }, { - key: "isSingular", - value: function isSingular() { - return this.numerator.length <= 1 && this.denominator.length === 0; - } - }, { - key: "map", - value: function map(callback) { - var i; - - for (i = 0; i < this.numerator.length; i++) { - this.numerator[i] = callback(this.numerator[i], false); - } - - for (i = 0; i < this.denominator.length; i++) { - this.denominator[i] = callback(this.denominator[i], true); - } - } - }, { - key: "usedUnits", - value: function usedUnits() { - var group; - var result = {}; - var mapUnit; - var groupName; - - mapUnit = function mapUnit(atomicUnit) { - /* jshint loopfunc:true */ - if (group.hasOwnProperty(atomicUnit) && !result[groupName]) { - result[groupName] = atomicUnit; - } - - return atomicUnit; - }; - - for (groupName in unitConversions) { - if (unitConversions.hasOwnProperty(groupName)) { - group = unitConversions[groupName]; - this.map(mapUnit); - } - } - - return result; - } - }, { - key: "cancel", - value: function cancel() { - var counter = {}; - var atomicUnit; - var i; - - for (i = 0; i < this.numerator.length; i++) { - atomicUnit = this.numerator[i]; - counter[atomicUnit] = (counter[atomicUnit] || 0) + 1; - } - - for (i = 0; i < this.denominator.length; i++) { - atomicUnit = this.denominator[i]; - counter[atomicUnit] = (counter[atomicUnit] || 0) - 1; - } - - this.numerator = []; - this.denominator = []; - - for (atomicUnit in counter) { - if (counter.hasOwnProperty(atomicUnit)) { - var count = counter[atomicUnit]; - - if (count > 0) { - for (i = 0; i < count; i++) { - this.numerator.push(atomicUnit); - } - } else if (count < 0) { - for (i = 0; i < -count; i++) { - this.denominator.push(atomicUnit); - } - } - } - } - - this.numerator.sort(); - this.denominator.sort(); - } - }]); - - return Unit; - }(Node); - - Unit.prototype.type = 'Unit'; - - // A number with a unit - // - - var Dimension = - /*#__PURE__*/ - function (_Node) { - _inherits(Dimension, _Node); - - function Dimension(value, unit) { - var _this; - - _classCallCheck(this, Dimension); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Dimension).call(this)); - _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, _assertThisInitialized(_this)); - - return _this; - } - - _createClass(Dimension, [{ - key: "accept", - value: function accept(visitor) { - this.unit = visitor.visit(this.unit); - } - }, { - key: "eval", - value: function _eval(context) { - return this; - } - }, { - key: "toColor", - value: function toColor() { - return new Color([this.value, this.value, this.value]); - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - if (context && context.strictUnits && !this.unit.isSingular()) { - throw new Error("Multiple units in dimension. Correct the units or use the unit function. Bad unit: ".concat(this.unit.toString())); - } - - var value = this.fround(context, this.value); - var strValue = String(value); - - if (value !== 0 && value < 0.000001 && value > -0.000001) { - // would be output 1e-6 etc. - strValue = value.toFixed(20).replace(/0+$/, ''); - } - - if (context && context.compress) { - // Zero values doesn't need a unit - if (value === 0 && this.unit.isLength()) { - output.add(strValue); - return; - } // Float values doesn't need a leading zero - - - if (value > 0 && value < 1) { - strValue = strValue.substr(1); - } - } - - output.add(strValue); - this.unit.genCSS(context, output); - } // In an operation between two Dimensions, - // we default to the first Dimension's unit, - // so `1px + 2` will yield `3px`. - - }, { - key: "operate", - value: function operate(context, op, other) { - /* jshint noempty:false */ - var value = this._operate(context, op, this.value, other.value); - - var unit = this.unit.clone(); - - if (op === '+' || op === '-') { - if (unit.numerator.length === 0 && unit.denominator.length === 0) { - unit = other.unit.clone(); - - if (this.unit.backupUnit) { - unit.backupUnit = this.unit.backupUnit; - } - } else if (other.unit.numerator.length === 0 && unit.denominator.length === 0) ; else { - other = other.convertTo(this.unit.usedUnits()); - - if (context.strictUnits && other.unit.toString() !== unit.toString()) { - throw new Error("Incompatible units. Change the units or use the unit function. " + "Bad units: '".concat(unit.toString(), "' and '").concat(other.unit.toString(), "'.")); - } - - value = this._operate(context, op, this.value, other.value); - } - } else if (op === '*') { - unit.numerator = unit.numerator.concat(other.unit.numerator).sort(); - unit.denominator = unit.denominator.concat(other.unit.denominator).sort(); - unit.cancel(); - } else if (op === '/') { - unit.numerator = unit.numerator.concat(other.unit.denominator).sort(); - unit.denominator = unit.denominator.concat(other.unit.numerator).sort(); - unit.cancel(); - } - - return new Dimension(value, unit); - } - }, { - key: "compare", - value: function compare(other) { - var a; - var b; - - if (!(other instanceof Dimension)) { - return undefined; - } - - if (this.unit.isEmpty() || other.unit.isEmpty()) { - a = this; - b = other; - } else { - a = this.unify(); - b = other.unify(); - - if (a.unit.compare(b.unit) !== 0) { - return undefined; - } - } - - return Node.numericCompare(a.value, b.value); - } - }, { - key: "unify", - value: function unify() { - return this.convertTo({ - length: 'px', - duration: 's', - angle: 'rad' - }); - } - }, { - key: "convertTo", - value: function convertTo(conversions) { - var value = this.value; - var unit = this.unit.clone(); - var i; - var groupName; - var group; - var targetUnit; - var derivedConversions = {}; - var applyUnit; - - if (typeof conversions === 'string') { - for (i in unitConversions) { - if (unitConversions[i].hasOwnProperty(conversions)) { - derivedConversions = {}; - derivedConversions[i] = conversions; - } - } - - conversions = derivedConversions; - } - - applyUnit = function applyUnit(atomicUnit, denominator) { - /* jshint loopfunc:true */ - if (group.hasOwnProperty(atomicUnit)) { - if (denominator) { - value = value / (group[atomicUnit] / group[targetUnit]); - } else { - value = value * (group[atomicUnit] / group[targetUnit]); - } - - return targetUnit; - } - - return atomicUnit; - }; - - for (groupName in conversions) { - if (conversions.hasOwnProperty(groupName)) { - targetUnit = conversions[groupName]; - group = unitConversions[groupName]; - unit.map(applyUnit); - } - } - - unit.cancel(); - return new Dimension(value, unit); - } - }]); - - return Dimension; - }(Node); - - Dimension.prototype.type = 'Dimension'; - - var MATH$1 = Math$1; - - var Operation = - /*#__PURE__*/ - function (_Node) { - _inherits(Operation, _Node); - - function Operation(op, operands, isSpaced) { - var _this; - - _classCallCheck(this, Operation); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Operation).call(this)); - _this.op = op.trim(); - _this.operands = operands; - _this.isSpaced = isSpaced; - return _this; - } - - _createClass(Operation, [{ - key: "accept", - value: function accept(visitor) { - this.operands = visitor.visitArray(this.operands); - } - }, { - key: "eval", - value: function _eval(context) { - var a = this.operands[0].eval(context); - var b = this.operands[1].eval(context); - var op; - - if (context.isMathOn(this.op)) { - op = this.op === './' ? '/' : this.op; - - if (a instanceof Dimension && b instanceof Color) { - a = a.toColor(); - } - - if (b instanceof Dimension && a instanceof Color) { - b = b.toColor(); - } - - if (!a.operate) { - if (a instanceof Operation && a.op === '/' && context.math === MATH$1.PARENS_DIVISION) { - return new Operation(this.op, [a, b], this.isSpaced); - } - - throw { - type: 'Operation', - message: 'Operation on an invalid type' - }; - } - - return a.operate(context, op, b); - } else { - return new Operation(this.op, [a, b], this.isSpaced); - } - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - this.operands[0].genCSS(context, output); - - if (this.isSpaced) { - output.add(' '); - } - - output.add(this.op); - - if (this.isSpaced) { - output.add(' '); - } - - this.operands[1].genCSS(context, output); - } - }]); - - return Operation; - }(Node); - - Operation.prototype.type = 'Operation'; - - var MATH$2 = Math$1; - - var Expression = - /*#__PURE__*/ - function (_Node) { - _inherits(Expression, _Node); - - function Expression(value, noSpacing) { - var _this; - - _classCallCheck(this, Expression); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Expression).call(this)); - _this.value = value; - _this.noSpacing = noSpacing; - - if (!value) { - throw new Error('Expression requires an array parameter'); - } - - return _this; - } - - _createClass(Expression, [{ - key: "accept", - value: function accept(visitor) { - this.value = visitor.visitArray(this.value); - } - }, { - key: "eval", - value: function _eval(context) { - var returnValue; - var mathOn = context.isMathOn(); - var inParenthesis = this.parens && (context.math !== MATH$2.STRICT_LEGACY || !this.parensInOp); - var doubleParen = false; - - if (inParenthesis) { - context.inParenthesis(); - } - - if (this.value.length > 1) { - returnValue = new Expression(this.value.map(function (e) { - if (!e.eval) { - return e; - } - - return e.eval(context); - }), this.noSpacing); - } else if (this.value.length === 1) { - if (this.value[0].parens && !this.value[0].parensInOp && !context.inCalc) { - doubleParen = true; - } - - returnValue = this.value[0].eval(context); - } else { - returnValue = this; - } - - if (inParenthesis) { - context.outOfParenthesis(); - } - - if (this.parens && this.parensInOp && !mathOn && !doubleParen && !(returnValue instanceof Dimension)) { - returnValue = new Paren(returnValue); - } - - return returnValue; - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - for (var i = 0; i < this.value.length; i++) { - this.value[i].genCSS(context, output); - - if (!this.noSpacing && i + 1 < this.value.length) { - output.add(' '); - } - } - } - }, { - key: "throwAwayComments", - value: function throwAwayComments() { - this.value = this.value.filter(function (v) { - return !(v instanceof Comment); - }); - } - }]); - - return Expression; - }(Node); - - Expression.prototype.type = 'Expression'; - - var functionCaller = - /*#__PURE__*/ - function () { - function functionCaller(name, context, index, currentFileInfo) { - _classCallCheck(this, functionCaller); - - this.name = name.toLowerCase(); - this.index = index; - this.context = context; - this.currentFileInfo = currentFileInfo; - this.func = context.frames[0].functionRegistry.get(this.name); - } - - _createClass(functionCaller, [{ - key: "isValid", - value: function isValid() { - return Boolean(this.func); - } - }, { - key: "call", - value: function call(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)) { - args = args.filter(function (item) { - if (item.type === 'Comment') { - return false; - } - - return true; - }).map(function (item) { - if (item.type === 'Expression') { - var subNodes = item.value.filter(function (item) { - if (item.type === 'Comment') { - return false; - } - - return true; - }); - - if (subNodes.length === 1) { - return subNodes[0]; - } else { - return new Expression(subNodes); - } - } - - return item; - }); - } - - return this.func.apply(this, _toConsumableArray(args)); - } - }]); - - return functionCaller; - }(); - - // A function call node. - // - - var Call = - /*#__PURE__*/ - function (_Node) { - _inherits(Call, _Node); - - function Call(name, args, index, currentFileInfo) { - var _this; - - _classCallCheck(this, Call); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Call).call(this)); - _this.name = name; - _this.args = args; - _this.calc = name === 'calc'; - _this._index = index; - _this._fileInfo = currentFileInfo; - return _this; - } - - _createClass(Call, [{ - key: "accept", - value: function accept(visitor) { - if (this.args) { - this.args = visitor.visitArray(this.args); - } - } // - // When evaluating a function call, - // we either find the function in the functionRegistry, - // in which case we call it, passing the evaluated arguments, - // if this returns null or we cannot find the function, we - // simply print it out as it appeared originally [2]. - // - // The reason why we evaluate the arguments, is in the case where - // we try to pass a variable to a function, like: `saturate(@color)`. - // The function should receive the value, not the variable. - // - - }, { - key: "eval", - value: function _eval(context) { - /** - * Turn off math for calc(), and switch back on for evaluating nested functions - */ - var currentMathContext = context.mathOn; - context.mathOn = !this.calc; - - if (this.calc || context.inCalc) { - context.enterCalc(); - } - - var args = this.args.map(function (a) { - return a.eval(context); - }); - - if (this.calc || context.inCalc) { - context.exitCalc(); - } - - context.mathOn = currentMathContext; - var result; - var 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 `".concat(this.name, "`").concat(e.message ? ": ".concat(e.message) : ''), - index: this.getIndex(), - filename: this.fileInfo().filename, - line: e.lineNumber, - column: e.columnNumber - }; - } - - 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.getIndex(), this.fileInfo()); - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - output.add("".concat(this.name, "("), this.fileInfo(), this.getIndex()); - - for (var i = 0; i < this.args.length; i++) { - this.args[i].genCSS(context, output); - - if (i + 1 < this.args.length) { - output.add(', '); - } - } - - output.add(')'); - } - }]); - - return Call; - }(Node); - - Call.prototype.type = 'Call'; - - var Variable = - /*#__PURE__*/ - function (_Node) { - _inherits(Variable, _Node); - - function Variable(name, index, currentFileInfo) { - var _this; - - _classCallCheck(this, Variable); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Variable).call(this)); - _this.name = name; - _this._index = index; - _this._fileInfo = currentFileInfo; - return _this; - } - - _createClass(Variable, [{ - key: "eval", - value: function _eval(context) { - var variable; - var name = this.name; - - if (name.indexOf('@@') === 0) { - name = "@".concat(new Variable(name.slice(1), this.getIndex(), this.fileInfo()).eval(context).value); - } - - if (this.evaluating) { - throw { - type: 'Name', - message: "Recursive variable definition for ".concat(name), - filename: this.fileInfo().filename, - index: this.getIndex() - }; - } - - this.evaluating = true; - variable = this.find(context.frames, function (frame) { - var v = frame.variable(name); - - if (v) { - if (v.important) { - var importantScope = context.importantScope[context.importantScope.length - 1]; - importantScope.important = v.important; - } // If in calc, wrap vars in a function call to cascade evaluate args first - - - if (context.inCalc) { - return new Call('_SELF', [v.value]).eval(context); - } else { - return v.value.eval(context); - } - } - }); - - if (variable) { - this.evaluating = false; - return variable; - } else { - throw { - type: 'Name', - message: "variable ".concat(name, " is undefined"), - filename: this.fileInfo().filename, - index: this.getIndex() - }; - } - } - }, { - key: "find", - value: function find(obj, fun) { - for (var i = 0, r; i < obj.length; i++) { - r = fun.call(obj, obj[i]); - - if (r) { - return r; - } - } - - return null; - } - }]); - - return Variable; - }(Node); - - Variable.prototype.type = 'Variable'; - - var Property = - /*#__PURE__*/ - function (_Node) { - _inherits(Property, _Node); - - function Property(name, index, currentFileInfo) { - var _this; - - _classCallCheck(this, Property); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Property).call(this)); - _this.name = name; - _this._index = index; - _this._fileInfo = currentFileInfo; - return _this; - } - - _createClass(Property, [{ - key: "eval", - value: function _eval(context) { - var property; - var 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 ".concat(name), - filename: this.fileInfo().filename, - index: this.getIndex() - }; - } - - this.evaluating = true; - property = this.find(context.frames, function (frame) { - var v; - var 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 '".concat(name, "' is undefined"), - filename: this.currentFileInfo.filename, - index: this.index - }; - } - } - }, { - key: "find", - value: function find(obj, fun) { - for (var i = 0, r; i < obj.length; i++) { - r = fun.call(obj, obj[i]); - - if (r) { - return r; - } - } - - return null; - } - }]); - - return Property; - }(Node); - - Property.prototype.type = 'Property'; - - var Attribute = - /*#__PURE__*/ - function (_Node) { - _inherits(Attribute, _Node); - - function Attribute(key, op, value) { - var _this; - - _classCallCheck(this, Attribute); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Attribute).call(this)); - _this.key = key; - _this.op = op; - _this.value = value; - return _this; - } - - _createClass(Attribute, [{ - key: "eval", - value: function _eval(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); - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - output.add(this.toCSS(context)); - } - }, { - key: "toCSS", - value: function toCSS(context) { - var value = this.key.toCSS ? this.key.toCSS(context) : this.key; - - if (this.op) { - value += this.op; - value += this.value.toCSS ? this.value.toCSS(context) : this.value; - } - - return "[".concat(value, "]"); - } - }]); - - return Attribute; - }(Node); - - Attribute.prototype.type = 'Attribute'; - - var Quoted = - /*#__PURE__*/ - function (_Node) { - _inherits(Quoted, _Node); - - function Quoted(str, content, escaped, index, currentFileInfo) { - var _this; - - _classCallCheck(this, Quoted); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Quoted).call(this)); - _this.escaped = escaped == null ? true : escaped; - _this.value = content || ''; - _this.quote = str.charAt(0); - _this._index = index; - _this._fileInfo = currentFileInfo; - _this.variableRegex = /@\{([\w-]+)\}/g; - _this.propRegex = /\$\{([\w-]+)\}/g; - _this.allowRoot = escaped; - return _this; - } - - _createClass(Quoted, [{ - key: "genCSS", - value: function genCSS(context, output) { - if (!this.escaped) { - output.add(this.quote, this.fileInfo(), this.getIndex()); - } - - output.add(this.value); - - if (!this.escaped) { - output.add(this.quote); - } - } - }, { - key: "containsVariables", - value: function containsVariables() { - return this.value.match(this.variableRegex); - } - }, { - key: "eval", - value: function _eval(context) { - var that = this; - var value = this.value; - - var variableReplacement = function variableReplacement(_, name) { - var v = new Variable("@".concat(name), that.getIndex(), that.fileInfo()).eval(context, true); - return v instanceof Quoted ? v.value : v.toCSS(); - }; - - var propertyReplacement = function propertyReplacement(_, name) { - var v = new Property("$".concat(name), that.getIndex(), that.fileInfo()).eval(context, true); - return v instanceof Quoted ? v.value : v.toCSS(); - }; - - function iterativeReplace(value, regexp, replacementFnc) { - var evaluatedValue = value; - - do { - value = evaluatedValue.toString(); - evaluatedValue = value.replace(regexp, replacementFnc); - } while (value !== evaluatedValue); - - return evaluatedValue; - } - - value = iterativeReplace(value, this.variableRegex, variableReplacement); - value = iterativeReplace(value, this.propRegex, propertyReplacement); - return new Quoted(this.quote + value + this.quote, value, this.escaped, this.getIndex(), this.fileInfo()); - } - }, { - key: "compare", - value: function compare(other) { - // when comparing quoted strings allow the quote to differ - if (other.type === 'Quoted' && !this.escaped && !other.escaped) { - return Node.numericCompare(this.value, other.value); - } else { - return other.toCSS && this.toCSS() === other.toCSS() ? 0 : undefined; - } - } - }]); - - return Quoted; - }(Node); - - Quoted.prototype.type = 'Quoted'; - - var URL = - /*#__PURE__*/ - function (_Node) { - _inherits(URL, _Node); - - function URL(val, index, currentFileInfo, isEvald) { - var _this; - - _classCallCheck(this, URL); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(URL).call(this)); - _this.value = val; - _this._index = index; - _this._fileInfo = currentFileInfo; - _this.isEvald = isEvald; - return _this; - } - - _createClass(URL, [{ - key: "accept", - value: function accept(visitor) { - this.value = visitor.visit(this.value); - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - output.add('url('); - this.value.genCSS(context, output); - output.add(')'); - } - }, { - key: "eval", - value: function _eval(context) { - var val = this.value.eval(context); - var rootpath; - - if (!this.isEvald) { - // Add the rootpath if the URL requires a rewrite - rootpath = this.fileInfo() && this.fileInfo().rootpath; - - if (typeof rootpath === 'string' && typeof val.value === 'string' && context.pathRequiresRewrite(val.value)) { - if (!val.quote) { - rootpath = escapePath(rootpath); - } - - val.value = context.rewritePath(val.value, rootpath); - } else { - val.value = context.normalizePath(val.value); - } // Add url args if enabled - - - if (context.urlArgs) { - if (!val.value.match(/^\s*data:/)) { - var delimiter = val.value.indexOf('?') === -1 ? '?' : '&'; - var urlArgs = delimiter + context.urlArgs; - - if (val.value.indexOf('#') !== -1) { - val.value = val.value.replace('#', "".concat(urlArgs, "#")); - } else { - val.value += urlArgs; - } - } - } - } - - return new URL(val, this.getIndex(), this.fileInfo(), true); - } - }]); - - return URL; - }(Node); - - URL.prototype.type = 'Url'; - - function escapePath(path) { - return path.replace(/[\(\)'"\s]/g, function (match) { - return "\\".concat(match); - }); - } - - var Media = - /*#__PURE__*/ - function (_AtRule) { - _inherits(Media, _AtRule); - - function Media(value, features, index, currentFileInfo, visibilityInfo) { - var _this; - - _classCallCheck(this, Media); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Media).call(this)); - _this._index = index; - _this._fileInfo = currentFileInfo; - 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, _assertThisInitialized(_this)); - - _this.setParent(_this.features, _assertThisInitialized(_this)); - - _this.setParent(_this.rules, _assertThisInitialized(_this)); - - return _this; - } - - _createClass(Media, [{ - key: "isRulesetLike", - value: function isRulesetLike() { - return true; - } - }, { - key: "accept", - value: function accept(visitor) { - if (this.features) { - this.features = visitor.visit(this.features); - } - - if (this.rules) { - this.rules = visitor.visitArray(this.rules); - } - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - output.add('@media ', this._fileInfo, this._index); - this.features.genCSS(context, output); - this.outputRuleset(context, output, this.rules); - } - }, { - key: "eval", - value: function _eval(context) { - if (!context.mediaBlocks) { - context.mediaBlocks = []; - context.mediaPath = []; - } - - var media = new Media(null, [], this._index, this._fileInfo, this.visibilityInfo()); - - if (this.debugInfo) { - this.rules[0].debugInfo = this.debugInfo; - media.debugInfo = this.debugInfo; - } - - media.features = this.features.eval(context); - context.mediaPath.push(media); - context.mediaBlocks.push(media); - this.rules[0].functionRegistry = context.frames[0].functionRegistry.inherit(); - context.frames.unshift(this.rules[0]); - media.rules = [this.rules[0].eval(context)]; - context.frames.shift(); - context.mediaPath.pop(); - return context.mediaPath.length === 0 ? media.evalTop(context) : media.evalNested(context); - } - }, { - key: "evalTop", - value: function evalTop(context) { - var result = this; // Render all dependent Media blocks. - - if (context.mediaBlocks.length > 1) { - 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; - delete context.mediaPath; - return result; - } - }, { - key: "evalNested", - value: function evalNested(context) { - var i; - var value; - var path = context.mediaPath.concat([this]); // Extract the media-query conditions separated with `,` (OR). - - for (i = 0; i < path.length; i++) { - value = path[i].features instanceof Value ? path[i].features.value : path[i].features; - path[i] = Array.isArray(value) ? value : [value]; - } // Trace all permutations to generate the resulting media-query. - // - // (a, b and c) with nested (d, e) -> - // a and d - // a and e - // b and c and d - // b and c and e - - - this.features = new Value(this.permute(path).map(function (path) { - path = path.map(function (fragment) { - return fragment.toCSS ? fragment : new Anonymous(fragment); - }); - - for (i = path.length - 1; i > 0; i--) { - path.splice(i, 0, new Anonymous('and')); - } - - return new Expression(path); - })); - this.setParent(this.features, this); // Fake a tree-node that doesn't output anything. - - return new Ruleset([], []); - } - }, { - key: "permute", - value: function permute(arr) { - if (arr.length === 0) { - return []; - } else if (arr.length === 1) { - return arr[0]; - } else { - var result = []; - var rest = this.permute(arr.slice(1)); - - for (var i = 0; i < rest.length; i++) { - for (var j = 0; j < arr[0].length; j++) { - result.push([arr[0][j]].concat(rest[i])); - } - } - - return result; - } - } - }, { - key: "bubbleSelectors", - value: function bubbleSelectors(selectors) { - if (!selectors) { - return; - } - - this.rules = [new Ruleset(copyArray(selectors), [this.rules[0]])]; + this.strictImports = strictImports; + this.copyVisibilityInfo(visibilityInfo); + this.allowRoot = true; + this.setParent(this.selectors, this); this.setParent(this.rules, this); - } - }]); - - return Media; - }(AtRule); - - Media.prototype.type = 'Media'; - - // CSS @import node - // - // The general strategy here is that we don't want to wait - // for the parsing to be completed, before we start importing - // the file. That's because in the context of a browser, - // most of the time will be spent waiting for the server to respond. - // - // On creation, we push the import path to our import queue, though - // `import,push`, we also pass it a callback, which it'll call once - // the file has been fetched, and parsed. - // - - var Import = - /*#__PURE__*/ - function (_Node) { - _inherits(Import, _Node); - - function Import(path, features, options, index, currentFileInfo, visibilityInfo) { - var _this; - - _classCallCheck(this, Import); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Import).call(this)); - _this.options = options; - _this._index = index; - _this._fileInfo = currentFileInfo; - _this.path = path; - _this.features = features; - _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)) { - _this.css = true; - } - } - - _this.copyVisibilityInfo(visibilityInfo); - - _this.setParent(_this.features, _assertThisInitialized(_this)); - - _this.setParent(_this.path, _assertThisInitialized(_this)); - - return _this; - } - - _createClass(Import, [{ - key: "accept", - value: function accept(visitor) { - if (this.features) { - this.features = visitor.visit(this.features); - } - - this.path = visitor.visit(this.path); - - if (!this.options.isPlugin && !this.options.inline && this.root) { - this.root = visitor.visit(this.root); - } - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - 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(' '); - this.features.genCSS(context, output); - } - - output.add(';'); - } - } - }, { - key: "getPath", - value: function getPath() { - return this.path instanceof URL ? this.path.value.value : this.path.value; - } - }, { - key: "isVariableImport", - value: function isVariableImport() { - var path = this.path; - - if (path instanceof URL) { - path = path.value; - } - - if (path instanceof Quoted) { - return path.containsVariables(); - } - - return true; - } - }, { - key: "evalForImport", - value: function evalForImport(context) { - var path = this.path; - - if (path instanceof URL) { - path = path.value; - } - - return new Import(path.eval(context), this.features, this.options, this._index, this._fileInfo, this.visibilityInfo()); - } - }, { - key: "evalPath", - value: function evalPath(context) { - var path = this.path.eval(context); - var fileInfo = this._fileInfo; - - if (!(path instanceof URL)) { - // Add the rootpath if the URL requires a rewrite - var pathValue = path.value; - - if (fileInfo && pathValue && context.pathRequiresRewrite(pathValue)) { - path.value = context.rewritePath(pathValue, fileInfo.rootpath); - } else { - path.value = context.normalizePath(path.value); - } - } - - return path; - } - }, { - key: "eval", - value: function _eval(context) { - var result = this.doEval(context); - - if (this.options.reference || this.blocksVisibility()) { - if (result.length || result.length === 0) { - result.forEach(function (node) { - node.addVisibilityBlock(); - }); - } else { - result.addVisibilityBlock(); - } - } - - return result; - } - }, { - key: "doEval", - value: function doEval(context) { - var ruleset; - var registry; - var features = this.features && this.features.eval(context); - - 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 []; - } - - if (this.skip) { - if (typeof this.skip === 'function') { - this.skip = this.skip(); - } - - if (this.skip) { - return []; - } - } - - if (this.options.inline) { - var contents = new Anonymous(this.root, 0, { - 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); - - if (!newImport.css && this.error) { - throw this.error; - } - - return newImport; - } else { - ruleset = new Ruleset(null, copyArray(this.root.rules)); - ruleset.evalImports(context); - return this.features ? new Media(ruleset.rules, this.features.value) : ruleset.rules; - } - } - }]); - - return Import; - }(Node); - - Import.prototype.type = 'Import'; - - var JsEvalNode = - /*#__PURE__*/ - function (_Node) { - _inherits(JsEvalNode, _Node); - - function JsEvalNode() { - _classCallCheck(this, JsEvalNode); - - return _possibleConstructorReturn(this, _getPrototypeOf(JsEvalNode).apply(this, arguments)); - } - - _createClass(JsEvalNode, [{ - key: "evaluateJavaScript", - value: function evaluateJavaScript(expression, context) { - var result; - var that = this; - var evalContext = {}; - - 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("@".concat(name), that.getIndex(), that.fileInfo()).eval(context)); - }); - - try { - expression = new Function("return (".concat(expression, ")")); - } catch (e) { - throw { - message: "JavaScript evaluation error: ".concat(e.message, " from `").concat(expression, "`"), - 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 */ - evalContext[k.slice(1)] = { - value: variables[k].value, - toJS: function toJS() { - return this.value.eval(context).toCSS(); - } - }; - } - } - - try { - result = expression.call(evalContext); - } catch (e) { - throw { - message: "JavaScript evaluation error: '".concat(e.name, ": ").concat(e.message.replace(/["]/g, '\''), "'"), - filename: this.fileInfo().filename, - index: this.getIndex() - }; - } - - return result; - } - }, { - key: "jsify", - value: function jsify(obj) { - if (Array.isArray(obj.value) && obj.value.length > 1) { - return "[".concat(obj.value.map(function (v) { - return v.toCSS(); - }).join(', '), "]"); - } else { - return obj.toCSS(); - } - } - }]); - - return JsEvalNode; - }(Node); - - var JavaScript = - /*#__PURE__*/ - function (_JsEvalNode) { - _inherits(JavaScript, _JsEvalNode); - - function JavaScript(string, escaped, index, currentFileInfo) { - var _this; - - _classCallCheck(this, JavaScript); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(JavaScript).call(this)); - _this.escaped = escaped; - _this.expression = string; - _this._index = index; - _this._fileInfo = currentFileInfo; - return _this; - } - - _createClass(JavaScript, [{ - key: "eval", - value: function _eval(context) { - var result = this.evaluateJavaScript(this.expression, context); - - var type = _typeof(result); - - if (type === 'number' && !isNaN(result)) { - return new Dimension(result); - } else if (type === 'string') { - return new Quoted("\"".concat(result, "\""), result, this.escaped, this._index); - } else if (Array.isArray(result)) { - return new Anonymous(result.join(', ')); - } else { - return new Anonymous(result); - } - } - }]); - - return JavaScript; - }(JsEvalNode); - - JavaScript.prototype.type = 'JavaScript'; - - var Assignment = - /*#__PURE__*/ - function (_Node) { - _inherits(Assignment, _Node); - - function Assignment(key, val) { - var _this; - - _classCallCheck(this, Assignment); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Assignment).call(this)); - _this.key = key; - _this.value = val; - return _this; - } - - _createClass(Assignment, [{ - key: "accept", - value: function accept(visitor) { - this.value = visitor.visit(this.value); - } - }, { - key: "eval", - value: function _eval(context) { - if (this.value.eval) { - return new Assignment(this.key, this.value.eval(context)); - } - - return this; - } - }, { - key: "genCSS", - value: function genCSS(context, output) { - output.add("".concat(this.key, "=")); - - if (this.value.genCSS) { - this.value.genCSS(context, output); - } else { - output.add(this.value); - } - } - }]); - - return Assignment; - }(Node); - - Assignment.prototype.type = 'Assignment'; - - var Condition = - /*#__PURE__*/ - function (_Node) { - _inherits(Condition, _Node); - - function Condition(op, l, r, i, negate) { - var _this; - - _classCallCheck(this, Condition); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Condition).call(this)); - _this.op = op.trim(); - _this.lvalue = l; - _this.rvalue = r; - _this._index = i; - _this.negate = negate; - return _this; - } - - _createClass(Condition, [{ - key: "accept", - value: function accept(visitor) { - this.lvalue = visitor.visit(this.lvalue); - this.rvalue = visitor.visit(this.rvalue); - } - }, { - key: "eval", - value: function _eval(context) { - var result = function (op, a, b) { - switch (op) { - case 'and': - return a && b; - - case 'or': - return a || b; - - default: - switch (Node.compare(a, b)) { - case -1: - return op === '<' || op === '=<' || op === '<='; - - case 0: - return op === '=' || op === '>=' || op === '=<' || op === '<='; - - case 1: - return op === '>' || op === '>='; - - default: - return false; - } - - } - }(this.op, this.lvalue.eval(context), this.rvalue.eval(context)); - - return this.negate ? !result : result; - } - }]); - - return Condition; - }(Node); - - Condition.prototype.type = 'Condition'; - - var UnicodeDescriptor = - /*#__PURE__*/ - function (_Node) { - _inherits(UnicodeDescriptor, _Node); - - function UnicodeDescriptor(value) { - var _this; - - _classCallCheck(this, UnicodeDescriptor); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(UnicodeDescriptor).call(this)); - _this.value = value; - return _this; - } - - return UnicodeDescriptor; - }(Node); - - UnicodeDescriptor.prototype.type = 'UnicodeDescriptor'; - - var Negative = - /*#__PURE__*/ - function (_Node) { - _inherits(Negative, _Node); - - function Negative(node) { - var _this; - - _classCallCheck(this, Negative); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Negative).call(this)); - _this.value = node; - return _this; - } - - _createClass(Negative, [{ - key: "genCSS", - value: function genCSS(context, output) { - output.add('-'); - this.value.genCSS(context, output); - } - }, { - key: "eval", - value: function _eval(context) { - if (context.isMathOn()) { - return new Operation('*', [new Dimension(-1), this.value]).eval(context); - } - - return new Negative(this.value.eval(context)); - } - }]); - - return Negative; - }(Node); - - Negative.prototype.type = 'Negative'; - - var Extend = - /*#__PURE__*/ - function (_Node) { - _inherits(Extend, _Node); - - function Extend(selector, option, index, currentFileInfo, visibilityInfo) { - var _this; - - _classCallCheck(this, Extend); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Extend).call(this)); - _this.selector = selector; - _this.option = option; - _this.object_id = Extend.next_id++; - _this.parent_ids = [_this.object_id]; - _this._index = index; - _this._fileInfo = currentFileInfo; - - _this.copyVisibilityInfo(visibilityInfo); - - _this.allowRoot = true; - - switch (option) { - case 'all': - _this.allowBefore = true; - _this.allowAfter = true; - break; - - default: - _this.allowBefore = false; - _this.allowAfter = false; - break; - } - - _this.setParent(_this.selector, _assertThisInitialized(_this)); - - return _this; - } - - _createClass(Extend, [{ - key: "accept", - value: function accept(visitor) { - this.selector = visitor.visit(this.selector); - } - }, { - key: "eval", - value: function _eval(context) { - return new Extend(this.selector.eval(context), this.option, this.getIndex(), this.fileInfo(), this.visibilityInfo()); - } - }, { - key: "clone", - value: function clone(context) { - return new Extend(this.selector, this.option, this.getIndex(), this.fileInfo(), this.visibilityInfo()); - } // it concatenates (joins) all selectors in selector array - - }, { - key: "findSelfSelectors", - value: function findSelfSelectors(selectors) { - var selfElements = []; - var i; - var selectorElements; - - for (i = 0; i < selectors.length; i++) { - selectorElements = selectors[i].elements; // duplicate the logic in genCSS function inside the selector node. - // future TODO - move both logics into the selector joiner visitor - - if (i > 0 && selectorElements.length && selectorElements[0].combinator.value === '') { - selectorElements[0].combinator.value = ' '; - } - - selfElements = selfElements.concat(selectors[i].elements); - } - - this.selfSelectors = [new Selector(selfElements)]; - this.selfSelectors[0].copyVisibilityInfo(this.visibilityInfo()); - } - }]); - - return Extend; - }(Node); - - Extend.next_id = 0; - Extend.prototype.type = 'Extend'; - - var VariableCall = - /*#__PURE__*/ - function (_Node) { - _inherits(VariableCall, _Node); - - function VariableCall(variable, index, currentFileInfo) { - var _this; - - _classCallCheck(this, VariableCall); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(VariableCall).call(this)); - _this.variable = variable; - _this._index = index; - _this._fileInfo = currentFileInfo; - _this.allowRoot = true; - return _this; - } - - _createClass(VariableCall, [{ - key: "eval", - value: function _eval(context) { - var rules; - var detachedRuleset = new Variable(this.variable, this.getIndex(), this.fileInfo()).eval(context); - var error = new LessError({ - message: "Could not evaluate variable call ".concat(this.variable) - }); - - if (!detachedRuleset.ruleset) { - if (detachedRuleset.rules) { - rules = detachedRuleset; - } else if (Array.isArray(detachedRuleset)) { - rules = new Ruleset('', detachedRuleset); - } else if (Array.isArray(detachedRuleset.value)) { - rules = new Ruleset('', detachedRuleset.value); - } else { - throw error; - } - - detachedRuleset = new DetachedRuleset(rules); - } - - if (detachedRuleset.ruleset) { - return detachedRuleset.callEval(context); - } - - throw error; - } - }]); - - return VariableCall; - }(Node); - - VariableCall.prototype.type = 'VariableCall'; - - var NamespaceValue = - /*#__PURE__*/ - function (_Node) { - _inherits(NamespaceValue, _Node); - - function NamespaceValue(ruleCall, lookups, important, index, fileInfo) { - var _this; - - _classCallCheck(this, NamespaceValue); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(NamespaceValue).call(this)); - _this.value = ruleCall; - _this.lookups = lookups; - _this.important = important; - _this._index = index; - _this._fileInfo = fileInfo; - return _this; - } - - _createClass(NamespaceValue, [{ - key: "eval", - value: function _eval(context) { - var i; - var name; - var rules = this.value.eval(context); - - for (i = 0; i < this.lookups.length; i++) { - name = this.lookups[i]; - /** - * Eval'd DRs return rulesets. - * Eval'd mixins return rules, so let's make a ruleset if we need it. - * We need to do this because of late parsing of values - */ - - if (Array.isArray(rules)) { - rules = new Ruleset([new Selector()], rules); - } - - if (name === '') { - rules = rules.lastDeclaration(); - } else if (name.charAt(0) === '@') { - if (name.charAt(1) === '@') { - name = "@".concat(new Variable(name.substr(1)).eval(context).value); - } - - if (rules.variables) { - rules = rules.variable(name); - } - - if (!rules) { - throw { - type: 'Name', - message: "variable ".concat(name, " not found"), - filename: this.fileInfo().filename, - index: this.getIndex() - }; - } - } else { - if (name.substring(0, 2) === '$@') { - name = "$".concat(new Variable(name.substr(1)).eval(context).value); - } else { - name = name.charAt(0) === '$' ? name : "$".concat(name); - } - - if (rules.properties) { - rules = rules.property(name); - } - - if (!rules) { - throw { - type: 'Name', - message: "property \"".concat(name.substr(1), "\" not found"), - filename: this.fileInfo().filename, - index: this.getIndex() - }; - } // Properties are an array of values, since a ruleset can have multiple props. - // We pick the last one (the "cascaded" value) - - - rules = rules[rules.length - 1]; - } - - if (rules.value) { - rules = rules.eval(context).value; - } - - if (rules.ruleset) { - rules = rules.ruleset.eval(context); - } - } - - return rules; - } - }]); - - return NamespaceValue; - }(Node); - - NamespaceValue.prototype.type = 'NamespaceValue'; - - var Definition = - /*#__PURE__*/ - function (_Ruleset) { - _inherits(Definition, _Ruleset); - - function Definition(name, params, rules, condition, variadic, frames, visibilityInfo) { - var _this; - - _classCallCheck(this, Definition); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Definition).call(this)); - _this.name = name || 'anonymous mixin'; - _this.selectors = [new Selector([new Element(null, name, false, _this._index, _this._fileInfo)])]; - _this.params = params; - _this.condition = condition; - _this.variadic = variadic; - _this.arity = params.length; - _this.rules = rules; - _this._lookups = {}; - var optionalParameters = []; - _this.required = params.reduce(function (count, p) { - if (!p.name || p.name && !p.value) { - return count + 1; - } else { - optionalParameters.push(p.name); - return count; - } - }, 0); - _this.optionalParameters = optionalParameters; - _this.frames = frames; - - _this.copyVisibilityInfo(visibilityInfo); - - _this.allowRoot = true; - return _this; - } - - _createClass(Definition, [{ - key: "accept", - value: function accept(visitor) { - if (this.params && this.params.length) { - this.params = visitor.visitArray(this.params); - } - - this.rules = visitor.visitArray(this.rules); - - if (this.condition) { - this.condition = visitor.visit(this.condition); - } - } - }, { - key: "evalParams", - value: function evalParams(context, mixinEnv, args, evaldArguments) { - /* jshint boss:true */ - var frame = new Ruleset(null, null); - var varargs; - var arg; - var params = copyArray(this.params); - var i; - var j; - var val; - var name; - var isNamedFound; - var argIndex; - var argsLength = 0; - - if (mixinEnv.frames && mixinEnv.frames[0] && mixinEnv.frames[0].functionRegistry) { - frame.functionRegistry = mixinEnv.frames[0].functionRegistry.inherit(); - } - - mixinEnv = new contexts.Eval(mixinEnv, [frame].concat(mixinEnv.frames)); - - if (args) { - args = copyArray(args); - argsLength = args.length; - - for (i = 0; i < argsLength; i++) { - arg = args[i]; - - if (name = arg && arg.name) { - isNamedFound = false; - - for (j = 0; j < params.length; j++) { - if (!evaldArguments[j] && name === params[j].name) { - evaldArguments[j] = arg.value.eval(context); - frame.prependRule(new Declaration(name, arg.value.eval(context))); - isNamedFound = true; - break; - } - } - - if (isNamedFound) { - args.splice(i, 1); - i--; - continue; - } else { - throw { - type: 'Runtime', - message: "Named argument for ".concat(this.name, " ").concat(args[i].name, " not found") - }; - } - } - } - } - - argIndex = 0; - - for (i = 0; i < params.length; i++) { - if (evaldArguments[i]) { - continue; - } - - arg = args && args[argIndex]; - - if (name = params[i].name) { - if (params[i].variadic) { - varargs = []; - - for (j = argIndex; j < argsLength; j++) { - varargs.push(args[j].value.eval(context)); - } - - frame.prependRule(new Declaration(name, new Expression(varargs).eval(context))); - } else { - val = arg && arg.value; - - if (val) { - // This was a mixin call, pass in a detached ruleset of it's eval'd rules - if (Array.isArray(val)) { - val = new DetachedRuleset(new Ruleset('', val)); - } else { - val = val.eval(context); - } - } else if (params[i].value) { - val = params[i].value.eval(mixinEnv); - frame.resetCache(); - } else { - throw { - type: 'Runtime', - message: "wrong number of arguments for ".concat(this.name, " (").concat(argsLength, " for ").concat(this.arity, ")") - }; - } - - frame.prependRule(new Declaration(name, val)); - evaldArguments[i] = val; - } - } - - if (params[i].variadic && args) { - for (j = argIndex; j < argsLength; j++) { - evaldArguments[j] = args[j].value.eval(context); - } - } - - argIndex++; - } - - return frame; - } - }, { - key: "makeImportant", - value: function makeImportant() { - var rules = !this.rules ? this.rules : this.rules.map(function (r) { - if (r.makeImportant) { - return r.makeImportant(true); - } else { - return r; - } - }); - var result = new Definition(this.name, this.params, rules, this.condition, this.variadic, this.frames); - return result; - } - }, { - key: "eval", - value: function _eval(context) { - return new Definition(this.name, this.params, this.rules, this.condition, this.variadic, this.frames || copyArray(context.frames)); - } - }, { - key: "evalCall", - value: function evalCall(context, args, important) { - var _arguments = []; - var mixinFrames = this.frames ? this.frames.concat(context.frames) : context.frames; - var frame = this.evalParams(context, new contexts.Eval(context, mixinFrames), args, _arguments); - var rules; - var ruleset; - frame.prependRule(new Declaration('@arguments', new Expression(_arguments).eval(context))); - rules = copyArray(this.rules); - ruleset = new Ruleset(null, rules); - ruleset.originalRuleset = this; - ruleset = ruleset.eval(new contexts.Eval(context, [this, frame].concat(mixinFrames))); - - if (important) { - ruleset = ruleset.makeImportant(); - } - - return ruleset; - } - }, { - key: "matchCondition", - value: function matchCondition(args, context) { - if (this.condition && !this.condition.eval(new contexts.Eval(context, [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 - return false; - } - - return true; - } - }, { - key: "matchArgs", - value: function matchArgs(args, context) { - var allArgsCnt = args && args.length || 0; - var len; - var optionalParameters = this.optionalParameters; - var requiredArgsCnt = !args ? 0 : args.reduce(function (count, p) { - if (optionalParameters.indexOf(p.name) < 0) { - return count + 1; - } else { - return count; - } - }, 0); - - if (!this.variadic) { - if (requiredArgsCnt < this.required) { - return false; - } - - if (allArgsCnt > this.params.length) { - return false; - } - } else { - if (requiredArgsCnt < this.required - 1) { - return false; - } - } // check patterns - - - len = Math.min(requiredArgsCnt, this.arity); - - for (var i = 0; i < len; i++) { - if (!this.params[i].name && !this.params[i].variadic) { - if (args[i].value.eval(context).toCSS() != this.params[i].value.eval(context).toCSS()) { - return false; - } - } - } - - return true; - } - }]); - - return Definition; - }(Ruleset); - - Definition.prototype.type = 'MixinDefinition'; - Definition.prototype.evalFirst = true; - - var MixinCall = - /*#__PURE__*/ - function (_Node) { - _inherits(MixinCall, _Node); - - function MixinCall(elements, args, index, currentFileInfo, important) { - var _this; - - _classCallCheck(this, MixinCall); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(MixinCall).call(this)); - _this.selector = new Selector(elements); - _this.arguments = args || []; - _this._index = index; - _this._fileInfo = currentFileInfo; - _this.important = important; - _this.allowRoot = true; - - _this.setParent(_this.selector, _assertThisInitialized(_this)); - - return _this; - } - - _createClass(MixinCall, [{ - key: "accept", - value: function accept(visitor) { - if (this.selector) { - this.selector = visitor.visit(this.selector); - } - - if (this.arguments.length) { - this.arguments = visitor.visitArray(this.arguments); - } - } - }, { - key: "eval", - value: function _eval(context) { - var mixins; - var mixin; - var mixinPath; - var args = []; - var arg; - var argValue; - var rules = []; - var match = false; - var i; - var m; - var f; - var isRecursive; - var isOneFound; - var candidates = []; - var candidate; - var conditionResult = []; - var defaultResult; - var defFalseEitherCase = -1; - var defNone = 0; - var defTrue = 1; - var defFalse = 2; - var count; - var originalRuleset; - var noArgumentsFilter; - this.selector = this.selector.eval(context); - - function calcDefGroup(mixin, mixinPath) { - var f; - var p; - var namespace; - - for (f = 0; f < 2; f++) { - conditionResult[f] = true; - defaultFunc.value(f); - - for (p = 0; p < mixinPath.length && conditionResult[f]; p++) { - namespace = mixinPath[p]; - - if (namespace.matchCondition) { - conditionResult[f] = conditionResult[f] && namespace.matchCondition(null, context); - } - } - - if (mixin.matchCondition) { - conditionResult[f] = conditionResult[f] && mixin.matchCondition(args, context); - } - } - - if (conditionResult[0] || conditionResult[1]) { - if (conditionResult[0] != conditionResult[1]) { - return conditionResult[1] ? defTrue : defFalse; - } - - return defNone; - } - - return defFalseEitherCase; - } - - for (i = 0; i < this.arguments.length; i++) { - arg = this.arguments[i]; - argValue = arg.value.eval(context); - - if (arg.expand && Array.isArray(argValue.value)) { - argValue = argValue.value; - - for (m = 0; m < argValue.length; m++) { - args.push({ - value: argValue[m] - }); - } - } else { - args.push({ - name: arg.name, - value: argValue - }); - } - } - - noArgumentsFilter = function noArgumentsFilter(rule) { - return rule.matchArgs(null, context); - }; - - for (i = 0; i < context.frames.length; i++) { - if ((mixins = context.frames[i].find(this.selector, null, noArgumentsFilter)).length > 0) { - isOneFound = true; // To make `default()` function independent of definition order we have two "subpasses" here. - // At first we evaluate each guard *twice* (with `default() == true` and `default() == false`), - // and build candidate list with corresponding flags. Then, when we know all possible matches, - // we make a final decision. - - for (m = 0; m < mixins.length; m++) { - mixin = mixins[m].rule; - mixinPath = mixins[m].path; - isRecursive = false; - - for (f = 0; f < context.frames.length; f++) { - if (!(mixin instanceof Definition) && mixin === (context.frames[f].originalRuleset || context.frames[f])) { - isRecursive = true; - break; - } - } - - if (isRecursive) { - continue; - } - - if (mixin.matchArgs(args, context)) { - candidate = { - mixin: mixin, - group: calcDefGroup(mixin, mixinPath) - }; - - if (candidate.group !== defFalseEitherCase) { - candidates.push(candidate); - } - - match = true; - } - } - - defaultFunc.reset(); - count = [0, 0, 0]; - - for (m = 0; m < candidates.length; m++) { - count[candidates[m].group]++; - } - - if (count[defNone] > 0) { - defaultResult = defFalse; - } else { - defaultResult = defTrue; - - if (count[defTrue] + count[defFalse] > 1) { - throw { - type: 'Runtime', - message: "Ambiguous use of `default()` found when matching for `".concat(this.format(args), "`"), - index: this.getIndex(), - filename: this.fileInfo().filename - }; - } - } - - for (m = 0; m < candidates.length; m++) { - candidate = candidates[m].group; - - if (candidate === defNone || candidate === defaultResult) { - try { - mixin = candidates[m].mixin; - - if (!(mixin instanceof Definition)) { - originalRuleset = mixin.originalRuleset || mixin; - mixin = new Definition('', [], mixin.rules, null, false, null, originalRuleset.visibilityInfo()); - mixin.originalRuleset = originalRuleset; - } - - var newRules = mixin.evalCall(context, args, this.important).rules; - - this._setVisibilityToReplacement(newRules); - - Array.prototype.push.apply(rules, newRules); - } catch (e) { - throw { - message: e.message, - index: this.getIndex(), - filename: this.fileInfo().filename, - stack: e.stack - }; - } - } - } - - if (match) { - return rules; - } - } - } - - if (isOneFound) { - throw { - type: 'Runtime', - message: "No matching definition was found for `".concat(this.format(args), "`"), - index: this.getIndex(), - filename: this.fileInfo().filename - }; - } else { - throw { - type: 'Name', - message: "".concat(this.selector.toCSS().trim(), " is undefined"), - index: this.getIndex(), - filename: this.fileInfo().filename - }; - } - } - }, { - key: "_setVisibilityToReplacement", - value: function _setVisibilityToReplacement(replacement) { - var i; - var rule; - - if (this.blocksVisibility()) { - for (i = 0; i < replacement.length; i++) { - rule = replacement[i]; - rule.addVisibilityBlock(); - } - } - } - }, { - key: "format", - value: function format(args) { - return "".concat(this.selector.toCSS().trim(), "(").concat(args ? args.map(function (a) { - var argValue = ''; - - if (a.name) { - argValue += "".concat(a.name, ":"); - } - - if (a.value.toCSS) { - argValue += a.value.toCSS(); - } else { - argValue += '???'; - } - - return argValue; - }).join(', ') : '', ")"); - } - }]); - - return MixinCall; - }(Node); - - MixinCall.prototype.type = 'MixinCall'; - - var tree = { - Node: Node, - Color: Color, - AtRule: AtRule, - DetachedRuleset: DetachedRuleset, - Operation: Operation, - Dimension: Dimension, - Unit: Unit, - Keyword: Keyword, - Variable: Variable, - Property: Property, - Ruleset: Ruleset, - Element: Element, - Attribute: Attribute, - Combinator: Combinator, - Selector: Selector, - Quoted: Quoted, - Expression: Expression, - Declaration: Declaration, - Call: Call, - URL: URL, - Import: Import, - Comment: Comment, - Anonymous: Anonymous, - Value: Value, - JavaScript: JavaScript, - Assignment: Assignment, - Condition: Condition, - Paren: Paren, - Media: Media, - UnicodeDescriptor: UnicodeDescriptor, - Negative: Negative, - Extend: Extend, - VariableCall: VariableCall, - NamespaceValue: NamespaceValue, - mixin: { - Call: MixinCall, - Definition: Definition - } - }; - - var logger = { - error: function error(msg) { - this._fireEvent('error', msg); - }, - warn: function warn(msg) { - this._fireEvent('warn', msg); - }, - info: function info(msg) { - this._fireEvent('info', msg); - }, - debug: function debug(msg) { - this._fireEvent('debug', msg); - }, - addListener: function addListener(listener) { - this._listeners.push(listener); - }, - removeListener: function removeListener(listener) { - for (var i = 0; i < this._listeners.length; i++) { - if (this._listeners[i] === listener) { - this._listeners.splice(i, 1); - - return; - } - } - }, - _fireEvent: function _fireEvent(type, msg) { - for (var i = 0; i < this._listeners.length; i++) { - var logFunction = this._listeners[i][type]; - - if (logFunction) { - logFunction(msg); - } - } - }, - _listeners: [] - }; - - var environment = - /*#__PURE__*/ - function () { - function environment(externalEnvironment, fileManagers) { - _classCallCheck(this, environment); - - this.fileManagers = fileManagers || []; - externalEnvironment = externalEnvironment || {}; - var optionalFunctions = ['encodeBase64', 'mimeLookup', 'charsetLookup', 'getSourceMapGenerator']; - var requiredFunctions = []; - var functions = requiredFunctions.concat(optionalFunctions); - - for (var i = 0; i < functions.length; i++) { - var propName = functions[i]; - var environmentFunc = externalEnvironment[propName]; - - if (environmentFunc) { - this[propName] = environmentFunc.bind(externalEnvironment); - } else if (i < requiredFunctions.length) { - this.warn("missing required function in environment - ".concat(propName)); - } - } - } - - _createClass(environment, [{ - key: "getFileManager", - value: function getFileManager(filename, currentDirectory, options, environment, isSync) { - if (!filename) { - logger.warn('getFileManager called with no filename.. Please report this issue. continuing.'); - } - - if (currentDirectory == null) { - logger.warn('getFileManager called with null directory.. Please report this issue. continuing.'); - } - - var fileManagers = this.fileManagers; - - if (options.pluginManager) { - fileManagers = [].concat(fileManagers).concat(options.pluginManager.getFileManagers()); - } - - for (var i = fileManagers.length - 1; i >= 0; i--) { - var fileManager = fileManagers[i]; - - if (fileManager[isSync ? 'supportsSync' : 'supports'](filename, currentDirectory, options, environment)) { - return fileManager; - } - } - - return null; - } - }, { - key: "addFileManager", - value: function addFileManager(fileManager) { - this.fileManagers.push(fileManager); - } - }, { - key: "clearFileManagers", - value: function clearFileManagers() { - this.fileManagers = []; - } - }]); - - return environment; - }(); - - var AbstractFileManager = - /*#__PURE__*/ - function () { - function AbstractFileManager() { - _classCallCheck(this, AbstractFileManager); - } - - _createClass(AbstractFileManager, [{ - key: "getPath", - value: function getPath(filename) { - var j = filename.lastIndexOf('?'); - - if (j > 0) { - filename = filename.slice(0, j); - } - - j = filename.lastIndexOf('/'); - - if (j < 0) { - j = filename.lastIndexOf('\\'); - } - - if (j < 0) { - return ''; - } - - return filename.slice(0, j + 1); - } - }, { - key: "tryAppendExtension", - value: function tryAppendExtension(path, ext) { - return /(\.[a-z]*$)|([\?;].*)$/.test(path) ? path : path + ext; - } - }, { - key: "tryAppendLessExtension", - value: function tryAppendLessExtension(path) { - return this.tryAppendExtension(path, '.less'); - } - }, { - key: "supportsSync", - value: function supportsSync() { - return false; - } - }, { - key: "alwaysMakePathsAbsolute", - value: function alwaysMakePathsAbsolute() { - return false; - } - }, { - key: "isPathAbsolute", - value: function isPathAbsolute(filename) { - return /^(?:[a-z-]+:|\/|\\|#)/i.test(filename); - } // TODO: pull out / replace? - - }, { - key: "join", - value: function join(basePath, laterPath) { - if (!basePath) { - return laterPath; - } - - return basePath + laterPath; - } - }, { - key: "pathDiff", - value: function pathDiff(url, baseUrl) { - // diff between two paths to create a relative path - var urlParts = this.extractUrlParts(url); - var baseUrlParts = this.extractUrlParts(baseUrl); - var i; - var max; - var urlDirectories; - var baseUrlDirectories; - var diff = ''; - - if (urlParts.hostPart !== baseUrlParts.hostPart) { - return ''; - } - - max = Math.max(baseUrlParts.directories.length, urlParts.directories.length); - - for (i = 0; i < max; i++) { - if (baseUrlParts.directories[i] !== urlParts.directories[i]) { - break; - } - } - - baseUrlDirectories = baseUrlParts.directories.slice(i); - urlDirectories = urlParts.directories.slice(i); - - for (i = 0; i < baseUrlDirectories.length - 1; i++) { - diff += '../'; - } - - for (i = 0; i < urlDirectories.length - 1; i++) { - diff += "".concat(urlDirectories[i], "/"); - } - - return diff; - } - }, { - key: "extractUrlParts", - // helper function, not part of API - value: function extractUrlParts(url, baseUrl) { - // urlParts[1] = protocol://hostname/ OR / - // urlParts[2] = / if path relative to host base - // urlParts[3] = directories - // urlParts[4] = filename - // urlParts[5] = parameters - var urlPartsRegex = /^((?:[a-z-]+:)?\/{2}(?:[^\/\?#]*\/)|([\/\\]))?((?:[^\/\\\?#]*[\/\\])*)([^\/\\\?#]*)([#\?].*)?$/i; - var urlParts = url.match(urlPartsRegex); - var returner = {}; - var rawDirectories = []; - var directories = []; - var i; - var baseUrlParts; - - if (!urlParts) { - throw new Error("Could not parse sheet href - '".concat(url, "'")); - } // Stylesheets in IE don't always return the full path - - - if (baseUrl && (!urlParts[1] || urlParts[2])) { - baseUrlParts = baseUrl.match(urlPartsRegex); - - if (!baseUrlParts) { - throw new Error("Could not parse page url - '".concat(baseUrl, "'")); - } - - urlParts[1] = urlParts[1] || baseUrlParts[1] || ''; - - if (!urlParts[2]) { - urlParts[3] = baseUrlParts[3] + urlParts[3]; - } - } - - if (urlParts[3]) { - rawDirectories = urlParts[3].replace(/\\/g, '/').split('/'); // collapse '..' and skip '.' - - for (i = 0; i < rawDirectories.length; i++) { - 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; - } - }]); - - return AbstractFileManager; - }(); - - var AbstractPluginLoader = - /*#__PURE__*/ - function () { - function AbstractPluginLoader() { - _classCallCheck(this, AbstractPluginLoader); - - // Implemented by Node.js plugin loader - this.require = function () { - return null; - }; - } - - _createClass(AbstractPluginLoader, [{ - key: "evalPlugin", - value: function evalPlugin(contents, context, imports, pluginOptions, fileInfo) { - var loader; - var registry; - var pluginObj; - var localModule; - var pluginManager; - var filename; - var result; - 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) { - result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions); - - if (result) { - return result; - } - - try { - if (pluginObj.use) { - pluginObj.use.call(this.context, pluginObj); - } - } catch (e) { - e.message = e.message || 'Error during @plugin call'; - return new LessError(e, imports, filename); - } - - return pluginObj; - } - } - - localModule = { - exports: {}, - pluginManager: pluginManager, - fileInfo: fileInfo - }; - registry = functionRegistry.create(); - - var registerPlugin = function registerPlugin(obj) { - pluginObj = obj; - }; - - try { - loader = new Function('module', 'require', 'registerPlugin', 'functions', 'tree', 'less', 'fileInfo', contents); - loader(localModule, this.require(filename), registerPlugin, registry, this.less.tree, this.less, fileInfo); - } catch (e) { - return new LessError(e, imports, filename); - } - - if (!pluginObj) { - pluginObj = localModule.exports; - } - - pluginObj = this.validatePlugin(pluginObj, filename, shortname); - - if (pluginObj instanceof LessError) { - return pluginObj; - } - - if (pluginObj) { - pluginObj.imports = imports; - pluginObj.filename = filename; // For < 3.x (or unspecified minVersion) - setOptions() before install() - - if (!pluginObj.minVersion || this.compareVersion('3.0.0', pluginObj.minVersion) < 0) { - result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions); - - if (result) { - return result; - } - } // Run on first load - - - pluginManager.addPlugin(pluginObj, fileInfo.filename, registry); - pluginObj.functions = registry.getLocalFunctions(); // Need to call setOptions again because the pluginObj might have functions - - result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions); - - if (result) { - return result; - } // Run every @plugin call - - - try { - if (pluginObj.use) { - pluginObj.use.call(this.context, pluginObj); - } - } catch (e) { - e.message = e.message || 'Error during @plugin call'; - return new LessError(e, imports, filename); - } - } else { - return new LessError({ - message: 'Not a valid plugin' - }, imports, filename); - } - - return pluginObj; - } - }, { - key: "trySetOptions", - value: function trySetOptions(plugin, filename, name, options) { - if (options && !plugin.setOptions) { - return new LessError({ - message: "Options have been provided but the plugin ".concat(name, " does not support any options.") - }); - } - - try { - plugin.setOptions && plugin.setOptions(options); - } catch (e) { - return new LessError(e); - } - } - }, { - key: "validatePlugin", - value: function validatePlugin(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) { - return new LessError({ - message: "Plugin ".concat(name, " requires version ").concat(this.versionToString(plugin.minVersion)) - }); - } - } - - return plugin; - } - - return null; - } - }, { - key: "compareVersion", - value: function compareVersion(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; - } - }, { - key: "versionToString", - value: function versionToString(version) { - var versionString = ''; - - for (var i = 0; i < version.length; i++) { - versionString += (versionString ? '.' : '') + version[i]; - } - - return versionString; - } - }, { - key: "printUsage", - value: function printUsage(plugins) { - for (var i = 0; i < plugins.length; i++) { - var plugin = plugins[i]; - - if (plugin.printUsage) { - plugin.printUsage(); - } - } - } - }]); - - return AbstractPluginLoader; - }(); - - var _visitArgs = { - visitDeeper: true - }; - var _hasIndexed = false; - - function _noop(node) { - return node; - } - - function indexNodeTypes(parent, ticker) { - // add .typeIndex to tree node types for lookup table - var key; - var child; - - 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; - } - - var Visitor = - /*#__PURE__*/ - function () { - function Visitor(implementation) { - _classCallCheck(this, Visitor); - - this._implementation = implementation; - this._visitInCache = {}; - this._visitOutCache = {}; - - if (!_hasIndexed) { - indexNodeTypes(tree, 1); - _hasIndexed = true; - } - } - - _createClass(Visitor, [{ - key: "visit", - value: function visit(node) { - if (!node) { - return node; - } - - var nodeTypeIndex = node.typeIndex; - - if (!nodeTypeIndex) { - // MixinCall args aren't a node type? - if (node.value && node.value.typeIndex) { - this.visit(node.value); - } - - return node; - } - - var impl = this._implementation; - var func = this._visitInCache[nodeTypeIndex]; - var funcOut = this._visitOutCache[nodeTypeIndex]; - var visitArgs = _visitArgs; - var fnName; - visitArgs.visitDeeper = true; - - if (!func) { - fnName = "visit".concat(node.type); - func = impl[fnName] || _noop; - funcOut = impl["".concat(fnName, "Out")] || _noop; - this._visitInCache[nodeTypeIndex] = func; - this._visitOutCache[nodeTypeIndex] = funcOut; - } - - if (func !== _noop) { - var newNode = func.call(impl, node, visitArgs); - - if (node && impl.isReplacing) { - node = newNode; - } - } - - if (visitArgs.visitDeeper && node && node.accept) { - node.accept(this); - } - - if (funcOut != _noop) { - funcOut.call(impl, node); - } - - return node; - } - }, { - key: "visitArray", - value: function visitArray(nodes, nonReplacing) { - if (!nodes) { - return nodes; - } - - var cnt = nodes.length; - var i; // Non-replacing - - if (nonReplacing || !this._implementation.isReplacing) { - for (i = 0; i < cnt; i++) { - this.visit(nodes[i]); - } - - return nodes; - } // Replacing - - - var out = []; - - for (i = 0; i < cnt; i++) { - var evald = this.visit(nodes[i]); - - if (evald === undefined) { - continue; - } - - if (!evald.splice) { - out.push(evald); - } else if (evald.length) { - this.flatten(evald, out); - } - } - - return out; - } - }, { - key: "flatten", - value: function flatten(arr, out) { - if (!out) { - out = []; - } - - var cnt; - var i; - var item; - var nestedCnt; - var j; - var nestedItem; - - for (i = 0, cnt = arr.length; i < cnt; i++) { - item = arr[i]; - - if (item === undefined) { - continue; - } - - if (!item.splice) { - out.push(item); - continue; - } - - for (j = 0, nestedCnt = item.length; j < nestedCnt; j++) { - nestedItem = item[j]; - - if (nestedItem === undefined) { - continue; - } - - if (!nestedItem.splice) { - out.push(nestedItem); - } else if (nestedItem.length) { - this.flatten(nestedItem, out); - } - } - } - - return out; - } - }]); - - return Visitor; - }(); - - var ImportSequencer = - /*#__PURE__*/ - function () { - function ImportSequencer(onSequencerEmpty) { - _classCallCheck(this, ImportSequencer); - - this.imports = []; - this.variableImports = []; - this._onSequencerEmpty = onSequencerEmpty; - this._currentDepth = 0; - } - - _createClass(ImportSequencer, [{ - key: "addImport", - value: function addImport(callback) { - var importSequencer = this; - var importItem = { - callback: callback, - args: null, - isReady: false - }; - this.imports.push(importItem); - return function () { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - importItem.args = Array.prototype.slice.call(args, 0); - importItem.isReady = true; - importSequencer.tryRun(); - }; - } - }, { - key: "addVariableImport", - value: function addVariableImport(callback) { - this.variableImports.push(callback); - } - }, { - key: "tryRun", - value: function tryRun() { - this._currentDepth++; - - try { - while (true) { - while (this.imports.length > 0) { - var importItem = this.imports[0]; - - if (!importItem.isReady) { - return; - } - - this.imports = this.imports.slice(1); - importItem.callback.apply(null, importItem.args); - } - - if (this.variableImports.length === 0) { - break; - } - - var variableImport = this.variableImports[0]; - this.variableImports = this.variableImports.slice(1); - variableImport(); - } - } finally { - this._currentDepth--; - } - - if (this._currentDepth === 0 && this._onSequencerEmpty) { - this._onSequencerEmpty(); - } - } - }]); - - return ImportSequencer; - }(); - - var ImportVisitor = function ImportVisitor(importer, finish) { - this._visitor = new Visitor(this); - this._importer = importer; - this._finish = finish; - this.context = new contexts.Eval(); - this.importCount = 0; - this.onceFileDetectionMap = {}; - this.recursionDetector = {}; - this._sequencer = new ImportSequencer(this._onSequencerEmpty.bind(this)); - }; - - ImportVisitor.prototype = { - isReplacing: false, - run: function run(root) { - try { - // process the contents - this._visitor.visit(root); - } catch (e) { - this.error = e; - } - - this.isFinished = true; - - this._sequencer.tryRun(); - }, - _onSequencerEmpty: function _onSequencerEmpty() { - if (!this.isFinished) { - return; - } - - this._finish(this.error); - }, - visitImport: function visitImport(importNode, visitArgs) { - var inlineCSS = importNode.options.inline; - - if (!importNode.css || inlineCSS) { - var context = new contexts.Eval(this.context, copyArray(this.context.frames)); - var importParent = context.frames[0]; - this.importCount++; - - if (importNode.isVariableImport()) { - this._sequencer.addVariableImport(this.processImportNode.bind(this, importNode, context, importParent)); - } else { - this.processImportNode(importNode, context, importParent); - } - } - - visitArgs.visitDeeper = false; - }, - processImportNode: function processImportNode(importNode, context, importParent) { - var evaldImportNode; - var inlineCSS = importNode.options.inline; - - try { - evaldImportNode = importNode.evalForImport(context); - } 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 - - importNode.error = e; - } - - if (evaldImportNode && (!evaldImportNode.css || inlineCSS)) { - if (evaldImportNode.options.multiple) { - context.importMultiple = true; - } // try appending if we haven't determined if it is css or not - - - var tryAppendLessExtension = evaldImportNode.css === undefined; - - for (var i = 0; i < importParent.rules.length; i++) { - if (importParent.rules[i] === importNode) { - importParent.rules[i] = evaldImportNode; - break; - } - } - - var onImported = this.onImported.bind(this, evaldImportNode, context); - - var sequencedOnImported = this._sequencer.addImport(onImported); - - this._importer.push(evaldImportNode.getPath(), tryAppendLessExtension, evaldImportNode.fileInfo(), evaldImportNode.options, sequencedOnImported); - } else { - this.importCount--; - - if (this.isFinished) { - this._sequencer.tryRun(); - } - } - }, - onImported: function onImported(importNode, context, e, root, importedAtRoot, fullPath) { - if (e) { - if (!e.filename) { - e.index = importNode.getIndex(); - e.filename = importNode.fileInfo().filename; - } - - this.error = e; - } - - var importVisitor = this; - var inlineCSS = importNode.options.inline; - var isPlugin = importNode.options.isPlugin; - var isOptional = importNode.options.optional; - var duplicateImport = importedAtRoot || fullPath in importVisitor.recursionDetector; - - if (!context.importMultiple) { - if (duplicateImport) { - importNode.skip = true; - } else { - importNode.skip = function () { - if (fullPath in importVisitor.onceFileDetectionMap) { - return true; - } - - importVisitor.onceFileDetectionMap[fullPath] = true; - return false; - }; - } - } - - if (!fullPath && isOptional) { - importNode.skip = true; - } - - if (root) { - importNode.root = root; - importNode.importedFilename = fullPath; - - if (!inlineCSS && !isPlugin && (context.importMultiple || !duplicateImport)) { - importVisitor.recursionDetector[fullPath] = true; - var oldContext = this.context; - this.context = context; - - try { - this._visitor.visit(root); - } catch (e) { - this.error = e; - } - - this.context = oldContext; - } - } - - importVisitor.importCount--; - - if (importVisitor.isFinished) { - importVisitor._sequencer.tryRun(); - } - }, - visitDeclaration: function visitDeclaration(declNode, visitArgs) { - if (declNode.value.type === 'DetachedRuleset') { - this.context.frames.unshift(declNode); - } else { - visitArgs.visitDeeper = false; - } - }, - visitDeclarationOut: function visitDeclarationOut(declNode) { - if (declNode.value.type === 'DetachedRuleset') { - this.context.frames.shift(); - } - }, - visitAtRule: function visitAtRule(atRuleNode, visitArgs) { - this.context.frames.unshift(atRuleNode); - }, - visitAtRuleOut: function visitAtRuleOut(atRuleNode) { - this.context.frames.shift(); - }, - visitMixinDefinition: function visitMixinDefinition(mixinDefinitionNode, visitArgs) { - this.context.frames.unshift(mixinDefinitionNode); - }, - visitMixinDefinitionOut: function visitMixinDefinitionOut(mixinDefinitionNode) { - this.context.frames.shift(); - }, - visitRuleset: function visitRuleset(rulesetNode, visitArgs) { - this.context.frames.unshift(rulesetNode); - }, - visitRulesetOut: function visitRulesetOut(rulesetNode) { - this.context.frames.shift(); - }, - visitMedia: function visitMedia(mediaNode, visitArgs) { - this.context.frames.unshift(mediaNode.rules[0]); - }, - visitMediaOut: function visitMediaOut(mediaNode) { - this.context.frames.shift(); - } - }; - - var SetTreeVisibilityVisitor = - /*#__PURE__*/ - function () { - function SetTreeVisibilityVisitor(visible) { - _classCallCheck(this, SetTreeVisibilityVisitor); - - this.visible = visible; - } - - _createClass(SetTreeVisibilityVisitor, [{ - key: "run", - value: function run(root) { - this.visit(root); - } - }, { - key: "visitArray", - value: function visitArray(nodes) { - if (!nodes) { - return nodes; - } - - var cnt = nodes.length; - var i; - - for (i = 0; i < cnt; i++) { - this.visit(nodes[i]); - } - - return nodes; - } - }, { - key: "visit", - value: function visit(node) { - if (!node) { - return node; - } - - if (node.constructor === Array) { - return this.visitArray(node); - } - - if (!node.blocksVisibility || node.blocksVisibility()) { - return node; - } - - if (this.visible) { - node.ensureVisibility(); - } else { - node.ensureInvisibility(); - } - - node.accept(this); - return node; - } - }]); - - return SetTreeVisibilityVisitor; - }(); - - /* jshint loopfunc:true */ - - var ExtendFinderVisitor = - /*#__PURE__*/ - function () { - function ExtendFinderVisitor() { - _classCallCheck(this, ExtendFinderVisitor); - - this._visitor = new Visitor(this); - this.contexts = []; - this.allExtendsStack = [[]]; - } - - _createClass(ExtendFinderVisitor, [{ - key: "run", - value: function run(root) { - root = this._visitor.visit(root); - root.allExtends = this.allExtendsStack[0]; - return root; - } - }, { - key: "visitDeclaration", - value: function visitDeclaration(declNode, visitArgs) { - visitArgs.visitDeeper = false; - } - }, { - key: "visitMixinDefinition", - value: function visitMixinDefinition(mixinDefinitionNode, visitArgs) { - visitArgs.visitDeeper = false; - } - }, { - key: "visitRuleset", - value: function visitRuleset(rulesetNode, visitArgs) { - if (rulesetNode.root) { - return; - } - - var i; - var j; - var extend; - var allSelectorsExtendList = []; - var extendList; // get &:extend(.a); rules which apply to all selectors in this ruleset - - var rules = rulesetNode.rules; - var ruleCnt = rules ? rules.length : 0; - - for (i = 0; i < ruleCnt; i++) { - if (rulesetNode.rules[i] instanceof tree.Extend) { - allSelectorsExtendList.push(rules[i]); - rulesetNode.extendOnEveryPath = true; - } - } // now find every selector and apply the extends that apply to all extends - // and the ones which apply to an individual extend - - - var paths = rulesetNode.paths; - - for (i = 0; i < paths.length; i++) { - var selectorPath = paths[i]; - var selector = selectorPath[selectorPath.length - 1]; - var selExtendList = selector.extendList; - extendList = selExtendList ? copyArray(selExtendList).concat(allSelectorsExtendList) : allSelectorsExtendList; - - if (extendList) { - extendList = extendList.map(function (allSelectorsExtend) { - return allSelectorsExtend.clone(); - }); - } - - for (j = 0; j < extendList.length; j++) { - this.foundExtends = true; - extend = extendList[j]; - extend.findSelfSelectors(selectorPath); - extend.ruleset = rulesetNode; - - if (j === 0) { - extend.firstExtendOnThisSelectorPath = true; - } - - this.allExtendsStack[this.allExtendsStack.length - 1].push(extend); - } - } - - this.contexts.push(rulesetNode.selectors); - } - }, { - key: "visitRulesetOut", - value: function visitRulesetOut(rulesetNode) { - if (!rulesetNode.root) { - this.contexts.length = this.contexts.length - 1; - } - } - }, { - key: "visitMedia", - value: function visitMedia(mediaNode, visitArgs) { - mediaNode.allExtends = []; - this.allExtendsStack.push(mediaNode.allExtends); - } - }, { - key: "visitMediaOut", - value: function visitMediaOut(mediaNode) { - this.allExtendsStack.length = this.allExtendsStack.length - 1; - } - }, { - key: "visitAtRule", - value: function visitAtRule(atRuleNode, visitArgs) { - atRuleNode.allExtends = []; - this.allExtendsStack.push(atRuleNode.allExtends); - } - }, { - key: "visitAtRuleOut", - value: function visitAtRuleOut(atRuleNode) { - this.allExtendsStack.length = this.allExtendsStack.length - 1; - } - }]); - - return ExtendFinderVisitor; - }(); - - var ProcessExtendsVisitor = - /*#__PURE__*/ - function () { - function ProcessExtendsVisitor() { - _classCallCheck(this, ProcessExtendsVisitor); - - this._visitor = new Visitor(this); - } - - _createClass(ProcessExtendsVisitor, [{ - key: "run", - value: function run(root) { - var extendFinder = new ExtendFinderVisitor(); - this.extendIndices = {}; - extendFinder.run(root); - - if (!extendFinder.foundExtends) { - return root; - } - - root.allExtends = root.allExtends.concat(this.doExtendChaining(root.allExtends, root.allExtends)); - this.allExtendsStack = [root.allExtends]; - - var newRoot = this._visitor.visit(root); - - this.checkExtendsForNonMatched(root.allExtends); - return newRoot; - } - }, { - key: "checkExtendsForNonMatched", - value: function checkExtendsForNonMatched(extendList) { - var indices = this.extendIndices; - extendList.filter(function (extend) { - return !extend.hasFoundMatches && extend.parent_ids.length == 1; - }).forEach(function (extend) { - var selector = '_unknown_'; - - try { - selector = extend.selector.toCSS({}); - } catch (_) {} - - if (!indices["".concat(extend.index, " ").concat(selector)]) { - indices["".concat(extend.index, " ").concat(selector)] = true; - logger.warn("extend '".concat(selector, "' has no matches")); - } - }); - } - }, { - key: "doExtendChaining", - value: function doExtendChaining(extendsList, extendsListTarget, iterationCount) { - // - // chaining is different from normal extension.. if we extend an extend then we are not just copying, altering - // and pasting the selector we would do normally, but we are also adding an extend with the same target selector - // this means this new extend can then go and alter other extends - // - // this method deals with all the chaining work - without it, extend is flat and doesn't work on other extend selectors - // this is also the most expensive.. and a match on one selector can cause an extension of a selector we had already - // processed if we look at each selector at a time, as is done in visitRuleset - var extendIndex; - var targetExtendIndex; - var matches; - var extendsToAdd = []; - var newSelector; - var extendVisitor = this; - var selectorPath; - var extend; - var targetExtend; - var newExtend; - iterationCount = iterationCount || 0; // 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. - // the separation into two lists allows us to process a subset of chains with a bigger set, as is the - // case when processing media queries - - for (extendIndex = 0; extendIndex < extendsList.length; extendIndex++) { - for (targetExtendIndex = 0; targetExtendIndex < extendsListTarget.length; targetExtendIndex++) { - extend = extendsList[extendIndex]; - targetExtend = extendsListTarget[targetExtendIndex]; // look for circular references - - if (extend.parent_ids.indexOf(targetExtend.object_id) >= 0) { - continue; - } // find a match in the target extends self selector (the bit before :extend) - - - selectorPath = [targetExtend.selfSelectors[0]]; - matches = extendVisitor.findMatch(extend, selectorPath); - - if (matches.length) { - extend.hasFoundMatches = true; // we found a match, so for each self selector.. - - extend.selfSelectors.forEach(function (selfSelector) { - var info = targetExtend.visibilityInfo(); // process the extend as usual - - 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.fileInfo(), info); - newExtend.selfSelectors = newSelector; // add the extend onto the list of extends for that selector - - newSelector[newSelector.length - 1].extendList = [newExtend]; // record that we need to add it. - - extendsToAdd.push(newExtend); - newExtend.ruleset = targetExtend.ruleset; // remember its parents for circular references - - newExtend.parent_ids = newExtend.parent_ids.concat(targetExtend.parent_ids, extend.parent_ids); // only process the selector once.. if we have :extend(.a,.b) then multiple - // extends will look at the same selector path, so when extending - // we know that any others will be duplicates in terms of what is added to the css - - if (targetExtend.firstExtendOnThisSelectorPath) { - newExtend.firstExtendOnThisSelectorPath = true; - targetExtend.ruleset.paths.push(newSelector); - } - }); - } - } - } - - if (extendsToAdd.length) { - // try to detect circular references to stop a stack overflow. - // may no longer be needed. - this.extendChainCount++; - - if (iterationCount > 100) { - var selectorOne = '{unable to calculate}'; - var selectorTwo = '{unable to calculate}'; - - try { - selectorOne = extendsToAdd[0].selfSelectors[0].toCSS(); - selectorTwo = extendsToAdd[0].selector.toCSS(); - } catch (e) {} - - throw { - message: "extend circular reference detected. One of the circular extends is currently:".concat(selectorOne, ":extend(").concat(selectorTwo, ")") - }; - } // now process the new extends on the existing rules so that we can handle a extending b extending c extending - // d extending e... - - - return extendsToAdd.concat(extendVisitor.doExtendChaining(extendsToAdd, extendsListTarget, iterationCount + 1)); - } else { - return extendsToAdd; - } - } - }, { - key: "visitDeclaration", - value: function visitDeclaration(ruleNode, visitArgs) { - visitArgs.visitDeeper = false; - } - }, { - key: "visitMixinDefinition", - value: function visitMixinDefinition(mixinDefinitionNode, visitArgs) { - visitArgs.visitDeeper = false; - } - }, { - key: "visitSelector", - value: function visitSelector(selectorNode, visitArgs) { - visitArgs.visitDeeper = false; - } - }, { - key: "visitRuleset", - value: function visitRuleset(rulesetNode, visitArgs) { - if (rulesetNode.root) { - return; - } - - var matches; - var pathIndex; - var extendIndex; - var allExtends = this.allExtendsStack[this.allExtendsStack.length - 1]; - var selectorsToAdd = []; - var extendVisitor = this; - var selectorPath; // look at each selector path in the ruleset, find any extend matches and then copy, find and replace - - for (extendIndex = 0; extendIndex < allExtends.length; extendIndex++) { - for (pathIndex = 0; pathIndex < rulesetNode.paths.length; pathIndex++) { - selectorPath = rulesetNode.paths[pathIndex]; // extending extends happens initially, before the main pass - - if (rulesetNode.extendOnEveryPath) { - continue; - } - - var extendList = selectorPath[selectorPath.length - 1].extendList; - - if (extendList && extendList.length) { - continue; - } - - matches = this.findMatch(allExtends[extendIndex], selectorPath); - - if (matches.length) { - allExtends[extendIndex].hasFoundMatches = true; - allExtends[extendIndex].selfSelectors.forEach(function (selfSelector) { - var extendedSelectors; - extendedSelectors = extendVisitor.extendSelector(matches, selectorPath, selfSelector, allExtends[extendIndex].isVisible()); - selectorsToAdd.push(extendedSelectors); - }); - } - } - } - - rulesetNode.paths = rulesetNode.paths.concat(selectorsToAdd); - } - }, { - key: "findMatch", - value: function findMatch(extend, haystackSelectorPath) { - // - // look through the haystack selector path to try and find the needle - extend.selector - // returns an array of selector matches that can then be replaced - // - var haystackSelectorIndex; - var hackstackSelector; - var hackstackElementIndex; - var haystackElement; - var targetCombinator; - var i; - var extendVisitor = this; - var needleElements = extend.selector.elements; - var potentialMatches = []; - var potentialMatch; - var matches = []; // loop through the haystack elements - - for (haystackSelectorIndex = 0; haystackSelectorIndex < haystackSelectorPath.length; haystackSelectorIndex++) { - hackstackSelector = haystackSelectorPath[haystackSelectorIndex]; - - for (hackstackElementIndex = 0; hackstackElementIndex < hackstackSelector.elements.length; hackstackElementIndex++) { - haystackElement = hackstackSelector.elements[hackstackElementIndex]; // if we allow elements before our match we can add a potential match every time. otherwise only at the first element. - - if (extend.allowBefore || haystackSelectorIndex === 0 && hackstackElementIndex === 0) { - potentialMatches.push({ - pathIndex: haystackSelectorIndex, - index: hackstackElementIndex, - matched: 0, - initialCombinator: haystackElement.combinator - }); - } - - for (i = 0; i < potentialMatches.length; i++) { - potentialMatch = potentialMatches[i]; // selectors add " " onto the first element. When we use & it joins the selectors together, but if we don't - // then each selector in haystackSelectorPath has a space before it added in the toCSS phase. so we need to - // work out what the resulting combinator will be - - targetCombinator = haystackElement.combinator.value; - - if (targetCombinator === '' && hackstackElementIndex === 0) { - targetCombinator = ' '; - } // if we don't match, null our match to indicate failure - - - if (!extendVisitor.isElementValuesEqual(needleElements[potentialMatch.matched].value, haystackElement.value) || potentialMatch.matched > 0 && needleElements[potentialMatch.matched].combinator.value !== targetCombinator) { - potentialMatch = null; - } else { - potentialMatch.matched++; - } // if we are still valid and have finished, test whether we have elements after and whether these are allowed - - - if (potentialMatch) { - potentialMatch.finished = potentialMatch.matched === needleElements.length; - - if (potentialMatch.finished && !extend.allowAfter && (hackstackElementIndex + 1 < hackstackSelector.elements.length || haystackSelectorIndex + 1 < haystackSelectorPath.length)) { - potentialMatch = null; - } - } // if null we remove, if not, we are still valid, so either push as a valid match or continue - - - if (potentialMatch) { - if (potentialMatch.finished) { - potentialMatch.length = needleElements.length; - potentialMatch.endPathIndex = haystackSelectorIndex; - potentialMatch.endPathElementIndex = hackstackElementIndex + 1; // index after end of match - - potentialMatches.length = 0; // we don't allow matches to overlap, so start matching again - - matches.push(potentialMatch); - } - } else { - potentialMatches.splice(i, 1); - i--; - } - } - } - } - - return matches; - } - }, { - key: "isElementValuesEqual", - value: function isElementValuesEqual(elementValue1, elementValue2) { - if (typeof elementValue1 === 'string' || typeof elementValue2 === 'string') { - return elementValue1 === elementValue2; - } - - if (elementValue1 instanceof tree.Attribute) { - if (elementValue1.op !== elementValue2.op || elementValue1.key !== elementValue2.key) { - return false; - } - - if (!elementValue1.value || !elementValue2.value) { - if (elementValue1.value || elementValue2.value) { - return false; - } - - return true; - } - - elementValue1 = elementValue1.value.value || elementValue1.value; - elementValue2 = elementValue2.value.value || elementValue2.value; - return elementValue1 === elementValue2; - } - - elementValue1 = elementValue1.value; - elementValue2 = elementValue2.value; - - if (elementValue1 instanceof tree.Selector) { - if (!(elementValue2 instanceof tree.Selector) || elementValue1.elements.length !== elementValue2.elements.length) { - return false; - } - - for (var i = 0; i < elementValue1.elements.length; i++) { - if (elementValue1.elements[i].combinator.value !== elementValue2.elements[i].combinator.value) { - if (i !== 0 || (elementValue1.elements[i].combinator.value || ' ') !== (elementValue2.elements[i].combinator.value || ' ')) { - return false; - } - } - - if (!this.isElementValuesEqual(elementValue1.elements[i].value, elementValue2.elements[i].value)) { - return false; - } - } - - return true; - } - - return false; - } - }, { - key: "extendSelector", - value: function extendSelector(matches, selectorPath, replacementSelector, isVisible) { - // for a set of matches, replace each match with the replacement selector - var currentSelectorPathIndex = 0; - var currentSelectorPathElementIndex = 0; - var path = []; - var matchIndex; - var selector; - var firstElement; - var match; - var newElements; - - for (matchIndex = 0; matchIndex < matches.length; matchIndex++) { - match = matches[matchIndex]; - selector = selectorPath[match.pathIndex]; - firstElement = new tree.Element(match.initialCombinator, replacementSelector.elements[0].value, replacementSelector.elements[0].isVariable, replacementSelector.elements[0].getIndex(), replacementSelector.elements[0].fileInfo()); - - if (match.pathIndex > currentSelectorPathIndex && currentSelectorPathElementIndex > 0) { - path[path.length - 1].elements = path[path.length - 1].elements.concat(selectorPath[currentSelectorPathIndex].elements.slice(currentSelectorPathElementIndex)); - currentSelectorPathElementIndex = 0; - currentSelectorPathIndex++; - } - - newElements = selector.elements.slice(currentSelectorPathElementIndex, match.index).concat([firstElement]).concat(replacementSelector.elements.slice(1)); - - if (currentSelectorPathIndex === match.pathIndex && matchIndex > 0) { - path[path.length - 1].elements = path[path.length - 1].elements.concat(newElements); - } else { - path = path.concat(selectorPath.slice(currentSelectorPathIndex, match.pathIndex)); - path.push(new tree.Selector(newElements)); - } - - currentSelectorPathIndex = match.endPathIndex; - currentSelectorPathElementIndex = match.endPathElementIndex; - - if (currentSelectorPathElementIndex >= selectorPath[currentSelectorPathIndex].elements.length) { - currentSelectorPathElementIndex = 0; - currentSelectorPathIndex++; - } - } - - if (currentSelectorPathIndex < selectorPath.length && currentSelectorPathElementIndex > 0) { - path[path.length - 1].elements = path[path.length - 1].elements.concat(selectorPath[currentSelectorPathIndex].elements.slice(currentSelectorPathElementIndex)); - currentSelectorPathIndex++; - } - - path = path.concat(selectorPath.slice(currentSelectorPathIndex, selectorPath.length)); - path = path.map(function (currentValue) { - // we can re-use elements here, because the visibility property matters only for selectors - var derived = currentValue.createDerived(currentValue.elements); - - if (isVisible) { - derived.ensureVisibility(); - } else { - derived.ensureInvisibility(); - } - - return derived; - }); - return path; - } - }, { - key: "visitMedia", - value: function visitMedia(mediaNode, visitArgs) { - var newAllExtends = mediaNode.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length - 1]); - newAllExtends = newAllExtends.concat(this.doExtendChaining(newAllExtends, mediaNode.allExtends)); - this.allExtendsStack.push(newAllExtends); - } - }, { - key: "visitMediaOut", - value: function visitMediaOut(mediaNode) { - var lastIndex = this.allExtendsStack.length - 1; - this.allExtendsStack.length = lastIndex; - } - }, { - key: "visitAtRule", - value: function visitAtRule(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); - } - }, { - key: "visitAtRuleOut", - value: function visitAtRuleOut(atRuleNode) { - var lastIndex = this.allExtendsStack.length - 1; - this.allExtendsStack.length = lastIndex; - } - }]); - - return ProcessExtendsVisitor; - }(); - - var JoinSelectorVisitor = - /*#__PURE__*/ - function () { - function JoinSelectorVisitor() { - _classCallCheck(this, JoinSelectorVisitor); - - this.contexts = [[]]; - this._visitor = new Visitor(this); - } - - _createClass(JoinSelectorVisitor, [{ - key: "run", - value: function run(root) { - return this._visitor.visit(root); - } - }, { - key: "visitDeclaration", - value: function visitDeclaration(declNode, visitArgs) { - visitArgs.visitDeeper = false; - } - }, { - key: "visitMixinDefinition", - value: function visitMixinDefinition(mixinDefinitionNode, visitArgs) { - visitArgs.visitDeeper = false; - } - }, { - key: "visitRuleset", - value: function visitRuleset(rulesetNode, visitArgs) { - var context = this.contexts[this.contexts.length - 1]; - var paths = []; - var selectors; - this.contexts.push(paths); - - if (!rulesetNode.root) { - selectors = rulesetNode.selectors; - - if (selectors) { - selectors = selectors.filter(function (selector) { - return selector.getIsOutput(); - }); - rulesetNode.selectors = selectors.length ? selectors : selectors = null; - - if (selectors) { - rulesetNode.joinSelectors(paths, context, selectors); - } - } - - if (!selectors) { - rulesetNode.rules = null; - } - - rulesetNode.paths = paths; - } - } - }, { - key: "visitRulesetOut", - value: function visitRulesetOut(rulesetNode) { - this.contexts.length = this.contexts.length - 1; - } - }, { - key: "visitMedia", - value: function visitMedia(mediaNode, visitArgs) { - var context = this.contexts[this.contexts.length - 1]; - mediaNode.rules[0].root = context.length === 0 || context[0].multiMedia; - } - }, { - key: "visitAtRule", - value: function visitAtRule(atRuleNode, visitArgs) { - var context = this.contexts[this.contexts.length - 1]; - - if (atRuleNode.rules && atRuleNode.rules.length) { - atRuleNode.rules[0].root = atRuleNode.isRooted || context.length === 0 || null; - } - } - }]); - - return JoinSelectorVisitor; - }(); - - var CSSVisitorUtils = - /*#__PURE__*/ - function () { - function CSSVisitorUtils(context) { - _classCallCheck(this, CSSVisitorUtils); - - this._visitor = new Visitor(this); - this._context = context; - } - - _createClass(CSSVisitorUtils, [{ - key: "containsSilentNonBlockedChild", - value: function containsSilentNonBlockedChild(bodyRules) { - var rule; - - 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 atrule contains something that was referenced (likely by extend) - // therefore it needs to be shown in output too - return true; - } - } - - return false; - } - }, { - key: "keepOnlyVisibleChilds", - value: function keepOnlyVisibleChilds(owner) { - if (owner && owner.rules) { - owner.rules = owner.rules.filter(function (thing) { - return thing.isVisible(); - }); - } - } - }, { - key: "isEmpty", - value: function isEmpty(owner) { - return owner && owner.rules ? owner.rules.length === 0 : true; - } - }, { - key: "hasVisibleSelector", - value: function hasVisibleSelector(rulesetNode) { - return rulesetNode && rulesetNode.paths ? rulesetNode.paths.length > 0 : false; - } - }, { - key: "resolveVisibility", - value: function resolveVisibility(node, originalRules) { - if (!node.blocksVisibility()) { - if (this.isEmpty(node) && !this.containsSilentNonBlockedChild(originalRules)) { - return; - } - - return node; - } - - var compiledRulesBody = node.rules[0]; - this.keepOnlyVisibleChilds(compiledRulesBody); - - if (this.isEmpty(compiledRulesBody)) { - return; - } - - node.ensureVisibility(); - node.removeVisibilityBlock(); - return node; - } - }, { - key: "isVisibleRuleset", - value: function isVisibleRuleset(rulesetNode) { - if (rulesetNode.firstRoot) { - return true; - } - - if (this.isEmpty(rulesetNode)) { - return false; - } - - if (!rulesetNode.root && !this.hasVisibleSelector(rulesetNode)) { - return false; - } - - return true; - } - }]); - - return CSSVisitorUtils; - }(); - - var ToCSSVisitor = function ToCSSVisitor(context) { - this._visitor = new Visitor(this); - this._context = context; - this.utils = new CSSVisitorUtils(context); - }; - - ToCSSVisitor.prototype = { - isReplacing: true, - run: function run(root) { - return this._visitor.visit(root); - }, - visitDeclaration: function visitDeclaration(declNode, visitArgs) { - if (declNode.blocksVisibility() || declNode.variable) { - return; - } - - return declNode; - }, - visitMixinDefinition: function visitMixinDefinition(mixinNode, visitArgs) { - // mixin definitions do not get eval'd - this means they keep state - // so we have to clear that state here so it isn't used if toCSS is called twice - mixinNode.frames = []; - }, - visitExtend: function visitExtend(extendNode, visitArgs) {}, - visitComment: function visitComment(commentNode, visitArgs) { - if (commentNode.blocksVisibility() || commentNode.isSilent(this._context)) { - return; - } - - return commentNode; - }, - visitMedia: function visitMedia(mediaNode, visitArgs) { - var originalRules = mediaNode.rules[0].rules; - mediaNode.accept(this._visitor); - visitArgs.visitDeeper = false; - return this.utils.resolveVisibility(mediaNode, originalRules); - }, - visitImport: function visitImport(importNode, visitArgs) { - if (importNode.blocksVisibility()) { - return; - } - - return importNode; - }, - visitAtRule: function visitAtRule(atRuleNode, visitArgs) { - if (atRuleNode.rules && atRuleNode.rules.length) { - return this.visitAtRuleWithBody(atRuleNode, visitArgs); - } else { - return this.visitAtRuleWithoutBody(atRuleNode, visitArgs); - } - }, - visitAnonymous: function visitAnonymous(anonymousNode, visitArgs) { - if (!anonymousNode.blocksVisibility()) { - anonymousNode.accept(this._visitor); - return anonymousNode; - } - }, - visitAtRuleWithBody: function visitAtRuleWithBody(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(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(atRuleNode); - atRuleNode.accept(this._visitor); - visitArgs.visitDeeper = false; - - if (!this.utils.isEmpty(atRuleNode)) { - this._mergeRules(atRuleNode.rules[0].rules); - } - - return this.utils.resolveVisibility(atRuleNode, originalRules); - }, - visitAtRuleWithoutBody: function visitAtRuleWithoutBody(atRuleNode, visitArgs) { - if (atRuleNode.blocksVisibility()) { - return; - } - - if (atRuleNode.name === '@charset') { - // Only output the debug info together with subsequent @charset definitions - // 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 (atRuleNode.debugInfo) { - var comment = new tree.Comment("/* ".concat(atRuleNode.toCSS(this._context).replace(/\n/g, ''), " */\n")); - comment.debugInfo = atRuleNode.debugInfo; - return this._visitor.visit(comment); - } - - return; - } - - this.charset = true; - } - - return atRuleNode; - }, - checkValidNodes: function checkValidNodes(rules, isRoot) { - if (!rules) { - return; - } - - for (var i = 0; i < rules.length; i++) { - var ruleNode = rules[i]; - - if (isRoot && ruleNode instanceof tree.Declaration && !ruleNode.variable) { - throw { - message: 'Properties must be inside selector blocks. They cannot be in the root', - index: ruleNode.getIndex(), - filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename - }; - } - - if (ruleNode instanceof tree.Call) { - throw { - message: "Function '".concat(ruleNode.name, "' is undefined"), - index: ruleNode.getIndex(), - filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename - }; - } - - if (ruleNode.type && !ruleNode.allowRoot) { - throw { - message: "".concat(ruleNode.type, " node returned by a function is not valid here"), - index: ruleNode.getIndex(), - filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename - }; - } - } - }, - visitRuleset: function visitRuleset(rulesetNode, visitArgs) { - // at this point rulesets are nested into each other - var rule; - var rulesets = []; - this.checkValidNodes(rulesetNode.rules, rulesetNode.firstRoot); - - if (!rulesetNode.root) { - // remove invisible paths - this._compileRulesetPaths(rulesetNode); // remove rulesets from this ruleset body and compile them separately - - - var nodeRules = rulesetNode.rules; - var nodeRuleCnt = nodeRules ? nodeRules.length : 0; - - for (var i = 0; i < nodeRuleCnt;) { - rule = nodeRules[i]; - - if (rule && rule.rules) { - // visit because we are moving them out from being a child - rulesets.push(this._visitor.visit(rule)); - nodeRules.splice(i, 1); - nodeRuleCnt--; - continue; - } - - i++; - } // accept the visitor to remove rules and refactor itself - // then we can decide nogw whether we want it or not - // compile body - - - if (nodeRuleCnt > 0) { - rulesetNode.accept(this._visitor); - } else { - rulesetNode.rules = null; - } - - visitArgs.visitDeeper = false; - } else { - // if (! rulesetNode.root) { - rulesetNode.accept(this._visitor); - visitArgs.visitDeeper = false; - } - - if (rulesetNode.rules) { - this._mergeRules(rulesetNode.rules); - - this._removeDuplicateRules(rulesetNode.rules); - } // now decide whether we keep the ruleset - - - if (this.utils.isVisibleRuleset(rulesetNode)) { - rulesetNode.ensureVisibility(); - rulesets.splice(0, 0, rulesetNode); - } - - if (rulesets.length === 1) { - return rulesets[0]; - } - - return rulesets; - }, - _compileRulesetPaths: function _compileRulesetPaths(rulesetNode) { - if (rulesetNode.paths) { - rulesetNode.paths = rulesetNode.paths.filter(function (p) { - var i; - - if (p[0].elements[0].combinator.value === ' ') { - p[0].elements[0].combinator = new tree.Combinator(''); - } - - for (i = 0; i < p.length; i++) { - if (p[i].isVisible() && p[i].getIsOutput()) { - return true; - } - } - - return false; - }); - } - }, - _removeDuplicateRules: function _removeDuplicateRules(rules) { - if (!rules) { - return; - } // remove duplicates - - - var ruleCache = {}; - var ruleList; - var rule; - var i; - - for (i = rules.length - 1; i >= 0; i--) { - rule = rules[i]; - - if (rule instanceof tree.Declaration) { - if (!ruleCache[rule.name]) { - ruleCache[rule.name] = rule; - } else { - ruleList = ruleCache[rule.name]; - - if (ruleList instanceof tree.Declaration) { - ruleList = ruleCache[rule.name] = [ruleCache[rule.name].toCSS(this._context)]; - } - - var ruleCSS = rule.toCSS(this._context); - - if (ruleList.indexOf(ruleCSS) !== -1) { - rules.splice(i, 1); - } else { - ruleList.push(ruleCSS); - } - } - } - } - }, - _mergeRules: function _mergeRules(rules) { - if (!rules) { - return; - } - - var groups = {}; - var groupsArr = []; - - for (var i = 0; i < rules.length; i++) { - 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); - } - } - - groupsArr.forEach(function (group) { - if (group.length > 0) { - var result = group[0]; - var space = []; - var comma = [new tree.Expression(space)]; - group.forEach(function (rule) { - if (rule.merge === '+' && space.length > 0) { - comma.push(new tree.Expression(space = [])); - } - - space.push(rule.value); - result.important = result.important || rule.important; - }); - result.value = new tree.Value(comma); - } - }); - } - }; - - var visitors = { - Visitor: Visitor, - ImportVisitor: ImportVisitor, - MarkVisibleSelectorsVisitor: SetTreeVisibilityVisitor, - ExtendVisitor: ProcessExtendsVisitor, - JoinSelectorVisitor: JoinSelectorVisitor, - ToCSSVisitor: ToCSSVisitor - }; - - // Split the input into chunks. - var chunker = (function (input, fail) { - var len = input.length; - var level = 0; - var parenLevel = 0; - var lastOpening; - var lastOpeningParen; - var lastMultiComment; - var lastMultiCommentEndBrace; - var chunks = []; - var emitFrom = 0; - var chunkerCurrentIndex; - var currentChunkStartIndex; - var cc; - var cc2; - var matched; - - function emitChunk(force) { - var len = chunkerCurrentIndex - emitFrom; - - if (len < 512 && !force || !len) { - return; - } - - chunks.push(input.slice(emitFrom, chunkerCurrentIndex + 1)); - emitFrom = chunkerCurrentIndex + 1; - } - - for (chunkerCurrentIndex = 0; chunkerCurrentIndex < len; chunkerCurrentIndex++) { - cc = input.charCodeAt(chunkerCurrentIndex); - - if (cc >= 97 && cc <= 122 || cc < 34) { - // a-z or whitespace - continue; - } - - switch (cc) { - case 40: - // ( - parenLevel++; - lastOpeningParen = chunkerCurrentIndex; - continue; - - case 41: - // ) - if (--parenLevel < 0) { - return fail('missing opening `(`', chunkerCurrentIndex); - } - - continue; - - case 59: - // ; - if (!parenLevel) { - emitChunk(); - } - - continue; - - case 123: - // { - level++; - lastOpening = chunkerCurrentIndex; - continue; - - case 125: - // } - if (--level < 0) { - return fail('missing opening `{`', chunkerCurrentIndex); - } - - if (!level && !parenLevel) { - emitChunk(); - } - - continue; - - case 92: - // \ - if (chunkerCurrentIndex < len - 1) { - chunkerCurrentIndex++; - continue; - } - - return fail('unescaped `\\`', chunkerCurrentIndex); - - case 34: - case 39: - case 96: - // ", ' and ` - matched = 0; - currentChunkStartIndex = chunkerCurrentIndex; - - for (chunkerCurrentIndex = chunkerCurrentIndex + 1; chunkerCurrentIndex < len; chunkerCurrentIndex++) { - cc2 = input.charCodeAt(chunkerCurrentIndex); - - if (cc2 > 96) { - continue; - } - - if (cc2 == cc) { - matched = 1; - break; - } - - if (cc2 == 92) { - // \ - if (chunkerCurrentIndex == len - 1) { - return fail('unescaped `\\`', chunkerCurrentIndex); - } - - chunkerCurrentIndex++; - } - } - - if (matched) { - continue; - } - - return fail("unmatched `".concat(String.fromCharCode(cc), "`"), currentChunkStartIndex); - - case 47: - // /, check for comment - if (parenLevel || chunkerCurrentIndex == len - 1) { - continue; - } - - cc2 = input.charCodeAt(chunkerCurrentIndex + 1); - - if (cc2 == 47) { - // //, find lnfeed - for (chunkerCurrentIndex = chunkerCurrentIndex + 2; chunkerCurrentIndex < len; chunkerCurrentIndex++) { - cc2 = input.charCodeAt(chunkerCurrentIndex); - - if (cc2 <= 13 && (cc2 == 10 || cc2 == 13)) { - break; - } - } - } else if (cc2 == 42) { - // /*, find */ - lastMultiComment = currentChunkStartIndex = chunkerCurrentIndex; - - for (chunkerCurrentIndex = chunkerCurrentIndex + 2; chunkerCurrentIndex < len - 1; chunkerCurrentIndex++) { - cc2 = input.charCodeAt(chunkerCurrentIndex); - - if (cc2 == 125) { - lastMultiCommentEndBrace = chunkerCurrentIndex; - } - - if (cc2 != 42) { - continue; - } - - if (input.charCodeAt(chunkerCurrentIndex + 1) == 47) { - break; - } - } - - if (chunkerCurrentIndex == len - 1) { - return fail('missing closing `*/`', currentChunkStartIndex); - } - - chunkerCurrentIndex++; - } - - continue; - - case 42: - // *, check for unmatched */ - if (chunkerCurrentIndex < len - 1 && input.charCodeAt(chunkerCurrentIndex + 1) == 47) { - return fail('unmatched `/*`', chunkerCurrentIndex); - } - - continue; - } - } - - if (level !== 0) { - if (lastMultiComment > lastOpening && lastMultiCommentEndBrace > lastMultiComment) { - return fail('missing closing `}` or `*/`', lastOpening); - } else { - return fail('missing closing `}`', lastOpening); - } - } else if (parenLevel !== 0) { - return fail('missing closing `)`', lastOpeningParen); - } - - emitChunk(true); - return chunks; - }); - - var getParserInput = (function () { - var // Less input string - input; - var // current chunk - j; - var // holds state for backtracking - saveStack = []; - var // furthest index the parser has gone to - furthest; - var // if this is furthest we got to, this is the probably cause - furthestPossibleErrorMessage; - var // chunkified input - chunks; - var // current chunk - current; - var // index of current chunk, in `input` - currentPos; - var parserInput = {}; - var CHARCODE_SPACE = 32; - var CHARCODE_TAB = 9; - var CHARCODE_LF = 10; - var CHARCODE_CR = 13; - var CHARCODE_PLUS = 43; - var CHARCODE_COMMA = 44; - var CHARCODE_FORWARD_SLASH = 47; - var CHARCODE_9 = 57; - - function skipWhitespace(length) { - var oldi = parserInput.i; - var oldj = j; - var curr = parserInput.i - currentPos; - var endIndex = parserInput.i + current.length - curr; - var mem = parserInput.i += length; - var inp = input; - var c; - var nextChar; - var comment; - - for (; parserInput.i < endIndex; parserInput.i++) { - c = inp.charCodeAt(parserInput.i); - - if (parserInput.autoCommentAbsorb && c === CHARCODE_FORWARD_SLASH) { - nextChar = inp.charAt(parserInput.i + 1); - - if (nextChar === '/') { - comment = { - index: parserInput.i, - isLineComment: true - }; - var nextNewLine = inp.indexOf('\n', parserInput.i + 2); - - if (nextNewLine < 0) { - nextNewLine = endIndex; - } - - parserInput.i = nextNewLine; - comment.text = inp.substr(comment.index, parserInput.i - comment.index); - parserInput.commentStore.push(comment); - continue; - } else if (nextChar === '*') { - var nextStarSlash = inp.indexOf('*/', parserInput.i + 2); - - if (nextStarSlash >= 0) { - comment = { - index: parserInput.i, - text: inp.substr(parserInput.i, nextStarSlash + 2 - parserInput.i), - isLineComment: false - }; - parserInput.i += comment.text.length - 1; - parserInput.commentStore.push(comment); - continue; - } - } - - break; - } - - if (c !== CHARCODE_SPACE && c !== CHARCODE_LF && c !== CHARCODE_TAB && c !== CHARCODE_CR) { - break; - } - } - - current = current.slice(length + parserInput.i - mem + curr); - currentPos = parserInput.i; - - if (!current.length) { - if (j < chunks.length - 1) { - current = chunks[++j]; - skipWhitespace(0); // skip space at the beginning of a chunk - - return true; // things changed - } - - parserInput.finished = true; - } - - return oldi !== parserInput.i || oldj !== j; - } - - parserInput.save = function () { - currentPos = parserInput.i; - saveStack.push({ - current: current, - i: parserInput.i, - j: j - }); }; - - parserInput.restore = function (possibleErrorMessage) { - if (parserInput.i > furthest || parserInput.i === furthest && possibleErrorMessage && !furthestPossibleErrorMessage) { - furthest = parserInput.i; - furthestPossibleErrorMessage = possibleErrorMessage; - } - - var state = saveStack.pop(); - current = state.current; - currentPos = parserInput.i = state.i; - j = state.j; - }; - - parserInput.forget = function () { - saveStack.pop(); - }; - - parserInput.isWhitespace = function (offset) { - var pos = parserInput.i + (offset || 0); - var code = input.charCodeAt(pos); - return code === CHARCODE_SPACE || code === CHARCODE_CR || code === CHARCODE_TAB || code === CHARCODE_LF; - }; // Specialization of $(tok) - - - parserInput.$re = function (tok) { - if (parserInput.i > currentPos) { - current = current.slice(parserInput.i - currentPos); - currentPos = parserInput.i; - } - - var m = tok.exec(current); - - if (!m) { - return null; - } - - skipWhitespace(m[0].length); - - if (typeof m === 'string') { - return m; - } - - return m.length === 1 ? m[0] : m; - }; - - parserInput.$char = function (tok) { - if (input.charAt(parserInput.i) !== tok) { - return null; - } - - skipWhitespace(1); - return tok; - }; - - parserInput.$str = function (tok) { - var tokLength = tok.length; // https://jsperf.com/string-startswith/21 - - for (var i = 0; i < tokLength; i++) { - if (input.charAt(parserInput.i + i) !== tok.charAt(i)) { - return null; - } - } - - skipWhitespace(tokLength); - return tok; - }; - - parserInput.$quoted = function (loc) { - var pos = loc || parserInput.i; - var startChar = input.charAt(pos); - - if (startChar !== '\'' && startChar !== '"') { - return; - } - - var length = input.length; - var currentPosition = pos; - - for (var i = 1; i + currentPosition < length; i++) { - var nextChar = input.charAt(i + currentPosition); - - switch (nextChar) { - case '\\': - i++; - continue; - - case '\r': - case '\n': - break; - - case startChar: - var str = input.substr(currentPosition, i + 1); - - if (!loc && loc !== 0) { - skipWhitespace(i + 1); - return str; + Ruleset.prototype = Object.assign(new Node(), { + type: 'Ruleset', + isRuleset: true, + isRulesetLike: function () { return true; }, + accept: function (visitor) { + if (this.paths) { + this.paths = visitor.visitArray(this.paths, true); } - - return [startChar, str]; - - default: - } - } - - return null; - }; - /** - * Permissive parsing. Ignores everything except matching {} [] () and quotes - * until matching token (outside of blocks) - */ - - - parserInput.$parseUntil = function (tok) { - var quote = ''; - var returnVal = null; - var inComment = false; - var blockDepth = 0; - var blockStack = []; - var parseGroups = []; - var length = input.length; - var startPos = parserInput.i; - var lastPos = parserInput.i; - var i = parserInput.i; - var loop = true; - var testChar; - - if (typeof tok === 'string') { - testChar = function testChar(char) { - return char === tok; - }; - } else { - testChar = function testChar(char) { - return tok.test(char); - }; - } - - do { - var nextChar = input.charAt(i); - - if (blockDepth === 0 && testChar(nextChar)) { - returnVal = input.substr(lastPos, i - lastPos); - - if (returnVal) { - parseGroups.push(returnVal); - } else { - parseGroups.push(' '); - } - - returnVal = parseGroups; - skipWhitespace(i - startPos); - loop = false; - } else { - if (inComment) { - if (nextChar === '*' && input.charAt(i + 1) === '/') { - i++; - blockDepth--; - inComment = false; + else if (this.selectors) { + this.selectors = visitor.visitArray(this.selectors); } - - i++; - continue; - } - - switch (nextChar) { - case '\\': - i++; - nextChar = input.charAt(i); - parseGroups.push(input.substr(lastPos, i - lastPos + 1)); - lastPos = i + 1; - break; - - case '/': - if (input.charAt(i + 1) === '*') { - i++; - inComment = true; - blockDepth++; - } - - break; - - case '\'': - case '"': - quote = parserInput.$quoted(i); - - if (quote) { - parseGroups.push(input.substr(lastPos, i - lastPos), quote); - i += quote[1].length - 1; - lastPos = i + 1; - } else { - skipWhitespace(i - startPos); - returnVal = nextChar; - loop = false; - } - - break; - - case '{': - blockStack.push('}'); - blockDepth++; - break; - - case '(': - blockStack.push(')'); - blockDepth++; - break; - - case '[': - blockStack.push(']'); - blockDepth++; - break; - - case '}': - case ')': - case ']': - var expected = blockStack.pop(); - - if (nextChar === expected) { - blockDepth--; - } else { - // move the parser to the error and return expected - skipWhitespace(i - startPos); - returnVal = expected; - loop = false; - } - - } - - i++; - - if (i > length) { - loop = false; - } - } - } while (loop); - - return returnVal ? returnVal : null; - }; - - parserInput.autoCommentAbsorb = true; - parserInput.commentStore = []; - parserInput.finished = false; // Same as $(), but don't change the state of the parser, - // just return the match. - - parserInput.peek = function (tok) { - if (typeof tok === 'string') { - // https://jsperf.com/string-startswith/21 - for (var i = 0; i < tok.length; i++) { - if (input.charAt(parserInput.i + i) !== tok.charAt(i)) { - return false; - } - } - - return true; - } else { - return tok.test(current); - } - }; // Specialization of peek() - // TODO remove or change some currentChar calls to peekChar - - - parserInput.peekChar = function (tok) { - return input.charAt(parserInput.i) === tok; - }; - - parserInput.currentChar = function () { - return input.charAt(parserInput.i); - }; - - parserInput.prevChar = function () { - return input.charAt(parserInput.i - 1); - }; - - parserInput.getInput = function () { - return input; - }; - - parserInput.peekNotNumeric = function () { - var c = input.charCodeAt(parserInput.i); // Is the first char of the dimension 0-9, '.', '+' or '-' - - return c > CHARCODE_9 || c < CHARCODE_PLUS || c === CHARCODE_FORWARD_SLASH || c === CHARCODE_COMMA; - }; - - parserInput.start = function (str, chunkInput, failFunction) { - input = str; - parserInput.i = j = currentPos = furthest = 0; // chunking apparently makes things quicker (but my tests indicate - // it might actually make things slower in node at least) - // and it is a non-perfect parse - it can't recognise - // unquoted urls, meaning it can't distinguish comments - // meaning comments with quotes or {}() in them get 'counted' - // and then lead to parse errors. - // In addition if the chunking chunks in the wrong place we might - // not be able to parse a parser statement in one go - // this is officially deprecated but can be switched on via an option - // in the case it causes too much performance issues. - - if (chunkInput) { - chunks = chunker(str, failFunction); - } else { - chunks = [str]; - } - - current = chunks[0]; - skipWhitespace(0); - }; - - parserInput.end = function () { - var message; - var isFinished = parserInput.i >= input.length; - - if (parserInput.i < furthest) { - message = furthestPossibleErrorMessage; - parserInput.i = furthest; - } - - return { - isFinished: isFinished, - furthest: parserInput.i, - furthestPossibleErrorMessage: message, - furthestReachedEnd: parserInput.i >= input.length - 1, - furthestChar: input[parserInput.i] - }; - }; - - return parserInput; - }); - - // less.js - parser - // - // A relatively straight-forward predictive parser. - // There is no tokenization/lexing stage, the input is parsed - // in one sweep. - // - // To make the parser fast enough to run in the browser, several - // optimization had to be made: - // - // - Matching and slicing on a huge input is often cause of slowdowns. - // The solution is to chunkify the input into smaller strings. - // The chunks are stored in the `chunks` var, - // `j` holds the current chunk index, and `currentPos` holds - // the index of the current chunk in relation to `input`. - // This gives us an almost 4x speed-up. - // - // - In many cases, we don't need to match individual tokens; - // for example, if a value doesn't hold any variables, operations - // or dynamic references, the parser can effectively 'skip' it, - // treating it as a literal. - // An example would be '1px solid #000' - which evaluates to itself, - // we don't need to know what the individual components are. - // The drawback, of course is that you don't get the benefits of - // syntax-checking on the CSS. This gives us a 50% speed-up in the parser, - // and a smaller speed-up in the code-gen. - // - // - // 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; - var parserInput = getParserInput(); - - function error(msg, type) { - throw new LessError({ - index: parserInput.i, - filename: fileInfo.filename, - type: type || 'Syntax', - message: msg - }, imports); - } - - function expect(arg, msg) { - // some older browsers return typeof 'function' for RegExp - var result = arg instanceof Function ? arg.call(parsers) : parserInput.$re(arg); - - if (result) { - return result; - } - - error(msg || (typeof arg === 'string' ? "expected '".concat(arg, "' got '").concat(parserInput.currentChar(), "'") : 'unexpected token')); - } // Specialization of expect() - - - function expectChar(arg, msg) { - if (parserInput.$char(arg)) { - return arg; - } - - error(msg || "expected '".concat(arg, "' got '").concat(parserInput.currentChar(), "'")); - } - - function getDebugInfo(index) { - var filename = fileInfo.filename; - return { - lineNumber: getLocation(index, parserInput.getInput()).line + 1, - fileName: filename - }; - } - /** - * 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; - var 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) { - try { - result._index = i + currentIndex; - result._fileInfo = fileInfo; - } catch (e) {} - - 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 - // @param callback call `callback` when done. - // @param [additionalData] An optional map which can contains vars - a map (key, value) of variables to apply - // - parse: function parse(str, callback, additionalData) { - var root; - var error = null; - var globalVars; - var modifyVars; - var ignored; - var preText = ''; - globalVars = additionalData && additionalData.globalVars ? "".concat(Parser.serializeVars(additionalData.globalVars), "\n") : ''; - modifyVars = additionalData && additionalData.modifyVars ? "\n".concat(Parser.serializeVars(additionalData.modifyVars)) : ''; - - if (context.pluginManager) { - var preProcessors = context.pluginManager.getPreProcessors(); - - for (var i = 0; i < preProcessors.length; i++) { - str = preProcessors[i].process(str, { - context: context, - imports: imports, - fileInfo: fileInfo - }); - } - } - - if (globalVars || additionalData && additionalData.banner) { - preText = (additionalData && additionalData.banner ? additionalData.banner : '') + globalVars; - ignored = imports.contentsIgnoredChars; - ignored[fileInfo.filename] = ignored[fileInfo.filename] || 0; - ignored[fileInfo.filename] += preText.length; - } - - str = str.replace(/\r\n?/g, '\n'); // Remove potential UTF Byte Order Mark - - str = preText + str.replace(/^\uFEFF/, '') + modifyVars; - imports.contents[fileInfo.filename] = str; // Start with the primary rule. - // The whole syntax tree is held under a Ruleset node, - // with the `root` property set to true, so no `{}` are - // output. The callback is called when the input is parsed. - - try { - parserInput.start(str, context.chunkInput, function fail(msg, index) { - throw new LessError({ - index: index, - type: 'Parse', - message: msg, - filename: fileInfo.filename - }, imports); - }); - 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)); - } // If `i` is smaller than the `input.length - 1`, - // it means the parser wasn't able to parse the whole - // string, so we've got a parsing error. - // - // We try to extract a \n delimited string, - // showing the line where the parse error occurred. - // We split it up into two parts (the part which parsed, - // and the part which didn't), so we can color them differently. - - - var endInfo = parserInput.end(); - - if (!endInfo.isFinished) { - var message = endInfo.furthestPossibleErrorMessage; - - if (!message) { - message = 'Unrecognised input'; - - if (endInfo.furthestChar === '}') { - message += '. Possibly missing opening \'{\''; - } else if (endInfo.furthestChar === ')') { - message += '. Possibly missing opening \'(\''; - } else if (endInfo.furthestReachedEnd) { - message += '. Possibly missing something'; + if (this.rules && this.rules.length) { + this.rules = visitor.visitArray(this.rules); } - } - - error = new LessError({ - type: 'Parse', - message: message, - index: endInfo.furthest, - filename: fileInfo.filename - }, imports); - } - - var finish = function finish(e) { - e = error || e || imports.error; - - if (e) { - if (!(e instanceof LessError)) { - e = new LessError(e, imports, fileInfo.filename); - } - - return callback(e); - } else { - return callback(null, root); - } - }; - - if (context.processImports !== false) { - new visitors.ImportVisitor(imports, finish).run(root); - } else { - return finish(); - } - }, - // - // Here in, the parsing rules/functions - // - // The basic structure of the syntax tree generated is as follows: - // - // Ruleset -> Declaration -> Value -> Expression -> Entity - // - // Here's some Less code: - // - // .class { - // color: #fff; - // border: 1px solid #000; - // width: @w + 4px; - // > .child {...} - // } - // - // And here's what the parse tree might look like: - // - // Ruleset (Selector '.class', [ - // 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'], [...]) - // ]) - // - // In general, most rules will try to parse a token with the `$re()` function, and if the return - // value is truly, will return a new node, of the relevant type. Sometimes, we need to check - // first, before parsing, that's when we use `peek()`. - // - parsers: parsers = { - // - // The `primary` rule is the *entry* and *exit* point of the parser. - // The rules here can appear at any level of the parse tree. - // - // The recursive nature of the grammar is an interplay between the `block` - // rule, which represents `{ ... }`, the `ruleset` rule, and this `primary` rule, - // as represented by this simplified grammar: - // - // primary → (ruleset | declaration)+ - // ruleset → selector+ block - // block → '{' primary '}' - // - // Only at one point is the primary rule not called from the - // block rule: at the root level. - // - primary: function primary() { - var mixin = this.mixin; - var root = []; - var node; - - while (true) { - while (true) { - node = this.comment(); - - if (!node) { - break; - } - - root.push(node); - } // always process comments before deciding if finished - - - if (parserInput.finished) { - break; - } - - if (parserInput.peek('}')) { - break; - } - - node = this.extendRule(); - - if (node) { - root = root.concat(node); - continue; - } - - node = mixin.definition() || this.declaration() || this.ruleset() || mixin.call(false, false) || this.variableCall() || this.entities.call() || this.atrule(); - - if (node) { - root.push(node); - } else { - var foundSemiColon = false; - - while (parserInput.$char(';')) { - foundSemiColon = true; - } - - if (!foundSemiColon) { - break; - } - } - } - - return root; }, - // comments are collected by the main parsing mechanism and then assigned to nodes - // where the current structure allows it - comment: function comment() { - if (parserInput.commentStore.length) { - var comment = parserInput.commentStore.shift(); - return new tree.Comment(comment.text, comment.isLineComment, comment.index, fileInfo); - } - }, - // - // Entities are tokens which can be found inside an Expression - // - entities: { - mixinLookup: function mixinLookup() { - return parsers.mixin.call(true, true); - }, - // - // A string, which supports escaping " and ' - // - // "milky way" 'he\'s the one!' - // - quoted: function quoted(forceEscaped) { - var str; - var index = parserInput.i; - var isEscaped = false; - parserInput.save(); - - if (parserInput.$char('~')) { - isEscaped = true; - } else if (forceEscaped) { - parserInput.restore(); - return; - } - - str = parserInput.$quoted(); - - if (!str) { - parserInput.restore(); - return; - } - - parserInput.forget(); - return new tree.Quoted(str.charAt(0), str.substr(1, str.length - 2), isEscaped, index, fileInfo); - }, - // - // A catch-all word, such as: - // - // black border-collapse - // - keyword: function keyword() { - var k = parserInput.$char('%') || parserInput.$re(/^\[?(?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+\]?/); - - if (k) { - return tree.Color.fromKeyword(k) || new tree.Keyword(k); - } - }, - // - // A function call - // - // rgb(255, 0, 255) - // - // The arguments are parsed with the `entities.arguments` parser. - // - call: function call() { - var name; - var args; - var func; - var index = parserInput.i; // http://jsperf.com/case-insensitive-regex-vs-strtolower-then-regex/18 - - if (parserInput.peek(/^url\(/i)) { - return; - } - - parserInput.save(); - name = parserInput.$re(/^([\w-]+|%|progid:[\w\.]+)\(/); - - if (!name) { - parserInput.forget(); - return; - } - - name = name[1]; - func = this.customFuncCall(name); - - if (func) { - args = func.parse(); - - if (args && func.stop) { - parserInput.forget(); - return args; - } - } - - args = this.arguments(args); - - if (!parserInput.$char(')')) { - parserInput.restore('Could not parse call arguments or missing \')\''); - return; - } - - parserInput.forget(); - return new tree.Call(name, args, index, fileInfo); - }, - // - // 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(...)`) - // - customFuncCall: function customFuncCall(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')]; - } - }, - arguments: function _arguments(prevArgs) { - var argsComma = prevArgs || []; - var argsSemiColon = []; - var isSemiColonSeparated; - var value; - parserInput.save(); - - while (true) { - if (prevArgs) { - prevArgs = false; - } else { - value = parsers.detachedRuleset() || this.assignment() || parsers.expression(); - - if (!value) { - break; - } - - if (value.value && value.value.length == 1) { - value = value.value[0]; - } - - argsComma.push(value); - } - - if (parserInput.$char(',')) { - continue; - } - - if (parserInput.$char(';') || isSemiColonSeparated) { - isSemiColonSeparated = true; - value = argsComma.length < 1 ? argsComma[0] : new tree.Value(argsComma); - argsSemiColon.push(value); - argsComma = []; - } - } - - parserInput.forget(); - return isSemiColonSeparated ? argsSemiColon : argsComma; - }, - literal: function literal() { - return this.dimension() || this.color() || this.quoted() || this.unicodeDescriptor(); - }, - // Assignments are argument entities for calls. - // They are present in ie filter properties as shown below. - // - // filter: progid:DXImageTransform.Microsoft.Alpha( *opacity=50* ) - // - assignment: function assignment() { - var key; - var value; - parserInput.save(); - key = parserInput.$re(/^\w+(?=\s?=)/i); - - if (!key) { - parserInput.restore(); - return; - } - - if (!parserInput.$char('=')) { - parserInput.restore(); - return; - } - - value = parsers.entity(); - - if (value) { - parserInput.forget(); - return new tree.Assignment(key, value); - } else { - parserInput.restore(); - } - }, - // - // Parse url() tokens - // - // We use a specific rule for urls, because they don't really behave like - // standard function calls. The difference is that the argument doesn't have - // to be enclosed within a string, so it can't be parsed as an Expression. - // - url: function url() { - var value; - var index = parserInput.i; - parserInput.autoCommentAbsorb = false; - - if (!parserInput.$str('url(')) { - parserInput.autoCommentAbsorb = true; - return; - } - - 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 instanceof tree.Property ? value : new tree.Anonymous(value, index), index, fileInfo); - }, - // - // A Variable entity, such as `@fink`, in - // - // width: @fink + 2px - // - // We use a different parser for variable definitions, - // see `parsers.variable`. - // - variable: function variable() { - var ch; - var name; - var index = parserInput.i; - parserInput.save(); - - if (parserInput.currentChar() === '@' && (name = parserInput.$re(/^@@?[\w-]+/))) { - ch = parserInput.currentChar(); - - if (ch === '(' || ch === '[' && !parserInput.prevChar().match(/^\s/)) { - // this may be a VariableCall lookup - var result = parsers.variableCall(name); - - if (result) { - parserInput.forget(); - return result; - } - } - - parserInput.forget(); - return new tree.Variable(name, index, fileInfo); - } - - parserInput.restore(); - }, - // A variable entity using the protective {} e.g. @{var} - variableCurly: function variableCurly() { - var curly; - var index = parserInput.i; - - if (parserInput.currentChar() === '@' && (curly = parserInput.$re(/^@\{([\w-]+)\}/))) { - return new tree.Variable("@".concat(curly[1]), index, fileInfo); - } - }, - // - // A Property accessor, such as `$color`, in - // - // background-color: $color - // - property: function property() { - var name; - var 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 propertyCurly() { - var curly; - var index = parserInput.i; - - if (parserInput.currentChar() === '$' && (curly = parserInput.$re(/^\$\{([\w-]+)\}/))) { - return new tree.Property("$".concat(curly[1]), index, fileInfo); - } - }, - // - // A Hexadecimal color - // - // #4F3C2F - // - // `rgb` and `hsl` colors are parsed through the `entities.call` parser. - // - color: function color() { - var rgb; - parserInput.save(); - - if (parserInput.currentChar() === '#' && (rgb = parserInput.$re(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3,4})([\w.#\[])?/))) { - if (!rgb[2]) { - parserInput.forget(); - return new tree.Color(rgb[1], undefined, rgb[0]); - } - } - - parserInput.restore(); - }, - colorKeyword: function colorKeyword() { - parserInput.save(); - var autoCommentAbsorb = parserInput.autoCommentAbsorb; - parserInput.autoCommentAbsorb = false; - var k = parserInput.$re(/^[_A-Za-z-][_A-Za-z0-9-]+/); - parserInput.autoCommentAbsorb = autoCommentAbsorb; - - if (!k) { - parserInput.forget(); - return; - } - - parserInput.restore(); - var color = tree.Color.fromKeyword(k); - - if (color) { - parserInput.$str(k); - return color; - } - }, - // - // A Dimension, that is, a number and a unit - // - // 0.5em 95% - // - dimension: function dimension() { - if (parserInput.peekNotNumeric()) { - return; - } - - var value = parserInput.$re(/^([+-]?\d*\.?\d+)(%|[a-z_]+)?/i); - - if (value) { - return new tree.Dimension(value[1], value[2]); - } - }, - // - // A unicode descriptor, as is used in unicode-range - // - // U+0?? or U+00A1-00A9 - // - unicodeDescriptor: function unicodeDescriptor() { - var ud; - ud = parserInput.$re(/^U\+[0-9a-fA-F?]+(\-[0-9a-fA-F?]+)?/); - - if (ud) { - return new tree.UnicodeDescriptor(ud[0]); - } - }, - // - // JavaScript code to be evaluated - // - // `window.location.href` - // - javascript: function javascript() { - var js; - var index = parserInput.i; - parserInput.save(); - var escape = parserInput.$char('~'); - var jsQuote = parserInput.$char('`'); - - if (!jsQuote) { - parserInput.restore(); - return; - } - - js = parserInput.$re(/^[^`]*`/); - - if (js) { - parserInput.forget(); - return new tree.JavaScript(js.substr(0, js.length - 1), Boolean(escape), index, fileInfo); - } - - parserInput.restore('invalid javascript definition'); - } - }, - // - // The variable part of a variable definition. Used in the `rule` parser - // - // @fink: - // - variable: function variable() { - var name; - - if (parserInput.currentChar() === '@' && (name = parserInput.$re(/^(@[\w-]+)\s*:/))) { - return name[1]; - } - }, - // - // Call a variable value to retrieve a detached ruleset - // or a value from a detached ruleset's rules. - // - // @fink(); - // @fink; - // color: @fink[@color]; - // - variableCall: function variableCall(parsedName) { - var lookups; - var important; - var i = parserInput.i; - var inValue = !!parsedName; - var name = parsedName; - parserInput.save(); - - if (name || parserInput.currentChar() === '@' && (name = parserInput.$re(/^(@[\w-]+)(\(\s*\))?/))) { - lookups = this.mixin.ruleLookups(); - - if (!lookups && (inValue && parserInput.$str('()') !== '()' || name[2] !== '()')) { - parserInput.restore('Missing \'[...]\' lookup in variable call'); - return; - } - - if (!inValue) { - name = name[1]; - } - - if (lookups && parsers.important()) { - important = true; - } - - var call = new tree.VariableCall(name, i, fileInfo); - - if (!inValue && parsers.end()) { - parserInput.forget(); - return call; - } else { - parserInput.forget(); - return new tree.NamespaceValue(call, lookups, important, i, fileInfo); - } - } - - parserInput.restore(); - }, - // - // extend syntax - used to extend selectors - // - extend: function extend(isRule) { - var elements; - var e; - var index = parserInput.i; - var option; - var extendList; - var extend; - - if (!parserInput.$str(isRule ? '&:extend(' : ':extend(')) { - return; - } - - do { - option = null; - elements = null; - - while (!(option = parserInput.$re(/^(all)(?=\s*(\)|,))/))) { - e = this.element(); - - if (!e) { - break; - } - - if (elements) { - elements.push(e); - } else { - elements = [e]; - } - } - - option = option && option[1]; - - if (!elements) { - error('Missing target selector for :extend().'); - } - - extend = new tree.Extend(new tree.Selector(elements), option, index, fileInfo); - - if (extendList) { - extendList.push(extend); - } else { - extendList = [extend]; - } - } while (parserInput.$char(',')); - - expect(/^\)/); - - if (isRule) { - expect(/^;/); - } - - return extendList; - }, - // - // extendRule - used in a rule to extend all the parent selectors - // - extendRule: function extendRule() { - return this.extend(true); - }, - // - // Mixins - // - mixin: { - // - // A Mixin call, with an optional argument list - // - // #mixins > .square(#fff); - // #mixins.square(#fff); - // .rounded(4px, black); - // .button; - // - // We can lookup / return a value using the lookup syntax: - // - // color: #mixin.square(#fff)[@color]; - // - // The `while` loop is there because mixins can be - // namespaced, but we only support the child and descendant - // selector for now. - // - call: function call(inValue, getLookup) { - var s = parserInput.currentChar(); - var important = false; - var lookups; - var index = parserInput.i; - var elements; - var args; - var hasParens; - - if (s !== '.' && s !== '#') { - return; - } - - parserInput.save(); // stop us absorbing part of an invalid selector - - elements = this.elements(); - - if (elements) { - if (parserInput.$char('(')) { - args = this.args(true).args; - expectChar(')'); - hasParens = true; - } - - if (getLookup !== false) { - lookups = this.ruleLookups(); - } - - if (getLookup === true && !lookups) { - parserInput.restore(); - return; - } - - if (inValue && !lookups && !hasParens) { - // This isn't a valid in-value mixin call - parserInput.restore(); - return; - } - - if (!inValue && parsers.important()) { - important = true; - } - - if (inValue || parsers.end()) { - parserInput.forget(); - var mixin = new tree.mixin.Call(elements, args, index, fileInfo, !lookups && important); - - if (lookups) { - return new tree.NamespaceValue(mixin, lookups, important); - } else { - return mixin; - } - } - } - - parserInput.restore(); - }, - - /** - * Matching elements for mixins - * (Start with . or # and can have > ) - */ - elements: function elements() { - var elements; - var e; - var c; - var elem; - var elemIndex; - var re = /^[#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/; - - while (true) { - elemIndex = parserInput.i; - e = parserInput.$re(re); - - if (!e) { - break; - } - - elem = new tree.Element(c, e, false, elemIndex, fileInfo); - - if (elements) { - elements.push(elem); - } else { - elements = [elem]; - } - - c = parserInput.$char('>'); - } - - return elements; - }, - args: function args(isCall) { - var entities = parsers.entities; - var returner = { - args: null, - variadic: false - }; - var expressions = []; - var argsSemiColon = []; - var argsComma = []; - var isSemiColonSeparated; - var expressionContainsNamed; - var name; - var nameLoop; - var value; - var arg; - var expand; - var hasSep = true; - parserInput.save(); - - while (true) { - if (isCall) { - arg = parsers.detachedRuleset() || parsers.expression(); - } else { - parserInput.commentStore.length = 0; - - if (parserInput.$str('...')) { - returner.variadic = true; - - if (parserInput.$char(';') && !isSemiColonSeparated) { - isSemiColonSeparated = true; - } - - (isSemiColonSeparated ? argsSemiColon : argsComma).push({ - variadic: true - }); - break; - } - - arg = entities.variable() || entities.property() || entities.literal() || entities.keyword() || this.call(true); - } - - if (!arg || !hasSep) { - break; - } - - nameLoop = null; - - if (arg.throwAwayComments) { - arg.throwAwayComments(); - } - - value = arg; - var val = null; - - if (isCall) { - // Variable - if (arg.value && arg.value.length == 1) { - val = arg.value[0]; - } - } else { - val = arg; - } - - if (val && (val instanceof tree.Variable || val instanceof tree.Property)) { - if (parserInput.$char(':')) { - if (expressions.length > 0) { - if (isSemiColonSeparated) { - error('Cannot mix ; and , as delimiter types'); + eval: function (context) { + var selectors; + var selCnt; + var selector; + var i; + var hasVariable; + var hasOnePassingSelector = false; + if (this.selectors && (selCnt = this.selectors.length)) { + 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 = this.selectors[i].eval(context); + for (var j = 0; j < selector.elements.length; j++) { + if (selector.elements[j].isVariable) { + hasVariable = true; + break; + } } - - expressionContainsNamed = true; - } - - value = parsers.detachedRuleset() || parsers.expression(); - - if (!value) { - if (isCall) { - error('could not understand value for named argument'); - } else { - parserInput.restore(); - returner.args = []; - return returner; + selectors[i] = selector; + if (selector.evaldCondition) { + hasOnePassingSelector = true; } - } - - nameLoop = name = val.name; - } else if (parserInput.$str('...')) { - if (!isCall) { - returner.variadic = true; - - if (parserInput.$char(';') && !isSemiColonSeparated) { - isSemiColonSeparated = true; + } + if (hasVariable) { + var toParseSelectors = new Array(selCnt); + for (i = 0; i < selCnt; i++) { + selector = selectors[i]; + toParseSelectors[i] = selector.toCSS(context); } - - (isSemiColonSeparated ? argsSemiColon : argsComma).push({ - name: arg.name, - variadic: true + this.parse.parseNode(toParseSelectors.join(','), ["selectors"], selectors[0].getIndex(), selectors[0].fileInfo(), function (err, result) { + if (result) { + selectors = flattenArray(result); + } }); - break; - } else { - expand = true; - } - } else if (!isCall) { - name = nameLoop = val.name; - value = null; } - } - - if (value) { - expressions.push(value); - } - - argsComma.push({ - name: nameLoop, - value: value, - expand: expand - }); - - if (parserInput.$char(',')) { - hasSep = true; - continue; - } - - hasSep = parserInput.$char(';') === ';'; - - if (hasSep || isSemiColonSeparated) { - if (expressionContainsNamed) { - error('Cannot mix ; and , as delimiter types'); - } - - isSemiColonSeparated = true; - - if (expressions.length > 1) { - value = new tree.Value(expressions); - } - - argsSemiColon.push({ - name: name, - value: value, - expand: expand - }); - name = null; - expressions = []; - expressionContainsNamed = false; - } + defaultFunc.reset(); } - - parserInput.forget(); - returner.args = isSemiColonSeparated ? argsSemiColon : argsComma; - return returner; - }, - // - // A Mixin definition, with a list of parameters - // - // .rounded (@radius: 2px, @color) { - // ... - // } - // - // Until we have a finer grained state-machine, we have to - // do a look-ahead, to make sure we don't have a mixin call. - // See the `rule` function for more information. - // - // We start by matching `.rounded (`, and then proceed on to - // the argument list, which has optional default values. - // We store the parameters in `params`, with a `value` key, - // if there is a value, such as in the case of `@radius`. - // - // Once we've got our params list, and a closing `)`, we parse - // the `{...}` block. - // - definition: function definition() { - var name; - var params = []; - var match; - var ruleset; - var cond; - var variadic = false; - - if (parserInput.currentChar() !== '.' && parserInput.currentChar() !== '#' || parserInput.peek(/^[^{]*\}/)) { - return; + else { + hasOnePassingSelector = true; } - - parserInput.save(); - match = parserInput.$re(/^([#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+)\s*\(/); - - if (match) { - name = match[1]; - var argInfo = this.args(false); - params = argInfo.args; - variadic = argInfo.variadic; // .mixincall("@{a}"); - // looks a bit like a mixin definition.. - // also - // .mixincall(@a: {rule: set;}); - // so we have to be nice and restore - - if (!parserInput.$char(')')) { - parserInput.restore('Missing closing \')\''); - return; - } - - parserInput.commentStore.length = 0; - - if (parserInput.$str('when')) { - // Guard - cond = expect(parsers.conditions, 'expected condition'); - } - - ruleset = parsers.block(); - - if (ruleset) { - parserInput.forget(); - return new tree.mixin.Definition(name, params, ruleset, cond, variadic); - } else { - parserInput.restore(); - } - } else { - parserInput.forget(); - } - }, - ruleLookups: function ruleLookups() { + var rules = this.rules ? copyArray(this.rules) : null; + var ruleset = new Ruleset(selectors, rules, this.strictImports, this.visibilityInfo()); var rule; - var lookups = []; - - if (parserInput.currentChar() !== '[') { - return; + var subRule; + ruleset.originalRuleset = this; + ruleset.root = this.root; + ruleset.firstRoot = this.firstRoot; + ruleset.allowImports = this.allowImports; + if (this.debugInfo) { + ruleset.debugInfo = this.debugInfo; } - - while (true) { - parserInput.save(); - rule = this.lookupValue(); - - if (!rule && rule !== '') { - parserInput.restore(); - break; - } - - lookups.push(rule); - parserInput.forget(); + if (!hasOnePassingSelector) { + rules.length = 0; } - - if (lookups.length > 0) { - return lookups; + // inherit a function registry from the frames stack when possible; + // otherwise from the global registry + ruleset.functionRegistry = (function (frames) { + var i = 0; + var n = frames.length; + var found; + for (; i !== n; ++i) { + found = frames[i].functionRegistry; + if (found) { + return found; + } + } + return functionRegistry; + }(context.frames)).inherit(); + // push the current ruleset to the frames stack + var ctxFrames = context.frames; + ctxFrames.unshift(ruleset); + // currrent selectors + var ctxSelectors = context.selectors; + if (!ctxSelectors) { + context.selectors = ctxSelectors = []; } - }, - lookupValue: function lookupValue() { - parserInput.save(); - - if (!parserInput.$char('[')) { - parserInput.restore(); - return; + ctxSelectors.unshift(this.selectors); + // Evaluate imports + if (ruleset.root || ruleset.allowImports || !ruleset.strictImports) { + ruleset.evalImports(context); } - - var name = parserInput.$re(/^(?:[@$]{0,2})[_a-zA-Z0-9-]*/); - - if (!parserInput.$char(']')) { - parserInput.restore(); - return; + // Store the frames around mixin definitions, + // so they can be evaluated like closures when the time comes. + var rsRules = ruleset.rules; + for (i = 0; (rule = rsRules[i]); i++) { + if (rule.evalFirst) { + rsRules[i] = rule.eval(context); + } } - - if (name || name === '') { - parserInput.forget(); - return name; + var mediaBlockCount = (context.mediaBlocks && context.mediaBlocks.length) || 0; + // Evaluate mixin calls. + 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 + return !(ruleset.variable(r.name)); + } + return true; + }); + rsRules.splice.apply(rsRules, [i, 1].concat(rules)); + i += rules.length - 1; + ruleset.resetCache(); + } + 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)); + i += rules.length - 1; + ruleset.resetCache(); + } } - - parserInput.restore(); - } - }, - // - // Entities are the smallest recognized token, - // and can be found inside a rule's value. - // - entity: function entity() { - var entities = this.entities; - return this.comment() || entities.literal() || entities.variable() || entities.url() || entities.property() || entities.call() || entities.keyword() || this.mixin.call(true) || entities.javascript(); - }, - // - // 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. - // - end: function end() { - return parserInput.$char(';') || parserInput.peek('}'); - }, - // - // IE's alpha function - // - // alpha(opacity=88) - // - ieAlpha: function ieAlpha() { - var value; // http://jsperf.com/case-insensitive-regex-vs-strtolower-then-regex/18 - - if (!parserInput.$re(/^opacity=/i)) { - return; - } - - value = parserInput.$re(/^\d+/); - - if (!value) { - value = expect(parsers.entities.variable, 'Could not parse alpha'); - value = "@{".concat(value.name.slice(1), "}"); - } - - expectChar(')'); - return new tree.Quoted('', "alpha(opacity=".concat(value, ")")); - }, - // - // A Selector Element - // - // div - // + h1 - // #socks - // input[type="text"] - // - // Elements are the building blocks for Selectors, - // they are made out of a `Combinator` (see combinator rule), - // and an element name, such as a tag a class, or `*`. - // - element: function element() { - var e; - var c; - var v; - var index = parserInput.i; - c = this.combinator(); - e = parserInput.$re(/^(?:\d+\.\d+|\d+)%/) || parserInput.$re(/^(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/) || parserInput.$char('*') || parserInput.$char('&') || this.attribute() || parserInput.$re(/^\([^&()@]+\)/) || parserInput.$re(/^[\.#:](?=@)/) || this.entities.variableCurly(); - - if (!e) { - parserInput.save(); - - if (parserInput.$char('(')) { - if ((v = this.selector(false)) && parserInput.$char(')')) { - e = new tree.Paren(v); - parserInput.forget(); - } else { - parserInput.restore('Missing closing \')\''); - } - } else { - parserInput.forget(); + // Evaluate everything else + for (i = 0; (rule = rsRules[i]); i++) { + if (!rule.evalFirst) { + rsRules[i] = rule = rule.eval ? rule.eval(context) : rule; + } } - } - - if (e) { - return new tree.Element(c, e, e instanceof tree.Variable, index, fileInfo); - } - }, - // - // Combinators combine elements together, in a Selector. - // - // Because our parser isn't white-space sensitive, special care - // has to be taken, when parsing the descendant combinator, ` `, - // as it's an empty space. We have to check the previous character - // in the input, to see if it's a ` ` character. More info on how - // we deal with this in *combinator.js*. - // - combinator: function combinator() { - var c = parserInput.currentChar(); - - if (c === '/') { - parserInput.save(); - var slashedCombinator = parserInput.$re(/^\/[a-z]+\//i); - - if (slashedCombinator) { - parserInput.forget(); - return new tree.Combinator(slashedCombinator); + // Evaluate everything else + 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] && rule.selectors[0].isJustParentSelector()) { + rsRules.splice(i--, 1); + 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); + } + } + } + } + } } - - parserInput.restore(); - } - - if (c === '>' || c === '+' || c === '~' || c === '|' || c === '^') { - parserInput.i++; - - if (c === '^' && parserInput.currentChar() === '^') { - c = '^^'; - parserInput.i++; + // Pop the stack + ctxFrames.shift(); + ctxSelectors.shift(); + if (context.mediaBlocks) { + for (i = mediaBlockCount; i < context.mediaBlocks.length; i++) { + context.mediaBlocks[i].bubbleSelectors(selectors); + } } - - while (parserInput.isWhitespace()) { - parserInput.i++; - } - - return new tree.Combinator(c); - } else if (parserInput.isWhitespace(-1)) { - return new tree.Combinator(' '); - } else { - return new tree.Combinator(null); - } - }, - // - // A CSS Selector - // with less extensions e.g. the ability to extend and guard - // - // .class > div + h1 - // li a:hover - // - // Selectors are made out of one or more Elements, see above. - // - selector: function selector(isLess) { - var index = parserInput.i; - var elements; - var extendList; - var c; - var e; - var allExtends; - var when; - var 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'); - } else if (condition) { - error('CSS guard can only be used at the end of selector'); - } else if (extendList) { - if (allExtends) { - allExtends = allExtends.concat(extendList); - } else { - allExtends = extendList; - } - } else { - if (allExtends) { - error('Extend can only be used at the end of selector'); - } - - c = parserInput.currentChar(); - - if (elements) { - elements.push(e); - } else { - elements = [e]; - } - - e = null; - } - - if (c === '{' || c === '}' || c === ';' || c === ',' || c === ')') { - break; - } - } - - if (elements) { - return new tree.Selector(elements, allExtends, condition, index, fileInfo); - } - - if (allExtends) { - error('Extend must be used to extend a selector, it cannot be used on its own'); - } - }, - selectors: function selectors() { - var s; - var selectors; - - while (true) { - s = this.selector(); - - if (!s) { - break; - } - - if (selectors) { - selectors.push(s); - } else { - selectors = [s]; - } - - parserInput.commentStore.length = 0; - - if (s.condition && selectors.length > 1) { - error("Guards are only currently allowed on a single selector."); - } - - if (!parserInput.$char(',')) { - break; - } - - if (s.condition) { - error("Guards are only currently allowed on a single selector."); - } - - parserInput.commentStore.length = 0; - } - - return selectors; - }, - attribute: function attribute() { - if (!parserInput.$char('[')) { - return; - } - - var entities = this.entities; - var key; - var val; - var op; - - if (!(key = entities.variableCurly())) { - key = expect(/^(?:[_A-Za-z0-9-\*]*\|)?(?:[_A-Za-z0-9-]|\\.)+/); - } - - op = parserInput.$re(/^[|~*$^]?=/); - - if (op) { - val = entities.quoted() || parserInput.$re(/^[0-9]+%/) || parserInput.$re(/^[\w-]+/) || entities.variableCurly(); - } - - expectChar(']'); - return new tree.Attribute(key, op, val); - }, - // - // The `block` rule is used by `ruleset` and `mixin.definition`. - // It's a wrapper around the `primary` rule, with added `{}`. - // - block: function block() { - var content; - - if (parserInput.$char('{') && (content = this.primary()) && parserInput.$char('}')) { - return content; - } - }, - blockRuleset: function blockRuleset() { - var block = this.block(); - - if (block) { - block = new tree.Ruleset(null, block); - } - - return block; - }, - detachedRuleset: function detachedRuleset() { - var argInfo; - var params; - var variadic; - parserInput.save(); - - if (parserInput.$re(/^[.#]\(/)) { - /** - * DR args currently only implemented for each() function, and not - * yet settable as `@dr: #(@arg) {}` - * This should be done when DRs are merged with mixins. - * See: https://github.com/less/less-meta/issues/16 - */ - argInfo = this.mixin.args(false); - params = argInfo.args; - variadic = argInfo.variadic; - - if (!parserInput.$char(')')) { - parserInput.restore(); - return; - } - } - - var blockRuleset = this.blockRuleset(); - - if (blockRuleset) { - parserInput.forget(); - - if (params) { - return new tree.mixin.Definition(null, params, blockRuleset, null, variadic); - } - - return new tree.DetachedRuleset(blockRuleset); - } - - parserInput.restore(); - }, - // - // div, .class, body > p {...} - // - ruleset: function ruleset() { - var selectors; - var rules; - var debugInfo; - parserInput.save(); - - if (context.dumpLineNumbers) { - debugInfo = getDebugInfo(parserInput.i); - } - - selectors = this.selectors(); - - if (selectors && (rules = this.block())) { - parserInput.forget(); - var ruleset = new tree.Ruleset(selectors, rules, context.strictImports); - - if (context.dumpLineNumbers) { - ruleset.debugInfo = debugInfo; - } - return ruleset; - } else { - parserInput.restore(); - } }, - declaration: function declaration() { - var name; - var value; - var index = parserInput.i; - var hasDR; - var c = parserInput.currentChar(); - var important; - var merge; - var isVariable; - - if (c === '.' || c === '#' || c === '&' || c === ':') { - return; - } - - parserInput.save(); - name = this.variable() || this.ruleProperty(); - - if (name) { - isVariable = typeof name === 'string'; - - if (isVariable) { - value = this.detachedRuleset(); - - if (value) { - hasDR = true; - } - } - - parserInput.commentStore.length = 0; - - if (!value) { - // a name returned by this.ruleProperty() is always an array of the form: - // [string-1, ..., string-n, ""] or [string-1, ..., string-n, "+"] - // where each item is a tree.Keyword or tree.Variable - merge = !isVariable && name.length > 1 && name.pop().value; // Custom property values get permissive parsing - - if (name[0].value && name[0].value.slice(0, 2) === '--') { - value = this.permissiveValue(); - } // Try to store values as anonymous - // If we need the value later we'll re-parse it in ruleset.parseValue - else { - 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, index, fileInfo); - } - - if (!value) { - value = this.value(); - } - - if (value) { - important = this.important(); - } else if (isVariable) { - // As a last resort, try permissiveValue - value = this.permissiveValue(); - } - } - - if (value && (this.end() || hasDR)) { - parserInput.forget(); - return new tree.Declaration(name, value, important, merge, index, fileInfo); - } else { - parserInput.restore(); - } - } else { - parserInput.restore(); - } - }, - anonymousValue: function anonymousValue() { - var index = parserInput.i; - var match = parserInput.$re(/^([^.#@\$+\/'"*`(;{}-]*);/); - - if (match) { - return new tree.Anonymous(match[1], index); - } - }, - - /** - * Used for custom properties, at-rules, and variables (as fallback) - * Parses almost anything inside of {} [] () "" blocks - * until it reaches outer-most tokens. - * - * First, it will try to parse comments and entities to reach - * the end. This is mostly like the Expression parser except no - * math is allowed. - */ - permissiveValue: function permissiveValue(untilTokens) { - var i; - var e; - var done; - var value; - var tok = untilTokens || ';'; - var index = parserInput.i; - var result = []; - - function testCurrentChar() { - var char = parserInput.currentChar(); - - if (typeof tok === 'string') { - return char === tok; - } else { - return tok.test(char); - } - } - - if (testCurrentChar()) { - return; - } - - value = []; - - do { - e = this.comment(); - - if (e) { - value.push(e); - continue; - } - - e = this.entity(); - - if (e) { - value.push(e); - } - } while (e); - - done = testCurrentChar(); - - if (value.length > 0) { - value = new tree.Expression(value); - - if (done) { - return value; - } else { - result.push(value); - } // Preserve space before $parseUntil as it will not - - - if (parserInput.prevChar() === ' ') { - result.push(new tree.Anonymous(' ', index)); - } - } - - parserInput.save(); - value = parserInput.$parseUntil(tok); - - if (value) { - if (typeof value === 'string') { - error("Expected '".concat(value, "'"), 'Parse'); - } - - if (value.length === 1 && value[0] === ' ') { - parserInput.forget(); - return new tree.Anonymous('', index); - } - - var item; - - for (i = 0; i < value.length; i++) { - item = value[i]; - - if (Array.isArray(item)) { - // Treat actual quotes as normal quoted values - result.push(new tree.Quoted(item[0], item[1], true, index, fileInfo)); - } else { - if (i === value.length - 1) { - item = item.trim(); - } // Treat like quoted values, but replace vars like unquoted expressions - - - var quote = new tree.Quoted('\'', item, true, index, fileInfo); - quote.variableRegex = /@([\w-]+)/g; - quote.propRegex = /\$([\w-]+)/g; - result.push(quote); - } - } - - parserInput.forget(); - return new tree.Expression(result, true); - } - - parserInput.restore(); - }, - // - // An @import atrule - // - // @import "lib"; - // - // 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. - // - 'import': function _import() { - var path; - var features; - var index = parserInput.i; - var dir = parserInput.$re(/^@import?\s+/); - - if (dir) { - var options = (dir ? this.importOptions() : null) || {}; - - if (path = this.entities.quoted() || this.entities.url()) { - features = this.mediaFeatures(); - - if (!parserInput.$char(';')) { - parserInput.i = index; - error('missing semi-colon or unrecognised media features on import'); - } - - features = features && new tree.Value(features); - return new tree.Import(path, features, options, index, fileInfo); - } else { - parserInput.i = index; - error('malformed import statement'); - } - } - }, - importOptions: function importOptions() { - var o; - var options = {}; - var optionName; - var value; // list of options, surrounded by parens - - if (!parserInput.$char('(')) { - return null; - } - - do { - o = this.importOption(); - - if (o) { - optionName = o; - value = true; - - switch (optionName) { - case 'css': - optionName = 'less'; - value = false; - break; - - case 'once': - optionName = 'multiple'; - value = false; - break; - } - - options[optionName] = value; - - if (!parserInput.$char(',')) { - break; - } - } - } while (o); - - expectChar(')'); - return options; - }, - importOption: function importOption() { - var opt = parserInput.$re(/^(less|css|multiple|once|inline|reference|optional)/); - - if (opt) { - return opt[1]; - } - }, - mediaFeature: function mediaFeature() { - var entities = this.entities; - var nodes = []; - var e; - var p; - parserInput.save(); - - do { - e = entities.keyword() || entities.variable() || entities.mixinLookup(); - - if (e) { - nodes.push(e); - } else if (parserInput.$char('(')) { - p = this.property(); - e = this.value(); - - if (parserInput.$char(')')) { - if (p && e) { - 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 { - error('badly formed media feature definition'); - } - } else { - error('Missing closing \')\'', 'Parse'); - } - } - } while (e); - - parserInput.forget(); - - if (nodes.length > 0) { - return new tree.Expression(nodes); - } - }, - mediaFeatures: function mediaFeatures() { - var entities = this.entities; - var features = []; - var e; - - do { - e = this.mediaFeature(); - - if (e) { - features.push(e); - - if (!parserInput.$char(',')) { - break; - } - } else { - e = entities.variable() || entities.mixinLookup(); - - if (e) { - features.push(e); - - if (!parserInput.$char(',')) { - break; - } - } - } - } while (e); - - return features.length > 0 ? features : null; - }, - media: function media() { - var features; - var rules; - var media; - var debugInfo; - var index = parserInput.i; - - if (context.dumpLineNumbers) { - debugInfo = getDebugInfo(index); - } - - parserInput.save(); - - if (parserInput.$str('@media')) { - features = this.mediaFeatures(); - rules = this.block(); - + evalImports: function (context) { + var rules = this.rules; + var i; + var importRules; if (!rules) { - error('media definitions require block statements after any features'); + return; } - - parserInput.forget(); - media = new tree.Media(rules, features, index, fileInfo); - - if (context.dumpLineNumbers) { - media.debugInfo = debugInfo; + for (i = 0; i < rules.length; i++) { + if (rules[i].type === 'Import') { + importRules = rules[i].eval(context); + if (importRules && (importRules.length || importRules.length === 0)) { + rules.splice.apply(rules, [i, 1].concat(importRules)); + i += importRules.length - 1; + } + else { + rules.splice(i, 1, importRules); + } + this.resetCache(); + } } - - return media; - } - - parserInput.restore(); }, - // - // A @plugin directive, used to import plugins dynamically. - // - // @plugin (args) "lib"; - // - plugin: function plugin() { - var path; - var args; - var options; - var index = parserInput.i; - var dir = parserInput.$re(/^@plugin?\s+/); - - if (dir) { - 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'); - } - - return new tree.Import(path, null, options, index, fileInfo); - } else { - parserInput.i = index; - error('malformed @plugin statement'); - } - } - }, - pluginArgs: function pluginArgs() { - // 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 AtRule - // - // @charset "utf-8"; - // - atrule: function atrule() { - var index = parserInput.i; - var name; - var value; - var rules; - var nonVendorSpecificName; - var hasIdentifier; - var hasExpression; - var hasUnknown; - var hasBlock = true; - var isRooted = true; - - if (parserInput.currentChar() !== '@') { - return; - } - - value = this['import']() || this.plugin() || this.media(); - - if (value) { - return value; - } - - parserInput.save(); - name = parserInput.$re(/^@[a-z-]+/); - - if (!name) { - return; - } - - nonVendorSpecificName = name; - - if (name.charAt(1) == '-' && name.indexOf('-', 2) > 0) { - nonVendorSpecificName = "@".concat(name.slice(name.indexOf('-', 2) + 1)); - } - - switch (nonVendorSpecificName) { - case '@charset': - hasIdentifier = true; - hasBlock = false; - break; - - case '@namespace': - hasExpression = true; - hasBlock = false; - break; - - case '@keyframes': - case '@counter-style': - hasIdentifier = true; - break; - - case '@document': - case '@supports': - hasUnknown = true; - isRooted = false; - break; - - default: - hasUnknown = true; - break; - } - - parserInput.commentStore.length = 0; - - if (hasIdentifier) { - value = this.entity(); - - if (!value) { - error("expected ".concat(name, " identifier")); - } - } else if (hasExpression) { - value = this.expression(); - - if (!value) { - error("expected ".concat(name, " expression")); - } - } else if (hasUnknown) { - value = this.permissiveValue(/^[{;]/); - hasBlock = parserInput.currentChar() === '{'; - - if (!value) { - if (!hasBlock && parserInput.currentChar() !== ';') { - error("".concat(name, " rule is missing block or ending semi-colon")); - } - } else if (!value.value) { - value = null; - } - } - - if (hasBlock) { - rules = this.blockRuleset(); - } - - if (rules || !hasBlock && value && parserInput.$char(';')) { - parserInput.forget(); - return new tree.AtRule(name, value, rules, index, fileInfo, context.dumpLineNumbers ? getDebugInfo(index) : null, isRooted); - } - - parserInput.restore('at-rule options not recognised'); - }, - // - // A Value is a comma-delimited list of Expressions - // - // font-family: Baskerville, Georgia, serif; - // - // In a Rule, a Value represents everything after the `:`, - // and before the `;`. - // - value: function value() { - var e; - var expressions = []; - var index = parserInput.i; - - do { - e = this.expression(); - - if (e) { - expressions.push(e); - - if (!parserInput.$char(',')) { - break; - } - } - } while (e); - - if (expressions.length > 0) { - return new tree.Value(expressions, index); - } - }, - important: function important() { - if (parserInput.currentChar() === '!') { - return parserInput.$re(/^! *important/); - } - }, - sub: function sub() { - var a; - var e; - parserInput.save(); - - if (parserInput.$char('(')) { - a = this.addition(); - - if (a && parserInput.$char(')')) { - parserInput.forget(); - e = new tree.Expression([a]); - e.parens = true; - return e; - } - - parserInput.restore('Expected \')\''); - return; - } - - parserInput.restore(); - }, - multiplication: function multiplication() { - var m; - var a; - var op; - var operation; - var isSpaced; - m = this.operand(); - - if (m) { - isSpaced = parserInput.isWhitespace(-1); - - while (true) { - if (parserInput.peek(/^\/[*\/]/)) { - break; - } - - parserInput.save(); - op = parserInput.$char('/') || parserInput.$char('*') || parserInput.$str('./'); - - if (!op) { - parserInput.forget(); - break; - } - - a = this.operand(); - - if (!a) { - parserInput.restore(); - break; - } - - parserInput.forget(); - m.parensInOp = true; - a.parensInOp = true; - operation = new tree.Operation(op, [operation || m, a], isSpaced); - isSpaced = parserInput.isWhitespace(-1); - } - - return operation || m; - } - }, - addition: function addition() { - var m; - var a; - var op; - var operation; - var isSpaced; - m = this.multiplication(); - - if (m) { - isSpaced = parserInput.isWhitespace(-1); - - while (true) { - op = parserInput.$re(/^[-+]\s+/) || !isSpaced && (parserInput.$char('+') || parserInput.$char('-')); - - if (!op) { - break; - } - - a = this.multiplication(); - - if (!a) { - break; - } - - m.parensInOp = true; - a.parensInOp = true; - operation = new tree.Operation(op, [operation || m, a], isSpaced); - isSpaced = parserInput.isWhitespace(-1); - } - - return operation || m; - } - }, - conditions: function conditions() { - var a; - var b; - var index = parserInput.i; - var condition; - a = this.condition(true); - - if (a) { - while (true) { - if (!parserInput.peek(/^,\s*(not\s*)?\(/) || !parserInput.$char(',')) { - break; - } - - b = this.condition(true); - - if (!b) { - break; - } - - condition = new tree.Condition('or', condition || a, b, index); - } - - return condition || a; - } - }, - condition: function condition(needsParens) { - var result; - var logical; - var next; - - function or() { - return parserInput.$str('or'); - } - - result = this.conditionAnd(needsParens); - - if (!result) { - return; - } - - logical = or(); - - if (logical) { - next = this.condition(needsParens); - - if (next) { - result = new tree.Condition(logical, result, next); - } else { - return; - } - } - - return result; - }, - conditionAnd: function conditionAnd(needsParens) { - var result; - var logical; - var next; - var self = this; - - function insideCondition() { - var cond = self.negatedCondition(needsParens) || self.parenthesisCondition(needsParens); - - if (!cond && !needsParens) { - return self.atomicCondition(needsParens); - } - - return cond; - } - - function and() { - return parserInput.$str('and'); - } - - result = insideCondition(); - - if (!result) { - return; - } - - logical = and(); - - if (logical) { - next = this.conditionAnd(needsParens); - - if (next) { - result = new tree.Condition(logical, result, next); - } else { - return; - } - } - - return result; - }, - negatedCondition: function negatedCondition(needsParens) { - if (parserInput.$str('not')) { - var result = this.parenthesisCondition(needsParens); - - if (result) { - result.negate = !result.negate; - } - + makeImportant: function () { + var result = new Ruleset(this.selectors, this.rules.map(function (r) { + if (r.makeImportant) { + return r.makeImportant(); + } + else { + return r; + } + }), this.strictImports, this.visibilityInfo()); return result; - } }, - parenthesisCondition: function parenthesisCondition(needsParens) { - function tryConditionFollowedByParenthesis(me) { - var body; - parserInput.save(); - body = me.condition(needsParens); - - if (!body) { - parserInput.restore(); - return; - } - - if (!parserInput.$char(')')) { - parserInput.restore(); - return; - } - - parserInput.forget(); - return body; - } - - var body; - parserInput.save(); - - if (!parserInput.$str('(')) { - parserInput.restore(); - return; - } - - body = tryConditionFollowedByParenthesis(this); - - if (body) { - parserInput.forget(); - return body; - } - - body = this.atomicCondition(needsParens); - - if (!body) { - parserInput.restore(); - return; - } - - if (!parserInput.$char(')')) { - parserInput.restore("expected ')' got '".concat(parserInput.currentChar(), "'")); - return; - } - - parserInput.forget(); - return body; + matchArgs: function (args) { + return !args || args.length === 0; }, - atomicCondition: function atomicCondition(needsParens) { - var entities = this.entities; - var index = parserInput.i; - var a; - var b; - var c; - var op; - - function cond() { - return this.addition() || entities.keyword() || entities.quoted() || entities.mixinLookup(); - } - - cond = cond.bind(this); - a = cond(); - - if (a) { - if (parserInput.$char('>')) { - if (parserInput.$char('=')) { - op = '>='; - } else { - op = '>'; - } - } else if (parserInput.$char('<')) { - if (parserInput.$char('=')) { - op = '<='; - } else { - op = '<'; - } - } else if (parserInput.$char('=')) { - if (parserInput.$char('>')) { - op = '=>'; - } else if (parserInput.$char('<')) { - op = '=<'; - } else { - op = '='; - } + // lets you call a css selector with a guard + matchCondition: function (args, context) { + var lastSelector = this.selectors[this.selectors.length - 1]; + if (!lastSelector.evaldCondition) { + return false; } - - if (op) { - b = cond(); - - if (b) { - c = new tree.Condition(op, a, b, index, false); - } else { - error('expected expression'); - } - } else { - c = new tree.Condition('=', a, new tree.Keyword('true'), index, false); + if (lastSelector.condition && + !lastSelector.condition.eval(new contexts.Eval(context, context.frames))) { + return false; } - - return c; - } + return true; }, - // - // An operand is anything that can be part of an operation, - // such as a Color, or a Variable - // - operand: function operand() { - var entities = this.entities; - var negate; - - if (parserInput.peek(/^-[@\$\(]/)) { - negate = parserInput.$char('-'); - } - - var o = this.sub() || entities.dimension() || entities.color() || entities.variable() || entities.property() || entities.call() || entities.quoted(true) || entities.colorKeyword() || entities.mixinLookup(); - - if (negate) { - o.parensInOp = true; - o = new tree.Negative(o); - } - - return o; + resetCache: function () { + this._rulesets = null; + this._variables = null; + this._properties = null; + this._lookups = {}; }, - // - // Expressions either represent mathematical operations, - // or white-space delimited Entities. - // - // 1px solid black - // @var * 2 - // - expression: function expression() { - var entities = []; - var e; - var delim; - var index = parserInput.i; - - do { - e = this.comment(); - - if (e) { - entities.push(e); - continue; + variables: function () { + if (!this._variables) { + this._variables = !this.rules ? {} : this.rules.reduce(function (hash, r) { + if (r instanceof Declaration && r.variable === true) { + hash[r.name] = r; + } + // when evaluating variables in an import statement, imports have not been eval'd + // so we need to go inside import statements. + // guard against root being a string (in the case of inlined less) + if (r.type === 'Import' && r.root && r.root.variables) { + var vars = r.root.variables(); + for (var name_1 in vars) { + if (vars.hasOwnProperty(name_1)) { + hash[name_1] = r.root.variable(name_1); + } + } + } + return hash; + }, {}); } - - e = this.addition() || this.entity(); - - if (e) { - entities.push(e); // operations do not allow keyword "/" dimension (e.g. small/20px) so we support that here - - if (!parserInput.peek(/^\/[\/*]/)) { - delim = parserInput.$char('/'); - - if (delim) { - entities.push(new tree.Anonymous(delim, index)); + return this._variables; + }, + properties: function () { + if (!this._properties) { + this._properties = !this.rules ? {} : this.rules.reduce(function (hash, r) { + if (r instanceof Declaration && r.variable !== true) { + var name_2 = (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_2]) { + hash["$" + name_2] = [r]; + } + else { + hash["$" + name_2].push(r); + } + } + return hash; + }, {}); + } + return this._properties; + }, + variable: function (name) { + var decl = this.variables()[name]; + if (decl) { + return this.parseValue(decl); + } + }, + property: function (name) { + var decl = this.properties()[name]; + if (decl) { + return this.parseValue(decl); + } + }, + lastDeclaration: function () { + for (var i = this.rules.length; i > 0; i--) { + var decl = this.rules[i - 1]; + if (decl instanceof Declaration) { + return this.parseValue(decl); } - } } - } while (e); - - if (entities.length > 0) { - return new tree.Expression(entities); - } }, - property: function property() { - var name = parserInput.$re(/^(\*?-?[_a-zA-Z0-9-]+)\s*:/); - - if (name) { - return name[1]; - } + parseValue: function (toParse) { + var self = this; + function transformDeclaration(decl) { + if (decl.value instanceof Anonymous && !decl.parsed) { + if (typeof decl.value.value === 'string') { + 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; + } + }); + } + else { + decl.parsed = true; + } + return decl; + } + else { + return decl; + } + } + if (!Array.isArray(toParse)) { + return transformDeclaration.call(self, toParse); + } + else { + var nodes_1 = []; + toParse.forEach(function (n) { + nodes_1.push(transformDeclaration.call(self, n)); + }); + return nodes_1; + } }, - ruleProperty: function ruleProperty() { - var name = []; - var index = []; - var s; - var k; - parserInput.save(); - var simpleProperty = parserInput.$re(/^([_a-zA-Z0-9-]+)\s*:/); - - if (simpleProperty) { - name = [new tree.Keyword(simpleProperty[1])]; - parserInput.forget(); - return name; - } - - function match(re) { - var i = parserInput.i; - var chunk = parserInput.$re(re); - - if (chunk) { - index.push(i); - return name.push(chunk[1]); + rulesets: function () { + if (!this.rules) { + return []; } - } - - match(/^(\*?)/); - - while (true) { - if (!match(/^((?:[\w-]+)|(?:[@\$]\{[\w-]+\}))/)) { - break; + var filtRules = []; + var rules = this.rules; + var i; + var rule; + for (i = 0; (rule = rules[i]); i++) { + if (rule.isRuleset) { + filtRules.push(rule); + } } - } - - if (name.length > 1 && match(/^((?:\+_|\+)?)\s*:/)) { - parserInput.forget(); // at last, we have the complete match now. move forward, - // convert name particles to tree objects and return: - - if (name[0] === '') { - name.shift(); - index.shift(); + return filtRules; + }, + prependRule: function (rule) { + var rules = this.rules; + if (rules) { + rules.unshift(rule); } - - for (k = 0; k < name.length; k++) { - s = name[k]; - name[k] = s.charAt(0) !== '@' && s.charAt(0) !== '$' ? new tree.Keyword(s) : s.charAt(0) === '@' ? new tree.Variable("@".concat(s.slice(2, -1)), index[k], fileInfo) : new tree.Property("$".concat(s.slice(2, -1)), index[k], fileInfo); + else { + this.rules = [rule]; + } + this.setParent(rule, this); + }, + find: function (selector, self, filter) { + self = self || this; + var rules = []; + var match; + var foundMixins; + var key = selector.toCSS(); + if (key in this._lookups) { + return this._lookups[key]; + } + this.rulesets().forEach(function (rule) { + if (rule !== self) { + for (var j = 0; j < rule.selectors.length; j++) { + match = selector.match(rule.selectors[j]); + if (match) { + if (selector.elements.length > match) { + if (!filter || filter(rule)) { + foundMixins = rule.find(new Selector(selector.elements.slice(match)), self, filter); + for (var i = 0; i < foundMixins.length; ++i) { + foundMixins[i].path.push(rule); + } + Array.prototype.push.apply(rules, foundMixins); + } + } + else { + rules.push({ rule: rule, path: [] }); + } + break; + } + } + } + }); + this._lookups[key] = rules; + return rules; + }, + genCSS: function (context, output) { + var i; + var j; + var charsetRuleNodes = []; + var ruleNodes = []; + var // Line number debugging + debugInfo$1; + var rule; + var path; + context.tabLevel = (context.tabLevel || 0); + if (!this.root) { + context.tabLevel++; + } + var tabRuleStr = context.compress ? '' : Array(context.tabLevel + 1).join(' '); + var tabSetStr = context.compress ? '' : Array(context.tabLevel).join(' '); + var sep; + var charsetNodeIndex = 0; + var importNodeIndex = 0; + for (i = 0; (rule = this.rules[i]); i++) { + if (rule instanceof Comment) { + if (importNodeIndex === i) { + importNodeIndex++; + } + ruleNodes.push(rule); + } + else if (rule.isCharset && rule.isCharset()) { + ruleNodes.splice(charsetNodeIndex, 0, rule); + charsetNodeIndex++; + importNodeIndex++; + } + else if (rule.type === 'Import') { + ruleNodes.splice(importNodeIndex, 0, rule); + importNodeIndex++; + } + else { + ruleNodes.push(rule); + } + } + ruleNodes = charsetRuleNodes.concat(ruleNodes); + // If this is the root node, we don't render + // a selector, or {}. + if (!this.root) { + debugInfo$1 = debugInfo(context, this, tabSetStr); + if (debugInfo$1) { + output.add(debugInfo$1); + output.add(tabSetStr); + } + var paths = this.paths; + var pathCnt = paths.length; + var pathSubCnt = void 0; + sep = context.compress ? ',' : (",\n" + tabSetStr); + for (i = 0; i < pathCnt; i++) { + path = paths[i]; + if (!(pathSubCnt = path.length)) { + continue; + } + if (i > 0) { + output.add(sep); + } + context.firstSelector = true; + path[0].genCSS(context, output); + context.firstSelector = false; + for (j = 1; j < pathSubCnt; j++) { + path[j].genCSS(context, output); + } + } + output.add((context.compress ? '{' : ' {\n') + tabRuleStr); + } + // Compile rules and rulesets + for (i = 0; (rule = ruleNodes[i]); i++) { + if (i + 1 === ruleNodes.length) { + context.lastRule = true; + } + var currentLastRule = context.lastRule; + if (rule.isRulesetLike(rule)) { + context.lastRule = false; + } + if (rule.genCSS) { + rule.genCSS(context, output); + } + else if (rule.value) { + output.add(rule.value.toString()); + } + context.lastRule = currentLastRule; + if (!context.lastRule && rule.isVisible()) { + output.add(context.compress ? '' : ("\n" + tabRuleStr)); + } + else { + context.lastRule = false; + } + } + if (!this.root) { + output.add((context.compress ? '}' : "\n" + tabSetStr + "}")); + context.tabLevel--; + } + if (!output.isEmpty() && !context.compress && this.firstRoot) { + output.add('\n'); + } + }, + joinSelectors: function (paths, context, selectors) { + for (var s = 0; s < selectors.length; s++) { + this.joinSelector(paths, context, selectors[s]); + } + }, + joinSelector: function (paths, context, selector) { + function createParenthesis(elementsToPak, originalElement) { + var replacementParen, j; + if (elementsToPak.length === 0) { + replacementParen = new Paren(elementsToPak[0]); + } + else { + var insideParent = new Array(elementsToPak.length); + for (j = 0; j < elementsToPak.length; j++) { + insideParent[j] = new Element(null, elementsToPak[j], originalElement.isVariable, originalElement._index, originalElement._fileInfo); + } + replacementParen = new Paren(new Selector(insideParent)); + } + return replacementParen; + } + function createSelector(containedElement, originalElement) { + var element, selector; + element = new Element(null, containedElement, originalElement.isVariable, originalElement._index, originalElement._fileInfo); + selector = new Selector([element]); + return selector; + } + // joins selector path from `beginningPath` with selector path in `addPath` + // `replacedElement` contains element that is being replaced by `addPath` + // returns concatenated path + function addReplacementIntoPath(beginningPath, addPath, replacedElement, originalSelector) { + var newSelectorPath, lastSelector, newJoinedSelector; + // our new selector path + newSelectorPath = []; + // 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 = copyArray(beginningPath); + lastSelector = newSelectorPath.pop(); + newJoinedSelector = originalSelector.createDerived(copyArray(lastSelector.elements)); + } + else { + newJoinedSelector = originalSelector.createDerived([]); + } + if (addPath.length > 0) { + // /deep/ is a CSS4 selector - (removed, so should deprecate) + // that is valid without anything in front of it + // so if the & does not have a combinator that is "" or " " then + // and there is a combinator on the parent, then grab that. + // this also allows + a { & .b { .a & { ... though not sure why you would want to do that + var combinator = replacedElement.combinator; + var parentEl = addPath[0].elements[0]; + if (combinator.emptyOrWhitespace && !parentEl.combinator.emptyOrWhitespace) { + combinator = parentEl.combinator; + } + // join the elements so far with the first part of the parent + newJoinedSelector.elements.push(new Element(combinator, parentEl.value, replacedElement.isVariable, replacedElement._index, replacedElement._fileInfo)); + newJoinedSelector.elements = newJoinedSelector.elements.concat(addPath[0].elements.slice(1)); + } + // now add the joined selector - but only if it is not empty + if (newJoinedSelector.elements.length !== 0) { + newSelectorPath.push(newJoinedSelector); + } + // 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) { + return selector.createDerived(selector.elements, []); + }); + newSelectorPath = newSelectorPath.concat(restOfPath); + } + return newSelectorPath; + } + // joins selector path from `beginningPath` with every selector path in `addPaths` array + // `replacedElement` contains element that is being replaced by `addPath` + // returns array with all concatenated paths + function addAllReplacementsIntoPath(beginningPath, addPaths, replacedElement, originalSelector, result) { + var j; + for (j = 0; j < beginningPath.length; j++) { + var newSelectorPath = addReplacementIntoPath(beginningPath[j], addPaths, replacedElement, originalSelector); + result.push(newSelectorPath); + } + return result; + } + function mergeElementsOnToSelectors(elements, selectors) { + var i, sel; + if (elements.length === 0) { + return; + } + if (selectors.length === 0) { + selectors.push([new Selector(elements)]); + return; + } + 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)); + } + else { + sel.push(new Selector(elements)); + } + } + } + // replace all parent selectors inside `inSelector` by content of `context` array + // resulting selectors are returned inside `paths` array + // returns true if `inSelector` contained at least one parent selector + function replaceParentSelector(paths, context, inSelector) { + // The paths are [[Selector]] + // The first list is a list of comma separated selectors + // The inner list is a list of inheritance separated selectors + // e.g. + // .a, .b { + // .c { + // } + // } + // == [[.a] [.c]] [[.b] [.c]] + // + var i, j, k, currentElements, newSelectors, selectorsMultiplied, sel, el, hadParentSelector = false, length, lastSelector; + function findNestedSelector(element) { + var maybeSelector; + if (!(element.value instanceof Paren)) { + return null; + } + maybeSelector = element.value.value; + if (!(maybeSelector instanceof Selector)) { + return null; + } + return maybeSelector; + } + // the elements from the current selector so far + currentElements = []; + // the current list of new selectors to add to the path. + // We will build it up. We initiate it with one empty selector as we "multiply" the new selectors + // by the parents + newSelectors = [ + [] + ]; + for (i = 0; (el = inSelector.elements[i]); i++) { + // non parent reference elements just get added + if (el.value !== '&') { + var nestedSelector = findNestedSelector(el); + if (nestedSelector != null) { + // merge the current list of non parent selector elements + // on to the current list of selectors to add + mergeElementsOnToSelectors(currentElements, newSelectors); + var nestedPaths = []; + var replaced = void 0; + var replacedNewSelectors = []; + replaced = replaceParentSelector(nestedPaths, context, nestedSelector); + hadParentSelector = hadParentSelector || replaced; + // 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); + } + newSelectors = replacedNewSelectors; + currentElements = []; + } + else { + currentElements.push(el); + } + } + else { + hadParentSelector = true; + // the new list of selectors to add + selectorsMultiplied = []; + // merge the current list of non parent selector elements + // on to the current list of selectors to add + mergeElementsOnToSelectors(currentElements, newSelectors); + // loop through our current selectors + for (j = 0; j < newSelectors.length; j++) { + sel = newSelectors[j]; + // if we don't have any parent paths, the & might be in a mixin so that it can be used + // whether there are parents or not + if (context.length === 0) { + // 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.isVariable, el._index, el._fileInfo)); + } + selectorsMultiplied.push(sel); + } + else { + // and the parent selectors + for (k = 0; k < context.length; k++) { + // We need to put the current selectors + // then join the last selector's elements on to the parents selectors + var newSelectorPath = addReplacementIntoPath(sel, context[k], el, inSelector); + // add that to our new set of selectors + selectorsMultiplied.push(newSelectorPath); + } + } + } + // our new selectors has been multiplied, so reset the state + newSelectors = selectorsMultiplied; + currentElements = []; + } + } + // if we have any elements left over (e.g. .a& .b == .b) + // add them on to all the current selectors + mergeElementsOnToSelectors(currentElements, newSelectors); + for (i = 0; i < newSelectors.length; i++) { + length = newSelectors[i].length; + if (length > 0) { + paths.push(newSelectors[i]); + lastSelector = newSelectors[i][length - 1]; + newSelectors[i][length - 1] = lastSelector.createDerived(lastSelector.elements, inSelector.extendList); + } + } + return hadParentSelector; + } + function deriveSelector(visibilityInfo, deriveFrom) { + var newSelector = deriveFrom.createDerived(deriveFrom.elements, deriveFrom.extendList, deriveFrom.evaldCondition); + newSelector.copyVisibilityInfo(visibilityInfo); + return newSelector; + } + // joinSelector code follows + var i, newPaths, hadParentSelector; + newPaths = []; + hadParentSelector = replaceParentSelector(newPaths, context, selector); + if (!hadParentSelector) { + if (context.length > 0) { + newPaths = []; + for (i = 0; i < context.length; i++) { + var concatenated = context[i].map(deriveSelector.bind(this, selector.visibilityInfo())); + concatenated.push(selector); + newPaths.push(concatenated); + } + } + else { + newPaths = [[selector]]; + } + } + for (i = 0; i < newPaths.length; i++) { + paths.push(newPaths[i]); } - - return name; - } - - parserInput.restore(); } - } - }; - }; + }); - Parser.serializeVars = function (vars) { - var s = ''; - - for (var name in vars) { - if (Object.hasOwnProperty.call(vars, name)) { - var value = vars[name]; - s += "".concat((name[0] === '@' ? '' : '@') + name, ": ").concat(value).concat(String(value).slice(-1) === ';' ? '' : ';'); - } - } - - return s; - }; - - function boolean(condition) { - return condition ? Keyword.True : Keyword.False; - } - - function If(condition, trueValue, falseValue) { - return condition ? trueValue : falseValue || new Anonymous(); - } - - var boolean$1 = { - boolean: boolean, - 'if': If - }; - - var colorFunctions; - - function clamp$1(val) { - return Math.min(1, Math.max(0, val)); - } - - function hsla(origColor, hsl) { - var color = colorFunctions.hsla(hsl.h, hsl.s, hsl.l, hsl.a); - - if (color) { - if (origColor.value && /^(rgb|hsl)/.test(origColor.value)) { - color.value = origColor.value; - } else { - color.value = 'rgb'; - } - - return color; - } - } - - function toHSL(color) { - if (color.toHSL) { - return color.toHSL(); - } else { - throw new Error('Argument cannot be evaluated to a color'); - } - } - - function toHSV(color) { - if (color.toHSV) { - return color.toHSV(); - } else { - throw new Error('Argument cannot be evaluated to a color'); - } - } - - function number(n) { - if (n instanceof Dimension) { - return parseFloat(n.unit.is('%') ? n.value / 100 : n.value); - } else if (typeof n === 'number') { - return n; - } else { - throw { - type: 'Argument', - message: 'color functions take numbers as parameters' - }; - } - } - - function scaled(n, size) { - if (n instanceof Dimension && n.unit.is('%')) { - return parseFloat(n.value * size / 100); - } else { - return number(n); - } - } - - colorFunctions = { - rgb: function rgb(r, g, b) { - var color = colorFunctions.rgba(r, g, b, 1.0); - - if (color) { - color.value = 'rgb'; - return color; - } - }, - rgba: function rgba(r, g, b, a) { - try { - if (r instanceof Color) { - if (g) { - a = number(g); - } else { - a = r.alpha; - } - - return new Color(r.rgb, a, 'rgba'); - } - - var rgb = [r, g, b].map(function (c) { - return scaled(c, 255); - }); - a = number(a); - return new Color(rgb, a, 'rgba'); - } catch (e) {} - }, - hsl: function hsl(h, s, l) { - var color = colorFunctions.hsla(h, s, l, 1.0); - - if (color) { - color.value = 'hsl'; - return color; - } - }, - hsla: function hsla(h, s, l, a) { - try { - var hue = function hue(h) { - h = h < 0 ? h + 1 : h > 1 ? h - 1 : h; - - if (h * 6 < 1) { - return m1 + (m2 - m1) * h * 6; - } else if (h * 2 < 1) { - return m2; - } else if (h * 3 < 2) { - return m1 + (m2 - m1) * (2 / 3 - h) * 6; - } else { - return m1; - } - }; - - if (h instanceof Color) { - if (s) { - a = number(s); - } else { - a = h.alpha; - } - - return new Color(h.rgb, a, 'hsla'); - } - - var m1; - var m2; - h = number(h) % 360 / 360; - s = clamp$1(number(s)); - l = clamp$1(number(l)); - a = clamp$1(number(a)); - m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s; - m1 = l * 2 - m2; - var rgb = [hue(h + 1 / 3) * 255, hue(h) * 255, hue(h - 1 / 3) * 255]; - a = number(a); - return new Color(rgb, a, 'hsla'); - } catch (e) {} - }, - hsv: function hsv(h, s, v) { - return colorFunctions.hsva(h, s, v, 1.0); - }, - hsva: function hsva(h, s, v, a) { - h = number(h) % 360 / 360 * 360; - s = number(s); - v = number(v); - a = number(a); - var i; - var f; - i = Math.floor(h / 60 % 6); - f = h / 60 - i; - var vs = [v, v * (1 - s), v * (1 - f * s), v * (1 - (1 - f) * s)]; - var perm = [[0, 3, 1], [2, 0, 1], [1, 0, 3], [1, 2, 0], [3, 1, 0], [0, 1, 2]]; - return colorFunctions.rgba(vs[perm[i][0]] * 255, vs[perm[i][1]] * 255, vs[perm[i][2]] * 255, a); - }, - hue: function hue(color) { - return new Dimension(toHSL(color).h); - }, - saturation: function saturation(color) { - return new Dimension(toHSL(color).s * 100, '%'); - }, - lightness: function lightness(color) { - return new Dimension(toHSL(color).l * 100, '%'); - }, - hsvhue: function hsvhue(color) { - return new Dimension(toHSV(color).h); - }, - hsvsaturation: function hsvsaturation(color) { - return new Dimension(toHSV(color).s * 100, '%'); - }, - hsvvalue: function hsvvalue(color) { - return new Dimension(toHSV(color).v * 100, '%'); - }, - red: function red(color) { - return new Dimension(color.rgb[0]); - }, - green: function green(color) { - return new Dimension(color.rgb[1]); - }, - blue: function blue(color) { - return new Dimension(color.rgb[2]); - }, - alpha: function alpha(color) { - return new Dimension(toHSL(color).a); - }, - luma: function luma(color) { - return new Dimension(color.luma() * color.alpha * 100, '%'); - }, - luminance: function luminance(color) { - var luminance = 0.2126 * color.rgb[0] / 255 + 0.7152 * color.rgb[1] / 255 + 0.0722 * color.rgb[2] / 255; - return new Dimension(luminance * color.alpha * 100, '%'); - }, - saturate: function saturate(color, amount, method) { - // filter: saturate(3.2); - // should be kept as is, so check for color - if (!color.rgb) { - return null; - } - - var hsl = toHSL(color); - - if (typeof method !== 'undefined' && method.value === 'relative') { - hsl.s += hsl.s * amount.value / 100; - } else { - hsl.s += amount.value / 100; - } - - hsl.s = clamp$1(hsl.s); - return hsla(color, hsl); - }, - desaturate: function desaturate(color, amount, method) { - var hsl = toHSL(color); - - if (typeof method !== 'undefined' && method.value === 'relative') { - hsl.s -= hsl.s * amount.value / 100; - } else { - hsl.s -= amount.value / 100; - } - - hsl.s = clamp$1(hsl.s); - return hsla(color, hsl); - }, - lighten: function lighten(color, amount, method) { - var hsl = toHSL(color); - - if (typeof method !== 'undefined' && method.value === 'relative') { - hsl.l += hsl.l * amount.value / 100; - } else { - hsl.l += amount.value / 100; - } - - hsl.l = clamp$1(hsl.l); - return hsla(color, hsl); - }, - darken: function darken(color, amount, method) { - var hsl = toHSL(color); - - if (typeof method !== 'undefined' && method.value === 'relative') { - hsl.l -= hsl.l * amount.value / 100; - } else { - hsl.l -= amount.value / 100; - } - - hsl.l = clamp$1(hsl.l); - return hsla(color, hsl); - }, - fadein: function fadein(color, amount, method) { - var hsl = toHSL(color); - - if (typeof method !== 'undefined' && method.value === 'relative') { - hsl.a += hsl.a * amount.value / 100; - } else { - hsl.a += amount.value / 100; - } - - hsl.a = clamp$1(hsl.a); - return hsla(color, hsl); - }, - fadeout: function fadeout(color, amount, method) { - var hsl = toHSL(color); - - if (typeof method !== 'undefined' && method.value === 'relative') { - hsl.a -= hsl.a * amount.value / 100; - } else { - hsl.a -= amount.value / 100; - } - - hsl.a = clamp$1(hsl.a); - return hsla(color, hsl); - }, - fade: function fade(color, amount) { - var hsl = toHSL(color); - hsl.a = amount.value / 100; - hsl.a = clamp$1(hsl.a); - return hsla(color, hsl); - }, - spin: function spin(color, amount) { - var hsl = toHSL(color); - var hue = (hsl.h + amount.value) % 360; - hsl.h = hue < 0 ? 360 + hue : hue; - return hsla(color, hsl); - }, - // - // Copyright (c) 2006-2009 Hampton Catlin, Natalie Weizenbaum, and Chris Eppstein - // http://sass-lang.com - // - mix: function mix(color1, color2, weight) { - if (!weight) { - weight = new Dimension(50); - } - - var p = weight.value / 100.0; - var w = p * 2 - 1; - var a = toHSL(color1).a - toHSL(color2).a; - var w1 = ((w * a == -1 ? w : (w + a) / (1 + w * a)) + 1) / 2.0; - var w2 = 1 - w1; - var rgb = [color1.rgb[0] * w1 + color2.rgb[0] * w2, color1.rgb[1] * w1 + color2.rgb[1] * w2, color1.rgb[2] * w1 + color2.rgb[2] * w2]; - var alpha = color1.alpha * p + color2.alpha * (1 - p); - return new Color(rgb, alpha); - }, - greyscale: function greyscale(color) { - return colorFunctions.desaturate(color, new Dimension(100)); - }, - contrast: function contrast(color, dark, light, threshold) { - // filter: contrast(3.2); - // should be kept as is, so check for color - if (!color.rgb) { - return null; - } - - if (typeof light === 'undefined') { - light = colorFunctions.rgba(255, 255, 255, 1.0); - } - - if (typeof dark === 'undefined') { - dark = colorFunctions.rgba(0, 0, 0, 1.0); - } // Figure out which is actually light and dark: - - - if (dark.luma() > light.luma()) { - var t = light; - light = dark; - dark = t; - } - - if (typeof threshold === 'undefined') { - threshold = 0.43; - } else { - threshold = number(threshold); - } - - if (color.luma() < threshold) { - return light; - } else { - 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 argb(color) { - return new Anonymous(color.toARGB()); - }, - color: function color(c) { - if (c instanceof Quoted && /^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3,4})$/i.test(c.value)) { - var val = c.value.slice(1); - return new Color(val, undefined, "#".concat(val)); - } - - if (c instanceof Color || (c = Color.fromKeyword(c.value))) { - c.value = undefined; - return c; - } - - throw { - type: 'Argument', - message: 'argument must be a color keyword or 3|4|6|8 digit hex e.g. #FFF' - }; - }, - tint: function tint(color, amount) { - return colorFunctions.mix(colorFunctions.rgb(255, 255, 255), color, amount); - }, - shade: function shade(color, amount) { - return colorFunctions.mix(colorFunctions.rgb(0, 0, 0), color, amount); - } - }; - var color = colorFunctions; - - // ref: http://www.w3.org/TR/compositing-1 - - function colorBlend(mode, color1, color2) { - var ab = color1.alpha; // result - - var // backdrop - cb; - var as = color2.alpha; - var // source - cs; - var ar; - var cr; - var r = []; - ar = as + ab * (1 - as); - - for (var i = 0; i < 3; i++) { - cb = color1.rgb[i] / 255; - cs = color2.rgb[i] / 255; - cr = mode(cb, cs); - - if (ar) { - cr = (as * cs + ab * (cb - as * (cb + cs - cr))) / ar; - } - - r[i] = cr * 255; - } - - return new Color(r, ar); - } - - var colorBlendModeFunctions = { - multiply: function multiply(cb, cs) { - return cb * cs; - }, - screen: function screen(cb, cs) { - return cb + cs - cb * cs; - }, - overlay: function overlay(cb, cs) { - cb *= 2; - return cb <= 1 ? colorBlendModeFunctions.multiply(cb, cs) : colorBlendModeFunctions.screen(cb - 1, cs); - }, - softlight: function softlight(cb, cs) { - var d = 1; - var e = cb; - - if (cs > 0.5) { - e = 1; - d = cb > 0.25 ? Math.sqrt(cb) : ((16 * cb - 12) * cb + 4) * cb; - } - - return cb - (1 - 2 * cs) * e * (d - cb); - }, - hardlight: function hardlight(cb, cs) { - return colorBlendModeFunctions.overlay(cs, cb); - }, - difference: function difference(cb, cs) { - return Math.abs(cb - cs); - }, - exclusion: function exclusion(cb, cs) { - return cb + cs - 2 * cb * cs; - }, - // non-w3c functions: - average: function average(cb, cs) { - return (cb + cs) / 2; - }, - negation: function negation(cb, cs) { - return 1 - Math.abs(cb + cs - 1); - } - }; - - for (var f in colorBlendModeFunctions) { - if (colorBlendModeFunctions.hasOwnProperty(f)) { - colorBlend[f] = colorBlend.bind(null, colorBlendModeFunctions[f]); - } - } - - var dataUri = (function (environment) { - var fallback = function fallback(functionThis, node) { - return new URL(node, functionThis.index, functionThis.currentFileInfo).eval(functionThis.context); - }; - - return { - 'data-uri': function dataUri(mimetypeNode, filePathNode) { - if (!filePathNode) { - filePathNode = mimetypeNode; - mimetypeNode = null; - } - - var mimetype = mimetypeNode && mimetypeNode.value; - var filePath = filePathNode.value; - var currentFileInfo = this.currentFileInfo; - var currentDirectory = currentFileInfo.rewriteUrls ? currentFileInfo.currentDirectory : currentFileInfo.entryPath; - var fragmentStart = filePath.indexOf('#'); - var fragment = ''; - - if (fragmentStart !== -1) { - fragment = filePath.slice(fragmentStart); - filePath = filePath.slice(0, fragmentStart); - } - - var context = clone(this.context); - context.rawBuffer = true; - var fileManager = environment.getFileManager(filePath, currentDirectory, context, environment, true); - - if (!fileManager) { - return fallback(this, filePathNode); - } - - var useBase64 = false; // detect the mimetype if not given - - if (!mimetypeNode) { - mimetype = environment.mimeLookup(filePath); - - if (mimetype === 'image/svg+xml') { - useBase64 = false; - } else { - // use base 64 unless it's an ASCII or UTF-8 format - var charset = environment.charsetLookup(mimetype); - useBase64 = ['US-ASCII', 'UTF-8'].indexOf(charset) < 0; - } - - if (useBase64) { - mimetype += ';base64'; - } - } else { - useBase64 = /;base64$/.test(mimetype); - } - - var fileSync = fileManager.loadFileSync(filePath, currentDirectory, context, environment); - - if (!fileSync.contents) { - logger.warn("Skipped data-uri embedding of ".concat(filePath, " because file not found")); - return fallback(this, filePathNode || mimetypeNode); - } - - var buf = fileSync.contents; - - if (useBase64 && !environment.encodeBase64) { - return fallback(this, filePathNode); - } - - buf = useBase64 ? environment.encodeBase64(buf) : encodeURIComponent(buf); - var uri = "data:".concat(mimetype, ",").concat(buf).concat(fragment); - return new URL(new Quoted("\"".concat(uri, "\""), uri, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo); - } - }; - }); - - var getItemsFromNode = function getItemsFromNode(node) { - // handle non-array values as an array of length 1 - // return 'undefined' if index is invalid - var items = Array.isArray(node.value) ? node.value : Array(node); - return items; - }; - - var list = { - _SELF: function _SELF(n) { - return n; - }, - extract: function extract(values, index) { - // (1-based index) - index = index.value - 1; - return getItemsFromNode(values)[index]; - }, - length: function length(values) { - return new Dimension(getItemsFromNode(values).length); - }, - - /** - * Creates a Less list of incremental values. - * Modeled after Lodash's range function, also exists natively in PHP - * - * @param {Dimension} [start=1] - * @param {Dimension} end - e.g. 10 or 10px - unit is added to output - * @param {Dimension} [step=1] - */ - range: function range(start, end, step) { - var from; - var to; - var stepValue = 1; - var list = []; - - if (end) { - to = end; - from = start.value; - - if (step) { - stepValue = step.value; - } - } else { - from = 1; - to = start; - } - - for (var i = from; i <= to.value; i += stepValue) { - list.push(new Dimension(i, to.unit)); - } - - return new Expression(list); - }, - each: function each(list, rs) { - var rules = []; - var newRules; - var iterator; - - if (list.value && !(list instanceof Quoted)) { - if (Array.isArray(list.value)) { - iterator = list.value; - } else { - iterator = [list.value]; - } - } else if (list.ruleset) { - iterator = list.ruleset.rules; - } else if (list.rules) { - iterator = list.rules; - } else if (Array.isArray(list)) { - iterator = list; - } else { - iterator = [list]; - } - - var valueName = '@value'; - var keyName = '@key'; - var indexName = '@index'; - - if (rs.params) { - valueName = rs.params[0] && rs.params[0].name; - keyName = rs.params[1] && rs.params[1].name; - indexName = rs.params[2] && rs.params[2].name; - rs = rs.rules; - } else { - rs = rs.ruleset; - } - - for (var i = 0; i < iterator.length; i++) { - var key = void 0; - var value = void 0; - var item = iterator[i]; - - if (item instanceof Declaration) { - key = typeof item.name === 'string' ? item.name : item.name[0].value; - value = item.value; - } else { - key = new Dimension(i + 1); - value = item; - } - - if (item instanceof Comment) { - continue; - } - - newRules = rs.rules.slice(0); - - if (valueName) { - newRules.push(new Declaration(valueName, value, false, false, this.index, this.currentFileInfo)); - } - - if (indexName) { - newRules.push(new Declaration(indexName, new Dimension(i + 1), false, false, this.index, this.currentFileInfo)); - } - - if (keyName) { - newRules.push(new Declaration(keyName, key, false, false, this.index, this.currentFileInfo)); - } - - rules.push(new Ruleset([new Selector([new Element("", '&')])], newRules, rs.strictImports, rs.visibilityInfo())); - } - - return new Ruleset([new Selector([new Element("", '&')])], rules, rs.strictImports, rs.visibilityInfo()).eval(this.context); - } - }; - - var MathHelper = function MathHelper(fn, unit, n) { - if (!(n instanceof Dimension)) { - throw { - type: 'Argument', - message: 'argument must be a number' - }; - } - - if (unit == null) { - unit = n.unit; - } else { - n = n.unify(); - } - - return new Dimension(fn(parseFloat(n.value)), unit); - }; - - var mathFunctions = { - // name, unit - ceil: null, - floor: null, - sqrt: null, - abs: null, - tan: '', - sin: '', - cos: '', - atan: 'rad', - asin: 'rad', - acos: 'rad' - }; - - for (var f$1 in mathFunctions) { - if (mathFunctions.hasOwnProperty(f$1)) { - mathFunctions[f$1] = MathHelper.bind(null, Math[f$1], mathFunctions[f$1]); - } - } - - mathFunctions.round = function (n, f) { - var fraction = typeof f === 'undefined' ? 0 : f.value; - return MathHelper(function (num) { - return num.toFixed(fraction); - }, null, n); - }; - - var minMax = function minMax(isMin, args) { - args = Array.prototype.slice.call(args); - - switch (args.length) { - case 0: - throw { - type: 'Argument', - message: 'one or more arguments required' - }; - } - - var i; // key is the unit.toString() for unified Dimension values, - - var j; - var current; - var currentUnified; - var referenceUnified; - var unit; - var unitStatic; - var unitClone; - var // elems only contains original argument values. - order = []; - var values = {}; // value is the index into the order array. - - for (i = 0; i < args.length; i++) { - current = args[i]; - - if (!(current instanceof Dimension)) { - if (Array.isArray(args[i].value)) { - Array.prototype.push.apply(args, Array.prototype.slice.call(args[i].value)); - } - - continue; - } - - currentUnified = current.unit.toString() === '' && unitClone !== undefined ? new Dimension(current.value, unitClone).unify() : current.unify(); - unit = currentUnified.unit.toString() === '' && unitStatic !== undefined ? unitStatic : currentUnified.unit.toString(); - unitStatic = unit !== '' && unitStatic === undefined || unit !== '' && order[0].unify().unit.toString() === '' ? unit : unitStatic; - unitClone = unit !== '' && unitClone === undefined ? current.unit.toString() : unitClone; - j = values[''] !== undefined && unit !== '' && unit === unitStatic ? values[''] : values[unit]; - - if (j === undefined) { - if (unitStatic !== undefined && unit !== unitStatic) { - throw { - type: 'Argument', - message: 'incompatible types' - }; - } - - values[unit] = order.length; - order.push(current); - continue; - } - - referenceUnified = order[j].unit.toString() === '' && unitClone !== undefined ? new Dimension(order[j].value, unitClone).unify() : order[j].unify(); - - if (isMin && currentUnified.value < referenceUnified.value || !isMin && currentUnified.value > referenceUnified.value) { - order[j] = current; - } - } - - if (order.length == 1) { - return order[0]; - } - - args = order.map(function (a) { - return a.toCSS(this.context); - }).join(this.context.compress ? ',' : ', '); - return new Anonymous("".concat(isMin ? 'min' : 'max', "(").concat(args, ")")); - }; - - var number$1 = { - min: function min() { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return minMax(true, args); - }, - max: function max() { - for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - return minMax(false, args); - }, - convert: function convert(val, unit) { - return val.convertTo(unit.value); - }, - pi: function pi() { - return new Dimension(Math.PI); - }, - mod: function mod(a, b) { - return new Dimension(a.value % b.value, a.unit); - }, - pow: function pow(x, y) { - if (typeof x === 'number' && typeof y === 'number') { - x = new Dimension(x); - y = new Dimension(y); - } else if (!(x instanceof Dimension) || !(y instanceof Dimension)) { - throw { - type: 'Argument', - message: 'arguments must be numbers' - }; - } - - return new Dimension(Math.pow(x.value, y.value), x.unit); - }, - percentage: function percentage(n) { - var result = MathHelper(function (num) { - return num * 100; - }, '%', n); - return result; - } - }; - - var string = { - e: function e(str) { - return new Quoted('"', str instanceof JavaScript ? str.evaluated : str.value, true); - }, - escape: function escape(str) { - return new Anonymous(encodeURI(str.value).replace(/=/g, '%3D').replace(/:/g, '%3A').replace(/#/g, '%23').replace(/;/g, '%3B').replace(/\(/g, '%28').replace(/\)/g, '%29')); - }, - replace: function replace(string, pattern, replacement, flags) { - var result = string.value; - replacement = replacement.type === 'Quoted' ? replacement.value : replacement.toCSS(); - result = result.replace(new RegExp(pattern.value, flags ? flags.value : ''), replacement); - return new Quoted(string.quote || '', result, string.escaped); - }, - '%': function _(string - /* arg, arg, ... */ - ) { - var args = Array.prototype.slice.call(arguments, 1); - var result = string.value; - - var _loop = function _loop(i) { - /* 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(); - return token.match(/[A-Z]$/) ? encodeURIComponent(value) : value; - }); - }; - - for (var i = 0; i < args.length; i++) { - _loop(i); - } - - result = result.replace(/%%/g, '%'); - return new Quoted(string.quote || '', result, string.escaped); - } - }; - - var svg = (function (environment) { - return { - 'svg-gradient': function svgGradient(direction) { - var stops; - var gradientDirectionSvg; - var gradientType = 'linear'; - var rectangleDimension = 'x="0" y="0" width="1" height="1"'; - var renderEnv = { - compress: false - }; - var returner; - var directionValue = direction.toCSS(renderEnv); + var AtRule = function (name, value, rules, index, currentFileInfo, debugInfo, isRooted, visibilityInfo) { var i; - var color; - var position; - var positionValue; - var 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' - }; + 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); } - - if (arguments.length == 2) { - if (arguments[1].value.length < 2) { - throwArgumentDescriptor(); - } - - stops = arguments[1].value; - } else if (arguments.length < 3) { - throwArgumentDescriptor(); - } else { - stops = Array.prototype.slice.call(arguments, 1); - } - - switch (directionValue) { - case 'to bottom': - gradientDirectionSvg = 'x1="0%" y1="0%" x2="0%" y2="100%"'; - break; - - case 'to right': - gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="0%"'; - break; - - case 'to bottom right': - gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="100%"'; - break; - - case 'to top right': - gradientDirectionSvg = 'x1="0%" y1="100%" x2="100%" y2="0%"'; - break; - - case 'ellipse': - case 'ellipse at center': - gradientType = 'radial'; - gradientDirectionSvg = 'cx="50%" cy="50%" r="75%"'; - rectangleDimension = 'x="-50" y="-50" width="101" height="101"'; - break; - - default: - throw { - type: 'Argument', - message: 'svg-gradient direction must be \'to bottom\', \'to right\',' + ' \'to bottom right\', \'to top right\' or \'ellipse at center\'' - }; - } - - returner = "<".concat(gradientType, "Gradient id=\"g\" ").concat(gradientDirectionSvg, ">"); - - for (i = 0; i < stops.length; i += 1) { - if (stops[i] instanceof Expression) { - color = stops[i].value[0]; - position = stops[i].value[1]; - } else { - color = stops[i]; - position = undefined; - } - - if (!(color instanceof Color) || !((i === 0 || i + 1 === stops.length) && position === undefined) && !(position instanceof Dimension)) { - throwArgumentDescriptor(); - } - - positionValue = position ? position.toCSS(renderEnv) : i === 0 ? '0%' : '100%'; - alpha = color.alpha; - returner += ""); - } - - returner += ""); - returner = encodeURIComponent(returner); - returner = "data:image/svg+xml,".concat(returner); - return new URL(new Quoted("'".concat(returner, "'"), returner, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo); - } + this._index = index; + this._fileInfo = currentFileInfo; + this.debugInfo = debugInfo; + this.isRooted = isRooted || false; + this.copyVisibilityInfo(visibilityInfo); + this.allowRoot = true; }; - }); - - var isa = function isa(n, Type) { - return n instanceof Type ? Keyword.True : Keyword.False; - }; - - var isunit = function isunit(n, unit) { - if (unit === undefined) { - throw { - type: 'Argument', - message: 'missing the required second argument to isunit.' - }; - } - - unit = typeof unit.value === 'string' ? unit.value : unit; - - if (typeof unit !== 'string') { - throw { - type: 'Argument', - message: 'Second argument to isunit should be a unit or a string.' - }; - } - - return n instanceof Dimension && n.unit.is(unit) ? Keyword.True : Keyword.False; - }; - - var types = { - isruleset: function isruleset(n) { - return isa(n, DetachedRuleset); - }, - iscolor: function iscolor(n) { - return isa(n, Color); - }, - isnumber: function isnumber(n) { - return isa(n, Dimension); - }, - isstring: function isstring(n) { - return isa(n, Quoted); - }, - iskeyword: function iskeyword(n) { - return isa(n, Keyword); - }, - isurl: function isurl(n) { - return isa(n, URL); - }, - ispixel: function ispixel(n) { - return isunit(n, 'px'); - }, - ispercentage: function ispercentage(n) { - return isunit(n, '%'); - }, - isem: function isem(n) { - return isunit(n, 'em'); - }, - isunit: isunit, - unit: function unit(val, _unit) { - if (!(val instanceof Dimension)) { - throw { - type: 'Argument', - message: "the first argument to unit must be a number".concat(val instanceof Operation ? '. Have you forgotten parenthesis?' : '') - }; - } - - if (_unit) { - if (_unit instanceof Keyword) { - _unit = _unit.value; - } else { - _unit = _unit.toCSS(); - } - } else { - _unit = ''; - } - - return new Dimension(val.value, _unit); - }, - 'get-unit': function getUnit(n) { - return new Anonymous(n.unit); - } - }; - - var Functions = (function (environment) { - var functions = { - functionRegistry: functionRegistry, - functionCaller: functionCaller - }; // register functions - - functionRegistry.addMultiple(boolean$1); - functionRegistry.add('default', defaultFunc.eval.bind(defaultFunc)); - functionRegistry.addMultiple(color); - functionRegistry.addMultiple(colorBlend); - functionRegistry.addMultiple(dataUri(environment)); - functionRegistry.addMultiple(list); - functionRegistry.addMultiple(mathFunctions); - functionRegistry.addMultiple(number$1); - functionRegistry.addMultiple(string); - functionRegistry.addMultiple(svg()); - functionRegistry.addMultiple(types); - return functions; - }); - - var sourceMapOutput = (function (environment) { - var SourceMapOutput = - /*#__PURE__*/ - function () { - function SourceMapOutput(options) { - _classCallCheck(this, SourceMapOutput); - - this._css = []; - this._rootNode = options.rootNode; - this._contentsMap = options.contentsMap; - this._contentsIgnoredCharsMap = options.contentsIgnoredCharsMap; - - if (options.sourceMapFilename) { - this._sourceMapFilename = options.sourceMapFilename.replace(/\\/g, '/'); - } - - this._outputFilename = options.outputFilename; - this.sourceMapURL = options.sourceMapURL; - - if (options.sourceMapBasepath) { - this._sourceMapBasepath = options.sourceMapBasepath.replace(/\\/g, '/'); - } - - if (options.sourceMapRootpath) { - this._sourceMapRootpath = options.sourceMapRootpath.replace(/\\/g, '/'); - - if (this._sourceMapRootpath.charAt(this._sourceMapRootpath.length - 1) !== '/') { - this._sourceMapRootpath += '/'; - } - } else { - this._sourceMapRootpath = ''; - } - - this._outputSourceFiles = options.outputSourceFiles; - this._sourceMapGeneratorConstructor = environment.getSourceMapGenerator(); - this._lineNumber = 0; - this._column = 0; - } - - _createClass(SourceMapOutput, [{ - key: "removeBasepath", - value: function removeBasepath(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); + AtRule.prototype = Object.assign(new Node(), { + type: 'AtRule', + accept: function (visitor) { + var value = this.value, rules = this.rules; + if (rules) { + this.rules = visitor.visitArray(rules); } - } - - return path; - } - }, { - key: "normalizeFilename", - value: function normalizeFilename(filename) { - filename = filename.replace(/\\/g, '/'); - filename = this.removeBasepath(filename); - return (this._sourceMapRootpath || '') + filename; - } - }, { - key: "add", - value: function add(chunk, fileInfo, index, mapLines) { - // ignore adding empty strings - if (!chunk) { - return; - } - - var lines; - var sourceLines; - var columns; - var sourceColumns; - var i; - - if (fileInfo && fileInfo.filename) { - var inputSource = this._contentsMap[fileInfo.filename]; // remove vars/banner added to the top of the file - - if (this._contentsIgnoredCharsMap[fileInfo.filename]) { - // adjust the index - index -= this._contentsIgnoredCharsMap[fileInfo.filename]; - - if (index < 0) { - index = 0; - } // adjust the source - - - inputSource = inputSource.slice(this._contentsIgnoredCharsMap[fileInfo.filename]); - } // ignore empty content - - - if (inputSource === undefined) { - return; + if (value) { + this.value = visitor.visit(value); } - - inputSource = inputSource.substring(0, index); - sourceLines = inputSource.split('\n'); - sourceColumns = sourceLines[sourceLines.length - 1]; - } - - lines = chunk.split('\n'); - columns = lines[lines.length - 1]; - - if (fileInfo && fileInfo.filename) { - if (!mapLines) { - this._sourceMapGenerator.addMapping({ - generated: { - line: this._lineNumber + 1, - column: this._column - }, - original: { - line: sourceLines.length, - column: sourceColumns.length - }, - source: this.normalizeFilename(fileInfo.filename) - }); - } else { - for (i = 0; i < lines.length; i++) { - this._sourceMapGenerator.addMapping({ - generated: { - line: this._lineNumber + i + 1, - column: i === 0 ? this._column : 0 - }, - original: { - line: sourceLines.length + i, - column: i === 0 ? sourceColumns.length : 0 - }, - source: this.normalizeFilename(fileInfo.filename) - }); - } + }, + isRulesetLike: function () { + return this.rules || !this.isCharset(); + }, + isCharset: function () { + return '@charset' === this.name; + }, + 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 (lines.length === 1) { - this._column += columns.length; - } else { - this._lineNumber += lines.length - 1; - this._column = columns.length; - } - - this._css.push(chunk); - } - }, { - key: "isEmpty", - value: function isEmpty() { - return this._css.length === 0; - } - }, { - key: "toCSS", - value: function toCSS(context) { - this._sourceMapGenerator = new this._sourceMapGeneratorConstructor({ - file: this._outputFilename, - sourceRoot: null - }); - - if (this._outputSourceFiles) { - for (var filename in this._contentsMap) { - if (this._contentsMap.hasOwnProperty(filename)) { - var source = this._contentsMap[filename]; - - if (this._contentsIgnoredCharsMap[filename]) { - source = source.slice(this._contentsIgnoredCharsMap[filename]); + if (rules) { + this.outputRuleset(context, output, rules); + } + else { + output.add(';'); + } + }, + 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()); + }, + 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); + } + }, + 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); + } + }, + 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]); + } + }, + outputRuleset: function (context, output, rules) { + var ruleCnt = rules.length; + var i; + context.tabLevel = (context.tabLevel | 0) + 1; + // Compressed + if (context.compress) { + output.add('{'); + for (i = 0; i < ruleCnt; i++) { + rules[i].genCSS(context, output); } - - this._sourceMapGenerator.setSourceContent(this.normalizeFilename(filename), source); - } + output.add('}'); + context.tabLevel--; + return; } - } - - this._rootNode.genCSS(context, this); - - if (this._css.length > 0) { - var sourceMapURL; - var sourceMapContent = JSON.stringify(this._sourceMapGenerator.toJSON()); - - if (this.sourceMapURL) { - sourceMapURL = this.sourceMapURL; - } else if (this._sourceMapFilename) { - sourceMapURL = this._sourceMapFilename; + // Non-compressed + var tabSetStr = "\n" + Array(context.tabLevel).join(' '), tabRuleStr = tabSetStr + " "; + if (!ruleCnt) { + output.add(" {" + tabSetStr + "}"); } - - this.sourceMapURL = sourceMapURL; - this.sourceMap = sourceMapContent; - } - - return this._css.join(''); - } - }]); - - return SourceMapOutput; - }(); - - return SourceMapOutput; - }); - - var sourceMapBuilder = (function (SourceMapOutput, environment) { - var SourceMapBuilder = - /*#__PURE__*/ - function () { - function SourceMapBuilder(options) { - _classCallCheck(this, SourceMapBuilder); - - this.options = options; - } - - _createClass(SourceMapBuilder, [{ - key: "toCSS", - value: function toCSS(rootNode, options, imports) { - var sourceMapOutput = new SourceMapOutput({ - contentsIgnoredCharsMap: imports.contentsIgnoredChars, - rootNode: rootNode, - contentsMap: imports.contents, - sourceMapFilename: this.options.sourceMapFilename, - sourceMapURL: this.options.sourceMapURL, - outputFilename: this.options.sourceMapOutputFilename, - sourceMapBasepath: this.options.sourceMapBasepath, - sourceMapRootpath: this.options.sourceMapRootpath, - outputSourceFiles: this.options.outputSourceFiles, - sourceMapGenerator: this.options.sourceMapGenerator, - sourceMapFileInline: this.options.sourceMapFileInline - }); - var css = sourceMapOutput.toCSS(options); - this.sourceMap = sourceMapOutput.sourceMap; - this.sourceMapURL = sourceMapOutput.sourceMapURL; - - 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(); - } - }, { - key: "getCSSAppendage", - value: function getCSSAppendage() { - var sourceMapURL = this.sourceMapURL; - - if (this.options.sourceMapFileInline) { - if (this.sourceMap === undefined) { - return ''; + 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 + "}"); } - - sourceMapURL = "data:application/json;base64,".concat(environment.encodeBase64(this.sourceMap)); - } - - if (sourceMapURL) { - return "/*# sourceMappingURL=".concat(sourceMapURL, " */"); - } - - return ''; + context.tabLevel--; } - }, { - key: "getExternalSourceMap", - value: function getExternalSourceMap() { - return this.sourceMap; + }); + + var DetachedRuleset = function (ruleset, frames) { + this.ruleset = ruleset; + this.frames = frames; + this.setParent(this.ruleset, this); + }; + DetachedRuleset.prototype = Object.assign(new Node(), { + type: 'DetachedRuleset', + evalFirst: true, + accept: function (visitor) { + this.ruleset = visitor.visit(this.ruleset); + }, + eval: function (context) { + var frames = this.frames || copyArray(context.frames); + return new DetachedRuleset(this.ruleset, frames); + }, + callEval: function (context) { + return this.ruleset.eval(this.frames ? new contexts.Eval(context, this.frames.concat(context.frames)) : context); } - }, { - key: "setExternalSourceMap", - value: function setExternalSourceMap(sourceMap) { - this.sourceMap = sourceMap; + }); + + var Unit = function (numerator, denominator, backupUnit) { + this.numerator = numerator ? copyArray(numerator).sort() : []; + this.denominator = denominator ? copyArray(denominator).sort() : []; + if (backupUnit) { + this.backupUnit = backupUnit; } - }, { - key: "isInline", - value: function isInline() { - return this.options.sourceMapFileInline; + else if (numerator && numerator.length) { + this.backupUnit = numerator[0]; } - }, { - key: "getSourceMapURL", - value: function getSourceMapURL() { - return this.sourceMapURL; - } - }, { - key: "getOutputFilename", - value: function getOutputFilename() { - return this.options.sourceMapOutputFilename; - } - }, { - key: "getInputFilename", - value: function getInputFilename() { - return this.sourceMapInputFilename; - } - }]); - - return SourceMapBuilder; - }(); - - return SourceMapBuilder; - }); - - var transformTree = (function (root) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var evaldRoot; - var variables = options.variables; - var evalEnv = new contexts.Eval(options); // - // Allows setting variables with a hash, so: - // - // `{ color: new tree.Color('#f01') }` will become: - // - // new tree.Declaration('@color', - // new tree.Value([ - // new tree.Expression([ - // new tree.Color('#f01') - // ]) - // ]) - // ) - // - - if (_typeof(variables) === 'object' && !Array.isArray(variables)) { - variables = Object.keys(variables).map(function (k) { - var value = variables[k]; - - if (!(value instanceof tree.Value)) { - if (!(value instanceof tree.Expression)) { - value = new tree.Expression([value]); - } - - value = new tree.Value([value]); - } - - return new tree.Declaration("@".concat(k), value, false, null, 0); - }); - evalEnv.frames = [new tree.Ruleset(null, variables)]; - } - - var visitors$1 = [new visitors.JoinSelectorVisitor(), new visitors.MarkVisibleSelectorsVisitor(true), new visitors.ExtendVisitor(), new visitors.ToCSSVisitor({ - compress: Boolean(options.compress) - })]; - var preEvalVisitors = []; - var v; - var visitorIterator; - /** - * first() / get() allows visitors to be added while visiting - * - * @todo Add scoping for visitors just like functions for @plugin; right now they're global - */ - - if (options.pluginManager) { - visitorIterator = options.pluginManager.visitor(); - - for (var i = 0; i < 2; i++) { - visitorIterator.first(); - - while (v = visitorIterator.get()) { - if (v.isPreEvalVisitor) { - if (i === 0 || preEvalVisitors.indexOf(v) === -1) { - preEvalVisitors.push(v); - v.run(root); + }; + Unit.prototype = Object.assign(new Node(), { + type: 'Unit', + clone: function () { + return new Unit(copyArray(this.numerator), copyArray(this.denominator), this.backupUnit); + }, + genCSS: function (context, output) { + // Dimension checks the unit is singular and throws an error if in strict math mode. + var strictUnits = context && context.strictUnits; + if (this.numerator.length === 1) { + output.add(this.numerator[0]); // the ideal situation } - } else { - if (i === 0 || visitors$1.indexOf(v) === -1) { - if (v.isPreVisitor) { - visitors$1.unshift(v); - } else { - visitors$1.push(v); - } + else if (!strictUnits && this.backupUnit) { + output.add(this.backupUnit); } - } - } - } - } - - evaldRoot = root.eval(evalEnv); - - for (var i = 0; i < visitors$1.length; i++) { - visitors$1[i].run(evaldRoot); - } // Run any remaining visitors added after eval pass - - - if (options.pluginManager) { - visitorIterator.first(); - - while (v = visitorIterator.get()) { - if (visitors$1.indexOf(v) === -1 && preEvalVisitors.indexOf(v) === -1) { - v.run(evaldRoot); - } - } - } - - return evaldRoot; - }); - - var parseTree = (function (SourceMapBuilder) { - var ParseTree = - /*#__PURE__*/ - function () { - function ParseTree(root, imports) { - _classCallCheck(this, ParseTree); - - this.root = root; - this.imports = imports; - } - - _createClass(ParseTree, [{ - key: "toCSS", - value: function toCSS(options) { - var evaldRoot; - var result = {}; - var sourceMapBuilder; - - try { - evaldRoot = transformTree(this.root, options); - } catch (e) { - throw new LessError(e, this.imports); - } - - try { - var compress = Boolean(options.compress); - - if (compress) { - logger.warn('The compress option has been deprecated. ' + 'We recommend you use a dedicated css minifier, for instance see less-plugin-clean-css.'); + else if (!strictUnits && this.denominator.length) { + output.add(this.denominator[0]); } - - var toCSSOptions = { - compress: compress, - dumpLineNumbers: options.dumpLineNumbers, - strictUnits: Boolean(options.strictUnits), - numPrecision: 8 + }, + toString: function () { + var i, returnStr = this.numerator.join('*'); + for (i = 0; i < this.denominator.length; i++) { + returnStr += "/" + this.denominator[i]; + } + return returnStr; + }, + compare: function (other) { + return this.is(other.toString()) ? 0 : undefined; + }, + is: function (unitString) { + return this.toString().toUpperCase() === unitString.toUpperCase(); + }, + isLength: function () { + return RegExp('^(px|em|ex|ch|rem|in|cm|mm|pc|pt|ex|vw|vh|vmin|vmax)$', 'gi').test(this.toCSS()); + }, + isEmpty: function () { + return this.numerator.length === 0 && this.denominator.length === 0; + }, + isSingular: function () { + return this.numerator.length <= 1 && this.denominator.length === 0; + }, + map: function (callback) { + var i; + for (i = 0; i < this.numerator.length; i++) { + this.numerator[i] = callback(this.numerator[i], false); + } + for (i = 0; i < this.denominator.length; i++) { + this.denominator[i] = callback(this.denominator[i], true); + } + }, + usedUnits: function () { + var group; + var result = {}; + var mapUnit; + var groupName; + mapUnit = function (atomicUnit) { + /* jshint loopfunc:true */ + if (group.hasOwnProperty(atomicUnit) && !result[groupName]) { + result[groupName] = atomicUnit; + } + return atomicUnit; }; - - if (options.sourceMap) { - sourceMapBuilder = new SourceMapBuilder(options.sourceMap); - result.css = sourceMapBuilder.toCSS(evaldRoot, toCSSOptions, this.imports); - } else { - result.css = evaldRoot.toCSS(toCSSOptions); + for (groupName in unitConversions) { + if (unitConversions.hasOwnProperty(groupName)) { + group = unitConversions[groupName]; + this.map(mapUnit); + } } - } catch (e) { - throw new LessError(e, this.imports); - } - - if (options.pluginManager) { - var postProcessors = options.pluginManager.getPostProcessors(); - - for (var i = 0; i < postProcessors.length; i++) { - result.css = postProcessors[i].process(result.css, { - sourceMap: sourceMapBuilder, - options: options, - imports: this.imports - }); + return result; + }, + cancel: function () { + var counter = {}; + var atomicUnit; + var i; + for (i = 0; i < this.numerator.length; i++) { + atomicUnit = this.numerator[i]; + counter[atomicUnit] = (counter[atomicUnit] || 0) + 1; } - } - - if (options.sourceMap) { - result.map = sourceMapBuilder.getExternalSourceMap(); - } - - result.imports = []; - - for (var file in this.imports.files) { - if (this.imports.files.hasOwnProperty(file) && file !== this.imports.rootFilename) { - result.imports.push(file); + for (i = 0; i < this.denominator.length; i++) { + atomicUnit = this.denominator[i]; + counter[atomicUnit] = (counter[atomicUnit] || 0) - 1; } - } - - return result; + this.numerator = []; + this.denominator = []; + for (atomicUnit in counter) { + if (counter.hasOwnProperty(atomicUnit)) { + var count = counter[atomicUnit]; + if (count > 0) { + for (i = 0; i < count; i++) { + this.numerator.push(atomicUnit); + } + } + else if (count < 0) { + for (i = 0; i < -count; i++) { + this.denominator.push(atomicUnit); + } + } + } + } + this.numerator.sort(); + this.denominator.sort(); } - }]); + }); - return ParseTree; - }(); - - return ParseTree; - }); - - var importManager = (function (environment) { - // FileInfo = { - // 'rewriteUrls' - option - whether to adjust URL's to be relative - // 'filename' - full resolved filename of current file - // 'rootpath' - path to append to normal URLs for this node - // 'currentDirectory' - path to the current file, absolute - // 'rootFilename' - filename of the base file - // 'entryPath' - absolute path to the entry file - // 'reference' - whether the file should not be output and only output parts that are referenced - var ImportManager = - /*#__PURE__*/ - function () { - function ImportManager(less, context, rootFileInfo) { - _classCallCheck(this, ImportManager); - - 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 - - this.contentsIgnoredChars = {}; // map - filename to lines at the beginning of each file to ignore - - this.mime = context.mime; - this.error = null; - this.context = context; // Deprecated? Unused outside of here, could be useful. - - 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 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 - */ - - - _createClass(ImportManager, [{ - key: "push", - value: function push(path, tryAppendExtension, currentFileInfo, importOptions, callback) { - var importManager = this; - var pluginLoader = this.context.pluginManager.Loader; - this.queue.push(path); - - var fileParsedFunc = function fileParsedFunc(e, root, fullPath) { - importManager.queue.splice(importManager.queue.indexOf(path), 1); // Remove the path from the queue - - var importedEqualsRoot = fullPath === importManager.rootFilename; - - if (importOptions.optional && e) { - callback(null, { - rules: [] - }, false, null); - logger.info("The file ".concat(fullPath, " was skipped because it was not found and the import was marked optional.")); - } else { - // Inline imports aren't cached here. - // If we start to cache them, please make sure they won't conflict with non-inline imports of the - // same name as they used to do before this comment and the condition below have been added. - if (!importManager.files[fullPath] && !importOptions.inline) { - importManager.files[fullPath] = { - root: root, - options: importOptions - }; - } - - if (e && !importManager.error) { - importManager.error = e; - } - - callback(e, root, importedEqualsRoot, fullPath); + // + // A number with a unit + // + 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 = Object.assign(new Node(), { + type: 'Dimension', + accept: function (visitor) { + this.unit = visitor.visit(this.unit); + }, + eval: function (context) { + return this; + }, + toColor: function () { + return new Color([this.value, this.value, this.value]); + }, + genCSS: function (context, output) { + if ((context && context.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 value = this.fround(context, this.value); + var strValue = String(value); + if (value !== 0 && value < 0.000001 && value > -0.000001) { + // would be output 1e-6 etc. + strValue = value.toFixed(20).replace(/0+$/, ''); + } + if (context && context.compress) { + // Zero values doesn't need a unit + if (value === 0 && this.unit.isLength()) { + output.add(strValue); + return; + } + // Float values doesn't need a leading zero + if (value > 0 && value < 1) { + strValue = (strValue).substr(1); + } + } + output.add(strValue); + this.unit.genCSS(context, output); + }, + // In an operation between two Dimensions, + // we default to the first Dimension's unit, + // so `1px + 2` will yield `3px`. + operate: function (context, op, other) { + /* jshint noempty:false */ + var value = this._operate(context, op, this.value, other.value); + var unit = this.unit.clone(); + if (op === '+' || op === '-') { + if (unit.numerator.length === 0 && unit.denominator.length === 0) { + unit = other.unit.clone(); + if (this.unit.backupUnit) { + unit.backupUnit = this.unit.backupUnit; + } + } + else if (other.unit.numerator.length === 0 && unit.denominator.length === 0) ; + else { + other = other.convertTo(this.unit.usedUnits()); + if (context.strictUnits && other.unit.toString() !== unit.toString()) { + throw new Error("Incompatible units. Change the units or use the unit function. " + + ("Bad units: '" + unit.toString() + "' and '" + other.unit.toString() + "'.")); + } + value = this._operate(context, op, this.value, other.value); + } + } + else if (op === '*') { + unit.numerator = unit.numerator.concat(other.unit.numerator).sort(); + unit.denominator = unit.denominator.concat(other.unit.denominator).sort(); + unit.cancel(); + } + else if (op === '/') { + unit.numerator = unit.numerator.concat(other.unit.denominator).sort(); + unit.denominator = unit.denominator.concat(other.unit.numerator).sort(); + unit.cancel(); + } + return new Dimension(value, unit); + }, + compare: function (other) { + var a, b; + if (!(other instanceof Dimension)) { + return undefined; + } + if (this.unit.isEmpty() || other.unit.isEmpty()) { + a = this; + b = other; + } + else { + a = this.unify(); + b = other.unify(); + if (a.unit.compare(b.unit) !== 0) { + return undefined; + } + } + return Node.numericCompare(a.value, b.value); + }, + unify: function () { + return this.convertTo({ length: 'px', duration: 's', angle: 'rad' }); + }, + convertTo: function (conversions) { + var value = this.value; + var unit = this.unit.clone(); + var i; + var groupName; + var group; + var targetUnit; + var derivedConversions = {}; + var applyUnit; + if (typeof conversions === 'string') { + for (i in unitConversions) { + if (unitConversions[i].hasOwnProperty(conversions)) { + derivedConversions = {}; + derivedConversions[i] = conversions; + } + } + conversions = derivedConversions; + } + applyUnit = function (atomicUnit, denominator) { + /* jshint loopfunc:true */ + if (group.hasOwnProperty(atomicUnit)) { + if (denominator) { + value = value / (group[atomicUnit] / group[targetUnit]); + } + else { + value = value * (group[atomicUnit] / group[targetUnit]); + } + return targetUnit; + } + return atomicUnit; + }; + for (groupName in conversions) { + if (conversions.hasOwnProperty(groupName)) { + targetUnit = conversions[groupName]; + group = unitConversions[groupName]; + unit.map(applyUnit); + } + } + unit.cancel(); + return new Dimension(value, unit); + } + }); - var newFileInfo = { - rewriteUrls: this.context.rewriteUrls, - entryPath: currentFileInfo.entryPath, - rootpath: currentFileInfo.rootpath, - rootFilename: currentFileInfo.rootFilename - }; - var fileManager = environment.getFileManager(path, currentFileInfo.currentDirectory, this.context, environment); + var MATH = Math$1; + var Operation = function (op, operands, isSpaced) { + this.op = op.trim(); + this.operands = operands; + this.isSpaced = isSpaced; + }; + Operation.prototype = Object.assign(new Node(), { + type: 'Operation', + accept: function (visitor) { + this.operands = visitor.visitArray(this.operands); + }, + eval: function (context) { + var a = this.operands[0].eval(context), b = this.operands[1].eval(context), op; + if (context.isMathOn(this.op)) { + op = this.op === './' ? '/' : this.op; + if (a instanceof Dimension && b instanceof Color) { + a = a.toColor(); + } + if (b instanceof Dimension && a instanceof Color) { + b = b.toColor(); + } + if (!a.operate || !b.operate) { + if ((a instanceof Operation || b instanceof Operation) + && a.op === '/' && context.math === MATH.PARENS_DIVISION) { + return new Operation(this.op, [a, b], this.isSpaced); + } + throw { type: 'Operation', + message: 'Operation on an invalid type' }; + } + return a.operate(context, op, b); + } + else { + return new Operation(this.op, [a, b], this.isSpaced); + } + }, + genCSS: function (context, output) { + this.operands[0].genCSS(context, output); + if (this.isSpaced) { + output.add(' '); + } + output.add(this.op); + if (this.isSpaced) { + output.add(' '); + } + this.operands[1].genCSS(context, output); + } + }); - if (!fileManager) { - fileParsedFunc({ - message: "Could not find a file-manager for ".concat(path) + /*! ***************************************************************************** + Copyright (c) Microsoft Corporation. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + ***************************************************************************** */ + + function __spreadArray(to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || from); + } + + var Expression = function (value, noSpacing) { + this.value = value; + this.noSpacing = noSpacing; + if (!value) { + throw new Error('Expression requires an array parameter'); + } + }; + Expression.prototype = Object.assign(new Node(), { + type: 'Expression', + accept: function (visitor) { + this.value = visitor.visitArray(this.value); + }, + eval: function (context) { + var returnValue; + var mathOn = context.isMathOn(); + var inParenthesis = this.parens; + var doubleParen = false; + if (inParenthesis) { + context.inParenthesis(); + } + if (this.value.length > 1) { + returnValue = new Expression(this.value.map(function (e) { + if (!e.eval) { + return e; + } + return e.eval(context); + }), this.noSpacing); + } + else if (this.value.length === 1) { + if (this.value[0].parens && !this.value[0].parensInOp && !context.inCalc) { + doubleParen = true; + } + returnValue = this.value[0].eval(context); + } + else { + returnValue = this; + } + if (inParenthesis) { + context.outOfParenthesis(); + } + if (this.parens && this.parensInOp && !mathOn && !doubleParen + && (!(returnValue instanceof Dimension))) { + returnValue = new Paren(returnValue); + } + return returnValue; + }, + genCSS: function (context, output) { + for (var i = 0; i < this.value.length; i++) { + this.value[i].genCSS(context, output); + if (!this.noSpacing && i + 1 < this.value.length) { + output.add(' '); + } + } + }, + throwAwayComments: function () { + this.value = this.value.filter(function (v) { + return !(v instanceof Comment); }); - return; - } + } + }); - var loadFileCallback = function loadFileCallback(loadedFile) { - var plugin; - var resolvedFilename = loadedFile.filename; - var contents = loadedFile.contents.replace(/^\uFEFF/, ''); // Pass on an updated rootpath if path of imported file is relative and file - // is in a (sub|sup) directory + var functionCaller = /** @class */ (function () { + function functionCaller(name, context, index, currentFileInfo) { + this.name = name.toLowerCase(); + this.index = index; + this.context = context; + this.currentFileInfo = currentFileInfo; + this.func = context.frames[0].functionRegistry.get(this.name); + } + functionCaller.prototype.isValid = function () { + return Boolean(this.func); + }; + functionCaller.prototype.call = function (args) { + var _this = this; + if (!(Array.isArray(args))) { + args = [args]; + } + var evalArgs = this.func.evalArgs; + if (evalArgs !== false) { + args = args.map(function (a) { return a.eval(_this.context); }); + } + var commentFilter = function (item) { return !(item.type === 'Comment'); }; + // This code is terrible and should be replaced as per this issue... + // https://github.com/less/less.js/issues/2477 + args = args + .filter(commentFilter) + .map(function (item) { + if (item.type === 'Expression') { + var subNodes = item.value.filter(commentFilter); + if (subNodes.length === 1) { + // https://github.com/less/less.js/issues/3616 + if (item.parens && subNodes[0].op === '/') { + return item; + } + return subNodes[0]; + } + else { + return new Expression(subNodes); + } + } + return item; + }); + if (evalArgs === false) { + return this.func.apply(this, __spreadArray([this.context], args)); + } + return this.func.apply(this, args); + }; + return functionCaller; + }()); + + // + // A function call node. + // + var Call = function (name, args, index, currentFileInfo) { + this.name = name; + this.args = args; + this.calc = name === 'calc'; + this._index = index; + this._fileInfo = currentFileInfo; + }; + Call.prototype = Object.assign(new Node(), { + type: 'Call', + accept: function (visitor) { + if (this.args) { + this.args = visitor.visitArray(this.args); + } + }, + // + // When evaluating a function call, + // we either find the function in the functionRegistry, + // in which case we call it, passing the evaluated arguments, + // if this returns null or we cannot find the function, we + // simply print it out as it appeared originally [2]. + // + // The reason why we evaluate the arguments, is in the case where + // we try to pass a variable to a function, like: `saturate(@color)`. + // The function should receive the value, not the variable. + // + eval: function (context) { + var _this = this; + /** + * Turn off math for calc(), and switch back on for evaluating nested functions + */ + var currentMathContext = context.mathOn; + context.mathOn = !this.calc; + if (this.calc || context.inCalc) { + context.enterCalc(); + } + var exitCalc = function () { + if (_this.calc || context.inCalc) { + context.exitCalc(); + } + context.mathOn = currentMathContext; + }; + var result; + var funcCaller = new functionCaller(this.name, context, this.getIndex(), this.fileInfo()); + if (funcCaller.isValid()) { + try { + result = funcCaller.call(this.args); + exitCalc(); + } + catch (e) { + if (e.hasOwnProperty('line') && e.hasOwnProperty('column')) { + throw e; + } + 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 !== 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; + } + var args = this.args.map(function (a) { return a.eval(context); }); + exitCalc(); + return new Call(this.name, args, this.getIndex(), this.fileInfo()); + }, + genCSS: function (context, output) { + output.add(this.name + "(", this.fileInfo(), this.getIndex()); + for (var i = 0; i < this.args.length; i++) { + this.args[i].genCSS(context, output); + if (i + 1 < this.args.length) { + output.add(', '); + } + } + output.add(')'); + } + }); + + var Variable = function (name, index, currentFileInfo) { + this.name = name; + this._index = index; + this._fileInfo = currentFileInfo; + }; + Variable.prototype = Object.assign(new Node(), { + type: 'Variable', + eval: function (context) { + var variable, name = this.name; + if (name.indexOf('@@') === 0) { + 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.fileInfo().filename, + index: this.getIndex() }; + } + this.evaluating = true; + variable = this.find(context.frames, function (frame) { + var v = frame.variable(name); + if (v) { + if (v.important) { + var importantScope = context.importantScope[context.importantScope.length - 1]; + importantScope.important = v.important; + } + // If in calc, wrap vars in a function call to cascade evaluate args first + if (context.inCalc) { + return (new Call('_SELF', [v.value])).eval(context); + } + else { + return v.value.eval(context); + } + } + }); + if (variable) { + this.evaluating = false; + return variable; + } + else { + throw { type: 'Name', + message: "variable " + name + " is undefined", + filename: this.fileInfo().filename, + index: this.getIndex() }; + } + }, + find: function (obj, fun) { + for (var i = 0, r = void 0; i < obj.length; i++) { + r = fun.call(obj, obj[i]); + if (r) { + return r; + } + } + return null; + } + }); + + var Property = function (name, index, currentFileInfo) { + this.name = name; + this._index = index; + this._fileInfo = currentFileInfo; + }; + Property.prototype = Object.assign(new Node(), { + type: 'Property', + eval: function (context) { + var property; + var 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; + var 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 }; + } + }, + find: function (obj, fun) { + for (var i = 0, r = void 0; i < obj.length; i++) { + r = fun.call(obj, obj[i]); + if (r) { + return r; + } + } + return null; + } + }); + + var Attribute = function (key, op, value) { + this.key = key; + this.op = op; + this.value = value; + }; + Attribute.prototype = Object.assign(new Node(), { + type: 'Attribute', + 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); + }, + genCSS: function (context, output) { + output.add(this.toCSS(context)); + }, + toCSS: function (context) { + var value = this.key.toCSS ? this.key.toCSS(context) : this.key; + if (this.op) { + value += this.op; + value += (this.value.toCSS ? this.value.toCSS(context) : this.value); + } + return "[" + value + "]"; + } + }); + + 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._fileInfo = currentFileInfo; + this.variableRegex = /@\{([\w-]+)\}/g; + this.propRegex = /\$\{([\w-]+)\}/g; + this.allowRoot = escaped; + }; + Quoted.prototype = Object.assign(new Node(), { + type: 'Quoted', + genCSS: function (context, output) { + if (!this.escaped) { + output.add(this.quote, this.fileInfo(), this.getIndex()); + } + output.add(this.value); + if (!this.escaped) { + output.add(this.quote); + } + }, + containsVariables: function () { + return this.value.match(this.variableRegex); + }, + eval: function (context) { + var that = this; + var value = this.value; + 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 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) { + var evaluatedValue = value; + do { + value = evaluatedValue.toString(); + evaluatedValue = value.replace(regexp, replacementFnc); + } while (value !== evaluatedValue); + return evaluatedValue; + } + value = iterativeReplace(value, this.variableRegex, variableReplacement); + value = iterativeReplace(value, this.propRegex, propertyReplacement); + return new Quoted(this.quote + value + this.quote, value, this.escaped, this.getIndex(), this.fileInfo()); + }, + compare: function (other) { + // when comparing quoted strings allow the quote to differ + if (other.type === 'Quoted' && !this.escaped && !other.escaped) { + return Node.numericCompare(this.value, other.value); + } + else { + return other.toCSS && this.toCSS() === other.toCSS() ? 0 : undefined; + } + } + }); + + function escapePath(path) { + return path.replace(/[\(\)'"\s]/g, function (match) { return "\\" + match; }); + } + var URL = function (val, index, currentFileInfo, isEvald) { + this.value = val; + this._index = index; + this._fileInfo = currentFileInfo; + this.isEvald = isEvald; + }; + URL.prototype = Object.assign(new Node(), { + type: 'Url', + accept: function (visitor) { + this.value = visitor.visit(this.value); + }, + genCSS: function (context, output) { + output.add('url('); + this.value.genCSS(context, output); + output.add(')'); + }, + eval: function (context) { + var val = this.value.eval(context); + var rootpath; + if (!this.isEvald) { + // Add the rootpath if the URL requires a rewrite + rootpath = this.fileInfo() && this.fileInfo().rootpath; + if (typeof rootpath === 'string' && + typeof val.value === 'string' && + context.pathRequiresRewrite(val.value)) { + if (!val.quote) { + rootpath = escapePath(rootpath); + } + val.value = context.rewritePath(val.value, rootpath); + } + else { + val.value = context.normalizePath(val.value); + } + // Add url args if enabled + if (context.urlArgs) { + if (!val.value.match(/^\s*data:/)) { + var delimiter = val.value.indexOf('?') === -1 ? '?' : '&'; + var urlArgs = delimiter + context.urlArgs; + if (val.value.indexOf('#') !== -1) { + val.value = val.value.replace('#', urlArgs + "#"); + } + else { + val.value += urlArgs; + } + } + } + } + return new URL(val, this.getIndex(), this.fileInfo(), true); + } + }); + + var Media = function (value, features, index, currentFileInfo, visibilityInfo) { + this._index = index; + this._fileInfo = currentFileInfo; + 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 = Object.assign(new AtRule(), { + type: 'Media', + isRulesetLike: function () { + return true; + }, + accept: function (visitor) { + if (this.features) { + this.features = visitor.visit(this.features); + } + if (this.rules) { + this.rules = visitor.visitArray(this.rules); + } + }, + genCSS: function (context, output) { + output.add('@media ', this._fileInfo, this._index); + this.features.genCSS(context, output); + this.outputRuleset(context, output, this.rules); + }, + eval: function (context) { + if (!context.mediaBlocks) { + context.mediaBlocks = []; + context.mediaPath = []; + } + var media = new Media(null, [], this._index, this._fileInfo, this.visibilityInfo()); + if (this.debugInfo) { + this.rules[0].debugInfo = this.debugInfo; + media.debugInfo = this.debugInfo; + } + media.features = this.features.eval(context); + context.mediaPath.push(media); + context.mediaBlocks.push(media); + this.rules[0].functionRegistry = context.frames[0].functionRegistry.inherit(); + context.frames.unshift(this.rules[0]); + media.rules = [this.rules[0].eval(context)]; + context.frames.shift(); + context.mediaPath.pop(); + return context.mediaPath.length === 0 ? media.evalTop(context) : + media.evalNested(context); + }, + evalTop: function (context) { + var result = this; + // Render all dependent Media blocks. + if (context.mediaBlocks.length > 1) { + 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; + delete context.mediaPath; + return result; + }, + evalNested: function (context) { + var i; + var value; + var path = context.mediaPath.concat([this]); + // Extract the media-query conditions separated with `,` (OR). + for (i = 0; i < path.length; i++) { + value = path[i].features instanceof Value ? + path[i].features.value : path[i].features; + path[i] = Array.isArray(value) ? value : [value]; + } + // Trace all permutations to generate the resulting media-query. // - // Examples: - // - If path of imported file is 'module/nav/nav.less' and rootpath is 'less/', - // then rootpath should become 'less/module/nav/' - // - If path of imported file is '../mixins.less' and rootpath is 'less/', - // then rootpath should become 'less/../' - - newFileInfo.currentDirectory = fileManager.getPath(resolvedFilename); - - if (newFileInfo.rewriteUrls) { - newFileInfo.rootpath = fileManager.join(importManager.context.rootpath || '', fileManager.pathDiff(newFileInfo.currentDirectory, newFileInfo.entryPath)); - - if (!fileManager.isPathAbsolute(newFileInfo.rootpath) && fileManager.alwaysMakePathsAbsolute()) { - newFileInfo.rootpath = fileManager.join(newFileInfo.entryPath, newFileInfo.rootpath); - } - } - - newFileInfo.filename = resolvedFilename; - var newEnv = new contexts.Parse(importManager.context); - newEnv.processImports = false; - importManager.contents[resolvedFilename] = contents; - - if (currentFileInfo.reference || importOptions.reference) { - newFileInfo.reference = true; - } - - 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 { - // 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; - var context = clone(this.context); - - if (tryAppendExtension) { - context.ext = importOptions.isPlugin ? '.js' : '.less'; - } - - if (importOptions.isPlugin) { - context.mime = 'application/javascript'; - 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; - }(); - - return ImportManager; - }); - - var Render = (function (environment, ParseTree, ImportManager) { - var render = function render(input, options, callback) { - if (typeof options === 'function') { - callback = options; - options = copyOptions(this.options, {}); - } else { - options = copyOptions(this.options, options || {}); - } - - if (!callback) { - var self = this; - return new Promise(function (resolve, reject) { - render.call(self, input, options, function (err, output) { - if (err) { - reject(err); - } else { - resolve(output); - } - }); - }); - } else { - this.parse(input, options, function (err, root, imports, options) { - if (err) { - return callback(err); - } - - var result; - - try { - var parseTree = new ParseTree(root, imports); - result = parseTree.toCSS(options); - } catch (err) { - return callback(err); - } - - callback(null, result); - }); - } - }; - - return render; - }); - - /** - * Plugin Manager - */ - var PluginManager = - /*#__PURE__*/ - function () { - function PluginManager(less) { - _classCallCheck(this, PluginManager); - - this.less = less; - this.visitors = []; - this.preProcessors = []; - this.postProcessors = []; - this.installedPlugins = []; - this.fileManagers = []; - this.iterator = -1; - this.pluginCache = {}; - this.Loader = new less.PluginLoader(less); - } - /** - * Adds all the plugins in the array - * @param {Array} plugins - */ - - - _createClass(PluginManager, [{ - key: "addPlugins", - value: function addPlugins(plugins) { - if (plugins) { - for (var i = 0; i < plugins.length; i++) { - this.addPlugin(plugins[i]); - } - } - } - /** - * - * @param plugin - * @param {String} filename - */ - - }, { - key: "addPlugin", - value: function addPlugin(plugin, filename, functionRegistry) { - this.installedPlugins.push(plugin); - - if (filename) { - this.pluginCache[filename] = plugin; - } - - if (plugin.install) { - plugin.install(this.less, this, functionRegistry || this.less.functions.functionRegistry); - } - } - /** - * - * @param filename - */ - - }, { - key: "get", - value: function get(filename) { - return this.pluginCache[filename]; - } - /** - * Adds a visitor. The visitor object has options on itself to determine - * when it should run. - * @param visitor - */ - - }, { - key: "addVisitor", - value: function addVisitor(visitor) { - this.visitors.push(visitor); - } - /** - * Adds a pre processor object - * @param {object} preProcessor - * @param {number} priority - guidelines 1 = before import, 1000 = import, 2000 = after import - */ - - }, { - key: "addPreProcessor", - value: function addPreProcessor(preProcessor, priority) { - var indexToInsertAt; - - for (indexToInsertAt = 0; indexToInsertAt < this.preProcessors.length; indexToInsertAt++) { - if (this.preProcessors[indexToInsertAt].priority >= priority) { - break; - } - } - - this.preProcessors.splice(indexToInsertAt, 0, { - preProcessor: preProcessor, - priority: priority - }); - } - /** - * Adds a post processor object - * @param {object} postProcessor - * @param {number} priority - guidelines 1 = before compression, 1000 = compression, 2000 = after compression - */ - - }, { - key: "addPostProcessor", - value: function addPostProcessor(postProcessor, priority) { - var indexToInsertAt; - - for (indexToInsertAt = 0; indexToInsertAt < this.postProcessors.length; indexToInsertAt++) { - if (this.postProcessors[indexToInsertAt].priority >= priority) { - break; - } - } - - this.postProcessors.splice(indexToInsertAt, 0, { - postProcessor: postProcessor, - priority: priority - }); - } - /** - * - * @param manager - */ - - }, { - key: "addFileManager", - value: function addFileManager(manager) { - this.fileManagers.push(manager); - } - /** - * - * @returns {Array} - * @private - */ - - }, { - key: "getPreProcessors", - value: function getPreProcessors() { - var preProcessors = []; - - for (var i = 0; i < this.preProcessors.length; i++) { - preProcessors.push(this.preProcessors[i].preProcessor); - } - - return preProcessors; - } - /** - * - * @returns {Array} - * @private - */ - - }, { - key: "getPostProcessors", - value: function getPostProcessors() { - var postProcessors = []; - - for (var i = 0; i < this.postProcessors.length; i++) { - postProcessors.push(this.postProcessors[i].postProcessor); - } - - return postProcessors; - } - /** - * - * @returns {Array} - * @private - */ - - }, { - key: "getVisitors", - value: function getVisitors() { - return this.visitors; - } - }, { - key: "visitor", - value: function visitor() { - var self = this; - return { - first: function first() { - self.iterator = -1; - return self.visitors[self.iterator]; - }, - get: function get() { - self.iterator += 1; - return self.visitors[self.iterator]; - } - }; - } - /** - * - * @returns {Array} - * @private - */ - - }, { - key: "getFileManagers", - value: function getFileManagers() { - return this.fileManagers; - } - }]); - - return PluginManager; - }(); - - var pm; - - function PluginManagerFactory(less, newFactory) { - if (newFactory || !pm) { - pm = new PluginManager(less); - } - - return pm; - } - - var Parse = (function (environment, ParseTree, ImportManager) { - var parse = function parse(input, options, callback) { - if (typeof options === 'function') { - callback = options; - options = copyOptions(this.options, {}); - } else { - options = copyOptions(this.options, options || {}); - } - - if (!callback) { - var self = this; - return new Promise(function (resolve, reject) { - parse.call(self, input, options, function (err, output) { - if (err) { - reject(err); - } else { - resolve(output); - } - }); - }); - } else { - var context; - var rootFileInfo; - var pluginManager = new PluginManagerFactory(this, !options.reUsePluginManager); - options.pluginManager = pluginManager; - context = new contexts.Parse(options); - - if (options.rootFileInfo) { - rootFileInfo = options.rootFileInfo; - } else { - var filename = options.filename || 'input'; - var entryPath = filename.replace(/[^\/\\]*$/, ''); - rootFileInfo = { - filename: filename, - rewriteUrls: context.rewriteUrls, - rootpath: context.rootpath || '', - currentDirectory: entryPath, - entryPath: entryPath, - rootFilename: filename - }; // add in a missing trailing slash - - if (rootFileInfo.rootpath && rootFileInfo.rootpath.slice(-1) !== '/') { - rootFileInfo.rootpath += '/'; - } - } - - 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; - var 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); - } - }; - - return parse; - }); - - var lessRoot = (function (environment$1, fileManagers) { - /** - * @todo - * This original code could be improved quite a bit. - * Many classes / modules currently add side-effects / mutations to passed in objects, - * which makes it hard to refactor and reason about. - */ - environment$1 = new environment(environment$1, fileManagers); - var SourceMapOutput = sourceMapOutput(environment$1); - var SourceMapBuilder = sourceMapBuilder(SourceMapOutput, environment$1); - var ParseTree = parseTree(SourceMapBuilder); - var ImportManager = importManager(environment$1); - var render = Render(environment$1, ParseTree); - var parse = Parse(environment$1, ParseTree, ImportManager); - var functions = Functions(environment$1); - /** - * @todo - * This root properties / methods need to be organized. - * It's not clear what should / must be public and why. - */ - - var initial = { - version: [3, 10, 3], - data: data, - tree: tree, - Environment: environment, - AbstractFileManager: AbstractFileManager, - AbstractPluginLoader: AbstractPluginLoader, - environment: environment$1, - visitors: visitors, - Parser: Parser, - functions: functions, - contexts: contexts, - SourceMapOutput: SourceMapOutput, - SourceMapBuilder: SourceMapBuilder, - ParseTree: ParseTree, - ImportManager: ImportManager, - render: render, - parse: parse, - LessError: LessError, - transformTree: transformTree, - utils: utils, - PluginManager: PluginManagerFactory, - logger: logger - }; // Create a public API - - var ctor = function ctor(t) { - return function () { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return _construct(t, args); - }; - }; - - var t; - var 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]); - } - } - } - - return api; - }); - - var options; - var logger$1; - var fileCache = {}; // TODOS - move log somewhere. pathDiff and doing something similar in node. use pathDiff in the other browser file for the initial load - - var FileManager = - /*#__PURE__*/ - function (_AbstractFileManager) { - _inherits(FileManager, _AbstractFileManager); - - function FileManager() { - _classCallCheck(this, FileManager); - - return _possibleConstructorReturn(this, _getPrototypeOf(FileManager).apply(this, arguments)); - } - - _createClass(FileManager, [{ - key: "alwaysMakePathsAbsolute", - value: function alwaysMakePathsAbsolute() { - return true; - } - }, { - key: "join", - value: function join(basePath, laterPath) { - if (!basePath) { - return laterPath; - } - - return this.extractUrlParts(laterPath, basePath).path; - } - }, { - key: "doXHR", - value: function doXHR(url, type, callback, errback) { - var xhr = new XMLHttpRequest(); - var async = options.isFileProtocol ? options.fileAsync : true; - - if (typeof xhr.overrideMimeType === 'function') { - xhr.overrideMimeType('text/css'); - } - - logger$1.debug("XHR: Getting '".concat(url, "'")); - xhr.open('GET', url, async); - xhr.setRequestHeader('Accept', type || 'text/x-less, text/css; q=0.9, */*; q=0.5'); - xhr.send(null); - - function handleResponse(xhr, callback, errback) { - if (xhr.status >= 200 && xhr.status < 300) { - callback(xhr.responseText, xhr.getResponseHeader('Last-Modified')); - } else if (typeof errback === 'function') { - errback(xhr.status, url); - } - } - - if (options.isFileProtocol && !options.fileAsync) { - if (xhr.status === 0 || xhr.status >= 200 && xhr.status < 300) { - callback(xhr.responseText); - } else { - errback(xhr.status, url); - } - } else if (async) { - xhr.onreadystatechange = function () { - if (xhr.readyState == 4) { - handleResponse(xhr, callback, errback); - } - }; - } else { - handleResponse(xhr, callback, errback); - } - } - }, { - key: "supports", - value: function supports() { - return true; - } - }, { - key: "clearFileCache", - value: function clearFileCache() { - fileCache = {}; - } - }, { - key: "loadFile", - value: 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; - 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() + // (a, b and c) with nested (d, e) -> + // a and d + // a and e + // b and c and d + // b and c and e + this.features = new Value(this.permute(path).map(function (path) { + path = path.map(function (fragment) { return fragment.toCSS ? fragment : new Anonymous(fragment); }); + for (i = path.length - 1; i > 0; i--) { + path.splice(i, 0, new Anonymous('and')); } - }); - } catch (e) { - return reject({ - filename: href, - message: "Error loading file ".concat(href, " error was ").concat(e.message) - }); + return new Expression(path); + })); + this.setParent(this.features, this); + // Fake a tree-node that doesn't output anything. + return new Ruleset([], []); + }, + permute: function (arr) { + if (arr.length === 0) { + return []; } - } + else if (arr.length === 1) { + return arr[0]; + } + else { + var result = []; + var rest = this.permute(arr.slice(1)); + for (var i = 0; i < rest.length; i++) { + for (var j = 0; j < arr[0].length; j++) { + result.push([arr[0][j]].concat(rest[i])); + } + } + return result; + } + }, + bubbleSelectors: function (selectors) { + if (!selectors) { + return; + } + this.rules = [new Ruleset(copyArray(selectors), [this.rules[0]])]; + this.setParent(this.rules, this); + } + }); - self.doXHR(href, options.mime, function doXHRCallback(data, lastModified) { - // per file cache - fileCache[href] = data; // Use remote copy (re-parse) + // + // CSS @import node + // + // The general strategy here is that we don't want to wait + // for the parsing to be completed, before we start importing + // the file. That's because in the context of a browser, + // most of the time will be spent waiting for the server to respond. + // + // On creation, we push the import path to our import queue, though + // `import,push`, we also pass it a callback, which it'll call once + // the file has been fetched, and parsed. + // + var Import = function (path, features, options, index, currentFileInfo, visibilityInfo) { + this.options = options; + this._index = index; + this._fileInfo = currentFileInfo; + this.path = path; + this.features = features; + 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)) { + this.css = true; + } + } + this.copyVisibilityInfo(visibilityInfo); + this.setParent(this.features, this); + this.setParent(this.path, this); + }; + Import.prototype = Object.assign(new Node(), { + type: 'Import', + accept: function (visitor) { + if (this.features) { + this.features = visitor.visit(this.features); + } + this.path = visitor.visit(this.path); + if (!this.options.isPlugin && !this.options.inline && this.root) { + this.root = visitor.visit(this.root); + } + }, + genCSS: function (context, output) { + 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(' '); + this.features.genCSS(context, output); + } + output.add(';'); + } + }, + getPath: function () { + return (this.path instanceof URL) ? + this.path.value.value : this.path.value; + }, + isVariableImport: function () { + var path = this.path; + if (path instanceof URL) { + path = path.value; + } + if (path instanceof Quoted) { + return path.containsVariables(); + } + return true; + }, + evalForImport: function (context) { + var path = this.path; + if (path instanceof URL) { + path = path.value; + } + return new Import(path.eval(context), this.features, this.options, this._index, this._fileInfo, this.visibilityInfo()); + }, + evalPath: function (context) { + var path = this.path.eval(context); + var fileInfo = this._fileInfo; + if (!(path instanceof URL)) { + // Add the rootpath if the URL requires a rewrite + var pathValue = path.value; + if (fileInfo && + pathValue && + context.pathRequiresRewrite(pathValue)) { + path.value = context.rewritePath(pathValue, fileInfo.rootpath); + } + else { + path.value = context.normalizePath(path.value); + } + } + return path; + }, + eval: function (context) { + var result = this.doEval(context); + if (this.options.reference || this.blocksVisibility()) { + if (result.length || result.length === 0) { + result.forEach(function (node) { + node.addVisibilityBlock(); + }); + } + else { + result.addVisibilityBlock(); + } + } + return result; + }, + doEval: function (context) { + var ruleset; + var registry; + var features = this.features && this.features.eval(context); + 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 []; + } + if (this.skip) { + if (typeof this.skip === 'function') { + this.skip = this.skip(); + } + if (this.skip) { + return []; + } + } + if (this.options.inline) { + var contents = new Anonymous(this.root, 0, { + 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); + if (!newImport.css && this.error) { + throw this.error; + } + return newImport; + } + else if (this.root) { + ruleset = new Ruleset(null, copyArray(this.root.rules)); + ruleset.evalImports(context); + return this.features ? new Media(ruleset.rules, this.features.value) : ruleset.rules; + } + else { + return []; + } + } + }); - resolve({ - contents: data, - filename: href, - webInfo: { - lastModified: lastModified - } + var JsEvalNode = function () { }; + JsEvalNode.prototype = Object.assign(new Node(), { + evaluateJavaScript: function (expression, context) { + var result; + var that = this; + var evalContext = {}; + 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.getIndex(), that.fileInfo()).eval(context)); }); - }, function doXHRError(status, url) { - reject({ - type: 'File', - message: "'".concat(url, "' wasn't found (").concat(status, ")"), - href: href + try { + expression = new Function("return (" + expression + ")"); + } + catch (e) { + throw { message: "JavaScript evaluation error: " + e.message + " from `" + expression + "`", + 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 */ + evalContext[k.slice(1)] = { + value: variables[k].value, + toJS: function () { + return this.value.eval(context).toCSS(); + } + }; + } + } + try { + result = expression.call(evalContext); + } + catch (e) { + throw { message: "JavaScript evaluation error: '" + e.name + ": " + e.message.replace(/["]/g, '\'') + "'", + filename: this.fileInfo().filename, + index: this.getIndex() }; + } + return result; + }, + jsify: function (obj) { + if (Array.isArray(obj.value) && (obj.value.length > 1)) { + return "[" + obj.value.map(function (v) { return v.toCSS(); }).join(', ') + "]"; + } + else { + return obj.toCSS(); + } + } + }); + + var JavaScript = function (string, escaped, index, currentFileInfo) { + this.escaped = escaped; + this.expression = string; + this._index = index; + this._fileInfo = currentFileInfo; + }; + JavaScript.prototype = Object.assign(new JsEvalNode(), { + type: 'JavaScript', + eval: function (context) { + var result = this.evaluateJavaScript(this.expression, context); + var type = typeof result; + if (type === 'number' && !isNaN(result)) { + return new Dimension(result); + } + else if (type === 'string') { + return new Quoted("\"" + result + "\"", result, this.escaped, this._index); + } + else if (Array.isArray(result)) { + return new Anonymous(result.join(', ')); + } + else { + return new Anonymous(result); + } + } + }); + + var Assignment = function (key, val) { + this.key = key; + this.value = val; + }; + Assignment.prototype = Object.assign(new Node(), { + type: 'Assignment', + accept: function (visitor) { + this.value = visitor.visit(this.value); + }, + eval: function (context) { + if (this.value.eval) { + return new Assignment(this.key, this.value.eval(context)); + } + return this; + }, + genCSS: function (context, output) { + output.add(this.key + "="); + if (this.value.genCSS) { + this.value.genCSS(context, output); + } + else { + output.add(this.value); + } + } + }); + + var Condition = function (op, l, r, i, negate) { + this.op = op.trim(); + this.lvalue = l; + this.rvalue = r; + this._index = i; + this.negate = negate; + }; + Condition.prototype = Object.assign(new Node(), { + type: 'Condition', + accept: function (visitor) { + this.lvalue = visitor.visit(this.lvalue); + this.rvalue = visitor.visit(this.rvalue); + }, + eval: function (context) { + var result = (function (op, a, b) { + switch (op) { + case 'and': return a && b; + case 'or': return a || b; + default: + switch (Node.compare(a, b)) { + case -1: + return op === '<' || op === '=<' || op === '<='; + case 0: + return op === '=' || op === '>=' || op === '=<' || op === '<='; + case 1: + return op === '>' || op === '>='; + default: + return false; + } + } + })(this.op, this.lvalue.eval(context), this.rvalue.eval(context)); + return this.negate ? !result : result; + } + }); + + var UnicodeDescriptor = function (value) { + this.value = value; + }; + UnicodeDescriptor.prototype = Object.assign(new Node(), { + type: 'UnicodeDescriptor' + }); + + var Negative = function (node) { + this.value = node; + }; + Negative.prototype = Object.assign(new Node(), { + type: 'Negative', + genCSS: function (context, output) { + output.add('-'); + this.value.genCSS(context, output); + }, + eval: function (context) { + if (context.isMathOn()) { + return (new Operation('*', [new Dimension(-1), this.value])).eval(context); + } + return new Negative(this.value.eval(context)); + } + }); + + var Extend = function (selector, option, index, currentFileInfo, visibilityInfo) { + this.selector = selector; + this.option = option; + this.object_id = Extend.next_id++; + this.parent_ids = [this.object_id]; + this._index = index; + this._fileInfo = currentFileInfo; + this.copyVisibilityInfo(visibilityInfo); + this.allowRoot = true; + switch (option) { + case 'all': + this.allowBefore = true; + this.allowAfter = true; + break; + default: + this.allowBefore = false; + this.allowAfter = false; + break; + } + this.setParent(this.selector, this); + }; + Extend.prototype = Object.assign(new Node(), { + type: 'Extend', + accept: function (visitor) { + this.selector = visitor.visit(this.selector); + }, + eval: function (context) { + return new Extend(this.selector.eval(context), this.option, this.getIndex(), this.fileInfo(), this.visibilityInfo()); + }, + clone: function (context) { + return new Extend(this.selector, this.option, this.getIndex(), this.fileInfo(), this.visibilityInfo()); + }, + // it concatenates (joins) all selectors in selector array + findSelfSelectors: function (selectors) { + var selfElements = [], i, selectorElements; + for (i = 0; i < selectors.length; i++) { + selectorElements = selectors[i].elements; + // duplicate the logic in genCSS function inside the selector node. + // future TODO - move both logics into the selector joiner visitor + if (i > 0 && selectorElements.length && selectorElements[0].combinator.value === '') { + selectorElements[0].combinator.value = ' '; + } + selfElements = selfElements.concat(selectors[i].elements); + } + this.selfSelectors = [new Selector(selfElements)]; + this.selfSelectors[0].copyVisibilityInfo(this.visibilityInfo()); + } + }); + Extend.next_id = 0; + + var VariableCall = function (variable, index, currentFileInfo) { + this.variable = variable; + this._index = index; + this._fileInfo = currentFileInfo; + this.allowRoot = true; + }; + VariableCall.prototype = Object.assign(new Node(), { + type: 'VariableCall', + eval: function (context) { + var rules; + var detachedRuleset = new Variable(this.variable, this.getIndex(), this.fileInfo()).eval(context); + var error = new LessError({ message: "Could not evaluate variable call " + this.variable }); + if (!detachedRuleset.ruleset) { + if (detachedRuleset.rules) { + rules = detachedRuleset; + } + else if (Array.isArray(detachedRuleset)) { + rules = new Ruleset('', detachedRuleset); + } + else if (Array.isArray(detachedRuleset.value)) { + rules = new Ruleset('', detachedRuleset.value); + } + else { + throw error; + } + detachedRuleset = new DetachedRuleset(rules); + } + if (detachedRuleset.ruleset) { + return detachedRuleset.callEval(context); + } + throw error; + } + }); + + var NamespaceValue = function (ruleCall, lookups, index, fileInfo) { + this.value = ruleCall; + this.lookups = lookups; + this._index = index; + this._fileInfo = fileInfo; + }; + NamespaceValue.prototype = Object.assign(new Node(), { + type: 'NamespaceValue', + eval: function (context) { + var i, name, rules = this.value.eval(context); + for (i = 0; i < this.lookups.length; i++) { + name = this.lookups[i]; + /** + * Eval'd DRs return rulesets. + * Eval'd mixins return rules, so let's make a ruleset if we need it. + * We need to do this because of late parsing of values + */ + if (Array.isArray(rules)) { + rules = new Ruleset([new Selector()], rules); + } + if (name === '') { + rules = rules.lastDeclaration(); + } + else if (name.charAt(0) === '@') { + if (name.charAt(1) === '@') { + name = "@" + new Variable(name.substr(1)).eval(context).value; + } + if (rules.variables) { + rules = rules.variable(name); + } + if (!rules) { + throw { type: 'Name', + message: "variable " + name + " not found", + filename: this.fileInfo().filename, + index: this.getIndex() }; + } + } + else { + if (name.substring(0, 2) === '$@') { + name = "$" + new Variable(name.substr(1)).eval(context).value; + } + else { + name = name.charAt(0) === '$' ? name : "$" + name; + } + if (rules.properties) { + rules = rules.property(name); + } + if (!rules) { + throw { type: 'Name', + message: "property \"" + name.substr(1) + "\" not found", + filename: this.fileInfo().filename, + index: this.getIndex() }; + } + // Properties are an array of values, since a ruleset can have multiple props. + // We pick the last one (the "cascaded" value) + rules = rules[rules.length - 1]; + } + if (rules.value) { + rules = rules.eval(context).value; + } + if (rules.ruleset) { + rules = rules.ruleset.eval(context); + } + } + return rules; + } + }); + + var Definition = function (name, params, rules, condition, variadic, frames, visibilityInfo) { + this.name = name || 'anonymous mixin'; + this.selectors = [new Selector([new Element(null, name, false, this._index, this._fileInfo)])]; + this.params = params; + this.condition = condition; + this.variadic = variadic; + this.arity = params.length; + this.rules = rules; + this._lookups = {}; + var optionalParameters = []; + this.required = params.reduce(function (count, p) { + if (!p.name || (p.name && !p.value)) { + return count + 1; + } + else { + optionalParameters.push(p.name); + return count; + } + }, 0); + this.optionalParameters = optionalParameters; + this.frames = frames; + this.copyVisibilityInfo(visibilityInfo); + this.allowRoot = true; + }; + Definition.prototype = Object.assign(new Ruleset(), { + type: 'MixinDefinition', + evalFirst: true, + accept: function (visitor) { + if (this.params && this.params.length) { + this.params = visitor.visitArray(this.params); + } + this.rules = visitor.visitArray(this.rules); + if (this.condition) { + this.condition = visitor.visit(this.condition); + } + }, + evalParams: function (context, mixinEnv, args, evaldArguments) { + /* jshint boss:true */ + var frame = new Ruleset(null, null); + var varargs; + var arg; + var params = copyArray(this.params); + var i; + var j; + var val; + var name; + var isNamedFound; + var argIndex; + var argsLength = 0; + if (mixinEnv.frames && mixinEnv.frames[0] && mixinEnv.frames[0].functionRegistry) { + frame.functionRegistry = mixinEnv.frames[0].functionRegistry.inherit(); + } + mixinEnv = new contexts.Eval(mixinEnv, [frame].concat(mixinEnv.frames)); + if (args) { + args = copyArray(args); + argsLength = args.length; + for (i = 0; i < argsLength; i++) { + arg = args[i]; + if (name = (arg && arg.name)) { + isNamedFound = false; + for (j = 0; j < params.length; j++) { + if (!evaldArguments[j] && name === params[j].name) { + evaldArguments[j] = arg.value.eval(context); + frame.prependRule(new Declaration(name, arg.value.eval(context))); + isNamedFound = true; + break; + } + } + if (isNamedFound) { + args.splice(i, 1); + i--; + continue; + } + else { + throw { type: 'Runtime', message: "Named argument for " + this.name + " " + args[i].name + " not found" }; + } + } + } + } + argIndex = 0; + for (i = 0; i < params.length; i++) { + if (evaldArguments[i]) { + continue; + } + arg = args && args[argIndex]; + if (name = params[i].name) { + if (params[i].variadic) { + varargs = []; + for (j = argIndex; j < argsLength; j++) { + varargs.push(args[j].value.eval(context)); + } + frame.prependRule(new Declaration(name, new Expression(varargs).eval(context))); + } + else { + val = arg && arg.value; + if (val) { + // This was a mixin call, pass in a detached ruleset of it's eval'd rules + if (Array.isArray(val)) { + val = new DetachedRuleset(new Ruleset('', val)); + } + else { + val = val.eval(context); + } + } + else if (params[i].value) { + val = params[i].value.eval(mixinEnv); + frame.resetCache(); + } + else { + throw { type: 'Runtime', message: "wrong number of arguments for " + this.name + " (" + argsLength + " for " + this.arity + ")" }; + } + frame.prependRule(new Declaration(name, val)); + evaldArguments[i] = val; + } + } + if (params[i].variadic && args) { + for (j = argIndex; j < argsLength; j++) { + evaldArguments[j] = args[j].value.eval(context); + } + } + argIndex++; + } + return frame; + }, + makeImportant: function () { + var rules = !this.rules ? this.rules : this.rules.map(function (r) { + if (r.makeImportant) { + return r.makeImportant(true); + } + else { + return r; + } }); - }); - }); - } - }]); - - return FileManager; - }(AbstractFileManager); - - var FM = (function (opts, log) { - options = opts; - logger$1 = log; - return FileManager; - }); - - /** - * Browser Plugin Loader - */ - - var PluginLoader = - /*#__PURE__*/ - function (_AbstractPluginLoader) { - _inherits(PluginLoader, _AbstractPluginLoader); - - function PluginLoader(less) { - var _this; - - _classCallCheck(this, PluginLoader); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(PluginLoader).call(this)); - _this.less = less; // Should we shim this.require for browser? Probably not? - - return _this; - } - - _createClass(PluginLoader, [{ - key: "loadPlugin", - value: function loadPlugin(filename, basePath, context, environment, fileManager) { - return new Promise(function (fulfill, reject) { - fileManager.loadFile(filename, basePath, context, environment).then(fulfill).catch(reject); - }); - } - }]); - - return PluginLoader; - }(AbstractPluginLoader); - - var LogListener = (function (less, options) { - var logLevel_debug = 4; - var logLevel_info = 3; - var logLevel_warn = 2; - var logLevel_error = 1; // The amount of logging in the javascript console. - // 3 - Debug, information and errors - // 2 - Information and errors - // 1 - Errors - // 0 - None - // Defaults to 2 - - options.logLevel = typeof options.logLevel !== 'undefined' ? options.logLevel : options.env === 'development' ? logLevel_info : logLevel_error; - - if (!options.loggers) { - options.loggers = [{ - debug: function debug(msg) { - if (options.logLevel >= logLevel_debug) { - console.log(msg); - } + var result = new Definition(this.name, this.params, rules, this.condition, this.variadic, this.frames); + return result; }, - info: function info(msg) { - if (options.logLevel >= logLevel_info) { - console.log(msg); - } + eval: function (context) { + return new Definition(this.name, this.params, this.rules, this.condition, this.variadic, this.frames || copyArray(context.frames)); }, - warn: function warn(msg) { - if (options.logLevel >= logLevel_warn) { - console.warn(msg); - } + evalCall: function (context, args, important) { + var _arguments = []; + var mixinFrames = this.frames ? this.frames.concat(context.frames) : context.frames; + var frame = this.evalParams(context, new contexts.Eval(context, mixinFrames), args, _arguments); + var rules; + var ruleset; + frame.prependRule(new Declaration('@arguments', new Expression(_arguments).eval(context))); + rules = copyArray(this.rules); + ruleset = new Ruleset(null, rules); + ruleset.originalRuleset = this; + ruleset = ruleset.eval(new contexts.Eval(context, [this, frame].concat(mixinFrames))); + if (important) { + ruleset = ruleset.makeImportant(); + } + return ruleset; }, - error: function error(msg) { - if (options.logLevel >= logLevel_error) { - console.error(msg); - } - } - }]; - } - - for (var i = 0; i < options.loggers.length; i++) { - less.logger.addListener(options.loggers[i]); - } - }); - - var ErrorReporting = (function (window, less, options) { - function errorHTML(e, rootHref) { - var id = "less-error-message:".concat(extractId(rootHref || '')); - var template = '
  • {content}
  • '; - var elem = window.document.createElement('div'); - var timer; - var content; - var errors = []; - var filename = e.filename || rootHref; - var filenameNoPath = filename.match(/([^\/]+(\?.*)?)$/)[1]; - elem.id = id; - elem.className = 'less-error-message'; - content = "

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

    in ").concat(filenameNoPath, " "); - - var errorline = function errorline(e, i, classname) { - if (e.extract[i] !== undefined) { - errors.push(template.replace(/\{line\}/, (parseInt(e.line, 10) || 0) + (i - 1)).replace(/\{class\}/, classname).replace(/\{content\}/, e.extract[i])); - } - }; - - if (e.line) { - errorline(e, 0, ''); - errorline(e, 1, 'line'); - errorline(e, 2, ''); - content += "on line ".concat(e.line, ", column ").concat(e.column + 1, ":

      ").concat(errors.join(''), "
    "); - } - - if (e.stack && (e.extract || options.logLevel >= 4)) { - content += "
    Stack Trace
    ".concat(e.stack.split('\n').slice(1).join('
    ')); - } - - elem.innerHTML = content; // CSS for error messages - - browser.createCSS(window.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' - }); - elem.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(';'); - - if (options.env === 'development') { - timer = setInterval(function () { - var document = window.document; - var body = document.body; - - if (body) { - if (document.getElementById(id)) { - body.replaceChild(elem, document.getElementById(id)); - } else { - body.insertBefore(elem, body.firstChild); + matchCondition: function (args, context) { + if (this.condition && !this.condition.eval(new contexts.Eval(context, [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 + return false; } - - clearInterval(timer); - } - }, 10); - } - } - - function removeErrorHTML(path) { - var node = window.document.getElementById("less-error-message:".concat(extractId(path))); - - if (node) { - node.parentNode.removeChild(node); - } - } - - function removeError(path) { - if (!options.errorReporting || options.errorReporting === 'html') { - removeErrorHTML(path); - } else if (options.errorReporting === 'console') ; else if (typeof options.errorReporting === 'function') { - options.errorReporting('remove', path); - } - } - - function errorConsole(e, rootHref) { - var template = '{line} {content}'; - var filename = e.filename || rootHref; - var errors = []; - var content = "".concat(e.type || 'Syntax', "Error: ").concat(e.message || 'There is an error in your .less file', " in ").concat(filename); - - var errorline = function errorline(e, i, classname) { - if (e.extract[i] !== undefined) { - errors.push(template.replace(/\{line\}/, (parseInt(e.line, 10) || 0) + (i - 1)).replace(/\{class\}/, classname).replace(/\{content\}/, e.extract[i])); - } - }; - - if (e.line) { - errorline(e, 0, ''); - errorline(e, 1, 'line'); - errorline(e, 2, ''); - content += " on line ".concat(e.line, ", column ").concat(e.column + 1, ":\n").concat(errors.join('\n')); - } - - if (e.stack && (e.extract || options.logLevel >= 4)) { - content += "\nStack Trace\n".concat(e.stack); - } - - less.logger.error(content); - } - - function error(e, rootHref) { - if (!options.errorReporting || options.errorReporting === 'html') { - errorHTML(e, rootHref); - } else if (options.errorReporting === 'console') { - errorConsole(e, rootHref); - } else if (typeof options.errorReporting === 'function') { - options.errorReporting('add', e, rootHref); - } - } - - return { - add: error, - remove: removeError - }; - }); - - // Cache system is a bit outdated and could do with work - var Cache = (function (window, options, logger) { - var cache = null; - - if (options.env !== 'development') { - try { - cache = typeof window.localStorage === 'undefined' ? null : window.localStorage; - } catch (_) {} - } - - return { - setCSS: function setCSS(path, lastModified, modifyVars, styles) { - if (cache) { - logger.info("saving ".concat(path, " to cache.")); - - try { - cache.setItem(path, styles); - cache.setItem("".concat(path, ":timestamp"), lastModified); - - if (modifyVars) { - cache.setItem("".concat(path, ":vars"), JSON.stringify(modifyVars)); + return true; + }, + matchArgs: function (args, context) { + var allArgsCnt = (args && args.length) || 0; + var len; + var optionalParameters = this.optionalParameters; + var requiredArgsCnt = !args ? 0 : args.reduce(function (count, p) { + if (optionalParameters.indexOf(p.name) < 0) { + return count + 1; + } + else { + return count; + } + }, 0); + if (!this.variadic) { + if (requiredArgsCnt < this.required) { + return false; + } + if (allArgsCnt > this.params.length) { + return false; + } } - } catch (e) { - // TODO - could do with adding more robust error handling - logger.error("failed to save \"".concat(path, "\" to local storage for caching.")); - } - } - }, - getCSS: function getCSS(path, webInfo, modifyVars) { - var css = cache && cache.getItem(path); - var timestamp = cache && cache.getItem("".concat(path, ":timestamp")); - var vars = cache && cache.getItem("".concat(path, ":vars")); - modifyVars = modifyVars || {}; - vars = vars || "{}"; // if not set, treat as the JSON representation of an empty object - - if (timestamp && webInfo.lastModified && new Date(webInfo.lastModified).valueOf() === new Date(timestamp).valueOf() && JSON.stringify(modifyVars) === vars) { - // Use local copy - return css; - } - } - }; - }); - - var ImageSize = (function () { - function _imageSize() { - throw { - type: 'Runtime', - message: 'Image size functions are not supported in browser version of less' - }; - } - - var imageFunctions = { - 'image-size': function imageSize(filePathNode) { - _imageSize(); - - return -1; - }, - 'image-width': function imageWidth(filePathNode) { - _imageSize(); - - return -1; - }, - 'image-height': function imageHeight(filePathNode) { - _imageSize(); - - return -1; - } - }; - functionRegistry.addMultiple(imageFunctions); - }); - - // - var root = (function (window, options) { - var document = window.document; - var less = lessRoot(); - less.options = options; - var environment = less.environment; - var FileManager = FM(options, less.logger); - var fileManager = new FileManager(); - environment.addFileManager(fileManager); - less.FileManager = FileManager; - less.PluginLoader = PluginLoader; - LogListener(less, options); - var errors = ErrorReporting(window, less, options); - var cache = less.cache = options.cache || Cache(window, options, less.logger); - ImageSize(less.environment); // Setup user functions - Deprecate? - - if (options.functions) { - less.functions.functionRegistry.addMultiple(options.functions); - } - - var typePattern = /^text\/(x-)?less$/; - - function clone(obj) { - var cloned = {}; - - for (var prop in obj) { - if (obj.hasOwnProperty(prop)) { - cloned[prop] = obj[prop]; - } - } - - return cloned; - } // only really needed for phantom - - - function bind(func, thisArg) { - var curryArgs = Array.prototype.slice.call(arguments, 2); - return function () { - var args = curryArgs.concat(Array.prototype.slice.call(arguments, 0)); - return func.apply(thisArg, args); - }; - } - - function loadStyles(modifyVars) { - var styles = document.getElementsByTagName('style'); - var style; - - for (var i = 0; i < styles.length; i++) { - style = styles[i]; - - if (style.type.match(typePattern)) { - var instanceOptions = clone(options); - instanceOptions.modifyVars = modifyVars; - var lessText = style.innerHTML || ''; - instanceOptions.filename = document.location.href.replace(/#.*$/, ''); - /* jshint loopfunc:true */ - // use closure to store current style - - less.render(lessText, instanceOptions, bind(function (style, e, result) { - if (e) { - errors.add(e, 'inline'); - } else { - style.type = 'text/css'; - - if (style.styleSheet) { - style.styleSheet.cssText = result.css; - } else { - style.innerHTML = result.css; - } + else { + if (requiredArgsCnt < (this.required - 1)) { + return false; + } } - }, null, style)); + // check patterns + len = Math.min(requiredArgsCnt, this.arity); + for (var i = 0; i < len; i++) { + if (!this.params[i].name && !this.params[i].variadic) { + if (args[i].value.eval(context).toCSS() != this.params[i].value.eval(context).toCSS()) { + return false; + } + } + } + return true; } - } - } + }); - function loadStyleSheet(sheet, callback, reload, remaining, modifyVars) { - var instanceOptions = clone(options); - addDataAttr(instanceOptions, sheet); - instanceOptions.mime = sheet.type; + var MixinCall = function (elements, args, index, currentFileInfo, important) { + this.selector = new Selector(elements); + this.arguments = args || []; + this._index = index; + this._fileInfo = currentFileInfo; + this.important = important; + this.allowRoot = true; + this.setParent(this.selector, this); + }; + MixinCall.prototype = Object.assign(new Node(), { + type: 'MixinCall', + accept: function (visitor) { + if (this.selector) { + this.selector = visitor.visit(this.selector); + } + if (this.arguments.length) { + this.arguments = visitor.visitArray(this.arguments); + } + }, + eval: function (context) { + var mixins; + var mixin; + var mixinPath; + var args = []; + var arg; + var argValue; + var rules = []; + var match = false; + var i; + var m; + var f; + var isRecursive; + var isOneFound; + var candidates = []; + var candidate; + var conditionResult = []; + var defaultResult; + var defFalseEitherCase = -1; + var defNone = 0; + var defTrue = 1; + var defFalse = 2; + var count; + var originalRuleset; + var noArgumentsFilter; + this.selector = this.selector.eval(context); + function calcDefGroup(mixin, mixinPath) { + var f, p, namespace; + for (f = 0; f < 2; f++) { + conditionResult[f] = true; + defaultFunc.value(f); + for (p = 0; p < mixinPath.length && conditionResult[f]; p++) { + namespace = mixinPath[p]; + if (namespace.matchCondition) { + conditionResult[f] = conditionResult[f] && namespace.matchCondition(null, context); + } + } + if (mixin.matchCondition) { + conditionResult[f] = conditionResult[f] && mixin.matchCondition(args, context); + } + } + if (conditionResult[0] || conditionResult[1]) { + if (conditionResult[0] != conditionResult[1]) { + return conditionResult[1] ? + defTrue : defFalse; + } + return defNone; + } + return defFalseEitherCase; + } + for (i = 0; i < this.arguments.length; i++) { + arg = this.arguments[i]; + argValue = arg.value.eval(context); + if (arg.expand && Array.isArray(argValue.value)) { + argValue = argValue.value; + for (m = 0; m < argValue.length; m++) { + args.push({ value: argValue[m] }); + } + } + else { + args.push({ name: arg.name, value: argValue }); + } + } + noArgumentsFilter = function (rule) { return rule.matchArgs(null, context); }; + for (i = 0; i < context.frames.length; i++) { + if ((mixins = context.frames[i].find(this.selector, null, noArgumentsFilter)).length > 0) { + isOneFound = true; + // To make `default()` function independent of definition order we have two "subpasses" here. + // At first we evaluate each guard *twice* (with `default() == true` and `default() == false`), + // and build candidate list with corresponding flags. Then, when we know all possible matches, + // we make a final decision. + for (m = 0; m < mixins.length; m++) { + mixin = mixins[m].rule; + mixinPath = mixins[m].path; + isRecursive = false; + for (f = 0; f < context.frames.length; f++) { + if ((!(mixin instanceof Definition)) && mixin === (context.frames[f].originalRuleset || context.frames[f])) { + isRecursive = true; + break; + } + } + if (isRecursive) { + continue; + } + if (mixin.matchArgs(args, context)) { + candidate = { mixin: mixin, group: calcDefGroup(mixin, mixinPath) }; + if (candidate.group !== defFalseEitherCase) { + candidates.push(candidate); + } + match = true; + } + } + defaultFunc.reset(); + count = [0, 0, 0]; + for (m = 0; m < candidates.length; m++) { + count[candidates[m].group]++; + } + if (count[defNone] > 0) { + defaultResult = defFalse; + } + else { + defaultResult = defTrue; + if ((count[defTrue] + count[defFalse]) > 1) { + throw { type: 'Runtime', + message: "Ambiguous use of `default()` found when matching for `" + this.format(args) + "`", + index: this.getIndex(), filename: this.fileInfo().filename }; + } + } + for (m = 0; m < candidates.length; m++) { + candidate = candidates[m].group; + if ((candidate === defNone) || (candidate === defaultResult)) { + try { + mixin = candidates[m].mixin; + if (!(mixin instanceof Definition)) { + originalRuleset = mixin.originalRuleset || mixin; + mixin = new Definition('', [], mixin.rules, null, false, null, originalRuleset.visibilityInfo()); + mixin.originalRuleset = originalRuleset; + } + var newRules = mixin.evalCall(context, args, this.important).rules; + this._setVisibilityToReplacement(newRules); + Array.prototype.push.apply(rules, newRules); + } + catch (e) { + throw { message: e.message, index: this.getIndex(), filename: this.fileInfo().filename, stack: e.stack }; + } + } + } + if (match) { + return rules; + } + } + } + if (isOneFound) { + throw { type: 'Runtime', + message: "No matching definition was found for `" + this.format(args) + "`", + index: this.getIndex(), filename: this.fileInfo().filename }; + } + else { + throw { type: 'Name', + message: this.selector.toCSS().trim() + " is undefined", + index: this.getIndex(), filename: this.fileInfo().filename }; + } + }, + _setVisibilityToReplacement: function (replacement) { + var i, rule; + if (this.blocksVisibility()) { + for (i = 0; i < replacement.length; i++) { + rule = replacement[i]; + rule.addVisibilityBlock(); + } + } + }, + format: function (args) { + return this.selector.toCSS().trim() + "(" + (args ? args.map(function (a) { + var argValue = ''; + if (a.name) { + argValue += a.name + ":"; + } + if (a.value.toCSS) { + argValue += a.value.toCSS(); + } + else { + argValue += '???'; + } + return argValue; + }).join(', ') : '') + ")"; + } + }); - if (modifyVars) { - instanceOptions.modifyVars = modifyVars; - } + var tree = { + Node: Node, + Color: Color, + AtRule: AtRule, + DetachedRuleset: DetachedRuleset, + Operation: Operation, + Dimension: Dimension, + Unit: Unit, + Keyword: Keyword, + Variable: Variable, + Property: Property, + Ruleset: Ruleset, + Element: Element, + Attribute: Attribute, + Combinator: Combinator, + Selector: Selector, + Quoted: Quoted, + Expression: Expression, + Declaration: Declaration, + Call: Call, + URL: URL, + Import: Import, + Comment: Comment, + Anonymous: Anonymous, + Value: Value, + JavaScript: JavaScript, + Assignment: Assignment, + Condition: Condition, + Paren: Paren, + Media: Media, + UnicodeDescriptor: UnicodeDescriptor, + Negative: Negative, + Extend: Extend, + VariableCall: VariableCall, + NamespaceValue: NamespaceValue, + mixin: { + Call: MixinCall, + Definition: Definition + } + }; - function loadInitialFileCallback(loadedFile) { - var data = loadedFile.contents; - var path = loadedFile.filename; - var webInfo = loadedFile.webInfo; - var newFileInfo = { - currentDirectory: fileManager.getPath(path), - filename: path, - rootFilename: path, - rewriteUrls: instanceOptions.rewriteUrls + var AbstractFileManager = /** @class */ (function () { + function AbstractFileManager() { + } + AbstractFileManager.prototype.getPath = function (filename) { + var j = filename.lastIndexOf('?'); + if (j > 0) { + filename = filename.slice(0, j); + } + j = filename.lastIndexOf('/'); + if (j < 0) { + j = filename.lastIndexOf('\\'); + } + if (j < 0) { + return ''; + } + return filename.slice(0, j + 1); }; - newFileInfo.entryPath = newFileInfo.currentDirectory; - newFileInfo.rootpath = instanceOptions.rootpath || newFileInfo.currentDirectory; + AbstractFileManager.prototype.tryAppendExtension = function (path, ext) { + return /(\.[a-z]*$)|([\?;].*)$/.test(path) ? path : path + ext; + }; + AbstractFileManager.prototype.tryAppendLessExtension = function (path) { + return this.tryAppendExtension(path, '.less'); + }; + AbstractFileManager.prototype.supportsSync = function () { + return false; + }; + AbstractFileManager.prototype.alwaysMakePathsAbsolute = function () { + return false; + }; + 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 (url, baseUrl) { + // diff between two paths to create a relative path + var urlParts = this.extractUrlParts(url); + var baseUrlParts = this.extractUrlParts(baseUrl); + var i; + var max; + var urlDirectories; + var baseUrlDirectories; + var diff = ''; + if (urlParts.hostPart !== baseUrlParts.hostPart) { + return ''; + } + max = Math.max(baseUrlParts.directories.length, urlParts.directories.length); + for (i = 0; i < max; i++) { + if (baseUrlParts.directories[i] !== urlParts.directories[i]) { + break; + } + } + baseUrlDirectories = baseUrlParts.directories.slice(i); + urlDirectories = urlParts.directories.slice(i); + for (i = 0; i < baseUrlDirectories.length - 1; i++) { + diff += '../'; + } + for (i = 0; i < urlDirectories.length - 1; i++) { + diff += urlDirectories[i] + "/"; + } + return diff; + }; + // helper function, not part of API + AbstractFileManager.prototype.extractUrlParts = function (url, baseUrl) { + // urlParts[1] = protocol://hostname/ OR / + // urlParts[2] = / if path relative to host base + // urlParts[3] = directories + // urlParts[4] = filename + // urlParts[5] = parameters + var urlPartsRegex = /^((?:[a-z-]+:)?\/{2}(?:[^\/\?#]*\/)|([\/\\]))?((?:[^\/\\\?#]*[\/\\])*)([^\/\\\?#]*)([#\?].*)?$/i; + var urlParts = url.match(urlPartsRegex); + var returner = {}; + var rawDirectories = []; + var directories = []; + var i; + var baseUrlParts; + if (!urlParts) { + throw new Error("Could not parse sheet href - '" + url + "'"); + } + // Stylesheets in IE don't always return the full path + if (baseUrl && (!urlParts[1] || urlParts[2])) { + baseUrlParts = baseUrl.match(urlPartsRegex); + if (!baseUrlParts) { + throw new Error("Could not parse page url - '" + baseUrl + "'"); + } + urlParts[1] = urlParts[1] || baseUrlParts[1] || ''; + if (!urlParts[2]) { + urlParts[3] = baseUrlParts[3] + urlParts[3]; + } + } + if (urlParts[3]) { + rawDirectories = urlParts[3].replace(/\\/g, '/').split('/'); + // collapse '..' and skip '.' + for (i = 0; i < rawDirectories.length; i++) { + 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; + }; + return AbstractFileManager; + }()); - if (webInfo) { - webInfo.remaining = remaining; - var css = cache.getCSS(path, webInfo, instanceOptions.modifyVars); - - if (!reload && css) { - webInfo.local = true; - callback(null, css, data, sheet, webInfo, path); - return; - } - } // TODO add tests around how this behaves when reloading - - - errors.remove(path); - instanceOptions.rootFileInfo = newFileInfo; - less.render(data, instanceOptions, function (e, result) { - if (e) { - e.href = path; - callback(e); - } else { - 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).then(function (loadedFile) { - loadInitialFileCallback(loadedFile); - }).catch(function (err) { - console.log(err); - callback(err); - }); - } - - function loadStyleSheets(callback, reload, modifyVars) { - for (var i = 0; i < less.sheets.length; i++) { - loadStyleSheet(less.sheets[i], callback, reload, less.sheets.length - (i + 1), modifyVars); - } - } - - function initRunningMode() { - if (less.env === 'development') { - less.watchTimer = setInterval(function () { - if (less.watchMode) { - fileManager.clearFileCache(); - loadStyleSheets(function (e, css, _, sheet, webInfo) { - if (e) { - errors.add(e, e.href || sheet.href); - } else if (css) { - browser.createCSS(window.document, css, sheet); - } - }); - } - }, options.poll); - } - } // - // Watch mode - // - - - less.watch = function () { - if (!less.watchMode) { - less.env = 'development'; - initRunningMode(); - } - - this.watchMode = true; - return true; - }; - - less.unwatch = function () { - clearInterval(less.watchTimer); - this.watchMode = false; - return false; - }; // - // Synchronously get all tags with the 'rel' attribute set to - // "stylesheet/less". - // - - - less.registerStylesheetsImmediately = function () { - var links = document.getElementsByTagName('link'); - less.sheets = []; - - for (var i = 0; i < links.length; i++) { - if (links[i].rel === 'stylesheet/less' || links[i].rel.match(/stylesheet/) && links[i].type.match(typePattern)) { - less.sheets.push(links[i]); + var AbstractPluginLoader = /** @class */ (function () { + function AbstractPluginLoader() { + // Implemented by Node.js plugin loader + this.require = function () { + return null; + }; } - } - }; // - // Asynchronously get all tags with the 'rel' attribute set to - // "stylesheet/less", returning a Promise. - // + AbstractPluginLoader.prototype.evalPlugin = function (contents, context, imports, pluginOptions, fileInfo) { + var loader, registry, pluginObj, localModule, pluginManager, filename, result; + 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) { + result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions); + if (result) { + return result; + } + try { + if (pluginObj.use) { + pluginObj.use.call(this.context, pluginObj); + } + } + catch (e) { + e.message = e.message || 'Error during @plugin call'; + return new 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(filename), registerPlugin, registry, this.less.tree, this.less, fileInfo); + } + catch (e) { + return new LessError(e, imports, filename); + } + if (!pluginObj) { + pluginObj = localModule.exports; + } + pluginObj = this.validatePlugin(pluginObj, filename, shortname); + if (pluginObj instanceof LessError) { + return pluginObj; + } + if (pluginObj) { + pluginObj.imports = imports; + pluginObj.filename = filename; + // For < 3.x (or unspecified minVersion) - setOptions() before install() + if (!pluginObj.minVersion || this.compareVersion('3.0.0', pluginObj.minVersion) < 0) { + result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions); + if (result) { + return result; + } + } + // Run on first load + pluginManager.addPlugin(pluginObj, fileInfo.filename, registry); + pluginObj.functions = registry.getLocalFunctions(); + // Need to call setOptions again because the pluginObj might have functions + result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions); + if (result) { + return result; + } + // Run every @plugin call + try { + if (pluginObj.use) { + pluginObj.use.call(this.context, pluginObj); + } + } + catch (e) { + e.message = e.message || 'Error during @plugin call'; + return new LessError(e, imports, filename); + } + } + else { + return new LessError({ message: 'Not a valid plugin' }, imports, filename); + } + return pluginObj; + }; + AbstractPluginLoader.prototype.trySetOptions = function (plugin, filename, name, options) { + if (options && !plugin.setOptions) { + return new LessError({ + message: "Options have been provided but the plugin " + name + " does not support any options." + }); + } + try { + plugin.setOptions && plugin.setOptions(options); + } + catch (e) { + return new LessError(e); + } + }; + 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) { + return new LessError({ + message: "Plugin " + name + " requires version " + this.versionToString(plugin.minVersion) + }); + } + } + 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(); + } + } + }; + return AbstractPluginLoader; + }()); + var _visitArgs = { visitDeeper: true }; + var _hasIndexed = false; + function _noop(node) { + return node; + } + function indexNodeTypes(parent, ticker) { + // add .typeIndex to tree node types for lookup table + var key, child; + 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; + } + var Visitor = /** @class */ (function () { + function Visitor(implementation) { + this._implementation = implementation; + this._visitInCache = {}; + this._visitOutCache = {}; + if (!_hasIndexed) { + indexNodeTypes(tree, 1); + _hasIndexed = true; + } + } + Visitor.prototype.visit = function (node) { + if (!node) { + return node; + } + var nodeTypeIndex = node.typeIndex; + if (!nodeTypeIndex) { + // MixinCall args aren't a node type? + if (node.value && node.value.typeIndex) { + this.visit(node.value); + } + return node; + } + var impl = this._implementation; + var func = this._visitInCache[nodeTypeIndex]; + var funcOut = this._visitOutCache[nodeTypeIndex]; + var visitArgs = _visitArgs; + var fnName; + visitArgs.visitDeeper = true; + if (!func) { + fnName = "visit" + node.type; + func = impl[fnName] || _noop; + funcOut = impl[fnName + "Out"] || _noop; + this._visitInCache[nodeTypeIndex] = func; + this._visitOutCache[nodeTypeIndex] = funcOut; + } + if (func !== _noop) { + var newNode = func.call(impl, node, visitArgs); + if (node && impl.isReplacing) { + node = newNode; + } + } + if (visitArgs.visitDeeper && node) { + if (node.length) { + for (var i = 0, cnt = node.length; i < cnt; i++) { + if (node[i].accept) { + node[i].accept(this); + } + } + } + else if (node.accept) { + node.accept(this); + } + } + if (funcOut != _noop) { + funcOut.call(impl, node); + } + return node; + }; + Visitor.prototype.visitArray = function (nodes, nonReplacing) { + if (!nodes) { + return nodes; + } + var cnt = nodes.length; + var i; + // Non-replacing + if (nonReplacing || !this._implementation.isReplacing) { + for (i = 0; i < cnt; i++) { + this.visit(nodes[i]); + } + return nodes; + } + // Replacing + var out = []; + for (i = 0; i < cnt; i++) { + var evald = this.visit(nodes[i]); + if (evald === undefined) { + continue; + } + if (!evald.splice) { + out.push(evald); + } + else if (evald.length) { + this.flatten(evald, out); + } + } + return out; + }; + Visitor.prototype.flatten = function (arr, out) { + if (!out) { + out = []; + } + var cnt, i, item, nestedCnt, j, nestedItem; + for (i = 0, cnt = arr.length; i < cnt; i++) { + item = arr[i]; + if (item === undefined) { + continue; + } + if (!item.splice) { + out.push(item); + continue; + } + for (j = 0, nestedCnt = item.length; j < nestedCnt; j++) { + nestedItem = item[j]; + if (nestedItem === undefined) { + continue; + } + if (!nestedItem.splice) { + out.push(nestedItem); + } + else if (nestedItem.length) { + this.flatten(nestedItem, out); + } + } + } + return out; + }; + return Visitor; + }()); - less.registerStylesheets = function () { - return new Promise(function (resolve, reject) { - less.registerStylesheetsImmediately(); - resolve(); - }); - }; // - // With this function, it's possible to alter variables and re-render - // CSS without reloading less-files - // + var ImportSequencer = /** @class */ (function () { + function ImportSequencer(onSequencerEmpty) { + this.imports = []; + this.variableImports = []; + this._onSequencerEmpty = onSequencerEmpty; + this._currentDepth = 0; + } + ImportSequencer.prototype.addImport = function (callback) { + var importSequencer = this, importItem = { + callback: callback, + args: null, + isReady: false + }; + this.imports.push(importItem); + return function () { + importItem.args = Array.prototype.slice.call(arguments, 0); + importItem.isReady = true; + importSequencer.tryRun(); + }; + }; + ImportSequencer.prototype.addVariableImport = function (callback) { + this.variableImports.push(callback); + }; + ImportSequencer.prototype.tryRun = function () { + this._currentDepth++; + try { + while (true) { + while (this.imports.length > 0) { + var importItem = this.imports[0]; + if (!importItem.isReady) { + return; + } + this.imports = this.imports.slice(1); + importItem.callback.apply(null, importItem.args); + } + if (this.variableImports.length === 0) { + break; + } + var variableImport = this.variableImports[0]; + this.variableImports = this.variableImports.slice(1); + variableImport(); + } + } + finally { + this._currentDepth--; + } + if (this._currentDepth === 0 && this._onSequencerEmpty) { + this._onSequencerEmpty(); + } + }; + return ImportSequencer; + }()); - - less.modifyVars = function (record) { - return less.refresh(true, record, false); + var ImportVisitor = function (importer, finish) { + this._visitor = new Visitor(this); + this._importer = importer; + this._finish = finish; + this.context = new contexts.Eval(); + this.importCount = 0; + this.onceFileDetectionMap = {}; + this.recursionDetector = {}; + this._sequencer = new ImportSequencer(this._onSequencerEmpty.bind(this)); }; - - less.refresh = function (reload, modifyVars, clearFileCache) { - if ((reload || clearFileCache) && clearFileCache !== false) { - fileManager.clearFileCache(); - } - - return new Promise(function (resolve, reject) { - var startTime; - var endTime; - var totalMilliseconds; - var remainingSheets; - startTime = endTime = new Date(); // Set counter for remaining unprocessed sheets - - remainingSheets = less.sheets.length; - - if (remainingSheets === 0) { - endTime = new Date(); - totalMilliseconds = endTime - startTime; - less.logger.info('Less has finished and no sheets were loaded.'); - resolve({ - startTime: startTime, - endTime: endTime, - totalMilliseconds: totalMilliseconds, - sheets: less.sheets.length - }); - } else { - // Relies on less.sheets array, callback seems to be guaranteed to be called for every element of the array - loadStyleSheets(function (e, css, _, sheet, webInfo) { + ImportVisitor.prototype = { + isReplacing: false, + run: function (root) { + try { + // process the contents + this._visitor.visit(root); + } + catch (e) { + this.error = e; + } + this.isFinished = true; + this._sequencer.tryRun(); + }, + _onSequencerEmpty: function () { + if (!this.isFinished) { + return; + } + this._finish(this.error); + }, + visitImport: function (importNode, visitArgs) { + var inlineCSS = importNode.options.inline; + if (!importNode.css || inlineCSS) { + var context = new contexts.Eval(this.context, copyArray(this.context.frames)); + var importParent = context.frames[0]; + this.importCount++; + if (importNode.isVariableImport()) { + this._sequencer.addVariableImport(this.processImportNode.bind(this, importNode, context, importParent)); + } + else { + this.processImportNode(importNode, context, importParent); + } + } + visitArgs.visitDeeper = false; + }, + processImportNode: function (importNode, context, importParent) { + var evaldImportNode; + var inlineCSS = importNode.options.inline; + try { + evaldImportNode = importNode.evalForImport(context); + } + 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 + importNode.error = e; + } + if (evaldImportNode && (!evaldImportNode.css || inlineCSS)) { + if (evaldImportNode.options.multiple) { + context.importMultiple = true; + } + // try appending if we haven't determined if it is css or not + var tryAppendLessExtension = evaldImportNode.css === undefined; + for (var i = 0; i < importParent.rules.length; i++) { + if (importParent.rules[i] === importNode) { + importParent.rules[i] = evaldImportNode; + break; + } + } + var onImported = this.onImported.bind(this, evaldImportNode, context), sequencedOnImported = this._sequencer.addImport(onImported); + this._importer.push(evaldImportNode.getPath(), tryAppendLessExtension, evaldImportNode.fileInfo(), evaldImportNode.options, sequencedOnImported); + } + else { + this.importCount--; + if (this.isFinished) { + this._sequencer.tryRun(); + } + } + }, + onImported: function (importNode, context, e, root, importedAtRoot, fullPath) { if (e) { - errors.add(e, e.href || sheet.href); - reject(e); - return; + if (!e.filename) { + e.index = importNode.getIndex(); + e.filename = importNode.fileInfo().filename; + } + this.error = e; } - - if (webInfo.local) { - less.logger.info("Loading ".concat(sheet.href, " from cache.")); - } else { - less.logger.info("Rendered ".concat(sheet.href, " successfully.")); + var importVisitor = this, inlineCSS = importNode.options.inline, isPlugin = importNode.options.isPlugin, isOptional = importNode.options.optional, duplicateImport = importedAtRoot || fullPath in importVisitor.recursionDetector; + if (!context.importMultiple) { + if (duplicateImport) { + importNode.skip = true; + } + else { + importNode.skip = function () { + if (fullPath in importVisitor.onceFileDetectionMap) { + return true; + } + importVisitor.onceFileDetectionMap[fullPath] = true; + return false; + }; + } } - - browser.createCSS(window.document, css, sheet); - less.logger.info("CSS for ".concat(sheet.href, " generated in ").concat(new Date() - endTime, "ms")); // Count completed sheet - - remainingSheets--; // Check if the last remaining sheet was processed and then call the promise - - if (remainingSheets === 0) { - totalMilliseconds = new Date() - startTime; - less.logger.info("Less has finished. CSS generated in ".concat(totalMilliseconds, "ms")); - resolve({ - startTime: startTime, - endTime: endTime, - totalMilliseconds: totalMilliseconds, - sheets: less.sheets.length - }); + if (!fullPath && isOptional) { + importNode.skip = true; } - - endTime = new Date(); - }, reload, modifyVars); + if (root) { + importNode.root = root; + importNode.importedFilename = fullPath; + if (!inlineCSS && !isPlugin && (context.importMultiple || !duplicateImport)) { + importVisitor.recursionDetector[fullPath] = true; + var oldContext = this.context; + this.context = context; + try { + this._visitor.visit(root); + } + catch (e) { + this.error = e; + } + this.context = oldContext; + } + } + importVisitor.importCount--; + if (importVisitor.isFinished) { + importVisitor._sequencer.tryRun(); + } + }, + visitDeclaration: function (declNode, visitArgs) { + if (declNode.value.type === 'DetachedRuleset') { + this.context.frames.unshift(declNode); + } + else { + visitArgs.visitDeeper = false; + } + }, + visitDeclarationOut: function (declNode) { + if (declNode.value.type === 'DetachedRuleset') { + this.context.frames.shift(); + } + }, + visitAtRule: function (atRuleNode, visitArgs) { + this.context.frames.unshift(atRuleNode); + }, + visitAtRuleOut: function (atRuleNode) { + this.context.frames.shift(); + }, + visitMixinDefinition: function (mixinDefinitionNode, visitArgs) { + this.context.frames.unshift(mixinDefinitionNode); + }, + visitMixinDefinitionOut: function (mixinDefinitionNode) { + this.context.frames.shift(); + }, + visitRuleset: function (rulesetNode, visitArgs) { + this.context.frames.unshift(rulesetNode); + }, + visitRulesetOut: function (rulesetNode) { + this.context.frames.shift(); + }, + visitMedia: function (mediaNode, visitArgs) { + this.context.frames.unshift(mediaNode.rules[0]); + }, + visitMediaOut: function (mediaNode) { + this.context.frames.shift(); } - - loadStyles(modifyVars); - }); }; - less.refreshStyles = loadStyles; + var SetTreeVisibilityVisitor = /** @class */ (function () { + function SetTreeVisibilityVisitor(visible) { + this.visible = visible; + } + SetTreeVisibilityVisitor.prototype.run = function (root) { + this.visit(root); + }; + SetTreeVisibilityVisitor.prototype.visitArray = function (nodes) { + if (!nodes) { + return nodes; + } + var cnt = nodes.length; + var i; + for (i = 0; i < cnt; i++) { + this.visit(nodes[i]); + } + return nodes; + }; + SetTreeVisibilityVisitor.prototype.visit = function (node) { + if (!node) { + return node; + } + if (node.constructor === Array) { + return this.visitArray(node); + } + if (!node.blocksVisibility || node.blocksVisibility()) { + return node; + } + if (this.visible) { + node.ensureVisibility(); + } + else { + node.ensureInvisibility(); + } + node.accept(this); + return node; + }; + return SetTreeVisibilityVisitor; + }()); + + /* jshint loopfunc:true */ + var ExtendFinderVisitor = /** @class */ (function () { + function ExtendFinderVisitor() { + this._visitor = new Visitor(this); + this.contexts = []; + this.allExtendsStack = [[]]; + } + ExtendFinderVisitor.prototype.run = function (root) { + root = this._visitor.visit(root); + root.allExtends = this.allExtendsStack[0]; + return root; + }; + ExtendFinderVisitor.prototype.visitDeclaration = function (declNode, visitArgs) { + visitArgs.visitDeeper = false; + }; + ExtendFinderVisitor.prototype.visitMixinDefinition = function (mixinDefinitionNode, visitArgs) { + visitArgs.visitDeeper = false; + }; + ExtendFinderVisitor.prototype.visitRuleset = function (rulesetNode, visitArgs) { + if (rulesetNode.root) { + return; + } + var i; + var j; + var extend; + var allSelectorsExtendList = []; + var extendList; + // get &:extend(.a); rules which apply to all selectors in this ruleset + var rules = rulesetNode.rules, ruleCnt = rules ? rules.length : 0; + for (i = 0; i < ruleCnt; i++) { + if (rulesetNode.rules[i] instanceof tree.Extend) { + allSelectorsExtendList.push(rules[i]); + rulesetNode.extendOnEveryPath = true; + } + } + // now find every selector and apply the extends that apply to all extends + // and the ones which apply to an individual extend + var paths = rulesetNode.paths; + for (i = 0; i < paths.length; i++) { + var selectorPath = paths[i], selector = selectorPath[selectorPath.length - 1], selExtendList = selector.extendList; + extendList = selExtendList ? copyArray(selExtendList).concat(allSelectorsExtendList) + : allSelectorsExtendList; + if (extendList) { + extendList = extendList.map(function (allSelectorsExtend) { + return allSelectorsExtend.clone(); + }); + } + for (j = 0; j < extendList.length; j++) { + this.foundExtends = true; + extend = extendList[j]; + extend.findSelfSelectors(selectorPath); + extend.ruleset = rulesetNode; + if (j === 0) { + extend.firstExtendOnThisSelectorPath = true; + } + this.allExtendsStack[this.allExtendsStack.length - 1].push(extend); + } + } + this.contexts.push(rulesetNode.selectors); + }; + ExtendFinderVisitor.prototype.visitRulesetOut = function (rulesetNode) { + if (!rulesetNode.root) { + this.contexts.length = this.contexts.length - 1; + } + }; + ExtendFinderVisitor.prototype.visitMedia = function (mediaNode, visitArgs) { + mediaNode.allExtends = []; + this.allExtendsStack.push(mediaNode.allExtends); + }; + ExtendFinderVisitor.prototype.visitMediaOut = function (mediaNode) { + this.allExtendsStack.length = this.allExtendsStack.length - 1; + }; + ExtendFinderVisitor.prototype.visitAtRule = function (atRuleNode, visitArgs) { + atRuleNode.allExtends = []; + this.allExtendsStack.push(atRuleNode.allExtends); + }; + ExtendFinderVisitor.prototype.visitAtRuleOut = function (atRuleNode) { + this.allExtendsStack.length = this.allExtendsStack.length - 1; + }; + return ExtendFinderVisitor; + }()); + var ProcessExtendsVisitor = /** @class */ (function () { + function ProcessExtendsVisitor() { + this._visitor = new Visitor(this); + } + ProcessExtendsVisitor.prototype.run = function (root) { + var extendFinder = new ExtendFinderVisitor(); + this.extendIndices = {}; + extendFinder.run(root); + if (!extendFinder.foundExtends) { + return root; + } + root.allExtends = root.allExtends.concat(this.doExtendChaining(root.allExtends, root.allExtends)); + this.allExtendsStack = [root.allExtends]; + var newRoot = this._visitor.visit(root); + this.checkExtendsForNonMatched(root.allExtends); + return newRoot; + }; + ProcessExtendsVisitor.prototype.checkExtendsForNonMatched = function (extendList) { + var indices = this.extendIndices; + extendList.filter(function (extend) { + return !extend.hasFoundMatches && extend.parent_ids.length == 1; + }).forEach(function (extend) { + var selector = '_unknown_'; + try { + selector = extend.selector.toCSS({}); + } + catch (_) { } + if (!indices[extend.index + " " + selector]) { + indices[extend.index + " " + selector] = true; + logger$1.warn("extend '" + selector + "' has no matches"); + } + }); + }; + ProcessExtendsVisitor.prototype.doExtendChaining = function (extendsList, extendsListTarget, iterationCount) { + // + // chaining is different from normal extension.. if we extend an extend then we are not just copying, altering + // and pasting the selector we would do normally, but we are also adding an extend with the same target selector + // this means this new extend can then go and alter other extends + // + // this method deals with all the chaining work - without it, extend is flat and doesn't work on other extend selectors + // this is also the most expensive.. and a match on one selector can cause an extension of a selector we had already + // processed if we look at each selector at a time, as is done in visitRuleset + var extendIndex; + var targetExtendIndex; + var matches; + var extendsToAdd = []; + var newSelector; + var extendVisitor = this; + var selectorPath; + var extend; + var targetExtend; + var newExtend; + iterationCount = iterationCount || 0; + // 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. + // the separation into two lists allows us to process a subset of chains with a bigger set, as is the + // case when processing media queries + for (extendIndex = 0; extendIndex < extendsList.length; extendIndex++) { + for (targetExtendIndex = 0; targetExtendIndex < extendsListTarget.length; targetExtendIndex++) { + extend = extendsList[extendIndex]; + targetExtend = extendsListTarget[targetExtendIndex]; + // look for circular references + if (extend.parent_ids.indexOf(targetExtend.object_id) >= 0) { + continue; + } + // find a match in the target extends self selector (the bit before :extend) + selectorPath = [targetExtend.selfSelectors[0]]; + matches = extendVisitor.findMatch(extend, selectorPath); + if (matches.length) { + extend.hasFoundMatches = true; + // we found a match, so for each self selector.. + extend.selfSelectors.forEach(function (selfSelector) { + var info = targetExtend.visibilityInfo(); + // process the extend as usual + 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.fileInfo(), info); + newExtend.selfSelectors = newSelector; + // add the extend onto the list of extends for that selector + newSelector[newSelector.length - 1].extendList = [newExtend]; + // record that we need to add it. + extendsToAdd.push(newExtend); + newExtend.ruleset = targetExtend.ruleset; + // remember its parents for circular references + newExtend.parent_ids = newExtend.parent_ids.concat(targetExtend.parent_ids, extend.parent_ids); + // only process the selector once.. if we have :extend(.a,.b) then multiple + // extends will look at the same selector path, so when extending + // we know that any others will be duplicates in terms of what is added to the css + if (targetExtend.firstExtendOnThisSelectorPath) { + newExtend.firstExtendOnThisSelectorPath = true; + targetExtend.ruleset.paths.push(newSelector); + } + }); + } + } + } + if (extendsToAdd.length) { + // try to detect circular references to stop a stack overflow. + // may no longer be needed. + this.extendChainCount++; + if (iterationCount > 100) { + var selectorOne = '{unable to calculate}'; + var selectorTwo = '{unable to calculate}'; + try { + selectorOne = extendsToAdd[0].selfSelectors[0].toCSS(); + selectorTwo = extendsToAdd[0].selector.toCSS(); + } + catch (e) { } + throw { message: "extend circular reference detected. One of the circular extends is currently:" + selectorOne + ":extend(" + selectorTwo + ")" }; + } + // now process the new extends on the existing rules so that we can handle a extending b extending c extending + // d extending e... + return extendsToAdd.concat(extendVisitor.doExtendChaining(extendsToAdd, extendsListTarget, iterationCount + 1)); + } + else { + return extendsToAdd; + } + }; + ProcessExtendsVisitor.prototype.visitDeclaration = function (ruleNode, visitArgs) { + visitArgs.visitDeeper = false; + }; + ProcessExtendsVisitor.prototype.visitMixinDefinition = function (mixinDefinitionNode, visitArgs) { + visitArgs.visitDeeper = false; + }; + ProcessExtendsVisitor.prototype.visitSelector = function (selectorNode, visitArgs) { + visitArgs.visitDeeper = false; + }; + ProcessExtendsVisitor.prototype.visitRuleset = function (rulesetNode, visitArgs) { + if (rulesetNode.root) { + return; + } + var matches; + var pathIndex; + var extendIndex; + var allExtends = this.allExtendsStack[this.allExtendsStack.length - 1]; + var selectorsToAdd = []; + var extendVisitor = this; + var selectorPath; + // look at each selector path in the ruleset, find any extend matches and then copy, find and replace + for (extendIndex = 0; extendIndex < allExtends.length; extendIndex++) { + for (pathIndex = 0; pathIndex < rulesetNode.paths.length; pathIndex++) { + selectorPath = rulesetNode.paths[pathIndex]; + // extending extends happens initially, before the main pass + if (rulesetNode.extendOnEveryPath) { + continue; + } + var extendList = selectorPath[selectorPath.length - 1].extendList; + if (extendList && extendList.length) { + continue; + } + matches = this.findMatch(allExtends[extendIndex], selectorPath); + if (matches.length) { + allExtends[extendIndex].hasFoundMatches = true; + allExtends[extendIndex].selfSelectors.forEach(function (selfSelector) { + var extendedSelectors; + extendedSelectors = extendVisitor.extendSelector(matches, selectorPath, selfSelector, allExtends[extendIndex].isVisible()); + selectorsToAdd.push(extendedSelectors); + }); + } + } + } + rulesetNode.paths = rulesetNode.paths.concat(selectorsToAdd); + }; + ProcessExtendsVisitor.prototype.findMatch = function (extend, haystackSelectorPath) { + // + // look through the haystack selector path to try and find the needle - extend.selector + // returns an array of selector matches that can then be replaced + // + var haystackSelectorIndex; + var hackstackSelector; + var hackstackElementIndex; + var haystackElement; + var targetCombinator; + var i; + var extendVisitor = this; + var needleElements = extend.selector.elements; + var potentialMatches = []; + var potentialMatch; + var matches = []; + // loop through the haystack elements + for (haystackSelectorIndex = 0; haystackSelectorIndex < haystackSelectorPath.length; haystackSelectorIndex++) { + hackstackSelector = haystackSelectorPath[haystackSelectorIndex]; + for (hackstackElementIndex = 0; hackstackElementIndex < hackstackSelector.elements.length; hackstackElementIndex++) { + haystackElement = hackstackSelector.elements[hackstackElementIndex]; + // if we allow elements before our match we can add a potential match every time. otherwise only at the first element. + if (extend.allowBefore || (haystackSelectorIndex === 0 && hackstackElementIndex === 0)) { + potentialMatches.push({ pathIndex: haystackSelectorIndex, index: hackstackElementIndex, matched: 0, + initialCombinator: haystackElement.combinator }); + } + for (i = 0; i < potentialMatches.length; i++) { + potentialMatch = potentialMatches[i]; + // selectors add " " onto the first element. When we use & it joins the selectors together, but if we don't + // then each selector in haystackSelectorPath has a space before it added in the toCSS phase. so we need to + // work out what the resulting combinator will be + targetCombinator = haystackElement.combinator.value; + if (targetCombinator === '' && hackstackElementIndex === 0) { + targetCombinator = ' '; + } + // if we don't match, null our match to indicate failure + if (!extendVisitor.isElementValuesEqual(needleElements[potentialMatch.matched].value, haystackElement.value) || + (potentialMatch.matched > 0 && needleElements[potentialMatch.matched].combinator.value !== targetCombinator)) { + potentialMatch = null; + } + else { + potentialMatch.matched++; + } + // if we are still valid and have finished, test whether we have elements after and whether these are allowed + if (potentialMatch) { + potentialMatch.finished = potentialMatch.matched === needleElements.length; + if (potentialMatch.finished && + (!extend.allowAfter && + (hackstackElementIndex + 1 < hackstackSelector.elements.length || haystackSelectorIndex + 1 < haystackSelectorPath.length))) { + potentialMatch = null; + } + } + // if null we remove, if not, we are still valid, so either push as a valid match or continue + if (potentialMatch) { + if (potentialMatch.finished) { + potentialMatch.length = needleElements.length; + potentialMatch.endPathIndex = haystackSelectorIndex; + potentialMatch.endPathElementIndex = hackstackElementIndex + 1; // index after end of match + potentialMatches.length = 0; // we don't allow matches to overlap, so start matching again + matches.push(potentialMatch); + } + } + else { + potentialMatches.splice(i, 1); + i--; + } + } + } + } + return matches; + }; + ProcessExtendsVisitor.prototype.isElementValuesEqual = function (elementValue1, elementValue2) { + if (typeof elementValue1 === 'string' || typeof elementValue2 === 'string') { + return elementValue1 === elementValue2; + } + if (elementValue1 instanceof tree.Attribute) { + if (elementValue1.op !== elementValue2.op || elementValue1.key !== elementValue2.key) { + return false; + } + if (!elementValue1.value || !elementValue2.value) { + if (elementValue1.value || elementValue2.value) { + return false; + } + return true; + } + elementValue1 = elementValue1.value.value || elementValue1.value; + elementValue2 = elementValue2.value.value || elementValue2.value; + return elementValue1 === elementValue2; + } + elementValue1 = elementValue1.value; + elementValue2 = elementValue2.value; + if (elementValue1 instanceof tree.Selector) { + if (!(elementValue2 instanceof tree.Selector) || elementValue1.elements.length !== elementValue2.elements.length) { + return false; + } + for (var i = 0; i < elementValue1.elements.length; i++) { + if (elementValue1.elements[i].combinator.value !== elementValue2.elements[i].combinator.value) { + if (i !== 0 || (elementValue1.elements[i].combinator.value || ' ') !== (elementValue2.elements[i].combinator.value || ' ')) { + return false; + } + } + if (!this.isElementValuesEqual(elementValue1.elements[i].value, elementValue2.elements[i].value)) { + return false; + } + } + return true; + } + return false; + }; + ProcessExtendsVisitor.prototype.extendSelector = function (matches, selectorPath, replacementSelector, isVisible) { + // for a set of matches, replace each match with the replacement selector + var currentSelectorPathIndex = 0, currentSelectorPathElementIndex = 0, path = [], matchIndex, selector, firstElement, match, newElements; + for (matchIndex = 0; matchIndex < matches.length; matchIndex++) { + match = matches[matchIndex]; + selector = selectorPath[match.pathIndex]; + firstElement = new tree.Element(match.initialCombinator, replacementSelector.elements[0].value, replacementSelector.elements[0].isVariable, replacementSelector.elements[0].getIndex(), replacementSelector.elements[0].fileInfo()); + if (match.pathIndex > currentSelectorPathIndex && currentSelectorPathElementIndex > 0) { + path[path.length - 1].elements = path[path.length - 1] + .elements.concat(selectorPath[currentSelectorPathIndex].elements.slice(currentSelectorPathElementIndex)); + currentSelectorPathElementIndex = 0; + currentSelectorPathIndex++; + } + newElements = selector.elements + .slice(currentSelectorPathElementIndex, match.index) + .concat([firstElement]) + .concat(replacementSelector.elements.slice(1)); + if (currentSelectorPathIndex === match.pathIndex && matchIndex > 0) { + path[path.length - 1].elements = + path[path.length - 1].elements.concat(newElements); + } + else { + path = path.concat(selectorPath.slice(currentSelectorPathIndex, match.pathIndex)); + path.push(new tree.Selector(newElements)); + } + currentSelectorPathIndex = match.endPathIndex; + currentSelectorPathElementIndex = match.endPathElementIndex; + if (currentSelectorPathElementIndex >= selectorPath[currentSelectorPathIndex].elements.length) { + currentSelectorPathElementIndex = 0; + currentSelectorPathIndex++; + } + } + if (currentSelectorPathIndex < selectorPath.length && currentSelectorPathElementIndex > 0) { + path[path.length - 1].elements = path[path.length - 1] + .elements.concat(selectorPath[currentSelectorPathIndex].elements.slice(currentSelectorPathElementIndex)); + currentSelectorPathIndex++; + } + path = path.concat(selectorPath.slice(currentSelectorPathIndex, selectorPath.length)); + path = path.map(function (currentValue) { + // we can re-use elements here, because the visibility property matters only for selectors + var derived = currentValue.createDerived(currentValue.elements); + if (isVisible) { + derived.ensureVisibility(); + } + else { + derived.ensureInvisibility(); + } + return derived; + }); + return path; + }; + ProcessExtendsVisitor.prototype.visitMedia = function (mediaNode, visitArgs) { + var newAllExtends = mediaNode.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length - 1]); + newAllExtends = newAllExtends.concat(this.doExtendChaining(newAllExtends, mediaNode.allExtends)); + this.allExtendsStack.push(newAllExtends); + }; + ProcessExtendsVisitor.prototype.visitMediaOut = function (mediaNode) { + var lastIndex = this.allExtendsStack.length - 1; + this.allExtendsStack.length = lastIndex; + }; + ProcessExtendsVisitor.prototype.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); + }; + ProcessExtendsVisitor.prototype.visitAtRuleOut = function (atRuleNode) { + var lastIndex = this.allExtendsStack.length - 1; + this.allExtendsStack.length = lastIndex; + }; + return ProcessExtendsVisitor; + }()); + + var JoinSelectorVisitor = /** @class */ (function () { + function JoinSelectorVisitor() { + this.contexts = [[]]; + this._visitor = new Visitor(this); + } + JoinSelectorVisitor.prototype.run = function (root) { + return this._visitor.visit(root); + }; + JoinSelectorVisitor.prototype.visitDeclaration = function (declNode, visitArgs) { + visitArgs.visitDeeper = false; + }; + JoinSelectorVisitor.prototype.visitMixinDefinition = function (mixinDefinitionNode, visitArgs) { + visitArgs.visitDeeper = false; + }; + JoinSelectorVisitor.prototype.visitRuleset = function (rulesetNode, visitArgs) { + var context = this.contexts[this.contexts.length - 1]; + var paths = []; + var selectors; + this.contexts.push(paths); + if (!rulesetNode.root) { + selectors = rulesetNode.selectors; + if (selectors) { + selectors = selectors.filter(function (selector) { return selector.getIsOutput(); }); + rulesetNode.selectors = selectors.length ? selectors : (selectors = null); + if (selectors) { + rulesetNode.joinSelectors(paths, context, selectors); + } + } + if (!selectors) { + rulesetNode.rules = null; + } + rulesetNode.paths = paths; + } + }; + JoinSelectorVisitor.prototype.visitRulesetOut = function (rulesetNode) { + this.contexts.length = this.contexts.length - 1; + }; + JoinSelectorVisitor.prototype.visitMedia = function (mediaNode, visitArgs) { + var context = this.contexts[this.contexts.length - 1]; + mediaNode.rules[0].root = (context.length === 0 || context[0].multiMedia); + }; + JoinSelectorVisitor.prototype.visitAtRule = function (atRuleNode, visitArgs) { + var context = this.contexts[this.contexts.length - 1]; + if (atRuleNode.rules && atRuleNode.rules.length) { + atRuleNode.rules[0].root = (atRuleNode.isRooted || context.length === 0 || null); + } + }; + return JoinSelectorVisitor; + }()); + + var CSSVisitorUtils = /** @class */ (function () { + function CSSVisitorUtils(context) { + this._visitor = new Visitor(this); + this._context = context; + } + CSSVisitorUtils.prototype.containsSilentNonBlockedChild = function (bodyRules) { + var rule; + 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 atrule contains something that was referenced (likely by extend) + // therefore it needs to be shown in output too + return true; + } + } + return false; + }; + CSSVisitorUtils.prototype.keepOnlyVisibleChilds = function (owner) { + if (owner && owner.rules) { + owner.rules = owner.rules.filter(function (thing) { return thing.isVisible(); }); + } + }; + CSSVisitorUtils.prototype.isEmpty = function (owner) { + return (owner && owner.rules) + ? (owner.rules.length === 0) : true; + }; + CSSVisitorUtils.prototype.hasVisibleSelector = function (rulesetNode) { + return (rulesetNode && rulesetNode.paths) + ? (rulesetNode.paths.length > 0) : false; + }; + CSSVisitorUtils.prototype.resolveVisibility = function (node, originalRules) { + if (!node.blocksVisibility()) { + if (this.isEmpty(node) && !this.containsSilentNonBlockedChild(originalRules)) { + return; + } + return node; + } + var compiledRulesBody = node.rules[0]; + this.keepOnlyVisibleChilds(compiledRulesBody); + if (this.isEmpty(compiledRulesBody)) { + return; + } + node.ensureVisibility(); + node.removeVisibilityBlock(); + return node; + }; + CSSVisitorUtils.prototype.isVisibleRuleset = function (rulesetNode) { + if (rulesetNode.firstRoot) { + return true; + } + if (this.isEmpty(rulesetNode)) { + return false; + } + if (!rulesetNode.root && !this.hasVisibleSelector(rulesetNode)) { + return false; + } + return true; + }; + return CSSVisitorUtils; + }()); + var ToCSSVisitor = function (context) { + this._visitor = new Visitor(this); + this._context = context; + this.utils = new CSSVisitorUtils(context); + }; + ToCSSVisitor.prototype = { + isReplacing: true, + run: function (root) { + return this._visitor.visit(root); + }, + visitDeclaration: function (declNode, visitArgs) { + if (declNode.blocksVisibility() || declNode.variable) { + return; + } + return declNode; + }, + visitMixinDefinition: function (mixinNode, visitArgs) { + // mixin definitions do not get eval'd - this means they keep state + // so we have to clear that state here so it isn't used if toCSS is called twice + mixinNode.frames = []; + }, + visitExtend: function (extendNode, visitArgs) { + }, + visitComment: function (commentNode, visitArgs) { + if (commentNode.blocksVisibility() || commentNode.isSilent(this._context)) { + return; + } + return commentNode; + }, + visitMedia: function (mediaNode, visitArgs) { + var originalRules = mediaNode.rules[0].rules; + mediaNode.accept(this._visitor); + visitArgs.visitDeeper = false; + return this.utils.resolveVisibility(mediaNode, originalRules); + }, + visitImport: function (importNode, visitArgs) { + if (importNode.blocksVisibility()) { + return; + } + return importNode; + }, + visitAtRule: function (atRuleNode, visitArgs) { + if (atRuleNode.rules && atRuleNode.rules.length) { + return this.visitAtRuleWithBody(atRuleNode, visitArgs); + } + else { + return this.visitAtRuleWithoutBody(atRuleNode, visitArgs); + } + }, + visitAnonymous: function (anonymousNode, visitArgs) { + if (!anonymousNode.blocksVisibility()) { + anonymousNode.accept(this._visitor); + return anonymousNode; + } + }, + 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(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(atRuleNode); + atRuleNode.accept(this._visitor); + visitArgs.visitDeeper = false; + if (!this.utils.isEmpty(atRuleNode)) { + this._mergeRules(atRuleNode.rules[0].rules); + } + return this.utils.resolveVisibility(atRuleNode, originalRules); + }, + visitAtRuleWithoutBody: function (atRuleNode, visitArgs) { + if (atRuleNode.blocksVisibility()) { + return; + } + if (atRuleNode.name === '@charset') { + // Only output the debug info together with subsequent @charset definitions + // 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 (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; + } + this.charset = true; + } + return atRuleNode; + }, + checkValidNodes: function (rules, isRoot) { + if (!rules) { + return; + } + for (var i = 0; i < rules.length; i++) { + var ruleNode = rules[i]; + if (isRoot && ruleNode instanceof tree.Declaration && !ruleNode.variable) { + throw { message: 'Properties must be inside selector blocks. They cannot be in the root', + index: ruleNode.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename }; + } + if (ruleNode instanceof tree.Call) { + throw { message: "Function '" + ruleNode.name + "' did not return a root node", + 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.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename }; + } + } + }, + visitRuleset: function (rulesetNode, visitArgs) { + // at this point rulesets are nested into each other + var rule; + var rulesets = []; + this.checkValidNodes(rulesetNode.rules, rulesetNode.firstRoot); + if (!rulesetNode.root) { + // remove invisible paths + this._compileRulesetPaths(rulesetNode); + // remove rulesets from this ruleset body and compile them separately + var nodeRules = rulesetNode.rules; + var nodeRuleCnt = nodeRules ? nodeRules.length : 0; + for (var i = 0; i < nodeRuleCnt;) { + rule = nodeRules[i]; + if (rule && rule.rules) { + // visit because we are moving them out from being a child + rulesets.push(this._visitor.visit(rule)); + nodeRules.splice(i, 1); + nodeRuleCnt--; + continue; + } + i++; + } + // accept the visitor to remove rules and refactor itself + // then we can decide nogw whether we want it or not + // compile body + if (nodeRuleCnt > 0) { + rulesetNode.accept(this._visitor); + } + else { + rulesetNode.rules = null; + } + visitArgs.visitDeeper = false; + } + else { // if (! rulesetNode.root) { + rulesetNode.accept(this._visitor); + visitArgs.visitDeeper = false; + } + if (rulesetNode.rules) { + this._mergeRules(rulesetNode.rules); + this._removeDuplicateRules(rulesetNode.rules); + } + // now decide whether we keep the ruleset + if (this.utils.isVisibleRuleset(rulesetNode)) { + rulesetNode.ensureVisibility(); + rulesets.splice(0, 0, rulesetNode); + } + if (rulesets.length === 1) { + return rulesets[0]; + } + return rulesets; + }, + _compileRulesetPaths: function (rulesetNode) { + if (rulesetNode.paths) { + rulesetNode.paths = rulesetNode.paths + .filter(function (p) { + var i; + if (p[0].elements[0].combinator.value === ' ') { + p[0].elements[0].combinator = new (tree.Combinator)(''); + } + for (i = 0; i < p.length; i++) { + if (p[i].isVisible() && p[i].getIsOutput()) { + return true; + } + } + return false; + }); + } + }, + _removeDuplicateRules: function (rules) { + if (!rules) { + return; + } + // remove duplicates + var ruleCache = {}; + var ruleList; + var rule; + var i; + for (i = rules.length - 1; i >= 0; i--) { + rule = rules[i]; + if (rule instanceof tree.Declaration) { + if (!ruleCache[rule.name]) { + ruleCache[rule.name] = rule; + } + else { + ruleList = ruleCache[rule.name]; + if (ruleList instanceof tree.Declaration) { + ruleList = ruleCache[rule.name] = [ruleCache[rule.name].toCSS(this._context)]; + } + var ruleCSS = rule.toCSS(this._context); + if (ruleList.indexOf(ruleCSS) !== -1) { + rules.splice(i, 1); + } + else { + ruleList.push(ruleCSS); + } + } + } + } + }, + _mergeRules: function (rules) { + if (!rules) { + return; + } + var groups = {}; + var groupsArr = []; + for (var i = 0; i < rules.length; i++) { + 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); + } + } + groupsArr.forEach(function (group) { + if (group.length > 0) { + var result_1 = group[0]; + var space_1 = []; + var comma_1 = [new tree.Expression(space_1)]; + group.forEach(function (rule) { + if ((rule.merge === '+') && (space_1.length > 0)) { + comma_1.push(new tree.Expression(space_1 = [])); + } + space_1.push(rule.value); + result_1.important = result_1.important || rule.important; + }); + result_1.value = new tree.Value(comma_1); + } + }); + } + }; + + var visitors = { + Visitor: Visitor, + ImportVisitor: ImportVisitor, + MarkVisibleSelectorsVisitor: SetTreeVisibilityVisitor, + ExtendVisitor: ProcessExtendsVisitor, + JoinSelectorVisitor: JoinSelectorVisitor, + ToCSSVisitor: ToCSSVisitor + }; + + // Split the input into chunks. + function chunker (input, fail) { + var len = input.length; + var level = 0; + var parenLevel = 0; + var lastOpening; + var lastOpeningParen; + var lastMultiComment; + var lastMultiCommentEndBrace; + var chunks = []; + var emitFrom = 0; + var chunkerCurrentIndex; + var currentChunkStartIndex; + var cc; + var cc2; + var matched; + function emitChunk(force) { + var len = chunkerCurrentIndex - emitFrom; + if (((len < 512) && !force) || !len) { + return; + } + chunks.push(input.slice(emitFrom, chunkerCurrentIndex + 1)); + emitFrom = chunkerCurrentIndex + 1; + } + for (chunkerCurrentIndex = 0; chunkerCurrentIndex < len; chunkerCurrentIndex++) { + cc = input.charCodeAt(chunkerCurrentIndex); + if (((cc >= 97) && (cc <= 122)) || (cc < 34)) { + // a-z or whitespace + continue; + } + switch (cc) { + case 40: // ( + parenLevel++; + lastOpeningParen = chunkerCurrentIndex; + continue; + case 41: // ) + if (--parenLevel < 0) { + return fail('missing opening `(`', chunkerCurrentIndex); + } + continue; + case 59: // ; + if (!parenLevel) { + emitChunk(); + } + continue; + case 123: // { + level++; + lastOpening = chunkerCurrentIndex; + continue; + case 125: // } + if (--level < 0) { + return fail('missing opening `{`', chunkerCurrentIndex); + } + if (!level && !parenLevel) { + emitChunk(); + } + continue; + case 92: // \ + if (chunkerCurrentIndex < len - 1) { + chunkerCurrentIndex++; + continue; + } + return fail('unescaped `\\`', chunkerCurrentIndex); + case 34: + case 39: + case 96: // ", ' and ` + matched = 0; + currentChunkStartIndex = chunkerCurrentIndex; + for (chunkerCurrentIndex = chunkerCurrentIndex + 1; chunkerCurrentIndex < len; chunkerCurrentIndex++) { + cc2 = input.charCodeAt(chunkerCurrentIndex); + if (cc2 > 96) { + continue; + } + if (cc2 == cc) { + matched = 1; + break; + } + if (cc2 == 92) { // \ + if (chunkerCurrentIndex == len - 1) { + return fail('unescaped `\\`', chunkerCurrentIndex); + } + chunkerCurrentIndex++; + } + } + if (matched) { + continue; + } + return fail("unmatched `" + String.fromCharCode(cc) + "`", currentChunkStartIndex); + case 47: // /, check for comment + if (parenLevel || (chunkerCurrentIndex == len - 1)) { + continue; + } + cc2 = input.charCodeAt(chunkerCurrentIndex + 1); + if (cc2 == 47) { + // //, find lnfeed + for (chunkerCurrentIndex = chunkerCurrentIndex + 2; chunkerCurrentIndex < len; chunkerCurrentIndex++) { + cc2 = input.charCodeAt(chunkerCurrentIndex); + if ((cc2 <= 13) && ((cc2 == 10) || (cc2 == 13))) { + break; + } + } + } + else if (cc2 == 42) { + // /*, find */ + lastMultiComment = currentChunkStartIndex = chunkerCurrentIndex; + for (chunkerCurrentIndex = chunkerCurrentIndex + 2; chunkerCurrentIndex < len - 1; chunkerCurrentIndex++) { + cc2 = input.charCodeAt(chunkerCurrentIndex); + if (cc2 == 125) { + lastMultiCommentEndBrace = chunkerCurrentIndex; + } + if (cc2 != 42) { + continue; + } + if (input.charCodeAt(chunkerCurrentIndex + 1) == 47) { + break; + } + } + if (chunkerCurrentIndex == len - 1) { + return fail('missing closing `*/`', currentChunkStartIndex); + } + chunkerCurrentIndex++; + } + continue; + case 42: // *, check for unmatched */ + if ((chunkerCurrentIndex < len - 1) && (input.charCodeAt(chunkerCurrentIndex + 1) == 47)) { + return fail('unmatched `/*`', chunkerCurrentIndex); + } + continue; + } + } + if (level !== 0) { + if ((lastMultiComment > lastOpening) && (lastMultiCommentEndBrace > lastMultiComment)) { + return fail('missing closing `}` or `*/`', lastOpening); + } + else { + return fail('missing closing `}`', lastOpening); + } + } + else if (parenLevel !== 0) { + return fail('missing closing `)`', lastOpeningParen); + } + emitChunk(true); + return chunks; + } + + var getParserInput = (function () { + var // Less input string + input; + var // current chunk + j; + var // holds state for backtracking + saveStack = []; + var // furthest index the parser has gone to + furthest; + var // if this is furthest we got to, this is the probably cause + furthestPossibleErrorMessage; + var // chunkified input + chunks; + var // current chunk + current; + var // index of current chunk, in `input` + currentPos; + var parserInput = {}; + var CHARCODE_SPACE = 32; + var CHARCODE_TAB = 9; + var CHARCODE_LF = 10; + var CHARCODE_CR = 13; + var CHARCODE_PLUS = 43; + var CHARCODE_COMMA = 44; + var CHARCODE_FORWARD_SLASH = 47; + var CHARCODE_9 = 57; + function skipWhitespace(length) { + var oldi = parserInput.i; + var oldj = j; + var curr = parserInput.i - currentPos; + var endIndex = parserInput.i + current.length - curr; + var mem = (parserInput.i += length); + var inp = input; + var c; + var nextChar; + var comment; + for (; parserInput.i < endIndex; parserInput.i++) { + c = inp.charCodeAt(parserInput.i); + if (parserInput.autoCommentAbsorb && c === CHARCODE_FORWARD_SLASH) { + nextChar = inp.charAt(parserInput.i + 1); + if (nextChar === '/') { + comment = { index: parserInput.i, isLineComment: true }; + var nextNewLine = inp.indexOf('\n', parserInput.i + 2); + if (nextNewLine < 0) { + nextNewLine = endIndex; + } + parserInput.i = nextNewLine; + comment.text = inp.substr(comment.index, parserInput.i - comment.index); + parserInput.commentStore.push(comment); + continue; + } + else if (nextChar === '*') { + var nextStarSlash = inp.indexOf('*/', parserInput.i + 2); + if (nextStarSlash >= 0) { + comment = { + index: parserInput.i, + text: inp.substr(parserInput.i, nextStarSlash + 2 - parserInput.i), + isLineComment: false + }; + parserInput.i += comment.text.length - 1; + parserInput.commentStore.push(comment); + continue; + } + } + break; + } + if ((c !== CHARCODE_SPACE) && (c !== CHARCODE_LF) && (c !== CHARCODE_TAB) && (c !== CHARCODE_CR)) { + break; + } + } + current = current.slice(length + parserInput.i - mem + curr); + currentPos = parserInput.i; + if (!current.length) { + if (j < chunks.length - 1) { + current = chunks[++j]; + skipWhitespace(0); // skip space at the beginning of a chunk + return true; // things changed + } + parserInput.finished = true; + } + return oldi !== parserInput.i || oldj !== j; + } + parserInput.save = function () { + currentPos = parserInput.i; + saveStack.push({ current: current, i: parserInput.i, j: j }); + }; + parserInput.restore = function (possibleErrorMessage) { + if (parserInput.i > furthest || (parserInput.i === furthest && possibleErrorMessage && !furthestPossibleErrorMessage)) { + furthest = parserInput.i; + furthestPossibleErrorMessage = possibleErrorMessage; + } + var state = saveStack.pop(); + current = state.current; + currentPos = parserInput.i = state.i; + j = state.j; + }; + parserInput.forget = function () { + saveStack.pop(); + }; + parserInput.isWhitespace = function (offset) { + var pos = parserInput.i + (offset || 0); + var code = input.charCodeAt(pos); + return (code === CHARCODE_SPACE || code === CHARCODE_CR || code === CHARCODE_TAB || code === CHARCODE_LF); + }; + // Specialization of $(tok) + parserInput.$re = function (tok) { + if (parserInput.i > currentPos) { + current = current.slice(parserInput.i - currentPos); + currentPos = parserInput.i; + } + var m = tok.exec(current); + if (!m) { + return null; + } + skipWhitespace(m[0].length); + if (typeof m === 'string') { + return m; + } + return m.length === 1 ? m[0] : m; + }; + parserInput.$char = function (tok) { + if (input.charAt(parserInput.i) !== tok) { + return null; + } + skipWhitespace(1); + return tok; + }; + parserInput.$str = function (tok) { + var tokLength = tok.length; + // https://jsperf.com/string-startswith/21 + for (var i = 0; i < tokLength; i++) { + if (input.charAt(parserInput.i + i) !== tok.charAt(i)) { + return null; + } + } + skipWhitespace(tokLength); + return tok; + }; + parserInput.$quoted = function (loc) { + var pos = loc || parserInput.i; + var startChar = input.charAt(pos); + if (startChar !== '\'' && startChar !== '"') { + return; + } + var length = input.length; + var currentPosition = pos; + for (var i = 1; i + currentPosition < length; i++) { + var nextChar = input.charAt(i + currentPosition); + switch (nextChar) { + case '\\': + i++; + continue; + case '\r': + case '\n': + break; + case startChar: + var str = input.substr(currentPosition, i + 1); + if (!loc && loc !== 0) { + skipWhitespace(i + 1); + return str; + } + return [startChar, str]; + } + } + return null; + }; + /** + * Permissive parsing. Ignores everything except matching {} [] () and quotes + * until matching token (outside of blocks) + */ + parserInput.$parseUntil = function (tok) { + var quote = ''; + var returnVal = null; + var inComment = false; + var blockDepth = 0; + var blockStack = []; + var parseGroups = []; + var length = input.length; + var startPos = parserInput.i; + var lastPos = parserInput.i; + var i = parserInput.i; + var loop = true; + var testChar; + if (typeof tok === 'string') { + testChar = function (char) { return char === tok; }; + } + else { + testChar = function (char) { return tok.test(char); }; + } + do { + var nextChar = input.charAt(i); + if (blockDepth === 0 && testChar(nextChar)) { + returnVal = input.substr(lastPos, i - lastPos); + if (returnVal) { + parseGroups.push(returnVal); + } + else { + parseGroups.push(' '); + } + returnVal = parseGroups; + skipWhitespace(i - startPos); + loop = false; + } + else { + if (inComment) { + if (nextChar === '*' && + input.charAt(i + 1) === '/') { + i++; + blockDepth--; + inComment = false; + } + i++; + continue; + } + switch (nextChar) { + case '\\': + i++; + nextChar = input.charAt(i); + parseGroups.push(input.substr(lastPos, i - lastPos + 1)); + lastPos = i + 1; + break; + case '/': + if (input.charAt(i + 1) === '*') { + i++; + inComment = true; + blockDepth++; + } + break; + case '\'': + case '"': + quote = parserInput.$quoted(i); + if (quote) { + parseGroups.push(input.substr(lastPos, i - lastPos), quote); + i += quote[1].length - 1; + lastPos = i + 1; + } + else { + skipWhitespace(i - startPos); + returnVal = nextChar; + loop = false; + } + break; + case '{': + blockStack.push('}'); + blockDepth++; + break; + case '(': + blockStack.push(')'); + blockDepth++; + break; + case '[': + blockStack.push(']'); + blockDepth++; + break; + case '}': + case ')': + case ']': + var expected = blockStack.pop(); + if (nextChar === expected) { + blockDepth--; + } + else { + // move the parser to the error and return expected + skipWhitespace(i - startPos); + returnVal = expected; + loop = false; + } + } + i++; + if (i > length) { + loop = false; + } + } + } while (loop); + return returnVal ? returnVal : null; + }; + parserInput.autoCommentAbsorb = true; + parserInput.commentStore = []; + parserInput.finished = false; + // Same as $(), but don't change the state of the parser, + // just return the match. + parserInput.peek = function (tok) { + if (typeof tok === 'string') { + // https://jsperf.com/string-startswith/21 + for (var i = 0; i < tok.length; i++) { + if (input.charAt(parserInput.i + i) !== tok.charAt(i)) { + return false; + } + } + return true; + } + else { + return tok.test(current); + } + }; + // Specialization of peek() + // TODO remove or change some currentChar calls to peekChar + parserInput.peekChar = function (tok) { return input.charAt(parserInput.i) === tok; }; + parserInput.currentChar = function () { return input.charAt(parserInput.i); }; + parserInput.prevChar = function () { return input.charAt(parserInput.i - 1); }; + parserInput.getInput = function () { return input; }; + parserInput.peekNotNumeric = function () { + var c = input.charCodeAt(parserInput.i); + // Is the first char of the dimension 0-9, '.', '+' or '-' + return (c > CHARCODE_9 || c < CHARCODE_PLUS) || c === CHARCODE_FORWARD_SLASH || c === CHARCODE_COMMA; + }; + parserInput.start = function (str, chunkInput, failFunction) { + input = str; + parserInput.i = j = currentPos = furthest = 0; + // chunking apparently makes things quicker (but my tests indicate + // it might actually make things slower in node at least) + // and it is a non-perfect parse - it can't recognise + // unquoted urls, meaning it can't distinguish comments + // meaning comments with quotes or {}() in them get 'counted' + // and then lead to parse errors. + // In addition if the chunking chunks in the wrong place we might + // not be able to parse a parser statement in one go + // this is officially deprecated but can be switched on via an option + // in the case it causes too much performance issues. + if (chunkInput) { + chunks = chunker(str, failFunction); + } + else { + chunks = [str]; + } + current = chunks[0]; + skipWhitespace(0); + }; + parserInput.end = function () { + var message; + var isFinished = parserInput.i >= input.length; + if (parserInput.i < furthest) { + message = furthestPossibleErrorMessage; + parserInput.i = furthest; + } + return { + isFinished: isFinished, + furthest: parserInput.i, + furthestPossibleErrorMessage: message, + furthestReachedEnd: parserInput.i >= input.length - 1, + furthestChar: input[parserInput.i] + }; + }; + return parserInput; + }); + + // + // less.js - parser + // + // A relatively straight-forward predictive parser. + // There is no tokenization/lexing stage, the input is parsed + // in one sweep. + // + // To make the parser fast enough to run in the browser, several + // optimization had to be made: + // + // - Matching and slicing on a huge input is often cause of slowdowns. + // The solution is to chunkify the input into smaller strings. + // The chunks are stored in the `chunks` var, + // `j` holds the current chunk index, and `currentPos` holds + // the index of the current chunk in relation to `input`. + // This gives us an almost 4x speed-up. + // + // - In many cases, we don't need to match individual tokens; + // for example, if a value doesn't hold any variables, operations + // or dynamic references, the parser can effectively 'skip' it, + // treating it as a literal. + // An example would be '1px solid #000' - which evaluates to itself, + // we don't need to know what the individual components are. + // The drawback, of course is that you don't get the benefits of + // syntax-checking on the CSS. This gives us a 50% speed-up in the parser, + // and a smaller speed-up in the code-gen. + // + // + // 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; + var parserInput = getParserInput(); + function error(msg, type) { + throw new LessError({ + index: parserInput.i, + filename: fileInfo.filename, + type: type || 'Syntax', + message: msg + }, imports); + } + function expect(arg, msg) { + // some older browsers return typeof 'function' for RegExp + var result = (arg instanceof Function) ? arg.call(parsers) : parserInput.$re(arg); + if (result) { + return result; + } + error(msg || (typeof arg === 'string' + ? "expected '" + arg + "' got '" + parserInput.currentChar() + "'" + : 'unexpected token')); + } + // Specialization of expect() + function expectChar(arg, msg) { + if (parserInput.$char(arg)) { + return arg; + } + error(msg || "expected '" + arg + "' got '" + parserInput.currentChar() + "'"); + } + function getDebugInfo(index) { + var filename = fileInfo.filename; + return { + lineNumber: getLocation(index, parserInput.getInput()).line + 1, + fileName: filename + }; + } + /** + * 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; + var returnNodes = []; + var parser = parserInput; + try { + parser.start(str, false, function fail(msg, index) { + callback({ + message: msg, + index: index + currentIndex + }); + }); + for (var x = 0, p = void 0, i = void 0; (p = parseList[x]); x++) { + i = parser.i; + result = parsers[p](); + if (result) { + try { + result._index = i + currentIndex; + result._fileInfo = fileInfo; + } + catch (e) { } + 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 + // @param callback call `callback` when done. + // @param [additionalData] An optional map which can contains vars - a map (key, value) of variables to apply + // + parse: function (str, callback, additionalData) { + var root; + var error = null; + var globalVars; + var modifyVars; + var ignored; + var preText = ''; + globalVars = (additionalData && additionalData.globalVars) ? Parser.serializeVars(additionalData.globalVars) + "\n" : ''; + modifyVars = (additionalData && additionalData.modifyVars) ? "\n" + Parser.serializeVars(additionalData.modifyVars) : ''; + if (context.pluginManager) { + var preProcessors = context.pluginManager.getPreProcessors(); + for (var i = 0; i < preProcessors.length; i++) { + str = preProcessors[i].process(str, { context: context, imports: imports, fileInfo: fileInfo }); + } + } + if (globalVars || (additionalData && additionalData.banner)) { + preText = ((additionalData && additionalData.banner) ? additionalData.banner : '') + globalVars; + ignored = imports.contentsIgnoredChars; + ignored[fileInfo.filename] = ignored[fileInfo.filename] || 0; + ignored[fileInfo.filename] += preText.length; + } + str = str.replace(/\r\n?/g, '\n'); + // Remove potential UTF Byte Order Mark + str = preText + str.replace(/^\uFEFF/, '') + modifyVars; + imports.contents[fileInfo.filename] = str; + // Start with the primary rule. + // The whole syntax tree is held under a Ruleset node, + // with the `root` property set to true, so no `{}` are + // output. The callback is called when the input is parsed. + try { + parserInput.start(str, context.chunkInput, function fail(msg, index) { + throw new LessError({ + index: index, + type: 'Parse', + message: msg, + filename: fileInfo.filename + }, imports); + }); + 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)); + } + // If `i` is smaller than the `input.length - 1`, + // it means the parser wasn't able to parse the whole + // string, so we've got a parsing error. + // + // We try to extract a \n delimited string, + // showing the line where the parse error occurred. + // We split it up into two parts (the part which parsed, + // and the part which didn't), so we can color them differently. + var endInfo = parserInput.end(); + if (!endInfo.isFinished) { + var message = endInfo.furthestPossibleErrorMessage; + if (!message) { + message = 'Unrecognised input'; + if (endInfo.furthestChar === '}') { + message += '. Possibly missing opening \'{\''; + } + else if (endInfo.furthestChar === ')') { + message += '. Possibly missing opening \'(\''; + } + else if (endInfo.furthestReachedEnd) { + message += '. Possibly missing something'; + } + } + error = new LessError({ + type: 'Parse', + message: message, + index: endInfo.furthest, + filename: fileInfo.filename + }, imports); + } + var finish = function (e) { + e = error || e || imports.error; + if (e) { + if (!(e instanceof LessError)) { + e = new LessError(e, imports, fileInfo.filename); + } + return callback(e); + } + else { + return callback(null, root); + } + }; + if (context.processImports !== false) { + new visitors.ImportVisitor(imports, finish) + .run(root); + } + else { + return finish(); + } + }, + // + // Here in, the parsing rules/functions + // + // The basic structure of the syntax tree generated is as follows: + // + // Ruleset -> Declaration -> Value -> Expression -> Entity + // + // Here's some Less code: + // + // .class { + // color: #fff; + // border: 1px solid #000; + // width: @w + 4px; + // > .child {...} + // } + // + // And here's what the parse tree might look like: + // + // Ruleset (Selector '.class', [ + // 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'], [...]) + // ]) + // + // In general, most rules will try to parse a token with the `$re()` function, and if the return + // value is truly, will return a new node, of the relevant type. Sometimes, we need to check + // first, before parsing, that's when we use `peek()`. + // + parsers: parsers = { + // + // The `primary` rule is the *entry* and *exit* point of the parser. + // The rules here can appear at any level of the parse tree. + // + // The recursive nature of the grammar is an interplay between the `block` + // rule, which represents `{ ... }`, the `ruleset` rule, and this `primary` rule, + // as represented by this simplified grammar: + // + // primary → (ruleset | declaration)+ + // ruleset → selector+ block + // block → '{' primary '}' + // + // Only at one point is the primary rule not called from the + // block rule: at the root level. + // + primary: function () { + var mixin = this.mixin; + var root = []; + var node; + while (true) { + while (true) { + node = this.comment(); + if (!node) { + break; + } + root.push(node); + } + // always process comments before deciding if finished + if (parserInput.finished) { + break; + } + if (parserInput.peek('}')) { + break; + } + node = this.extendRule(); + if (node) { + root = root.concat(node); + continue; + } + node = mixin.definition() || this.declaration() || mixin.call(false, false) || + this.ruleset() || this.variableCall() || this.entities.call() || this.atrule(); + if (node) { + root.push(node); + } + else { + var foundSemiColon = false; + while (parserInput.$char(';')) { + foundSemiColon = true; + } + if (!foundSemiColon) { + break; + } + } + } + return root; + }, + // comments are collected by the main parsing mechanism and then assigned to nodes + // where the current structure allows it + comment: function () { + if (parserInput.commentStore.length) { + var comment = parserInput.commentStore.shift(); + return new (tree.Comment)(comment.text, comment.isLineComment, comment.index, fileInfo); + } + }, + // + // Entities are tokens which can be found inside an Expression + // + entities: { + mixinLookup: function () { + return parsers.mixin.call(true, true); + }, + // + // A string, which supports escaping " and ' + // + // "milky way" 'he\'s the one!' + // + quoted: function (forceEscaped) { + var str; + var index = parserInput.i; + var isEscaped = false; + parserInput.save(); + if (parserInput.$char('~')) { + isEscaped = true; + } + else if (forceEscaped) { + parserInput.restore(); + return; + } + str = parserInput.$quoted(); + if (!str) { + parserInput.restore(); + return; + } + parserInput.forget(); + return new (tree.Quoted)(str.charAt(0), str.substr(1, str.length - 2), isEscaped, index, fileInfo); + }, + // + // A catch-all word, such as: + // + // black border-collapse + // + keyword: function () { + var k = parserInput.$char('%') || parserInput.$re(/^\[?(?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+\]?/); + if (k) { + return tree.Color.fromKeyword(k) || new (tree.Keyword)(k); + } + }, + // + // A function call + // + // rgb(255, 0, 255) + // + // The arguments are parsed with the `entities.arguments` parser. + // + call: function () { + var name; + var args; + var func; + var index = parserInput.i; + // http://jsperf.com/case-insensitive-regex-vs-strtolower-then-regex/18 + if (parserInput.peek(/^url\(/i)) { + return; + } + parserInput.save(); + name = parserInput.$re(/^([\w-]+|%|~|progid:[\w\.]+)\(/); + if (!name) { + parserInput.forget(); + return; + } + name = name[1]; + func = this.customFuncCall(name); + if (func) { + args = func.parse(); + if (args && func.stop) { + parserInput.forget(); + return args; + } + } + args = this.arguments(args); + if (!parserInput.$char(')')) { + parserInput.restore('Could not parse call arguments or missing \')\''); + return; + } + parserInput.forget(); + return new (tree.Call)(name, args, index, fileInfo); + }, + // + // 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(...)`) + // + 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, + stop: stop // when true - stop after parse() and return its result, + // otherwise continue for plain args + }; + } + function condition() { + return [expect(parsers.condition, 'expected condition')]; + } + }, + arguments: function (prevArgs) { + var argsComma = prevArgs || []; + var argsSemiColon = []; + var isSemiColonSeparated; + var value; + parserInput.save(); + while (true) { + if (prevArgs) { + prevArgs = false; + } + else { + value = parsers.detachedRuleset() || this.assignment() || parsers.expression(); + if (!value) { + break; + } + if (value.value && value.value.length == 1) { + value = value.value[0]; + } + argsComma.push(value); + } + if (parserInput.$char(',')) { + continue; + } + if (parserInput.$char(';') || isSemiColonSeparated) { + isSemiColonSeparated = true; + value = (argsComma.length < 1) ? argsComma[0] + : new tree.Value(argsComma); + argsSemiColon.push(value); + argsComma = []; + } + } + parserInput.forget(); + return isSemiColonSeparated ? argsSemiColon : argsComma; + }, + literal: function () { + return this.dimension() || + this.color() || + this.quoted() || + this.unicodeDescriptor(); + }, + // Assignments are argument entities for calls. + // They are present in ie filter properties as shown below. + // + // filter: progid:DXImageTransform.Microsoft.Alpha( *opacity=50* ) + // + assignment: function () { + var key; + var value; + parserInput.save(); + key = parserInput.$re(/^\w+(?=\s?=)/i); + if (!key) { + parserInput.restore(); + return; + } + if (!parserInput.$char('=')) { + parserInput.restore(); + return; + } + value = parsers.entity(); + if (value) { + parserInput.forget(); + return new (tree.Assignment)(key, value); + } + else { + parserInput.restore(); + } + }, + // + // Parse url() tokens + // + // We use a specific rule for urls, because they don't really behave like + // standard function calls. The difference is that the argument doesn't have + // to be enclosed within a string, so it can't be parsed as an Expression. + // + url: function () { + var value; + var index = parserInput.i; + parserInput.autoCommentAbsorb = false; + if (!parserInput.$str('url(')) { + parserInput.autoCommentAbsorb = true; + return; + } + 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 instanceof tree.Property) ? + value : new (tree.Anonymous)(value, index), index, fileInfo); + }, + // + // A Variable entity, such as `@fink`, in + // + // width: @fink + 2px + // + // We use a different parser for variable definitions, + // see `parsers.variable`. + // + variable: function () { + var ch; + var name; + var index = parserInput.i; + parserInput.save(); + if (parserInput.currentChar() === '@' && (name = parserInput.$re(/^@@?[\w-]+/))) { + ch = parserInput.currentChar(); + if (ch === '(' || ch === '[' && !parserInput.prevChar().match(/^\s/)) { + // this may be a VariableCall lookup + var result = parsers.variableCall(name); + if (result) { + parserInput.forget(); + return result; + } + } + parserInput.forget(); + return new (tree.Variable)(name, index, fileInfo); + } + parserInput.restore(); + }, + // A variable entity using the protective {} e.g. @{var} + variableCurly: function () { + var curly; + var index = parserInput.i; + if (parserInput.currentChar() === '@' && (curly = parserInput.$re(/^@\{([\w-]+)\}/))) { + return new (tree.Variable)("@" + curly[1], index, fileInfo); + } + }, + // + // A Property accessor, such as `$color`, in + // + // background-color: $color + // + property: function () { + var name; + var 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; + var index = parserInput.i; + if (parserInput.currentChar() === '$' && (curly = parserInput.$re(/^\$\{([\w-]+)\}/))) { + return new (tree.Property)("$" + curly[1], index, fileInfo); + } + }, + // + // A Hexadecimal color + // + // #4F3C2F + // + // `rgb` and `hsl` colors are parsed through the `entities.call` parser. + // + color: function () { + var rgb; + parserInput.save(); + if (parserInput.currentChar() === '#' && (rgb = parserInput.$re(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3,4})([\w.#\[])?/))) { + if (!rgb[2]) { + parserInput.forget(); + return new (tree.Color)(rgb[1], undefined, rgb[0]); + } + } + parserInput.restore(); + }, + colorKeyword: function () { + parserInput.save(); + var autoCommentAbsorb = parserInput.autoCommentAbsorb; + parserInput.autoCommentAbsorb = false; + var k = parserInput.$re(/^[_A-Za-z-][_A-Za-z0-9-]+/); + parserInput.autoCommentAbsorb = autoCommentAbsorb; + if (!k) { + parserInput.forget(); + return; + } + parserInput.restore(); + var color = tree.Color.fromKeyword(k); + if (color) { + parserInput.$str(k); + return color; + } + }, + // + // A Dimension, that is, a number and a unit + // + // 0.5em 95% + // + dimension: function () { + if (parserInput.peekNotNumeric()) { + return; + } + var value = parserInput.$re(/^([+-]?\d*\.?\d+)(%|[a-z_]+)?/i); + if (value) { + return new (tree.Dimension)(value[1], value[2]); + } + }, + // + // A unicode descriptor, as is used in unicode-range + // + // U+0?? or U+00A1-00A9 + // + unicodeDescriptor: function () { + var ud; + ud = parserInput.$re(/^U\+[0-9a-fA-F?]+(\-[0-9a-fA-F?]+)?/); + if (ud) { + return new (tree.UnicodeDescriptor)(ud[0]); + } + }, + // + // JavaScript code to be evaluated + // + // `window.location.href` + // + javascript: function () { + var js; + var index = parserInput.i; + parserInput.save(); + var escape = parserInput.$char('~'); + var jsQuote = parserInput.$char('`'); + if (!jsQuote) { + parserInput.restore(); + return; + } + js = parserInput.$re(/^[^`]*`/); + if (js) { + parserInput.forget(); + return new (tree.JavaScript)(js.substr(0, js.length - 1), Boolean(escape), index, fileInfo); + } + parserInput.restore('invalid javascript definition'); + } + }, + // + // The variable part of a variable definition. Used in the `rule` parser + // + // @fink: + // + variable: function () { + var name; + if (parserInput.currentChar() === '@' && (name = parserInput.$re(/^(@[\w-]+)\s*:/))) { + return name[1]; + } + }, + // + // Call a variable value to retrieve a detached ruleset + // or a value from a detached ruleset's rules. + // + // @fink(); + // @fink; + // color: @fink[@color]; + // + variableCall: function (parsedName) { + var lookups; + var i = parserInput.i; + var inValue = !!parsedName; + var name = parsedName; + parserInput.save(); + if (name || (parserInput.currentChar() === '@' + && (name = parserInput.$re(/^(@[\w-]+)(\(\s*\))?/)))) { + lookups = this.mixin.ruleLookups(); + if (!lookups && ((inValue && parserInput.$str('()') !== '()') || (name[2] !== '()'))) { + parserInput.restore('Missing \'[...]\' lookup in variable call'); + return; + } + if (!inValue) { + name = name[1]; + } + var call = new tree.VariableCall(name, i, fileInfo); + if (!inValue && parsers.end()) { + parserInput.forget(); + return call; + } + else { + parserInput.forget(); + return new tree.NamespaceValue(call, lookups, i, fileInfo); + } + } + parserInput.restore(); + }, + // + // extend syntax - used to extend selectors + // + extend: function (isRule) { + var elements; + var e; + var index = parserInput.i; + var option; + var extendList; + var extend; + if (!parserInput.$str(isRule ? '&:extend(' : ':extend(')) { + return; + } + do { + option = null; + elements = null; + while (!(option = parserInput.$re(/^(all)(?=\s*(\)|,))/))) { + e = this.element(); + if (!e) { + break; + } + if (elements) { + elements.push(e); + } + else { + elements = [e]; + } + } + option = option && option[1]; + if (!elements) { + error('Missing target selector for :extend().'); + } + extend = new (tree.Extend)(new (tree.Selector)(elements), option, index, fileInfo); + if (extendList) { + extendList.push(extend); + } + else { + extendList = [extend]; + } + } while (parserInput.$char(',')); + expect(/^\)/); + if (isRule) { + expect(/^;/); + } + return extendList; + }, + // + // extendRule - used in a rule to extend all the parent selectors + // + extendRule: function () { + return this.extend(true); + }, + // + // Mixins + // + mixin: { + // + // A Mixin call, with an optional argument list + // + // #mixins > .square(#fff); + // #mixins.square(#fff); + // .rounded(4px, black); + // .button; + // + // We can lookup / return a value using the lookup syntax: + // + // color: #mixin.square(#fff)[@color]; + // + // The `while` loop is there because mixins can be + // namespaced, but we only support the child and descendant + // selector for now. + // + call: function (inValue, getLookup) { + var s = parserInput.currentChar(); + var important = false; + var lookups; + var index = parserInput.i; + var elements; + var args; + var hasParens; + if (s !== '.' && s !== '#') { + return; + } + parserInput.save(); // stop us absorbing part of an invalid selector + elements = this.elements(); + if (elements) { + if (parserInput.$char('(')) { + args = this.args(true).args; + expectChar(')'); + hasParens = true; + } + if (getLookup !== false) { + lookups = this.ruleLookups(); + } + if (getLookup === true && !lookups) { + parserInput.restore(); + return; + } + if (inValue && !lookups && !hasParens) { + // This isn't a valid in-value mixin call + parserInput.restore(); + return; + } + if (!inValue && parsers.important()) { + important = true; + } + if (inValue || parsers.end()) { + parserInput.forget(); + var mixin = new (tree.mixin.Call)(elements, args, index, fileInfo, !lookups && important); + if (lookups) { + return new tree.NamespaceValue(mixin, lookups); + } + else { + return mixin; + } + } + } + parserInput.restore(); + }, + /** + * Matching elements for mixins + * (Start with . or # and can have > ) + */ + elements: function () { + var elements; + var e; + var c; + var elem; + var elemIndex; + var re = /^[#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/; + while (true) { + elemIndex = parserInput.i; + e = parserInput.$re(re); + if (!e) { + break; + } + elem = new (tree.Element)(c, e, false, elemIndex, fileInfo); + if (elements) { + elements.push(elem); + } + else { + elements = [elem]; + } + c = parserInput.$char('>'); + } + return elements; + }, + args: function (isCall) { + var entities = parsers.entities; + var returner = { args: null, variadic: false }; + var expressions = []; + var argsSemiColon = []; + var argsComma = []; + var isSemiColonSeparated; + var expressionContainsNamed; + var name; + var nameLoop; + var value; + var arg; + var expand; + var hasSep = true; + parserInput.save(); + while (true) { + if (isCall) { + arg = parsers.detachedRuleset() || parsers.expression(); + } + else { + parserInput.commentStore.length = 0; + if (parserInput.$str('...')) { + returner.variadic = true; + if (parserInput.$char(';') && !isSemiColonSeparated) { + isSemiColonSeparated = true; + } + (isSemiColonSeparated ? argsSemiColon : argsComma) + .push({ variadic: true }); + break; + } + arg = entities.variable() || entities.property() || entities.literal() || entities.keyword() || this.call(true); + } + if (!arg || !hasSep) { + break; + } + nameLoop = null; + if (arg.throwAwayComments) { + arg.throwAwayComments(); + } + value = arg; + var val = null; + if (isCall) { + // Variable + if (arg.value && arg.value.length == 1) { + val = arg.value[0]; + } + } + else { + val = arg; + } + if (val && (val instanceof tree.Variable || val instanceof tree.Property)) { + if (parserInput.$char(':')) { + if (expressions.length > 0) { + if (isSemiColonSeparated) { + error('Cannot mix ; and , as delimiter types'); + } + expressionContainsNamed = true; + } + value = parsers.detachedRuleset() || parsers.expression(); + if (!value) { + if (isCall) { + error('could not understand value for named argument'); + } + else { + parserInput.restore(); + returner.args = []; + return returner; + } + } + nameLoop = (name = val.name); + } + else if (parserInput.$str('...')) { + if (!isCall) { + returner.variadic = true; + if (parserInput.$char(';') && !isSemiColonSeparated) { + isSemiColonSeparated = true; + } + (isSemiColonSeparated ? argsSemiColon : argsComma) + .push({ name: arg.name, variadic: true }); + break; + } + else { + expand = true; + } + } + else if (!isCall) { + name = nameLoop = val.name; + value = null; + } + } + if (value) { + expressions.push(value); + } + argsComma.push({ name: nameLoop, value: value, expand: expand }); + if (parserInput.$char(',')) { + hasSep = true; + continue; + } + hasSep = parserInput.$char(';') === ';'; + if (hasSep || isSemiColonSeparated) { + if (expressionContainsNamed) { + error('Cannot mix ; and , as delimiter types'); + } + isSemiColonSeparated = true; + if (expressions.length > 1) { + value = new (tree.Value)(expressions); + } + argsSemiColon.push({ name: name, value: value, expand: expand }); + name = null; + expressions = []; + expressionContainsNamed = false; + } + } + parserInput.forget(); + returner.args = isSemiColonSeparated ? argsSemiColon : argsComma; + return returner; + }, + // + // A Mixin definition, with a list of parameters + // + // .rounded (@radius: 2px, @color) { + // ... + // } + // + // Until we have a finer grained state-machine, we have to + // do a look-ahead, to make sure we don't have a mixin call. + // See the `rule` function for more information. + // + // We start by matching `.rounded (`, and then proceed on to + // the argument list, which has optional default values. + // We store the parameters in `params`, with a `value` key, + // if there is a value, such as in the case of `@radius`. + // + // Once we've got our params list, and a closing `)`, we parse + // the `{...}` block. + // + definition: function () { + var name; + var params = []; + var match; + var ruleset; + var cond; + var variadic = false; + if ((parserInput.currentChar() !== '.' && parserInput.currentChar() !== '#') || + parserInput.peek(/^[^{]*\}/)) { + return; + } + parserInput.save(); + match = parserInput.$re(/^([#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+)\s*\(/); + if (match) { + name = match[1]; + var argInfo = this.args(false); + params = argInfo.args; + variadic = argInfo.variadic; + // .mixincall("@{a}"); + // looks a bit like a mixin definition.. + // also + // .mixincall(@a: {rule: set;}); + // so we have to be nice and restore + if (!parserInput.$char(')')) { + parserInput.restore('Missing closing \')\''); + return; + } + parserInput.commentStore.length = 0; + if (parserInput.$str('when')) { // Guard + cond = expect(parsers.conditions, 'expected condition'); + } + ruleset = parsers.block(); + if (ruleset) { + parserInput.forget(); + return new (tree.mixin.Definition)(name, params, ruleset, cond, variadic); + } + else { + parserInput.restore(); + } + } + else { + parserInput.restore(); + } + }, + ruleLookups: function () { + var rule; + var lookups = []; + if (parserInput.currentChar() !== '[') { + return; + } + while (true) { + parserInput.save(); + rule = this.lookupValue(); + if (!rule && rule !== '') { + parserInput.restore(); + break; + } + lookups.push(rule); + parserInput.forget(); + } + if (lookups.length > 0) { + return lookups; + } + }, + lookupValue: function () { + parserInput.save(); + if (!parserInput.$char('[')) { + parserInput.restore(); + return; + } + var name = parserInput.$re(/^(?:[@$]{0,2})[_a-zA-Z0-9-]*/); + if (!parserInput.$char(']')) { + parserInput.restore(); + return; + } + if (name || name === '') { + parserInput.forget(); + return name; + } + parserInput.restore(); + } + }, + // + // Entities are the smallest recognized token, + // and can be found inside a rule's value. + // + entity: function () { + var entities = this.entities; + return this.comment() || entities.literal() || entities.variable() || entities.url() || + entities.property() || entities.call() || entities.keyword() || this.mixin.call(true) || + entities.javascript(); + }, + // + // 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. + // + end: function () { + return parserInput.$char(';') || parserInput.peek('}'); + }, + // + // IE's alpha function + // + // alpha(opacity=88) + // + ieAlpha: function () { + var value; + // http://jsperf.com/case-insensitive-regex-vs-strtolower-then-regex/18 + if (!parserInput.$re(/^opacity=/i)) { + return; + } + value = parserInput.$re(/^\d+/); + if (!value) { + value = expect(parsers.entities.variable, 'Could not parse alpha'); + value = "@{" + value.name.slice(1) + "}"; + } + expectChar(')'); + return new tree.Quoted('', "alpha(opacity=" + value + ")"); + }, + // + // A Selector Element + // + // div + // + h1 + // #socks + // input[type="text"] + // + // Elements are the building blocks for Selectors, + // they are made out of a `Combinator` (see combinator rule), + // and an element name, such as a tag a class, or `*`. + // + element: function () { + var e; + var c; + var v; + var index = parserInput.i; + c = this.combinator(); + e = parserInput.$re(/^(?:\d+\.\d+|\d+)%/) || + parserInput.$re(/^(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/) || + parserInput.$char('*') || parserInput.$char('&') || this.attribute() || + parserInput.$re(/^\([^&()@]+\)/) || parserInput.$re(/^[\.#:](?=@)/) || + this.entities.variableCurly(); + if (!e) { + parserInput.save(); + if (parserInput.$char('(')) { + if ((v = this.selector(false)) && parserInput.$char(')')) { + e = new (tree.Paren)(v); + parserInput.forget(); + } + else { + parserInput.restore('Missing closing \')\''); + } + } + else { + parserInput.forget(); + } + } + if (e) { + return new (tree.Element)(c, e, e instanceof tree.Variable, index, fileInfo); + } + }, + // + // Combinators combine elements together, in a Selector. + // + // Because our parser isn't white-space sensitive, special care + // has to be taken, when parsing the descendant combinator, ` `, + // as it's an empty space. We have to check the previous character + // in the input, to see if it's a ` ` character. More info on how + // we deal with this in *combinator.js*. + // + combinator: function () { + var c = parserInput.currentChar(); + if (c === '/') { + parserInput.save(); + var slashedCombinator = parserInput.$re(/^\/[a-z]+\//i); + if (slashedCombinator) { + parserInput.forget(); + return new (tree.Combinator)(slashedCombinator); + } + parserInput.restore(); + } + if (c === '>' || c === '+' || c === '~' || c === '|' || c === '^') { + parserInput.i++; + if (c === '^' && parserInput.currentChar() === '^') { + c = '^^'; + parserInput.i++; + } + while (parserInput.isWhitespace()) { + parserInput.i++; + } + return new (tree.Combinator)(c); + } + else if (parserInput.isWhitespace(-1)) { + return new (tree.Combinator)(' '); + } + else { + return new (tree.Combinator)(null); + } + }, + // + // A CSS Selector + // with less extensions e.g. the ability to extend and guard + // + // .class > div + h1 + // li a:hover + // + // Selectors are made out of one or more Elements, see above. + // + selector: function (isLess) { + var index = parserInput.i; + var elements; + var extendList; + var c; + var e; + var allExtends; + var when; + var 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'); + } + else if (condition) { + error('CSS guard can only be used at the end of selector'); + } + else if (extendList) { + if (allExtends) { + allExtends = allExtends.concat(extendList); + } + else { + allExtends = extendList; + } + } + else { + if (allExtends) { + error('Extend can only be used at the end of selector'); + } + c = parserInput.currentChar(); + if (elements) { + elements.push(e); + } + else { + elements = [e]; + } + e = null; + } + if (c === '{' || c === '}' || c === ';' || c === ',' || c === ')') { + break; + } + } + if (elements) { + return new (tree.Selector)(elements, allExtends, condition, index, fileInfo); + } + if (allExtends) { + error('Extend must be used to extend a selector, it cannot be used on its own'); + } + }, + selectors: function () { + var s; + var selectors; + while (true) { + s = this.selector(); + if (!s) { + break; + } + if (selectors) { + selectors.push(s); + } + else { + selectors = [s]; + } + parserInput.commentStore.length = 0; + if (s.condition && selectors.length > 1) { + error("Guards are only currently allowed on a single selector."); + } + if (!parserInput.$char(',')) { + break; + } + if (s.condition) { + error("Guards are only currently allowed on a single selector."); + } + parserInput.commentStore.length = 0; + } + return selectors; + }, + attribute: function () { + if (!parserInput.$char('[')) { + return; + } + var entities = this.entities; + var key; + var val; + var op; + if (!(key = entities.variableCurly())) { + key = expect(/^(?:[_A-Za-z0-9-\*]*\|)?(?:[_A-Za-z0-9-]|\\.)+/); + } + op = parserInput.$re(/^[|~*$^]?=/); + if (op) { + val = entities.quoted() || parserInput.$re(/^[0-9]+%/) || parserInput.$re(/^[\w-]+/) || entities.variableCurly(); + } + expectChar(']'); + return new (tree.Attribute)(key, op, val); + }, + // + // The `block` rule is used by `ruleset` and `mixin.definition`. + // It's a wrapper around the `primary` rule, with added `{}`. + // + block: function () { + var content; + if (parserInput.$char('{') && (content = this.primary()) && parserInput.$char('}')) { + return content; + } + }, + blockRuleset: function () { + var block = this.block(); + if (block) { + block = new tree.Ruleset(null, block); + } + return block; + }, + detachedRuleset: function () { + var argInfo; + var params; + var variadic; + parserInput.save(); + if (parserInput.$re(/^[.#]\(/)) { + /** + * DR args currently only implemented for each() function, and not + * yet settable as `@dr: #(@arg) {}` + * This should be done when DRs are merged with mixins. + * See: https://github.com/less/less-meta/issues/16 + */ + argInfo = this.mixin.args(false); + params = argInfo.args; + variadic = argInfo.variadic; + if (!parserInput.$char(')')) { + parserInput.restore(); + return; + } + } + var blockRuleset = this.blockRuleset(); + if (blockRuleset) { + parserInput.forget(); + if (params) { + return new tree.mixin.Definition(null, params, blockRuleset, null, variadic); + } + return new tree.DetachedRuleset(blockRuleset); + } + parserInput.restore(); + }, + // + // div, .class, body > p {...} + // + ruleset: function () { + var selectors; + var rules; + var debugInfo; + parserInput.save(); + if (context.dumpLineNumbers) { + debugInfo = getDebugInfo(parserInput.i); + } + selectors = this.selectors(); + if (selectors && (rules = this.block())) { + parserInput.forget(); + var ruleset = new (tree.Ruleset)(selectors, rules, context.strictImports); + if (context.dumpLineNumbers) { + ruleset.debugInfo = debugInfo; + } + return ruleset; + } + else { + parserInput.restore(); + } + }, + declaration: function () { + var name; + var value; + var index = parserInput.i; + var hasDR; + var c = parserInput.currentChar(); + var important; + var merge; + var isVariable; + if (c === '.' || c === '#' || c === '&' || c === ':') { + return; + } + parserInput.save(); + name = this.variable() || this.ruleProperty(); + if (name) { + isVariable = typeof name === 'string'; + if (isVariable) { + value = this.detachedRuleset(); + if (value) { + hasDR = true; + } + } + parserInput.commentStore.length = 0; + if (!value) { + // a name returned by this.ruleProperty() is always an array of the form: + // [string-1, ..., string-n, ""] or [string-1, ..., string-n, "+"] + // where each item is a tree.Keyword or tree.Variable + merge = !isVariable && name.length > 1 && name.pop().value; + // Custom property values get permissive parsing + if (name[0].value && name[0].value.slice(0, 2) === '--') { + value = this.permissiveValue(); + } + // Try to store values as anonymous + // If we need the value later we'll re-parse it in ruleset.parseValue + else { + 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, index, fileInfo); + } + if (!value) { + value = this.value(); + } + if (value) { + important = this.important(); + } + else if (isVariable) { + // As a last resort, try permissiveValue + value = this.permissiveValue(); + } + } + if (value && (this.end() || hasDR)) { + parserInput.forget(); + return new (tree.Declaration)(name, value, important, merge, index, fileInfo); + } + else { + parserInput.restore(); + } + } + else { + parserInput.restore(); + } + }, + anonymousValue: function () { + var index = parserInput.i; + var match = parserInput.$re(/^([^.#@\$+\/'"*`(;{}-]*);/); + if (match) { + return new (tree.Anonymous)(match[1], index); + } + }, + /** + * Used for custom properties, at-rules, and variables (as fallback) + * Parses almost anything inside of {} [] () "" blocks + * until it reaches outer-most tokens. + * + * First, it will try to parse comments and entities to reach + * the end. This is mostly like the Expression parser except no + * math is allowed. + */ + permissiveValue: function (untilTokens) { + var i; + var e; + var done; + var value; + var tok = untilTokens || ';'; + var index = parserInput.i; + var result = []; + function testCurrentChar() { + var char = parserInput.currentChar(); + if (typeof tok === 'string') { + return char === tok; + } + else { + return tok.test(char); + } + } + if (testCurrentChar()) { + return; + } + value = []; + do { + e = this.comment(); + if (e) { + value.push(e); + continue; + } + e = this.entity(); + if (e) { + value.push(e); + } + } while (e); + done = testCurrentChar(); + if (value.length > 0) { + value = new (tree.Expression)(value); + if (done) { + return value; + } + else { + result.push(value); + } + // Preserve space before $parseUntil as it will not + if (parserInput.prevChar() === ' ') { + result.push(new tree.Anonymous(' ', index)); + } + } + parserInput.save(); + value = parserInput.$parseUntil(tok); + if (value) { + if (typeof value === 'string') { + error("Expected '" + value + "'", 'Parse'); + } + if (value.length === 1 && value[0] === ' ') { + parserInput.forget(); + return new tree.Anonymous('', index); + } + var item = void 0; + for (i = 0; i < value.length; i++) { + item = value[i]; + if (Array.isArray(item)) { + // Treat actual quotes as normal quoted values + result.push(new tree.Quoted(item[0], item[1], true, index, fileInfo)); + } + else { + if (i === value.length - 1) { + item = item.trim(); + } + // Treat like quoted values, but replace vars like unquoted expressions + var quote = new tree.Quoted('\'', item, true, index, fileInfo); + quote.variableRegex = /@([\w-]+)/g; + quote.propRegex = /\$([\w-]+)/g; + result.push(quote); + } + } + parserInput.forget(); + return new tree.Expression(result, true); + } + parserInput.restore(); + }, + // + // An @import atrule + // + // @import "lib"; + // + // 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. + // + 'import': function () { + var path; + var features; + var index = parserInput.i; + var dir = parserInput.$re(/^@import?\s+/); + if (dir) { + var options = (dir ? this.importOptions() : null) || {}; + if ((path = this.entities.quoted() || this.entities.url())) { + features = this.mediaFeatures(); + if (!parserInput.$char(';')) { + parserInput.i = index; + error('missing semi-colon or unrecognised media features on import'); + } + features = features && new (tree.Value)(features); + return new (tree.Import)(path, features, options, index, fileInfo); + } + else { + parserInput.i = index; + error('malformed import statement'); + } + } + }, + importOptions: function () { + var o; + var options = {}; + var optionName; + var value; + // list of options, surrounded by parens + if (!parserInput.$char('(')) { + return null; + } + do { + o = this.importOption(); + if (o) { + optionName = o; + value = true; + switch (optionName) { + case 'css': + optionName = 'less'; + value = false; + break; + case 'once': + optionName = 'multiple'; + value = false; + break; + } + options[optionName] = value; + if (!parserInput.$char(',')) { + break; + } + } + } while (o); + expectChar(')'); + return options; + }, + importOption: function () { + var opt = parserInput.$re(/^(less|css|multiple|once|inline|reference|optional)/); + if (opt) { + return opt[1]; + } + }, + mediaFeature: function () { + var entities = this.entities; + var nodes = []; + var e; + var p; + parserInput.save(); + do { + e = entities.keyword() || entities.variable() || entities.mixinLookup(); + if (e) { + nodes.push(e); + } + else if (parserInput.$char('(')) { + p = this.property(); + e = this.value(); + if (parserInput.$char(')')) { + if (p && e) { + 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 { + error('badly formed media feature definition'); + } + } + else { + error('Missing closing \')\'', 'Parse'); + } + } + } while (e); + parserInput.forget(); + if (nodes.length > 0) { + return new (tree.Expression)(nodes); + } + }, + mediaFeatures: function () { + var entities = this.entities; + var features = []; + var e; + do { + e = this.mediaFeature(); + if (e) { + features.push(e); + if (!parserInput.$char(',')) { + break; + } + } + else { + e = entities.variable() || entities.mixinLookup(); + if (e) { + features.push(e); + if (!parserInput.$char(',')) { + break; + } + } + } + } while (e); + return features.length > 0 ? features : null; + }, + media: function () { + var features; + var rules; + var media; + var debugInfo; + var index = parserInput.i; + if (context.dumpLineNumbers) { + debugInfo = getDebugInfo(index); + } + parserInput.save(); + if (parserInput.$str('@media')) { + features = this.mediaFeatures(); + rules = this.block(); + if (!rules) { + error('media definitions require block statements after any features'); + } + parserInput.forget(); + media = new (tree.Media)(rules, features, index, fileInfo); + if (context.dumpLineNumbers) { + media.debugInfo = debugInfo; + } + return media; + } + parserInput.restore(); + }, + // + // A @plugin directive, used to import plugins dynamically. + // + // @plugin (args) "lib"; + // + plugin: function () { + var path; + var args; + var options; + var index = parserInput.i; + var dir = parserInput.$re(/^@plugin?\s+/); + if (dir) { + 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'); + } + return new (tree.Import)(path, null, options, index, fileInfo); + } + else { + parserInput.i = index; + 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 AtRule + // + // @charset "utf-8"; + // + atrule: function () { + var index = parserInput.i; + var name; + var value; + var rules; + var nonVendorSpecificName; + var hasIdentifier; + var hasExpression; + var hasUnknown; + var hasBlock = true; + var isRooted = true; + if (parserInput.currentChar() !== '@') { + return; + } + value = this['import']() || this.plugin() || this.media(); + if (value) { + return value; + } + parserInput.save(); + name = parserInput.$re(/^@[a-z-]+/); + if (!name) { + return; + } + nonVendorSpecificName = name; + if (name.charAt(1) == '-' && name.indexOf('-', 2) > 0) { + nonVendorSpecificName = "@" + name.slice(name.indexOf('-', 2) + 1); + } + switch (nonVendorSpecificName) { + case '@charset': + hasIdentifier = true; + hasBlock = false; + break; + case '@namespace': + hasExpression = true; + hasBlock = false; + break; + case '@keyframes': + case '@counter-style': + hasIdentifier = true; + break; + case '@document': + case '@supports': + hasUnknown = true; + isRooted = false; + break; + default: + hasUnknown = true; + break; + } + parserInput.commentStore.length = 0; + if (hasIdentifier) { + value = this.entity(); + if (!value) { + error("expected " + name + " identifier"); + } + } + else if (hasExpression) { + value = this.expression(); + if (!value) { + error("expected " + name + " expression"); + } + } + else if (hasUnknown) { + value = this.permissiveValue(/^[{;]/); + hasBlock = (parserInput.currentChar() === '{'); + if (!value) { + if (!hasBlock && parserInput.currentChar() !== ';') { + error(name + " rule is missing block or ending semi-colon"); + } + } + else if (!value.value) { + value = null; + } + } + if (hasBlock) { + rules = this.blockRuleset(); + } + if (rules || (!hasBlock && value && parserInput.$char(';'))) { + parserInput.forget(); + return new (tree.AtRule)(name, value, rules, index, fileInfo, context.dumpLineNumbers ? getDebugInfo(index) : null, isRooted); + } + parserInput.restore('at-rule options not recognised'); + }, + // + // A Value is a comma-delimited list of Expressions + // + // font-family: Baskerville, Georgia, serif; + // + // In a Rule, a Value represents everything after the `:`, + // and before the `;`. + // + value: function () { + var e; + var expressions = []; + var index = parserInput.i; + do { + e = this.expression(); + if (e) { + expressions.push(e); + if (!parserInput.$char(',')) { + break; + } + } + } while (e); + if (expressions.length > 0) { + return new (tree.Value)(expressions, index); + } + }, + important: function () { + if (parserInput.currentChar() === '!') { + return parserInput.$re(/^! *important/); + } + }, + sub: function () { + var a; + var e; + parserInput.save(); + if (parserInput.$char('(')) { + a = this.addition(); + if (a && parserInput.$char(')')) { + parserInput.forget(); + e = new (tree.Expression)([a]); + e.parens = true; + return e; + } + parserInput.restore('Expected \')\''); + return; + } + parserInput.restore(); + }, + multiplication: function () { + var m; + var a; + var op; + var operation; + var isSpaced; + m = this.operand(); + if (m) { + isSpaced = parserInput.isWhitespace(-1); + while (true) { + if (parserInput.peek(/^\/[*\/]/)) { + break; + } + parserInput.save(); + op = parserInput.$char('/') || parserInput.$char('*') || parserInput.$str('./'); + if (!op) { + parserInput.forget(); + break; + } + a = this.operand(); + if (!a) { + parserInput.restore(); + break; + } + parserInput.forget(); + m.parensInOp = true; + a.parensInOp = true; + operation = new (tree.Operation)(op, [operation || m, a], isSpaced); + isSpaced = parserInput.isWhitespace(-1); + } + return operation || m; + } + }, + addition: function () { + var m; + var a; + var op; + var operation; + var isSpaced; + m = this.multiplication(); + if (m) { + isSpaced = parserInput.isWhitespace(-1); + while (true) { + op = parserInput.$re(/^[-+]\s+/) || (!isSpaced && (parserInput.$char('+') || parserInput.$char('-'))); + if (!op) { + break; + } + a = this.multiplication(); + if (!a) { + break; + } + m.parensInOp = true; + a.parensInOp = true; + operation = new (tree.Operation)(op, [operation || m, a], isSpaced); + isSpaced = parserInput.isWhitespace(-1); + } + return operation || m; + } + }, + conditions: function () { + var a; + var b; + var index = parserInput.i; + var condition; + a = this.condition(true); + if (a) { + while (true) { + if (!parserInput.peek(/^,\s*(not\s*)?\(/) || !parserInput.$char(',')) { + break; + } + b = this.condition(true); + if (!b) { + break; + } + condition = new (tree.Condition)('or', condition || a, b, index); + } + return condition || a; + } + }, + condition: function (needsParens) { + var result; + var logical; + var next; + function or() { + return parserInput.$str('or'); + } + result = this.conditionAnd(needsParens); + if (!result) { + return; + } + logical = or(); + if (logical) { + next = this.condition(needsParens); + if (next) { + result = new (tree.Condition)(logical, result, next); + } + else { + return; + } + } + return result; + }, + conditionAnd: function (needsParens) { + var result; + var logical; + var next; + var self = this; + function insideCondition() { + var cond = self.negatedCondition(needsParens) || self.parenthesisCondition(needsParens); + if (!cond && !needsParens) { + return self.atomicCondition(needsParens); + } + return cond; + } + function and() { + return parserInput.$str('and'); + } + result = insideCondition(); + if (!result) { + return; + } + logical = and(); + if (logical) { + next = this.conditionAnd(needsParens); + if (next) { + result = new (tree.Condition)(logical, result, next); + } + else { + return; + } + } + return result; + }, + negatedCondition: function (needsParens) { + if (parserInput.$str('not')) { + var result = this.parenthesisCondition(needsParens); + if (result) { + result.negate = !result.negate; + } + return result; + } + }, + parenthesisCondition: function (needsParens) { + function tryConditionFollowedByParenthesis(me) { + var body; + parserInput.save(); + body = me.condition(needsParens); + if (!body) { + parserInput.restore(); + return; + } + if (!parserInput.$char(')')) { + parserInput.restore(); + return; + } + parserInput.forget(); + return body; + } + var body; + parserInput.save(); + if (!parserInput.$str('(')) { + parserInput.restore(); + return; + } + body = tryConditionFollowedByParenthesis(this); + if (body) { + parserInput.forget(); + return body; + } + body = this.atomicCondition(needsParens); + if (!body) { + parserInput.restore(); + return; + } + if (!parserInput.$char(')')) { + parserInput.restore("expected ')' got '" + parserInput.currentChar() + "'"); + return; + } + parserInput.forget(); + return body; + }, + atomicCondition: function (needsParens) { + var entities = this.entities; + var index = parserInput.i; + var a; + var b; + var c; + var op; + function cond() { + return this.addition() || entities.keyword() || entities.quoted() || entities.mixinLookup(); + } + cond = cond.bind(this); + a = cond(); + if (a) { + if (parserInput.$char('>')) { + if (parserInput.$char('=')) { + op = '>='; + } + else { + op = '>'; + } + } + else if (parserInput.$char('<')) { + if (parserInput.$char('=')) { + op = '<='; + } + else { + op = '<'; + } + } + else if (parserInput.$char('=')) { + if (parserInput.$char('>')) { + op = '=>'; + } + else if (parserInput.$char('<')) { + op = '=<'; + } + else { + op = '='; + } + } + if (op) { + b = cond(); + if (b) { + c = new (tree.Condition)(op, a, b, index, false); + } + else { + error('expected expression'); + } + } + else { + c = new (tree.Condition)('=', a, new (tree.Keyword)('true'), index, false); + } + return c; + } + }, + // + // An operand is anything that can be part of an operation, + // such as a Color, or a Variable + // + operand: function () { + var entities = this.entities; + var negate; + if (parserInput.peek(/^-[@\$\(]/)) { + negate = parserInput.$char('-'); + } + var o = this.sub() || entities.dimension() || + entities.color() || entities.variable() || + entities.property() || entities.call() || + entities.quoted(true) || entities.colorKeyword() || + entities.mixinLookup(); + if (negate) { + o.parensInOp = true; + o = new (tree.Negative)(o); + } + return o; + }, + // + // Expressions either represent mathematical operations, + // or white-space delimited Entities. + // + // 1px solid black + // @var * 2 + // + expression: function () { + var entities = []; + var e; + var delim; + var index = parserInput.i; + do { + e = this.comment(); + if (e) { + entities.push(e); + continue; + } + e = this.addition() || this.entity(); + if (e instanceof tree.Comment) { + e = null; + } + if (e) { + entities.push(e); + // operations do not allow keyword "/" dimension (e.g. small/20px) so we support that here + if (!parserInput.peek(/^\/[\/*]/)) { + delim = parserInput.$char('/'); + if (delim) { + entities.push(new (tree.Anonymous)(delim, index)); + } + } + } + } while (e); + if (entities.length > 0) { + return new (tree.Expression)(entities); + } + }, + property: function () { + var name = parserInput.$re(/^(\*?-?[_a-zA-Z0-9-]+)\s*:/); + if (name) { + return name[1]; + } + }, + ruleProperty: function () { + var name = []; + var index = []; + var s; + var k; + parserInput.save(); + var simpleProperty = parserInput.$re(/^([_a-zA-Z0-9-]+)\s*:/); + if (simpleProperty) { + name = [new (tree.Keyword)(simpleProperty[1])]; + parserInput.forget(); + return name; + } + function match(re) { + var i = parserInput.i; + var chunk = parserInput.$re(re); + if (chunk) { + index.push(i); + return name.push(chunk[1]); + } + } + match(/^(\*?)/); + while (true) { + if (!match(/^((?:[\w-]+)|(?:[@\$]\{[\w-]+\}))/)) { + break; + } + } + if ((name.length > 1) && match(/^((?:\+_|\+)?)\s*:/)) { + parserInput.forget(); + // at last, we have the complete match now. move forward, + // convert name particles to tree objects and return: + if (name[0] === '') { + name.shift(); + index.shift(); + } + for (k = 0; k < name.length; k++) { + s = name[k]; + name[k] = (s.charAt(0) !== '@' && s.charAt(0) !== '$') ? + new (tree.Keyword)(s) : + (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; + } + parserInput.restore(); + } + } + }; + }; + Parser.serializeVars = function (vars) { + var s = ''; + for (var name_1 in vars) { + if (Object.hasOwnProperty.call(vars, name_1)) { + var value = vars[name_1]; + s += ((name_1[0] === '@') ? '' : '@') + name_1 + ": " + value + ((String(value).slice(-1) === ';') ? '' : ';'); + } + } + return s; + }; + + function boolean(condition) { + return condition ? Keyword.True : Keyword.False; + } + /** + * Functions with evalArgs set to false are sent context + * as the first argument. + */ + function If(context, condition, trueValue, falseValue) { + return condition.eval(context) ? trueValue.eval(context) + : (falseValue ? falseValue.eval(context) : new Anonymous); + } + If.evalArgs = false; + function isdefined(context, variable) { + try { + variable.eval(context); + return Keyword.True; + } + catch (e) { + return Keyword.False; + } + } + isdefined.evalArgs = false; + var boolean$1 = { isdefined: isdefined, boolean: boolean, 'if': If }; + + var colorFunctions; + function clamp(val) { + return Math.min(1, Math.max(0, val)); + } + function hsla(origColor, hsl) { + var color = colorFunctions.hsla(hsl.h, hsl.s, hsl.l, hsl.a); + if (color) { + if (origColor.value && + /^(rgb|hsl)/.test(origColor.value)) { + color.value = origColor.value; + } + else { + color.value = 'rgb'; + } + return color; + } + } + function toHSL(color) { + if (color.toHSL) { + return color.toHSL(); + } + else { + throw new Error('Argument cannot be evaluated to a color'); + } + } + function toHSV(color) { + if (color.toHSV) { + return color.toHSV(); + } + else { + throw new Error('Argument cannot be evaluated to a color'); + } + } + function number$1(n) { + if (n instanceof Dimension) { + return parseFloat(n.unit.is('%') ? n.value / 100 : n.value); + } + else if (typeof n === 'number') { + return n; + } + else { + throw { + type: 'Argument', + message: 'color functions take numbers as parameters' + }; + } + } + function scaled(n, size) { + if (n instanceof Dimension && n.unit.is('%')) { + return parseFloat(n.value * size / 100); + } + else { + return number$1(n); + } + } + colorFunctions = { + rgb: function (r, g, b) { + var a = 1; + /** + * Comma-less syntax + * e.g. rgb(0 128 255 / 50%) + */ + if (r instanceof Expression) { + var val = r.value; + r = val[0]; + g = val[1]; + b = val[2]; + /** + * @todo - should this be normalized in + * function caller? Or parsed differently? + */ + if (b instanceof Operation) { + var op = b; + b = op.operands[0]; + a = op.operands[1]; + } + } + var color = colorFunctions.rgba(r, g, b, a); + if (color) { + color.value = 'rgb'; + return color; + } + }, + rgba: function (r, g, b, a) { + try { + if (r instanceof Color) { + if (g) { + a = number$1(g); + } + else { + a = r.alpha; + } + return new Color(r.rgb, a, 'rgba'); + } + var rgb = [r, g, b].map(function (c) { return scaled(c, 255); }); + a = number$1(a); + return new Color(rgb, a, 'rgba'); + } + catch (e) { } + }, + hsl: function (h, s, l) { + var a = 1; + if (h instanceof Expression) { + var val = h.value; + h = val[0]; + s = val[1]; + l = val[2]; + if (l instanceof Operation) { + var op = l; + l = op.operands[0]; + a = op.operands[1]; + } + } + var color = colorFunctions.hsla(h, s, l, a); + if (color) { + color.value = 'hsl'; + return color; + } + }, + hsla: function (h, s, l, a) { + try { + if (h instanceof Color) { + if (s) { + a = number$1(s); + } + else { + a = h.alpha; + } + return new Color(h.rgb, a, 'hsla'); + } + var m1_1; + var m2_1; + function hue(h) { + h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h); + if (h * 6 < 1) { + return m1_1 + (m2_1 - m1_1) * h * 6; + } + else if (h * 2 < 1) { + return m2_1; + } + else if (h * 3 < 2) { + return m1_1 + (m2_1 - m1_1) * (2 / 3 - h) * 6; + } + else { + return m1_1; + } + } + h = (number$1(h) % 360) / 360; + s = clamp(number$1(s)); + l = clamp(number$1(l)); + a = clamp(number$1(a)); + m2_1 = l <= 0.5 ? l * (s + 1) : l + s - l * s; + m1_1 = l * 2 - m2_1; + var rgb = [ + hue(h + 1 / 3) * 255, + hue(h) * 255, + hue(h - 1 / 3) * 255 + ]; + a = number$1(a); + return new Color(rgb, a, 'hsla'); + } + catch (e) { } + }, + hsv: function (h, s, v) { + return colorFunctions.hsva(h, s, v, 1.0); + }, + hsva: function (h, s, v, a) { + h = ((number$1(h) % 360) / 360) * 360; + s = number$1(s); + v = number$1(v); + a = number$1(a); + var i; + var f; + i = Math.floor((h / 60) % 6); + f = (h / 60) - i; + var vs = [v, + v * (1 - s), + v * (1 - f * s), + v * (1 - (1 - f) * s)]; + var perm = [[0, 3, 1], + [2, 0, 1], + [1, 0, 3], + [1, 2, 0], + [3, 1, 0], + [0, 1, 2]]; + return colorFunctions.rgba(vs[perm[i][0]] * 255, vs[perm[i][1]] * 255, vs[perm[i][2]] * 255, a); + }, + hue: function (color) { + return new Dimension(toHSL(color).h); + }, + saturation: function (color) { + return new Dimension(toHSL(color).s * 100, '%'); + }, + lightness: function (color) { + return new Dimension(toHSL(color).l * 100, '%'); + }, + hsvhue: function (color) { + return new Dimension(toHSV(color).h); + }, + hsvsaturation: function (color) { + return new Dimension(toHSV(color).s * 100, '%'); + }, + hsvvalue: function (color) { + return new Dimension(toHSV(color).v * 100, '%'); + }, + red: function (color) { + return new Dimension(color.rgb[0]); + }, + green: function (color) { + return new Dimension(color.rgb[1]); + }, + blue: function (color) { + return new Dimension(color.rgb[2]); + }, + alpha: function (color) { + return new Dimension(toHSL(color).a); + }, + luma: function (color) { + return new Dimension(color.luma() * color.alpha * 100, '%'); + }, + luminance: function (color) { + var luminance = (0.2126 * color.rgb[0] / 255) + + (0.7152 * color.rgb[1] / 255) + + (0.0722 * color.rgb[2] / 255); + return new Dimension(luminance * color.alpha * 100, '%'); + }, + saturate: function (color, amount, method) { + // filter: saturate(3.2); + // should be kept as is, so check for color + if (!color.rgb) { + return null; + } + var hsl = toHSL(color); + if (typeof method !== 'undefined' && method.value === 'relative') { + hsl.s += hsl.s * amount.value / 100; + } + else { + hsl.s += amount.value / 100; + } + hsl.s = clamp(hsl.s); + return hsla(color, hsl); + }, + desaturate: function (color, amount, method) { + var hsl = toHSL(color); + if (typeof method !== 'undefined' && method.value === 'relative') { + hsl.s -= hsl.s * amount.value / 100; + } + else { + hsl.s -= amount.value / 100; + } + hsl.s = clamp(hsl.s); + return hsla(color, hsl); + }, + lighten: function (color, amount, method) { + var hsl = toHSL(color); + if (typeof method !== 'undefined' && method.value === 'relative') { + hsl.l += hsl.l * amount.value / 100; + } + else { + hsl.l += amount.value / 100; + } + hsl.l = clamp(hsl.l); + return hsla(color, hsl); + }, + darken: function (color, amount, method) { + var hsl = toHSL(color); + if (typeof method !== 'undefined' && method.value === 'relative') { + hsl.l -= hsl.l * amount.value / 100; + } + else { + hsl.l -= amount.value / 100; + } + hsl.l = clamp(hsl.l); + return hsla(color, hsl); + }, + fadein: function (color, amount, method) { + var hsl = toHSL(color); + if (typeof method !== 'undefined' && method.value === 'relative') { + hsl.a += hsl.a * amount.value / 100; + } + else { + hsl.a += amount.value / 100; + } + hsl.a = clamp(hsl.a); + return hsla(color, hsl); + }, + fadeout: function (color, amount, method) { + var hsl = toHSL(color); + if (typeof method !== 'undefined' && method.value === 'relative') { + hsl.a -= hsl.a * amount.value / 100; + } + else { + hsl.a -= amount.value / 100; + } + hsl.a = clamp(hsl.a); + return hsla(color, hsl); + }, + fade: function (color, amount) { + var hsl = toHSL(color); + hsl.a = amount.value / 100; + hsl.a = clamp(hsl.a); + return hsla(color, hsl); + }, + spin: function (color, amount) { + var hsl = toHSL(color); + var hue = (hsl.h + amount.value) % 360; + hsl.h = hue < 0 ? 360 + hue : hue; + return hsla(color, hsl); + }, + // + // Copyright (c) 2006-2009 Hampton Catlin, Natalie Weizenbaum, and Chris Eppstein + // http://sass-lang.com + // + mix: function (color1, color2, weight) { + if (!weight) { + weight = new Dimension(50); + } + var p = weight.value / 100.0; + var w = p * 2 - 1; + var a = toHSL(color1).a - toHSL(color2).a; + var w1 = (((w * a == -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0; + var w2 = 1 - w1; + var rgb = [color1.rgb[0] * w1 + color2.rgb[0] * w2, + color1.rgb[1] * w1 + color2.rgb[1] * w2, + color1.rgb[2] * w1 + color2.rgb[2] * w2]; + var alpha = color1.alpha * p + color2.alpha * (1 - p); + return new Color(rgb, alpha); + }, + greyscale: function (color) { + return colorFunctions.desaturate(color, new Dimension(100)); + }, + contrast: function (color, dark, light, threshold) { + // filter: contrast(3.2); + // should be kept as is, so check for color + if (!color.rgb) { + return null; + } + if (typeof light === 'undefined') { + light = colorFunctions.rgba(255, 255, 255, 1.0); + } + if (typeof dark === 'undefined') { + dark = colorFunctions.rgba(0, 0, 0, 1.0); + } + // Figure out which is actually light and dark: + if (dark.luma() > light.luma()) { + var t = light; + light = dark; + dark = t; + } + if (typeof threshold === 'undefined') { + threshold = 0.43; + } + else { + threshold = number$1(threshold); + } + if (color.luma() < threshold) { + return light; + } + else { + 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()); + }, + color: function (c) { + if ((c instanceof Quoted) && + (/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3,4})$/i.test(c.value))) { + var val = c.value.slice(1); + return new Color(val, undefined, "#" + val); + } + if ((c instanceof Color) || (c = Color.fromKeyword(c.value))) { + c.value = undefined; + return c; + } + throw { + type: 'Argument', + message: 'argument must be a color keyword or 3|4|6|8 digit hex e.g. #FFF' + }; + }, + tint: function (color, amount) { + return colorFunctions.mix(colorFunctions.rgb(255, 255, 255), color, amount); + }, + shade: function (color, amount) { + return colorFunctions.mix(colorFunctions.rgb(0, 0, 0), color, amount); + } + }; + var color = colorFunctions; + + // Color Blending + // ref: http://www.w3.org/TR/compositing-1 + function colorBlend(mode, color1, color2) { + var ab = color1.alpha; // result + var // backdrop + cb; + var as = color2.alpha; + var // source + cs; + var ar; + var cr; + var r = []; + ar = as + ab * (1 - as); + for (var i = 0; i < 3; i++) { + cb = color1.rgb[i] / 255; + cs = color2.rgb[i] / 255; + cr = mode(cb, cs); + if (ar) { + cr = (as * cs + ab * (cb - + as * (cb + cs - cr))) / ar; + } + r[i] = cr * 255; + } + return new Color(r, ar); + } + var colorBlendModeFunctions = { + multiply: function (cb, cs) { + return cb * cs; + }, + screen: function (cb, cs) { + return cb + cs - cb * cs; + }, + overlay: function (cb, cs) { + cb *= 2; + return (cb <= 1) ? + colorBlendModeFunctions.multiply(cb, cs) : + colorBlendModeFunctions.screen(cb - 1, cs); + }, + softlight: function (cb, cs) { + var d = 1; + var e = cb; + if (cs > 0.5) { + e = 1; + d = (cb > 0.25) ? Math.sqrt(cb) + : ((16 * cb - 12) * cb + 4) * cb; + } + return cb - (1 - 2 * cs) * e * (d - cb); + }, + hardlight: function (cb, cs) { + return colorBlendModeFunctions.overlay(cs, cb); + }, + difference: function (cb, cs) { + return Math.abs(cb - cs); + }, + exclusion: function (cb, cs) { + return cb + cs - 2 * cb * cs; + }, + // non-w3c functions: + average: function (cb, cs) { + return (cb + cs) / 2; + }, + negation: function (cb, cs) { + return 1 - Math.abs(cb + cs - 1); + } + }; + for (var f$1 in colorBlendModeFunctions) { + if (colorBlendModeFunctions.hasOwnProperty(f$1)) { + colorBlend[f$1] = colorBlend.bind(null, colorBlendModeFunctions[f$1]); + } + } + + var dataUri = (function (environment) { + var fallback = function (functionThis, node) { return new URL(node, functionThis.index, functionThis.currentFileInfo).eval(functionThis.context); }; + return { 'data-uri': function (mimetypeNode, filePathNode) { + if (!filePathNode) { + filePathNode = mimetypeNode; + mimetypeNode = null; + } + var mimetype = mimetypeNode && mimetypeNode.value; + var filePath = filePathNode.value; + var currentFileInfo = this.currentFileInfo; + var currentDirectory = currentFileInfo.rewriteUrls ? + currentFileInfo.currentDirectory : currentFileInfo.entryPath; + var fragmentStart = filePath.indexOf('#'); + var fragment = ''; + if (fragmentStart !== -1) { + fragment = filePath.slice(fragmentStart); + filePath = filePath.slice(0, fragmentStart); + } + var context = clone(this.context); + context.rawBuffer = true; + var fileManager = environment.getFileManager(filePath, currentDirectory, context, environment, true); + if (!fileManager) { + return fallback(this, filePathNode); + } + var useBase64 = false; + // detect the mimetype if not given + if (!mimetypeNode) { + mimetype = environment.mimeLookup(filePath); + if (mimetype === 'image/svg+xml') { + useBase64 = false; + } + else { + // use base 64 unless it's an ASCII or UTF-8 format + var charset = environment.charsetLookup(mimetype); + useBase64 = ['US-ASCII', 'UTF-8'].indexOf(charset) < 0; + } + if (useBase64) { + mimetype += ';base64'; + } + } + else { + useBase64 = /;base64$/.test(mimetype); + } + var fileSync = fileManager.loadFileSync(filePath, currentDirectory, context, environment); + if (!fileSync.contents) { + logger$1.warn("Skipped data-uri embedding of " + filePath + " because file not found"); + return fallback(this, filePathNode || mimetypeNode); + } + var buf = fileSync.contents; + if (useBase64 && !environment.encodeBase64) { + return fallback(this, filePathNode); + } + buf = useBase64 ? environment.encodeBase64(buf) : encodeURIComponent(buf); + var uri = "data:" + mimetype + "," + buf + fragment; + return new URL(new Quoted("\"" + uri + "\"", uri, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo); + } }; + }); + + var getItemsFromNode = function (node) { + // handle non-array values as an array of length 1 + // return 'undefined' if index is invalid + var items = Array.isArray(node.value) ? + node.value : Array(node); + return items; + }; + var list = { + _SELF: function (n) { + return n; + }, + '~': function () { + var expr = []; + for (var _i = 0; _i < arguments.length; _i++) { + expr[_i] = arguments[_i]; + } + if (expr.length === 1) { + return expr[0]; + } + return new Value(expr); + }, + extract: function (values, index) { + // (1-based index) + index = index.value - 1; + return getItemsFromNode(values)[index]; + }, + length: function (values) { + return new Dimension(getItemsFromNode(values).length); + }, + /** + * Creates a Less list of incremental values. + * Modeled after Lodash's range function, also exists natively in PHP + * + * @param {Dimension} [start=1] + * @param {Dimension} end - e.g. 10 or 10px - unit is added to output + * @param {Dimension} [step=1] + */ + range: function (start, end, step) { + var from; + var to; + var stepValue = 1; + var list = []; + if (end) { + to = end; + from = start.value; + if (step) { + stepValue = step.value; + } + } + else { + from = 1; + to = start; + } + for (var i = from; i <= to.value; i += stepValue) { + list.push(new Dimension(i, to.unit)); + } + return new Expression(list); + }, + each: function (list, rs) { + var _this = this; + var rules = []; + var newRules; + var iterator; + var tryEval = function (val) { + if (val instanceof Node) { + return val.eval(_this.context); + } + return val; + }; + if (list.value && !(list instanceof Quoted)) { + if (Array.isArray(list.value)) { + iterator = list.value.map(tryEval); + } + else { + iterator = [tryEval(list.value)]; + } + } + else if (list.ruleset) { + iterator = tryEval(list.ruleset).rules; + } + else if (list.rules) { + iterator = list.rules.map(tryEval); + } + else if (Array.isArray(list)) { + iterator = list.map(tryEval); + } + else { + iterator = [tryEval(list)]; + } + var valueName = '@value'; + var keyName = '@key'; + var indexName = '@index'; + if (rs.params) { + valueName = rs.params[0] && rs.params[0].name; + keyName = rs.params[1] && rs.params[1].name; + indexName = rs.params[2] && rs.params[2].name; + rs = rs.rules; + } + else { + rs = rs.ruleset; + } + for (var i = 0; i < iterator.length; i++) { + var key = void 0; + var value = void 0; + var item = iterator[i]; + if (item instanceof Declaration) { + key = typeof item.name === 'string' ? item.name : item.name[0].value; + value = item.value; + } + else { + key = new Dimension(i + 1); + value = item; + } + if (item instanceof Comment) { + continue; + } + newRules = rs.rules.slice(0); + if (valueName) { + newRules.push(new Declaration(valueName, value, false, false, this.index, this.currentFileInfo)); + } + if (indexName) { + newRules.push(new Declaration(indexName, new Dimension(i + 1), false, false, this.index, this.currentFileInfo)); + } + if (keyName) { + newRules.push(new Declaration(keyName, key, false, false, this.index, this.currentFileInfo)); + } + rules.push(new Ruleset([new (Selector)([new Element("", '&')])], newRules, rs.strictImports, rs.visibilityInfo())); + } + return new Ruleset([new (Selector)([new Element("", '&')])], rules, rs.strictImports, rs.visibilityInfo()).eval(this.context); + } + }; + + var MathHelper = function (fn, unit, n) { + if (!(n instanceof Dimension)) { + throw { type: 'Argument', message: 'argument must be a number' }; + } + if (unit == null) { + unit = n.unit; + } + else { + n = n.unify(); + } + return new Dimension(fn(parseFloat(n.value)), unit); + }; + + var mathFunctions = { + // name, unit + ceil: null, + floor: null, + sqrt: null, + abs: null, + tan: '', + sin: '', + cos: '', + atan: 'rad', + asin: 'rad', + acos: 'rad' + }; + for (var f in mathFunctions) { + if (mathFunctions.hasOwnProperty(f)) { + mathFunctions[f] = MathHelper.bind(null, Math[f], mathFunctions[f]); + } + } + mathFunctions.round = function (n, f) { + var fraction = typeof f === 'undefined' ? 0 : f.value; + return MathHelper(function (num) { return num.toFixed(fraction); }, null, n); + }; + + var minMax = function (isMin, args) { + args = Array.prototype.slice.call(args); + switch (args.length) { + case 0: throw { type: 'Argument', message: 'one or more arguments required' }; + } + var i; // key is the unit.toString() for unified Dimension values, + var j; + var current; + var currentUnified; + var referenceUnified; + var unit; + var unitStatic; + var unitClone; + var // elems only contains original argument values. + order = []; + var values = {}; + // value is the index into the order array. + for (i = 0; i < args.length; i++) { + current = args[i]; + if (!(current instanceof Dimension)) { + if (Array.isArray(args[i].value)) { + Array.prototype.push.apply(args, Array.prototype.slice.call(args[i].value)); + } + continue; + } + currentUnified = current.unit.toString() === '' && unitClone !== undefined ? new Dimension(current.value, unitClone).unify() : current.unify(); + unit = currentUnified.unit.toString() === '' && unitStatic !== undefined ? unitStatic : currentUnified.unit.toString(); + unitStatic = unit !== '' && unitStatic === undefined || unit !== '' && order[0].unify().unit.toString() === '' ? unit : unitStatic; + unitClone = unit !== '' && unitClone === undefined ? current.unit.toString() : unitClone; + j = values[''] !== undefined && unit !== '' && unit === unitStatic ? values[''] : values[unit]; + if (j === undefined) { + if (unitStatic !== undefined && unit !== unitStatic) { + throw { type: 'Argument', message: 'incompatible types' }; + } + values[unit] = order.length; + order.push(current); + continue; + } + referenceUnified = order[j].unit.toString() === '' && unitClone !== undefined ? new Dimension(order[j].value, unitClone).unify() : order[j].unify(); + if (isMin && currentUnified.value < referenceUnified.value || + !isMin && currentUnified.value > referenceUnified.value) { + order[j] = current; + } + } + if (order.length == 1) { + return order[0]; + } + args = order.map(function (a) { return a.toCSS(this.context); }).join(this.context.compress ? ',' : ', '); + return new Anonymous((isMin ? 'min' : 'max') + "(" + args + ")"); + }; + var number = { + min: function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + try { + return minMax(true, args); + } + catch (e) { } + }, + max: function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + try { + return minMax(false, args); + } + catch (e) { } + }, + convert: function (val, unit) { + return val.convertTo(unit.value); + }, + pi: function () { + return new Dimension(Math.PI); + }, + mod: function (a, b) { + return new Dimension(a.value % b.value, a.unit); + }, + pow: function (x, y) { + if (typeof x === 'number' && typeof y === 'number') { + x = new Dimension(x); + y = new Dimension(y); + } + else if (!(x instanceof Dimension) || !(y instanceof Dimension)) { + throw { type: 'Argument', message: 'arguments must be numbers' }; + } + return new Dimension(Math.pow(x.value, y.value), x.unit); + }, + percentage: function (n) { + var result = MathHelper(function (num) { return num * 100; }, '%', n); + return result; + } + }; + + var string = { + e: function (str) { + return new Quoted('"', str instanceof JavaScript ? str.evaluated : str.value, true); + }, + escape: function (str) { + return new Anonymous(encodeURI(str.value).replace(/=/g, '%3D').replace(/:/g, '%3A').replace(/#/g, '%23').replace(/;/g, '%3B') + .replace(/\(/g, '%28').replace(/\)/g, '%29')); + }, + replace: function (string, pattern, replacement, flags) { + var result = string.value; + replacement = (replacement.type === 'Quoted') ? + replacement.value : replacement.toCSS(); + result = result.replace(new RegExp(pattern.value, flags ? flags.value : ''), replacement); + return new Quoted(string.quote || '', result, string.escaped); + }, + '%': function (string /* arg, arg, ... */) { + var args = Array.prototype.slice.call(arguments, 1); + var result = string.value; + var _loop_1 = function (i) { + /* 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(); + return token.match(/[A-Z]$/) ? encodeURIComponent(value) : value; + }); + }; + for (var i = 0; i < args.length; i++) { + _loop_1(i); + } + result = result.replace(/%%/g, '%'); + return new Quoted(string.quote || '', result, string.escaped); + } + }; + + var svg = (function (environment) { + return { 'svg-gradient': function (direction) { + var stops; + var gradientDirectionSvg; + var gradientType = 'linear'; + var rectangleDimension = 'x="0" y="0" width="1" height="1"'; + var renderEnv = { compress: false }; + var returner; + var directionValue = direction.toCSS(renderEnv); + var i; + var color; + var position; + var positionValue; + var 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' }; + } + if (arguments.length == 2) { + if (arguments[1].value.length < 2) { + throwArgumentDescriptor(); + } + stops = arguments[1].value; + } + else if (arguments.length < 3) { + throwArgumentDescriptor(); + } + else { + stops = Array.prototype.slice.call(arguments, 1); + } + switch (directionValue) { + case 'to bottom': + gradientDirectionSvg = 'x1="0%" y1="0%" x2="0%" y2="100%"'; + break; + case 'to right': + gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="0%"'; + break; + case 'to bottom right': + gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="100%"'; + break; + case 'to top right': + gradientDirectionSvg = 'x1="0%" y1="100%" x2="100%" y2="0%"'; + break; + case 'ellipse': + case 'ellipse at center': + gradientType = 'radial'; + gradientDirectionSvg = 'cx="50%" cy="50%" r="75%"'; + rectangleDimension = 'x="-50" y="-50" width="101" height="101"'; + break; + default: + throw { type: 'Argument', message: 'svg-gradient direction must be \'to bottom\', \'to right\',' + + ' \'to bottom right\', \'to top right\' or \'ellipse at center\'' }; + } + returner = "<" + gradientType + "Gradient id=\"g\" " + gradientDirectionSvg + ">"; + for (i = 0; i < stops.length; i += 1) { + if (stops[i] instanceof Expression) { + color = stops[i].value[0]; + position = stops[i].value[1]; + } + else { + color = stops[i]; + position = undefined; + } + if (!(color instanceof Color) || (!((i === 0 || i + 1 === stops.length) && position === undefined) && !(position instanceof Dimension))) { + throwArgumentDescriptor(); + } + positionValue = position ? position.toCSS(renderEnv) : i === 0 ? '0%' : '100%'; + alpha = color.alpha; + returner += ""; + } + returner += ""; + returner = encodeURIComponent(returner); + returner = "data:image/svg+xml," + returner; + return new URL(new Quoted("'" + returner + "'", returner, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo); + } }; + }); + + var isa = function (n, Type) { return (n instanceof Type) ? Keyword.True : Keyword.False; }; + var isunit = function (n, unit) { + if (unit === undefined) { + throw { type: 'Argument', message: 'missing the required second argument to isunit.' }; + } + unit = typeof unit.value === 'string' ? unit.value : unit; + if (typeof unit !== 'string') { + throw { type: 'Argument', message: 'Second argument to isunit should be a unit or a string.' }; + } + return (n instanceof Dimension) && n.unit.is(unit) ? Keyword.True : Keyword.False; + }; + var types = { + isruleset: function (n) { + return isa(n, DetachedRuleset); + }, + iscolor: function (n) { + return isa(n, Color); + }, + isnumber: function (n) { + return isa(n, Dimension); + }, + isstring: function (n) { + return isa(n, Quoted); + }, + iskeyword: function (n) { + return isa(n, Keyword); + }, + isurl: function (n) { + return isa(n, URL); + }, + ispixel: function (n) { + return isunit(n, 'px'); + }, + ispercentage: function (n) { + return isunit(n, '%'); + }, + isem: function (n) { + return isunit(n, 'em'); + }, + isunit: isunit, + unit: function (val, unit) { + if (!(val instanceof Dimension)) { + throw { type: 'Argument', + message: "the first argument to unit must be a number" + (val instanceof Operation ? '. Have you forgotten parenthesis?' : '') }; + } + if (unit) { + if (unit instanceof Keyword) { + unit = unit.value; + } + else { + unit = unit.toCSS(); + } + } + else { + unit = ''; + } + return new Dimension(val.value, unit); + }, + 'get-unit': function (n) { + return new Anonymous(n.unit); + } + }; + + var functions = (function (environment) { + var functions = { functionRegistry: functionRegistry, functionCaller: functionCaller }; + // register functions + functionRegistry.addMultiple(boolean$1); + functionRegistry.add('default', defaultFunc.eval.bind(defaultFunc)); + functionRegistry.addMultiple(color); + functionRegistry.addMultiple(colorBlend); + functionRegistry.addMultiple(dataUri(environment)); + functionRegistry.addMultiple(list); + functionRegistry.addMultiple(mathFunctions); + functionRegistry.addMultiple(number); + functionRegistry.addMultiple(string); + functionRegistry.addMultiple(svg()); + functionRegistry.addMultiple(types); + return functions; + }); + + function transformTree (root, options) { + options = options || {}; + var evaldRoot; + var variables = options.variables; + var evalEnv = new contexts.Eval(options); + // + // Allows setting variables with a hash, so: + // + // `{ color: new tree.Color('#f01') }` will become: + // + // new tree.Declaration('@color', + // new tree.Value([ + // new tree.Expression([ + // new tree.Color('#f01') + // ]) + // ]) + // ) + // + if (typeof variables === 'object' && !Array.isArray(variables)) { + variables = Object.keys(variables).map(function (k) { + var value = variables[k]; + if (!(value instanceof tree.Value)) { + if (!(value instanceof tree.Expression)) { + value = new tree.Expression([value]); + } + value = new tree.Value([value]); + } + return new tree.Declaration("@" + k, value, false, null, 0); + }); + evalEnv.frames = [new tree.Ruleset(null, variables)]; + } + var visitors$1 = [ + new visitors.JoinSelectorVisitor(), + new visitors.MarkVisibleSelectorsVisitor(true), + new visitors.ExtendVisitor(), + new visitors.ToCSSVisitor({ compress: Boolean(options.compress) }) + ]; + var preEvalVisitors = []; + var v; + var visitorIterator; + /** + * first() / get() allows visitors to be added while visiting + * + * @todo Add scoping for visitors just like functions for @plugin; right now they're global + */ + if (options.pluginManager) { + visitorIterator = options.pluginManager.visitor(); + for (var i = 0; i < 2; i++) { + visitorIterator.first(); + while ((v = visitorIterator.get())) { + if (v.isPreEvalVisitor) { + if (i === 0 || preEvalVisitors.indexOf(v) === -1) { + preEvalVisitors.push(v); + v.run(root); + } + } + else { + if (i === 0 || visitors$1.indexOf(v) === -1) { + if (v.isPreVisitor) { + visitors$1.unshift(v); + } + else { + visitors$1.push(v); + } + } + } + } + } + } + evaldRoot = root.eval(evalEnv); + for (var i = 0; i < visitors$1.length; i++) { + visitors$1[i].run(evaldRoot); + } + // Run any remaining visitors added after eval pass + if (options.pluginManager) { + visitorIterator.first(); + while ((v = visitorIterator.get())) { + if (visitors$1.indexOf(v) === -1 && preEvalVisitors.indexOf(v) === -1) { + v.run(evaldRoot); + } + } + } + return evaldRoot; + } + + /** + * Plugin Manager + */ + var PluginManager = /** @class */ (function () { + function PluginManager(less) { + this.less = less; + this.visitors = []; + this.preProcessors = []; + this.postProcessors = []; + this.installedPlugins = []; + this.fileManagers = []; + this.iterator = -1; + this.pluginCache = {}; + this.Loader = new less.PluginLoader(less); + } + /** + * Adds all the plugins in the array + * @param {Array} plugins + */ + PluginManager.prototype.addPlugins = function (plugins) { + if (plugins) { + for (var i = 0; i < plugins.length; i++) { + this.addPlugin(plugins[i]); + } + } + }; + /** + * + * @param plugin + * @param {String} filename + */ + PluginManager.prototype.addPlugin = function (plugin, filename, functionRegistry) { + this.installedPlugins.push(plugin); + 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. + * @param visitor + */ + PluginManager.prototype.addVisitor = function (visitor) { + this.visitors.push(visitor); + }; + /** + * Adds a pre processor object + * @param {object} preProcessor + * @param {number} priority - guidelines 1 = before import, 1000 = import, 2000 = after import + */ + PluginManager.prototype.addPreProcessor = function (preProcessor, priority) { + var indexToInsertAt; + for (indexToInsertAt = 0; indexToInsertAt < this.preProcessors.length; indexToInsertAt++) { + if (this.preProcessors[indexToInsertAt].priority >= priority) { + break; + } + } + this.preProcessors.splice(indexToInsertAt, 0, { preProcessor: preProcessor, priority: priority }); + }; + /** + * Adds a post processor object + * @param {object} postProcessor + * @param {number} priority - guidelines 1 = before compression, 1000 = compression, 2000 = after compression + */ + PluginManager.prototype.addPostProcessor = function (postProcessor, priority) { + var indexToInsertAt; + for (indexToInsertAt = 0; indexToInsertAt < this.postProcessors.length; indexToInsertAt++) { + if (this.postProcessors[indexToInsertAt].priority >= priority) { + break; + } + } + this.postProcessors.splice(indexToInsertAt, 0, { postProcessor: postProcessor, priority: priority }); + }; + /** + * + * @param manager + */ + PluginManager.prototype.addFileManager = function (manager) { + this.fileManagers.push(manager); + }; + /** + * + * @returns {Array} + * @private + */ + PluginManager.prototype.getPreProcessors = function () { + var preProcessors = []; + for (var i = 0; i < this.preProcessors.length; i++) { + preProcessors.push(this.preProcessors[i].preProcessor); + } + return preProcessors; + }; + /** + * + * @returns {Array} + * @private + */ + PluginManager.prototype.getPostProcessors = function () { + var postProcessors = []; + for (var i = 0; i < this.postProcessors.length; i++) { + postProcessors.push(this.postProcessors[i].postProcessor); + } + return postProcessors; + }; + /** + * + * @returns {Array} + * @private + */ + 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} + * @private + */ + PluginManager.prototype.getFileManagers = function () { + return this.fileManagers; + }; + return PluginManager; + }()); + var pm; + var PluginManagerFactory = function (less, newFactory) { + if (newFactory || !pm) { + pm = new PluginManager(less); + } + return pm; + }; + + function SourceMapOutput (environment) { + var SourceMapOutput = /** @class */ (function () { + function SourceMapOutput(options) { + this._css = []; + this._rootNode = options.rootNode; + this._contentsMap = options.contentsMap; + this._contentsIgnoredCharsMap = options.contentsIgnoredCharsMap; + if (options.sourceMapFilename) { + this._sourceMapFilename = options.sourceMapFilename.replace(/\\/g, '/'); + } + this._outputFilename = options.outputFilename; + this.sourceMapURL = options.sourceMapURL; + if (options.sourceMapBasepath) { + this._sourceMapBasepath = options.sourceMapBasepath.replace(/\\/g, '/'); + } + if (options.sourceMapRootpath) { + this._sourceMapRootpath = options.sourceMapRootpath.replace(/\\/g, '/'); + if (this._sourceMapRootpath.charAt(this._sourceMapRootpath.length - 1) !== '/') { + this._sourceMapRootpath += '/'; + } + } + else { + this._sourceMapRootpath = ''; + } + this._outputSourceFiles = options.outputSourceFiles; + this._sourceMapGeneratorConstructor = environment.getSourceMapGenerator(); + this._lineNumber = 0; + this._column = 0; + } + 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 + if (!chunk) { + return; + } + var lines, sourceLines, columns, sourceColumns, i; + if (fileInfo && fileInfo.filename) { + var inputSource = this._contentsMap[fileInfo.filename]; + // remove vars/banner added to the top of the file + if (this._contentsIgnoredCharsMap[fileInfo.filename]) { + // adjust the index + index -= this._contentsIgnoredCharsMap[fileInfo.filename]; + if (index < 0) { + index = 0; + } + // adjust the source + inputSource = inputSource.slice(this._contentsIgnoredCharsMap[fileInfo.filename]); + } + /** + * ignore empty content, or failsafe + * if contents map is incorrect + */ + if (inputSource === undefined) { + this._css.push(chunk); + return; + } + inputSource = inputSource.substring(0, index); + sourceLines = inputSource.split('\n'); + sourceColumns = sourceLines[sourceLines.length - 1]; + } + lines = chunk.split('\n'); + columns = lines[lines.length - 1]; + if (fileInfo && fileInfo.filename) { + if (!mapLines) { + this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + 1, column: this._column }, + original: { line: sourceLines.length, column: sourceColumns.length }, + source: this.normalizeFilename(fileInfo.filename) }); + } + else { + for (i = 0; i < lines.length; i++) { + this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + i + 1, column: i === 0 ? this._column : 0 }, + original: { line: sourceLines.length + i, column: i === 0 ? sourceColumns.length : 0 }, + source: this.normalizeFilename(fileInfo.filename) }); + } + } + } + if (lines.length === 1) { + this._column += columns.length; + } + else { + this._lineNumber += lines.length - 1; + this._column = columns.length; + } + this._css.push(chunk); + }; + SourceMapOutput.prototype.isEmpty = function () { + return this._css.length === 0; + }; + SourceMapOutput.prototype.toCSS = function (context) { + this._sourceMapGenerator = new this._sourceMapGeneratorConstructor({ file: this._outputFilename, sourceRoot: null }); + if (this._outputSourceFiles) { + for (var filename in this._contentsMap) { + if (this._contentsMap.hasOwnProperty(filename)) { + var source = this._contentsMap[filename]; + if (this._contentsIgnoredCharsMap[filename]) { + source = source.slice(this._contentsIgnoredCharsMap[filename]); + } + this._sourceMapGenerator.setSourceContent(this.normalizeFilename(filename), source); + } + } + } + this._rootNode.genCSS(context, this); + if (this._css.length > 0) { + var sourceMapURL = void 0; + var sourceMapContent = JSON.stringify(this._sourceMapGenerator.toJSON()); + if (this.sourceMapURL) { + sourceMapURL = this.sourceMapURL; + } + else if (this._sourceMapFilename) { + sourceMapURL = this._sourceMapFilename; + } + this.sourceMapURL = sourceMapURL; + this.sourceMap = sourceMapContent; + } + return this._css.join(''); + }; + return SourceMapOutput; + }()); + return SourceMapOutput; + } + + function SourceMapBuilder (SourceMapOutput, environment) { + var SourceMapBuilder = /** @class */ (function () { + function SourceMapBuilder(options) { + this.options = options; + } + SourceMapBuilder.prototype.toCSS = function (rootNode, options, imports) { + var sourceMapOutput = new SourceMapOutput({ + contentsIgnoredCharsMap: imports.contentsIgnoredChars, + rootNode: rootNode, + contentsMap: imports.contents, + sourceMapFilename: this.options.sourceMapFilename, + sourceMapURL: this.options.sourceMapURL, + outputFilename: this.options.sourceMapOutputFilename, + sourceMapBasepath: this.options.sourceMapBasepath, + sourceMapRootpath: this.options.sourceMapRootpath, + outputSourceFiles: this.options.outputSourceFiles, + sourceMapGenerator: this.options.sourceMapGenerator, + sourceMapFileInline: this.options.sourceMapFileInline, + disableSourcemapAnnotation: this.options.disableSourcemapAnnotation + }); + var css = sourceMapOutput.toCSS(options); + this.sourceMap = sourceMapOutput.sourceMap; + this.sourceMapURL = sourceMapOutput.sourceMapURL; + 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(); + }; + SourceMapBuilder.prototype.getCSSAppendage = function () { + var sourceMapURL = this.sourceMapURL; + if (this.options.sourceMapFileInline) { + if (this.sourceMap === undefined) { + return ''; + } + sourceMapURL = "data:application/json;base64," + environment.encodeBase64(this.sourceMap); + } + if (this.options.disableSourcemapAnnotation) { + return ''; + } + if (sourceMapURL) { + return "/*# sourceMappingURL=" + sourceMapURL + " */"; + } + return ''; + }; + SourceMapBuilder.prototype.getExternalSourceMap = function () { + return this.sourceMap; + }; + SourceMapBuilder.prototype.setExternalSourceMap = function (sourceMap) { + this.sourceMap = sourceMap; + }; + SourceMapBuilder.prototype.isInline = function () { + return this.options.sourceMapFileInline; + }; + SourceMapBuilder.prototype.getSourceMapURL = function () { + return this.sourceMapURL; + }; + SourceMapBuilder.prototype.getOutputFilename = function () { + return this.options.sourceMapOutputFilename; + }; + SourceMapBuilder.prototype.getInputFilename = function () { + return this.sourceMapInputFilename; + }; + return SourceMapBuilder; + }()); + return SourceMapBuilder; + } + + function ParseTree (SourceMapBuilder) { + var ParseTree = /** @class */ (function () { + function ParseTree(root, imports) { + this.root = root; + this.imports = imports; + } + ParseTree.prototype.toCSS = function (options) { + var evaldRoot; + var result = {}; + var sourceMapBuilder; + try { + evaldRoot = transformTree(this.root, options); + } + catch (e) { + throw new LessError(e, this.imports); + } + try { + var compress = Boolean(options.compress); + if (compress) { + logger$1.warn('The compress option has been deprecated. ' + + 'We recommend you use a dedicated css minifier, for instance see less-plugin-clean-css.'); + } + var toCSSOptions = { + compress: compress, + dumpLineNumbers: options.dumpLineNumbers, + strictUnits: Boolean(options.strictUnits), + numPrecision: 8 + }; + if (options.sourceMap) { + sourceMapBuilder = new SourceMapBuilder(options.sourceMap); + result.css = sourceMapBuilder.toCSS(evaldRoot, toCSSOptions, this.imports); + } + else { + result.css = evaldRoot.toCSS(toCSSOptions); + } + } + catch (e) { + throw new LessError(e, this.imports); + } + if (options.pluginManager) { + var postProcessors = options.pluginManager.getPostProcessors(); + for (var i = 0; i < postProcessors.length; i++) { + result.css = postProcessors[i].process(result.css, { sourceMap: sourceMapBuilder, options: options, imports: this.imports }); + } + } + if (options.sourceMap) { + result.map = sourceMapBuilder.getExternalSourceMap(); + } + result.imports = []; + for (var file in this.imports.files) { + if (this.imports.files.hasOwnProperty(file) && file !== this.imports.rootFilename) { + result.imports.push(file); + } + } + return result; + }; + return ParseTree; + }()); + return ParseTree; + } + + function ImportManager (environment) { + // FileInfo = { + // 'rewriteUrls' - option - whether to adjust URL's to be relative + // 'filename' - full resolved filename of current file + // 'rootpath' - path to append to normal URLs for this node + // 'currentDirectory' - path to the current file, absolute + // 'rootFilename' - filename of the base file + // 'entryPath' - absolute path to the entry file + // 'reference' - whether the file should not be output and only output parts that are referenced + var ImportManager = /** @class */ (function () { + function ImportManager(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 + this.contentsIgnoredChars = {}; // map - filename to lines at the beginning of each file to ignore + this.mime = context.mime; + this.error = null; + this.context = context; + // Deprecated? Unused outside of here, could be useful. + 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 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, tryAppendExtension, currentFileInfo, importOptions, callback) { + var importManager = this, pluginLoader = this.context.pluginManager.Loader; + this.queue.push(path); + var fileParsedFunc = function (e, root, fullPath) { + importManager.queue.splice(importManager.queue.indexOf(path), 1); // Remove the path from the queue + var importedEqualsRoot = fullPath === importManager.rootFilename; + if (importOptions.optional && e) { + callback(null, { rules: [] }, false, null); + logger$1.info("The file " + fullPath + " was skipped because it was not found and the import was marked optional."); + } + else { + // Inline imports aren't cached here. + // If we start to cache them, please make sure they won't conflict with non-inline imports of the + // same name as they used to do before this comment and the condition below have been added. + if (!importManager.files[fullPath] && !importOptions.inline) { + importManager.files[fullPath] = { root: root, options: importOptions }; + } + if (e && !importManager.error) { + importManager.error = e; + } + callback(e, root, importedEqualsRoot, fullPath); + } + }; + var newFileInfo = { + rewriteUrls: this.context.rewriteUrls, + entryPath: currentFileInfo.entryPath, + rootpath: currentFileInfo.rootpath, + rootFilename: currentFileInfo.rootFilename + }; + var fileManager = environment.getFileManager(path, currentFileInfo.currentDirectory, this.context, environment); + if (!fileManager) { + fileParsedFunc({ message: "Could not find a file-manager for " + path }); + return; + } + var loadFileCallback = function (loadedFile) { + var plugin; + var resolvedFilename = loadedFile.filename; + var contents = loadedFile.contents.replace(/^\uFEFF/, ''); + // Pass on an updated rootpath if path of imported file is relative and file + // is in a (sub|sup) directory + // + // Examples: + // - If path of imported file is 'module/nav/nav.less' and rootpath is 'less/', + // then rootpath should become 'less/module/nav/' + // - If path of imported file is '../mixins.less' and rootpath is 'less/', + // then rootpath should become 'less/../' + newFileInfo.currentDirectory = fileManager.getPath(resolvedFilename); + if (newFileInfo.rewriteUrls) { + newFileInfo.rootpath = fileManager.join((importManager.context.rootpath || ''), fileManager.pathDiff(newFileInfo.currentDirectory, newFileInfo.entryPath)); + if (!fileManager.isPathAbsolute(newFileInfo.rootpath) && fileManager.alwaysMakePathsAbsolute()) { + newFileInfo.rootpath = fileManager.join(newFileInfo.entryPath, newFileInfo.rootpath); + } + } + newFileInfo.filename = resolvedFilename; + var newEnv = new contexts.Parse(importManager.context); + newEnv.processImports = false; + importManager.contents[resolvedFilename] = contents; + if (currentFileInfo.reference || importOptions.reference) { + newFileInfo.reference = true; + } + 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 { + // 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 loadedFile; + var promise; + var context = clone(this.context); + if (tryAppendExtension) { + context.ext = importOptions.isPlugin ? '.js' : '.less'; + } + if (importOptions.isPlugin) { + context.mime = 'application/javascript'; + if (context.syncImport) { + loadedFile = pluginLoader.loadPluginSync(path, currentFileInfo.currentDirectory, context, environment, fileManager); + } + else { + promise = pluginLoader.loadPlugin(path, currentFileInfo.currentDirectory, context, environment, fileManager); + } + } + else { + if (context.syncImport) { + loadedFile = fileManager.loadFileSync(path, currentFileInfo.currentDirectory, context, environment); + } + else { + promise = fileManager.loadFile(path, currentFileInfo.currentDirectory, context, environment, function (err, loadedFile) { + if (err) { + fileParsedFunc(err); + } + else { + loadFileCallback(loadedFile); + } + }); + } + } + if (loadedFile) { + if (!loadedFile.filename) { + fileParsedFunc(loadedFile); + } + else { + loadFileCallback(loadedFile); + } + } + else if (promise) { + promise.then(loadFileCallback, fileParsedFunc); + } + }; + return ImportManager; + }()); + return ImportManager; + } + + function Parse (environment, ParseTree, ImportManager) { + var parse = function (input, options, callback) { + if (typeof options === 'function') { + callback = options; + options = copyOptions(this.options, {}); + } + else { + options = copyOptions(this.options, options || {}); + } + if (!callback) { + var self_1 = this; + return new Promise(function (resolve, reject) { + parse.call(self_1, input, options, function (err, output) { + if (err) { + reject(err); + } + else { + resolve(output); + } + }); + }); + } + else { + var context_1; + var rootFileInfo = void 0; + var pluginManager_1 = new PluginManagerFactory(this, !options.reUsePluginManager); + options.pluginManager = pluginManager_1; + context_1 = new contexts.Parse(options); + if (options.rootFileInfo) { + rootFileInfo = options.rootFileInfo; + } + else { + var filename = options.filename || 'input'; + var entryPath = filename.replace(/[^\/\\]*$/, ''); + rootFileInfo = { + filename: filename, + rewriteUrls: context_1.rewriteUrls, + rootpath: context_1.rootpath || '', + currentDirectory: entryPath, + entryPath: entryPath, + rootFilename: filename + }; + // add in a missing trailing slash + if (rootFileInfo.rootpath && rootFileInfo.rootpath.slice(-1) !== '/') { + rootFileInfo.rootpath += '/'; + } + } + var imports_1 = new ImportManager(this, context_1, rootFileInfo); + this.importManager = imports_1; + // 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_1.Loader.evalPlugin(contents, context_1, imports_1, plugin.options, plugin.filename); + if (evalResult instanceof LessError) { + return callback(evalResult); + } + } + else { + pluginManager_1.addPlugin(plugin); + } + }); + } + new Parser(context_1, imports_1, rootFileInfo) + .parse(input, function (e, root) { + if (e) { + return callback(e); + } + callback(null, root, imports_1, options); + }, options); + } + }; + return parse; + } + + function Render (environment, ParseTree, ImportManager) { + var render = function (input, options, callback) { + if (typeof options === 'function') { + callback = options; + options = copyOptions(this.options, {}); + } + else { + options = copyOptions(this.options, options || {}); + } + if (!callback) { + var self_1 = this; + return new Promise(function (resolve, reject) { + render.call(self_1, input, options, function (err, output) { + if (err) { + reject(err); + } + else { + resolve(output); + } + }); + }); + } + else { + this.parse(input, options, function (err, root, imports, options) { + if (err) { + return callback(err); + } + var result; + try { + var parseTree = new ParseTree(root, imports); + result = parseTree.toCSS(options); + } + catch (err) { + return callback(err); + } + callback(null, result); + }); + } + }; + return render; + } + + var version = "4.1.2"; + + function parseNodeVersion(version) { + var match = version.match(/^v(\d{1,2})\.(\d{1,2})\.(\d{1,2})(?:-([0-9A-Za-z-.]+))?(?:\+([0-9A-Za-z-.]+))?$/); // eslint-disable-line max-len + if (!match) { + throw new Error('Unable to parse: ' + version); + } + + var res = { + major: parseInt(match[1], 10), + minor: parseInt(match[2], 10), + patch: parseInt(match[3], 10), + pre: match[4] || '', + build: match[5] || '', + }; + + return res; + } + + var parseNodeVersion_1 = parseNodeVersion; + + function lessRoot (environment, fileManagers) { + var sourceMapOutput, sourceMapBuilder, parseTree, importManager; + environment = new Environment(environment, fileManagers); + sourceMapOutput = SourceMapOutput(environment); + sourceMapBuilder = SourceMapBuilder(sourceMapOutput, environment); + parseTree = ParseTree(sourceMapBuilder); + importManager = ImportManager(environment); + var render = Render(environment, parseTree); + var parse = Parse(environment, parseTree, importManager); + var v = parseNodeVersion_1("v" + version); + var initial = { + version: [v.major, v.minor, v.patch], + data: data, + tree: tree, + Environment: Environment, + AbstractFileManager: AbstractFileManager, + AbstractPluginLoader: AbstractPluginLoader, + environment: environment, + visitors: visitors, + Parser: Parser, + functions: functions(environment), + contexts: contexts, + SourceMapOutput: sourceMapOutput, + SourceMapBuilder: sourceMapBuilder, + ParseTree: parseTree, + ImportManager: importManager, + render: render, + parse: parse, + LessError: LessError, + transformTree: transformTree, + utils: utils, + PluginManager: PluginManagerFactory, + logger: logger$1 + }; + // Create a public API + 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; + var 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]); + } + } + } + /** + * Some of the functions assume a `this` context of the API object, + * which causes it to fail when wrapped for ES6 imports. + * + * An assumed `this` should be removed in the future. + */ + initial.parse = initial.parse.bind(api); + initial.render = initial.render.bind(api); + return api; + } + + /* global window, XMLHttpRequest */ + var options$1; + var 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 + var FileManager = function () { }; + FileManager.prototype = Object.assign(new AbstractFileManager(), { + alwaysMakePathsAbsolute: function () { + return true; + }, + join: function (basePath, laterPath) { + if (!basePath) { + return laterPath; + } + return this.extractUrlParts(laterPath, basePath).path; + }, + doXHR: function (url, type, callback, errback) { + var xhr = new XMLHttpRequest(); + var async = options$1.isFileProtocol ? options$1.fileAsync : true; + if (typeof xhr.overrideMimeType === 'function') { + xhr.overrideMimeType('text/css'); + } + logger.debug("XHR: Getting '" + url + "'"); + xhr.open('GET', url, async); + xhr.setRequestHeader('Accept', type || 'text/x-less, text/css; q=0.9, */*; q=0.5'); + xhr.send(null); + function handleResponse(xhr, callback, errback) { + if (xhr.status >= 200 && xhr.status < 300) { + callback(xhr.responseText, xhr.getResponseHeader('Last-Modified')); + } + else if (typeof errback === 'function') { + errback(xhr.status, url); + } + } + if (options$1.isFileProtocol && !options$1.fileAsync) { + if (xhr.status === 0 || (xhr.status >= 200 && xhr.status < 300)) { + callback(xhr.responseText); + } + else { + errback(xhr.status, url); + } + } + else if (async) { + xhr.onreadystatechange = function () { + if (xhr.readyState == 4) { + handleResponse(xhr, callback, errback); + } + }; + } + else { + handleResponse(xhr, callback, errback); + } + }, + supports: function () { + return true; + }, + clearFileCache: function () { + fileCache = {}; + }, + loadFile: function (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; + 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 }); + } + } + self.doXHR(href, options.mime, function doXHRCallback(data, lastModified) { + // per file cache + fileCache[href] = data; + // 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 }); + }); + }); + } + }); + var FM = (function (opts, log) { + options$1 = opts; + logger = log; + return FileManager; + }); + + // TODO: Add tests for browser @plugin + /** + * Browser Plugin Loader + */ + var PluginLoader = function (less) { + this.less = less; + // Should we shim this.require for browser? Probably not? + }; + PluginLoader.prototype = Object.assign(new AbstractPluginLoader(), { + loadPlugin: function (filename, basePath, context, environment, fileManager) { + return new Promise(function (fulfill, reject) { + fileManager.loadFile(filename, basePath, context, environment) + .then(fulfill).catch(reject); + }); + } + }); + + var LogListener = (function (less, options) { + var logLevel_debug = 4; + var logLevel_info = 3; + var logLevel_warn = 2; + var logLevel_error = 1; + // The amount of logging in the javascript console. + // 3 - Debug, information and errors + // 2 - Information and errors + // 1 - Errors + // 0 - None + // Defaults to 2 + options.logLevel = typeof options.logLevel !== 'undefined' ? options.logLevel : (options.env === 'development' ? logLevel_info : logLevel_error); + if (!options.loggers) { + options.loggers = [{ + debug: function (msg) { + if (options.logLevel >= logLevel_debug) { + console.log(msg); + } + }, + info: function (msg) { + if (options.logLevel >= logLevel_info) { + console.log(msg); + } + }, + warn: function (msg) { + if (options.logLevel >= logLevel_warn) { + console.warn(msg); + } + }, + error: function (msg) { + if (options.logLevel >= logLevel_error) { + console.error(msg); + } + } + }]; + } + for (var i = 0; i < options.loggers.length; i++) { + less.logger.addListener(options.loggers[i]); + } + }); + + var ErrorReporting = (function (window, less, options) { + function errorHTML(e, rootHref) { + var id = "less-error-message:" + extractId(rootHref || ''); + var template = '
  • {content}
  • '; + var elem = window.document.createElement('div'); + var timer; + var content; + var errors = []; + var filename = e.filename || rootHref; + var filenameNoPath = filename.match(/([^\/]+(\?.*)?)$/)[1]; + elem.id = id; + elem.className = 'less-error-message'; + content = "

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

    in " + filenameNoPath + " "); + var errorline = function (e, i, classname) { + if (e.extract[i] !== undefined) { + errors.push(template.replace(/\{line\}/, (parseInt(e.line, 10) || 0) + (i - 1)) + .replace(/\{class\}/, classname) + .replace(/\{content\}/, e.extract[i])); + } + }; + if (e.line) { + errorline(e, 0, ''); + errorline(e, 1, 'line'); + errorline(e, 2, ''); + content += "on line " + e.line + ", column " + (e.column + 1) + ":

      " + errors.join('') + "
    "; + } + if (e.stack && (e.extract || options.logLevel >= 4)) { + content += "
    Stack Trace
    " + e.stack.split('\n').slice(1).join('
    '); + } + elem.innerHTML = content; + // CSS for error messages + browser.createCSS(window.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' }); + elem.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(';'); + if (options.env === 'development') { + timer = setInterval(function () { + var document = window.document; + var body = document.body; + if (body) { + if (document.getElementById(id)) { + body.replaceChild(elem, document.getElementById(id)); + } + else { + body.insertBefore(elem, body.firstChild); + } + clearInterval(timer); + } + }, 10); + } + } + function removeErrorHTML(path) { + var node = window.document.getElementById("less-error-message:" + extractId(path)); + if (node) { + node.parentNode.removeChild(node); + } + } + function removeError(path) { + if (!options.errorReporting || options.errorReporting === 'html') { + removeErrorHTML(path); + } + else if (options.errorReporting === 'console') ; + else if (typeof options.errorReporting === 'function') { + options.errorReporting('remove', path); + } + } + function errorConsole(e, rootHref) { + var template = '{line} {content}'; + 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; + var errorline = function (e, i, classname) { + if (e.extract[i] !== undefined) { + errors.push(template.replace(/\{line\}/, (parseInt(e.line, 10) || 0) + (i - 1)) + .replace(/\{class\}/, classname) + .replace(/\{content\}/, e.extract[i])); + } + }; + if (e.line) { + errorline(e, 0, ''); + errorline(e, 1, 'line'); + errorline(e, 2, ''); + content += " on line " + e.line + ", column " + (e.column + 1) + ":\n" + errors.join('\n'); + } + if (e.stack && (e.extract || options.logLevel >= 4)) { + content += "\nStack Trace\n" + e.stack; + } + less.logger.error(content); + } + function error(e, rootHref) { + if (!options.errorReporting || options.errorReporting === 'html') { + errorHTML(e, rootHref); + } + else if (options.errorReporting === 'console') { + errorConsole(e, rootHref); + } + else if (typeof options.errorReporting === 'function') { + options.errorReporting('add', e, rootHref); + } + } + return { + add: error, + remove: removeError + }; + }); + + // Cache system is a bit outdated and could do with work + var Cache = (function (window, options, logger) { + var cache = null; + if (options.env !== 'development') { + try { + cache = (typeof window.localStorage === 'undefined') ? null : window.localStorage; + } + catch (_) { } + } + return { + setCSS: function (path, lastModified, modifyVars, styles) { + if (cache) { + logger.info("saving " + path + " to cache."); + try { + cache.setItem(path, styles); + cache.setItem(path + ":timestamp", lastModified); + if (modifyVars) { + cache.setItem(path + ":vars", JSON.stringify(modifyVars)); + } + } + catch (e) { + // TODO - could do with adding more robust error handling + logger.error("failed to save \"" + path + "\" to local storage for caching."); + } + } + }, + getCSS: function (path, webInfo, modifyVars) { + var css = cache && cache.getItem(path); + var timestamp = cache && cache.getItem(path + ":timestamp"); + var vars = cache && cache.getItem(path + ":vars"); + modifyVars = modifyVars || {}; + vars = vars || "{}"; // if not set, treat as the JSON representation of an empty object + if (timestamp && webInfo.lastModified && + (new Date(webInfo.lastModified).valueOf() === + new Date(timestamp).valueOf()) && + JSON.stringify(modifyVars) === vars) { + // Use local copy + return css; + } + } + }; + }); + + var ImageSize = (function () { + function imageSize() { + throw { + type: 'Runtime', + message: 'Image size functions are not supported in browser version of less' + }; + } + var imageFunctions = { + 'image-size': function (filePathNode) { + imageSize(); + return -1; + }, + 'image-width': function (filePathNode) { + imageSize(); + return -1; + }, + 'image-height': function (filePathNode) { + imageSize(); + return -1; + } + }; + functionRegistry.addMultiple(imageFunctions); + }); + + // + var root = (function (window, options) { + var document = window.document; + var less = lessRoot(); + less.options = options; + var environment = less.environment; + var FileManager = FM(options, less.logger); + var fileManager = new FileManager(); + environment.addFileManager(fileManager); + less.FileManager = FileManager; + less.PluginLoader = PluginLoader; + LogListener(less, options); + var errors = ErrorReporting(window, less, options); + var cache = less.cache = options.cache || Cache(window, options, less.logger); + ImageSize(less.environment); + // Setup user functions - Deprecate? + if (options.functions) { + less.functions.functionRegistry.addMultiple(options.functions); + } + var typePattern = /^text\/(x-)?less$/; + function clone(obj) { + var cloned = {}; + for (var prop in obj) { + if (obj.hasOwnProperty(prop)) { + cloned[prop] = obj[prop]; + } + } + return cloned; + } + // only really needed for phantom + function bind(func, thisArg) { + var curryArgs = Array.prototype.slice.call(arguments, 2); + return function () { + var args = curryArgs.concat(Array.prototype.slice.call(arguments, 0)); + return func.apply(thisArg, args); + }; + } + function loadStyles(modifyVars) { + var styles = document.getElementsByTagName('style'); + var style; + for (var i = 0; i < styles.length; i++) { + style = styles[i]; + if (style.type.match(typePattern)) { + var instanceOptions = clone(options); + instanceOptions.modifyVars = modifyVars; + var lessText = style.innerHTML || ''; + instanceOptions.filename = document.location.href.replace(/#.*$/, ''); + /* jshint loopfunc:true */ + // use closure to store current style + less.render(lessText, instanceOptions, bind(function (style, e, result) { + if (e) { + errors.add(e, 'inline'); + } + else { + style.type = 'text/css'; + if (style.styleSheet) { + style.styleSheet.cssText = result.css; + } + else { + style.innerHTML = result.css; + } + } + }, null, style)); + } + } + } + function loadStyleSheet(sheet, callback, reload, remaining, modifyVars) { + var instanceOptions = clone(options); + addDataAttr(instanceOptions, sheet); + instanceOptions.mime = sheet.type; + if (modifyVars) { + instanceOptions.modifyVars = modifyVars; + } + function loadInitialFileCallback(loadedFile) { + var data = loadedFile.contents; + var path = loadedFile.filename; + var webInfo = loadedFile.webInfo; + var newFileInfo = { + currentDirectory: fileManager.getPath(path), + filename: path, + rootFilename: path, + rewriteUrls: instanceOptions.rewriteUrls + }; + newFileInfo.entryPath = newFileInfo.currentDirectory; + newFileInfo.rootpath = instanceOptions.rootpath || newFileInfo.currentDirectory; + if (webInfo) { + webInfo.remaining = remaining; + var css = cache.getCSS(path, webInfo, instanceOptions.modifyVars); + if (!reload && css) { + webInfo.local = true; + callback(null, css, data, sheet, webInfo, path); + return; + } + } + // TODO add tests around how this behaves when reloading + errors.remove(path); + instanceOptions.rootFileInfo = newFileInfo; + less.render(data, instanceOptions, function (e, result) { + if (e) { + e.href = path; + callback(e); + } + else { + 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) + .then(function (loadedFile) { + loadInitialFileCallback(loadedFile); + }).catch(function (err) { + console.log(err); + callback(err); + }); + } + function loadStyleSheets(callback, reload, modifyVars) { + for (var i = 0; i < less.sheets.length; i++) { + loadStyleSheet(less.sheets[i], callback, reload, less.sheets.length - (i + 1), modifyVars); + } + } + function initRunningMode() { + if (less.env === 'development') { + less.watchTimer = setInterval(function () { + if (less.watchMode) { + fileManager.clearFileCache(); + loadStyleSheets(function (e, css, _, sheet, webInfo) { + if (e) { + errors.add(e, e.href || sheet.href); + } + else if (css) { + browser.createCSS(window.document, css, sheet); + } + }); + } + }, options.poll); + } + } + // + // Watch mode + // + less.watch = function () { + if (!less.watchMode) { + less.env = 'development'; + initRunningMode(); + } + this.watchMode = true; + return true; + }; + less.unwatch = function () { clearInterval(less.watchTimer); this.watchMode = false; return false; }; + // + // Synchronously get all tags with the 'rel' attribute set to + // "stylesheet/less". + // + less.registerStylesheetsImmediately = function () { + var links = document.getElementsByTagName('link'); + less.sheets = []; + for (var i = 0; i < links.length; i++) { + if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) && + (links[i].type.match(typePattern)))) { + less.sheets.push(links[i]); + } + } + }; + // + // Asynchronously get all tags with the 'rel' attribute set to + // "stylesheet/less", returning a Promise. + // + less.registerStylesheets = function () { return new Promise(function (resolve, reject) { + less.registerStylesheetsImmediately(); + resolve(); + }); }; + // + // With this function, it's possible to alter variables and re-render + // CSS without reloading less-files + // + less.modifyVars = function (record) { return less.refresh(true, record, false); }; + less.refresh = function (reload, modifyVars, clearFileCache) { + if ((reload || clearFileCache) && clearFileCache !== false) { + fileManager.clearFileCache(); + } + return new Promise(function (resolve, reject) { + var startTime; + var endTime; + var totalMilliseconds; + var remainingSheets; + startTime = endTime = new Date(); + // Set counter for remaining unprocessed sheets + remainingSheets = less.sheets.length; + if (remainingSheets === 0) { + endTime = new Date(); + totalMilliseconds = endTime - startTime; + less.logger.info('Less has finished and no sheets were loaded.'); + resolve({ + startTime: startTime, + endTime: endTime, + totalMilliseconds: totalMilliseconds, + sheets: less.sheets.length + }); + } + else { + // Relies on less.sheets array, callback seems to be guaranteed to be called for every element of the array + loadStyleSheets(function (e, css, _, sheet, webInfo) { + if (e) { + errors.add(e, e.href || sheet.href); + reject(e); + return; + } + if (webInfo.local) { + less.logger.info("Loading " + sheet.href + " from cache."); + } + else { + less.logger.info("Rendered " + sheet.href + " successfully."); + } + browser.createCSS(window.document, css, sheet); + less.logger.info("CSS for " + sheet.href + " generated in " + (new Date() - endTime) + "ms"); + // Count completed sheet + remainingSheets--; + // Check if the last remaining sheet was processed and then call the promise + if (remainingSheets === 0) { + totalMilliseconds = new Date() - startTime; + less.logger.info("Less has finished. CSS generated in " + totalMilliseconds + "ms"); + resolve({ + startTime: startTime, + endTime: endTime, + totalMilliseconds: totalMilliseconds, + sheets: less.sheets.length + }); + } + endTime = new Date(); + }, reload, modifyVars); + } + loadStyles(modifyVars); + }); + }; + less.refreshStyles = loadStyles; + return less; + }); + + /** + * Kicks off less and compiles any stylesheets + * used in the browser distributed version of less + * to kick-start less using the browser api + */ + var options = defaultOptions(); + if (window.less) { + for (var key in window.less) { + if (window.less.hasOwnProperty(key)) { + options[key] = window.less[key]; + } + } + } + addDefaultOptions(window, options); + options.plugins = options.plugins || []; + if (window.LESS_PLUGINS) { + options.plugins = options.plugins.concat(window.LESS_PLUGINS); + } + var less = root(window, options); + window.less = less; + var css; + var head; + var style; + // Always restore page visibility + function resolveOrReject(data) { + if (data.filename) { + console.warn(data); + } + if (!options.async) { + head.removeChild(style); + } + } + if (options.onReady) { + if (/!watch/.test(window.location.hash)) { + less.watch(); + } + // Simulate synchronous stylesheet loading by hiding page rendering + if (!options.async) { + css = 'body { display: none !important }'; + head = document.head || document.getElementsByTagName('head')[0]; + style = document.createElement('style'); + style.type = 'text/css'; + if (style.styleSheet) { + style.styleSheet.cssText = css; + } + else { + style.appendChild(document.createTextNode(css)); + } + head.appendChild(style); + } + less.registerStylesheetsImmediately(); + less.pageLoadFinished = less.refresh(less.env === 'development').then(resolveOrReject, resolveOrReject); + } + return less; - }); - /** - * Kicks off less and compiles any stylesheets - * used in the browser distributed version of less - * to kick-start less using the browser api - */ - var options$1 = defaultOptions(); - - if (window.less) { - for (var key in window.less) { - if (window.less.hasOwnProperty(key)) { - options$1[key] = window.less[key]; - } - } - } - - addDefaultOptions(window, options$1); - options$1.plugins = options$1.plugins || []; - - if (window.LESS_PLUGINS) { - options$1.plugins = options$1.plugins.concat(window.LESS_PLUGINS); - } - - var less = root(window, options$1); - window.less = less; - var css; - var head; - var style; // Always restore page visibility - - function resolveOrReject(data) { - if (data.filename) { - console.warn(data); - } - - if (!options$1.async) { - head.removeChild(style); - } - } - - if (options$1.onReady) { - if (/!watch/.test(window.location.hash)) { - less.watch(); - } // Simulate synchronous stylesheet loading by hiding page rendering - - - if (!options$1.async) { - css = 'body { display: none !important }'; - head = document.head || document.getElementsByTagName('head')[0]; - style = document.createElement('style'); - style.type = 'text/css'; - - if (style.styleSheet) { - style.styleSheet.cssText = css; - } else { - style.appendChild(document.createTextNode(css)); - } - - head.appendChild(style); - } - - less.registerStylesheetsImmediately(); - less.pageLoadFinished = less.refresh(less.env === 'development').then(resolveOrReject, resolveOrReject); - } - - return less; - -})); +}))); diff --git a/vendor/less/dist/less.min.js b/vendor/less/dist/less.min.js index 5472db1a0..ce4c4aa7d 100644 --- a/vendor/less/dist/less.min.js +++ b/vendor/less/dist/less.min.js @@ -1,11 +1,11 @@ /** - * Less - Leaner CSS v3.10.3 + * Less - Leaner CSS v4.1.2 * http://lesscss.org * - * Copyright (c) 2009-2019, Alexis Sellier + * Copyright (c) 2009-2021, Alexis Sellier * Licensed under the Apache-2.0 License. * * @license Apache-2.0 */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).less=t()}(this,function(){"use strict";function e(e){return e.replace(/^[a-z-]+:\/+?[^\/]+/,"").replace(/[\?\&]livereload=\w+/,"").replace(/^\//,"").replace(/\.[a-zA-Z]+$/,"").replace(/[^\.\w-]+/g,"-").replace(/\./g,":")}function t(e,t){for(var n in t.dataset)if(t.dataset.hasOwnProperty(n))if("env"===n||"dumpLineNumbers"===n||"rootpath"===n||"errorReporting"===n)e[n]=t.dataset[n];else try{e[n]=JSON.parse(t.dataset[n])}catch(e){}}var n={createCSS:function(t,n,i){var r=i.href||"",a="less:".concat(i.title||e(r)),s=t.getElementById(a),o=!1,l=t.createElement("style");l.setAttribute("type","text/css"),i.media&&l.setAttribute("media",i.media),l.id=a,l.styleSheet||(l.appendChild(t.createTextNode(n)),o=null!==s&&s.childNodes.length>0&&l.childNodes.length>0&&s.firstChild.nodeValue===l.firstChild.nodeValue);var u=t.getElementsByTagName("head")[0];if(null===s||!1===o){var c=i&&i.nextSibling||null;c?c.parentNode.insertBefore(l,c):u.appendChild(l)}if(s&&!1===o&&s.parentNode.removeChild(s),l.styleSheet)try{l.styleSheet.cssText=n}catch(e){throw new Error("Couldn't reassign styleSheet.cssText.")}},currentScript:function(e){var t,n=e.document;return n.currentScript||(t=n.getElementsByTagName("script"))[t.length-1]}};function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;nt?1:void 0};var y=function(e){function t(e,n,i){var a;r(this,t);var s=h(a=f(this,l(t).call(this)));return Array.isArray(e)?a.rgb=e:e.length>=6?(a.rgb=[],e.match(/.{2}/g).map(function(e,t){t<3?s.rgb.push(parseInt(e,16)):s.alpha=parseInt(e,16)/255})):(a.rgb=[],e.split("").map(function(e,t){t<3?s.rgb.push(parseInt(e+e,16)):s.alpha=parseInt(e+e,16)/255})),a.alpha=a.alpha||("number"==typeof n?n:1),void 0!==i&&(a.value=i),a}return o(t,g),s(t,[{key:"luma",value:function(){var e=this.rgb[0]/255,t=this.rgb[1]/255,n=this.rgb[2]/255;return.2126*(e=e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.7152*(t=t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.0722*(n=n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))}},{key:"genCSS",value:function(e,t){t.add(this.toCSS(e))}},{key:"toCSS",value:function(e,t){var n,i,r,a=e&&e.compress&&!t,s=[];if(i=this.fround(e,this.alpha),this.value)if(0===this.value.indexOf("rgb"))i<1&&(r="rgba");else{if(0!==this.value.indexOf("hsl"))return this.value;r=i<1?"hsla":"hsl"}else i<1&&(r="rgba");switch(r){case"rgba":s=this.rgb.map(function(e){return b(Math.round(e),255)}).concat(b(i,1));break;case"hsla":s.push(b(i,1));case"hsl":n=this.toHSL(),s=[this.fround(e,n.h),"".concat(this.fround(e,100*n.s),"%"),"".concat(this.fround(e,100*n.l),"%")].concat(s)}if(r)return"".concat(r,"(").concat(s.join(",".concat(a?"":" ")),")");if(n=this.toRGB(),a){var o=n.split("");o[1]===o[2]&&o[3]===o[4]&&o[5]===o[6]&&(n="#".concat(o[1]).concat(o[3]).concat(o[5]))}return n}},{key:"operate",value:function(e,n,i){for(var r=new Array(3),a=this.alpha*(1-i.alpha)+i.alpha,s=0;s<3;s++)r[s]=this._operate(e,n,this.rgb[s],i.rgb[s]);return new t(r,a)}},{key:"toRGB",value:function(){return w(this.rgb)}},{key:"toHSL",value:function(){var e,t,n=this.rgb[0]/255,i=this.rgb[1]/255,r=this.rgb[2]/255,a=this.alpha,s=Math.max(n,i,r),o=Math.min(n,i,r),l=(s+o)/2,u=s-o;if(s===o)e=t=0;else{switch(t=l>.5?u/(2-s-o):u/(s+o),s){case n:e=(i-r)/u+(i0&&void 0!==arguments[0]?arguments[0]:{},t=this.value,n=e.firstSelector;return t instanceof k&&(e.firstSelector=!0),t=t.toCSS?t.toCSS(e):t,e.firstSelector=n,""===t&&"&"===this.combinator.value.charAt(0)?"":this.combinator.toCSS(e)+t}}]),t}();I.prototype.type="Element";var C={ALWAYS:0,PARENS_DIVISION:1,PARENS:2,STRICT_LEGACY:3},_={OFF:0,LOCAL:1,ALL:2};var A=function(e,t){return e(t={exports:{}},t.exports),t.exports}(function(e){var t=function(){function e(e,t){return null!=t&&e instanceof t}var t,n,i;try{t=Map}catch(e){t=function(){}}try{n=Set}catch(e){n=function(){}}try{i=Promise}catch(e){i=function(){}}function r(a,o,l,u,c){"object"==typeof o&&(l=o.depth,u=o.prototype,c=o.includeNonEnumerable,o=o.circular);var h=[],f=[],p="undefined"!=typeof Buffer;return void 0===o&&(o=!0),void 0===l&&(l=1/0),function a(l,v){if(null===l)return null;if(0===v)return l;var d,m;if("object"!=typeof l)return l;if(e(l,t))d=new t;else if(e(l,n))d=new n;else if(e(l,i))d=new i(function(e,t){l.then(function(t){e(a(t,v-1))},function(e){t(a(e,v-1))})});else if(r.__isArray(l))d=[];else if(r.__isRegExp(l))d=new RegExp(l.source,s(l)),l.lastIndex&&(d.lastIndex=l.lastIndex);else if(r.__isDate(l))d=new Date(l.getTime());else{if(p&&Buffer.isBuffer(l))return d=Buffer.allocUnsafe?Buffer.allocUnsafe(l.length):new Buffer(l.length),l.copy(d),d;e(l,Error)?d=Object.create(l):void 0===u?(m=Object.getPrototypeOf(l),d=Object.create(m)):(d=Object.create(u),m=u)}if(o){var g=h.indexOf(l);if(-1!=g)return f[g];h.push(l),f.push(d)}for(var y in e(l,t)&&l.forEach(function(e,t){var n=a(t,v-1),i=a(e,v-1);d.set(n,i)}),e(l,n)&&l.forEach(function(e){var t=a(e,v-1);d.add(t)}),l){var b;m&&(b=Object.getOwnPropertyDescriptor(m,y)),b&&null==b.set||(d[y]=a(l[y],v-1))}if(Object.getOwnPropertySymbols){var w=Object.getOwnPropertySymbols(l);for(y=0;y=0&&"\n"!==t.charAt(n);)r++;return"number"==typeof e&&(i=(t.slice(0,e).match(/\n/g)||"").length),{line:i,column:r}}function P(e){var t,n=e.length,i=new Array(n);for(t=0;t1&&void 0!==arguments[1]?arguments[1]:[],n=0,i=e.length;n|Function):(\d+):(\d+)/);c&&(c[2]&&(this.line=parseInt(c[2])-2),c[3]&&(this.column=parseInt(c[3])))}this.callLine=l+1,this.callExtract=u[l],this.extract=[u[this.line-2],u[this.line-1],u[this.line]]}};if(void 0===Object.create){var L=function(){};L.prototype=Error.prototype,$.prototype=new L}else $.prototype=Object.create(Error.prototype);$.prototype.constructor=$,$.prototype.toString=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",n=this.extract||[],r=[],a=function(e){return e};if(e.stylize){var s=i(e.stylize);if("function"!==s)throw Error("options.stylize should be a function, got a ".concat(s,"!"));a=e.stylize}if(null!==this.line){if("string"==typeof n[0]&&r.push(a("".concat(this.line-1," ").concat(n[0]),"grey")),"string"==typeof n[1]){var o="".concat(this.line," ");n[1]&&(o+=n[1].slice(0,this.column)+a(a(a(n[1].substr(this.column,1),"bold")+n[1].slice(this.column+1),"red"),"inverse")),r.push(o)}"string"==typeof n[2]&&r.push(a("".concat(this.line+1," ").concat(n[2]),"grey")),r="".concat(r.join("\n")+a("","reset"),"\n")}return t+=a("".concat(this.type,"Error: ").concat(this.message),"red"),this.filename&&(t+=a(" in ","red")+this.filename),this.line&&(t+=a(" on line ".concat(this.line,", column ").concat(this.column+1,":"),"grey")),t+="\n".concat(r),this.callLine&&(t+="".concat(a("from ","red")+(this.filename||""),"/n"),t+="".concat(a(this.callLine,"grey")," ").concat(this.callExtract,"/n")),t};var D=function(e){function t(e,n,i,a,s,o){var u;return r(this,t),(u=f(this,l(t).call(this))).extendList=n,u.condition=i,u.evaldCondition=!i,u._index=a,u._fileInfo=s,u.elements=u.getElements(e),u.mixinElements_=void 0,u.copyVisibilityInfo(o),u.setParent(u.elements,h(u)),u}return o(t,g),s(t,[{key:"accept",value:function(e){this.elements&&(this.elements=e.visitArray(this.elements)),this.extendList&&(this.extendList=e.visitArray(this.extendList)),this.condition&&(this.condition=e.visit(this.condition))}},{key:"createDerived",value:function(e,n,i){var r=new t(e=this.getElements(e),n||this.extendList,null,this.getIndex(),this.fileInfo(),this.visibilityInfo());return r.evaldCondition=null!=i?i:this.evaldCondition,r.mediaEmpty=this.mediaEmpty,r}},{key:"getElements",value:function(e){return e?("string"==typeof e&&this.parse.parseNode(e,["selector"],this._index,this._fileInfo,function(t,n){if(t)throw new $({index:t.index,message:t.message},this.parse.imports,this._fileInfo.filename);e=n[0].elements}),e):[new I("","&",!1,this._index,this._fileInfo)]}},{key:"createEmptySelectors",value:function(){var e=[new t([new I("","&",!1,this._index,this._fileInfo)],null,null,this._index,this._fileInfo)];return e[0].mediaEmpty=!0,e}},{key:"match",value:function(e){var t,n,i=this.elements,r=i.length;if(0===(t=(e=e.mixinElements()).length)||rC.PARENS_DIVISION)||this.parensStack&&this.parensStack.length))}},{key:"pathRequiresRewrite",value:function(e){return(this.rewriteUrls===_.LOCAL?K:Q)(e)}},{key:"rewritePath",value:function(e,t){var n;return t=t||"",n=this.normalizePath(t+e),K(e)&&Q(t)&&!1===K(n)&&(n="./".concat(n)),n}},{key:"normalizePath",value:function(e){var t,n=e.split("/").reverse();for(e=[];0!==n.length;)switch(t=n.pop()){case".":break;case"..":0===e.length||".."===e[e.length-1]?e.push(t):e.pop();break;default:e.push(t)}return e.join("/")}}]),e}();var Z=function e(t){return{_data:{},add:function(e,t){e=e.toLowerCase(),this._data.hasOwnProperty(e),this._data[e]=t},addMultiple:function(e){var t=this;Object.keys(e).forEach(function(n){t.add(n,e[n])})},get:function(e){return this._data[e]||t&&t.get(e)},getLocalFunctions:function(){return this._data},inherit:function(){return e(this)},create:function(t){return e(t)}}}(null),Y={eval:function(){var e=this.value_,t=this.error_;if(t)throw t;if(null!=e)return e?j.True:j.False},value:function(e){this.value_=e},error:function(e){this.error_=e},reset:function(){this.value_=this.error_=null}},X=function(e){function t(e,n,i,a){var s;return r(this,t),(s=f(this,l(t).call(this))).selectors=e,s.rules=n,s._lookups={},s._variables=null,s._properties=null,s.strictImports=i,s.copyVisibilityInfo(a),s.allowRoot=!0,s.setParent(s.selectors,h(s)),s.setParent(s.rules,h(s)),s}return o(t,g),s(t,[{key:"isRulesetLike",value:function(){return!0}},{key:"accept",value:function(e){this.paths?this.paths=e.visitArray(this.paths,!0):this.selectors&&(this.selectors=e.visitArray(this.selectors)),this.rules&&this.rules.length&&(this.rules=e.visitArray(this.rules))}},{key:"eval",value:function(e){var n,i,r,a,s,o=!1;if(this.selectors&&(i=this.selectors.length)){for(n=new Array(i),Y.error({type:"Syntax",message:"it is currently only allowed in parametric mixin guards,"}),a=0;a0;e--){var t=this.rules[e-1];if(t instanceof q)return this.parseValue(t)}}},{key:"parseValue",value:function(e){var t=this;function n(e){return e.value instanceof B&&!e.parsed?("string"==typeof e.value.value?this.parse.parseNode(e.value.value,["value","important"],e.value.getIndex(),e.fileInfo(),function(t,n){t&&(e.parsed=!0),n&&(e.value=n[0],e.important=n[1]||"",e.parsed=!0)}):e.parsed=!0,e):e}if(Array.isArray(e)){var i=[];return e.forEach(function(e){i.push(n.call(t,e))}),i}return n.call(t,e)}},{key:"rulesets",value:function(){if(!this.rules)return[];var e,t,n=[],i=this.rules;for(e=0;t=i[e];e++)t.isRuleset&&n.push(t);return n}},{key:"prependRule",value:function(e){var t=this.rules;t?t.unshift(e):this.rules=[e],this.setParent(e,this)}},{key:"find",value:function(e){var t,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this,r=arguments.length>2?arguments[2]:void 0,a=[],s=e.toCSS();return s in this._lookups?this._lookups[s]:(this.rulesets().forEach(function(s){if(s!==i)for(var o=0;ot){if(!r||r(s)){n=s.find(new D(e.elements.slice(t)),i,r);for(var l=0;l0&&t.add(l),e.firstSelector=!0,s[0].genCSS(e,t),e.firstSelector=!1,i=1;i0?(a=(r=P(e)).pop(),s=i.createDerived(P(a.elements))):s=i.createDerived([]),t.length>0){var o=n.combinator,l=t[0].elements[0];o.emptyOrWhitespace&&!l.combinator.emptyOrWhitespace&&(o=l.combinator),s.elements.push(new I(o,l.value,n.isVariable,n._index,n._fileInfo)),s.elements=s.elements.concat(t[0].elements.slice(1))}if(0!==s.elements.length&&r.push(s),t.length>1){var u=t.slice(1);u=u.map(function(e){return e.createDerived(e.elements,[])}),r=r.concat(u)}return r}function s(e,t,n,i,r){var s;for(s=0;s0?i[i.length-1]=i[i.length-1].createDerived(i[i.length-1].elements.concat(e)):i.push(new D(e));else t.push([new D(e)])}function l(e,t){var n=t.createDerived(t.elements,t.extendList,t.evaldCondition);return n.copyVisibilityInfo(e),n}var u,c;if(!function e(t,n,l){var u,c,h,f,p,v,d,m,g,y,b,w,x=!1;for(f=[],p=[[]],u=0;m=l.elements[u];u++)if("&"!==m.value){var S=(w=void 0,(b=m).value instanceof k&&(w=b.value.value)instanceof D?w:null);if(null!=S){o(f,p);var C,_=[],A=[];for(C=e(_,n,S),x=x||C,h=0;h<_.length;h++)s(p,[r(i(_[h],m),m)],m,l,A);p=A,f=[]}else f.push(m)}else{for(x=!0,v=[],o(f,p),c=0;c0&&d[0].elements.push(new I(m.combinator,"",m.isVariable,m._index,m._fileInfo)),v.push(d);else for(h=0;h0&&(t.push(p[u]),y=p[u][g-1],p[u][g-1]=y.createDerived(y.elements,l.extendList));return x}(c=[],t,n))if(t.length>0)for(c=[],u=0;u0)for(t=0;t-1e-6&&(i=n.toFixed(20).replace(/0+$/,"")),e&&e.compress){if(0===n&&this.unit.isLength())return void t.add(i);n>0&&n<1&&(i=i.substr(1))}t.add(i),this.unit.genCSS(e,t)}},{key:"operate",value:function(e,n,i){var r=this._operate(e,n,this.value,i.value),a=this.unit.clone();if("+"===n||"-"===n)if(0===a.numerator.length&&0===a.denominator.length)a=i.unit.clone(),this.unit.backupUnit&&(a.backupUnit=this.unit.backupUnit);else if(0===i.unit.numerator.length&&0===a.denominator.length);else{if(i=i.convertTo(this.unit.usedUnits()),e.strictUnits&&i.unit.toString()!==a.toString())throw new Error("Incompatible units. Change the units or use the unit function. "+"Bad units: '".concat(a.toString(),"' and '").concat(i.unit.toString(),"'."));r=this._operate(e,n,this.value,i.value)}else"*"===n?(a.numerator=a.numerator.concat(i.unit.numerator).sort(),a.denominator=a.denominator.concat(i.unit.denominator).sort(),a.cancel()):"/"===n&&(a.numerator=a.numerator.concat(i.unit.denominator).sort(),a.denominator=a.denominator.concat(i.unit.numerator).sort(),a.cancel());return new t(r,a)}},{key:"compare",value:function(e){var n,i;if(e instanceof t){if(this.unit.isEmpty()||e.unit.isEmpty())n=this,i=e;else if(n=this.unify(),i=e.unify(),0!==n.unit.compare(i.unit))return;return g.numericCompare(n.value,i.value)}}},{key:"unify",value:function(){return this.convertTo({length:"px",duration:"s",angle:"rad"})}},{key:"convertTo",value:function(e){var n,i,r,a,s,o=this.value,l=this.unit.clone(),u={};if("string"==typeof e){for(n in d)d[n].hasOwnProperty(e)&&((u={})[n]=e);e=u}for(i in s=function(e,t){return r.hasOwnProperty(e)?(t?o/=r[e]/r[a]:o*=r[e]/r[a],a):e},e)e.hasOwnProperty(i)&&(a=e[i],r=d[i],l.map(s));return l.cancel(),new t(o,l)}}]),t}();ie.prototype.type="Dimension";var re=C,ae=function(e){function t(e,n,i){var a;return r(this,t),(a=f(this,l(t).call(this))).op=e.trim(),a.operands=n,a.isSpaced=i,a}return o(t,g),s(t,[{key:"accept",value:function(e){this.operands=e.visitArray(this.operands)}},{key:"eval",value:function(e){var n,i=this.operands[0].eval(e),r=this.operands[1].eval(e);if(e.isMathOn(this.op)){if(n="./"===this.op?"/":this.op,i instanceof ie&&r instanceof y&&(i=i.toColor()),r instanceof ie&&i instanceof y&&(r=r.toColor()),!i.operate){if(i instanceof t&&"/"===i.op&&e.math===re.PARENS_DIVISION)return new t(this.op,[i,r],this.isSpaced);throw{type:"Operation",message:"Operation on an invalid type"}}return i.operate(e,n,r)}return new t(this.op,[i,r],this.isSpaced)}},{key:"genCSS",value:function(e,t){this.operands[0].genCSS(e,t),this.isSpaced&&t.add(" "),t.add(this.op),this.isSpaced&&t.add(" "),this.operands[1].genCSS(e,t)}}]),t}();ae.prototype.type="Operation";var se=C,oe=function(e){function t(e,n){var i;if(r(this,t),(i=f(this,l(t).call(this))).value=e,i.noSpacing=n,!e)throw new Error("Expression requires an array parameter");return i}return o(t,g),s(t,[{key:"accept",value:function(e){this.value=e.visitArray(this.value)}},{key:"eval",value:function(e){var n,i=e.isMathOn(),r=this.parens&&(e.math!==se.STRICT_LEGACY||!this.parensInOp),a=!1;return r&&e.inParenthesis(),this.value.length>1?n=new t(this.value.map(function(t){return t.eval?t.eval(e):t}),this.noSpacing):1===this.value.length?(!this.value[0].parens||this.value[0].parensInOp||e.inCalc||(a=!0),n=this.value[0].eval(e)):n=this,r&&e.outOfParenthesis(),!this.parens||!this.parensInOp||i||a||n instanceof ie||(n=new k(n)),n}},{key:"genCSS",value:function(e,t){for(var n=0;n1){var n=new D([],null,null,this.getIndex(),this.fileInfo()).createEmptySelectors();(t=new X(n,e.mediaBlocks)).multiMedia=!0,t.copyVisibilityInfo(this.visibilityInfo()),this.setParent(t,this)}return delete e.mediaBlocks,delete e.mediaPath,t}},{key:"evalNested",value:function(e){var t,n,i=e.mediaPath.concat([this]);for(t=0;t0;t--)e.splice(t,0,new B("and"));return new oe(e)})),this.setParent(this.features,this),new X([],[])}},{key:"permute",value:function(e){if(0===e.length)return[];if(1===e.length)return e[0];for(var t=[],n=this.permute(e.slice(1)),i=0;i1?"[".concat(e.value.map(function(e){return e.toCSS()}).join(", "),"]"):e.toCSS()}}]),t}(),ye=function(e){function t(e,n,i,a){var s;return r(this,t),(s=f(this,l(t).call(this))).escaped=n,s.expression=e,s._index=i,s._fileInfo=a,s}return o(t,ge),s(t,[{key:"eval",value:function(e){var t=this.evaluateJavaScript(this.expression,e),n=i(t);return"number"!==n||isNaN(t)?"string"===n?new pe('"'.concat(t,'"'),t,this.escaped,this._index):Array.isArray(t)?new B(t.join(", ")):new B(t):new ie(t)}}]),t}();ye.prototype.type="JavaScript";var be=function(e){function t(e,n){var i;return r(this,t),(i=f(this,l(t).call(this))).key=e,i.value=n,i}return o(t,g),s(t,[{key:"accept",value:function(e){this.value=e.visit(this.value)}},{key:"eval",value:function(e){return this.value.eval?new t(this.key,this.value.eval(e)):this}},{key:"genCSS",value:function(e,t){t.add("".concat(this.key,"=")),this.value.genCSS?this.value.genCSS(e,t):t.add(this.value)}}]),t}();be.prototype.type="Assignment";var we=function(e){function t(e,n,i,a,s){var o;return r(this,t),(o=f(this,l(t).call(this))).op=e.trim(),o.lvalue=n,o.rvalue=i,o._index=a,o.negate=s,o}return o(t,g),s(t,[{key:"accept",value:function(e){this.lvalue=e.visit(this.lvalue),this.rvalue=e.visit(this.rvalue)}},{key:"eval",value:function(e){var t=function(e,t,n){switch(e){case"and":return t&&n;case"or":return t||n;default:switch(g.compare(t,n)){case-1:return"<"===e||"=<"===e||"<="===e;case 0:return"="===e||">="===e||"=<"===e||"<="===e;case 1:return">"===e||">="===e;default:return!1}}}(this.op,this.lvalue.eval(e),this.rvalue.eval(e));return this.negate?!t:t}}]),t}();we.prototype.type="Condition";var ke=function(e){function t(e){var n;return r(this,t),(n=f(this,l(t).call(this))).value=e,n}return o(t,g),t}();ke.prototype.type="UnicodeDescriptor";var xe=function(e){function t(e){var n;return r(this,t),(n=f(this,l(t).call(this))).value=e,n}return o(t,g),s(t,[{key:"genCSS",value:function(e,t){t.add("-"),this.value.genCSS(e,t)}},{key:"eval",value:function(e){return e.isMathOn()?new ae("*",[new ie(-1),this.value]).eval(e):new t(this.value.eval(e))}}]),t}();xe.prototype.type="Negative";var Se=function(e){function t(e,n,i,a,s){var o;switch(r(this,t),(o=f(this,l(t).call(this))).selector=e,o.option=n,o.object_id=t.next_id++,o.parent_ids=[o.object_id],o._index=i,o._fileInfo=a,o.copyVisibilityInfo(s),o.allowRoot=!0,n){case"all":o.allowBefore=!0,o.allowAfter=!0;break;default:o.allowBefore=!1,o.allowAfter=!1}return o.setParent(o.selector,h(o)),o}return o(t,g),s(t,[{key:"accept",value:function(e){this.selector=e.visit(this.selector)}},{key:"eval",value:function(e){return new t(this.selector.eval(e),this.option,this.getIndex(),this.fileInfo(),this.visibilityInfo())}},{key:"clone",value:function(e){return new t(this.selector,this.option,this.getIndex(),this.fileInfo(),this.visibilityInfo())}},{key:"findSelfSelectors",value:function(e){var t,n,i=[];for(t=0;t0&&n.length&&""===n[0].combinator.value&&(n[0].combinator.value=" "),i=i.concat(e[t].elements);this.selfSelectors=[new D(i)],this.selfSelectors[0].copyVisibilityInfo(this.visibilityInfo())}}]),t}();Se.next_id=0,Se.prototype.type="Extend";var Ie=function(e){function t(e,n,i){var a;return r(this,t),(a=f(this,l(t).call(this))).variable=e,a._index=n,a._fileInfo=i,a.allowRoot=!0,a}return o(t,g),s(t,[{key:"eval",value:function(e){var t,n=new ce(this.variable,this.getIndex(),this.fileInfo()).eval(e),i=new $({message:"Could not evaluate variable call ".concat(this.variable)});if(!n.ruleset){if(n.rules)t=n;else if(Array.isArray(n))t=new X("",n);else{if(!Array.isArray(n.value))throw i;t=new X("",n.value)}n=new te(t)}if(n.ruleset)return n.callEval(e);throw i}}]),t}();Ie.prototype.type="VariableCall";var Ce=function(e){function t(e,n,i,a,s){var o;return r(this,t),(o=f(this,l(t).call(this))).value=e,o.lookups=n,o.important=i,o._index=a,o._fileInfo=s,o}return o(t,g),s(t,[{key:"eval",value:function(e){var t,n,i=this.value.eval(e);for(t=0;tthis.params.length)return!1}n=Math.min(a,this.arity);for(var s=0;s0){for(c=!0,o=0;o0)f=I;else if(f=S,p[S]+p[I]>1)throw{type:"Runtime",message:"Ambiguous use of `default()` found when matching for `".concat(this.format(m),"`"),index:this.getIndex(),filename:this.fileInfo().filename};for(o=0;o=0;s--){var o=a[s];if(o[r?"supportsSync":"supports"](e,t,n,i))return o}return null}},{key:"addFileManager",value:function(e){this.fileManagers.push(e)}},{key:"clearFileManagers",value:function(){this.fileManagers=[]}}]),e}(),Re=function(){function e(){r(this,e)}return s(e,[{key:"getPath",value:function(e){var t=e.lastIndexOf("?");return t>0&&(e=e.slice(0,t)),(t=e.lastIndexOf("/"))<0&&(t=e.lastIndexOf("\\")),t<0?"":e.slice(0,t+1)}},{key:"tryAppendExtension",value:function(e,t){return/(\.[a-z]*$)|([\?;].*)$/.test(e)?e:e+t}},{key:"tryAppendLessExtension",value:function(e){return this.tryAppendExtension(e,".less")}},{key:"supportsSync",value:function(){return!1}},{key:"alwaysMakePathsAbsolute",value:function(){return!1}},{key:"isPathAbsolute",value:function(e){return/^(?:[a-z-]+:|\/|\\|#)/i.test(e)}},{key:"join",value:function(e,t){return e?e+t:t}},{key:"pathDiff",value:function(e,t){var n,i,r,a,s=this.extractUrlParts(e),o=this.extractUrlParts(t),l="";if(s.hostPart!==o.hostPart)return"";for(i=Math.max(o.directories.length,s.directories.length),n=0;nparseInt(t[n])?-1:1;return 0}},{key:"versionToString",value:function(e){for(var t="",n=0;n0;){var e=this.imports[0];if(!e.isReady)return;this.imports=this.imports.slice(1),e.callback.apply(null,e.args)}if(0===this.variableImports.length)break;var t=this.variableImports[0];this.variableImports=this.variableImports.slice(1),t()}}finally{this._currentDepth--}0===this._currentDepth&&this._onSequencerEmpty&&this._onSequencerEmpty()}}]),e}(),Ne=function(e,t){this._visitor=new Le(this),this._importer=e,this._finish=t,this.context=new G.Eval,this.importCount=0,this.onceFileDetectionMap={},this.recursionDetector={},this._sequencer=new De(this._onSequencerEmpty.bind(this))};Ne.prototype={isReplacing:!1,run:function(e){try{this._visitor.visit(e)}catch(e){this.error=e}this.isFinished=!0,this._sequencer.tryRun()},_onSequencerEmpty:function(){this.isFinished&&this._finish(this.error)},visitImport:function(e,t){var n=e.options.inline;if(!e.css||n){var i=new G.Eval(this.context,P(this.context.frames)),r=i.frames[0];this.importCount++,e.isVariableImport()?this._sequencer.addVariableImport(this.processImportNode.bind(this,e,i,r)):this.processImportNode(e,i,r)}t.visitDeeper=!1},processImportNode:function(e,t,n){var i,r=e.options.inline;try{i=e.evalForImport(t)}catch(t){t.filename||(t.index=e.getIndex(),t.filename=e.fileInfo().filename),e.css=!0,e.error=t}if(!i||i.css&&!r)this.importCount--,this.isFinished&&this._sequencer.tryRun();else{i.options.multiple&&(t.importMultiple=!0);for(var a=void 0===i.css,s=0;s=0||(o=[u.selfSelectors[0]],(a=f.findMatch(l,o)).length&&(l.hasFoundMatches=!0,l.selfSelectors.forEach(function(e){var t=u.visibilityInfo();s=f.extendSelector(a,o,e,l.isVisible()),(c=new Me.Extend(u.selector,u.option,0,u.fileInfo(),t)).selfSelectors=s,s[s.length-1].extendList=[c],h.push(c),c.ruleset=u.ruleset,c.parent_ids=c.parent_ids.concat(u.parent_ids,l.parent_ids),u.firstExtendOnThisSelectorPath&&(c.firstExtendOnThisSelectorPath=!0,u.ruleset.paths.push(s))})));if(h.length){if(this.extendChainCount++,n>100){var p="{unable to calculate}",v="{unable to calculate}";try{p=h[0].selfSelectors[0].toCSS(),v=h[0].selector.toCSS()}catch(e){}throw{message:"extend circular reference detected. One of the circular extends is currently:".concat(p,":extend(").concat(v,")")}}return h.concat(f.doExtendChaining(h,t,n+1))}return h}},{key:"visitDeclaration",value:function(e,t){t.visitDeeper=!1}},{key:"visitMixinDefinition",value:function(e,t){t.visitDeeper=!1}},{key:"visitSelector",value:function(e,t){t.visitDeeper=!1}},{key:"visitRuleset",value:function(e,t){if(!e.root){var n,i,r,a,s=this.allExtendsStack[this.allExtendsStack.length-1],o=[],l=this;for(r=0;r0&&u[l.matched].combinator.value!==s?l=null:l.matched++,l&&(l.finished=l.matched===u.length,l.finished&&!e.allowAfter&&(r+1u&&c>0&&(h[h.length-1].elements=h[h.length-1].elements.concat(t[u].elements.slice(c)),c=0,u++),l=a.elements.slice(c,o.index).concat([s]).concat(n.elements.slice(1)),u===o.pathIndex&&r>0?h[h.length-1].elements=h[h.length-1].elements.concat(l):(h=h.concat(t.slice(u,o.pathIndex))).push(new Me.Selector(l)),u=o.endPathIndex,(c=o.endPathElementIndex)>=t[u].elements.length&&(c=0,u++);return u0&&(h[h.length-1].elements=h[h.length-1].elements.concat(t[u].elements.slice(c)),u++),h=(h=h.concat(t.slice(u,t.length))).map(function(e){var t=e.createDerived(e.elements);return i?t.ensureVisibility():t.ensureInvisibility(),t})}},{key:"visitMedia",value:function(e,t){var n=e.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length-1]);n=n.concat(this.doExtendChaining(n,e.allExtends)),this.allExtendsStack.push(n)}},{key:"visitMediaOut",value:function(e){var t=this.allExtendsStack.length-1;this.allExtendsStack.length=t}},{key:"visitAtRule",value:function(e,t){var n=e.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length-1]);n=n.concat(this.doExtendChaining(n,e.allExtends)),this.allExtendsStack.push(n)}},{key:"visitAtRuleOut",value:function(e){var t=this.allExtendsStack.length-1;this.allExtendsStack.length=t}}]),e}(),qe=function(){function e(){r(this,e),this.contexts=[[]],this._visitor=new Le(this)}return s(e,[{key:"run",value:function(e){return this._visitor.visit(e)}},{key:"visitDeclaration",value:function(e,t){t.visitDeeper=!1}},{key:"visitMixinDefinition",value:function(e,t){t.visitDeeper=!1}},{key:"visitRuleset",value:function(e,t){var n,i=this.contexts[this.contexts.length-1],r=[];this.contexts.push(r),e.root||((n=e.selectors)&&(n=n.filter(function(e){return e.getIsOutput()}),e.selectors=n.length?n:n=null,n&&e.joinSelectors(r,i,n)),n||(e.rules=null),e.paths=r)}},{key:"visitRulesetOut",value:function(e){this.contexts.length=this.contexts.length-1}},{key:"visitMedia",value:function(e,t){var n=this.contexts[this.contexts.length-1];e.rules[0].root=0===n.length||n[0].multiMedia}},{key:"visitAtRule",value:function(e,t){var n=this.contexts[this.contexts.length-1];e.rules&&e.rules.length&&(e.rules[0].root=e.isRooted||0===n.length||null)}}]),e}(),Te=function(){function e(t){r(this,e),this._visitor=new Le(this),this._context=t}return s(e,[{key:"containsSilentNonBlockedChild",value:function(e){var t;if(!e)return!1;for(var n=0;n0}},{key:"resolveVisibility",value:function(e,t){if(!e.blocksVisibility()){if(this.isEmpty(e)&&!this.containsSilentNonBlockedChild(t))return;return e}var n=e.rules[0];if(this.keepOnlyVisibleChilds(n),!this.isEmpty(n))return e.ensureVisibility(),e.removeVisibilityBlock(),e}},{key:"isVisibleRuleset",value:function(e){return!!e.firstRoot||!this.isEmpty(e)&&!(!e.root&&!this.hasVisibleSelector(e))}}]),e}(),ze=function(e){this._visitor=new Le(this),this._context=e,this.utils=new Te(e)};ze.prototype={isReplacing:!0,run:function(e){return this._visitor.visit(e)},visitDeclaration:function(e,t){if(!e.blocksVisibility()&&!e.variable)return e},visitMixinDefinition:function(e,t){e.frames=[]},visitExtend:function(e,t){},visitComment:function(e,t){if(!e.blocksVisibility()&&!e.isSilent(this._context))return e},visitMedia:function(e,t){var n=e.rules[0].rules;return e.accept(this._visitor),t.visitDeeper=!1,this.utils.resolveVisibility(e,n)},visitImport:function(e,t){if(!e.blocksVisibility())return e},visitAtRule:function(e,t){return e.rules&&e.rules.length?this.visitAtRuleWithBody(e,t):this.visitAtRuleWithoutBody(e,t)},visitAnonymous:function(e,t){if(!e.blocksVisibility())return e.accept(this._visitor),e},visitAtRuleWithBody:function(e,t){var n=function(e){var t=e.rules;return function(e){var t=e.rules;return 1===t.length&&(!t[0].paths||0===t[0].paths.length)}(e)?t[0].rules:t}(e);return e.accept(this._visitor),t.visitDeeper=!1,this.utils.isEmpty(e)||this._mergeRules(e.rules[0].rules),this.utils.resolveVisibility(e,n)},visitAtRuleWithoutBody:function(e,t){if(!e.blocksVisibility()){if("@charset"===e.name){if(this.charset){if(e.debugInfo){var n=new Me.Comment("/* ".concat(e.toCSS(this._context).replace(/\n/g,"")," */\n"));return n.debugInfo=e.debugInfo,this._visitor.visit(n)}return}this.charset=!0}return e}},checkValidNodes:function(e,t){if(e)for(var n=0;n0?e.accept(this._visitor):e.rules=null,t.visitDeeper=!1}return e.rules&&(this._mergeRules(e.rules),this._removeDuplicateRules(e.rules)),this.utils.isVisibleRuleset(e)&&(e.ensureVisibility(),i.splice(0,0,e)),1===i.length?i[0]:i},_compileRulesetPaths:function(e){e.paths&&(e.paths=e.paths.filter(function(e){var t;for(" "===e[0].elements[0].combinator.value&&(e[0].elements[0].combinator=new Me.Combinator("")),t=0;t=0;i--)if((n=e[i])instanceof Me.Declaration)if(r[n.name]){(t=r[n.name])instanceof Me.Declaration&&(t=r[n.name]=[r[n.name].toCSS(this._context)]);var a=n.toCSS(this._context);-1!==t.indexOf(a)?e.splice(i,1):t.push(a)}else r[n.name]=n}},_mergeRules:function(e){if(e){for(var t={},n=[],i=0;i0){var t=e[0],n=[],i=[new Me.Expression(n)];e.forEach(function(e){"+"===e.merge&&n.length>0&&i.push(new Me.Expression(n=[])),n.push(e.value),t.important=t.important||e.important}),t.value=new Me.Value(i)}})}}};var Ge={Visitor:Le,ImportVisitor:Ne,MarkVisibleSelectorsVisitor:je,ExtendVisitor:Ue,JoinSelectorVisitor:qe,ToCSSVisitor:ze},We=function(){var e,t,n,i,r,a,s,o=[],l={},u=32,c=9,h=10,f=13,p=47;function v(n){for(var i,o,d,m=l.i,g=t,y=l.i-s,b=l.i+a.length-y,w=l.i+=n,k=e;l.i=0){d={index:l.i,text:k.substr(l.i,S+2-l.i),isLineComment:!1},l.i+=d.text.length-1,l.commentStore.push(d);continue}}break}if(i!==u&&i!==h&&i!==c&&i!==f)break}if(a=a.slice(n+l.i-w+y),s=l.i,!a.length){if(tn||l.i===n&&e&&!i)&&(n=l.i,i=e);var r=o.pop();a=r.current,s=l.i=r.i,t=r.j},l.forget=function(){o.pop()},l.isWhitespace=function(t){var n=l.i+(t||0),i=e.charCodeAt(n);return i===u||i===f||i===c||i===h},l.$re=function(e){l.i>s&&(a=a.slice(l.i-s),s=l.i);var t=e.exec(a);return t?(v(t[0].length),"string"==typeof t?t:1===t.length?t[0]:t):null},l.$char=function(t){return e.charAt(l.i)!==t?null:(v(1),t)},l.$str=function(t){for(var n=t.length,i=0;ic&&(d=!1)}}while(d);return r||null},l.autoCommentAbsorb=!0,l.commentStore=[],l.finished=!1,l.peek=function(t){if("string"==typeof t){for(var n=0;n57||t<43||t===p||44===t},l.start=function(i,o,u){e=i,l.i=t=s=n=0,r=o?function(e,t){var n,i,r,a,s,o,l,u,c,h=e.length,f=0,p=0,v=[],d=0;function m(t){var n=s-d;n<512&&!t||!n||(v.push(e.slice(d,s+1)),d=s+1)}for(s=0;s=97&&l<=122||l<34))switch(l){case 40:p++,i=s;continue;case 41:if(--p<0)return t("missing opening `(`",s);continue;case 59:p||m();continue;case 123:f++,n=s;continue;case 125:if(--f<0)return t("missing opening `{`",s);f||p||m();continue;case 92:if(s96)){if(u==l){c=1;break}if(92==u){if(s==h-1)return t("unescaped `\\`",s);s++}}if(c)continue;return t("unmatched `".concat(String.fromCharCode(l),"`"),o);case 47:if(p||s==h-1)continue;if(47==(u=e.charCodeAt(s+1)))for(s+=2;sn&&a>r?"missing closing `}` or `*/`":"missing closing `}`",n):0!==p?t("missing closing `)`",i):(m(!0),v)}(i,u):[i],a=r[0],v(0)},l.end=function(){var t,r=l.i>=e.length;return l.i=e.length-1,furthestChar:e[l.i]}},l},Je=function e(t,n,i){var r,a=We();function s(e,t){throw new $({index:a.i,filename:i.filename,type:t||"Syntax",message:e},n)}function o(e,t){var n=e instanceof Function?e.call(r):a.$re(e);if(n)return n;s(t||("string"==typeof e?"expected '".concat(e,"' got '").concat(a.currentChar(),"'"):"unexpected token"))}function l(e,t){if(a.$char(e))return e;s(t||"expected '".concat(e,"' got '").concat(a.currentChar(),"'"))}function u(e){var t=i.filename;return{lineNumber:M(e,a.getInput()).line+1,fileName:t}}return{parserInput:a,imports:n,fileInfo:i,parseNode:function(e,t,i,s,o){var l,u=[],c=a;try{c.start(e,!1,function(e,t){o({message:e,index:t+i})});for(var h,f,p=0;h=t[p];p++)if(f=c.i,l=r[h]()){try{l._index=f+i,l._fileInfo=s}catch(e){}u.push(l)}else u.push(null);c.end().isFinished?o(null,u):o(!0,null)}catch(e){throw new $({index:e.index+i,message:e.message},n,s.filename)}},parse:function(r,s,o){var l,u,c,h,f=null,p="";if(u=o&&o.globalVars?"".concat(e.serializeVars(o.globalVars),"\n"):"",c=o&&o.modifyVars?"\n".concat(e.serializeVars(o.modifyVars)):"",t.pluginManager)for(var v=t.pluginManager.getPreProcessors(),d=0;d");return e},args:function(e){var t,n,i,o,l,u,c,h=r.entities,f={args:null,variadic:!1},p=[],v=[],d=[],m=!0;for(a.save();;){if(e)u=r.detachedRuleset()||r.expression();else{if(a.commentStore.length=0,a.$str("...")){f.variadic=!0,a.$char(";")&&!t&&(t=!0),(t?v:d).push({variadic:!0});break}u=h.variable()||h.property()||h.literal()||h.keyword()||this.call(!0)}if(!u||!m)break;o=null,u.throwAwayComments&&u.throwAwayComments(),l=u;var g=null;if(e?u.value&&1==u.value.length&&(g=u.value[0]):g=u,g&&(g instanceof Me.Variable||g instanceof Me.Property))if(a.$char(":")){if(p.length>0&&(t&&s("Cannot mix ; and , as delimiter types"),n=!0),!(l=r.detachedRuleset()||r.expression())){if(!e)return a.restore(),f.args=[],f;s("could not understand value for named argument")}o=i=g.name}else if(a.$str("...")){if(!e){f.variadic=!0,a.$char(";")&&!t&&(t=!0),(t?v:d).push({name:u.name,variadic:!0});break}c=!0}else e||(i=o=g.name,l=null);l&&p.push(l),d.push({name:o,value:l,expand:c}),a.$char(",")?m=!0:((m=";"===a.$char(";"))||t)&&(n&&s("Cannot mix ; and , as delimiter types"),t=!0,p.length>1&&(l=new Me.Value(p)),v.push({name:i,value:l,expand:c}),i=null,p=[],n=!1)}return a.forget(),f.args=t?v:d,f},definition:function(){var e,t,n,i,s=[],l=!1;if(!("."!==a.currentChar()&&"#"!==a.currentChar()||a.peek(/^[^{]*\}/)))if(a.save(),t=a.$re(/^([#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+)\s*\(/)){e=t[1];var u=this.args(!1);if(s=u.args,l=u.variadic,!a.$char(")"))return void a.restore("Missing closing ')'");if(a.commentStore.length=0,a.$str("when")&&(i=o(r.conditions,"expected condition")),n=r.block())return a.forget(),new Me.mixin.Definition(e,s,n,i,l);a.restore()}else a.forget()},ruleLookups:function(){var e,t=[];if("["===a.currentChar()){for(;;){if(a.save(),!(e=this.lookupValue())&&""!==e){a.restore();break}t.push(e),a.forget()}return t.length>0?t:void 0}},lookupValue:function(){if(a.save(),a.$char("[")){var e=a.$re(/^(?:[@$]{0,2})[_a-zA-Z0-9-]*/);if(a.$char("]"))return e||""===e?(a.forget(),e):void a.restore();a.restore()}else a.restore()}},entity:function(){var e=this.entities;return this.comment()||e.literal()||e.variable()||e.url()||e.property()||e.call()||e.keyword()||this.mixin.call(!0)||e.javascript()},end:function(){return a.$char(";")||a.peek("}")},ieAlpha:function(){var e;if(a.$re(/^opacity=/i))return(e=a.$re(/^\d+/))||(e=o(r.entities.variable,"Could not parse alpha"),e="@{".concat(e.name.slice(1),"}")),l(")"),new Me.Quoted("","alpha(opacity=".concat(e,")"))},element:function(){var e,t,n,r=a.i;if(t=this.combinator(),(e=a.$re(/^(?:\d+\.\d+|\d+)%/)||a.$re(/^(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/)||a.$char("*")||a.$char("&")||this.attribute()||a.$re(/^\([^&()@]+\)/)||a.$re(/^[\.#:](?=@)/)||this.entities.variableCurly())||(a.save(),a.$char("(")?(n=this.selector(!1))&&a.$char(")")?(e=new Me.Paren(n),a.forget()):a.restore("Missing closing ')'"):a.forget()),e)return new Me.Element(t,e,e instanceof Me.Variable,r,i)},combinator:function(){var e=a.currentChar();if("/"===e){a.save();var t=a.$re(/^\/[a-z]+\//i);if(t)return a.forget(),new Me.Combinator(t);a.restore()}if(">"===e||"+"===e||"~"===e||"|"===e||"^"===e){for(a.i++,"^"===e&&"^"===a.currentChar()&&(e="^^",a.i++);a.isWhitespace();)a.i++;return new Me.Combinator(e)}return a.isWhitespace(-1)?new Me.Combinator(" "):new Me.Combinator(null)},selector:function(e){var t,n,r,l,u,c,h,f=a.i;for(e=!1!==e;(e&&(n=this.extend())||e&&(c=a.$str("when"))||(l=this.element()))&&(c?h=o(this.conditions,"expected condition"):h?s("CSS guard can only be used at the end of selector"):n?u=u?u.concat(n):n:(u&&s("Extend can only be used at the end of selector"),r=a.currentChar(),t?t.push(l):t=[l],l=null),"{"!==r&&"}"!==r&&";"!==r&&","!==r&&")"!==r););if(t)return new Me.Selector(t,u,h,f,i);u&&s("Extend must be used to extend a selector, it cannot be used on its own")},selectors:function(){for(var e,t;(e=this.selector())&&(t?t.push(e):t=[e],a.commentStore.length=0,e.condition&&t.length>1&&s("Guards are only currently allowed on a single selector."),a.$char(","));)e.condition&&s("Guards are only currently allowed on a single selector."),a.commentStore.length=0;return t},attribute:function(){if(a.$char("[")){var e,t,n,i=this.entities;return(e=i.variableCurly())||(e=o(/^(?:[_A-Za-z0-9-\*]*\|)?(?:[_A-Za-z0-9-]|\\.)+/)),(n=a.$re(/^[|~*$^]?=/))&&(t=i.quoted()||a.$re(/^[0-9]+%/)||a.$re(/^[\w-]+/)||i.variableCurly()),l("]"),new Me.Attribute(e,n,t)}},block:function(){var e;if(a.$char("{")&&(e=this.primary())&&a.$char("}"))return e},blockRuleset:function(){var e=this.block();return e&&(e=new Me.Ruleset(null,e)),e},detachedRuleset:function(){var e,t,n;if(a.save(),!a.$re(/^[.#]\(/)||(t=(e=this.mixin.args(!1)).args,n=e.variadic,a.$char(")"))){var i=this.blockRuleset();if(i)return a.forget(),t?new Me.mixin.Definition(null,t,i,null,n):new Me.DetachedRuleset(i);a.restore()}else a.restore()},ruleset:function(){var e,n,i;if(a.save(),t.dumpLineNumbers&&(i=u(a.i)),(e=this.selectors())&&(n=this.block())){a.forget();var r=new Me.Ruleset(e,n,t.strictImports);return t.dumpLineNumbers&&(r.debugInfo=i),r}a.restore()},declaration:function(){var e,t,n,r,s,o,l=a.i,u=a.currentChar();if("."!==u&&"#"!==u&&"&"!==u&&":"!==u)if(a.save(),e=this.variable()||this.ruleProperty()){if((o="string"==typeof e)&&(t=this.detachedRuleset())&&(n=!0),a.commentStore.length=0,!t){if(s=!o&&e.length>1&&e.pop().value,t=e[0].value&&"--"===e[0].value.slice(0,2)?this.permissiveValue():this.anonymousValue())return a.forget(),new Me.Declaration(e,t,!1,s,l,i);t||(t=this.value()),t?r=this.important():o&&(t=this.permissiveValue())}if(t&&(this.end()||n))return a.forget(),new Me.Declaration(e,t,r,s,l,i);a.restore()}else a.restore()},anonymousValue:function(){var e=a.i,t=a.$re(/^([^.#@\$+\/'"*`(;{}-]*);/);if(t)return new Me.Anonymous(t[1],e)},permissiveValue:function(e){var t,n,r,o,l=e||";",u=a.i,c=[];function h(){var e=a.currentChar();return"string"==typeof l?e===l:l.test(e)}if(!h()){o=[];do{(n=this.comment())?o.push(n):(n=this.entity())&&o.push(n)}while(n);if(r=h(),o.length>0){if(o=new Me.Expression(o),r)return o;c.push(o)," "===a.prevChar()&&c.push(new Me.Anonymous(" ",u))}if(a.save(),o=a.$parseUntil(l)){if("string"==typeof o&&s("Expected '".concat(o,"'"),"Parse"),1===o.length&&" "===o[0])return a.forget(),new Me.Anonymous("",u);var f;for(t=0;t0)return new Me.Expression(r)},mediaFeatures:function(){var e,t=this.entities,n=[];do{if(e=this.mediaFeature()){if(n.push(e),!a.$char(","))break}else if((e=t.variable()||t.mixinLookup())&&(n.push(e),!a.$char(",")))break}while(e);return n.length>0?n:null},media:function(){var e,n,r,o,l=a.i;if(t.dumpLineNumbers&&(o=u(l)),a.save(),a.$str("@media"))return e=this.mediaFeatures(),(n=this.block())||s("media definitions require block statements after any features"),a.forget(),r=new Me.Media(n,e,l,i),t.dumpLineNumbers&&(r.debugInfo=o),r;a.restore()},plugin:function(){var e,t,n,r=a.i;if(a.$re(/^@plugin?\s+/)){if(n=(t=this.pluginArgs())?{pluginArgs:t,isPlugin:!0}:{isPlugin:!0},e=this.entities.quoted()||this.entities.url())return a.$char(";")||(a.i=r,s("missing semi-colon on @plugin")),new Me.Import(e,null,n,r,i);a.i=r,s("malformed @plugin statement")}},pluginArgs:function(){if(a.save(),!a.$char("("))return a.restore(),null;var e=a.$re(/^\s*([^\);]+)\)\s*/);return e[1]?(a.forget(),e[1].trim()):(a.restore(),null)},atrule:function(){var e,n,r,o,l,c,h,f=a.i,p=!0,v=!0;if("@"===a.currentChar()){if(n=this.import()||this.plugin()||this.media())return n;if(a.save(),e=a.$re(/^@[a-z-]+/)){switch(o=e,"-"==e.charAt(1)&&e.indexOf("-",2)>0&&(o="@".concat(e.slice(e.indexOf("-",2)+1))),o){case"@charset":l=!0,p=!1;break;case"@namespace":c=!0,p=!1;break;case"@keyframes":case"@counter-style":l=!0;break;case"@document":case"@supports":h=!0,v=!1;break;default:h=!0}if(a.commentStore.length=0,l?(n=this.entity())||s("expected ".concat(e," identifier")):c?(n=this.expression())||s("expected ".concat(e," expression")):h&&(n=this.permissiveValue(/^[{;]/),p="{"===a.currentChar(),n?n.value||(n=null):p||";"===a.currentChar()||s("".concat(e," rule is missing block or ending semi-colon"))),p&&(r=this.blockRuleset()),r||!p&&n&&a.$char(";"))return a.forget(),new Me.AtRule(e,n,r,f,i,t.dumpLineNumbers?u(f):null,v);a.restore("at-rule options not recognised")}}},value:function(){var e,t=[],n=a.i;do{if((e=this.expression())&&(t.push(e),!a.$char(",")))break}while(e);if(t.length>0)return new Me.Value(t,n)},important:function(){if("!"===a.currentChar())return a.$re(/^! *important/)},sub:function(){var e,t;if(a.save(),a.$char("("))return(e=this.addition())&&a.$char(")")?(a.forget(),(t=new Me.Expression([e])).parens=!0,t):void a.restore("Expected ')'");a.restore()},multiplication:function(){var e,t,n,i,r;if(e=this.operand()){for(r=a.isWhitespace(-1);!a.peek(/^\/[*\/]/);){if(a.save(),!(n=a.$char("/")||a.$char("*")||a.$str("./"))){a.forget();break}if(!(t=this.operand())){a.restore();break}a.forget(),e.parensInOp=!0,t.parensInOp=!0,i=new Me.Operation(n,[i||e,t],r),r=a.isWhitespace(-1)}return i||e}},addition:function(){var e,t,n,i,r;if(e=this.multiplication()){for(r=a.isWhitespace(-1);(n=a.$re(/^[-+]\s+/)||!r&&(a.$char("+")||a.$char("-")))&&(t=this.multiplication());)e.parensInOp=!0,t.parensInOp=!0,i=new Me.Operation(n,[i||e,t],r),r=a.isWhitespace(-1);return i||e}},conditions:function(){var e,t,n,i=a.i;if(e=this.condition(!0)){for(;a.peek(/^,\s*(not\s*)?\(/)&&a.$char(",")&&(t=this.condition(!0));)n=new Me.Condition("or",n||e,t,i);return n||e}},condition:function(e){var t,n,i;if(t=this.conditionAnd(e)){if(n=a.$str("or")){if(!(i=this.condition(e)))return;t=new Me.Condition(n,t,i)}return t}},conditionAnd:function(e){var t,n,i,r,s=this;if(t=(r=s.negatedCondition(e)||s.parenthesisCondition(e))||e?r:s.atomicCondition(e)){if(n=a.$str("and")){if(!(i=this.conditionAnd(e)))return;t=new Me.Condition(n,t,i)}return t}},negatedCondition:function(e){if(a.$str("not")){var t=this.parenthesisCondition(e);return t&&(t.negate=!t.negate),t}},parenthesisCondition:function(e){var t;if(a.save(),a.$str("(")){if(t=function(t){var n;if(a.save(),n=t.condition(e)){if(a.$char(")"))return a.forget(),n;a.restore()}else a.restore()}(this))return a.forget(),t;if(t=this.atomicCondition(e)){if(a.$char(")"))return a.forget(),t;a.restore("expected ')' got '".concat(a.currentChar(),"'"))}else a.restore()}else a.restore()},atomicCondition:function(e){var t,n,i,r,o=this.entities,l=a.i;function u(){return this.addition()||o.keyword()||o.quoted()||o.mixinLookup()}if(t=(u=u.bind(this))())return a.$char(">")?r=a.$char("=")?">=":">":a.$char("<")?r=a.$char("=")?"<=":"<":a.$char("=")&&(r=a.$char(">")?"=>":a.$char("<")?"=<":"="),r?(n=u())?i=new Me.Condition(r,t,n,l,!1):s("expected expression"):i=new Me.Condition("=",t,new Me.Keyword("true"),l,!1),i},operand:function(){var e,t=this.entities;a.peek(/^-[@\$\(]/)&&(e=a.$char("-"));var n=this.sub()||t.dimension()||t.color()||t.variable()||t.property()||t.call()||t.quoted(!0)||t.colorKeyword()||t.mixinLookup();return e&&(n.parensInOp=!0,n=new Me.Negative(n)),n},expression:function(){var e,t,n=[],i=a.i;do{(e=this.comment())?n.push(e):(e=this.addition()||this.entity())&&(n.push(e),a.peek(/^\/[\/*]/)||(t=a.$char("/"))&&n.push(new Me.Anonymous(t,i)))}while(e);if(n.length>0)return new Me.Expression(n)},property:function(){var e=a.$re(/^(\*?-?[_a-zA-Z0-9-]+)\s*:/);if(e)return e[1]},ruleProperty:function(){var e,t,n=[],r=[];a.save();var s=a.$re(/^([_a-zA-Z0-9-]+)\s*:/);if(s)return n=[new Me.Keyword(s[1])],a.forget(),n;function o(e){var t=a.i,i=a.$re(e);if(i)return r.push(t),n.push(i[1])}for(o(/^(\*?)/);o(/^((?:[\w-]+)|(?:[@\$]\{[\w-]+\}))/););if(n.length>1&&o(/^((?:\+_|\+)?)\s*:/)){for(a.forget(),""===n[0]&&(n.shift(),r.shift()),t=0;t1?e-1:e)<1?r+(a-r)*e*6:2*e<1?a:3*e<2?r+(a-r)*(2/3-e)*6:r};if(e instanceof y)return i=t?et(t):e.alpha,new y(e.rgb,i,"hsla");e=et(e)%360/360,t=Ke(et(t)),n=Ke(et(n)),i=Ke(et(i)),r=2*n-(a=n<=.5?n*(t+1):n+t-n*t);var o=[255*s(e+1/3),255*s(e),255*s(e-1/3)];return i=et(i),new y(o,i,"hsla")}catch(e){}},hsv:function(e,t,n){return He.hsva(e,t,n,1)},hsva:function(e,t,n,i){var r,a;e=et(e)%360/360*360,t=et(t),n=et(n),i=et(i);var s=[n,n*(1-t),n*(1-(a=e/60-(r=Math.floor(e/60%6)))*t),n*(1-(1-a)*t)],o=[[0,3,1],[2,0,1],[1,0,3],[1,2,0],[3,1,0],[0,1,2]];return He.rgba(255*s[o[r][0]],255*s[o[r][1]],255*s[o[r][2]],i)},hue:function(e){return new ie(Ye(e).h)},saturation:function(e){return new ie(100*Ye(e).s,"%")},lightness:function(e){return new ie(100*Ye(e).l,"%")},hsvhue:function(e){return new ie(Xe(e).h)},hsvsaturation:function(e){return new ie(100*Xe(e).s,"%")},hsvvalue:function(e){return new ie(100*Xe(e).v,"%")},red:function(e){return new ie(e.rgb[0])},green:function(e){return new ie(e.rgb[1])},blue:function(e){return new ie(e.rgb[2])},alpha:function(e){return new ie(Ye(e).a)},luma:function(e){return new ie(e.luma()*e.alpha*100,"%")},luminance:function(e){var t=.2126*e.rgb[0]/255+.7152*e.rgb[1]/255+.0722*e.rgb[2]/255;return new ie(t*e.alpha*100,"%")},saturate:function(e,t,n){if(!e.rgb)return null;var i=Ye(e);return void 0!==n&&"relative"===n.value?i.s+=i.s*t.value/100:i.s+=t.value/100,i.s=Ke(i.s),Ze(e,i)},desaturate:function(e,t,n){var i=Ye(e);return void 0!==n&&"relative"===n.value?i.s-=i.s*t.value/100:i.s-=t.value/100,i.s=Ke(i.s),Ze(e,i)},lighten:function(e,t,n){var i=Ye(e);return void 0!==n&&"relative"===n.value?i.l+=i.l*t.value/100:i.l+=t.value/100,i.l=Ke(i.l),Ze(e,i)},darken:function(e,t,n){var i=Ye(e);return void 0!==n&&"relative"===n.value?i.l-=i.l*t.value/100:i.l-=t.value/100,i.l=Ke(i.l),Ze(e,i)},fadein:function(e,t,n){var i=Ye(e);return void 0!==n&&"relative"===n.value?i.a+=i.a*t.value/100:i.a+=t.value/100,i.a=Ke(i.a),Ze(e,i)},fadeout:function(e,t,n){var i=Ye(e);return void 0!==n&&"relative"===n.value?i.a-=i.a*t.value/100:i.a-=t.value/100,i.a=Ke(i.a),Ze(e,i)},fade:function(e,t){var n=Ye(e);return n.a=t.value/100,n.a=Ke(n.a),Ze(e,n)},spin:function(e,t){var n=Ye(e),i=(n.h+t.value)%360;return n.h=i<0?360+i:i,Ze(e,n)},mix:function(e,t,n){n||(n=new ie(50));var i=n.value/100,r=2*i-1,a=Ye(e).a-Ye(t).a,s=((r*a==-1?r:(r+a)/(1+r*a))+1)/2,o=1-s,l=[e.rgb[0]*s+t.rgb[0]*o,e.rgb[1]*s+t.rgb[1]*o,e.rgb[2]*s+t.rgb[2]*o],u=e.alpha*i+t.alpha*(1-i);return new y(l,u)},greyscale:function(e){return He.desaturate(e,new ie(100))},contrast:function(e,t,n,i){if(!e.rgb)return null;if(void 0===n&&(n=He.rgba(255,255,255,1)),void 0===t&&(t=He.rgba(0,0,0,1)),t.luma()>n.luma()){var r=n;n=t,t=r}return i=void 0===i?.43:et(i),e.luma().5&&(i=1,n=e>.25?Math.sqrt(e):((16*e-12)*e+4)*e),e-(1-2*t)*i*(n-e)},hardlight:function(e,t){return it.overlay(t,e)},difference:function(e,t){return Math.abs(e-t)},exclusion:function(e,t){return e+t-2*e*t},average:function(e,t){return(e+t)/2},negation:function(e,t){return 1-Math.abs(e+t-1)}};for(var rt in it)it.hasOwnProperty(rt)&&(nt[rt]=nt.bind(null,it[rt]));var at=function(e){return Array.isArray(e.value)?e.value:Array(e)},st={_SELF:function(e){return e},extract:function(e,t){return t=t.value-1,at(e)[t]},length:function(e){return new ie(at(e).length)},range:function(e,t,n){var i,r,a=1,s=[];t?(r=t,i=e.value,n&&(a=n.value)):(i=1,r=e);for(var o=i;o<=r.value;o+=a)s.push(new ie(o,r.unit));return new oe(s)},each:function(e,t){var n,i,r=[];i=!e.value||e instanceof pe?e.ruleset?e.ruleset.rules:e.rules?e.rules:Array.isArray(e)?e:[e]:Array.isArray(e.value)?e.value:[e.value];var a="@value",s="@key",o="@index";t.params?(a=t.params[0]&&t.params[0].name,s=t.params[1]&&t.params[1].name,o=t.params[2]&&t.params[2].name,t=t.rules):t=t.ruleset;for(var l=0;ls.value)&&(c[i]=r);else{if(void 0!==l&&o!==l)throw{type:"Argument",message:"incompatible types"};h[o]=c.length,c.push(r)}else Array.isArray(t[n].value)&&Array.prototype.push.apply(t,Array.prototype.slice.call(t[n].value));return 1==c.length?c[0]:(t=c.map(function(e){return e.toCSS(this.context)}).join(this.context.compress?",":", "),new B("".concat(e?"min":"max","(").concat(t,")")))},ft={min:function(){for(var e=arguments.length,t=new Array(e),n=0;n"),r=0;r");return i+="'),i=encodeURIComponent(i),i="data:image/svg+xml,".concat(i),new ve(new pe("'".concat(i,"'"),i,!1,this.index,this.currentFileInfo),this.index,this.currentFileInfo)}}),Z.addMultiple(mt),t},yt=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=n.variables,a=new G.Eval(n);"object"!==i(r)||Array.isArray(r)||(r=Object.keys(r).map(function(e){var t=r[e];return t instanceof Me.Value||(t instanceof Me.Expression||(t=new Me.Expression([t])),t=new Me.Value([t])),new Me.Declaration("@".concat(e),t,!1,null,0)}),a.frames=[new Me.Ruleset(null,r)]);var s,o,l=[new Ge.JoinSelectorVisitor,new Ge.MarkVisibleSelectorsVisitor(!0),new Ge.ExtendVisitor,new Ge.ToCSSVisitor({compress:Boolean(n.compress)})],u=[];if(n.pluginManager){o=n.pluginManager.visitor();for(var c=0;c<2;c++)for(o.first();s=o.get();)s.isPreEvalVisitor?0!==c&&-1!==u.indexOf(s)||(u.push(s),s.run(e)):0!==c&&-1!==l.indexOf(s)||(s.isPreVisitor?l.unshift(s):l.push(s))}t=e.eval(a);for(c=0;c=t);n++);this.preProcessors.splice(n,0,{preProcessor:e,priority:t})}},{key:"addPostProcessor",value:function(e,t){var n;for(n=0;n=t);n++);this.postProcessors.splice(n,0,{postProcessor:e,priority:t})}},{key:"addFileManager",value:function(e){this.fileManagers.push(e)}},{key:"getPreProcessors",value:function(){for(var e=[],t=0;t0){var i,r=JSON.stringify(this._sourceMapGenerator.toJSON());this.sourceMapURL?i=this.sourceMapURL:this._sourceMapFilename&&(i=this._sourceMapFilename),this.sourceMapURL=i,this.sourceMap=r}return this._css.join("")}}]),t}()}(e=new Ee(e,t)),a=function(e,t){return function(){function n(e){r(this,n),this.options=e}return s(n,[{key:"toCSS",value:function(t,n,i){var r=new e({contentsIgnoredCharsMap:i.contentsIgnoredChars,rootNode:t,contentsMap:i.contents,sourceMapFilename:this.options.sourceMapFilename,sourceMapURL:this.options.sourceMapURL,outputFilename:this.options.sourceMapOutputFilename,sourceMapBasepath:this.options.sourceMapBasepath,sourceMapRootpath:this.options.sourceMapRootpath,outputSourceFiles:this.options.outputSourceFiles,sourceMapGenerator:this.options.sourceMapGenerator,sourceMapFileInline:this.options.sourceMapFileInline}),a=r.toCSS(n);return this.sourceMap=r.sourceMap,this.sourceMapURL=r.sourceMapURL,this.options.sourceMapInputFilename&&(this.sourceMapInputFilename=r.normalizeFilename(this.options.sourceMapInputFilename)),void 0!==this.options.sourceMapBasepath&&void 0!==this.sourceMapURL&&(this.sourceMapURL=r.removeBasepath(this.sourceMapURL)),a+this.getCSSAppendage()}},{key:"getCSSAppendage",value:function(){var e=this.sourceMapURL;if(this.options.sourceMapFileInline){if(void 0===this.sourceMap)return"";e="data:application/json;base64,".concat(t.encodeBase64(this.sourceMap))}return e?"/*# sourceMappingURL=".concat(e," */"):""}},{key:"getExternalSourceMap",value:function(){return this.sourceMap}},{key:"setExternalSourceMap",value:function(e){this.sourceMap=e}},{key:"isInline",value:function(){return this.options.sourceMapFileInline}},{key:"getSourceMapURL",value:function(){return this.sourceMapURL}},{key:"getOutputFilename",value:function(){return this.options.sourceMapOutputFilename}},{key:"getInputFilename",value:function(){return this.sourceMapInputFilename}}]),n}()}(i,e),o=function(e){return function(){function t(e,n){r(this,t),this.root=e,this.imports=n}return s(t,[{key:"toCSS",value:function(t){var n,i,r={};try{n=yt(this.root,t)}catch(e){throw new $(e,this.imports)}try{var a=Boolean(t.compress);a&&Pe.warn("The compress option has been deprecated. We recommend you use a dedicated css minifier, for instance see less-plugin-clean-css.");var s={compress:a,dumpLineNumbers:t.dumpLineNumbers,strictUnits:Boolean(t.strictUnits),numPrecision:8};t.sourceMap?(i=new e(t.sourceMap),r.css=i.toCSS(n,s,this.imports)):r.css=n.toCSS(s)}catch(e){throw new $(e,this.imports)}if(t.pluginManager)for(var o=t.pluginManager.getPostProcessors(),l=0;l=200&&t.status<300?n(t.responseText,t.getResponseHeader("Last-Modified")):"function"==typeof i&&i(t.status,e)}"function"==typeof r.overrideMimeType&&r.overrideMimeType("text/css"),xt.debug("XHR: Getting '".concat(e,"'")),r.open("GET",e,a),r.setRequestHeader("Accept",t||"text/x-less, text/css; q=0.9, */*; q=0.5"),r.send(null),kt.isFileProtocol&&!kt.fileAsync?0===r.status||r.status>=200&&r.status<300?n(r.responseText):i(r.status,e):a?r.onreadystatechange=function(){4==r.readyState&&s(r,n,i)}:s(r,n,i)}},{key:"supports",value:function(){return!0}},{key:"clearFileCache",value:function(){It={}}},{key:"loadFile",value:function(e,t,n,i){t&&!this.isPathAbsolute(e)&&(e=t+e),e=n.ext?this.tryAppendExtension(e,n.ext):e,n=n||{};var r=this.extractUrlParts(e,window.location.href).url,a=this;return new Promise(function(e,t){if(n.useFileCache&&It[r])try{var i=It[r];return e({contents:i,filename:r,webInfo:{lastModified:new Date}})}catch(e){return t({filename:r,message:"Error loading file ".concat(r," error was ").concat(e.message)})}a.doXHR(r,n.mime,function(t,n){It[r]=t,e({contents:t,filename:r,webInfo:{lastModified:n}})},function(e,n){t({type:"File",message:"'".concat(n,"' wasn't found (").concat(e,")"),href:r})})})}}]),t}(),_t=function(e,t){return kt=e,xt=t,Ct},At=function(e){function t(e){var n;return r(this,t),(n=f(this,l(t).call(this))).less=e,n}return o(t,Oe),s(t,[{key:"loadPlugin",value:function(e,t,n,i,r){return new Promise(function(a,s){r.loadFile(e,t,n,i).then(a).catch(s)})}}]),t}(),Mt=function(t,i,r){return{add:function(a,s){r.errorReporting&&"html"!==r.errorReporting?"console"===r.errorReporting?function(e,t){var n=e.filename||t,a=[],s="".concat(e.type||"Syntax","Error: ").concat(e.message||"There is an error in your .less file"," in ").concat(n),o=function(e,t,n){void 0!==e.extract[t]&&a.push("{line} {content}".replace(/\{line\}/,(parseInt(e.line,10)||0)+(t-1)).replace(/\{class\}/,n).replace(/\{content\}/,e.extract[t]))};e.line&&(o(e,0,""),o(e,1,"line"),o(e,2,""),s+=" on line ".concat(e.line,", column ").concat(e.column+1,":\n").concat(a.join("\n"))),e.stack&&(e.extract||r.logLevel>=4)&&(s+="\nStack Trace\n".concat(e.stack)),i.logger.error(s)}(a,s):"function"==typeof r.errorReporting&&r.errorReporting("add",a,s):function(i,a){var s,o,l="less-error-message:".concat(e(a||"")),u=t.document.createElement("div"),c=[],h=i.filename||a,f=h.match(/([^\/]+(\?.*)?)$/)[1];u.id=l,u.className="less-error-message",o="

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

    in ').concat(f," ");var p=function(e,t,n){void 0!==e.extract[t]&&c.push('

  • {content}
  • '.replace(/\{line\}/,(parseInt(e.line,10)||0)+(t-1)).replace(/\{class\}/,n).replace(/\{content\}/,e.extract[t]))};i.line&&(p(i,0,""),p(i,1,"line"),p(i,2,""),o+="on line ".concat(i.line,", column ").concat(i.column+1,":

      ").concat(c.join(""),"
    ")),i.stack&&(i.extract||r.logLevel>=4)&&(o+="
    Stack Trace
    ".concat(i.stack.split("\n").slice(1).join("
    "))),u.innerHTML=o,n.createCSS(t.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"}),u.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"===r.env&&(s=setInterval(function(){var e=t.document,n=e.body;n&&(e.getElementById(l)?n.replaceChild(u,e.getElementById(l)):n.insertBefore(u,n.firstChild),clearInterval(s))},10))}(a,s)},remove:function(n){r.errorReporting&&"html"!==r.errorReporting?"console"===r.errorReporting||"function"==typeof r.errorReporting&&r.errorReporting("remove",n):function(n){var i=t.document.getElementById("less-error-message:".concat(e(n)));i&&i.parentNode.removeChild(i)}(n)}}},Pt={javascriptEnabled:!1,depends:!1,compress:!1,lint:!1,paths:[],color:!0,strictImports:!1,insecure:!1,rootpath:"",rewriteUrls:!1,math:0,strictUnits:!1,globalVars:null,modifyVars:null,urlArgs:""};if(window.less)for(var Et in window.less)window.less.hasOwnProperty(Et)&&(Pt[Et]=window.less[Et]);!function(e,i){t(i,n.currentScript(e)),void 0===i.isFileProtocol&&(i.isFileProtocol=/^(file|(chrome|safari)(-extension)?|resource|qrc|app):/.test(e.location.protocol)),i.async=i.async||!1,i.fileAsync=i.fileAsync||!1,i.poll=i.poll||(i.isFileProtocol?1e3:1500),i.env=i.env||("127.0.0.1"==e.location.hostname||"0.0.0.0"==e.location.hostname||"localhost"==e.location.hostname||e.location.port&&e.location.port.length>0||i.isFileProtocol?"development":"production");var r=/!dumpLineNumbers:(comments|mediaquery|all)/.exec(e.location.hash);r&&(i.dumpLineNumbers=r[1]),void 0===i.useFileCache&&(i.useFileCache=!0),void 0===i.onReady&&(i.onReady=!0),i.relativeUrls&&(i.rewriteUrls="all")}(window,Pt),Pt.plugins=Pt.plugins||[],window.LESS_PLUGINS&&(Pt.plugins=Pt.plugins.concat(window.LESS_PLUGINS));var Rt,Ot,Ft,Vt=function(e,i){var r=e.document,a=St();a.options=i;var s=a.environment,o=_t(i,a.logger),l=new o;s.addFileManager(l),a.FileManager=o,a.PluginLoader=At,function(e,t){t.logLevel=void 0!==t.logLevel?t.logLevel:"development"===t.env?3:1,t.loggers||(t.loggers=[{debug:function(e){t.logLevel>=4&&console.log(e)},info:function(e){t.logLevel>=3&&console.log(e)},warn:function(e){t.logLevel>=2&&console.warn(e)},error:function(e){t.logLevel>=1&&console.error(e)}}]);for(var n=0;n0&&l.childNodes.length>0&&o.firstChild.nodeValue===l.firstChild.nodeValue);var u=t.getElementsByTagName("head")[0];if(null===o||!1===a){var c=n&&n.nextSibling||null;c?c.parentNode.insertBefore(l,c):u.appendChild(l)}if(o&&!1===a&&o.parentNode.removeChild(o),l.styleSheet)try{l.styleSheet.cssText=i}catch(e){throw new Error("Couldn't reassign styleSheet.cssText.")}},n=function(e){var t,i=e.document;return i.currentScript||(t=i.getElementsByTagName("script"))[t.length-1]},r={error:function(e){this._fireEvent("error",e)},warn:function(e){this._fireEvent("warn",e)},info:function(e){this._fireEvent("info",e)},debug:function(e){this._fireEvent("debug",e)},addListener:function(e){this._listeners.push(e)},removeListener:function(e){for(var t=0;t=0;a--){var l=o[a];if(l[s?"supportsSync":"supports"](e,t,i,n))return l}return null},e.prototype.addFileManager=function(e){this.fileManagers.push(e)},e.prototype.clearFileManagers=function(){this.fileManagers=[]},e}(),o={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgrey:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},a={length:{m:1,cm:.01,mm:.001,in:.0254,px:.0254/96,pt:.0254/72,pc:.0254/72*12},duration:{s:1,ms:.001},angle:{rad:1/(2*Math.PI),deg:1/360,grad:1/400,turn:1}},l={colors:o,unitConversions:a},u=function(){function e(){this.parent=null,this.visibilityBlocks=void 0,this.nodeVisible=void 0,this.rootNode=null,this.parsed=null}return Object.defineProperty(e.prototype,"currentFileInfo",{get:function(){return this.fileInfo()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"index",{get:function(){return this.getIndex()},enumerable:!1,configurable:!0}),e.prototype.setParent=function(t,i){function n(t){t&&t instanceof e&&(t.parent=i)}Array.isArray(t)?t.forEach(n):n(t)},e.prototype.getIndex=function(){return this._index||this.parent&&this.parent.getIndex()||0},e.prototype.fileInfo=function(){return this._fileInfo||this.parent&&this.parent.fileInfo()||{}},e.prototype.isRulesetLike=function(){return!1},e.prototype.toCSS=function(e){var t=[];return this.genCSS(e,{add:function(e,i,n){t.push(e)},isEmpty:function(){return 0===t.length}}),t.join("")},e.prototype.genCSS=function(e,t){t.add(this.value)},e.prototype.accept=function(e){this.value=e.visit(this.value)},e.prototype.eval=function(){return this},e.prototype._operate=function(e,t,i,n){switch(t){case"+":return i+n;case"-":return i-n;case"*":return i*n;case"/":return i/n}},e.prototype.fround=function(e,t){var i=e&&e.numPrecision;return i?Number((t+2e-16).toFixed(i)):t},e.compare=function(t,i){if(t.compare&&"Quoted"!==i.type&&"Anonymous"!==i.type)return t.compare(i);if(i.compare)return-i.compare(t);if(t.type===i.type){if(t=t.value,i=i.value,!Array.isArray(t))return t===i?0:void 0;if(t.length===i.length){for(var n=0;nt?1:void 0},e.prototype.blocksVisibility=function(){return null==this.visibilityBlocks&&(this.visibilityBlocks=0),0!==this.visibilityBlocks},e.prototype.addVisibilityBlock=function(){null==this.visibilityBlocks&&(this.visibilityBlocks=0),this.visibilityBlocks=this.visibilityBlocks+1},e.prototype.removeVisibilityBlock=function(){null==this.visibilityBlocks&&(this.visibilityBlocks=0),this.visibilityBlocks=this.visibilityBlocks-1},e.prototype.ensureVisibility=function(){this.nodeVisible=!0},e.prototype.ensureInvisibility=function(){this.nodeVisible=!1},e.prototype.isVisible=function(){return this.nodeVisible},e.prototype.visibilityInfo=function(){return{visibilityBlocks:this.visibilityBlocks,nodeVisible:this.nodeVisible}},e.prototype.copyVisibilityInfo=function(e){e&&(this.visibilityBlocks=e.visibilityBlocks,this.nodeVisible=e.nodeVisible)},e}(),c=function(e,t,i){var n=this;Array.isArray(e)?this.rgb=e:e.length>=6?(this.rgb=[],e.match(/.{2}/g).map((function(e,t){t<3?n.rgb.push(parseInt(e,16)):n.alpha=parseInt(e,16)/255}))):(this.rgb=[],e.split("").map((function(e,t){t<3?n.rgb.push(parseInt(e+e,16)):n.alpha=parseInt(e+e,16)/255}))),this.alpha=this.alpha||("number"==typeof t?t:1),void 0!==i&&(this.value=i)};function h(e,t){return Math.min(Math.max(e,0),t)}function f(e){return"#"+e.map((function(e){return((e=h(Math.round(e),255))<16?"0":"")+e.toString(16)})).join("")}c.prototype=Object.assign(new u,{type:"Color",luma:function(){var e=this.rgb[0]/255,t=this.rgb[1]/255,i=this.rgb[2]/255;return.2126*(e=e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.7152*(t=t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.0722*(i=i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4))},genCSS:function(e,t){t.add(this.toCSS(e))},toCSS:function(e,t){var i,n,r,s=e&&e.compress&&!t,o=[];if(n=this.fround(e,this.alpha),this.value)if(0===this.value.indexOf("rgb"))n<1&&(r="rgba");else{if(0!==this.value.indexOf("hsl"))return this.value;r=n<1?"hsla":"hsl"}else n<1&&(r="rgba");switch(r){case"rgba":o=this.rgb.map((function(e){return h(Math.round(e),255)})).concat(h(n,1));break;case"hsla":o.push(h(n,1));case"hsl":i=this.toHSL(),o=[this.fround(e,i.h),this.fround(e,100*i.s)+"%",this.fround(e,100*i.l)+"%"].concat(o)}if(r)return r+"("+o.join(","+(s?"":" "))+")";if(i=this.toRGB(),s){var a=i.split("");a[1]===a[2]&&a[3]===a[4]&&a[5]===a[6]&&(i="#"+a[1]+a[3]+a[5])}return i},operate:function(e,t,i){for(var n=new Array(3),r=this.alpha*(1-i.alpha)+i.alpha,s=0;s<3;s++)n[s]=this._operate(e,t,this.rgb[s],i.rgb[s]);return new c(n,r)},toRGB:function(){return f(this.rgb)},toHSL:function(){var e,t,i=this.rgb[0]/255,n=this.rgb[1]/255,r=this.rgb[2]/255,s=this.alpha,o=Math.max(i,n,r),a=Math.min(i,n,r),l=(o+a)/2,u=o-a;if(o===a)e=t=0;else{switch(t=l>.5?u/(2-o-a):u/(o+a),o){case i:e=(n-r)/u+(n=0&&"\n"!==t.charAt(i);)r++;return"number"==typeof e&&(n=(t.slice(0,e).match(/\n/g)||"").length),{line:n,column:r}}function k(e){var t,i=e.length,n=new Array(i);for(t=0;t|Function):(\d+):(\d+)/,O=function(e,t,i){Error.call(this);var n=e.filename||i;if(this.message=e.message,this.stack=e.stack,t&&n){var r=t.contents[n],s=C(e.index,r),o=s.line,a=s.column,l=e.call&&C(e.call,r).line,u=r?r.split("\n"):"";if(this.type=e.type||"Syntax",this.filename=n,this.index=e.index,this.line="number"==typeof o?o+1:null,this.column=a,!this.line&&this.stack){var c=this.stack.match(R),h=new Function("a","throw new Error()"),f=0;try{h()}catch(e){var p=e.stack.match(R);f=1-(o=parseInt(p[2]))}c&&(c[2]&&(this.line=parseInt(c[2])+f),c[3]&&(this.column=parseInt(c[3])))}this.callLine=l+1,this.callExtract=u[l],this.extract=[u[this.line-2],u[this.line-1],u[this.line]]}};if(void 0===Object.create){var V=function(){};V.prototype=Error.prototype,O.prototype=new V}else O.prototype=Object.create(Error.prototype);O.prototype.constructor=O,O.prototype.toString=function(e){e=e||{};var t="",i=this.extract||[],n=[],r=function(e){return e};if(e.stylize){var s=typeof e.stylize;if("function"!==s)throw Error("options.stylize should be a function, got a "+s+"!");r=e.stylize}if(null!==this.line){if("string"==typeof i[0]&&n.push(r(this.line-1+" "+i[0],"grey")),"string"==typeof i[1]){var o=this.line+" ";i[1]&&(o+=i[1].slice(0,this.column)+r(r(r(i[1].substr(this.column,1),"bold")+i[1].slice(this.column+1),"red"),"inverse")),n.push(o)}"string"==typeof i[2]&&n.push(r(this.line+1+" "+i[2],"grey")),n=n.join("\n")+r("","reset")+"\n"}return t+=r(this.type+"Error: "+this.message,"red"),this.filename&&(t+=r(" in ","red")+this.filename),this.line&&(t+=r(" on line "+this.line+", column "+(this.column+1)+":","grey")),t+="\n"+n,this.callLine&&(t+=r("from ","red")+(this.filename||"")+"/n",t+=r(this.callLine,"grey")+" "+this.callExtract+"/n"),t};var F=function(e,t,i,n,r,s){this.extendList=t,this.condition=i,this.evaldCondition=!i,this._index=n,this._fileInfo=r,this.elements=this.getElements(e),this.mixinElements_=void 0,this.copyVisibilityInfo(s),this.setParent(this.elements,this)};F.prototype=Object.assign(new u,{type:"Selector",accept:function(e){this.elements&&(this.elements=e.visitArray(this.elements)),this.extendList&&(this.extendList=e.visitArray(this.extendList)),this.condition&&(this.condition=e.visit(this.condition))},createDerived:function(e,t,i){e=this.getElements(e);var n=new F(e,t||this.extendList,null,this.getIndex(),this.fileInfo(),this.visibilityInfo());return n.evaldCondition=null!=i?i:this.evaldCondition,n.mediaEmpty=this.mediaEmpty,n},getElements:function(e){return e?("string"==typeof e&&this.parse.parseNode(e,["selector"],this._index,this._fileInfo,(function(t,i){if(t)throw new O({index:t.index,message:t.message},this.parse.imports,this._fileInfo.filename);e=i[0].elements})),e):[new m("","&",!1,this._index,this._fileInfo)]},createEmptySelectors:function(){var e=new m("","&",!1,this._index,this._fileInfo),t=[new F([e],null,null,this._index,this._fileInfo)];return t[0].mediaEmpty=!0,t},match:function(e){var t,i,n=this.elements,r=n.length;if(0===(t=(e=e.mixinElements()).length)||rg.PARENS_DIVISION)||this.parensStack&&this.parensStack.length))},q.Eval.prototype.pathRequiresRewrite=function(e){return(this.rewriteUrls===b?J:W)(e)},q.Eval.prototype.rewritePath=function(e,t){var i;return t=t||"",i=this.normalizePath(t+e),J(e)&&W(t)&&!1===J(i)&&(i="./"+i),i},q.Eval.prototype.normalizePath=function(e){var t,i=e.split("/").reverse();for(e=[];0!==i.length;)switch(t=i.pop()){case".":break;case"..":0===e.length||".."===e[e.length-1]?e.push(t):e.pop();break;default:e.push(t)}return e.join("/")};var H=function e(t){return{_data:{},add:function(e,t){e=e.toLowerCase(),this._data.hasOwnProperty(e),this._data[e]=t},addMultiple:function(e){var t=this;Object.keys(e).forEach((function(i){t.add(i,e[i])}))},get:function(e){return this._data[e]||t&&t.get(e)},getLocalFunctions:function(){return this._data},inherit:function(){return e(this)},create:function(t){return e(t)}}}(null),Q={eval:function(){var e=this.value_,t=this.error_;if(t)throw t;if(null!=e)return e?L.True:L.False},value:function(e){this.value_=e},error:function(e){this.error_=e},reset:function(){this.value_=this.error_=null}},K=function(e,t,i,n){this.selectors=e,this.rules=t,this._lookups={},this._variables=null,this._properties=null,this.strictImports=i,this.copyVisibilityInfo(n),this.allowRoot=!0,this.setParent(this.selectors,this),this.setParent(this.rules,this)};K.prototype=Object.assign(new u,{type:"Ruleset",isRuleset:!0,isRulesetLike:function(){return!0},accept:function(e){this.paths?this.paths=e.visitArray(this.paths,!0):this.selectors&&(this.selectors=e.visitArray(this.selectors)),this.rules&&this.rules.length&&(this.rules=e.visitArray(this.rules))},eval:function(e){var t,i,n,r,s,o=!1;if(this.selectors&&(i=this.selectors.length)){for(t=new Array(i),Q.error({type:"Syntax",message:"it is currently only allowed in parametric mixin guards,"}),r=0;r0;e--){var t=this.rules[e-1];if(t instanceof D)return this.parseValue(t)}},parseValue:function(e){var t=this;function i(e){return e.value instanceof j&&!e.parsed?("string"==typeof e.value.value?this.parse.parseNode(e.value.value,["value","important"],e.value.getIndex(),e.fileInfo(),(function(t,i){t&&(e.parsed=!0),i&&(e.value=i[0],e.important=i[1]||"",e.parsed=!0)})):e.parsed=!0,e):e}if(Array.isArray(e)){var n=[];return e.forEach((function(e){n.push(i.call(t,e))})),n}return i.call(t,e)},rulesets:function(){if(!this.rules)return[];var e,t,i=[],n=this.rules;for(e=0;t=n[e];e++)t.isRuleset&&i.push(t);return i},prependRule:function(e){var t=this.rules;t?t.unshift(e):this.rules=[e],this.setParent(e,this)},find:function(e,t,i){t=t||this;var n,r,s=[],o=e.toCSS();return o in this._lookups?this._lookups[o]:(this.rulesets().forEach((function(o){if(o!==t)for(var a=0;an){if(!i||i(o)){r=o.find(new F(e.elements.slice(n)),t,i);for(var l=0;l0&&t.add(l),e.firstSelector=!0,o[0].genCSS(e,t),e.firstSelector=!1,n=1;n0?(s=(r=k(e)).pop(),o=n.createDerived(k(s.elements))):o=n.createDerived([]),t.length>0){var a=i.combinator,l=t[0].elements[0];a.emptyOrWhitespace&&!l.combinator.emptyOrWhitespace&&(a=l.combinator),o.elements.push(new m(a,l.value,i.isVariable,i._index,i._fileInfo)),o.elements=o.elements.concat(t[0].elements.slice(1))}if(0!==o.elements.length&&r.push(o),t.length>1){var u=t.slice(1);u=u.map((function(e){return e.createDerived(e.elements,[])})),r=r.concat(u)}return r}function o(e,t,i,n,r){var o;for(o=0;o0?n[n.length-1]=n[n.length-1].createDerived(n[n.length-1].elements.concat(e)):n.push(new F(e));else t.push([new F(e)])}function l(e,t){var i=t.createDerived(t.elements,t.extendList,t.evaldCondition);return i.copyVisibilityInfo(e),i}var u,c;if(!function e(t,i,l){var u,c,h,f,v,d,g,y,b,w,x,S,I=!1;for(f=[],v=[[]],u=0;y=l.elements[u];u++)if("&"!==y.value){var C=(S=void 0,(x=y).value instanceof p&&(S=x.value.value)instanceof F?S:null);if(null!=C){a(f,v);var k,_=[],A=[];for(k=e(_,i,C),I=I||k,h=0;h<_.length;h++){o(v,[r(n(_[h],y),y)],y,l,A)}v=A,f=[]}else f.push(y)}else{for(I=!0,d=[],a(f,v),c=0;c0&&g[0].elements.push(new m(y.combinator,"",y.isVariable,y._index,y._fileInfo)),d.push(g);else for(h=0;h0&&(t.push(v[u]),w=v[u][b-1],v[u][b-1]=w.createDerived(w.elements,l.extendList));return I}(c=[],t,i))if(t.length>0)for(c=[],u=0;u0)for(t=0;t-1e-6&&(n=i.toFixed(20).replace(/0+$/,"")),e&&e.compress){if(0===i&&this.unit.isLength())return void t.add(n);i>0&&i<1&&(n=n.substr(1))}t.add(n),this.unit.genCSS(e,t)},operate:function(e,t,i){var n=this._operate(e,t,this.value,i.value),r=this.unit.clone();if("+"===t||"-"===t)if(0===r.numerator.length&&0===r.denominator.length)r=i.unit.clone(),this.unit.backupUnit&&(r.backupUnit=this.unit.backupUnit);else if(0===i.unit.numerator.length&&0===r.denominator.length);else{if(i=i.convertTo(this.unit.usedUnits()),e.strictUnits&&i.unit.toString()!==r.toString())throw new Error("Incompatible units. Change the units or use the unit function. Bad units: '"+r.toString()+"' and '"+i.unit.toString()+"'.");n=this._operate(e,t,this.value,i.value)}else"*"===t?(r.numerator=r.numerator.concat(i.unit.numerator).sort(),r.denominator=r.denominator.concat(i.unit.denominator).sort(),r.cancel()):"/"===t&&(r.numerator=r.numerator.concat(i.unit.denominator).sort(),r.denominator=r.denominator.concat(i.unit.numerator).sort(),r.cancel());return new ee(n,r)},compare:function(e){var t,i;if(e instanceof ee){if(this.unit.isEmpty()||e.unit.isEmpty())t=this,i=e;else if(t=this.unify(),i=e.unify(),0!==t.unit.compare(i.unit))return;return u.numericCompare(t.value,i.value)}},unify:function(){return this.convertTo({length:"px",duration:"s",angle:"rad"})},convertTo:function(e){var t,i,n,r,s,o=this.value,l=this.unit.clone(),u={};if("string"==typeof e){for(t in a)a[t].hasOwnProperty(e)&&((u={})[t]=e);e=u}for(i in s=function(e,t){return n.hasOwnProperty(e)?(t?o/=n[e]/n[r]:o*=n[e]/n[r],r):e},e)e.hasOwnProperty(i)&&(r=e[i],n=a[i],l.map(s));return l.cancel(),new ee(o,l)}});var te=g,ie=function(e,t,i){this.op=e.trim(),this.operands=t,this.isSpaced=i};ie.prototype=Object.assign(new u,{type:"Operation",accept:function(e){this.operands=e.visitArray(this.operands)},eval:function(e){var t,i=this.operands[0].eval(e),n=this.operands[1].eval(e);if(e.isMathOn(this.op)){if(t="./"===this.op?"/":this.op,i instanceof ee&&n instanceof c&&(i=i.toColor()),n instanceof ee&&i instanceof c&&(n=n.toColor()),!i.operate||!n.operate){if((i instanceof ie||n instanceof ie)&&"/"===i.op&&e.math===te.PARENS_DIVISION)return new ie(this.op,[i,n],this.isSpaced);throw{type:"Operation",message:"Operation on an invalid type"}}return i.operate(e,t,n)}return new ie(this.op,[i,n],this.isSpaced)},genCSS:function(e,t){this.operands[0].genCSS(e,t),this.isSpaced&&t.add(" "),t.add(this.op),this.isSpaced&&t.add(" "),this.operands[1].genCSS(e,t)}});var ne=function(e,t){if(this.value=e,this.noSpacing=t,!e)throw new Error("Expression requires an array parameter")};ne.prototype=Object.assign(new u,{type:"Expression",accept:function(e){this.value=e.visitArray(this.value)},eval:function(e){var t,i=e.isMathOn(),n=this.parens,r=!1;return n&&e.inParenthesis(),this.value.length>1?t=new ne(this.value.map((function(t){return t.eval?t.eval(e):t})),this.noSpacing):1===this.value.length?(!this.value[0].parens||this.value[0].parensInOp||e.inCalc||(r=!0),t=this.value[0].eval(e)):t=this,n&&e.outOfParenthesis(),!this.parens||!this.parensInOp||i||r||t instanceof ee||(t=new p(t)),t},genCSS:function(e,t){for(var i=0;i1){var i=new F([],null,null,this.getIndex(),this.fileInfo()).createEmptySelectors();(t=new K(i,e.mediaBlocks)).multiMedia=!0,t.copyVisibilityInfo(this.visibilityInfo()),this.setParent(t,this)}return delete e.mediaBlocks,delete e.mediaPath,t},evalNested:function(e){var t,i,n=e.mediaPath.concat([this]);for(t=0;t0;t--)e.splice(t,0,new j("and"));return new ne(e)}))),this.setParent(this.features,this),new K([],[])},permute:function(e){if(0===e.length)return[];if(1===e.length)return e[0];for(var t=[],i=this.permute(e.slice(1)),n=0;n1?"["+e.value.map((function(e){return e.toCSS()})).join(", ")+"]":e.toCSS()}});var ve=function(e,t,i,n){this.escaped=t,this.expression=e,this._index=i,this._fileInfo=n};ve.prototype=Object.assign(new pe,{type:"JavaScript",eval:function(e){var t=this.evaluateJavaScript(this.expression,e),i=typeof t;return"number"!==i||isNaN(t)?"string"===i?new ue('"'+t+'"',t,this.escaped,this._index):Array.isArray(t)?new j(t.join(", ")):new j(t):new ee(t)}});var de=function(e,t){this.key=e,this.value=t};de.prototype=Object.assign(new u,{type:"Assignment",accept:function(e){this.value=e.visit(this.value)},eval:function(e){return this.value.eval?new de(this.key,this.value.eval(e)):this},genCSS:function(e,t){t.add(this.key+"="),this.value.genCSS?this.value.genCSS(e,t):t.add(this.value)}});var me=function(e,t,i,n,r){this.op=e.trim(),this.lvalue=t,this.rvalue=i,this._index=n,this.negate=r};me.prototype=Object.assign(new u,{type:"Condition",accept:function(e){this.lvalue=e.visit(this.lvalue),this.rvalue=e.visit(this.rvalue)},eval:function(e){var t=function(e,t,i){switch(e){case"and":return t&&i;case"or":return t||i;default:switch(u.compare(t,i)){case-1:return"<"===e||"=<"===e||"<="===e;case 0:return"="===e||">="===e||"=<"===e||"<="===e;case 1:return">"===e||">="===e;default:return!1}}}(this.op,this.lvalue.eval(e),this.rvalue.eval(e));return this.negate?!t:t}});var ge=function(e){this.value=e};ge.prototype=Object.assign(new u,{type:"UnicodeDescriptor"});var ye=function(e){this.value=e};ye.prototype=Object.assign(new u,{type:"Negative",genCSS:function(e,t){t.add("-"),this.value.genCSS(e,t)},eval:function(e){return e.isMathOn()?new ie("*",[new ee(-1),this.value]).eval(e):new ye(this.value.eval(e))}});var be=function(e,t,i,n,r){switch(this.selector=e,this.option=t,this.object_id=be.next_id++,this.parent_ids=[this.object_id],this._index=i,this._fileInfo=n,this.copyVisibilityInfo(r),this.allowRoot=!0,t){case"all":this.allowBefore=!0,this.allowAfter=!0;break;default:this.allowBefore=!1,this.allowAfter=!1}this.setParent(this.selector,this)};be.prototype=Object.assign(new u,{type:"Extend",accept:function(e){this.selector=e.visit(this.selector)},eval:function(e){return new be(this.selector.eval(e),this.option,this.getIndex(),this.fileInfo(),this.visibilityInfo())},clone:function(e){return new be(this.selector,this.option,this.getIndex(),this.fileInfo(),this.visibilityInfo())},findSelfSelectors:function(e){var t,i,n=[];for(t=0;t0&&i.length&&""===i[0].combinator.value&&(i[0].combinator.value=" "),n=n.concat(e[t].elements);this.selfSelectors=[new F(n)],this.selfSelectors[0].copyVisibilityInfo(this.visibilityInfo())}}),be.next_id=0;var we=function(e,t,i){this.variable=e,this._index=t,this._fileInfo=i,this.allowRoot=!0};we.prototype=Object.assign(new u,{type:"VariableCall",eval:function(e){var t,i=new oe(this.variable,this.getIndex(),this.fileInfo()).eval(e),n=new O({message:"Could not evaluate variable call "+this.variable});if(!i.ruleset){if(i.rules)t=i;else if(Array.isArray(i))t=new K("",i);else{if(!Array.isArray(i.value))throw n;t=new K("",i.value)}i=new X(t)}if(i.ruleset)return i.callEval(e);throw n}});var xe=function(e,t,i,n){this.value=e,this.lookups=t,this._index=i,this._fileInfo=n};xe.prototype=Object.assign(new u,{type:"NamespaceValue",eval:function(e){var t,i,n=this.value.eval(e);for(t=0;tthis.params.length)return!1}i=Math.min(s,this.arity);for(var o=0;o0){for(c=!0,a=0;a0)f=2;else if(f=1,p[1]+p[2]>1)throw{type:"Runtime",message:"Ambiguous use of `default()` found when matching for `"+this.format(m)+"`",index:this.getIndex(),filename:this.fileInfo().filename};for(a=0;a0&&(e=e.slice(0,t)),(t=e.lastIndexOf("/"))<0&&(t=e.lastIndexOf("\\")),t<0?"":e.slice(0,t+1)},e.prototype.tryAppendExtension=function(e,t){return/(\.[a-z]*$)|([\?;].*)$/.test(e)?e:e+t},e.prototype.tryAppendLessExtension=function(e){return this.tryAppendExtension(e,".less")},e.prototype.supportsSync=function(){return!1},e.prototype.alwaysMakePathsAbsolute=function(){return!1},e.prototype.isPathAbsolute=function(e){return/^(?:[a-z-]+:|\/|\\|#)/i.test(e)},e.prototype.join=function(e,t){return e?e+t:t},e.prototype.pathDiff=function(e,t){var i,n,r,s,o=this.extractUrlParts(e),a=this.extractUrlParts(t),l="";if(o.hostPart!==a.hostPart)return"";for(n=Math.max(a.directories.length,o.directories.length),i=0;iparseInt(t[i])?-1:1;return 0},e.prototype.versionToString=function(e){for(var t="",i=0;i0;){var e=this.imports[0];if(!e.isReady)return;this.imports=this.imports.slice(1),e.callback.apply(null,e.args)}if(0===this.variableImports.length)break;var t=this.variableImports[0];this.variableImports=this.variableImports.slice(1),t()}}finally{this._currentDepth--}0===this._currentDepth&&this._onSequencerEmpty&&this._onSequencerEmpty()},e}(),Oe=function(e,t){this._visitor=new Pe(this),this._importer=e,this._finish=t,this.context=new q.Eval,this.importCount=0,this.onceFileDetectionMap={},this.recursionDetector={},this._sequencer=new Re(this._onSequencerEmpty.bind(this))};Oe.prototype={isReplacing:!1,run:function(e){try{this._visitor.visit(e)}catch(e){this.error=e}this.isFinished=!0,this._sequencer.tryRun()},_onSequencerEmpty:function(){this.isFinished&&this._finish(this.error)},visitImport:function(e,t){var i=e.options.inline;if(!e.css||i){var n=new q.Eval(this.context,k(this.context.frames)),r=n.frames[0];this.importCount++,e.isVariableImport()?this._sequencer.addVariableImport(this.processImportNode.bind(this,e,n,r)):this.processImportNode(e,n,r)}t.visitDeeper=!1},processImportNode:function(e,t,i){var n,r=e.options.inline;try{n=e.evalForImport(t)}catch(t){t.filename||(t.index=e.getIndex(),t.filename=e.fileInfo().filename),e.css=!0,e.error=t}if(!n||n.css&&!r)this.importCount--,this.isFinished&&this._sequencer.tryRun();else{n.options.multiple&&(t.importMultiple=!0);for(var s=void 0===n.css,o=0;o=0||(a=[u.selfSelectors[0]],(s=f.findMatch(l,a)).length&&(l.hasFoundMatches=!0,l.selfSelectors.forEach((function(e){var t=u.visibilityInfo();o=f.extendSelector(s,a,e,l.isVisible()),(c=new Ce.Extend(u.selector,u.option,0,u.fileInfo(),t)).selfSelectors=o,o[o.length-1].extendList=[c],h.push(c),c.ruleset=u.ruleset,c.parent_ids=c.parent_ids.concat(u.parent_ids,l.parent_ids),u.firstExtendOnThisSelectorPath&&(c.firstExtendOnThisSelectorPath=!0,u.ruleset.paths.push(o))}))));if(h.length){if(this.extendChainCount++,i>100){var p="{unable to calculate}",v="{unable to calculate}";try{p=h[0].selfSelectors[0].toCSS(),v=h[0].selector.toCSS()}catch(e){}throw{message:"extend circular reference detected. One of the circular extends is currently:"+p+":extend("+v+")"}}return h.concat(f.doExtendChaining(h,t,i+1))}return h},e.prototype.visitDeclaration=function(e,t){t.visitDeeper=!1},e.prototype.visitMixinDefinition=function(e,t){t.visitDeeper=!1},e.prototype.visitSelector=function(e,t){t.visitDeeper=!1},e.prototype.visitRuleset=function(e,t){if(!e.root){var i,n,r,s,o=this.allExtendsStack[this.allExtendsStack.length-1],a=[],l=this;for(r=0;r0&&u[l.matched].combinator.value!==o?l=null:l.matched++,l&&(l.finished=l.matched===u.length,l.finished&&!e.allowAfter&&(r+1u&&c>0&&(h[h.length-1].elements=h[h.length-1].elements.concat(t[u].elements.slice(c)),c=0,u++),l=s.elements.slice(c,a.index).concat([o]).concat(i.elements.slice(1)),u===a.pathIndex&&r>0?h[h.length-1].elements=h[h.length-1].elements.concat(l):(h=h.concat(t.slice(u,a.pathIndex))).push(new Ce.Selector(l)),u=a.endPathIndex,(c=a.endPathElementIndex)>=t[u].elements.length&&(c=0,u++);return u0&&(h[h.length-1].elements=h[h.length-1].elements.concat(t[u].elements.slice(c)),u++),h=(h=h.concat(t.slice(u,t.length))).map((function(e){var t=e.createDerived(e.elements);return n?t.ensureVisibility():t.ensureInvisibility(),t}))},e.prototype.visitMedia=function(e,t){var i=e.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length-1]);i=i.concat(this.doExtendChaining(i,e.allExtends)),this.allExtendsStack.push(i)},e.prototype.visitMediaOut=function(e){var t=this.allExtendsStack.length-1;this.allExtendsStack.length=t},e.prototype.visitAtRule=function(e,t){var i=e.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length-1]);i=i.concat(this.doExtendChaining(i,e.allExtends)),this.allExtendsStack.push(i)},e.prototype.visitAtRuleOut=function(e){var t=this.allExtendsStack.length-1;this.allExtendsStack.length=t},e}(),Le=function(){function e(){this.contexts=[[]],this._visitor=new Pe(this)}return e.prototype.run=function(e){return this._visitor.visit(e)},e.prototype.visitDeclaration=function(e,t){t.visitDeeper=!1},e.prototype.visitMixinDefinition=function(e,t){t.visitDeeper=!1},e.prototype.visitRuleset=function(e,t){var i,n=this.contexts[this.contexts.length-1],r=[];this.contexts.push(r),e.root||((i=e.selectors)&&(i=i.filter((function(e){return e.getIsOutput()})),e.selectors=i.length?i:i=null,i&&e.joinSelectors(r,n,i)),i||(e.rules=null),e.paths=r)},e.prototype.visitRulesetOut=function(e){this.contexts.length=this.contexts.length-1},e.prototype.visitMedia=function(e,t){var i=this.contexts[this.contexts.length-1];e.rules[0].root=0===i.length||i[0].multiMedia},e.prototype.visitAtRule=function(e,t){var i=this.contexts[this.contexts.length-1];e.rules&&e.rules.length&&(e.rules[0].root=e.isRooted||0===i.length||null)},e}(),je=function(){function e(e){this._visitor=new Pe(this),this._context=e}return e.prototype.containsSilentNonBlockedChild=function(e){var t;if(!e)return!1;for(var i=0;i0},e.prototype.resolveVisibility=function(e,t){if(!e.blocksVisibility()){if(this.isEmpty(e)&&!this.containsSilentNonBlockedChild(t))return;return e}var i=e.rules[0];if(this.keepOnlyVisibleChilds(i),!this.isEmpty(i))return e.ensureVisibility(),e.removeVisibilityBlock(),e},e.prototype.isVisibleRuleset=function(e){return!!e.firstRoot||!this.isEmpty(e)&&!(!e.root&&!this.hasVisibleSelector(e))},e}(),Ne=function(e){this._visitor=new Pe(this),this._context=e,this.utils=new je(e)};Ne.prototype={isReplacing:!0,run:function(e){return this._visitor.visit(e)},visitDeclaration:function(e,t){if(!e.blocksVisibility()&&!e.variable)return e},visitMixinDefinition:function(e,t){e.frames=[]},visitExtend:function(e,t){},visitComment:function(e,t){if(!e.blocksVisibility()&&!e.isSilent(this._context))return e},visitMedia:function(e,t){var i=e.rules[0].rules;return e.accept(this._visitor),t.visitDeeper=!1,this.utils.resolveVisibility(e,i)},visitImport:function(e,t){if(!e.blocksVisibility())return e},visitAtRule:function(e,t){return e.rules&&e.rules.length?this.visitAtRuleWithBody(e,t):this.visitAtRuleWithoutBody(e,t)},visitAnonymous:function(e,t){if(!e.blocksVisibility())return e.accept(this._visitor),e},visitAtRuleWithBody:function(e,t){var i=function(e){var t=e.rules;return function(e){var t=e.rules;return 1===t.length&&(!t[0].paths||0===t[0].paths.length)}(e)?t[0].rules:t}(e);return e.accept(this._visitor),t.visitDeeper=!1,this.utils.isEmpty(e)||this._mergeRules(e.rules[0].rules),this.utils.resolveVisibility(e,i)},visitAtRuleWithoutBody:function(e,t){if(!e.blocksVisibility()){if("@charset"===e.name){if(this.charset){if(e.debugInfo){var i=new Ce.Comment("/* "+e.toCSS(this._context).replace(/\n/g,"")+" */\n");return i.debugInfo=e.debugInfo,this._visitor.visit(i)}return}this.charset=!0}return e}},checkValidNodes:function(e,t){if(e)for(var i=0;i0?e.accept(this._visitor):e.rules=null,t.visitDeeper=!1}return e.rules&&(this._mergeRules(e.rules),this._removeDuplicateRules(e.rules)),this.utils.isVisibleRuleset(e)&&(e.ensureVisibility(),n.splice(0,0,e)),1===n.length?n[0]:n},_compileRulesetPaths:function(e){e.paths&&(e.paths=e.paths.filter((function(e){var t;for(" "===e[0].elements[0].combinator.value&&(e[0].elements[0].combinator=new Ce.Combinator("")),t=0;t=0;n--)if((i=e[n])instanceof Ce.Declaration)if(r[i.name]){(t=r[i.name])instanceof Ce.Declaration&&(t=r[i.name]=[r[i.name].toCSS(this._context)]);var s=i.toCSS(this._context);-1!==t.indexOf(s)?e.splice(n,1):t.push(s)}else r[i.name]=i}},_mergeRules:function(e){if(e){for(var t={},i=[],n=0;n0){var t=e[0],i=[],n=[new Ce.Expression(i)];e.forEach((function(e){"+"===e.merge&&i.length>0&&n.push(new Ce.Expression(i=[])),i.push(e.value),t.important=t.important||e.important})),t.value=new Ce.Value(n)}}))}}};var De={Visitor:Pe,ImportVisitor:Oe,MarkVisibleSelectorsVisitor:Ve,ExtendVisitor:$e,JoinSelectorVisitor:Le,ToCSSVisitor:Ne};var Be=function(){var e,t,i,n,r,s,o,a=[],l={};function u(i){for(var n,a,c,h=l.i,f=t,p=l.i-o,v=l.i+s.length-p,d=l.i+=i,m=e;l.i=0){c={index:l.i,text:m.substr(l.i,y+2-l.i),isLineComment:!1},l.i+=c.text.length-1,l.commentStore.push(c);continue}}break}if(32!==n&&10!==n&&9!==n&&13!==n)break}if(s=s.slice(i+l.i-d+p),o=l.i,!s.length){if(ti||l.i===i&&e&&!n)&&(i=l.i,n=e);var r=a.pop();s=r.current,o=l.i=r.i,t=r.j},l.forget=function(){a.pop()},l.isWhitespace=function(t){var i=l.i+(t||0),n=e.charCodeAt(i);return 32===n||13===n||9===n||10===n},l.$re=function(e){l.i>o&&(s=s.slice(l.i-o),o=l.i);var t=e.exec(s);return t?(u(t[0].length),"string"==typeof t?t:1===t.length?t[0]:t):null},l.$char=function(t){return e.charAt(l.i)!==t?null:(u(1),t)},l.$str=function(t){for(var i=t.length,n=0;nh&&(d=!1)}}while(d);return r||null},l.autoCommentAbsorb=!0,l.commentStore=[],l.finished=!1,l.peek=function(t){if("string"==typeof t){for(var i=0;i57||t<43||47===t||44===t},l.start=function(n,a,c){e=n,l.i=t=o=i=0,r=a?function(e,t){var i,n,r,s,o,a,l,u,c,h=e.length,f=0,p=0,v=[],d=0;function m(t){var i=o-d;i<512&&!t||!i||(v.push(e.slice(d,o+1)),d=o+1)}for(o=0;o=97&&l<=122||l<34))switch(l){case 40:p++,n=o;continue;case 41:if(--p<0)return t("missing opening `(`",o);continue;case 59:p||m();continue;case 123:f++,i=o;continue;case 125:if(--f<0)return t("missing opening `{`",o);f||p||m();continue;case 92:if(o96)){if(u==l){c=1;break}if(92==u){if(o==h-1)return t("unescaped `\\`",o);o++}}if(c)continue;return t("unmatched `"+String.fromCharCode(l)+"`",a);case 47:if(p||o==h-1)continue;if(47==(u=e.charCodeAt(o+1)))for(o+=2;oi&&s>r?"missing closing `}` or `*/`":"missing closing `}`",i):0!==p?t("missing closing `)`",n):(m(!0),v)}(n,c):[n],s=r[0],u(0)},l.end=function(){var t,r=l.i>=e.length;return l.i=e.length-1,furthestChar:e[l.i]}},l},Ue=function e(t,i,n){var r,s=Be();function o(e,t){throw new O({index:s.i,filename:n.filename,type:t||"Syntax",message:e},i)}function a(e,t){var i=e instanceof Function?e.call(r):s.$re(e);if(i)return i;o(t||("string"==typeof e?"expected '"+e+"' got '"+s.currentChar()+"'":"unexpected token"))}function l(e,t){if(s.$char(e))return e;o(t||"expected '"+e+"' got '"+s.currentChar()+"'")}function u(e){var t=n.filename;return{lineNumber:C(e,s.getInput()).line+1,fileName:t}}return{parserInput:s,imports:i,fileInfo:n,parseNode:function(e,t,n,o,a){var l,u=[],c=s;try{c.start(e,!1,(function(e,t){a({message:e,index:t+n})}));for(var h=0,f=void 0,p=void 0;f=t[h];h++)if(p=c.i,l=r[f]()){try{l._index=p+n,l._fileInfo=o}catch(e){}u.push(l)}else u.push(null);c.end().isFinished?a(null,u):a(!0,null)}catch(e){throw new O({index:e.index+n,message:e.message},i,o.filename)}},parse:function(r,o,a){var l,u,c,h,f=null,p="";if(u=a&&a.globalVars?e.serializeVars(a.globalVars)+"\n":"",c=a&&a.modifyVars?"\n"+e.serializeVars(a.modifyVars):"",t.pluginManager)for(var v=t.pluginManager.getPreProcessors(),d=0;d");return e},args:function(e){var t,i,n,a,l,u,c,h=r.entities,f={args:null,variadic:!1},p=[],v=[],d=[],m=!0;for(s.save();;){if(e)u=r.detachedRuleset()||r.expression();else{if(s.commentStore.length=0,s.$str("...")){f.variadic=!0,s.$char(";")&&!t&&(t=!0),(t?v:d).push({variadic:!0});break}u=h.variable()||h.property()||h.literal()||h.keyword()||this.call(!0)}if(!u||!m)break;a=null,u.throwAwayComments&&u.throwAwayComments(),l=u;var g=null;if(e?u.value&&1==u.value.length&&(g=u.value[0]):g=u,g&&(g instanceof Ce.Variable||g instanceof Ce.Property))if(s.$char(":")){if(p.length>0&&(t&&o("Cannot mix ; and , as delimiter types"),i=!0),!(l=r.detachedRuleset()||r.expression())){if(!e)return s.restore(),f.args=[],f;o("could not understand value for named argument")}a=n=g.name}else if(s.$str("...")){if(!e){f.variadic=!0,s.$char(";")&&!t&&(t=!0),(t?v:d).push({name:u.name,variadic:!0});break}c=!0}else e||(n=a=g.name,l=null);l&&p.push(l),d.push({name:a,value:l,expand:c}),s.$char(",")?m=!0:((m=";"===s.$char(";"))||t)&&(i&&o("Cannot mix ; and , as delimiter types"),t=!0,p.length>1&&(l=new Ce.Value(p)),v.push({name:n,value:l,expand:c}),n=null,p=[],i=!1)}return s.forget(),f.args=t?v:d,f},definition:function(){var e,t,i,n,o=[],l=!1;if(!("."!==s.currentChar()&&"#"!==s.currentChar()||s.peek(/^[^{]*\}/)))if(s.save(),t=s.$re(/^([#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+)\s*\(/)){e=t[1];var u=this.args(!1);if(o=u.args,l=u.variadic,!s.$char(")"))return void s.restore("Missing closing ')'");if(s.commentStore.length=0,s.$str("when")&&(n=a(r.conditions,"expected condition")),i=r.block())return s.forget(),new Ce.mixin.Definition(e,o,i,n,l);s.restore()}else s.restore()},ruleLookups:function(){var e,t=[];if("["===s.currentChar()){for(;;){if(s.save(),!(e=this.lookupValue())&&""!==e){s.restore();break}t.push(e),s.forget()}return t.length>0?t:void 0}},lookupValue:function(){if(s.save(),s.$char("[")){var e=s.$re(/^(?:[@$]{0,2})[_a-zA-Z0-9-]*/);if(s.$char("]"))return e||""===e?(s.forget(),e):void s.restore();s.restore()}else s.restore()}},entity:function(){var e=this.entities;return this.comment()||e.literal()||e.variable()||e.url()||e.property()||e.call()||e.keyword()||this.mixin.call(!0)||e.javascript()},end:function(){return s.$char(";")||s.peek("}")},ieAlpha:function(){var e;if(s.$re(/^opacity=/i))return(e=s.$re(/^\d+/))||(e="@{"+(e=a(r.entities.variable,"Could not parse alpha")).name.slice(1)+"}"),l(")"),new Ce.Quoted("","alpha(opacity="+e+")")},element:function(){var e,t,i,r=s.i;if(t=this.combinator(),(e=s.$re(/^(?:\d+\.\d+|\d+)%/)||s.$re(/^(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/)||s.$char("*")||s.$char("&")||this.attribute()||s.$re(/^\([^&()@]+\)/)||s.$re(/^[\.#:](?=@)/)||this.entities.variableCurly())||(s.save(),s.$char("(")?(i=this.selector(!1))&&s.$char(")")?(e=new Ce.Paren(i),s.forget()):s.restore("Missing closing ')'"):s.forget()),e)return new Ce.Element(t,e,e instanceof Ce.Variable,r,n)},combinator:function(){var e=s.currentChar();if("/"===e){s.save();var t=s.$re(/^\/[a-z]+\//i);if(t)return s.forget(),new Ce.Combinator(t);s.restore()}if(">"===e||"+"===e||"~"===e||"|"===e||"^"===e){for(s.i++,"^"===e&&"^"===s.currentChar()&&(e="^^",s.i++);s.isWhitespace();)s.i++;return new Ce.Combinator(e)}return s.isWhitespace(-1)?new Ce.Combinator(" "):new Ce.Combinator(null)},selector:function(e){var t,i,r,l,u,c,h,f=s.i;for(e=!1!==e;(e&&(i=this.extend())||e&&(c=s.$str("when"))||(l=this.element()))&&(c?h=a(this.conditions,"expected condition"):h?o("CSS guard can only be used at the end of selector"):i?u=u?u.concat(i):i:(u&&o("Extend can only be used at the end of selector"),r=s.currentChar(),t?t.push(l):t=[l],l=null),"{"!==r&&"}"!==r&&";"!==r&&","!==r&&")"!==r););if(t)return new Ce.Selector(t,u,h,f,n);u&&o("Extend must be used to extend a selector, it cannot be used on its own")},selectors:function(){for(var e,t;(e=this.selector())&&(t?t.push(e):t=[e],s.commentStore.length=0,e.condition&&t.length>1&&o("Guards are only currently allowed on a single selector."),s.$char(","));)e.condition&&o("Guards are only currently allowed on a single selector."),s.commentStore.length=0;return t},attribute:function(){if(s.$char("[")){var e,t,i,n=this.entities;return(e=n.variableCurly())||(e=a(/^(?:[_A-Za-z0-9-\*]*\|)?(?:[_A-Za-z0-9-]|\\.)+/)),(i=s.$re(/^[|~*$^]?=/))&&(t=n.quoted()||s.$re(/^[0-9]+%/)||s.$re(/^[\w-]+/)||n.variableCurly()),l("]"),new Ce.Attribute(e,i,t)}},block:function(){var e;if(s.$char("{")&&(e=this.primary())&&s.$char("}"))return e},blockRuleset:function(){var e=this.block();return e&&(e=new Ce.Ruleset(null,e)),e},detachedRuleset:function(){var e,t,i;if(s.save(),!s.$re(/^[.#]\(/)||(t=(e=this.mixin.args(!1)).args,i=e.variadic,s.$char(")"))){var n=this.blockRuleset();if(n)return s.forget(),t?new Ce.mixin.Definition(null,t,n,null,i):new Ce.DetachedRuleset(n);s.restore()}else s.restore()},ruleset:function(){var e,i,n;if(s.save(),t.dumpLineNumbers&&(n=u(s.i)),(e=this.selectors())&&(i=this.block())){s.forget();var r=new Ce.Ruleset(e,i,t.strictImports);return t.dumpLineNumbers&&(r.debugInfo=n),r}s.restore()},declaration:function(){var e,t,i,r,o,a,l=s.i,u=s.currentChar();if("."!==u&&"#"!==u&&"&"!==u&&":"!==u)if(s.save(),e=this.variable()||this.ruleProperty()){if((a="string"==typeof e)&&(t=this.detachedRuleset())&&(i=!0),s.commentStore.length=0,!t){if(o=!a&&e.length>1&&e.pop().value,t=e[0].value&&"--"===e[0].value.slice(0,2)?this.permissiveValue():this.anonymousValue())return s.forget(),new Ce.Declaration(e,t,!1,o,l,n);t||(t=this.value()),t?r=this.important():a&&(t=this.permissiveValue())}if(t&&(this.end()||i))return s.forget(),new Ce.Declaration(e,t,r,o,l,n);s.restore()}else s.restore()},anonymousValue:function(){var e=s.i,t=s.$re(/^([^.#@\$+\/'"*`(;{}-]*);/);if(t)return new Ce.Anonymous(t[1],e)},permissiveValue:function(e){var t,i,r,a,l=e||";",u=s.i,c=[];function h(){var e=s.currentChar();return"string"==typeof l?e===l:l.test(e)}if(!h()){a=[];do{((i=this.comment())||(i=this.entity()))&&a.push(i)}while(i);if(r=h(),a.length>0){if(a=new Ce.Expression(a),r)return a;c.push(a)," "===s.prevChar()&&c.push(new Ce.Anonymous(" ",u))}if(s.save(),a=s.$parseUntil(l)){if("string"==typeof a&&o("Expected '"+a+"'","Parse"),1===a.length&&" "===a[0])return s.forget(),new Ce.Anonymous("",u);var f=void 0;for(t=0;t0)return new Ce.Expression(r)},mediaFeatures:function(){var e,t=this.entities,i=[];do{if(e=this.mediaFeature()){if(i.push(e),!s.$char(","))break}else if((e=t.variable()||t.mixinLookup())&&(i.push(e),!s.$char(",")))break}while(e);return i.length>0?i:null},media:function(){var e,i,r,a,l=s.i;if(t.dumpLineNumbers&&(a=u(l)),s.save(),s.$str("@media"))return e=this.mediaFeatures(),(i=this.block())||o("media definitions require block statements after any features"),s.forget(),r=new Ce.Media(i,e,l,n),t.dumpLineNumbers&&(r.debugInfo=a),r;s.restore()},plugin:function(){var e,t,i,r=s.i;if(s.$re(/^@plugin?\s+/)){if(i=(t=this.pluginArgs())?{pluginArgs:t,isPlugin:!0}:{isPlugin:!0},e=this.entities.quoted()||this.entities.url())return s.$char(";")||(s.i=r,o("missing semi-colon on @plugin")),new Ce.Import(e,null,i,r,n);s.i=r,o("malformed @plugin statement")}},pluginArgs:function(){if(s.save(),!s.$char("("))return s.restore(),null;var e=s.$re(/^\s*([^\);]+)\)\s*/);return e[1]?(s.forget(),e[1].trim()):(s.restore(),null)},atrule:function(){var e,i,r,a,l,c,h,f=s.i,p=!0,v=!0;if("@"===s.currentChar()){if(i=this.import()||this.plugin()||this.media())return i;if(s.save(),e=s.$re(/^@[a-z-]+/)){switch(a=e,"-"==e.charAt(1)&&e.indexOf("-",2)>0&&(a="@"+e.slice(e.indexOf("-",2)+1)),a){case"@charset":l=!0,p=!1;break;case"@namespace":c=!0,p=!1;break;case"@keyframes":case"@counter-style":l=!0;break;case"@document":case"@supports":h=!0,v=!1;break;default:h=!0}if(s.commentStore.length=0,l?(i=this.entity())||o("expected "+e+" identifier"):c?(i=this.expression())||o("expected "+e+" expression"):h&&(i=this.permissiveValue(/^[{;]/),p="{"===s.currentChar(),i?i.value||(i=null):p||";"===s.currentChar()||o(e+" rule is missing block or ending semi-colon")),p&&(r=this.blockRuleset()),r||!p&&i&&s.$char(";"))return s.forget(),new Ce.AtRule(e,i,r,f,n,t.dumpLineNumbers?u(f):null,v);s.restore("at-rule options not recognised")}}},value:function(){var e,t=[],i=s.i;do{if((e=this.expression())&&(t.push(e),!s.$char(",")))break}while(e);if(t.length>0)return new Ce.Value(t,i)},important:function(){if("!"===s.currentChar())return s.$re(/^! *important/)},sub:function(){var e,t;if(s.save(),s.$char("("))return(e=this.addition())&&s.$char(")")?(s.forget(),(t=new Ce.Expression([e])).parens=!0,t):void s.restore("Expected ')'");s.restore()},multiplication:function(){var e,t,i,n,r;if(e=this.operand()){for(r=s.isWhitespace(-1);!s.peek(/^\/[*\/]/);){if(s.save(),!(i=s.$char("/")||s.$char("*")||s.$str("./"))){s.forget();break}if(!(t=this.operand())){s.restore();break}s.forget(),e.parensInOp=!0,t.parensInOp=!0,n=new Ce.Operation(i,[n||e,t],r),r=s.isWhitespace(-1)}return n||e}},addition:function(){var e,t,i,n,r;if(e=this.multiplication()){for(r=s.isWhitespace(-1);(i=s.$re(/^[-+]\s+/)||!r&&(s.$char("+")||s.$char("-")))&&(t=this.multiplication());)e.parensInOp=!0,t.parensInOp=!0,n=new Ce.Operation(i,[n||e,t],r),r=s.isWhitespace(-1);return n||e}},conditions:function(){var e,t,i,n=s.i;if(e=this.condition(!0)){for(;s.peek(/^,\s*(not\s*)?\(/)&&s.$char(",")&&(t=this.condition(!0));)i=new Ce.Condition("or",i||e,t,n);return i||e}},condition:function(e){var t,i,n;if(t=this.conditionAnd(e)){if(i=s.$str("or")){if(!(n=this.condition(e)))return;t=new Ce.Condition(i,t,n)}return t}},conditionAnd:function(e){var t,i,n,r,o=this;if(t=(r=o.negatedCondition(e)||o.parenthesisCondition(e))||e?r:o.atomicCondition(e)){if(i=s.$str("and")){if(!(n=this.conditionAnd(e)))return;t=new Ce.Condition(i,t,n)}return t}},negatedCondition:function(e){if(s.$str("not")){var t=this.parenthesisCondition(e);return t&&(t.negate=!t.negate),t}},parenthesisCondition:function(e){var t;if(s.save(),s.$str("(")){if(t=function(t){var i;if(s.save(),i=t.condition(e)){if(s.$char(")"))return s.forget(),i;s.restore()}else s.restore()}(this))return s.forget(),t;if(t=this.atomicCondition(e)){if(s.$char(")"))return s.forget(),t;s.restore("expected ')' got '"+s.currentChar()+"'")}else s.restore()}else s.restore()},atomicCondition:function(e){var t,i,n,r,a=this.entities,l=s.i;function u(){return this.addition()||a.keyword()||a.quoted()||a.mixinLookup()}if(t=(u=u.bind(this))())return s.$char(">")?r=s.$char("=")?">=":">":s.$char("<")?r=s.$char("=")?"<=":"<":s.$char("=")&&(r=s.$char(">")?"=>":s.$char("<")?"=<":"="),r?(i=u())?n=new Ce.Condition(r,t,i,l,!1):o("expected expression"):n=new Ce.Condition("=",t,new Ce.Keyword("true"),l,!1),n},operand:function(){var e,t=this.entities;s.peek(/^-[@\$\(]/)&&(e=s.$char("-"));var i=this.sub()||t.dimension()||t.color()||t.variable()||t.property()||t.call()||t.quoted(!0)||t.colorKeyword()||t.mixinLookup();return e&&(i.parensInOp=!0,i=new Ce.Negative(i)),i},expression:function(){var e,t,i=[],n=s.i;do{(e=this.comment())?i.push(e):((e=this.addition()||this.entity())instanceof Ce.Comment&&(e=null),e&&(i.push(e),s.peek(/^\/[\/*]/)||(t=s.$char("/"))&&i.push(new Ce.Anonymous(t,n))))}while(e);if(i.length>0)return new Ce.Expression(i)},property:function(){var e=s.$re(/^(\*?-?[_a-zA-Z0-9-]+)\s*:/);if(e)return e[1]},ruleProperty:function(){var e,t,i=[],r=[];s.save();var o=s.$re(/^([_a-zA-Z0-9-]+)\s*:/);if(o)return i=[new Ce.Keyword(o[1])],s.forget(),i;function a(e){var t=s.i,n=s.$re(e);if(n)return r.push(t),i.push(n[1])}for(a(/^(\*?)/);a(/^((?:[\w-]+)|(?:[@\$]\{[\w-]+\}))/););if(i.length>1&&a(/^((?:\+_|\+)?)\s*:/)){for(s.forget(),""===i[0]&&(i.shift(),r.shift()),t=0;t1?e-1:e)<1?r+(s-r)*e*6:2*e<1?s:3*e<2?r+(s-r)*(2/3-e)*6:r}e=Ke(e)%360/360,t=We(Ke(t)),i=We(Ke(i)),n=We(Ke(n)),r=2*i-(s=i<=.5?i*(t+1):i+t-i*t);var a=[255*o(e+1/3),255*o(e),255*o(e-1/3)];return n=Ke(n),new c(a,n,"hsla")}catch(e){}},hsv:function(e,t,i){return ze.hsva(e,t,i,1)},hsva:function(e,t,i,n){var r,s;e=Ke(e)%360/360*360,t=Ke(t),i=Ke(i),n=Ke(n);var o=[i,i*(1-t),i*(1-(s=e/60-(r=Math.floor(e/60%6)))*t),i*(1-(1-s)*t)],a=[[0,3,1],[2,0,1],[1,0,3],[1,2,0],[3,1,0],[0,1,2]];return ze.rgba(255*o[a[r][0]],255*o[a[r][1]],255*o[a[r][2]],n)},hue:function(e){return new ee(He(e).h)},saturation:function(e){return new ee(100*He(e).s,"%")},lightness:function(e){return new ee(100*He(e).l,"%")},hsvhue:function(e){return new ee(Qe(e).h)},hsvsaturation:function(e){return new ee(100*Qe(e).s,"%")},hsvvalue:function(e){return new ee(100*Qe(e).v,"%")},red:function(e){return new ee(e.rgb[0])},green:function(e){return new ee(e.rgb[1])},blue:function(e){return new ee(e.rgb[2])},alpha:function(e){return new ee(He(e).a)},luma:function(e){return new ee(e.luma()*e.alpha*100,"%")},luminance:function(e){var t=.2126*e.rgb[0]/255+.7152*e.rgb[1]/255+.0722*e.rgb[2]/255;return new ee(t*e.alpha*100,"%")},saturate:function(e,t,i){if(!e.rgb)return null;var n=He(e);return void 0!==i&&"relative"===i.value?n.s+=n.s*t.value/100:n.s+=t.value/100,n.s=We(n.s),Je(e,n)},desaturate:function(e,t,i){var n=He(e);return void 0!==i&&"relative"===i.value?n.s-=n.s*t.value/100:n.s-=t.value/100,n.s=We(n.s),Je(e,n)},lighten:function(e,t,i){var n=He(e);return void 0!==i&&"relative"===i.value?n.l+=n.l*t.value/100:n.l+=t.value/100,n.l=We(n.l),Je(e,n)},darken:function(e,t,i){var n=He(e);return void 0!==i&&"relative"===i.value?n.l-=n.l*t.value/100:n.l-=t.value/100,n.l=We(n.l),Je(e,n)},fadein:function(e,t,i){var n=He(e);return void 0!==i&&"relative"===i.value?n.a+=n.a*t.value/100:n.a+=t.value/100,n.a=We(n.a),Je(e,n)},fadeout:function(e,t,i){var n=He(e);return void 0!==i&&"relative"===i.value?n.a-=n.a*t.value/100:n.a-=t.value/100,n.a=We(n.a),Je(e,n)},fade:function(e,t){var i=He(e);return i.a=t.value/100,i.a=We(i.a),Je(e,i)},spin:function(e,t){var i=He(e),n=(i.h+t.value)%360;return i.h=n<0?360+n:n,Je(e,i)},mix:function(e,t,i){i||(i=new ee(50));var n=i.value/100,r=2*n-1,s=He(e).a-He(t).a,o=((r*s==-1?r:(r+s)/(1+r*s))+1)/2,a=1-o,l=[e.rgb[0]*o+t.rgb[0]*a,e.rgb[1]*o+t.rgb[1]*a,e.rgb[2]*o+t.rgb[2]*a],u=e.alpha*n+t.alpha*(1-n);return new c(l,u)},greyscale:function(e){return ze.desaturate(e,new ee(100))},contrast:function(e,t,i,n){if(!e.rgb)return null;if(void 0===i&&(i=ze.rgba(255,255,255,1)),void 0===t&&(t=ze.rgba(0,0,0,1)),t.luma()>i.luma()){var r=i;i=t,t=r}return n=void 0===n?.43:Ke(n),e.luma().5&&(n=1,i=e>.25?Math.sqrt(e):((16*e-12)*e+4)*e),e-(1-2*t)*n*(i-e)},hardlight:function(e,t){return Ye.overlay(t,e)},difference:function(e,t){return Math.abs(e-t)},exclusion:function(e,t){return e+t-2*e*t},average:function(e,t){return(e+t)/2},negation:function(e,t){return 1-Math.abs(e+t-1)}};for(var et in Ye)Ye.hasOwnProperty(et)&&(Xe[et]=Xe.bind(null,Ye[et]));var tt=function(e){return Array.isArray(e.value)?e.value:Array(e)},it={_SELF:function(e){return e},"~":function(){for(var e=[],t=0;to.value)&&(c[n]=r);else{if(void 0!==l&&a!==l)throw{type:"Argument",message:"incompatible types"};h[a]=c.length,c.push(r)}else Array.isArray(t[i].value)&&Array.prototype.push.apply(t,Array.prototype.slice.call(t[i].value));return 1==c.length?c[0]:(t=c.map((function(e){return e.toCSS(this.context)})).join(this.context.compress?",":", "),new j((e?"min":"max")+"("+t+")"))},at={min:function(){for(var e=[],t=0;t",r=0;r";return n+="',n=encodeURIComponent(n),new ce(new ue("'"+(n="data:image/svg+xml,"+n)+"'",n,!1,this.index,this.currentFileInfo),this.index,this.currentFileInfo)}}),H.addMultiple(ht),t};function pt(e,t){var i,n=(t=t||{}).variables,r=new q.Eval(t);"object"!=typeof n||Array.isArray(n)||(n=Object.keys(n).map((function(e){var t=n[e];return t instanceof Ce.Value||(t instanceof Ce.Expression||(t=new Ce.Expression([t])),t=new Ce.Value([t])),new Ce.Declaration("@"+e,t,!1,null,0)})),r.frames=[new Ce.Ruleset(null,n)]);var s,o,a=[new De.JoinSelectorVisitor,new De.MarkVisibleSelectorsVisitor(!0),new De.ExtendVisitor,new De.ToCSSVisitor({compress:Boolean(t.compress)})],l=[];if(t.pluginManager){o=t.pluginManager.visitor();for(var u=0;u<2;u++)for(o.first();s=o.get();)s.isPreEvalVisitor?0!==u&&-1!==l.indexOf(s)||(l.push(s),s.run(e)):0!==u&&-1!==a.indexOf(s)||(s.isPreVisitor?a.unshift(s):a.push(s))}i=e.eval(r);for(u=0;u=t);i++);this.preProcessors.splice(i,0,{preProcessor:e,priority:t})},e.prototype.addPostProcessor=function(e,t){var i;for(i=0;i=t);i++);this.postProcessors.splice(i,0,{postProcessor:e,priority:t})},e.prototype.addFileManager=function(e){this.fileManagers.push(e)},e.prototype.getPreProcessors=function(){for(var e=[],t=0;t0){var n=void 0,r=JSON.stringify(this._sourceMapGenerator.toJSON());this.sourceMapURL?n=this.sourceMapURL:this._sourceMapFilename&&(n=this._sourceMapFilename),this.sourceMapURL=n,this.sourceMap=r}return this._css.join("")},t}()}(e=new s(e,t)),e)),a=function(e){return function(){function t(e,t,i){this.less=e,this.rootFilename=i.filename,this.paths=t.paths||[],this.contents={},this.contentsIgnoredChars={},this.mime=t.mime,this.error=null,this.context=t,this.queue=[],this.files={}}return t.prototype.push=function(t,i,n,s,o){var a=this,l=this.context.pluginManager.Loader;this.queue.push(t);var u=function(e,i,n){a.queue.splice(a.queue.indexOf(t),1);var l=n===a.rootFilename;s.optional&&e?(o(null,{rules:[]},!1,null),r.info("The file "+n+" was skipped because it was not found and the import was marked optional.")):(a.files[n]||s.inline||(a.files[n]={root:i,options:s}),e&&!a.error&&(a.error=e),o(e,i,l,n))},c={rewriteUrls:this.context.rewriteUrls,entryPath:n.entryPath,rootpath:n.rootpath,rootFilename:n.rootFilename},h=e.getFileManager(t,n.currentDirectory,this.context,e);if(h){var f,p,v=function(e){var t,i=e.filename,r=e.contents.replace(/^\uFEFF/,"");c.currentDirectory=h.getPath(i),c.rewriteUrls&&(c.rootpath=h.join(a.context.rootpath||"",h.pathDiff(c.currentDirectory,c.entryPath)),!h.isPathAbsolute(c.rootpath)&&h.alwaysMakePathsAbsolute()&&(c.rootpath=h.join(c.entryPath,c.rootpath))),c.filename=i;var o=new q.Parse(a.context);o.processImports=!1,a.contents[i]=r,(n.reference||s.reference)&&(c.reference=!0),s.isPlugin?(t=l.evalPlugin(r,o,a,s.pluginArgs,c))instanceof O?u(t,null,i):u(null,t,i):s.inline?u(null,r,i):!a.files[i]||a.files[i].options.multiple||s.multiple?new Ue(o,a,c).parse(r,(function(e,t){u(e,t,i)})):u(null,a.files[i].root,i)},d=_(this.context);i&&(d.ext=s.isPlugin?".js":".less"),s.isPlugin?(d.mime="application/javascript",d.syncImport?f=l.loadPluginSync(t,n.currentDirectory,d,e,h):p=l.loadPlugin(t,n.currentDirectory,d,e,h)):d.syncImport?f=h.loadFileSync(t,n.currentDirectory,d,e):p=h.loadFile(t,n.currentDirectory,d,e,(function(e,t){e?u(e):v(t)})),f?f.filename?v(f):u(f):p&&p.then(v,u)}else u({message:"Could not find a file-manager for "+t})},t}()}(e);var u,c=function(e,t,i){var n=function(e,i,r){if("function"==typeof i?(r=i,i=M(this.options,{})):i=M(this.options,i||{}),!r){var s=this;return new Promise((function(t,r){n.call(s,e,i,(function(e,i){e?r(e):t(i)}))}))}this.parse(e,i,(function(e,i,n,s){if(e)return r(e);var o;try{o=new t(i,n).toCSS(s)}catch(e){return r(e)}r(null,o)}))};return n}(0,o),h=function(e,t,i){var n=function(e,t,r){if("function"==typeof t?(r=t,t=M(this.options,{})):t=M(this.options,t||{}),!r){var s=this;return new Promise((function(i,r){n.call(s,e,t,(function(e,t){e?r(e):i(t)}))}))}var o,a=void 0,l=new mt(this,!t.reUsePluginManager);if(t.pluginManager=l,o=new q.Parse(t),t.rootFileInfo)a=t.rootFileInfo;else{var u=t.filename||"input",c=u.replace(/[^\/\\]*$/,"");(a={filename:u,rewriteUrls:o.rewriteUrls,rootpath:o.rootpath||"",currentDirectory:c,entryPath:c,rootFilename:u}).rootpath&&"/"!==a.rootpath.slice(-1)&&(a.rootpath+="/")}var h=new i(this,o,a);this.importManager=h,t.plugins&&t.plugins.forEach((function(e){var t,i;if(e.fileContent){if(i=e.fileContent.replace(/^\uFEFF/,""),(t=l.Loader.evalPlugin(i,o,h,e.options,e.filename))instanceof O)return r(t)}else l.addPlugin(e)})),new Ue(o,h,a).parse(e,(function(e,i){if(e)return r(e);r(null,i,h,t)}),t)};return n}(0,0,a),f=bt("v4.1.2"),p={version:[f.major,f.minor,f.patch],data:l,tree:Ce,Environment:s,AbstractFileManager:ke,AbstractPluginLoader:_e,environment:e,visitors:De,Parser:Ue,functions:ft(e),contexts:q,SourceMapOutput:i,SourceMapBuilder:n,ParseTree:o,ImportManager:a,render:c,parse:h,LessError:O,transformTree:pt,utils:P,PluginManager:mt,logger:r},v=function(e){return function(){var t=Object.create(e.prototype);return e.apply(t,Array.prototype.slice.call(arguments,0)),t}},d=Object.create(p);for(var m in p.tree)if("function"==typeof(u=p.tree[m]))d[m.toLowerCase()]=v(u);else for(var g in d[m]=Object.create(null),u)d[m][g.toLowerCase()]=v(u[g]);return p.parse=p.parse.bind(d),p.render=p.render.bind(d),d}var xt={},St=function(){};St.prototype=Object.assign(new ke,{alwaysMakePathsAbsolute:function(){return!0},join:function(e,t){return e?this.extractUrlParts(t,e).path:t},doXHR:function(e,t,i,n){var r=new XMLHttpRequest,s=!gt.isFileProtocol||gt.fileAsync;function o(t,i,n){t.status>=200&&t.status<300?i(t.responseText,t.getResponseHeader("Last-Modified")):"function"==typeof n&&n(t.status,e)}"function"==typeof r.overrideMimeType&&r.overrideMimeType("text/css"),yt.debug("XHR: Getting '"+e+"'"),r.open("GET",e,s),r.setRequestHeader("Accept",t||"text/x-less, text/css; q=0.9, */*; q=0.5"),r.send(null),gt.isFileProtocol&&!gt.fileAsync?0===r.status||r.status>=200&&r.status<300?i(r.responseText):n(r.status,e):s?r.onreadystatechange=function(){4==r.readyState&&o(r,i,n)}:o(r,i,n)},supports:function(){return!0},clearFileCache:function(){xt={}},loadFile:function(e,t,i,n){t&&!this.isPathAbsolute(e)&&(e=t+e),e=i.ext?this.tryAppendExtension(e,i.ext):e,i=i||{};var r=this.extractUrlParts(e,window.location.href).url,s=this;return new Promise((function(e,t){if(i.useFileCache&&xt[r])try{var n=xt[r];return e({contents:n,filename:r,webInfo:{lastModified:new Date}})}catch(e){return t({filename:r,message:"Error loading file "+r+" error was "+e.message})}s.doXHR(r,i.mime,(function(t,i){xt[r]=t,e({contents:t,filename:r,webInfo:{lastModified:i}})}),(function(e,i){t({type:"File",message:"'"+i+"' wasn't found ("+e+")",href:r})}))}))}});var It=function(e,t){return gt=e,yt=t,St},Ct=function(e){this.less=e};Ct.prototype=Object.assign(new _e,{loadPlugin:function(e,t,i,n,r){return new Promise((function(s,o){r.loadFile(e,t,i,n).then(s).catch(o)}))}});var kt=function(t,n,r){return{add:function(s,o){r.errorReporting&&"html"!==r.errorReporting?"console"===r.errorReporting?function(e,t){var i=e.filename||t,s=[],o=(e.type||"Syntax")+"Error: "+(e.message||"There is an error in your .less file")+" in "+i,a=function(e,t,i){void 0!==e.extract[t]&&s.push("{line} {content}".replace(/\{line\}/,(parseInt(e.line,10)||0)+(t-1)).replace(/\{class\}/,i).replace(/\{content\}/,e.extract[t]))};e.line&&(a(e,0,""),a(e,1,"line"),a(e,2,""),o+=" on line "+e.line+", column "+(e.column+1)+":\n"+s.join("\n")),e.stack&&(e.extract||r.logLevel>=4)&&(o+="\nStack Trace\n"+e.stack),n.logger.error(o)}(s,o):"function"==typeof r.errorReporting&&r.errorReporting("add",s,o):function(n,s){var o,a,l="less-error-message:"+e(s||""),u=t.document.createElement("div"),c=[],h=n.filename||s,f=h.match(/([^\/]+(\?.*)?)$/)[1];u.id=l,u.className="less-error-message",a="

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

    in '+f+" ";var p=function(e,t,i){void 0!==e.extract[t]&&c.push('

  • {content}
  • '.replace(/\{line\}/,(parseInt(e.line,10)||0)+(t-1)).replace(/\{class\}/,i).replace(/\{content\}/,e.extract[t]))};n.line&&(p(n,0,""),p(n,1,"line"),p(n,2,""),a+="on line "+n.line+", column "+(n.column+1)+":

      "+c.join("")+"
    "),n.stack&&(n.extract||r.logLevel>=4)&&(a+="
    Stack Trace
    "+n.stack.split("\n").slice(1).join("
    ")),u.innerHTML=a,i(t.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"}),u.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"===r.env&&(o=setInterval((function(){var e=t.document,i=e.body;i&&(e.getElementById(l)?i.replaceChild(u,e.getElementById(l)):i.insertBefore(u,i.firstChild),clearInterval(o))}),10))}(s,o)},remove:function(i){r.errorReporting&&"html"!==r.errorReporting?"console"===r.errorReporting||"function"==typeof r.errorReporting&&r.errorReporting("remove",i):function(i){var n=t.document.getElementById("less-error-message:"+e(i));n&&n.parentNode.removeChild(n)}(i)}}},_t={javascriptEnabled:!1,depends:!1,compress:!1,lint:!1,paths:[],color:!0,strictImports:!1,insecure:!1,rootpath:"",rewriteUrls:!1,math:1,strictUnits:!1,globalVars:null,modifyVars:null,urlArgs:""};if(window.less)for(var At in window.less)window.less.hasOwnProperty(At)&&(_t[At]=window.less[At]);!function(e,i){t(i,n(e)),void 0===i.isFileProtocol&&(i.isFileProtocol=/^(file|(chrome|safari)(-extension)?|resource|qrc|app):/.test(e.location.protocol)),i.async=i.async||!1,i.fileAsync=i.fileAsync||!1,i.poll=i.poll||(i.isFileProtocol?1e3:1500),i.env=i.env||("127.0.0.1"==e.location.hostname||"0.0.0.0"==e.location.hostname||"localhost"==e.location.hostname||e.location.port&&e.location.port.length>0||i.isFileProtocol?"development":"production");var r=/!dumpLineNumbers:(comments|mediaquery|all)/.exec(e.location.hash);r&&(i.dumpLineNumbers=r[1]),void 0===i.useFileCache&&(i.useFileCache=!0),void 0===i.onReady&&(i.onReady=!0),i.relativeUrls&&(i.rewriteUrls="all")}(window,_t),_t.plugins=_t.plugins||[],window.LESS_PLUGINS&&(_t.plugins=_t.plugins.concat(window.LESS_PLUGINS));var Mt,Et,Pt,Rt=function(e,n){var r=e.document,s=wt();s.options=n;var o=s.environment,a=It(n,s.logger),l=new a;o.addFileManager(l),s.FileManager=a,s.PluginLoader=Ct,function(e,t){t.logLevel=void 0!==t.logLevel?t.logLevel:"development"===t.env?3:1,t.loggers||(t.loggers=[{debug:function(e){t.logLevel>=4&&console.log(e)},info:function(e){t.logLevel>=3&&console.log(e)},warn:function(e){t.logLevel>=2&&console.warn(e)},error:function(e){t.logLevel>=1&&console.error(e)}}]);for(var i=0;i 0 && styleNode.childNodes.length > 0 &&\n oldStyleNode.firstChild.nodeValue === styleNode.firstChild.nodeValue);\n }\n\n const head = document.getElementsByTagName('head')[0];\n\n // If there is no oldStyleNode, just append; otherwise, only append if we need\n // to replace oldStyleNode with an updated stylesheet\n if (oldStyleNode === null || keepOldStyleNode === false) {\n const nextEl = sheet && sheet.nextSibling || null;\n if (nextEl) {\n nextEl.parentNode.insertBefore(styleNode, nextEl);\n } else {\n head.appendChild(styleNode);\n }\n }\n if (oldStyleNode && keepOldStyleNode === false) {\n oldStyleNode.parentNode.removeChild(oldStyleNode);\n }\n\n // For IE.\n // This needs to happen *after* the style element is added to the DOM, otherwise IE 7 and 8 may crash.\n // See http://social.msdn.microsoft.com/Forums/en-US/7e081b65-878a-4c22-8e68-c10d39c2ed32/internet-explorer-crashes-appending-style-element-to-head\n if (styleNode.styleSheet) {\n try {\n styleNode.styleSheet.cssText = styles;\n } catch (e) {\n throw new Error('Couldn\\'t reassign styleSheet.cssText.');\n }\n }\n },\n currentScript: function(window) {\n const document = window.document;\n return document.currentScript || (() => {\n const scripts = document.getElementsByTagName('script');\n return scripts[scripts.length - 1];\n })();\n }\n};\n","export default {\n 'aliceblue':'#f0f8ff',\n 'antiquewhite':'#faebd7',\n 'aqua':'#00ffff',\n 'aquamarine':'#7fffd4',\n 'azure':'#f0ffff',\n 'beige':'#f5f5dc',\n 'bisque':'#ffe4c4',\n 'black':'#000000',\n 'blanchedalmond':'#ffebcd',\n 'blue':'#0000ff',\n 'blueviolet':'#8a2be2',\n 'brown':'#a52a2a',\n 'burlywood':'#deb887',\n 'cadetblue':'#5f9ea0',\n 'chartreuse':'#7fff00',\n 'chocolate':'#d2691e',\n 'coral':'#ff7f50',\n 'cornflowerblue':'#6495ed',\n 'cornsilk':'#fff8dc',\n 'crimson':'#dc143c',\n 'cyan':'#00ffff',\n 'darkblue':'#00008b',\n 'darkcyan':'#008b8b',\n 'darkgoldenrod':'#b8860b',\n 'darkgray':'#a9a9a9',\n 'darkgrey':'#a9a9a9',\n 'darkgreen':'#006400',\n 'darkkhaki':'#bdb76b',\n 'darkmagenta':'#8b008b',\n 'darkolivegreen':'#556b2f',\n 'darkorange':'#ff8c00',\n 'darkorchid':'#9932cc',\n 'darkred':'#8b0000',\n 'darksalmon':'#e9967a',\n 'darkseagreen':'#8fbc8f',\n 'darkslateblue':'#483d8b',\n 'darkslategray':'#2f4f4f',\n 'darkslategrey':'#2f4f4f',\n 'darkturquoise':'#00ced1',\n 'darkviolet':'#9400d3',\n 'deeppink':'#ff1493',\n 'deepskyblue':'#00bfff',\n 'dimgray':'#696969',\n 'dimgrey':'#696969',\n 'dodgerblue':'#1e90ff',\n 'firebrick':'#b22222',\n 'floralwhite':'#fffaf0',\n 'forestgreen':'#228b22',\n 'fuchsia':'#ff00ff',\n 'gainsboro':'#dcdcdc',\n 'ghostwhite':'#f8f8ff',\n 'gold':'#ffd700',\n 'goldenrod':'#daa520',\n 'gray':'#808080',\n 'grey':'#808080',\n 'green':'#008000',\n 'greenyellow':'#adff2f',\n 'honeydew':'#f0fff0',\n 'hotpink':'#ff69b4',\n 'indianred':'#cd5c5c',\n 'indigo':'#4b0082',\n 'ivory':'#fffff0',\n 'khaki':'#f0e68c',\n 'lavender':'#e6e6fa',\n 'lavenderblush':'#fff0f5',\n 'lawngreen':'#7cfc00',\n 'lemonchiffon':'#fffacd',\n 'lightblue':'#add8e6',\n 'lightcoral':'#f08080',\n 'lightcyan':'#e0ffff',\n 'lightgoldenrodyellow':'#fafad2',\n 'lightgray':'#d3d3d3',\n 'lightgrey':'#d3d3d3',\n 'lightgreen':'#90ee90',\n 'lightpink':'#ffb6c1',\n 'lightsalmon':'#ffa07a',\n 'lightseagreen':'#20b2aa',\n 'lightskyblue':'#87cefa',\n 'lightslategray':'#778899',\n 'lightslategrey':'#778899',\n 'lightsteelblue':'#b0c4de',\n 'lightyellow':'#ffffe0',\n 'lime':'#00ff00',\n 'limegreen':'#32cd32',\n 'linen':'#faf0e6',\n 'magenta':'#ff00ff',\n 'maroon':'#800000',\n 'mediumaquamarine':'#66cdaa',\n 'mediumblue':'#0000cd',\n 'mediumorchid':'#ba55d3',\n 'mediumpurple':'#9370d8',\n 'mediumseagreen':'#3cb371',\n 'mediumslateblue':'#7b68ee',\n 'mediumspringgreen':'#00fa9a',\n 'mediumturquoise':'#48d1cc',\n 'mediumvioletred':'#c71585',\n 'midnightblue':'#191970',\n 'mintcream':'#f5fffa',\n 'mistyrose':'#ffe4e1',\n 'moccasin':'#ffe4b5',\n 'navajowhite':'#ffdead',\n 'navy':'#000080',\n 'oldlace':'#fdf5e6',\n 'olive':'#808000',\n 'olivedrab':'#6b8e23',\n 'orange':'#ffa500',\n 'orangered':'#ff4500',\n 'orchid':'#da70d6',\n 'palegoldenrod':'#eee8aa',\n 'palegreen':'#98fb98',\n 'paleturquoise':'#afeeee',\n 'palevioletred':'#d87093',\n 'papayawhip':'#ffefd5',\n 'peachpuff':'#ffdab9',\n 'peru':'#cd853f',\n 'pink':'#ffc0cb',\n 'plum':'#dda0dd',\n 'powderblue':'#b0e0e6',\n 'purple':'#800080',\n 'rebeccapurple':'#663399',\n 'red':'#ff0000',\n 'rosybrown':'#bc8f8f',\n 'royalblue':'#4169e1',\n 'saddlebrown':'#8b4513',\n 'salmon':'#fa8072',\n 'sandybrown':'#f4a460',\n 'seagreen':'#2e8b57',\n 'seashell':'#fff5ee',\n 'sienna':'#a0522d',\n 'silver':'#c0c0c0',\n 'skyblue':'#87ceeb',\n 'slateblue':'#6a5acd',\n 'slategray':'#708090',\n 'slategrey':'#708090',\n 'snow':'#fffafa',\n 'springgreen':'#00ff7f',\n 'steelblue':'#4682b4',\n 'tan':'#d2b48c',\n 'teal':'#008080',\n 'thistle':'#d8bfd8',\n 'tomato':'#ff6347',\n 'turquoise':'#40e0d0',\n 'violet':'#ee82ee',\n 'wheat':'#f5deb3',\n 'white':'#ffffff',\n 'whitesmoke':'#f5f5f5',\n 'yellow':'#ffff00',\n 'yellowgreen':'#9acd32'\n};","export default {\n length: {\n 'm': 1,\n 'cm': 0.01,\n 'mm': 0.001,\n 'in': 0.0254,\n 'px': 0.0254 / 96,\n 'pt': 0.0254 / 72,\n 'pc': 0.0254 / 72 * 12\n },\n duration: {\n 's': 1,\n 'ms': 0.001\n },\n angle: {\n 'rad': 1 / (2 * Math.PI),\n 'deg': 1 / 360,\n 'grad': 1 / 400,\n 'turn': 1\n }\n};","import colors from './colors';\nimport unitConversions from './unit-conversions';\n\nexport default { colors, unitConversions };\n","class Node {\n constructor() {\n this.parent = null;\n this.visibilityBlocks = undefined;\n this.nodeVisible = undefined;\n this.rootNode = null;\n this.parsed = null;\n\n const self = this;\n Object.defineProperty(this, 'currentFileInfo', {\n get: function() { return self.fileInfo(); }\n });\n Object.defineProperty(this, 'index', {\n get: function() { return self.getIndex(); }\n });\n\n }\n\n setParent(nodes, parent) {\n function set(node) {\n if (node && node instanceof Node) {\n node.parent = parent;\n }\n }\n if (Array.isArray(nodes)) {\n nodes.forEach(set);\n }\n else {\n set(nodes);\n }\n }\n\n getIndex() {\n return this._index || (this.parent && this.parent.getIndex()) || 0;\n }\n\n fileInfo() {\n return this._fileInfo || (this.parent && this.parent.fileInfo()) || {};\n }\n\n isRulesetLike() {\n return false;\n }\n\n toCSS(context) {\n const strs = [];\n this.genCSS(context, {\n add: function(chunk, fileInfo, index) {\n strs.push(chunk);\n },\n isEmpty: function () {\n return strs.length === 0;\n }\n });\n return strs.join('');\n }\n\n genCSS(context, output) {\n output.add(this.value);\n }\n\n accept(visitor) {\n this.value = visitor.visit(this.value);\n }\n\n eval() { return this; }\n\n _operate(context, op, a, b) {\n switch (op) {\n case '+': return a + b;\n case '-': return a - b;\n case '*': return a * b;\n case '/': return a / b;\n }\n }\n\n fround(context, value) {\n const precision = context && context.numPrecision;\n // add \"epsilon\" to ensure numbers like 1.000000005 (represented as 1.000000004999...) are properly rounded:\n return (precision) ? Number((value + 2e-16).toFixed(precision)) : value;\n }\n\n // Returns true if this node represents root of ast imported by reference\n blocksVisibility() {\n if (this.visibilityBlocks == null) {\n this.visibilityBlocks = 0;\n }\n return this.visibilityBlocks !== 0;\n }\n\n addVisibilityBlock() {\n if (this.visibilityBlocks == null) {\n this.visibilityBlocks = 0;\n }\n this.visibilityBlocks = this.visibilityBlocks + 1;\n }\n\n removeVisibilityBlock() {\n if (this.visibilityBlocks == null) {\n this.visibilityBlocks = 0;\n }\n this.visibilityBlocks = this.visibilityBlocks - 1;\n }\n\n // Turns on node visibility - if called node will be shown in output regardless\n // of whether it comes from import by reference or not\n ensureVisibility() {\n this.nodeVisible = true;\n }\n\n // Turns off node visibility - if called node will NOT be shown in output regardless\n // of whether it comes from import by reference or not\n ensureInvisibility() {\n this.nodeVisible = false;\n }\n\n // return values:\n // false - the node must not be visible\n // true - the node must be visible\n // undefined or null - the node has the same visibility as its parent\n isVisible() {\n return this.nodeVisible;\n }\n\n visibilityInfo() {\n return {\n visibilityBlocks: this.visibilityBlocks,\n nodeVisible: this.nodeVisible\n };\n }\n\n copyVisibilityInfo(info) {\n if (!info) {\n return;\n }\n this.visibilityBlocks = info.visibilityBlocks;\n this.nodeVisible = info.nodeVisible;\n }\n}\n\nNode.compare = (a, b) => {\n /* returns:\n -1: a < b\n 0: a = b\n 1: a > b\n and *any* other value for a != b (e.g. undefined, NaN, -2 etc.) */\n\n if ((a.compare) &&\n // for \"symmetric results\" force toCSS-based comparison\n // of Quoted or Anonymous if either value is one of those\n !(b.type === 'Quoted' || b.type === 'Anonymous')) {\n return a.compare(b);\n } else if (b.compare) {\n return -b.compare(a);\n } else if (a.type !== b.type) {\n return undefined;\n }\n\n a = a.value;\n b = b.value;\n if (!Array.isArray(a)) {\n return a === b ? 0 : undefined;\n }\n if (a.length !== b.length) {\n return undefined;\n }\n for (let i = 0; i < a.length; i++) {\n if (Node.compare(a[i], b[i]) !== 0) {\n return undefined;\n }\n }\n return 0;\n};\n\nNode.numericCompare = (a, b) => a < b ? -1\n : a === b ? 0\n : a > b ? 1 : undefined;\nexport default Node;\n","import Node from './node';\nimport colors from '../data/colors';\n\n//\n// RGB Colors - #ff0014, #eee\n//\nclass Color extends Node {\n constructor(rgb, a, originalForm) {\n super();\n\n const self = this;\n //\n // The end goal here, is to parse the arguments\n // into an integer triplet, such as `128, 255, 0`\n //\n // This facilitates operations and conversions.\n //\n if (Array.isArray(rgb)) {\n this.rgb = rgb;\n } else if (rgb.length >= 6) {\n this.rgb = [];\n rgb.match(/.{2}/g).map((c, i) => {\n if (i < 3) {\n self.rgb.push(parseInt(c, 16));\n } else {\n self.alpha = (parseInt(c, 16)) / 255;\n }\n });\n } else {\n this.rgb = [];\n rgb.split('').map((c, i) => {\n if (i < 3) {\n self.rgb.push(parseInt(c + c, 16));\n } else {\n self.alpha = (parseInt(c + c, 16)) / 255;\n }\n });\n }\n this.alpha = this.alpha || (typeof a === 'number' ? a : 1);\n if (typeof originalForm !== 'undefined') {\n this.value = originalForm;\n }\n }\n\n luma() {\n let r = this.rgb[0] / 255;\n let g = this.rgb[1] / 255;\n let b = this.rgb[2] / 255;\n\n r = (r <= 0.03928) ? r / 12.92 : Math.pow(((r + 0.055) / 1.055), 2.4);\n g = (g <= 0.03928) ? g / 12.92 : Math.pow(((g + 0.055) / 1.055), 2.4);\n b = (b <= 0.03928) ? b / 12.92 : Math.pow(((b + 0.055) / 1.055), 2.4);\n\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n }\n\n genCSS(context, output) {\n output.add(this.toCSS(context));\n }\n\n toCSS(context, doNotCompress) {\n const compress = context && context.compress && !doNotCompress;\n let color;\n let alpha;\n let colorFunction;\n let args = [];\n\n // `value` is set if this color was originally\n // converted from a named color string so we need\n // to respect this and try to output named color too.\n alpha = this.fround(context, this.alpha);\n\n if (this.value) {\n if (this.value.indexOf('rgb') === 0) {\n if (alpha < 1) {\n colorFunction = 'rgba';\n }\n } else if (this.value.indexOf('hsl') === 0) {\n if (alpha < 1) {\n colorFunction = 'hsla';\n } else {\n colorFunction = 'hsl';\n }\n } else {\n return this.value;\n }\n } else {\n if (alpha < 1) {\n colorFunction = 'rgba';\n }\n }\n\n switch (colorFunction) {\n case 'rgba':\n args = this.rgb.map(c => clamp(Math.round(c), 255)).concat(clamp(alpha, 1));\n break;\n case 'hsla':\n args.push(clamp(alpha, 1));\n case 'hsl':\n color = this.toHSL();\n args = [\n this.fround(context, color.h),\n `${this.fround(context, color.s * 100)}%`,\n `${this.fround(context, color.l * 100)}%`\n ].concat(args);\n }\n\n if (colorFunction) {\n // Values are capped between `0` and `255`, rounded and zero-padded.\n return `${colorFunction}(${args.join(`,${compress ? '' : ' '}`)})`;\n }\n\n color = this.toRGB();\n\n if (compress) {\n const splitcolor = color.split('');\n\n // Convert color to short format\n if (splitcolor[1] === splitcolor[2] && splitcolor[3] === splitcolor[4] && splitcolor[5] === splitcolor[6]) {\n color = `#${splitcolor[1]}${splitcolor[3]}${splitcolor[5]}`;\n }\n }\n\n return color;\n }\n\n //\n // Operations have to be done per-channel, if not,\n // channels will spill onto each other. Once we have\n // our result, in the form of an integer triplet,\n // we create a new Color node to hold the result.\n //\n operate(context, op, other) {\n const rgb = new Array(3);\n const alpha = this.alpha * (1 - other.alpha) + other.alpha;\n for (let c = 0; c < 3; c++) {\n rgb[c] = this._operate(context, op, this.rgb[c], other.rgb[c]);\n }\n return new Color(rgb, alpha);\n }\n\n toRGB() {\n return toHex(this.rgb);\n }\n\n toHSL() {\n const r = this.rgb[0] / 255;\n const g = this.rgb[1] / 255;\n const b = this.rgb[2] / 255;\n const a = this.alpha;\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n let h;\n let s;\n const l = (max + min) / 2;\n const d = max - min;\n\n if (max === min) {\n h = s = 0;\n } else {\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n\n switch (max) {\n case r: h = (g - b) / d + (g < b ? 6 : 0); break;\n case g: h = (b - r) / d + 2; break;\n case b: h = (r - g) / d + 4; break;\n }\n h /= 6;\n }\n return { h: h * 360, s, l, a };\n }\n\n // Adapted from http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript\n toHSV() {\n const r = this.rgb[0] / 255;\n const g = this.rgb[1] / 255;\n const b = this.rgb[2] / 255;\n const a = this.alpha;\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n let h;\n let s;\n const v = max;\n\n const d = max - min;\n if (max === 0) {\n s = 0;\n } else {\n s = d / max;\n }\n\n if (max === min) {\n h = 0;\n } else {\n switch (max) {\n case r: h = (g - b) / d + (g < b ? 6 : 0); break;\n case g: h = (b - r) / d + 2; break;\n case b: h = (r - g) / d + 4; break;\n }\n h /= 6;\n }\n return { h: h * 360, s, v, a };\n }\n\n toARGB() {\n return toHex([this.alpha * 255].concat(this.rgb));\n }\n\n compare(x) {\n return (x.rgb &&\n x.rgb[0] === this.rgb[0] &&\n x.rgb[1] === this.rgb[1] &&\n x.rgb[2] === this.rgb[2] &&\n x.alpha === this.alpha) ? 0 : undefined;\n }\n}\n\nColor.prototype.type = 'Color';\n\nfunction clamp(v, max) {\n return Math.min(Math.max(v, 0), max);\n}\n\nfunction toHex(v) {\n return `#${v.map(c => {\n c = clamp(Math.round(c), 255);\n return (c < 16 ? '0' : '') + c.toString(16);\n }).join('')}`;\n}\n\nColor.fromKeyword = keyword => {\n let c;\n const key = keyword.toLowerCase();\n if (colors.hasOwnProperty(key)) {\n c = new Color(colors[key].slice(1));\n }\n else if (key === 'transparent') {\n c = new Color([0, 0, 0], 0);\n }\n\n if (c) {\n c.value = keyword;\n return c;\n }\n};\nexport default Color;\n","import Node from './node';\n\nclass Paren extends Node {\n constructor(node) {\n super();\n\n this.value = node;\n }\n\n genCSS(context, output) {\n output.add('(');\n this.value.genCSS(context, output);\n output.add(')');\n }\n\n eval(context) {\n return new Paren(this.value.eval(context));\n }\n}\n\nParen.prototype.type = 'Paren';\nexport default Paren;\n","import Node from './node';\nconst _noSpaceCombinators = {\n '': true,\n ' ': true,\n '|': true\n};\n\nclass Combinator extends Node {\n constructor(value) {\n super();\n\n if (value === ' ') {\n this.value = ' ';\n this.emptyOrWhitespace = true;\n } else {\n this.value = value ? value.trim() : '';\n this.emptyOrWhitespace = this.value === '';\n }\n }\n\n genCSS(context, output) {\n const spaceOrEmpty = (context.compress || _noSpaceCombinators[this.value]) ? '' : ' ';\n output.add(spaceOrEmpty + this.value + spaceOrEmpty);\n }\n}\n\nCombinator.prototype.type = 'Combinator';\n\nexport default Combinator;\n","import Node from './node';\nimport Paren from './paren';\nimport Combinator from './combinator';\n\nclass Element extends Node {\n constructor(combinator, value, isVariable, index, currentFileInfo, visibilityInfo) {\n super();\n\n this.combinator = combinator instanceof Combinator ?\n combinator : new Combinator(combinator);\n\n if (typeof value === 'string') {\n this.value = value.trim();\n } else if (value) {\n this.value = value;\n } else {\n this.value = '';\n }\n this.isVariable = isVariable;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.copyVisibilityInfo(visibilityInfo);\n this.setParent(this.combinator, this);\n }\n\n accept(visitor) {\n const value = this.value;\n this.combinator = visitor.visit(this.combinator);\n if (typeof value === 'object') {\n this.value = visitor.visit(value);\n }\n }\n\n eval(context) {\n return new Element(this.combinator,\n this.value.eval ? this.value.eval(context) : this.value,\n this.isVariable,\n this.getIndex(),\n this.fileInfo(), this.visibilityInfo());\n }\n\n clone() {\n return new Element(this.combinator,\n this.value,\n this.isVariable,\n this.getIndex(),\n this.fileInfo(), this.visibilityInfo());\n }\n\n genCSS(context, output) {\n output.add(this.toCSS(context), this.fileInfo(), this.getIndex());\n }\n\n toCSS(context = {}) {\n let value = this.value;\n const firstSelector = context.firstSelector;\n if (value instanceof Paren) {\n // selector in parens should not be affected by outer selector\n // flags (breaks only interpolated selectors - see #1973)\n context.firstSelector = true;\n }\n value = value.toCSS ? value.toCSS(context) : value;\n context.firstSelector = firstSelector;\n if (value === '' && this.combinator.value.charAt(0) === '&') {\n return '';\n } else {\n return this.combinator.toCSS(context) + value;\n }\n }\n}\n\nElement.prototype.type = 'Element';\nexport default Element;\n","\nexport const Math = {\n ALWAYS: 0,\n PARENS_DIVISION: 1,\n PARENS: 2,\n STRICT_LEGACY: 3\n};\n\nexport const RewriteUrls = {\n OFF: 0,\n LOCAL: 1,\n ALL: 2\n};","var clone = (function() {\n'use strict';\n\nfunction _instanceof(obj, type) {\n return type != null && obj instanceof type;\n}\n\nvar nativeMap;\ntry {\n nativeMap = Map;\n} catch(_) {\n // maybe a reference error because no `Map`. Give it a dummy value that no\n // value will ever be an instanceof.\n nativeMap = function() {};\n}\n\nvar nativeSet;\ntry {\n nativeSet = Set;\n} catch(_) {\n nativeSet = function() {};\n}\n\nvar nativePromise;\ntry {\n nativePromise = Promise;\n} catch(_) {\n nativePromise = function() {};\n}\n\n/**\n * Clones (copies) an Object using deep copying.\n *\n * This function supports circular references by default, but if you are certain\n * there are no circular references in your object, you can save some CPU time\n * by calling clone(obj, false).\n *\n * Caution: if `circular` is false and `parent` contains circular references,\n * your program may enter an infinite loop and crash.\n *\n * @param `parent` - the object to be cloned\n * @param `circular` - set to true if the object to be cloned may contain\n * circular references. (optional - true by default)\n * @param `depth` - set to a number if the object is only to be cloned to\n * a particular depth. (optional - defaults to Infinity)\n * @param `prototype` - sets the prototype to be used when cloning an object.\n * (optional - defaults to parent prototype).\n * @param `includeNonEnumerable` - set to true if the non-enumerable properties\n * should be cloned as well. Non-enumerable properties on the prototype\n * chain will be ignored. (optional - false by default)\n*/\nfunction clone(parent, circular, depth, prototype, includeNonEnumerable) {\n if (typeof circular === 'object') {\n depth = circular.depth;\n prototype = circular.prototype;\n includeNonEnumerable = circular.includeNonEnumerable;\n circular = circular.circular;\n }\n // maintain two arrays for circular references, where corresponding parents\n // and children have the same index\n var allParents = [];\n var allChildren = [];\n\n var useBuffer = typeof Buffer != 'undefined';\n\n if (typeof circular == 'undefined')\n circular = true;\n\n if (typeof depth == 'undefined')\n depth = Infinity;\n\n // recurse this function so we don't reset allParents and allChildren\n function _clone(parent, depth) {\n // cloning null always returns null\n if (parent === null)\n return null;\n\n if (depth === 0)\n return parent;\n\n var child;\n var proto;\n if (typeof parent != 'object') {\n return parent;\n }\n\n if (_instanceof(parent, nativeMap)) {\n child = new nativeMap();\n } else if (_instanceof(parent, nativeSet)) {\n child = new nativeSet();\n } else if (_instanceof(parent, nativePromise)) {\n child = new nativePromise(function (resolve, reject) {\n parent.then(function(value) {\n resolve(_clone(value, depth - 1));\n }, function(err) {\n reject(_clone(err, depth - 1));\n });\n });\n } else if (clone.__isArray(parent)) {\n child = [];\n } else if (clone.__isRegExp(parent)) {\n child = new RegExp(parent.source, __getRegExpFlags(parent));\n if (parent.lastIndex) child.lastIndex = parent.lastIndex;\n } else if (clone.__isDate(parent)) {\n child = new Date(parent.getTime());\n } else if (useBuffer && Buffer.isBuffer(parent)) {\n if (Buffer.allocUnsafe) {\n // Node.js >= 4.5.0\n child = Buffer.allocUnsafe(parent.length);\n } else {\n // Older Node.js versions\n child = new Buffer(parent.length);\n }\n parent.copy(child);\n return child;\n } else if (_instanceof(parent, Error)) {\n child = Object.create(parent);\n } else {\n if (typeof prototype == 'undefined') {\n proto = Object.getPrototypeOf(parent);\n child = Object.create(proto);\n }\n else {\n child = Object.create(prototype);\n proto = prototype;\n }\n }\n\n if (circular) {\n var index = allParents.indexOf(parent);\n\n if (index != -1) {\n return allChildren[index];\n }\n allParents.push(parent);\n allChildren.push(child);\n }\n\n if (_instanceof(parent, nativeMap)) {\n parent.forEach(function(value, key) {\n var keyChild = _clone(key, depth - 1);\n var valueChild = _clone(value, depth - 1);\n child.set(keyChild, valueChild);\n });\n }\n if (_instanceof(parent, nativeSet)) {\n parent.forEach(function(value) {\n var entryChild = _clone(value, depth - 1);\n child.add(entryChild);\n });\n }\n\n for (var i in parent) {\n var attrs;\n if (proto) {\n attrs = Object.getOwnPropertyDescriptor(proto, i);\n }\n\n if (attrs && attrs.set == null) {\n continue;\n }\n child[i] = _clone(parent[i], depth - 1);\n }\n\n if (Object.getOwnPropertySymbols) {\n var symbols = Object.getOwnPropertySymbols(parent);\n for (var i = 0; i < symbols.length; i++) {\n // Don't need to worry about cloning a symbol because it is a primitive,\n // like a number or string.\n var symbol = symbols[i];\n var descriptor = Object.getOwnPropertyDescriptor(parent, symbol);\n if (descriptor && !descriptor.enumerable && !includeNonEnumerable) {\n continue;\n }\n child[symbol] = _clone(parent[symbol], depth - 1);\n if (!descriptor.enumerable) {\n Object.defineProperty(child, symbol, {\n enumerable: false\n });\n }\n }\n }\n\n if (includeNonEnumerable) {\n var allPropertyNames = Object.getOwnPropertyNames(parent);\n for (var i = 0; i < allPropertyNames.length; i++) {\n var propertyName = allPropertyNames[i];\n var descriptor = Object.getOwnPropertyDescriptor(parent, propertyName);\n if (descriptor && descriptor.enumerable) {\n continue;\n }\n child[propertyName] = _clone(parent[propertyName], depth - 1);\n Object.defineProperty(child, propertyName, {\n enumerable: false\n });\n }\n }\n\n return child;\n }\n\n return _clone(parent, depth);\n}\n\n/**\n * Simple flat clone using prototype, accepts only objects, usefull for property\n * override on FLAT configuration object (no nested props).\n *\n * USE WITH CAUTION! This may not behave as you wish if you do not know how this\n * works.\n */\nclone.clonePrototype = function clonePrototype(parent) {\n if (parent === null)\n return null;\n\n var c = function () {};\n c.prototype = parent;\n return new c();\n};\n\n// private utility functions\n\nfunction __objToStr(o) {\n return Object.prototype.toString.call(o);\n}\nclone.__objToStr = __objToStr;\n\nfunction __isDate(o) {\n return typeof o === 'object' && __objToStr(o) === '[object Date]';\n}\nclone.__isDate = __isDate;\n\nfunction __isArray(o) {\n return typeof o === 'object' && __objToStr(o) === '[object Array]';\n}\nclone.__isArray = __isArray;\n\nfunction __isRegExp(o) {\n return typeof o === 'object' && __objToStr(o) === '[object RegExp]';\n}\nclone.__isRegExp = __isRegExp;\n\nfunction __getRegExpFlags(re) {\n var flags = '';\n if (re.global) flags += 'g';\n if (re.ignoreCase) flags += 'i';\n if (re.multiline) flags += 'm';\n return flags;\n}\nclone.__getRegExpFlags = __getRegExpFlags;\n\nreturn clone;\n})();\n\nif (typeof module === 'object' && module.exports) {\n module.exports = clone;\n}\n","/* jshint proto: true */\nimport * as Constants from './constants';\nimport CloneHelper from 'clone';\n\nexport function getLocation(index, inputStream) {\n let n = index + 1;\n let line = null;\n let column = -1;\n\n while (--n >= 0 && inputStream.charAt(n) !== '\\n') {\n column++;\n }\n\n if (typeof index === 'number') {\n line = (inputStream.slice(0, index).match(/\\n/g) || '').length;\n }\n\n return {\n line,\n column\n };\n}\n\nexport function copyArray(arr) {\n let i;\n const length = arr.length;\n const copy = new Array(length);\n\n for (i = 0; i < length; i++) {\n copy[i] = arr[i];\n }\n return copy;\n}\n\nexport function clone(obj) {\n const cloned = {};\n for (const prop in obj) {\n if (obj.hasOwnProperty(prop)) {\n cloned[prop] = obj[prop];\n }\n }\n return cloned;\n}\n\nexport function defaults(obj1, obj2) {\n let newObj = obj2 || {};\n if (!obj2._defaults) {\n newObj = {};\n const defaults = CloneHelper(obj1);\n newObj._defaults = defaults;\n const cloned = obj2 ? CloneHelper(obj2) : {};\n Object.assign(newObj, defaults, cloned);\n }\n return newObj;\n}\n\nexport function copyOptions(obj1, obj2) {\n if (obj2 && obj2._defaults) {\n return obj2;\n }\n const opts = defaults(obj1, obj2);\n if (opts.strictMath) {\n opts.math = Constants.Math.STRICT_LEGACY;\n }\n // Back compat with changed relativeUrls option\n if (opts.relativeUrls) {\n opts.rewriteUrls = Constants.RewriteUrls.ALL;\n }\n if (typeof opts.math === 'string') {\n switch (opts.math.toLowerCase()) {\n case 'always':\n opts.math = Constants.Math.ALWAYS;\n break;\n case 'parens-division':\n opts.math = Constants.Math.PARENS_DIVISION;\n break;\n case 'strict':\n case 'parens':\n opts.math = Constants.Math.PARENS;\n break;\n case 'strict-legacy':\n opts.math = Constants.Math.STRICT_LEGACY;\n }\n }\n if (typeof opts.rewriteUrls === 'string') {\n switch (opts.rewriteUrls.toLowerCase()) {\n case 'off':\n opts.rewriteUrls = Constants.RewriteUrls.OFF;\n break;\n case 'local':\n opts.rewriteUrls = Constants.RewriteUrls.LOCAL;\n break;\n case 'all':\n opts.rewriteUrls = Constants.RewriteUrls.ALL;\n break;\n }\n }\n return opts;\n}\n\nexport function merge(obj1, obj2) {\n for (const prop in obj2) {\n if (obj2.hasOwnProperty(prop)) {\n obj1[prop] = obj2[prop];\n }\n }\n return obj1;\n}\n\nexport function flattenArray(arr, result = []) {\n for (let i = 0, length = arr.length; i < length; i++) {\n const value = arr[i];\n if (Array.isArray(value)) {\n flattenArray(value, result);\n } else {\n if (value !== undefined) {\n result.push(value);\n }\n }\n }\n return result;\n}","import * as utils from './utils';\n/**\n * This is a centralized class of any error that could be thrown internally (mostly by the parser).\n * Besides standard .message it keeps some additional data like a path to the file where the error\n * occurred along with line and column numbers.\n *\n * @class\n * @extends Error\n * @type {module.LessError}\n *\n * @prop {string} type\n * @prop {string} filename\n * @prop {number} index\n * @prop {number} line\n * @prop {number} column\n * @prop {number} callLine\n * @prop {number} callExtract\n * @prop {string[]} extract\n *\n * @param {Object} e - An error object to wrap around or just a descriptive object\n * @param {Object} fileContentMap - An object with file contents in 'contents' property (like importManager) @todo - move to fileManager?\n * @param {string} [currentFilename]\n */\nconst LessError = function LessError(e, fileContentMap, currentFilename) {\n Error.call(this);\n\n const filename = e.filename || currentFilename;\n\n this.message = e.message;\n this.stack = e.stack;\n\n if (fileContentMap && filename) {\n const input = fileContentMap.contents[filename];\n const loc = utils.getLocation(e.index, input);\n const line = loc.line;\n const col = loc.column;\n const callLine = e.call && utils.getLocation(e.call, input).line;\n const lines = input ? input.split('\\n') : '';\n\n this.type = e.type || 'Syntax';\n this.filename = filename;\n this.index = e.index;\n this.line = typeof line === 'number' ? line + 1 : null;\n this.column = col;\n\n if (!this.line && this.stack) {\n const found = this.stack.match(/(|Function):(\\d+):(\\d+)/);\n\n if (found) {\n if (found[2]) {\n this.line = parseInt(found[2]) - 2;\n }\n if (found[3]) {\n this.column = parseInt(found[3]);\n }\n }\n }\n\n this.callLine = callLine + 1;\n this.callExtract = lines[callLine];\n\n this.extract = [\n lines[this.line - 2],\n lines[this.line - 1],\n lines[this.line]\n ];\n }\n\n};\n\nif (typeof Object.create === 'undefined') {\n const F = () => {};\n F.prototype = Error.prototype;\n LessError.prototype = new F();\n} else {\n LessError.prototype = Object.create(Error.prototype);\n}\n\nLessError.prototype.constructor = LessError;\n\n/**\n * An overridden version of the default Object.prototype.toString\n * which uses additional information to create a helpful message.\n *\n * @param {Object} options\n * @returns {string}\n */\nLessError.prototype.toString = function(options = {}) {\n let message = '';\n const extract = this.extract || [];\n let error = [];\n let stylize = str => str;\n if (options.stylize) {\n const type = typeof options.stylize;\n if (type !== 'function') {\n throw Error(`options.stylize should be a function, got a ${type}!`);\n }\n stylize = options.stylize;\n }\n\n if (this.line !== null) {\n if (typeof extract[0] === 'string') {\n error.push(stylize(`${this.line - 1} ${extract[0]}`, 'grey'));\n }\n\n if (typeof extract[1] === 'string') {\n let errorTxt = `${this.line} `;\n if (extract[1]) {\n errorTxt += extract[1].slice(0, this.column) +\n stylize(stylize(stylize(extract[1].substr(this.column, 1), 'bold') +\n extract[1].slice(this.column + 1), 'red'), 'inverse');\n }\n error.push(errorTxt);\n }\n\n if (typeof extract[2] === 'string') {\n error.push(stylize(`${this.line + 1} ${extract[2]}`, 'grey'));\n }\n error = `${error.join('\\n') + stylize('', 'reset')}\\n`;\n }\n\n message += stylize(`${this.type}Error: ${this.message}`, 'red');\n if (this.filename) {\n message += stylize(' in ', 'red') + this.filename;\n }\n if (this.line) {\n message += stylize(` on line ${this.line}, column ${this.column + 1}:`, 'grey');\n }\n\n message += `\\n${error}`;\n\n if (this.callLine) {\n message += `${stylize('from ', 'red') + (this.filename || '')}/n`;\n message += `${stylize(this.callLine, 'grey')} ${this.callExtract}/n`;\n }\n\n return message;\n};\n\nexport default LessError;","import Node from './node';\nimport Element from './element';\nimport LessError from '../less-error';\n\nclass Selector extends Node {\n constructor(elements, extendList, condition, index, currentFileInfo, visibilityInfo) {\n super();\n\n this.extendList = extendList;\n this.condition = condition;\n this.evaldCondition = !condition;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.elements = this.getElements(elements);\n this.mixinElements_ = undefined;\n this.copyVisibilityInfo(visibilityInfo);\n this.setParent(this.elements, this);\n }\n\n accept(visitor) {\n if (this.elements) {\n this.elements = visitor.visitArray(this.elements);\n }\n if (this.extendList) {\n this.extendList = visitor.visitArray(this.extendList);\n }\n if (this.condition) {\n this.condition = visitor.visit(this.condition);\n }\n }\n\n createDerived(elements, extendList, evaldCondition) {\n elements = this.getElements(elements);\n const newSelector = new Selector(elements, extendList || this.extendList,\n null, this.getIndex(), this.fileInfo(), this.visibilityInfo());\n newSelector.evaldCondition = (evaldCondition != null) ? evaldCondition : this.evaldCondition;\n newSelector.mediaEmpty = this.mediaEmpty;\n return newSelector;\n }\n\n getElements(els) {\n if (!els) {\n return [new Element('', '&', false, this._index, this._fileInfo)];\n }\n if (typeof els === 'string') {\n this.parse.parseNode(\n els, \n ['selector'],\n this._index, \n this._fileInfo, \n function(err, result) {\n if (err) {\n throw new LessError({\n index: err.index,\n message: err.message\n }, this.parse.imports, this._fileInfo.filename);\n }\n els = result[0].elements;\n });\n }\n return els;\n }\n\n createEmptySelectors() {\n const el = new Element('', '&', false, this._index, this._fileInfo);\n const sels = [new Selector([el], null, null, this._index, this._fileInfo)];\n sels[0].mediaEmpty = true;\n return sels;\n }\n\n match(other) {\n const elements = this.elements;\n const len = elements.length;\n let olen;\n let i;\n\n other = other.mixinElements();\n olen = other.length;\n if (olen === 0 || len < olen) {\n return 0;\n } else {\n for (i = 0; i < olen; i++) {\n if (elements[i].value !== other[i]) {\n return 0;\n }\n }\n }\n\n return olen; // return number of matched elements\n }\n\n mixinElements() {\n if (this.mixinElements_) {\n return this.mixinElements_;\n }\n\n let elements = this.elements.map( v => v.combinator.value + (v.value.value || v.value)).join('').match(/[,&#\\*\\.\\w-]([\\w-]|(\\\\.))*/g);\n\n if (elements) {\n if (elements[0] === '&') {\n elements.shift();\n }\n } else {\n elements = [];\n }\n\n return (this.mixinElements_ = elements);\n }\n\n isJustParentSelector() {\n return !this.mediaEmpty &&\n this.elements.length === 1 &&\n this.elements[0].value === '&' &&\n (this.elements[0].combinator.value === ' ' || this.elements[0].combinator.value === '');\n }\n\n eval(context) {\n const evaldCondition = this.condition && this.condition.eval(context);\n let elements = this.elements;\n let extendList = this.extendList;\n\n elements = elements && elements.map(e => e.eval(context));\n extendList = extendList && extendList.map(extend => extend.eval(context));\n\n return this.createDerived(elements, extendList, evaldCondition);\n }\n\n genCSS(context, output) {\n let i;\n let element;\n if ((!context || !context.firstSelector) && this.elements[0].combinator.value === '') {\n output.add(' ', this.fileInfo(), this.getIndex());\n }\n for (i = 0; i < this.elements.length; i++) {\n element = this.elements[i];\n element.genCSS(context, output);\n }\n }\n\n getIsOutput() {\n return this.evaldCondition;\n }\n}\n\nSelector.prototype.type = 'Selector';\nexport default Selector;\n","import Node from './node';\n\nclass Value extends Node {\n constructor(value) {\n super();\n\n if (!value) {\n throw new Error('Value requires an array argument');\n }\n if (!Array.isArray(value)) {\n this.value = [ value ];\n }\n else {\n this.value = value;\n }\n }\n\n accept(visitor) {\n if (this.value) {\n this.value = visitor.visitArray(this.value);\n }\n }\n\n eval(context) {\n if (this.value.length === 1) {\n return this.value[0].eval(context);\n } else {\n return new Value(this.value.map(v => v.eval(context)));\n }\n }\n\n genCSS(context, output) {\n let i;\n for (i = 0; i < this.value.length; i++) {\n this.value[i].genCSS(context, output);\n if (i + 1 < this.value.length) {\n output.add((context && context.compress) ? ',' : ', ');\n }\n }\n }\n}\n\nValue.prototype.type = 'Value';\nexport default Value;\n","import Node from './node';\n\nclass Keyword extends Node {\n constructor(value) {\n super();\n\n this.value = value;\n }\n\n genCSS(context, output) {\n if (this.value === '%') { throw { type: 'Syntax', message: 'Invalid % without number' }; }\n output.add(this.value);\n }\n}\n\nKeyword.prototype.type = 'Keyword';\n\nKeyword.True = new Keyword('true');\nKeyword.False = new Keyword('false');\n\nexport default Keyword;\n","import Node from './node';\n\nclass Anonymous extends Node {\n constructor(value, index, currentFileInfo, mapLines, rulesetLike, visibilityInfo) {\n super();\n\n this.value = value;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.mapLines = mapLines;\n this.rulesetLike = (typeof rulesetLike === 'undefined') ? false : rulesetLike;\n this.allowRoot = true;\n this.copyVisibilityInfo(visibilityInfo);\n }\n\n eval() {\n return new Anonymous(this.value, this._index, this._fileInfo, this.mapLines, this.rulesetLike, this.visibilityInfo());\n }\n\n compare(other) {\n return other.toCSS && this.toCSS() === other.toCSS() ? 0 : undefined;\n }\n\n isRulesetLike() {\n return this.rulesetLike;\n }\n\n genCSS(context, output) {\n this.nodeVisible = Boolean(this.value);\n if (this.nodeVisible) {\n output.add(this.value, this._fileInfo, this._index, this.mapLines);\n }\n }\n}\n\nAnonymous.prototype.type = 'Anonymous';\nexport default Anonymous;\n","import Node from './node';\nimport Value from './value';\nimport Keyword from './keyword';\nimport Anonymous from './anonymous';\nimport * as Constants from '../constants';\nconst MATH = Constants.Math;\n\n\nclass Declaration extends Node {\n constructor(name, value, important, merge, index, currentFileInfo, inline, variable) {\n super();\n\n this.name = name;\n this.value = (value instanceof Node) ? value : new Value([value ? new Anonymous(value) : null]);\n this.important = important ? ` ${important.trim()}` : '';\n this.merge = merge;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.inline = inline || false;\n this.variable = (variable !== undefined) ? variable\n : (name.charAt && (name.charAt(0) === '@'));\n this.allowRoot = true;\n this.setParent(this.value, this);\n }\n\n genCSS(context, output) {\n output.add(this.name + (context.compress ? ':' : ': '), this.fileInfo(), this.getIndex());\n try {\n this.value.genCSS(context, output);\n }\n catch (e) {\n e.index = this._index;\n e.filename = this._fileInfo.filename;\n throw e;\n }\n output.add(this.important + ((this.inline || (context.lastRule && context.compress)) ? '' : ';'), this._fileInfo, this._index);\n }\n\n eval(context) {\n let mathBypass = false;\n let prevMath;\n let name = this.name;\n let evaldValue;\n let variable = this.variable;\n if (typeof name !== 'string') {\n // expand 'primitive' name directly to get\n // things faster (~10% for benchmark.less):\n name = (name.length === 1) && (name[0] instanceof Keyword) ?\n name[0].value : evalName(context, name);\n variable = false; // never treat expanded interpolation as new variable name\n }\n\n // @todo remove when parens-division is default\n if (name === 'font' && context.math === MATH.ALWAYS) {\n mathBypass = true;\n prevMath = context.math;\n context.math = MATH.PARENS_DIVISION;\n }\n try {\n context.importantScope.push({});\n evaldValue = this.value.eval(context);\n\n if (!this.variable && evaldValue.type === 'DetachedRuleset') {\n throw { message: 'Rulesets cannot be evaluated on a property.',\n index: this.getIndex(), filename: this.fileInfo().filename };\n }\n let important = this.important;\n const importantResult = context.importantScope.pop();\n if (!important && importantResult.important) {\n important = importantResult.important;\n }\n\n return new Declaration(name,\n evaldValue,\n important,\n this.merge,\n this.getIndex(), this.fileInfo(), this.inline,\n variable);\n }\n catch (e) {\n if (typeof e.index !== 'number') {\n e.index = this.getIndex();\n e.filename = this.fileInfo().filename;\n }\n throw e;\n }\n finally {\n if (mathBypass) {\n context.math = prevMath;\n }\n }\n }\n\n makeImportant() {\n return new Declaration(this.name,\n this.value,\n '!important',\n this.merge,\n this.getIndex(), this.fileInfo(), this.inline);\n }\n}\n\nfunction evalName(context, name) {\n let value = '';\n let i;\n const n = name.length;\n const output = {add: function (s) {value += s;}};\n for (i = 0; i < n; i++) {\n name[i].eval(context).genCSS(context, output);\n }\n return value;\n}\n\nDeclaration.prototype.type = 'Declaration';\nexport default Declaration;","const debugInfo = (context, ctx, lineSeparator) => {\n let result = '';\n if (context.dumpLineNumbers && !context.compress) {\n switch (context.dumpLineNumbers) {\n case 'comments':\n result = debugInfo.asComment(ctx);\n break;\n case 'mediaquery':\n result = debugInfo.asMediaQuery(ctx);\n break;\n case 'all':\n result = debugInfo.asComment(ctx) + (lineSeparator || '') + debugInfo.asMediaQuery(ctx);\n break;\n }\n }\n return result;\n};\n\ndebugInfo.asComment = ctx => `/* line ${ctx.debugInfo.lineNumber}, ${ctx.debugInfo.fileName} */\\n`;\n\ndebugInfo.asMediaQuery = ctx => {\n let filenameWithProtocol = ctx.debugInfo.fileName;\n if (!/^[a-z]+:\\/\\//i.test(filenameWithProtocol)) {\n filenameWithProtocol = `file://${filenameWithProtocol}`;\n }\n return `@media -sass-debug-info{filename{font-family:${filenameWithProtocol.replace(/([.:\\/\\\\])/g, a => {\n if (a == '\\\\') {\n a = '\\/';\n }\n return `\\\\${a}`;\n })}}line{font-family:\\\\00003${ctx.debugInfo.lineNumber}}}\\n`;\n};\n\nexport default debugInfo;\n","import Node from './node';\nimport getDebugInfo from './debug-info';\n\nclass Comment extends Node {\n constructor(value, isLineComment, index, currentFileInfo) {\n super();\n\n this.value = value;\n this.isLineComment = isLineComment;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.allowRoot = true;\n }\n\n genCSS(context, output) {\n if (this.debugInfo) {\n output.add(getDebugInfo(context, this), this.fileInfo(), this.getIndex());\n }\n output.add(this.value);\n }\n\n isSilent(context) {\n const isCompressed = context.compress && this.value[2] !== '!';\n return this.isLineComment || isCompressed;\n }\n}\n\nComment.prototype.type = 'Comment';\nexport default Comment;\n","const contexts = {};\nexport default contexts;\nimport * as Constants from './constants';\n\nconst copyFromOriginal = function copyFromOriginal(original, destination, propertiesToCopy) {\n if (!original) { return; }\n\n for (let i = 0; i < propertiesToCopy.length; i++) {\n if (original.hasOwnProperty(propertiesToCopy[i])) {\n destination[propertiesToCopy[i]] = original[propertiesToCopy[i]];\n }\n }\n};\n\n/*\n parse is used whilst parsing\n */\nconst parseCopyProperties = [\n // options\n 'paths', // option - unmodified - paths to search for imports on\n 'rewriteUrls', // option - whether to adjust URL's to be relative\n 'rootpath', // option - rootpath to append to URL's\n 'strictImports', // option -\n 'insecure', // option - whether to allow imports from insecure ssl hosts\n 'dumpLineNumbers', // option - whether to dump line numbers\n 'compress', // option - whether to compress\n 'syncImport', // option - whether to import synchronously\n 'chunkInput', // option - whether to chunk input. more performant but causes parse issues.\n 'mime', // browser only - mime type for sheet import\n 'useFileCache', // browser only - whether to use the per file session cache\n // context\n 'processImports', // option & context - whether to process imports. if false then imports will not be imported.\n // Used by the import manager to stop multiple import visitors being created.\n 'pluginManager' // Used as the plugin manager for the session\n];\n\ncontexts.Parse = function(options) {\n copyFromOriginal(options, this, parseCopyProperties);\n\n if (typeof this.paths === 'string') { this.paths = [this.paths]; }\n};\n\nconst evalCopyProperties = [\n 'paths', // additional include paths\n 'compress', // whether to compress\n 'math', // whether math has to be within parenthesis\n 'strictUnits', // whether units need to evaluate correctly\n 'sourceMap', // whether to output a source map\n 'importMultiple', // whether we are currently importing multiple copies\n 'urlArgs', // whether to add args into url tokens\n 'javascriptEnabled', // option - whether Inline JavaScript is enabled. if undefined, defaults to false\n 'pluginManager', // Used as the plugin manager for the session\n 'importantScope', // used to bubble up !important statements\n 'rewriteUrls' // option - whether to adjust URL's to be relative\n];\n\nfunction isPathRelative(path) {\n return !/^(?:[a-z-]+:|\\/|#)/i.test(path);\n}\n\nfunction isPathLocalRelative(path) {\n return path.charAt(0) === '.';\n}\n\ncontexts.Eval = class {\n constructor(options, frames) {\n copyFromOriginal(options, this, evalCopyProperties);\n\n if (typeof this.paths === 'string') { this.paths = [this.paths]; }\n\n this.frames = frames || [];\n this.importantScope = this.importantScope || [];\n this.inCalc = false;\n this.mathOn = true;\n }\n\n enterCalc() {\n if (!this.calcStack) {\n this.calcStack = [];\n }\n this.calcStack.push(true);\n this.inCalc = true;\n }\n\n exitCalc() {\n this.calcStack.pop();\n if (!this.calcStack) {\n this.inCalc = false;\n }\n }\n\n inParenthesis() {\n if (!this.parensStack) {\n this.parensStack = [];\n }\n this.parensStack.push(true);\n };\n\n outOfParenthesis() {\n this.parensStack.pop();\n };\n\n isMathOn(op) {\n if (!this.mathOn) {\n return false;\n }\n if (op === '/' && this.math !== Constants.Math.ALWAYS && (!this.parensStack || !this.parensStack.length)) {\n return false;\n }\n if (this.math > Constants.Math.PARENS_DIVISION) {\n return this.parensStack && this.parensStack.length;\n }\n return true;\n }\n\n pathRequiresRewrite(path) {\n const isRelative = this.rewriteUrls === Constants.RewriteUrls.LOCAL ? isPathLocalRelative : isPathRelative;\n\n return isRelative(path);\n }\n\n rewritePath(path, rootpath) {\n let newPath;\n\n rootpath = rootpath || '';\n newPath = this.normalizePath(rootpath + path);\n\n // If a path was explicit relative and the rootpath was not an absolute path\n // we must ensure that the new path is also explicit relative.\n if (isPathLocalRelative(path) &&\n isPathRelative(rootpath) &&\n isPathLocalRelative(newPath) === false) {\n newPath = `./${newPath}`;\n }\n\n return newPath;\n }\n\n normalizePath(path) {\n const segments = path.split('/').reverse();\n let segment;\n\n path = [];\n while (segments.length !== 0) {\n segment = segments.pop();\n switch ( segment ) {\n case '.':\n break;\n case '..':\n if ((path.length === 0) || (path[path.length - 1] === '..')) {\n path.push( segment );\n } else {\n path.pop();\n }\n break;\n default:\n path.push(segment);\n break;\n }\n }\n\n return path.join('/');\n }\n}\n","function makeRegistry( base ) {\n return {\n _data: {},\n add: function(name, func) {\n // precautionary case conversion, as later querying of\n // the registry by function-caller uses lower case as well.\n name = name.toLowerCase();\n\n if (this._data.hasOwnProperty(name)) {\n // TODO warn\n }\n this._data[name] = func;\n },\n addMultiple: function(functions) {\n Object.keys(functions).forEach(\n name => {\n this.add(name, functions[name]);\n });\n },\n get: function(name) {\n return this._data[name] || ( base && base.get( name ));\n },\n getLocalFunctions: function() {\n return this._data;\n },\n inherit: function() {\n return makeRegistry( this );\n },\n create: function(base) {\n return makeRegistry(base);\n }\n };\n}\n\nexport default makeRegistry( null );","import Keyword from '../tree/keyword';\n\nconst defaultFunc = {\n eval: function () {\n const v = this.value_;\n const e = this.error_;\n if (e) {\n throw e;\n }\n if (v != null) {\n return v ? Keyword.True : Keyword.False;\n }\n },\n value: function (v) {\n this.value_ = v;\n },\n error: function (e) {\n this.error_ = e;\n },\n reset: function () {\n this.value_ = this.error_ = null;\n }\n};\n\nexport default defaultFunc;\n","import Node from './node';\nimport Declaration from './declaration';\nimport Keyword from './keyword';\nimport Comment from './comment';\nimport Paren from './paren';\nimport Selector from './selector';\nimport Element from './element';\nimport Anonymous from './anonymous';\nimport contexts from '../contexts';\nimport globalFunctionRegistry from '../functions/function-registry';\nimport defaultFunc from '../functions/default';\nimport getDebugInfo from './debug-info';\nimport * as utils from '../utils';\n\nclass Ruleset extends Node {\n constructor(selectors, rules, strictImports, visibilityInfo) {\n super();\n\n this.selectors = selectors;\n this.rules = rules;\n this._lookups = {};\n this._variables = null;\n this._properties = null;\n this.strictImports = strictImports;\n this.copyVisibilityInfo(visibilityInfo);\n this.allowRoot = true;\n\n this.setParent(this.selectors, this);\n this.setParent(this.rules, this);\n\n }\n\n isRulesetLike() {\n return true;\n }\n\n accept(visitor) {\n if (this.paths) {\n this.paths = visitor.visitArray(this.paths, true);\n } else if (this.selectors) {\n this.selectors = visitor.visitArray(this.selectors);\n }\n if (this.rules && this.rules.length) {\n this.rules = visitor.visitArray(this.rules);\n }\n }\n\n eval(context) {\n const that = this;\n let selectors;\n let selCnt;\n let selector;\n let i;\n let hasVariable;\n let hasOnePassingSelector = false;\n\n if (this.selectors && (selCnt = this.selectors.length)) {\n selectors = new Array(selCnt);\n defaultFunc.error({\n type: 'Syntax',\n message: 'it is currently only allowed in parametric mixin guards,'\n });\n\n for (i = 0; i < selCnt; i++) {\n selector = this.selectors[i].eval(context);\n for (var j = 0; j < selector.elements.length; j++) {\n if (selector.elements[j].isVariable) {\n hasVariable = true;\n break;\n }\n }\n selectors[i] = selector;\n if (selector.evaldCondition) {\n hasOnePassingSelector = true;\n }\n }\n\n if (hasVariable) {\n const toParseSelectors = new Array(selCnt);\n for (i = 0; i < selCnt; i++) {\n selector = selectors[i];\n toParseSelectors[i] = selector.toCSS(context);\n }\n this.parse.parseNode(\n toParseSelectors.join(','),\n [\"selectors\"], \n selectors[0].getIndex(), \n selectors[0].fileInfo(), \n (err, result) => {\n if (result) {\n selectors = utils.flattenArray(result);\n }\n });\n }\n\n defaultFunc.reset();\n } else {\n hasOnePassingSelector = true;\n }\n\n let rules = this.rules ? utils.copyArray(this.rules) : null;\n const ruleset = new Ruleset(selectors, rules, this.strictImports, this.visibilityInfo());\n let rule;\n let subRule;\n\n ruleset.originalRuleset = this;\n ruleset.root = this.root;\n ruleset.firstRoot = this.firstRoot;\n ruleset.allowImports = this.allowImports;\n\n if (this.debugInfo) {\n ruleset.debugInfo = this.debugInfo;\n }\n\n if (!hasOnePassingSelector) {\n rules.length = 0;\n }\n\n // inherit a function registry from the frames stack when possible;\n // otherwise from the global registry\n ruleset.functionRegistry = (frames => {\n let i = 0;\n const n = frames.length;\n let found;\n for ( ; i !== n ; ++i ) {\n found = frames[ i ].functionRegistry;\n if ( found ) { return found; }\n }\n return globalFunctionRegistry;\n })(context.frames).inherit();\n\n // push the current ruleset to the frames stack\n const ctxFrames = context.frames;\n ctxFrames.unshift(ruleset);\n\n // currrent selectors\n let ctxSelectors = context.selectors;\n if (!ctxSelectors) {\n context.selectors = ctxSelectors = [];\n }\n ctxSelectors.unshift(this.selectors);\n\n // Evaluate imports\n if (ruleset.root || ruleset.allowImports || !ruleset.strictImports) {\n ruleset.evalImports(context);\n }\n\n // Store the frames around mixin definitions,\n // so they can be evaluated like closures when the time comes.\n const rsRules = ruleset.rules;\n for (i = 0; (rule = rsRules[i]); i++) {\n if (rule.evalFirst) {\n rsRules[i] = rule.eval(context);\n }\n }\n\n const mediaBlockCount = (context.mediaBlocks && context.mediaBlocks.length) || 0;\n\n // Evaluate mixin calls.\n for (i = 0; (rule = rsRules[i]); i++) {\n if (rule.type === 'MixinCall') {\n /* jshint loopfunc:true */\n rules = rule.eval(context).filter(r => {\n if ((r instanceof Declaration) && r.variable) {\n // do not pollute the scope if the variable is\n // already there. consider returning false here\n // but we need a way to \"return\" variable from mixins\n return !(ruleset.variable(r.name));\n }\n return true;\n });\n rsRules.splice(...[i, 1].concat(rules));\n i += rules.length - 1;\n ruleset.resetCache();\n } else if (rule.type === 'VariableCall') {\n /* jshint loopfunc:true */\n rules = rule.eval(context).rules.filter(r => {\n if ((r instanceof Declaration) && r.variable) {\n // do not pollute the scope at all\n return false;\n }\n return true;\n });\n rsRules.splice(...[i, 1].concat(rules));\n i += rules.length - 1;\n ruleset.resetCache();\n }\n }\n\n // Evaluate everything else\n for (i = 0; (rule = rsRules[i]); i++) {\n if (!rule.evalFirst) {\n rsRules[i] = rule = rule.eval ? rule.eval(context) : rule;\n }\n }\n\n // Evaluate everything else\n for (i = 0; (rule = rsRules[i]); i++) {\n // for rulesets, check if it is a css guard and can be removed\n if (rule instanceof Ruleset && rule.selectors && rule.selectors.length === 1) {\n // check if it can be folded in (e.g. & where)\n if (rule.selectors[0] && rule.selectors[0].isJustParentSelector()) {\n rsRules.splice(i--, 1);\n\n for (var j = 0; (subRule = rule.rules[j]); j++) {\n if (subRule instanceof Node) {\n subRule.copyVisibilityInfo(rule.visibilityInfo());\n if (!(subRule instanceof Declaration) || !subRule.variable) {\n rsRules.splice(++i, 0, subRule);\n }\n }\n }\n }\n }\n }\n\n // Pop the stack\n ctxFrames.shift();\n ctxSelectors.shift();\n\n if (context.mediaBlocks) {\n for (i = mediaBlockCount; i < context.mediaBlocks.length; i++) {\n context.mediaBlocks[i].bubbleSelectors(selectors);\n }\n }\n\n return ruleset;\n }\n\n evalImports(context) {\n const rules = this.rules;\n let i;\n let importRules;\n if (!rules) { return; }\n\n for (i = 0; i < rules.length; i++) {\n if (rules[i].type === 'Import') {\n importRules = rules[i].eval(context);\n if (importRules && (importRules.length || importRules.length === 0)) {\n rules.splice(...[i, 1].concat(importRules));\n i += importRules.length - 1;\n } else {\n rules.splice(i, 1, importRules);\n }\n this.resetCache();\n }\n }\n }\n\n makeImportant() {\n const result = new Ruleset(this.selectors, this.rules.map(r => {\n if (r.makeImportant) {\n return r.makeImportant();\n } else {\n return r;\n }\n }), this.strictImports, this.visibilityInfo());\n\n return result;\n }\n\n matchArgs(args) {\n return !args || args.length === 0;\n }\n\n // lets you call a css selector with a guard\n matchCondition(args, context) {\n const lastSelector = this.selectors[this.selectors.length - 1];\n if (!lastSelector.evaldCondition) {\n return false;\n }\n if (lastSelector.condition &&\n !lastSelector.condition.eval(\n new contexts.Eval(context,\n context.frames))) {\n return false;\n }\n return true;\n }\n\n resetCache() {\n this._rulesets = null;\n this._variables = null;\n this._properties = null;\n this._lookups = {};\n }\n\n variables() {\n if (!this._variables) {\n this._variables = !this.rules ? {} : this.rules.reduce((hash, r) => {\n if (r instanceof Declaration && r.variable === true) {\n hash[r.name] = r;\n }\n // when evaluating variables in an import statement, imports have not been eval'd\n // so we need to go inside import statements.\n // guard against root being a string (in the case of inlined less)\n if (r.type === 'Import' && r.root && r.root.variables) {\n const vars = r.root.variables();\n for (const name in vars) {\n if (vars.hasOwnProperty(name)) {\n hash[name] = r.root.variable(name);\n }\n }\n }\n return hash;\n }, {});\n }\n return this._variables;\n }\n\n properties() {\n if (!this._properties) {\n this._properties = !this.rules ? {} : this.rules.reduce((hash, r) => {\n if (r instanceof Declaration && r.variable !== true) {\n const name = (r.name.length === 1) && (r.name[0] instanceof Keyword) ?\n r.name[0].value : r.name;\n // Properties don't overwrite as they can merge\n if (!hash[`$${name}`]) {\n hash[`$${name}`] = [ r ];\n }\n else {\n hash[`$${name}`].push(r);\n }\n }\n return hash;\n }, {});\n }\n return this._properties;\n }\n\n variable(name) {\n const decl = this.variables()[name];\n if (decl) {\n return this.parseValue(decl);\n }\n }\n\n property(name) {\n const decl = this.properties()[name];\n if (decl) {\n return this.parseValue(decl);\n }\n }\n\n lastDeclaration() {\n for (let i = this.rules.length; i > 0; i--) {\n const decl = this.rules[i - 1];\n if (decl instanceof Declaration) {\n return this.parseValue(decl);\n }\n }\n }\n\n parseValue(toParse) {\n const self = this;\n function transformDeclaration(decl) {\n if (decl.value instanceof Anonymous && !decl.parsed) {\n if (typeof decl.value.value === 'string') {\n this.parse.parseNode(\n decl.value.value,\n ['value', 'important'], \n decl.value.getIndex(), \n decl.fileInfo(), \n (err, result) => {\n if (err) {\n decl.parsed = true;\n }\n if (result) {\n decl.value = result[0];\n decl.important = result[1] || '';\n decl.parsed = true;\n }\n });\n } else {\n decl.parsed = true;\n }\n\n return decl;\n }\n else {\n return decl;\n }\n }\n if (!Array.isArray(toParse)) {\n return transformDeclaration.call(self, toParse);\n }\n else {\n const nodes = [];\n toParse.forEach(n => {\n nodes.push(transformDeclaration.call(self, n));\n });\n return nodes;\n }\n }\n\n rulesets() {\n if (!this.rules) { return []; }\n\n const filtRules = [];\n const rules = this.rules;\n let i;\n let rule;\n\n for (i = 0; (rule = rules[i]); i++) {\n if (rule.isRuleset) {\n filtRules.push(rule);\n }\n }\n\n return filtRules;\n }\n\n prependRule(rule) {\n const rules = this.rules;\n if (rules) {\n rules.unshift(rule);\n } else {\n this.rules = [ rule ];\n }\n this.setParent(rule, this);\n }\n\n find(selector, self = this, filter) {\n const rules = [];\n let match;\n let foundMixins;\n const key = selector.toCSS();\n\n if (key in this._lookups) { return this._lookups[key]; }\n\n this.rulesets().forEach(rule => {\n if (rule !== self) {\n for (let j = 0; j < rule.selectors.length; j++) {\n match = selector.match(rule.selectors[j]);\n if (match) {\n if (selector.elements.length > match) {\n if (!filter || filter(rule)) {\n foundMixins = rule.find(new Selector(selector.elements.slice(match)), self, filter);\n for (let i = 0; i < foundMixins.length; ++i) {\n foundMixins[i].path.push(rule);\n }\n Array.prototype.push.apply(rules, foundMixins);\n }\n } else {\n rules.push({ rule, path: []});\n }\n break;\n }\n }\n }\n });\n this._lookups[key] = rules;\n return rules;\n }\n\n genCSS(context, output) {\n let i;\n let j;\n const charsetRuleNodes = [];\n let ruleNodes = [];\n\n let // Line number debugging\n debugInfo;\n\n let rule;\n let path;\n\n context.tabLevel = (context.tabLevel || 0);\n\n if (!this.root) {\n context.tabLevel++;\n }\n\n const tabRuleStr = context.compress ? '' : Array(context.tabLevel + 1).join(' ');\n const tabSetStr = context.compress ? '' : Array(context.tabLevel).join(' ');\n let sep;\n\n let charsetNodeIndex = 0;\n let importNodeIndex = 0;\n for (i = 0; (rule = this.rules[i]); i++) {\n if (rule instanceof Comment) {\n if (importNodeIndex === i) {\n importNodeIndex++;\n }\n ruleNodes.push(rule);\n } else if (rule.isCharset && rule.isCharset()) {\n ruleNodes.splice(charsetNodeIndex, 0, rule);\n charsetNodeIndex++;\n importNodeIndex++;\n } else if (rule.type === 'Import') {\n ruleNodes.splice(importNodeIndex, 0, rule);\n importNodeIndex++;\n } else {\n ruleNodes.push(rule);\n }\n }\n ruleNodes = charsetRuleNodes.concat(ruleNodes);\n\n // If this is the root node, we don't render\n // a selector, or {}.\n if (!this.root) {\n debugInfo = getDebugInfo(context, this, tabSetStr);\n\n if (debugInfo) {\n output.add(debugInfo);\n output.add(tabSetStr);\n }\n\n const paths = this.paths;\n const pathCnt = paths.length;\n let pathSubCnt;\n\n sep = context.compress ? ',' : (`,\\n${tabSetStr}`);\n\n for (i = 0; i < pathCnt; i++) {\n path = paths[i];\n if (!(pathSubCnt = path.length)) { continue; }\n if (i > 0) { output.add(sep); }\n\n context.firstSelector = true;\n path[0].genCSS(context, output);\n\n context.firstSelector = false;\n for (j = 1; j < pathSubCnt; j++) {\n path[j].genCSS(context, output);\n }\n }\n\n output.add((context.compress ? '{' : ' {\\n') + tabRuleStr);\n }\n\n // Compile rules and rulesets\n for (i = 0; (rule = ruleNodes[i]); i++) {\n\n if (i + 1 === ruleNodes.length) {\n context.lastRule = true;\n }\n\n const currentLastRule = context.lastRule;\n if (rule.isRulesetLike(rule)) {\n context.lastRule = false;\n }\n\n if (rule.genCSS) {\n rule.genCSS(context, output);\n } else if (rule.value) {\n output.add(rule.value.toString());\n }\n\n context.lastRule = currentLastRule;\n\n if (!context.lastRule && rule.isVisible()) {\n output.add(context.compress ? '' : (`\\n${tabRuleStr}`));\n } else {\n context.lastRule = false;\n }\n }\n\n if (!this.root) {\n output.add((context.compress ? '}' : `\\n${tabSetStr}}`));\n context.tabLevel--;\n }\n\n if (!output.isEmpty() && !context.compress && this.firstRoot) {\n output.add('\\n');\n }\n }\n\n joinSelectors(paths, context, selectors) {\n for (let s = 0; s < selectors.length; s++) {\n this.joinSelector(paths, context, selectors[s]);\n }\n }\n\n joinSelector(paths, context, selector) {\n function createParenthesis(elementsToPak, originalElement) {\n let replacementParen;\n let j;\n if (elementsToPak.length === 0) {\n replacementParen = new Paren(elementsToPak[0]);\n } else {\n const insideParent = new Array(elementsToPak.length);\n for (j = 0; j < elementsToPak.length; j++) {\n insideParent[j] = new Element(\n null,\n elementsToPak[j],\n originalElement.isVariable,\n originalElement._index,\n originalElement._fileInfo\n );\n }\n replacementParen = new Paren(new Selector(insideParent));\n }\n return replacementParen;\n }\n\n function createSelector(containedElement, originalElement) {\n let element;\n let selector;\n element = new Element(null, containedElement, originalElement.isVariable, originalElement._index, originalElement._fileInfo);\n selector = new Selector([element]);\n return selector;\n }\n\n // joins selector path from `beginningPath` with selector path in `addPath`\n // `replacedElement` contains element that is being replaced by `addPath`\n // returns concatenated path\n function addReplacementIntoPath(beginningPath, addPath, replacedElement, originalSelector) {\n let newSelectorPath;\n let lastSelector;\n let newJoinedSelector;\n // our new selector path\n newSelectorPath = [];\n\n // construct the joined selector - if & is the first thing this will be empty,\n // if not newJoinedSelector will be the last set of elements in the selector\n if (beginningPath.length > 0) {\n newSelectorPath = utils.copyArray(beginningPath);\n lastSelector = newSelectorPath.pop();\n newJoinedSelector = originalSelector.createDerived(utils.copyArray(lastSelector.elements));\n }\n else {\n newJoinedSelector = originalSelector.createDerived([]);\n }\n\n if (addPath.length > 0) {\n // /deep/ is a CSS4 selector - (removed, so should deprecate)\n // that is valid without anything in front of it\n // so if the & does not have a combinator that is \"\" or \" \" then\n // and there is a combinator on the parent, then grab that.\n // this also allows + a { & .b { .a & { ... though not sure why you would want to do that\n let combinator = replacedElement.combinator;\n\n const parentEl = addPath[0].elements[0];\n if (combinator.emptyOrWhitespace && !parentEl.combinator.emptyOrWhitespace) {\n combinator = parentEl.combinator;\n }\n // join the elements so far with the first part of the parent\n newJoinedSelector.elements.push(new Element(\n combinator,\n parentEl.value,\n replacedElement.isVariable,\n replacedElement._index,\n replacedElement._fileInfo\n ));\n newJoinedSelector.elements = newJoinedSelector.elements.concat(addPath[0].elements.slice(1));\n }\n\n // now add the joined selector - but only if it is not empty\n if (newJoinedSelector.elements.length !== 0) {\n newSelectorPath.push(newJoinedSelector);\n }\n\n // put together the parent selectors after the join (e.g. the rest of the parent)\n if (addPath.length > 1) {\n let restOfPath = addPath.slice(1);\n restOfPath = restOfPath.map(selector => selector.createDerived(selector.elements, []));\n newSelectorPath = newSelectorPath.concat(restOfPath);\n }\n return newSelectorPath;\n }\n\n // joins selector path from `beginningPath` with every selector path in `addPaths` array\n // `replacedElement` contains element that is being replaced by `addPath`\n // returns array with all concatenated paths\n function addAllReplacementsIntoPath( beginningPath, addPaths, replacedElement, originalSelector, result) {\n let j;\n for (j = 0; j < beginningPath.length; j++) {\n const newSelectorPath = addReplacementIntoPath(beginningPath[j], addPaths, replacedElement, originalSelector);\n result.push(newSelectorPath);\n }\n return result;\n }\n\n function mergeElementsOnToSelectors(elements, selectors) {\n let i;\n let sel;\n\n if (elements.length === 0) {\n return ;\n }\n if (selectors.length === 0) {\n selectors.push([ new Selector(elements) ]);\n return;\n }\n\n for (i = 0; (sel = selectors[i]); i++) {\n // if the previous thing in sel is a parent this needs to join on to it\n if (sel.length > 0) {\n sel[sel.length - 1] = sel[sel.length - 1].createDerived(sel[sel.length - 1].elements.concat(elements));\n }\n else {\n sel.push(new Selector(elements));\n }\n }\n }\n\n // replace all parent selectors inside `inSelector` by content of `context` array\n // resulting selectors are returned inside `paths` array\n // returns true if `inSelector` contained at least one parent selector\n function replaceParentSelector(paths, context, inSelector) {\n // The paths are [[Selector]]\n // The first list is a list of comma separated selectors\n // The inner list is a list of inheritance separated selectors\n // e.g.\n // .a, .b {\n // .c {\n // }\n // }\n // == [[.a] [.c]] [[.b] [.c]]\n //\n let i;\n\n let j;\n let k;\n let currentElements;\n let newSelectors;\n let selectorsMultiplied;\n let sel;\n let el;\n let hadParentSelector = false;\n let length;\n let lastSelector;\n function findNestedSelector(element) {\n let maybeSelector;\n if (!(element.value instanceof Paren)) {\n return null;\n }\n\n maybeSelector = element.value.value;\n if (!(maybeSelector instanceof Selector)) {\n return null;\n }\n\n return maybeSelector;\n }\n\n // the elements from the current selector so far\n currentElements = [];\n // the current list of new selectors to add to the path.\n // We will build it up. We initiate it with one empty selector as we \"multiply\" the new selectors\n // by the parents\n newSelectors = [\n []\n ];\n\n for (i = 0; (el = inSelector.elements[i]); i++) {\n // non parent reference elements just get added\n if (el.value !== '&') {\n const nestedSelector = findNestedSelector(el);\n if (nestedSelector != null) {\n // merge the current list of non parent selector elements\n // on to the current list of selectors to add\n mergeElementsOnToSelectors(currentElements, newSelectors);\n\n const nestedPaths = [];\n let replaced;\n const replacedNewSelectors = [];\n replaced = replaceParentSelector(nestedPaths, context, nestedSelector);\n hadParentSelector = hadParentSelector || replaced;\n // the nestedPaths array should have only one member - replaceParentSelector does not multiply selectors\n for (k = 0; k < nestedPaths.length; k++) {\n const replacementSelector = createSelector(createParenthesis(nestedPaths[k], el), el);\n addAllReplacementsIntoPath(newSelectors, [replacementSelector], el, inSelector, replacedNewSelectors);\n }\n newSelectors = replacedNewSelectors;\n currentElements = [];\n } else {\n currentElements.push(el);\n }\n\n } else {\n hadParentSelector = true;\n // the new list of selectors to add\n selectorsMultiplied = [];\n\n // merge the current list of non parent selector elements\n // on to the current list of selectors to add\n mergeElementsOnToSelectors(currentElements, newSelectors);\n\n // loop through our current selectors\n for (j = 0; j < newSelectors.length; j++) {\n sel = newSelectors[j];\n // if we don't have any parent paths, the & might be in a mixin so that it can be used\n // whether there are parents or not\n if (context.length === 0) {\n // the combinator used on el should now be applied to the next element instead so that\n // it is not lost\n if (sel.length > 0) {\n sel[0].elements.push(new Element(el.combinator, '', el.isVariable, el._index, el._fileInfo));\n }\n selectorsMultiplied.push(sel);\n }\n else {\n // and the parent selectors\n for (k = 0; k < context.length; k++) {\n // We need to put the current selectors\n // then join the last selector's elements on to the parents selectors\n const newSelectorPath = addReplacementIntoPath(sel, context[k], el, inSelector);\n // add that to our new set of selectors\n selectorsMultiplied.push(newSelectorPath);\n }\n }\n }\n\n // our new selectors has been multiplied, so reset the state\n newSelectors = selectorsMultiplied;\n currentElements = [];\n }\n }\n\n // if we have any elements left over (e.g. .a& .b == .b)\n // add them on to all the current selectors\n mergeElementsOnToSelectors(currentElements, newSelectors);\n\n for (i = 0; i < newSelectors.length; i++) {\n length = newSelectors[i].length;\n if (length > 0) {\n paths.push(newSelectors[i]);\n lastSelector = newSelectors[i][length - 1];\n newSelectors[i][length - 1] = lastSelector.createDerived(lastSelector.elements, inSelector.extendList);\n }\n }\n\n return hadParentSelector;\n }\n\n function deriveSelector(visibilityInfo, deriveFrom) {\n const newSelector = deriveFrom.createDerived(deriveFrom.elements, deriveFrom.extendList, deriveFrom.evaldCondition);\n newSelector.copyVisibilityInfo(visibilityInfo);\n return newSelector;\n }\n\n // joinSelector code follows\n let i;\n\n let newPaths;\n let hadParentSelector;\n\n newPaths = [];\n hadParentSelector = replaceParentSelector(newPaths, context, selector);\n\n if (!hadParentSelector) {\n if (context.length > 0) {\n newPaths = [];\n for (i = 0; i < context.length; i++) {\n\n const concatenated = context[i].map(deriveSelector.bind(this, selector.visibilityInfo()));\n\n concatenated.push(selector);\n newPaths.push(concatenated);\n }\n }\n else {\n newPaths = [[selector]];\n }\n }\n\n for (i = 0; i < newPaths.length; i++) {\n paths.push(newPaths[i]);\n }\n }\n}\n\nRuleset.prototype.type = 'Ruleset';\nRuleset.prototype.isRuleset = true;\nexport default Ruleset;\n","import Node from './node';\nimport Selector from './selector';\nimport Ruleset from './ruleset';\nimport Anonymous from './anonymous';\n\nclass AtRule extends Node {\n constructor(\n name,\n value,\n rules,\n index,\n currentFileInfo,\n debugInfo,\n isRooted,\n visibilityInfo\n ) {\n super();\n\n let i;\n\n this.name = name;\n this.value = (value instanceof Node) ? value : (value ? new Anonymous(value) : value);\n if (rules) {\n if (Array.isArray(rules)) {\n this.rules = rules;\n } else {\n this.rules = [rules];\n this.rules[0].selectors = (new Selector([], null, null, index, currentFileInfo)).createEmptySelectors();\n }\n for (i = 0; i < this.rules.length; i++) {\n this.rules[i].allowImports = true;\n }\n this.setParent(this.rules, this);\n }\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.debugInfo = debugInfo;\n this.isRooted = isRooted || false;\n this.copyVisibilityInfo(visibilityInfo);\n this.allowRoot = true;\n }\n\n accept(visitor) {\n const value = this.value;\n const rules = this.rules;\n if (rules) {\n this.rules = visitor.visitArray(rules);\n }\n if (value) {\n this.value = visitor.visit(value);\n }\n }\n\n isRulesetLike() {\n return this.rules || !this.isCharset();\n }\n\n isCharset() {\n return '@charset' === this.name;\n }\n\n genCSS(context, output) {\n const value = this.value;\n const rules = this.rules;\n output.add(this.name, this.fileInfo(), this.getIndex());\n if (value) {\n output.add(' ');\n value.genCSS(context, output);\n }\n if (rules) {\n this.outputRuleset(context, output, rules);\n } else {\n output.add(';');\n }\n }\n\n eval(context) {\n let mediaPathBackup;\n let mediaBlocksBackup;\n let value = this.value;\n let rules = this.rules;\n\n // media stored inside other atrule should not bubble over it\n // backpup media bubbling information\n mediaPathBackup = context.mediaPath;\n mediaBlocksBackup = context.mediaBlocks;\n // deleted media bubbling information\n context.mediaPath = [];\n context.mediaBlocks = [];\n\n if (value) {\n value = value.eval(context);\n }\n if (rules) {\n // assuming that there is only one rule at this point - that is how parser constructs the rule\n rules = [rules[0].eval(context)];\n rules[0].root = true;\n }\n // restore media bubbling information\n context.mediaPath = mediaPathBackup;\n context.mediaBlocks = mediaBlocksBackup;\n\n return new AtRule(this.name, value, rules,\n this.getIndex(), this.fileInfo(), this.debugInfo, this.isRooted, this.visibilityInfo());\n }\n\n variable(name) {\n if (this.rules) {\n // assuming that there is only one rule at this point - that is how parser constructs the rule\n return Ruleset.prototype.variable.call(this.rules[0], name);\n }\n }\n\n find(...args) {\n if (this.rules) {\n // assuming that there is only one rule at this point - that is how parser constructs the rule\n return Ruleset.prototype.find.apply(this.rules[0], args);\n }\n }\n\n rulesets() {\n if (this.rules) {\n // assuming that there is only one rule at this point - that is how parser constructs the rule\n return Ruleset.prototype.rulesets.apply(this.rules[0]);\n }\n }\n\n outputRuleset(context, output, rules) {\n const ruleCnt = rules.length;\n let i;\n context.tabLevel = (context.tabLevel | 0) + 1;\n\n // Compressed\n if (context.compress) {\n output.add('{');\n for (i = 0; i < ruleCnt; i++) {\n rules[i].genCSS(context, output);\n }\n output.add('}');\n context.tabLevel--;\n return;\n }\n\n // Non-compressed\n const tabSetStr = `\\n${Array(context.tabLevel).join(' ')}`;\n\n const tabRuleStr = `${tabSetStr} `;\n if (!ruleCnt) {\n output.add(` {${tabSetStr}}`);\n } else {\n output.add(` {${tabRuleStr}`);\n rules[0].genCSS(context, output);\n for (i = 1; i < ruleCnt; i++) {\n output.add(tabRuleStr);\n rules[i].genCSS(context, output);\n }\n output.add(`${tabSetStr}}`);\n }\n\n context.tabLevel--;\n }\n}\n\nAtRule.prototype.type = 'AtRule';\nexport default AtRule;\n","import Node from './node';\nimport contexts from '../contexts';\nimport * as utils from '../utils';\n\nclass DetachedRuleset extends Node {\n constructor(ruleset, frames) {\n super();\n\n this.ruleset = ruleset;\n this.frames = frames;\n this.setParent(this.ruleset, this);\n }\n\n accept(visitor) {\n this.ruleset = visitor.visit(this.ruleset);\n }\n\n eval(context) {\n const frames = this.frames || utils.copyArray(context.frames);\n return new DetachedRuleset(this.ruleset, frames);\n }\n\n callEval(context) {\n return this.ruleset.eval(this.frames ? new contexts.Eval(context, this.frames.concat(context.frames)) : context);\n }\n}\n\nDetachedRuleset.prototype.type = 'DetachedRuleset';\nDetachedRuleset.prototype.evalFirst = true;\nexport default DetachedRuleset;\n","import Node from './node';\nimport unitConversions from '../data/unit-conversions';\nimport * as utils from '../utils';\n\nclass Unit extends Node {\n constructor(numerator, denominator, backupUnit) {\n super();\n\n this.numerator = numerator ? utils.copyArray(numerator).sort() : [];\n this.denominator = denominator ? utils.copyArray(denominator).sort() : [];\n if (backupUnit) {\n this.backupUnit = backupUnit;\n } else if (numerator && numerator.length) {\n this.backupUnit = numerator[0];\n }\n }\n\n clone() {\n return new Unit(utils.copyArray(this.numerator), utils.copyArray(this.denominator), this.backupUnit);\n }\n\n genCSS(context, output) {\n // Dimension checks the unit is singular and throws an error if in strict math mode.\n const strictUnits = context && context.strictUnits;\n if (this.numerator.length === 1) {\n output.add(this.numerator[0]); // the ideal situation\n } else if (!strictUnits && this.backupUnit) {\n output.add(this.backupUnit);\n } else if (!strictUnits && this.denominator.length) {\n output.add(this.denominator[0]);\n }\n }\n\n toString() {\n let i;\n let returnStr = this.numerator.join('*');\n for (i = 0; i < this.denominator.length; i++) {\n returnStr += `/${this.denominator[i]}`;\n }\n return returnStr;\n }\n\n compare(other) {\n return this.is(other.toString()) ? 0 : undefined;\n }\n\n is(unitString) {\n return this.toString().toUpperCase() === unitString.toUpperCase();\n }\n\n isLength() {\n return RegExp('^(px|em|ex|ch|rem|in|cm|mm|pc|pt|ex|vw|vh|vmin|vmax)$', 'gi').test(this.toCSS());\n }\n\n isEmpty() {\n return this.numerator.length === 0 && this.denominator.length === 0;\n }\n\n isSingular() {\n return this.numerator.length <= 1 && this.denominator.length === 0;\n }\n\n map(callback) {\n let i;\n\n for (i = 0; i < this.numerator.length; i++) {\n this.numerator[i] = callback(this.numerator[i], false);\n }\n\n for (i = 0; i < this.denominator.length; i++) {\n this.denominator[i] = callback(this.denominator[i], true);\n }\n }\n\n usedUnits() {\n let group;\n const result = {};\n let mapUnit;\n let groupName;\n\n mapUnit = atomicUnit => {\n /* jshint loopfunc:true */\n if (group.hasOwnProperty(atomicUnit) && !result[groupName]) {\n result[groupName] = atomicUnit;\n }\n\n return atomicUnit;\n };\n\n for (groupName in unitConversions) {\n if (unitConversions.hasOwnProperty(groupName)) {\n group = unitConversions[groupName];\n\n this.map(mapUnit);\n }\n }\n\n return result;\n }\n\n cancel() {\n const counter = {};\n let atomicUnit;\n let i;\n\n for (i = 0; i < this.numerator.length; i++) {\n atomicUnit = this.numerator[i];\n counter[atomicUnit] = (counter[atomicUnit] || 0) + 1;\n }\n\n for (i = 0; i < this.denominator.length; i++) {\n atomicUnit = this.denominator[i];\n counter[atomicUnit] = (counter[atomicUnit] || 0) - 1;\n }\n\n this.numerator = [];\n this.denominator = [];\n\n for (atomicUnit in counter) {\n if (counter.hasOwnProperty(atomicUnit)) {\n const count = counter[atomicUnit];\n\n if (count > 0) {\n for (i = 0; i < count; i++) {\n this.numerator.push(atomicUnit);\n }\n } else if (count < 0) {\n for (i = 0; i < -count; i++) {\n this.denominator.push(atomicUnit);\n }\n }\n }\n }\n\n this.numerator.sort();\n this.denominator.sort();\n }\n}\n\nUnit.prototype.type = 'Unit';\nexport default Unit;\n","import Node from './node';\nimport unitConversions from '../data/unit-conversions';\nimport Unit from './unit';\nimport Color from './color';\n\n//\n// A number with a unit\n//\nclass Dimension extends Node {\n constructor(value, unit) {\n super();\n\n this.value = parseFloat(value);\n if (isNaN(this.value)) {\n throw new Error('Dimension is not a number.');\n }\n this.unit = (unit && unit instanceof Unit) ? unit :\n new Unit(unit ? [unit] : undefined);\n this.setParent(this.unit, this);\n }\n\n accept(visitor) {\n this.unit = visitor.visit(this.unit);\n }\n\n eval(context) {\n return this;\n }\n\n toColor() {\n return new Color([this.value, this.value, this.value]);\n }\n\n genCSS(context, output) {\n if ((context && context.strictUnits) && !this.unit.isSingular()) {\n throw new Error(`Multiple units in dimension. Correct the units or use the unit function. Bad unit: ${this.unit.toString()}`);\n }\n\n const value = this.fround(context, this.value);\n let strValue = String(value);\n\n if (value !== 0 && value < 0.000001 && value > -0.000001) {\n // would be output 1e-6 etc.\n strValue = value.toFixed(20).replace(/0+$/, '');\n }\n\n if (context && context.compress) {\n // Zero values doesn't need a unit\n if (value === 0 && this.unit.isLength()) {\n output.add(strValue);\n return;\n }\n\n // Float values doesn't need a leading zero\n if (value > 0 && value < 1) {\n strValue = (strValue).substr(1);\n }\n }\n\n output.add(strValue);\n this.unit.genCSS(context, output);\n }\n\n // In an operation between two Dimensions,\n // we default to the first Dimension's unit,\n // so `1px + 2` will yield `3px`.\n operate(context, op, other) {\n /* jshint noempty:false */\n let value = this._operate(context, op, this.value, other.value);\n\n let unit = this.unit.clone();\n\n if (op === '+' || op === '-') {\n if (unit.numerator.length === 0 && unit.denominator.length === 0) {\n unit = other.unit.clone();\n if (this.unit.backupUnit) {\n unit.backupUnit = this.unit.backupUnit;\n }\n } else if (other.unit.numerator.length === 0 && unit.denominator.length === 0) {\n // do nothing\n } else {\n other = other.convertTo(this.unit.usedUnits());\n\n if (context.strictUnits && other.unit.toString() !== unit.toString()) {\n throw new Error(`Incompatible units. Change the units or use the unit function. ` + \n `Bad units: '${unit.toString()}' and '${other.unit.toString()}'.`);\n }\n\n value = this._operate(context, op, this.value, other.value);\n }\n } else if (op === '*') {\n unit.numerator = unit.numerator.concat(other.unit.numerator).sort();\n unit.denominator = unit.denominator.concat(other.unit.denominator).sort();\n unit.cancel();\n } else if (op === '/') {\n unit.numerator = unit.numerator.concat(other.unit.denominator).sort();\n unit.denominator = unit.denominator.concat(other.unit.numerator).sort();\n unit.cancel();\n }\n return new Dimension(value, unit);\n }\n\n compare(other) {\n let a;\n let b;\n\n if (!(other instanceof Dimension)) {\n return undefined;\n }\n\n if (this.unit.isEmpty() || other.unit.isEmpty()) {\n a = this;\n b = other;\n } else {\n a = this.unify();\n b = other.unify();\n if (a.unit.compare(b.unit) !== 0) {\n return undefined;\n }\n }\n\n return Node.numericCompare(a.value, b.value);\n }\n\n unify() {\n return this.convertTo({ length: 'px', duration: 's', angle: 'rad' });\n }\n\n convertTo(conversions) {\n let value = this.value;\n const unit = this.unit.clone();\n let i;\n let groupName;\n let group;\n let targetUnit;\n let derivedConversions = {};\n let applyUnit;\n\n if (typeof conversions === 'string') {\n for (i in unitConversions) {\n if (unitConversions[i].hasOwnProperty(conversions)) {\n derivedConversions = {};\n derivedConversions[i] = conversions;\n }\n }\n conversions = derivedConversions;\n }\n applyUnit = (atomicUnit, denominator) => {\n /* jshint loopfunc:true */\n if (group.hasOwnProperty(atomicUnit)) {\n if (denominator) {\n value = value / (group[atomicUnit] / group[targetUnit]);\n } else {\n value = value * (group[atomicUnit] / group[targetUnit]);\n }\n\n return targetUnit;\n }\n\n return atomicUnit;\n };\n\n for (groupName in conversions) {\n if (conversions.hasOwnProperty(groupName)) {\n targetUnit = conversions[groupName];\n group = unitConversions[groupName];\n\n unit.map(applyUnit);\n }\n }\n\n unit.cancel();\n\n return new Dimension(value, unit);\n }\n}\n\nDimension.prototype.type = 'Dimension';\nexport default Dimension;\n","import Node from './node';\nimport Color from './color';\nimport Dimension from './dimension';\nimport * as Constants from '../constants';\nconst MATH = Constants.Math;\n\n\nclass Operation extends Node {\n constructor(op, operands, isSpaced) {\n super();\n\n this.op = op.trim();\n this.operands = operands;\n this.isSpaced = isSpaced;\n }\n\n accept(visitor) {\n this.operands = visitor.visitArray(this.operands);\n }\n\n eval(context) {\n let a = this.operands[0].eval(context);\n let b = this.operands[1].eval(context);\n let op;\n\n if (context.isMathOn(this.op)) {\n op = this.op === './' ? '/' : this.op;\n if (a instanceof Dimension && b instanceof Color) {\n a = a.toColor();\n }\n if (b instanceof Dimension && a instanceof Color) {\n b = b.toColor();\n }\n if (!a.operate) {\n if (a instanceof Operation && a.op === '/' && context.math === MATH.PARENS_DIVISION) {\n return new Operation(this.op, [a, b], this.isSpaced);\n }\n throw { type: 'Operation',\n message: 'Operation on an invalid type' };\n }\n\n return a.operate(context, op, b);\n } else {\n return new Operation(this.op, [a, b], this.isSpaced);\n }\n }\n\n genCSS(context, output) {\n this.operands[0].genCSS(context, output);\n if (this.isSpaced) {\n output.add(' ');\n }\n output.add(this.op);\n if (this.isSpaced) {\n output.add(' ');\n }\n this.operands[1].genCSS(context, output);\n }\n}\n\nOperation.prototype.type = 'Operation';\nexport default Operation;\n","import Node from './node';\nimport Paren from './paren';\nimport Comment from './comment';\nimport Dimension from './dimension';\nimport * as Constants from '../constants';\nconst MATH = Constants.Math;\n\nclass Expression extends Node {\n constructor(value, noSpacing) {\n super();\n\n this.value = value;\n this.noSpacing = noSpacing;\n if (!value) {\n throw new Error('Expression requires an array parameter');\n }\n }\n\n accept(visitor) {\n this.value = visitor.visitArray(this.value);\n }\n\n eval(context) {\n let returnValue;\n const mathOn = context.isMathOn();\n\n const inParenthesis = this.parens && \n (context.math !== MATH.STRICT_LEGACY || !this.parensInOp);\n\n let doubleParen = false;\n if (inParenthesis) {\n context.inParenthesis();\n }\n if (this.value.length > 1) {\n returnValue = new Expression(this.value.map(e => {\n if (!e.eval) {\n return e;\n }\n return e.eval(context);\n }), this.noSpacing);\n } else if (this.value.length === 1) {\n if (this.value[0].parens && !this.value[0].parensInOp && !context.inCalc) {\n doubleParen = true;\n }\n returnValue = this.value[0].eval(context);\n } else {\n returnValue = this;\n }\n if (inParenthesis) {\n context.outOfParenthesis();\n }\n if (this.parens && this.parensInOp && !mathOn && !doubleParen \n && (!(returnValue instanceof Dimension))) {\n returnValue = new Paren(returnValue);\n }\n return returnValue;\n }\n\n genCSS(context, output) {\n for (let i = 0; i < this.value.length; i++) {\n this.value[i].genCSS(context, output);\n if (!this.noSpacing && i + 1 < this.value.length) {\n output.add(' ');\n }\n }\n }\n\n throwAwayComments() {\n this.value = this.value.filter(v => !(v instanceof Comment));\n }\n}\n\nExpression.prototype.type = 'Expression';\nexport default Expression;\n","import Expression from '../tree/expression';\n\nclass functionCaller {\n constructor(name, context, index, currentFileInfo) {\n this.name = name.toLowerCase();\n this.index = index;\n this.context = context;\n this.currentFileInfo = currentFileInfo;\n\n this.func = context.frames[0].functionRegistry.get(this.name);\n }\n\n isValid() {\n return Boolean(this.func);\n }\n\n call(args) {\n // This code is terrible and should be replaced as per this issue...\n // https://github.com/less/less.js/issues/2477\n if (Array.isArray(args)) {\n args = args.filter(item => {\n if (item.type === 'Comment') {\n return false;\n }\n return true;\n })\n .map(item => {\n if (item.type === 'Expression') {\n const subNodes = item.value.filter(item => {\n if (item.type === 'Comment') {\n return false;\n }\n return true;\n });\n if (subNodes.length === 1) {\n return subNodes[0];\n } else {\n return new Expression(subNodes);\n }\n }\n return item;\n });\n }\n\n return this.func(...args);\n }\n}\n\nexport default functionCaller;\n","import Node from './node';\nimport Anonymous from './anonymous';\nimport FunctionCaller from '../functions/function-caller';\n\n//\n// A function call node.\n//\nclass Call extends Node {\n constructor(name, args, index, currentFileInfo) {\n super();\n\n this.name = name;\n this.args = args;\n this.calc = name === 'calc';\n this._index = index;\n this._fileInfo = currentFileInfo;\n }\n\n accept(visitor) {\n if (this.args) {\n this.args = visitor.visitArray(this.args);\n }\n }\n\n //\n // When evaluating a function call,\n // we either find the function in the functionRegistry,\n // in which case we call it, passing the evaluated arguments,\n // if this returns null or we cannot find the function, we\n // simply print it out as it appeared originally [2].\n //\n // The reason why we evaluate the arguments, is in the case where\n // we try to pass a variable to a function, like: `saturate(@color)`.\n // The function should receive the value, not the variable.\n //\n eval(context) {\n /**\n * Turn off math for calc(), and switch back on for evaluating nested functions\n */\n const currentMathContext = context.mathOn;\n context.mathOn = !this.calc;\n if (this.calc || context.inCalc) {\n context.enterCalc();\n }\n const args = this.args.map(a => a.eval(context));\n if (this.calc || context.inCalc) {\n context.exitCalc();\n }\n context.mathOn = currentMathContext;\n\n let result;\n const funcCaller = new FunctionCaller(this.name, context, this.getIndex(), this.fileInfo());\n\n if (funcCaller.isValid()) {\n try {\n result = funcCaller.call(args);\n } catch (e) {\n throw { \n type: e.type || 'Runtime',\n message: `error evaluating function \\`${this.name}\\`${e.message ? `: ${e.message}` : ''}`,\n index: this.getIndex(), \n filename: this.fileInfo().filename,\n line: e.lineNumber,\n column: e.columnNumber\n };\n }\n\n if (result !== null && result !== undefined) {\n // Results that that are not nodes are cast as Anonymous nodes\n // Falsy values or booleans are returned as empty nodes\n if (!(result instanceof Node)) {\n if (!result || result === true) {\n result = new Anonymous(null); \n }\n else {\n result = new Anonymous(result.toString()); \n }\n \n }\n result._index = this._index;\n result._fileInfo = this._fileInfo;\n return result;\n }\n\n }\n\n return new Call(this.name, args, this.getIndex(), this.fileInfo());\n }\n\n genCSS(context, output) {\n output.add(`${this.name}(`, this.fileInfo(), this.getIndex());\n\n for (let i = 0; i < this.args.length; i++) {\n this.args[i].genCSS(context, output);\n if (i + 1 < this.args.length) {\n output.add(', ');\n }\n }\n\n output.add(')');\n }\n}\n\nCall.prototype.type = 'Call';\nexport default Call;\n","import Node from './node';\nimport Call from './call';\n\nclass Variable extends Node {\n constructor(name, index, currentFileInfo) {\n super();\n\n this.name = name;\n this._index = index;\n this._fileInfo = currentFileInfo;\n }\n\n eval(context) {\n let variable;\n let name = this.name;\n\n if (name.indexOf('@@') === 0) {\n name = `@${new Variable(name.slice(1), this.getIndex(), this.fileInfo()).eval(context).value}`;\n }\n\n if (this.evaluating) {\n throw { type: 'Name',\n message: `Recursive variable definition for ${name}`,\n filename: this.fileInfo().filename,\n index: this.getIndex() };\n }\n\n this.evaluating = true;\n\n variable = this.find(context.frames, frame => {\n const v = frame.variable(name);\n if (v) {\n if (v.important) {\n const importantScope = context.importantScope[context.importantScope.length - 1];\n importantScope.important = v.important;\n }\n // If in calc, wrap vars in a function call to cascade evaluate args first\n if (context.inCalc) {\n return (new Call('_SELF', [v.value])).eval(context);\n }\n else {\n return v.value.eval(context);\n }\n }\n });\n if (variable) {\n this.evaluating = false;\n return variable;\n } else {\n throw { type: 'Name',\n message: `variable ${name} is undefined`,\n filename: this.fileInfo().filename,\n index: this.getIndex() };\n }\n }\n\n find(obj, fun) {\n for (let i = 0, r; i < obj.length; i++) {\n r = fun.call(obj, obj[i]);\n if (r) { return r; }\n }\n return null;\n }\n}\n\nVariable.prototype.type = 'Variable';\nexport default Variable;\n","import Node from './node';\nimport Declaration from './declaration';\n\nclass Property extends Node {\n constructor(name, index, currentFileInfo) {\n super();\n\n this.name = name;\n this._index = index;\n this._fileInfo = currentFileInfo;\n }\n\n eval(context) {\n let property;\n const name = this.name;\n // TODO: shorten this reference\n const mergeRules = context.pluginManager.less.visitors.ToCSSVisitor.prototype._mergeRules;\n\n if (this.evaluating) {\n throw { type: 'Name',\n message: `Recursive property reference for ${name}`,\n filename: this.fileInfo().filename,\n index: this.getIndex() };\n }\n\n this.evaluating = true;\n\n property = this.find(context.frames, frame => {\n let v;\n const vArr = frame.property(name);\n if (vArr) {\n for (let i = 0; i < vArr.length; i++) {\n v = vArr[i];\n\n vArr[i] = new Declaration(v.name,\n v.value,\n v.important,\n v.merge,\n v.index,\n v.currentFileInfo,\n v.inline,\n v.variable\n );\n }\n mergeRules(vArr);\n\n v = vArr[vArr.length - 1];\n if (v.important) {\n const importantScope = context.importantScope[context.importantScope.length - 1];\n importantScope.important = v.important;\n }\n v = v.value.eval(context);\n return v;\n }\n });\n if (property) {\n this.evaluating = false;\n return property;\n } else {\n throw { type: 'Name',\n message: `Property '${name}' is undefined`,\n filename: this.currentFileInfo.filename,\n index: this.index };\n }\n }\n\n find(obj, fun) {\n for (let i = 0, r; i < obj.length; i++) {\n r = fun.call(obj, obj[i]);\n if (r) { return r; }\n }\n return null;\n }\n}\n\nProperty.prototype.type = 'Property';\nexport default Property;\n","import Node from './node';\n\nclass Attribute extends Node {\n constructor(key, op, value) {\n super();\n\n this.key = key;\n this.op = op;\n this.value = value;\n }\n\n eval(context) {\n return new Attribute(this.key.eval ? this.key.eval(context) : this.key,\n this.op, (this.value && this.value.eval) ? this.value.eval(context) : this.value);\n }\n\n genCSS(context, output) {\n output.add(this.toCSS(context));\n }\n\n toCSS(context) {\n let value = this.key.toCSS ? this.key.toCSS(context) : this.key;\n\n if (this.op) {\n value += this.op;\n value += (this.value.toCSS ? this.value.toCSS(context) : this.value);\n }\n\n return `[${value}]`;\n }\n}\n\nAttribute.prototype.type = 'Attribute';\nexport default Attribute;\n","import Node from './node';\nimport Variable from './variable';\nimport Property from './property';\n\n\nclass Quoted extends Node {\n constructor(str, content, escaped, index, currentFileInfo) {\n super();\n\n this.escaped = (escaped == null) ? true : escaped;\n this.value = content || '';\n this.quote = str.charAt(0);\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.variableRegex = /@\\{([\\w-]+)\\}/g;\n this.propRegex = /\\$\\{([\\w-]+)\\}/g;\n this.allowRoot = escaped;\n }\n\n genCSS(context, output) {\n if (!this.escaped) {\n output.add(this.quote, this.fileInfo(), this.getIndex());\n }\n output.add(this.value);\n if (!this.escaped) {\n output.add(this.quote);\n }\n }\n\n containsVariables() {\n return this.value.match(this.variableRegex);\n }\n\n eval(context) {\n const that = this;\n let value = this.value;\n const variableReplacement = (_, name) => {\n const v = new Variable(`@${name}`, that.getIndex(), that.fileInfo()).eval(context, true);\n return (v instanceof Quoted) ? v.value : v.toCSS();\n };\n const propertyReplacement = (_, name) => {\n const v = new Property(`$${name}`, that.getIndex(), that.fileInfo()).eval(context, true);\n return (v instanceof Quoted) ? v.value : v.toCSS();\n };\n function iterativeReplace(value, regexp, replacementFnc) {\n let evaluatedValue = value;\n do {\n value = evaluatedValue.toString();\n evaluatedValue = value.replace(regexp, replacementFnc);\n } while (value !== evaluatedValue);\n return evaluatedValue;\n }\n value = iterativeReplace(value, this.variableRegex, variableReplacement);\n value = iterativeReplace(value, this.propRegex, propertyReplacement);\n\n return new Quoted(this.quote + value + this.quote, value, this.escaped, this.getIndex(), this.fileInfo());\n }\n\n compare(other) {\n // when comparing quoted strings allow the quote to differ\n if (other.type === 'Quoted' && !this.escaped && !other.escaped) {\n return Node.numericCompare(this.value, other.value);\n } else {\n return other.toCSS && this.toCSS() === other.toCSS() ? 0 : undefined;\n }\n }\n}\n\nQuoted.prototype.type = 'Quoted';\nexport default Quoted;\n","import Node from './node';\n\nclass URL extends Node {\n constructor(val, index, currentFileInfo, isEvald) {\n super();\n\n this.value = val;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.isEvald = isEvald;\n }\n\n accept(visitor) {\n this.value = visitor.visit(this.value);\n }\n\n genCSS(context, output) {\n output.add('url(');\n this.value.genCSS(context, output);\n output.add(')');\n }\n\n eval(context) {\n const val = this.value.eval(context);\n let rootpath;\n\n if (!this.isEvald) {\n // Add the rootpath if the URL requires a rewrite\n rootpath = this.fileInfo() && this.fileInfo().rootpath;\n if (typeof rootpath === 'string' &&\n typeof val.value === 'string' &&\n context.pathRequiresRewrite(val.value)) {\n if (!val.quote) {\n rootpath = escapePath(rootpath);\n }\n val.value = context.rewritePath(val.value, rootpath);\n } else {\n val.value = context.normalizePath(val.value);\n }\n\n // Add url args if enabled\n if (context.urlArgs) {\n if (!val.value.match(/^\\s*data:/)) {\n const delimiter = val.value.indexOf('?') === -1 ? '?' : '&';\n const urlArgs = delimiter + context.urlArgs;\n if (val.value.indexOf('#') !== -1) {\n val.value = val.value.replace('#', `${urlArgs}#`);\n } else {\n val.value += urlArgs;\n }\n }\n }\n }\n\n return new URL(val, this.getIndex(), this.fileInfo(), true);\n }\n}\n\nURL.prototype.type = 'Url';\n\nfunction escapePath(path) {\n return path.replace(/[\\(\\)'\"\\s]/g, match => `\\\\${match}`);\n}\n\nexport default URL;\n","import Ruleset from './ruleset';\nimport Value from './value';\nimport Selector from './selector';\nimport Anonymous from './anonymous';\nimport Expression from './expression';\nimport AtRule from './atrule';\nimport * as utils from '../utils';\n\nclass Media extends AtRule {\n constructor(value, features, index, currentFileInfo, visibilityInfo) {\n super();\n\n this._index = index;\n this._fileInfo = currentFileInfo;\n\n const selectors = (new Selector([], null, null, this._index, this._fileInfo)).createEmptySelectors();\n\n this.features = new Value(features);\n this.rules = [new Ruleset(selectors, value)];\n this.rules[0].allowImports = true;\n this.copyVisibilityInfo(visibilityInfo);\n this.allowRoot = true;\n this.setParent(selectors, this);\n this.setParent(this.features, this);\n this.setParent(this.rules, this);\n }\n\n isRulesetLike() {\n return true;\n }\n\n accept(visitor) {\n if (this.features) {\n this.features = visitor.visit(this.features);\n }\n if (this.rules) {\n this.rules = visitor.visitArray(this.rules);\n }\n }\n\n genCSS(context, output) {\n output.add('@media ', this._fileInfo, this._index);\n this.features.genCSS(context, output);\n this.outputRuleset(context, output, this.rules);\n }\n\n eval(context) {\n if (!context.mediaBlocks) {\n context.mediaBlocks = [];\n context.mediaPath = [];\n }\n\n const media = new Media(null, [], this._index, this._fileInfo, this.visibilityInfo());\n if (this.debugInfo) {\n this.rules[0].debugInfo = this.debugInfo;\n media.debugInfo = this.debugInfo;\n }\n \n media.features = this.features.eval(context);\n\n context.mediaPath.push(media);\n context.mediaBlocks.push(media);\n\n this.rules[0].functionRegistry = context.frames[0].functionRegistry.inherit();\n context.frames.unshift(this.rules[0]);\n media.rules = [this.rules[0].eval(context)];\n context.frames.shift();\n\n context.mediaPath.pop();\n\n return context.mediaPath.length === 0 ? media.evalTop(context) :\n media.evalNested(context);\n }\n\n evalTop(context) {\n let result = this;\n\n // Render all dependent Media blocks.\n if (context.mediaBlocks.length > 1) {\n const selectors = (new Selector([], null, null, this.getIndex(), this.fileInfo())).createEmptySelectors();\n result = new Ruleset(selectors, context.mediaBlocks);\n result.multiMedia = true;\n result.copyVisibilityInfo(this.visibilityInfo());\n this.setParent(result, this);\n }\n\n delete context.mediaBlocks;\n delete context.mediaPath;\n\n return result;\n }\n\n evalNested(context) {\n let i;\n let value;\n const path = context.mediaPath.concat([this]);\n\n // Extract the media-query conditions separated with `,` (OR).\n for (i = 0; i < path.length; i++) {\n value = path[i].features instanceof Value ?\n path[i].features.value : path[i].features;\n path[i] = Array.isArray(value) ? value : [value];\n }\n\n // Trace all permutations to generate the resulting media-query.\n //\n // (a, b and c) with nested (d, e) ->\n // a and d\n // a and e\n // b and c and d\n // b and c and e\n this.features = new Value(this.permute(path).map(path => {\n path = path.map(fragment => fragment.toCSS ? fragment : new Anonymous(fragment));\n\n for (i = path.length - 1; i > 0; i--) {\n path.splice(i, 0, new Anonymous('and'));\n }\n\n return new Expression(path);\n }));\n this.setParent(this.features, this);\n\n // Fake a tree-node that doesn't output anything.\n return new Ruleset([], []);\n }\n\n permute(arr) {\n if (arr.length === 0) {\n return [];\n } else if (arr.length === 1) {\n return arr[0];\n } else {\n const result = [];\n const rest = this.permute(arr.slice(1));\n for (let i = 0; i < rest.length; i++) {\n for (let j = 0; j < arr[0].length; j++) {\n result.push([arr[0][j]].concat(rest[i]));\n }\n }\n return result;\n }\n }\n\n bubbleSelectors(selectors) {\n if (!selectors) {\n return;\n }\n this.rules = [new Ruleset(utils.copyArray(selectors), [this.rules[0]])];\n this.setParent(this.rules, this);\n }\n}\n\nMedia.prototype.type = 'Media';\nexport default Media;\n","import Node from './node';\nimport Media from './media';\nimport URL from './url';\nimport Quoted from './quoted';\nimport Ruleset from './ruleset';\nimport Anonymous from './anonymous';\nimport * as utils from '../utils';\nimport LessError from '../less-error';\n\n//\n// CSS @import node\n//\n// The general strategy here is that we don't want to wait\n// for the parsing to be completed, before we start importing\n// the file. That's because in the context of a browser,\n// most of the time will be spent waiting for the server to respond.\n//\n// On creation, we push the import path to our import queue, though\n// `import,push`, we also pass it a callback, which it'll call once\n// the file has been fetched, and parsed.\n//\nclass Import extends Node {\n constructor(path, features, options, index, currentFileInfo, visibilityInfo) {\n super();\n\n this.options = options;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.path = path;\n this.features = features;\n this.allowRoot = true;\n\n if (this.options.less !== undefined || this.options.inline) {\n this.css = !this.options.less || this.options.inline;\n } else {\n const pathValue = this.getPath();\n if (pathValue && /[#\\.\\&\\?]css([\\?;].*)?$/.test(pathValue)) {\n this.css = true;\n }\n }\n this.copyVisibilityInfo(visibilityInfo);\n this.setParent(this.features, this);\n this.setParent(this.path, this);\n }\n\n accept(visitor) {\n if (this.features) {\n this.features = visitor.visit(this.features);\n }\n this.path = visitor.visit(this.path);\n if (!this.options.isPlugin && !this.options.inline && this.root) {\n this.root = visitor.visit(this.root);\n }\n }\n\n genCSS(context, output) {\n if (this.css && this.path._fileInfo.reference === undefined) {\n output.add('@import ', this._fileInfo, this._index);\n this.path.genCSS(context, output);\n if (this.features) {\n output.add(' ');\n this.features.genCSS(context, output);\n }\n output.add(';');\n }\n }\n\n getPath() {\n return (this.path instanceof URL) ?\n this.path.value.value : this.path.value;\n }\n\n isVariableImport() {\n let path = this.path;\n if (path instanceof URL) {\n path = path.value;\n }\n if (path instanceof Quoted) {\n return path.containsVariables();\n }\n\n return true;\n }\n\n evalForImport(context) {\n let path = this.path;\n\n if (path instanceof URL) {\n path = path.value;\n }\n\n return new Import(path.eval(context), this.features, this.options, this._index, this._fileInfo, this.visibilityInfo());\n }\n\n evalPath(context) {\n const path = this.path.eval(context);\n const fileInfo = this._fileInfo;\n\n if (!(path instanceof URL)) {\n // Add the rootpath if the URL requires a rewrite\n const pathValue = path.value;\n if (fileInfo &&\n pathValue &&\n context.pathRequiresRewrite(pathValue)) {\n path.value = context.rewritePath(pathValue, fileInfo.rootpath);\n } else {\n path.value = context.normalizePath(path.value);\n }\n }\n\n return path;\n }\n\n eval(context) {\n const result = this.doEval(context);\n if (this.options.reference || this.blocksVisibility()) {\n if (result.length || result.length === 0) {\n result.forEach(node => {\n node.addVisibilityBlock();\n }\n );\n } else {\n result.addVisibilityBlock();\n }\n }\n return result;\n }\n\n doEval(context) {\n let ruleset;\n let registry;\n const features = this.features && this.features.eval(context);\n\n if (this.options.isPlugin) {\n if (this.root && this.root.eval) {\n try {\n this.root.eval(context);\n }\n catch (e) {\n e.message = 'Plugin error during evaluation';\n throw new LessError(e, this.root.imports, this.root.filename);\n }\n }\n registry = context.frames[0] && context.frames[0].functionRegistry;\n if ( registry && this.root && this.root.functions ) {\n registry.addMultiple( this.root.functions );\n }\n\n return [];\n }\n\n if (this.skip) {\n if (typeof this.skip === 'function') {\n this.skip = this.skip();\n }\n if (this.skip) {\n return [];\n }\n }\n if (this.options.inline) {\n const contents = new Anonymous(this.root, 0,\n {\n filename: this.importedFilename,\n reference: this.path._fileInfo && this.path._fileInfo.reference\n }, true, true);\n\n return this.features ? new Media([contents], this.features.value) : [contents];\n } else if (this.css) {\n const newImport = new Import(this.evalPath(context), features, this.options, this._index);\n if (!newImport.css && this.error) {\n throw this.error;\n }\n return newImport;\n } else {\n ruleset = new Ruleset(null, utils.copyArray(this.root.rules));\n ruleset.evalImports(context);\n\n return this.features ? new Media(ruleset.rules, this.features.value) : ruleset.rules;\n }\n }\n}\n\nImport.prototype.type = 'Import';\nexport default Import;\n","import Node from './node';\nimport Variable from './variable';\n\nclass JsEvalNode extends Node {\n evaluateJavaScript(expression, context) {\n let result;\n const that = this;\n const evalContext = {};\n\n if (!context.javascriptEnabled) {\n throw { message: 'Inline JavaScript is not enabled. Is it set in your options?',\n filename: this.fileInfo().filename,\n index: this.getIndex() };\n }\n\n expression = expression.replace(/@\\{([\\w-]+)\\}/g, (_, name) => that.jsify(new Variable(`@${name}`, that.getIndex(), that.fileInfo()).eval(context)));\n\n try {\n expression = new Function(`return (${expression})`);\n } catch (e) {\n throw { message: `JavaScript evaluation error: ${e.message} from \\`${expression}\\`` ,\n filename: this.fileInfo().filename,\n index: this.getIndex() };\n }\n\n const variables = context.frames[0].variables();\n for (const k in variables) {\n if (variables.hasOwnProperty(k)) {\n /* jshint loopfunc:true */\n evalContext[k.slice(1)] = {\n value: variables[k].value,\n toJS: function () {\n return this.value.eval(context).toCSS();\n }\n };\n }\n }\n\n try {\n result = expression.call(evalContext);\n } catch (e) {\n throw { message: `JavaScript evaluation error: '${e.name}: ${e.message.replace(/[\"]/g, '\\'')}'` ,\n filename: this.fileInfo().filename,\n index: this.getIndex() };\n }\n return result;\n }\n\n jsify(obj) {\n if (Array.isArray(obj.value) && (obj.value.length > 1)) {\n return `[${obj.value.map(v => v.toCSS()).join(', ')}]`;\n } else {\n return obj.toCSS();\n }\n }\n}\n\nexport default JsEvalNode;\n","import JsEvalNode from './js-eval-node';\nimport Dimension from './dimension';\nimport Quoted from './quoted';\nimport Anonymous from './anonymous';\n\nclass JavaScript extends JsEvalNode {\n constructor(string, escaped, index, currentFileInfo) {\n super();\n\n this.escaped = escaped;\n this.expression = string;\n this._index = index;\n this._fileInfo = currentFileInfo;\n }\n\n eval(context) {\n const result = this.evaluateJavaScript(this.expression, context);\n const type = typeof result;\n\n if (type === 'number' && !isNaN(result)) {\n return new Dimension(result);\n } else if (type === 'string') {\n return new Quoted(`\"${result}\"`, result, this.escaped, this._index);\n } else if (Array.isArray(result)) {\n return new Anonymous(result.join(', '));\n } else {\n return new Anonymous(result);\n }\n }\n}\n\nJavaScript.prototype.type = 'JavaScript';\nexport default JavaScript;\n","import Node from './node';\n\nclass Assignment extends Node {\n constructor(key, val) {\n super();\n\n this.key = key;\n this.value = val;\n }\n\n accept(visitor) {\n this.value = visitor.visit(this.value);\n }\n\n eval(context) {\n if (this.value.eval) {\n return new Assignment(this.key, this.value.eval(context));\n }\n return this;\n }\n\n genCSS(context, output) {\n output.add(`${this.key}=`);\n if (this.value.genCSS) {\n this.value.genCSS(context, output);\n } else {\n output.add(this.value);\n }\n }\n}\n\nAssignment.prototype.type = 'Assignment';\nexport default Assignment;\n","import Node from './node';\n\nclass Condition extends Node {\n constructor(op, l, r, i, negate) {\n super();\n\n this.op = op.trim();\n this.lvalue = l;\n this.rvalue = r;\n this._index = i;\n this.negate = negate;\n }\n\n accept(visitor) {\n this.lvalue = visitor.visit(this.lvalue);\n this.rvalue = visitor.visit(this.rvalue);\n }\n\n eval(context) {\n const result = ((op, a, b) => {\n switch (op) {\n case 'and': return a && b;\n case 'or': return a || b;\n default:\n switch (Node.compare(a, b)) {\n case -1:\n return op === '<' || op === '=<' || op === '<=';\n case 0:\n return op === '=' || op === '>=' || op === '=<' || op === '<=';\n case 1:\n return op === '>' || op === '>=';\n default:\n return false;\n }\n }\n })(this.op, this.lvalue.eval(context), this.rvalue.eval(context));\n\n return this.negate ? !result : result;\n }\n}\n\nCondition.prototype.type = 'Condition';\nexport default Condition;\n","import Node from './node';\n\nclass UnicodeDescriptor extends Node {\n constructor(value) {\n super();\n\n this.value = value;\n }\n}\n\nUnicodeDescriptor.prototype.type = 'UnicodeDescriptor';\n\nexport default UnicodeDescriptor;\n","import Node from './node';\nimport Operation from './operation';\nimport Dimension from './dimension';\n\nclass Negative extends Node {\n constructor(node) {\n super();\n\n this.value = node;\n }\n\n genCSS(context, output) {\n output.add('-');\n this.value.genCSS(context, output);\n }\n\n eval(context) {\n if (context.isMathOn()) {\n return (new Operation('*', [new Dimension(-1), this.value])).eval(context);\n }\n return new Negative(this.value.eval(context));\n }\n}\n\nNegative.prototype.type = 'Negative';\nexport default Negative;\n","import Node from './node';\nimport Selector from './selector';\n\nclass Extend extends Node {\n constructor(selector, option, index, currentFileInfo, visibilityInfo) {\n super();\n\n this.selector = selector;\n this.option = option;\n this.object_id = Extend.next_id++;\n this.parent_ids = [this.object_id];\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.copyVisibilityInfo(visibilityInfo);\n this.allowRoot = true;\n\n switch (option) {\n case 'all':\n this.allowBefore = true;\n this.allowAfter = true;\n break;\n default:\n this.allowBefore = false;\n this.allowAfter = false;\n break;\n }\n this.setParent(this.selector, this);\n }\n\n accept(visitor) {\n this.selector = visitor.visit(this.selector);\n }\n\n eval(context) {\n return new Extend(this.selector.eval(context), this.option, this.getIndex(), this.fileInfo(), this.visibilityInfo());\n }\n\n clone(context) {\n return new Extend(this.selector, this.option, this.getIndex(), this.fileInfo(), this.visibilityInfo());\n }\n\n // it concatenates (joins) all selectors in selector array\n findSelfSelectors(selectors) {\n let selfElements = [];\n let i;\n let selectorElements;\n\n for (i = 0; i < selectors.length; i++) {\n selectorElements = selectors[i].elements;\n // duplicate the logic in genCSS function inside the selector node.\n // future TODO - move both logics into the selector joiner visitor\n if (i > 0 && selectorElements.length && selectorElements[0].combinator.value === '') {\n selectorElements[0].combinator.value = ' ';\n }\n selfElements = selfElements.concat(selectors[i].elements);\n }\n\n this.selfSelectors = [new Selector(selfElements)];\n this.selfSelectors[0].copyVisibilityInfo(this.visibilityInfo());\n }\n}\n\nExtend.next_id = 0;\n\nExtend.prototype.type = 'Extend';\nexport default Extend;\n","import Node from './node';\nimport Variable from './variable';\nimport Ruleset from './ruleset';\nimport DetachedRuleset from './detached-ruleset';\nimport LessError from '../less-error';\n\nclass VariableCall extends Node {\n constructor(variable, index, currentFileInfo) {\n super();\n\n this.variable = variable;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.allowRoot = true;\n }\n\n eval(context) {\n let rules;\n let detachedRuleset = new Variable(this.variable, this.getIndex(), this.fileInfo()).eval(context);\n const error = new LessError({message: `Could not evaluate variable call ${this.variable}`});\n\n if (!detachedRuleset.ruleset) {\n if (detachedRuleset.rules) {\n rules = detachedRuleset;\n }\n else if (Array.isArray(detachedRuleset)) {\n rules = new Ruleset('', detachedRuleset);\n }\n else if (Array.isArray(detachedRuleset.value)) {\n rules = new Ruleset('', detachedRuleset.value);\n }\n else {\n throw error;\n }\n detachedRuleset = new DetachedRuleset(rules);\n }\n\n if (detachedRuleset.ruleset) {\n return detachedRuleset.callEval(context);\n }\n throw error;\n }\n}\n\nVariableCall.prototype.type = 'VariableCall';\nexport default VariableCall;\n","import Node from './node';\nimport Variable from './variable';\nimport Ruleset from './ruleset';\nimport Selector from './selector';\n\nclass NamespaceValue extends Node {\n constructor(ruleCall, lookups, important, index, fileInfo) {\n super();\n\n this.value = ruleCall;\n this.lookups = lookups;\n this.important = important;\n this._index = index;\n this._fileInfo = fileInfo;\n }\n\n eval(context) {\n let i;\n let j;\n let name;\n let rules = this.value.eval(context);\n\n for (i = 0; i < this.lookups.length; i++) {\n name = this.lookups[i];\n\n /**\n * Eval'd DRs return rulesets.\n * Eval'd mixins return rules, so let's make a ruleset if we need it.\n * We need to do this because of late parsing of values\n */\n if (Array.isArray(rules)) {\n rules = new Ruleset([new Selector()], rules);\n }\n\n if (name === '') {\n rules = rules.lastDeclaration();\n }\n else if (name.charAt(0) === '@') {\n if (name.charAt(1) === '@') {\n name = `@${new Variable(name.substr(1)).eval(context).value}`;\n }\n if (rules.variables) {\n rules = rules.variable(name);\n }\n \n if (!rules) {\n throw { type: 'Name',\n message: `variable ${name} not found`,\n filename: this.fileInfo().filename,\n index: this.getIndex() };\n }\n }\n else {\n if (name.substring(0, 2) === '$@') {\n name = `$${new Variable(name.substr(1)).eval(context).value}`;\n }\n else {\n name = name.charAt(0) === '$' ? name : `$${name}`;\n }\n if (rules.properties) {\n rules = rules.property(name);\n }\n \n if (!rules) {\n throw { type: 'Name',\n message: `property \"${name.substr(1)}\" not found`,\n filename: this.fileInfo().filename,\n index: this.getIndex() };\n }\n // Properties are an array of values, since a ruleset can have multiple props.\n // We pick the last one (the \"cascaded\" value)\n rules = rules[rules.length - 1];\n }\n\n if (rules.value) {\n rules = rules.eval(context).value;\n }\n if (rules.ruleset) {\n rules = rules.ruleset.eval(context);\n }\n }\n return rules;\n }\n}\n\nNamespaceValue.prototype.type = 'NamespaceValue';\nexport default NamespaceValue;\n","import Selector from './selector';\nimport Element from './element';\nimport Ruleset from './ruleset';\nimport Declaration from './declaration';\nimport DetachedRuleset from './detached-ruleset';\nimport Expression from './expression';\nimport contexts from '../contexts';\nimport * as utils from '../utils';\n\nclass Definition extends Ruleset {\n constructor(name, params, rules, condition, variadic, frames, visibilityInfo) {\n super();\n\n this.name = name || 'anonymous mixin';\n this.selectors = [new Selector([new Element(null, name, false, this._index, this._fileInfo)])];\n this.params = params;\n this.condition = condition;\n this.variadic = variadic;\n this.arity = params.length;\n this.rules = rules;\n this._lookups = {};\n const optionalParameters = [];\n this.required = params.reduce((count, p) => {\n if (!p.name || (p.name && !p.value)) {\n return count + 1;\n }\n else {\n optionalParameters.push(p.name);\n return count;\n }\n }, 0);\n this.optionalParameters = optionalParameters;\n this.frames = frames;\n this.copyVisibilityInfo(visibilityInfo);\n this.allowRoot = true;\n }\n\n accept(visitor) {\n if (this.params && this.params.length) {\n this.params = visitor.visitArray(this.params);\n }\n this.rules = visitor.visitArray(this.rules);\n if (this.condition) {\n this.condition = visitor.visit(this.condition);\n }\n }\n\n evalParams(context, mixinEnv, args, evaldArguments) {\n /* jshint boss:true */\n const frame = new Ruleset(null, null);\n\n let varargs;\n let arg;\n const params = utils.copyArray(this.params);\n let i;\n let j;\n let val;\n let name;\n let isNamedFound;\n let argIndex;\n let argsLength = 0;\n\n if (mixinEnv.frames && mixinEnv.frames[0] && mixinEnv.frames[0].functionRegistry) {\n frame.functionRegistry = mixinEnv.frames[0].functionRegistry.inherit();\n }\n mixinEnv = new contexts.Eval(mixinEnv, [frame].concat(mixinEnv.frames));\n\n if (args) {\n args = utils.copyArray(args);\n argsLength = args.length;\n\n for (i = 0; i < argsLength; i++) {\n arg = args[i];\n if (name = (arg && arg.name)) {\n isNamedFound = false;\n for (j = 0; j < params.length; j++) {\n if (!evaldArguments[j] && name === params[j].name) {\n evaldArguments[j] = arg.value.eval(context);\n frame.prependRule(new Declaration(name, arg.value.eval(context)));\n isNamedFound = true;\n break;\n }\n }\n if (isNamedFound) {\n args.splice(i, 1);\n i--;\n continue;\n } else {\n throw { type: 'Runtime', message: `Named argument for ${this.name} ${args[i].name} not found` };\n }\n }\n }\n }\n argIndex = 0;\n for (i = 0; i < params.length; i++) {\n if (evaldArguments[i]) { continue; }\n\n arg = args && args[argIndex];\n\n if (name = params[i].name) {\n if (params[i].variadic) {\n varargs = [];\n for (j = argIndex; j < argsLength; j++) {\n varargs.push(args[j].value.eval(context));\n }\n frame.prependRule(new Declaration(name, new Expression(varargs).eval(context)));\n } else {\n val = arg && arg.value;\n if (val) {\n // This was a mixin call, pass in a detached ruleset of it's eval'd rules\n if (Array.isArray(val)) {\n val = new DetachedRuleset(new Ruleset('', val));\n }\n else {\n val = val.eval(context);\n }\n } else if (params[i].value) {\n val = params[i].value.eval(mixinEnv);\n frame.resetCache();\n } else {\n throw { type: 'Runtime', message: `wrong number of arguments for ${this.name} (${argsLength} for ${this.arity})` };\n }\n\n frame.prependRule(new Declaration(name, val));\n evaldArguments[i] = val;\n }\n }\n\n if (params[i].variadic && args) {\n for (j = argIndex; j < argsLength; j++) {\n evaldArguments[j] = args[j].value.eval(context);\n }\n }\n argIndex++;\n }\n\n return frame;\n }\n\n makeImportant() {\n const rules = !this.rules ? this.rules : this.rules.map(r => {\n if (r.makeImportant) {\n return r.makeImportant(true);\n } else {\n return r;\n }\n });\n const result = new Definition(this.name, this.params, rules, this.condition, this.variadic, this.frames);\n return result;\n }\n\n eval(context) {\n return new Definition(this.name, this.params, this.rules, this.condition, this.variadic, this.frames || utils.copyArray(context.frames));\n }\n\n evalCall(context, args, important) {\n const _arguments = [];\n const mixinFrames = this.frames ? this.frames.concat(context.frames) : context.frames;\n const frame = this.evalParams(context, new contexts.Eval(context, mixinFrames), args, _arguments);\n let rules;\n let ruleset;\n\n frame.prependRule(new Declaration('@arguments', new Expression(_arguments).eval(context)));\n\n rules = utils.copyArray(this.rules);\n\n ruleset = new Ruleset(null, rules);\n ruleset.originalRuleset = this;\n ruleset = ruleset.eval(new contexts.Eval(context, [this, frame].concat(mixinFrames)));\n if (important) {\n ruleset = ruleset.makeImportant();\n }\n return ruleset;\n }\n\n matchCondition(args, context) {\n if (this.condition && !this.condition.eval(\n new contexts.Eval(context,\n [this.evalParams(context, /* the parameter variables */\n new contexts.Eval(context, this.frames ? this.frames.concat(context.frames) : context.frames), args, [])]\n .concat(this.frames || []) // the parent namespace/mixin frames\n .concat(context.frames)))) { // the current environment frames\n return false;\n }\n return true;\n }\n\n matchArgs(args, context) {\n const allArgsCnt = (args && args.length) || 0;\n let len;\n const optionalParameters = this.optionalParameters;\n const requiredArgsCnt = !args ? 0 : args.reduce((count, p) => {\n if (optionalParameters.indexOf(p.name) < 0) {\n return count + 1;\n } else {\n return count;\n }\n }, 0);\n\n if (!this.variadic) {\n if (requiredArgsCnt < this.required) {\n return false;\n }\n if (allArgsCnt > this.params.length) {\n return false;\n }\n } else {\n if (requiredArgsCnt < (this.required - 1)) {\n return false;\n }\n }\n\n // check patterns\n len = Math.min(requiredArgsCnt, this.arity);\n\n for (let i = 0; i < len; i++) {\n if (!this.params[i].name && !this.params[i].variadic) {\n if (args[i].value.eval(context).toCSS() != this.params[i].value.eval(context).toCSS()) {\n return false;\n }\n }\n }\n return true;\n }\n}\n\nDefinition.prototype.type = 'MixinDefinition';\nDefinition.prototype.evalFirst = true;\nexport default Definition;\n","import Node from './node';\nimport Selector from './selector';\nimport MixinDefinition from './mixin-definition';\nimport defaultFunc from '../functions/default';\n\nclass MixinCall extends Node {\n constructor(elements, args, index, currentFileInfo, important) {\n super();\n\n this.selector = new Selector(elements);\n this.arguments = args || [];\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.important = important;\n this.allowRoot = true;\n this.setParent(this.selector, this);\n }\n\n accept(visitor) {\n if (this.selector) {\n this.selector = visitor.visit(this.selector);\n }\n if (this.arguments.length) {\n this.arguments = visitor.visitArray(this.arguments);\n }\n }\n\n eval(context) {\n let mixins;\n let mixin;\n let mixinPath;\n const args = [];\n let arg;\n let argValue;\n const rules = [];\n let match = false;\n let i;\n let m;\n let f;\n let isRecursive;\n let isOneFound;\n const candidates = [];\n let candidate;\n const conditionResult = [];\n let defaultResult;\n const defFalseEitherCase = -1;\n const defNone = 0;\n const defTrue = 1;\n const defFalse = 2;\n let count;\n let originalRuleset;\n let noArgumentsFilter;\n\n this.selector = this.selector.eval(context);\n\n function calcDefGroup(mixin, mixinPath) {\n let f;\n let p;\n let namespace;\n\n for (f = 0; f < 2; f++) {\n conditionResult[f] = true;\n defaultFunc.value(f);\n for (p = 0; p < mixinPath.length && conditionResult[f]; p++) {\n namespace = mixinPath[p];\n if (namespace.matchCondition) {\n conditionResult[f] = conditionResult[f] && namespace.matchCondition(null, context);\n }\n }\n if (mixin.matchCondition) {\n conditionResult[f] = conditionResult[f] && mixin.matchCondition(args, context);\n }\n }\n if (conditionResult[0] || conditionResult[1]) {\n if (conditionResult[0] != conditionResult[1]) {\n return conditionResult[1] ?\n defTrue : defFalse;\n }\n\n return defNone;\n }\n return defFalseEitherCase;\n }\n\n for (i = 0; i < this.arguments.length; i++) {\n arg = this.arguments[i];\n argValue = arg.value.eval(context);\n if (arg.expand && Array.isArray(argValue.value)) {\n argValue = argValue.value;\n for (m = 0; m < argValue.length; m++) {\n args.push({value: argValue[m]});\n }\n } else {\n args.push({name: arg.name, value: argValue});\n }\n }\n\n noArgumentsFilter = rule => rule.matchArgs(null, context);\n\n for (i = 0; i < context.frames.length; i++) {\n if ((mixins = context.frames[i].find(this.selector, null, noArgumentsFilter)).length > 0) {\n isOneFound = true;\n\n // To make `default()` function independent of definition order we have two \"subpasses\" here.\n // At first we evaluate each guard *twice* (with `default() == true` and `default() == false`),\n // and build candidate list with corresponding flags. Then, when we know all possible matches,\n // we make a final decision.\n\n for (m = 0; m < mixins.length; m++) {\n mixin = mixins[m].rule;\n mixinPath = mixins[m].path;\n isRecursive = false;\n for (f = 0; f < context.frames.length; f++) {\n if ((!(mixin instanceof MixinDefinition)) && mixin === (context.frames[f].originalRuleset || context.frames[f])) {\n isRecursive = true;\n break;\n }\n }\n if (isRecursive) {\n continue;\n }\n\n if (mixin.matchArgs(args, context)) {\n candidate = {mixin, group: calcDefGroup(mixin, mixinPath)};\n\n if (candidate.group !== defFalseEitherCase) {\n candidates.push(candidate);\n }\n\n match = true;\n }\n }\n\n defaultFunc.reset();\n\n count = [0, 0, 0];\n for (m = 0; m < candidates.length; m++) {\n count[candidates[m].group]++;\n }\n\n if (count[defNone] > 0) {\n defaultResult = defFalse;\n } else {\n defaultResult = defTrue;\n if ((count[defTrue] + count[defFalse]) > 1) {\n throw { type: 'Runtime',\n message: `Ambiguous use of \\`default()\\` found when matching for \\`${this.format(args)}\\``,\n index: this.getIndex(), filename: this.fileInfo().filename };\n }\n }\n\n for (m = 0; m < candidates.length; m++) {\n candidate = candidates[m].group;\n if ((candidate === defNone) || (candidate === defaultResult)) {\n try {\n mixin = candidates[m].mixin;\n if (!(mixin instanceof MixinDefinition)) {\n originalRuleset = mixin.originalRuleset || mixin;\n mixin = new MixinDefinition('', [], mixin.rules, null, false, null, originalRuleset.visibilityInfo());\n mixin.originalRuleset = originalRuleset;\n }\n const newRules = mixin.evalCall(context, args, this.important).rules;\n this._setVisibilityToReplacement(newRules);\n Array.prototype.push.apply(rules, newRules);\n } catch (e) {\n throw { message: e.message, index: this.getIndex(), filename: this.fileInfo().filename, stack: e.stack };\n }\n }\n }\n\n if (match) {\n return rules;\n }\n }\n }\n if (isOneFound) {\n throw { type: 'Runtime',\n message: `No matching definition was found for \\`${this.format(args)}\\``,\n index: this.getIndex(), filename: this.fileInfo().filename };\n } else {\n throw { type: 'Name',\n message: `${this.selector.toCSS().trim()} is undefined`,\n index: this.getIndex(), filename: this.fileInfo().filename };\n }\n }\n\n _setVisibilityToReplacement(replacement) {\n let i;\n let rule;\n if (this.blocksVisibility()) {\n for (i = 0; i < replacement.length; i++) {\n rule = replacement[i];\n rule.addVisibilityBlock();\n }\n }\n }\n\n format(args) {\n return `${this.selector.toCSS().trim()}(${args ? args.map(a => {\n let argValue = '';\n if (a.name) {\n argValue += `${a.name}:`;\n }\n if (a.value.toCSS) {\n argValue += a.value.toCSS();\n } else {\n argValue += '???';\n }\n return argValue;\n }).join(', ') : ''})`;\n }\n}\n\nMixinCall.prototype.type = 'MixinCall';\nexport default MixinCall;\n","const tree = Object.create(null);\n\nimport Node from './node';\nimport Color from './color';\nimport AtRule from './atrule';\nimport DetachedRuleset from './detached-ruleset';\nimport Operation from './operation';\nimport Dimension from './dimension';\nimport Unit from './unit';\nimport Keyword from './keyword';\nimport Variable from './variable';\nimport Property from './property';\nimport Ruleset from './ruleset';\nimport Element from './element';\nimport Attribute from './attribute';\nimport Combinator from './combinator';\nimport Selector from './selector';\nimport Quoted from './quoted';\nimport Expression from './expression';\nimport Declaration from './declaration';\nimport Call from './call';\nimport URL from './url';\nimport Import from './import';\nimport Comment from './comment';\nimport Anonymous from './anonymous';\nimport Value from './value';\nimport JavaScript from './javascript';\nimport Assignment from './assignment';\nimport Condition from './condition';\nimport Paren from './paren';\nimport Media from './media';\nimport UnicodeDescriptor from './unicode-descriptor';\nimport Negative from './negative';\nimport Extend from './extend';\nimport VariableCall from './variable-call';\nimport NamespaceValue from './namespace-value';\n\n// mixins\nimport MixinCall from './mixin-call';\nimport MixinDefinition from './mixin-definition';\n\nexport default {\n Node, Color, AtRule, DetachedRuleset, Operation,\n Dimension, Unit, Keyword, Variable, Property,\n Ruleset, Element, Attribute, Combinator, Selector,\n Quoted, Expression, Declaration, Call, URL, Import,\n Comment, Anonymous, Value, JavaScript, Assignment,\n Condition, Paren, Media, UnicodeDescriptor, Negative,\n Extend, VariableCall, NamespaceValue,\n mixin: {\n Call: MixinCall,\n Definition: MixinDefinition\n }\n};","export default {\n error: function(msg) {\n this._fireEvent('error', msg);\n },\n warn: function(msg) {\n this._fireEvent('warn', msg);\n },\n info: function(msg) {\n this._fireEvent('info', msg);\n },\n debug: function(msg) {\n this._fireEvent('debug', msg);\n },\n addListener: function(listener) {\n this._listeners.push(listener);\n },\n removeListener: function(listener) {\n for (let i = 0; i < this._listeners.length; i++) {\n if (this._listeners[i] === listener) {\n this._listeners.splice(i, 1);\n return;\n }\n }\n },\n _fireEvent: function(type, msg) {\n for (let i = 0; i < this._listeners.length; i++) {\n const logFunction = this._listeners[i][type];\n if (logFunction) {\n logFunction(msg);\n }\n }\n },\n _listeners: []\n};\n","/**\n * @todo Document why this abstraction exists, and the relationship between\n * environment, file managers, and plugin manager\n */\n\nimport logger from '../logger';\n\nclass environment {\n constructor(externalEnvironment, fileManagers) {\n this.fileManagers = fileManagers || [];\n externalEnvironment = externalEnvironment || {};\n\n const optionalFunctions = ['encodeBase64', 'mimeLookup', 'charsetLookup', 'getSourceMapGenerator'];\n const requiredFunctions = [];\n const functions = requiredFunctions.concat(optionalFunctions);\n\n for (let i = 0; i < functions.length; i++) {\n const propName = functions[i];\n const environmentFunc = externalEnvironment[propName];\n if (environmentFunc) {\n this[propName] = environmentFunc.bind(externalEnvironment);\n } else if (i < requiredFunctions.length) {\n this.warn(`missing required function in environment - ${propName}`);\n }\n }\n }\n\n getFileManager(filename, currentDirectory, options, environment, isSync) {\n\n if (!filename) {\n logger.warn('getFileManager called with no filename.. Please report this issue. continuing.');\n }\n if (currentDirectory == null) {\n logger.warn('getFileManager called with null directory.. Please report this issue. continuing.');\n }\n\n let fileManagers = this.fileManagers;\n if (options.pluginManager) {\n fileManagers = [].concat(fileManagers).concat(options.pluginManager.getFileManagers());\n }\n for (let i = fileManagers.length - 1; i >= 0 ; i--) {\n const fileManager = fileManagers[i];\n if (fileManager[isSync ? 'supportsSync' : 'supports'](filename, currentDirectory, options, environment)) {\n return fileManager;\n }\n }\n return null;\n }\n\n addFileManager(fileManager) {\n this.fileManagers.push(fileManager);\n }\n\n clearFileManagers() {\n this.fileManagers = [];\n }\n}\n\nexport default environment;\n","class AbstractFileManager {\n getPath(filename) {\n let j = filename.lastIndexOf('?');\n if (j > 0) {\n filename = filename.slice(0, j);\n }\n j = filename.lastIndexOf('/');\n if (j < 0) {\n j = filename.lastIndexOf('\\\\');\n }\n if (j < 0) {\n return '';\n }\n return filename.slice(0, j + 1);\n }\n\n tryAppendExtension(path, ext) {\n return /(\\.[a-z]*$)|([\\?;].*)$/.test(path) ? path : path + ext;\n }\n\n tryAppendLessExtension(path) {\n return this.tryAppendExtension(path, '.less');\n };\n\n supportsSync() { return false; }\n\n alwaysMakePathsAbsolute() { return false; }\n\n isPathAbsolute(filename) {\n return (/^(?:[a-z-]+:|\\/|\\\\|#)/i).test(filename);\n }\n // TODO: pull out / replace?\n join(basePath, laterPath) {\n if (!basePath) {\n return laterPath;\n }\n return basePath + laterPath;\n };\n\n pathDiff(url, baseUrl) {\n // diff between two paths to create a relative path\n const urlParts = this.extractUrlParts(url);\n const baseUrlParts = this.extractUrlParts(baseUrl);\n\n let i;\n let max;\n let urlDirectories;\n let baseUrlDirectories;\n let diff = '';\n if (urlParts.hostPart !== baseUrlParts.hostPart) {\n return '';\n }\n max = Math.max(baseUrlParts.directories.length, urlParts.directories.length);\n for (i = 0; i < max; i++) {\n if (baseUrlParts.directories[i] !== urlParts.directories[i]) { break; }\n }\n baseUrlDirectories = baseUrlParts.directories.slice(i);\n urlDirectories = urlParts.directories.slice(i);\n for (i = 0; i < baseUrlDirectories.length - 1; i++) {\n diff += '../';\n }\n for (i = 0; i < urlDirectories.length - 1; i++) {\n diff += `${urlDirectories[i]}/`;\n }\n return diff;\n };\n // helper function, not part of API\n extractUrlParts(url, baseUrl) {\n // urlParts[1] = protocol://hostname/ OR /\n // urlParts[2] = / if path relative to host base\n // urlParts[3] = directories\n // urlParts[4] = filename\n // urlParts[5] = parameters\n\n const urlPartsRegex = /^((?:[a-z-]+:)?\\/{2}(?:[^\\/\\?#]*\\/)|([\\/\\\\]))?((?:[^\\/\\\\\\?#]*[\\/\\\\])*)([^\\/\\\\\\?#]*)([#\\?].*)?$/i;\n\n const urlParts = url.match(urlPartsRegex);\n const returner = {};\n let rawDirectories = [];\n const directories = [];\n let i;\n let baseUrlParts;\n\n if (!urlParts) {\n throw new Error(`Could not parse sheet href - '${url}'`);\n }\n\n // Stylesheets in IE don't always return the full path\n if (baseUrl && (!urlParts[1] || urlParts[2])) {\n baseUrlParts = baseUrl.match(urlPartsRegex);\n if (!baseUrlParts) {\n throw new Error(`Could not parse page url - '${baseUrl}'`);\n }\n urlParts[1] = urlParts[1] || baseUrlParts[1] || '';\n if (!urlParts[2]) {\n urlParts[3] = baseUrlParts[3] + urlParts[3];\n }\n }\n\n if (urlParts[3]) {\n rawDirectories = urlParts[3].replace(/\\\\/g, '/').split('/');\n\n // collapse '..' and skip '.'\n for (i = 0; i < rawDirectories.length; i++) {\n\n if (rawDirectories[i] === '..') {\n directories.pop();\n }\n else if (rawDirectories[i] !== '.') {\n directories.push(rawDirectories[i]);\n }\n \n }\n }\n\n returner.hostPart = urlParts[1];\n returner.directories = directories;\n returner.rawPath = (urlParts[1] || '') + rawDirectories.join('/');\n returner.path = (urlParts[1] || '') + directories.join('/');\n returner.filename = urlParts[4];\n returner.fileUrl = returner.path + (urlParts[4] || '');\n returner.url = returner.fileUrl + (urlParts[5] || '');\n return returner;\n };\n}\n\nexport default AbstractFileManager;\n","import functionRegistry from '../functions/function-registry';\nimport LessError from '../less-error';\n\nclass AbstractPluginLoader {\n constructor() {\n // Implemented by Node.js plugin loader\n this.require = () => null\n }\n\n evalPlugin(contents, context, imports, pluginOptions, fileInfo) {\n let loader;\n let registry;\n let pluginObj;\n let localModule;\n let pluginManager;\n let filename;\n let result;\n\n pluginManager = context.pluginManager;\n\n if (fileInfo) {\n if (typeof fileInfo === 'string') {\n filename = fileInfo;\n }\n else {\n filename = fileInfo.filename;\n }\n }\n const shortname = (new this.less.FileManager()).extractUrlParts(filename).filename;\n\n if (filename) {\n pluginObj = pluginManager.get(filename);\n\n if (pluginObj) {\n result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions);\n if (result) {\n return result;\n }\n try {\n if (pluginObj.use) {\n pluginObj.use.call(this.context, pluginObj);\n }\n }\n catch (e) {\n e.message = e.message || 'Error during @plugin call';\n return new LessError(e, imports, filename);\n }\n return pluginObj;\n }\n }\n localModule = {\n exports: {},\n pluginManager,\n fileInfo\n };\n registry = functionRegistry.create();\n\n const registerPlugin = obj => {\n pluginObj = obj;\n };\n\n try {\n loader = new Function('module', 'require', 'registerPlugin', 'functions', 'tree', 'less', 'fileInfo', contents);\n loader(localModule, this.require(filename), registerPlugin, registry, this.less.tree, this.less, fileInfo);\n }\n catch (e) {\n return new LessError(e, imports, filename);\n }\n\n if (!pluginObj) {\n pluginObj = localModule.exports;\n }\n pluginObj = this.validatePlugin(pluginObj, filename, shortname);\n\n if (pluginObj instanceof LessError) {\n return pluginObj;\n }\n\n if (pluginObj) {\n pluginObj.imports = imports;\n pluginObj.filename = filename;\n\n // For < 3.x (or unspecified minVersion) - setOptions() before install()\n if (!pluginObj.minVersion || this.compareVersion('3.0.0', pluginObj.minVersion) < 0) {\n result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions);\n\n if (result) {\n return result;\n }\n }\n\n // Run on first load\n pluginManager.addPlugin(pluginObj, fileInfo.filename, registry);\n pluginObj.functions = registry.getLocalFunctions();\n\n // Need to call setOptions again because the pluginObj might have functions\n result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions);\n if (result) {\n return result;\n }\n\n // Run every @plugin call\n try {\n if (pluginObj.use) {\n pluginObj.use.call(this.context, pluginObj);\n }\n }\n catch (e) {\n e.message = e.message || 'Error during @plugin call';\n return new LessError(e, imports, filename);\n }\n\n }\n else {\n return new LessError({ message: 'Not a valid plugin' }, imports, filename);\n }\n\n return pluginObj;\n }\n\n trySetOptions(plugin, filename, name, options) {\n if (options && !plugin.setOptions) {\n return new LessError({\n message: `Options have been provided but the plugin ${name} does not support any options.`\n });\n }\n try {\n plugin.setOptions && plugin.setOptions(options);\n }\n catch (e) {\n return new LessError(e);\n }\n }\n\n validatePlugin(plugin, filename, name) {\n if (plugin) {\n // support plugins being a function\n // so that the plugin can be more usable programmatically\n if (typeof plugin === 'function') {\n plugin = new plugin();\n }\n\n if (plugin.minVersion) {\n if (this.compareVersion(plugin.minVersion, this.less.version) < 0) {\n return new LessError({\n message: `Plugin ${name} requires version ${this.versionToString(plugin.minVersion)}`\n });\n }\n }\n return plugin;\n }\n return null;\n }\n\n compareVersion(aVersion, bVersion) {\n if (typeof aVersion === 'string') {\n aVersion = aVersion.match(/^(\\d+)\\.?(\\d+)?\\.?(\\d+)?/);\n aVersion.shift();\n }\n for (let i = 0; i < aVersion.length; i++) {\n if (aVersion[i] !== bVersion[i]) {\n return parseInt(aVersion[i]) > parseInt(bVersion[i]) ? -1 : 1;\n }\n }\n return 0;\n }\n\n versionToString(version) {\n let versionString = '';\n for (let i = 0; i < version.length; i++) {\n versionString += (versionString ? '.' : '') + version[i];\n }\n return versionString;\n }\n\n printUsage(plugins) {\n for (let i = 0; i < plugins.length; i++) {\n const plugin = plugins[i];\n if (plugin.printUsage) {\n plugin.printUsage();\n }\n }\n }\n}\n\nexport default AbstractPluginLoader;\n\n","import tree from '../tree';\nconst _visitArgs = { visitDeeper: true };\nlet _hasIndexed = false;\n\nfunction _noop(node) {\n return node;\n}\n\nfunction indexNodeTypes(parent, ticker) {\n // add .typeIndex to tree node types for lookup table\n let key;\n\n let child;\n for (key in parent) { \n /* eslint guard-for-in: 0 */\n child = parent[key];\n switch (typeof child) {\n case 'function':\n // ignore bound functions directly on tree which do not have a prototype\n // or aren't nodes\n if (child.prototype && child.prototype.type) {\n child.prototype.typeIndex = ticker++;\n }\n break;\n case 'object':\n ticker = indexNodeTypes(child, ticker);\n break;\n \n }\n }\n return ticker;\n}\n\nclass Visitor {\n constructor(implementation) {\n this._implementation = implementation;\n this._visitInCache = {};\n this._visitOutCache = {};\n\n if (!_hasIndexed) {\n indexNodeTypes(tree, 1);\n _hasIndexed = true;\n }\n }\n\n visit(node) {\n if (!node) {\n return node;\n }\n\n const nodeTypeIndex = node.typeIndex;\n if (!nodeTypeIndex) {\n // MixinCall args aren't a node type?\n if (node.value && node.value.typeIndex) {\n this.visit(node.value);\n }\n return node;\n }\n\n const impl = this._implementation;\n let func = this._visitInCache[nodeTypeIndex];\n let funcOut = this._visitOutCache[nodeTypeIndex];\n const visitArgs = _visitArgs;\n let fnName;\n\n visitArgs.visitDeeper = true;\n\n if (!func) {\n fnName = `visit${node.type}`;\n func = impl[fnName] || _noop;\n funcOut = impl[`${fnName}Out`] || _noop;\n this._visitInCache[nodeTypeIndex] = func;\n this._visitOutCache[nodeTypeIndex] = funcOut;\n }\n\n if (func !== _noop) {\n const newNode = func.call(impl, node, visitArgs);\n if (node && impl.isReplacing) {\n node = newNode;\n }\n }\n\n if (visitArgs.visitDeeper && node && node.accept) {\n node.accept(this);\n }\n\n if (funcOut != _noop) {\n funcOut.call(impl, node);\n }\n\n return node;\n }\n\n visitArray(nodes, nonReplacing) {\n if (!nodes) {\n return nodes;\n }\n\n const cnt = nodes.length;\n let i;\n\n // Non-replacing\n if (nonReplacing || !this._implementation.isReplacing) {\n for (i = 0; i < cnt; i++) {\n this.visit(nodes[i]);\n }\n return nodes;\n }\n\n // Replacing\n const out = [];\n for (i = 0; i < cnt; i++) {\n const evald = this.visit(nodes[i]);\n if (evald === undefined) { continue; }\n if (!evald.splice) {\n out.push(evald);\n } else if (evald.length) {\n this.flatten(evald, out);\n }\n }\n return out;\n }\n\n flatten(arr, out) {\n if (!out) {\n out = [];\n }\n\n let cnt;\n let i;\n let item;\n let nestedCnt;\n let j;\n let nestedItem;\n\n for (i = 0, cnt = arr.length; i < cnt; i++) {\n item = arr[i];\n if (item === undefined) {\n continue;\n }\n if (!item.splice) {\n out.push(item);\n continue;\n }\n\n for (j = 0, nestedCnt = item.length; j < nestedCnt; j++) {\n nestedItem = item[j];\n if (nestedItem === undefined) {\n continue;\n }\n if (!nestedItem.splice) {\n out.push(nestedItem);\n } else if (nestedItem.length) {\n this.flatten(nestedItem, out);\n }\n }\n }\n\n return out;\n }\n}\n\nexport default Visitor;\n","class ImportSequencer {\n constructor(onSequencerEmpty) {\n this.imports = [];\n this.variableImports = [];\n this._onSequencerEmpty = onSequencerEmpty;\n this._currentDepth = 0;\n }\n\n addImport(callback) {\n const importSequencer = this;\n\n const importItem = {\n callback,\n args: null,\n isReady: false\n };\n\n this.imports.push(importItem);\n return function(...args) {\n importItem.args = Array.prototype.slice.call(args, 0);\n importItem.isReady = true;\n importSequencer.tryRun();\n };\n }\n\n addVariableImport(callback) {\n this.variableImports.push(callback);\n }\n\n tryRun() {\n this._currentDepth++;\n try {\n while (true) {\n while (this.imports.length > 0) {\n const importItem = this.imports[0];\n if (!importItem.isReady) {\n return;\n }\n this.imports = this.imports.slice(1);\n importItem.callback.apply(null, importItem.args);\n }\n if (this.variableImports.length === 0) {\n break;\n }\n const variableImport = this.variableImports[0];\n this.variableImports = this.variableImports.slice(1);\n variableImport();\n }\n } finally {\n this._currentDepth--;\n }\n if (this._currentDepth === 0 && this._onSequencerEmpty) {\n this._onSequencerEmpty();\n }\n }\n}\n\nexport default ImportSequencer;\n","import contexts from '../contexts';\nimport Visitor from './visitor';\nimport ImportSequencer from './import-sequencer';\nimport * as utils from '../utils';\n\nconst ImportVisitor = function(importer, finish) {\n\n this._visitor = new Visitor(this);\n this._importer = importer;\n this._finish = finish;\n this.context = new contexts.Eval();\n this.importCount = 0;\n this.onceFileDetectionMap = {};\n this.recursionDetector = {};\n this._sequencer = new ImportSequencer(this._onSequencerEmpty.bind(this));\n};\n\nImportVisitor.prototype = {\n isReplacing: false,\n run: function (root) {\n try {\n // process the contents\n this._visitor.visit(root);\n }\n catch (e) {\n this.error = e;\n }\n\n this.isFinished = true;\n this._sequencer.tryRun();\n },\n _onSequencerEmpty: function() {\n if (!this.isFinished) {\n return;\n }\n this._finish(this.error);\n },\n visitImport: function (importNode, visitArgs) {\n const inlineCSS = importNode.options.inline;\n\n if (!importNode.css || inlineCSS) {\n\n const context = new contexts.Eval(this.context, utils.copyArray(this.context.frames));\n const importParent = context.frames[0];\n\n this.importCount++;\n if (importNode.isVariableImport()) {\n this._sequencer.addVariableImport(this.processImportNode.bind(this, importNode, context, importParent));\n } else {\n this.processImportNode(importNode, context, importParent);\n }\n }\n visitArgs.visitDeeper = false;\n },\n processImportNode: function(importNode, context, importParent) {\n let evaldImportNode;\n const inlineCSS = importNode.options.inline;\n\n try {\n evaldImportNode = importNode.evalForImport(context);\n } catch (e) {\n if (!e.filename) { e.index = importNode.getIndex(); e.filename = importNode.fileInfo().filename; }\n // attempt to eval properly and treat as css\n importNode.css = true;\n // if that fails, this error will be thrown\n importNode.error = e;\n }\n\n if (evaldImportNode && (!evaldImportNode.css || inlineCSS)) {\n if (evaldImportNode.options.multiple) {\n context.importMultiple = true;\n }\n\n // try appending if we haven't determined if it is css or not\n const tryAppendLessExtension = evaldImportNode.css === undefined;\n\n for (let i = 0; i < importParent.rules.length; i++) {\n if (importParent.rules[i] === importNode) {\n importParent.rules[i] = evaldImportNode;\n break;\n }\n }\n\n const onImported = this.onImported.bind(this, evaldImportNode, context);\n const sequencedOnImported = this._sequencer.addImport(onImported);\n\n this._importer.push(evaldImportNode.getPath(), tryAppendLessExtension, evaldImportNode.fileInfo(),\n evaldImportNode.options, sequencedOnImported);\n } else {\n this.importCount--;\n if (this.isFinished) {\n this._sequencer.tryRun();\n }\n }\n },\n onImported: function (importNode, context, e, root, importedAtRoot, fullPath) {\n if (e) {\n if (!e.filename) {\n e.index = importNode.getIndex(); e.filename = importNode.fileInfo().filename;\n }\n this.error = e;\n }\n\n const importVisitor = this;\n const inlineCSS = importNode.options.inline;\n const isPlugin = importNode.options.isPlugin;\n const isOptional = importNode.options.optional;\n const duplicateImport = importedAtRoot || fullPath in importVisitor.recursionDetector;\n\n if (!context.importMultiple) {\n if (duplicateImport) {\n importNode.skip = true;\n } else {\n importNode.skip = () => {\n if (fullPath in importVisitor.onceFileDetectionMap) {\n return true;\n }\n importVisitor.onceFileDetectionMap[fullPath] = true;\n return false;\n };\n }\n }\n\n if (!fullPath && isOptional) {\n importNode.skip = true;\n }\n\n if (root) {\n importNode.root = root;\n importNode.importedFilename = fullPath;\n\n if (!inlineCSS && !isPlugin && (context.importMultiple || !duplicateImport)) {\n importVisitor.recursionDetector[fullPath] = true;\n\n const oldContext = this.context;\n this.context = context;\n try {\n this._visitor.visit(root);\n } catch (e) {\n this.error = e;\n }\n this.context = oldContext;\n }\n }\n\n importVisitor.importCount--;\n\n if (importVisitor.isFinished) {\n importVisitor._sequencer.tryRun();\n }\n },\n visitDeclaration: function (declNode, visitArgs) {\n if (declNode.value.type === 'DetachedRuleset') {\n this.context.frames.unshift(declNode);\n } else {\n visitArgs.visitDeeper = false;\n }\n },\n visitDeclarationOut: function(declNode) {\n if (declNode.value.type === 'DetachedRuleset') {\n this.context.frames.shift();\n }\n },\n visitAtRule: function (atRuleNode, visitArgs) {\n this.context.frames.unshift(atRuleNode);\n },\n visitAtRuleOut: function (atRuleNode) {\n this.context.frames.shift();\n },\n visitMixinDefinition: function (mixinDefinitionNode, visitArgs) {\n this.context.frames.unshift(mixinDefinitionNode);\n },\n visitMixinDefinitionOut: function (mixinDefinitionNode) {\n this.context.frames.shift();\n },\n visitRuleset: function (rulesetNode, visitArgs) {\n this.context.frames.unshift(rulesetNode);\n },\n visitRulesetOut: function (rulesetNode) {\n this.context.frames.shift();\n },\n visitMedia: function (mediaNode, visitArgs) {\n this.context.frames.unshift(mediaNode.rules[0]);\n },\n visitMediaOut: function (mediaNode) {\n this.context.frames.shift();\n }\n};\nexport default ImportVisitor;\n","class SetTreeVisibilityVisitor {\n constructor(visible) {\n this.visible = visible;\n }\n\n run(root) {\n this.visit(root);\n }\n\n visitArray(nodes) {\n if (!nodes) {\n return nodes;\n }\n\n const cnt = nodes.length;\n let i;\n for (i = 0; i < cnt; i++) {\n this.visit(nodes[i]);\n }\n return nodes;\n }\n\n visit(node) {\n if (!node) {\n return node;\n }\n if (node.constructor === Array) {\n return this.visitArray(node);\n }\n\n if (!node.blocksVisibility || node.blocksVisibility()) {\n return node;\n }\n if (this.visible) {\n node.ensureVisibility();\n } else {\n node.ensureInvisibility();\n }\n\n node.accept(this);\n return node;\n }\n}\n\nexport default SetTreeVisibilityVisitor;","import tree from '../tree';\nimport Visitor from './visitor';\nimport logger from '../logger';\nimport * as utils from '../utils';\n\n/* jshint loopfunc:true */\n\nclass ExtendFinderVisitor {\n constructor() {\n this._visitor = new Visitor(this);\n this.contexts = [];\n this.allExtendsStack = [[]];\n }\n\n run(root) {\n root = this._visitor.visit(root);\n root.allExtends = this.allExtendsStack[0];\n return root;\n }\n\n visitDeclaration(declNode, visitArgs) {\n visitArgs.visitDeeper = false;\n }\n\n visitMixinDefinition(mixinDefinitionNode, visitArgs) {\n visitArgs.visitDeeper = false;\n }\n\n visitRuleset(rulesetNode, visitArgs) {\n if (rulesetNode.root) {\n return;\n }\n\n let i;\n let j;\n let extend;\n const allSelectorsExtendList = [];\n let extendList;\n\n // get &:extend(.a); rules which apply to all selectors in this ruleset\n const rules = rulesetNode.rules;\n\n const ruleCnt = rules ? rules.length : 0;\n for (i = 0; i < ruleCnt; i++) {\n if (rulesetNode.rules[i] instanceof tree.Extend) {\n allSelectorsExtendList.push(rules[i]);\n rulesetNode.extendOnEveryPath = true;\n }\n }\n\n // now find every selector and apply the extends that apply to all extends\n // and the ones which apply to an individual extend\n const paths = rulesetNode.paths;\n for (i = 0; i < paths.length; i++) {\n const selectorPath = paths[i];\n const selector = selectorPath[selectorPath.length - 1];\n const selExtendList = selector.extendList;\n\n extendList = selExtendList ? utils.copyArray(selExtendList).concat(allSelectorsExtendList)\n : allSelectorsExtendList;\n\n if (extendList) {\n extendList = extendList.map(allSelectorsExtend => allSelectorsExtend.clone());\n }\n\n for (j = 0; j < extendList.length; j++) {\n this.foundExtends = true;\n extend = extendList[j];\n extend.findSelfSelectors(selectorPath);\n extend.ruleset = rulesetNode;\n if (j === 0) { extend.firstExtendOnThisSelectorPath = true; }\n this.allExtendsStack[this.allExtendsStack.length - 1].push(extend);\n }\n }\n\n this.contexts.push(rulesetNode.selectors);\n }\n\n visitRulesetOut(rulesetNode) {\n if (!rulesetNode.root) {\n this.contexts.length = this.contexts.length - 1;\n }\n }\n\n visitMedia(mediaNode, visitArgs) {\n mediaNode.allExtends = [];\n this.allExtendsStack.push(mediaNode.allExtends);\n }\n\n visitMediaOut(mediaNode) {\n this.allExtendsStack.length = this.allExtendsStack.length - 1;\n }\n\n visitAtRule(atRuleNode, visitArgs) {\n atRuleNode.allExtends = [];\n this.allExtendsStack.push(atRuleNode.allExtends);\n }\n\n visitAtRuleOut(atRuleNode) {\n this.allExtendsStack.length = this.allExtendsStack.length - 1;\n }\n}\n\nclass ProcessExtendsVisitor {\n constructor() {\n this._visitor = new Visitor(this);\n }\n\n run(root) {\n const extendFinder = new ExtendFinderVisitor();\n this.extendIndices = {};\n extendFinder.run(root);\n if (!extendFinder.foundExtends) { return root; }\n root.allExtends = root.allExtends.concat(this.doExtendChaining(root.allExtends, root.allExtends));\n this.allExtendsStack = [root.allExtends];\n const newRoot = this._visitor.visit(root);\n this.checkExtendsForNonMatched(root.allExtends);\n return newRoot;\n }\n\n checkExtendsForNonMatched(extendList) {\n const indices = this.extendIndices;\n extendList.filter(extend => !extend.hasFoundMatches && extend.parent_ids.length == 1).forEach(extend => {\n let selector = '_unknown_';\n try {\n selector = extend.selector.toCSS({});\n }\n catch (_) {}\n\n if (!indices[`${extend.index} ${selector}`]) {\n indices[`${extend.index} ${selector}`] = true;\n logger.warn(`extend '${selector}' has no matches`);\n }\n });\n }\n\n doExtendChaining(extendsList, extendsListTarget, iterationCount) {\n //\n // chaining is different from normal extension.. if we extend an extend then we are not just copying, altering\n // and pasting the selector we would do normally, but we are also adding an extend with the same target selector\n // this means this new extend can then go and alter other extends\n //\n // this method deals with all the chaining work - without it, extend is flat and doesn't work on other extend selectors\n // this is also the most expensive.. and a match on one selector can cause an extension of a selector we had already\n // processed if we look at each selector at a time, as is done in visitRuleset\n\n let extendIndex;\n\n let targetExtendIndex;\n let matches;\n const extendsToAdd = [];\n let newSelector;\n const extendVisitor = this;\n let selectorPath;\n let extend;\n let targetExtend;\n let newExtend;\n\n iterationCount = iterationCount || 0;\n\n // loop through comparing every extend with every target extend.\n // a target extend is the one on the ruleset we are looking at copy/edit/pasting in place\n // e.g. .a:extend(.b) {} and .b:extend(.c) {} then the first extend extends the second one\n // and the second is the target.\n // the separation into two lists allows us to process a subset of chains with a bigger set, as is the\n // case when processing media queries\n for (extendIndex = 0; extendIndex < extendsList.length; extendIndex++) {\n for (targetExtendIndex = 0; targetExtendIndex < extendsListTarget.length; targetExtendIndex++) {\n\n extend = extendsList[extendIndex];\n targetExtend = extendsListTarget[targetExtendIndex];\n\n // look for circular references\n if ( extend.parent_ids.indexOf( targetExtend.object_id ) >= 0 ) { continue; }\n\n // find a match in the target extends self selector (the bit before :extend)\n selectorPath = [targetExtend.selfSelectors[0]];\n matches = extendVisitor.findMatch(extend, selectorPath);\n\n if (matches.length) {\n extend.hasFoundMatches = true;\n\n // we found a match, so for each self selector..\n extend.selfSelectors.forEach(selfSelector => {\n const info = targetExtend.visibilityInfo();\n\n // process the extend as usual\n newSelector = extendVisitor.extendSelector(matches, selectorPath, selfSelector, extend.isVisible());\n\n // but now we create a new extend from it\n newExtend = new(tree.Extend)(targetExtend.selector, targetExtend.option, 0, targetExtend.fileInfo(), info);\n newExtend.selfSelectors = newSelector;\n\n // add the extend onto the list of extends for that selector\n newSelector[newSelector.length - 1].extendList = [newExtend];\n\n // record that we need to add it.\n extendsToAdd.push(newExtend);\n newExtend.ruleset = targetExtend.ruleset;\n\n // remember its parents for circular references\n newExtend.parent_ids = newExtend.parent_ids.concat(targetExtend.parent_ids, extend.parent_ids);\n\n // only process the selector once.. if we have :extend(.a,.b) then multiple\n // extends will look at the same selector path, so when extending\n // we know that any others will be duplicates in terms of what is added to the css\n if (targetExtend.firstExtendOnThisSelectorPath) {\n newExtend.firstExtendOnThisSelectorPath = true;\n targetExtend.ruleset.paths.push(newSelector);\n }\n });\n }\n }\n }\n\n if (extendsToAdd.length) {\n // try to detect circular references to stop a stack overflow.\n // may no longer be needed.\n this.extendChainCount++;\n if (iterationCount > 100) {\n let selectorOne = '{unable to calculate}';\n let selectorTwo = '{unable to calculate}';\n try {\n selectorOne = extendsToAdd[0].selfSelectors[0].toCSS();\n selectorTwo = extendsToAdd[0].selector.toCSS();\n }\n catch (e) {}\n throw { message: `extend circular reference detected. One of the circular extends is currently:${selectorOne}:extend(${selectorTwo})`};\n }\n\n // now process the new extends on the existing rules so that we can handle a extending b extending c extending\n // d extending e...\n return extendsToAdd.concat(extendVisitor.doExtendChaining(extendsToAdd, extendsListTarget, iterationCount + 1));\n } else {\n return extendsToAdd;\n }\n }\n\n visitDeclaration(ruleNode, visitArgs) {\n visitArgs.visitDeeper = false;\n }\n\n visitMixinDefinition(mixinDefinitionNode, visitArgs) {\n visitArgs.visitDeeper = false;\n }\n\n visitSelector(selectorNode, visitArgs) {\n visitArgs.visitDeeper = false;\n }\n\n visitRuleset(rulesetNode, visitArgs) {\n if (rulesetNode.root) {\n return;\n }\n let matches;\n let pathIndex;\n let extendIndex;\n const allExtends = this.allExtendsStack[this.allExtendsStack.length - 1];\n const selectorsToAdd = [];\n const extendVisitor = this;\n let selectorPath;\n\n // look at each selector path in the ruleset, find any extend matches and then copy, find and replace\n\n for (extendIndex = 0; extendIndex < allExtends.length; extendIndex++) {\n for (pathIndex = 0; pathIndex < rulesetNode.paths.length; pathIndex++) {\n selectorPath = rulesetNode.paths[pathIndex];\n\n // extending extends happens initially, before the main pass\n if (rulesetNode.extendOnEveryPath) { continue; }\n const extendList = selectorPath[selectorPath.length - 1].extendList;\n if (extendList && extendList.length) { continue; }\n\n matches = this.findMatch(allExtends[extendIndex], selectorPath);\n\n if (matches.length) {\n allExtends[extendIndex].hasFoundMatches = true;\n\n allExtends[extendIndex].selfSelectors.forEach(selfSelector => {\n let extendedSelectors;\n extendedSelectors = extendVisitor.extendSelector(matches, selectorPath, selfSelector, allExtends[extendIndex].isVisible());\n selectorsToAdd.push(extendedSelectors);\n });\n }\n }\n }\n rulesetNode.paths = rulesetNode.paths.concat(selectorsToAdd);\n }\n\n findMatch(extend, haystackSelectorPath) {\n //\n // look through the haystack selector path to try and find the needle - extend.selector\n // returns an array of selector matches that can then be replaced\n //\n let haystackSelectorIndex;\n\n let hackstackSelector;\n let hackstackElementIndex;\n let haystackElement;\n let targetCombinator;\n let i;\n const extendVisitor = this;\n const needleElements = extend.selector.elements;\n const potentialMatches = [];\n let potentialMatch;\n const matches = [];\n\n // loop through the haystack elements\n for (haystackSelectorIndex = 0; haystackSelectorIndex < haystackSelectorPath.length; haystackSelectorIndex++) {\n hackstackSelector = haystackSelectorPath[haystackSelectorIndex];\n\n for (hackstackElementIndex = 0; hackstackElementIndex < hackstackSelector.elements.length; hackstackElementIndex++) {\n\n haystackElement = hackstackSelector.elements[hackstackElementIndex];\n\n // if we allow elements before our match we can add a potential match every time. otherwise only at the first element.\n if (extend.allowBefore || (haystackSelectorIndex === 0 && hackstackElementIndex === 0)) {\n potentialMatches.push({pathIndex: haystackSelectorIndex, index: hackstackElementIndex, matched: 0,\n initialCombinator: haystackElement.combinator});\n }\n\n for (i = 0; i < potentialMatches.length; i++) {\n potentialMatch = potentialMatches[i];\n\n // selectors add \" \" onto the first element. When we use & it joins the selectors together, but if we don't\n // then each selector in haystackSelectorPath has a space before it added in the toCSS phase. so we need to\n // work out what the resulting combinator will be\n targetCombinator = haystackElement.combinator.value;\n if (targetCombinator === '' && hackstackElementIndex === 0) {\n targetCombinator = ' ';\n }\n\n // if we don't match, null our match to indicate failure\n if (!extendVisitor.isElementValuesEqual(needleElements[potentialMatch.matched].value, haystackElement.value) ||\n (potentialMatch.matched > 0 && needleElements[potentialMatch.matched].combinator.value !== targetCombinator)) {\n potentialMatch = null;\n } else {\n potentialMatch.matched++;\n }\n\n // if we are still valid and have finished, test whether we have elements after and whether these are allowed\n if (potentialMatch) {\n potentialMatch.finished = potentialMatch.matched === needleElements.length;\n if (potentialMatch.finished &&\n (!extend.allowAfter &&\n (hackstackElementIndex + 1 < hackstackSelector.elements.length || haystackSelectorIndex + 1 < haystackSelectorPath.length))) {\n potentialMatch = null;\n }\n }\n // if null we remove, if not, we are still valid, so either push as a valid match or continue\n if (potentialMatch) {\n if (potentialMatch.finished) {\n potentialMatch.length = needleElements.length;\n potentialMatch.endPathIndex = haystackSelectorIndex;\n potentialMatch.endPathElementIndex = hackstackElementIndex + 1; // index after end of match\n potentialMatches.length = 0; // we don't allow matches to overlap, so start matching again\n matches.push(potentialMatch);\n }\n } else {\n potentialMatches.splice(i, 1);\n i--;\n }\n }\n }\n }\n return matches;\n }\n\n isElementValuesEqual(elementValue1, elementValue2) {\n if (typeof elementValue1 === 'string' || typeof elementValue2 === 'string') {\n return elementValue1 === elementValue2;\n }\n if (elementValue1 instanceof tree.Attribute) {\n if (elementValue1.op !== elementValue2.op || elementValue1.key !== elementValue2.key) {\n return false;\n }\n if (!elementValue1.value || !elementValue2.value) {\n if (elementValue1.value || elementValue2.value) {\n return false;\n }\n return true;\n }\n elementValue1 = elementValue1.value.value || elementValue1.value;\n elementValue2 = elementValue2.value.value || elementValue2.value;\n return elementValue1 === elementValue2;\n }\n elementValue1 = elementValue1.value;\n elementValue2 = elementValue2.value;\n if (elementValue1 instanceof tree.Selector) {\n if (!(elementValue2 instanceof tree.Selector) || elementValue1.elements.length !== elementValue2.elements.length) {\n return false;\n }\n for (let i = 0; i < elementValue1.elements.length; i++) {\n if (elementValue1.elements[i].combinator.value !== elementValue2.elements[i].combinator.value) {\n if (i !== 0 || (elementValue1.elements[i].combinator.value || ' ') !== (elementValue2.elements[i].combinator.value || ' ')) {\n return false;\n }\n }\n if (!this.isElementValuesEqual(elementValue1.elements[i].value, elementValue2.elements[i].value)) {\n return false;\n }\n }\n return true;\n }\n return false;\n }\n\n extendSelector(matches, selectorPath, replacementSelector, isVisible) {\n // for a set of matches, replace each match with the replacement selector\n\n let currentSelectorPathIndex = 0;\n\n let currentSelectorPathElementIndex = 0;\n let path = [];\n let matchIndex;\n let selector;\n let firstElement;\n let match;\n let newElements;\n\n for (matchIndex = 0; matchIndex < matches.length; matchIndex++) {\n match = matches[matchIndex];\n selector = selectorPath[match.pathIndex];\n firstElement = new tree.Element(\n match.initialCombinator,\n replacementSelector.elements[0].value,\n replacementSelector.elements[0].isVariable,\n replacementSelector.elements[0].getIndex(),\n replacementSelector.elements[0].fileInfo()\n );\n\n if (match.pathIndex > currentSelectorPathIndex && currentSelectorPathElementIndex > 0) {\n path[path.length - 1].elements = path[path.length - 1]\n .elements.concat(selectorPath[currentSelectorPathIndex].elements.slice(currentSelectorPathElementIndex));\n currentSelectorPathElementIndex = 0;\n currentSelectorPathIndex++;\n }\n\n newElements = selector.elements\n .slice(currentSelectorPathElementIndex, match.index)\n .concat([firstElement])\n .concat(replacementSelector.elements.slice(1));\n\n if (currentSelectorPathIndex === match.pathIndex && matchIndex > 0) {\n path[path.length - 1].elements =\n path[path.length - 1].elements.concat(newElements);\n } else {\n path = path.concat(selectorPath.slice(currentSelectorPathIndex, match.pathIndex));\n\n path.push(new tree.Selector(\n newElements\n ));\n }\n currentSelectorPathIndex = match.endPathIndex;\n currentSelectorPathElementIndex = match.endPathElementIndex;\n if (currentSelectorPathElementIndex >= selectorPath[currentSelectorPathIndex].elements.length) {\n currentSelectorPathElementIndex = 0;\n currentSelectorPathIndex++;\n }\n }\n\n if (currentSelectorPathIndex < selectorPath.length && currentSelectorPathElementIndex > 0) {\n path[path.length - 1].elements = path[path.length - 1]\n .elements.concat(selectorPath[currentSelectorPathIndex].elements.slice(currentSelectorPathElementIndex));\n currentSelectorPathIndex++;\n }\n\n path = path.concat(selectorPath.slice(currentSelectorPathIndex, selectorPath.length));\n path = path.map(currentValue => {\n // we can re-use elements here, because the visibility property matters only for selectors\n const derived = currentValue.createDerived(currentValue.elements);\n if (isVisible) {\n derived.ensureVisibility();\n } else {\n derived.ensureInvisibility();\n }\n return derived;\n });\n return path;\n }\n\n visitMedia(mediaNode, visitArgs) {\n let newAllExtends = mediaNode.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length - 1]);\n newAllExtends = newAllExtends.concat(this.doExtendChaining(newAllExtends, mediaNode.allExtends));\n this.allExtendsStack.push(newAllExtends);\n }\n\n visitMediaOut(mediaNode) {\n const lastIndex = this.allExtendsStack.length - 1;\n this.allExtendsStack.length = lastIndex;\n }\n\n visitAtRule(atRuleNode, visitArgs) {\n let newAllExtends = atRuleNode.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length - 1]);\n newAllExtends = newAllExtends.concat(this.doExtendChaining(newAllExtends, atRuleNode.allExtends));\n this.allExtendsStack.push(newAllExtends);\n }\n\n visitAtRuleOut(atRuleNode) {\n const lastIndex = this.allExtendsStack.length - 1;\n this.allExtendsStack.length = lastIndex;\n }\n}\n\nexport default ProcessExtendsVisitor;\n","import Visitor from './visitor';\n\nclass JoinSelectorVisitor {\n constructor() {\n this.contexts = [[]];\n this._visitor = new Visitor(this);\n }\n\n run(root) {\n return this._visitor.visit(root);\n }\n\n visitDeclaration(declNode, visitArgs) {\n visitArgs.visitDeeper = false;\n }\n\n visitMixinDefinition(mixinDefinitionNode, visitArgs) {\n visitArgs.visitDeeper = false;\n }\n\n visitRuleset(rulesetNode, visitArgs) {\n const context = this.contexts[this.contexts.length - 1];\n const paths = [];\n let selectors;\n\n this.contexts.push(paths);\n\n if (!rulesetNode.root) {\n selectors = rulesetNode.selectors;\n if (selectors) {\n selectors = selectors.filter(selector => selector.getIsOutput());\n rulesetNode.selectors = selectors.length ? selectors : (selectors = null);\n if (selectors) { rulesetNode.joinSelectors(paths, context, selectors); }\n }\n if (!selectors) { rulesetNode.rules = null; }\n rulesetNode.paths = paths;\n }\n }\n\n visitRulesetOut(rulesetNode) {\n this.contexts.length = this.contexts.length - 1;\n }\n\n visitMedia(mediaNode, visitArgs) {\n const context = this.contexts[this.contexts.length - 1];\n mediaNode.rules[0].root = (context.length === 0 || context[0].multiMedia);\n }\n\n visitAtRule(atRuleNode, visitArgs) {\n const context = this.contexts[this.contexts.length - 1];\n if (atRuleNode.rules && atRuleNode.rules.length) {\n atRuleNode.rules[0].root = (atRuleNode.isRooted || context.length === 0 || null);\n }\n }\n}\n\nexport default JoinSelectorVisitor;\n","import tree from '../tree';\nimport Visitor from './visitor';\n\nclass CSSVisitorUtils {\n constructor(context) {\n this._visitor = new Visitor(this);\n this._context = context;\n }\n\n containsSilentNonBlockedChild(bodyRules) {\n let rule;\n if (!bodyRules) {\n return false;\n }\n for (let r = 0; r < bodyRules.length; r++) {\n rule = bodyRules[r];\n if (rule.isSilent && rule.isSilent(this._context) && !rule.blocksVisibility()) {\n // the atrule contains something that was referenced (likely by extend)\n // therefore it needs to be shown in output too\n return true;\n }\n }\n return false;\n }\n\n keepOnlyVisibleChilds(owner) {\n if (owner && owner.rules) {\n owner.rules = owner.rules.filter(thing => thing.isVisible());\n }\n }\n\n isEmpty(owner) {\n return (owner && owner.rules) \n ? (owner.rules.length === 0) : true;\n }\n\n hasVisibleSelector(rulesetNode) {\n return (rulesetNode && rulesetNode.paths)\n ? (rulesetNode.paths.length > 0) : false;\n }\n\n resolveVisibility(node, originalRules) {\n if (!node.blocksVisibility()) {\n if (this.isEmpty(node) && !this.containsSilentNonBlockedChild(originalRules)) {\n return ;\n }\n\n return node;\n }\n\n const compiledRulesBody = node.rules[0];\n this.keepOnlyVisibleChilds(compiledRulesBody);\n\n if (this.isEmpty(compiledRulesBody)) {\n return ;\n }\n\n node.ensureVisibility();\n node.removeVisibilityBlock();\n\n return node;\n }\n\n isVisibleRuleset(rulesetNode) {\n if (rulesetNode.firstRoot) {\n return true;\n }\n\n if (this.isEmpty(rulesetNode)) {\n return false;\n }\n\n if (!rulesetNode.root && !this.hasVisibleSelector(rulesetNode)) {\n return false;\n }\n\n return true;\n }\n}\n\nconst ToCSSVisitor = function(context) {\n this._visitor = new Visitor(this);\n this._context = context;\n this.utils = new CSSVisitorUtils(context);\n};\n\nToCSSVisitor.prototype = {\n isReplacing: true,\n run: function (root) {\n return this._visitor.visit(root);\n },\n\n visitDeclaration: function (declNode, visitArgs) {\n if (declNode.blocksVisibility() || declNode.variable) {\n return;\n }\n return declNode;\n },\n\n visitMixinDefinition: function (mixinNode, visitArgs) {\n // mixin definitions do not get eval'd - this means they keep state\n // so we have to clear that state here so it isn't used if toCSS is called twice\n mixinNode.frames = [];\n },\n\n visitExtend: function (extendNode, visitArgs) {\n },\n\n visitComment: function (commentNode, visitArgs) {\n if (commentNode.blocksVisibility() || commentNode.isSilent(this._context)) {\n return;\n }\n return commentNode;\n },\n\n visitMedia: function(mediaNode, visitArgs) {\n const originalRules = mediaNode.rules[0].rules;\n mediaNode.accept(this._visitor);\n visitArgs.visitDeeper = false;\n\n return this.utils.resolveVisibility(mediaNode, originalRules);\n },\n\n visitImport: function (importNode, visitArgs) {\n if (importNode.blocksVisibility()) {\n return ;\n }\n return importNode;\n },\n\n visitAtRule: function(atRuleNode, visitArgs) {\n if (atRuleNode.rules && atRuleNode.rules.length) {\n return this.visitAtRuleWithBody(atRuleNode, visitArgs);\n } else {\n return this.visitAtRuleWithoutBody(atRuleNode, visitArgs);\n }\n },\n\n visitAnonymous: function(anonymousNode, visitArgs) {\n if (!anonymousNode.blocksVisibility()) {\n anonymousNode.accept(this._visitor);\n return anonymousNode;\n }\n },\n\n visitAtRuleWithBody: function(atRuleNode, visitArgs) {\n // if there is only one nested ruleset and that one has no path, then it is\n // just fake ruleset\n function hasFakeRuleset(atRuleNode) {\n const bodyRules = atRuleNode.rules;\n return bodyRules.length === 1 && (!bodyRules[0].paths || bodyRules[0].paths.length === 0);\n }\n function getBodyRules(atRuleNode) {\n const nodeRules = atRuleNode.rules;\n if (hasFakeRuleset(atRuleNode)) {\n return nodeRules[0].rules;\n }\n\n return nodeRules;\n }\n // it is still true that it is only one ruleset in array\n // this is last such moment\n // process childs\n const originalRules = getBodyRules(atRuleNode);\n atRuleNode.accept(this._visitor);\n visitArgs.visitDeeper = false;\n\n if (!this.utils.isEmpty(atRuleNode)) {\n this._mergeRules(atRuleNode.rules[0].rules);\n }\n\n return this.utils.resolveVisibility(atRuleNode, originalRules);\n },\n\n visitAtRuleWithoutBody: function(atRuleNode, visitArgs) {\n if (atRuleNode.blocksVisibility()) {\n return;\n }\n\n if (atRuleNode.name === '@charset') {\n // Only output the debug info together with subsequent @charset definitions\n // a comment (or @media statement) before the actual @charset atrule would\n // be considered illegal css as it has to be on the first line\n if (this.charset) {\n if (atRuleNode.debugInfo) {\n const comment = new tree.Comment(`/* ${atRuleNode.toCSS(this._context).replace(/\\n/g, '')} */\\n`);\n comment.debugInfo = atRuleNode.debugInfo;\n return this._visitor.visit(comment);\n }\n return;\n }\n this.charset = true;\n }\n\n return atRuleNode;\n },\n\n checkValidNodes: function(rules, isRoot) {\n if (!rules) {\n return;\n }\n\n for (let i = 0; i < rules.length; i++) {\n const ruleNode = rules[i];\n if (isRoot && ruleNode instanceof tree.Declaration && !ruleNode.variable) {\n throw { message: 'Properties must be inside selector blocks. They cannot be in the root',\n index: ruleNode.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename};\n }\n if (ruleNode instanceof tree.Call) {\n throw { message: `Function '${ruleNode.name}' is undefined`,\n index: ruleNode.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename};\n }\n if (ruleNode.type && !ruleNode.allowRoot) {\n throw { message: `${ruleNode.type} node returned by a function is not valid here`,\n index: ruleNode.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename};\n }\n }\n },\n\n visitRuleset: function (rulesetNode, visitArgs) {\n // at this point rulesets are nested into each other\n let rule;\n\n const rulesets = [];\n\n this.checkValidNodes(rulesetNode.rules, rulesetNode.firstRoot);\n\n if (!rulesetNode.root) {\n // remove invisible paths\n this._compileRulesetPaths(rulesetNode);\n\n // remove rulesets from this ruleset body and compile them separately\n const nodeRules = rulesetNode.rules;\n\n let nodeRuleCnt = nodeRules ? nodeRules.length : 0;\n for (let i = 0; i < nodeRuleCnt; ) {\n rule = nodeRules[i];\n if (rule && rule.rules) {\n // visit because we are moving them out from being a child\n rulesets.push(this._visitor.visit(rule));\n nodeRules.splice(i, 1);\n nodeRuleCnt--;\n continue;\n }\n i++;\n }\n // accept the visitor to remove rules and refactor itself\n // then we can decide nogw whether we want it or not\n // compile body\n if (nodeRuleCnt > 0) {\n rulesetNode.accept(this._visitor);\n } else {\n rulesetNode.rules = null;\n }\n visitArgs.visitDeeper = false;\n } else { // if (! rulesetNode.root) {\n rulesetNode.accept(this._visitor);\n visitArgs.visitDeeper = false;\n }\n\n if (rulesetNode.rules) {\n this._mergeRules(rulesetNode.rules);\n this._removeDuplicateRules(rulesetNode.rules);\n }\n\n // now decide whether we keep the ruleset\n if (this.utils.isVisibleRuleset(rulesetNode)) {\n rulesetNode.ensureVisibility();\n rulesets.splice(0, 0, rulesetNode);\n }\n\n if (rulesets.length === 1) {\n return rulesets[0];\n }\n return rulesets;\n },\n\n _compileRulesetPaths: function(rulesetNode) {\n if (rulesetNode.paths) {\n rulesetNode.paths = rulesetNode.paths\n .filter(p => {\n let i;\n if (p[0].elements[0].combinator.value === ' ') {\n p[0].elements[0].combinator = new(tree.Combinator)('');\n }\n for (i = 0; i < p.length; i++) {\n if (p[i].isVisible() && p[i].getIsOutput()) {\n return true;\n }\n }\n return false;\n });\n }\n },\n\n _removeDuplicateRules: function(rules) {\n if (!rules) { return; }\n\n // remove duplicates\n const ruleCache = {};\n\n let ruleList;\n let rule;\n let i;\n\n for (i = rules.length - 1; i >= 0 ; i--) {\n rule = rules[i];\n if (rule instanceof tree.Declaration) {\n if (!ruleCache[rule.name]) {\n ruleCache[rule.name] = rule;\n } else {\n ruleList = ruleCache[rule.name];\n if (ruleList instanceof tree.Declaration) {\n ruleList = ruleCache[rule.name] = [ruleCache[rule.name].toCSS(this._context)];\n }\n const ruleCSS = rule.toCSS(this._context);\n if (ruleList.indexOf(ruleCSS) !== -1) {\n rules.splice(i, 1);\n } else {\n ruleList.push(ruleCSS);\n }\n }\n }\n }\n },\n\n _mergeRules: function(rules) {\n if (!rules) {\n return; \n }\n\n const groups = {};\n const groupsArr = [];\n\n for (let i = 0; i < rules.length; i++) {\n const rule = rules[i];\n if (rule.merge) {\n const key = rule.name;\n groups[key] ? rules.splice(i--, 1) : \n groupsArr.push(groups[key] = []);\n groups[key].push(rule);\n }\n }\n\n groupsArr.forEach(group => {\n if (group.length > 0) {\n const result = group[0];\n let space = [];\n const comma = [new tree.Expression(space)];\n group.forEach(rule => {\n if ((rule.merge === '+') && (space.length > 0)) {\n comma.push(new tree.Expression(space = []));\n }\n space.push(rule.value);\n result.important = result.important || rule.important;\n });\n result.value = new tree.Value(comma);\n }\n });\n }\n};\n\nexport default ToCSSVisitor;\n","import Visitor from './visitor';\nimport ImportVisitor from './import-visitor';\nimport MarkVisibleSelectorsVisitor from './set-tree-visibility-visitor';\nimport ExtendVisitor from './extend-visitor';\nimport JoinSelectorVisitor from './join-selector-visitor';\nimport ToCSSVisitor from './to-css-visitor';\n\nexport default {\n Visitor,\n ImportVisitor,\n MarkVisibleSelectorsVisitor,\n ExtendVisitor,\n JoinSelectorVisitor,\n ToCSSVisitor\n};\n","import chunker from './chunker';\n\nexport default () => {\n let // Less input string\n input;\n\n let // current chunk\n j;\n\n const // holds state for backtracking\n saveStack = [];\n\n let // furthest index the parser has gone to\n furthest;\n\n let // if this is furthest we got to, this is the probably cause\n furthestPossibleErrorMessage;\n\n let // chunkified input\n chunks;\n\n let // current chunk\n current;\n\n let // index of current chunk, in `input`\n currentPos;\n\n const parserInput = {};\n const CHARCODE_SPACE = 32;\n const CHARCODE_TAB = 9;\n const CHARCODE_LF = 10;\n const CHARCODE_CR = 13;\n const CHARCODE_PLUS = 43;\n const CHARCODE_COMMA = 44;\n const CHARCODE_FORWARD_SLASH = 47;\n const CHARCODE_9 = 57;\n\n function skipWhitespace(length) {\n const oldi = parserInput.i;\n const oldj = j;\n const curr = parserInput.i - currentPos;\n const endIndex = parserInput.i + current.length - curr;\n const mem = (parserInput.i += length);\n const inp = input;\n let c;\n let nextChar;\n let comment;\n\n for (; parserInput.i < endIndex; parserInput.i++) {\n c = inp.charCodeAt(parserInput.i);\n\n if (parserInput.autoCommentAbsorb && c === CHARCODE_FORWARD_SLASH) {\n nextChar = inp.charAt(parserInput.i + 1);\n if (nextChar === '/') {\n comment = {index: parserInput.i, isLineComment: true};\n let nextNewLine = inp.indexOf('\\n', parserInput.i + 2);\n if (nextNewLine < 0) {\n nextNewLine = endIndex;\n }\n parserInput.i = nextNewLine;\n comment.text = inp.substr(comment.index, parserInput.i - comment.index);\n parserInput.commentStore.push(comment);\n continue;\n } else if (nextChar === '*') {\n const nextStarSlash = inp.indexOf('*/', parserInput.i + 2);\n if (nextStarSlash >= 0) {\n comment = {\n index: parserInput.i,\n text: inp.substr(parserInput.i, nextStarSlash + 2 - parserInput.i),\n isLineComment: false\n };\n parserInput.i += comment.text.length - 1;\n parserInput.commentStore.push(comment);\n continue;\n }\n }\n break;\n }\n\n if ((c !== CHARCODE_SPACE) && (c !== CHARCODE_LF) && (c !== CHARCODE_TAB) && (c !== CHARCODE_CR)) {\n break;\n }\n }\n\n current = current.slice(length + parserInput.i - mem + curr);\n currentPos = parserInput.i;\n\n if (!current.length) {\n if (j < chunks.length - 1) {\n current = chunks[++j];\n skipWhitespace(0); // skip space at the beginning of a chunk\n return true; // things changed\n }\n parserInput.finished = true;\n }\n\n return oldi !== parserInput.i || oldj !== j;\n }\n\n parserInput.save = () => {\n currentPos = parserInput.i;\n saveStack.push( { current, i: parserInput.i, j });\n };\n parserInput.restore = possibleErrorMessage => {\n\n if (parserInput.i > furthest || (parserInput.i === furthest && possibleErrorMessage && !furthestPossibleErrorMessage)) {\n furthest = parserInput.i;\n furthestPossibleErrorMessage = possibleErrorMessage;\n }\n const state = saveStack.pop();\n current = state.current;\n currentPos = parserInput.i = state.i;\n j = state.j;\n };\n parserInput.forget = () => {\n saveStack.pop();\n };\n parserInput.isWhitespace = offset => {\n const pos = parserInput.i + (offset || 0);\n const code = input.charCodeAt(pos);\n return (code === CHARCODE_SPACE || code === CHARCODE_CR || code === CHARCODE_TAB || code === CHARCODE_LF);\n };\n\n // Specialization of $(tok)\n parserInput.$re = tok => {\n if (parserInput.i > currentPos) {\n current = current.slice(parserInput.i - currentPos);\n currentPos = parserInput.i;\n }\n\n const m = tok.exec(current);\n if (!m) {\n return null;\n }\n\n skipWhitespace(m[0].length);\n if (typeof m === 'string') {\n return m;\n }\n\n return m.length === 1 ? m[0] : m;\n };\n\n parserInput.$char = tok => {\n if (input.charAt(parserInput.i) !== tok) {\n return null;\n }\n skipWhitespace(1);\n return tok;\n };\n\n parserInput.$str = tok => {\n const tokLength = tok.length;\n\n // https://jsperf.com/string-startswith/21\n for (let i = 0; i < tokLength; i++) {\n if (input.charAt(parserInput.i + i) !== tok.charAt(i)) {\n return null;\n }\n }\n\n skipWhitespace(tokLength);\n return tok;\n };\n\n parserInput.$quoted = loc => {\n const pos = loc || parserInput.i;\n const startChar = input.charAt(pos);\n\n if (startChar !== '\\'' && startChar !== '\"') {\n return;\n }\n const length = input.length;\n const currentPosition = pos;\n\n for (let i = 1; i + currentPosition < length; i++) {\n const nextChar = input.charAt(i + currentPosition);\n switch (nextChar) {\n case '\\\\':\n i++;\n continue;\n case '\\r':\n case '\\n':\n break;\n case startChar:\n const str = input.substr(currentPosition, i + 1);\n if (!loc && loc !== 0) {\n skipWhitespace(i + 1);\n return str\n }\n return [startChar, str];\n default:\n }\n }\n return null;\n };\n\n /**\n * Permissive parsing. Ignores everything except matching {} [] () and quotes\n * until matching token (outside of blocks)\n */\n parserInput.$parseUntil = tok => {\n let quote = '';\n let returnVal = null;\n let inComment = false;\n let blockDepth = 0;\n const blockStack = [];\n const parseGroups = [];\n const length = input.length;\n const startPos = parserInput.i;\n let lastPos = parserInput.i;\n let i = parserInput.i;\n let loop = true;\n let testChar;\n\n if (typeof tok === 'string') {\n testChar = char => char === tok\n } else {\n testChar = char => tok.test(char)\n }\n\n do {\n let prevChar;\n let nextChar = input.charAt(i);\n if (blockDepth === 0 && testChar(nextChar)) {\n returnVal = input.substr(lastPos, i - lastPos);\n if (returnVal) {\n parseGroups.push(returnVal);\n }\n else {\n parseGroups.push(' ');\n }\n returnVal = parseGroups;\n skipWhitespace(i - startPos);\n loop = false\n } else {\n if (inComment) {\n if (nextChar === '*' && \n input.charAt(i + 1) === '/') {\n i++;\n blockDepth--;\n inComment = false;\n }\n i++;\n continue;\n }\n switch (nextChar) {\n case '\\\\':\n i++;\n nextChar = input.charAt(i);\n parseGroups.push(input.substr(lastPos, i - lastPos + 1));\n lastPos = i + 1;\n break;\n case '/':\n if (input.charAt(i + 1) === '*') {\n i++;\n inComment = true;\n blockDepth++;\n }\n break;\n case '\\'':\n case '\"':\n quote = parserInput.$quoted(i);\n if (quote) {\n parseGroups.push(input.substr(lastPos, i - lastPos), quote);\n i += quote[1].length - 1;\n lastPos = i + 1;\n }\n else {\n skipWhitespace(i - startPos);\n returnVal = nextChar;\n loop = false;\n }\n break;\n case '{':\n blockStack.push('}');\n blockDepth++;\n break;\n case '(':\n blockStack.push(')');\n blockDepth++;\n break;\n case '[':\n blockStack.push(']');\n blockDepth++;\n break;\n case '}':\n case ')':\n case ']':\n const expected = blockStack.pop();\n if (nextChar === expected) {\n blockDepth--;\n } else {\n // move the parser to the error and return expected\n skipWhitespace(i - startPos);\n returnVal = expected;\n loop = false;\n }\n }\n i++;\n if (i > length) {\n loop = false;\n }\n }\n prevChar = nextChar;\n } while (loop);\n\n return returnVal ? returnVal : null;\n }\n\n parserInput.autoCommentAbsorb = true;\n parserInput.commentStore = [];\n parserInput.finished = false;\n\n // Same as $(), but don't change the state of the parser,\n // just return the match.\n parserInput.peek = tok => {\n if (typeof tok === 'string') {\n // https://jsperf.com/string-startswith/21\n for (let i = 0; i < tok.length; i++) {\n if (input.charAt(parserInput.i + i) !== tok.charAt(i)) {\n return false;\n }\n }\n return true;\n } else {\n return tok.test(current);\n }\n };\n\n // Specialization of peek()\n // TODO remove or change some currentChar calls to peekChar\n parserInput.peekChar = tok => input.charAt(parserInput.i) === tok;\n\n parserInput.currentChar = () => input.charAt(parserInput.i);\n\n parserInput.prevChar = () => input.charAt(parserInput.i - 1);\n\n parserInput.getInput = () => input;\n\n parserInput.peekNotNumeric = () => {\n const c = input.charCodeAt(parserInput.i);\n // Is the first char of the dimension 0-9, '.', '+' or '-'\n return (c > CHARCODE_9 || c < CHARCODE_PLUS) || c === CHARCODE_FORWARD_SLASH || c === CHARCODE_COMMA;\n };\n\n parserInput.start = (str, chunkInput, failFunction) => {\n input = str;\n parserInput.i = j = currentPos = furthest = 0;\n\n // chunking apparently makes things quicker (but my tests indicate\n // it might actually make things slower in node at least)\n // and it is a non-perfect parse - it can't recognise\n // unquoted urls, meaning it can't distinguish comments\n // meaning comments with quotes or {}() in them get 'counted'\n // and then lead to parse errors.\n // In addition if the chunking chunks in the wrong place we might\n // not be able to parse a parser statement in one go\n // this is officially deprecated but can be switched on via an option\n // in the case it causes too much performance issues.\n if (chunkInput) {\n chunks = chunker(str, failFunction);\n } else {\n chunks = [str];\n }\n\n current = chunks[0];\n\n skipWhitespace(0);\n };\n\n parserInput.end = () => {\n let message;\n const isFinished = parserInput.i >= input.length;\n\n if (parserInput.i < furthest) {\n message = furthestPossibleErrorMessage;\n parserInput.i = furthest;\n }\n return {\n isFinished,\n furthest: parserInput.i,\n furthestPossibleErrorMessage: message,\n furthestReachedEnd: parserInput.i >= input.length - 1,\n furthestChar: input[parserInput.i]\n };\n };\n\n return parserInput;\n};\n","// Split the input into chunks.\nexport default (input, fail) => {\n const len = input.length;\n let level = 0;\n let parenLevel = 0;\n let lastOpening;\n let lastOpeningParen;\n let lastMultiComment;\n let lastMultiCommentEndBrace;\n const chunks = [];\n let emitFrom = 0;\n let chunkerCurrentIndex;\n let currentChunkStartIndex;\n let cc;\n let cc2;\n let matched;\n\n function emitChunk(force) {\n const len = chunkerCurrentIndex - emitFrom;\n if (((len < 512) && !force) || !len) {\n return;\n }\n chunks.push(input.slice(emitFrom, chunkerCurrentIndex + 1));\n emitFrom = chunkerCurrentIndex + 1;\n }\n\n for (chunkerCurrentIndex = 0; chunkerCurrentIndex < len; chunkerCurrentIndex++) {\n cc = input.charCodeAt(chunkerCurrentIndex);\n if (((cc >= 97) && (cc <= 122)) || (cc < 34)) {\n // a-z or whitespace\n continue;\n }\n\n switch (cc) {\n case 40: // (\n parenLevel++;\n lastOpeningParen = chunkerCurrentIndex;\n continue;\n case 41: // )\n if (--parenLevel < 0) {\n return fail('missing opening `(`', chunkerCurrentIndex);\n }\n continue;\n case 59: // ;\n if (!parenLevel) { emitChunk(); }\n continue;\n case 123: // {\n level++;\n lastOpening = chunkerCurrentIndex;\n continue;\n case 125: // }\n if (--level < 0) {\n return fail('missing opening `{`', chunkerCurrentIndex);\n }\n if (!level && !parenLevel) { emitChunk(); }\n continue;\n case 92: // \\\n if (chunkerCurrentIndex < len - 1) { chunkerCurrentIndex++; continue; }\n return fail('unescaped `\\\\`', chunkerCurrentIndex);\n case 34:\n case 39:\n case 96: // \", ' and `\n matched = 0;\n currentChunkStartIndex = chunkerCurrentIndex;\n for (chunkerCurrentIndex = chunkerCurrentIndex + 1; chunkerCurrentIndex < len; chunkerCurrentIndex++) {\n cc2 = input.charCodeAt(chunkerCurrentIndex);\n if (cc2 > 96) { continue; }\n if (cc2 == cc) { matched = 1; break; }\n if (cc2 == 92) { // \\\n if (chunkerCurrentIndex == len - 1) {\n return fail('unescaped `\\\\`', chunkerCurrentIndex);\n }\n chunkerCurrentIndex++;\n }\n }\n if (matched) { continue; }\n return fail(`unmatched \\`${String.fromCharCode(cc)}\\``, currentChunkStartIndex);\n case 47: // /, check for comment\n if (parenLevel || (chunkerCurrentIndex == len - 1)) { continue; }\n cc2 = input.charCodeAt(chunkerCurrentIndex + 1);\n if (cc2 == 47) {\n // //, find lnfeed\n for (chunkerCurrentIndex = chunkerCurrentIndex + 2; chunkerCurrentIndex < len; chunkerCurrentIndex++) {\n cc2 = input.charCodeAt(chunkerCurrentIndex);\n if ((cc2 <= 13) && ((cc2 == 10) || (cc2 == 13))) { break; }\n }\n } else if (cc2 == 42) {\n // /*, find */\n lastMultiComment = currentChunkStartIndex = chunkerCurrentIndex;\n for (chunkerCurrentIndex = chunkerCurrentIndex + 2; chunkerCurrentIndex < len - 1; chunkerCurrentIndex++) {\n cc2 = input.charCodeAt(chunkerCurrentIndex);\n if (cc2 == 125) { lastMultiCommentEndBrace = chunkerCurrentIndex; }\n if (cc2 != 42) { continue; }\n if (input.charCodeAt(chunkerCurrentIndex + 1) == 47) { break; }\n }\n if (chunkerCurrentIndex == len - 1) {\n return fail('missing closing `*/`', currentChunkStartIndex);\n }\n chunkerCurrentIndex++;\n }\n continue;\n case 42: // *, check for unmatched */\n if ((chunkerCurrentIndex < len - 1) && (input.charCodeAt(chunkerCurrentIndex + 1) == 47)) {\n return fail('unmatched `/*`', chunkerCurrentIndex);\n }\n continue;\n }\n }\n\n if (level !== 0) {\n if ((lastMultiComment > lastOpening) && (lastMultiCommentEndBrace > lastMultiComment)) {\n return fail('missing closing `}` or `*/`', lastOpening);\n } else {\n return fail('missing closing `}`', lastOpening);\n }\n } else if (parenLevel !== 0) {\n return fail('missing closing `)`', lastOpeningParen);\n }\n\n emitChunk(true);\n return chunks;\n};\n","import LessError from '../less-error';\nimport tree from '../tree';\nimport visitors from '../visitors';\nimport getParserInput from './parser-input';\nimport * as utils from '../utils';\nimport functionRegistry from '../functions/function-registry';\n\n//\n// less.js - parser\n//\n// A relatively straight-forward predictive parser.\n// There is no tokenization/lexing stage, the input is parsed\n// in one sweep.\n//\n// To make the parser fast enough to run in the browser, several\n// optimization had to be made:\n//\n// - Matching and slicing on a huge input is often cause of slowdowns.\n// The solution is to chunkify the input into smaller strings.\n// The chunks are stored in the `chunks` var,\n// `j` holds the current chunk index, and `currentPos` holds\n// the index of the current chunk in relation to `input`.\n// This gives us an almost 4x speed-up.\n//\n// - In many cases, we don't need to match individual tokens;\n// for example, if a value doesn't hold any variables, operations\n// or dynamic references, the parser can effectively 'skip' it,\n// treating it as a literal.\n// An example would be '1px solid #000' - which evaluates to itself,\n// we don't need to know what the individual components are.\n// The drawback, of course is that you don't get the benefits of\n// syntax-checking on the CSS. This gives us a 50% speed-up in the parser,\n// and a smaller speed-up in the code-gen.\n//\n//\n// Token matching is done with the `$` function, which either takes\n// a terminal string or regexp, or a non-terminal function to call.\n// It also takes care of moving all the indices forwards.\n//\n\nconst Parser = function Parser(context, imports, fileInfo) {\n let parsers;\n const parserInput = getParserInput();\n\n function error(msg, type) {\n throw new LessError(\n {\n index: parserInput.i,\n filename: fileInfo.filename,\n type: type || 'Syntax',\n message: msg\n },\n imports\n );\n }\n\n function expect(arg, msg) {\n // some older browsers return typeof 'function' for RegExp\n const result = (arg instanceof Function) ? arg.call(parsers) : parserInput.$re(arg);\n if (result) {\n return result;\n }\n \n error(msg || (typeof arg === 'string'\n ? `expected '${arg}' got '${parserInput.currentChar()}'`\n : 'unexpected token'));\n }\n\n // Specialization of expect()\n function expectChar(arg, msg) {\n if (parserInput.$char(arg)) {\n return arg;\n }\n error(msg || `expected '${arg}' got '${parserInput.currentChar()}'`);\n }\n\n function getDebugInfo(index) {\n const filename = fileInfo.filename;\n\n return {\n lineNumber: utils.getLocation(index, parserInput.getInput()).line + 1,\n fileName: filename\n };\n }\n\n /**\n * Used after initial parsing to create nodes on the fly\n * \n * @param {String} str - string to parse \n * @param {Array} parseList - array of parsers to run input through e.g. [\"value\", \"important\"]\n * @param {Number} currentIndex - start number to begin indexing\n * @param {Object} fileInfo - fileInfo to attach to created nodes\n */\n function parseNode(str, parseList, currentIndex, fileInfo, callback) {\n let result;\n const returnNodes = [];\n const parser = parserInput;\n\n try {\n parser.start(str, false, function fail(msg, index) {\n callback({\n message: msg,\n index: index + currentIndex\n });\n });\n for (let x = 0, p, i; (p = parseList[x]); x++) {\n i = parser.i;\n result = parsers[p]();\n if (result) {\n try {\n result._index = i + currentIndex;\n result._fileInfo = fileInfo;\n } catch (e) {}\n returnNodes.push(result);\n }\n else {\n returnNodes.push(null);\n }\n }\n\n const endInfo = parser.end();\n if (endInfo.isFinished) {\n callback(null, returnNodes);\n }\n else {\n callback(true, null);\n }\n } catch (e) {\n throw new LessError({\n index: e.index + currentIndex,\n message: e.message\n }, imports, fileInfo.filename);\n }\n }\n\n //\n // The Parser\n //\n return {\n parserInput,\n imports,\n fileInfo,\n parseNode,\n //\n // Parse an input string into an abstract syntax tree,\n // @param str A string containing 'less' markup\n // @param callback call `callback` when done.\n // @param [additionalData] An optional map which can contains vars - a map (key, value) of variables to apply\n //\n parse: function (str, callback, additionalData) {\n let root;\n let error = null;\n let globalVars;\n let modifyVars;\n let ignored;\n let preText = '';\n\n globalVars = (additionalData && additionalData.globalVars) ? `${Parser.serializeVars(additionalData.globalVars)}\\n` : '';\n modifyVars = (additionalData && additionalData.modifyVars) ? `\\n${Parser.serializeVars(additionalData.modifyVars)}` : '';\n\n if (context.pluginManager) {\n const preProcessors = context.pluginManager.getPreProcessors();\n for (let i = 0; i < preProcessors.length; i++) {\n str = preProcessors[i].process(str, { context, imports, fileInfo });\n }\n }\n\n if (globalVars || (additionalData && additionalData.banner)) {\n preText = ((additionalData && additionalData.banner) ? additionalData.banner : '') + globalVars;\n ignored = imports.contentsIgnoredChars;\n ignored[fileInfo.filename] = ignored[fileInfo.filename] || 0;\n ignored[fileInfo.filename] += preText.length;\n }\n\n str = str.replace(/\\r\\n?/g, '\\n');\n // Remove potential UTF Byte Order Mark\n str = preText + str.replace(/^\\uFEFF/, '') + modifyVars;\n imports.contents[fileInfo.filename] = str;\n\n // Start with the primary rule.\n // The whole syntax tree is held under a Ruleset node,\n // with the `root` property set to true, so no `{}` are\n // output. The callback is called when the input is parsed.\n try {\n parserInput.start(str, context.chunkInput, function fail(msg, index) {\n throw new LessError({\n index,\n type: 'Parse',\n message: msg,\n filename: fileInfo.filename\n }, imports);\n });\n\n tree.Node.prototype.parse = this;\n root = new tree.Ruleset(null, this.parsers.primary());\n tree.Node.prototype.rootNode = root;\n root.root = true;\n root.firstRoot = true;\n root.functionRegistry = functionRegistry.inherit();\n \n } catch (e) {\n return callback(new LessError(e, imports, fileInfo.filename));\n }\n\n // If `i` is smaller than the `input.length - 1`,\n // it means the parser wasn't able to parse the whole\n // string, so we've got a parsing error.\n //\n // We try to extract a \\n delimited string,\n // showing the line where the parse error occurred.\n // We split it up into two parts (the part which parsed,\n // and the part which didn't), so we can color them differently.\n const endInfo = parserInput.end();\n if (!endInfo.isFinished) {\n\n let message = endInfo.furthestPossibleErrorMessage;\n\n if (!message) {\n message = 'Unrecognised input';\n if (endInfo.furthestChar === '}') {\n message += '. Possibly missing opening \\'{\\'';\n } else if (endInfo.furthestChar === ')') {\n message += '. Possibly missing opening \\'(\\'';\n } else if (endInfo.furthestReachedEnd) {\n message += '. Possibly missing something';\n }\n }\n\n error = new LessError({\n type: 'Parse',\n message,\n index: endInfo.furthest,\n filename: fileInfo.filename\n }, imports);\n }\n\n const finish = e => {\n e = error || e || imports.error;\n\n if (e) {\n if (!(e instanceof LessError)) {\n e = new LessError(e, imports, fileInfo.filename);\n }\n\n return callback(e);\n }\n else {\n return callback(null, root);\n }\n };\n\n if (context.processImports !== false) {\n new visitors.ImportVisitor(imports, finish)\n .run(root);\n } else {\n return finish();\n }\n },\n\n //\n // Here in, the parsing rules/functions\n //\n // The basic structure of the syntax tree generated is as follows:\n //\n // Ruleset -> Declaration -> Value -> Expression -> Entity\n //\n // Here's some Less code:\n //\n // .class {\n // color: #fff;\n // border: 1px solid #000;\n // width: @w + 4px;\n // > .child {...}\n // }\n //\n // And here's what the parse tree might look like:\n //\n // Ruleset (Selector '.class', [\n // Declaration (\"color\", Value ([Expression [Color #fff]]))\n // Declaration (\"border\", Value ([Expression [Dimension 1px][Keyword \"solid\"][Color #000]]))\n // Declaration (\"width\", Value ([Expression [Operation \" + \" [Variable \"@w\"][Dimension 4px]]]))\n // Ruleset (Selector [Element '>', '.child'], [...])\n // ])\n //\n // In general, most rules will try to parse a token with the `$re()` function, and if the return\n // value is truly, will return a new node, of the relevant type. Sometimes, we need to check\n // first, before parsing, that's when we use `peek()`.\n //\n parsers: parsers = {\n //\n // The `primary` rule is the *entry* and *exit* point of the parser.\n // The rules here can appear at any level of the parse tree.\n //\n // The recursive nature of the grammar is an interplay between the `block`\n // rule, which represents `{ ... }`, the `ruleset` rule, and this `primary` rule,\n // as represented by this simplified grammar:\n //\n // primary → (ruleset | declaration)+\n // ruleset → selector+ block\n // block → '{' primary '}'\n //\n // Only at one point is the primary rule not called from the\n // block rule: at the root level.\n //\n primary: function () {\n const mixin = this.mixin;\n let root = [];\n let node;\n\n while (true) {\n while (true) {\n node = this.comment();\n if (!node) { break; }\n root.push(node);\n }\n // always process comments before deciding if finished\n if (parserInput.finished) {\n break;\n }\n if (parserInput.peek('}')) {\n break;\n }\n\n node = this.extendRule();\n if (node) {\n root = root.concat(node);\n continue;\n }\n\n node = mixin.definition() || this.declaration() || this.ruleset() ||\n mixin.call(false, false) || this.variableCall() || this.entities.call() || this.atrule();\n if (node) {\n root.push(node);\n } else {\n let foundSemiColon = false;\n while (parserInput.$char(';')) {\n foundSemiColon = true;\n }\n if (!foundSemiColon) {\n break;\n }\n }\n }\n\n return root;\n },\n\n // comments are collected by the main parsing mechanism and then assigned to nodes\n // where the current structure allows it\n comment: function () {\n if (parserInput.commentStore.length) {\n const comment = parserInput.commentStore.shift();\n return new(tree.Comment)(comment.text, comment.isLineComment, comment.index, fileInfo);\n }\n },\n\n //\n // Entities are tokens which can be found inside an Expression\n //\n entities: {\n mixinLookup: function() {\n return parsers.mixin.call(true, true);\n },\n //\n // A string, which supports escaping \" and '\n //\n // \"milky way\" 'he\\'s the one!'\n //\n quoted: function (forceEscaped) {\n let str;\n const index = parserInput.i;\n let isEscaped = false;\n\n parserInput.save();\n if (parserInput.$char('~')) {\n isEscaped = true;\n } else if (forceEscaped) {\n parserInput.restore();\n return;\n }\n\n str = parserInput.$quoted();\n if (!str) {\n parserInput.restore();\n return;\n }\n parserInput.forget();\n\n return new(tree.Quoted)(str.charAt(0), str.substr(1, str.length - 2), isEscaped, index, fileInfo);\n },\n\n //\n // A catch-all word, such as:\n //\n // black border-collapse\n //\n keyword: function () {\n const k = parserInput.$char('%') || parserInput.$re(/^\\[?(?:[\\w-]|\\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+\\]?/);\n if (k) {\n return tree.Color.fromKeyword(k) || new(tree.Keyword)(k);\n }\n },\n\n //\n // A function call\n //\n // rgb(255, 0, 255)\n //\n // The arguments are parsed with the `entities.arguments` parser.\n //\n call: function () {\n let name;\n let args;\n let func;\n const index = parserInput.i;\n\n // http://jsperf.com/case-insensitive-regex-vs-strtolower-then-regex/18\n if (parserInput.peek(/^url\\(/i)) {\n return;\n }\n\n parserInput.save();\n\n name = parserInput.$re(/^([\\w-]+|%|progid:[\\w\\.]+)\\(/);\n if (!name) {\n parserInput.forget(); \n return;\n }\n\n name = name[1];\n func = this.customFuncCall(name);\n if (func) {\n args = func.parse();\n if (args && func.stop) {\n parserInput.forget();\n return args;\n }\n }\n\n args = this.arguments(args);\n\n if (!parserInput.$char(')')) {\n parserInput.restore('Could not parse call arguments or missing \\')\\'');\n return;\n }\n\n parserInput.forget();\n\n return new(tree.Call)(name, args, index, fileInfo);\n },\n \n //\n // Parsing rules for functions with non-standard args, e.g.:\n //\n // boolean(not(2 > 1))\n //\n // This is a quick prototype, to be modified/improved when\n // more custom-parsed funcs come (e.g. `selector(...)`)\n //\n\n customFuncCall: function (name) {\n /* Ideally the table is to be moved out of here for faster perf.,\n but it's quite tricky since it relies on all these `parsers`\n and `expect` available only here */\n return {\n alpha: f(parsers.ieAlpha, true),\n boolean: f(condition),\n 'if': f(condition)\n }[name.toLowerCase()];\n\n function f(parse, stop) {\n return {\n parse, // parsing function\n stop // when true - stop after parse() and return its result, \n // otherwise continue for plain args\n };\n }\n \n function condition() {\n return [expect(parsers.condition, 'expected condition')];\n }\n },\n\n arguments: function (prevArgs) {\n let argsComma = prevArgs || [];\n const argsSemiColon = [];\n let isSemiColonSeparated;\n let value;\n\n parserInput.save();\n\n while (true) {\n if (prevArgs) {\n prevArgs = false;\n } else {\n value = parsers.detachedRuleset() || this.assignment() || parsers.expression();\n if (!value) {\n break;\n }\n\n if (value.value && value.value.length == 1) {\n value = value.value[0];\n }\n\n argsComma.push(value);\n }\n\n if (parserInput.$char(',')) {\n continue;\n }\n\n if (parserInput.$char(';') || isSemiColonSeparated) {\n isSemiColonSeparated = true;\n value = (argsComma.length < 1) ? argsComma[0]\n : new tree.Value(argsComma);\n argsSemiColon.push(value);\n argsComma = [];\n }\n }\n\n parserInput.forget();\n return isSemiColonSeparated ? argsSemiColon : argsComma;\n },\n literal: function () {\n return this.dimension() ||\n this.color() ||\n this.quoted() ||\n this.unicodeDescriptor();\n },\n\n // Assignments are argument entities for calls.\n // They are present in ie filter properties as shown below.\n //\n // filter: progid:DXImageTransform.Microsoft.Alpha( *opacity=50* )\n //\n\n assignment: function () {\n let key;\n let value;\n parserInput.save();\n key = parserInput.$re(/^\\w+(?=\\s?=)/i);\n if (!key) {\n parserInput.restore();\n return;\n }\n if (!parserInput.$char('=')) {\n parserInput.restore();\n return;\n }\n value = parsers.entity();\n if (value) {\n parserInput.forget();\n return new(tree.Assignment)(key, value);\n } else {\n parserInput.restore();\n }\n },\n\n //\n // Parse url() tokens\n //\n // We use a specific rule for urls, because they don't really behave like\n // standard function calls. The difference is that the argument doesn't have\n // to be enclosed within a string, so it can't be parsed as an Expression.\n //\n url: function () {\n let value;\n const index = parserInput.i;\n\n parserInput.autoCommentAbsorb = false;\n\n if (!parserInput.$str('url(')) {\n parserInput.autoCommentAbsorb = true;\n return;\n }\n\n value = this.quoted() || this.variable() || this.property() ||\n parserInput.$re(/^(?:(?:\\\\[\\(\\)'\"])|[^\\(\\)'\"])+/) || '';\n\n parserInput.autoCommentAbsorb = true;\n\n expectChar(')');\n\n return new(tree.URL)((value.value != null || \n value instanceof tree.Variable || \n value instanceof tree.Property) ?\n value : new(tree.Anonymous)(value, index), index, fileInfo);\n },\n\n //\n // A Variable entity, such as `@fink`, in\n //\n // width: @fink + 2px\n //\n // We use a different parser for variable definitions,\n // see `parsers.variable`.\n //\n variable: function () {\n let ch;\n let name;\n const index = parserInput.i;\n\n parserInput.save();\n if (parserInput.currentChar() === '@' && (name = parserInput.$re(/^@@?[\\w-]+/))) {\n ch = parserInput.currentChar();\n if (ch === '(' || ch === '[' && !parserInput.prevChar().match(/^\\s/)) {\n // this may be a VariableCall lookup\n const result = parsers.variableCall(name);\n if (result) {\n parserInput.forget();\n return result;\n }\n }\n parserInput.forget();\n return new(tree.Variable)(name, index, fileInfo);\n }\n parserInput.restore();\n },\n\n // A variable entity using the protective {} e.g. @{var}\n variableCurly: function () {\n let curly;\n const index = parserInput.i;\n\n if (parserInput.currentChar() === '@' && (curly = parserInput.$re(/^@\\{([\\w-]+)\\}/))) {\n return new(tree.Variable)(`@${curly[1]}`, index, fileInfo);\n }\n },\n //\n // A Property accessor, such as `$color`, in\n //\n // background-color: $color\n //\n property: function () {\n let name;\n const index = parserInput.i;\n\n if (parserInput.currentChar() === '$' && (name = parserInput.$re(/^\\$[\\w-]+/))) {\n return new(tree.Property)(name, index, fileInfo);\n }\n },\n\n // A property entity useing the protective {} e.g. ${prop}\n propertyCurly: function () {\n let curly;\n const index = parserInput.i;\n\n if (parserInput.currentChar() === '$' && (curly = parserInput.$re(/^\\$\\{([\\w-]+)\\}/))) {\n return new(tree.Property)(`$${curly[1]}`, index, fileInfo);\n }\n },\n //\n // A Hexadecimal color\n //\n // #4F3C2F\n //\n // `rgb` and `hsl` colors are parsed through the `entities.call` parser.\n //\n color: function () {\n let rgb;\n parserInput.save();\n\n if (parserInput.currentChar() === '#' && (rgb = parserInput.$re(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3,4})([\\w.#\\[])?/))) {\n if (!rgb[2]) {\n parserInput.forget();\n return new(tree.Color)(rgb[1], undefined, rgb[0]);\n } \n }\n parserInput.restore();\n },\n\n colorKeyword: function () {\n parserInput.save();\n const autoCommentAbsorb = parserInput.autoCommentAbsorb;\n parserInput.autoCommentAbsorb = false;\n const k = parserInput.$re(/^[_A-Za-z-][_A-Za-z0-9-]+/);\n parserInput.autoCommentAbsorb = autoCommentAbsorb;\n if (!k) {\n parserInput.forget();\n return;\n }\n parserInput.restore();\n const color = tree.Color.fromKeyword(k);\n if (color) {\n parserInput.$str(k);\n return color;\n }\n },\n\n //\n // A Dimension, that is, a number and a unit\n //\n // 0.5em 95%\n //\n dimension: function () {\n if (parserInput.peekNotNumeric()) {\n return;\n }\n\n const value = parserInput.$re(/^([+-]?\\d*\\.?\\d+)(%|[a-z_]+)?/i);\n if (value) {\n return new(tree.Dimension)(value[1], value[2]);\n }\n },\n\n //\n // A unicode descriptor, as is used in unicode-range\n //\n // U+0?? or U+00A1-00A9\n //\n unicodeDescriptor: function () {\n let ud;\n\n ud = parserInput.$re(/^U\\+[0-9a-fA-F?]+(\\-[0-9a-fA-F?]+)?/);\n if (ud) {\n return new(tree.UnicodeDescriptor)(ud[0]);\n }\n },\n\n //\n // JavaScript code to be evaluated\n //\n // `window.location.href`\n //\n javascript: function () {\n let js;\n const index = parserInput.i;\n\n parserInput.save();\n\n const escape = parserInput.$char('~');\n const jsQuote = parserInput.$char('`');\n\n if (!jsQuote) {\n parserInput.restore();\n return;\n }\n\n js = parserInput.$re(/^[^`]*`/);\n if (js) {\n parserInput.forget();\n return new(tree.JavaScript)(js.substr(0, js.length - 1), Boolean(escape), index, fileInfo);\n }\n parserInput.restore('invalid javascript definition');\n }\n },\n\n //\n // The variable part of a variable definition. Used in the `rule` parser\n //\n // @fink:\n //\n variable: function () {\n let name;\n\n if (parserInput.currentChar() === '@' && (name = parserInput.$re(/^(@[\\w-]+)\\s*:/))) { return name[1]; }\n },\n\n //\n // Call a variable value to retrieve a detached ruleset\n // or a value from a detached ruleset's rules.\n //\n // @fink();\n // @fink;\n // color: @fink[@color];\n //\n variableCall: function (parsedName) {\n let lookups;\n let important;\n const i = parserInput.i;\n const inValue = !!parsedName;\n let name = parsedName;\n\n parserInput.save();\n\n if (name || (parserInput.currentChar() === '@'\n && (name = parserInput.$re(/^(@[\\w-]+)(\\(\\s*\\))?/)))) {\n\n lookups = this.mixin.ruleLookups();\n\n if (!lookups && ((inValue && parserInput.$str('()') !== '()') || (name[2] !== '()'))) {\n parserInput.restore('Missing \\'[...]\\' lookup in variable call');\n return;\n }\n\n if (!inValue) {\n name = name[1];\n }\n\n if (lookups && parsers.important()) {\n important = true;\n }\n\n const call = new tree.VariableCall(name, i, fileInfo);\n if (!inValue && parsers.end()) {\n parserInput.forget();\n return call;\n }\n else {\n parserInput.forget();\n return new tree.NamespaceValue(call, lookups, important, i, fileInfo);\n }\n }\n\n parserInput.restore();\n },\n\n //\n // extend syntax - used to extend selectors\n //\n extend: function(isRule) {\n let elements;\n let e;\n const index = parserInput.i;\n let option;\n let extendList;\n let extend;\n\n if (!parserInput.$str(isRule ? '&:extend(' : ':extend(')) {\n return;\n }\n\n do {\n option = null;\n elements = null;\n while (!(option = parserInput.$re(/^(all)(?=\\s*(\\)|,))/))) {\n e = this.element();\n if (!e) {\n break;\n }\n if (elements) {\n elements.push(e);\n } else {\n elements = [ e ];\n }\n }\n\n option = option && option[1];\n if (!elements) {\n error('Missing target selector for :extend().');\n }\n extend = new(tree.Extend)(new(tree.Selector)(elements), option, index, fileInfo);\n if (extendList) {\n extendList.push(extend);\n } else {\n extendList = [ extend ];\n }\n } while (parserInput.$char(','));\n\n expect(/^\\)/);\n\n if (isRule) {\n expect(/^;/);\n }\n\n return extendList;\n },\n\n //\n // extendRule - used in a rule to extend all the parent selectors\n //\n extendRule: function() {\n return this.extend(true);\n },\n\n //\n // Mixins\n //\n mixin: {\n //\n // A Mixin call, with an optional argument list\n //\n // #mixins > .square(#fff);\n // #mixins.square(#fff);\n // .rounded(4px, black);\n // .button;\n //\n // We can lookup / return a value using the lookup syntax:\n //\n // color: #mixin.square(#fff)[@color];\n //\n // The `while` loop is there because mixins can be\n // namespaced, but we only support the child and descendant\n // selector for now.\n //\n call: function (inValue, getLookup) {\n const s = parserInput.currentChar();\n let important = false;\n let lookups;\n const index = parserInput.i;\n let elements;\n let args;\n let hasParens;\n\n if (s !== '.' && s !== '#') { return; }\n\n parserInput.save(); // stop us absorbing part of an invalid selector\n\n elements = this.elements();\n\n if (elements) {\n if (parserInput.$char('(')) {\n args = this.args(true).args;\n expectChar(')');\n hasParens = true;\n }\n\n if (getLookup !== false) {\n lookups = this.ruleLookups();\n }\n if (getLookup === true && !lookups) {\n parserInput.restore();\n return;\n }\n\n if (inValue && !lookups && !hasParens) {\n // This isn't a valid in-value mixin call\n parserInput.restore();\n return;\n }\n\n if (!inValue && parsers.important()) {\n important = true;\n }\n\n if (inValue || parsers.end()) {\n parserInput.forget();\n const mixin = new(tree.mixin.Call)(elements, args, index, fileInfo, !lookups && important);\n if (lookups) {\n return new tree.NamespaceValue(mixin, lookups, important);\n }\n else {\n return mixin;\n }\n }\n }\n\n parserInput.restore();\n },\n /**\n * Matching elements for mixins\n * (Start with . or # and can have > )\n */\n elements: function() {\n let elements;\n let e;\n let c;\n let elem;\n let elemIndex;\n const re = /^[#.](?:[\\w-]|\\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/;\n while (true) {\n elemIndex = parserInput.i;\n e = parserInput.$re(re);\n \n if (!e) {\n break;\n }\n elem = new(tree.Element)(c, e, false, elemIndex, fileInfo);\n if (elements) {\n elements.push(elem);\n } else {\n elements = [ elem ];\n }\n c = parserInput.$char('>');\n }\n return elements;\n },\n args: function (isCall) {\n const entities = parsers.entities;\n const returner = { args:null, variadic: false };\n let expressions = [];\n const argsSemiColon = [];\n const argsComma = [];\n let isSemiColonSeparated;\n let expressionContainsNamed;\n let name;\n let nameLoop;\n let value;\n let arg;\n let expand;\n let hasSep = true;\n\n parserInput.save();\n\n while (true) {\n if (isCall) {\n arg = parsers.detachedRuleset() || parsers.expression();\n } else {\n parserInput.commentStore.length = 0;\n if (parserInput.$str('...')) {\n returner.variadic = true;\n if (parserInput.$char(';') && !isSemiColonSeparated) {\n isSemiColonSeparated = true;\n }\n (isSemiColonSeparated ? argsSemiColon : argsComma)\n .push({ variadic: true });\n break;\n }\n arg = entities.variable() || entities.property() || entities.literal() || entities.keyword() || this.call(true);\n }\n\n if (!arg || !hasSep) {\n break;\n }\n\n nameLoop = null;\n if (arg.throwAwayComments) {\n arg.throwAwayComments();\n }\n value = arg;\n let val = null;\n\n if (isCall) {\n // Variable\n if (arg.value && arg.value.length == 1) {\n val = arg.value[0];\n }\n } else {\n val = arg;\n }\n\n if (val && (val instanceof tree.Variable || val instanceof tree.Property)) {\n if (parserInput.$char(':')) {\n if (expressions.length > 0) {\n if (isSemiColonSeparated) {\n error('Cannot mix ; and , as delimiter types');\n }\n expressionContainsNamed = true;\n }\n\n value = parsers.detachedRuleset() || parsers.expression();\n\n if (!value) {\n if (isCall) {\n error('could not understand value for named argument');\n } else {\n parserInput.restore();\n returner.args = [];\n return returner;\n }\n }\n nameLoop = (name = val.name);\n } else if (parserInput.$str('...')) {\n if (!isCall) {\n returner.variadic = true;\n if (parserInput.$char(';') && !isSemiColonSeparated) {\n isSemiColonSeparated = true;\n }\n (isSemiColonSeparated ? argsSemiColon : argsComma)\n .push({ name: arg.name, variadic: true });\n break;\n } else {\n expand = true;\n }\n } else if (!isCall) {\n name = nameLoop = val.name;\n value = null;\n }\n }\n\n if (value) {\n expressions.push(value);\n }\n\n argsComma.push({ name:nameLoop, value, expand });\n\n if (parserInput.$char(',')) {\n hasSep = true;\n continue;\n }\n hasSep = parserInput.$char(';') === ';';\n\n if (hasSep || isSemiColonSeparated) {\n\n if (expressionContainsNamed) {\n error('Cannot mix ; and , as delimiter types');\n }\n\n isSemiColonSeparated = true;\n\n if (expressions.length > 1) {\n value = new(tree.Value)(expressions);\n }\n argsSemiColon.push({ name, value, expand });\n\n name = null;\n expressions = [];\n expressionContainsNamed = false;\n }\n }\n\n parserInput.forget();\n returner.args = isSemiColonSeparated ? argsSemiColon : argsComma;\n return returner;\n },\n //\n // A Mixin definition, with a list of parameters\n //\n // .rounded (@radius: 2px, @color) {\n // ...\n // }\n //\n // Until we have a finer grained state-machine, we have to\n // do a look-ahead, to make sure we don't have a mixin call.\n // See the `rule` function for more information.\n //\n // We start by matching `.rounded (`, and then proceed on to\n // the argument list, which has optional default values.\n // We store the parameters in `params`, with a `value` key,\n // if there is a value, such as in the case of `@radius`.\n //\n // Once we've got our params list, and a closing `)`, we parse\n // the `{...}` block.\n //\n definition: function () {\n let name;\n let params = [];\n let match;\n let ruleset;\n let cond;\n let variadic = false;\n if ((parserInput.currentChar() !== '.' && parserInput.currentChar() !== '#') ||\n parserInput.peek(/^[^{]*\\}/)) {\n return;\n }\n\n parserInput.save();\n\n match = parserInput.$re(/^([#.](?:[\\w-]|\\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+)\\s*\\(/);\n if (match) {\n name = match[1];\n\n const argInfo = this.args(false);\n params = argInfo.args;\n variadic = argInfo.variadic;\n\n // .mixincall(\"@{a}\");\n // looks a bit like a mixin definition..\n // also\n // .mixincall(@a: {rule: set;});\n // so we have to be nice and restore\n if (!parserInput.$char(')')) {\n parserInput.restore('Missing closing \\')\\'');\n return;\n }\n\n parserInput.commentStore.length = 0;\n\n if (parserInput.$str('when')) { // Guard\n cond = expect(parsers.conditions, 'expected condition');\n }\n\n ruleset = parsers.block();\n\n if (ruleset) {\n parserInput.forget();\n return new(tree.mixin.Definition)(name, params, ruleset, cond, variadic);\n } else {\n parserInput.restore();\n }\n } else {\n parserInput.forget();\n }\n },\n \n ruleLookups: function() {\n let rule;\n let args;\n const lookups = [];\n\n if (parserInput.currentChar() !== '[') { \n return;\n }\n\n while (true) {\n parserInput.save();\n args = null;\n rule = this.lookupValue();\n if (!rule && rule !== '') {\n parserInput.restore();\n break;\n }\n lookups.push(rule);\n parserInput.forget();\n }\n if (lookups.length > 0) {\n return lookups;\n }\n },\n \n lookupValue: function() {\n parserInput.save();\n \n if (!parserInput.$char('[')) { \n parserInput.restore();\n return;\n }\n \n const name = parserInput.$re(/^(?:[@$]{0,2})[_a-zA-Z0-9-]*/);\n \n if (!parserInput.$char(']')) {\n parserInput.restore();\n return;\n } \n\n if (name || name === '') {\n parserInput.forget();\n return name;\n }\n \n parserInput.restore();\n }\n },\n //\n // Entities are the smallest recognized token,\n // and can be found inside a rule's value.\n //\n entity: function () {\n const entities = this.entities;\n\n return this.comment() || entities.literal() || entities.variable() || entities.url() ||\n entities.property() || entities.call() || entities.keyword() || this.mixin.call(true) ||\n entities.javascript();\n },\n\n //\n // A Declaration terminator. Note that we use `peek()` to check for '}',\n // because the `block` rule will be expecting it, but we still need to make sure\n // it's there, if ';' was omitted.\n //\n end: function () {\n return parserInput.$char(';') || parserInput.peek('}');\n },\n\n //\n // IE's alpha function\n //\n // alpha(opacity=88)\n //\n ieAlpha: function () {\n let value;\n\n // http://jsperf.com/case-insensitive-regex-vs-strtolower-then-regex/18\n if (!parserInput.$re(/^opacity=/i)) { return; }\n value = parserInput.$re(/^\\d+/);\n if (!value) {\n value = expect(parsers.entities.variable, 'Could not parse alpha');\n value = `@{${value.name.slice(1)}}`;\n }\n expectChar(')');\n return new tree.Quoted('', `alpha(opacity=${value})`);\n },\n\n //\n // A Selector Element\n //\n // div\n // + h1\n // #socks\n // input[type=\"text\"]\n //\n // Elements are the building blocks for Selectors,\n // they are made out of a `Combinator` (see combinator rule),\n // and an element name, such as a tag a class, or `*`.\n //\n element: function () {\n let e;\n let c;\n let v;\n const index = parserInput.i;\n\n c = this.combinator();\n\n e = parserInput.$re(/^(?:\\d+\\.\\d+|\\d+)%/) ||\n parserInput.$re(/^(?:[.#]?|:*)(?:[\\w-]|[^\\x00-\\x9f]|\\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/) ||\n parserInput.$char('*') || parserInput.$char('&') || this.attribute() ||\n parserInput.$re(/^\\([^&()@]+\\)/) || parserInput.$re(/^[\\.#:](?=@)/) ||\n this.entities.variableCurly();\n\n if (!e) {\n parserInput.save();\n if (parserInput.$char('(')) {\n if ((v = this.selector(false)) && parserInput.$char(')')) {\n e = new(tree.Paren)(v);\n parserInput.forget();\n } else {\n parserInput.restore('Missing closing \\')\\'');\n }\n } else {\n parserInput.forget();\n }\n }\n\n if (e) { return new(tree.Element)(c, e, e instanceof tree.Variable, index, fileInfo); }\n },\n\n //\n // Combinators combine elements together, in a Selector.\n //\n // Because our parser isn't white-space sensitive, special care\n // has to be taken, when parsing the descendant combinator, ` `,\n // as it's an empty space. We have to check the previous character\n // in the input, to see if it's a ` ` character. More info on how\n // we deal with this in *combinator.js*.\n //\n combinator: function () {\n let c = parserInput.currentChar();\n\n if (c === '/') {\n parserInput.save();\n const slashedCombinator = parserInput.$re(/^\\/[a-z]+\\//i);\n if (slashedCombinator) {\n parserInput.forget();\n return new(tree.Combinator)(slashedCombinator);\n }\n parserInput.restore();\n }\n\n if (c === '>' || c === '+' || c === '~' || c === '|' || c === '^') {\n parserInput.i++;\n if (c === '^' && parserInput.currentChar() === '^') {\n c = '^^';\n parserInput.i++;\n }\n while (parserInput.isWhitespace()) { parserInput.i++; }\n return new(tree.Combinator)(c);\n } else if (parserInput.isWhitespace(-1)) {\n return new(tree.Combinator)(' ');\n } else {\n return new(tree.Combinator)(null);\n }\n },\n //\n // A CSS Selector\n // with less extensions e.g. the ability to extend and guard\n //\n // .class > div + h1\n // li a:hover\n //\n // Selectors are made out of one or more Elements, see above.\n //\n selector: function (isLess) {\n const index = parserInput.i;\n let elements;\n let extendList;\n let c;\n let e;\n let allExtends;\n let when;\n let condition;\n isLess = isLess !== false;\n while ((isLess && (extendList = this.extend())) || (isLess && (when = parserInput.$str('when'))) || (e = this.element())) {\n if (when) {\n condition = expect(this.conditions, 'expected condition');\n } else if (condition) {\n error('CSS guard can only be used at the end of selector');\n } else if (extendList) {\n if (allExtends) {\n allExtends = allExtends.concat(extendList);\n } else {\n allExtends = extendList;\n }\n } else {\n if (allExtends) { error('Extend can only be used at the end of selector'); }\n c = parserInput.currentChar();\n if (elements) {\n elements.push(e);\n } else {\n elements = [ e ];\n }\n e = null;\n }\n if (c === '{' || c === '}' || c === ';' || c === ',' || c === ')') {\n break;\n }\n }\n\n if (elements) { return new(tree.Selector)(elements, allExtends, condition, index, fileInfo); }\n if (allExtends) { error('Extend must be used to extend a selector, it cannot be used on its own'); }\n },\n selectors: function () {\n let s;\n let selectors;\n while (true) {\n s = this.selector();\n if (!s) {\n break;\n }\n if (selectors) {\n selectors.push(s);\n } else {\n selectors = [ s ];\n }\n parserInput.commentStore.length = 0;\n if (s.condition && selectors.length > 1) {\n error(\"Guards are only currently allowed on a single selector.\");\n }\n if (!parserInput.$char(',')) { break; }\n if (s.condition) {\n error(\"Guards are only currently allowed on a single selector.\");\n }\n parserInput.commentStore.length = 0;\n }\n return selectors;\n },\n attribute: function () {\n if (!parserInput.$char('[')) { return; }\n\n const entities = this.entities;\n let key;\n let val;\n let op;\n\n if (!(key = entities.variableCurly())) {\n key = expect(/^(?:[_A-Za-z0-9-\\*]*\\|)?(?:[_A-Za-z0-9-]|\\\\.)+/);\n }\n\n op = parserInput.$re(/^[|~*$^]?=/);\n if (op) {\n val = entities.quoted() || parserInput.$re(/^[0-9]+%/) || parserInput.$re(/^[\\w-]+/) || entities.variableCurly();\n }\n\n expectChar(']');\n\n return new(tree.Attribute)(key, op, val);\n },\n\n //\n // The `block` rule is used by `ruleset` and `mixin.definition`.\n // It's a wrapper around the `primary` rule, with added `{}`.\n //\n block: function () {\n let content;\n if (parserInput.$char('{') && (content = this.primary()) && parserInput.$char('}')) {\n return content;\n }\n },\n\n blockRuleset: function() {\n let block = this.block();\n\n if (block) {\n block = new tree.Ruleset(null, block);\n }\n return block;\n },\n\n detachedRuleset: function() {\n let argInfo;\n let params;\n let variadic;\n\n parserInput.save();\n if (parserInput.$re(/^[.#]\\(/)) {\n /**\n * DR args currently only implemented for each() function, and not \n * yet settable as `@dr: #(@arg) {}`\n * This should be done when DRs are merged with mixins.\n * See: https://github.com/less/less-meta/issues/16\n */\n argInfo = this.mixin.args(false);\n params = argInfo.args;\n variadic = argInfo.variadic;\n if (!parserInput.$char(')')) {\n parserInput.restore();\n return;\n }\n }\n const blockRuleset = this.blockRuleset();\n if (blockRuleset) {\n parserInput.forget();\n if (params) {\n return new tree.mixin.Definition(null, params, blockRuleset, null, variadic);\n }\n return new tree.DetachedRuleset(blockRuleset);\n }\n parserInput.restore();\n },\n\n //\n // div, .class, body > p {...}\n //\n ruleset: function () {\n let selectors;\n let rules;\n let debugInfo;\n\n parserInput.save();\n\n if (context.dumpLineNumbers) {\n debugInfo = getDebugInfo(parserInput.i);\n }\n\n selectors = this.selectors();\n\n if (selectors && (rules = this.block())) {\n parserInput.forget();\n const ruleset = new(tree.Ruleset)(selectors, rules, context.strictImports);\n if (context.dumpLineNumbers) {\n ruleset.debugInfo = debugInfo;\n }\n return ruleset;\n } else {\n parserInput.restore();\n }\n },\n declaration: function () {\n let name;\n let value;\n const index = parserInput.i;\n let hasDR;\n const c = parserInput.currentChar();\n let important;\n let merge;\n let isVariable;\n\n if (c === '.' || c === '#' || c === '&' || c === ':') { return; }\n\n parserInput.save();\n\n name = this.variable() || this.ruleProperty();\n if (name) {\n isVariable = typeof name === 'string';\n\n if (isVariable) {\n value = this.detachedRuleset();\n if (value) {\n hasDR = true;\n }\n }\n\n parserInput.commentStore.length = 0;\n if (!value) {\n // a name returned by this.ruleProperty() is always an array of the form:\n // [string-1, ..., string-n, \"\"] or [string-1, ..., string-n, \"+\"]\n // where each item is a tree.Keyword or tree.Variable\n merge = !isVariable && name.length > 1 && name.pop().value;\n\n // Custom property values get permissive parsing\n if (name[0].value && name[0].value.slice(0, 2) === '--') {\n value = this.permissiveValue();\n }\n // Try to store values as anonymous\n // If we need the value later we'll re-parse it in ruleset.parseValue\n else {\n value = this.anonymousValue();\n }\n if (value) {\n parserInput.forget();\n // anonymous values absorb the end ';' which is required for them to work\n return new(tree.Declaration)(name, value, false, merge, index, fileInfo);\n }\n\n if (!value) {\n value = this.value();\n }\n\n if (value) {\n important = this.important();\n } else if (isVariable) {\n // As a last resort, try permissiveValue\n value = this.permissiveValue();\n }\n }\n\n if (value && (this.end() || hasDR)) {\n parserInput.forget();\n return new(tree.Declaration)(name, value, important, merge, index, fileInfo);\n }\n else {\n parserInput.restore();\n }\n } else {\n parserInput.restore();\n }\n },\n anonymousValue: function () {\n const index = parserInput.i;\n const match = parserInput.$re(/^([^.#@\\$+\\/'\"*`(;{}-]*);/);\n if (match) {\n return new(tree.Anonymous)(match[1], index);\n }\n },\n /**\n * Used for custom properties, at-rules, and variables (as fallback)\n * Parses almost anything inside of {} [] () \"\" blocks\n * until it reaches outer-most tokens.\n * \n * First, it will try to parse comments and entities to reach\n * the end. This is mostly like the Expression parser except no\n * math is allowed.\n */\n permissiveValue: function (untilTokens) {\n let i;\n let e;\n let done;\n let value;\n const tok = untilTokens || ';';\n const index = parserInput.i;\n const result = [];\n\n function testCurrentChar() {\n const char = parserInput.currentChar();\n if (typeof tok === 'string') {\n return char === tok;\n } else {\n return tok.test(char);\n }\n }\n if (testCurrentChar()) {\n return;\n }\n value = [];\n do {\n e = this.comment();\n if (e) {\n value.push(e);\n continue;\n }\n e = this.entity();\n if (e) {\n value.push(e);\n }\n } while (e);\n\n done = testCurrentChar();\n\n if (value.length > 0) {\n value = new(tree.Expression)(value);\n if (done) {\n return value;\n }\n else {\n result.push(value);\n }\n // Preserve space before $parseUntil as it will not\n if (parserInput.prevChar() === ' ') {\n result.push(new tree.Anonymous(' ', index));\n }\n }\n parserInput.save();\n\n value = parserInput.$parseUntil(tok);\n\n if (value) {\n if (typeof value === 'string') {\n error(`Expected '${value}'`, 'Parse');\n }\n if (value.length === 1 && value[0] === ' ') {\n parserInput.forget();\n return new tree.Anonymous('', index);\n }\n let item;\n for (i = 0; i < value.length; i++) {\n item = value[i];\n if (Array.isArray(item)) {\n // Treat actual quotes as normal quoted values\n result.push(new tree.Quoted(item[0], item[1], true, index, fileInfo));\n }\n else {\n if (i === value.length - 1) {\n item = item.trim();\n }\n // Treat like quoted values, but replace vars like unquoted expressions\n const quote = new tree.Quoted('\\'', item, true, index, fileInfo);\n quote.variableRegex = /@([\\w-]+)/g;\n quote.propRegex = /\\$([\\w-]+)/g;\n result.push(quote);\n }\n }\n parserInput.forget();\n return new tree.Expression(result, true);\n }\n parserInput.restore();\n },\n\n //\n // An @import atrule\n //\n // @import \"lib\";\n //\n // Depending on our environment, importing is done differently:\n // In the browser, it's an XHR request, in Node, it would be a\n // file-system operation. The function used for importing is\n // stored in `import`, which we pass to the Import constructor.\n //\n 'import': function () {\n let path;\n let features;\n const index = parserInput.i;\n\n const dir = parserInput.$re(/^@import?\\s+/);\n\n if (dir) {\n const options = (dir ? this.importOptions() : null) || {};\n\n if ((path = this.entities.quoted() || this.entities.url())) {\n features = this.mediaFeatures();\n\n if (!parserInput.$char(';')) {\n parserInput.i = index;\n error('missing semi-colon or unrecognised media features on import');\n }\n features = features && new(tree.Value)(features);\n return new(tree.Import)(path, features, options, index, fileInfo);\n }\n else {\n parserInput.i = index;\n error('malformed import statement');\n }\n }\n },\n\n importOptions: function() {\n let o;\n const options = {};\n let optionName;\n let value;\n\n // list of options, surrounded by parens\n if (!parserInput.$char('(')) { return null; }\n do {\n o = this.importOption();\n if (o) {\n optionName = o;\n value = true;\n switch (optionName) {\n case 'css':\n optionName = 'less';\n value = false;\n break;\n case 'once':\n optionName = 'multiple';\n value = false;\n break;\n }\n options[optionName] = value;\n if (!parserInput.$char(',')) { break; }\n }\n } while (o);\n expectChar(')');\n return options;\n },\n\n importOption: function() {\n const opt = parserInput.$re(/^(less|css|multiple|once|inline|reference|optional)/);\n if (opt) {\n return opt[1];\n }\n },\n\n mediaFeature: function () {\n const entities = this.entities;\n const nodes = [];\n let e;\n let p;\n parserInput.save();\n do {\n e = entities.keyword() || entities.variable() || entities.mixinLookup();\n if (e) {\n nodes.push(e);\n } else if (parserInput.$char('(')) {\n p = this.property();\n e = this.value();\n if (parserInput.$char(')')) {\n if (p && e) {\n nodes.push(new(tree.Paren)(new(tree.Declaration)(p, e, null, null, parserInput.i, fileInfo, true)));\n } else if (e) {\n nodes.push(new(tree.Paren)(e));\n } else {\n error('badly formed media feature definition');\n }\n } else {\n error('Missing closing \\')\\'', 'Parse');\n }\n }\n } while (e);\n\n parserInput.forget();\n if (nodes.length > 0) {\n return new(tree.Expression)(nodes);\n }\n },\n\n mediaFeatures: function () {\n const entities = this.entities;\n const features = [];\n let e;\n do {\n e = this.mediaFeature();\n if (e) {\n features.push(e);\n if (!parserInput.$char(',')) { break; }\n } else {\n e = entities.variable() || entities.mixinLookup();\n if (e) {\n features.push(e);\n if (!parserInput.$char(',')) { break; }\n }\n }\n } while (e);\n\n return features.length > 0 ? features : null;\n },\n\n media: function () {\n let features;\n let rules;\n let media;\n let debugInfo;\n const index = parserInput.i;\n\n if (context.dumpLineNumbers) {\n debugInfo = getDebugInfo(index);\n }\n\n parserInput.save();\n\n if (parserInput.$str('@media')) {\n features = this.mediaFeatures();\n\n rules = this.block();\n\n if (!rules) {\n error('media definitions require block statements after any features');\n }\n\n parserInput.forget();\n\n media = new(tree.Media)(rules, features, index, fileInfo);\n if (context.dumpLineNumbers) {\n media.debugInfo = debugInfo;\n }\n\n return media;\n }\n\n parserInput.restore();\n },\n\n //\n\n // A @plugin directive, used to import plugins dynamically.\n //\n // @plugin (args) \"lib\";\n //\n plugin: function () {\n let path;\n let args;\n let options;\n const index = parserInput.i;\n const dir = parserInput.$re(/^@plugin?\\s+/);\n\n if (dir) {\n args = this.pluginArgs();\n\n if (args) {\n options = {\n pluginArgs: args,\n isPlugin: true\n };\n }\n else {\n options = { isPlugin: true };\n }\n\n if ((path = this.entities.quoted() || this.entities.url())) {\n\n if (!parserInput.$char(';')) {\n parserInput.i = index;\n error('missing semi-colon on @plugin');\n }\n return new(tree.Import)(path, null, options, index, fileInfo);\n }\n else {\n parserInput.i = index;\n error('malformed @plugin statement');\n }\n }\n },\n\n pluginArgs: function() {\n // list of options, surrounded by parens\n parserInput.save();\n if (!parserInput.$char('(')) {\n parserInput.restore();\n return null;\n }\n const args = parserInput.$re(/^\\s*([^\\);]+)\\)\\s*/);\n if (args[1]) {\n parserInput.forget();\n return args[1].trim();\n }\n else { \n parserInput.restore();\n return null;\n }\n },\n\n //\n // A CSS AtRule\n //\n // @charset \"utf-8\";\n //\n atrule: function () {\n const index = parserInput.i;\n let name;\n let value;\n let rules;\n let nonVendorSpecificName;\n let hasIdentifier;\n let hasExpression;\n let hasUnknown;\n let hasBlock = true;\n let isRooted = true;\n\n if (parserInput.currentChar() !== '@') { return; }\n\n value = this['import']() || this.plugin() || this.media();\n if (value) {\n return value;\n }\n\n parserInput.save();\n\n name = parserInput.$re(/^@[a-z-]+/);\n\n if (!name) { return; }\n\n nonVendorSpecificName = name;\n if (name.charAt(1) == '-' && name.indexOf('-', 2) > 0) {\n nonVendorSpecificName = `@${name.slice(name.indexOf('-', 2) + 1)}`;\n }\n\n switch (nonVendorSpecificName) {\n case '@charset':\n hasIdentifier = true;\n hasBlock = false;\n break;\n case '@namespace':\n hasExpression = true;\n hasBlock = false;\n break;\n case '@keyframes':\n case '@counter-style':\n hasIdentifier = true;\n break;\n case '@document':\n case '@supports':\n hasUnknown = true;\n isRooted = false;\n break;\n default:\n hasUnknown = true;\n break;\n }\n\n parserInput.commentStore.length = 0;\n\n if (hasIdentifier) {\n value = this.entity();\n if (!value) {\n error(`expected ${name} identifier`);\n }\n } else if (hasExpression) {\n value = this.expression();\n if (!value) {\n error(`expected ${name} expression`);\n }\n } else if (hasUnknown) {\n value = this.permissiveValue(/^[{;]/);\n hasBlock = (parserInput.currentChar() === '{');\n if (!value) {\n if (!hasBlock && parserInput.currentChar() !== ';') {\n error(`${name} rule is missing block or ending semi-colon`);\n }\n }\n else if (!value.value) {\n value = null;\n }\n }\n\n if (hasBlock) {\n rules = this.blockRuleset();\n }\n\n if (rules || (!hasBlock && value && parserInput.$char(';'))) {\n parserInput.forget();\n return new(tree.AtRule)(name, value, rules, index, fileInfo,\n context.dumpLineNumbers ? getDebugInfo(index) : null,\n isRooted\n );\n }\n\n parserInput.restore('at-rule options not recognised');\n },\n\n //\n // A Value is a comma-delimited list of Expressions\n //\n // font-family: Baskerville, Georgia, serif;\n //\n // In a Rule, a Value represents everything after the `:`,\n // and before the `;`.\n //\n value: function () {\n let e;\n const expressions = [];\n const index = parserInput.i;\n\n do {\n e = this.expression();\n if (e) {\n expressions.push(e);\n if (!parserInput.$char(',')) { break; }\n }\n } while (e);\n\n if (expressions.length > 0) {\n return new(tree.Value)(expressions, index);\n }\n },\n important: function () {\n if (parserInput.currentChar() === '!') {\n return parserInput.$re(/^! *important/);\n }\n },\n sub: function () {\n let a;\n let e;\n\n parserInput.save();\n if (parserInput.$char('(')) {\n a = this.addition();\n if (a && parserInput.$char(')')) {\n parserInput.forget();\n e = new(tree.Expression)([a]);\n e.parens = true;\n return e;\n }\n parserInput.restore('Expected \\')\\'');\n return;\n }\n parserInput.restore();\n },\n multiplication: function () {\n let m;\n let a;\n let op;\n let operation;\n let isSpaced;\n m = this.operand();\n if (m) {\n isSpaced = parserInput.isWhitespace(-1);\n while (true) {\n if (parserInput.peek(/^\\/[*\\/]/)) {\n break;\n }\n\n parserInput.save();\n\n op = parserInput.$char('/') || parserInput.$char('*') || parserInput.$str('./');\n\n if (!op) { parserInput.forget(); break; }\n\n a = this.operand();\n\n if (!a) { parserInput.restore(); break; }\n parserInput.forget();\n\n m.parensInOp = true;\n a.parensInOp = true;\n operation = new(tree.Operation)(op, [operation || m, a], isSpaced);\n isSpaced = parserInput.isWhitespace(-1);\n }\n return operation || m;\n }\n },\n addition: function () {\n let m;\n let a;\n let op;\n let operation;\n let isSpaced;\n m = this.multiplication();\n if (m) {\n isSpaced = parserInput.isWhitespace(-1);\n while (true) {\n op = parserInput.$re(/^[-+]\\s+/) || (!isSpaced && (parserInput.$char('+') || parserInput.$char('-')));\n if (!op) {\n break;\n }\n a = this.multiplication();\n if (!a) {\n break;\n }\n\n m.parensInOp = true;\n a.parensInOp = true;\n operation = new(tree.Operation)(op, [operation || m, a], isSpaced);\n isSpaced = parserInput.isWhitespace(-1);\n }\n return operation || m;\n }\n },\n conditions: function () {\n let a;\n let b;\n const index = parserInput.i;\n let condition;\n\n a = this.condition(true);\n if (a) {\n while (true) {\n if (!parserInput.peek(/^,\\s*(not\\s*)?\\(/) || !parserInput.$char(',')) {\n break;\n }\n b = this.condition(true);\n if (!b) {\n break;\n }\n condition = new(tree.Condition)('or', condition || a, b, index);\n }\n return condition || a;\n }\n },\n condition: function (needsParens) {\n let result;\n let logical;\n let next;\n function or() {\n return parserInput.$str('or');\n }\n\n result = this.conditionAnd(needsParens);\n if (!result) {\n return ;\n }\n logical = or();\n if (logical) {\n next = this.condition(needsParens);\n if (next) {\n result = new(tree.Condition)(logical, result, next);\n } else {\n return ;\n }\n }\n return result;\n },\n conditionAnd: function (needsParens) {\n let result;\n let logical;\n let next;\n const self = this;\n function insideCondition() {\n const cond = self.negatedCondition(needsParens) || self.parenthesisCondition(needsParens);\n if (!cond && !needsParens) {\n return self.atomicCondition(needsParens);\n }\n return cond;\n }\n function and() {\n return parserInput.$str('and');\n }\n\n result = insideCondition();\n if (!result) {\n return ;\n }\n logical = and();\n if (logical) {\n next = this.conditionAnd(needsParens);\n if (next) {\n result = new(tree.Condition)(logical, result, next);\n } else {\n return ;\n }\n }\n return result;\n },\n negatedCondition: function (needsParens) {\n if (parserInput.$str('not')) {\n const result = this.parenthesisCondition(needsParens);\n if (result) {\n result.negate = !result.negate;\n }\n return result;\n }\n },\n parenthesisCondition: function (needsParens) {\n function tryConditionFollowedByParenthesis(me) {\n let body;\n parserInput.save();\n body = me.condition(needsParens);\n if (!body) {\n parserInput.restore();\n return ;\n }\n if (!parserInput.$char(')')) {\n parserInput.restore();\n return ;\n }\n parserInput.forget();\n return body;\n }\n\n let body;\n parserInput.save();\n if (!parserInput.$str('(')) {\n parserInput.restore();\n return ;\n }\n body = tryConditionFollowedByParenthesis(this);\n if (body) {\n parserInput.forget();\n return body;\n }\n\n body = this.atomicCondition(needsParens);\n if (!body) {\n parserInput.restore();\n return ;\n }\n if (!parserInput.$char(')')) {\n parserInput.restore(`expected ')' got '${parserInput.currentChar()}'`);\n return ;\n }\n parserInput.forget();\n return body;\n },\n atomicCondition: function (needsParens) {\n const entities = this.entities;\n const index = parserInput.i;\n let a;\n let b;\n let c;\n let op;\n\n function cond() {\n return this.addition() || entities.keyword() || entities.quoted() || entities.mixinLookup();\n }\n cond = cond.bind(this);\n\n a = cond();\n if (a) {\n if (parserInput.$char('>')) {\n if (parserInput.$char('=')) {\n op = '>=';\n } else {\n op = '>';\n }\n } else\n if (parserInput.$char('<')) {\n if (parserInput.$char('=')) {\n op = '<=';\n } else {\n op = '<';\n }\n } else\n if (parserInput.$char('=')) {\n if (parserInput.$char('>')) {\n op = '=>';\n } else if (parserInput.$char('<')) {\n op = '=<';\n } else {\n op = '=';\n }\n }\n if (op) {\n b = cond();\n if (b) {\n c = new(tree.Condition)(op, a, b, index, false);\n } else {\n error('expected expression');\n }\n } else {\n c = new(tree.Condition)('=', a, new(tree.Keyword)('true'), index, false);\n }\n return c;\n }\n },\n\n //\n // An operand is anything that can be part of an operation,\n // such as a Color, or a Variable\n //\n operand: function () {\n const entities = this.entities;\n let negate;\n\n if (parserInput.peek(/^-[@\\$\\(]/)) {\n negate = parserInput.$char('-');\n }\n\n let o = this.sub() || entities.dimension() ||\n entities.color() || entities.variable() ||\n entities.property() || entities.call() ||\n entities.quoted(true) || entities.colorKeyword() ||\n entities.mixinLookup();\n\n if (negate) {\n o.parensInOp = true;\n o = new(tree.Negative)(o);\n }\n\n return o;\n },\n\n //\n // Expressions either represent mathematical operations,\n // or white-space delimited Entities.\n //\n // 1px solid black\n // @var * 2\n //\n expression: function () {\n const entities = [];\n let e;\n let delim;\n const index = parserInput.i;\n\n do {\n e = this.comment();\n if (e) {\n entities.push(e);\n continue;\n }\n e = this.addition() || this.entity();\n if (e) {\n entities.push(e);\n // operations do not allow keyword \"/\" dimension (e.g. small/20px) so we support that here\n if (!parserInput.peek(/^\\/[\\/*]/)) {\n delim = parserInput.$char('/');\n if (delim) {\n entities.push(new(tree.Anonymous)(delim, index));\n }\n }\n }\n } while (e);\n if (entities.length > 0) {\n return new(tree.Expression)(entities);\n }\n },\n property: function () {\n const name = parserInput.$re(/^(\\*?-?[_a-zA-Z0-9-]+)\\s*:/);\n if (name) {\n return name[1];\n }\n },\n ruleProperty: function () {\n let name = [];\n const index = [];\n let s;\n let k;\n\n parserInput.save();\n\n const simpleProperty = parserInput.$re(/^([_a-zA-Z0-9-]+)\\s*:/);\n if (simpleProperty) {\n name = [new(tree.Keyword)(simpleProperty[1])];\n parserInput.forget();\n return name;\n }\n\n function match(re) {\n const i = parserInput.i;\n const chunk = parserInput.$re(re);\n if (chunk) {\n index.push(i);\n return name.push(chunk[1]);\n }\n }\n\n match(/^(\\*?)/);\n while (true) {\n if (!match(/^((?:[\\w-]+)|(?:[@\\$]\\{[\\w-]+\\}))/)) {\n break;\n }\n }\n\n if ((name.length > 1) && match(/^((?:\\+_|\\+)?)\\s*:/)) {\n parserInput.forget();\n\n // at last, we have the complete match now. move forward,\n // convert name particles to tree objects and return:\n if (name[0] === '') {\n name.shift();\n index.shift();\n }\n for (k = 0; k < name.length; k++) {\n s = name[k];\n name[k] = (s.charAt(0) !== '@' && s.charAt(0) !== '$') ?\n new(tree.Keyword)(s) :\n (s.charAt(0) === '@' ?\n new(tree.Variable)(`@${s.slice(2, -1)}`, index[k], fileInfo) :\n new(tree.Property)(`$${s.slice(2, -1)}`, index[k], fileInfo));\n }\n return name;\n }\n parserInput.restore();\n }\n }\n };\n};\nParser.serializeVars = vars => {\n let s = '';\n\n for (const name in vars) {\n if (Object.hasOwnProperty.call(vars, name)) {\n const value = vars[name];\n s += `${((name[0] === '@') ? '' : '@') + name}: ${value}${(String(value).slice(-1) === ';') ? '' : ';'}`;\n }\n }\n\n return s;\n};\n\nexport default Parser;\n","import Dimension from '../tree/dimension';\nimport Color from '../tree/color';\nimport Quoted from '../tree/quoted';\nimport Anonymous from '../tree/anonymous';\nlet colorFunctions;\n\nfunction clamp(val) {\n return Math.min(1, Math.max(0, val));\n}\nfunction hsla(origColor, hsl) {\n const color = colorFunctions.hsla(hsl.h, hsl.s, hsl.l, hsl.a);\n if (color) {\n if (origColor.value && \n /^(rgb|hsl)/.test(origColor.value)) {\n color.value = origColor.value;\n } else {\n color.value = 'rgb';\n }\n return color;\n }\n}\nfunction toHSL(color) {\n if (color.toHSL) {\n return color.toHSL();\n } else {\n throw new Error('Argument cannot be evaluated to a color');\n }\n}\n\nfunction toHSV(color) {\n if (color.toHSV) {\n return color.toHSV();\n } else {\n throw new Error('Argument cannot be evaluated to a color');\n }\n}\n\nfunction number(n) {\n if (n instanceof Dimension) {\n return parseFloat(n.unit.is('%') ? n.value / 100 : n.value);\n } else if (typeof n === 'number') {\n return n;\n } else {\n throw {\n type: 'Argument',\n message: 'color functions take numbers as parameters'\n };\n }\n}\nfunction scaled(n, size) {\n if (n instanceof Dimension && n.unit.is('%')) {\n return parseFloat(n.value * size / 100);\n } else {\n return number(n);\n }\n}\ncolorFunctions = {\n rgb: function (r, g, b) {\n const color = colorFunctions.rgba(r, g, b, 1.0);\n if (color) {\n color.value = 'rgb';\n return color;\n }\n },\n rgba: function (r, g, b, a) {\n try {\n if (r instanceof Color) {\n if (g) {\n a = number(g);\n } else {\n a = r.alpha;\n }\n return new Color(r.rgb, a, 'rgba');\n }\n const rgb = [r, g, b].map(c => scaled(c, 255));\n a = number(a);\n return new Color(rgb, a, 'rgba');\n }\n catch (e) {}\n },\n hsl: function (h, s, l) {\n const color = colorFunctions.hsla(h, s, l, 1.0);\n if (color) {\n color.value = 'hsl';\n return color;\n }\n },\n hsla: function (h, s, l, a) {\n try {\n if (h instanceof Color) {\n if (s) {\n a = number(s);\n } else {\n a = h.alpha;\n }\n return new Color(h.rgb, a, 'hsla');\n }\n\n let m1;\n let m2;\n\n function hue(h) {\n h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);\n if (h * 6 < 1) {\n return m1 + (m2 - m1) * h * 6;\n }\n else if (h * 2 < 1) {\n return m2;\n }\n else if (h * 3 < 2) {\n return m1 + (m2 - m1) * (2 / 3 - h) * 6;\n }\n else {\n return m1;\n }\n }\n\n h = (number(h) % 360) / 360;\n s = clamp(number(s));l = clamp(number(l));a = clamp(number(a));\n\n m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;\n m1 = l * 2 - m2;\n\n const rgb = [\n hue(h + 1 / 3) * 255,\n hue(h) * 255,\n hue(h - 1 / 3) * 255\n ];\n a = number(a);\n return new Color(rgb, a, 'hsla');\n }\n catch (e) {}\n },\n\n hsv: function(h, s, v) {\n return colorFunctions.hsva(h, s, v, 1.0);\n },\n\n hsva: function(h, s, v, a) {\n h = ((number(h) % 360) / 360) * 360;\n s = number(s);v = number(v);a = number(a);\n\n let i;\n let f;\n i = Math.floor((h / 60) % 6);\n f = (h / 60) - i;\n\n const vs = [v,\n v * (1 - s),\n v * (1 - f * s),\n v * (1 - (1 - f) * s)];\n const perm = [[0, 3, 1],\n [2, 0, 1],\n [1, 0, 3],\n [1, 2, 0],\n [3, 1, 0],\n [0, 1, 2]];\n\n return colorFunctions.rgba(vs[perm[i][0]] * 255,\n vs[perm[i][1]] * 255,\n vs[perm[i][2]] * 255,\n a);\n },\n\n hue: function (color) {\n return new Dimension(toHSL(color).h);\n },\n saturation: function (color) {\n return new Dimension(toHSL(color).s * 100, '%');\n },\n lightness: function (color) {\n return new Dimension(toHSL(color).l * 100, '%');\n },\n hsvhue: function(color) {\n return new Dimension(toHSV(color).h);\n },\n hsvsaturation: function (color) {\n return new Dimension(toHSV(color).s * 100, '%');\n },\n hsvvalue: function (color) {\n return new Dimension(toHSV(color).v * 100, '%');\n },\n red: function (color) {\n return new Dimension(color.rgb[0]);\n },\n green: function (color) {\n return new Dimension(color.rgb[1]);\n },\n blue: function (color) {\n return new Dimension(color.rgb[2]);\n },\n alpha: function (color) {\n return new Dimension(toHSL(color).a);\n },\n luma: function (color) {\n return new Dimension(color.luma() * color.alpha * 100, '%');\n },\n luminance: function (color) {\n const luminance =\n (0.2126 * color.rgb[0] / 255) +\n (0.7152 * color.rgb[1] / 255) +\n (0.0722 * color.rgb[2] / 255);\n\n return new Dimension(luminance * color.alpha * 100, '%');\n },\n saturate: function (color, amount, method) {\n // filter: saturate(3.2);\n // should be kept as is, so check for color\n if (!color.rgb) {\n return null;\n }\n const hsl = toHSL(color);\n\n if (typeof method !== 'undefined' && method.value === 'relative') {\n hsl.s += hsl.s * amount.value / 100;\n }\n else {\n hsl.s += amount.value / 100;\n }\n hsl.s = clamp(hsl.s);\n return hsla(color, hsl);\n },\n desaturate: function (color, amount, method) {\n const hsl = toHSL(color);\n\n if (typeof method !== 'undefined' && method.value === 'relative') {\n hsl.s -= hsl.s * amount.value / 100;\n }\n else {\n hsl.s -= amount.value / 100;\n }\n hsl.s = clamp(hsl.s);\n return hsla(color, hsl);\n },\n lighten: function (color, amount, method) {\n const hsl = toHSL(color);\n\n if (typeof method !== 'undefined' && method.value === 'relative') {\n hsl.l += hsl.l * amount.value / 100;\n }\n else {\n hsl.l += amount.value / 100;\n }\n hsl.l = clamp(hsl.l);\n return hsla(color, hsl);\n },\n darken: function (color, amount, method) {\n const hsl = toHSL(color);\n\n if (typeof method !== 'undefined' && method.value === 'relative') {\n hsl.l -= hsl.l * amount.value / 100;\n }\n else {\n hsl.l -= amount.value / 100;\n }\n hsl.l = clamp(hsl.l);\n return hsla(color, hsl);\n },\n fadein: function (color, amount, method) {\n const hsl = toHSL(color);\n\n if (typeof method !== 'undefined' && method.value === 'relative') {\n hsl.a += hsl.a * amount.value / 100;\n }\n else {\n hsl.a += amount.value / 100;\n }\n hsl.a = clamp(hsl.a);\n return hsla(color, hsl);\n },\n fadeout: function (color, amount, method) {\n const hsl = toHSL(color);\n\n if (typeof method !== 'undefined' && method.value === 'relative') {\n hsl.a -= hsl.a * amount.value / 100;\n }\n else {\n hsl.a -= amount.value / 100;\n }\n hsl.a = clamp(hsl.a);\n return hsla(color, hsl);\n },\n fade: function (color, amount) {\n const hsl = toHSL(color);\n\n hsl.a = amount.value / 100;\n hsl.a = clamp(hsl.a);\n return hsla(color, hsl);\n },\n spin: function (color, amount) {\n const hsl = toHSL(color);\n const hue = (hsl.h + amount.value) % 360;\n\n hsl.h = hue < 0 ? 360 + hue : hue;\n\n return hsla(color, hsl);\n },\n //\n // Copyright (c) 2006-2009 Hampton Catlin, Natalie Weizenbaum, and Chris Eppstein\n // http://sass-lang.com\n //\n mix: function (color1, color2, weight) {\n if (!weight) {\n weight = new Dimension(50);\n }\n const p = weight.value / 100.0;\n const w = p * 2 - 1;\n const a = toHSL(color1).a - toHSL(color2).a;\n\n const w1 = (((w * a == -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;\n const w2 = 1 - w1;\n\n const rgb = [color1.rgb[0] * w1 + color2.rgb[0] * w2,\n color1.rgb[1] * w1 + color2.rgb[1] * w2,\n color1.rgb[2] * w1 + color2.rgb[2] * w2];\n\n const alpha = color1.alpha * p + color2.alpha * (1 - p);\n\n return new Color(rgb, alpha);\n },\n greyscale: function (color) {\n return colorFunctions.desaturate(color, new Dimension(100));\n },\n contrast: function (color, dark, light, threshold) {\n // filter: contrast(3.2);\n // should be kept as is, so check for color\n if (!color.rgb) {\n return null;\n }\n if (typeof light === 'undefined') {\n light = colorFunctions.rgba(255, 255, 255, 1.0);\n }\n if (typeof dark === 'undefined') {\n dark = colorFunctions.rgba(0, 0, 0, 1.0);\n }\n // Figure out which is actually light and dark:\n if (dark.luma() > light.luma()) {\n const t = light;\n light = dark;\n dark = t;\n }\n if (typeof threshold === 'undefined') {\n threshold = 0.43;\n } else {\n threshold = number(threshold);\n }\n if (color.luma() < threshold) {\n return light;\n } else {\n return dark;\n }\n },\n // Changes made in 2.7.0 - Reverted in 3.0.0\n // contrast: function (color, color1, color2, threshold) {\n // // Return which of `color1` and `color2` has the greatest contrast with `color`\n // // according to the standard WCAG contrast ratio calculation.\n // // http://www.w3.org/TR/WCAG20/#contrast-ratiodef\n // // The threshold param is no longer used, in line with SASS.\n // // filter: contrast(3.2);\n // // should be kept as is, so check for color\n // if (!color.rgb) {\n // return null;\n // }\n // if (typeof color1 === 'undefined') {\n // color1 = colorFunctions.rgba(0, 0, 0, 1.0);\n // }\n // if (typeof color2 === 'undefined') {\n // color2 = colorFunctions.rgba(255, 255, 255, 1.0);\n // }\n // var contrast1, contrast2;\n // var luma = color.luma();\n // var luma1 = color1.luma();\n // var luma2 = color2.luma();\n // // Calculate contrast ratios for each color\n // if (luma > luma1) {\n // contrast1 = (luma + 0.05) / (luma1 + 0.05);\n // } else {\n // contrast1 = (luma1 + 0.05) / (luma + 0.05);\n // }\n // if (luma > luma2) {\n // contrast2 = (luma + 0.05) / (luma2 + 0.05);\n // } else {\n // contrast2 = (luma2 + 0.05) / (luma + 0.05);\n // }\n // if (contrast1 > contrast2) {\n // return color1;\n // } else {\n // return color2;\n // }\n // },\n argb: function (color) {\n return new Anonymous(color.toARGB());\n },\n color: function(c) {\n if ((c instanceof Quoted) &&\n (/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3,4})$/i.test(c.value))) {\n const val = c.value.slice(1);\n return new Color(val, undefined, `#${val}`);\n }\n if ((c instanceof Color) || (c = Color.fromKeyword(c.value))) {\n c.value = undefined;\n return c;\n }\n throw {\n type: 'Argument',\n message: 'argument must be a color keyword or 3|4|6|8 digit hex e.g. #FFF'\n };\n },\n tint: function(color, amount) {\n return colorFunctions.mix(colorFunctions.rgb(255, 255, 255), color, amount);\n },\n shade: function(color, amount) {\n return colorFunctions.mix(colorFunctions.rgb(0, 0, 0), color, amount);\n }\n};\n\nexport default colorFunctions;\n","import Anonymous from '../tree/anonymous';\nimport Keyword from '../tree/keyword';\n\nfunction boolean(condition) {\n return condition ? Keyword.True : Keyword.False;\n}\n\nfunction If(condition, trueValue, falseValue) {\n return condition ? trueValue\n : (falseValue || new Anonymous);\n}\n\nexport default { boolean, 'if': If };\n","import Color from '../tree/color';\n\n// Color Blending\n// ref: http://www.w3.org/TR/compositing-1\n\nfunction colorBlend(mode, color1, color2) {\n const ab = color1.alpha; // result\n\n let // backdrop\n cb;\n\n const as = color2.alpha;\n\n let // source\n cs;\n\n let ar;\n let cr;\n const r = [];\n\n ar = as + ab * (1 - as);\n for (let i = 0; i < 3; i++) {\n cb = color1.rgb[i] / 255;\n cs = color2.rgb[i] / 255;\n cr = mode(cb, cs);\n if (ar) {\n cr = (as * cs + ab * (cb -\n as * (cb + cs - cr))) / ar;\n }\n r[i] = cr * 255;\n }\n\n return new Color(r, ar);\n}\n\nconst colorBlendModeFunctions = {\n multiply: function(cb, cs) {\n return cb * cs;\n },\n screen: function(cb, cs) {\n return cb + cs - cb * cs;\n },\n overlay: function(cb, cs) {\n cb *= 2;\n return (cb <= 1) ?\n colorBlendModeFunctions.multiply(cb, cs) :\n colorBlendModeFunctions.screen(cb - 1, cs);\n },\n softlight: function(cb, cs) {\n let d = 1;\n let e = cb;\n if (cs > 0.5) {\n e = 1;\n d = (cb > 0.25) ? Math.sqrt(cb)\n : ((16 * cb - 12) * cb + 4) * cb;\n }\n return cb - (1 - 2 * cs) * e * (d - cb);\n },\n hardlight: function(cb, cs) {\n return colorBlendModeFunctions.overlay(cs, cb);\n },\n difference: function(cb, cs) {\n return Math.abs(cb - cs);\n },\n exclusion: function(cb, cs) {\n return cb + cs - 2 * cb * cs;\n },\n\n // non-w3c functions:\n average: function(cb, cs) {\n return (cb + cs) / 2;\n },\n negation: function(cb, cs) {\n return 1 - Math.abs(cb + cs - 1);\n }\n};\n\nfor (const f in colorBlendModeFunctions) {\n if (colorBlendModeFunctions.hasOwnProperty(f)) {\n colorBlend[f] = colorBlend.bind(null, colorBlendModeFunctions[f]);\n }\n}\n\nexport default colorBlend;\n","import Comment from '../tree/comment';\nimport Dimension from '../tree/dimension';\nimport Declaration from '../tree/declaration';\nimport Expression from '../tree/expression';\nimport Ruleset from '../tree/ruleset';\nimport Selector from '../tree/selector';\nimport Element from '../tree/element';\nimport Quote from '../tree/quoted';\n\nconst getItemsFromNode = node => {\n // handle non-array values as an array of length 1\n // return 'undefined' if index is invalid\n const items = Array.isArray(node.value) ?\n node.value : Array(node);\n\n return items;\n};\n\nexport default {\n _SELF: function(n) {\n return n;\n },\n extract: function(values, index) {\n // (1-based index)\n index = index.value - 1;\n\n return getItemsFromNode(values)[index];\n },\n length: function(values) {\n return new Dimension(getItemsFromNode(values).length);\n },\n /**\n * Creates a Less list of incremental values.\n * Modeled after Lodash's range function, also exists natively in PHP\n * \n * @param {Dimension} [start=1]\n * @param {Dimension} end - e.g. 10 or 10px - unit is added to output\n * @param {Dimension} [step=1] \n */\n range: function(start, end, step) {\n let from;\n let to;\n let stepValue = 1;\n const list = [];\n if (end) {\n to = end;\n from = start.value;\n if (step) {\n stepValue = step.value;\n }\n }\n else {\n from = 1;\n to = start;\n }\n\n for (let i = from; i <= to.value; i += stepValue) {\n list.push(new Dimension(i, to.unit));\n }\n\n return new Expression(list);\n },\n each: function(list, rs) {\n const rules = [];\n let newRules;\n let iterator;\n\n if (list.value && !(list instanceof Quote)) {\n if (Array.isArray(list.value)) {\n iterator = list.value;\n } else {\n iterator = [list.value];\n }\n } else if (list.ruleset) {\n iterator = list.ruleset.rules;\n } else if (list.rules) {\n iterator = list.rules;\n } else if (Array.isArray(list)) {\n iterator = list;\n } else {\n iterator = [list];\n }\n\n let valueName = '@value';\n let keyName = '@key';\n let indexName = '@index';\n\n if (rs.params) {\n valueName = rs.params[0] && rs.params[0].name;\n keyName = rs.params[1] && rs.params[1].name;\n indexName = rs.params[2] && rs.params[2].name;\n rs = rs.rules;\n } else {\n rs = rs.ruleset;\n }\n\n for (let i = 0; i < iterator.length; i++) {\n let key;\n let value;\n const item = iterator[i];\n if (item instanceof Declaration) {\n key = typeof item.name === 'string' ? item.name : item.name[0].value;\n value = item.value;\n } else {\n key = new Dimension(i + 1);\n value = item;\n }\n\n if (item instanceof Comment) {\n continue;\n }\n\n newRules = rs.rules.slice(0);\n if (valueName) {\n newRules.push(new Declaration(valueName,\n value,\n false, false, this.index, this.currentFileInfo));\n }\n if (indexName) {\n newRules.push(new Declaration(indexName,\n new Dimension(i + 1),\n false, false, this.index, this.currentFileInfo));\n }\n if (keyName) {\n newRules.push(new Declaration(keyName,\n key,\n false, false, this.index, this.currentFileInfo));\n }\n\n rules.push(new Ruleset([ new(Selector)([ new Element(\"\", '&') ]) ],\n newRules,\n rs.strictImports,\n rs.visibilityInfo()\n ));\n }\n\n return new Ruleset([ new(Selector)([ new Element(\"\", '&') ]) ],\n rules,\n rs.strictImports,\n rs.visibilityInfo()\n ).eval(this.context);\n }\n};\n","import Dimension from '../tree/dimension';\n\nconst MathHelper = (fn, unit, n) => {\n if (!(n instanceof Dimension)) {\n throw { type: 'Argument', message: 'argument must be a number' };\n }\n if (unit == null) {\n unit = n.unit;\n } else {\n n = n.unify();\n }\n return new Dimension(fn(parseFloat(n.value)), unit);\n};\n\nexport default MathHelper;","import mathHelper from './math-helper.js';\n\nconst mathFunctions = {\n // name, unit\n ceil: null,\n floor: null,\n sqrt: null,\n abs: null,\n tan: '',\n sin: '',\n cos: '',\n atan: 'rad',\n asin: 'rad',\n acos: 'rad'\n};\n\nfor (const f in mathFunctions) {\n if (mathFunctions.hasOwnProperty(f)) {\n mathFunctions[f] = mathHelper.bind(null, Math[f], mathFunctions[f]);\n }\n}\n\nmathFunctions.round = (n, f) => {\n const fraction = typeof f === 'undefined' ? 0 : f.value;\n return mathHelper(num => num.toFixed(fraction), null, n);\n};\n\nexport default mathFunctions;\n","import Dimension from '../tree/dimension';\nimport Anonymous from '../tree/anonymous';\nimport mathHelper from './math-helper.js';\n\nconst minMax = function (isMin, args) {\n args = Array.prototype.slice.call(args);\n switch (args.length) {\n case 0: throw { type: 'Argument', message: 'one or more arguments required' };\n }\n let i; // key is the unit.toString() for unified Dimension values,\n let j;\n let current;\n let currentUnified;\n let referenceUnified;\n let unit;\n let unitStatic;\n let unitClone;\n\n const // elems only contains original argument values.\n order = [];\n\n const values = {};\n // value is the index into the order array.\n for (i = 0; i < args.length; i++) {\n current = args[i];\n if (!(current instanceof Dimension)) {\n if (Array.isArray(args[i].value)) {\n Array.prototype.push.apply(args, Array.prototype.slice.call(args[i].value));\n }\n continue;\n }\n currentUnified = current.unit.toString() === '' && unitClone !== undefined ? new Dimension(current.value, unitClone).unify() : current.unify();\n unit = currentUnified.unit.toString() === '' && unitStatic !== undefined ? unitStatic : currentUnified.unit.toString();\n unitStatic = unit !== '' && unitStatic === undefined || unit !== '' && order[0].unify().unit.toString() === '' ? unit : unitStatic;\n unitClone = unit !== '' && unitClone === undefined ? current.unit.toString() : unitClone;\n j = values[''] !== undefined && unit !== '' && unit === unitStatic ? values[''] : values[unit];\n if (j === undefined) {\n if (unitStatic !== undefined && unit !== unitStatic) {\n throw { type: 'Argument', message: 'incompatible types' };\n }\n values[unit] = order.length;\n order.push(current);\n continue;\n }\n referenceUnified = order[j].unit.toString() === '' && unitClone !== undefined ? new Dimension(order[j].value, unitClone).unify() : order[j].unify();\n if ( isMin && currentUnified.value < referenceUnified.value ||\n !isMin && currentUnified.value > referenceUnified.value) {\n order[j] = current;\n }\n }\n if (order.length == 1) {\n return order[0];\n }\n args = order.map(function (a) { return a.toCSS(this.context); }).join(this.context.compress ? ',' : ', ');\n return new Anonymous(`${isMin ? 'min' : 'max'}(${args})`);\n};\n\nexport default {\n min: function(...args) {\n return minMax(true, args);\n },\n max: function(...args) {\n return minMax(false, args);\n },\n convert: function (val, unit) {\n return val.convertTo(unit.value);\n },\n pi: function () {\n return new Dimension(Math.PI);\n },\n mod: function(a, b) {\n return new Dimension(a.value % b.value, a.unit);\n },\n pow: function(x, y) {\n if (typeof x === 'number' && typeof y === 'number') {\n x = new Dimension(x);\n y = new Dimension(y);\n } else if (!(x instanceof Dimension) || !(y instanceof Dimension)) {\n throw { type: 'Argument', message: 'arguments must be numbers' };\n }\n\n return new Dimension(Math.pow(x.value, y.value), x.unit);\n },\n percentage: function (n) {\n const result = mathHelper(num => num * 100, '%', n);\n\n return result;\n }\n};\n","/**\n * Plugin Manager\n */\nclass PluginManager {\n constructor(less) {\n this.less = less;\n this.visitors = [];\n this.preProcessors = [];\n this.postProcessors = [];\n this.installedPlugins = [];\n this.fileManagers = [];\n this.iterator = -1;\n this.pluginCache = {};\n this.Loader = new less.PluginLoader(less);\n }\n\n /**\n * Adds all the plugins in the array\n * @param {Array} plugins\n */\n addPlugins(plugins) {\n if (plugins) {\n for (let i = 0; i < plugins.length; i++) {\n this.addPlugin(plugins[i]);\n }\n }\n }\n\n /**\n *\n * @param plugin\n * @param {String} filename\n */\n addPlugin(plugin, filename, functionRegistry) {\n this.installedPlugins.push(plugin);\n if (filename) {\n this.pluginCache[filename] = plugin;\n }\n if (plugin.install) {\n plugin.install(this.less, this, functionRegistry || this.less.functions.functionRegistry);\n }\n }\n\n /**\n *\n * @param filename\n */\n get(filename) {\n return this.pluginCache[filename];\n }\n\n /**\n * Adds a visitor. The visitor object has options on itself to determine\n * when it should run.\n * @param visitor\n */\n addVisitor(visitor) {\n this.visitors.push(visitor);\n }\n\n /**\n * Adds a pre processor object\n * @param {object} preProcessor\n * @param {number} priority - guidelines 1 = before import, 1000 = import, 2000 = after import\n */\n addPreProcessor(preProcessor, priority) {\n let indexToInsertAt;\n for (indexToInsertAt = 0; indexToInsertAt < this.preProcessors.length; indexToInsertAt++) {\n if (this.preProcessors[indexToInsertAt].priority >= priority) {\n break;\n }\n }\n this.preProcessors.splice(indexToInsertAt, 0, {preProcessor, priority});\n }\n\n /**\n * Adds a post processor object\n * @param {object} postProcessor\n * @param {number} priority - guidelines 1 = before compression, 1000 = compression, 2000 = after compression\n */\n addPostProcessor(postProcessor, priority) {\n let indexToInsertAt;\n for (indexToInsertAt = 0; indexToInsertAt < this.postProcessors.length; indexToInsertAt++) {\n if (this.postProcessors[indexToInsertAt].priority >= priority) {\n break;\n }\n }\n this.postProcessors.splice(indexToInsertAt, 0, {postProcessor, priority});\n }\n\n /**\n *\n * @param manager\n */\n addFileManager(manager) {\n this.fileManagers.push(manager);\n }\n\n /**\n *\n * @returns {Array}\n * @private\n */\n getPreProcessors() {\n const preProcessors = [];\n for (let i = 0; i < this.preProcessors.length; i++) {\n preProcessors.push(this.preProcessors[i].preProcessor);\n }\n return preProcessors;\n }\n\n /**\n *\n * @returns {Array}\n * @private\n */\n getPostProcessors() {\n const postProcessors = [];\n for (let i = 0; i < this.postProcessors.length; i++) {\n postProcessors.push(this.postProcessors[i].postProcessor);\n }\n return postProcessors;\n }\n\n /**\n *\n * @returns {Array}\n * @private\n */\n getVisitors() {\n return this.visitors;\n }\n\n visitor() {\n const self = this;\n return {\n first: function() {\n self.iterator = -1;\n return self.visitors[self.iterator];\n },\n get: function() {\n self.iterator += 1;\n return self.visitors[self.iterator];\n }\n };\n }\n\n /**\n *\n * @returns {Array}\n * @private\n */\n getFileManagers() {\n return this.fileManagers;\n }\n}\n\nlet pm;\n\nfunction PluginManagerFactory(less, newFactory) {\n if (newFactory || !pm) {\n pm = new PluginManager(less);\n }\n return pm;\n};\n\n//\nexport default PluginManagerFactory;\n","import Quoted from '../tree/quoted';\nimport Anonymous from '../tree/anonymous';\nimport JavaScript from '../tree/javascript';\n\nexport default {\n e: function (str) {\n return new Quoted('\"', str instanceof JavaScript ? str.evaluated : str.value, true);\n },\n escape: function (str) {\n return new Anonymous(\n encodeURI(str.value).replace(/=/g, '%3D').replace(/:/g, '%3A').replace(/#/g, '%23').replace(/;/g, '%3B')\n .replace(/\\(/g, '%28').replace(/\\)/g, '%29'));\n },\n replace: function (string, pattern, replacement, flags) {\n let result = string.value;\n replacement = (replacement.type === 'Quoted') ?\n replacement.value : replacement.toCSS();\n result = result.replace(new RegExp(pattern.value, flags ? flags.value : ''), replacement);\n return new Quoted(string.quote || '', result, string.escaped);\n },\n '%': function (string /* arg, arg, ... */) {\n const args = Array.prototype.slice.call(arguments, 1);\n let result = string.value;\n\n for (let i = 0; i < args.length; i++) {\n /* jshint loopfunc:true */\n result = result.replace(/%[sda]/i, token => {\n const value = ((args[i].type === 'Quoted') &&\n token.match(/s/i)) ? args[i].value : args[i].toCSS();\n return token.match(/[A-Z]$/) ? encodeURIComponent(value) : value;\n });\n }\n result = result.replace(/%%/g, '%');\n return new Quoted(string.quote || '', result, string.escaped);\n }\n};\n","import Keyword from '../tree/keyword';\nimport DetachedRuleset from '../tree/detached-ruleset';\nimport Dimension from '../tree/dimension';\nimport Color from '../tree/color';\nimport Quoted from '../tree/quoted';\nimport Anonymous from '../tree/anonymous';\nimport URL from '../tree/url';\nimport Operation from '../tree/operation';\n\nconst isa = (n, Type) => (n instanceof Type) ? Keyword.True : Keyword.False;\nconst isunit = (n, unit) => {\n if (unit === undefined) {\n throw { type: 'Argument', message: 'missing the required second argument to isunit.' };\n }\n unit = typeof unit.value === 'string' ? unit.value : unit;\n if (typeof unit !== 'string') {\n throw { type: 'Argument', message: 'Second argument to isunit should be a unit or a string.' };\n }\n return (n instanceof Dimension) && n.unit.is(unit) ? Keyword.True : Keyword.False;\n};\n\nexport default {\n isruleset: function (n) {\n return isa(n, DetachedRuleset);\n },\n iscolor: function (n) {\n return isa(n, Color);\n },\n isnumber: function (n) {\n return isa(n, Dimension);\n },\n isstring: function (n) {\n return isa(n, Quoted);\n },\n iskeyword: function (n) {\n return isa(n, Keyword);\n },\n isurl: function (n) {\n return isa(n, URL);\n },\n ispixel: function (n) {\n return isunit(n, 'px');\n },\n ispercentage: function (n) {\n return isunit(n, '%');\n },\n isem: function (n) {\n return isunit(n, 'em');\n },\n isunit,\n unit: function (val, unit) {\n if (!(val instanceof Dimension)) {\n throw { type: 'Argument',\n message: `the first argument to unit must be a number${val instanceof Operation ? '. Have you forgotten parenthesis?' : ''}` };\n }\n if (unit) {\n if (unit instanceof Keyword) {\n unit = unit.value;\n } else {\n unit = unit.toCSS();\n }\n } else {\n unit = '';\n }\n return new Dimension(val.value, unit);\n },\n 'get-unit': function (n) {\n return new Anonymous(n.unit);\n }\n};\n","import functionRegistry from './function-registry';\nimport functionCaller from './function-caller';\n\nimport boolean from './boolean';\nimport defaultFunc from './default';\nimport color from './color';\nimport colorBlending from './color-blending';\nimport dataUri from './data-uri';\nimport list from './list';\nimport math from './math';\nimport number from './number';\nimport string from './string';\nimport svg from './svg';\nimport types from './types';\n\nexport default environment => {\n const functions = { functionRegistry, functionCaller };\n\n // register functions\n functionRegistry.addMultiple(boolean);\n functionRegistry.add('default', defaultFunc.eval.bind(defaultFunc));\n functionRegistry.addMultiple(color);\n functionRegistry.addMultiple(colorBlending);\n functionRegistry.addMultiple(dataUri(environment));\n functionRegistry.addMultiple(list);\n functionRegistry.addMultiple(math);\n functionRegistry.addMultiple(number);\n functionRegistry.addMultiple(string);\n functionRegistry.addMultiple(svg(environment));\n functionRegistry.addMultiple(types);\n\n return functions;\n};\n","import Quoted from '../tree/quoted';\nimport URL from '../tree/url';\nimport * as utils from '../utils';\nimport logger from '../logger';\n\nexport default environment => {\n \n const fallback = (functionThis, node) => new URL(node, functionThis.index, functionThis.currentFileInfo).eval(functionThis.context); \n\n return { 'data-uri': function(mimetypeNode, filePathNode) {\n\n if (!filePathNode) {\n filePathNode = mimetypeNode;\n mimetypeNode = null;\n }\n\n let mimetype = mimetypeNode && mimetypeNode.value;\n let filePath = filePathNode.value;\n const currentFileInfo = this.currentFileInfo;\n const currentDirectory = currentFileInfo.rewriteUrls ?\n currentFileInfo.currentDirectory : currentFileInfo.entryPath;\n\n const fragmentStart = filePath.indexOf('#');\n let fragment = '';\n if (fragmentStart !== -1) {\n fragment = filePath.slice(fragmentStart);\n filePath = filePath.slice(0, fragmentStart);\n }\n const context = utils.clone(this.context);\n context.rawBuffer = true;\n\n const fileManager = environment.getFileManager(filePath, currentDirectory, context, environment, true);\n\n if (!fileManager) {\n return fallback(this, filePathNode);\n }\n\n let useBase64 = false;\n\n // detect the mimetype if not given\n if (!mimetypeNode) {\n\n mimetype = environment.mimeLookup(filePath);\n\n if (mimetype === 'image/svg+xml') {\n useBase64 = false;\n } else {\n // use base 64 unless it's an ASCII or UTF-8 format\n const charset = environment.charsetLookup(mimetype);\n useBase64 = ['US-ASCII', 'UTF-8'].indexOf(charset) < 0;\n }\n if (useBase64) { mimetype += ';base64'; }\n }\n else {\n useBase64 = /;base64$/.test(mimetype);\n }\n\n const fileSync = fileManager.loadFileSync(filePath, currentDirectory, context, environment);\n if (!fileSync.contents) {\n logger.warn(`Skipped data-uri embedding of ${filePath} because file not found`);\n return fallback(this, filePathNode || mimetypeNode);\n }\n let buf = fileSync.contents;\n if (useBase64 && !environment.encodeBase64) {\n return fallback(this, filePathNode);\n }\n\n buf = useBase64 ? environment.encodeBase64(buf) : encodeURIComponent(buf);\n\n const uri = `data:${mimetype},${buf}${fragment}`;\n\n return new URL(new Quoted(`\"${uri}\"`, uri, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo);\n }};\n};\n","import Dimension from '../tree/dimension';\nimport Color from '../tree/color';\nimport Expression from '../tree/expression';\nimport Quoted from '../tree/quoted';\nimport URL from '../tree/url';\n\nexport default environment => {\n return { 'svg-gradient': function(direction) {\n let stops;\n let gradientDirectionSvg;\n let gradientType = 'linear';\n let rectangleDimension = 'x=\"0\" y=\"0\" width=\"1\" height=\"1\"';\n const renderEnv = {compress: false};\n let returner;\n const directionValue = direction.toCSS(renderEnv);\n let i;\n let color;\n let position;\n let positionValue;\n let alpha;\n\n function throwArgumentDescriptor() {\n throw { type: 'Argument',\n message: 'svg-gradient expects direction, start_color [start_position], [color position,]...,' +\n ' end_color [end_position] or direction, color list' };\n }\n\n if (arguments.length == 2) {\n if (arguments[1].value.length < 2) {\n throwArgumentDescriptor();\n }\n stops = arguments[1].value;\n } else if (arguments.length < 3) {\n throwArgumentDescriptor();\n } else {\n stops = Array.prototype.slice.call(arguments, 1);\n }\n\n switch (directionValue) {\n case 'to bottom':\n gradientDirectionSvg = 'x1=\"0%\" y1=\"0%\" x2=\"0%\" y2=\"100%\"';\n break;\n case 'to right':\n gradientDirectionSvg = 'x1=\"0%\" y1=\"0%\" x2=\"100%\" y2=\"0%\"';\n break;\n case 'to bottom right':\n gradientDirectionSvg = 'x1=\"0%\" y1=\"0%\" x2=\"100%\" y2=\"100%\"';\n break;\n case 'to top right':\n gradientDirectionSvg = 'x1=\"0%\" y1=\"100%\" x2=\"100%\" y2=\"0%\"';\n break;\n case 'ellipse':\n case 'ellipse at center':\n gradientType = 'radial';\n gradientDirectionSvg = 'cx=\"50%\" cy=\"50%\" r=\"75%\"';\n rectangleDimension = 'x=\"-50\" y=\"-50\" width=\"101\" height=\"101\"';\n break;\n default:\n throw { type: 'Argument', message: 'svg-gradient direction must be \\'to bottom\\', \\'to right\\',' +\n ' \\'to bottom right\\', \\'to top right\\' or \\'ellipse at center\\'' };\n }\n returner = `<${gradientType}Gradient id=\"g\" ${gradientDirectionSvg}>`;\n\n for (i = 0; i < stops.length; i += 1) {\n if (stops[i] instanceof Expression) {\n color = stops[i].value[0];\n position = stops[i].value[1];\n } else {\n color = stops[i];\n position = undefined;\n }\n\n if (!(color instanceof Color) || (!((i === 0 || i + 1 === stops.length) && position === undefined) && !(position instanceof Dimension))) {\n throwArgumentDescriptor();\n }\n positionValue = position ? position.toCSS(renderEnv) : i === 0 ? '0%' : '100%';\n alpha = color.alpha;\n returner += ``;\n }\n returner += ``;\n\n returner = encodeURIComponent(returner);\n\n returner = `data:image/svg+xml,${returner}`;\n return new URL(new Quoted(`'${returner}'`, returner, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo);\n }};\n};\n","import contexts from './contexts';\nimport visitor from './visitors';\nimport tree from './tree';\n\nexport default (root, options = {}) => {\n let evaldRoot;\n let variables = options.variables;\n const evalEnv = new contexts.Eval(options);\n\n //\n // Allows setting variables with a hash, so:\n //\n // `{ color: new tree.Color('#f01') }` will become:\n //\n // new tree.Declaration('@color',\n // new tree.Value([\n // new tree.Expression([\n // new tree.Color('#f01')\n // ])\n // ])\n // )\n //\n if (typeof variables === 'object' && !Array.isArray(variables)) {\n variables = Object.keys(variables).map(k => {\n let value = variables[k];\n\n if (!(value instanceof tree.Value)) {\n if (!(value instanceof tree.Expression)) {\n value = new tree.Expression([value]);\n }\n value = new tree.Value([value]);\n }\n return new tree.Declaration(`@${k}`, value, false, null, 0);\n });\n evalEnv.frames = [new tree.Ruleset(null, variables)];\n }\n\n const visitors = [\n new visitor.JoinSelectorVisitor(),\n new visitor.MarkVisibleSelectorsVisitor(true),\n new visitor.ExtendVisitor(),\n new visitor.ToCSSVisitor({compress: Boolean(options.compress)})\n ];\n\n const preEvalVisitors = [];\n let v;\n let visitorIterator;\n\n /**\n * first() / get() allows visitors to be added while visiting\n * \n * @todo Add scoping for visitors just like functions for @plugin; right now they're global\n */\n if (options.pluginManager) {\n visitorIterator = options.pluginManager.visitor();\n for (var i = 0; i < 2; i++) {\n visitorIterator.first();\n while ((v = visitorIterator.get())) {\n if (v.isPreEvalVisitor) {\n if (i === 0 || preEvalVisitors.indexOf(v) === -1) {\n preEvalVisitors.push(v);\n v.run(root);\n }\n }\n else {\n if (i === 0 || visitors.indexOf(v) === -1) {\n if (v.isPreVisitor) {\n visitors.unshift(v);\n }\n else {\n visitors.push(v);\n }\n }\n }\n }\n }\n }\n\n evaldRoot = root.eval(evalEnv);\n\n for (var i = 0; i < visitors.length; i++) {\n visitors[i].run(evaldRoot);\n }\n\n // Run any remaining visitors added after eval pass\n if (options.pluginManager) {\n visitorIterator.first();\n while ((v = visitorIterator.get())) {\n if (visitors.indexOf(v) === -1 && preEvalVisitors.indexOf(v) === -1) {\n v.run(evaldRoot);\n }\n }\n }\n\n return evaldRoot;\n};\n","/* global window, XMLHttpRequest */\n\nimport AbstractFileManager from '../less/environment/abstract-file-manager.js';\n\nlet options;\nlet logger;\nlet fileCache = {};\n\n// TODOS - move log somewhere. pathDiff and doing something similar in node. use pathDiff in the other browser file for the initial load\nclass FileManager extends AbstractFileManager {\n alwaysMakePathsAbsolute() {\n return true;\n }\n\n join(basePath, laterPath) {\n if (!basePath) {\n return laterPath;\n }\n return this.extractUrlParts(laterPath, basePath).path;\n }\n\n doXHR(url, type, callback, errback) {\n const xhr = new XMLHttpRequest();\n const async = options.isFileProtocol ? options.fileAsync : true;\n\n if (typeof xhr.overrideMimeType === 'function') {\n xhr.overrideMimeType('text/css');\n }\n logger.debug(`XHR: Getting '${url}'`);\n xhr.open('GET', url, async);\n xhr.setRequestHeader('Accept', type || 'text/x-less, text/css; q=0.9, */*; q=0.5');\n xhr.send(null);\n\n function handleResponse(xhr, callback, errback) {\n if (xhr.status >= 200 && xhr.status < 300) {\n callback(xhr.responseText,\n xhr.getResponseHeader('Last-Modified'));\n } else if (typeof errback === 'function') {\n errback(xhr.status, url);\n }\n }\n\n if (options.isFileProtocol && !options.fileAsync) {\n if (xhr.status === 0 || (xhr.status >= 200 && xhr.status < 300)) {\n callback(xhr.responseText);\n } else {\n errback(xhr.status, url);\n }\n } else if (async) {\n xhr.onreadystatechange = () => {\n if (xhr.readyState == 4) {\n handleResponse(xhr, callback, errback);\n }\n };\n } else {\n handleResponse(xhr, callback, errback);\n }\n }\n\n supports() {\n return true;\n }\n\n clearFileCache() {\n fileCache = {};\n }\n\n loadFile(filename, currentDirectory, options, environment) {\n // TODO: Add prefix support like less-node?\n // What about multiple paths?\n\n if (currentDirectory && !this.isPathAbsolute(filename)) {\n filename = currentDirectory + filename;\n }\n\n filename = options.ext ? this.tryAppendExtension(filename, options.ext) : filename;\n\n options = options || {};\n\n // sheet may be set to the stylesheet for the initial load or a collection of properties including\n // some context variables for imports\n const hrefParts = this.extractUrlParts(filename, window.location.href);\n const href = hrefParts.url;\n const self = this;\n \n return new Promise((resolve, reject) => {\n if (options.useFileCache && fileCache[href]) {\n try {\n const lessText = fileCache[href];\n return resolve({ contents: lessText, filename: href, webInfo: { lastModified: new Date() }});\n } catch (e) {\n return reject({ filename: href, message: `Error loading file ${href} error was ${e.message}` });\n }\n }\n\n self.doXHR(href, options.mime, function doXHRCallback(data, lastModified) {\n // per file cache\n fileCache[href] = data;\n\n // Use remote copy (re-parse)\n resolve({ contents: data, filename: href, webInfo: { lastModified }});\n }, function doXHRError(status, url) {\n reject({ type: 'File', message: `'${url}' wasn't found (${status})`, href });\n });\n });\n }\n}\n\nexport default (opts, log) => {\n options = opts;\n logger = log;\n return FileManager;\n}\n","import data from './data';\nimport tree from './tree';\nimport Environment from './environment/environment';\nimport AbstractFileManager from './environment/abstract-file-manager';\nimport AbstractPluginLoader from './environment/abstract-plugin-loader';\nimport visitors from './visitors';\nimport Parser from './parser/parser';\nimport Functions from './functions';\nimport contexts from './contexts';\nimport sourceMapOutput from './source-map-output';\nimport sourceMapBuilder from './source-map-builder';\nimport parseTree from './parse-tree';\nimport importManager from './import-manager';\nimport Render from './render';\nimport Parse from './parse';\nimport LessError from './less-error';\nimport transformTree from './transform-tree';\nimport * as utils from './utils';\nimport PluginManager from './plugin-manager';\nimport logger from './logger';\n\nexport default (environment, fileManagers) => {\n /**\n * @todo\n * This original code could be improved quite a bit.\n * Many classes / modules currently add side-effects / mutations to passed in objects,\n * which makes it hard to refactor and reason about. \n */\n environment = new Environment(environment, fileManagers);\n\n const SourceMapOutput = sourceMapOutput(environment);\n const SourceMapBuilder = sourceMapBuilder(SourceMapOutput, environment);\n const ParseTree = parseTree(SourceMapBuilder);\n const ImportManager = importManager(environment);\n const render = Render(environment, ParseTree, ImportManager);\n const parse = Parse(environment, ParseTree, ImportManager);\n const functions = Functions(environment);\n\n /**\n * @todo\n * This root properties / methods need to be organized.\n * It's not clear what should / must be public and why.\n */\n const initial = {\n version: [3, 10, 3],\n data,\n tree,\n Environment,\n AbstractFileManager,\n AbstractPluginLoader,\n environment,\n visitors,\n Parser,\n functions,\n contexts,\n SourceMapOutput,\n SourceMapBuilder,\n ParseTree,\n ImportManager,\n render,\n parse,\n LessError,\n transformTree,\n utils,\n PluginManager,\n logger\n };\n\n // Create a public API\n const ctor = t => function (...args) {\n return new t(...args);\n };\n\n let t;\n const api = Object.create(initial);\n for (const n in initial.tree) {\n /* eslint guard-for-in: 0 */\n t = initial.tree[n];\n if (typeof t === 'function') {\n api[n.toLowerCase()] = ctor(t);\n }\n else {\n api[n] = Object.create(null);\n for (const o in t) {\n /* eslint guard-for-in: 0 */\n api[n][o.toLowerCase()] = ctor(t[o]);\n }\n }\n }\n\n return api;\n};\n","export default environment => {\n class SourceMapOutput {\n constructor(options) {\n this._css = [];\n this._rootNode = options.rootNode;\n this._contentsMap = options.contentsMap;\n this._contentsIgnoredCharsMap = options.contentsIgnoredCharsMap;\n if (options.sourceMapFilename) {\n this._sourceMapFilename = options.sourceMapFilename.replace(/\\\\/g, '/');\n }\n this._outputFilename = options.outputFilename;\n this.sourceMapURL = options.sourceMapURL;\n if (options.sourceMapBasepath) {\n this._sourceMapBasepath = options.sourceMapBasepath.replace(/\\\\/g, '/');\n }\n if (options.sourceMapRootpath) {\n this._sourceMapRootpath = options.sourceMapRootpath.replace(/\\\\/g, '/');\n if (this._sourceMapRootpath.charAt(this._sourceMapRootpath.length - 1) !== '/') {\n this._sourceMapRootpath += '/';\n }\n } else {\n this._sourceMapRootpath = '';\n }\n this._outputSourceFiles = options.outputSourceFiles;\n this._sourceMapGeneratorConstructor = environment.getSourceMapGenerator();\n\n this._lineNumber = 0;\n this._column = 0;\n }\n\n removeBasepath(path) {\n if (this._sourceMapBasepath && path.indexOf(this._sourceMapBasepath) === 0) {\n path = path.substring(this._sourceMapBasepath.length);\n if (path.charAt(0) === '\\\\' || path.charAt(0) === '/') {\n path = path.substring(1);\n }\n }\n\n return path;\n }\n\n normalizeFilename(filename) {\n filename = filename.replace(/\\\\/g, '/');\n filename = this.removeBasepath(filename);\n return (this._sourceMapRootpath || '') + filename;\n }\n\n add(chunk, fileInfo, index, mapLines) {\n // ignore adding empty strings\n if (!chunk) {\n return;\n }\n\n let lines;\n let sourceLines;\n let columns;\n let sourceColumns;\n let i;\n\n if (fileInfo && fileInfo.filename) {\n let inputSource = this._contentsMap[fileInfo.filename];\n\n // remove vars/banner added to the top of the file\n if (this._contentsIgnoredCharsMap[fileInfo.filename]) {\n // adjust the index\n index -= this._contentsIgnoredCharsMap[fileInfo.filename];\n if (index < 0) { index = 0; }\n // adjust the source\n inputSource = inputSource.slice(this._contentsIgnoredCharsMap[fileInfo.filename]);\n }\n\n // ignore empty content\n if (inputSource === undefined) {\n return;\n }\n\n inputSource = inputSource.substring(0, index);\n sourceLines = inputSource.split('\\n');\n sourceColumns = sourceLines[sourceLines.length - 1];\n }\n\n lines = chunk.split('\\n');\n columns = lines[lines.length - 1];\n\n if (fileInfo && fileInfo.filename) {\n if (!mapLines) {\n this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + 1, column: this._column},\n original: { line: sourceLines.length, column: sourceColumns.length},\n source: this.normalizeFilename(fileInfo.filename)});\n } else {\n for (i = 0; i < lines.length; i++) {\n this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + i + 1, column: i === 0 ? this._column : 0},\n original: { line: sourceLines.length + i, column: i === 0 ? sourceColumns.length : 0},\n source: this.normalizeFilename(fileInfo.filename)});\n }\n }\n }\n\n if (lines.length === 1) {\n this._column += columns.length;\n } else {\n this._lineNumber += lines.length - 1;\n this._column = columns.length;\n }\n\n this._css.push(chunk);\n }\n\n isEmpty() {\n return this._css.length === 0;\n }\n\n toCSS(context) {\n this._sourceMapGenerator = new this._sourceMapGeneratorConstructor({ file: this._outputFilename, sourceRoot: null });\n\n if (this._outputSourceFiles) {\n for (const filename in this._contentsMap) {\n if (this._contentsMap.hasOwnProperty(filename)) {\n let source = this._contentsMap[filename];\n if (this._contentsIgnoredCharsMap[filename]) {\n source = source.slice(this._contentsIgnoredCharsMap[filename]);\n }\n this._sourceMapGenerator.setSourceContent(this.normalizeFilename(filename), source);\n }\n }\n }\n\n this._rootNode.genCSS(context, this);\n\n if (this._css.length > 0) {\n let sourceMapURL;\n const sourceMapContent = JSON.stringify(this._sourceMapGenerator.toJSON());\n\n if (this.sourceMapURL) {\n sourceMapURL = this.sourceMapURL;\n } else if (this._sourceMapFilename) {\n sourceMapURL = this._sourceMapFilename;\n }\n this.sourceMapURL = sourceMapURL;\n\n this.sourceMap = sourceMapContent;\n }\n\n return this._css.join('');\n }\n }\n\n return SourceMapOutput;\n};\n","export default (SourceMapOutput, environment) => {\n class SourceMapBuilder {\n constructor(options) {\n this.options = options;\n }\n\n toCSS(rootNode, options, imports) {\n const sourceMapOutput = new SourceMapOutput(\n {\n contentsIgnoredCharsMap: imports.contentsIgnoredChars,\n rootNode,\n contentsMap: imports.contents,\n sourceMapFilename: this.options.sourceMapFilename,\n sourceMapURL: this.options.sourceMapURL,\n outputFilename: this.options.sourceMapOutputFilename,\n sourceMapBasepath: this.options.sourceMapBasepath,\n sourceMapRootpath: this.options.sourceMapRootpath,\n outputSourceFiles: this.options.outputSourceFiles,\n sourceMapGenerator: this.options.sourceMapGenerator,\n sourceMapFileInline: this.options.sourceMapFileInline\n });\n\n const css = sourceMapOutput.toCSS(options);\n this.sourceMap = sourceMapOutput.sourceMap;\n this.sourceMapURL = sourceMapOutput.sourceMapURL;\n if (this.options.sourceMapInputFilename) {\n this.sourceMapInputFilename = sourceMapOutput.normalizeFilename(this.options.sourceMapInputFilename);\n }\n if (this.options.sourceMapBasepath !== undefined && this.sourceMapURL !== undefined) {\n this.sourceMapURL = sourceMapOutput.removeBasepath(this.sourceMapURL);\n }\n return css + this.getCSSAppendage();\n }\n\n getCSSAppendage() {\n\n let sourceMapURL = this.sourceMapURL;\n if (this.options.sourceMapFileInline) {\n if (this.sourceMap === undefined) {\n return '';\n }\n sourceMapURL = `data:application/json;base64,${environment.encodeBase64(this.sourceMap)}`;\n }\n\n if (sourceMapURL) {\n return `/*# sourceMappingURL=${sourceMapURL} */`;\n }\n return '';\n }\n\n getExternalSourceMap() {\n return this.sourceMap;\n }\n\n setExternalSourceMap(sourceMap) {\n this.sourceMap = sourceMap;\n }\n\n isInline() {\n return this.options.sourceMapFileInline;\n }\n\n getSourceMapURL() {\n return this.sourceMapURL;\n }\n\n getOutputFilename() {\n return this.options.sourceMapOutputFilename;\n }\n\n getInputFilename() {\n return this.sourceMapInputFilename;\n }\n }\n\n return SourceMapBuilder;\n};\n","import LessError from './less-error';\nimport transformTree from './transform-tree';\nimport logger from './logger';\n\nexport default SourceMapBuilder => {\n class ParseTree {\n constructor(root, imports) {\n this.root = root;\n this.imports = imports;\n }\n\n toCSS(options) {\n let evaldRoot;\n const result = {};\n let sourceMapBuilder;\n try {\n evaldRoot = transformTree(this.root, options);\n } catch (e) {\n throw new LessError(e, this.imports);\n }\n\n try {\n const compress = Boolean(options.compress);\n if (compress) {\n logger.warn('The compress option has been deprecated. ' + \n 'We recommend you use a dedicated css minifier, for instance see less-plugin-clean-css.');\n }\n\n const toCSSOptions = {\n compress,\n dumpLineNumbers: options.dumpLineNumbers,\n strictUnits: Boolean(options.strictUnits),\n numPrecision: 8};\n\n if (options.sourceMap) {\n sourceMapBuilder = new SourceMapBuilder(options.sourceMap);\n result.css = sourceMapBuilder.toCSS(evaldRoot, toCSSOptions, this.imports);\n } else {\n result.css = evaldRoot.toCSS(toCSSOptions);\n }\n } catch (e) {\n throw new LessError(e, this.imports);\n }\n\n if (options.pluginManager) {\n const postProcessors = options.pluginManager.getPostProcessors();\n for (let i = 0; i < postProcessors.length; i++) {\n result.css = postProcessors[i].process(result.css, { sourceMap: sourceMapBuilder, options, imports: this.imports });\n }\n }\n if (options.sourceMap) {\n result.map = sourceMapBuilder.getExternalSourceMap();\n }\n\n result.imports = [];\n for (const file in this.imports.files) {\n if (this.imports.files.hasOwnProperty(file) && file !== this.imports.rootFilename) {\n result.imports.push(file);\n }\n }\n return result;\n }\n }\n\n return ParseTree;\n};\n","import contexts from './contexts';\nimport Parser from './parser/parser';\nimport LessError from './less-error';\nimport * as utils from './utils';\nimport logger from './logger';\n\nexport default environment => {\n // FileInfo = {\n // 'rewriteUrls' - option - whether to adjust URL's to be relative\n // 'filename' - full resolved filename of current file\n // 'rootpath' - path to append to normal URLs for this node\n // 'currentDirectory' - path to the current file, absolute\n // 'rootFilename' - filename of the base file\n // 'entryPath' - absolute path to the entry file\n // 'reference' - whether the file should not be output and only output parts that are referenced\n\n class ImportManager {\n constructor(less, context, rootFileInfo) {\n this.less = less;\n this.rootFilename = rootFileInfo.filename;\n this.paths = context.paths || []; // Search paths, when importing\n this.contents = {}; // map - filename to contents of all the files\n this.contentsIgnoredChars = {}; // map - filename to lines at the beginning of each file to ignore\n this.mime = context.mime;\n this.error = null;\n this.context = context;\n // Deprecated? Unused outside of here, could be useful.\n this.queue = []; // Files which haven't been imported yet\n this.files = {}; // Holds the imported parse trees.\n }\n\n /**\n * Add an import to be imported\n * @param path - the raw path\n * @param tryAppendExtension - whether to try appending a file extension (.less or .js if the path has no extension)\n * @param currentFileInfo - the current file info (used for instance to work out relative paths)\n * @param importOptions - import options\n * @param callback - callback for when it is imported\n */\n push(path, tryAppendExtension, currentFileInfo, importOptions, callback) {\n const importManager = this;\n const pluginLoader = this.context.pluginManager.Loader;\n\n this.queue.push(path);\n\n const fileParsedFunc = (e, root, fullPath) => {\n importManager.queue.splice(importManager.queue.indexOf(path), 1); // Remove the path from the queue\n\n const importedEqualsRoot = fullPath === importManager.rootFilename;\n if (importOptions.optional && e) {\n callback(null, {rules:[]}, false, null);\n logger.info(`The file ${fullPath} was skipped because it was not found and the import was marked optional.`);\n }\n else {\n // Inline imports aren't cached here.\n // If we start to cache them, please make sure they won't conflict with non-inline imports of the\n // same name as they used to do before this comment and the condition below have been added.\n if (!importManager.files[fullPath] && !importOptions.inline) {\n importManager.files[fullPath] = { root, options: importOptions };\n }\n if (e && !importManager.error) { importManager.error = e; }\n callback(e, root, importedEqualsRoot, fullPath);\n }\n };\n\n const newFileInfo = {\n rewriteUrls: this.context.rewriteUrls,\n entryPath: currentFileInfo.entryPath,\n rootpath: currentFileInfo.rootpath,\n rootFilename: currentFileInfo.rootFilename\n };\n\n const fileManager = environment.getFileManager(path, currentFileInfo.currentDirectory, this.context, environment);\n\n if (!fileManager) {\n fileParsedFunc({ message: `Could not find a file-manager for ${path}` });\n return;\n }\n\n const loadFileCallback = loadedFile => {\n let plugin;\n const resolvedFilename = loadedFile.filename;\n const contents = loadedFile.contents.replace(/^\\uFEFF/, '');\n\n // Pass on an updated rootpath if path of imported file is relative and file\n // is in a (sub|sup) directory\n //\n // Examples:\n // - If path of imported file is 'module/nav/nav.less' and rootpath is 'less/',\n // then rootpath should become 'less/module/nav/'\n // - If path of imported file is '../mixins.less' and rootpath is 'less/',\n // then rootpath should become 'less/../'\n newFileInfo.currentDirectory = fileManager.getPath(resolvedFilename);\n if (newFileInfo.rewriteUrls) {\n newFileInfo.rootpath = fileManager.join(\n (importManager.context.rootpath || ''),\n fileManager.pathDiff(newFileInfo.currentDirectory, newFileInfo.entryPath));\n\n if (!fileManager.isPathAbsolute(newFileInfo.rootpath) && fileManager.alwaysMakePathsAbsolute()) {\n newFileInfo.rootpath = fileManager.join(newFileInfo.entryPath, newFileInfo.rootpath);\n }\n }\n newFileInfo.filename = resolvedFilename;\n\n const newEnv = new contexts.Parse(importManager.context);\n\n newEnv.processImports = false;\n importManager.contents[resolvedFilename] = contents;\n\n if (currentFileInfo.reference || importOptions.reference) {\n newFileInfo.reference = true;\n }\n\n if (importOptions.isPlugin) {\n plugin = pluginLoader.evalPlugin(contents, newEnv, importManager, importOptions.pluginArgs, newFileInfo);\n if (plugin instanceof LessError) {\n fileParsedFunc(plugin, null, resolvedFilename);\n }\n else {\n fileParsedFunc(null, plugin, resolvedFilename);\n }\n } else if (importOptions.inline) {\n fileParsedFunc(null, contents, resolvedFilename);\n } else {\n\n // import (multiple) parse trees apparently get altered and can't be cached.\n // TODO: investigate why this is\n if (importManager.files[resolvedFilename]\n && !importManager.files[resolvedFilename].options.multiple\n && !importOptions.multiple) {\n\n fileParsedFunc(null, importManager.files[resolvedFilename].root, resolvedFilename);\n }\n else {\n new Parser(newEnv, importManager, newFileInfo).parse(contents, (e, root) => {\n fileParsedFunc(e, root, resolvedFilename);\n });\n }\n }\n };\n let promise;\n const context = utils.clone(this.context);\n\n if (tryAppendExtension) {\n context.ext = importOptions.isPlugin ? '.js' : '.less';\n }\n\n if (importOptions.isPlugin) {\n context.mime = 'application/javascript';\n promise = pluginLoader.loadPlugin(path, currentFileInfo.currentDirectory, context, environment, fileManager);\n }\n else {\n promise = fileManager.loadFile(path, currentFileInfo.currentDirectory, context, environment,\n (err, loadedFile) => {\n if (err) {\n fileParsedFunc(err);\n } else {\n loadFileCallback(loadedFile);\n }\n });\n }\n if (promise) {\n promise.then(loadFileCallback, fileParsedFunc);\n }\n }\n }\n\n return ImportManager;\n};\n","let PromiseConstructor;\nimport * as utils from './utils';\n\nexport default (environment, ParseTree, ImportManager) => {\n const render = function (input, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = utils.copyOptions(this.options, {});\n }\n else {\n options = utils.copyOptions(this.options, options || {});\n }\n\n if (!callback) {\n const self = this;\n return new Promise((resolve, reject) => {\n render.call(self, input, options, (err, output) => {\n if (err) {\n reject(err);\n } else {\n resolve(output);\n }\n });\n });\n } else {\n this.parse(input, options, (err, root, imports, options) => {\n if (err) { return callback(err); }\n\n let result;\n try {\n const parseTree = new ParseTree(root, imports);\n result = parseTree.toCSS(options);\n }\n catch (err) { return callback(err); }\n\n callback(null, result);\n });\n }\n };\n\n return render;\n};\n","let PromiseConstructor;\nimport contexts from './contexts';\nimport Parser from './parser/parser';\nimport PluginManager from './plugin-manager';\nimport LessError from './less-error';\nimport * as utils from './utils';\n\nexport default (environment, ParseTree, ImportManager) => {\n const parse = function (input, options, callback) {\n\n if (typeof options === 'function') {\n callback = options;\n options = utils.copyOptions(this.options, {});\n }\n else {\n options = utils.copyOptions(this.options, options || {});\n }\n\n if (!callback) {\n const self = this;\n return new Promise((resolve, reject) => {\n parse.call(self, input, options, (err, output) => {\n if (err) {\n reject(err);\n } else {\n resolve(output);\n }\n });\n });\n } else {\n let context;\n let rootFileInfo;\n const pluginManager = new PluginManager(this, !options.reUsePluginManager);\n\n options.pluginManager = pluginManager;\n\n context = new contexts.Parse(options);\n\n if (options.rootFileInfo) {\n rootFileInfo = options.rootFileInfo;\n } else {\n const filename = options.filename || 'input';\n const entryPath = filename.replace(/[^\\/\\\\]*$/, '');\n rootFileInfo = {\n filename,\n rewriteUrls: context.rewriteUrls,\n rootpath: context.rootpath || '',\n currentDirectory: entryPath,\n entryPath,\n rootFilename: filename\n };\n // add in a missing trailing slash\n if (rootFileInfo.rootpath && rootFileInfo.rootpath.slice(-1) !== '/') {\n rootFileInfo.rootpath += '/';\n }\n }\n\n const imports = new ImportManager(this, context, rootFileInfo);\n this.importManager = imports;\n\n // TODO: allow the plugins to be just a list of paths or names\n // Do an async plugin queue like lessc\n\n if (options.plugins) {\n options.plugins.forEach(plugin => {\n let evalResult;\n let contents;\n if (plugin.fileContent) {\n contents = plugin.fileContent.replace(/^\\uFEFF/, '');\n evalResult = pluginManager.Loader.evalPlugin(contents, context, imports, plugin.options, plugin.filename);\n if (evalResult instanceof LessError) {\n return callback(evalResult);\n }\n }\n else {\n pluginManager.addPlugin(plugin);\n }\n });\n }\n\n new Parser(context, imports, rootFileInfo)\n .parse(input, (e, root) => {\n if (e) { return callback(e); }\n callback(null, root, imports, options);\n }, options);\n }\n };\n return parse;\n};\n","// TODO: Add tests for browser @plugin\n/* global window */\n\nimport AbstractPluginLoader from '../less/environment/abstract-plugin-loader.js';\n\n/**\n * Browser Plugin Loader\n */\nclass PluginLoader extends AbstractPluginLoader {\n constructor(less) {\n super();\n\n this.less = less;\n // Should we shim this.require for browser? Probably not?\n }\n\n loadPlugin(filename, basePath, context, environment, fileManager) {\n return new Promise((fulfill, reject) => {\n fileManager.loadFile(filename, basePath, context, environment)\n .then(fulfill).catch(reject);\n });\n }\n}\n\nexport default PluginLoader;\n\n","import * as utils from './utils';\nimport browser from './browser';\n\nexport default (window, less, options) => {\n\n function errorHTML(e, rootHref) {\n const id = `less-error-message:${utils.extractId(rootHref || '')}`;\n const template = '
  • {content}
  • ';\n const elem = window.document.createElement('div');\n let timer;\n let content;\n const errors = [];\n const filename = e.filename || rootHref;\n const filenameNoPath = filename.match(/([^\\/]+(\\?.*)?)$/)[1];\n\n elem.id = id;\n elem.className = 'less-error-message';\n\n content = `

    ${e.type || 'Syntax'}Error: ${e.message || 'There is an error in your .less file'}` + \n `

    in ${filenameNoPath} `;\n\n const errorline = (e, i, classname) => {\n if (e.extract[i] !== undefined) {\n errors.push(template.replace(/\\{line\\}/, (parseInt(e.line, 10) || 0) + (i - 1))\n .replace(/\\{class\\}/, classname)\n .replace(/\\{content\\}/, e.extract[i]));\n }\n };\n\n if (e.line) {\n errorline(e, 0, '');\n errorline(e, 1, 'line');\n errorline(e, 2, '');\n content += `on line ${e.line}, column ${e.column + 1}:

      ${errors.join('')}
    `;\n }\n if (e.stack && (e.extract || options.logLevel >= 4)) {\n content += `
    Stack Trace
    ${e.stack.split('\\n').slice(1).join('
    ')}`;\n }\n elem.innerHTML = content;\n\n // CSS for error messages\n browser.createCSS(window.document, [\n '.less-error-message ul, .less-error-message li {',\n 'list-style-type: none;',\n 'margin-right: 15px;',\n 'padding: 4px 0;',\n 'margin: 0;',\n '}',\n '.less-error-message label {',\n 'font-size: 12px;',\n 'margin-right: 15px;',\n 'padding: 4px 0;',\n 'color: #cc7777;',\n '}',\n '.less-error-message pre {',\n 'color: #dd6666;',\n 'padding: 4px 0;',\n 'margin: 0;',\n 'display: inline-block;',\n '}',\n '.less-error-message pre.line {',\n 'color: #ff0000;',\n '}',\n '.less-error-message h3 {',\n 'font-size: 20px;',\n 'font-weight: bold;',\n 'padding: 15px 0 5px 0;',\n 'margin: 0;',\n '}',\n '.less-error-message a {',\n 'color: #10a',\n '}',\n '.less-error-message .error {',\n 'color: red;',\n 'font-weight: bold;',\n 'padding-bottom: 2px;',\n 'border-bottom: 1px dashed red;',\n '}'\n ].join('\\n'), { title: 'error-message' });\n\n elem.style.cssText = [\n 'font-family: Arial, sans-serif',\n 'border: 1px solid #e00',\n 'background-color: #eee',\n 'border-radius: 5px',\n '-webkit-border-radius: 5px',\n '-moz-border-radius: 5px',\n 'color: #e00',\n 'padding: 15px',\n 'margin-bottom: 15px'\n ].join(';');\n\n if (options.env === 'development') {\n timer = setInterval(() => {\n const document = window.document;\n const body = document.body;\n if (body) {\n if (document.getElementById(id)) {\n body.replaceChild(elem, document.getElementById(id));\n } else {\n body.insertBefore(elem, body.firstChild);\n }\n clearInterval(timer);\n }\n }, 10);\n }\n }\n\n function removeErrorHTML(path) {\n const node = window.document.getElementById(`less-error-message:${utils.extractId(path)}`);\n if (node) {\n node.parentNode.removeChild(node);\n }\n }\n\n function removeErrorConsole(path) {\n // no action\n }\n\n function removeError(path) {\n if (!options.errorReporting || options.errorReporting === 'html') {\n removeErrorHTML(path);\n } else if (options.errorReporting === 'console') {\n removeErrorConsole(path);\n } else if (typeof options.errorReporting === 'function') {\n options.errorReporting('remove', path);\n }\n }\n\n function errorConsole(e, rootHref) {\n const template = '{line} {content}';\n const filename = e.filename || rootHref;\n const errors = [];\n let content = `${e.type || 'Syntax'}Error: ${e.message || 'There is an error in your .less file'} in ${filename}`;\n\n const errorline = (e, i, classname) => {\n if (e.extract[i] !== undefined) {\n errors.push(template.replace(/\\{line\\}/, (parseInt(e.line, 10) || 0) + (i - 1))\n .replace(/\\{class\\}/, classname)\n .replace(/\\{content\\}/, e.extract[i]));\n }\n };\n\n if (e.line) {\n errorline(e, 0, '');\n errorline(e, 1, 'line');\n errorline(e, 2, '');\n content += ` on line ${e.line}, column ${e.column + 1}:\\n${errors.join('\\n')}`;\n }\n if (e.stack && (e.extract || options.logLevel >= 4)) {\n content += `\\nStack Trace\\n${e.stack}`;\n }\n less.logger.error(content);\n }\n\n function error(e, rootHref) {\n if (!options.errorReporting || options.errorReporting === 'html') {\n errorHTML(e, rootHref);\n } else if (options.errorReporting === 'console') {\n errorConsole(e, rootHref);\n } else if (typeof options.errorReporting === 'function') {\n options.errorReporting('add', e, rootHref);\n }\n }\n\n return {\n add: error,\n remove: removeError\n };\n};\n","/**\n * Kicks off less and compiles any stylesheets\n * used in the browser distributed version of less\n * to kick-start less using the browser api\n */\n/* global window, document */\n\nimport defaultOptions from '../less/default-options';\nimport addDefaultOptions from './add-default-options';\nimport root from './index';\n\nconst options = defaultOptions();\n\nif (window.less) {\n for (const key in window.less) {\n if (window.less.hasOwnProperty(key)) {\n options[key] = window.less[key];\n }\n }\n}\naddDefaultOptions(window, options);\n\noptions.plugins = options.plugins || [];\n\nif (window.LESS_PLUGINS) {\n options.plugins = options.plugins.concat(window.LESS_PLUGINS);\n}\n\nconst less = root(window, options);\nexport default less;\n\nwindow.less = less;\n\nlet css;\nlet head;\nlet style;\n\n// Always restore page visibility\nfunction resolveOrReject(data) {\n if (data.filename) {\n console.warn(data);\n }\n if (!options.async) {\n head.removeChild(style);\n }\n}\n\nif (options.onReady) {\n if (/!watch/.test(window.location.hash)) {\n less.watch();\n }\n // Simulate synchronous stylesheet loading by hiding page rendering\n if (!options.async) {\n css = 'body { display: none !important }';\n head = document.head || document.getElementsByTagName('head')[0];\n style = document.createElement('style');\n\n style.type = 'text/css';\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n\n head.appendChild(style);\n }\n less.registerStylesheetsImmediately();\n less.pageLoadFinished = less.refresh(less.env === 'development').then(resolveOrReject, resolveOrReject);\n}\n","// Export a new default each time\nexport default () => ({\n /* Inline Javascript - @plugin still allowed */\n javascriptEnabled: false,\n\n /* Outputs a makefile import dependency list to stdout. */\n depends: false,\n\n /* (DEPRECATED) Compress using less built-in compression. \n * This does an okay job but does not utilise all the tricks of \n * dedicated css compression. */\n compress: false,\n\n /* Runs the less parser and just reports errors without any output. */\n lint: false,\n\n /* Sets available include paths.\n * If the file in an @import rule does not exist at that exact location, \n * less will look for it at the location(s) passed to this option. \n * You might use this for instance to specify a path to a library which \n * you want to be referenced simply and relatively in the less files. */\n paths: [],\n\n /* color output in the terminal */\n color: true,\n\n /* The strictImports controls whether the compiler will allow an @import inside of either \n * @media blocks or (a later addition) other selector blocks.\n * See: https://github.com/less/less.js/issues/656 */\n strictImports: false,\n\n /* Allow Imports from Insecure HTTPS Hosts */\n insecure: false,\n\n /* Allows you to add a path to every generated import and url in your css. \n * This does not affect less import statements that are processed, just ones \n * that are left in the output css. */\n rootpath: '',\n\n /* By default URLs are kept as-is, so if you import a file in a sub-directory \n * that references an image, exactly the same URL will be output in the css. \n * This option allows you to re-write URL's in imported files so that the \n * URL is always relative to the base imported file */\n rewriteUrls: false,\n\n /* How to process math \n * 0 always - eagerly try to solve all operations\n * 1 parens-division - require parens for division \"/\"\n * 2 parens | strict - require parens for all operations\n * 3 strict-legacy - legacy strict behavior (super-strict)\n */\n math: 0,\n\n /* Without this option, less attempts to guess at the output unit when it does maths. */\n strictUnits: false,\n\n /* Effectively the declaration is put at the top of your base Less file, \n * meaning it can be used but it also can be overridden if this variable \n * is defined in the file. */\n globalVars: null,\n\n /* As opposed to the global variable option, this puts the declaration at the\n * end of your base file, meaning it will override anything defined in your Less file. */\n modifyVars: null,\n\n /* This option allows you to specify a argument to go on to every URL. */\n urlArgs: ''\n});","import {addDataAttr} from './utils';\nimport browser from './browser';\n\nexport default (window, options) => {\n\n // use options from the current script tag data attribues\n addDataAttr(options, browser.currentScript(window));\n\n if (options.isFileProtocol === undefined) {\n options.isFileProtocol = /^(file|(chrome|safari)(-extension)?|resource|qrc|app):/.test(window.location.protocol);\n }\n\n // Load styles asynchronously (default: false)\n //\n // This is set to `false` by default, so that the body\n // doesn't start loading before the stylesheets are parsed.\n // Setting this to `true` can result in flickering.\n //\n options.async = options.async || false;\n options.fileAsync = options.fileAsync || false;\n\n // Interval between watch polls\n options.poll = options.poll || (options.isFileProtocol ? 1000 : 1500);\n\n options.env = options.env || (window.location.hostname == '127.0.0.1' ||\n window.location.hostname == '0.0.0.0' ||\n window.location.hostname == 'localhost' ||\n (window.location.port &&\n window.location.port.length > 0) ||\n options.isFileProtocol ? 'development'\n : 'production');\n\n const dumpLineNumbers = /!dumpLineNumbers:(comments|mediaquery|all)/.exec(window.location.hash);\n if (dumpLineNumbers) {\n options.dumpLineNumbers = dumpLineNumbers[1];\n }\n\n if (options.useFileCache === undefined) {\n options.useFileCache = true;\n }\n\n if (options.onReady === undefined) {\n options.onReady = true;\n }\n\n if (options.relativeUrls) {\n options.rewriteUrls = 'all';\n }\n};\n","//\n// index.js\n// Should expose the additional browser functions on to the less object\n//\nimport {addDataAttr} from './utils';\nimport lessRoot from '../less';\nimport browser from './browser';\nimport FM from './file-manager';\nimport PluginLoader from './plugin-loader';\nimport LogListener from './log-listener';\nimport ErrorReporting from './error-reporting';\nimport Cache from './cache';\nimport ImageSize from './image-size';\n\nexport default (window, options) => {\n const document = window.document;\n const less = lessRoot();\n\n less.options = options;\n const environment = less.environment;\n const FileManager = FM(options, less.logger);\n const fileManager = new FileManager();\n environment.addFileManager(fileManager);\n less.FileManager = FileManager;\n less.PluginLoader = PluginLoader;\n\n LogListener(less, options);\n const errors = ErrorReporting(window, less, options);\n const cache = less.cache = options.cache || Cache(window, options, less.logger);\n ImageSize(less.environment);\n\n // Setup user functions - Deprecate?\n if (options.functions) {\n less.functions.functionRegistry.addMultiple(options.functions);\n }\n\n const typePattern = /^text\\/(x-)?less$/;\n\n function clone(obj) {\n const cloned = {};\n for (const prop in obj) {\n if (obj.hasOwnProperty(prop)) {\n cloned[prop] = obj[prop];\n }\n }\n return cloned;\n }\n\n // only really needed for phantom\n function bind(func, thisArg) {\n const curryArgs = Array.prototype.slice.call(arguments, 2);\n return function() {\n const args = curryArgs.concat(Array.prototype.slice.call(arguments, 0));\n return func.apply(thisArg, args);\n };\n }\n\n function loadStyles(modifyVars) {\n const styles = document.getElementsByTagName('style');\n let style;\n\n for (let i = 0; i < styles.length; i++) {\n style = styles[i];\n if (style.type.match(typePattern)) {\n const instanceOptions = clone(options);\n instanceOptions.modifyVars = modifyVars;\n const lessText = style.innerHTML || '';\n instanceOptions.filename = document.location.href.replace(/#.*$/, '');\n\n /* jshint loopfunc:true */\n // use closure to store current style\n less.render(lessText, instanceOptions,\n bind((style, e, result) => {\n if (e) {\n errors.add(e, 'inline');\n } else {\n style.type = 'text/css';\n if (style.styleSheet) {\n style.styleSheet.cssText = result.css;\n } else {\n style.innerHTML = result.css;\n }\n }\n }, null, style));\n }\n }\n }\n\n function loadStyleSheet(sheet, callback, reload, remaining, modifyVars) {\n\n const instanceOptions = clone(options);\n addDataAttr(instanceOptions, sheet);\n instanceOptions.mime = sheet.type;\n\n if (modifyVars) {\n instanceOptions.modifyVars = modifyVars;\n }\n\n function loadInitialFileCallback(loadedFile) {\n const data = loadedFile.contents;\n const path = loadedFile.filename;\n const webInfo = loadedFile.webInfo;\n\n const newFileInfo = {\n currentDirectory: fileManager.getPath(path),\n filename: path,\n rootFilename: path,\n rewriteUrls: instanceOptions.rewriteUrls\n };\n\n newFileInfo.entryPath = newFileInfo.currentDirectory;\n newFileInfo.rootpath = instanceOptions.rootpath || newFileInfo.currentDirectory;\n\n if (webInfo) {\n webInfo.remaining = remaining;\n\n const css = cache.getCSS(path, webInfo, instanceOptions.modifyVars);\n if (!reload && css) {\n webInfo.local = true;\n callback(null, css, data, sheet, webInfo, path);\n return;\n }\n\n }\n\n // TODO add tests around how this behaves when reloading\n errors.remove(path);\n\n instanceOptions.rootFileInfo = newFileInfo;\n less.render(data, instanceOptions, (e, result) => {\n if (e) {\n e.href = path;\n callback(e);\n } else {\n cache.setCSS(sheet.href, webInfo.lastModified, instanceOptions.modifyVars, result.css);\n callback(null, result.css, data, sheet, webInfo, path);\n }\n });\n }\n\n fileManager.loadFile(sheet.href, null, instanceOptions, environment)\n .then(loadedFile => {\n loadInitialFileCallback(loadedFile);\n }).catch(err => {\n console.log(err);\n callback(err);\n });\n\n }\n\n function loadStyleSheets(callback, reload, modifyVars) {\n for (let i = 0; i < less.sheets.length; i++) {\n loadStyleSheet(less.sheets[i], callback, reload, less.sheets.length - (i + 1), modifyVars);\n }\n }\n\n function initRunningMode() {\n if (less.env === 'development') {\n less.watchTimer = setInterval(() => {\n if (less.watchMode) {\n fileManager.clearFileCache();\n loadStyleSheets((e, css, _, sheet, webInfo) => {\n if (e) {\n errors.add(e, e.href || sheet.href);\n } else if (css) {\n browser.createCSS(window.document, css, sheet);\n }\n });\n }\n }, options.poll);\n }\n }\n\n //\n // Watch mode\n //\n less.watch = function () {\n if (!less.watchMode ) {\n less.env = 'development';\n initRunningMode();\n }\n this.watchMode = true;\n return true;\n };\n\n less.unwatch = function () {clearInterval(less.watchTimer); this.watchMode = false; return false; };\n\n //\n // Synchronously get all tags with the 'rel' attribute set to\n // \"stylesheet/less\".\n //\n less.registerStylesheetsImmediately = () => {\n const links = document.getElementsByTagName('link');\n less.sheets = [];\n\n for (let i = 0; i < links.length; i++) {\n if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) &&\n (links[i].type.match(typePattern)))) {\n less.sheets.push(links[i]);\n }\n }\n };\n\n //\n // Asynchronously get all tags with the 'rel' attribute set to\n // \"stylesheet/less\", returning a Promise.\n //\n less.registerStylesheets = () => new Promise((resolve, reject) => {\n less.registerStylesheetsImmediately();\n resolve();\n });\n\n //\n // With this function, it's possible to alter variables and re-render\n // CSS without reloading less-files\n //\n less.modifyVars = record => less.refresh(true, record, false);\n\n less.refresh = (reload, modifyVars, clearFileCache) => {\n if ((reload || clearFileCache) && clearFileCache !== false) {\n fileManager.clearFileCache();\n }\n return new Promise((resolve, reject) => {\n let startTime;\n let endTime;\n let totalMilliseconds;\n let remainingSheets;\n startTime = endTime = new Date();\n\n // Set counter for remaining unprocessed sheets\n remainingSheets = less.sheets.length;\n\n if (remainingSheets === 0) {\n\n endTime = new Date();\n totalMilliseconds = endTime - startTime;\n less.logger.info('Less has finished and no sheets were loaded.');\n resolve({\n startTime,\n endTime,\n totalMilliseconds,\n sheets: less.sheets.length\n });\n\n } else {\n // Relies on less.sheets array, callback seems to be guaranteed to be called for every element of the array\n loadStyleSheets((e, css, _, sheet, webInfo) => {\n if (e) {\n errors.add(e, e.href || sheet.href);\n reject(e);\n return;\n }\n if (webInfo.local) {\n less.logger.info(`Loading ${sheet.href} from cache.`);\n } else {\n less.logger.info(`Rendered ${sheet.href} successfully.`);\n }\n browser.createCSS(window.document, css, sheet);\n less.logger.info(`CSS for ${sheet.href} generated in ${new Date() - endTime}ms`);\n\n // Count completed sheet\n remainingSheets--;\n\n // Check if the last remaining sheet was processed and then call the promise\n if (remainingSheets === 0) {\n totalMilliseconds = new Date() - startTime;\n less.logger.info(`Less has finished. CSS generated in ${totalMilliseconds}ms`);\n resolve({\n startTime,\n endTime,\n totalMilliseconds,\n sheets: less.sheets.length\n });\n }\n endTime = new Date();\n }, reload, modifyVars);\n }\n\n loadStyles(modifyVars);\n });\n };\n\n less.refreshStyles = loadStyles;\n return less;\n};\n","export default (less, options) => {\n const logLevel_debug = 4;\n const logLevel_info = 3;\n const logLevel_warn = 2;\n const logLevel_error = 1;\n\n // The amount of logging in the javascript console.\n // 3 - Debug, information and errors\n // 2 - Information and errors\n // 1 - Errors\n // 0 - None\n // Defaults to 2\n options.logLevel = typeof options.logLevel !== 'undefined' ? options.logLevel : (options.env === 'development' ? logLevel_info : logLevel_error);\n\n if (!options.loggers) {\n options.loggers = [{\n debug: function(msg) {\n if (options.logLevel >= logLevel_debug) {\n console.log(msg);\n }\n },\n info: function(msg) {\n if (options.logLevel >= logLevel_info) {\n console.log(msg);\n }\n },\n warn: function(msg) {\n if (options.logLevel >= logLevel_warn) {\n console.warn(msg);\n }\n },\n error: function(msg) {\n if (options.logLevel >= logLevel_error) {\n console.error(msg);\n }\n }\n }];\n }\n for (let i = 0; i < options.loggers.length; i++) {\n less.logger.addListener(options.loggers[i]);\n }\n};\n","// Cache system is a bit outdated and could do with work\n\nexport default (window, options, logger) => {\n let cache = null;\n if (options.env !== 'development') {\n try {\n cache = (typeof window.localStorage === 'undefined') ? null : window.localStorage;\n } catch (_) {}\n }\n return {\n setCSS: function(path, lastModified, modifyVars, styles) {\n if (cache) {\n logger.info(`saving ${path} to cache.`);\n try {\n cache.setItem(path, styles);\n cache.setItem(`${path}:timestamp`, lastModified);\n if (modifyVars) {\n cache.setItem(`${path}:vars`, JSON.stringify(modifyVars));\n }\n } catch (e) {\n // TODO - could do with adding more robust error handling\n logger.error(`failed to save \"${path}\" to local storage for caching.`);\n }\n }\n },\n getCSS: function(path, webInfo, modifyVars) {\n const css = cache && cache.getItem(path);\n const timestamp = cache && cache.getItem(`${path}:timestamp`);\n let vars = cache && cache.getItem(`${path}:vars`);\n\n modifyVars = modifyVars || {};\n vars = vars || \"{}\"; // if not set, treat as the JSON representation of an empty object\n\n if (timestamp && webInfo.lastModified &&\n (new Date(webInfo.lastModified).valueOf() ===\n new Date(timestamp).valueOf()) &&\n JSON.stringify(modifyVars) === vars) {\n // Use local copy\n return css;\n }\n }\n };\n};\n","\nimport functionRegistry from './../less/functions/function-registry';\n\nexport default () => {\n function imageSize() {\n throw {\n type: 'Runtime',\n message: 'Image size functions are not supported in browser version of less'\n };\n }\n\n const imageFunctions = {\n 'image-size': function(filePathNode) {\n imageSize(this, filePathNode);\n return -1;\n },\n 'image-width': function(filePathNode) {\n imageSize(this, filePathNode);\n return -1;\n },\n 'image-height': function(filePathNode) {\n imageSize(this, filePathNode);\n return -1;\n }\n };\n\n functionRegistry.addMultiple(imageFunctions);\n};\n"],"names":["extractId","href","replace","addDataAttr","options","tag","opt","dataset","hasOwnProperty","JSON","parse","_","createCSS","document","styles","sheet","id","title","utils","oldStyleNode","getElementById","keepOldStyleNode","styleNode","createElement","setAttribute","media","styleSheet","appendChild","createTextNode","childNodes","length","firstChild","nodeValue","head","getElementsByTagName","nextEl","nextSibling","parentNode","insertBefore","removeChild","cssText","e","Error","currentScript","window","scripts","duration","angle","Math","PI","colors","unitConversions","Node","parent","visibilityBlocks","undefined","nodeVisible","rootNode","parsed","self","this","Object","defineProperty","get","fileInfo","getIndex","nodes","set","node","Array","isArray","forEach","_index","_fileInfo","context","strs","genCSS","add","chunk","index","push","isEmpty","join","output","value","visitor","visit","op","a","b","precision","numPrecision","Number","toFixed","info","compare","type","i","numericCompare","Color","rgb","originalForm","match","map","c","parseInt","alpha","split","_this","r","g","pow","toCSS","doNotCompress","color","colorFunction","compress","args","fround","indexOf","clamp","round","concat","toHSL","h","s","l","toRGB","splitcolor","other","_operate","toHex","max","min","d","v","x","toString","prototype","fromKeyword","keyword","key","toLowerCase","slice","Paren","eval","_noSpaceCombinators","Combinator","emptyOrWhitespace","trim","spaceOrEmpty","Element","combinator","isVariable","currentFileInfo","visibilityInfo","copyVisibilityInfo","setParent","_typeof","firstSelector","charAt","ALWAYS","PARENS_DIVISION","PARENS","STRICT_LEGACY","RewriteUrls","OFF","LOCAL","ALL","clone","_instanceof","obj","nativeMap","nativeSet","nativePromise","Map","Set","Promise","circular","depth","includeNonEnumerable","allParents","allChildren","useBuffer","Buffer","Infinity","_clone","child","proto","resolve","reject","then","err","__isArray","__isRegExp","RegExp","source","__getRegExpFlags","lastIndex","__isDate","Date","getTime","isBuffer","allocUnsafe","copy","create","getPrototypeOf","keyChild","valueChild","entryChild","attrs","getOwnPropertyDescriptor","getOwnPropertySymbols","symbols","symbol","descriptor","enumerable","allPropertyNames","getOwnPropertyNames","propertyName","__objToStr","o","call","re","flags","global","ignoreCase","multiline","clonePrototype","module","exports","getLocation","inputStream","n","line","column","copyArray","arr","cloned","prop","defaults","obj1","obj2","newObj","_defaults","CloneHelper","assign","copyOptions","opts","strictMath","math","Constants","relativeUrls","rewriteUrls","flattenArray","result","LessError","fileContentMap","currentFilename","filename","message","stack","input","contents","loc","col","callLine","lines","found","callExtract","extract","F","constructor","error","stylize","str","errorTxt","substr","Selector","elements","extendList","condition","evaldCondition","getElements","mixinElements_","visitArray","newSelector","mediaEmpty","els","parseNode","imports","sels","olen","len","mixinElements","shift","extend","createDerived","Value","Keyword","True","False","Anonymous","mapLines","rulesetLike","allowRoot","Boolean","MATH","Declaration","name","important","merge","inline","variable","lastRule","prevMath","evaldValue","mathBypass","evalName","importantScope","importantResult","pop","debugInfo","ctx","lineSeparator","dumpLineNumbers","asComment","asMediaQuery","lineNumber","fileName","filenameWithProtocol","test","Comment","isLineComment","getDebugInfo","isCompressed","contexts","copyFromOriginal","original","destination","propertiesToCopy","parseCopyProperties","Parse","paths","evalCopyProperties","isPathRelative","path","isPathLocalRelative","Eval","frames","inCalc","mathOn","calcStack","parensStack","rootpath","newPath","normalizePath","segment","segments","reverse","makeRegistry","base","_data","func","addMultiple","functions","keys","getLocalFunctions","inherit","defaultFunc","value_","error_","reset","Ruleset","selectors","rules","strictImports","_lookups","_variables","_properties","selCnt","selector","hasVariable","hasOnePassingSelector","j","toParseSelectors","rule","subRule","ruleset","originalRuleset","root","firstRoot","allowImports","functionRegistry","globalFunctionRegistry","ctxFrames","unshift","ctxSelectors","evalImports","rsRules","evalFirst","mediaBlockCount","mediaBlocks","filter","splice","resetCache","isJustParentSelector","bubbleSelectors","importRules","makeImportant","lastSelector","_rulesets","reduce","hash","variables","vars","decl","parseValue","properties","toParse","transformDeclaration","filtRules","isRuleset","foundMixins","rulesets","find","apply","ruleNodes","tabLevel","sep","tabRuleStr","tabSetStr","charsetNodeIndex","importNodeIndex","isCharset","pathSubCnt","pathCnt","currentLastRule","isRulesetLike","isVisible","joinSelector","createParenthesis","elementsToPak","originalElement","replacementParen","insideParent","createSelector","containedElement","element","addReplacementIntoPath","beginningPath","addPath","replacedElement","originalSelector","newSelectorPath","newJoinedSelector","parentEl","restOfPath","addAllReplacementsIntoPath","addPaths","mergeElementsOnToSelectors","sel","deriveSelector","deriveFrom","newPaths","replaceParentSelector","inSelector","k","currentElements","newSelectors","selectorsMultiplied","el","maybeSelector","hadParentSelector","nestedSelector","replaced","nestedPaths","replacedNewSelectors","concatenated","bind","AtRule","isRooted","createEmptySelectors","outputRuleset","mediaPathBackup","mediaBlocksBackup","mediaPath","ruleCnt","DetachedRuleset","Unit","numerator","denominator","backupUnit","sort","strictUnits","returnStr","is","unitString","toUpperCase","callback","group","mapUnit","groupName","atomicUnit","counter","count","Dimension","unit","parseFloat","isNaN","isSingular","strValue","String","isLength","convertTo","usedUnits","cancel","unify","conversions","targetUnit","applyUnit","derivedConversions","Operation","operands","isSpaced","isMathOn","toColor","operate","Expression","noSpacing","returnValue","inParenthesis","parens","parensInOp","doubleParen","outOfParenthesis","functionCaller","item","subNodes","Call","calc","currentMathContext","enterCalc","exitCalc","funcCaller","FunctionCaller","isValid","columnNumber","Variable","evaluating","frame","fun","Property","property","mergeRules","pluginManager","less","visitors","ToCSSVisitor","_mergeRules","vArr","Attribute","Quoted","content","escaped","quote","variableRegex","propRegex","that","iterativeReplace","regexp","replacementFnc","evaluatedValue","URL","val","isEvald","pathRequiresRewrite","rewritePath","urlArgs","Media","features","evalTop","evalNested","multiMedia","permute","fragment","rest","Import","css","pathValue","getPath","isPlugin","reference","containsVariables","doEval","blocksVisibility","addVisibilityBlock","registry","skip","importedFilename","newImport","evalPath","JsEvalNode","expression","evalContext","javascriptEnabled","jsify","Function","toJS","JavaScript","string","evaluateJavaScript","Assignment","Condition","negate","lvalue","rvalue","UnicodeDescriptor","Negative","Extend","option","object_id","next_id","parent_ids","allowBefore","allowAfter","selectorElements","selfElements","selfSelectors","VariableCall","detachedRuleset","callEval","NamespaceValue","ruleCall","lookups","lastDeclaration","substring","Definition","params","variadic","arity","optionalParameters","required","p","mixinEnv","evaldArguments","varargs","arg","isNamedFound","argIndex","argsLength","prependRule","_arguments","mixinFrames","evalParams","allArgsCnt","requiredArgsCnt","MixinCall","arguments","mixins","mixin","mixinPath","argValue","m","f","isRecursive","isOneFound","candidate","defaultResult","noArgumentsFilter","candidates","conditionResult","defFalseEitherCase","defNone","defTrue","defFalse","calcDefGroup","namespace","matchCondition","expand","matchArgs","MixinDefinition","format","newRules","evalCall","_setVisibilityToReplacement","replacement","msg","_fireEvent","warn","debug","addListener","listener","_listeners","removeListener","logFunction","environment","externalEnvironment","fileManagers","requiredFunctions","propName","environmentFunc","currentDirectory","isSync","logger","getFileManagers","fileManager","AbstractFileManager","lastIndexOf","ext","tryAppendExtension","basePath","laterPath","url","baseUrl","urlDirectories","baseUrlDirectories","urlParts","extractUrlParts","baseUrlParts","diff","hostPart","directories","urlPartsRegex","returner","rawDirectories","rawPath","fileUrl","AbstractPluginLoader","require","pluginOptions","pluginObj","localModule","shortname","FileManager","trySetOptions","use","loader","tree","validatePlugin","minVersion","compareVersion","addPlugin","plugin","setOptions","version","versionToString","aVersion","bVersion","versionString","plugins","printUsage","_visitArgs","visitDeeper","_hasIndexed","_noop","Visitor","implementation","_implementation","_visitInCache","_visitOutCache","indexNodeTypes","ticker","typeIndex","nodeTypeIndex","fnName","impl","funcOut","visitArgs","newNode","isReplacing","accept","nonReplacing","cnt","out","evald","flatten","nestedCnt","nestedItem","ImportSequencer","onSequencerEmpty","variableImports","_onSequencerEmpty","_currentDepth","importSequencer","importItem","isReady","tryRun","variableImport","ImportVisitor","importer","finish","_visitor","_importer","_finish","importCount","onceFileDetectionMap","recursionDetector","_sequencer","run","isFinished","visitImport","importNode","inlineCSS","importParent","isVariableImport","addVariableImport","processImportNode","evaldImportNode","evalForImport","multiple","importMultiple","tryAppendLessExtension","onImported","sequencedOnImported","addImport","importedAtRoot","fullPath","importVisitor","isOptional","optional","duplicateImport","oldContext","visitDeclaration","declNode","visitDeclarationOut","visitAtRule","atRuleNode","visitAtRuleOut","visitMixinDefinition","mixinDefinitionNode","visitMixinDefinitionOut","visitRuleset","rulesetNode","visitRulesetOut","visitMedia","mediaNode","visitMediaOut","SetTreeVisibilityVisitor","visible","ensureVisibility","ensureInvisibility","ExtendFinderVisitor","allExtendsStack","allExtends","allSelectorsExtendList","extendOnEveryPath","selectorPath","selExtendList","allSelectorsExtend","foundExtends","findSelfSelectors","firstExtendOnThisSelectorPath","ProcessExtendsVisitor","extendFinder","extendIndices","doExtendChaining","newRoot","checkExtendsForNonMatched","indices","hasFoundMatches","extendsList","extendsListTarget","iterationCount","extendIndex","targetExtendIndex","matches","targetExtend","newExtend","extendsToAdd","extendVisitor","findMatch","selfSelector","extendSelector","extendChainCount","selectorOne","selectorTwo","ruleNode","selectorNode","pathIndex","selectorsToAdd","extendedSelectors","haystackSelectorPath","haystackSelectorIndex","hackstackSelector","hackstackElementIndex","haystackElement","targetCombinator","potentialMatch","needleElements","potentialMatches","matched","initialCombinator","isElementValuesEqual","finished","endPathIndex","endPathElementIndex","elementValue1","elementValue2","replacementSelector","matchIndex","firstElement","newElements","currentSelectorPathIndex","currentSelectorPathElementIndex","currentValue","derived","newAllExtends","JoinSelectorVisitor","getIsOutput","joinSelectors","CSSVisitorUtils","_context","bodyRules","isSilent","owner","thing","originalRules","containsSilentNonBlockedChild","compiledRulesBody","keepOnlyVisibleChilds","removeVisibilityBlock","hasVisibleSelector","mixinNode","visitExtend","extendNode","visitComment","commentNode","resolveVisibility","visitAtRuleWithBody","visitAtRuleWithoutBody","visitAnonymous","anonymousNode","nodeRules","hasFakeRuleset","getBodyRules","charset","comment","checkValidNodes","isRoot","_compileRulesetPaths","nodeRuleCnt","_removeDuplicateRules","isVisibleRuleset","ruleList","ruleCache","ruleCSS","groups","groupsArr","space","comma","MarkVisibleSelectorsVisitor","ExtendVisitor","furthest","furthestPossibleErrorMessage","chunks","current","currentPos","saveStack","parserInput","CHARCODE_SPACE","CHARCODE_TAB","CHARCODE_LF","CHARCODE_CR","CHARCODE_FORWARD_SLASH","skipWhitespace","nextChar","oldi","oldj","curr","endIndex","mem","inp","charCodeAt","autoCommentAbsorb","nextNewLine","text","commentStore","nextStarSlash","save","restore","possibleErrorMessage","state","forget","isWhitespace","offset","pos","code","$re","tok","exec","$char","$str","tokLength","$quoted","startChar","currentPosition","$parseUntil","testChar","returnVal","inComment","blockDepth","blockStack","parseGroups","startPos","lastPos","loop","char","expected","peek","peekChar","currentChar","prevChar","getInput","peekNotNumeric","start","chunkInput","failFunction","fail","lastOpening","lastOpeningParen","lastMultiComment","lastMultiCommentEndBrace","chunkerCurrentIndex","currentChunkStartIndex","cc","cc2","level","parenLevel","emitFrom","emitChunk","force","fromCharCode","chunker","end","furthestReachedEnd","furthestChar","Parser","parsers","getParserInput","expect","expectChar","parseList","currentIndex","returnNodes","parser","additionalData","globalVars","modifyVars","ignored","preText","serializeVars","preProcessors","getPreProcessors","process","banner","contentsIgnoredChars","primary","endInfo","processImports","extendRule","definition","declaration","variableCall","entities","atrule","foundSemiColon","mixinLookup","quoted","forceEscaped","isEscaped","customFuncCall","stop","ieAlpha","boolean","prevArgs","isSemiColonSeparated","argsComma","argsSemiColon","assignment","literal","dimension","unicodeDescriptor","entity","ch","variableCurly","curly","propertyCurly","colorKeyword","ud","javascript","js","escape","parsedName","inValue","ruleLookups","isRule","getLookup","hasParens","elem","elemIndex","isCall","expressionContainsNamed","nameLoop","expressions","hasSep","throwAwayComments","cond","argInfo","conditions","block","lookupValue","attribute","slashedCombinator","isLess","when","blockRuleset","hasDR","ruleProperty","permissiveValue","anonymousValue","untilTokens","done","testCurrentChar","dir","importOptions","mediaFeatures","optionName","importOption","mediaFeature","pluginArgs","nonVendorSpecificName","hasIdentifier","hasExpression","hasUnknown","hasBlock","sub","addition","multiplication","operation","operand","needsParens","logical","next","conditionAnd","negatedCondition","parenthesisCondition","atomicCondition","body","me","tryConditionFollowedByParenthesis","delim","simpleProperty","colorFunctions","trueValue","falseValue","hsla","origColor","hsl","toHSV","number","rgba","size","m1","m2","hue","hsv","hsva","vs","floor","perm","saturation","lightness","hsvhue","hsvsaturation","hsvvalue","red","green","blue","luma","luminance","saturate","amount","method","desaturate","lighten","darken","fadein","fadeout","fade","spin","mix","color1","color2","weight","w","w1","w2","greyscale","contrast","dark","light","threshold","t","argb","toARGB","tint","shade","colorBlend","mode","cb","cs","ar","cr","ab","as","colorBlendModeFunctions","multiply","screen","overlay","softlight","sqrt","hardlight","difference","abs","exclusion","average","negation","getItemsFromNode","_SELF","values","range","step","from","to","stepValue","list","each","rs","iterator","Quote","valueName","keyName","indexName","MathHelper","fn","mathFunctions","ceil","tan","sin","cos","atan","asin","acos","mathHelper","fraction","num","pm","minMax","isMin","currentUnified","referenceUnified","unitStatic","unitClone","order","convert","pi","mod","y","percentage","evaluated","encodeURI","pattern","token","encodeURIComponent","isa","Type","isunit","isruleset","iscolor","isnumber","isstring","iskeyword","isurl","ispixel","ispercentage","isem","colorBlending","fallback","functionThis","mimetypeNode","filePathNode","mimetype","filePath","entryPath","fragmentStart","rawBuffer","getFileManager","useBase64","mimeLookup","charsetLookup","fileSync","loadFileSync","buf","encodeBase64","uri","dataUri","direction","stops","gradientDirectionSvg","position","positionValue","gradientType","rectangleDimension","renderEnv","directionValue","throwArgumentDescriptor","types","evaldRoot","evalEnv","visitorIterator","preEvalVisitors","first","isPreEvalVisitor","isPreVisitor","PluginManager","postProcessors","installedPlugins","pluginCache","Loader","PluginLoader","install","preProcessor","priority","indexToInsertAt","postProcessor","manager","PluginManagerFactory","newFactory","SourceMapOutput","_css","_rootNode","_contentsMap","contentsMap","_contentsIgnoredCharsMap","contentsIgnoredCharsMap","sourceMapFilename","_sourceMapFilename","_outputFilename","outputFilename","sourceMapURL","sourceMapBasepath","_sourceMapBasepath","sourceMapRootpath","_sourceMapRootpath","_outputSourceFiles","outputSourceFiles","_sourceMapGeneratorConstructor","getSourceMapGenerator","_lineNumber","_column","removeBasepath","sourceLines","columns","sourceColumns","inputSource","_sourceMapGenerator","addMapping","generated","normalizeFilename","file","sourceRoot","setSourceContent","sourceMapContent","stringify","toJSON","sourceMap","sourceMapOutput","Environment","SourceMapBuilder","sourceMapOutputFilename","sourceMapGenerator","sourceMapFileInline","sourceMapInputFilename","getCSSAppendage","sourceMapBuilder","ParseTree","transformTree","toCSSOptions","getPostProcessors","getExternalSourceMap","files","rootFilename","parseTree","ImportManager","rootFileInfo","mime","queue","importManager","pluginLoader","fileParsedFunc","importedEqualsRoot","newFileInfo","promise","loadFileCallback","loadedFile","resolvedFilename","pathDiff","isPathAbsolute","alwaysMakePathsAbsolute","newEnv","evalPlugin","loadPlugin","loadFile","render","Render","reUsePluginManager","evalResult","fileContent","Functions","initial","data","ctor","api","fileCache","errback","xhr","XMLHttpRequest","async","isFileProtocol","fileAsync","handleResponse","status","responseText","getResponseHeader","overrideMimeType","open","setRequestHeader","send","onreadystatechange","readyState","location","useFileCache","lessText","webInfo","lastModified","doXHR","log","fulfill","catch","rootHref","errorReporting","errors","errorline","classname","logLevel","errorConsole","timer","filenameNoPath","className","innerHTML","browser","style","env","setInterval","replaceChild","clearInterval","errorHTML","remove","removeErrorHTML","depends","lint","insecure","protocol","poll","hostname","port","onReady","addDefaultOptions","LESS_PLUGINS","lessRoot","FM","addFileManager","loggers","console","LogListener","ErrorReporting","cache","localStorage","setCSS","setItem","getCSS","getItem","timestamp","valueOf","Cache","imageSize","imageFunctions","ImageSize","typePattern","thisArg","curryArgs","loadStyles","instanceOptions","loadStyleSheet","reload","remaining","local","loadInitialFileCallback","loadStyleSheets","sheets","watch","watchMode","watchTimer","clearFileCache","unwatch","registerStylesheetsImmediately","links","rel","registerStylesheets","record","refresh","startTime","endTime","totalMilliseconds","remainingSheets","refreshStyles","resolveOrReject","pageLoadFinished"],"mappings":";;;;;;;;;0LACO,SAASA,EAAUC,UACfA,EAAKC,QAAQ,sBAAuB,IACtCA,QAAQ,uBAAwB,IAChCA,QAAQ,MAAO,IACfA,QAAQ,eAAgB,IACxBA,QAAQ,aAAc,KACtBA,QAAQ,MAAO,KAGjB,SAASC,EAAYC,EAASC,OAC5B,IAAMC,KAAOD,EAAIE,WACdF,EAAIE,QAAQC,eAAeF,MACf,QAARA,GAAyB,oBAARA,GAAqC,aAARA,GAA8B,mBAARA,EACpEF,EAAQE,GAAOD,EAAIE,QAAQD,YAGvBF,EAAQE,GAAOG,KAAKC,MAAML,EAAIE,QAAQD,IAE1C,MAAOK,WCjBR,CACXC,UAAW,SAAUC,EAAUC,EAAQC,OAE7Bd,EAAOc,EAAMd,MAAQ,GAGrBe,iBAAaD,EAAME,OAASC,EAAgBjB,IAG5CkB,EAAeN,EAASO,eAAeJ,GACzCK,GAAmB,EAGjBC,EAAYT,EAASU,cAAc,SACzCD,EAAUE,aAAa,OAAQ,YAC3BT,EAAMU,OACNH,EAAUE,aAAa,QAAST,EAAMU,OAE1CH,EAAUN,GAAKA,EAEVM,EAAUI,aACXJ,EAAUK,YAAYd,EAASe,eAAed,IAG9CO,EAAqC,OAAjBF,GAAyBA,EAAaU,WAAWC,OAAS,GAAKR,EAAUO,WAAWC,OAAS,GAC7GX,EAAaY,WAAWC,YAAcV,EAAUS,WAAWC,eAG7DC,EAAOpB,EAASqB,qBAAqB,QAAQ,MAI9B,OAAjBf,IAA8C,IAArBE,EAA4B,KAC/Cc,EAASpB,GAASA,EAAMqB,aAAe,KACzCD,EACAA,EAAOE,WAAWC,aAAahB,EAAWa,GAE1CF,EAAKN,YAAYL,MAGrBH,IAAqC,IAArBE,GAChBF,EAAakB,WAAWE,YAAYpB,GAMpCG,EAAUI,eAENJ,EAAUI,WAAWc,QAAU1B,EACjC,MAAO2B,SACC,IAAIC,MAAM,2CAI5BC,cAAe,SAASC,OAGVC,EAFJhC,EAAW+B,EAAO/B,gBACjBA,EAAS8B,gBACNE,EAAUhC,EAASqB,qBAAqB,WAC/BW,EAAQf,OAAS,s7DC7D7B,WACC,uBACG,eACR,qBACM,gBACL,gBACA,iBACC,gBACD,yBACS,eACV,qBACM,gBACL,oBACI,oBACA,qBACC,oBACD,gBACJ,yBACS,mBACN,kBACD,eACH,mBACI,mBACA,wBACK,mBACL,mBACA,oBACC,oBACA,sBACE,yBACG,qBACJ,qBACA,kBACH,qBACG,uBACE,wBACC,wBACA,wBACA,wBACA,qBACH,mBACF,sBACG,kBACJ,kBACA,qBACG,oBACD,sBACE,sBACA,kBACJ,oBACE,qBACC,eACN,oBACK,eACL,eACA,gBACC,sBACM,mBACH,kBACD,oBACE,iBACH,gBACD,gBACA,mBACG,wBACK,oBACJ,uBACG,oBACH,qBACC,oBACD,+BACW,oBACX,oBACA,qBACC,oBACD,sBACE,wBACE,uBACD,yBACE,yBACA,yBACA,sBACH,eACP,oBACK,gBACJ,kBACE,iBACD,2BACU,qBACN,uBACE,uBACA,yBACE,0BACC,4BACE,0BACF,0BACA,uBACH,oBACH,oBACA,mBACD,sBACG,eACP,kBACG,gBACF,oBACI,iBACH,oBACG,iBACH,wBACO,oBACJ,wBACI,wBACA,qBACH,oBAC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pB,SAASqB,qBAAqB,QAAQ,IAC9Do5C,GAAQz6C,SAASU,cAAc,UAEzByE,KAAO,WACTs1C,GAAM55C,WACN45C,GAAM55C,WAAWc,QAAUoiB,GAE3B02B,GAAM35C,YAAYd,SAASe,eAAegjB,KAG9C3iB,GAAKN,YAAY25C,KAErB14B,GAAKg8B,iCACLh8B,GAAK48B,iBAAmB58B,GAAKq8B,QAAqB,gBAAbr8B,GAAK24B,KAAuBxvC,KAAKwzC,GAAiBA"} \ No newline at end of file +{"version":3,"file":"less.min.js","sources":["../src/less-browser/utils.js","../src/less-browser/browser.js","../src/less/logger.js","../src/less/environment/environment.js","../src/less/data/colors.js","../src/less/data/unit-conversions.js","../src/less/data/index.js","../src/less/tree/node.js","../src/less/tree/color.js","../src/less/tree/paren.js","../src/less/tree/combinator.js","../src/less/tree/element.js","../src/less/constants.js","../node_modules/is-what/dist/index.esm.js","../node_modules/copy-anything/dist/index.esm.js","../src/less/utils.js","../src/less/less-error.js","../src/less/tree/selector.js","../src/less/tree/value.js","../src/less/tree/keyword.js","../src/less/tree/anonymous.js","../src/less/tree/declaration.js","../src/less/tree/debug-info.js","../src/less/tree/comment.js","../src/less/contexts.js","../src/less/functions/function-registry.js","../src/less/functions/default.js","../src/less/tree/ruleset.js","../src/less/tree/atrule.js","../src/less/tree/detached-ruleset.js","../src/less/tree/unit.js","../src/less/tree/dimension.js","../src/less/tree/operation.js","../src/less/tree/expression.js","../src/less/functions/function-caller.js","../node_modules/tslib/tslib.es6.js","../src/less/tree/call.js","../src/less/tree/variable.js","../src/less/tree/property.js","../src/less/tree/attribute.js","../src/less/tree/quoted.js","../src/less/tree/url.js","../src/less/tree/media.js","../src/less/tree/import.js","../src/less/tree/js-eval-node.js","../src/less/tree/javascript.js","../src/less/tree/assignment.js","../src/less/tree/condition.js","../src/less/tree/unicode-descriptor.js","../src/less/tree/negative.js","../src/less/tree/extend.js","../src/less/tree/variable-call.js","../src/less/tree/namespace-value.js","../src/less/tree/mixin-definition.js","../src/less/tree/mixin-call.js","../src/less/tree/index.js","../src/less/environment/abstract-file-manager.js","../src/less/environment/abstract-plugin-loader.js","../src/less/visitors/visitor.js","../src/less/visitors/import-sequencer.js","../src/less/visitors/import-visitor.js","../src/less/visitors/set-tree-visibility-visitor.js","../src/less/visitors/extend-visitor.js","../src/less/visitors/join-selector-visitor.js","../src/less/visitors/to-css-visitor.js","../src/less/visitors/index.js","../src/less/parser/parser-input.js","../src/less/parser/chunker.js","../src/less/parser/parser.js","../src/less/functions/boolean.js","../src/less/functions/color.js","../src/less/functions/color-blending.js","../src/less/functions/list.js","../src/less/functions/math-helper.js","../src/less/functions/math.js","../src/less/functions/number.js","../src/less/functions/string.js","../src/less/functions/types.js","../src/less/functions/index.js","../src/less/functions/data-uri.js","../src/less/functions/svg.js","../src/less/transform-tree.js","../src/less/plugin-manager.js","../node_modules/parse-node-version/index.js","../src/less-browser/file-manager.js","../src/less/index.js","../src/less/parse-tree.js","../src/less/source-map-builder.js","../src/less/source-map-output.js","../src/less/import-manager.js","../src/less/render.js","../src/less/parse.js","../src/less-browser/plugin-loader.js","../src/less-browser/error-reporting.js","../src/less-browser/bootstrap.js","../src/less/default-options.js","../src/less-browser/add-default-options.js","../src/less-browser/index.js","../src/less-browser/log-listener.js","../src/less-browser/cache.js","../src/less-browser/image-size.js"],"sourcesContent":["\nexport function extractId(href) {\n return href.replace(/^[a-z-]+:\\/+?[^\\/]+/, '') // Remove protocol & domain\n .replace(/[\\?\\&]livereload=\\w+/, '') // Remove LiveReload cachebuster\n .replace(/^\\//, '') // Remove root /\n .replace(/\\.[a-zA-Z]+$/, '') // Remove simple extension\n .replace(/[^\\.\\w-]+/g, '-') // Replace illegal characters\n .replace(/\\./g, ':'); // Replace dots with colons(for valid id)\n}\n\nexport function addDataAttr(options, tag) {\n for (const opt in tag.dataset) {\n if (tag.dataset.hasOwnProperty(opt)) {\n if (opt === 'env' || opt === 'dumpLineNumbers' || opt === 'rootpath' || opt === 'errorReporting') {\n options[opt] = tag.dataset[opt];\n } else {\n try {\n options[opt] = JSON.parse(tag.dataset[opt]);\n }\n catch (_) {}\n }\n }\n }\n}\n","import * as utils from './utils';\n\nexport default {\n createCSS: function (document, styles, sheet) {\n // Strip the query-string\n const href = sheet.href || '';\n\n // If there is no title set, use the filename, minus the extension\n const id = `less:${sheet.title || utils.extractId(href)}`;\n\n // If this has already been inserted into the DOM, we may need to replace it\n const oldStyleNode = document.getElementById(id);\n let keepOldStyleNode = false;\n\n // Create a new stylesheet node for insertion or (if necessary) replacement\n const styleNode = document.createElement('style');\n styleNode.setAttribute('type', 'text/css');\n if (sheet.media) {\n styleNode.setAttribute('media', sheet.media);\n }\n styleNode.id = id;\n\n if (!styleNode.styleSheet) {\n styleNode.appendChild(document.createTextNode(styles));\n\n // If new contents match contents of oldStyleNode, don't replace oldStyleNode\n keepOldStyleNode = (oldStyleNode !== null && oldStyleNode.childNodes.length > 0 && styleNode.childNodes.length > 0 &&\n oldStyleNode.firstChild.nodeValue === styleNode.firstChild.nodeValue);\n }\n\n const head = document.getElementsByTagName('head')[0];\n\n // If there is no oldStyleNode, just append; otherwise, only append if we need\n // to replace oldStyleNode with an updated stylesheet\n if (oldStyleNode === null || keepOldStyleNode === false) {\n const nextEl = sheet && sheet.nextSibling || null;\n if (nextEl) {\n nextEl.parentNode.insertBefore(styleNode, nextEl);\n } else {\n head.appendChild(styleNode);\n }\n }\n if (oldStyleNode && keepOldStyleNode === false) {\n oldStyleNode.parentNode.removeChild(oldStyleNode);\n }\n\n // For IE.\n // This needs to happen *after* the style element is added to the DOM, otherwise IE 7 and 8 may crash.\n // See http://social.msdn.microsoft.com/Forums/en-US/7e081b65-878a-4c22-8e68-c10d39c2ed32/internet-explorer-crashes-appending-style-element-to-head\n if (styleNode.styleSheet) {\n try {\n styleNode.styleSheet.cssText = styles;\n } catch (e) {\n throw new Error('Couldn\\'t reassign styleSheet.cssText.');\n }\n }\n },\n currentScript: function(window) {\n const document = window.document;\n return document.currentScript || (() => {\n const scripts = document.getElementsByTagName('script');\n return scripts[scripts.length - 1];\n })();\n }\n};\n","export default {\n error: function(msg) {\n this._fireEvent('error', msg);\n },\n warn: function(msg) {\n this._fireEvent('warn', msg);\n },\n info: function(msg) {\n this._fireEvent('info', msg);\n },\n debug: function(msg) {\n this._fireEvent('debug', msg);\n },\n addListener: function(listener) {\n this._listeners.push(listener);\n },\n removeListener: function(listener) {\n for (let i = 0; i < this._listeners.length; i++) {\n if (this._listeners[i] === listener) {\n this._listeners.splice(i, 1);\n return;\n }\n }\n },\n _fireEvent: function(type, msg) {\n for (let i = 0; i < this._listeners.length; i++) {\n const logFunction = this._listeners[i][type];\n if (logFunction) {\n logFunction(msg);\n }\n }\n },\n _listeners: []\n};\n","/**\n * @todo Document why this abstraction exists, and the relationship between\n * environment, file managers, and plugin manager\n */\n\nimport logger from '../logger';\n\nclass Environment {\n constructor(externalEnvironment, fileManagers) {\n this.fileManagers = fileManagers || [];\n externalEnvironment = externalEnvironment || {};\n\n const optionalFunctions = ['encodeBase64', 'mimeLookup', 'charsetLookup', 'getSourceMapGenerator'];\n const requiredFunctions = [];\n const functions = requiredFunctions.concat(optionalFunctions);\n\n for (let i = 0; i < functions.length; i++) {\n const propName = functions[i];\n const environmentFunc = externalEnvironment[propName];\n if (environmentFunc) {\n this[propName] = environmentFunc.bind(externalEnvironment);\n } else if (i < requiredFunctions.length) {\n this.warn(`missing required function in environment - ${propName}`);\n }\n }\n }\n\n getFileManager(filename, currentDirectory, options, environment, isSync) {\n\n if (!filename) {\n logger.warn('getFileManager called with no filename.. Please report this issue. continuing.');\n }\n if (currentDirectory == null) {\n logger.warn('getFileManager called with null directory.. Please report this issue. continuing.');\n }\n\n let fileManagers = this.fileManagers;\n if (options.pluginManager) {\n fileManagers = [].concat(fileManagers).concat(options.pluginManager.getFileManagers());\n }\n for (let i = fileManagers.length - 1; i >= 0 ; i--) {\n const fileManager = fileManagers[i];\n if (fileManager[isSync ? 'supportsSync' : 'supports'](filename, currentDirectory, options, environment)) {\n return fileManager;\n }\n }\n return null;\n }\n\n addFileManager(fileManager) {\n this.fileManagers.push(fileManager);\n }\n\n clearFileManagers() {\n this.fileManagers = [];\n }\n}\n\nexport default Environment;\n","export default {\n 'aliceblue':'#f0f8ff',\n 'antiquewhite':'#faebd7',\n 'aqua':'#00ffff',\n 'aquamarine':'#7fffd4',\n 'azure':'#f0ffff',\n 'beige':'#f5f5dc',\n 'bisque':'#ffe4c4',\n 'black':'#000000',\n 'blanchedalmond':'#ffebcd',\n 'blue':'#0000ff',\n 'blueviolet':'#8a2be2',\n 'brown':'#a52a2a',\n 'burlywood':'#deb887',\n 'cadetblue':'#5f9ea0',\n 'chartreuse':'#7fff00',\n 'chocolate':'#d2691e',\n 'coral':'#ff7f50',\n 'cornflowerblue':'#6495ed',\n 'cornsilk':'#fff8dc',\n 'crimson':'#dc143c',\n 'cyan':'#00ffff',\n 'darkblue':'#00008b',\n 'darkcyan':'#008b8b',\n 'darkgoldenrod':'#b8860b',\n 'darkgray':'#a9a9a9',\n 'darkgrey':'#a9a9a9',\n 'darkgreen':'#006400',\n 'darkkhaki':'#bdb76b',\n 'darkmagenta':'#8b008b',\n 'darkolivegreen':'#556b2f',\n 'darkorange':'#ff8c00',\n 'darkorchid':'#9932cc',\n 'darkred':'#8b0000',\n 'darksalmon':'#e9967a',\n 'darkseagreen':'#8fbc8f',\n 'darkslateblue':'#483d8b',\n 'darkslategray':'#2f4f4f',\n 'darkslategrey':'#2f4f4f',\n 'darkturquoise':'#00ced1',\n 'darkviolet':'#9400d3',\n 'deeppink':'#ff1493',\n 'deepskyblue':'#00bfff',\n 'dimgray':'#696969',\n 'dimgrey':'#696969',\n 'dodgerblue':'#1e90ff',\n 'firebrick':'#b22222',\n 'floralwhite':'#fffaf0',\n 'forestgreen':'#228b22',\n 'fuchsia':'#ff00ff',\n 'gainsboro':'#dcdcdc',\n 'ghostwhite':'#f8f8ff',\n 'gold':'#ffd700',\n 'goldenrod':'#daa520',\n 'gray':'#808080',\n 'grey':'#808080',\n 'green':'#008000',\n 'greenyellow':'#adff2f',\n 'honeydew':'#f0fff0',\n 'hotpink':'#ff69b4',\n 'indianred':'#cd5c5c',\n 'indigo':'#4b0082',\n 'ivory':'#fffff0',\n 'khaki':'#f0e68c',\n 'lavender':'#e6e6fa',\n 'lavenderblush':'#fff0f5',\n 'lawngreen':'#7cfc00',\n 'lemonchiffon':'#fffacd',\n 'lightblue':'#add8e6',\n 'lightcoral':'#f08080',\n 'lightcyan':'#e0ffff',\n 'lightgoldenrodyellow':'#fafad2',\n 'lightgray':'#d3d3d3',\n 'lightgrey':'#d3d3d3',\n 'lightgreen':'#90ee90',\n 'lightpink':'#ffb6c1',\n 'lightsalmon':'#ffa07a',\n 'lightseagreen':'#20b2aa',\n 'lightskyblue':'#87cefa',\n 'lightslategray':'#778899',\n 'lightslategrey':'#778899',\n 'lightsteelblue':'#b0c4de',\n 'lightyellow':'#ffffe0',\n 'lime':'#00ff00',\n 'limegreen':'#32cd32',\n 'linen':'#faf0e6',\n 'magenta':'#ff00ff',\n 'maroon':'#800000',\n 'mediumaquamarine':'#66cdaa',\n 'mediumblue':'#0000cd',\n 'mediumorchid':'#ba55d3',\n 'mediumpurple':'#9370d8',\n 'mediumseagreen':'#3cb371',\n 'mediumslateblue':'#7b68ee',\n 'mediumspringgreen':'#00fa9a',\n 'mediumturquoise':'#48d1cc',\n 'mediumvioletred':'#c71585',\n 'midnightblue':'#191970',\n 'mintcream':'#f5fffa',\n 'mistyrose':'#ffe4e1',\n 'moccasin':'#ffe4b5',\n 'navajowhite':'#ffdead',\n 'navy':'#000080',\n 'oldlace':'#fdf5e6',\n 'olive':'#808000',\n 'olivedrab':'#6b8e23',\n 'orange':'#ffa500',\n 'orangered':'#ff4500',\n 'orchid':'#da70d6',\n 'palegoldenrod':'#eee8aa',\n 'palegreen':'#98fb98',\n 'paleturquoise':'#afeeee',\n 'palevioletred':'#d87093',\n 'papayawhip':'#ffefd5',\n 'peachpuff':'#ffdab9',\n 'peru':'#cd853f',\n 'pink':'#ffc0cb',\n 'plum':'#dda0dd',\n 'powderblue':'#b0e0e6',\n 'purple':'#800080',\n 'rebeccapurple':'#663399',\n 'red':'#ff0000',\n 'rosybrown':'#bc8f8f',\n 'royalblue':'#4169e1',\n 'saddlebrown':'#8b4513',\n 'salmon':'#fa8072',\n 'sandybrown':'#f4a460',\n 'seagreen':'#2e8b57',\n 'seashell':'#fff5ee',\n 'sienna':'#a0522d',\n 'silver':'#c0c0c0',\n 'skyblue':'#87ceeb',\n 'slateblue':'#6a5acd',\n 'slategray':'#708090',\n 'slategrey':'#708090',\n 'snow':'#fffafa',\n 'springgreen':'#00ff7f',\n 'steelblue':'#4682b4',\n 'tan':'#d2b48c',\n 'teal':'#008080',\n 'thistle':'#d8bfd8',\n 'tomato':'#ff6347',\n 'turquoise':'#40e0d0',\n 'violet':'#ee82ee',\n 'wheat':'#f5deb3',\n 'white':'#ffffff',\n 'whitesmoke':'#f5f5f5',\n 'yellow':'#ffff00',\n 'yellowgreen':'#9acd32'\n};","export default {\n length: {\n 'm': 1,\n 'cm': 0.01,\n 'mm': 0.001,\n 'in': 0.0254,\n 'px': 0.0254 / 96,\n 'pt': 0.0254 / 72,\n 'pc': 0.0254 / 72 * 12\n },\n duration: {\n 's': 1,\n 'ms': 0.001\n },\n angle: {\n 'rad': 1 / (2 * Math.PI),\n 'deg': 1 / 360,\n 'grad': 1 / 400,\n 'turn': 1\n }\n};","import colors from './colors';\nimport unitConversions from './unit-conversions';\n\nexport default { colors, unitConversions };\n","/**\n * The reason why Node is a class and other nodes simply do not extend\n * from Node (since we're transpiling) is due to this issue:\n * \n * https://github.com/less/less.js/issues/3434\n */\nclass Node {\n constructor() {\n this.parent = null;\n this.visibilityBlocks = undefined;\n this.nodeVisible = undefined;\n this.rootNode = null;\n this.parsed = null;\n }\n\n get currentFileInfo() {\n return this.fileInfo();\n }\n\n get index() {\n return this.getIndex();\n }\n\n setParent(nodes, parent) {\n function set(node) {\n if (node && node instanceof Node) {\n node.parent = parent;\n }\n }\n if (Array.isArray(nodes)) {\n nodes.forEach(set);\n }\n else {\n set(nodes);\n }\n }\n\n getIndex() {\n return this._index || (this.parent && this.parent.getIndex()) || 0;\n }\n\n fileInfo() {\n return this._fileInfo || (this.parent && this.parent.fileInfo()) || {};\n }\n\n isRulesetLike() { return false; }\n\n toCSS(context) {\n const strs = [];\n this.genCSS(context, {\n add: function(chunk, fileInfo, index) {\n strs.push(chunk);\n },\n isEmpty: function () {\n return strs.length === 0;\n }\n });\n return strs.join('');\n }\n\n genCSS(context, output) {\n output.add(this.value);\n }\n\n accept(visitor) {\n this.value = visitor.visit(this.value);\n }\n\n eval() { return this; }\n\n _operate(context, op, a, b) {\n switch (op) {\n case '+': return a + b;\n case '-': return a - b;\n case '*': return a * b;\n case '/': return a / b;\n }\n }\n\n fround(context, value) {\n const precision = context && context.numPrecision;\n // add \"epsilon\" to ensure numbers like 1.000000005 (represented as 1.000000004999...) are properly rounded:\n return (precision) ? Number((value + 2e-16).toFixed(precision)) : value;\n }\n\n static compare(a, b) {\n /* returns:\n -1: a < b\n 0: a = b\n 1: a > b\n and *any* other value for a != b (e.g. undefined, NaN, -2 etc.) */\n\n if ((a.compare) &&\n // for \"symmetric results\" force toCSS-based comparison\n // of Quoted or Anonymous if either value is one of those\n !(b.type === 'Quoted' || b.type === 'Anonymous')) {\n return a.compare(b);\n } else if (b.compare) {\n return -b.compare(a);\n } else if (a.type !== b.type) {\n return undefined;\n }\n\n a = a.value;\n b = b.value;\n if (!Array.isArray(a)) {\n return a === b ? 0 : undefined;\n }\n if (a.length !== b.length) {\n return undefined;\n }\n for (let i = 0; i < a.length; i++) {\n if (Node.compare(a[i], b[i]) !== 0) {\n return undefined;\n }\n }\n return 0;\n }\n\n static numericCompare(a, b) {\n return a < b ? -1\n : a === b ? 0\n : a > b ? 1 : undefined;\n }\n\n // Returns true if this node represents root of ast imported by reference\n blocksVisibility() {\n if (this.visibilityBlocks == null) {\n this.visibilityBlocks = 0;\n }\n return this.visibilityBlocks !== 0;\n }\n\n addVisibilityBlock() {\n if (this.visibilityBlocks == null) {\n this.visibilityBlocks = 0;\n }\n this.visibilityBlocks = this.visibilityBlocks + 1;\n }\n\n removeVisibilityBlock() {\n if (this.visibilityBlocks == null) {\n this.visibilityBlocks = 0;\n }\n this.visibilityBlocks = this.visibilityBlocks - 1;\n }\n\n // Turns on node visibility - if called node will be shown in output regardless\n // of whether it comes from import by reference or not\n ensureVisibility() {\n this.nodeVisible = true;\n }\n\n // Turns off node visibility - if called node will NOT be shown in output regardless\n // of whether it comes from import by reference or not\n ensureInvisibility() {\n this.nodeVisible = false;\n }\n\n // return values:\n // false - the node must not be visible\n // true - the node must be visible\n // undefined or null - the node has the same visibility as its parent\n isVisible() {\n return this.nodeVisible;\n }\n\n visibilityInfo() {\n return {\n visibilityBlocks: this.visibilityBlocks,\n nodeVisible: this.nodeVisible\n };\n }\n\n copyVisibilityInfo(info) {\n if (!info) {\n return;\n }\n this.visibilityBlocks = info.visibilityBlocks;\n this.nodeVisible = info.nodeVisible;\n }\n}\n\nexport default Node;\n","import Node from './node';\nimport colors from '../data/colors';\n\n//\n// RGB Colors - #ff0014, #eee\n//\nconst Color = function(rgb, a, originalForm) {\n const self = this;\n //\n // The end goal here, is to parse the arguments\n // into an integer triplet, such as `128, 255, 0`\n //\n // This facilitates operations and conversions.\n //\n if (Array.isArray(rgb)) {\n this.rgb = rgb;\n } else if (rgb.length >= 6) {\n this.rgb = [];\n rgb.match(/.{2}/g).map(function (c, i) {\n if (i < 3) {\n self.rgb.push(parseInt(c, 16));\n } else {\n self.alpha = (parseInt(c, 16)) / 255;\n }\n });\n } else {\n this.rgb = [];\n rgb.split('').map(function (c, i) {\n if (i < 3) {\n self.rgb.push(parseInt(c + c, 16));\n } else {\n self.alpha = (parseInt(c + c, 16)) / 255;\n }\n });\n }\n this.alpha = this.alpha || (typeof a === 'number' ? a : 1);\n if (typeof originalForm !== 'undefined') {\n this.value = originalForm;\n }\n}\n\nColor.prototype = Object.assign(new Node(), {\n type: 'Color',\n\n luma() {\n let r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255;\n\n r = (r <= 0.03928) ? r / 12.92 : Math.pow(((r + 0.055) / 1.055), 2.4);\n g = (g <= 0.03928) ? g / 12.92 : Math.pow(((g + 0.055) / 1.055), 2.4);\n b = (b <= 0.03928) ? b / 12.92 : Math.pow(((b + 0.055) / 1.055), 2.4);\n\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n },\n\n genCSS(context, output) {\n output.add(this.toCSS(context));\n },\n\n toCSS(context, doNotCompress) {\n const compress = context && context.compress && !doNotCompress;\n let color;\n let alpha;\n let colorFunction;\n let args = [];\n\n // `value` is set if this color was originally\n // converted from a named color string so we need\n // to respect this and try to output named color too.\n alpha = this.fround(context, this.alpha);\n\n if (this.value) {\n if (this.value.indexOf('rgb') === 0) {\n if (alpha < 1) {\n colorFunction = 'rgba';\n }\n } else if (this.value.indexOf('hsl') === 0) {\n if (alpha < 1) {\n colorFunction = 'hsla';\n } else {\n colorFunction = 'hsl';\n }\n } else {\n return this.value;\n }\n } else {\n if (alpha < 1) {\n colorFunction = 'rgba';\n }\n }\n\n switch (colorFunction) {\n case 'rgba':\n args = this.rgb.map(function (c) {\n return clamp(Math.round(c), 255);\n }).concat(clamp(alpha, 1));\n break;\n case 'hsla':\n args.push(clamp(alpha, 1));\n case 'hsl':\n color = this.toHSL();\n args = [\n this.fround(context, color.h),\n `${this.fround(context, color.s * 100)}%`,\n `${this.fround(context, color.l * 100)}%`\n ].concat(args);\n }\n\n if (colorFunction) {\n // Values are capped between `0` and `255`, rounded and zero-padded.\n return `${colorFunction}(${args.join(`,${compress ? '' : ' '}`)})`;\n }\n\n color = this.toRGB();\n\n if (compress) {\n const splitcolor = color.split('');\n\n // Convert color to short format\n if (splitcolor[1] === splitcolor[2] && splitcolor[3] === splitcolor[4] && splitcolor[5] === splitcolor[6]) {\n color = `#${splitcolor[1]}${splitcolor[3]}${splitcolor[5]}`;\n }\n }\n\n return color;\n },\n\n //\n // Operations have to be done per-channel, if not,\n // channels will spill onto each other. Once we have\n // our result, in the form of an integer triplet,\n // we create a new Color node to hold the result.\n //\n operate(context, op, other) {\n const rgb = new Array(3);\n const alpha = this.alpha * (1 - other.alpha) + other.alpha;\n for (let c = 0; c < 3; c++) {\n rgb[c] = this._operate(context, op, this.rgb[c], other.rgb[c]);\n }\n return new Color(rgb, alpha);\n },\n\n toRGB() {\n return toHex(this.rgb);\n },\n\n toHSL() {\n const r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255, a = this.alpha;\n\n const max = Math.max(r, g, b), min = Math.min(r, g, b);\n let h;\n let s;\n const l = (max + min) / 2;\n const d = max - min;\n\n if (max === min) {\n h = s = 0;\n } else {\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n\n switch (max) {\n case r: h = (g - b) / d + (g < b ? 6 : 0); break;\n case g: h = (b - r) / d + 2; break;\n case b: h = (r - g) / d + 4; break;\n }\n h /= 6;\n }\n return { h: h * 360, s, l, a };\n },\n\n // Adapted from http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript\n toHSV() {\n const r = this.rgb[0] / 255, g = this.rgb[1] / 255, b = this.rgb[2] / 255, a = this.alpha;\n\n const max = Math.max(r, g, b), min = Math.min(r, g, b);\n let h;\n let s;\n const v = max;\n\n const d = max - min;\n if (max === 0) {\n s = 0;\n } else {\n s = d / max;\n }\n\n if (max === min) {\n h = 0;\n } else {\n switch (max) {\n case r: h = (g - b) / d + (g < b ? 6 : 0); break;\n case g: h = (b - r) / d + 2; break;\n case b: h = (r - g) / d + 4; break;\n }\n h /= 6;\n }\n return { h: h * 360, s, v, a };\n },\n\n toARGB() {\n return toHex([this.alpha * 255].concat(this.rgb));\n },\n\n compare(x) {\n return (x.rgb &&\n x.rgb[0] === this.rgb[0] &&\n x.rgb[1] === this.rgb[1] &&\n x.rgb[2] === this.rgb[2] &&\n x.alpha === this.alpha) ? 0 : undefined;\n }\n});\n\nColor.fromKeyword = function(keyword) {\n let c;\n const key = keyword.toLowerCase();\n if (colors.hasOwnProperty(key)) {\n c = new Color(colors[key].slice(1));\n }\n else if (key === 'transparent') {\n c = new Color([0, 0, 0], 0);\n }\n\n if (c) {\n c.value = keyword;\n return c;\n }\n};\n\nfunction clamp(v, max) {\n return Math.min(Math.max(v, 0), max);\n}\n\nfunction toHex(v) {\n return `#${v.map(function (c) {\n c = clamp(Math.round(c), 255);\n return (c < 16 ? '0' : '') + c.toString(16);\n }).join('')}`;\n}\n\nexport default Color;\n","import Node from './node';\n\nconst Paren = function(node) {\n this.value = node;\n};\n\nParen.prototype = Object.assign(new Node(), {\n type: 'Paren',\n\n genCSS(context, output) {\n output.add('(');\n this.value.genCSS(context, output);\n output.add(')');\n },\n\n eval(context) {\n return new Paren(this.value.eval(context));\n }\n});\n\nexport default Paren;\n","import Node from './node';\nconst _noSpaceCombinators = {\n '': true,\n ' ': true,\n '|': true\n};\n\nconst Combinator = function(value) {\n if (value === ' ') {\n this.value = ' ';\n this.emptyOrWhitespace = true;\n } else {\n this.value = value ? value.trim() : '';\n this.emptyOrWhitespace = this.value === '';\n }\n}\n\nCombinator.prototype = Object.assign(new Node(), {\n type: 'Combinator',\n\n genCSS(context, output) {\n const spaceOrEmpty = (context.compress || _noSpaceCombinators[this.value]) ? '' : ' ';\n output.add(spaceOrEmpty + this.value + spaceOrEmpty);\n }\n});\n\nexport default Combinator;\n","import Node from './node';\nimport Paren from './paren';\nimport Combinator from './combinator';\n\nconst Element = function(combinator, value, isVariable, index, currentFileInfo, visibilityInfo) {\n this.combinator = combinator instanceof Combinator ?\n combinator : new Combinator(combinator);\n\n if (typeof value === 'string') {\n this.value = value.trim();\n } else if (value) {\n this.value = value;\n } else {\n this.value = '';\n }\n this.isVariable = isVariable;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.copyVisibilityInfo(visibilityInfo);\n this.setParent(this.combinator, this);\n}\n\nElement.prototype = Object.assign(new Node(), {\n type: 'Element',\n\n accept(visitor) {\n const value = this.value;\n this.combinator = visitor.visit(this.combinator);\n if (typeof value === 'object') {\n this.value = visitor.visit(value);\n }\n },\n\n eval(context) {\n return new Element(this.combinator,\n this.value.eval ? this.value.eval(context) : this.value,\n this.isVariable,\n this.getIndex(),\n this.fileInfo(), this.visibilityInfo());\n },\n\n clone() {\n return new Element(this.combinator,\n this.value,\n this.isVariable,\n this.getIndex(),\n this.fileInfo(), this.visibilityInfo());\n },\n\n genCSS(context, output) {\n output.add(this.toCSS(context), this.fileInfo(), this.getIndex());\n },\n\n toCSS(context) {\n context = context || {};\n let value = this.value;\n const firstSelector = context.firstSelector;\n if (value instanceof Paren) {\n // selector in parens should not be affected by outer selector\n // flags (breaks only interpolated selectors - see #1973)\n context.firstSelector = true;\n }\n value = value.toCSS ? value.toCSS(context) : value;\n context.firstSelector = firstSelector;\n if (value === '' && this.combinator.value.charAt(0) === '&') {\n return '';\n } else {\n return this.combinator.toCSS(context) + value;\n }\n }\n});\n\nexport default Element;\n","\nexport const Math = {\n ALWAYS: 0,\n PARENS_DIVISION: 1,\n PARENS: 2\n // removed - STRICT_LEGACY: 3\n};\n\nexport const RewriteUrls = {\n OFF: 0,\n LOCAL: 1,\n ALL: 2\n};","/**\r\n * Returns the object type of the given payload\r\n *\r\n * @param {*} payload\r\n * @returns {string}\r\n */\r\nfunction getType(payload) {\r\n return Object.prototype.toString.call(payload).slice(8, -1);\r\n}\r\n/**\r\n * Returns whether the payload is undefined\r\n *\r\n * @param {*} payload\r\n * @returns {payload is undefined}\r\n */\r\nfunction isUndefined(payload) {\r\n return getType(payload) === 'Undefined';\r\n}\r\n/**\r\n * Returns whether the payload is null\r\n *\r\n * @param {*} payload\r\n * @returns {payload is null}\r\n */\r\nfunction isNull(payload) {\r\n return getType(payload) === 'Null';\r\n}\r\n/**\r\n * Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes)\r\n *\r\n * @param {*} payload\r\n * @returns {payload is Record}\r\n */\r\nfunction isPlainObject(payload) {\r\n if (getType(payload) !== 'Object')\r\n return false;\r\n return payload.constructor === Object && Object.getPrototypeOf(payload) === Object.prototype;\r\n}\r\n/**\r\n * Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes)\r\n *\r\n * @param {*} payload\r\n * @returns {payload is Record}\r\n */\r\nfunction isObject(payload) {\r\n return isPlainObject(payload);\r\n}\r\n/**\r\n * Returns whether the payload is a an empty object (excluding special classes or objects with other prototypes)\r\n *\r\n * @param {*} payload\r\n * @returns {payload is { [K in any]: never }}\r\n */\r\nfunction isEmptyObject(payload) {\r\n return isPlainObject(payload) && Object.keys(payload).length === 0;\r\n}\r\n/**\r\n * Returns whether the payload is an any kind of object (including special classes or objects with different prototypes)\r\n *\r\n * @param {*} payload\r\n * @returns {payload is Record}\r\n */\r\nfunction isAnyObject(payload) {\r\n return getType(payload) === 'Object';\r\n}\r\n/**\r\n * Returns whether the payload is an object like a type passed in < >\r\n *\r\n * Usage: isObjectLike<{id: any}>(payload) // will make sure it's an object and has an `id` prop.\r\n *\r\n * @template T this must be passed in < >\r\n * @param {*} payload\r\n * @returns {payload is T}\r\n */\r\nfunction isObjectLike(payload) {\r\n return isAnyObject(payload);\r\n}\r\n/**\r\n * Returns whether the payload is a function (regular or async)\r\n *\r\n * @param {*} payload\r\n * @returns {payload is AnyFunction}\r\n */\r\nfunction isFunction(payload) {\r\n return typeof payload === \"function\";\r\n}\r\n/**\r\n * Returns whether the payload is an array\r\n *\r\n * @param {any} payload\r\n * @returns {payload is any[]}\r\n */\r\nfunction isArray(payload) {\r\n return getType(payload) === 'Array';\r\n}\r\n/**\r\n * Returns whether the payload is a an array with at least 1 item\r\n *\r\n * @param {*} payload\r\n * @returns {payload is any[]}\r\n */\r\nfunction isFullArray(payload) {\r\n return isArray(payload) && payload.length > 0;\r\n}\r\n/**\r\n * Returns whether the payload is a an empty array\r\n *\r\n * @param {*} payload\r\n * @returns {payload is []}\r\n */\r\nfunction isEmptyArray(payload) {\r\n return isArray(payload) && payload.length === 0;\r\n}\r\n/**\r\n * Returns whether the payload is a string\r\n *\r\n * @param {*} payload\r\n * @returns {payload is string}\r\n */\r\nfunction isString(payload) {\r\n return getType(payload) === 'String';\r\n}\r\n/**\r\n * Returns whether the payload is a string, BUT returns false for ''\r\n *\r\n * @param {*} payload\r\n * @returns {payload is string}\r\n */\r\nfunction isFullString(payload) {\r\n return isString(payload) && payload !== '';\r\n}\r\n/**\r\n * Returns whether the payload is ''\r\n *\r\n * @param {*} payload\r\n * @returns {payload is string}\r\n */\r\nfunction isEmptyString(payload) {\r\n return payload === '';\r\n}\r\n/**\r\n * Returns whether the payload is a number (but not NaN)\r\n *\r\n * This will return `false` for `NaN`!!\r\n *\r\n * @param {*} payload\r\n * @returns {payload is number}\r\n */\r\nfunction isNumber(payload) {\r\n return getType(payload) === 'Number' && !isNaN(payload);\r\n}\r\n/**\r\n * Returns whether the payload is a boolean\r\n *\r\n * @param {*} payload\r\n * @returns {payload is boolean}\r\n */\r\nfunction isBoolean(payload) {\r\n return getType(payload) === 'Boolean';\r\n}\r\n/**\r\n * Returns whether the payload is a regular expression (RegExp)\r\n *\r\n * @param {*} payload\r\n * @returns {payload is RegExp}\r\n */\r\nfunction isRegExp(payload) {\r\n return getType(payload) === 'RegExp';\r\n}\r\n/**\r\n * Returns whether the payload is a Map\r\n *\r\n * @param {*} payload\r\n * @returns {payload is Map}\r\n */\r\nfunction isMap(payload) {\r\n return getType(payload) === 'Map';\r\n}\r\n/**\r\n * Returns whether the payload is a WeakMap\r\n *\r\n * @param {*} payload\r\n * @returns {payload is WeakMap}\r\n */\r\nfunction isWeakMap(payload) {\r\n return getType(payload) === 'WeakMap';\r\n}\r\n/**\r\n * Returns whether the payload is a Set\r\n *\r\n * @param {*} payload\r\n * @returns {payload is Set}\r\n */\r\nfunction isSet(payload) {\r\n return getType(payload) === 'Set';\r\n}\r\n/**\r\n * Returns whether the payload is a WeakSet\r\n *\r\n * @param {*} payload\r\n * @returns {payload is WeakSet}\r\n */\r\nfunction isWeakSet(payload) {\r\n return getType(payload) === 'WeakSet';\r\n}\r\n/**\r\n * Returns whether the payload is a Symbol\r\n *\r\n * @param {*} payload\r\n * @returns {payload is symbol}\r\n */\r\nfunction isSymbol(payload) {\r\n return getType(payload) === 'Symbol';\r\n}\r\n/**\r\n * Returns whether the payload is a Date, and that the date is valid\r\n *\r\n * @param {*} payload\r\n * @returns {payload is Date}\r\n */\r\nfunction isDate(payload) {\r\n return getType(payload) === 'Date' && !isNaN(payload);\r\n}\r\n/**\r\n * Returns whether the payload is a Blob\r\n *\r\n * @param {*} payload\r\n * @returns {payload is Blob}\r\n */\r\nfunction isBlob(payload) {\r\n return getType(payload) === 'Blob';\r\n}\r\n/**\r\n * Returns whether the payload is a File\r\n *\r\n * @param {*} payload\r\n * @returns {payload is File}\r\n */\r\nfunction isFile(payload) {\r\n return getType(payload) === 'File';\r\n}\r\n/**\r\n * Returns whether the payload is a Promise\r\n *\r\n * @param {*} payload\r\n * @returns {payload is Promise}\r\n */\r\nfunction isPromise(payload) {\r\n return getType(payload) === 'Promise';\r\n}\r\n/**\r\n * Returns whether the payload is an Error\r\n *\r\n * @param {*} payload\r\n * @returns {payload is Error}\r\n */\r\nfunction isError(payload) {\r\n return getType(payload) === 'Error';\r\n}\r\n/**\r\n * Returns whether the payload is literally the value `NaN` (it's `NaN` and also a `number`)\r\n *\r\n * @param {*} payload\r\n * @returns {payload is typeof NaN}\r\n */\r\nfunction isNaNValue(payload) {\r\n return getType(payload) === 'Number' && isNaN(payload);\r\n}\r\n/**\r\n * Returns whether the payload is a primitive type (eg. Boolean | Null | Undefined | Number | String | Symbol)\r\n *\r\n * @param {*} payload\r\n * @returns {(payload is boolean | null | undefined | number | string | symbol)}\r\n */\r\nfunction isPrimitive(payload) {\r\n return (isBoolean(payload) ||\r\n isNull(payload) ||\r\n isUndefined(payload) ||\r\n isNumber(payload) ||\r\n isString(payload) ||\r\n isSymbol(payload));\r\n}\r\n/**\r\n * Returns true whether the payload is null or undefined\r\n *\r\n * @param {*} payload\r\n * @returns {(payload is null | undefined)}\r\n */\r\nfunction isNullOrUndefined(payload) {\r\n return isNull(payload) || isUndefined(payload);\r\n}\r\n/**\r\n * Does a generic check to check that the given payload is of a given type.\r\n * In cases like Number, it will return true for NaN as NaN is a Number (thanks javascript!);\r\n * It will, however, differentiate between object and null\r\n *\r\n * @template T\r\n * @param {*} payload\r\n * @param {T} type\r\n * @throws {TypeError} Will throw type error if type is an invalid type\r\n * @returns {payload is T}\r\n */\r\nfunction isType(payload, type) {\r\n if (!(type instanceof Function)) {\r\n throw new TypeError('Type must be a function');\r\n }\r\n if (!Object.prototype.hasOwnProperty.call(type, 'prototype')) {\r\n throw new TypeError('Type is not a class');\r\n }\r\n // Classes usually have names (as functions usually have names)\r\n var name = type.name;\r\n return getType(payload) === name || Boolean(payload && payload.constructor === type);\r\n}\n\nexport { getType, isAnyObject, isArray, isBlob, isBoolean, isDate, isEmptyArray, isEmptyObject, isEmptyString, isError, isFile, isFullArray, isFullString, isFunction, isMap, isNaNValue, isNull, isNullOrUndefined, isNumber, isObject, isObjectLike, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isType, isUndefined, isWeakMap, isWeakSet };\n","import { isArray, isPlainObject } from 'is-what';\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n\r\nfunction __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\n\nfunction assignProp(carry, key, newVal, originalObject, includeNonenumerable) {\r\n var propType = {}.propertyIsEnumerable.call(originalObject, key)\r\n ? 'enumerable'\r\n : 'nonenumerable';\r\n if (propType === 'enumerable')\r\n carry[key] = newVal;\r\n if (includeNonenumerable && propType === 'nonenumerable') {\r\n Object.defineProperty(carry, key, {\r\n value: newVal,\r\n enumerable: false,\r\n writable: true,\r\n configurable: true,\r\n });\r\n }\r\n}\r\n/**\r\n * Copy (clone) an object and all its props recursively to get rid of any prop referenced of the original object. Arrays are also cloned, however objects inside arrays are still linked.\r\n *\r\n * @export\r\n * @template T\r\n * @param {T} target Target can be anything\r\n * @param {Options} [options={}] Options can be `props` or `nonenumerable`\r\n * @returns {T} the target with replaced values\r\n * @export\r\n */\r\nfunction copy(target, options) {\r\n if (options === void 0) { options = {}; }\r\n if (isArray(target))\r\n return target.map(function (i) { return copy(i, options); });\r\n if (!isPlainObject(target))\r\n return target;\r\n var props = Object.getOwnPropertyNames(target);\r\n var symbols = Object.getOwnPropertySymbols(target);\r\n return __spreadArrays(props, symbols).reduce(function (carry, key) {\r\n if (isArray(options.props) && !options.props.includes(key)) {\r\n return carry;\r\n }\r\n var val = target[key];\r\n var newVal = copy(val, options);\r\n assignProp(carry, key, newVal, target, options.nonenumerable);\r\n return carry;\r\n }, {});\r\n}\n\nexport { copy };\n","/* jshint proto: true */\nimport * as Constants from './constants';\nimport { copy } from 'copy-anything';\n\nexport function getLocation(index, inputStream) {\n let n = index + 1;\n let line = null;\n let column = -1;\n\n while (--n >= 0 && inputStream.charAt(n) !== '\\n') {\n column++;\n }\n\n if (typeof index === 'number') {\n line = (inputStream.slice(0, index).match(/\\n/g) || '').length;\n }\n\n return {\n line,\n column\n };\n}\n\nexport function copyArray(arr) {\n let i;\n const length = arr.length;\n const copy = new Array(length);\n\n for (i = 0; i < length; i++) {\n copy[i] = arr[i];\n }\n return copy;\n}\n\nexport function clone(obj) {\n const cloned = {};\n for (const prop in obj) {\n if (obj.hasOwnProperty(prop)) {\n cloned[prop] = obj[prop];\n }\n }\n return cloned;\n}\n\nexport function defaults(obj1, obj2) {\n let newObj = obj2 || {};\n if (!obj2._defaults) {\n newObj = {};\n const defaults = copy(obj1);\n newObj._defaults = defaults;\n const cloned = obj2 ? copy(obj2) : {};\n Object.assign(newObj, defaults, cloned);\n }\n return newObj;\n}\n\nexport function copyOptions(obj1, obj2) {\n if (obj2 && obj2._defaults) {\n return obj2;\n }\n const opts = defaults(obj1, obj2);\n if (opts.strictMath) {\n opts.math = Constants.Math.PARENS;\n }\n // Back compat with changed relativeUrls option\n if (opts.relativeUrls) {\n opts.rewriteUrls = Constants.RewriteUrls.ALL;\n }\n if (typeof opts.math === 'string') {\n switch (opts.math.toLowerCase()) {\n case 'always':\n opts.math = Constants.Math.ALWAYS;\n break;\n case 'parens-division':\n opts.math = Constants.Math.PARENS_DIVISION;\n break;\n case 'strict':\n case 'parens':\n opts.math = Constants.Math.PARENS;\n break;\n default:\n opts.math = Constants.Math.PARENS;\n }\n }\n if (typeof opts.rewriteUrls === 'string') {\n switch (opts.rewriteUrls.toLowerCase()) {\n case 'off':\n opts.rewriteUrls = Constants.RewriteUrls.OFF;\n break;\n case 'local':\n opts.rewriteUrls = Constants.RewriteUrls.LOCAL;\n break;\n case 'all':\n opts.rewriteUrls = Constants.RewriteUrls.ALL;\n break;\n }\n }\n return opts;\n}\n\nexport function merge(obj1, obj2) {\n for (const prop in obj2) {\n if (obj2.hasOwnProperty(prop)) {\n obj1[prop] = obj2[prop];\n }\n }\n return obj1;\n}\n\nexport function flattenArray(arr, result = []) {\n for (let i = 0, length = arr.length; i < length; i++) {\n const value = arr[i];\n if (Array.isArray(value)) {\n flattenArray(value, result);\n } else {\n if (value !== undefined) {\n result.push(value);\n }\n }\n }\n return result;\n}","import * as utils from './utils';\n\nconst anonymousFunc = /(|Function):(\\d+):(\\d+)/;\n\n/**\n * This is a centralized class of any error that could be thrown internally (mostly by the parser).\n * Besides standard .message it keeps some additional data like a path to the file where the error\n * occurred along with line and column numbers.\n *\n * @class\n * @extends Error\n * @type {module.LessError}\n *\n * @prop {string} type\n * @prop {string} filename\n * @prop {number} index\n * @prop {number} line\n * @prop {number} column\n * @prop {number} callLine\n * @prop {number} callExtract\n * @prop {string[]} extract\n *\n * @param {Object} e - An error object to wrap around or just a descriptive object\n * @param {Object} fileContentMap - An object with file contents in 'contents' property (like importManager) @todo - move to fileManager?\n * @param {string} [currentFilename]\n */\nconst LessError = function(e, fileContentMap, currentFilename) {\n Error.call(this);\n\n const filename = e.filename || currentFilename;\n\n this.message = e.message;\n this.stack = e.stack;\n\n if (fileContentMap && filename) {\n const input = fileContentMap.contents[filename];\n const loc = utils.getLocation(e.index, input);\n var line = loc.line;\n const col = loc.column;\n const callLine = e.call && utils.getLocation(e.call, input).line;\n const lines = input ? input.split('\\n') : '';\n\n this.type = e.type || 'Syntax';\n this.filename = filename;\n this.index = e.index;\n this.line = typeof line === 'number' ? line + 1 : null;\n this.column = col;\n\n if (!this.line && this.stack) {\n const found = this.stack.match(anonymousFunc);\n\n /**\n * We have to figure out how this environment stringifies anonymous functions\n * so we can correctly map plugin errors.\n * \n * Note, in Node 8, the output of anonymous funcs varied based on parameters\n * being present or not, so we inject dummy params.\n */\n const func = new Function('a', 'throw new Error()');\n let lineAdjust = 0;\n try {\n func();\n } catch (e) {\n const match = e.stack.match(anonymousFunc);\n var line = parseInt(match[2]);\n lineAdjust = 1 - line;\n }\n\n if (found) {\n if (found[2]) {\n this.line = parseInt(found[2]) + lineAdjust;\n }\n if (found[3]) {\n this.column = parseInt(found[3]);\n }\n }\n }\n\n this.callLine = callLine + 1;\n this.callExtract = lines[callLine];\n\n this.extract = [\n lines[this.line - 2],\n lines[this.line - 1],\n lines[this.line]\n ];\n }\n\n};\n\nif (typeof Object.create === 'undefined') {\n const F = function () {};\n F.prototype = Error.prototype;\n LessError.prototype = new F();\n} else {\n LessError.prototype = Object.create(Error.prototype);\n}\n\nLessError.prototype.constructor = LessError;\n\n/**\n * An overridden version of the default Object.prototype.toString\n * which uses additional information to create a helpful message.\n *\n * @param {Object} options\n * @returns {string}\n */\nLessError.prototype.toString = function(options) {\n options = options || {};\n\n let message = '';\n const extract = this.extract || [];\n let error = [];\n let stylize = function (str) { return str; };\n if (options.stylize) {\n const type = typeof options.stylize;\n if (type !== 'function') {\n throw Error(`options.stylize should be a function, got a ${type}!`);\n }\n stylize = options.stylize;\n }\n\n if (this.line !== null) {\n if (typeof extract[0] === 'string') {\n error.push(stylize(`${this.line - 1} ${extract[0]}`, 'grey'));\n }\n\n if (typeof extract[1] === 'string') {\n let errorTxt = `${this.line} `;\n if (extract[1]) {\n errorTxt += extract[1].slice(0, this.column) +\n stylize(stylize(stylize(extract[1].substr(this.column, 1), 'bold') +\n extract[1].slice(this.column + 1), 'red'), 'inverse');\n }\n error.push(errorTxt);\n }\n\n if (typeof extract[2] === 'string') {\n error.push(stylize(`${this.line + 1} ${extract[2]}`, 'grey'));\n }\n error = `${error.join('\\n') + stylize('', 'reset')}\\n`;\n }\n\n message += stylize(`${this.type}Error: ${this.message}`, 'red');\n if (this.filename) {\n message += stylize(' in ', 'red') + this.filename;\n }\n if (this.line) {\n message += stylize(` on line ${this.line}, column ${this.column + 1}:`, 'grey');\n }\n\n message += `\\n${error}`;\n\n if (this.callLine) {\n message += `${stylize('from ', 'red') + (this.filename || '')}/n`;\n message += `${stylize(this.callLine, 'grey')} ${this.callExtract}/n`;\n }\n\n return message;\n};\n\nexport default LessError;","import Node from './node';\nimport Element from './element';\nimport LessError from '../less-error';\n\nconst Selector = function(elements, extendList, condition, index, currentFileInfo, visibilityInfo) {\n this.extendList = extendList;\n this.condition = condition;\n this.evaldCondition = !condition;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.elements = this.getElements(elements);\n this.mixinElements_ = undefined;\n this.copyVisibilityInfo(visibilityInfo);\n this.setParent(this.elements, this);\n};\n\nSelector.prototype = Object.assign(new Node(), {\n type: 'Selector',\n\n accept(visitor) {\n if (this.elements) {\n this.elements = visitor.visitArray(this.elements);\n }\n if (this.extendList) {\n this.extendList = visitor.visitArray(this.extendList);\n }\n if (this.condition) {\n this.condition = visitor.visit(this.condition);\n }\n },\n\n createDerived(elements, extendList, evaldCondition) {\n elements = this.getElements(elements);\n const newSelector = new Selector(elements, extendList || this.extendList,\n null, this.getIndex(), this.fileInfo(), this.visibilityInfo());\n newSelector.evaldCondition = (evaldCondition != null) ? evaldCondition : this.evaldCondition;\n newSelector.mediaEmpty = this.mediaEmpty;\n return newSelector;\n },\n\n getElements(els) {\n if (!els) {\n return [new Element('', '&', false, this._index, this._fileInfo)];\n }\n if (typeof els === 'string') {\n this.parse.parseNode(\n els, \n ['selector'],\n this._index, \n this._fileInfo, \n function(err, result) {\n if (err) {\n throw new LessError({\n index: err.index,\n message: err.message\n }, this.parse.imports, this._fileInfo.filename);\n }\n els = result[0].elements;\n });\n }\n return els;\n },\n\n createEmptySelectors() {\n const el = new Element('', '&', false, this._index, this._fileInfo), sels = [new Selector([el], null, null, this._index, this._fileInfo)];\n sels[0].mediaEmpty = true;\n return sels;\n },\n\n match(other) {\n const elements = this.elements;\n const len = elements.length;\n let olen;\n let i;\n\n other = other.mixinElements();\n olen = other.length;\n if (olen === 0 || len < olen) {\n return 0;\n } else {\n for (i = 0; i < olen; i++) {\n if (elements[i].value !== other[i]) {\n return 0;\n }\n }\n }\n\n return olen; // return number of matched elements\n },\n\n mixinElements() {\n if (this.mixinElements_) {\n return this.mixinElements_;\n }\n\n let elements = this.elements.map( function(v) {\n return v.combinator.value + (v.value.value || v.value);\n }).join('').match(/[,&#\\*\\.\\w-]([\\w-]|(\\\\.))*/g);\n\n if (elements) {\n if (elements[0] === '&') {\n elements.shift();\n }\n } else {\n elements = [];\n }\n\n return (this.mixinElements_ = elements);\n },\n\n isJustParentSelector() {\n return !this.mediaEmpty &&\n this.elements.length === 1 &&\n this.elements[0].value === '&' &&\n (this.elements[0].combinator.value === ' ' || this.elements[0].combinator.value === '');\n },\n\n eval(context) {\n const evaldCondition = this.condition && this.condition.eval(context);\n let elements = this.elements;\n let extendList = this.extendList;\n\n elements = elements && elements.map(function (e) { return e.eval(context); });\n extendList = extendList && extendList.map(function(extend) { return extend.eval(context); });\n\n return this.createDerived(elements, extendList, evaldCondition);\n },\n\n genCSS(context, output) {\n let i, element;\n if ((!context || !context.firstSelector) && this.elements[0].combinator.value === '') {\n output.add(' ', this.fileInfo(), this.getIndex());\n }\n for (i = 0; i < this.elements.length; i++) {\n element = this.elements[i];\n element.genCSS(context, output);\n }\n },\n\n getIsOutput() {\n return this.evaldCondition;\n }\n});\n\nexport default Selector;\n","import Node from './node';\n\nconst Value = function(value) {\n if (!value) {\n throw new Error('Value requires an array argument');\n }\n if (!Array.isArray(value)) {\n this.value = [ value ];\n }\n else {\n this.value = value;\n }\n};\n\nValue.prototype = Object.assign(new Node(), {\n type: 'Value',\n\n accept(visitor) {\n if (this.value) {\n this.value = visitor.visitArray(this.value);\n }\n },\n\n eval(context) {\n if (this.value.length === 1) {\n return this.value[0].eval(context);\n } else {\n return new Value(this.value.map(function (v) {\n return v.eval(context);\n }));\n }\n },\n\n genCSS(context, output) {\n let i;\n for (i = 0; i < this.value.length; i++) {\n this.value[i].genCSS(context, output);\n if (i + 1 < this.value.length) {\n output.add((context && context.compress) ? ',' : ', ');\n }\n }\n }\n});\n\nexport default Value;\n","import Node from './node';\n\nconst Keyword = function(value) {\n this.value = value;\n};\n\nKeyword.prototype = Object.assign(new Node(), {\n type: 'Keyword',\n\n genCSS(context, output) {\n if (this.value === '%') { throw { type: 'Syntax', message: 'Invalid % without number' }; }\n output.add(this.value);\n }\n});\n\nKeyword.True = new Keyword('true');\nKeyword.False = new Keyword('false');\n\nexport default Keyword;\n","import Node from './node';\n\nconst Anonymous = function(value, index, currentFileInfo, mapLines, rulesetLike, visibilityInfo) {\n this.value = value;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.mapLines = mapLines;\n this.rulesetLike = (typeof rulesetLike === 'undefined') ? false : rulesetLike;\n this.allowRoot = true;\n this.copyVisibilityInfo(visibilityInfo);\n}\n\nAnonymous.prototype = Object.assign(new Node(), {\n type: 'Anonymous',\n eval() {\n return new Anonymous(this.value, this._index, this._fileInfo, this.mapLines, this.rulesetLike, this.visibilityInfo());\n },\n compare(other) {\n return other.toCSS && this.toCSS() === other.toCSS() ? 0 : undefined;\n },\n isRulesetLike() {\n return this.rulesetLike;\n },\n genCSS(context, output) {\n this.nodeVisible = Boolean(this.value);\n if (this.nodeVisible) {\n output.add(this.value, this._fileInfo, this._index, this.mapLines);\n }\n }\n})\n\nexport default Anonymous;\n","import Node from './node';\nimport Value from './value';\nimport Keyword from './keyword';\nimport Anonymous from './anonymous';\nimport * as Constants from '../constants';\nconst MATH = Constants.Math;\n\nfunction evalName(context, name) {\n let value = '';\n let i;\n const n = name.length;\n const output = {add: function (s) {value += s;}};\n for (i = 0; i < n; i++) {\n name[i].eval(context).genCSS(context, output);\n }\n return value;\n}\n\nconst Declaration = function(name, value, important, merge, index, currentFileInfo, inline, variable) {\n this.name = name;\n this.value = (value instanceof Node) ? value : new Value([value ? new Anonymous(value) : null]);\n this.important = important ? ` ${important.trim()}` : '';\n this.merge = merge;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.inline = inline || false;\n this.variable = (variable !== undefined) ? variable\n : (name.charAt && (name.charAt(0) === '@'));\n this.allowRoot = true;\n this.setParent(this.value, this);\n};\n\nDeclaration.prototype = Object.assign(new Node(), {\n type: 'Declaration',\n\n genCSS(context, output) {\n output.add(this.name + (context.compress ? ':' : ': '), this.fileInfo(), this.getIndex());\n try {\n this.value.genCSS(context, output);\n }\n catch (e) {\n e.index = this._index;\n e.filename = this._fileInfo.filename;\n throw e;\n }\n output.add(this.important + ((this.inline || (context.lastRule && context.compress)) ? '' : ';'), this._fileInfo, this._index);\n },\n\n eval(context) {\n let mathBypass = false, prevMath, name = this.name, evaldValue, variable = this.variable;\n if (typeof name !== 'string') {\n // expand 'primitive' name directly to get\n // things faster (~10% for benchmark.less):\n name = (name.length === 1) && (name[0] instanceof Keyword) ?\n name[0].value : evalName(context, name);\n variable = false; // never treat expanded interpolation as new variable name\n }\n\n // @todo remove when parens-division is default\n if (name === 'font' && context.math === MATH.ALWAYS) {\n mathBypass = true;\n prevMath = context.math;\n context.math = MATH.PARENS_DIVISION;\n }\n try {\n context.importantScope.push({});\n evaldValue = this.value.eval(context);\n\n if (!this.variable && evaldValue.type === 'DetachedRuleset') {\n throw { message: 'Rulesets cannot be evaluated on a property.',\n index: this.getIndex(), filename: this.fileInfo().filename };\n }\n let important = this.important;\n const importantResult = context.importantScope.pop();\n if (!important && importantResult.important) {\n important = importantResult.important;\n }\n\n return new Declaration(name,\n evaldValue,\n important,\n this.merge,\n this.getIndex(), this.fileInfo(), this.inline,\n variable);\n }\n catch (e) {\n if (typeof e.index !== 'number') {\n e.index = this.getIndex();\n e.filename = this.fileInfo().filename;\n }\n throw e;\n }\n finally {\n if (mathBypass) {\n context.math = prevMath;\n }\n }\n },\n\n makeImportant() {\n return new Declaration(this.name,\n this.value,\n '!important',\n this.merge,\n this.getIndex(), this.fileInfo(), this.inline);\n }\n});\n\nexport default Declaration;","class debugInfo {\n constructor(context, ctx, lineSeparator) {\n let result = '';\n if (context.dumpLineNumbers && !context.compress) {\n switch (context.dumpLineNumbers) {\n case 'comments':\n result = debugInfo.asComment(ctx);\n break;\n case 'mediaquery':\n result = debugInfo.asMediaQuery(ctx);\n break;\n case 'all':\n result = debugInfo.asComment(ctx) + (lineSeparator || '') + debugInfo.asMediaQuery(ctx);\n break;\n }\n }\n return result;\n }\n\n static asComment(ctx) {\n return `/* line ${ctx.debugInfo.lineNumber}, ${ctx.debugInfo.fileName} */\\n`;\n }\n\n static asMediaQuery(ctx) {\n let filenameWithProtocol = ctx.debugInfo.fileName;\n if (!/^[a-z]+:\\/\\//i.test(filenameWithProtocol)) {\n filenameWithProtocol = `file://${filenameWithProtocol}`;\n }\n return `@media -sass-debug-info{filename{font-family:${filenameWithProtocol.replace(/([.:\\/\\\\])/g, function (a) {\n if (a == '\\\\') {\n a = '\\/';\n }\n return `\\\\${a}`;\n })}}line{font-family:\\\\00003${ctx.debugInfo.lineNumber}}}\\n`;\n }\n}\n\nexport default debugInfo;\n","import Node from './node';\nimport getDebugInfo from './debug-info';\n\nconst Comment = function(value, isLineComment, index, currentFileInfo) {\n this.value = value;\n this.isLineComment = isLineComment;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.allowRoot = true;\n}\n\nComment.prototype = Object.assign(new Node(), {\n type: 'Comment',\n\n genCSS(context, output) {\n if (this.debugInfo) {\n output.add(getDebugInfo(context, this), this.fileInfo(), this.getIndex());\n }\n output.add(this.value);\n },\n\n isSilent(context) {\n const isCompressed = context.compress && this.value[2] !== '!';\n return this.isLineComment || isCompressed;\n }\n});\n\nexport default Comment;\n","const contexts = {};\nexport default contexts;\nimport * as Constants from './constants';\n\nconst copyFromOriginal = function copyFromOriginal(original, destination, propertiesToCopy) {\n if (!original) { return; }\n\n for (let i = 0; i < propertiesToCopy.length; i++) {\n if (original.hasOwnProperty(propertiesToCopy[i])) {\n destination[propertiesToCopy[i]] = original[propertiesToCopy[i]];\n }\n }\n};\n\n/*\n parse is used whilst parsing\n */\nconst parseCopyProperties = [\n // options\n 'paths', // option - unmodified - paths to search for imports on\n 'rewriteUrls', // option - whether to adjust URL's to be relative\n 'rootpath', // option - rootpath to append to URL's\n 'strictImports', // option -\n 'insecure', // option - whether to allow imports from insecure ssl hosts\n 'dumpLineNumbers', // option - whether to dump line numbers\n 'compress', // option - whether to compress\n 'syncImport', // option - whether to import synchronously\n 'chunkInput', // option - whether to chunk input. more performant but causes parse issues.\n 'mime', // browser only - mime type for sheet import\n 'useFileCache', // browser only - whether to use the per file session cache\n // context\n 'processImports', // option & context - whether to process imports. if false then imports will not be imported.\n // Used by the import manager to stop multiple import visitors being created.\n 'pluginManager' // Used as the plugin manager for the session\n];\n\ncontexts.Parse = function(options) {\n copyFromOriginal(options, this, parseCopyProperties);\n\n if (typeof this.paths === 'string') { this.paths = [this.paths]; }\n};\n\nconst evalCopyProperties = [\n 'paths', // additional include paths\n 'compress', // whether to compress\n 'math', // whether math has to be within parenthesis\n 'strictUnits', // whether units need to evaluate correctly\n 'sourceMap', // whether to output a source map\n 'importMultiple', // whether we are currently importing multiple copies\n 'urlArgs', // whether to add args into url tokens\n 'javascriptEnabled', // option - whether Inline JavaScript is enabled. if undefined, defaults to false\n 'pluginManager', // Used as the plugin manager for the session\n 'importantScope', // used to bubble up !important statements\n 'rewriteUrls' // option - whether to adjust URL's to be relative\n];\n\ncontexts.Eval = function(options, frames) {\n copyFromOriginal(options, this, evalCopyProperties);\n\n if (typeof this.paths === 'string') { this.paths = [this.paths]; }\n\n this.frames = frames || [];\n this.importantScope = this.importantScope || [];\n};\n\ncontexts.Eval.prototype.enterCalc = function () {\n if (!this.calcStack) {\n this.calcStack = [];\n }\n this.calcStack.push(true);\n this.inCalc = true;\n};\n\ncontexts.Eval.prototype.exitCalc = function () {\n this.calcStack.pop();\n if (!this.calcStack.length) {\n this.inCalc = false;\n }\n};\n\ncontexts.Eval.prototype.inParenthesis = function () {\n if (!this.parensStack) {\n this.parensStack = [];\n }\n this.parensStack.push(true);\n};\n\ncontexts.Eval.prototype.outOfParenthesis = function () {\n this.parensStack.pop();\n};\n\ncontexts.Eval.prototype.inCalc = false;\ncontexts.Eval.prototype.mathOn = true;\ncontexts.Eval.prototype.isMathOn = function (op) {\n if (!this.mathOn) {\n return false;\n }\n if (op === '/' && this.math !== Constants.Math.ALWAYS && (!this.parensStack || !this.parensStack.length)) {\n return false;\n }\n if (this.math > Constants.Math.PARENS_DIVISION) {\n return this.parensStack && this.parensStack.length;\n }\n return true;\n};\n\ncontexts.Eval.prototype.pathRequiresRewrite = function (path) {\n const isRelative = this.rewriteUrls === Constants.RewriteUrls.LOCAL ? isPathLocalRelative : isPathRelative;\n\n return isRelative(path);\n};\n\ncontexts.Eval.prototype.rewritePath = function (path, rootpath) {\n let newPath;\n\n rootpath = rootpath || '';\n newPath = this.normalizePath(rootpath + path);\n\n // If a path was explicit relative and the rootpath was not an absolute path\n // we must ensure that the new path is also explicit relative.\n if (isPathLocalRelative(path) &&\n isPathRelative(rootpath) &&\n isPathLocalRelative(newPath) === false) {\n newPath = `./${newPath}`;\n }\n\n return newPath;\n};\n\ncontexts.Eval.prototype.normalizePath = function (path) {\n const segments = path.split('/').reverse();\n let segment;\n\n path = [];\n while (segments.length !== 0) {\n segment = segments.pop();\n switch ( segment ) {\n case '.':\n break;\n case '..':\n if ((path.length === 0) || (path[path.length - 1] === '..')) {\n path.push( segment );\n } else {\n path.pop();\n }\n break;\n default:\n path.push(segment);\n break;\n }\n }\n\n return path.join('/');\n};\n\nfunction isPathRelative(path) {\n return !/^(?:[a-z-]+:|\\/|#)/i.test(path);\n}\n\nfunction isPathLocalRelative(path) {\n return path.charAt(0) === '.';\n}\n\n// todo - do the same for the toCSS ?\n","function makeRegistry( base ) {\n return {\n _data: {},\n add: function(name, func) {\n // precautionary case conversion, as later querying of\n // the registry by function-caller uses lower case as well.\n name = name.toLowerCase();\n\n if (this._data.hasOwnProperty(name)) {\n // TODO warn\n }\n this._data[name] = func;\n },\n addMultiple: function(functions) {\n Object.keys(functions).forEach(\n name => {\n this.add(name, functions[name]);\n });\n },\n get: function(name) {\n return this._data[name] || ( base && base.get( name ));\n },\n getLocalFunctions: function() {\n return this._data;\n },\n inherit: function() {\n return makeRegistry( this );\n },\n create: function(base) {\n return makeRegistry(base);\n }\n };\n}\n\nexport default makeRegistry( null );","import Keyword from '../tree/keyword';\n\nconst defaultFunc = {\n eval: function () {\n const v = this.value_;\n const e = this.error_;\n if (e) {\n throw e;\n }\n if (v != null) {\n return v ? Keyword.True : Keyword.False;\n }\n },\n value: function (v) {\n this.value_ = v;\n },\n error: function (e) {\n this.error_ = e;\n },\n reset: function () {\n this.value_ = this.error_ = null;\n }\n};\n\nexport default defaultFunc;\n","import Node from './node';\nimport Declaration from './declaration';\nimport Keyword from './keyword';\nimport Comment from './comment';\nimport Paren from './paren';\nimport Selector from './selector';\nimport Element from './element';\nimport Anonymous from './anonymous';\nimport contexts from '../contexts';\nimport globalFunctionRegistry from '../functions/function-registry';\nimport defaultFunc from '../functions/default';\nimport getDebugInfo from './debug-info';\nimport * as utils from '../utils';\n\nconst Ruleset = function(selectors, rules, strictImports, visibilityInfo) {\n this.selectors = selectors;\n this.rules = rules;\n this._lookups = {};\n this._variables = null;\n this._properties = null;\n this.strictImports = strictImports;\n this.copyVisibilityInfo(visibilityInfo);\n this.allowRoot = true;\n\n this.setParent(this.selectors, this);\n this.setParent(this.rules, this);\n}\n\nRuleset.prototype = Object.assign(new Node(), {\n type: 'Ruleset',\n isRuleset: true,\n\n isRulesetLike() { return true; },\n\n accept(visitor) {\n if (this.paths) {\n this.paths = visitor.visitArray(this.paths, true);\n } else if (this.selectors) {\n this.selectors = visitor.visitArray(this.selectors);\n }\n if (this.rules && this.rules.length) {\n this.rules = visitor.visitArray(this.rules);\n }\n },\n\n eval(context) {\n const that = this;\n let selectors;\n let selCnt;\n let selector;\n let i;\n let hasVariable;\n let hasOnePassingSelector = false;\n\n if (this.selectors && (selCnt = this.selectors.length)) {\n selectors = new Array(selCnt);\n defaultFunc.error({\n type: 'Syntax',\n message: 'it is currently only allowed in parametric mixin guards,'\n });\n\n for (i = 0; i < selCnt; i++) {\n selector = this.selectors[i].eval(context);\n for (var j = 0; j < selector.elements.length; j++) {\n if (selector.elements[j].isVariable) {\n hasVariable = true;\n break;\n }\n }\n selectors[i] = selector;\n if (selector.evaldCondition) {\n hasOnePassingSelector = true;\n }\n }\n\n if (hasVariable) {\n const toParseSelectors = new Array(selCnt);\n for (i = 0; i < selCnt; i++) {\n selector = selectors[i];\n toParseSelectors[i] = selector.toCSS(context);\n }\n this.parse.parseNode(\n toParseSelectors.join(','),\n [\"selectors\"], \n selectors[0].getIndex(), \n selectors[0].fileInfo(), \n function(err, result) {\n if (result) {\n selectors = utils.flattenArray(result);\n }\n });\n }\n\n defaultFunc.reset();\n } else {\n hasOnePassingSelector = true;\n }\n\n let rules = this.rules ? utils.copyArray(this.rules) : null;\n const ruleset = new Ruleset(selectors, rules, this.strictImports, this.visibilityInfo());\n let rule;\n let subRule;\n\n ruleset.originalRuleset = this;\n ruleset.root = this.root;\n ruleset.firstRoot = this.firstRoot;\n ruleset.allowImports = this.allowImports;\n\n if (this.debugInfo) {\n ruleset.debugInfo = this.debugInfo;\n }\n\n if (!hasOnePassingSelector) {\n rules.length = 0;\n }\n\n // inherit a function registry from the frames stack when possible;\n // otherwise from the global registry\n ruleset.functionRegistry = (function (frames) {\n let i = 0;\n const n = frames.length;\n let found;\n for ( ; i !== n ; ++i ) {\n found = frames[ i ].functionRegistry;\n if ( found ) { return found; }\n }\n return globalFunctionRegistry;\n }(context.frames)).inherit();\n\n // push the current ruleset to the frames stack\n const ctxFrames = context.frames;\n ctxFrames.unshift(ruleset);\n\n // currrent selectors\n let ctxSelectors = context.selectors;\n if (!ctxSelectors) {\n context.selectors = ctxSelectors = [];\n }\n ctxSelectors.unshift(this.selectors);\n\n // Evaluate imports\n if (ruleset.root || ruleset.allowImports || !ruleset.strictImports) {\n ruleset.evalImports(context);\n }\n\n // Store the frames around mixin definitions,\n // so they can be evaluated like closures when the time comes.\n const rsRules = ruleset.rules;\n for (i = 0; (rule = rsRules[i]); i++) {\n if (rule.evalFirst) {\n rsRules[i] = rule.eval(context);\n }\n }\n\n const mediaBlockCount = (context.mediaBlocks && context.mediaBlocks.length) || 0;\n\n // Evaluate mixin calls.\n for (i = 0; (rule = rsRules[i]); i++) {\n if (rule.type === 'MixinCall') {\n /* jshint loopfunc:true */\n rules = rule.eval(context).filter(function(r) {\n if ((r instanceof Declaration) && r.variable) {\n // do not pollute the scope if the variable is\n // already there. consider returning false here\n // but we need a way to \"return\" variable from mixins\n return !(ruleset.variable(r.name));\n }\n return true;\n });\n rsRules.splice.apply(rsRules, [i, 1].concat(rules));\n i += rules.length - 1;\n ruleset.resetCache();\n } else if (rule.type === 'VariableCall') {\n /* jshint loopfunc:true */\n rules = rule.eval(context).rules.filter(function(r) {\n if ((r instanceof Declaration) && r.variable) {\n // do not pollute the scope at all\n return false;\n }\n return true;\n });\n rsRules.splice.apply(rsRules, [i, 1].concat(rules));\n i += rules.length - 1;\n ruleset.resetCache();\n }\n }\n\n // Evaluate everything else\n for (i = 0; (rule = rsRules[i]); i++) {\n if (!rule.evalFirst) {\n rsRules[i] = rule = rule.eval ? rule.eval(context) : rule;\n }\n }\n\n // Evaluate everything else\n for (i = 0; (rule = rsRules[i]); i++) {\n // for rulesets, check if it is a css guard and can be removed\n if (rule instanceof Ruleset && rule.selectors && rule.selectors.length === 1) {\n // check if it can be folded in (e.g. & where)\n if (rule.selectors[0] && rule.selectors[0].isJustParentSelector()) {\n rsRules.splice(i--, 1);\n\n for (var j = 0; (subRule = rule.rules[j]); j++) {\n if (subRule instanceof Node) {\n subRule.copyVisibilityInfo(rule.visibilityInfo());\n if (!(subRule instanceof Declaration) || !subRule.variable) {\n rsRules.splice(++i, 0, subRule);\n }\n }\n }\n }\n }\n }\n\n // Pop the stack\n ctxFrames.shift();\n ctxSelectors.shift();\n\n if (context.mediaBlocks) {\n for (i = mediaBlockCount; i < context.mediaBlocks.length; i++) {\n context.mediaBlocks[i].bubbleSelectors(selectors);\n }\n }\n\n return ruleset;\n },\n\n evalImports(context) {\n const rules = this.rules;\n let i;\n let importRules;\n if (!rules) { return; }\n\n for (i = 0; i < rules.length; i++) {\n if (rules[i].type === 'Import') {\n importRules = rules[i].eval(context);\n if (importRules && (importRules.length || importRules.length === 0)) {\n rules.splice.apply(rules, [i, 1].concat(importRules));\n i += importRules.length - 1;\n } else {\n rules.splice(i, 1, importRules);\n }\n this.resetCache();\n }\n }\n },\n\n makeImportant() {\n const result = new Ruleset(this.selectors, this.rules.map(function (r) {\n if (r.makeImportant) {\n return r.makeImportant();\n } else {\n return r;\n }\n }), this.strictImports, this.visibilityInfo());\n\n return result;\n },\n\n matchArgs(args) {\n return !args || args.length === 0;\n },\n\n // lets you call a css selector with a guard\n matchCondition(args, context) {\n const lastSelector = this.selectors[this.selectors.length - 1];\n if (!lastSelector.evaldCondition) {\n return false;\n }\n if (lastSelector.condition &&\n !lastSelector.condition.eval(\n new contexts.Eval(context,\n context.frames))) {\n return false;\n }\n return true;\n },\n\n resetCache() {\n this._rulesets = null;\n this._variables = null;\n this._properties = null;\n this._lookups = {};\n },\n\n variables() {\n if (!this._variables) {\n this._variables = !this.rules ? {} : this.rules.reduce(function (hash, r) {\n if (r instanceof Declaration && r.variable === true) {\n hash[r.name] = r;\n }\n // when evaluating variables in an import statement, imports have not been eval'd\n // so we need to go inside import statements.\n // guard against root being a string (in the case of inlined less)\n if (r.type === 'Import' && r.root && r.root.variables) {\n const vars = r.root.variables();\n for (const name in vars) {\n if (vars.hasOwnProperty(name)) {\n hash[name] = r.root.variable(name);\n }\n }\n }\n return hash;\n }, {});\n }\n return this._variables;\n },\n\n properties() {\n if (!this._properties) {\n this._properties = !this.rules ? {} : this.rules.reduce(function (hash, r) {\n if (r instanceof Declaration && r.variable !== true) {\n const name = (r.name.length === 1) && (r.name[0] instanceof Keyword) ?\n r.name[0].value : r.name;\n // Properties don't overwrite as they can merge\n if (!hash[`$${name}`]) {\n hash[`$${name}`] = [ r ];\n }\n else {\n hash[`$${name}`].push(r);\n }\n }\n return hash;\n }, {});\n }\n return this._properties;\n },\n\n variable(name) {\n const decl = this.variables()[name];\n if (decl) {\n return this.parseValue(decl);\n }\n },\n\n property(name) {\n const decl = this.properties()[name];\n if (decl) {\n return this.parseValue(decl);\n }\n },\n\n lastDeclaration() {\n for (let i = this.rules.length; i > 0; i--) {\n const decl = this.rules[i - 1];\n if (decl instanceof Declaration) {\n return this.parseValue(decl);\n }\n }\n },\n\n parseValue(toParse) {\n const self = this;\n function transformDeclaration(decl) {\n if (decl.value instanceof Anonymous && !decl.parsed) {\n if (typeof decl.value.value === 'string') {\n this.parse.parseNode(\n decl.value.value,\n ['value', 'important'], \n decl.value.getIndex(), \n decl.fileInfo(), \n function(err, result) {\n if (err) {\n decl.parsed = true;\n }\n if (result) {\n decl.value = result[0];\n decl.important = result[1] || '';\n decl.parsed = true;\n }\n });\n } else {\n decl.parsed = true;\n }\n\n return decl;\n }\n else {\n return decl;\n }\n }\n if (!Array.isArray(toParse)) {\n return transformDeclaration.call(self, toParse);\n }\n else {\n const nodes = [];\n toParse.forEach(function(n) {\n nodes.push(transformDeclaration.call(self, n));\n });\n return nodes;\n }\n },\n\n rulesets() {\n if (!this.rules) { return []; }\n\n const filtRules = [];\n const rules = this.rules;\n let i;\n let rule;\n\n for (i = 0; (rule = rules[i]); i++) {\n if (rule.isRuleset) {\n filtRules.push(rule);\n }\n }\n\n return filtRules;\n },\n\n prependRule(rule) {\n const rules = this.rules;\n if (rules) {\n rules.unshift(rule);\n } else {\n this.rules = [ rule ];\n }\n this.setParent(rule, this);\n },\n\n find(selector, self, filter) {\n self = self || this;\n const rules = [];\n let match;\n let foundMixins;\n const key = selector.toCSS();\n\n if (key in this._lookups) { return this._lookups[key]; }\n\n this.rulesets().forEach(function (rule) {\n if (rule !== self) {\n for (let j = 0; j < rule.selectors.length; j++) {\n match = selector.match(rule.selectors[j]);\n if (match) {\n if (selector.elements.length > match) {\n if (!filter || filter(rule)) {\n foundMixins = rule.find(new Selector(selector.elements.slice(match)), self, filter);\n for (let i = 0; i < foundMixins.length; ++i) {\n foundMixins[i].path.push(rule);\n }\n Array.prototype.push.apply(rules, foundMixins);\n }\n } else {\n rules.push({ rule, path: []});\n }\n break;\n }\n }\n }\n });\n this._lookups[key] = rules;\n return rules;\n },\n\n genCSS(context, output) {\n let i;\n let j;\n const charsetRuleNodes = [];\n let ruleNodes = [];\n\n let // Line number debugging\n debugInfo;\n\n let rule;\n let path;\n\n context.tabLevel = (context.tabLevel || 0);\n\n if (!this.root) {\n context.tabLevel++;\n }\n\n const tabRuleStr = context.compress ? '' : Array(context.tabLevel + 1).join(' ');\n const tabSetStr = context.compress ? '' : Array(context.tabLevel).join(' ');\n let sep;\n\n let charsetNodeIndex = 0;\n let importNodeIndex = 0;\n for (i = 0; (rule = this.rules[i]); i++) {\n if (rule instanceof Comment) {\n if (importNodeIndex === i) {\n importNodeIndex++;\n }\n ruleNodes.push(rule);\n } else if (rule.isCharset && rule.isCharset()) {\n ruleNodes.splice(charsetNodeIndex, 0, rule);\n charsetNodeIndex++;\n importNodeIndex++;\n } else if (rule.type === 'Import') {\n ruleNodes.splice(importNodeIndex, 0, rule);\n importNodeIndex++;\n } else {\n ruleNodes.push(rule);\n }\n }\n ruleNodes = charsetRuleNodes.concat(ruleNodes);\n\n // If this is the root node, we don't render\n // a selector, or {}.\n if (!this.root) {\n debugInfo = getDebugInfo(context, this, tabSetStr);\n\n if (debugInfo) {\n output.add(debugInfo);\n output.add(tabSetStr);\n }\n\n const paths = this.paths;\n const pathCnt = paths.length;\n let pathSubCnt;\n\n sep = context.compress ? ',' : (`,\\n${tabSetStr}`);\n\n for (i = 0; i < pathCnt; i++) {\n path = paths[i];\n if (!(pathSubCnt = path.length)) { continue; }\n if (i > 0) { output.add(sep); }\n\n context.firstSelector = true;\n path[0].genCSS(context, output);\n\n context.firstSelector = false;\n for (j = 1; j < pathSubCnt; j++) {\n path[j].genCSS(context, output);\n }\n }\n\n output.add((context.compress ? '{' : ' {\\n') + tabRuleStr);\n }\n\n // Compile rules and rulesets\n for (i = 0; (rule = ruleNodes[i]); i++) {\n\n if (i + 1 === ruleNodes.length) {\n context.lastRule = true;\n }\n\n const currentLastRule = context.lastRule;\n if (rule.isRulesetLike(rule)) {\n context.lastRule = false;\n }\n\n if (rule.genCSS) {\n rule.genCSS(context, output);\n } else if (rule.value) {\n output.add(rule.value.toString());\n }\n\n context.lastRule = currentLastRule;\n\n if (!context.lastRule && rule.isVisible()) {\n output.add(context.compress ? '' : (`\\n${tabRuleStr}`));\n } else {\n context.lastRule = false;\n }\n }\n\n if (!this.root) {\n output.add((context.compress ? '}' : `\\n${tabSetStr}}`));\n context.tabLevel--;\n }\n\n if (!output.isEmpty() && !context.compress && this.firstRoot) {\n output.add('\\n');\n }\n },\n\n joinSelectors(paths, context, selectors) {\n for (let s = 0; s < selectors.length; s++) {\n this.joinSelector(paths, context, selectors[s]);\n }\n },\n\n joinSelector(paths, context, selector) {\n\n function createParenthesis(elementsToPak, originalElement) {\n let replacementParen, j;\n if (elementsToPak.length === 0) {\n replacementParen = new Paren(elementsToPak[0]);\n } else {\n const insideParent = new Array(elementsToPak.length);\n for (j = 0; j < elementsToPak.length; j++) {\n insideParent[j] = new Element(\n null,\n elementsToPak[j],\n originalElement.isVariable,\n originalElement._index,\n originalElement._fileInfo\n );\n }\n replacementParen = new Paren(new Selector(insideParent));\n }\n return replacementParen;\n }\n\n function createSelector(containedElement, originalElement) {\n let element, selector;\n element = new Element(null, containedElement, originalElement.isVariable, originalElement._index, originalElement._fileInfo);\n selector = new Selector([element]);\n return selector;\n }\n\n // joins selector path from `beginningPath` with selector path in `addPath`\n // `replacedElement` contains element that is being replaced by `addPath`\n // returns concatenated path\n function addReplacementIntoPath(beginningPath, addPath, replacedElement, originalSelector) {\n let newSelectorPath, lastSelector, newJoinedSelector;\n // our new selector path\n newSelectorPath = [];\n\n // construct the joined selector - if & is the first thing this will be empty,\n // if not newJoinedSelector will be the last set of elements in the selector\n if (beginningPath.length > 0) {\n newSelectorPath = utils.copyArray(beginningPath);\n lastSelector = newSelectorPath.pop();\n newJoinedSelector = originalSelector.createDerived(utils.copyArray(lastSelector.elements));\n }\n else {\n newJoinedSelector = originalSelector.createDerived([]);\n }\n\n if (addPath.length > 0) {\n // /deep/ is a CSS4 selector - (removed, so should deprecate)\n // that is valid without anything in front of it\n // so if the & does not have a combinator that is \"\" or \" \" then\n // and there is a combinator on the parent, then grab that.\n // this also allows + a { & .b { .a & { ... though not sure why you would want to do that\n let combinator = replacedElement.combinator;\n\n const parentEl = addPath[0].elements[0];\n if (combinator.emptyOrWhitespace && !parentEl.combinator.emptyOrWhitespace) {\n combinator = parentEl.combinator;\n }\n // join the elements so far with the first part of the parent\n newJoinedSelector.elements.push(new Element(\n combinator,\n parentEl.value,\n replacedElement.isVariable,\n replacedElement._index,\n replacedElement._fileInfo\n ));\n newJoinedSelector.elements = newJoinedSelector.elements.concat(addPath[0].elements.slice(1));\n }\n\n // now add the joined selector - but only if it is not empty\n if (newJoinedSelector.elements.length !== 0) {\n newSelectorPath.push(newJoinedSelector);\n }\n\n // put together the parent selectors after the join (e.g. the rest of the parent)\n if (addPath.length > 1) {\n let restOfPath = addPath.slice(1);\n restOfPath = restOfPath.map(function (selector) {\n return selector.createDerived(selector.elements, []);\n });\n newSelectorPath = newSelectorPath.concat(restOfPath);\n }\n return newSelectorPath;\n }\n\n // joins selector path from `beginningPath` with every selector path in `addPaths` array\n // `replacedElement` contains element that is being replaced by `addPath`\n // returns array with all concatenated paths\n function addAllReplacementsIntoPath( beginningPath, addPaths, replacedElement, originalSelector, result) {\n let j;\n for (j = 0; j < beginningPath.length; j++) {\n const newSelectorPath = addReplacementIntoPath(beginningPath[j], addPaths, replacedElement, originalSelector);\n result.push(newSelectorPath);\n }\n return result;\n }\n\n function mergeElementsOnToSelectors(elements, selectors) {\n let i, sel;\n\n if (elements.length === 0) {\n return ;\n }\n if (selectors.length === 0) {\n selectors.push([ new Selector(elements) ]);\n return;\n }\n\n for (i = 0; (sel = selectors[i]); i++) {\n // if the previous thing in sel is a parent this needs to join on to it\n if (sel.length > 0) {\n sel[sel.length - 1] = sel[sel.length - 1].createDerived(sel[sel.length - 1].elements.concat(elements));\n }\n else {\n sel.push(new Selector(elements));\n }\n }\n }\n\n // replace all parent selectors inside `inSelector` by content of `context` array\n // resulting selectors are returned inside `paths` array\n // returns true if `inSelector` contained at least one parent selector\n function replaceParentSelector(paths, context, inSelector) {\n // The paths are [[Selector]]\n // The first list is a list of comma separated selectors\n // The inner list is a list of inheritance separated selectors\n // e.g.\n // .a, .b {\n // .c {\n // }\n // }\n // == [[.a] [.c]] [[.b] [.c]]\n //\n let i, j, k, currentElements, newSelectors, selectorsMultiplied, sel, el, hadParentSelector = false, length, lastSelector;\n function findNestedSelector(element) {\n let maybeSelector;\n if (!(element.value instanceof Paren)) {\n return null;\n }\n\n maybeSelector = element.value.value;\n if (!(maybeSelector instanceof Selector)) {\n return null;\n }\n\n return maybeSelector;\n }\n\n // the elements from the current selector so far\n currentElements = [];\n // the current list of new selectors to add to the path.\n // We will build it up. We initiate it with one empty selector as we \"multiply\" the new selectors\n // by the parents\n newSelectors = [\n []\n ];\n\n for (i = 0; (el = inSelector.elements[i]); i++) {\n // non parent reference elements just get added\n if (el.value !== '&') {\n const nestedSelector = findNestedSelector(el);\n if (nestedSelector != null) {\n // merge the current list of non parent selector elements\n // on to the current list of selectors to add\n mergeElementsOnToSelectors(currentElements, newSelectors);\n\n const nestedPaths = [];\n let replaced;\n const replacedNewSelectors = [];\n replaced = replaceParentSelector(nestedPaths, context, nestedSelector);\n hadParentSelector = hadParentSelector || replaced;\n // the nestedPaths array should have only one member - replaceParentSelector does not multiply selectors\n for (k = 0; k < nestedPaths.length; k++) {\n const replacementSelector = createSelector(createParenthesis(nestedPaths[k], el), el);\n addAllReplacementsIntoPath(newSelectors, [replacementSelector], el, inSelector, replacedNewSelectors);\n }\n newSelectors = replacedNewSelectors;\n currentElements = [];\n } else {\n currentElements.push(el);\n }\n\n } else {\n hadParentSelector = true;\n // the new list of selectors to add\n selectorsMultiplied = [];\n\n // merge the current list of non parent selector elements\n // on to the current list of selectors to add\n mergeElementsOnToSelectors(currentElements, newSelectors);\n\n // loop through our current selectors\n for (j = 0; j < newSelectors.length; j++) {\n sel = newSelectors[j];\n // if we don't have any parent paths, the & might be in a mixin so that it can be used\n // whether there are parents or not\n if (context.length === 0) {\n // the combinator used on el should now be applied to the next element instead so that\n // it is not lost\n if (sel.length > 0) {\n sel[0].elements.push(new Element(el.combinator, '', el.isVariable, el._index, el._fileInfo));\n }\n selectorsMultiplied.push(sel);\n }\n else {\n // and the parent selectors\n for (k = 0; k < context.length; k++) {\n // We need to put the current selectors\n // then join the last selector's elements on to the parents selectors\n const newSelectorPath = addReplacementIntoPath(sel, context[k], el, inSelector);\n // add that to our new set of selectors\n selectorsMultiplied.push(newSelectorPath);\n }\n }\n }\n\n // our new selectors has been multiplied, so reset the state\n newSelectors = selectorsMultiplied;\n currentElements = [];\n }\n }\n\n // if we have any elements left over (e.g. .a& .b == .b)\n // add them on to all the current selectors\n mergeElementsOnToSelectors(currentElements, newSelectors);\n\n for (i = 0; i < newSelectors.length; i++) {\n length = newSelectors[i].length;\n if (length > 0) {\n paths.push(newSelectors[i]);\n lastSelector = newSelectors[i][length - 1];\n newSelectors[i][length - 1] = lastSelector.createDerived(lastSelector.elements, inSelector.extendList);\n }\n }\n\n return hadParentSelector;\n }\n\n function deriveSelector(visibilityInfo, deriveFrom) {\n const newSelector = deriveFrom.createDerived(deriveFrom.elements, deriveFrom.extendList, deriveFrom.evaldCondition);\n newSelector.copyVisibilityInfo(visibilityInfo);\n return newSelector;\n }\n\n // joinSelector code follows\n let i, newPaths, hadParentSelector;\n\n newPaths = [];\n hadParentSelector = replaceParentSelector(newPaths, context, selector);\n\n if (!hadParentSelector) {\n if (context.length > 0) {\n newPaths = [];\n for (i = 0; i < context.length; i++) {\n\n const concatenated = context[i].map(deriveSelector.bind(this, selector.visibilityInfo()));\n\n concatenated.push(selector);\n newPaths.push(concatenated);\n }\n }\n else {\n newPaths = [[selector]];\n }\n }\n\n for (i = 0; i < newPaths.length; i++) {\n paths.push(newPaths[i]);\n }\n\n }\n});\n\nexport default Ruleset;\n","import Node from './node';\nimport Selector from './selector';\nimport Ruleset from './ruleset';\nimport Anonymous from './anonymous';\n\nconst AtRule = function(\n name,\n value,\n rules,\n index,\n currentFileInfo,\n debugInfo,\n isRooted,\n visibilityInfo\n) {\n let i;\n\n this.name = name;\n this.value = (value instanceof Node) ? value : (value ? new Anonymous(value) : value);\n if (rules) {\n if (Array.isArray(rules)) {\n this.rules = rules;\n } else {\n this.rules = [rules];\n this.rules[0].selectors = (new Selector([], null, null, index, currentFileInfo)).createEmptySelectors();\n }\n for (i = 0; i < this.rules.length; i++) {\n this.rules[i].allowImports = true;\n }\n this.setParent(this.rules, this);\n }\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.debugInfo = debugInfo;\n this.isRooted = isRooted || false;\n this.copyVisibilityInfo(visibilityInfo);\n this.allowRoot = true;\n}\n\nAtRule.prototype = Object.assign(new Node(), {\n type: 'AtRule',\n accept(visitor) {\n const value = this.value, rules = this.rules;\n if (rules) {\n this.rules = visitor.visitArray(rules);\n }\n if (value) {\n this.value = visitor.visit(value);\n }\n },\n\n isRulesetLike() {\n return this.rules || !this.isCharset();\n },\n\n isCharset() {\n return '@charset' === this.name;\n },\n\n genCSS(context, output) {\n const value = this.value, rules = this.rules;\n output.add(this.name, this.fileInfo(), this.getIndex());\n if (value) {\n output.add(' ');\n value.genCSS(context, output);\n }\n if (rules) {\n this.outputRuleset(context, output, rules);\n } else {\n output.add(';');\n }\n },\n\n eval(context) {\n let mediaPathBackup, mediaBlocksBackup, value = this.value, rules = this.rules;\n\n // media stored inside other atrule should not bubble over it\n // backpup media bubbling information\n mediaPathBackup = context.mediaPath;\n mediaBlocksBackup = context.mediaBlocks;\n // deleted media bubbling information\n context.mediaPath = [];\n context.mediaBlocks = [];\n\n if (value) {\n value = value.eval(context);\n }\n if (rules) {\n // assuming that there is only one rule at this point - that is how parser constructs the rule\n rules = [rules[0].eval(context)];\n rules[0].root = true;\n }\n // restore media bubbling information\n context.mediaPath = mediaPathBackup;\n context.mediaBlocks = mediaBlocksBackup;\n\n return new AtRule(this.name, value, rules,\n this.getIndex(), this.fileInfo(), this.debugInfo, this.isRooted, this.visibilityInfo());\n },\n\n variable(name) {\n if (this.rules) {\n // assuming that there is only one rule at this point - that is how parser constructs the rule\n return Ruleset.prototype.variable.call(this.rules[0], name);\n }\n },\n\n find() {\n if (this.rules) {\n // assuming that there is only one rule at this point - that is how parser constructs the rule\n return Ruleset.prototype.find.apply(this.rules[0], arguments);\n }\n },\n\n rulesets() {\n if (this.rules) {\n // assuming that there is only one rule at this point - that is how parser constructs the rule\n return Ruleset.prototype.rulesets.apply(this.rules[0]);\n }\n },\n\n outputRuleset(context, output, rules) {\n const ruleCnt = rules.length;\n let i;\n context.tabLevel = (context.tabLevel | 0) + 1;\n\n // Compressed\n if (context.compress) {\n output.add('{');\n for (i = 0; i < ruleCnt; i++) {\n rules[i].genCSS(context, output);\n }\n output.add('}');\n context.tabLevel--;\n return;\n }\n\n // Non-compressed\n const tabSetStr = `\\n${Array(context.tabLevel).join(' ')}`, tabRuleStr = `${tabSetStr} `;\n if (!ruleCnt) {\n output.add(` {${tabSetStr}}`);\n } else {\n output.add(` {${tabRuleStr}`);\n rules[0].genCSS(context, output);\n for (i = 1; i < ruleCnt; i++) {\n output.add(tabRuleStr);\n rules[i].genCSS(context, output);\n }\n output.add(`${tabSetStr}}`);\n }\n\n context.tabLevel--;\n }\n});\n\nexport default AtRule;\n","import Node from './node';\nimport contexts from '../contexts';\nimport * as utils from '../utils';\n\nconst DetachedRuleset = function(ruleset, frames) {\n this.ruleset = ruleset;\n this.frames = frames;\n this.setParent(this.ruleset, this);\n};\n\nDetachedRuleset.prototype = Object.assign(new Node(), {\n type: 'DetachedRuleset',\n evalFirst: true,\n\n accept(visitor) {\n this.ruleset = visitor.visit(this.ruleset);\n },\n\n eval(context) {\n const frames = this.frames || utils.copyArray(context.frames);\n return new DetachedRuleset(this.ruleset, frames);\n },\n\n callEval(context) {\n return this.ruleset.eval(this.frames ? new contexts.Eval(context, this.frames.concat(context.frames)) : context);\n }\n});\n\nexport default DetachedRuleset;\n","import Node from './node';\nimport unitConversions from '../data/unit-conversions';\nimport * as utils from '../utils';\n\nconst Unit = function(numerator, denominator, backupUnit) {\n this.numerator = numerator ? utils.copyArray(numerator).sort() : [];\n this.denominator = denominator ? utils.copyArray(denominator).sort() : [];\n if (backupUnit) {\n this.backupUnit = backupUnit;\n } else if (numerator && numerator.length) {\n this.backupUnit = numerator[0];\n }\n};\n\nUnit.prototype = Object.assign(new Node(), {\n type: 'Unit',\n\n clone() {\n return new Unit(utils.copyArray(this.numerator), utils.copyArray(this.denominator), this.backupUnit);\n },\n\n genCSS(context, output) {\n // Dimension checks the unit is singular and throws an error if in strict math mode.\n const strictUnits = context && context.strictUnits;\n if (this.numerator.length === 1) {\n output.add(this.numerator[0]); // the ideal situation\n } else if (!strictUnits && this.backupUnit) {\n output.add(this.backupUnit);\n } else if (!strictUnits && this.denominator.length) {\n output.add(this.denominator[0]);\n }\n },\n\n toString() {\n let i, returnStr = this.numerator.join('*');\n for (i = 0; i < this.denominator.length; i++) {\n returnStr += `/${this.denominator[i]}`;\n }\n return returnStr;\n },\n\n compare(other) {\n return this.is(other.toString()) ? 0 : undefined;\n },\n\n is(unitString) {\n return this.toString().toUpperCase() === unitString.toUpperCase();\n },\n\n isLength() {\n return RegExp('^(px|em|ex|ch|rem|in|cm|mm|pc|pt|ex|vw|vh|vmin|vmax)$', 'gi').test(this.toCSS());\n },\n\n isEmpty() {\n return this.numerator.length === 0 && this.denominator.length === 0;\n },\n\n isSingular() {\n return this.numerator.length <= 1 && this.denominator.length === 0;\n },\n\n map(callback) {\n let i;\n\n for (i = 0; i < this.numerator.length; i++) {\n this.numerator[i] = callback(this.numerator[i], false);\n }\n\n for (i = 0; i < this.denominator.length; i++) {\n this.denominator[i] = callback(this.denominator[i], true);\n }\n },\n\n usedUnits() {\n let group;\n const result = {};\n let mapUnit;\n let groupName;\n\n mapUnit = function (atomicUnit) {\n /* jshint loopfunc:true */\n if (group.hasOwnProperty(atomicUnit) && !result[groupName]) {\n result[groupName] = atomicUnit;\n }\n\n return atomicUnit;\n };\n\n for (groupName in unitConversions) {\n if (unitConversions.hasOwnProperty(groupName)) {\n group = unitConversions[groupName];\n\n this.map(mapUnit);\n }\n }\n\n return result;\n },\n\n cancel() {\n const counter = {};\n let atomicUnit;\n let i;\n\n for (i = 0; i < this.numerator.length; i++) {\n atomicUnit = this.numerator[i];\n counter[atomicUnit] = (counter[atomicUnit] || 0) + 1;\n }\n\n for (i = 0; i < this.denominator.length; i++) {\n atomicUnit = this.denominator[i];\n counter[atomicUnit] = (counter[atomicUnit] || 0) - 1;\n }\n\n this.numerator = [];\n this.denominator = [];\n\n for (atomicUnit in counter) {\n if (counter.hasOwnProperty(atomicUnit)) {\n const count = counter[atomicUnit];\n\n if (count > 0) {\n for (i = 0; i < count; i++) {\n this.numerator.push(atomicUnit);\n }\n } else if (count < 0) {\n for (i = 0; i < -count; i++) {\n this.denominator.push(atomicUnit);\n }\n }\n }\n }\n\n this.numerator.sort();\n this.denominator.sort();\n }\n});\n\nexport default Unit;\n","import Node from './node';\nimport unitConversions from '../data/unit-conversions';\nimport Unit from './unit';\nimport Color from './color';\n\n//\n// A number with a unit\n//\nconst Dimension = function(value, unit) {\n this.value = parseFloat(value);\n if (isNaN(this.value)) {\n throw new Error('Dimension is not a number.');\n }\n this.unit = (unit && unit instanceof Unit) ? unit :\n new Unit(unit ? [unit] : undefined);\n this.setParent(this.unit, this);\n};\n\nDimension.prototype = Object.assign(new Node(), {\n type: 'Dimension',\n\n accept(visitor) {\n this.unit = visitor.visit(this.unit);\n },\n\n eval(context) {\n return this;\n },\n\n toColor() {\n return new Color([this.value, this.value, this.value]);\n },\n\n genCSS(context, output) {\n if ((context && context.strictUnits) && !this.unit.isSingular()) {\n throw new Error(`Multiple units in dimension. Correct the units or use the unit function. Bad unit: ${this.unit.toString()}`);\n }\n\n const value = this.fround(context, this.value);\n let strValue = String(value);\n\n if (value !== 0 && value < 0.000001 && value > -0.000001) {\n // would be output 1e-6 etc.\n strValue = value.toFixed(20).replace(/0+$/, '');\n }\n\n if (context && context.compress) {\n // Zero values doesn't need a unit\n if (value === 0 && this.unit.isLength()) {\n output.add(strValue);\n return;\n }\n\n // Float values doesn't need a leading zero\n if (value > 0 && value < 1) {\n strValue = (strValue).substr(1);\n }\n }\n\n output.add(strValue);\n this.unit.genCSS(context, output);\n },\n\n // In an operation between two Dimensions,\n // we default to the first Dimension's unit,\n // so `1px + 2` will yield `3px`.\n operate(context, op, other) {\n /* jshint noempty:false */\n let value = this._operate(context, op, this.value, other.value);\n let unit = this.unit.clone();\n\n if (op === '+' || op === '-') {\n if (unit.numerator.length === 0 && unit.denominator.length === 0) {\n unit = other.unit.clone();\n if (this.unit.backupUnit) {\n unit.backupUnit = this.unit.backupUnit;\n }\n } else if (other.unit.numerator.length === 0 && unit.denominator.length === 0) {\n // do nothing\n } else {\n other = other.convertTo(this.unit.usedUnits());\n\n if (context.strictUnits && other.unit.toString() !== unit.toString()) {\n throw new Error(`Incompatible units. Change the units or use the unit function. `\n + `Bad units: '${unit.toString()}' and '${other.unit.toString()}'.`);\n }\n\n value = this._operate(context, op, this.value, other.value);\n }\n } else if (op === '*') {\n unit.numerator = unit.numerator.concat(other.unit.numerator).sort();\n unit.denominator = unit.denominator.concat(other.unit.denominator).sort();\n unit.cancel();\n } else if (op === '/') {\n unit.numerator = unit.numerator.concat(other.unit.denominator).sort();\n unit.denominator = unit.denominator.concat(other.unit.numerator).sort();\n unit.cancel();\n }\n return new Dimension(value, unit);\n },\n\n compare(other) {\n let a, b;\n\n if (!(other instanceof Dimension)) {\n return undefined;\n }\n\n if (this.unit.isEmpty() || other.unit.isEmpty()) {\n a = this;\n b = other;\n } else {\n a = this.unify();\n b = other.unify();\n if (a.unit.compare(b.unit) !== 0) {\n return undefined;\n }\n }\n\n return Node.numericCompare(a.value, b.value);\n },\n\n unify() {\n return this.convertTo({ length: 'px', duration: 's', angle: 'rad' });\n },\n\n convertTo(conversions) {\n let value = this.value;\n const unit = this.unit.clone();\n let i;\n let groupName;\n let group;\n let targetUnit;\n let derivedConversions = {};\n let applyUnit;\n\n if (typeof conversions === 'string') {\n for (i in unitConversions) {\n if (unitConversions[i].hasOwnProperty(conversions)) {\n derivedConversions = {};\n derivedConversions[i] = conversions;\n }\n }\n conversions = derivedConversions;\n }\n applyUnit = function (atomicUnit, denominator) {\n /* jshint loopfunc:true */\n if (group.hasOwnProperty(atomicUnit)) {\n if (denominator) {\n value = value / (group[atomicUnit] / group[targetUnit]);\n } else {\n value = value * (group[atomicUnit] / group[targetUnit]);\n }\n\n return targetUnit;\n }\n\n return atomicUnit;\n };\n\n for (groupName in conversions) {\n if (conversions.hasOwnProperty(groupName)) {\n targetUnit = conversions[groupName];\n group = unitConversions[groupName];\n\n unit.map(applyUnit);\n }\n }\n\n unit.cancel();\n\n return new Dimension(value, unit);\n }\n});\n\nexport default Dimension;\n","import Node from './node';\nimport Color from './color';\nimport Dimension from './dimension';\nimport * as Constants from '../constants';\nconst MATH = Constants.Math;\n\n\nconst Operation = function(op, operands, isSpaced) {\n this.op = op.trim();\n this.operands = operands;\n this.isSpaced = isSpaced;\n};\n\nOperation.prototype = Object.assign(new Node(), {\n type: 'Operation',\n\n accept(visitor) {\n this.operands = visitor.visitArray(this.operands);\n },\n\n eval(context) {\n let a = this.operands[0].eval(context), b = this.operands[1].eval(context), op;\n\n if (context.isMathOn(this.op)) {\n op = this.op === './' ? '/' : this.op;\n if (a instanceof Dimension && b instanceof Color) {\n a = a.toColor();\n }\n if (b instanceof Dimension && a instanceof Color) {\n b = b.toColor();\n }\n if (!a.operate || !b.operate) {\n if (\n (a instanceof Operation || b instanceof Operation)\n && a.op === '/' && context.math === MATH.PARENS_DIVISION\n ) {\n return new Operation(this.op, [a, b], this.isSpaced);\n }\n throw { type: 'Operation',\n message: 'Operation on an invalid type' };\n }\n\n return a.operate(context, op, b);\n } else {\n return new Operation(this.op, [a, b], this.isSpaced);\n }\n },\n\n genCSS(context, output) {\n this.operands[0].genCSS(context, output);\n if (this.isSpaced) {\n output.add(' ');\n }\n output.add(this.op);\n if (this.isSpaced) {\n output.add(' ');\n }\n this.operands[1].genCSS(context, output);\n }\n});\n\nexport default Operation;\n","import Node from './node';\nimport Paren from './paren';\nimport Comment from './comment';\nimport Dimension from './dimension';\nimport * as Constants from '../constants';\nconst MATH = Constants.Math;\n\nconst Expression = function(value, noSpacing) {\n this.value = value;\n this.noSpacing = noSpacing;\n if (!value) {\n throw new Error('Expression requires an array parameter');\n }\n};\n\nExpression.prototype = Object.assign(new Node(), {\n type: 'Expression',\n\n accept(visitor) {\n this.value = visitor.visitArray(this.value);\n },\n\n eval(context) {\n let returnValue;\n const mathOn = context.isMathOn();\n const inParenthesis = this.parens;\n\n let doubleParen = false;\n if (inParenthesis) {\n context.inParenthesis();\n }\n if (this.value.length > 1) {\n returnValue = new Expression(this.value.map(function (e) {\n if (!e.eval) {\n return e;\n }\n return e.eval(context);\n }), this.noSpacing);\n } else if (this.value.length === 1) {\n if (this.value[0].parens && !this.value[0].parensInOp && !context.inCalc) {\n doubleParen = true;\n }\n returnValue = this.value[0].eval(context);\n } else {\n returnValue = this;\n }\n if (inParenthesis) {\n context.outOfParenthesis();\n }\n if (this.parens && this.parensInOp && !mathOn && !doubleParen \n && (!(returnValue instanceof Dimension))) {\n returnValue = new Paren(returnValue);\n }\n return returnValue;\n },\n\n genCSS(context, output) {\n for (let i = 0; i < this.value.length; i++) {\n this.value[i].genCSS(context, output);\n if (!this.noSpacing && i + 1 < this.value.length) {\n output.add(' ');\n }\n }\n },\n\n throwAwayComments() {\n this.value = this.value.filter(function(v) {\n return !(v instanceof Comment);\n });\n }\n});\n\nexport default Expression;\n","import Expression from '../tree/expression';\n\nclass functionCaller {\n constructor(name, context, index, currentFileInfo) {\n this.name = name.toLowerCase();\n this.index = index;\n this.context = context;\n this.currentFileInfo = currentFileInfo;\n\n this.func = context.frames[0].functionRegistry.get(this.name);\n }\n\n isValid() {\n return Boolean(this.func);\n }\n\n call(args) {\n if (!(Array.isArray(args))) {\n args = [args];\n }\n const evalArgs = this.func.evalArgs;\n if (evalArgs !== false) {\n args = args.map(a => a.eval(this.context));\n }\n const commentFilter = item => !(item.type === 'Comment');\n\n // This code is terrible and should be replaced as per this issue...\n // https://github.com/less/less.js/issues/2477\n args = args\n .filter(commentFilter)\n .map(item => {\n if (item.type === 'Expression') {\n const subNodes = item.value.filter(commentFilter);\n if (subNodes.length === 1) {\n // https://github.com/less/less.js/issues/3616\n if (item.parens && subNodes[0].op === '/') {\n return item;\n }\n return subNodes[0];\n } else {\n return new Expression(subNodes);\n }\n }\n return item;\n });\n\n if (evalArgs === false) {\n return this.func(this.context, ...args);\n }\n\n return this.func(...args);\n }\n}\n\nexport default functionCaller;\n","/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || from);\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","import Node from './node';\nimport Anonymous from './anonymous';\nimport FunctionCaller from '../functions/function-caller';\n\n//\n// A function call node.\n//\nconst Call = function(name, args, index, currentFileInfo) {\n this.name = name;\n this.args = args;\n this.calc = name === 'calc';\n this._index = index;\n this._fileInfo = currentFileInfo;\n}\n\nCall.prototype = Object.assign(new Node(), {\n type: 'Call',\n\n accept(visitor) {\n if (this.args) {\n this.args = visitor.visitArray(this.args);\n }\n },\n\n //\n // When evaluating a function call,\n // we either find the function in the functionRegistry,\n // in which case we call it, passing the evaluated arguments,\n // if this returns null or we cannot find the function, we\n // simply print it out as it appeared originally [2].\n //\n // The reason why we evaluate the arguments, is in the case where\n // we try to pass a variable to a function, like: `saturate(@color)`.\n // The function should receive the value, not the variable.\n //\n eval(context) {\n /**\n * Turn off math for calc(), and switch back on for evaluating nested functions\n */\n const currentMathContext = context.mathOn;\n context.mathOn = !this.calc;\n if (this.calc || context.inCalc) {\n context.enterCalc();\n }\n\n const exitCalc = () => {\n if (this.calc || context.inCalc) {\n context.exitCalc();\n }\n context.mathOn = currentMathContext;\n };\n\n let result;\n const funcCaller = new FunctionCaller(this.name, context, this.getIndex(), this.fileInfo());\n\n if (funcCaller.isValid()) {\n try {\n result = funcCaller.call(this.args);\n exitCalc();\n } catch (e) {\n if (e.hasOwnProperty('line') && e.hasOwnProperty('column')) {\n throw e;\n }\n throw { \n type: e.type || 'Runtime',\n message: `Error evaluating function \\`${this.name}\\`${e.message ? `: ${e.message}` : ''}`,\n index: this.getIndex(), \n filename: this.fileInfo().filename,\n line: e.lineNumber,\n column: e.columnNumber\n };\n }\n }\n\n if (result !== null && result !== undefined) {\n // Results that that are not nodes are cast as Anonymous nodes\n // Falsy values or booleans are returned as empty nodes\n if (!(result instanceof Node)) {\n if (!result || result === true) {\n result = new Anonymous(null); \n }\n else {\n result = new Anonymous(result.toString()); \n }\n \n }\n result._index = this._index;\n result._fileInfo = this._fileInfo;\n return result;\n }\n\n const args = this.args.map(a => a.eval(context));\n exitCalc();\n\n return new Call(this.name, args, this.getIndex(), this.fileInfo());\n },\n\n genCSS(context, output) {\n output.add(`${this.name}(`, this.fileInfo(), this.getIndex());\n\n for (let i = 0; i < this.args.length; i++) {\n this.args[i].genCSS(context, output);\n if (i + 1 < this.args.length) {\n output.add(', ');\n }\n }\n\n output.add(')');\n }\n});\n\nexport default Call;\n","import Node from './node';\nimport Call from './call';\n\nconst Variable = function(name, index, currentFileInfo) {\n this.name = name;\n this._index = index;\n this._fileInfo = currentFileInfo;\n};\n\nVariable.prototype = Object.assign(new Node(), {\n type: 'Variable',\n\n eval(context) {\n let variable, name = this.name;\n\n if (name.indexOf('@@') === 0) {\n name = `@${new Variable(name.slice(1), this.getIndex(), this.fileInfo()).eval(context).value}`;\n }\n\n if (this.evaluating) {\n throw { type: 'Name',\n message: `Recursive variable definition for ${name}`,\n filename: this.fileInfo().filename,\n index: this.getIndex() };\n }\n\n this.evaluating = true;\n\n variable = this.find(context.frames, function (frame) {\n const v = frame.variable(name);\n if (v) {\n if (v.important) {\n const importantScope = context.importantScope[context.importantScope.length - 1];\n importantScope.important = v.important;\n }\n // If in calc, wrap vars in a function call to cascade evaluate args first\n if (context.inCalc) {\n return (new Call('_SELF', [v.value])).eval(context);\n }\n else {\n return v.value.eval(context);\n }\n }\n });\n if (variable) {\n this.evaluating = false;\n return variable;\n } else {\n throw { type: 'Name',\n message: `variable ${name} is undefined`,\n filename: this.fileInfo().filename,\n index: this.getIndex() };\n }\n },\n\n find(obj, fun) {\n for (let i = 0, r; i < obj.length; i++) {\n r = fun.call(obj, obj[i]);\n if (r) { return r; }\n }\n return null;\n }\n});\n\nexport default Variable;\n","import Node from './node';\nimport Declaration from './declaration';\n\nconst Property = function(name, index, currentFileInfo) {\n this.name = name;\n this._index = index;\n this._fileInfo = currentFileInfo;\n};\n\nProperty.prototype = Object.assign(new Node(), {\n type: 'Property',\n\n eval(context) {\n let property;\n const name = this.name;\n // TODO: shorten this reference\n const mergeRules = context.pluginManager.less.visitors.ToCSSVisitor.prototype._mergeRules;\n\n if (this.evaluating) {\n throw { type: 'Name',\n message: `Recursive property reference for ${name}`,\n filename: this.fileInfo().filename,\n index: this.getIndex() };\n }\n\n this.evaluating = true;\n\n property = this.find(context.frames, function (frame) {\n let v;\n const vArr = frame.property(name);\n if (vArr) {\n for (let i = 0; i < vArr.length; i++) {\n v = vArr[i];\n\n vArr[i] = new Declaration(v.name,\n v.value,\n v.important,\n v.merge,\n v.index,\n v.currentFileInfo,\n v.inline,\n v.variable\n );\n }\n mergeRules(vArr);\n\n v = vArr[vArr.length - 1];\n if (v.important) {\n const importantScope = context.importantScope[context.importantScope.length - 1];\n importantScope.important = v.important;\n }\n v = v.value.eval(context);\n return v;\n }\n });\n if (property) {\n this.evaluating = false;\n return property;\n } else {\n throw { type: 'Name',\n message: `Property '${name}' is undefined`,\n filename: this.currentFileInfo.filename,\n index: this.index };\n }\n },\n\n find(obj, fun) {\n for (let i = 0, r; i < obj.length; i++) {\n r = fun.call(obj, obj[i]);\n if (r) { return r; }\n }\n return null;\n }\n});\n\nexport default Property;\n","import Node from './node';\n\nconst Attribute = function(key, op, value) {\n this.key = key;\n this.op = op;\n this.value = value;\n}\n\nAttribute.prototype = Object.assign(new Node(), {\n type: 'Attribute',\n\n eval(context) {\n return new Attribute(this.key.eval ? this.key.eval(context) : this.key,\n this.op, (this.value && this.value.eval) ? this.value.eval(context) : this.value);\n },\n\n genCSS(context, output) {\n output.add(this.toCSS(context));\n },\n\n toCSS(context) {\n let value = this.key.toCSS ? this.key.toCSS(context) : this.key;\n\n if (this.op) {\n value += this.op;\n value += (this.value.toCSS ? this.value.toCSS(context) : this.value);\n }\n\n return `[${value}]`;\n }\n});\n\nexport default Attribute;\n","import Node from './node';\nimport Variable from './variable';\nimport Property from './property';\n\n\nconst Quoted = function(str, content, escaped, index, currentFileInfo) {\n this.escaped = (escaped == null) ? true : escaped;\n this.value = content || '';\n this.quote = str.charAt(0);\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.variableRegex = /@\\{([\\w-]+)\\}/g;\n this.propRegex = /\\$\\{([\\w-]+)\\}/g;\n this.allowRoot = escaped;\n};\n\nQuoted.prototype = Object.assign(new Node(), {\n type: 'Quoted',\n\n genCSS(context, output) {\n if (!this.escaped) {\n output.add(this.quote, this.fileInfo(), this.getIndex());\n }\n output.add(this.value);\n if (!this.escaped) {\n output.add(this.quote);\n }\n },\n\n containsVariables() {\n return this.value.match(this.variableRegex);\n },\n\n eval(context) {\n const that = this;\n let value = this.value;\n const variableReplacement = function (_, name) {\n const v = new Variable(`@${name}`, that.getIndex(), that.fileInfo()).eval(context, true);\n return (v instanceof Quoted) ? v.value : v.toCSS();\n };\n const propertyReplacement = function (_, name) {\n const v = new Property(`$${name}`, that.getIndex(), that.fileInfo()).eval(context, true);\n return (v instanceof Quoted) ? v.value : v.toCSS();\n };\n function iterativeReplace(value, regexp, replacementFnc) {\n let evaluatedValue = value;\n do {\n value = evaluatedValue.toString();\n evaluatedValue = value.replace(regexp, replacementFnc);\n } while (value !== evaluatedValue);\n return evaluatedValue;\n }\n value = iterativeReplace(value, this.variableRegex, variableReplacement);\n value = iterativeReplace(value, this.propRegex, propertyReplacement);\n return new Quoted(this.quote + value + this.quote, value, this.escaped, this.getIndex(), this.fileInfo());\n },\n\n compare(other) {\n // when comparing quoted strings allow the quote to differ\n if (other.type === 'Quoted' && !this.escaped && !other.escaped) {\n return Node.numericCompare(this.value, other.value);\n } else {\n return other.toCSS && this.toCSS() === other.toCSS() ? 0 : undefined;\n }\n }\n});\n\nexport default Quoted;\n","import Node from './node';\n\nfunction escapePath(path) {\n return path.replace(/[\\(\\)'\"\\s]/g, function(match) { return `\\\\${match}`; });\n}\n\nconst URL = function(val, index, currentFileInfo, isEvald) {\n this.value = val;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.isEvald = isEvald;\n};\n\nURL.prototype = Object.assign(new Node(), {\n type: 'Url',\n\n accept(visitor) {\n this.value = visitor.visit(this.value);\n },\n\n genCSS(context, output) {\n output.add('url(');\n this.value.genCSS(context, output);\n output.add(')');\n },\n\n eval(context) {\n const val = this.value.eval(context);\n let rootpath;\n\n if (!this.isEvald) {\n // Add the rootpath if the URL requires a rewrite\n rootpath = this.fileInfo() && this.fileInfo().rootpath;\n if (typeof rootpath === 'string' &&\n typeof val.value === 'string' &&\n context.pathRequiresRewrite(val.value)) {\n if (!val.quote) {\n rootpath = escapePath(rootpath);\n }\n val.value = context.rewritePath(val.value, rootpath);\n } else {\n val.value = context.normalizePath(val.value);\n }\n\n // Add url args if enabled\n if (context.urlArgs) {\n if (!val.value.match(/^\\s*data:/)) {\n const delimiter = val.value.indexOf('?') === -1 ? '?' : '&';\n const urlArgs = delimiter + context.urlArgs;\n if (val.value.indexOf('#') !== -1) {\n val.value = val.value.replace('#', `${urlArgs}#`);\n } else {\n val.value += urlArgs;\n }\n }\n }\n }\n\n return new URL(val, this.getIndex(), this.fileInfo(), true);\n }\n});\n\nexport default URL;\n","import Ruleset from './ruleset';\nimport Value from './value';\nimport Selector from './selector';\nimport Anonymous from './anonymous';\nimport Expression from './expression';\nimport AtRule from './atrule';\nimport * as utils from '../utils';\n\nconst Media = function(value, features, index, currentFileInfo, visibilityInfo) {\n this._index = index;\n this._fileInfo = currentFileInfo;\n\n const selectors = (new Selector([], null, null, this._index, this._fileInfo)).createEmptySelectors();\n\n this.features = new Value(features);\n this.rules = [new Ruleset(selectors, value)];\n this.rules[0].allowImports = true;\n this.copyVisibilityInfo(visibilityInfo);\n this.allowRoot = true;\n this.setParent(selectors, this);\n this.setParent(this.features, this);\n this.setParent(this.rules, this);\n};\n\nMedia.prototype = Object.assign(new AtRule(), {\n type: 'Media',\n\n isRulesetLike() {\n return true;\n },\n\n accept(visitor) {\n if (this.features) {\n this.features = visitor.visit(this.features);\n }\n if (this.rules) {\n this.rules = visitor.visitArray(this.rules);\n }\n },\n\n genCSS(context, output) {\n output.add('@media ', this._fileInfo, this._index);\n this.features.genCSS(context, output);\n this.outputRuleset(context, output, this.rules);\n },\n\n eval(context) {\n if (!context.mediaBlocks) {\n context.mediaBlocks = [];\n context.mediaPath = [];\n }\n\n const media = new Media(null, [], this._index, this._fileInfo, this.visibilityInfo());\n if (this.debugInfo) {\n this.rules[0].debugInfo = this.debugInfo;\n media.debugInfo = this.debugInfo;\n }\n \n media.features = this.features.eval(context);\n\n context.mediaPath.push(media);\n context.mediaBlocks.push(media);\n\n this.rules[0].functionRegistry = context.frames[0].functionRegistry.inherit();\n context.frames.unshift(this.rules[0]);\n media.rules = [this.rules[0].eval(context)];\n context.frames.shift();\n\n context.mediaPath.pop();\n\n return context.mediaPath.length === 0 ? media.evalTop(context) :\n media.evalNested(context);\n },\n\n evalTop(context) {\n let result = this;\n\n // Render all dependent Media blocks.\n if (context.mediaBlocks.length > 1) {\n const selectors = (new Selector([], null, null, this.getIndex(), this.fileInfo())).createEmptySelectors();\n result = new Ruleset(selectors, context.mediaBlocks);\n result.multiMedia = true;\n result.copyVisibilityInfo(this.visibilityInfo());\n this.setParent(result, this);\n }\n\n delete context.mediaBlocks;\n delete context.mediaPath;\n\n return result;\n },\n\n evalNested(context) {\n let i;\n let value;\n const path = context.mediaPath.concat([this]);\n\n // Extract the media-query conditions separated with `,` (OR).\n for (i = 0; i < path.length; i++) {\n value = path[i].features instanceof Value ?\n path[i].features.value : path[i].features;\n path[i] = Array.isArray(value) ? value : [value];\n }\n\n // Trace all permutations to generate the resulting media-query.\n //\n // (a, b and c) with nested (d, e) ->\n // a and d\n // a and e\n // b and c and d\n // b and c and e\n this.features = new Value(this.permute(path).map(path => {\n path = path.map(fragment => fragment.toCSS ? fragment : new Anonymous(fragment));\n\n for (i = path.length - 1; i > 0; i--) {\n path.splice(i, 0, new Anonymous('and'));\n }\n\n return new Expression(path);\n }));\n this.setParent(this.features, this);\n\n // Fake a tree-node that doesn't output anything.\n return new Ruleset([], []);\n },\n\n permute(arr) {\n if (arr.length === 0) {\n return [];\n } else if (arr.length === 1) {\n return arr[0];\n } else {\n const result = [];\n const rest = this.permute(arr.slice(1));\n for (let i = 0; i < rest.length; i++) {\n for (let j = 0; j < arr[0].length; j++) {\n result.push([arr[0][j]].concat(rest[i]));\n }\n }\n return result;\n }\n },\n\n bubbleSelectors(selectors) {\n if (!selectors) {\n return;\n }\n this.rules = [new Ruleset(utils.copyArray(selectors), [this.rules[0]])];\n this.setParent(this.rules, this);\n }\n});\n\nexport default Media;\n","import Node from './node';\nimport Media from './media';\nimport URL from './url';\nimport Quoted from './quoted';\nimport Ruleset from './ruleset';\nimport Anonymous from './anonymous';\nimport * as utils from '../utils';\nimport LessError from '../less-error';\n\n//\n// CSS @import node\n//\n// The general strategy here is that we don't want to wait\n// for the parsing to be completed, before we start importing\n// the file. That's because in the context of a browser,\n// most of the time will be spent waiting for the server to respond.\n//\n// On creation, we push the import path to our import queue, though\n// `import,push`, we also pass it a callback, which it'll call once\n// the file has been fetched, and parsed.\n//\nconst Import = function(path, features, options, index, currentFileInfo, visibilityInfo) {\n this.options = options;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.path = path;\n this.features = features;\n this.allowRoot = true;\n\n if (this.options.less !== undefined || this.options.inline) {\n this.css = !this.options.less || this.options.inline;\n } else {\n const pathValue = this.getPath();\n if (pathValue && /[#\\.\\&\\?]css([\\?;].*)?$/.test(pathValue)) {\n this.css = true;\n }\n }\n this.copyVisibilityInfo(visibilityInfo);\n this.setParent(this.features, this);\n this.setParent(this.path, this);\n};\n\nImport.prototype = Object.assign(new Node(), {\n type: 'Import',\n\n accept(visitor) {\n if (this.features) {\n this.features = visitor.visit(this.features);\n }\n this.path = visitor.visit(this.path);\n if (!this.options.isPlugin && !this.options.inline && this.root) {\n this.root = visitor.visit(this.root);\n }\n },\n\n genCSS(context, output) {\n if (this.css && this.path._fileInfo.reference === undefined) {\n output.add('@import ', this._fileInfo, this._index);\n this.path.genCSS(context, output);\n if (this.features) {\n output.add(' ');\n this.features.genCSS(context, output);\n }\n output.add(';');\n }\n },\n\n getPath() {\n return (this.path instanceof URL) ?\n this.path.value.value : this.path.value;\n },\n\n isVariableImport() {\n let path = this.path;\n if (path instanceof URL) {\n path = path.value;\n }\n if (path instanceof Quoted) {\n return path.containsVariables();\n }\n\n return true;\n },\n\n evalForImport(context) {\n let path = this.path;\n\n if (path instanceof URL) {\n path = path.value;\n }\n\n return new Import(path.eval(context), this.features, this.options, this._index, this._fileInfo, this.visibilityInfo());\n },\n\n evalPath(context) {\n const path = this.path.eval(context);\n const fileInfo = this._fileInfo;\n\n if (!(path instanceof URL)) {\n // Add the rootpath if the URL requires a rewrite\n const pathValue = path.value;\n if (fileInfo &&\n pathValue &&\n context.pathRequiresRewrite(pathValue)) {\n path.value = context.rewritePath(pathValue, fileInfo.rootpath);\n } else {\n path.value = context.normalizePath(path.value);\n }\n }\n\n return path;\n },\n\n eval(context) {\n const result = this.doEval(context);\n if (this.options.reference || this.blocksVisibility()) {\n if (result.length || result.length === 0) {\n result.forEach(function (node) {\n node.addVisibilityBlock();\n }\n );\n } else {\n result.addVisibilityBlock();\n }\n }\n return result;\n },\n\n doEval(context) {\n let ruleset;\n let registry;\n const features = this.features && this.features.eval(context);\n\n if (this.options.isPlugin) {\n if (this.root && this.root.eval) {\n try {\n this.root.eval(context);\n }\n catch (e) {\n e.message = 'Plugin error during evaluation';\n throw new LessError(e, this.root.imports, this.root.filename);\n }\n }\n registry = context.frames[0] && context.frames[0].functionRegistry;\n if ( registry && this.root && this.root.functions ) {\n registry.addMultiple( this.root.functions );\n }\n\n return [];\n }\n\n if (this.skip) {\n if (typeof this.skip === 'function') {\n this.skip = this.skip();\n }\n if (this.skip) {\n return [];\n }\n }\n if (this.options.inline) {\n const contents = new Anonymous(this.root, 0,\n {\n filename: this.importedFilename,\n reference: this.path._fileInfo && this.path._fileInfo.reference\n }, true, true);\n\n return this.features ? new Media([contents], this.features.value) : [contents];\n } else if (this.css) {\n const newImport = new Import(this.evalPath(context), features, this.options, this._index);\n if (!newImport.css && this.error) {\n throw this.error;\n }\n return newImport;\n } else if (this.root) {\n ruleset = new Ruleset(null, utils.copyArray(this.root.rules));\n ruleset.evalImports(context);\n\n return this.features ? new Media(ruleset.rules, this.features.value) : ruleset.rules;\n } else {\n return [];\n }\n }\n});\n\nexport default Import;\n","import Node from './node';\nimport Variable from './variable';\n\nconst JsEvalNode = function() {};\n\nJsEvalNode.prototype = Object.assign(new Node(), {\n evaluateJavaScript(expression, context) {\n let result;\n const that = this;\n const evalContext = {};\n\n if (!context.javascriptEnabled) {\n throw { message: 'Inline JavaScript is not enabled. Is it set in your options?',\n filename: this.fileInfo().filename,\n index: this.getIndex() };\n }\n\n expression = expression.replace(/@\\{([\\w-]+)\\}/g, function (_, name) {\n return that.jsify(new Variable(`@${name}`, that.getIndex(), that.fileInfo()).eval(context));\n });\n\n try {\n expression = new Function(`return (${expression})`);\n } catch (e) {\n throw { message: `JavaScript evaluation error: ${e.message} from \\`${expression}\\`` ,\n filename: this.fileInfo().filename,\n index: this.getIndex() };\n }\n\n const variables = context.frames[0].variables();\n for (const k in variables) {\n if (variables.hasOwnProperty(k)) {\n /* jshint loopfunc:true */\n evalContext[k.slice(1)] = {\n value: variables[k].value,\n toJS: function () {\n return this.value.eval(context).toCSS();\n }\n };\n }\n }\n\n try {\n result = expression.call(evalContext);\n } catch (e) {\n throw { message: `JavaScript evaluation error: '${e.name}: ${e.message.replace(/[\"]/g, '\\'')}'` ,\n filename: this.fileInfo().filename,\n index: this.getIndex() };\n }\n return result;\n },\n\n jsify(obj) {\n if (Array.isArray(obj.value) && (obj.value.length > 1)) {\n return `[${obj.value.map(function (v) { return v.toCSS(); }).join(', ')}]`;\n } else {\n return obj.toCSS();\n }\n }\n});\n\nexport default JsEvalNode;\n","import JsEvalNode from './js-eval-node';\nimport Dimension from './dimension';\nimport Quoted from './quoted';\nimport Anonymous from './anonymous';\n\nconst JavaScript = function(string, escaped, index, currentFileInfo) {\n this.escaped = escaped;\n this.expression = string;\n this._index = index;\n this._fileInfo = currentFileInfo;\n}\n\nJavaScript.prototype = Object.assign(new JsEvalNode(), {\n type: 'JavaScript',\n\n eval(context) {\n const result = this.evaluateJavaScript(this.expression, context);\n const type = typeof result;\n\n if (type === 'number' && !isNaN(result)) {\n return new Dimension(result);\n } else if (type === 'string') {\n return new Quoted(`\"${result}\"`, result, this.escaped, this._index);\n } else if (Array.isArray(result)) {\n return new Anonymous(result.join(', '));\n } else {\n return new Anonymous(result);\n }\n }\n});\n\nexport default JavaScript;\n","import Node from './node';\n\nconst Assignment = function(key, val) {\n this.key = key;\n this.value = val;\n}\n\nAssignment.prototype = Object.assign(new Node(), {\n type: 'Assignment',\n\n accept(visitor) {\n this.value = visitor.visit(this.value);\n },\n\n eval(context) {\n if (this.value.eval) {\n return new Assignment(this.key, this.value.eval(context));\n }\n return this;\n },\n\n genCSS(context, output) {\n output.add(`${this.key}=`);\n if (this.value.genCSS) {\n this.value.genCSS(context, output);\n } else {\n output.add(this.value);\n }\n }\n});\n\nexport default Assignment;\n","import Node from './node';\n\nconst Condition = function(op, l, r, i, negate) {\n this.op = op.trim();\n this.lvalue = l;\n this.rvalue = r;\n this._index = i;\n this.negate = negate;\n};\n\nCondition.prototype = Object.assign(new Node(), {\n type: 'Condition',\n\n accept(visitor) {\n this.lvalue = visitor.visit(this.lvalue);\n this.rvalue = visitor.visit(this.rvalue);\n },\n\n eval(context) {\n const result = (function (op, a, b) {\n switch (op) {\n case 'and': return a && b;\n case 'or': return a || b;\n default:\n switch (Node.compare(a, b)) {\n case -1:\n return op === '<' || op === '=<' || op === '<=';\n case 0:\n return op === '=' || op === '>=' || op === '=<' || op === '<=';\n case 1:\n return op === '>' || op === '>=';\n default:\n return false;\n }\n }\n })(this.op, this.lvalue.eval(context), this.rvalue.eval(context));\n\n return this.negate ? !result : result;\n }\n});\n\nexport default Condition;\n","import Node from './node';\n\nconst UnicodeDescriptor = function(value) {\n this.value = value;\n}\n\nUnicodeDescriptor.prototype = Object.assign(new Node(), {\n type: 'UnicodeDescriptor'\n})\n\nexport default UnicodeDescriptor;\n","import Node from './node';\nimport Operation from './operation';\nimport Dimension from './dimension';\n\nconst Negative = function(node) {\n this.value = node;\n};\n\nNegative.prototype = Object.assign(new Node(), {\n type: 'Negative',\n\n genCSS(context, output) {\n output.add('-');\n this.value.genCSS(context, output);\n },\n\n eval(context) {\n if (context.isMathOn()) {\n return (new Operation('*', [new Dimension(-1), this.value])).eval(context);\n }\n return new Negative(this.value.eval(context));\n }\n});\n\nexport default Negative;\n","import Node from './node';\nimport Selector from './selector';\n\nconst Extend = function(selector, option, index, currentFileInfo, visibilityInfo) {\n this.selector = selector;\n this.option = option;\n this.object_id = Extend.next_id++;\n this.parent_ids = [this.object_id];\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.copyVisibilityInfo(visibilityInfo);\n this.allowRoot = true;\n\n switch (option) {\n case 'all':\n this.allowBefore = true;\n this.allowAfter = true;\n break;\n default:\n this.allowBefore = false;\n this.allowAfter = false;\n break;\n }\n this.setParent(this.selector, this);\n};\n\nExtend.prototype = Object.assign(new Node(), {\n type: 'Extend',\n\n accept(visitor) {\n this.selector = visitor.visit(this.selector);\n },\n\n eval(context) {\n return new Extend(this.selector.eval(context), this.option, this.getIndex(), this.fileInfo(), this.visibilityInfo());\n },\n\n clone(context) {\n return new Extend(this.selector, this.option, this.getIndex(), this.fileInfo(), this.visibilityInfo());\n },\n\n // it concatenates (joins) all selectors in selector array\n findSelfSelectors(selectors) {\n let selfElements = [], i, selectorElements;\n\n for (i = 0; i < selectors.length; i++) {\n selectorElements = selectors[i].elements;\n // duplicate the logic in genCSS function inside the selector node.\n // future TODO - move both logics into the selector joiner visitor\n if (i > 0 && selectorElements.length && selectorElements[0].combinator.value === '') {\n selectorElements[0].combinator.value = ' ';\n }\n selfElements = selfElements.concat(selectors[i].elements);\n }\n\n this.selfSelectors = [new Selector(selfElements)];\n this.selfSelectors[0].copyVisibilityInfo(this.visibilityInfo());\n }\n});\n\nExtend.next_id = 0;\nexport default Extend;\n","import Node from './node';\nimport Variable from './variable';\nimport Ruleset from './ruleset';\nimport DetachedRuleset from './detached-ruleset';\nimport LessError from '../less-error';\n\nconst VariableCall = function(variable, index, currentFileInfo) {\n this.variable = variable;\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.allowRoot = true;\n};\n\nVariableCall.prototype = Object.assign(new Node(), {\n type: 'VariableCall',\n\n eval(context) {\n let rules;\n let detachedRuleset = new Variable(this.variable, this.getIndex(), this.fileInfo()).eval(context);\n const error = new LessError({message: `Could not evaluate variable call ${this.variable}`});\n\n if (!detachedRuleset.ruleset) {\n if (detachedRuleset.rules) {\n rules = detachedRuleset;\n }\n else if (Array.isArray(detachedRuleset)) {\n rules = new Ruleset('', detachedRuleset);\n }\n else if (Array.isArray(detachedRuleset.value)) {\n rules = new Ruleset('', detachedRuleset.value);\n }\n else {\n throw error;\n }\n detachedRuleset = new DetachedRuleset(rules);\n }\n\n if (detachedRuleset.ruleset) {\n return detachedRuleset.callEval(context);\n }\n throw error;\n }\n});\n\nexport default VariableCall;\n","import Node from './node';\nimport Variable from './variable';\nimport Ruleset from './ruleset';\nimport Selector from './selector';\n\nconst NamespaceValue = function(ruleCall, lookups, index, fileInfo) {\n this.value = ruleCall;\n this.lookups = lookups;\n this._index = index;\n this._fileInfo = fileInfo;\n};\n\nNamespaceValue.prototype = Object.assign(new Node(), {\n type: 'NamespaceValue',\n\n eval(context) {\n let i, j, name, rules = this.value.eval(context);\n \n for (i = 0; i < this.lookups.length; i++) {\n name = this.lookups[i];\n\n /**\n * Eval'd DRs return rulesets.\n * Eval'd mixins return rules, so let's make a ruleset if we need it.\n * We need to do this because of late parsing of values\n */\n if (Array.isArray(rules)) {\n rules = new Ruleset([new Selector()], rules);\n }\n\n if (name === '') {\n rules = rules.lastDeclaration();\n }\n else if (name.charAt(0) === '@') {\n if (name.charAt(1) === '@') {\n name = `@${new Variable(name.substr(1)).eval(context).value}`;\n }\n if (rules.variables) {\n rules = rules.variable(name);\n }\n \n if (!rules) {\n throw { type: 'Name',\n message: `variable ${name} not found`,\n filename: this.fileInfo().filename,\n index: this.getIndex() };\n }\n }\n else {\n if (name.substring(0, 2) === '$@') {\n name = `$${new Variable(name.substr(1)).eval(context).value}`;\n }\n else {\n name = name.charAt(0) === '$' ? name : `$${name}`;\n }\n if (rules.properties) {\n rules = rules.property(name);\n }\n \n if (!rules) {\n throw { type: 'Name',\n message: `property \"${name.substr(1)}\" not found`,\n filename: this.fileInfo().filename,\n index: this.getIndex() };\n }\n // Properties are an array of values, since a ruleset can have multiple props.\n // We pick the last one (the \"cascaded\" value)\n rules = rules[rules.length - 1];\n }\n\n if (rules.value) {\n rules = rules.eval(context).value;\n }\n if (rules.ruleset) {\n rules = rules.ruleset.eval(context);\n }\n }\n return rules;\n }\n});\n\nexport default NamespaceValue;\n","import Selector from './selector';\nimport Element from './element';\nimport Ruleset from './ruleset';\nimport Declaration from './declaration';\nimport DetachedRuleset from './detached-ruleset';\nimport Expression from './expression';\nimport contexts from '../contexts';\nimport * as utils from '../utils';\n\nconst Definition = function(name, params, rules, condition, variadic, frames, visibilityInfo) {\n this.name = name || 'anonymous mixin';\n this.selectors = [new Selector([new Element(null, name, false, this._index, this._fileInfo)])];\n this.params = params;\n this.condition = condition;\n this.variadic = variadic;\n this.arity = params.length;\n this.rules = rules;\n this._lookups = {};\n const optionalParameters = [];\n this.required = params.reduce(function (count, p) {\n if (!p.name || (p.name && !p.value)) {\n return count + 1;\n }\n else {\n optionalParameters.push(p.name);\n return count;\n }\n }, 0);\n this.optionalParameters = optionalParameters;\n this.frames = frames;\n this.copyVisibilityInfo(visibilityInfo);\n this.allowRoot = true;\n}\n\nDefinition.prototype = Object.assign(new Ruleset(), {\n type: 'MixinDefinition',\n evalFirst: true,\n\n accept(visitor) {\n if (this.params && this.params.length) {\n this.params = visitor.visitArray(this.params);\n }\n this.rules = visitor.visitArray(this.rules);\n if (this.condition) {\n this.condition = visitor.visit(this.condition);\n }\n },\n\n evalParams(context, mixinEnv, args, evaldArguments) {\n /* jshint boss:true */\n const frame = new Ruleset(null, null);\n\n let varargs;\n let arg;\n const params = utils.copyArray(this.params);\n let i;\n let j;\n let val;\n let name;\n let isNamedFound;\n let argIndex;\n let argsLength = 0;\n\n if (mixinEnv.frames && mixinEnv.frames[0] && mixinEnv.frames[0].functionRegistry) {\n frame.functionRegistry = mixinEnv.frames[0].functionRegistry.inherit();\n }\n mixinEnv = new contexts.Eval(mixinEnv, [frame].concat(mixinEnv.frames));\n\n if (args) {\n args = utils.copyArray(args);\n argsLength = args.length;\n\n for (i = 0; i < argsLength; i++) {\n arg = args[i];\n if (name = (arg && arg.name)) {\n isNamedFound = false;\n for (j = 0; j < params.length; j++) {\n if (!evaldArguments[j] && name === params[j].name) {\n evaldArguments[j] = arg.value.eval(context);\n frame.prependRule(new Declaration(name, arg.value.eval(context)));\n isNamedFound = true;\n break;\n }\n }\n if (isNamedFound) {\n args.splice(i, 1);\n i--;\n continue;\n } else {\n throw { type: 'Runtime', message: `Named argument for ${this.name} ${args[i].name} not found` };\n }\n }\n }\n }\n argIndex = 0;\n for (i = 0; i < params.length; i++) {\n if (evaldArguments[i]) { continue; }\n\n arg = args && args[argIndex];\n\n if (name = params[i].name) {\n if (params[i].variadic) {\n varargs = [];\n for (j = argIndex; j < argsLength; j++) {\n varargs.push(args[j].value.eval(context));\n }\n frame.prependRule(new Declaration(name, new Expression(varargs).eval(context)));\n } else {\n val = arg && arg.value;\n if (val) {\n // This was a mixin call, pass in a detached ruleset of it's eval'd rules\n if (Array.isArray(val)) {\n val = new DetachedRuleset(new Ruleset('', val));\n }\n else {\n val = val.eval(context);\n }\n } else if (params[i].value) {\n val = params[i].value.eval(mixinEnv);\n frame.resetCache();\n } else {\n throw { type: 'Runtime', message: `wrong number of arguments for ${this.name} (${argsLength} for ${this.arity})` };\n }\n\n frame.prependRule(new Declaration(name, val));\n evaldArguments[i] = val;\n }\n }\n\n if (params[i].variadic && args) {\n for (j = argIndex; j < argsLength; j++) {\n evaldArguments[j] = args[j].value.eval(context);\n }\n }\n argIndex++;\n }\n\n return frame;\n },\n\n makeImportant() {\n const rules = !this.rules ? this.rules : this.rules.map(function (r) {\n if (r.makeImportant) {\n return r.makeImportant(true);\n } else {\n return r;\n }\n });\n const result = new Definition(this.name, this.params, rules, this.condition, this.variadic, this.frames);\n return result;\n },\n\n eval(context) {\n return new Definition(this.name, this.params, this.rules, this.condition, this.variadic, this.frames || utils.copyArray(context.frames));\n },\n\n evalCall(context, args, important) {\n const _arguments = [];\n const mixinFrames = this.frames ? this.frames.concat(context.frames) : context.frames;\n const frame = this.evalParams(context, new contexts.Eval(context, mixinFrames), args, _arguments);\n let rules;\n let ruleset;\n\n frame.prependRule(new Declaration('@arguments', new Expression(_arguments).eval(context)));\n\n rules = utils.copyArray(this.rules);\n\n ruleset = new Ruleset(null, rules);\n ruleset.originalRuleset = this;\n ruleset = ruleset.eval(new contexts.Eval(context, [this, frame].concat(mixinFrames)));\n if (important) {\n ruleset = ruleset.makeImportant();\n }\n return ruleset;\n },\n\n matchCondition(args, context) {\n if (this.condition && !this.condition.eval(\n new contexts.Eval(context,\n [this.evalParams(context, /* the parameter variables */\n new contexts.Eval(context, this.frames ? this.frames.concat(context.frames) : context.frames), args, [])]\n .concat(this.frames || []) // the parent namespace/mixin frames\n .concat(context.frames)))) { // the current environment frames\n return false;\n }\n return true;\n },\n\n matchArgs(args, context) {\n const allArgsCnt = (args && args.length) || 0;\n let len;\n const optionalParameters = this.optionalParameters;\n const requiredArgsCnt = !args ? 0 : args.reduce(function (count, p) {\n if (optionalParameters.indexOf(p.name) < 0) {\n return count + 1;\n } else {\n return count;\n }\n }, 0);\n\n if (!this.variadic) {\n if (requiredArgsCnt < this.required) {\n return false;\n }\n if (allArgsCnt > this.params.length) {\n return false;\n }\n } else {\n if (requiredArgsCnt < (this.required - 1)) {\n return false;\n }\n }\n\n // check patterns\n len = Math.min(requiredArgsCnt, this.arity);\n\n for (let i = 0; i < len; i++) {\n if (!this.params[i].name && !this.params[i].variadic) {\n if (args[i].value.eval(context).toCSS() != this.params[i].value.eval(context).toCSS()) {\n return false;\n }\n }\n }\n return true;\n }\n});\n\nexport default Definition;\n","import Node from './node';\nimport Selector from './selector';\nimport MixinDefinition from './mixin-definition';\nimport defaultFunc from '../functions/default';\n\nconst MixinCall = function(elements, args, index, currentFileInfo, important) {\n this.selector = new Selector(elements);\n this.arguments = args || [];\n this._index = index;\n this._fileInfo = currentFileInfo;\n this.important = important;\n this.allowRoot = true;\n this.setParent(this.selector, this);\n};\n\nMixinCall.prototype = Object.assign(new Node(), {\n type: 'MixinCall',\n\n accept(visitor) {\n if (this.selector) {\n this.selector = visitor.visit(this.selector);\n }\n if (this.arguments.length) {\n this.arguments = visitor.visitArray(this.arguments);\n }\n },\n\n eval(context) {\n let mixins;\n let mixin;\n let mixinPath;\n const args = [];\n let arg;\n let argValue;\n const rules = [];\n let match = false;\n let i;\n let m;\n let f;\n let isRecursive;\n let isOneFound;\n const candidates = [];\n let candidate;\n const conditionResult = [];\n let defaultResult;\n const defFalseEitherCase = -1;\n const defNone = 0;\n const defTrue = 1;\n const defFalse = 2;\n let count;\n let originalRuleset;\n let noArgumentsFilter;\n\n this.selector = this.selector.eval(context);\n\n function calcDefGroup(mixin, mixinPath) {\n let f, p, namespace;\n\n for (f = 0; f < 2; f++) {\n conditionResult[f] = true;\n defaultFunc.value(f);\n for (p = 0; p < mixinPath.length && conditionResult[f]; p++) {\n namespace = mixinPath[p];\n if (namespace.matchCondition) {\n conditionResult[f] = conditionResult[f] && namespace.matchCondition(null, context);\n }\n }\n if (mixin.matchCondition) {\n conditionResult[f] = conditionResult[f] && mixin.matchCondition(args, context);\n }\n }\n if (conditionResult[0] || conditionResult[1]) {\n if (conditionResult[0] != conditionResult[1]) {\n return conditionResult[1] ?\n defTrue : defFalse;\n }\n\n return defNone;\n }\n return defFalseEitherCase;\n }\n\n for (i = 0; i < this.arguments.length; i++) {\n arg = this.arguments[i];\n argValue = arg.value.eval(context);\n if (arg.expand && Array.isArray(argValue.value)) {\n argValue = argValue.value;\n for (m = 0; m < argValue.length; m++) {\n args.push({value: argValue[m]});\n }\n } else {\n args.push({name: arg.name, value: argValue});\n }\n }\n\n noArgumentsFilter = function(rule) {return rule.matchArgs(null, context);};\n\n for (i = 0; i < context.frames.length; i++) {\n if ((mixins = context.frames[i].find(this.selector, null, noArgumentsFilter)).length > 0) {\n isOneFound = true;\n\n // To make `default()` function independent of definition order we have two \"subpasses\" here.\n // At first we evaluate each guard *twice* (with `default() == true` and `default() == false`),\n // and build candidate list with corresponding flags. Then, when we know all possible matches,\n // we make a final decision.\n\n for (m = 0; m < mixins.length; m++) {\n mixin = mixins[m].rule;\n mixinPath = mixins[m].path;\n isRecursive = false;\n for (f = 0; f < context.frames.length; f++) {\n if ((!(mixin instanceof MixinDefinition)) && mixin === (context.frames[f].originalRuleset || context.frames[f])) {\n isRecursive = true;\n break;\n }\n }\n if (isRecursive) {\n continue;\n }\n\n if (mixin.matchArgs(args, context)) {\n candidate = {mixin, group: calcDefGroup(mixin, mixinPath)};\n\n if (candidate.group !== defFalseEitherCase) {\n candidates.push(candidate);\n }\n\n match = true;\n }\n }\n\n defaultFunc.reset();\n\n count = [0, 0, 0];\n for (m = 0; m < candidates.length; m++) {\n count[candidates[m].group]++;\n }\n\n if (count[defNone] > 0) {\n defaultResult = defFalse;\n } else {\n defaultResult = defTrue;\n if ((count[defTrue] + count[defFalse]) > 1) {\n throw { type: 'Runtime',\n message: `Ambiguous use of \\`default()\\` found when matching for \\`${this.format(args)}\\``,\n index: this.getIndex(), filename: this.fileInfo().filename };\n }\n }\n\n for (m = 0; m < candidates.length; m++) {\n candidate = candidates[m].group;\n if ((candidate === defNone) || (candidate === defaultResult)) {\n try {\n mixin = candidates[m].mixin;\n if (!(mixin instanceof MixinDefinition)) {\n originalRuleset = mixin.originalRuleset || mixin;\n mixin = new MixinDefinition('', [], mixin.rules, null, false, null, originalRuleset.visibilityInfo());\n mixin.originalRuleset = originalRuleset;\n }\n const newRules = mixin.evalCall(context, args, this.important).rules;\n this._setVisibilityToReplacement(newRules);\n Array.prototype.push.apply(rules, newRules);\n } catch (e) {\n throw { message: e.message, index: this.getIndex(), filename: this.fileInfo().filename, stack: e.stack };\n }\n }\n }\n\n if (match) {\n return rules;\n }\n }\n }\n if (isOneFound) {\n throw { type: 'Runtime',\n message: `No matching definition was found for \\`${this.format(args)}\\``,\n index: this.getIndex(), filename: this.fileInfo().filename };\n } else {\n throw { type: 'Name',\n message: `${this.selector.toCSS().trim()} is undefined`,\n index: this.getIndex(), filename: this.fileInfo().filename };\n }\n },\n\n _setVisibilityToReplacement(replacement) {\n let i, rule;\n if (this.blocksVisibility()) {\n for (i = 0; i < replacement.length; i++) {\n rule = replacement[i];\n rule.addVisibilityBlock();\n }\n }\n },\n\n format(args) {\n return `${this.selector.toCSS().trim()}(${args ? args.map(function (a) {\n let argValue = '';\n if (a.name) {\n argValue += `${a.name}:`;\n }\n if (a.value.toCSS) {\n argValue += a.value.toCSS();\n } else {\n argValue += '???';\n }\n return argValue;\n }).join(', ') : ''})`;\n }\n});\n\nexport default MixinCall;\n","import Node from './node';\nimport Color from './color';\nimport AtRule from './atrule';\nimport DetachedRuleset from './detached-ruleset';\nimport Operation from './operation';\nimport Dimension from './dimension';\nimport Unit from './unit';\nimport Keyword from './keyword';\nimport Variable from './variable';\nimport Property from './property';\nimport Ruleset from './ruleset';\nimport Element from './element';\nimport Attribute from './attribute';\nimport Combinator from './combinator';\nimport Selector from './selector';\nimport Quoted from './quoted';\nimport Expression from './expression';\nimport Declaration from './declaration';\nimport Call from './call';\nimport URL from './url';\nimport Import from './import';\nimport Comment from './comment';\nimport Anonymous from './anonymous';\nimport Value from './value';\nimport JavaScript from './javascript';\nimport Assignment from './assignment';\nimport Condition from './condition';\nimport Paren from './paren';\nimport Media from './media';\nimport UnicodeDescriptor from './unicode-descriptor';\nimport Negative from './negative';\nimport Extend from './extend';\nimport VariableCall from './variable-call';\nimport NamespaceValue from './namespace-value';\n\n// mixins\nimport MixinCall from './mixin-call';\nimport MixinDefinition from './mixin-definition';\n\nexport default {\n Node, Color, AtRule, DetachedRuleset, Operation,\n Dimension, Unit, Keyword, Variable, Property,\n Ruleset, Element, Attribute, Combinator, Selector,\n Quoted, Expression, Declaration, Call, URL, Import,\n Comment, Anonymous, Value, JavaScript, Assignment,\n Condition, Paren, Media, UnicodeDescriptor, Negative,\n Extend, VariableCall, NamespaceValue,\n mixin: {\n Call: MixinCall,\n Definition: MixinDefinition\n }\n};","class AbstractFileManager {\n getPath(filename) {\n let j = filename.lastIndexOf('?');\n if (j > 0) {\n filename = filename.slice(0, j);\n }\n j = filename.lastIndexOf('/');\n if (j < 0) {\n j = filename.lastIndexOf('\\\\');\n }\n if (j < 0) {\n return '';\n }\n return filename.slice(0, j + 1);\n }\n\n tryAppendExtension(path, ext) {\n return /(\\.[a-z]*$)|([\\?;].*)$/.test(path) ? path : path + ext;\n }\n\n tryAppendLessExtension(path) {\n return this.tryAppendExtension(path, '.less');\n }\n\n supportsSync() {\n return false;\n }\n\n alwaysMakePathsAbsolute() {\n return false;\n }\n\n isPathAbsolute(filename) {\n return (/^(?:[a-z-]+:|\\/|\\\\|#)/i).test(filename);\n }\n\n // TODO: pull out / replace?\n join(basePath, laterPath) {\n if (!basePath) {\n return laterPath;\n }\n return basePath + laterPath;\n }\n\n pathDiff(url, baseUrl) {\n // diff between two paths to create a relative path\n\n const urlParts = this.extractUrlParts(url);\n\n const baseUrlParts = this.extractUrlParts(baseUrl);\n let i;\n let max;\n let urlDirectories;\n let baseUrlDirectories;\n let diff = '';\n if (urlParts.hostPart !== baseUrlParts.hostPart) {\n return '';\n }\n max = Math.max(baseUrlParts.directories.length, urlParts.directories.length);\n for (i = 0; i < max; i++) {\n if (baseUrlParts.directories[i] !== urlParts.directories[i]) { break; }\n }\n baseUrlDirectories = baseUrlParts.directories.slice(i);\n urlDirectories = urlParts.directories.slice(i);\n for (i = 0; i < baseUrlDirectories.length - 1; i++) {\n diff += '../';\n }\n for (i = 0; i < urlDirectories.length - 1; i++) {\n diff += `${urlDirectories[i]}/`;\n }\n return diff;\n }\n\n // helper function, not part of API\n extractUrlParts(url, baseUrl) {\n // urlParts[1] = protocol://hostname/ OR /\n // urlParts[2] = / if path relative to host base\n // urlParts[3] = directories\n // urlParts[4] = filename\n // urlParts[5] = parameters\n\n const urlPartsRegex = /^((?:[a-z-]+:)?\\/{2}(?:[^\\/\\?#]*\\/)|([\\/\\\\]))?((?:[^\\/\\\\\\?#]*[\\/\\\\])*)([^\\/\\\\\\?#]*)([#\\?].*)?$/i;\n\n const urlParts = url.match(urlPartsRegex);\n const returner = {};\n let rawDirectories = [];\n const directories = [];\n let i;\n let baseUrlParts;\n\n if (!urlParts) {\n throw new Error(`Could not parse sheet href - '${url}'`);\n }\n\n // Stylesheets in IE don't always return the full path\n if (baseUrl && (!urlParts[1] || urlParts[2])) {\n baseUrlParts = baseUrl.match(urlPartsRegex);\n if (!baseUrlParts) {\n throw new Error(`Could not parse page url - '${baseUrl}'`);\n }\n urlParts[1] = urlParts[1] || baseUrlParts[1] || '';\n if (!urlParts[2]) {\n urlParts[3] = baseUrlParts[3] + urlParts[3];\n }\n }\n\n if (urlParts[3]) {\n rawDirectories = urlParts[3].replace(/\\\\/g, '/').split('/');\n\n // collapse '..' and skip '.'\n for (i = 0; i < rawDirectories.length; i++) {\n\n if (rawDirectories[i] === '..') {\n directories.pop();\n }\n else if (rawDirectories[i] !== '.') {\n directories.push(rawDirectories[i]);\n }\n \n }\n }\n\n returner.hostPart = urlParts[1];\n returner.directories = directories;\n returner.rawPath = (urlParts[1] || '') + rawDirectories.join('/');\n returner.path = (urlParts[1] || '') + directories.join('/');\n returner.filename = urlParts[4];\n returner.fileUrl = returner.path + (urlParts[4] || '');\n returner.url = returner.fileUrl + (urlParts[5] || '');\n return returner;\n }\n}\n\nexport default AbstractFileManager;\n","import functionRegistry from '../functions/function-registry';\nimport LessError from '../less-error';\n\nclass AbstractPluginLoader {\n constructor() {\n // Implemented by Node.js plugin loader\n this.require = function() {\n return null;\n }\n }\n\n evalPlugin(contents, context, imports, pluginOptions, fileInfo) {\n\n let loader, registry, pluginObj, localModule, pluginManager, filename, result;\n\n pluginManager = context.pluginManager;\n\n if (fileInfo) {\n if (typeof fileInfo === 'string') {\n filename = fileInfo;\n }\n else {\n filename = fileInfo.filename;\n }\n }\n const shortname = (new this.less.FileManager()).extractUrlParts(filename).filename;\n\n if (filename) {\n pluginObj = pluginManager.get(filename);\n\n if (pluginObj) {\n result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions);\n if (result) {\n return result;\n }\n try {\n if (pluginObj.use) {\n pluginObj.use.call(this.context, pluginObj);\n }\n }\n catch (e) {\n e.message = e.message || 'Error during @plugin call';\n return new LessError(e, imports, filename);\n }\n return pluginObj;\n }\n }\n localModule = {\n exports: {},\n pluginManager,\n fileInfo\n };\n registry = functionRegistry.create();\n\n const registerPlugin = function(obj) {\n pluginObj = obj;\n };\n\n try {\n loader = new Function('module', 'require', 'registerPlugin', 'functions', 'tree', 'less', 'fileInfo', contents);\n loader(localModule, this.require(filename), registerPlugin, registry, this.less.tree, this.less, fileInfo);\n }\n catch (e) {\n return new LessError(e, imports, filename);\n }\n\n if (!pluginObj) {\n pluginObj = localModule.exports;\n }\n pluginObj = this.validatePlugin(pluginObj, filename, shortname);\n\n if (pluginObj instanceof LessError) {\n return pluginObj;\n }\n\n if (pluginObj) {\n pluginObj.imports = imports;\n pluginObj.filename = filename;\n\n // For < 3.x (or unspecified minVersion) - setOptions() before install()\n if (!pluginObj.minVersion || this.compareVersion('3.0.0', pluginObj.minVersion) < 0) {\n result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions);\n\n if (result) {\n return result;\n }\n }\n\n // Run on first load\n pluginManager.addPlugin(pluginObj, fileInfo.filename, registry);\n pluginObj.functions = registry.getLocalFunctions();\n\n // Need to call setOptions again because the pluginObj might have functions\n result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions);\n if (result) {\n return result;\n }\n\n // Run every @plugin call\n try {\n if (pluginObj.use) {\n pluginObj.use.call(this.context, pluginObj);\n }\n }\n catch (e) {\n e.message = e.message || 'Error during @plugin call';\n return new LessError(e, imports, filename);\n }\n\n }\n else {\n return new LessError({ message: 'Not a valid plugin' }, imports, filename);\n }\n\n return pluginObj;\n\n }\n\n trySetOptions(plugin, filename, name, options) {\n if (options && !plugin.setOptions) {\n return new LessError({\n message: `Options have been provided but the plugin ${name} does not support any options.`\n });\n }\n try {\n plugin.setOptions && plugin.setOptions(options);\n }\n catch (e) {\n return new LessError(e);\n }\n }\n\n validatePlugin(plugin, filename, name) {\n if (plugin) {\n // support plugins being a function\n // so that the plugin can be more usable programmatically\n if (typeof plugin === 'function') {\n plugin = new plugin();\n }\n\n if (plugin.minVersion) {\n if (this.compareVersion(plugin.minVersion, this.less.version) < 0) {\n return new LessError({\n message: `Plugin ${name} requires version ${this.versionToString(plugin.minVersion)}`\n });\n }\n }\n return plugin;\n }\n return null;\n }\n\n compareVersion(aVersion, bVersion) {\n if (typeof aVersion === 'string') {\n aVersion = aVersion.match(/^(\\d+)\\.?(\\d+)?\\.?(\\d+)?/);\n aVersion.shift();\n }\n for (let i = 0; i < aVersion.length; i++) {\n if (aVersion[i] !== bVersion[i]) {\n return parseInt(aVersion[i]) > parseInt(bVersion[i]) ? -1 : 1;\n }\n }\n return 0;\n }\n\n versionToString(version) {\n let versionString = '';\n for (let i = 0; i < version.length; i++) {\n versionString += (versionString ? '.' : '') + version[i];\n }\n return versionString;\n }\n\n printUsage(plugins) {\n for (let i = 0; i < plugins.length; i++) {\n const plugin = plugins[i];\n if (plugin.printUsage) {\n plugin.printUsage();\n }\n }\n }\n}\n\nexport default AbstractPluginLoader;\n\n","import tree from '../tree';\n\nconst _visitArgs = { visitDeeper: true };\nlet _hasIndexed = false;\n\nfunction _noop(node) {\n return node;\n}\n\nfunction indexNodeTypes(parent, ticker) {\n // add .typeIndex to tree node types for lookup table\n let key, child;\n for (key in parent) { \n /* eslint guard-for-in: 0 */\n child = parent[key];\n switch (typeof child) {\n case 'function':\n // ignore bound functions directly on tree which do not have a prototype\n // or aren't nodes\n if (child.prototype && child.prototype.type) {\n child.prototype.typeIndex = ticker++;\n }\n break;\n case 'object':\n ticker = indexNodeTypes(child, ticker);\n break;\n \n }\n }\n return ticker;\n}\n\nclass Visitor {\n constructor(implementation) {\n this._implementation = implementation;\n this._visitInCache = {};\n this._visitOutCache = {};\n\n if (!_hasIndexed) {\n indexNodeTypes(tree, 1);\n _hasIndexed = true;\n }\n }\n\n visit(node) {\n if (!node) {\n return node;\n }\n\n const nodeTypeIndex = node.typeIndex;\n if (!nodeTypeIndex) {\n // MixinCall args aren't a node type?\n if (node.value && node.value.typeIndex) {\n this.visit(node.value);\n }\n return node;\n }\n\n const impl = this._implementation;\n let func = this._visitInCache[nodeTypeIndex];\n let funcOut = this._visitOutCache[nodeTypeIndex];\n const visitArgs = _visitArgs;\n let fnName;\n\n visitArgs.visitDeeper = true;\n\n if (!func) {\n fnName = `visit${node.type}`;\n func = impl[fnName] || _noop;\n funcOut = impl[`${fnName}Out`] || _noop;\n this._visitInCache[nodeTypeIndex] = func;\n this._visitOutCache[nodeTypeIndex] = funcOut;\n }\n\n if (func !== _noop) {\n const newNode = func.call(impl, node, visitArgs);\n if (node && impl.isReplacing) {\n node = newNode;\n }\n }\n\n if (visitArgs.visitDeeper && node) {\n if (node.length) {\n for (let i = 0, cnt = node.length; i < cnt; i++) {\n if (node[i].accept) {\n node[i].accept(this);\n }\n }\n } else if (node.accept) {\n node.accept(this);\n }\n }\n\n if (funcOut != _noop) {\n funcOut.call(impl, node);\n }\n\n return node;\n }\n\n visitArray(nodes, nonReplacing) {\n if (!nodes) {\n return nodes;\n }\n\n const cnt = nodes.length;\n let i;\n\n // Non-replacing\n if (nonReplacing || !this._implementation.isReplacing) {\n for (i = 0; i < cnt; i++) {\n this.visit(nodes[i]);\n }\n return nodes;\n }\n\n // Replacing\n const out = [];\n for (i = 0; i < cnt; i++) {\n const evald = this.visit(nodes[i]);\n if (evald === undefined) { continue; }\n if (!evald.splice) {\n out.push(evald);\n } else if (evald.length) {\n this.flatten(evald, out);\n }\n }\n return out;\n }\n\n flatten(arr, out) {\n if (!out) {\n out = [];\n }\n\n let cnt, i, item, nestedCnt, j, nestedItem;\n\n for (i = 0, cnt = arr.length; i < cnt; i++) {\n item = arr[i];\n if (item === undefined) {\n continue;\n }\n if (!item.splice) {\n out.push(item);\n continue;\n }\n\n for (j = 0, nestedCnt = item.length; j < nestedCnt; j++) {\n nestedItem = item[j];\n if (nestedItem === undefined) {\n continue;\n }\n if (!nestedItem.splice) {\n out.push(nestedItem);\n } else if (nestedItem.length) {\n this.flatten(nestedItem, out);\n }\n }\n }\n\n return out;\n }\n}\n\nexport default Visitor;\n","class ImportSequencer {\n constructor(onSequencerEmpty) {\n this.imports = [];\n this.variableImports = [];\n this._onSequencerEmpty = onSequencerEmpty;\n this._currentDepth = 0;\n }\n\n addImport(callback) {\n const importSequencer = this,\n importItem = {\n callback,\n args: null,\n isReady: false\n };\n this.imports.push(importItem);\n return function() {\n importItem.args = Array.prototype.slice.call(arguments, 0);\n importItem.isReady = true;\n importSequencer.tryRun();\n };\n }\n\n addVariableImport(callback) {\n this.variableImports.push(callback);\n }\n\n tryRun() {\n this._currentDepth++;\n try {\n while (true) {\n while (this.imports.length > 0) {\n const importItem = this.imports[0];\n if (!importItem.isReady) {\n return;\n }\n this.imports = this.imports.slice(1);\n importItem.callback.apply(null, importItem.args);\n }\n if (this.variableImports.length === 0) {\n break;\n }\n const variableImport = this.variableImports[0];\n this.variableImports = this.variableImports.slice(1);\n variableImport();\n }\n } finally {\n this._currentDepth--;\n }\n if (this._currentDepth === 0 && this._onSequencerEmpty) {\n this._onSequencerEmpty();\n }\n }\n}\n\nexport default ImportSequencer;\n","import contexts from '../contexts';\nimport Visitor from './visitor';\nimport ImportSequencer from './import-sequencer';\nimport * as utils from '../utils';\n\nconst ImportVisitor = function(importer, finish) {\n\n this._visitor = new Visitor(this);\n this._importer = importer;\n this._finish = finish;\n this.context = new contexts.Eval();\n this.importCount = 0;\n this.onceFileDetectionMap = {};\n this.recursionDetector = {};\n this._sequencer = new ImportSequencer(this._onSequencerEmpty.bind(this));\n};\n\nImportVisitor.prototype = {\n isReplacing: false,\n run: function (root) {\n try {\n // process the contents\n this._visitor.visit(root);\n }\n catch (e) {\n this.error = e;\n }\n\n this.isFinished = true;\n this._sequencer.tryRun();\n },\n _onSequencerEmpty: function() {\n if (!this.isFinished) {\n return;\n }\n this._finish(this.error);\n },\n visitImport: function (importNode, visitArgs) {\n const inlineCSS = importNode.options.inline;\n\n if (!importNode.css || inlineCSS) {\n\n const context = new contexts.Eval(this.context, utils.copyArray(this.context.frames));\n const importParent = context.frames[0];\n\n this.importCount++;\n if (importNode.isVariableImport()) {\n this._sequencer.addVariableImport(this.processImportNode.bind(this, importNode, context, importParent));\n } else {\n this.processImportNode(importNode, context, importParent);\n }\n }\n visitArgs.visitDeeper = false;\n },\n processImportNode: function(importNode, context, importParent) {\n let evaldImportNode;\n const inlineCSS = importNode.options.inline;\n\n try {\n evaldImportNode = importNode.evalForImport(context);\n } catch (e) {\n if (!e.filename) { e.index = importNode.getIndex(); e.filename = importNode.fileInfo().filename; }\n // attempt to eval properly and treat as css\n importNode.css = true;\n // if that fails, this error will be thrown\n importNode.error = e;\n }\n\n if (evaldImportNode && (!evaldImportNode.css || inlineCSS)) {\n\n if (evaldImportNode.options.multiple) {\n context.importMultiple = true;\n }\n\n // try appending if we haven't determined if it is css or not\n const tryAppendLessExtension = evaldImportNode.css === undefined;\n\n for (let i = 0; i < importParent.rules.length; i++) {\n if (importParent.rules[i] === importNode) {\n importParent.rules[i] = evaldImportNode;\n break;\n }\n }\n\n const onImported = this.onImported.bind(this, evaldImportNode, context), sequencedOnImported = this._sequencer.addImport(onImported);\n\n this._importer.push(evaldImportNode.getPath(), tryAppendLessExtension, evaldImportNode.fileInfo(),\n evaldImportNode.options, sequencedOnImported);\n } else {\n this.importCount--;\n if (this.isFinished) {\n this._sequencer.tryRun();\n }\n }\n },\n onImported: function (importNode, context, e, root, importedAtRoot, fullPath) {\n if (e) {\n if (!e.filename) {\n e.index = importNode.getIndex(); e.filename = importNode.fileInfo().filename;\n }\n this.error = e;\n }\n\n const importVisitor = this,\n inlineCSS = importNode.options.inline,\n isPlugin = importNode.options.isPlugin,\n isOptional = importNode.options.optional,\n duplicateImport = importedAtRoot || fullPath in importVisitor.recursionDetector;\n\n if (!context.importMultiple) {\n if (duplicateImport) {\n importNode.skip = true;\n } else {\n importNode.skip = function() {\n if (fullPath in importVisitor.onceFileDetectionMap) {\n return true;\n }\n importVisitor.onceFileDetectionMap[fullPath] = true;\n return false;\n };\n }\n }\n\n if (!fullPath && isOptional) {\n importNode.skip = true;\n }\n\n if (root) {\n importNode.root = root;\n importNode.importedFilename = fullPath;\n\n if (!inlineCSS && !isPlugin && (context.importMultiple || !duplicateImport)) {\n importVisitor.recursionDetector[fullPath] = true;\n\n const oldContext = this.context;\n this.context = context;\n try {\n this._visitor.visit(root);\n } catch (e) {\n this.error = e;\n }\n this.context = oldContext;\n }\n }\n\n importVisitor.importCount--;\n\n if (importVisitor.isFinished) {\n importVisitor._sequencer.tryRun();\n }\n },\n visitDeclaration: function (declNode, visitArgs) {\n if (declNode.value.type === 'DetachedRuleset') {\n this.context.frames.unshift(declNode);\n } else {\n visitArgs.visitDeeper = false;\n }\n },\n visitDeclarationOut: function(declNode) {\n if (declNode.value.type === 'DetachedRuleset') {\n this.context.frames.shift();\n }\n },\n visitAtRule: function (atRuleNode, visitArgs) {\n this.context.frames.unshift(atRuleNode);\n },\n visitAtRuleOut: function (atRuleNode) {\n this.context.frames.shift();\n },\n visitMixinDefinition: function (mixinDefinitionNode, visitArgs) {\n this.context.frames.unshift(mixinDefinitionNode);\n },\n visitMixinDefinitionOut: function (mixinDefinitionNode) {\n this.context.frames.shift();\n },\n visitRuleset: function (rulesetNode, visitArgs) {\n this.context.frames.unshift(rulesetNode);\n },\n visitRulesetOut: function (rulesetNode) {\n this.context.frames.shift();\n },\n visitMedia: function (mediaNode, visitArgs) {\n this.context.frames.unshift(mediaNode.rules[0]);\n },\n visitMediaOut: function (mediaNode) {\n this.context.frames.shift();\n }\n};\nexport default ImportVisitor;\n","class SetTreeVisibilityVisitor {\n constructor(visible) {\n this.visible = visible;\n }\n\n run(root) {\n this.visit(root);\n }\n\n visitArray(nodes) {\n if (!nodes) {\n return nodes;\n }\n\n const cnt = nodes.length;\n let i;\n for (i = 0; i < cnt; i++) {\n this.visit(nodes[i]);\n }\n return nodes;\n }\n\n visit(node) {\n if (!node) {\n return node;\n }\n if (node.constructor === Array) {\n return this.visitArray(node);\n }\n\n if (!node.blocksVisibility || node.blocksVisibility()) {\n return node;\n }\n if (this.visible) {\n node.ensureVisibility();\n } else {\n node.ensureInvisibility();\n }\n\n node.accept(this);\n return node;\n }\n}\n\nexport default SetTreeVisibilityVisitor;","import tree from '../tree';\nimport Visitor from './visitor';\nimport logger from '../logger';\nimport * as utils from '../utils';\n\n/* jshint loopfunc:true */\n\nclass ExtendFinderVisitor {\n constructor() {\n this._visitor = new Visitor(this);\n this.contexts = [];\n this.allExtendsStack = [[]];\n }\n\n run(root) {\n root = this._visitor.visit(root);\n root.allExtends = this.allExtendsStack[0];\n return root;\n }\n\n visitDeclaration(declNode, visitArgs) {\n visitArgs.visitDeeper = false;\n }\n\n visitMixinDefinition(mixinDefinitionNode, visitArgs) {\n visitArgs.visitDeeper = false;\n }\n\n visitRuleset(rulesetNode, visitArgs) {\n if (rulesetNode.root) {\n return;\n }\n\n let i;\n let j;\n let extend;\n const allSelectorsExtendList = [];\n let extendList;\n\n // get &:extend(.a); rules which apply to all selectors in this ruleset\n const rules = rulesetNode.rules, ruleCnt = rules ? rules.length : 0;\n for (i = 0; i < ruleCnt; i++) {\n if (rulesetNode.rules[i] instanceof tree.Extend) {\n allSelectorsExtendList.push(rules[i]);\n rulesetNode.extendOnEveryPath = true;\n }\n }\n\n // now find every selector and apply the extends that apply to all extends\n // and the ones which apply to an individual extend\n const paths = rulesetNode.paths;\n for (i = 0; i < paths.length; i++) {\n const selectorPath = paths[i], selector = selectorPath[selectorPath.length - 1], selExtendList = selector.extendList;\n\n extendList = selExtendList ? utils.copyArray(selExtendList).concat(allSelectorsExtendList)\n : allSelectorsExtendList;\n\n if (extendList) {\n extendList = extendList.map(function(allSelectorsExtend) {\n return allSelectorsExtend.clone();\n });\n }\n\n for (j = 0; j < extendList.length; j++) {\n this.foundExtends = true;\n extend = extendList[j];\n extend.findSelfSelectors(selectorPath);\n extend.ruleset = rulesetNode;\n if (j === 0) { extend.firstExtendOnThisSelectorPath = true; }\n this.allExtendsStack[this.allExtendsStack.length - 1].push(extend);\n }\n }\n\n this.contexts.push(rulesetNode.selectors);\n }\n\n visitRulesetOut(rulesetNode) {\n if (!rulesetNode.root) {\n this.contexts.length = this.contexts.length - 1;\n }\n }\n\n visitMedia(mediaNode, visitArgs) {\n mediaNode.allExtends = [];\n this.allExtendsStack.push(mediaNode.allExtends);\n }\n\n visitMediaOut(mediaNode) {\n this.allExtendsStack.length = this.allExtendsStack.length - 1;\n }\n\n visitAtRule(atRuleNode, visitArgs) {\n atRuleNode.allExtends = [];\n this.allExtendsStack.push(atRuleNode.allExtends);\n }\n\n visitAtRuleOut(atRuleNode) {\n this.allExtendsStack.length = this.allExtendsStack.length - 1;\n }\n}\n\nclass ProcessExtendsVisitor {\n constructor() {\n this._visitor = new Visitor(this);\n }\n\n run(root) {\n const extendFinder = new ExtendFinderVisitor();\n this.extendIndices = {};\n extendFinder.run(root);\n if (!extendFinder.foundExtends) { return root; }\n root.allExtends = root.allExtends.concat(this.doExtendChaining(root.allExtends, root.allExtends));\n this.allExtendsStack = [root.allExtends];\n const newRoot = this._visitor.visit(root);\n this.checkExtendsForNonMatched(root.allExtends);\n return newRoot;\n }\n\n checkExtendsForNonMatched(extendList) {\n const indices = this.extendIndices;\n extendList.filter(function(extend) {\n return !extend.hasFoundMatches && extend.parent_ids.length == 1;\n }).forEach(function(extend) {\n let selector = '_unknown_';\n try {\n selector = extend.selector.toCSS({});\n }\n catch (_) {}\n\n if (!indices[`${extend.index} ${selector}`]) {\n indices[`${extend.index} ${selector}`] = true;\n logger.warn(`extend '${selector}' has no matches`);\n }\n });\n }\n\n doExtendChaining(extendsList, extendsListTarget, iterationCount) {\n //\n // chaining is different from normal extension.. if we extend an extend then we are not just copying, altering\n // and pasting the selector we would do normally, but we are also adding an extend with the same target selector\n // this means this new extend can then go and alter other extends\n //\n // this method deals with all the chaining work - without it, extend is flat and doesn't work on other extend selectors\n // this is also the most expensive.. and a match on one selector can cause an extension of a selector we had already\n // processed if we look at each selector at a time, as is done in visitRuleset\n\n let extendIndex;\n\n let targetExtendIndex;\n let matches;\n const extendsToAdd = [];\n let newSelector;\n const extendVisitor = this;\n let selectorPath;\n let extend;\n let targetExtend;\n let newExtend;\n\n iterationCount = iterationCount || 0;\n\n // loop through comparing every extend with every target extend.\n // a target extend is the one on the ruleset we are looking at copy/edit/pasting in place\n // e.g. .a:extend(.b) {} and .b:extend(.c) {} then the first extend extends the second one\n // and the second is the target.\n // the separation into two lists allows us to process a subset of chains with a bigger set, as is the\n // case when processing media queries\n for (extendIndex = 0; extendIndex < extendsList.length; extendIndex++) {\n for (targetExtendIndex = 0; targetExtendIndex < extendsListTarget.length; targetExtendIndex++) {\n\n extend = extendsList[extendIndex];\n targetExtend = extendsListTarget[targetExtendIndex];\n\n // look for circular references\n if ( extend.parent_ids.indexOf( targetExtend.object_id ) >= 0 ) { continue; }\n\n // find a match in the target extends self selector (the bit before :extend)\n selectorPath = [targetExtend.selfSelectors[0]];\n matches = extendVisitor.findMatch(extend, selectorPath);\n\n if (matches.length) {\n extend.hasFoundMatches = true;\n\n // we found a match, so for each self selector..\n extend.selfSelectors.forEach(function(selfSelector) {\n const info = targetExtend.visibilityInfo();\n\n // process the extend as usual\n newSelector = extendVisitor.extendSelector(matches, selectorPath, selfSelector, extend.isVisible());\n\n // but now we create a new extend from it\n newExtend = new(tree.Extend)(targetExtend.selector, targetExtend.option, 0, targetExtend.fileInfo(), info);\n newExtend.selfSelectors = newSelector;\n\n // add the extend onto the list of extends for that selector\n newSelector[newSelector.length - 1].extendList = [newExtend];\n\n // record that we need to add it.\n extendsToAdd.push(newExtend);\n newExtend.ruleset = targetExtend.ruleset;\n\n // remember its parents for circular references\n newExtend.parent_ids = newExtend.parent_ids.concat(targetExtend.parent_ids, extend.parent_ids);\n\n // only process the selector once.. if we have :extend(.a,.b) then multiple\n // extends will look at the same selector path, so when extending\n // we know that any others will be duplicates in terms of what is added to the css\n if (targetExtend.firstExtendOnThisSelectorPath) {\n newExtend.firstExtendOnThisSelectorPath = true;\n targetExtend.ruleset.paths.push(newSelector);\n }\n });\n }\n }\n }\n\n if (extendsToAdd.length) {\n // try to detect circular references to stop a stack overflow.\n // may no longer be needed.\n this.extendChainCount++;\n if (iterationCount > 100) {\n let selectorOne = '{unable to calculate}';\n let selectorTwo = '{unable to calculate}';\n try {\n selectorOne = extendsToAdd[0].selfSelectors[0].toCSS();\n selectorTwo = extendsToAdd[0].selector.toCSS();\n }\n catch (e) {}\n throw { message: `extend circular reference detected. One of the circular extends is currently:${selectorOne}:extend(${selectorTwo})`};\n }\n\n // now process the new extends on the existing rules so that we can handle a extending b extending c extending\n // d extending e...\n return extendsToAdd.concat(extendVisitor.doExtendChaining(extendsToAdd, extendsListTarget, iterationCount + 1));\n } else {\n return extendsToAdd;\n }\n }\n\n visitDeclaration(ruleNode, visitArgs) {\n visitArgs.visitDeeper = false;\n }\n\n visitMixinDefinition(mixinDefinitionNode, visitArgs) {\n visitArgs.visitDeeper = false;\n }\n\n visitSelector(selectorNode, visitArgs) {\n visitArgs.visitDeeper = false;\n }\n\n visitRuleset(rulesetNode, visitArgs) {\n if (rulesetNode.root) {\n return;\n }\n let matches;\n let pathIndex;\n let extendIndex;\n const allExtends = this.allExtendsStack[this.allExtendsStack.length - 1];\n const selectorsToAdd = [];\n const extendVisitor = this;\n let selectorPath;\n\n // look at each selector path in the ruleset, find any extend matches and then copy, find and replace\n\n for (extendIndex = 0; extendIndex < allExtends.length; extendIndex++) {\n for (pathIndex = 0; pathIndex < rulesetNode.paths.length; pathIndex++) {\n selectorPath = rulesetNode.paths[pathIndex];\n\n // extending extends happens initially, before the main pass\n if (rulesetNode.extendOnEveryPath) { continue; }\n const extendList = selectorPath[selectorPath.length - 1].extendList;\n if (extendList && extendList.length) { continue; }\n\n matches = this.findMatch(allExtends[extendIndex], selectorPath);\n\n if (matches.length) {\n allExtends[extendIndex].hasFoundMatches = true;\n\n allExtends[extendIndex].selfSelectors.forEach(function(selfSelector) {\n let extendedSelectors;\n extendedSelectors = extendVisitor.extendSelector(matches, selectorPath, selfSelector, allExtends[extendIndex].isVisible());\n selectorsToAdd.push(extendedSelectors);\n });\n }\n }\n }\n rulesetNode.paths = rulesetNode.paths.concat(selectorsToAdd);\n }\n\n findMatch(extend, haystackSelectorPath) {\n //\n // look through the haystack selector path to try and find the needle - extend.selector\n // returns an array of selector matches that can then be replaced\n //\n let haystackSelectorIndex;\n\n let hackstackSelector;\n let hackstackElementIndex;\n let haystackElement;\n let targetCombinator;\n let i;\n const extendVisitor = this;\n const needleElements = extend.selector.elements;\n const potentialMatches = [];\n let potentialMatch;\n const matches = [];\n\n // loop through the haystack elements\n for (haystackSelectorIndex = 0; haystackSelectorIndex < haystackSelectorPath.length; haystackSelectorIndex++) {\n hackstackSelector = haystackSelectorPath[haystackSelectorIndex];\n\n for (hackstackElementIndex = 0; hackstackElementIndex < hackstackSelector.elements.length; hackstackElementIndex++) {\n\n haystackElement = hackstackSelector.elements[hackstackElementIndex];\n\n // if we allow elements before our match we can add a potential match every time. otherwise only at the first element.\n if (extend.allowBefore || (haystackSelectorIndex === 0 && hackstackElementIndex === 0)) {\n potentialMatches.push({pathIndex: haystackSelectorIndex, index: hackstackElementIndex, matched: 0,\n initialCombinator: haystackElement.combinator});\n }\n\n for (i = 0; i < potentialMatches.length; i++) {\n potentialMatch = potentialMatches[i];\n\n // selectors add \" \" onto the first element. When we use & it joins the selectors together, but if we don't\n // then each selector in haystackSelectorPath has a space before it added in the toCSS phase. so we need to\n // work out what the resulting combinator will be\n targetCombinator = haystackElement.combinator.value;\n if (targetCombinator === '' && hackstackElementIndex === 0) {\n targetCombinator = ' ';\n }\n\n // if we don't match, null our match to indicate failure\n if (!extendVisitor.isElementValuesEqual(needleElements[potentialMatch.matched].value, haystackElement.value) ||\n (potentialMatch.matched > 0 && needleElements[potentialMatch.matched].combinator.value !== targetCombinator)) {\n potentialMatch = null;\n } else {\n potentialMatch.matched++;\n }\n\n // if we are still valid and have finished, test whether we have elements after and whether these are allowed\n if (potentialMatch) {\n potentialMatch.finished = potentialMatch.matched === needleElements.length;\n if (potentialMatch.finished &&\n (!extend.allowAfter &&\n (hackstackElementIndex + 1 < hackstackSelector.elements.length || haystackSelectorIndex + 1 < haystackSelectorPath.length))) {\n potentialMatch = null;\n }\n }\n // if null we remove, if not, we are still valid, so either push as a valid match or continue\n if (potentialMatch) {\n if (potentialMatch.finished) {\n potentialMatch.length = needleElements.length;\n potentialMatch.endPathIndex = haystackSelectorIndex;\n potentialMatch.endPathElementIndex = hackstackElementIndex + 1; // index after end of match\n potentialMatches.length = 0; // we don't allow matches to overlap, so start matching again\n matches.push(potentialMatch);\n }\n } else {\n potentialMatches.splice(i, 1);\n i--;\n }\n }\n }\n }\n return matches;\n }\n\n isElementValuesEqual(elementValue1, elementValue2) {\n if (typeof elementValue1 === 'string' || typeof elementValue2 === 'string') {\n return elementValue1 === elementValue2;\n }\n if (elementValue1 instanceof tree.Attribute) {\n if (elementValue1.op !== elementValue2.op || elementValue1.key !== elementValue2.key) {\n return false;\n }\n if (!elementValue1.value || !elementValue2.value) {\n if (elementValue1.value || elementValue2.value) {\n return false;\n }\n return true;\n }\n elementValue1 = elementValue1.value.value || elementValue1.value;\n elementValue2 = elementValue2.value.value || elementValue2.value;\n return elementValue1 === elementValue2;\n }\n elementValue1 = elementValue1.value;\n elementValue2 = elementValue2.value;\n if (elementValue1 instanceof tree.Selector) {\n if (!(elementValue2 instanceof tree.Selector) || elementValue1.elements.length !== elementValue2.elements.length) {\n return false;\n }\n for (let i = 0; i < elementValue1.elements.length; i++) {\n if (elementValue1.elements[i].combinator.value !== elementValue2.elements[i].combinator.value) {\n if (i !== 0 || (elementValue1.elements[i].combinator.value || ' ') !== (elementValue2.elements[i].combinator.value || ' ')) {\n return false;\n }\n }\n if (!this.isElementValuesEqual(elementValue1.elements[i].value, elementValue2.elements[i].value)) {\n return false;\n }\n }\n return true;\n }\n return false;\n }\n\n extendSelector(matches, selectorPath, replacementSelector, isVisible) {\n\n // for a set of matches, replace each match with the replacement selector\n\n let currentSelectorPathIndex = 0, currentSelectorPathElementIndex = 0, path = [], matchIndex, selector, firstElement, match, newElements;\n\n for (matchIndex = 0; matchIndex < matches.length; matchIndex++) {\n match = matches[matchIndex];\n selector = selectorPath[match.pathIndex];\n firstElement = new tree.Element(\n match.initialCombinator,\n replacementSelector.elements[0].value,\n replacementSelector.elements[0].isVariable,\n replacementSelector.elements[0].getIndex(),\n replacementSelector.elements[0].fileInfo()\n );\n\n if (match.pathIndex > currentSelectorPathIndex && currentSelectorPathElementIndex > 0) {\n path[path.length - 1].elements = path[path.length - 1]\n .elements.concat(selectorPath[currentSelectorPathIndex].elements.slice(currentSelectorPathElementIndex));\n currentSelectorPathElementIndex = 0;\n currentSelectorPathIndex++;\n }\n\n newElements = selector.elements\n .slice(currentSelectorPathElementIndex, match.index)\n .concat([firstElement])\n .concat(replacementSelector.elements.slice(1));\n\n if (currentSelectorPathIndex === match.pathIndex && matchIndex > 0) {\n path[path.length - 1].elements =\n path[path.length - 1].elements.concat(newElements);\n } else {\n path = path.concat(selectorPath.slice(currentSelectorPathIndex, match.pathIndex));\n\n path.push(new tree.Selector(\n newElements\n ));\n }\n currentSelectorPathIndex = match.endPathIndex;\n currentSelectorPathElementIndex = match.endPathElementIndex;\n if (currentSelectorPathElementIndex >= selectorPath[currentSelectorPathIndex].elements.length) {\n currentSelectorPathElementIndex = 0;\n currentSelectorPathIndex++;\n }\n }\n\n if (currentSelectorPathIndex < selectorPath.length && currentSelectorPathElementIndex > 0) {\n path[path.length - 1].elements = path[path.length - 1]\n .elements.concat(selectorPath[currentSelectorPathIndex].elements.slice(currentSelectorPathElementIndex));\n currentSelectorPathIndex++;\n }\n\n path = path.concat(selectorPath.slice(currentSelectorPathIndex, selectorPath.length));\n path = path.map(function (currentValue) {\n // we can re-use elements here, because the visibility property matters only for selectors\n const derived = currentValue.createDerived(currentValue.elements);\n if (isVisible) {\n derived.ensureVisibility();\n } else {\n derived.ensureInvisibility();\n }\n return derived;\n });\n return path;\n }\n\n visitMedia(mediaNode, visitArgs) {\n let newAllExtends = mediaNode.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length - 1]);\n newAllExtends = newAllExtends.concat(this.doExtendChaining(newAllExtends, mediaNode.allExtends));\n this.allExtendsStack.push(newAllExtends);\n }\n\n visitMediaOut(mediaNode) {\n const lastIndex = this.allExtendsStack.length - 1;\n this.allExtendsStack.length = lastIndex;\n }\n\n visitAtRule(atRuleNode, visitArgs) {\n let newAllExtends = atRuleNode.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length - 1]);\n newAllExtends = newAllExtends.concat(this.doExtendChaining(newAllExtends, atRuleNode.allExtends));\n this.allExtendsStack.push(newAllExtends);\n }\n\n visitAtRuleOut(atRuleNode) {\n const lastIndex = this.allExtendsStack.length - 1;\n this.allExtendsStack.length = lastIndex;\n }\n}\n\nexport default ProcessExtendsVisitor;\n","import Visitor from './visitor';\n\nclass JoinSelectorVisitor {\n constructor() {\n this.contexts = [[]];\n this._visitor = new Visitor(this);\n }\n\n run(root) {\n return this._visitor.visit(root);\n }\n\n visitDeclaration(declNode, visitArgs) {\n visitArgs.visitDeeper = false;\n }\n\n visitMixinDefinition(mixinDefinitionNode, visitArgs) {\n visitArgs.visitDeeper = false;\n }\n\n visitRuleset(rulesetNode, visitArgs) {\n const context = this.contexts[this.contexts.length - 1];\n const paths = [];\n let selectors;\n\n this.contexts.push(paths);\n\n if (!rulesetNode.root) {\n selectors = rulesetNode.selectors;\n if (selectors) {\n selectors = selectors.filter(function(selector) { return selector.getIsOutput(); });\n rulesetNode.selectors = selectors.length ? selectors : (selectors = null);\n if (selectors) { rulesetNode.joinSelectors(paths, context, selectors); }\n }\n if (!selectors) { rulesetNode.rules = null; }\n rulesetNode.paths = paths;\n }\n }\n\n visitRulesetOut(rulesetNode) {\n this.contexts.length = this.contexts.length - 1;\n }\n\n visitMedia(mediaNode, visitArgs) {\n const context = this.contexts[this.contexts.length - 1];\n mediaNode.rules[0].root = (context.length === 0 || context[0].multiMedia);\n }\n\n visitAtRule(atRuleNode, visitArgs) {\n const context = this.contexts[this.contexts.length - 1];\n if (atRuleNode.rules && atRuleNode.rules.length) {\n atRuleNode.rules[0].root = (atRuleNode.isRooted || context.length === 0 || null);\n }\n }\n}\n\nexport default JoinSelectorVisitor;\n","import tree from '../tree';\nimport Visitor from './visitor';\n\nclass CSSVisitorUtils {\n constructor(context) {\n this._visitor = new Visitor(this);\n this._context = context;\n }\n\n containsSilentNonBlockedChild(bodyRules) {\n let rule;\n if (!bodyRules) {\n return false;\n }\n for (let r = 0; r < bodyRules.length; r++) {\n rule = bodyRules[r];\n if (rule.isSilent && rule.isSilent(this._context) && !rule.blocksVisibility()) {\n // the atrule contains something that was referenced (likely by extend)\n // therefore it needs to be shown in output too\n return true;\n }\n }\n return false;\n }\n\n keepOnlyVisibleChilds(owner) {\n if (owner && owner.rules) {\n owner.rules = owner.rules.filter(thing => thing.isVisible());\n }\n }\n\n isEmpty(owner) {\n return (owner && owner.rules) \n ? (owner.rules.length === 0) : true;\n }\n\n hasVisibleSelector(rulesetNode) {\n return (rulesetNode && rulesetNode.paths)\n ? (rulesetNode.paths.length > 0) : false;\n }\n\n resolveVisibility(node, originalRules) {\n if (!node.blocksVisibility()) {\n if (this.isEmpty(node) && !this.containsSilentNonBlockedChild(originalRules)) {\n return ;\n }\n\n return node;\n }\n\n const compiledRulesBody = node.rules[0];\n this.keepOnlyVisibleChilds(compiledRulesBody);\n\n if (this.isEmpty(compiledRulesBody)) {\n return ;\n }\n\n node.ensureVisibility();\n node.removeVisibilityBlock();\n\n return node;\n }\n\n isVisibleRuleset(rulesetNode) {\n if (rulesetNode.firstRoot) {\n return true;\n }\n\n if (this.isEmpty(rulesetNode)) {\n return false;\n }\n\n if (!rulesetNode.root && !this.hasVisibleSelector(rulesetNode)) {\n return false;\n }\n\n return true;\n }\n}\n\nconst ToCSSVisitor = function(context) {\n this._visitor = new Visitor(this);\n this._context = context;\n this.utils = new CSSVisitorUtils(context);\n};\n\nToCSSVisitor.prototype = {\n isReplacing: true,\n run: function (root) {\n return this._visitor.visit(root);\n },\n\n visitDeclaration: function (declNode, visitArgs) {\n if (declNode.blocksVisibility() || declNode.variable) {\n return;\n }\n return declNode;\n },\n\n visitMixinDefinition: function (mixinNode, visitArgs) {\n // mixin definitions do not get eval'd - this means they keep state\n // so we have to clear that state here so it isn't used if toCSS is called twice\n mixinNode.frames = [];\n },\n\n visitExtend: function (extendNode, visitArgs) {\n },\n\n visitComment: function (commentNode, visitArgs) {\n if (commentNode.blocksVisibility() || commentNode.isSilent(this._context)) {\n return;\n }\n return commentNode;\n },\n\n visitMedia: function(mediaNode, visitArgs) {\n const originalRules = mediaNode.rules[0].rules;\n mediaNode.accept(this._visitor);\n visitArgs.visitDeeper = false;\n\n return this.utils.resolveVisibility(mediaNode, originalRules);\n },\n\n visitImport: function (importNode, visitArgs) {\n if (importNode.blocksVisibility()) {\n return ;\n }\n return importNode;\n },\n\n visitAtRule: function(atRuleNode, visitArgs) {\n if (atRuleNode.rules && atRuleNode.rules.length) {\n return this.visitAtRuleWithBody(atRuleNode, visitArgs);\n } else {\n return this.visitAtRuleWithoutBody(atRuleNode, visitArgs);\n }\n },\n\n visitAnonymous: function(anonymousNode, visitArgs) {\n if (!anonymousNode.blocksVisibility()) {\n anonymousNode.accept(this._visitor);\n return anonymousNode;\n }\n },\n\n visitAtRuleWithBody: function(atRuleNode, visitArgs) {\n // if there is only one nested ruleset and that one has no path, then it is\n // just fake ruleset\n function hasFakeRuleset(atRuleNode) {\n const bodyRules = atRuleNode.rules;\n return bodyRules.length === 1 && (!bodyRules[0].paths || bodyRules[0].paths.length === 0);\n }\n function getBodyRules(atRuleNode) {\n const nodeRules = atRuleNode.rules;\n if (hasFakeRuleset(atRuleNode)) {\n return nodeRules[0].rules;\n }\n\n return nodeRules;\n }\n // it is still true that it is only one ruleset in array\n // this is last such moment\n // process childs\n const originalRules = getBodyRules(atRuleNode);\n atRuleNode.accept(this._visitor);\n visitArgs.visitDeeper = false;\n\n if (!this.utils.isEmpty(atRuleNode)) {\n this._mergeRules(atRuleNode.rules[0].rules);\n }\n\n return this.utils.resolveVisibility(atRuleNode, originalRules);\n },\n\n visitAtRuleWithoutBody: function(atRuleNode, visitArgs) {\n if (atRuleNode.blocksVisibility()) {\n return;\n }\n\n if (atRuleNode.name === '@charset') {\n // Only output the debug info together with subsequent @charset definitions\n // a comment (or @media statement) before the actual @charset atrule would\n // be considered illegal css as it has to be on the first line\n if (this.charset) {\n if (atRuleNode.debugInfo) {\n const comment = new tree.Comment(`/* ${atRuleNode.toCSS(this._context).replace(/\\n/g, '')} */\\n`);\n comment.debugInfo = atRuleNode.debugInfo;\n return this._visitor.visit(comment);\n }\n return;\n }\n this.charset = true;\n }\n\n return atRuleNode;\n },\n\n checkValidNodes: function(rules, isRoot) {\n if (!rules) {\n return;\n }\n\n for (let i = 0; i < rules.length; i++) {\n const ruleNode = rules[i];\n if (isRoot && ruleNode instanceof tree.Declaration && !ruleNode.variable) {\n throw { message: 'Properties must be inside selector blocks. They cannot be in the root',\n index: ruleNode.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename};\n }\n if (ruleNode instanceof tree.Call) {\n throw { message: `Function '${ruleNode.name}' did not return a root node`,\n index: ruleNode.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename};\n }\n if (ruleNode.type && !ruleNode.allowRoot) {\n throw { message: `${ruleNode.type} node returned by a function is not valid here`,\n index: ruleNode.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename};\n }\n }\n },\n\n visitRuleset: function (rulesetNode, visitArgs) {\n // at this point rulesets are nested into each other\n let rule;\n\n const rulesets = [];\n\n this.checkValidNodes(rulesetNode.rules, rulesetNode.firstRoot);\n\n if (!rulesetNode.root) {\n // remove invisible paths\n this._compileRulesetPaths(rulesetNode);\n\n // remove rulesets from this ruleset body and compile them separately\n const nodeRules = rulesetNode.rules;\n\n let nodeRuleCnt = nodeRules ? nodeRules.length : 0;\n for (let i = 0; i < nodeRuleCnt; ) {\n rule = nodeRules[i];\n if (rule && rule.rules) {\n // visit because we are moving them out from being a child\n rulesets.push(this._visitor.visit(rule));\n nodeRules.splice(i, 1);\n nodeRuleCnt--;\n continue;\n }\n i++;\n }\n // accept the visitor to remove rules and refactor itself\n // then we can decide nogw whether we want it or not\n // compile body\n if (nodeRuleCnt > 0) {\n rulesetNode.accept(this._visitor);\n } else {\n rulesetNode.rules = null;\n }\n visitArgs.visitDeeper = false;\n } else { // if (! rulesetNode.root) {\n rulesetNode.accept(this._visitor);\n visitArgs.visitDeeper = false;\n }\n\n if (rulesetNode.rules) {\n this._mergeRules(rulesetNode.rules);\n this._removeDuplicateRules(rulesetNode.rules);\n }\n\n // now decide whether we keep the ruleset\n if (this.utils.isVisibleRuleset(rulesetNode)) {\n rulesetNode.ensureVisibility();\n rulesets.splice(0, 0, rulesetNode);\n }\n\n if (rulesets.length === 1) {\n return rulesets[0];\n }\n return rulesets;\n },\n\n _compileRulesetPaths: function(rulesetNode) {\n if (rulesetNode.paths) {\n rulesetNode.paths = rulesetNode.paths\n .filter(p => {\n let i;\n if (p[0].elements[0].combinator.value === ' ') {\n p[0].elements[0].combinator = new(tree.Combinator)('');\n }\n for (i = 0; i < p.length; i++) {\n if (p[i].isVisible() && p[i].getIsOutput()) {\n return true;\n }\n }\n return false;\n });\n }\n },\n\n _removeDuplicateRules: function(rules) {\n if (!rules) { return; }\n\n // remove duplicates\n const ruleCache = {};\n\n let ruleList;\n let rule;\n let i;\n\n for (i = rules.length - 1; i >= 0 ; i--) {\n rule = rules[i];\n if (rule instanceof tree.Declaration) {\n if (!ruleCache[rule.name]) {\n ruleCache[rule.name] = rule;\n } else {\n ruleList = ruleCache[rule.name];\n if (ruleList instanceof tree.Declaration) {\n ruleList = ruleCache[rule.name] = [ruleCache[rule.name].toCSS(this._context)];\n }\n const ruleCSS = rule.toCSS(this._context);\n if (ruleList.indexOf(ruleCSS) !== -1) {\n rules.splice(i, 1);\n } else {\n ruleList.push(ruleCSS);\n }\n }\n }\n }\n },\n\n _mergeRules: function(rules) {\n if (!rules) {\n return; \n }\n\n const groups = {};\n const groupsArr = [];\n\n for (let i = 0; i < rules.length; i++) {\n const rule = rules[i];\n if (rule.merge) {\n const key = rule.name;\n groups[key] ? rules.splice(i--, 1) : \n groupsArr.push(groups[key] = []);\n groups[key].push(rule);\n }\n }\n\n groupsArr.forEach(group => {\n if (group.length > 0) {\n const result = group[0];\n let space = [];\n const comma = [new tree.Expression(space)];\n group.forEach(rule => {\n if ((rule.merge === '+') && (space.length > 0)) {\n comma.push(new tree.Expression(space = []));\n }\n space.push(rule.value);\n result.important = result.important || rule.important;\n });\n result.value = new tree.Value(comma);\n }\n });\n }\n};\n\nexport default ToCSSVisitor;\n","import Visitor from './visitor';\nimport ImportVisitor from './import-visitor';\nimport MarkVisibleSelectorsVisitor from './set-tree-visibility-visitor';\nimport ExtendVisitor from './extend-visitor';\nimport JoinSelectorVisitor from './join-selector-visitor';\nimport ToCSSVisitor from './to-css-visitor';\n\nexport default {\n Visitor,\n ImportVisitor,\n MarkVisibleSelectorsVisitor,\n ExtendVisitor,\n JoinSelectorVisitor,\n ToCSSVisitor\n};\n","import chunker from './chunker';\n\nexport default () => {\n let // Less input string\n input;\n\n let // current chunk\n j;\n\n const // holds state for backtracking\n saveStack = [];\n\n let // furthest index the parser has gone to\n furthest;\n\n let // if this is furthest we got to, this is the probably cause\n furthestPossibleErrorMessage;\n\n let // chunkified input\n chunks;\n\n let // current chunk\n current;\n\n let // index of current chunk, in `input`\n currentPos;\n\n const parserInput = {};\n const CHARCODE_SPACE = 32;\n const CHARCODE_TAB = 9;\n const CHARCODE_LF = 10;\n const CHARCODE_CR = 13;\n const CHARCODE_PLUS = 43;\n const CHARCODE_COMMA = 44;\n const CHARCODE_FORWARD_SLASH = 47;\n const CHARCODE_9 = 57;\n\n function skipWhitespace(length) {\n const oldi = parserInput.i;\n const oldj = j;\n const curr = parserInput.i - currentPos;\n const endIndex = parserInput.i + current.length - curr;\n const mem = (parserInput.i += length);\n const inp = input;\n let c;\n let nextChar;\n let comment;\n\n for (; parserInput.i < endIndex; parserInput.i++) {\n c = inp.charCodeAt(parserInput.i);\n\n if (parserInput.autoCommentAbsorb && c === CHARCODE_FORWARD_SLASH) {\n nextChar = inp.charAt(parserInput.i + 1);\n if (nextChar === '/') {\n comment = {index: parserInput.i, isLineComment: true};\n let nextNewLine = inp.indexOf('\\n', parserInput.i + 2);\n if (nextNewLine < 0) {\n nextNewLine = endIndex;\n }\n parserInput.i = nextNewLine;\n comment.text = inp.substr(comment.index, parserInput.i - comment.index);\n parserInput.commentStore.push(comment);\n continue;\n } else if (nextChar === '*') {\n const nextStarSlash = inp.indexOf('*/', parserInput.i + 2);\n if (nextStarSlash >= 0) {\n comment = {\n index: parserInput.i,\n text: inp.substr(parserInput.i, nextStarSlash + 2 - parserInput.i),\n isLineComment: false\n };\n parserInput.i += comment.text.length - 1;\n parserInput.commentStore.push(comment);\n continue;\n }\n }\n break;\n }\n\n if ((c !== CHARCODE_SPACE) && (c !== CHARCODE_LF) && (c !== CHARCODE_TAB) && (c !== CHARCODE_CR)) {\n break;\n }\n }\n\n current = current.slice(length + parserInput.i - mem + curr);\n currentPos = parserInput.i;\n\n if (!current.length) {\n if (j < chunks.length - 1) {\n current = chunks[++j];\n skipWhitespace(0); // skip space at the beginning of a chunk\n return true; // things changed\n }\n parserInput.finished = true;\n }\n\n return oldi !== parserInput.i || oldj !== j;\n }\n\n parserInput.save = () => {\n currentPos = parserInput.i;\n saveStack.push( { current, i: parserInput.i, j });\n };\n parserInput.restore = possibleErrorMessage => {\n\n if (parserInput.i > furthest || (parserInput.i === furthest && possibleErrorMessage && !furthestPossibleErrorMessage)) {\n furthest = parserInput.i;\n furthestPossibleErrorMessage = possibleErrorMessage;\n }\n const state = saveStack.pop();\n current = state.current;\n currentPos = parserInput.i = state.i;\n j = state.j;\n };\n parserInput.forget = () => {\n saveStack.pop();\n };\n parserInput.isWhitespace = offset => {\n const pos = parserInput.i + (offset || 0);\n const code = input.charCodeAt(pos);\n return (code === CHARCODE_SPACE || code === CHARCODE_CR || code === CHARCODE_TAB || code === CHARCODE_LF);\n };\n\n // Specialization of $(tok)\n parserInput.$re = tok => {\n if (parserInput.i > currentPos) {\n current = current.slice(parserInput.i - currentPos);\n currentPos = parserInput.i;\n }\n\n const m = tok.exec(current);\n if (!m) {\n return null;\n }\n\n skipWhitespace(m[0].length);\n if (typeof m === 'string') {\n return m;\n }\n\n return m.length === 1 ? m[0] : m;\n };\n\n parserInput.$char = tok => {\n if (input.charAt(parserInput.i) !== tok) {\n return null;\n }\n skipWhitespace(1);\n return tok;\n };\n\n parserInput.$str = tok => {\n const tokLength = tok.length;\n\n // https://jsperf.com/string-startswith/21\n for (let i = 0; i < tokLength; i++) {\n if (input.charAt(parserInput.i + i) !== tok.charAt(i)) {\n return null;\n }\n }\n\n skipWhitespace(tokLength);\n return tok;\n };\n\n parserInput.$quoted = loc => {\n const pos = loc || parserInput.i;\n const startChar = input.charAt(pos);\n\n if (startChar !== '\\'' && startChar !== '\"') {\n return;\n }\n const length = input.length;\n const currentPosition = pos;\n\n for (let i = 1; i + currentPosition < length; i++) {\n const nextChar = input.charAt(i + currentPosition);\n switch (nextChar) {\n case '\\\\':\n i++;\n continue;\n case '\\r':\n case '\\n':\n break;\n case startChar:\n const str = input.substr(currentPosition, i + 1);\n if (!loc && loc !== 0) {\n skipWhitespace(i + 1);\n return str\n }\n return [startChar, str];\n default:\n }\n }\n return null;\n };\n\n /**\n * Permissive parsing. Ignores everything except matching {} [] () and quotes\n * until matching token (outside of blocks)\n */\n parserInput.$parseUntil = tok => {\n let quote = '';\n let returnVal = null;\n let inComment = false;\n let blockDepth = 0;\n const blockStack = [];\n const parseGroups = [];\n const length = input.length;\n const startPos = parserInput.i;\n let lastPos = parserInput.i;\n let i = parserInput.i;\n let loop = true;\n let testChar;\n\n if (typeof tok === 'string') {\n testChar = char => char === tok\n } else {\n testChar = char => tok.test(char)\n }\n\n do {\n let prevChar;\n let nextChar = input.charAt(i);\n if (blockDepth === 0 && testChar(nextChar)) {\n returnVal = input.substr(lastPos, i - lastPos);\n if (returnVal) {\n parseGroups.push(returnVal);\n }\n else {\n parseGroups.push(' ');\n }\n returnVal = parseGroups;\n skipWhitespace(i - startPos);\n loop = false\n } else {\n if (inComment) {\n if (nextChar === '*' && \n input.charAt(i + 1) === '/') {\n i++;\n blockDepth--;\n inComment = false;\n }\n i++;\n continue;\n }\n switch (nextChar) {\n case '\\\\':\n i++;\n nextChar = input.charAt(i);\n parseGroups.push(input.substr(lastPos, i - lastPos + 1));\n lastPos = i + 1;\n break;\n case '/':\n if (input.charAt(i + 1) === '*') {\n i++;\n inComment = true;\n blockDepth++;\n }\n break;\n case '\\'':\n case '\"':\n quote = parserInput.$quoted(i);\n if (quote) {\n parseGroups.push(input.substr(lastPos, i - lastPos), quote);\n i += quote[1].length - 1;\n lastPos = i + 1;\n }\n else {\n skipWhitespace(i - startPos);\n returnVal = nextChar;\n loop = false;\n }\n break;\n case '{':\n blockStack.push('}');\n blockDepth++;\n break;\n case '(':\n blockStack.push(')');\n blockDepth++;\n break;\n case '[':\n blockStack.push(']');\n blockDepth++;\n break;\n case '}':\n case ')':\n case ']':\n const expected = blockStack.pop();\n if (nextChar === expected) {\n blockDepth--;\n } else {\n // move the parser to the error and return expected\n skipWhitespace(i - startPos);\n returnVal = expected;\n loop = false;\n }\n }\n i++;\n if (i > length) {\n loop = false;\n }\n }\n prevChar = nextChar;\n } while (loop);\n\n return returnVal ? returnVal : null;\n }\n\n parserInput.autoCommentAbsorb = true;\n parserInput.commentStore = [];\n parserInput.finished = false;\n\n // Same as $(), but don't change the state of the parser,\n // just return the match.\n parserInput.peek = tok => {\n if (typeof tok === 'string') {\n // https://jsperf.com/string-startswith/21\n for (let i = 0; i < tok.length; i++) {\n if (input.charAt(parserInput.i + i) !== tok.charAt(i)) {\n return false;\n }\n }\n return true;\n } else {\n return tok.test(current);\n }\n };\n\n // Specialization of peek()\n // TODO remove or change some currentChar calls to peekChar\n parserInput.peekChar = tok => input.charAt(parserInput.i) === tok;\n\n parserInput.currentChar = () => input.charAt(parserInput.i);\n\n parserInput.prevChar = () => input.charAt(parserInput.i - 1);\n\n parserInput.getInput = () => input;\n\n parserInput.peekNotNumeric = () => {\n const c = input.charCodeAt(parserInput.i);\n // Is the first char of the dimension 0-9, '.', '+' or '-'\n return (c > CHARCODE_9 || c < CHARCODE_PLUS) || c === CHARCODE_FORWARD_SLASH || c === CHARCODE_COMMA;\n };\n\n parserInput.start = (str, chunkInput, failFunction) => {\n input = str;\n parserInput.i = j = currentPos = furthest = 0;\n\n // chunking apparently makes things quicker (but my tests indicate\n // it might actually make things slower in node at least)\n // and it is a non-perfect parse - it can't recognise\n // unquoted urls, meaning it can't distinguish comments\n // meaning comments with quotes or {}() in them get 'counted'\n // and then lead to parse errors.\n // In addition if the chunking chunks in the wrong place we might\n // not be able to parse a parser statement in one go\n // this is officially deprecated but can be switched on via an option\n // in the case it causes too much performance issues.\n if (chunkInput) {\n chunks = chunker(str, failFunction);\n } else {\n chunks = [str];\n }\n\n current = chunks[0];\n\n skipWhitespace(0);\n };\n\n parserInput.end = () => {\n let message;\n const isFinished = parserInput.i >= input.length;\n\n if (parserInput.i < furthest) {\n message = furthestPossibleErrorMessage;\n parserInput.i = furthest;\n }\n return {\n isFinished,\n furthest: parserInput.i,\n furthestPossibleErrorMessage: message,\n furthestReachedEnd: parserInput.i >= input.length - 1,\n furthestChar: input[parserInput.i]\n };\n };\n\n return parserInput;\n};\n","// Split the input into chunks.\nexport default function (input, fail) {\n const len = input.length;\n let level = 0;\n let parenLevel = 0;\n let lastOpening;\n let lastOpeningParen;\n let lastMultiComment;\n let lastMultiCommentEndBrace;\n const chunks = [];\n let emitFrom = 0;\n let chunkerCurrentIndex;\n let currentChunkStartIndex;\n let cc;\n let cc2;\n let matched;\n\n function emitChunk(force) {\n const len = chunkerCurrentIndex - emitFrom;\n if (((len < 512) && !force) || !len) {\n return;\n }\n chunks.push(input.slice(emitFrom, chunkerCurrentIndex + 1));\n emitFrom = chunkerCurrentIndex + 1;\n }\n\n for (chunkerCurrentIndex = 0; chunkerCurrentIndex < len; chunkerCurrentIndex++) {\n cc = input.charCodeAt(chunkerCurrentIndex);\n if (((cc >= 97) && (cc <= 122)) || (cc < 34)) {\n // a-z or whitespace\n continue;\n }\n\n switch (cc) {\n case 40: // (\n parenLevel++;\n lastOpeningParen = chunkerCurrentIndex;\n continue;\n case 41: // )\n if (--parenLevel < 0) {\n return fail('missing opening `(`', chunkerCurrentIndex);\n }\n continue;\n case 59: // ;\n if (!parenLevel) { emitChunk(); }\n continue;\n case 123: // {\n level++;\n lastOpening = chunkerCurrentIndex;\n continue;\n case 125: // }\n if (--level < 0) {\n return fail('missing opening `{`', chunkerCurrentIndex);\n }\n if (!level && !parenLevel) { emitChunk(); }\n continue;\n case 92: // \\\n if (chunkerCurrentIndex < len - 1) { chunkerCurrentIndex++; continue; }\n return fail('unescaped `\\\\`', chunkerCurrentIndex);\n case 34:\n case 39:\n case 96: // \", ' and `\n matched = 0;\n currentChunkStartIndex = chunkerCurrentIndex;\n for (chunkerCurrentIndex = chunkerCurrentIndex + 1; chunkerCurrentIndex < len; chunkerCurrentIndex++) {\n cc2 = input.charCodeAt(chunkerCurrentIndex);\n if (cc2 > 96) { continue; }\n if (cc2 == cc) { matched = 1; break; }\n if (cc2 == 92) { // \\\n if (chunkerCurrentIndex == len - 1) {\n return fail('unescaped `\\\\`', chunkerCurrentIndex);\n }\n chunkerCurrentIndex++;\n }\n }\n if (matched) { continue; }\n return fail(`unmatched \\`${String.fromCharCode(cc)}\\``, currentChunkStartIndex);\n case 47: // /, check for comment\n if (parenLevel || (chunkerCurrentIndex == len - 1)) { continue; }\n cc2 = input.charCodeAt(chunkerCurrentIndex + 1);\n if (cc2 == 47) {\n // //, find lnfeed\n for (chunkerCurrentIndex = chunkerCurrentIndex + 2; chunkerCurrentIndex < len; chunkerCurrentIndex++) {\n cc2 = input.charCodeAt(chunkerCurrentIndex);\n if ((cc2 <= 13) && ((cc2 == 10) || (cc2 == 13))) { break; }\n }\n } else if (cc2 == 42) {\n // /*, find */\n lastMultiComment = currentChunkStartIndex = chunkerCurrentIndex;\n for (chunkerCurrentIndex = chunkerCurrentIndex + 2; chunkerCurrentIndex < len - 1; chunkerCurrentIndex++) {\n cc2 = input.charCodeAt(chunkerCurrentIndex);\n if (cc2 == 125) { lastMultiCommentEndBrace = chunkerCurrentIndex; }\n if (cc2 != 42) { continue; }\n if (input.charCodeAt(chunkerCurrentIndex + 1) == 47) { break; }\n }\n if (chunkerCurrentIndex == len - 1) {\n return fail('missing closing `*/`', currentChunkStartIndex);\n }\n chunkerCurrentIndex++;\n }\n continue;\n case 42: // *, check for unmatched */\n if ((chunkerCurrentIndex < len - 1) && (input.charCodeAt(chunkerCurrentIndex + 1) == 47)) {\n return fail('unmatched `/*`', chunkerCurrentIndex);\n }\n continue;\n }\n }\n\n if (level !== 0) {\n if ((lastMultiComment > lastOpening) && (lastMultiCommentEndBrace > lastMultiComment)) {\n return fail('missing closing `}` or `*/`', lastOpening);\n } else {\n return fail('missing closing `}`', lastOpening);\n }\n } else if (parenLevel !== 0) {\n return fail('missing closing `)`', lastOpeningParen);\n }\n\n emitChunk(true);\n return chunks;\n};\n","import LessError from '../less-error';\nimport tree from '../tree';\nimport visitors from '../visitors';\nimport getParserInput from './parser-input';\nimport * as utils from '../utils';\nimport functionRegistry from '../functions/function-registry';\n\n//\n// less.js - parser\n//\n// A relatively straight-forward predictive parser.\n// There is no tokenization/lexing stage, the input is parsed\n// in one sweep.\n//\n// To make the parser fast enough to run in the browser, several\n// optimization had to be made:\n//\n// - Matching and slicing on a huge input is often cause of slowdowns.\n// The solution is to chunkify the input into smaller strings.\n// The chunks are stored in the `chunks` var,\n// `j` holds the current chunk index, and `currentPos` holds\n// the index of the current chunk in relation to `input`.\n// This gives us an almost 4x speed-up.\n//\n// - In many cases, we don't need to match individual tokens;\n// for example, if a value doesn't hold any variables, operations\n// or dynamic references, the parser can effectively 'skip' it,\n// treating it as a literal.\n// An example would be '1px solid #000' - which evaluates to itself,\n// we don't need to know what the individual components are.\n// The drawback, of course is that you don't get the benefits of\n// syntax-checking on the CSS. This gives us a 50% speed-up in the parser,\n// and a smaller speed-up in the code-gen.\n//\n//\n// Token matching is done with the `$` function, which either takes\n// a terminal string or regexp, or a non-terminal function to call.\n// It also takes care of moving all the indices forwards.\n//\n\nconst Parser = function Parser(context, imports, fileInfo) {\n let parsers;\n const parserInput = getParserInput();\n\n function error(msg, type) {\n throw new LessError(\n {\n index: parserInput.i,\n filename: fileInfo.filename,\n type: type || 'Syntax',\n message: msg\n },\n imports\n );\n }\n\n function expect(arg, msg) {\n // some older browsers return typeof 'function' for RegExp\n const result = (arg instanceof Function) ? arg.call(parsers) : parserInput.$re(arg);\n if (result) {\n return result;\n }\n \n error(msg || (typeof arg === 'string'\n ? `expected '${arg}' got '${parserInput.currentChar()}'`\n : 'unexpected token'));\n }\n\n // Specialization of expect()\n function expectChar(arg, msg) {\n if (parserInput.$char(arg)) {\n return arg;\n }\n error(msg || `expected '${arg}' got '${parserInput.currentChar()}'`);\n }\n\n function getDebugInfo(index) {\n const filename = fileInfo.filename;\n\n return {\n lineNumber: utils.getLocation(index, parserInput.getInput()).line + 1,\n fileName: filename\n };\n }\n\n /**\n * Used after initial parsing to create nodes on the fly\n * \n * @param {String} str - string to parse \n * @param {Array} parseList - array of parsers to run input through e.g. [\"value\", \"important\"]\n * @param {Number} currentIndex - start number to begin indexing\n * @param {Object} fileInfo - fileInfo to attach to created nodes\n */\n function parseNode(str, parseList, currentIndex, fileInfo, callback) {\n let result;\n const returnNodes = [];\n const parser = parserInput;\n\n try {\n parser.start(str, false, function fail(msg, index) {\n callback({\n message: msg,\n index: index + currentIndex\n });\n });\n for (let x = 0, p, i; (p = parseList[x]); x++) {\n i = parser.i;\n result = parsers[p]();\n if (result) {\n try {\n result._index = i + currentIndex;\n result._fileInfo = fileInfo;\n } catch (e) {}\n returnNodes.push(result);\n }\n else {\n returnNodes.push(null);\n }\n }\n\n const endInfo = parser.end();\n if (endInfo.isFinished) {\n callback(null, returnNodes);\n }\n else {\n callback(true, null);\n }\n } catch (e) {\n throw new LessError({\n index: e.index + currentIndex,\n message: e.message\n }, imports, fileInfo.filename);\n }\n }\n\n //\n // The Parser\n //\n return {\n parserInput,\n imports,\n fileInfo,\n parseNode,\n //\n // Parse an input string into an abstract syntax tree,\n // @param str A string containing 'less' markup\n // @param callback call `callback` when done.\n // @param [additionalData] An optional map which can contains vars - a map (key, value) of variables to apply\n //\n parse: function (str, callback, additionalData) {\n let root;\n let error = null;\n let globalVars;\n let modifyVars;\n let ignored;\n let preText = '';\n\n globalVars = (additionalData && additionalData.globalVars) ? `${Parser.serializeVars(additionalData.globalVars)}\\n` : '';\n modifyVars = (additionalData && additionalData.modifyVars) ? `\\n${Parser.serializeVars(additionalData.modifyVars)}` : '';\n\n if (context.pluginManager) {\n const preProcessors = context.pluginManager.getPreProcessors();\n for (let i = 0; i < preProcessors.length; i++) {\n str = preProcessors[i].process(str, { context, imports, fileInfo });\n }\n }\n\n if (globalVars || (additionalData && additionalData.banner)) {\n preText = ((additionalData && additionalData.banner) ? additionalData.banner : '') + globalVars;\n ignored = imports.contentsIgnoredChars;\n ignored[fileInfo.filename] = ignored[fileInfo.filename] || 0;\n ignored[fileInfo.filename] += preText.length;\n }\n\n str = str.replace(/\\r\\n?/g, '\\n');\n // Remove potential UTF Byte Order Mark\n str = preText + str.replace(/^\\uFEFF/, '') + modifyVars;\n imports.contents[fileInfo.filename] = str;\n\n // Start with the primary rule.\n // The whole syntax tree is held under a Ruleset node,\n // with the `root` property set to true, so no `{}` are\n // output. The callback is called when the input is parsed.\n try {\n parserInput.start(str, context.chunkInput, function fail(msg, index) {\n throw new LessError({\n index,\n type: 'Parse',\n message: msg,\n filename: fileInfo.filename\n }, imports);\n });\n\n tree.Node.prototype.parse = this;\n root = new tree.Ruleset(null, this.parsers.primary());\n tree.Node.prototype.rootNode = root;\n root.root = true;\n root.firstRoot = true;\n root.functionRegistry = functionRegistry.inherit();\n \n } catch (e) {\n return callback(new LessError(e, imports, fileInfo.filename));\n }\n\n // If `i` is smaller than the `input.length - 1`,\n // it means the parser wasn't able to parse the whole\n // string, so we've got a parsing error.\n //\n // We try to extract a \\n delimited string,\n // showing the line where the parse error occurred.\n // We split it up into two parts (the part which parsed,\n // and the part which didn't), so we can color them differently.\n const endInfo = parserInput.end();\n if (!endInfo.isFinished) {\n\n let message = endInfo.furthestPossibleErrorMessage;\n\n if (!message) {\n message = 'Unrecognised input';\n if (endInfo.furthestChar === '}') {\n message += '. Possibly missing opening \\'{\\'';\n } else if (endInfo.furthestChar === ')') {\n message += '. Possibly missing opening \\'(\\'';\n } else if (endInfo.furthestReachedEnd) {\n message += '. Possibly missing something';\n }\n }\n\n error = new LessError({\n type: 'Parse',\n message,\n index: endInfo.furthest,\n filename: fileInfo.filename\n }, imports);\n }\n\n const finish = e => {\n e = error || e || imports.error;\n\n if (e) {\n if (!(e instanceof LessError)) {\n e = new LessError(e, imports, fileInfo.filename);\n }\n\n return callback(e);\n }\n else {\n return callback(null, root);\n }\n };\n\n if (context.processImports !== false) {\n new visitors.ImportVisitor(imports, finish)\n .run(root);\n } else {\n return finish();\n }\n },\n\n //\n // Here in, the parsing rules/functions\n //\n // The basic structure of the syntax tree generated is as follows:\n //\n // Ruleset -> Declaration -> Value -> Expression -> Entity\n //\n // Here's some Less code:\n //\n // .class {\n // color: #fff;\n // border: 1px solid #000;\n // width: @w + 4px;\n // > .child {...}\n // }\n //\n // And here's what the parse tree might look like:\n //\n // Ruleset (Selector '.class', [\n // Declaration (\"color\", Value ([Expression [Color #fff]]))\n // Declaration (\"border\", Value ([Expression [Dimension 1px][Keyword \"solid\"][Color #000]]))\n // Declaration (\"width\", Value ([Expression [Operation \" + \" [Variable \"@w\"][Dimension 4px]]]))\n // Ruleset (Selector [Element '>', '.child'], [...])\n // ])\n //\n // In general, most rules will try to parse a token with the `$re()` function, and if the return\n // value is truly, will return a new node, of the relevant type. Sometimes, we need to check\n // first, before parsing, that's when we use `peek()`.\n //\n parsers: parsers = {\n //\n // The `primary` rule is the *entry* and *exit* point of the parser.\n // The rules here can appear at any level of the parse tree.\n //\n // The recursive nature of the grammar is an interplay between the `block`\n // rule, which represents `{ ... }`, the `ruleset` rule, and this `primary` rule,\n // as represented by this simplified grammar:\n //\n // primary → (ruleset | declaration)+\n // ruleset → selector+ block\n // block → '{' primary '}'\n //\n // Only at one point is the primary rule not called from the\n // block rule: at the root level.\n //\n primary: function () {\n const mixin = this.mixin;\n let root = [];\n let node;\n\n while (true) {\n while (true) {\n node = this.comment();\n if (!node) { break; }\n root.push(node);\n }\n // always process comments before deciding if finished\n if (parserInput.finished) {\n break;\n }\n if (parserInput.peek('}')) {\n break;\n }\n\n node = this.extendRule();\n if (node) {\n root = root.concat(node);\n continue;\n }\n\n node = mixin.definition() || this.declaration() || mixin.call(false, false) || \n this.ruleset() || this.variableCall() || this.entities.call() || this.atrule();\n if (node) {\n root.push(node);\n } else {\n let foundSemiColon = false;\n while (parserInput.$char(';')) {\n foundSemiColon = true;\n }\n if (!foundSemiColon) {\n break;\n }\n }\n }\n\n return root;\n },\n\n // comments are collected by the main parsing mechanism and then assigned to nodes\n // where the current structure allows it\n comment: function () {\n if (parserInput.commentStore.length) {\n const comment = parserInput.commentStore.shift();\n return new(tree.Comment)(comment.text, comment.isLineComment, comment.index, fileInfo);\n }\n },\n\n //\n // Entities are tokens which can be found inside an Expression\n //\n entities: {\n mixinLookup: function() {\n return parsers.mixin.call(true, true);\n },\n //\n // A string, which supports escaping \" and '\n //\n // \"milky way\" 'he\\'s the one!'\n //\n quoted: function (forceEscaped) {\n let str;\n const index = parserInput.i;\n let isEscaped = false;\n\n parserInput.save();\n if (parserInput.$char('~')) {\n isEscaped = true;\n } else if (forceEscaped) {\n parserInput.restore();\n return;\n }\n\n str = parserInput.$quoted();\n if (!str) {\n parserInput.restore();\n return;\n }\n parserInput.forget();\n\n return new(tree.Quoted)(str.charAt(0), str.substr(1, str.length - 2), isEscaped, index, fileInfo);\n },\n\n //\n // A catch-all word, such as:\n //\n // black border-collapse\n //\n keyword: function () {\n const k = parserInput.$char('%') || parserInput.$re(/^\\[?(?:[\\w-]|\\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+\\]?/);\n if (k) {\n return tree.Color.fromKeyword(k) || new(tree.Keyword)(k);\n }\n },\n\n //\n // A function call\n //\n // rgb(255, 0, 255)\n //\n // The arguments are parsed with the `entities.arguments` parser.\n //\n call: function () {\n let name;\n let args;\n let func;\n const index = parserInput.i;\n\n // http://jsperf.com/case-insensitive-regex-vs-strtolower-then-regex/18\n if (parserInput.peek(/^url\\(/i)) {\n return;\n }\n\n parserInput.save();\n\n name = parserInput.$re(/^([\\w-]+|%|~|progid:[\\w\\.]+)\\(/);\n if (!name) {\n parserInput.forget(); \n return;\n }\n\n name = name[1];\n func = this.customFuncCall(name);\n if (func) {\n args = func.parse();\n if (args && func.stop) {\n parserInput.forget();\n return args;\n }\n }\n\n args = this.arguments(args);\n\n if (!parserInput.$char(')')) {\n parserInput.restore('Could not parse call arguments or missing \\')\\'');\n return;\n }\n\n parserInput.forget();\n\n return new(tree.Call)(name, args, index, fileInfo);\n },\n \n //\n // Parsing rules for functions with non-standard args, e.g.:\n //\n // boolean(not(2 > 1))\n //\n // This is a quick prototype, to be modified/improved when\n // more custom-parsed funcs come (e.g. `selector(...)`)\n //\n\n customFuncCall: function (name) {\n /* Ideally the table is to be moved out of here for faster perf.,\n but it's quite tricky since it relies on all these `parsers`\n and `expect` available only here */\n return {\n alpha: f(parsers.ieAlpha, true),\n boolean: f(condition),\n 'if': f(condition)\n }[name.toLowerCase()];\n\n function f(parse, stop) {\n return {\n parse, // parsing function\n stop // when true - stop after parse() and return its result, \n // otherwise continue for plain args\n };\n }\n \n function condition() {\n return [expect(parsers.condition, 'expected condition')];\n }\n },\n\n arguments: function (prevArgs) {\n let argsComma = prevArgs || [];\n const argsSemiColon = [];\n let isSemiColonSeparated;\n let value;\n\n parserInput.save();\n\n while (true) {\n if (prevArgs) {\n prevArgs = false;\n } else {\n value = parsers.detachedRuleset() || this.assignment() || parsers.expression();\n if (!value) {\n break;\n }\n\n if (value.value && value.value.length == 1) {\n value = value.value[0];\n }\n\n argsComma.push(value);\n }\n\n if (parserInput.$char(',')) {\n continue;\n }\n\n if (parserInput.$char(';') || isSemiColonSeparated) {\n isSemiColonSeparated = true;\n value = (argsComma.length < 1) ? argsComma[0]\n : new tree.Value(argsComma);\n argsSemiColon.push(value);\n argsComma = [];\n }\n }\n\n parserInput.forget();\n return isSemiColonSeparated ? argsSemiColon : argsComma;\n },\n literal: function () {\n return this.dimension() ||\n this.color() ||\n this.quoted() ||\n this.unicodeDescriptor();\n },\n\n // Assignments are argument entities for calls.\n // They are present in ie filter properties as shown below.\n //\n // filter: progid:DXImageTransform.Microsoft.Alpha( *opacity=50* )\n //\n\n assignment: function () {\n let key;\n let value;\n parserInput.save();\n key = parserInput.$re(/^\\w+(?=\\s?=)/i);\n if (!key) {\n parserInput.restore();\n return;\n }\n if (!parserInput.$char('=')) {\n parserInput.restore();\n return;\n }\n value = parsers.entity();\n if (value) {\n parserInput.forget();\n return new(tree.Assignment)(key, value);\n } else {\n parserInput.restore();\n }\n },\n\n //\n // Parse url() tokens\n //\n // We use a specific rule for urls, because they don't really behave like\n // standard function calls. The difference is that the argument doesn't have\n // to be enclosed within a string, so it can't be parsed as an Expression.\n //\n url: function () {\n let value;\n const index = parserInput.i;\n\n parserInput.autoCommentAbsorb = false;\n\n if (!parserInput.$str('url(')) {\n parserInput.autoCommentAbsorb = true;\n return;\n }\n\n value = this.quoted() || this.variable() || this.property() ||\n parserInput.$re(/^(?:(?:\\\\[\\(\\)'\"])|[^\\(\\)'\"])+/) || '';\n\n parserInput.autoCommentAbsorb = true;\n\n expectChar(')');\n\n return new(tree.URL)((value.value != null || \n value instanceof tree.Variable || \n value instanceof tree.Property) ?\n value : new(tree.Anonymous)(value, index), index, fileInfo);\n },\n\n //\n // A Variable entity, such as `@fink`, in\n //\n // width: @fink + 2px\n //\n // We use a different parser for variable definitions,\n // see `parsers.variable`.\n //\n variable: function () {\n let ch;\n let name;\n const index = parserInput.i;\n\n parserInput.save();\n if (parserInput.currentChar() === '@' && (name = parserInput.$re(/^@@?[\\w-]+/))) {\n ch = parserInput.currentChar();\n if (ch === '(' || ch === '[' && !parserInput.prevChar().match(/^\\s/)) {\n // this may be a VariableCall lookup\n const result = parsers.variableCall(name);\n if (result) {\n parserInput.forget();\n return result;\n }\n }\n parserInput.forget();\n return new(tree.Variable)(name, index, fileInfo);\n }\n parserInput.restore();\n },\n\n // A variable entity using the protective {} e.g. @{var}\n variableCurly: function () {\n let curly;\n const index = parserInput.i;\n\n if (parserInput.currentChar() === '@' && (curly = parserInput.$re(/^@\\{([\\w-]+)\\}/))) {\n return new(tree.Variable)(`@${curly[1]}`, index, fileInfo);\n }\n },\n //\n // A Property accessor, such as `$color`, in\n //\n // background-color: $color\n //\n property: function () {\n let name;\n const index = parserInput.i;\n\n if (parserInput.currentChar() === '$' && (name = parserInput.$re(/^\\$[\\w-]+/))) {\n return new(tree.Property)(name, index, fileInfo);\n }\n },\n\n // A property entity useing the protective {} e.g. ${prop}\n propertyCurly: function () {\n let curly;\n const index = parserInput.i;\n\n if (parserInput.currentChar() === '$' && (curly = parserInput.$re(/^\\$\\{([\\w-]+)\\}/))) {\n return new(tree.Property)(`$${curly[1]}`, index, fileInfo);\n }\n },\n //\n // A Hexadecimal color\n //\n // #4F3C2F\n //\n // `rgb` and `hsl` colors are parsed through the `entities.call` parser.\n //\n color: function () {\n let rgb;\n parserInput.save();\n\n if (parserInput.currentChar() === '#' && (rgb = parserInput.$re(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3,4})([\\w.#\\[])?/))) {\n if (!rgb[2]) {\n parserInput.forget();\n return new(tree.Color)(rgb[1], undefined, rgb[0]);\n } \n }\n parserInput.restore();\n },\n\n colorKeyword: function () {\n parserInput.save();\n const autoCommentAbsorb = parserInput.autoCommentAbsorb;\n parserInput.autoCommentAbsorb = false;\n const k = parserInput.$re(/^[_A-Za-z-][_A-Za-z0-9-]+/);\n parserInput.autoCommentAbsorb = autoCommentAbsorb;\n if (!k) {\n parserInput.forget();\n return;\n }\n parserInput.restore();\n const color = tree.Color.fromKeyword(k);\n if (color) {\n parserInput.$str(k);\n return color;\n }\n },\n\n //\n // A Dimension, that is, a number and a unit\n //\n // 0.5em 95%\n //\n dimension: function () {\n if (parserInput.peekNotNumeric()) {\n return;\n }\n\n const value = parserInput.$re(/^([+-]?\\d*\\.?\\d+)(%|[a-z_]+)?/i);\n if (value) {\n return new(tree.Dimension)(value[1], value[2]);\n }\n },\n\n //\n // A unicode descriptor, as is used in unicode-range\n //\n // U+0?? or U+00A1-00A9\n //\n unicodeDescriptor: function () {\n let ud;\n\n ud = parserInput.$re(/^U\\+[0-9a-fA-F?]+(\\-[0-9a-fA-F?]+)?/);\n if (ud) {\n return new(tree.UnicodeDescriptor)(ud[0]);\n }\n },\n\n //\n // JavaScript code to be evaluated\n //\n // `window.location.href`\n //\n javascript: function () {\n let js;\n const index = parserInput.i;\n\n parserInput.save();\n\n const escape = parserInput.$char('~');\n const jsQuote = parserInput.$char('`');\n\n if (!jsQuote) {\n parserInput.restore();\n return;\n }\n\n js = parserInput.$re(/^[^`]*`/);\n if (js) {\n parserInput.forget();\n return new(tree.JavaScript)(js.substr(0, js.length - 1), Boolean(escape), index, fileInfo);\n }\n parserInput.restore('invalid javascript definition');\n }\n },\n\n //\n // The variable part of a variable definition. Used in the `rule` parser\n //\n // @fink:\n //\n variable: function () {\n let name;\n\n if (parserInput.currentChar() === '@' && (name = parserInput.$re(/^(@[\\w-]+)\\s*:/))) { return name[1]; }\n },\n\n //\n // Call a variable value to retrieve a detached ruleset\n // or a value from a detached ruleset's rules.\n //\n // @fink();\n // @fink;\n // color: @fink[@color];\n //\n variableCall: function (parsedName) {\n let lookups;\n const i = parserInput.i;\n const inValue = !!parsedName;\n let name = parsedName;\n\n parserInput.save();\n\n if (name || (parserInput.currentChar() === '@'\n && (name = parserInput.$re(/^(@[\\w-]+)(\\(\\s*\\))?/)))) {\n\n lookups = this.mixin.ruleLookups();\n\n if (!lookups && ((inValue && parserInput.$str('()') !== '()') || (name[2] !== '()'))) {\n parserInput.restore('Missing \\'[...]\\' lookup in variable call');\n return;\n }\n\n if (!inValue) {\n name = name[1];\n }\n\n const call = new tree.VariableCall(name, i, fileInfo);\n if (!inValue && parsers.end()) {\n parserInput.forget();\n return call;\n }\n else {\n parserInput.forget();\n return new tree.NamespaceValue(call, lookups, i, fileInfo);\n }\n }\n\n parserInput.restore();\n },\n\n //\n // extend syntax - used to extend selectors\n //\n extend: function(isRule) {\n let elements;\n let e;\n const index = parserInput.i;\n let option;\n let extendList;\n let extend;\n\n if (!parserInput.$str(isRule ? '&:extend(' : ':extend(')) {\n return;\n }\n\n do {\n option = null;\n elements = null;\n while (!(option = parserInput.$re(/^(all)(?=\\s*(\\)|,))/))) {\n e = this.element();\n if (!e) {\n break;\n }\n if (elements) {\n elements.push(e);\n } else {\n elements = [ e ];\n }\n }\n\n option = option && option[1];\n if (!elements) {\n error('Missing target selector for :extend().');\n }\n extend = new(tree.Extend)(new(tree.Selector)(elements), option, index, fileInfo);\n if (extendList) {\n extendList.push(extend);\n } else {\n extendList = [ extend ];\n }\n } while (parserInput.$char(','));\n\n expect(/^\\)/);\n\n if (isRule) {\n expect(/^;/);\n }\n\n return extendList;\n },\n\n //\n // extendRule - used in a rule to extend all the parent selectors\n //\n extendRule: function() {\n return this.extend(true);\n },\n\n //\n // Mixins\n //\n mixin: {\n //\n // A Mixin call, with an optional argument list\n //\n // #mixins > .square(#fff);\n // #mixins.square(#fff);\n // .rounded(4px, black);\n // .button;\n //\n // We can lookup / return a value using the lookup syntax:\n //\n // color: #mixin.square(#fff)[@color];\n //\n // The `while` loop is there because mixins can be\n // namespaced, but we only support the child and descendant\n // selector for now.\n //\n call: function (inValue, getLookup) {\n const s = parserInput.currentChar();\n let important = false;\n let lookups;\n const index = parserInput.i;\n let elements;\n let args;\n let hasParens;\n\n if (s !== '.' && s !== '#') { return; }\n\n parserInput.save(); // stop us absorbing part of an invalid selector\n\n elements = this.elements();\n\n if (elements) {\n if (parserInput.$char('(')) {\n args = this.args(true).args;\n expectChar(')');\n hasParens = true;\n }\n\n if (getLookup !== false) {\n lookups = this.ruleLookups();\n }\n if (getLookup === true && !lookups) {\n parserInput.restore();\n return;\n }\n\n if (inValue && !lookups && !hasParens) {\n // This isn't a valid in-value mixin call\n parserInput.restore();\n return;\n }\n\n if (!inValue && parsers.important()) {\n important = true;\n }\n\n if (inValue || parsers.end()) {\n parserInput.forget();\n const mixin = new(tree.mixin.Call)(elements, args, index, fileInfo, !lookups && important);\n if (lookups) {\n return new tree.NamespaceValue(mixin, lookups);\n }\n else {\n return mixin;\n }\n }\n }\n\n parserInput.restore();\n },\n /**\n * Matching elements for mixins\n * (Start with . or # and can have > )\n */\n elements: function() {\n let elements;\n let e;\n let c;\n let elem;\n let elemIndex;\n const re = /^[#.](?:[\\w-]|\\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/;\n while (true) {\n elemIndex = parserInput.i;\n e = parserInput.$re(re);\n \n if (!e) {\n break;\n }\n elem = new(tree.Element)(c, e, false, elemIndex, fileInfo);\n if (elements) {\n elements.push(elem);\n } else {\n elements = [ elem ];\n }\n c = parserInput.$char('>');\n }\n return elements;\n },\n args: function (isCall) {\n const entities = parsers.entities;\n const returner = { args:null, variadic: false };\n let expressions = [];\n const argsSemiColon = [];\n const argsComma = [];\n let isSemiColonSeparated;\n let expressionContainsNamed;\n let name;\n let nameLoop;\n let value;\n let arg;\n let expand;\n let hasSep = true;\n\n parserInput.save();\n\n while (true) {\n if (isCall) {\n arg = parsers.detachedRuleset() || parsers.expression();\n } else {\n parserInput.commentStore.length = 0;\n if (parserInput.$str('...')) {\n returner.variadic = true;\n if (parserInput.$char(';') && !isSemiColonSeparated) {\n isSemiColonSeparated = true;\n }\n (isSemiColonSeparated ? argsSemiColon : argsComma)\n .push({ variadic: true });\n break;\n }\n arg = entities.variable() || entities.property() || entities.literal() || entities.keyword() || this.call(true);\n }\n\n if (!arg || !hasSep) {\n break;\n }\n\n nameLoop = null;\n if (arg.throwAwayComments) {\n arg.throwAwayComments();\n }\n value = arg;\n let val = null;\n\n if (isCall) {\n // Variable\n if (arg.value && arg.value.length == 1) {\n val = arg.value[0];\n }\n } else {\n val = arg;\n }\n\n if (val && (val instanceof tree.Variable || val instanceof tree.Property)) {\n if (parserInput.$char(':')) {\n if (expressions.length > 0) {\n if (isSemiColonSeparated) {\n error('Cannot mix ; and , as delimiter types');\n }\n expressionContainsNamed = true;\n }\n\n value = parsers.detachedRuleset() || parsers.expression();\n\n if (!value) {\n if (isCall) {\n error('could not understand value for named argument');\n } else {\n parserInput.restore();\n returner.args = [];\n return returner;\n }\n }\n nameLoop = (name = val.name);\n } else if (parserInput.$str('...')) {\n if (!isCall) {\n returner.variadic = true;\n if (parserInput.$char(';') && !isSemiColonSeparated) {\n isSemiColonSeparated = true;\n }\n (isSemiColonSeparated ? argsSemiColon : argsComma)\n .push({ name: arg.name, variadic: true });\n break;\n } else {\n expand = true;\n }\n } else if (!isCall) {\n name = nameLoop = val.name;\n value = null;\n }\n }\n\n if (value) {\n expressions.push(value);\n }\n\n argsComma.push({ name:nameLoop, value, expand });\n\n if (parserInput.$char(',')) {\n hasSep = true;\n continue;\n }\n hasSep = parserInput.$char(';') === ';';\n\n if (hasSep || isSemiColonSeparated) {\n\n if (expressionContainsNamed) {\n error('Cannot mix ; and , as delimiter types');\n }\n\n isSemiColonSeparated = true;\n\n if (expressions.length > 1) {\n value = new(tree.Value)(expressions);\n }\n argsSemiColon.push({ name, value, expand });\n\n name = null;\n expressions = [];\n expressionContainsNamed = false;\n }\n }\n\n parserInput.forget();\n returner.args = isSemiColonSeparated ? argsSemiColon : argsComma;\n return returner;\n },\n //\n // A Mixin definition, with a list of parameters\n //\n // .rounded (@radius: 2px, @color) {\n // ...\n // }\n //\n // Until we have a finer grained state-machine, we have to\n // do a look-ahead, to make sure we don't have a mixin call.\n // See the `rule` function for more information.\n //\n // We start by matching `.rounded (`, and then proceed on to\n // the argument list, which has optional default values.\n // We store the parameters in `params`, with a `value` key,\n // if there is a value, such as in the case of `@radius`.\n //\n // Once we've got our params list, and a closing `)`, we parse\n // the `{...}` block.\n //\n definition: function () {\n let name;\n let params = [];\n let match;\n let ruleset;\n let cond;\n let variadic = false;\n if ((parserInput.currentChar() !== '.' && parserInput.currentChar() !== '#') ||\n parserInput.peek(/^[^{]*\\}/)) {\n return;\n }\n\n parserInput.save();\n\n match = parserInput.$re(/^([#.](?:[\\w-]|\\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+)\\s*\\(/);\n if (match) {\n name = match[1];\n\n const argInfo = this.args(false);\n params = argInfo.args;\n variadic = argInfo.variadic;\n\n // .mixincall(\"@{a}\");\n // looks a bit like a mixin definition..\n // also\n // .mixincall(@a: {rule: set;});\n // so we have to be nice and restore\n if (!parserInput.$char(')')) {\n parserInput.restore('Missing closing \\')\\'');\n return;\n }\n\n parserInput.commentStore.length = 0;\n\n if (parserInput.$str('when')) { // Guard\n cond = expect(parsers.conditions, 'expected condition');\n }\n\n ruleset = parsers.block();\n\n if (ruleset) {\n parserInput.forget();\n return new(tree.mixin.Definition)(name, params, ruleset, cond, variadic);\n } else {\n parserInput.restore();\n }\n } else {\n parserInput.restore();\n }\n },\n \n ruleLookups: function() {\n let rule;\n let args;\n const lookups = [];\n\n if (parserInput.currentChar() !== '[') { \n return;\n }\n\n while (true) {\n parserInput.save();\n args = null;\n rule = this.lookupValue();\n if (!rule && rule !== '') {\n parserInput.restore();\n break;\n }\n lookups.push(rule);\n parserInput.forget();\n }\n if (lookups.length > 0) {\n return lookups;\n }\n },\n \n lookupValue: function() {\n parserInput.save();\n \n if (!parserInput.$char('[')) { \n parserInput.restore();\n return;\n }\n \n const name = parserInput.$re(/^(?:[@$]{0,2})[_a-zA-Z0-9-]*/);\n \n if (!parserInput.$char(']')) {\n parserInput.restore();\n return;\n } \n\n if (name || name === '') {\n parserInput.forget();\n return name;\n }\n \n parserInput.restore();\n }\n },\n //\n // Entities are the smallest recognized token,\n // and can be found inside a rule's value.\n //\n entity: function () {\n const entities = this.entities;\n\n return this.comment() || entities.literal() || entities.variable() || entities.url() ||\n entities.property() || entities.call() || entities.keyword() || this.mixin.call(true) ||\n entities.javascript();\n },\n\n //\n // A Declaration terminator. Note that we use `peek()` to check for '}',\n // because the `block` rule will be expecting it, but we still need to make sure\n // it's there, if ';' was omitted.\n //\n end: function () {\n return parserInput.$char(';') || parserInput.peek('}');\n },\n\n //\n // IE's alpha function\n //\n // alpha(opacity=88)\n //\n ieAlpha: function () {\n let value;\n\n // http://jsperf.com/case-insensitive-regex-vs-strtolower-then-regex/18\n if (!parserInput.$re(/^opacity=/i)) { return; }\n value = parserInput.$re(/^\\d+/);\n if (!value) {\n value = expect(parsers.entities.variable, 'Could not parse alpha');\n value = `@{${value.name.slice(1)}}`;\n }\n expectChar(')');\n return new tree.Quoted('', `alpha(opacity=${value})`);\n },\n\n //\n // A Selector Element\n //\n // div\n // + h1\n // #socks\n // input[type=\"text\"]\n //\n // Elements are the building blocks for Selectors,\n // they are made out of a `Combinator` (see combinator rule),\n // and an element name, such as a tag a class, or `*`.\n //\n element: function () {\n let e;\n let c;\n let v;\n const index = parserInput.i;\n\n c = this.combinator();\n\n e = parserInput.$re(/^(?:\\d+\\.\\d+|\\d+)%/) ||\n parserInput.$re(/^(?:[.#]?|:*)(?:[\\w-]|[^\\x00-\\x9f]|\\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/) ||\n parserInput.$char('*') || parserInput.$char('&') || this.attribute() ||\n parserInput.$re(/^\\([^&()@]+\\)/) || parserInput.$re(/^[\\.#:](?=@)/) ||\n this.entities.variableCurly();\n\n if (!e) {\n parserInput.save();\n if (parserInput.$char('(')) {\n if ((v = this.selector(false)) && parserInput.$char(')')) {\n e = new(tree.Paren)(v);\n parserInput.forget();\n } else {\n parserInput.restore('Missing closing \\')\\'');\n }\n } else {\n parserInput.forget();\n }\n }\n\n if (e) { return new(tree.Element)(c, e, e instanceof tree.Variable, index, fileInfo); }\n },\n\n //\n // Combinators combine elements together, in a Selector.\n //\n // Because our parser isn't white-space sensitive, special care\n // has to be taken, when parsing the descendant combinator, ` `,\n // as it's an empty space. We have to check the previous character\n // in the input, to see if it's a ` ` character. More info on how\n // we deal with this in *combinator.js*.\n //\n combinator: function () {\n let c = parserInput.currentChar();\n\n if (c === '/') {\n parserInput.save();\n const slashedCombinator = parserInput.$re(/^\\/[a-z]+\\//i);\n if (slashedCombinator) {\n parserInput.forget();\n return new(tree.Combinator)(slashedCombinator);\n }\n parserInput.restore();\n }\n\n if (c === '>' || c === '+' || c === '~' || c === '|' || c === '^') {\n parserInput.i++;\n if (c === '^' && parserInput.currentChar() === '^') {\n c = '^^';\n parserInput.i++;\n }\n while (parserInput.isWhitespace()) { parserInput.i++; }\n return new(tree.Combinator)(c);\n } else if (parserInput.isWhitespace(-1)) {\n return new(tree.Combinator)(' ');\n } else {\n return new(tree.Combinator)(null);\n }\n },\n //\n // A CSS Selector\n // with less extensions e.g. the ability to extend and guard\n //\n // .class > div + h1\n // li a:hover\n //\n // Selectors are made out of one or more Elements, see above.\n //\n selector: function (isLess) {\n const index = parserInput.i;\n let elements;\n let extendList;\n let c;\n let e;\n let allExtends;\n let when;\n let condition;\n isLess = isLess !== false;\n while ((isLess && (extendList = this.extend())) || (isLess && (when = parserInput.$str('when'))) || (e = this.element())) {\n if (when) {\n condition = expect(this.conditions, 'expected condition');\n } else if (condition) {\n error('CSS guard can only be used at the end of selector');\n } else if (extendList) {\n if (allExtends) {\n allExtends = allExtends.concat(extendList);\n } else {\n allExtends = extendList;\n }\n } else {\n if (allExtends) { error('Extend can only be used at the end of selector'); }\n c = parserInput.currentChar();\n if (elements) {\n elements.push(e);\n } else {\n elements = [ e ];\n }\n e = null;\n }\n if (c === '{' || c === '}' || c === ';' || c === ',' || c === ')') {\n break;\n }\n }\n\n if (elements) { return new(tree.Selector)(elements, allExtends, condition, index, fileInfo); }\n if (allExtends) { error('Extend must be used to extend a selector, it cannot be used on its own'); }\n },\n selectors: function () {\n let s;\n let selectors;\n while (true) {\n s = this.selector();\n if (!s) {\n break;\n }\n if (selectors) {\n selectors.push(s);\n } else {\n selectors = [ s ];\n }\n parserInput.commentStore.length = 0;\n if (s.condition && selectors.length > 1) {\n error(\"Guards are only currently allowed on a single selector.\");\n }\n if (!parserInput.$char(',')) { break; }\n if (s.condition) {\n error(\"Guards are only currently allowed on a single selector.\");\n }\n parserInput.commentStore.length = 0;\n }\n return selectors;\n },\n attribute: function () {\n if (!parserInput.$char('[')) { return; }\n\n const entities = this.entities;\n let key;\n let val;\n let op;\n\n if (!(key = entities.variableCurly())) {\n key = expect(/^(?:[_A-Za-z0-9-\\*]*\\|)?(?:[_A-Za-z0-9-]|\\\\.)+/);\n }\n\n op = parserInput.$re(/^[|~*$^]?=/);\n if (op) {\n val = entities.quoted() || parserInput.$re(/^[0-9]+%/) || parserInput.$re(/^[\\w-]+/) || entities.variableCurly();\n }\n\n expectChar(']');\n\n return new(tree.Attribute)(key, op, val);\n },\n\n //\n // The `block` rule is used by `ruleset` and `mixin.definition`.\n // It's a wrapper around the `primary` rule, with added `{}`.\n //\n block: function () {\n let content;\n if (parserInput.$char('{') && (content = this.primary()) && parserInput.$char('}')) {\n return content;\n }\n },\n\n blockRuleset: function() {\n let block = this.block();\n\n if (block) {\n block = new tree.Ruleset(null, block);\n }\n return block;\n },\n\n detachedRuleset: function() {\n let argInfo;\n let params;\n let variadic;\n\n parserInput.save();\n if (parserInput.$re(/^[.#]\\(/)) {\n /**\n * DR args currently only implemented for each() function, and not \n * yet settable as `@dr: #(@arg) {}`\n * This should be done when DRs are merged with mixins.\n * See: https://github.com/less/less-meta/issues/16\n */\n argInfo = this.mixin.args(false);\n params = argInfo.args;\n variadic = argInfo.variadic;\n if (!parserInput.$char(')')) {\n parserInput.restore();\n return;\n }\n }\n const blockRuleset = this.blockRuleset();\n if (blockRuleset) {\n parserInput.forget();\n if (params) {\n return new tree.mixin.Definition(null, params, blockRuleset, null, variadic);\n }\n return new tree.DetachedRuleset(blockRuleset);\n }\n parserInput.restore();\n },\n\n //\n // div, .class, body > p {...}\n //\n ruleset: function () {\n let selectors;\n let rules;\n let debugInfo;\n\n parserInput.save();\n\n if (context.dumpLineNumbers) {\n debugInfo = getDebugInfo(parserInput.i);\n }\n\n selectors = this.selectors();\n\n if (selectors && (rules = this.block())) {\n parserInput.forget();\n const ruleset = new(tree.Ruleset)(selectors, rules, context.strictImports);\n if (context.dumpLineNumbers) {\n ruleset.debugInfo = debugInfo;\n }\n return ruleset;\n } else {\n parserInput.restore();\n }\n },\n declaration: function () {\n let name;\n let value;\n const index = parserInput.i;\n let hasDR;\n const c = parserInput.currentChar();\n let important;\n let merge;\n let isVariable;\n\n if (c === '.' || c === '#' || c === '&' || c === ':') { return; }\n\n parserInput.save();\n\n name = this.variable() || this.ruleProperty();\n if (name) {\n isVariable = typeof name === 'string';\n\n if (isVariable) {\n value = this.detachedRuleset();\n if (value) {\n hasDR = true;\n }\n }\n\n parserInput.commentStore.length = 0;\n if (!value) {\n // a name returned by this.ruleProperty() is always an array of the form:\n // [string-1, ..., string-n, \"\"] or [string-1, ..., string-n, \"+\"]\n // where each item is a tree.Keyword or tree.Variable\n merge = !isVariable && name.length > 1 && name.pop().value;\n\n // Custom property values get permissive parsing\n if (name[0].value && name[0].value.slice(0, 2) === '--') {\n value = this.permissiveValue();\n }\n // Try to store values as anonymous\n // If we need the value later we'll re-parse it in ruleset.parseValue\n else {\n value = this.anonymousValue();\n }\n if (value) {\n parserInput.forget();\n // anonymous values absorb the end ';' which is required for them to work\n return new(tree.Declaration)(name, value, false, merge, index, fileInfo);\n }\n\n if (!value) {\n value = this.value();\n }\n\n if (value) {\n important = this.important();\n } else if (isVariable) {\n // As a last resort, try permissiveValue\n value = this.permissiveValue();\n }\n }\n\n if (value && (this.end() || hasDR)) {\n parserInput.forget();\n return new(tree.Declaration)(name, value, important, merge, index, fileInfo);\n }\n else {\n parserInput.restore();\n }\n } else {\n parserInput.restore();\n }\n },\n anonymousValue: function () {\n const index = parserInput.i;\n const match = parserInput.$re(/^([^.#@\\$+\\/'\"*`(;{}-]*);/);\n if (match) {\n return new(tree.Anonymous)(match[1], index);\n }\n },\n /**\n * Used for custom properties, at-rules, and variables (as fallback)\n * Parses almost anything inside of {} [] () \"\" blocks\n * until it reaches outer-most tokens.\n * \n * First, it will try to parse comments and entities to reach\n * the end. This is mostly like the Expression parser except no\n * math is allowed.\n */\n permissiveValue: function (untilTokens) {\n let i;\n let e;\n let done;\n let value;\n const tok = untilTokens || ';';\n const index = parserInput.i;\n const result = [];\n\n function testCurrentChar() {\n const char = parserInput.currentChar();\n if (typeof tok === 'string') {\n return char === tok;\n } else {\n return tok.test(char);\n }\n }\n if (testCurrentChar()) {\n return;\n }\n value = [];\n do {\n e = this.comment();\n if (e) {\n value.push(e);\n continue;\n }\n e = this.entity();\n if (e) {\n value.push(e);\n }\n } while (e);\n\n done = testCurrentChar();\n\n if (value.length > 0) {\n value = new(tree.Expression)(value);\n if (done) {\n return value;\n }\n else {\n result.push(value);\n }\n // Preserve space before $parseUntil as it will not\n if (parserInput.prevChar() === ' ') {\n result.push(new tree.Anonymous(' ', index));\n }\n }\n parserInput.save();\n\n value = parserInput.$parseUntil(tok);\n\n if (value) {\n if (typeof value === 'string') {\n error(`Expected '${value}'`, 'Parse');\n }\n if (value.length === 1 && value[0] === ' ') {\n parserInput.forget();\n return new tree.Anonymous('', index);\n }\n let item;\n for (i = 0; i < value.length; i++) {\n item = value[i];\n if (Array.isArray(item)) {\n // Treat actual quotes as normal quoted values\n result.push(new tree.Quoted(item[0], item[1], true, index, fileInfo));\n }\n else {\n if (i === value.length - 1) {\n item = item.trim();\n }\n // Treat like quoted values, but replace vars like unquoted expressions\n const quote = new tree.Quoted('\\'', item, true, index, fileInfo);\n quote.variableRegex = /@([\\w-]+)/g;\n quote.propRegex = /\\$([\\w-]+)/g;\n result.push(quote);\n }\n }\n parserInput.forget();\n return new tree.Expression(result, true);\n }\n parserInput.restore();\n },\n\n //\n // An @import atrule\n //\n // @import \"lib\";\n //\n // Depending on our environment, importing is done differently:\n // In the browser, it's an XHR request, in Node, it would be a\n // file-system operation. The function used for importing is\n // stored in `import`, which we pass to the Import constructor.\n //\n 'import': function () {\n let path;\n let features;\n const index = parserInput.i;\n\n const dir = parserInput.$re(/^@import?\\s+/);\n\n if (dir) {\n const options = (dir ? this.importOptions() : null) || {};\n\n if ((path = this.entities.quoted() || this.entities.url())) {\n features = this.mediaFeatures();\n\n if (!parserInput.$char(';')) {\n parserInput.i = index;\n error('missing semi-colon or unrecognised media features on import');\n }\n features = features && new(tree.Value)(features);\n return new(tree.Import)(path, features, options, index, fileInfo);\n }\n else {\n parserInput.i = index;\n error('malformed import statement');\n }\n }\n },\n\n importOptions: function() {\n let o;\n const options = {};\n let optionName;\n let value;\n\n // list of options, surrounded by parens\n if (!parserInput.$char('(')) { return null; }\n do {\n o = this.importOption();\n if (o) {\n optionName = o;\n value = true;\n switch (optionName) {\n case 'css':\n optionName = 'less';\n value = false;\n break;\n case 'once':\n optionName = 'multiple';\n value = false;\n break;\n }\n options[optionName] = value;\n if (!parserInput.$char(',')) { break; }\n }\n } while (o);\n expectChar(')');\n return options;\n },\n\n importOption: function() {\n const opt = parserInput.$re(/^(less|css|multiple|once|inline|reference|optional)/);\n if (opt) {\n return opt[1];\n }\n },\n\n mediaFeature: function () {\n const entities = this.entities;\n const nodes = [];\n let e;\n let p;\n parserInput.save();\n do {\n e = entities.keyword() || entities.variable() || entities.mixinLookup();\n if (e) {\n nodes.push(e);\n } else if (parserInput.$char('(')) {\n p = this.property();\n e = this.value();\n if (parserInput.$char(')')) {\n if (p && e) {\n nodes.push(new(tree.Paren)(new(tree.Declaration)(p, e, null, null, parserInput.i, fileInfo, true)));\n } else if (e) {\n nodes.push(new(tree.Paren)(e));\n } else {\n error('badly formed media feature definition');\n }\n } else {\n error('Missing closing \\')\\'', 'Parse');\n }\n }\n } while (e);\n\n parserInput.forget();\n if (nodes.length > 0) {\n return new(tree.Expression)(nodes);\n }\n },\n\n mediaFeatures: function () {\n const entities = this.entities;\n const features = [];\n let e;\n do {\n e = this.mediaFeature();\n if (e) {\n features.push(e);\n if (!parserInput.$char(',')) { break; }\n } else {\n e = entities.variable() || entities.mixinLookup();\n if (e) {\n features.push(e);\n if (!parserInput.$char(',')) { break; }\n }\n }\n } while (e);\n\n return features.length > 0 ? features : null;\n },\n\n media: function () {\n let features;\n let rules;\n let media;\n let debugInfo;\n const index = parserInput.i;\n\n if (context.dumpLineNumbers) {\n debugInfo = getDebugInfo(index);\n }\n\n parserInput.save();\n\n if (parserInput.$str('@media')) {\n features = this.mediaFeatures();\n\n rules = this.block();\n\n if (!rules) {\n error('media definitions require block statements after any features');\n }\n\n parserInput.forget();\n\n media = new(tree.Media)(rules, features, index, fileInfo);\n if (context.dumpLineNumbers) {\n media.debugInfo = debugInfo;\n }\n\n return media;\n }\n\n parserInput.restore();\n },\n\n //\n\n // A @plugin directive, used to import plugins dynamically.\n //\n // @plugin (args) \"lib\";\n //\n plugin: function () {\n let path;\n let args;\n let options;\n const index = parserInput.i;\n const dir = parserInput.$re(/^@plugin?\\s+/);\n\n if (dir) {\n args = this.pluginArgs();\n\n if (args) {\n options = {\n pluginArgs: args,\n isPlugin: true\n };\n }\n else {\n options = { isPlugin: true };\n }\n\n if ((path = this.entities.quoted() || this.entities.url())) {\n\n if (!parserInput.$char(';')) {\n parserInput.i = index;\n error('missing semi-colon on @plugin');\n }\n return new(tree.Import)(path, null, options, index, fileInfo);\n }\n else {\n parserInput.i = index;\n error('malformed @plugin statement');\n }\n }\n },\n\n pluginArgs: function() {\n // list of options, surrounded by parens\n parserInput.save();\n if (!parserInput.$char('(')) {\n parserInput.restore();\n return null;\n }\n const args = parserInput.$re(/^\\s*([^\\);]+)\\)\\s*/);\n if (args[1]) {\n parserInput.forget();\n return args[1].trim();\n }\n else { \n parserInput.restore();\n return null;\n }\n },\n\n //\n // A CSS AtRule\n //\n // @charset \"utf-8\";\n //\n atrule: function () {\n const index = parserInput.i;\n let name;\n let value;\n let rules;\n let nonVendorSpecificName;\n let hasIdentifier;\n let hasExpression;\n let hasUnknown;\n let hasBlock = true;\n let isRooted = true;\n\n if (parserInput.currentChar() !== '@') { return; }\n\n value = this['import']() || this.plugin() || this.media();\n if (value) {\n return value;\n }\n\n parserInput.save();\n\n name = parserInput.$re(/^@[a-z-]+/);\n\n if (!name) { return; }\n\n nonVendorSpecificName = name;\n if (name.charAt(1) == '-' && name.indexOf('-', 2) > 0) {\n nonVendorSpecificName = `@${name.slice(name.indexOf('-', 2) + 1)}`;\n }\n\n switch (nonVendorSpecificName) {\n case '@charset':\n hasIdentifier = true;\n hasBlock = false;\n break;\n case '@namespace':\n hasExpression = true;\n hasBlock = false;\n break;\n case '@keyframes':\n case '@counter-style':\n hasIdentifier = true;\n break;\n case '@document':\n case '@supports':\n hasUnknown = true;\n isRooted = false;\n break;\n default:\n hasUnknown = true;\n break;\n }\n\n parserInput.commentStore.length = 0;\n\n if (hasIdentifier) {\n value = this.entity();\n if (!value) {\n error(`expected ${name} identifier`);\n }\n } else if (hasExpression) {\n value = this.expression();\n if (!value) {\n error(`expected ${name} expression`);\n }\n } else if (hasUnknown) {\n value = this.permissiveValue(/^[{;]/);\n hasBlock = (parserInput.currentChar() === '{');\n if (!value) {\n if (!hasBlock && parserInput.currentChar() !== ';') {\n error(`${name} rule is missing block or ending semi-colon`);\n }\n }\n else if (!value.value) {\n value = null;\n }\n }\n\n if (hasBlock) {\n rules = this.blockRuleset();\n }\n\n if (rules || (!hasBlock && value && parserInput.$char(';'))) {\n parserInput.forget();\n return new(tree.AtRule)(name, value, rules, index, fileInfo,\n context.dumpLineNumbers ? getDebugInfo(index) : null,\n isRooted\n );\n }\n\n parserInput.restore('at-rule options not recognised');\n },\n\n //\n // A Value is a comma-delimited list of Expressions\n //\n // font-family: Baskerville, Georgia, serif;\n //\n // In a Rule, a Value represents everything after the `:`,\n // and before the `;`.\n //\n value: function () {\n let e;\n const expressions = [];\n const index = parserInput.i;\n\n do {\n e = this.expression();\n if (e) {\n expressions.push(e);\n if (!parserInput.$char(',')) { break; }\n }\n } while (e);\n\n if (expressions.length > 0) {\n return new(tree.Value)(expressions, index);\n }\n },\n important: function () {\n if (parserInput.currentChar() === '!') {\n return parserInput.$re(/^! *important/);\n }\n },\n sub: function () {\n let a;\n let e;\n\n parserInput.save();\n if (parserInput.$char('(')) {\n a = this.addition();\n if (a && parserInput.$char(')')) {\n parserInput.forget();\n e = new(tree.Expression)([a]);\n e.parens = true;\n return e;\n }\n parserInput.restore('Expected \\')\\'');\n return;\n }\n parserInput.restore();\n },\n multiplication: function () {\n let m;\n let a;\n let op;\n let operation;\n let isSpaced;\n m = this.operand();\n if (m) {\n isSpaced = parserInput.isWhitespace(-1);\n while (true) {\n if (parserInput.peek(/^\\/[*\\/]/)) {\n break;\n }\n\n parserInput.save();\n\n op = parserInput.$char('/') || parserInput.$char('*') || parserInput.$str('./');\n\n if (!op) { parserInput.forget(); break; }\n\n a = this.operand();\n\n if (!a) { parserInput.restore(); break; }\n parserInput.forget();\n\n m.parensInOp = true;\n a.parensInOp = true;\n operation = new(tree.Operation)(op, [operation || m, a], isSpaced);\n isSpaced = parserInput.isWhitespace(-1);\n }\n return operation || m;\n }\n },\n addition: function () {\n let m;\n let a;\n let op;\n let operation;\n let isSpaced;\n m = this.multiplication();\n if (m) {\n isSpaced = parserInput.isWhitespace(-1);\n while (true) {\n op = parserInput.$re(/^[-+]\\s+/) || (!isSpaced && (parserInput.$char('+') || parserInput.$char('-')));\n if (!op) {\n break;\n }\n a = this.multiplication();\n if (!a) {\n break;\n }\n\n m.parensInOp = true;\n a.parensInOp = true;\n operation = new(tree.Operation)(op, [operation || m, a], isSpaced);\n isSpaced = parserInput.isWhitespace(-1);\n }\n return operation || m;\n }\n },\n conditions: function () {\n let a;\n let b;\n const index = parserInput.i;\n let condition;\n\n a = this.condition(true);\n if (a) {\n while (true) {\n if (!parserInput.peek(/^,\\s*(not\\s*)?\\(/) || !parserInput.$char(',')) {\n break;\n }\n b = this.condition(true);\n if (!b) {\n break;\n }\n condition = new(tree.Condition)('or', condition || a, b, index);\n }\n return condition || a;\n }\n },\n condition: function (needsParens) {\n let result;\n let logical;\n let next;\n function or() {\n return parserInput.$str('or');\n }\n\n result = this.conditionAnd(needsParens);\n if (!result) {\n return ;\n }\n logical = or();\n if (logical) {\n next = this.condition(needsParens);\n if (next) {\n result = new(tree.Condition)(logical, result, next);\n } else {\n return ;\n }\n }\n return result;\n },\n conditionAnd: function (needsParens) {\n let result;\n let logical;\n let next;\n const self = this;\n function insideCondition() {\n const cond = self.negatedCondition(needsParens) || self.parenthesisCondition(needsParens);\n if (!cond && !needsParens) {\n return self.atomicCondition(needsParens);\n }\n return cond;\n }\n function and() {\n return parserInput.$str('and');\n }\n\n result = insideCondition();\n if (!result) {\n return ;\n }\n logical = and();\n if (logical) {\n next = this.conditionAnd(needsParens);\n if (next) {\n result = new(tree.Condition)(logical, result, next);\n } else {\n return ;\n }\n }\n return result;\n },\n negatedCondition: function (needsParens) {\n if (parserInput.$str('not')) {\n const result = this.parenthesisCondition(needsParens);\n if (result) {\n result.negate = !result.negate;\n }\n return result;\n }\n },\n parenthesisCondition: function (needsParens) {\n function tryConditionFollowedByParenthesis(me) {\n let body;\n parserInput.save();\n body = me.condition(needsParens);\n if (!body) {\n parserInput.restore();\n return ;\n }\n if (!parserInput.$char(')')) {\n parserInput.restore();\n return ;\n }\n parserInput.forget();\n return body;\n }\n\n let body;\n parserInput.save();\n if (!parserInput.$str('(')) {\n parserInput.restore();\n return ;\n }\n body = tryConditionFollowedByParenthesis(this);\n if (body) {\n parserInput.forget();\n return body;\n }\n\n body = this.atomicCondition(needsParens);\n if (!body) {\n parserInput.restore();\n return ;\n }\n if (!parserInput.$char(')')) {\n parserInput.restore(`expected ')' got '${parserInput.currentChar()}'`);\n return ;\n }\n parserInput.forget();\n return body;\n },\n atomicCondition: function (needsParens) {\n const entities = this.entities;\n const index = parserInput.i;\n let a;\n let b;\n let c;\n let op;\n\n function cond() {\n return this.addition() || entities.keyword() || entities.quoted() || entities.mixinLookup();\n }\n cond = cond.bind(this);\n\n a = cond();\n if (a) {\n if (parserInput.$char('>')) {\n if (parserInput.$char('=')) {\n op = '>=';\n } else {\n op = '>';\n }\n } else\n if (parserInput.$char('<')) {\n if (parserInput.$char('=')) {\n op = '<=';\n } else {\n op = '<';\n }\n } else\n if (parserInput.$char('=')) {\n if (parserInput.$char('>')) {\n op = '=>';\n } else if (parserInput.$char('<')) {\n op = '=<';\n } else {\n op = '=';\n }\n }\n if (op) {\n b = cond();\n if (b) {\n c = new(tree.Condition)(op, a, b, index, false);\n } else {\n error('expected expression');\n }\n } else {\n c = new(tree.Condition)('=', a, new(tree.Keyword)('true'), index, false);\n }\n return c;\n }\n },\n\n //\n // An operand is anything that can be part of an operation,\n // such as a Color, or a Variable\n //\n operand: function () {\n const entities = this.entities;\n let negate;\n\n if (parserInput.peek(/^-[@\\$\\(]/)) {\n negate = parserInput.$char('-');\n }\n\n let o = this.sub() || entities.dimension() ||\n entities.color() || entities.variable() ||\n entities.property() || entities.call() ||\n entities.quoted(true) || entities.colorKeyword() ||\n entities.mixinLookup();\n\n if (negate) {\n o.parensInOp = true;\n o = new(tree.Negative)(o);\n }\n\n return o;\n },\n\n //\n // Expressions either represent mathematical operations,\n // or white-space delimited Entities.\n //\n // 1px solid black\n // @var * 2\n //\n expression: function () {\n const entities = [];\n let e;\n let delim;\n const index = parserInput.i;\n\n do {\n e = this.comment();\n if (e) {\n entities.push(e);\n continue;\n }\n e = this.addition() || this.entity();\n\n if (e instanceof tree.Comment) {\n e = null;\n }\n\n if (e) {\n entities.push(e);\n // operations do not allow keyword \"/\" dimension (e.g. small/20px) so we support that here\n if (!parserInput.peek(/^\\/[\\/*]/)) {\n delim = parserInput.$char('/');\n if (delim) {\n entities.push(new(tree.Anonymous)(delim, index));\n }\n }\n }\n } while (e);\n if (entities.length > 0) {\n return new(tree.Expression)(entities);\n }\n },\n property: function () {\n const name = parserInput.$re(/^(\\*?-?[_a-zA-Z0-9-]+)\\s*:/);\n if (name) {\n return name[1];\n }\n },\n ruleProperty: function () {\n let name = [];\n const index = [];\n let s;\n let k;\n\n parserInput.save();\n\n const simpleProperty = parserInput.$re(/^([_a-zA-Z0-9-]+)\\s*:/);\n if (simpleProperty) {\n name = [new(tree.Keyword)(simpleProperty[1])];\n parserInput.forget();\n return name;\n }\n\n function match(re) {\n const i = parserInput.i;\n const chunk = parserInput.$re(re);\n if (chunk) {\n index.push(i);\n return name.push(chunk[1]);\n }\n }\n\n match(/^(\\*?)/);\n while (true) {\n if (!match(/^((?:[\\w-]+)|(?:[@\\$]\\{[\\w-]+\\}))/)) {\n break;\n }\n }\n\n if ((name.length > 1) && match(/^((?:\\+_|\\+)?)\\s*:/)) {\n parserInput.forget();\n\n // at last, we have the complete match now. move forward,\n // convert name particles to tree objects and return:\n if (name[0] === '') {\n name.shift();\n index.shift();\n }\n for (k = 0; k < name.length; k++) {\n s = name[k];\n name[k] = (s.charAt(0) !== '@' && s.charAt(0) !== '$') ?\n new(tree.Keyword)(s) :\n (s.charAt(0) === '@' ?\n new(tree.Variable)(`@${s.slice(2, -1)}`, index[k], fileInfo) :\n new(tree.Property)(`$${s.slice(2, -1)}`, index[k], fileInfo));\n }\n return name;\n }\n parserInput.restore();\n }\n }\n };\n};\nParser.serializeVars = vars => {\n let s = '';\n\n for (const name in vars) {\n if (Object.hasOwnProperty.call(vars, name)) {\n const value = vars[name];\n s += `${((name[0] === '@') ? '' : '@') + name}: ${value}${(String(value).slice(-1) === ';') ? '' : ';'}`;\n }\n }\n\n return s;\n};\n\nexport default Parser;\n","import Anonymous from '../tree/anonymous';\nimport Keyword from '../tree/keyword';\n\nfunction boolean(condition) {\n return condition ? Keyword.True : Keyword.False;\n}\n\n/**\n * Functions with evalArgs set to false are sent context\n * as the first argument.\n */\nfunction If(context, condition, trueValue, falseValue) {\n return condition.eval(context) ? trueValue.eval(context)\n : (falseValue ? falseValue.eval(context) : new Anonymous);\n}\nIf.evalArgs = false;\n\nfunction isdefined(context, variable) {\n try {\n variable.eval(context);\n return Keyword.True;\n } catch (e) {\n return Keyword.False;\n }\n}\n\nisdefined.evalArgs = false;\n\nexport default { isdefined, boolean, 'if': If };\n","import Dimension from '../tree/dimension';\nimport Color from '../tree/color';\nimport Quoted from '../tree/quoted';\nimport Anonymous from '../tree/anonymous';\nimport Expression from '../tree/expression';\nimport Operation from '../tree/operation';\nlet colorFunctions;\n\nfunction clamp(val) {\n return Math.min(1, Math.max(0, val));\n}\nfunction hsla(origColor, hsl) {\n const color = colorFunctions.hsla(hsl.h, hsl.s, hsl.l, hsl.a);\n if (color) {\n if (origColor.value && \n /^(rgb|hsl)/.test(origColor.value)) {\n color.value = origColor.value;\n } else {\n color.value = 'rgb';\n }\n return color;\n }\n}\nfunction toHSL(color) {\n if (color.toHSL) {\n return color.toHSL();\n } else {\n throw new Error('Argument cannot be evaluated to a color');\n }\n}\n\nfunction toHSV(color) {\n if (color.toHSV) {\n return color.toHSV();\n } else {\n throw new Error('Argument cannot be evaluated to a color');\n }\n}\n\nfunction number(n) {\n if (n instanceof Dimension) {\n return parseFloat(n.unit.is('%') ? n.value / 100 : n.value);\n } else if (typeof n === 'number') {\n return n;\n } else {\n throw {\n type: 'Argument',\n message: 'color functions take numbers as parameters'\n };\n }\n}\nfunction scaled(n, size) {\n if (n instanceof Dimension && n.unit.is('%')) {\n return parseFloat(n.value * size / 100);\n } else {\n return number(n);\n }\n}\ncolorFunctions = {\n rgb: function (r, g, b) {\n let a = 1\n /**\n * Comma-less syntax\n * e.g. rgb(0 128 255 / 50%)\n */\n if (r instanceof Expression) {\n const val = r.value\n r = val[0]\n g = val[1]\n b = val[2]\n /** \n * @todo - should this be normalized in\n * function caller? Or parsed differently?\n */\n if (b instanceof Operation) {\n const op = b\n b = op.operands[0]\n a = op.operands[1]\n }\n }\n const color = colorFunctions.rgba(r, g, b, a);\n if (color) {\n color.value = 'rgb';\n return color;\n }\n },\n rgba: function (r, g, b, a) {\n try {\n if (r instanceof Color) {\n if (g) {\n a = number(g);\n } else {\n a = r.alpha;\n }\n return new Color(r.rgb, a, 'rgba');\n }\n const rgb = [r, g, b].map(c => scaled(c, 255));\n a = number(a);\n return new Color(rgb, a, 'rgba');\n }\n catch (e) {}\n },\n hsl: function (h, s, l) {\n let a = 1\n if (h instanceof Expression) {\n const val = h.value\n h = val[0]\n s = val[1]\n l = val[2]\n\n if (l instanceof Operation) {\n const op = l\n l = op.operands[0]\n a = op.operands[1]\n }\n }\n const color = colorFunctions.hsla(h, s, l, a);\n if (color) {\n color.value = 'hsl';\n return color;\n }\n },\n hsla: function (h, s, l, a) {\n try {\n if (h instanceof Color) {\n if (s) {\n a = number(s);\n } else {\n a = h.alpha;\n }\n return new Color(h.rgb, a, 'hsla');\n }\n\n let m1;\n let m2;\n\n function hue(h) {\n h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);\n if (h * 6 < 1) {\n return m1 + (m2 - m1) * h * 6;\n }\n else if (h * 2 < 1) {\n return m2;\n }\n else if (h * 3 < 2) {\n return m1 + (m2 - m1) * (2 / 3 - h) * 6;\n }\n else {\n return m1;\n }\n }\n\n h = (number(h) % 360) / 360;\n s = clamp(number(s));l = clamp(number(l));a = clamp(number(a));\n\n m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;\n m1 = l * 2 - m2;\n\n const rgb = [\n hue(h + 1 / 3) * 255,\n hue(h) * 255,\n hue(h - 1 / 3) * 255\n ];\n a = number(a);\n return new Color(rgb, a, 'hsla');\n }\n catch (e) {}\n },\n\n hsv: function(h, s, v) {\n return colorFunctions.hsva(h, s, v, 1.0);\n },\n\n hsva: function(h, s, v, a) {\n h = ((number(h) % 360) / 360) * 360;\n s = number(s);v = number(v);a = number(a);\n\n let i;\n let f;\n i = Math.floor((h / 60) % 6);\n f = (h / 60) - i;\n\n const vs = [v,\n v * (1 - s),\n v * (1 - f * s),\n v * (1 - (1 - f) * s)];\n const perm = [[0, 3, 1],\n [2, 0, 1],\n [1, 0, 3],\n [1, 2, 0],\n [3, 1, 0],\n [0, 1, 2]];\n\n return colorFunctions.rgba(vs[perm[i][0]] * 255,\n vs[perm[i][1]] * 255,\n vs[perm[i][2]] * 255,\n a);\n },\n\n hue: function (color) {\n return new Dimension(toHSL(color).h);\n },\n saturation: function (color) {\n return new Dimension(toHSL(color).s * 100, '%');\n },\n lightness: function (color) {\n return new Dimension(toHSL(color).l * 100, '%');\n },\n hsvhue: function(color) {\n return new Dimension(toHSV(color).h);\n },\n hsvsaturation: function (color) {\n return new Dimension(toHSV(color).s * 100, '%');\n },\n hsvvalue: function (color) {\n return new Dimension(toHSV(color).v * 100, '%');\n },\n red: function (color) {\n return new Dimension(color.rgb[0]);\n },\n green: function (color) {\n return new Dimension(color.rgb[1]);\n },\n blue: function (color) {\n return new Dimension(color.rgb[2]);\n },\n alpha: function (color) {\n return new Dimension(toHSL(color).a);\n },\n luma: function (color) {\n return new Dimension(color.luma() * color.alpha * 100, '%');\n },\n luminance: function (color) {\n const luminance =\n (0.2126 * color.rgb[0] / 255) +\n (0.7152 * color.rgb[1] / 255) +\n (0.0722 * color.rgb[2] / 255);\n\n return new Dimension(luminance * color.alpha * 100, '%');\n },\n saturate: function (color, amount, method) {\n // filter: saturate(3.2);\n // should be kept as is, so check for color\n if (!color.rgb) {\n return null;\n }\n const hsl = toHSL(color);\n\n if (typeof method !== 'undefined' && method.value === 'relative') {\n hsl.s += hsl.s * amount.value / 100;\n }\n else {\n hsl.s += amount.value / 100;\n }\n hsl.s = clamp(hsl.s);\n return hsla(color, hsl);\n },\n desaturate: function (color, amount, method) {\n const hsl = toHSL(color);\n\n if (typeof method !== 'undefined' && method.value === 'relative') {\n hsl.s -= hsl.s * amount.value / 100;\n }\n else {\n hsl.s -= amount.value / 100;\n }\n hsl.s = clamp(hsl.s);\n return hsla(color, hsl);\n },\n lighten: function (color, amount, method) {\n const hsl = toHSL(color);\n\n if (typeof method !== 'undefined' && method.value === 'relative') {\n hsl.l += hsl.l * amount.value / 100;\n }\n else {\n hsl.l += amount.value / 100;\n }\n hsl.l = clamp(hsl.l);\n return hsla(color, hsl);\n },\n darken: function (color, amount, method) {\n const hsl = toHSL(color);\n\n if (typeof method !== 'undefined' && method.value === 'relative') {\n hsl.l -= hsl.l * amount.value / 100;\n }\n else {\n hsl.l -= amount.value / 100;\n }\n hsl.l = clamp(hsl.l);\n return hsla(color, hsl);\n },\n fadein: function (color, amount, method) {\n const hsl = toHSL(color);\n\n if (typeof method !== 'undefined' && method.value === 'relative') {\n hsl.a += hsl.a * amount.value / 100;\n }\n else {\n hsl.a += amount.value / 100;\n }\n hsl.a = clamp(hsl.a);\n return hsla(color, hsl);\n },\n fadeout: function (color, amount, method) {\n const hsl = toHSL(color);\n\n if (typeof method !== 'undefined' && method.value === 'relative') {\n hsl.a -= hsl.a * amount.value / 100;\n }\n else {\n hsl.a -= amount.value / 100;\n }\n hsl.a = clamp(hsl.a);\n return hsla(color, hsl);\n },\n fade: function (color, amount) {\n const hsl = toHSL(color);\n\n hsl.a = amount.value / 100;\n hsl.a = clamp(hsl.a);\n return hsla(color, hsl);\n },\n spin: function (color, amount) {\n const hsl = toHSL(color);\n const hue = (hsl.h + amount.value) % 360;\n\n hsl.h = hue < 0 ? 360 + hue : hue;\n\n return hsla(color, hsl);\n },\n //\n // Copyright (c) 2006-2009 Hampton Catlin, Natalie Weizenbaum, and Chris Eppstein\n // http://sass-lang.com\n //\n mix: function (color1, color2, weight) {\n if (!weight) {\n weight = new Dimension(50);\n }\n const p = weight.value / 100.0;\n const w = p * 2 - 1;\n const a = toHSL(color1).a - toHSL(color2).a;\n\n const w1 = (((w * a == -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;\n const w2 = 1 - w1;\n\n const rgb = [color1.rgb[0] * w1 + color2.rgb[0] * w2,\n color1.rgb[1] * w1 + color2.rgb[1] * w2,\n color1.rgb[2] * w1 + color2.rgb[2] * w2];\n\n const alpha = color1.alpha * p + color2.alpha * (1 - p);\n\n return new Color(rgb, alpha);\n },\n greyscale: function (color) {\n return colorFunctions.desaturate(color, new Dimension(100));\n },\n contrast: function (color, dark, light, threshold) {\n // filter: contrast(3.2);\n // should be kept as is, so check for color\n if (!color.rgb) {\n return null;\n }\n if (typeof light === 'undefined') {\n light = colorFunctions.rgba(255, 255, 255, 1.0);\n }\n if (typeof dark === 'undefined') {\n dark = colorFunctions.rgba(0, 0, 0, 1.0);\n }\n // Figure out which is actually light and dark:\n if (dark.luma() > light.luma()) {\n const t = light;\n light = dark;\n dark = t;\n }\n if (typeof threshold === 'undefined') {\n threshold = 0.43;\n } else {\n threshold = number(threshold);\n }\n if (color.luma() < threshold) {\n return light;\n } else {\n return dark;\n }\n },\n // Changes made in 2.7.0 - Reverted in 3.0.0\n // contrast: function (color, color1, color2, threshold) {\n // // Return which of `color1` and `color2` has the greatest contrast with `color`\n // // according to the standard WCAG contrast ratio calculation.\n // // http://www.w3.org/TR/WCAG20/#contrast-ratiodef\n // // The threshold param is no longer used, in line with SASS.\n // // filter: contrast(3.2);\n // // should be kept as is, so check for color\n // if (!color.rgb) {\n // return null;\n // }\n // if (typeof color1 === 'undefined') {\n // color1 = colorFunctions.rgba(0, 0, 0, 1.0);\n // }\n // if (typeof color2 === 'undefined') {\n // color2 = colorFunctions.rgba(255, 255, 255, 1.0);\n // }\n // var contrast1, contrast2;\n // var luma = color.luma();\n // var luma1 = color1.luma();\n // var luma2 = color2.luma();\n // // Calculate contrast ratios for each color\n // if (luma > luma1) {\n // contrast1 = (luma + 0.05) / (luma1 + 0.05);\n // } else {\n // contrast1 = (luma1 + 0.05) / (luma + 0.05);\n // }\n // if (luma > luma2) {\n // contrast2 = (luma + 0.05) / (luma2 + 0.05);\n // } else {\n // contrast2 = (luma2 + 0.05) / (luma + 0.05);\n // }\n // if (contrast1 > contrast2) {\n // return color1;\n // } else {\n // return color2;\n // }\n // },\n argb: function (color) {\n return new Anonymous(color.toARGB());\n },\n color: function(c) {\n if ((c instanceof Quoted) &&\n (/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3,4})$/i.test(c.value))) {\n const val = c.value.slice(1);\n return new Color(val, undefined, `#${val}`);\n }\n if ((c instanceof Color) || (c = Color.fromKeyword(c.value))) {\n c.value = undefined;\n return c;\n }\n throw {\n type: 'Argument',\n message: 'argument must be a color keyword or 3|4|6|8 digit hex e.g. #FFF'\n };\n },\n tint: function(color, amount) {\n return colorFunctions.mix(colorFunctions.rgb(255, 255, 255), color, amount);\n },\n shade: function(color, amount) {\n return colorFunctions.mix(colorFunctions.rgb(0, 0, 0), color, amount);\n }\n};\n\nexport default colorFunctions;\n","import Color from '../tree/color';\n\n// Color Blending\n// ref: http://www.w3.org/TR/compositing-1\n\nfunction colorBlend(mode, color1, color2) {\n const ab = color1.alpha; // result\n\n let // backdrop\n cb;\n\n const as = color2.alpha;\n\n let // source\n cs;\n\n let ar;\n let cr;\n const r = [];\n\n ar = as + ab * (1 - as);\n for (let i = 0; i < 3; i++) {\n cb = color1.rgb[i] / 255;\n cs = color2.rgb[i] / 255;\n cr = mode(cb, cs);\n if (ar) {\n cr = (as * cs + ab * (cb -\n as * (cb + cs - cr))) / ar;\n }\n r[i] = cr * 255;\n }\n\n return new Color(r, ar);\n}\n\nconst colorBlendModeFunctions = {\n multiply: function(cb, cs) {\n return cb * cs;\n },\n screen: function(cb, cs) {\n return cb + cs - cb * cs;\n },\n overlay: function(cb, cs) {\n cb *= 2;\n return (cb <= 1) ?\n colorBlendModeFunctions.multiply(cb, cs) :\n colorBlendModeFunctions.screen(cb - 1, cs);\n },\n softlight: function(cb, cs) {\n let d = 1;\n let e = cb;\n if (cs > 0.5) {\n e = 1;\n d = (cb > 0.25) ? Math.sqrt(cb)\n : ((16 * cb - 12) * cb + 4) * cb;\n }\n return cb - (1 - 2 * cs) * e * (d - cb);\n },\n hardlight: function(cb, cs) {\n return colorBlendModeFunctions.overlay(cs, cb);\n },\n difference: function(cb, cs) {\n return Math.abs(cb - cs);\n },\n exclusion: function(cb, cs) {\n return cb + cs - 2 * cb * cs;\n },\n\n // non-w3c functions:\n average: function(cb, cs) {\n return (cb + cs) / 2;\n },\n negation: function(cb, cs) {\n return 1 - Math.abs(cb + cs - 1);\n }\n};\n\nfor (const f in colorBlendModeFunctions) {\n if (colorBlendModeFunctions.hasOwnProperty(f)) {\n colorBlend[f] = colorBlend.bind(null, colorBlendModeFunctions[f]);\n }\n}\n\nexport default colorBlend;\n","import Comment from '../tree/comment';\nimport Node from '../tree/node';\nimport Dimension from '../tree/dimension';\nimport Declaration from '../tree/declaration';\nimport Expression from '../tree/expression';\nimport Ruleset from '../tree/ruleset';\nimport Selector from '../tree/selector';\nimport Element from '../tree/element';\nimport Quote from '../tree/quoted';\nimport Value from '../tree/value';\n\nconst getItemsFromNode = node => {\n // handle non-array values as an array of length 1\n // return 'undefined' if index is invalid\n const items = Array.isArray(node.value) ?\n node.value : Array(node);\n\n return items;\n};\n\nexport default {\n _SELF: function(n) {\n return n;\n },\n '~': function(...expr) {\n if (expr.length === 1) {\n return expr[0];\n }\n return new Value(expr);\n },\n extract: function(values, index) {\n // (1-based index)\n index = index.value - 1;\n\n return getItemsFromNode(values)[index];\n },\n length: function(values) {\n return new Dimension(getItemsFromNode(values).length);\n },\n /**\n * Creates a Less list of incremental values.\n * Modeled after Lodash's range function, also exists natively in PHP\n * \n * @param {Dimension} [start=1]\n * @param {Dimension} end - e.g. 10 or 10px - unit is added to output\n * @param {Dimension} [step=1] \n */\n range: function(start, end, step) {\n let from;\n let to;\n let stepValue = 1;\n const list = [];\n if (end) {\n to = end;\n from = start.value;\n if (step) {\n stepValue = step.value;\n }\n }\n else {\n from = 1;\n to = start;\n }\n\n for (let i = from; i <= to.value; i += stepValue) {\n list.push(new Dimension(i, to.unit));\n }\n\n return new Expression(list);\n },\n each: function(list, rs) {\n const rules = [];\n let newRules;\n let iterator;\n\n const tryEval = val => {\n if (val instanceof Node) {\n return val.eval(this.context);\n }\n return val;\n };\n\n if (list.value && !(list instanceof Quote)) {\n if (Array.isArray(list.value)) {\n iterator = list.value.map(tryEval);\n } else {\n iterator = [tryEval(list.value)];\n }\n } else if (list.ruleset) {\n iterator = tryEval(list.ruleset).rules;\n } else if (list.rules) {\n iterator = list.rules.map(tryEval);\n } else if (Array.isArray(list)) {\n iterator = list.map(tryEval);\n } else {\n iterator = [tryEval(list)];\n }\n\n let valueName = '@value';\n let keyName = '@key';\n let indexName = '@index';\n\n if (rs.params) {\n valueName = rs.params[0] && rs.params[0].name;\n keyName = rs.params[1] && rs.params[1].name;\n indexName = rs.params[2] && rs.params[2].name;\n rs = rs.rules;\n } else {\n rs = rs.ruleset;\n }\n\n for (let i = 0; i < iterator.length; i++) {\n let key;\n let value;\n const item = iterator[i];\n if (item instanceof Declaration) {\n key = typeof item.name === 'string' ? item.name : item.name[0].value;\n value = item.value;\n } else {\n key = new Dimension(i + 1);\n value = item;\n }\n\n if (item instanceof Comment) {\n continue;\n }\n\n newRules = rs.rules.slice(0);\n if (valueName) {\n newRules.push(new Declaration(valueName,\n value,\n false, false, this.index, this.currentFileInfo));\n }\n if (indexName) {\n newRules.push(new Declaration(indexName,\n new Dimension(i + 1),\n false, false, this.index, this.currentFileInfo));\n }\n if (keyName) {\n newRules.push(new Declaration(keyName,\n key,\n false, false, this.index, this.currentFileInfo));\n }\n\n rules.push(new Ruleset([ new(Selector)([ new Element(\"\", '&') ]) ],\n newRules,\n rs.strictImports,\n rs.visibilityInfo()\n ));\n }\n\n return new Ruleset([ new(Selector)([ new Element(\"\", '&') ]) ],\n rules,\n rs.strictImports,\n rs.visibilityInfo()\n ).eval(this.context);\n }\n};\n","import Dimension from '../tree/dimension';\n\nconst MathHelper = (fn, unit, n) => {\n if (!(n instanceof Dimension)) {\n throw { type: 'Argument', message: 'argument must be a number' };\n }\n if (unit == null) {\n unit = n.unit;\n } else {\n n = n.unify();\n }\n return new Dimension(fn(parseFloat(n.value)), unit);\n};\n\nexport default MathHelper;","import mathHelper from './math-helper.js';\n\nconst mathFunctions = {\n // name, unit\n ceil: null,\n floor: null,\n sqrt: null,\n abs: null,\n tan: '',\n sin: '',\n cos: '',\n atan: 'rad',\n asin: 'rad',\n acos: 'rad'\n};\n\nfor (const f in mathFunctions) {\n if (mathFunctions.hasOwnProperty(f)) {\n mathFunctions[f] = mathHelper.bind(null, Math[f], mathFunctions[f]);\n }\n}\n\nmathFunctions.round = (n, f) => {\n const fraction = typeof f === 'undefined' ? 0 : f.value;\n return mathHelper(num => num.toFixed(fraction), null, n);\n};\n\nexport default mathFunctions;\n","import Dimension from '../tree/dimension';\nimport Anonymous from '../tree/anonymous';\nimport mathHelper from './math-helper.js';\n\nconst minMax = function (isMin, args) {\n args = Array.prototype.slice.call(args);\n switch (args.length) {\n case 0: throw { type: 'Argument', message: 'one or more arguments required' };\n }\n let i; // key is the unit.toString() for unified Dimension values,\n let j;\n let current;\n let currentUnified;\n let referenceUnified;\n let unit;\n let unitStatic;\n let unitClone;\n\n const // elems only contains original argument values.\n order = [];\n\n const values = {};\n // value is the index into the order array.\n for (i = 0; i < args.length; i++) {\n current = args[i];\n if (!(current instanceof Dimension)) {\n if (Array.isArray(args[i].value)) {\n Array.prototype.push.apply(args, Array.prototype.slice.call(args[i].value));\n }\n continue;\n }\n currentUnified = current.unit.toString() === '' && unitClone !== undefined ? new Dimension(current.value, unitClone).unify() : current.unify();\n unit = currentUnified.unit.toString() === '' && unitStatic !== undefined ? unitStatic : currentUnified.unit.toString();\n unitStatic = unit !== '' && unitStatic === undefined || unit !== '' && order[0].unify().unit.toString() === '' ? unit : unitStatic;\n unitClone = unit !== '' && unitClone === undefined ? current.unit.toString() : unitClone;\n j = values[''] !== undefined && unit !== '' && unit === unitStatic ? values[''] : values[unit];\n if (j === undefined) {\n if (unitStatic !== undefined && unit !== unitStatic) {\n throw { type: 'Argument', message: 'incompatible types' };\n }\n values[unit] = order.length;\n order.push(current);\n continue;\n }\n referenceUnified = order[j].unit.toString() === '' && unitClone !== undefined ? new Dimension(order[j].value, unitClone).unify() : order[j].unify();\n if ( isMin && currentUnified.value < referenceUnified.value ||\n !isMin && currentUnified.value > referenceUnified.value) {\n order[j] = current;\n }\n }\n if (order.length == 1) {\n return order[0];\n }\n args = order.map(function (a) { return a.toCSS(this.context); }).join(this.context.compress ? ',' : ', ');\n return new Anonymous(`${isMin ? 'min' : 'max'}(${args})`);\n};\n\nexport default {\n min: function(...args) {\n try {\n return minMax(true, args);\n } catch (e) {}\n },\n max: function(...args) {\n try {\n return minMax(false, args);\n } catch (e) {}\n },\n convert: function (val, unit) {\n return val.convertTo(unit.value);\n },\n pi: function () {\n return new Dimension(Math.PI);\n },\n mod: function(a, b) {\n return new Dimension(a.value % b.value, a.unit);\n },\n pow: function(x, y) {\n if (typeof x === 'number' && typeof y === 'number') {\n x = new Dimension(x);\n y = new Dimension(y);\n } else if (!(x instanceof Dimension) || !(y instanceof Dimension)) {\n throw { type: 'Argument', message: 'arguments must be numbers' };\n }\n\n return new Dimension(Math.pow(x.value, y.value), x.unit);\n },\n percentage: function (n) {\n const result = mathHelper(num => num * 100, '%', n);\n\n return result;\n }\n};\n","import Quoted from '../tree/quoted';\nimport Anonymous from '../tree/anonymous';\nimport JavaScript from '../tree/javascript';\n\nexport default {\n e: function (str) {\n return new Quoted('\"', str instanceof JavaScript ? str.evaluated : str.value, true);\n },\n escape: function (str) {\n return new Anonymous(\n encodeURI(str.value).replace(/=/g, '%3D').replace(/:/g, '%3A').replace(/#/g, '%23').replace(/;/g, '%3B')\n .replace(/\\(/g, '%28').replace(/\\)/g, '%29'));\n },\n replace: function (string, pattern, replacement, flags) {\n let result = string.value;\n replacement = (replacement.type === 'Quoted') ?\n replacement.value : replacement.toCSS();\n result = result.replace(new RegExp(pattern.value, flags ? flags.value : ''), replacement);\n return new Quoted(string.quote || '', result, string.escaped);\n },\n '%': function (string /* arg, arg, ... */) {\n const args = Array.prototype.slice.call(arguments, 1);\n let result = string.value;\n\n for (let i = 0; i < args.length; i++) {\n /* jshint loopfunc:true */\n result = result.replace(/%[sda]/i, token => {\n const value = ((args[i].type === 'Quoted') &&\n token.match(/s/i)) ? args[i].value : args[i].toCSS();\n return token.match(/[A-Z]$/) ? encodeURIComponent(value) : value;\n });\n }\n result = result.replace(/%%/g, '%');\n return new Quoted(string.quote || '', result, string.escaped);\n }\n};\n","import Keyword from '../tree/keyword';\nimport DetachedRuleset from '../tree/detached-ruleset';\nimport Dimension from '../tree/dimension';\nimport Color from '../tree/color';\nimport Quoted from '../tree/quoted';\nimport Anonymous from '../tree/anonymous';\nimport URL from '../tree/url';\nimport Operation from '../tree/operation';\n\nconst isa = (n, Type) => (n instanceof Type) ? Keyword.True : Keyword.False;\nconst isunit = (n, unit) => {\n if (unit === undefined) {\n throw { type: 'Argument', message: 'missing the required second argument to isunit.' };\n }\n unit = typeof unit.value === 'string' ? unit.value : unit;\n if (typeof unit !== 'string') {\n throw { type: 'Argument', message: 'Second argument to isunit should be a unit or a string.' };\n }\n return (n instanceof Dimension) && n.unit.is(unit) ? Keyword.True : Keyword.False;\n};\n\nexport default {\n isruleset: function (n) {\n return isa(n, DetachedRuleset);\n },\n iscolor: function (n) {\n return isa(n, Color);\n },\n isnumber: function (n) {\n return isa(n, Dimension);\n },\n isstring: function (n) {\n return isa(n, Quoted);\n },\n iskeyword: function (n) {\n return isa(n, Keyword);\n },\n isurl: function (n) {\n return isa(n, URL);\n },\n ispixel: function (n) {\n return isunit(n, 'px');\n },\n ispercentage: function (n) {\n return isunit(n, '%');\n },\n isem: function (n) {\n return isunit(n, 'em');\n },\n isunit,\n unit: function (val, unit) {\n if (!(val instanceof Dimension)) {\n throw { type: 'Argument',\n message: `the first argument to unit must be a number${val instanceof Operation ? '. Have you forgotten parenthesis?' : ''}` };\n }\n if (unit) {\n if (unit instanceof Keyword) {\n unit = unit.value;\n } else {\n unit = unit.toCSS();\n }\n } else {\n unit = '';\n }\n return new Dimension(val.value, unit);\n },\n 'get-unit': function (n) {\n return new Anonymous(n.unit);\n }\n};\n","import functionRegistry from './function-registry';\nimport functionCaller from './function-caller';\n\nimport boolean from './boolean';\nimport defaultFunc from './default';\nimport color from './color';\nimport colorBlending from './color-blending';\nimport dataUri from './data-uri';\nimport list from './list';\nimport math from './math';\nimport number from './number';\nimport string from './string';\nimport svg from './svg';\nimport types from './types';\n\nexport default environment => {\n const functions = { functionRegistry, functionCaller };\n\n // register functions\n functionRegistry.addMultiple(boolean);\n functionRegistry.add('default', defaultFunc.eval.bind(defaultFunc));\n functionRegistry.addMultiple(color);\n functionRegistry.addMultiple(colorBlending);\n functionRegistry.addMultiple(dataUri(environment));\n functionRegistry.addMultiple(list);\n functionRegistry.addMultiple(math);\n functionRegistry.addMultiple(number);\n functionRegistry.addMultiple(string);\n functionRegistry.addMultiple(svg(environment));\n functionRegistry.addMultiple(types);\n\n return functions;\n};\n","import Quoted from '../tree/quoted';\nimport URL from '../tree/url';\nimport * as utils from '../utils';\nimport logger from '../logger';\n\nexport default environment => {\n \n const fallback = (functionThis, node) => new URL(node, functionThis.index, functionThis.currentFileInfo).eval(functionThis.context); \n\n return { 'data-uri': function(mimetypeNode, filePathNode) {\n\n if (!filePathNode) {\n filePathNode = mimetypeNode;\n mimetypeNode = null;\n }\n\n let mimetype = mimetypeNode && mimetypeNode.value;\n let filePath = filePathNode.value;\n const currentFileInfo = this.currentFileInfo;\n const currentDirectory = currentFileInfo.rewriteUrls ?\n currentFileInfo.currentDirectory : currentFileInfo.entryPath;\n\n const fragmentStart = filePath.indexOf('#');\n let fragment = '';\n if (fragmentStart !== -1) {\n fragment = filePath.slice(fragmentStart);\n filePath = filePath.slice(0, fragmentStart);\n }\n const context = utils.clone(this.context);\n context.rawBuffer = true;\n\n const fileManager = environment.getFileManager(filePath, currentDirectory, context, environment, true);\n\n if (!fileManager) {\n return fallback(this, filePathNode);\n }\n\n let useBase64 = false;\n\n // detect the mimetype if not given\n if (!mimetypeNode) {\n\n mimetype = environment.mimeLookup(filePath);\n\n if (mimetype === 'image/svg+xml') {\n useBase64 = false;\n } else {\n // use base 64 unless it's an ASCII or UTF-8 format\n const charset = environment.charsetLookup(mimetype);\n useBase64 = ['US-ASCII', 'UTF-8'].indexOf(charset) < 0;\n }\n if (useBase64) { mimetype += ';base64'; }\n }\n else {\n useBase64 = /;base64$/.test(mimetype);\n }\n\n const fileSync = fileManager.loadFileSync(filePath, currentDirectory, context, environment);\n if (!fileSync.contents) {\n logger.warn(`Skipped data-uri embedding of ${filePath} because file not found`);\n return fallback(this, filePathNode || mimetypeNode);\n }\n let buf = fileSync.contents;\n if (useBase64 && !environment.encodeBase64) {\n return fallback(this, filePathNode);\n }\n\n buf = useBase64 ? environment.encodeBase64(buf) : encodeURIComponent(buf);\n\n const uri = `data:${mimetype},${buf}${fragment}`;\n\n return new URL(new Quoted(`\"${uri}\"`, uri, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo);\n }};\n};\n","import Dimension from '../tree/dimension';\nimport Color from '../tree/color';\nimport Expression from '../tree/expression';\nimport Quoted from '../tree/quoted';\nimport URL from '../tree/url';\n\nexport default environment => {\n return { 'svg-gradient': function(direction) {\n let stops;\n let gradientDirectionSvg;\n let gradientType = 'linear';\n let rectangleDimension = 'x=\"0\" y=\"0\" width=\"1\" height=\"1\"';\n const renderEnv = {compress: false};\n let returner;\n const directionValue = direction.toCSS(renderEnv);\n let i;\n let color;\n let position;\n let positionValue;\n let alpha;\n\n function throwArgumentDescriptor() {\n throw { type: 'Argument',\n message: 'svg-gradient expects direction, start_color [start_position], [color position,]...,' +\n ' end_color [end_position] or direction, color list' };\n }\n\n if (arguments.length == 2) {\n if (arguments[1].value.length < 2) {\n throwArgumentDescriptor();\n }\n stops = arguments[1].value;\n } else if (arguments.length < 3) {\n throwArgumentDescriptor();\n } else {\n stops = Array.prototype.slice.call(arguments, 1);\n }\n\n switch (directionValue) {\n case 'to bottom':\n gradientDirectionSvg = 'x1=\"0%\" y1=\"0%\" x2=\"0%\" y2=\"100%\"';\n break;\n case 'to right':\n gradientDirectionSvg = 'x1=\"0%\" y1=\"0%\" x2=\"100%\" y2=\"0%\"';\n break;\n case 'to bottom right':\n gradientDirectionSvg = 'x1=\"0%\" y1=\"0%\" x2=\"100%\" y2=\"100%\"';\n break;\n case 'to top right':\n gradientDirectionSvg = 'x1=\"0%\" y1=\"100%\" x2=\"100%\" y2=\"0%\"';\n break;\n case 'ellipse':\n case 'ellipse at center':\n gradientType = 'radial';\n gradientDirectionSvg = 'cx=\"50%\" cy=\"50%\" r=\"75%\"';\n rectangleDimension = 'x=\"-50\" y=\"-50\" width=\"101\" height=\"101\"';\n break;\n default:\n throw { type: 'Argument', message: 'svg-gradient direction must be \\'to bottom\\', \\'to right\\',' +\n ' \\'to bottom right\\', \\'to top right\\' or \\'ellipse at center\\'' };\n }\n returner = `<${gradientType}Gradient id=\"g\" ${gradientDirectionSvg}>`;\n\n for (i = 0; i < stops.length; i += 1) {\n if (stops[i] instanceof Expression) {\n color = stops[i].value[0];\n position = stops[i].value[1];\n } else {\n color = stops[i];\n position = undefined;\n }\n\n if (!(color instanceof Color) || (!((i === 0 || i + 1 === stops.length) && position === undefined) && !(position instanceof Dimension))) {\n throwArgumentDescriptor();\n }\n positionValue = position ? position.toCSS(renderEnv) : i === 0 ? '0%' : '100%';\n alpha = color.alpha;\n returner += ``;\n }\n returner += ``;\n\n returner = encodeURIComponent(returner);\n\n returner = `data:image/svg+xml,${returner}`;\n return new URL(new Quoted(`'${returner}'`, returner, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo);\n }};\n};\n","import contexts from './contexts';\nimport visitor from './visitors';\nimport tree from './tree';\n\nexport default function(root, options) {\n options = options || {};\n let evaldRoot;\n let variables = options.variables;\n const evalEnv = new contexts.Eval(options);\n\n //\n // Allows setting variables with a hash, so:\n //\n // `{ color: new tree.Color('#f01') }` will become:\n //\n // new tree.Declaration('@color',\n // new tree.Value([\n // new tree.Expression([\n // new tree.Color('#f01')\n // ])\n // ])\n // )\n //\n if (typeof variables === 'object' && !Array.isArray(variables)) {\n variables = Object.keys(variables).map(function (k) {\n let value = variables[k];\n\n if (!(value instanceof tree.Value)) {\n if (!(value instanceof tree.Expression)) {\n value = new tree.Expression([value]);\n }\n value = new tree.Value([value]);\n }\n return new tree.Declaration(`@${k}`, value, false, null, 0);\n });\n evalEnv.frames = [new tree.Ruleset(null, variables)];\n }\n\n const visitors = [\n new visitor.JoinSelectorVisitor(),\n new visitor.MarkVisibleSelectorsVisitor(true),\n new visitor.ExtendVisitor(),\n new visitor.ToCSSVisitor({compress: Boolean(options.compress)})\n ];\n\n const preEvalVisitors = [];\n let v;\n let visitorIterator;\n\n /**\n * first() / get() allows visitors to be added while visiting\n * \n * @todo Add scoping for visitors just like functions for @plugin; right now they're global\n */\n if (options.pluginManager) {\n visitorIterator = options.pluginManager.visitor();\n for (var i = 0; i < 2; i++) {\n visitorIterator.first();\n while ((v = visitorIterator.get())) {\n if (v.isPreEvalVisitor) {\n if (i === 0 || preEvalVisitors.indexOf(v) === -1) {\n preEvalVisitors.push(v);\n v.run(root);\n }\n }\n else {\n if (i === 0 || visitors.indexOf(v) === -1) {\n if (v.isPreVisitor) {\n visitors.unshift(v);\n }\n else {\n visitors.push(v);\n }\n }\n }\n }\n }\n }\n\n evaldRoot = root.eval(evalEnv);\n\n for (var i = 0; i < visitors.length; i++) {\n visitors[i].run(evaldRoot);\n }\n\n // Run any remaining visitors added after eval pass\n if (options.pluginManager) {\n visitorIterator.first();\n while ((v = visitorIterator.get())) {\n if (visitors.indexOf(v) === -1 && preEvalVisitors.indexOf(v) === -1) {\n v.run(evaldRoot);\n }\n }\n }\n\n return evaldRoot;\n};\n","/**\n * Plugin Manager\n */\nclass PluginManager {\n constructor(less) {\n this.less = less;\n this.visitors = [];\n this.preProcessors = [];\n this.postProcessors = [];\n this.installedPlugins = [];\n this.fileManagers = [];\n this.iterator = -1;\n this.pluginCache = {};\n this.Loader = new less.PluginLoader(less);\n }\n\n /**\n * Adds all the plugins in the array\n * @param {Array} plugins\n */\n addPlugins(plugins) {\n if (plugins) {\n for (let i = 0; i < plugins.length; i++) {\n this.addPlugin(plugins[i]);\n }\n }\n }\n\n /**\n *\n * @param plugin\n * @param {String} filename\n */\n addPlugin(plugin, filename, functionRegistry) {\n this.installedPlugins.push(plugin);\n if (filename) {\n this.pluginCache[filename] = plugin;\n }\n if (plugin.install) {\n plugin.install(this.less, this, functionRegistry || this.less.functions.functionRegistry);\n }\n }\n\n /**\n *\n * @param filename\n */\n get(filename) {\n return this.pluginCache[filename];\n }\n\n /**\n * Adds a visitor. The visitor object has options on itself to determine\n * when it should run.\n * @param visitor\n */\n addVisitor(visitor) {\n this.visitors.push(visitor);\n }\n\n /**\n * Adds a pre processor object\n * @param {object} preProcessor\n * @param {number} priority - guidelines 1 = before import, 1000 = import, 2000 = after import\n */\n addPreProcessor(preProcessor, priority) {\n let indexToInsertAt;\n for (indexToInsertAt = 0; indexToInsertAt < this.preProcessors.length; indexToInsertAt++) {\n if (this.preProcessors[indexToInsertAt].priority >= priority) {\n break;\n }\n }\n this.preProcessors.splice(indexToInsertAt, 0, {preProcessor, priority});\n }\n\n /**\n * Adds a post processor object\n * @param {object} postProcessor\n * @param {number} priority - guidelines 1 = before compression, 1000 = compression, 2000 = after compression\n */\n addPostProcessor(postProcessor, priority) {\n let indexToInsertAt;\n for (indexToInsertAt = 0; indexToInsertAt < this.postProcessors.length; indexToInsertAt++) {\n if (this.postProcessors[indexToInsertAt].priority >= priority) {\n break;\n }\n }\n this.postProcessors.splice(indexToInsertAt, 0, {postProcessor, priority});\n }\n\n /**\n *\n * @param manager\n */\n addFileManager(manager) {\n this.fileManagers.push(manager);\n }\n\n /**\n *\n * @returns {Array}\n * @private\n */\n getPreProcessors() {\n const preProcessors = [];\n for (let i = 0; i < this.preProcessors.length; i++) {\n preProcessors.push(this.preProcessors[i].preProcessor);\n }\n return preProcessors;\n }\n\n /**\n *\n * @returns {Array}\n * @private\n */\n getPostProcessors() {\n const postProcessors = [];\n for (let i = 0; i < this.postProcessors.length; i++) {\n postProcessors.push(this.postProcessors[i].postProcessor);\n }\n return postProcessors;\n }\n\n /**\n *\n * @returns {Array}\n * @private\n */\n getVisitors() {\n return this.visitors;\n }\n\n visitor() {\n const self = this;\n return {\n first: function() {\n self.iterator = -1;\n return self.visitors[self.iterator];\n },\n get: function() {\n self.iterator += 1;\n return self.visitors[self.iterator];\n }\n };\n }\n\n /**\n *\n * @returns {Array}\n * @private\n */\n getFileManagers() {\n return this.fileManagers;\n }\n}\n\nlet pm;\n\nconst PluginManagerFactory = function(less, newFactory) {\n if (newFactory || !pm) {\n pm = new PluginManager(less);\n }\n return pm;\n};\n\n//\nexport default PluginManagerFactory;\n","'use strict';\n\nfunction parseNodeVersion(version) {\n var match = version.match(/^v(\\d{1,2})\\.(\\d{1,2})\\.(\\d{1,2})(?:-([0-9A-Za-z-.]+))?(?:\\+([0-9A-Za-z-.]+))?$/); // eslint-disable-line max-len\n if (!match) {\n throw new Error('Unable to parse: ' + version);\n }\n\n var res = {\n major: parseInt(match[1], 10),\n minor: parseInt(match[2], 10),\n patch: parseInt(match[3], 10),\n pre: match[4] || '',\n build: match[5] || '',\n };\n\n return res;\n}\n\nmodule.exports = parseNodeVersion;\n","/* global window, XMLHttpRequest */\n\nimport AbstractFileManager from '../less/environment/abstract-file-manager.js';\n\nlet options;\nlet logger;\nlet fileCache = {};\n\n// TODOS - move log somewhere. pathDiff and doing something similar in node. use pathDiff in the other browser file for the initial load\nconst FileManager = function() {}\nFileManager.prototype = Object.assign(new AbstractFileManager(), {\n alwaysMakePathsAbsolute() {\n return true;\n },\n\n join(basePath, laterPath) {\n if (!basePath) {\n return laterPath;\n }\n return this.extractUrlParts(laterPath, basePath).path;\n },\n\n doXHR(url, type, callback, errback) {\n const xhr = new XMLHttpRequest();\n const async = options.isFileProtocol ? options.fileAsync : true;\n\n if (typeof xhr.overrideMimeType === 'function') {\n xhr.overrideMimeType('text/css');\n }\n logger.debug(`XHR: Getting '${url}'`);\n xhr.open('GET', url, async);\n xhr.setRequestHeader('Accept', type || 'text/x-less, text/css; q=0.9, */*; q=0.5');\n xhr.send(null);\n\n function handleResponse(xhr, callback, errback) {\n if (xhr.status >= 200 && xhr.status < 300) {\n callback(xhr.responseText,\n xhr.getResponseHeader('Last-Modified'));\n } else if (typeof errback === 'function') {\n errback(xhr.status, url);\n }\n }\n\n if (options.isFileProtocol && !options.fileAsync) {\n if (xhr.status === 0 || (xhr.status >= 200 && xhr.status < 300)) {\n callback(xhr.responseText);\n } else {\n errback(xhr.status, url);\n }\n } else if (async) {\n xhr.onreadystatechange = () => {\n if (xhr.readyState == 4) {\n handleResponse(xhr, callback, errback);\n }\n };\n } else {\n handleResponse(xhr, callback, errback);\n }\n },\n\n supports() {\n return true;\n },\n\n clearFileCache() {\n fileCache = {};\n },\n\n loadFile(filename, currentDirectory, options, environment) {\n // TODO: Add prefix support like less-node?\n // What about multiple paths?\n\n if (currentDirectory && !this.isPathAbsolute(filename)) {\n filename = currentDirectory + filename;\n }\n\n filename = options.ext ? this.tryAppendExtension(filename, options.ext) : filename;\n\n options = options || {};\n\n // sheet may be set to the stylesheet for the initial load or a collection of properties including\n // some context variables for imports\n const hrefParts = this.extractUrlParts(filename, window.location.href);\n const href = hrefParts.url;\n const self = this;\n \n return new Promise((resolve, reject) => {\n if (options.useFileCache && fileCache[href]) {\n try {\n const lessText = fileCache[href];\n return resolve({ contents: lessText, filename: href, webInfo: { lastModified: new Date() }});\n } catch (e) {\n return reject({ filename: href, message: `Error loading file ${href} error was ${e.message}` });\n }\n }\n\n self.doXHR(href, options.mime, function doXHRCallback(data, lastModified) {\n // per file cache\n fileCache[href] = data;\n\n // Use remote copy (re-parse)\n resolve({ contents: data, filename: href, webInfo: { lastModified }});\n }, function doXHRError(status, url) {\n reject({ type: 'File', message: `'${url}' wasn't found (${status})`, href });\n });\n });\n }\n});\n\nexport default (opts, log) => {\n options = opts;\n logger = log;\n return FileManager;\n}\n","import Environment from './environment/environment';\nimport data from './data';\nimport tree from './tree';\nimport AbstractFileManager from './environment/abstract-file-manager';\nimport AbstractPluginLoader from './environment/abstract-plugin-loader';\nimport visitors from './visitors';\nimport Parser from './parser/parser';\nimport functions from './functions';\nimport contexts from './contexts';\nimport LessError from './less-error';\nimport transformTree from './transform-tree';\nimport * as utils from './utils';\nimport PluginManager from './plugin-manager';\nimport logger from './logger';\nimport SourceMapOutput from './source-map-output';\nimport SourceMapBuilder from './source-map-builder';\nimport ParseTree from './parse-tree';\nimport ImportManager from './import-manager';\nimport Parse from './parse';\nimport Render from './render';\nimport { version } from '../../package.json';\nimport parseVersion from 'parse-node-version';\n\nexport default function(environment, fileManagers) {\n let sourceMapOutput, sourceMapBuilder, parseTree, importManager;\n\n environment = new Environment(environment, fileManagers);\n sourceMapOutput = SourceMapOutput(environment);\n sourceMapBuilder = SourceMapBuilder(sourceMapOutput, environment);\n parseTree = ParseTree(sourceMapBuilder);\n importManager = ImportManager(environment);\n\n const render = Render(environment, parseTree, importManager);\n const parse = Parse(environment, parseTree, importManager);\n\n const v = parseVersion(`v${version}`);\n const initial = {\n version: [v.major, v.minor, v.patch],\n data,\n tree,\n Environment,\n AbstractFileManager,\n AbstractPluginLoader,\n environment,\n visitors,\n Parser,\n functions: functions(environment),\n contexts,\n SourceMapOutput: sourceMapOutput,\n SourceMapBuilder: sourceMapBuilder,\n ParseTree: parseTree,\n ImportManager: importManager,\n render,\n parse,\n LessError,\n transformTree,\n utils,\n PluginManager,\n logger\n };\n\n // Create a public API\n\n const ctor = function(t) {\n return function() {\n const obj = Object.create(t.prototype);\n t.apply(obj, Array.prototype.slice.call(arguments, 0));\n return obj;\n };\n };\n let t;\n const api = Object.create(initial);\n for (const n in initial.tree) {\n /* eslint guard-for-in: 0 */\n t = initial.tree[n];\n if (typeof t === 'function') {\n api[n.toLowerCase()] = ctor(t);\n }\n else {\n api[n] = Object.create(null);\n for (const o in t) {\n /* eslint guard-for-in: 0 */\n api[n][o.toLowerCase()] = ctor(t[o]);\n }\n }\n }\n\n /**\n * Some of the functions assume a `this` context of the API object,\n * which causes it to fail when wrapped for ES6 imports.\n * \n * An assumed `this` should be removed in the future.\n */\n initial.parse = initial.parse.bind(api);\n initial.render = initial.render.bind(api);\n\n return api;\n};\n","import LessError from './less-error';\nimport transformTree from './transform-tree';\nimport logger from './logger';\n\nexport default function(SourceMapBuilder) {\n class ParseTree {\n constructor(root, imports) {\n this.root = root;\n this.imports = imports;\n }\n\n toCSS(options) {\n let evaldRoot;\n const result = {};\n let sourceMapBuilder;\n try {\n evaldRoot = transformTree(this.root, options);\n } catch (e) {\n throw new LessError(e, this.imports);\n }\n\n try {\n const compress = Boolean(options.compress);\n if (compress) {\n logger.warn('The compress option has been deprecated. ' + \n 'We recommend you use a dedicated css minifier, for instance see less-plugin-clean-css.');\n }\n\n const toCSSOptions = {\n compress,\n dumpLineNumbers: options.dumpLineNumbers,\n strictUnits: Boolean(options.strictUnits),\n numPrecision: 8};\n\n if (options.sourceMap) {\n sourceMapBuilder = new SourceMapBuilder(options.sourceMap);\n result.css = sourceMapBuilder.toCSS(evaldRoot, toCSSOptions, this.imports);\n } else {\n result.css = evaldRoot.toCSS(toCSSOptions);\n }\n } catch (e) {\n throw new LessError(e, this.imports);\n }\n\n if (options.pluginManager) {\n const postProcessors = options.pluginManager.getPostProcessors();\n for (let i = 0; i < postProcessors.length; i++) {\n result.css = postProcessors[i].process(result.css, { sourceMap: sourceMapBuilder, options, imports: this.imports });\n }\n }\n if (options.sourceMap) {\n result.map = sourceMapBuilder.getExternalSourceMap();\n }\n\n result.imports = [];\n for (const file in this.imports.files) {\n if (this.imports.files.hasOwnProperty(file) && file !== this.imports.rootFilename) {\n result.imports.push(file);\n }\n }\n return result;\n }\n }\n\n return ParseTree;\n};\n","export default function (SourceMapOutput, environment) {\n class SourceMapBuilder {\n constructor(options) {\n this.options = options;\n }\n\n toCSS(rootNode, options, imports) {\n const sourceMapOutput = new SourceMapOutput(\n {\n contentsIgnoredCharsMap: imports.contentsIgnoredChars,\n rootNode,\n contentsMap: imports.contents,\n sourceMapFilename: this.options.sourceMapFilename,\n sourceMapURL: this.options.sourceMapURL,\n outputFilename: this.options.sourceMapOutputFilename,\n sourceMapBasepath: this.options.sourceMapBasepath,\n sourceMapRootpath: this.options.sourceMapRootpath,\n outputSourceFiles: this.options.outputSourceFiles,\n sourceMapGenerator: this.options.sourceMapGenerator,\n sourceMapFileInline: this.options.sourceMapFileInline, \n disableSourcemapAnnotation: this.options.disableSourcemapAnnotation\n });\n\n const css = sourceMapOutput.toCSS(options);\n this.sourceMap = sourceMapOutput.sourceMap;\n this.sourceMapURL = sourceMapOutput.sourceMapURL;\n if (this.options.sourceMapInputFilename) {\n this.sourceMapInputFilename = sourceMapOutput.normalizeFilename(this.options.sourceMapInputFilename);\n }\n if (this.options.sourceMapBasepath !== undefined && this.sourceMapURL !== undefined) {\n this.sourceMapURL = sourceMapOutput.removeBasepath(this.sourceMapURL);\n }\n return css + this.getCSSAppendage();\n }\n\n getCSSAppendage() {\n\n let sourceMapURL = this.sourceMapURL;\n if (this.options.sourceMapFileInline) {\n if (this.sourceMap === undefined) {\n return '';\n }\n sourceMapURL = `data:application/json;base64,${environment.encodeBase64(this.sourceMap)}`;\n }\n\n if (this.options.disableSourcemapAnnotation) {\n return '';\n }\n\n if (sourceMapURL) {\n return `/*# sourceMappingURL=${sourceMapURL} */`;\n }\n return '';\n }\n\n getExternalSourceMap() {\n return this.sourceMap;\n }\n\n setExternalSourceMap(sourceMap) {\n this.sourceMap = sourceMap;\n }\n\n isInline() {\n return this.options.sourceMapFileInline;\n }\n\n getSourceMapURL() {\n return this.sourceMapURL;\n }\n\n getOutputFilename() {\n return this.options.sourceMapOutputFilename;\n }\n\n getInputFilename() {\n return this.sourceMapInputFilename;\n }\n }\n\n return SourceMapBuilder;\n};\n","export default function (environment) {\n class SourceMapOutput {\n constructor(options) {\n this._css = [];\n this._rootNode = options.rootNode;\n this._contentsMap = options.contentsMap;\n this._contentsIgnoredCharsMap = options.contentsIgnoredCharsMap;\n if (options.sourceMapFilename) {\n this._sourceMapFilename = options.sourceMapFilename.replace(/\\\\/g, '/');\n }\n this._outputFilename = options.outputFilename;\n this.sourceMapURL = options.sourceMapURL;\n if (options.sourceMapBasepath) {\n this._sourceMapBasepath = options.sourceMapBasepath.replace(/\\\\/g, '/');\n }\n if (options.sourceMapRootpath) {\n this._sourceMapRootpath = options.sourceMapRootpath.replace(/\\\\/g, '/');\n if (this._sourceMapRootpath.charAt(this._sourceMapRootpath.length - 1) !== '/') {\n this._sourceMapRootpath += '/';\n }\n } else {\n this._sourceMapRootpath = '';\n }\n this._outputSourceFiles = options.outputSourceFiles;\n this._sourceMapGeneratorConstructor = environment.getSourceMapGenerator();\n\n this._lineNumber = 0;\n this._column = 0;\n }\n\n removeBasepath(path) {\n if (this._sourceMapBasepath && path.indexOf(this._sourceMapBasepath) === 0) {\n path = path.substring(this._sourceMapBasepath.length);\n if (path.charAt(0) === '\\\\' || path.charAt(0) === '/') {\n path = path.substring(1);\n }\n }\n\n return path;\n }\n\n normalizeFilename(filename) {\n filename = filename.replace(/\\\\/g, '/');\n filename = this.removeBasepath(filename);\n return (this._sourceMapRootpath || '') + filename;\n }\n\n add(chunk, fileInfo, index, mapLines) {\n\n // ignore adding empty strings\n if (!chunk) {\n return;\n }\n\n let lines, sourceLines, columns, sourceColumns, i;\n\n if (fileInfo && fileInfo.filename) {\n let inputSource = this._contentsMap[fileInfo.filename];\n\n // remove vars/banner added to the top of the file\n if (this._contentsIgnoredCharsMap[fileInfo.filename]) {\n // adjust the index\n index -= this._contentsIgnoredCharsMap[fileInfo.filename];\n if (index < 0) { index = 0; }\n // adjust the source\n inputSource = inputSource.slice(this._contentsIgnoredCharsMap[fileInfo.filename]);\n }\n\n /** \n * ignore empty content, or failsafe\n * if contents map is incorrect\n */\n if (inputSource === undefined) {\n this._css.push(chunk);\n return;\n }\n\n inputSource = inputSource.substring(0, index);\n sourceLines = inputSource.split('\\n');\n sourceColumns = sourceLines[sourceLines.length - 1];\n }\n\n lines = chunk.split('\\n');\n columns = lines[lines.length - 1];\n\n if (fileInfo && fileInfo.filename) {\n if (!mapLines) {\n this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + 1, column: this._column},\n original: { line: sourceLines.length, column: sourceColumns.length},\n source: this.normalizeFilename(fileInfo.filename)});\n } else {\n for (i = 0; i < lines.length; i++) {\n this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + i + 1, column: i === 0 ? this._column : 0},\n original: { line: sourceLines.length + i, column: i === 0 ? sourceColumns.length : 0},\n source: this.normalizeFilename(fileInfo.filename)});\n }\n }\n }\n\n if (lines.length === 1) {\n this._column += columns.length;\n } else {\n this._lineNumber += lines.length - 1;\n this._column = columns.length;\n }\n\n this._css.push(chunk);\n }\n\n isEmpty() {\n return this._css.length === 0;\n }\n\n toCSS(context) {\n this._sourceMapGenerator = new this._sourceMapGeneratorConstructor({ file: this._outputFilename, sourceRoot: null });\n\n if (this._outputSourceFiles) {\n for (const filename in this._contentsMap) {\n if (this._contentsMap.hasOwnProperty(filename)) {\n let source = this._contentsMap[filename];\n if (this._contentsIgnoredCharsMap[filename]) {\n source = source.slice(this._contentsIgnoredCharsMap[filename]);\n }\n this._sourceMapGenerator.setSourceContent(this.normalizeFilename(filename), source);\n }\n }\n }\n\n this._rootNode.genCSS(context, this);\n\n if (this._css.length > 0) {\n let sourceMapURL;\n const sourceMapContent = JSON.stringify(this._sourceMapGenerator.toJSON());\n\n if (this.sourceMapURL) {\n sourceMapURL = this.sourceMapURL;\n } else if (this._sourceMapFilename) {\n sourceMapURL = this._sourceMapFilename;\n }\n this.sourceMapURL = sourceMapURL;\n\n this.sourceMap = sourceMapContent;\n }\n\n return this._css.join('');\n }\n }\n\n return SourceMapOutput;\n};\n","import contexts from './contexts';\nimport Parser from './parser/parser';\nimport LessError from './less-error';\nimport * as utils from './utils';\nimport logger from './logger';\n\nexport default function(environment) {\n // FileInfo = {\n // 'rewriteUrls' - option - whether to adjust URL's to be relative\n // 'filename' - full resolved filename of current file\n // 'rootpath' - path to append to normal URLs for this node\n // 'currentDirectory' - path to the current file, absolute\n // 'rootFilename' - filename of the base file\n // 'entryPath' - absolute path to the entry file\n // 'reference' - whether the file should not be output and only output parts that are referenced\n\n class ImportManager {\n constructor(less, context, rootFileInfo) {\n this.less = less;\n this.rootFilename = rootFileInfo.filename;\n this.paths = context.paths || []; // Search paths, when importing\n this.contents = {}; // map - filename to contents of all the files\n this.contentsIgnoredChars = {}; // map - filename to lines at the beginning of each file to ignore\n this.mime = context.mime;\n this.error = null;\n this.context = context;\n // Deprecated? Unused outside of here, could be useful.\n this.queue = []; // Files which haven't been imported yet\n this.files = {}; // Holds the imported parse trees.\n }\n\n /**\n * Add an import to be imported\n * @param path - the raw path\n * @param tryAppendExtension - whether to try appending a file extension (.less or .js if the path has no extension)\n * @param currentFileInfo - the current file info (used for instance to work out relative paths)\n * @param importOptions - import options\n * @param callback - callback for when it is imported\n */\n push(path, tryAppendExtension, currentFileInfo, importOptions, callback) {\n const importManager = this, pluginLoader = this.context.pluginManager.Loader;\n\n this.queue.push(path);\n\n const fileParsedFunc = function (e, root, fullPath) {\n importManager.queue.splice(importManager.queue.indexOf(path), 1); // Remove the path from the queue\n\n const importedEqualsRoot = fullPath === importManager.rootFilename;\n if (importOptions.optional && e) {\n callback(null, {rules:[]}, false, null);\n logger.info(`The file ${fullPath} was skipped because it was not found and the import was marked optional.`);\n }\n else {\n // Inline imports aren't cached here.\n // If we start to cache them, please make sure they won't conflict with non-inline imports of the\n // same name as they used to do before this comment and the condition below have been added.\n if (!importManager.files[fullPath] && !importOptions.inline) {\n importManager.files[fullPath] = { root, options: importOptions };\n }\n if (e && !importManager.error) { importManager.error = e; }\n callback(e, root, importedEqualsRoot, fullPath);\n }\n };\n\n const newFileInfo = {\n rewriteUrls: this.context.rewriteUrls,\n entryPath: currentFileInfo.entryPath,\n rootpath: currentFileInfo.rootpath,\n rootFilename: currentFileInfo.rootFilename\n };\n\n const fileManager = environment.getFileManager(path, currentFileInfo.currentDirectory, this.context, environment);\n\n if (!fileManager) {\n fileParsedFunc({ message: `Could not find a file-manager for ${path}` });\n return;\n }\n\n const loadFileCallback = function(loadedFile) {\n let plugin;\n const resolvedFilename = loadedFile.filename;\n const contents = loadedFile.contents.replace(/^\\uFEFF/, '');\n\n // Pass on an updated rootpath if path of imported file is relative and file\n // is in a (sub|sup) directory\n //\n // Examples:\n // - If path of imported file is 'module/nav/nav.less' and rootpath is 'less/',\n // then rootpath should become 'less/module/nav/'\n // - If path of imported file is '../mixins.less' and rootpath is 'less/',\n // then rootpath should become 'less/../'\n newFileInfo.currentDirectory = fileManager.getPath(resolvedFilename);\n if (newFileInfo.rewriteUrls) {\n newFileInfo.rootpath = fileManager.join(\n (importManager.context.rootpath || ''),\n fileManager.pathDiff(newFileInfo.currentDirectory, newFileInfo.entryPath));\n\n if (!fileManager.isPathAbsolute(newFileInfo.rootpath) && fileManager.alwaysMakePathsAbsolute()) {\n newFileInfo.rootpath = fileManager.join(newFileInfo.entryPath, newFileInfo.rootpath);\n }\n }\n newFileInfo.filename = resolvedFilename;\n\n const newEnv = new contexts.Parse(importManager.context);\n\n newEnv.processImports = false;\n importManager.contents[resolvedFilename] = contents;\n\n if (currentFileInfo.reference || importOptions.reference) {\n newFileInfo.reference = true;\n }\n\n if (importOptions.isPlugin) {\n plugin = pluginLoader.evalPlugin(contents, newEnv, importManager, importOptions.pluginArgs, newFileInfo);\n if (plugin instanceof LessError) {\n fileParsedFunc(plugin, null, resolvedFilename);\n }\n else {\n fileParsedFunc(null, plugin, resolvedFilename);\n }\n } else if (importOptions.inline) {\n fileParsedFunc(null, contents, resolvedFilename);\n } else {\n // import (multiple) parse trees apparently get altered and can't be cached.\n // TODO: investigate why this is\n if (importManager.files[resolvedFilename]\n && !importManager.files[resolvedFilename].options.multiple\n && !importOptions.multiple) {\n\n fileParsedFunc(null, importManager.files[resolvedFilename].root, resolvedFilename);\n }\n else {\n new Parser(newEnv, importManager, newFileInfo).parse(contents, function (e, root) {\n fileParsedFunc(e, root, resolvedFilename);\n });\n }\n }\n };\n let loadedFile;\n let promise;\n const context = utils.clone(this.context);\n\n if (tryAppendExtension) {\n context.ext = importOptions.isPlugin ? '.js' : '.less';\n }\n\n if (importOptions.isPlugin) {\n context.mime = 'application/javascript';\n\n if (context.syncImport) {\n loadedFile = pluginLoader.loadPluginSync(path, currentFileInfo.currentDirectory, context, environment, fileManager);\n } else {\n promise = pluginLoader.loadPlugin(path, currentFileInfo.currentDirectory, context, environment, fileManager);\n }\n }\n else {\n if (context.syncImport) {\n loadedFile = fileManager.loadFileSync(path, currentFileInfo.currentDirectory, context, environment);\n } else {\n promise = fileManager.loadFile(path, currentFileInfo.currentDirectory, context, environment,\n (err, loadedFile) => {\n if (err) {\n fileParsedFunc(err);\n } else {\n loadFileCallback(loadedFile);\n }\n });\n }\n }\n if (loadedFile) {\n if (!loadedFile.filename) {\n fileParsedFunc(loadedFile);\n } else {\n loadFileCallback(loadedFile);\n }\n } else if (promise) {\n promise.then(loadFileCallback, fileParsedFunc);\n }\n }\n }\n\n return ImportManager;\n};\n","import * as utils from './utils';\n\nexport default function(environment, ParseTree, ImportManager) {\n const render = function (input, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = utils.copyOptions(this.options, {});\n }\n else {\n options = utils.copyOptions(this.options, options || {});\n }\n\n if (!callback) {\n const self = this;\n return new Promise(function (resolve, reject) {\n render.call(self, input, options, function(err, output) {\n if (err) {\n reject(err);\n } else {\n resolve(output);\n }\n });\n });\n } else {\n this.parse(input, options, function(err, root, imports, options) {\n if (err) { return callback(err); }\n\n let result;\n try {\n const parseTree = new ParseTree(root, imports);\n result = parseTree.toCSS(options);\n }\n catch (err) { return callback(err); }\n\n callback(null, result);\n });\n }\n };\n\n return render;\n};\n","import contexts from './contexts';\nimport Parser from './parser/parser';\nimport PluginManager from './plugin-manager';\nimport LessError from './less-error';\nimport * as utils from './utils';\n\nexport default function(environment, ParseTree, ImportManager) {\n const parse = function (input, options, callback) {\n\n if (typeof options === 'function') {\n callback = options;\n options = utils.copyOptions(this.options, {});\n }\n else {\n options = utils.copyOptions(this.options, options || {});\n }\n\n if (!callback) {\n const self = this;\n return new Promise(function (resolve, reject) {\n parse.call(self, input, options, function(err, output) {\n if (err) {\n reject(err);\n } else {\n resolve(output);\n }\n });\n });\n } else {\n let context;\n let rootFileInfo;\n const pluginManager = new PluginManager(this, !options.reUsePluginManager);\n\n options.pluginManager = pluginManager;\n\n context = new contexts.Parse(options);\n\n if (options.rootFileInfo) {\n rootFileInfo = options.rootFileInfo;\n } else {\n const filename = options.filename || 'input';\n const entryPath = filename.replace(/[^\\/\\\\]*$/, '');\n rootFileInfo = {\n filename,\n rewriteUrls: context.rewriteUrls,\n rootpath: context.rootpath || '',\n currentDirectory: entryPath,\n entryPath,\n rootFilename: filename\n };\n // add in a missing trailing slash\n if (rootFileInfo.rootpath && rootFileInfo.rootpath.slice(-1) !== '/') {\n rootFileInfo.rootpath += '/';\n }\n }\n\n const imports = new ImportManager(this, context, rootFileInfo);\n this.importManager = imports;\n\n // TODO: allow the plugins to be just a list of paths or names\n // Do an async plugin queue like lessc\n\n if (options.plugins) {\n options.plugins.forEach(function(plugin) {\n let evalResult, contents;\n if (plugin.fileContent) {\n contents = plugin.fileContent.replace(/^\\uFEFF/, '');\n evalResult = pluginManager.Loader.evalPlugin(contents, context, imports, plugin.options, plugin.filename);\n if (evalResult instanceof LessError) {\n return callback(evalResult);\n }\n }\n else {\n pluginManager.addPlugin(plugin);\n }\n });\n }\n\n new Parser(context, imports, rootFileInfo)\n .parse(input, function (e, root) {\n if (e) { return callback(e); }\n callback(null, root, imports, options);\n }, options);\n }\n };\n return parse;\n};\n","// TODO: Add tests for browser @plugin\n/* global window */\n\nimport AbstractPluginLoader from '../less/environment/abstract-plugin-loader.js';\n\n/**\n * Browser Plugin Loader\n */\nconst PluginLoader = function(less) {\n this.less = less;\n // Should we shim this.require for browser? Probably not?\n};\n\nPluginLoader.prototype = Object.assign(new AbstractPluginLoader(), {\n loadPlugin(filename, basePath, context, environment, fileManager) {\n return new Promise((fulfill, reject) => {\n fileManager.loadFile(filename, basePath, context, environment)\n .then(fulfill).catch(reject);\n });\n }\n});\n\nexport default PluginLoader;\n\n","import * as utils from './utils';\nimport browser from './browser';\n\nexport default (window, less, options) => {\n\n function errorHTML(e, rootHref) {\n const id = `less-error-message:${utils.extractId(rootHref || '')}`;\n const template = '
  • {content}
  • ';\n const elem = window.document.createElement('div');\n let timer;\n let content;\n const errors = [];\n const filename = e.filename || rootHref;\n const filenameNoPath = filename.match(/([^\\/]+(\\?.*)?)$/)[1];\n\n elem.id = id;\n elem.className = 'less-error-message';\n\n content = `

    ${e.type || 'Syntax'}Error: ${e.message || 'There is an error in your .less file'}` + \n `

    in ${filenameNoPath} `;\n\n const errorline = (e, i, classname) => {\n if (e.extract[i] !== undefined) {\n errors.push(template.replace(/\\{line\\}/, (parseInt(e.line, 10) || 0) + (i - 1))\n .replace(/\\{class\\}/, classname)\n .replace(/\\{content\\}/, e.extract[i]));\n }\n };\n\n if (e.line) {\n errorline(e, 0, '');\n errorline(e, 1, 'line');\n errorline(e, 2, '');\n content += `on line ${e.line}, column ${e.column + 1}:

      ${errors.join('')}
    `;\n }\n if (e.stack && (e.extract || options.logLevel >= 4)) {\n content += `
    Stack Trace
    ${e.stack.split('\\n').slice(1).join('
    ')}`;\n }\n elem.innerHTML = content;\n\n // CSS for error messages\n browser.createCSS(window.document, [\n '.less-error-message ul, .less-error-message li {',\n 'list-style-type: none;',\n 'margin-right: 15px;',\n 'padding: 4px 0;',\n 'margin: 0;',\n '}',\n '.less-error-message label {',\n 'font-size: 12px;',\n 'margin-right: 15px;',\n 'padding: 4px 0;',\n 'color: #cc7777;',\n '}',\n '.less-error-message pre {',\n 'color: #dd6666;',\n 'padding: 4px 0;',\n 'margin: 0;',\n 'display: inline-block;',\n '}',\n '.less-error-message pre.line {',\n 'color: #ff0000;',\n '}',\n '.less-error-message h3 {',\n 'font-size: 20px;',\n 'font-weight: bold;',\n 'padding: 15px 0 5px 0;',\n 'margin: 0;',\n '}',\n '.less-error-message a {',\n 'color: #10a',\n '}',\n '.less-error-message .error {',\n 'color: red;',\n 'font-weight: bold;',\n 'padding-bottom: 2px;',\n 'border-bottom: 1px dashed red;',\n '}'\n ].join('\\n'), { title: 'error-message' });\n\n elem.style.cssText = [\n 'font-family: Arial, sans-serif',\n 'border: 1px solid #e00',\n 'background-color: #eee',\n 'border-radius: 5px',\n '-webkit-border-radius: 5px',\n '-moz-border-radius: 5px',\n 'color: #e00',\n 'padding: 15px',\n 'margin-bottom: 15px'\n ].join(';');\n\n if (options.env === 'development') {\n timer = setInterval(() => {\n const document = window.document;\n const body = document.body;\n if (body) {\n if (document.getElementById(id)) {\n body.replaceChild(elem, document.getElementById(id));\n } else {\n body.insertBefore(elem, body.firstChild);\n }\n clearInterval(timer);\n }\n }, 10);\n }\n }\n\n function removeErrorHTML(path) {\n const node = window.document.getElementById(`less-error-message:${utils.extractId(path)}`);\n if (node) {\n node.parentNode.removeChild(node);\n }\n }\n\n function removeErrorConsole(path) {\n // no action\n }\n\n function removeError(path) {\n if (!options.errorReporting || options.errorReporting === 'html') {\n removeErrorHTML(path);\n } else if (options.errorReporting === 'console') {\n removeErrorConsole(path);\n } else if (typeof options.errorReporting === 'function') {\n options.errorReporting('remove', path);\n }\n }\n\n function errorConsole(e, rootHref) {\n const template = '{line} {content}';\n const filename = e.filename || rootHref;\n const errors = [];\n let content = `${e.type || 'Syntax'}Error: ${e.message || 'There is an error in your .less file'} in ${filename}`;\n\n const errorline = (e, i, classname) => {\n if (e.extract[i] !== undefined) {\n errors.push(template.replace(/\\{line\\}/, (parseInt(e.line, 10) || 0) + (i - 1))\n .replace(/\\{class\\}/, classname)\n .replace(/\\{content\\}/, e.extract[i]));\n }\n };\n\n if (e.line) {\n errorline(e, 0, '');\n errorline(e, 1, 'line');\n errorline(e, 2, '');\n content += ` on line ${e.line}, column ${e.column + 1}:\\n${errors.join('\\n')}`;\n }\n if (e.stack && (e.extract || options.logLevel >= 4)) {\n content += `\\nStack Trace\\n${e.stack}`;\n }\n less.logger.error(content);\n }\n\n function error(e, rootHref) {\n if (!options.errorReporting || options.errorReporting === 'html') {\n errorHTML(e, rootHref);\n } else if (options.errorReporting === 'console') {\n errorConsole(e, rootHref);\n } else if (typeof options.errorReporting === 'function') {\n options.errorReporting('add', e, rootHref);\n }\n }\n\n return {\n add: error,\n remove: removeError\n };\n};\n","/**\n * Kicks off less and compiles any stylesheets\n * used in the browser distributed version of less\n * to kick-start less using the browser api\n */\n/* global window, document */\n\nimport defaultOptions from '../less/default-options';\nimport addDefaultOptions from './add-default-options';\nimport root from './index';\n\nconst options = defaultOptions();\n\nif (window.less) {\n for (const key in window.less) {\n if (window.less.hasOwnProperty(key)) {\n options[key] = window.less[key];\n }\n }\n}\naddDefaultOptions(window, options);\n\noptions.plugins = options.plugins || [];\n\nif (window.LESS_PLUGINS) {\n options.plugins = options.plugins.concat(window.LESS_PLUGINS);\n}\n\nconst less = root(window, options);\nexport default less;\n\nwindow.less = less;\n\nlet css;\nlet head;\nlet style;\n\n// Always restore page visibility\nfunction resolveOrReject(data) {\n if (data.filename) {\n console.warn(data);\n }\n if (!options.async) {\n head.removeChild(style);\n }\n}\n\nif (options.onReady) {\n if (/!watch/.test(window.location.hash)) {\n less.watch();\n }\n // Simulate synchronous stylesheet loading by hiding page rendering\n if (!options.async) {\n css = 'body { display: none !important }';\n head = document.head || document.getElementsByTagName('head')[0];\n style = document.createElement('style');\n\n style.type = 'text/css';\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n\n head.appendChild(style);\n }\n less.registerStylesheetsImmediately();\n less.pageLoadFinished = less.refresh(less.env === 'development').then(resolveOrReject, resolveOrReject);\n}\n","// Export a new default each time\nexport default function() {\n return {\n /* Inline Javascript - @plugin still allowed */\n javascriptEnabled: false,\n\n /* Outputs a makefile import dependency list to stdout. */\n depends: false,\n\n /* (DEPRECATED) Compress using less built-in compression. \n * This does an okay job but does not utilise all the tricks of \n * dedicated css compression. */\n compress: false,\n\n /* Runs the less parser and just reports errors without any output. */\n lint: false,\n\n /* Sets available include paths.\n * If the file in an @import rule does not exist at that exact location, \n * less will look for it at the location(s) passed to this option. \n * You might use this for instance to specify a path to a library which \n * you want to be referenced simply and relatively in the less files. */\n paths: [],\n\n /* color output in the terminal */\n color: true,\n\n /* The strictImports controls whether the compiler will allow an @import inside of either \n * @media blocks or (a later addition) other selector blocks.\n * See: https://github.com/less/less.js/issues/656 */\n strictImports: false,\n\n /* Allow Imports from Insecure HTTPS Hosts */\n insecure: false,\n\n /* Allows you to add a path to every generated import and url in your css. \n * This does not affect less import statements that are processed, just ones \n * that are left in the output css. */\n rootpath: '',\n\n /* By default URLs are kept as-is, so if you import a file in a sub-directory \n * that references an image, exactly the same URL will be output in the css. \n * This option allows you to re-write URL's in imported files so that the \n * URL is always relative to the base imported file */\n rewriteUrls: false,\n\n /* How to process math \n * 0 always - eagerly try to solve all operations\n * 1 parens-division - require parens for division \"/\"\n * 2 parens | strict - require parens for all operations\n * 3 strict-legacy - legacy strict behavior (super-strict)\n */\n math: 1,\n\n /* Without this option, less attempts to guess at the output unit when it does maths. */\n strictUnits: false,\n\n /* Effectively the declaration is put at the top of your base Less file, \n * meaning it can be used but it also can be overridden if this variable \n * is defined in the file. */\n globalVars: null,\n\n /* As opposed to the global variable option, this puts the declaration at the\n * end of your base file, meaning it will override anything defined in your Less file. */\n modifyVars: null,\n\n /* This option allows you to specify a argument to go on to every URL. */\n urlArgs: ''\n }\n};","import {addDataAttr} from './utils';\nimport browser from './browser';\n\nexport default (window, options) => {\n\n // use options from the current script tag data attribues\n addDataAttr(options, browser.currentScript(window));\n\n if (options.isFileProtocol === undefined) {\n options.isFileProtocol = /^(file|(chrome|safari)(-extension)?|resource|qrc|app):/.test(window.location.protocol);\n }\n\n // Load styles asynchronously (default: false)\n //\n // This is set to `false` by default, so that the body\n // doesn't start loading before the stylesheets are parsed.\n // Setting this to `true` can result in flickering.\n //\n options.async = options.async || false;\n options.fileAsync = options.fileAsync || false;\n\n // Interval between watch polls\n options.poll = options.poll || (options.isFileProtocol ? 1000 : 1500);\n\n options.env = options.env || (window.location.hostname == '127.0.0.1' ||\n window.location.hostname == '0.0.0.0' ||\n window.location.hostname == 'localhost' ||\n (window.location.port &&\n window.location.port.length > 0) ||\n options.isFileProtocol ? 'development'\n : 'production');\n\n const dumpLineNumbers = /!dumpLineNumbers:(comments|mediaquery|all)/.exec(window.location.hash);\n if (dumpLineNumbers) {\n options.dumpLineNumbers = dumpLineNumbers[1];\n }\n\n if (options.useFileCache === undefined) {\n options.useFileCache = true;\n }\n\n if (options.onReady === undefined) {\n options.onReady = true;\n }\n\n if (options.relativeUrls) {\n options.rewriteUrls = 'all';\n }\n};\n","//\n// index.js\n// Should expose the additional browser functions on to the less object\n//\nimport {addDataAttr} from './utils';\nimport lessRoot from '../less';\nimport browser from './browser';\nimport FM from './file-manager';\nimport PluginLoader from './plugin-loader';\nimport LogListener from './log-listener';\nimport ErrorReporting from './error-reporting';\nimport Cache from './cache';\nimport ImageSize from './image-size';\n\nexport default (window, options) => {\n const document = window.document;\n const less = lessRoot();\n\n less.options = options;\n const environment = less.environment;\n const FileManager = FM(options, less.logger);\n const fileManager = new FileManager();\n environment.addFileManager(fileManager);\n less.FileManager = FileManager;\n less.PluginLoader = PluginLoader;\n\n LogListener(less, options);\n const errors = ErrorReporting(window, less, options);\n const cache = less.cache = options.cache || Cache(window, options, less.logger);\n ImageSize(less.environment);\n\n // Setup user functions - Deprecate?\n if (options.functions) {\n less.functions.functionRegistry.addMultiple(options.functions);\n }\n\n const typePattern = /^text\\/(x-)?less$/;\n\n function clone(obj) {\n const cloned = {};\n for (const prop in obj) {\n if (obj.hasOwnProperty(prop)) {\n cloned[prop] = obj[prop];\n }\n }\n return cloned;\n }\n\n // only really needed for phantom\n function bind(func, thisArg) {\n const curryArgs = Array.prototype.slice.call(arguments, 2);\n return function() {\n const args = curryArgs.concat(Array.prototype.slice.call(arguments, 0));\n return func.apply(thisArg, args);\n };\n }\n\n function loadStyles(modifyVars) {\n const styles = document.getElementsByTagName('style');\n let style;\n\n for (let i = 0; i < styles.length; i++) {\n style = styles[i];\n if (style.type.match(typePattern)) {\n const instanceOptions = clone(options);\n instanceOptions.modifyVars = modifyVars;\n const lessText = style.innerHTML || '';\n instanceOptions.filename = document.location.href.replace(/#.*$/, '');\n\n /* jshint loopfunc:true */\n // use closure to store current style\n less.render(lessText, instanceOptions,\n bind((style, e, result) => {\n if (e) {\n errors.add(e, 'inline');\n } else {\n style.type = 'text/css';\n if (style.styleSheet) {\n style.styleSheet.cssText = result.css;\n } else {\n style.innerHTML = result.css;\n }\n }\n }, null, style));\n }\n }\n }\n\n function loadStyleSheet(sheet, callback, reload, remaining, modifyVars) {\n\n const instanceOptions = clone(options);\n addDataAttr(instanceOptions, sheet);\n instanceOptions.mime = sheet.type;\n\n if (modifyVars) {\n instanceOptions.modifyVars = modifyVars;\n }\n\n function loadInitialFileCallback(loadedFile) {\n const data = loadedFile.contents;\n const path = loadedFile.filename;\n const webInfo = loadedFile.webInfo;\n\n const newFileInfo = {\n currentDirectory: fileManager.getPath(path),\n filename: path,\n rootFilename: path,\n rewriteUrls: instanceOptions.rewriteUrls\n };\n\n newFileInfo.entryPath = newFileInfo.currentDirectory;\n newFileInfo.rootpath = instanceOptions.rootpath || newFileInfo.currentDirectory;\n\n if (webInfo) {\n webInfo.remaining = remaining;\n\n const css = cache.getCSS(path, webInfo, instanceOptions.modifyVars);\n if (!reload && css) {\n webInfo.local = true;\n callback(null, css, data, sheet, webInfo, path);\n return;\n }\n\n }\n\n // TODO add tests around how this behaves when reloading\n errors.remove(path);\n\n instanceOptions.rootFileInfo = newFileInfo;\n less.render(data, instanceOptions, (e, result) => {\n if (e) {\n e.href = path;\n callback(e);\n } else {\n cache.setCSS(sheet.href, webInfo.lastModified, instanceOptions.modifyVars, result.css);\n callback(null, result.css, data, sheet, webInfo, path);\n }\n });\n }\n\n fileManager.loadFile(sheet.href, null, instanceOptions, environment)\n .then(loadedFile => {\n loadInitialFileCallback(loadedFile);\n }).catch(err => {\n console.log(err);\n callback(err);\n });\n\n }\n\n function loadStyleSheets(callback, reload, modifyVars) {\n for (let i = 0; i < less.sheets.length; i++) {\n loadStyleSheet(less.sheets[i], callback, reload, less.sheets.length - (i + 1), modifyVars);\n }\n }\n\n function initRunningMode() {\n if (less.env === 'development') {\n less.watchTimer = setInterval(() => {\n if (less.watchMode) {\n fileManager.clearFileCache();\n loadStyleSheets((e, css, _, sheet, webInfo) => {\n if (e) {\n errors.add(e, e.href || sheet.href);\n } else if (css) {\n browser.createCSS(window.document, css, sheet);\n }\n });\n }\n }, options.poll);\n }\n }\n\n //\n // Watch mode\n //\n less.watch = function () {\n if (!less.watchMode ) {\n less.env = 'development';\n initRunningMode();\n }\n this.watchMode = true;\n return true;\n };\n\n less.unwatch = function () {clearInterval(less.watchTimer); this.watchMode = false; return false; };\n\n //\n // Synchronously get all tags with the 'rel' attribute set to\n // \"stylesheet/less\".\n //\n less.registerStylesheetsImmediately = () => {\n const links = document.getElementsByTagName('link');\n less.sheets = [];\n\n for (let i = 0; i < links.length; i++) {\n if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) &&\n (links[i].type.match(typePattern)))) {\n less.sheets.push(links[i]);\n }\n }\n };\n\n //\n // Asynchronously get all tags with the 'rel' attribute set to\n // \"stylesheet/less\", returning a Promise.\n //\n less.registerStylesheets = () => new Promise((resolve, reject) => {\n less.registerStylesheetsImmediately();\n resolve();\n });\n\n //\n // With this function, it's possible to alter variables and re-render\n // CSS without reloading less-files\n //\n less.modifyVars = record => less.refresh(true, record, false);\n\n less.refresh = (reload, modifyVars, clearFileCache) => {\n if ((reload || clearFileCache) && clearFileCache !== false) {\n fileManager.clearFileCache();\n }\n return new Promise((resolve, reject) => {\n let startTime;\n let endTime;\n let totalMilliseconds;\n let remainingSheets;\n startTime = endTime = new Date();\n\n // Set counter for remaining unprocessed sheets\n remainingSheets = less.sheets.length;\n\n if (remainingSheets === 0) {\n\n endTime = new Date();\n totalMilliseconds = endTime - startTime;\n less.logger.info('Less has finished and no sheets were loaded.');\n resolve({\n startTime,\n endTime,\n totalMilliseconds,\n sheets: less.sheets.length\n });\n\n } else {\n // Relies on less.sheets array, callback seems to be guaranteed to be called for every element of the array\n loadStyleSheets((e, css, _, sheet, webInfo) => {\n if (e) {\n errors.add(e, e.href || sheet.href);\n reject(e);\n return;\n }\n if (webInfo.local) {\n less.logger.info(`Loading ${sheet.href} from cache.`);\n } else {\n less.logger.info(`Rendered ${sheet.href} successfully.`);\n }\n browser.createCSS(window.document, css, sheet);\n less.logger.info(`CSS for ${sheet.href} generated in ${new Date() - endTime}ms`);\n\n // Count completed sheet\n remainingSheets--;\n\n // Check if the last remaining sheet was processed and then call the promise\n if (remainingSheets === 0) {\n totalMilliseconds = new Date() - startTime;\n less.logger.info(`Less has finished. CSS generated in ${totalMilliseconds}ms`);\n resolve({\n startTime,\n endTime,\n totalMilliseconds,\n sheets: less.sheets.length\n });\n }\n endTime = new Date();\n }, reload, modifyVars);\n }\n\n loadStyles(modifyVars);\n });\n };\n\n less.refreshStyles = loadStyles;\n return less;\n};\n","export default (less, options) => {\n const logLevel_debug = 4;\n const logLevel_info = 3;\n const logLevel_warn = 2;\n const logLevel_error = 1;\n\n // The amount of logging in the javascript console.\n // 3 - Debug, information and errors\n // 2 - Information and errors\n // 1 - Errors\n // 0 - None\n // Defaults to 2\n options.logLevel = typeof options.logLevel !== 'undefined' ? options.logLevel : (options.env === 'development' ? logLevel_info : logLevel_error);\n\n if (!options.loggers) {\n options.loggers = [{\n debug: function(msg) {\n if (options.logLevel >= logLevel_debug) {\n console.log(msg);\n }\n },\n info: function(msg) {\n if (options.logLevel >= logLevel_info) {\n console.log(msg);\n }\n },\n warn: function(msg) {\n if (options.logLevel >= logLevel_warn) {\n console.warn(msg);\n }\n },\n error: function(msg) {\n if (options.logLevel >= logLevel_error) {\n console.error(msg);\n }\n }\n }];\n }\n for (let i = 0; i < options.loggers.length; i++) {\n less.logger.addListener(options.loggers[i]);\n }\n};\n","// Cache system is a bit outdated and could do with work\n\nexport default (window, options, logger) => {\n let cache = null;\n if (options.env !== 'development') {\n try {\n cache = (typeof window.localStorage === 'undefined') ? null : window.localStorage;\n } catch (_) {}\n }\n return {\n setCSS: function(path, lastModified, modifyVars, styles) {\n if (cache) {\n logger.info(`saving ${path} to cache.`);\n try {\n cache.setItem(path, styles);\n cache.setItem(`${path}:timestamp`, lastModified);\n if (modifyVars) {\n cache.setItem(`${path}:vars`, JSON.stringify(modifyVars));\n }\n } catch (e) {\n // TODO - could do with adding more robust error handling\n logger.error(`failed to save \"${path}\" to local storage for caching.`);\n }\n }\n },\n getCSS: function(path, webInfo, modifyVars) {\n const css = cache && cache.getItem(path);\n const timestamp = cache && cache.getItem(`${path}:timestamp`);\n let vars = cache && cache.getItem(`${path}:vars`);\n\n modifyVars = modifyVars || {};\n vars = vars || \"{}\"; // if not set, treat as the JSON representation of an empty object\n\n if (timestamp && webInfo.lastModified &&\n (new Date(webInfo.lastModified).valueOf() ===\n new Date(timestamp).valueOf()) &&\n JSON.stringify(modifyVars) === vars) {\n // Use local copy\n return css;\n }\n }\n };\n};\n","\nimport functionRegistry from './../less/functions/function-registry';\n\nexport default () => {\n function imageSize() {\n throw {\n type: 'Runtime',\n message: 'Image size functions are not supported in browser version of less'\n };\n }\n\n const imageFunctions = {\n 'image-size': function(filePathNode) {\n imageSize(this, filePathNode);\n return -1;\n },\n 'image-width': function(filePathNode) {\n imageSize(this, filePathNode);\n return -1;\n },\n 'image-height': function(filePathNode) {\n imageSize(this, filePathNode);\n return -1;\n }\n };\n\n functionRegistry.addMultiple(imageFunctions);\n};\n"],"names":["extractId","href","replace","addDataAttr","options","tag","opt","dataset","hasOwnProperty","JSON","parse","_","document","styles","sheet","id","title","utils.extractId","oldStyleNode","getElementById","keepOldStyleNode","styleNode","createElement","setAttribute","media","styleSheet","appendChild","createTextNode","childNodes","length","firstChild","nodeValue","head","getElementsByTagName","nextEl","nextSibling","parentNode","insertBefore","removeChild","cssText","e","Error","window","scripts","currentScript","error","msg","this","_fireEvent","warn","info","debug","addListener","listener","_listeners","push","removeListener","i","splice","type","logFunction","externalEnvironment","fileManagers","requiredFunctions","functions","concat","propName","environmentFunc","bind","Environment","filename","currentDirectory","environment","isSync","logger","pluginManager","getFileManagers","fileManager","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgrey","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgrey","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","m","cm","mm","in","px","pt","pc","duration","s","ms","angle","rad","Math","PI","deg","grad","turn","colors","unitConversions","parent","visibilityBlocks","undefined","nodeVisible","rootNode","parsed","Object","Node","fileInfo","getIndex","nodes","set","node","Array","isArray","forEach","_index","_fileInfo","context","strs","genCSS","add","chunk","index","isEmpty","join","output","value","visitor","visit","op","a","b","precision","numPrecision","Number","toFixed","compare","Color","rgb","originalForm","self","match","map","c","parseInt","alpha","split","clamp","v","max","min","toHex","round","toString","prototype","assign","luma","r","g","pow","toCSS","doNotCompress","color","colorFunction","compress","args","fround","indexOf","toHSL","h","l","toRGB","splitcolor","operate","other","_operate","d","toHSV","toARGB","x","fromKeyword","keyword","key","toLowerCase","slice","Paren","eval","_noSpaceCombinators"," ","|","Combinator","emptyOrWhitespace","trim","spaceOrEmpty","Element","combinator","isVariable","currentFileInfo","visibilityInfo","copyVisibilityInfo","setParent","accept","clone","firstSelector","charAt","ALWAYS","PARENS_DIVISION","PARENS","RewriteUrls","getType","payload","call","copy","target","constructor","getPrototypeOf","il","arguments","k","j","jl","__spreadArrays","getOwnPropertyNames","getOwnPropertySymbols","reduce","carry","props","includes","newVal","originalObject","includeNonenumerable","propType","propertyIsEnumerable","defineProperty","enumerable","writable","configurable","assignProp","nonenumerable","getLocation","inputStream","n","line","column","copyArray","arr","obj","cloned","prop","defaults","obj1","obj2","newObj","_defaults","defaults_1","copyOptions","opts","strictMath","math","Constants.Math","relativeUrls","rewriteUrls","Constants.RewriteUrls","flattenArray","result","length_1","anonymousFunc","LessError","fileContentMap","currentFilename","message","stack","input","contents","loc","utils.getLocation","col","callLine","lines","found","func","Function","lineAdjust","callExtract","extract","create","F","stylize","str","errorTxt","substr","Selector","elements","extendList","condition","evaldCondition","getElements","mixinElements_","visitArray","createDerived","newSelector","mediaEmpty","els","parseNode","err","imports","createEmptySelectors","el","sels","olen","len","mixinElements","shift","isJustParentSelector","extend","getIsOutput","Value","Keyword","True","False","Anonymous","mapLines","rulesetLike","allowRoot","isRulesetLike","Boolean","MATH","Declaration","name","important","merge","inline","variable","lastRule","prevMath","evaldValue","mathBypass","evalName","importantScope","importantResult","pop","makeImportant","ctx","lineSeparator","dumpLineNumbers","debugInfo","asComment","asMediaQuery","lineNumber","fileName","filenameWithProtocol","test","Comment","isLineComment","getDebugInfo","isSilent","isCompressed","contexts","copyFromOriginal","original","destination","propertiesToCopy","parseCopyProperties","Parse","paths","evalCopyProperties","isPathRelative","path","isPathLocalRelative","Eval","frames","enterCalc","calcStack","inCalc","exitCalc","inParenthesis","parensStack","outOfParenthesis","mathOn","isMathOn","pathRequiresRewrite","rewritePath","rootpath","newPath","normalizePath","segment","segments","reverse","makeRegistry","base","_data","addMultiple","keys","_this","get","getLocalFunctions","inherit","defaultFunc","value_","error_","reset","Ruleset","selectors","rules","strictImports","_lookups","_variables","_properties","isRuleset","selCnt","selector","hasVariable","hasOnePassingSelector","toParseSelectors","utils.flattenArray","rule","subRule","utils.copyArray","ruleset","originalRuleset","root","firstRoot","allowImports","functionRegistry","globalFunctionRegistry","ctxFrames","unshift","ctxSelectors","evalImports","rsRules","evalFirst","mediaBlockCount","mediaBlocks","filter","apply","resetCache","bubbleSelectors","importRules","matchArgs","matchCondition","lastSelector","_rulesets","variables","hash","vars","name_1","properties","name_2","decl","parseValue","property","lastDeclaration","toParse","transformDeclaration","nodes_1","rulesets","filtRules","prependRule","find","foundMixins","ruleNodes","tabLevel","sep","tabRuleStr","tabSetStr","charsetNodeIndex","importNodeIndex","isCharset","pathCnt","pathSubCnt","currentLastRule","isVisible","joinSelectors","joinSelector","createParenthesis","elementsToPak","originalElement","replacementParen","insideParent","createSelector","containedElement","element","addReplacementIntoPath","beginningPath","addPath","replacedElement","originalSelector","newSelectorPath","newJoinedSelector","parentEl","restOfPath","addAllReplacementsIntoPath","addPaths","mergeElementsOnToSelectors","sel","deriveSelector","deriveFrom","newPaths","replaceParentSelector","inSelector","currentElements","newSelectors","selectorsMultiplied","maybeSelector","hadParentSelector","nestedSelector","replaced","nestedPaths","replacedNewSelectors","concatenated","AtRule","isRooted","outputRuleset","mediaPathBackup","mediaBlocksBackup","mediaPath","ruleCnt","DetachedRuleset","callEval","Unit","numerator","denominator","backupUnit","sort","strictUnits","returnStr","is","unitString","toUpperCase","isLength","RegExp","isSingular","callback","usedUnits","group","mapUnit","groupName","atomicUnit","cancel","counter","count","Dimension","unit","parseFloat","isNaN","toColor","strValue","String","convertTo","unify","numericCompare","conversions","targetUnit","applyUnit","derivedConversions","Operation","operands","isSpaced","Expression","noSpacing","returnValue","parens","doubleParen","parensInOp","throwAwayComments","functionCaller","evalArgs","commentFilter","item","subNodes","to","from","pack","ar","Call","calc","currentMathContext","funcCaller","FunctionCaller","isValid","columnNumber","Variable","evaluating","frame","fun","Property","mergeRules","less","visitors","ToCSSVisitor","_mergeRules","vArr","Attribute","Quoted","content","escaped","quote","variableRegex","propRegex","containsVariables","that","iterativeReplace","regexp","replacementFnc","evaluatedValue","URL","val","isEvald","urlArgs","Media","features","evalTop","evalNested","multiMedia","permute","fragment","rest","Import","css","pathValue","getPath","isPlugin","reference","isVariableImport","evalForImport","evalPath","doEval","blocksVisibility","addVisibilityBlock","registry","skip","importedFilename","newImport","JsEvalNode","evaluateJavaScript","expression","evalContext","javascriptEnabled","jsify","toJS","JavaScript","string","Assignment","Condition","negate","lvalue","rvalue","UnicodeDescriptor","Negative","Extend","option","object_id","next_id","parent_ids","allowBefore","allowAfter","findSelfSelectors","selectorElements","selfElements","selfSelectors","VariableCall","detachedRuleset","NamespaceValue","ruleCall","lookups","substring","Definition","params","variadic","arity","optionalParameters","required","p","evalParams","mixinEnv","evaldArguments","varargs","arg","isNamedFound","argIndex","argsLength","evalCall","_arguments","mixinFrames","allArgsCnt","requiredArgsCnt","MixinCall","mixins","mixin","mixinPath","argValue","f","isRecursive","isOneFound","candidate","defaultResult","noArgumentsFilter","candidates","conditionResult","calcDefGroup","namespace","expand","MixinDefinition","format","newRules","_setVisibilityToReplacement","replacement","AbstractFileManager","lastIndexOf","ext","tryAppendExtension","basePath","laterPath","url","baseUrl","urlDirectories","baseUrlDirectories","urlParts","extractUrlParts","baseUrlParts","diff","hostPart","directories","urlPartsRegex","returner","rawDirectories","rawPath","fileUrl","require","AbstractPluginLoader","pluginOptions","pluginObj","localModule","shortname","FileManager","trySetOptions","use","exports","loader","tree","validatePlugin","minVersion","compareVersion","addPlugin","plugin","setOptions","version","versionToString","aVersion","bVersion","versionString","plugins","printUsage","_visitArgs","visitDeeper","_hasIndexed","_noop","implementation","_implementation","_visitInCache","_visitOutCache","indexNodeTypes","ticker","child","typeIndex","Visitor","nodeTypeIndex","fnName","impl","funcOut","visitArgs","newNode","isReplacing","cnt","nonReplacing","out","evald","flatten","nestedCnt","nestedItem","onSequencerEmpty","variableImports","_onSequencerEmpty","_currentDepth","ImportSequencer","importSequencer","importItem","isReady","tryRun","variableImport","ImportVisitor","importer","finish","_visitor","_importer","_finish","importCount","onceFileDetectionMap","recursionDetector","_sequencer","run","isFinished","visitImport","importNode","inlineCSS","importParent","addVariableImport","processImportNode","evaldImportNode","multiple","importMultiple","tryAppendLessExtension","onImported","sequencedOnImported","addImport","importedAtRoot","fullPath","importVisitor","isOptional","optional","duplicateImport","oldContext","visitDeclaration","declNode","visitDeclarationOut","visitAtRule","atRuleNode","visitAtRuleOut","visitMixinDefinition","mixinDefinitionNode","visitMixinDefinitionOut","visitRuleset","rulesetNode","visitRulesetOut","visitMedia","mediaNode","visitMediaOut","visible","SetTreeVisibilityVisitor","ensureVisibility","ensureInvisibility","allExtendsStack","ExtendFinderVisitor","allExtends","allSelectorsExtendList","extendOnEveryPath","selectorPath","selExtendList","allSelectorsExtend","foundExtends","firstExtendOnThisSelectorPath","ProcessExtendsVisitor","extendFinder","extendIndices","doExtendChaining","newRoot","checkExtendsForNonMatched","indices","hasFoundMatches","extendsList","extendsListTarget","iterationCount","extendIndex","targetExtendIndex","matches","targetExtend","newExtend","extendsToAdd","extendVisitor","findMatch","selfSelector","extendSelector","extendChainCount","selectorOne","selectorTwo","ruleNode","selectorNode","pathIndex","selectorsToAdd","extendedSelectors","haystackSelectorPath","haystackSelectorIndex","hackstackSelector","hackstackElementIndex","haystackElement","targetCombinator","potentialMatch","needleElements","potentialMatches","matched","initialCombinator","isElementValuesEqual","finished","endPathIndex","endPathElementIndex","elementValue1","elementValue2","replacementSelector","matchIndex","firstElement","newElements","currentSelectorPathIndex","currentSelectorPathElementIndex","currentValue","derived","newAllExtends","lastIndex","JoinSelectorVisitor","_context","CSSVisitorUtils","bodyRules","owner","thing","originalRules","containsSilentNonBlockedChild","compiledRulesBody","keepOnlyVisibleChilds","removeVisibilityBlock","hasVisibleSelector","utils","mixinNode","visitExtend","extendNode","visitComment","commentNode","resolveVisibility","visitAtRuleWithBody","visitAtRuleWithoutBody","visitAnonymous","anonymousNode","nodeRules","hasFakeRuleset","getBodyRules","charset","comment","checkValidNodes","isRoot","_compileRulesetPaths","nodeRuleCnt","_removeDuplicateRules","isVisibleRuleset","ruleList","ruleCache","ruleCSS","groups","groupsArr","result_1","space_1","comma_1","MarkVisibleSelectorsVisitor","ExtendVisitor","furthest","furthestPossibleErrorMessage","chunks","current","currentPos","saveStack","parserInput","skipWhitespace","nextChar","oldi","oldj","curr","endIndex","mem","inp","charCodeAt","autoCommentAbsorb","nextNewLine","text","commentStore","nextStarSlash","save","restore","possibleErrorMessage","state","forget","isWhitespace","offset","pos","code","$re","tok","exec","$char","$str","tokLength","$quoted","startChar","currentPosition","$parseUntil","testChar","returnVal","inComment","blockDepth","blockStack","parseGroups","startPos","lastPos","loop","char","expected","peek","peekChar","currentChar","prevChar","getInput","peekNotNumeric","start","chunkInput","failFunction","fail","lastOpening","lastOpeningParen","lastMultiComment","lastMultiCommentEndBrace","chunkerCurrentIndex","currentChunkStartIndex","cc","cc2","level","parenLevel","emitFrom","emitChunk","force","fromCharCode","chunker","end","furthestReachedEnd","furthestChar","Parser","parsers","getParserInput","expect","expectChar","parseList","currentIndex","returnNodes","parser","additionalData","globalVars","modifyVars","ignored","preText","serializeVars","preProcessors","getPreProcessors","process","banner","contentsIgnoredChars","primary","endInfo","processImports","extendRule","definition","declaration","variableCall","entities","atrule","foundSemiColon","mixinLookup","quoted","forceEscaped","isEscaped","customFuncCall","stop","ieAlpha","boolean","if","prevArgs","isSemiColonSeparated","argsComma","argsSemiColon","assignment","literal","dimension","unicodeDescriptor","entity","ch","variableCurly","curly","propertyCurly","colorKeyword","ud","javascript","js","escape","parsedName","inValue","ruleLookups","isRule","getLookup","hasParens","elem","elemIndex","re","isCall","expressionContainsNamed","nameLoop","expressions","hasSep","cond","argInfo","conditions","block","lookupValue","attribute","slashedCombinator","isLess","when","blockRuleset","hasDR","ruleProperty","permissiveValue","anonymousValue","untilTokens","done","testCurrentChar","import","dir","importOptions","mediaFeatures","o","optionName","importOption","mediaFeature","pluginArgs","nonVendorSpecificName","hasIdentifier","hasExpression","hasUnknown","hasBlock","sub","addition","multiplication","operation","operand","needsParens","logical","next","conditionAnd","negatedCondition","parenthesisCondition","atomicCondition","body","me","tryConditionFollowedByParenthesis","delim","simpleProperty","If","trueValue","falseValue","isdefined","colorFunctions","hsla","origColor","hsl","number","rgba","size","m1_1","m2_1","hue","hsv","hsva","vs","floor","perm","saturation","lightness","hsvhue","hsvsaturation","hsvvalue","luminance","saturate","amount","method","desaturate","lighten","darken","fadein","fadeout","fade","spin","mix","color1","color2","weight","w","w1","w2","greyscale","contrast","dark","light","threshold","t","argb","tint","shade","colorBlend","mode","cb","cs","cr","ab","as","colorBlendModeFunctions","multiply","screen","overlay","softlight","sqrt","hardlight","difference","abs","exclusion","average","negation","getItemsFromNode","_SELF","~","_i","expr","values","range","step","stepValue","list","each","rs","iterator","tryEval","Quote","valueName","keyName","indexName","MathHelper","fn","mathFunctions","ceil","sin","cos","atan","asin","acos","mathHelper","fraction","num","minMax","isMin","currentUnified","referenceUnified","unitStatic","unitClone","order","convert","pi","mod","y","percentage","evaluated","encodeURI","pattern","flags","%","token","encodeURIComponent","isa","Type","isunit","isruleset","iscolor","isnumber","isstring","iskeyword","isurl","ispixel","ispercentage","isem","get-unit","colorBlending","fallback","functionThis","data-uri","mimetypeNode","filePathNode","mimetype","filePath","entryPath","fragmentStart","utils.clone","rawBuffer","getFileManager","useBase64","mimeLookup","charsetLookup","fileSync","loadFileSync","buf","encodeBase64","uri","dataUri","svg-gradient","direction","stops","gradientDirectionSvg","position","positionValue","gradientType","rectangleDimension","renderEnv","directionValue","throwArgumentDescriptor","types","evaldRoot","evalEnv","visitorIterator","preEvalVisitors","first","isPreEvalVisitor","isPreVisitor","pm","postProcessors","installedPlugins","pluginCache","Loader","PluginLoader","PluginManager","install","preProcessor","priority","indexToInsertAt","postProcessor","manager","PluginManagerFactory","newFactory","major","minor","patch","pre","build","sourceMapOutput","sourceMapBuilder","parseTree","importManager","SourceMapBuilder","ParseTree","transformTree","toCSSOptions","sourceMap","getPostProcessors","file","getExternalSourceMap","files","rootFilename","SourceMapOutput","contentsIgnoredCharsMap","contentsMap","sourceMapFilename","sourceMapURL","outputFilename","sourceMapOutputFilename","sourceMapBasepath","sourceMapRootpath","outputSourceFiles","sourceMapGenerator","sourceMapFileInline","disableSourcemapAnnotation","sourceMapInputFilename","normalizeFilename","removeBasepath","getCSSAppendage","_css","_rootNode","_contentsMap","_contentsIgnoredCharsMap","_sourceMapFilename","_outputFilename","_sourceMapBasepath","_sourceMapRootpath","_outputSourceFiles","_sourceMapGeneratorConstructor","getSourceMapGenerator","_lineNumber","_column","sourceLines","columns","sourceColumns","inputSource","_sourceMapGenerator","addMapping","generated","source","sourceRoot","setSourceContent","sourceMapContent","stringify","toJSON","rootFileInfo","mime","queue","ImportManager","pluginLoader","fileParsedFunc","importedEqualsRoot","newFileInfo","loadedFile","promise","loadFileCallback","resolvedFilename","pathDiff","isPathAbsolute","alwaysMakePathsAbsolute","newEnv","evalPlugin","syncImport","loadPluginSync","loadPlugin","loadFile","then","render","utils.copyOptions","self_1","Promise","resolve","reject","Render","context_1","pluginManager_1","reUsePluginManager","imports_1","evalResult","fileContent","parseVersion","initial","data","ctor","api","fileCache","doXHR","errback","xhr","XMLHttpRequest","async","isFileProtocol","fileAsync","handleResponse","status","responseText","getResponseHeader","overrideMimeType","open","setRequestHeader","send","onreadystatechange","readyState","supports","clearFileCache","location","useFileCache","lessText","webInfo","lastModified","Date","log","fulfill","catch","rootHref","errorReporting","errors","errorline","classname","logLevel","errorConsole","timer","filenameNoPath","className","innerHTML","browser","style","env","setInterval","replaceChild","clearInterval","errorHTML","remove","removeErrorHTML","depends","lint","insecure","protocol","poll","hostname","port","onReady","addDefaultOptions","LESS_PLUGINS","lessRoot","FM","addFileManager","loggers","console","LogListener","ErrorReporting","cache","localStorage","setCSS","setItem","getCSS","getItem","timestamp","valueOf","Cache","imageSize","imageFunctions","image-size","image-width","image-height","ImageSize","typePattern","thisArg","curryArgs","loadStyles","instanceOptions","loadStyleSheet","reload","remaining","local","loadInitialFileCallback","loadStyleSheets","sheets","watch","watchMode","watchTimer","unwatch","registerStylesheetsImmediately","links","rel","registerStylesheets","record","refresh","startTime","endTime","totalMilliseconds","remainingSheets","refreshStyles","resolveOrReject","pageLoadFinished"],"mappings":";;;;;;;;;8OACgBA,EAAUC,GACtB,OAAOA,EAAKC,QAAQ,sBAAuB,IACtCA,QAAQ,uBAAwB,IAChCA,QAAQ,MAAO,IACfA,QAAQ,eAAgB,IACxBA,QAAQ,aAAc,KACtBA,QAAQ,MAAO,cAGRC,EAAYC,EAASC,GACjC,IAAK,IAAMC,KAAOD,EAAIE,QAClB,GAAIF,EAAIE,QAAQC,eAAeF,GAC3B,GAAY,QAARA,GAAyB,oBAARA,GAAqC,aAARA,GAA8B,mBAARA,EACpEF,EAAQE,GAAOD,EAAIE,QAAQD,QAE3B,IACIF,EAAQE,GAAOG,KAAKC,MAAML,EAAIE,QAAQD,IAE1C,MAAOK,WChBR,SAAUC,EAAUC,EAAQC,GAEnC,IAAMb,EAAOa,EAAMb,MAAQ,GAGrBc,EAAK,SAAQD,EAAME,OAASC,EAAgBhB,IAG5CiB,EAAeN,EAASO,eAAeJ,GACzCK,GAAmB,EAGjBC,EAAYT,EAASU,cAAc,SACzCD,EAAUE,aAAa,OAAQ,YAC3BT,EAAMU,OACNH,EAAUE,aAAa,QAAST,EAAMU,OAE1CH,EAAUN,GAAKA,EAEVM,EAAUI,aACXJ,EAAUK,YAAYd,EAASe,eAAed,IAG9CO,EAAqC,OAAjBF,GAAyBA,EAAaU,WAAWC,OAAS,GAAKR,EAAUO,WAAWC,OAAS,GAC7GX,EAAaY,WAAWC,YAAcV,EAAUS,WAAWC,WAGnE,IAAMC,EAAOpB,EAASqB,qBAAqB,QAAQ,GAInD,GAAqB,OAAjBf,IAA8C,IAArBE,EAA4B,C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