UNPKG

82 kBPlain TextView Raw
1#!/usr/bin/env node
2'use strict';
3
4function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
5
6var fs = require('fs');
7var fs__default = _interopDefault(fs);
8var path = require('path');
9var path__default = _interopDefault(path);
10var module$1 = _interopDefault(require('module'));
11var os = _interopDefault(require('os'));
12var rollup = require('../dist/rollup.js');
13
14var index$1 = function (args, opts) {
15 if (!opts) { opts = {}; }
16
17 var flags = { bools : {}, strings : {}, unknownFn: null };
18
19 if (typeof opts['unknown'] === 'function') {
20 flags.unknownFn = opts['unknown'];
21 }
22
23 if (typeof opts['boolean'] === 'boolean' && opts['boolean']) {
24 flags.allBools = true;
25 } else {
26 [].concat(opts['boolean']).filter(Boolean).forEach(function (key) {
27 flags.bools[key] = true;
28 });
29 }
30
31 var aliases = {};
32 Object.keys(opts.alias || {}).forEach(function (key) {
33 aliases[key] = [].concat(opts.alias[key]);
34 aliases[key].forEach(function (x) {
35 aliases[x] = [key].concat(aliases[key].filter(function (y) {
36 return x !== y;
37 }));
38 });
39 });
40
41 [].concat(opts.string).filter(Boolean).forEach(function (key) {
42 flags.strings[key] = true;
43 if (aliases[key]) {
44 flags.strings[aliases[key]] = true;
45 }
46 });
47
48 var defaults = opts['default'] || {};
49
50 var argv = { _ : [] };
51 Object.keys(flags.bools).forEach(function (key) {
52 setArg(key, defaults[key] === undefined ? false : defaults[key]);
53 });
54
55 var notFlags = [];
56
57 if (args.indexOf('--') !== -1) {
58 notFlags = args.slice(args.indexOf('--')+1);
59 args = args.slice(0, args.indexOf('--'));
60 }
61
62 function argDefined(key, arg) {
63 return (flags.allBools && /^--[^=]+$/.test(arg)) ||
64 flags.strings[key] || flags.bools[key] || aliases[key];
65 }
66
67 function setArg (key, val, arg) {
68 if (arg && flags.unknownFn && !argDefined(key, arg)) {
69 if (flags.unknownFn(arg) === false) { return; }
70 }
71
72 var value = !flags.strings[key] && isNumber(val)
73 ? Number(val) : val;
74 setKey(argv, key.split('.'), value);
75
76 (aliases[key] || []).forEach(function (x) {
77 setKey(argv, x.split('.'), value);
78 });
79 }
80
81 function setKey (obj, keys, value) {
82 var o = obj;
83 keys.slice(0,-1).forEach(function (key) {
84 if (o[key] === undefined) { o[key] = {}; }
85 o = o[key];
86 });
87
88 var key = keys[keys.length - 1];
89 if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') {
90 o[key] = value;
91 }
92 else if (Array.isArray(o[key])) {
93 o[key].push(value);
94 }
95 else {
96 o[key] = [ o[key], value ];
97 }
98 }
99
100 function aliasIsBoolean(key) {
101 return aliases[key].some(function (x) {
102 return flags.bools[x];
103 });
104 }
105
106 for (var i = 0; i < args.length; i++) {
107 var arg = args[i];
108
109 if (/^--.+=/.test(arg)) {
110 // Using [\s\S] instead of . because js doesn't support the
111 // 'dotall' regex modifier. See:
112 // http://stackoverflow.com/a/1068308/13216
113 var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
114 var key = m[1];
115 var value = m[2];
116 if (flags.bools[key]) {
117 value = value !== 'false';
118 }
119 setArg(key, value, arg);
120 }
121 else if (/^--no-.+/.test(arg)) {
122 var key = arg.match(/^--no-(.+)/)[1];
123 setArg(key, false, arg);
124 }
125 else if (/^--.+/.test(arg)) {
126 var key = arg.match(/^--(.+)/)[1];
127 var next = args[i + 1];
128 if (next !== undefined && !/^-/.test(next)
129 && !flags.bools[key]
130 && !flags.allBools
131 && (aliases[key] ? !aliasIsBoolean(key) : true)) {
132 setArg(key, next, arg);
133 i++;
134 }
135 else if (/^(true|false)$/.test(next)) {
136 setArg(key, next === 'true', arg);
137 i++;
138 }
139 else {
140 setArg(key, flags.strings[key] ? '' : true, arg);
141 }
142 }
143 else if (/^-[^-]+/.test(arg)) {
144 var letters = arg.slice(1,-1).split('');
145
146 var broken = false;
147 for (var j = 0; j < letters.length; j++) {
148 var next = arg.slice(j+2);
149
150 if (next === '-') {
151 setArg(letters[j], next, arg);
152 continue;
153 }
154
155 if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) {
156 setArg(letters[j], next.split('=')[1], arg);
157 broken = true;
158 break;
159 }
160
161 if (/[A-Za-z]/.test(letters[j])
162 && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
163 setArg(letters[j], next, arg);
164 broken = true;
165 break;
166 }
167
168 if (letters[j+1] && letters[j+1].match(/\W/)) {
169 setArg(letters[j], arg.slice(j+2), arg);
170 broken = true;
171 break;
172 }
173 else {
174 setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg);
175 }
176 }
177
178 var key = arg.slice(-1)[0];
179 if (!broken && key !== '-') {
180 if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1])
181 && !flags.bools[key]
182 && (aliases[key] ? !aliasIsBoolean(key) : true)) {
183 setArg(key, args[i+1], arg);
184 i++;
185 }
186 else if (args[i+1] && /true|false/.test(args[i+1])) {
187 setArg(key, args[i+1] === 'true', arg);
188 i++;
189 }
190 else {
191 setArg(key, flags.strings[key] ? '' : true, arg);
192 }
193 }
194 }
195 else {
196 if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
197 argv._.push(
198 flags.strings['_'] || !isNumber(arg) ? arg : Number(arg)
199 );
200 }
201 if (opts.stopEarly) {
202 argv._.push.apply(argv._, args.slice(i + 1));
203 break;
204 }
205 }
206 }
207
208 Object.keys(defaults).forEach(function (key) {
209 if (!hasKey(argv, key.split('.'))) {
210 setKey(argv, key.split('.'), defaults[key]);
211
212 (aliases[key] || []).forEach(function (x) {
213 setKey(argv, x.split('.'), defaults[key]);
214 });
215 }
216 });
217
218 if (opts['--']) {
219 argv['--'] = new Array();
220 notFlags.forEach(function(key) {
221 argv['--'].push(key);
222 });
223 }
224 else {
225 notFlags.forEach(function(key) {
226 argv._.push(key);
227 });
228 }
229
230 return argv;
231};
232
233function hasKey (obj, keys) {
234 var o = obj;
235 keys.slice(0,-1).forEach(function (key) {
236 o = (o[key] || {});
237 });
238
239 var key = keys[keys.length - 1];
240 return key in o;
241}
242
243function isNumber (x) {
244 if (typeof x === 'number') { return true; }
245 if (/^0x[0-9a-f]+$/i.test(x)) { return true; }
246 return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
247}
248
249var help = "rollup version __VERSION__\n=====================================\n\nUsage: rollup [options] <entry file>\n\nBasic options:\n\n-v, --version Show version number\n-h, --help Show this help message\n-c, --config Use this config file (if argument is used but value\n is unspecified, defaults to rollup.config.js)\n-w, --watch Watch files in bundle and rebuild on changes\n-i, --input Input (alternative to <entry file>)\n-o, --output <output> Output (if absent, prints to stdout)\n-f, --format [es] Type of output (amd, cjs, es, iife, umd)\n-e, --external Comma-separate list of module IDs to exclude\n-g, --globals Comma-separate list of `module ID:Global` pairs\n Any module IDs defined here are added to external\n-n, --name Name for UMD export\n-u, --id ID for AMD module (default is anonymous)\n-m, --sourcemap Generate sourcemap (`-m inline` for inline map)\n--no-strict Don't emit a `\"use strict\";` in the generated modules.\n--no-indent Don't indent result\n--environment <values> Settings passed to config file (see example)\n--no-conflict Generate a noConflict method for UMD globals\n--silent Don't print warnings\n--intro Content to insert at top of bundle (inside wrapper)\n--outro Content to insert at end of bundle (inside wrapper)\n--banner Content to insert at top of bundle (outside wrapper)\n--footer Content to insert at end of bundle (outside wrapper)\n--interop Include interop block (true by default)\n\nExamples:\n\n# use settings in config file\nrollup -c\n\n# in config file, process.env.INCLUDE_DEPS === 'true'\n# and process.env.BUILD === 'production'\nrollup -c --environment INCLUDE_DEPS,BUILD:production\n\n# create CommonJS bundle.js from src/main.js\nrollup --format=cjs --output=bundle.js -- src/main.js\n\n# create self-executing IIFE using `window.jQuery`\n# and `window._` as external globals\nrollup -f iife --globals jquery:jQuery,lodash:_ \\\n -i src/app.js -o build/app.js -m build/app.js.map\n\nNotes:\n\n* When piping to stdout, only inline sourcemaps are permitted\n\nFor more information visit https://github.com/rollup/rollup/wiki\n";
250
251var version = "0.47.4";
252
253var modules = {};
254
255var getModule = function(dir) {
256 var rootPath = dir ? path__default.resolve(dir) : process.cwd();
257 var rootName = path__default.join(rootPath, '@root');
258 var root = modules[rootName];
259 if (!root) {
260 root = new module$1(rootName);
261 root.filename = rootName;
262 root.paths = module$1._nodeModulePaths(rootPath);
263 modules[rootName] = root;
264 }
265 return root;
266};
267
268var requireRelative = function(requested, relativeTo) {
269 var root = getModule(relativeTo);
270 return root.require(requested);
271};
272
273requireRelative.resolve = function(requested, relativeTo) {
274 var root = getModule(relativeTo);
275 return module$1._resolveFilename(requested, root);
276};
277
278var index$2 = requireRelative;
279
280var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
281
282var index$4 = function (str) {
283 if (typeof str !== 'string') {
284 throw new TypeError('Expected a string');
285 }
286
287 return str.replace(matchOperatorsRe, '\\$&');
288};
289
290function createCommonjsModule(fn, module) {
291 return module = { exports: {} }, fn(module, module.exports), module.exports;
292}
293
294var index$10 = {
295 "aliceblue": [240, 248, 255],
296 "antiquewhite": [250, 235, 215],
297 "aqua": [0, 255, 255],
298 "aquamarine": [127, 255, 212],
299 "azure": [240, 255, 255],
300 "beige": [245, 245, 220],
301 "bisque": [255, 228, 196],
302 "black": [0, 0, 0],
303 "blanchedalmond": [255, 235, 205],
304 "blue": [0, 0, 255],
305 "blueviolet": [138, 43, 226],
306 "brown": [165, 42, 42],
307 "burlywood": [222, 184, 135],
308 "cadetblue": [95, 158, 160],
309 "chartreuse": [127, 255, 0],
310 "chocolate": [210, 105, 30],
311 "coral": [255, 127, 80],
312 "cornflowerblue": [100, 149, 237],
313 "cornsilk": [255, 248, 220],
314 "crimson": [220, 20, 60],
315 "cyan": [0, 255, 255],
316 "darkblue": [0, 0, 139],
317 "darkcyan": [0, 139, 139],
318 "darkgoldenrod": [184, 134, 11],
319 "darkgray": [169, 169, 169],
320 "darkgreen": [0, 100, 0],
321 "darkgrey": [169, 169, 169],
322 "darkkhaki": [189, 183, 107],
323 "darkmagenta": [139, 0, 139],
324 "darkolivegreen": [85, 107, 47],
325 "darkorange": [255, 140, 0],
326 "darkorchid": [153, 50, 204],
327 "darkred": [139, 0, 0],
328 "darksalmon": [233, 150, 122],
329 "darkseagreen": [143, 188, 143],
330 "darkslateblue": [72, 61, 139],
331 "darkslategray": [47, 79, 79],
332 "darkslategrey": [47, 79, 79],
333 "darkturquoise": [0, 206, 209],
334 "darkviolet": [148, 0, 211],
335 "deeppink": [255, 20, 147],
336 "deepskyblue": [0, 191, 255],
337 "dimgray": [105, 105, 105],
338 "dimgrey": [105, 105, 105],
339 "dodgerblue": [30, 144, 255],
340 "firebrick": [178, 34, 34],
341 "floralwhite": [255, 250, 240],
342 "forestgreen": [34, 139, 34],
343 "fuchsia": [255, 0, 255],
344 "gainsboro": [220, 220, 220],
345 "ghostwhite": [248, 248, 255],
346 "gold": [255, 215, 0],
347 "goldenrod": [218, 165, 32],
348 "gray": [128, 128, 128],
349 "green": [0, 128, 0],
350 "greenyellow": [173, 255, 47],
351 "grey": [128, 128, 128],
352 "honeydew": [240, 255, 240],
353 "hotpink": [255, 105, 180],
354 "indianred": [205, 92, 92],
355 "indigo": [75, 0, 130],
356 "ivory": [255, 255, 240],
357 "khaki": [240, 230, 140],
358 "lavender": [230, 230, 250],
359 "lavenderblush": [255, 240, 245],
360 "lawngreen": [124, 252, 0],
361 "lemonchiffon": [255, 250, 205],
362 "lightblue": [173, 216, 230],
363 "lightcoral": [240, 128, 128],
364 "lightcyan": [224, 255, 255],
365 "lightgoldenrodyellow": [250, 250, 210],
366 "lightgray": [211, 211, 211],
367 "lightgreen": [144, 238, 144],
368 "lightgrey": [211, 211, 211],
369 "lightpink": [255, 182, 193],
370 "lightsalmon": [255, 160, 122],
371 "lightseagreen": [32, 178, 170],
372 "lightskyblue": [135, 206, 250],
373 "lightslategray": [119, 136, 153],
374 "lightslategrey": [119, 136, 153],
375 "lightsteelblue": [176, 196, 222],
376 "lightyellow": [255, 255, 224],
377 "lime": [0, 255, 0],
378 "limegreen": [50, 205, 50],
379 "linen": [250, 240, 230],
380 "magenta": [255, 0, 255],
381 "maroon": [128, 0, 0],
382 "mediumaquamarine": [102, 205, 170],
383 "mediumblue": [0, 0, 205],
384 "mediumorchid": [186, 85, 211],
385 "mediumpurple": [147, 112, 219],
386 "mediumseagreen": [60, 179, 113],
387 "mediumslateblue": [123, 104, 238],
388 "mediumspringgreen": [0, 250, 154],
389 "mediumturquoise": [72, 209, 204],
390 "mediumvioletred": [199, 21, 133],
391 "midnightblue": [25, 25, 112],
392 "mintcream": [245, 255, 250],
393 "mistyrose": [255, 228, 225],
394 "moccasin": [255, 228, 181],
395 "navajowhite": [255, 222, 173],
396 "navy": [0, 0, 128],
397 "oldlace": [253, 245, 230],
398 "olive": [128, 128, 0],
399 "olivedrab": [107, 142, 35],
400 "orange": [255, 165, 0],
401 "orangered": [255, 69, 0],
402 "orchid": [218, 112, 214],
403 "palegoldenrod": [238, 232, 170],
404 "palegreen": [152, 251, 152],
405 "paleturquoise": [175, 238, 238],
406 "palevioletred": [219, 112, 147],
407 "papayawhip": [255, 239, 213],
408 "peachpuff": [255, 218, 185],
409 "peru": [205, 133, 63],
410 "pink": [255, 192, 203],
411 "plum": [221, 160, 221],
412 "powderblue": [176, 224, 230],
413 "purple": [128, 0, 128],
414 "rebeccapurple": [102, 51, 153],
415 "red": [255, 0, 0],
416 "rosybrown": [188, 143, 143],
417 "royalblue": [65, 105, 225],
418 "saddlebrown": [139, 69, 19],
419 "salmon": [250, 128, 114],
420 "sandybrown": [244, 164, 96],
421 "seagreen": [46, 139, 87],
422 "seashell": [255, 245, 238],
423 "sienna": [160, 82, 45],
424 "silver": [192, 192, 192],
425 "skyblue": [135, 206, 235],
426 "slateblue": [106, 90, 205],
427 "slategray": [112, 128, 144],
428 "slategrey": [112, 128, 144],
429 "snow": [255, 250, 250],
430 "springgreen": [0, 255, 127],
431 "steelblue": [70, 130, 180],
432 "tan": [210, 180, 140],
433 "teal": [0, 128, 128],
434 "thistle": [216, 191, 216],
435 "tomato": [255, 99, 71],
436 "turquoise": [64, 224, 208],
437 "violet": [238, 130, 238],
438 "wheat": [245, 222, 179],
439 "white": [255, 255, 255],
440 "whitesmoke": [245, 245, 245],
441 "yellow": [255, 255, 0],
442 "yellowgreen": [154, 205, 50]
443};
444
445var conversions = createCommonjsModule(function (module) {
446/* MIT license */
447
448
449// NOTE: conversions should only return primitive values (i.e. arrays, or
450// values that give correct `typeof` results).
451// do not use box values types (i.e. Number(), String(), etc.)
452
453var reverseKeywords = {};
454for (var key in index$10) {
455 if (index$10.hasOwnProperty(key)) {
456 reverseKeywords[index$10[key]] = key;
457 }
458}
459
460var convert = module.exports = {
461 rgb: {channels: 3, labels: 'rgb'},
462 hsl: {channels: 3, labels: 'hsl'},
463 hsv: {channels: 3, labels: 'hsv'},
464 hwb: {channels: 3, labels: 'hwb'},
465 cmyk: {channels: 4, labels: 'cmyk'},
466 xyz: {channels: 3, labels: 'xyz'},
467 lab: {channels: 3, labels: 'lab'},
468 lch: {channels: 3, labels: 'lch'},
469 hex: {channels: 1, labels: ['hex']},
470 keyword: {channels: 1, labels: ['keyword']},
471 ansi16: {channels: 1, labels: ['ansi16']},
472 ansi256: {channels: 1, labels: ['ansi256']},
473 hcg: {channels: 3, labels: ['h', 'c', 'g']},
474 apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
475 gray: {channels: 1, labels: ['gray']}
476};
477
478// hide .channels and .labels properties
479for (var model in convert) {
480 if (convert.hasOwnProperty(model)) {
481 if (!('channels' in convert[model])) {
482 throw new Error('missing channels property: ' + model);
483 }
484
485 if (!('labels' in convert[model])) {
486 throw new Error('missing channel labels property: ' + model);
487 }
488
489 if (convert[model].labels.length !== convert[model].channels) {
490 throw new Error('channel and label counts mismatch: ' + model);
491 }
492
493 var channels = convert[model].channels;
494 var labels = convert[model].labels;
495 delete convert[model].channels;
496 delete convert[model].labels;
497 Object.defineProperty(convert[model], 'channels', {value: channels});
498 Object.defineProperty(convert[model], 'labels', {value: labels});
499 }
500}
501
502convert.rgb.hsl = function (rgb) {
503 var r = rgb[0] / 255;
504 var g = rgb[1] / 255;
505 var b = rgb[2] / 255;
506 var min = Math.min(r, g, b);
507 var max = Math.max(r, g, b);
508 var delta = max - min;
509 var h;
510 var s;
511 var l;
512
513 if (max === min) {
514 h = 0;
515 } else if (r === max) {
516 h = (g - b) / delta;
517 } else if (g === max) {
518 h = 2 + (b - r) / delta;
519 } else if (b === max) {
520 h = 4 + (r - g) / delta;
521 }
522
523 h = Math.min(h * 60, 360);
524
525 if (h < 0) {
526 h += 360;
527 }
528
529 l = (min + max) / 2;
530
531 if (max === min) {
532 s = 0;
533 } else if (l <= 0.5) {
534 s = delta / (max + min);
535 } else {
536 s = delta / (2 - max - min);
537 }
538
539 return [h, s * 100, l * 100];
540};
541
542convert.rgb.hsv = function (rgb) {
543 var r = rgb[0];
544 var g = rgb[1];
545 var b = rgb[2];
546 var min = Math.min(r, g, b);
547 var max = Math.max(r, g, b);
548 var delta = max - min;
549 var h;
550 var s;
551 var v;
552
553 if (max === 0) {
554 s = 0;
555 } else {
556 s = (delta / max * 1000) / 10;
557 }
558
559 if (max === min) {
560 h = 0;
561 } else if (r === max) {
562 h = (g - b) / delta;
563 } else if (g === max) {
564 h = 2 + (b - r) / delta;
565 } else if (b === max) {
566 h = 4 + (r - g) / delta;
567 }
568
569 h = Math.min(h * 60, 360);
570
571 if (h < 0) {
572 h += 360;
573 }
574
575 v = ((max / 255) * 1000) / 10;
576
577 return [h, s, v];
578};
579
580convert.rgb.hwb = function (rgb) {
581 var r = rgb[0];
582 var g = rgb[1];
583 var b = rgb[2];
584 var h = convert.rgb.hsl(rgb)[0];
585 var w = 1 / 255 * Math.min(r, Math.min(g, b));
586
587 b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
588
589 return [h, w * 100, b * 100];
590};
591
592convert.rgb.cmyk = function (rgb) {
593 var r = rgb[0] / 255;
594 var g = rgb[1] / 255;
595 var b = rgb[2] / 255;
596 var c;
597 var m;
598 var y;
599 var k;
600
601 k = Math.min(1 - r, 1 - g, 1 - b);
602 c = (1 - r - k) / (1 - k) || 0;
603 m = (1 - g - k) / (1 - k) || 0;
604 y = (1 - b - k) / (1 - k) || 0;
605
606 return [c * 100, m * 100, y * 100, k * 100];
607};
608
609/**
610 * See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
611 * */
612function comparativeDistance(x, y) {
613 return (
614 Math.pow(x[0] - y[0], 2) +
615 Math.pow(x[1] - y[1], 2) +
616 Math.pow(x[2] - y[2], 2)
617 );
618}
619
620convert.rgb.keyword = function (rgb) {
621 var reversed = reverseKeywords[rgb];
622 if (reversed) {
623 return reversed;
624 }
625
626 var currentClosestDistance = Infinity;
627 var currentClosestKeyword;
628
629 for (var keyword in index$10) {
630 if (index$10.hasOwnProperty(keyword)) {
631 var value = index$10[keyword];
632
633 // Compute comparative distance
634 var distance = comparativeDistance(rgb, value);
635
636 // Check if its less, if so set as closest
637 if (distance < currentClosestDistance) {
638 currentClosestDistance = distance;
639 currentClosestKeyword = keyword;
640 }
641 }
642 }
643
644 return currentClosestKeyword;
645};
646
647convert.keyword.rgb = function (keyword) {
648 return index$10[keyword];
649};
650
651convert.rgb.xyz = function (rgb) {
652 var r = rgb[0] / 255;
653 var g = rgb[1] / 255;
654 var b = rgb[2] / 255;
655
656 // assume sRGB
657 r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);
658 g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);
659 b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);
660
661 var x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
662 var y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
663 var z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
664
665 return [x * 100, y * 100, z * 100];
666};
667
668convert.rgb.lab = function (rgb) {
669 var xyz = convert.rgb.xyz(rgb);
670 var x = xyz[0];
671 var y = xyz[1];
672 var z = xyz[2];
673 var l;
674 var a;
675 var b;
676
677 x /= 95.047;
678 y /= 100;
679 z /= 108.883;
680
681 x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116);
682 y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116);
683 z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116);
684
685 l = (116 * y) - 16;
686 a = 500 * (x - y);
687 b = 200 * (y - z);
688
689 return [l, a, b];
690};
691
692convert.hsl.rgb = function (hsl) {
693 var h = hsl[0] / 360;
694 var s = hsl[1] / 100;
695 var l = hsl[2] / 100;
696 var t1;
697 var t2;
698 var t3;
699 var rgb;
700 var val;
701
702 if (s === 0) {
703 val = l * 255;
704 return [val, val, val];
705 }
706
707 if (l < 0.5) {
708 t2 = l * (1 + s);
709 } else {
710 t2 = l + s - l * s;
711 }
712
713 t1 = 2 * l - t2;
714
715 rgb = [0, 0, 0];
716 for (var i = 0; i < 3; i++) {
717 t3 = h + 1 / 3 * -(i - 1);
718 if (t3 < 0) {
719 t3++;
720 }
721 if (t3 > 1) {
722 t3--;
723 }
724
725 if (6 * t3 < 1) {
726 val = t1 + (t2 - t1) * 6 * t3;
727 } else if (2 * t3 < 1) {
728 val = t2;
729 } else if (3 * t3 < 2) {
730 val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
731 } else {
732 val = t1;
733 }
734
735 rgb[i] = val * 255;
736 }
737
738 return rgb;
739};
740
741convert.hsl.hsv = function (hsl) {
742 var h = hsl[0];
743 var s = hsl[1] / 100;
744 var l = hsl[2] / 100;
745 var smin = s;
746 var lmin = Math.max(l, 0.01);
747 var sv;
748 var v;
749
750 l *= 2;
751 s *= (l <= 1) ? l : 2 - l;
752 smin *= lmin <= 1 ? lmin : 2 - lmin;
753 v = (l + s) / 2;
754 sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
755
756 return [h, sv * 100, v * 100];
757};
758
759convert.hsv.rgb = function (hsv) {
760 var h = hsv[0] / 60;
761 var s = hsv[1] / 100;
762 var v = hsv[2] / 100;
763 var hi = Math.floor(h) % 6;
764
765 var f = h - Math.floor(h);
766 var p = 255 * v * (1 - s);
767 var q = 255 * v * (1 - (s * f));
768 var t = 255 * v * (1 - (s * (1 - f)));
769 v *= 255;
770
771 switch (hi) {
772 case 0:
773 return [v, t, p];
774 case 1:
775 return [q, v, p];
776 case 2:
777 return [p, v, t];
778 case 3:
779 return [p, q, v];
780 case 4:
781 return [t, p, v];
782 case 5:
783 return [v, p, q];
784 }
785};
786
787convert.hsv.hsl = function (hsv) {
788 var h = hsv[0];
789 var s = hsv[1] / 100;
790 var v = hsv[2] / 100;
791 var vmin = Math.max(v, 0.01);
792 var lmin;
793 var sl;
794 var l;
795
796 l = (2 - s) * v;
797 lmin = (2 - s) * vmin;
798 sl = s * vmin;
799 sl /= (lmin <= 1) ? lmin : 2 - lmin;
800 sl = sl || 0;
801 l /= 2;
802
803 return [h, sl * 100, l * 100];
804};
805
806// http://dev.w3.org/csswg/css-color/#hwb-to-rgb
807convert.hwb.rgb = function (hwb) {
808 var h = hwb[0] / 360;
809 var wh = hwb[1] / 100;
810 var bl = hwb[2] / 100;
811 var ratio = wh + bl;
812 var i;
813 var v;
814 var f;
815 var n;
816
817 // wh + bl cant be > 1
818 if (ratio > 1) {
819 wh /= ratio;
820 bl /= ratio;
821 }
822
823 i = Math.floor(6 * h);
824 v = 1 - bl;
825 f = 6 * h - i;
826
827 if ((i & 0x01) !== 0) {
828 f = 1 - f;
829 }
830
831 n = wh + f * (v - wh); // linear interpolation
832
833 var r;
834 var g;
835 var b;
836 switch (i) {
837 default:
838 case 6:
839 case 0: r = v; g = n; b = wh; break;
840 case 1: r = n; g = v; b = wh; break;
841 case 2: r = wh; g = v; b = n; break;
842 case 3: r = wh; g = n; b = v; break;
843 case 4: r = n; g = wh; b = v; break;
844 case 5: r = v; g = wh; b = n; break;
845 }
846
847 return [r * 255, g * 255, b * 255];
848};
849
850convert.cmyk.rgb = function (cmyk) {
851 var c = cmyk[0] / 100;
852 var m = cmyk[1] / 100;
853 var y = cmyk[2] / 100;
854 var k = cmyk[3] / 100;
855 var r;
856 var g;
857 var b;
858
859 r = 1 - Math.min(1, c * (1 - k) + k);
860 g = 1 - Math.min(1, m * (1 - k) + k);
861 b = 1 - Math.min(1, y * (1 - k) + k);
862
863 return [r * 255, g * 255, b * 255];
864};
865
866convert.xyz.rgb = function (xyz) {
867 var x = xyz[0] / 100;
868 var y = xyz[1] / 100;
869 var z = xyz[2] / 100;
870 var r;
871 var g;
872 var b;
873
874 r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
875 g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
876 b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
877
878 // assume sRGB
879 r = r > 0.0031308
880 ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)
881 : r * 12.92;
882
883 g = g > 0.0031308
884 ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)
885 : g * 12.92;
886
887 b = b > 0.0031308
888 ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)
889 : b * 12.92;
890
891 r = Math.min(Math.max(0, r), 1);
892 g = Math.min(Math.max(0, g), 1);
893 b = Math.min(Math.max(0, b), 1);
894
895 return [r * 255, g * 255, b * 255];
896};
897
898convert.xyz.lab = function (xyz) {
899 var x = xyz[0];
900 var y = xyz[1];
901 var z = xyz[2];
902 var l;
903 var a;
904 var b;
905
906 x /= 95.047;
907 y /= 100;
908 z /= 108.883;
909
910 x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116);
911 y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116);
912 z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116);
913
914 l = (116 * y) - 16;
915 a = 500 * (x - y);
916 b = 200 * (y - z);
917
918 return [l, a, b];
919};
920
921convert.lab.xyz = function (lab) {
922 var l = lab[0];
923 var a = lab[1];
924 var b = lab[2];
925 var x;
926 var y;
927 var z;
928
929 y = (l + 16) / 116;
930 x = a / 500 + y;
931 z = y - b / 200;
932
933 var y2 = Math.pow(y, 3);
934 var x2 = Math.pow(x, 3);
935 var z2 = Math.pow(z, 3);
936 y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
937 x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
938 z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
939
940 x *= 95.047;
941 y *= 100;
942 z *= 108.883;
943
944 return [x, y, z];
945};
946
947convert.lab.lch = function (lab) {
948 var l = lab[0];
949 var a = lab[1];
950 var b = lab[2];
951 var hr;
952 var h;
953 var c;
954
955 hr = Math.atan2(b, a);
956 h = hr * 360 / 2 / Math.PI;
957
958 if (h < 0) {
959 h += 360;
960 }
961
962 c = Math.sqrt(a * a + b * b);
963
964 return [l, c, h];
965};
966
967convert.lch.lab = function (lch) {
968 var l = lch[0];
969 var c = lch[1];
970 var h = lch[2];
971 var a;
972 var b;
973 var hr;
974
975 hr = h / 360 * 2 * Math.PI;
976 a = c * Math.cos(hr);
977 b = c * Math.sin(hr);
978
979 return [l, a, b];
980};
981
982convert.rgb.ansi16 = function (args) {
983 var r = args[0];
984 var g = args[1];
985 var b = args[2];
986 var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2]; // hsv -> ansi16 optimization
987
988 value = Math.round(value / 50);
989
990 if (value === 0) {
991 return 30;
992 }
993
994 var ansi = 30
995 + ((Math.round(b / 255) << 2)
996 | (Math.round(g / 255) << 1)
997 | Math.round(r / 255));
998
999 if (value === 2) {
1000 ansi += 60;
1001 }
1002
1003 return ansi;
1004};
1005
1006convert.hsv.ansi16 = function (args) {
1007 // optimization here; we already know the value and don't need to get
1008 // it converted for us.
1009 return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
1010};
1011
1012convert.rgb.ansi256 = function (args) {
1013 var r = args[0];
1014 var g = args[1];
1015 var b = args[2];
1016
1017 // we use the extended greyscale palette here, with the exception of
1018 // black and white. normal palette only has 4 greyscale shades.
1019 if (r === g && g === b) {
1020 if (r < 8) {
1021 return 16;
1022 }
1023
1024 if (r > 248) {
1025 return 231;
1026 }
1027
1028 return Math.round(((r - 8) / 247) * 24) + 232;
1029 }
1030
1031 var ansi = 16
1032 + (36 * Math.round(r / 255 * 5))
1033 + (6 * Math.round(g / 255 * 5))
1034 + Math.round(b / 255 * 5);
1035
1036 return ansi;
1037};
1038
1039convert.ansi16.rgb = function (args) {
1040 var color = args % 10;
1041
1042 // handle greyscale
1043 if (color === 0 || color === 7) {
1044 if (args > 50) {
1045 color += 3.5;
1046 }
1047
1048 color = color / 10.5 * 255;
1049
1050 return [color, color, color];
1051 }
1052
1053 var mult = (~~(args > 50) + 1) * 0.5;
1054 var r = ((color & 1) * mult) * 255;
1055 var g = (((color >> 1) & 1) * mult) * 255;
1056 var b = (((color >> 2) & 1) * mult) * 255;
1057
1058 return [r, g, b];
1059};
1060
1061convert.ansi256.rgb = function (args) {
1062 // handle greyscale
1063 if (args >= 232) {
1064 var c = (args - 232) * 10 + 8;
1065 return [c, c, c];
1066 }
1067
1068 args -= 16;
1069
1070 var rem;
1071 var r = Math.floor(args / 36) / 5 * 255;
1072 var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
1073 var b = (rem % 6) / 5 * 255;
1074
1075 return [r, g, b];
1076};
1077
1078convert.rgb.hex = function (args) {
1079 var integer = ((Math.round(args[0]) & 0xFF) << 16)
1080 + ((Math.round(args[1]) & 0xFF) << 8)
1081 + (Math.round(args[2]) & 0xFF);
1082
1083 var string = integer.toString(16).toUpperCase();
1084 return '000000'.substring(string.length) + string;
1085};
1086
1087convert.hex.rgb = function (args) {
1088 var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
1089 if (!match) {
1090 return [0, 0, 0];
1091 }
1092
1093 var colorString = match[0];
1094
1095 if (match[0].length === 3) {
1096 colorString = colorString.split('').map(function (char) {
1097 return char + char;
1098 }).join('');
1099 }
1100
1101 var integer = parseInt(colorString, 16);
1102 var r = (integer >> 16) & 0xFF;
1103 var g = (integer >> 8) & 0xFF;
1104 var b = integer & 0xFF;
1105
1106 return [r, g, b];
1107};
1108
1109convert.rgb.hcg = function (rgb) {
1110 var r = rgb[0] / 255;
1111 var g = rgb[1] / 255;
1112 var b = rgb[2] / 255;
1113 var max = Math.max(Math.max(r, g), b);
1114 var min = Math.min(Math.min(r, g), b);
1115 var chroma = (max - min);
1116 var grayscale;
1117 var hue;
1118
1119 if (chroma < 1) {
1120 grayscale = min / (1 - chroma);
1121 } else {
1122 grayscale = 0;
1123 }
1124
1125 if (chroma <= 0) {
1126 hue = 0;
1127 } else
1128 if (max === r) {
1129 hue = ((g - b) / chroma) % 6;
1130 } else
1131 if (max === g) {
1132 hue = 2 + (b - r) / chroma;
1133 } else {
1134 hue = 4 + (r - g) / chroma + 4;
1135 }
1136
1137 hue /= 6;
1138 hue %= 1;
1139
1140 return [hue * 360, chroma * 100, grayscale * 100];
1141};
1142
1143convert.hsl.hcg = function (hsl) {
1144 var s = hsl[1] / 100;
1145 var l = hsl[2] / 100;
1146 var c = 1;
1147 var f = 0;
1148
1149 if (l < 0.5) {
1150 c = 2.0 * s * l;
1151 } else {
1152 c = 2.0 * s * (1.0 - l);
1153 }
1154
1155 if (c < 1.0) {
1156 f = (l - 0.5 * c) / (1.0 - c);
1157 }
1158
1159 return [hsl[0], c * 100, f * 100];
1160};
1161
1162convert.hsv.hcg = function (hsv) {
1163 var s = hsv[1] / 100;
1164 var v = hsv[2] / 100;
1165
1166 var c = s * v;
1167 var f = 0;
1168
1169 if (c < 1.0) {
1170 f = (v - c) / (1 - c);
1171 }
1172
1173 return [hsv[0], c * 100, f * 100];
1174};
1175
1176convert.hcg.rgb = function (hcg) {
1177 var h = hcg[0] / 360;
1178 var c = hcg[1] / 100;
1179 var g = hcg[2] / 100;
1180
1181 if (c === 0.0) {
1182 return [g * 255, g * 255, g * 255];
1183 }
1184
1185 var pure = [0, 0, 0];
1186 var hi = (h % 1) * 6;
1187 var v = hi % 1;
1188 var w = 1 - v;
1189 var mg = 0;
1190
1191 switch (Math.floor(hi)) {
1192 case 0:
1193 pure[0] = 1; pure[1] = v; pure[2] = 0; break;
1194 case 1:
1195 pure[0] = w; pure[1] = 1; pure[2] = 0; break;
1196 case 2:
1197 pure[0] = 0; pure[1] = 1; pure[2] = v; break;
1198 case 3:
1199 pure[0] = 0; pure[1] = w; pure[2] = 1; break;
1200 case 4:
1201 pure[0] = v; pure[1] = 0; pure[2] = 1; break;
1202 default:
1203 pure[0] = 1; pure[1] = 0; pure[2] = w;
1204 }
1205
1206 mg = (1.0 - c) * g;
1207
1208 return [
1209 (c * pure[0] + mg) * 255,
1210 (c * pure[1] + mg) * 255,
1211 (c * pure[2] + mg) * 255
1212 ];
1213};
1214
1215convert.hcg.hsv = function (hcg) {
1216 var c = hcg[1] / 100;
1217 var g = hcg[2] / 100;
1218
1219 var v = c + g * (1.0 - c);
1220 var f = 0;
1221
1222 if (v > 0.0) {
1223 f = c / v;
1224 }
1225
1226 return [hcg[0], f * 100, v * 100];
1227};
1228
1229convert.hcg.hsl = function (hcg) {
1230 var c = hcg[1] / 100;
1231 var g = hcg[2] / 100;
1232
1233 var l = g * (1.0 - c) + 0.5 * c;
1234 var s = 0;
1235
1236 if (l > 0.0 && l < 0.5) {
1237 s = c / (2 * l);
1238 } else
1239 if (l >= 0.5 && l < 1.0) {
1240 s = c / (2 * (1 - l));
1241 }
1242
1243 return [hcg[0], s * 100, l * 100];
1244};
1245
1246convert.hcg.hwb = function (hcg) {
1247 var c = hcg[1] / 100;
1248 var g = hcg[2] / 100;
1249 var v = c + g * (1.0 - c);
1250 return [hcg[0], (v - c) * 100, (1 - v) * 100];
1251};
1252
1253convert.hwb.hcg = function (hwb) {
1254 var w = hwb[1] / 100;
1255 var b = hwb[2] / 100;
1256 var v = 1 - b;
1257 var c = v - w;
1258 var g = 0;
1259
1260 if (c < 1) {
1261 g = (v - c) / (1 - c);
1262 }
1263
1264 return [hwb[0], c * 100, g * 100];
1265};
1266
1267convert.apple.rgb = function (apple) {
1268 return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
1269};
1270
1271convert.rgb.apple = function (rgb) {
1272 return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
1273};
1274
1275convert.gray.rgb = function (args) {
1276 return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
1277};
1278
1279convert.gray.hsl = convert.gray.hsv = function (args) {
1280 return [0, 0, args[0]];
1281};
1282
1283convert.gray.hwb = function (gray) {
1284 return [0, 100, gray[0]];
1285};
1286
1287convert.gray.cmyk = function (gray) {
1288 return [0, 0, 0, gray[0]];
1289};
1290
1291convert.gray.lab = function (gray) {
1292 return [gray[0], 0, 0];
1293};
1294
1295convert.gray.hex = function (gray) {
1296 var val = Math.round(gray[0] / 100 * 255) & 0xFF;
1297 var integer = (val << 16) + (val << 8) + val;
1298
1299 var string = integer.toString(16).toUpperCase();
1300 return '000000'.substring(string.length) + string;
1301};
1302
1303convert.rgb.gray = function (rgb) {
1304 var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
1305 return [val / 255 * 100];
1306};
1307});
1308
1309/*
1310 this function routes a model to all other models.
1311
1312 all functions that are routed have a property `.conversion` attached
1313 to the returned synthetic function. This property is an array
1314 of strings, each with the steps in between the 'from' and 'to'
1315 color models (inclusive).
1316
1317 conversions that are not possible simply are not included.
1318*/
1319
1320// https://jsperf.com/object-keys-vs-for-in-with-closure/3
1321var models$1 = Object.keys(conversions);
1322
1323function buildGraph() {
1324 var graph = {};
1325
1326 for (var len = models$1.length, i = 0; i < len; i++) {
1327 graph[models$1[i]] = {
1328 // http://jsperf.com/1-vs-infinity
1329 // micro-opt, but this is simple.
1330 distance: -1,
1331 parent: null
1332 };
1333 }
1334
1335 return graph;
1336}
1337
1338// https://en.wikipedia.org/wiki/Breadth-first_search
1339function deriveBFS(fromModel) {
1340 var graph = buildGraph();
1341 var queue = [fromModel]; // unshift -> queue -> pop
1342
1343 graph[fromModel].distance = 0;
1344
1345 while (queue.length) {
1346 var current = queue.pop();
1347 var adjacents = Object.keys(conversions[current]);
1348
1349 for (var len = adjacents.length, i = 0; i < len; i++) {
1350 var adjacent = adjacents[i];
1351 var node = graph[adjacent];
1352
1353 if (node.distance === -1) {
1354 node.distance = graph[current].distance + 1;
1355 node.parent = current;
1356 queue.unshift(adjacent);
1357 }
1358 }
1359 }
1360
1361 return graph;
1362}
1363
1364function link(from, to) {
1365 return function (args) {
1366 return to(from(args));
1367 };
1368}
1369
1370function wrapConversion(toModel, graph) {
1371 var path$$1 = [graph[toModel].parent, toModel];
1372 var fn = conversions[graph[toModel].parent][toModel];
1373
1374 var cur = graph[toModel].parent;
1375 while (graph[cur].parent) {
1376 path$$1.unshift(graph[cur].parent);
1377 fn = link(conversions[graph[cur].parent][cur], fn);
1378 cur = graph[cur].parent;
1379 }
1380
1381 fn.conversion = path$$1;
1382 return fn;
1383}
1384
1385var route = function (fromModel) {
1386 var graph = deriveBFS(fromModel);
1387 var conversion = {};
1388
1389 var models = Object.keys(graph);
1390 for (var len = models.length, i = 0; i < len; i++) {
1391 var toModel = models[i];
1392 var node = graph[toModel];
1393
1394 if (node.parent === null) {
1395 // no possible conversion, or this node is the source model.
1396 continue;
1397 }
1398
1399 conversion[toModel] = wrapConversion(toModel, graph);
1400 }
1401
1402 return conversion;
1403};
1404
1405var convert = {};
1406
1407var models = Object.keys(conversions);
1408
1409function wrapRaw(fn) {
1410 var wrappedFn = function (args) {
1411 if (args === undefined || args === null) {
1412 return args;
1413 }
1414
1415 if (arguments.length > 1) {
1416 args = Array.prototype.slice.call(arguments);
1417 }
1418
1419 return fn(args);
1420 };
1421
1422 // preserve .conversion property if there is one
1423 if ('conversion' in fn) {
1424 wrappedFn.conversion = fn.conversion;
1425 }
1426
1427 return wrappedFn;
1428}
1429
1430function wrapRounded(fn) {
1431 var wrappedFn = function (args) {
1432 if (args === undefined || args === null) {
1433 return args;
1434 }
1435
1436 if (arguments.length > 1) {
1437 args = Array.prototype.slice.call(arguments);
1438 }
1439
1440 var result = fn(args);
1441
1442 // we're assuming the result is an array here.
1443 // see notice in conversions.js; don't use box types
1444 // in conversion functions.
1445 if (typeof result === 'object') {
1446 for (var len = result.length, i = 0; i < len; i++) {
1447 result[i] = Math.round(result[i]);
1448 }
1449 }
1450
1451 return result;
1452 };
1453
1454 // preserve .conversion property if there is one
1455 if ('conversion' in fn) {
1456 wrappedFn.conversion = fn.conversion;
1457 }
1458
1459 return wrappedFn;
1460}
1461
1462models.forEach(function (fromModel) {
1463 convert[fromModel] = {};
1464
1465 Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
1466 Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
1467
1468 var routes = route(fromModel);
1469 var routeModels = Object.keys(routes);
1470
1471 routeModels.forEach(function (toModel) {
1472 var fn = routes[toModel];
1473
1474 convert[fromModel][toModel] = wrapRounded(fn);
1475 convert[fromModel][toModel].raw = wrapRaw(fn);
1476 });
1477});
1478
1479var index$8 = convert;
1480
1481var index$6 = createCommonjsModule(function (module) {
1482'use strict';
1483
1484
1485const wrapAnsi16 = (fn, offset) => function () {
1486 const code = fn.apply(index$8, arguments);
1487 return `\u001B[${code + offset}m`;
1488};
1489
1490const wrapAnsi256 = (fn, offset) => function () {
1491 const code = fn.apply(index$8, arguments);
1492 return `\u001B[${38 + offset};5;${code}m`;
1493};
1494
1495const wrapAnsi16m = (fn, offset) => function () {
1496 const rgb = fn.apply(index$8, arguments);
1497 return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
1498};
1499
1500function assembleStyles() {
1501 const codes = new Map();
1502 const styles = {
1503 modifier: {
1504 reset: [0, 0],
1505 // 21 isn't widely supported and 22 does the same thing
1506 bold: [1, 22],
1507 dim: [2, 22],
1508 italic: [3, 23],
1509 underline: [4, 24],
1510 inverse: [7, 27],
1511 hidden: [8, 28],
1512 strikethrough: [9, 29]
1513 },
1514 color: {
1515 black: [30, 39],
1516 red: [31, 39],
1517 green: [32, 39],
1518 yellow: [33, 39],
1519 blue: [34, 39],
1520 magenta: [35, 39],
1521 cyan: [36, 39],
1522 white: [37, 39],
1523 gray: [90, 39],
1524
1525 // Bright color
1526 redBright: [91, 39],
1527 greenBright: [92, 39],
1528 yellowBright: [93, 39],
1529 blueBright: [94, 39],
1530 magentaBright: [95, 39],
1531 cyanBright: [96, 39],
1532 whiteBright: [97, 39]
1533 },
1534 bgColor: {
1535 bgBlack: [40, 49],
1536 bgRed: [41, 49],
1537 bgGreen: [42, 49],
1538 bgYellow: [43, 49],
1539 bgBlue: [44, 49],
1540 bgMagenta: [45, 49],
1541 bgCyan: [46, 49],
1542 bgWhite: [47, 49],
1543
1544 // Bright color
1545 bgBlackBright: [100, 49],
1546 bgRedBright: [101, 49],
1547 bgGreenBright: [102, 49],
1548 bgYellowBright: [103, 49],
1549 bgBlueBright: [104, 49],
1550 bgMagentaBright: [105, 49],
1551 bgCyanBright: [106, 49],
1552 bgWhiteBright: [107, 49]
1553 }
1554 };
1555
1556 // Fix humans
1557 styles.color.grey = styles.color.gray;
1558
1559 for (const groupName of Object.keys(styles)) {
1560 const group = styles[groupName];
1561
1562 for (const styleName of Object.keys(group)) {
1563 const style = group[styleName];
1564
1565 styles[styleName] = {
1566 open: `\u001B[${style[0]}m`,
1567 close: `\u001B[${style[1]}m`
1568 };
1569
1570 group[styleName] = styles[styleName];
1571
1572 codes.set(style[0], style[1]);
1573 }
1574
1575 Object.defineProperty(styles, groupName, {
1576 value: group,
1577 enumerable: false
1578 });
1579
1580 Object.defineProperty(styles, 'codes', {
1581 value: codes,
1582 enumerable: false
1583 });
1584 }
1585
1586 const rgb2rgb = (r, g, b) => [r, g, b];
1587
1588 styles.color.close = '\u001B[39m';
1589 styles.bgColor.close = '\u001B[49m';
1590
1591 styles.color.ansi = {};
1592 styles.color.ansi256 = {};
1593 styles.color.ansi16m = {
1594 rgb: wrapAnsi16m(rgb2rgb, 0)
1595 };
1596
1597 styles.bgColor.ansi = {};
1598 styles.bgColor.ansi256 = {};
1599 styles.bgColor.ansi16m = {
1600 rgb: wrapAnsi16m(rgb2rgb, 10)
1601 };
1602
1603 for (const key of Object.keys(index$8)) {
1604 if (typeof index$8[key] !== 'object') {
1605 continue;
1606 }
1607
1608 const suite = index$8[key];
1609
1610 if ('ansi16' in suite) {
1611 styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
1612 styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
1613 }
1614
1615 if ('ansi256' in suite) {
1616 styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
1617 styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
1618 }
1619
1620 if ('rgb' in suite) {
1621 styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
1622 styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
1623 }
1624 }
1625
1626 return styles;
1627}
1628
1629// Make the export immutable
1630Object.defineProperty(module, 'exports', {
1631 enumerable: true,
1632 get: assembleStyles
1633});
1634});
1635
1636var index$14 = function (flag, argv) {
1637 argv = argv || process.argv;
1638
1639 var terminatorPos = argv.indexOf('--');
1640 var prefix = /^-{1,2}/.test(flag) ? '' : '--';
1641 var pos = argv.indexOf(prefix + flag);
1642
1643 return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
1644};
1645
1646var index$12 = createCommonjsModule(function (module) {
1647'use strict';
1648
1649
1650
1651const env = process.env;
1652
1653const support = level => {
1654 if (level === 0) {
1655 return false;
1656 }
1657
1658 return {
1659 level,
1660 hasBasic: true,
1661 has256: level >= 2,
1662 has16m: level >= 3
1663 };
1664};
1665
1666let supportLevel = (() => {
1667 if (index$14('no-color') ||
1668 index$14('no-colors') ||
1669 index$14('color=false')) {
1670 return 0;
1671 }
1672
1673 if (index$14('color=16m') ||
1674 index$14('color=full') ||
1675 index$14('color=truecolor')) {
1676 return 3;
1677 }
1678
1679 if (index$14('color=256')) {
1680 return 2;
1681 }
1682
1683 if (index$14('color') ||
1684 index$14('colors') ||
1685 index$14('color=true') ||
1686 index$14('color=always')) {
1687 return 1;
1688 }
1689
1690 if (process.stdout && !process.stdout.isTTY) {
1691 return 0;
1692 }
1693
1694 if (process.platform === 'win32') {
1695 // Node.js 7.5.0 is the first version of Node.js to include a patch to
1696 // libuv that enables 256 color output on Windows. Anything earlier and it
1697 // won't work. However, here we target Node.js 8 at minimum as it is an LTS
1698 // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
1699 // release that supports 256 colors.
1700 const osRelease = os.release().split('.');
1701 if (
1702 Number(process.versions.node.split('.')[0]) >= 8 &&
1703 Number(osRelease[0]) >= 10 &&
1704 Number(osRelease[2]) >= 10586
1705 ) {
1706 return 2;
1707 }
1708
1709 return 1;
1710 }
1711
1712 if ('CI' in env) {
1713 if ('TRAVIS' in env || env.CI === 'Travis' || 'CIRCLECI' in env) {
1714 return 1;
1715 }
1716
1717 return 0;
1718 }
1719
1720 if ('TEAMCITY_VERSION' in env) {
1721 return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
1722 }
1723
1724 if ('TERM_PROGRAM' in env) {
1725 const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
1726
1727 switch (env.TERM_PROGRAM) {
1728 case 'iTerm.app':
1729 return version >= 3 ? 3 : 2;
1730 case 'Hyper':
1731 return 3;
1732 case 'Apple_Terminal':
1733 return 2;
1734 // No default
1735 }
1736 }
1737
1738 if (/^(screen|xterm)-256(?:color)?/.test(env.TERM)) {
1739 return 2;
1740 }
1741
1742 if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(env.TERM)) {
1743 return 1;
1744 }
1745
1746 if ('COLORTERM' in env) {
1747 return 1;
1748 }
1749
1750 if (env.TERM === 'dumb') {
1751 return 0;
1752 }
1753
1754 return 0;
1755})();
1756
1757if ('FORCE_COLOR' in env) {
1758 supportLevel = parseInt(env.FORCE_COLOR, 10) === 0 ? 0 : (supportLevel || 1);
1759}
1760
1761module.exports = process && support(supportLevel);
1762});
1763
1764var templates = createCommonjsModule(function (module) {
1765'use strict';
1766const TEMPLATE_REGEX = /(?:\\(u[a-f0-9]{4}|x[a-f0-9]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
1767const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
1768const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
1769const ESCAPE_REGEX = /\\(u[0-9a-f]{4}|x[0-9a-f]{2}|.)|([^\\])/gi;
1770
1771const ESCAPES = {
1772 n: '\n',
1773 r: '\r',
1774 t: '\t',
1775 b: '\b',
1776 f: '\f',
1777 v: '\v',
1778 0: '\0',
1779 '\\': '\\',
1780 e: '\u001b',
1781 a: '\u0007'
1782};
1783
1784function unescape(c) {
1785 if ((c[0] === 'u' && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
1786 return String.fromCharCode(parseInt(c.slice(1), 16));
1787 }
1788
1789 return ESCAPES[c] || c;
1790}
1791
1792function parseArguments(name, args) {
1793 const results = [];
1794 const chunks = args.trim().split(/\s*,\s*/g);
1795 let matches;
1796
1797 for (const chunk of chunks) {
1798 if (!isNaN(chunk)) {
1799 results.push(Number(chunk));
1800 } else if ((matches = chunk.match(STRING_REGEX))) {
1801 results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr));
1802 } else {
1803 throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
1804 }
1805 }
1806
1807 return results;
1808}
1809
1810function parseStyle(style) {
1811 STYLE_REGEX.lastIndex = 0;
1812
1813 const results = [];
1814 let matches;
1815
1816 while ((matches = STYLE_REGEX.exec(style)) !== null) {
1817 const name = matches[1];
1818
1819 if (matches[2]) {
1820 const args = parseArguments(name, matches[2]);
1821 results.push([name].concat(args));
1822 } else {
1823 results.push([name]);
1824 }
1825 }
1826
1827 return results;
1828}
1829
1830function buildStyle(chalk, styles) {
1831 const enabled = {};
1832
1833 for (const layer of styles) {
1834 for (const style of layer.styles) {
1835 enabled[style[0]] = layer.inverse ? null : style.slice(1);
1836 }
1837 }
1838
1839 let current = chalk;
1840 for (const styleName of Object.keys(enabled)) {
1841 if (Array.isArray(enabled[styleName])) {
1842 if (!(styleName in current)) {
1843 throw new Error(`Unknown Chalk style: ${styleName}`);
1844 }
1845
1846 if (enabled[styleName].length > 0) {
1847 current = current[styleName].apply(current, enabled[styleName]);
1848 } else {
1849 current = current[styleName];
1850 }
1851 }
1852 }
1853
1854 return current;
1855}
1856
1857module.exports = (chalk, tmp) => {
1858 const styles = [];
1859 const chunks = [];
1860 let chunk = [];
1861
1862 // eslint-disable-next-line max-params
1863 tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => {
1864 if (escapeChar) {
1865 chunk.push(unescape(escapeChar));
1866 } else if (style) {
1867 const str = chunk.join('');
1868 chunk = [];
1869 chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
1870 styles.push({inverse, styles: parseStyle(style)});
1871 } else if (close) {
1872 if (styles.length === 0) {
1873 throw new Error('Found extraneous } in Chalk template literal');
1874 }
1875
1876 chunks.push(buildStyle(chalk, styles)(chunk.join('')));
1877 chunk = [];
1878 styles.pop();
1879 } else {
1880 chunk.push(chr);
1881 }
1882 });
1883
1884 chunks.push(chunk.join(''));
1885
1886 if (styles.length > 0) {
1887 const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
1888 throw new Error(errMsg);
1889 }
1890
1891 return chunks.join('');
1892};
1893});
1894
1895const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm');
1896
1897// `supportsColor.level` → `ansiStyles.color[name]` mapping
1898const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m'];
1899
1900// `color-convert` models to exclude from the Chalk API due to conflicts and such
1901const skipModels = new Set(['gray']);
1902
1903const styles = Object.create(null);
1904
1905function applyOptions(obj, options) {
1906 options = options || {};
1907
1908 // Detect level if not set manually
1909 const scLevel = index$12 ? index$12.level : 0;
1910 obj.level = options.level === undefined ? scLevel : options.level;
1911 obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
1912}
1913
1914function Chalk(options) {
1915 // We check for this.template here since calling `chalk.constructor()`
1916 // by itself will have a `this` of a previously constructed chalk object
1917 if (!this || !(this instanceof Chalk) || this.template) {
1918 const chalk = {};
1919 applyOptions(chalk, options);
1920
1921 chalk.template = function () {
1922 const args = [].slice.call(arguments);
1923 return chalkTag.apply(null, [chalk.template].concat(args));
1924 };
1925
1926 Object.setPrototypeOf(chalk, Chalk.prototype);
1927 Object.setPrototypeOf(chalk.template, chalk);
1928
1929 chalk.template.constructor = Chalk;
1930
1931 return chalk.template;
1932 }
1933
1934 applyOptions(this, options);
1935}
1936
1937// Use bright blue on Windows as the normal blue color is illegible
1938if (isSimpleWindowsTerm) {
1939 index$6.blue.open = '\u001B[94m';
1940}
1941
1942for (const key of Object.keys(index$6)) {
1943 index$6[key].closeRe = new RegExp(index$4(index$6[key].close), 'g');
1944
1945 styles[key] = {
1946 get() {
1947 const codes = index$6[key];
1948 return build.call(this, this._styles ? this._styles.concat(codes) : [codes], key);
1949 }
1950 };
1951}
1952
1953index$6.color.closeRe = new RegExp(index$4(index$6.color.close), 'g');
1954for (const model of Object.keys(index$6.color.ansi)) {
1955 if (skipModels.has(model)) {
1956 continue;
1957 }
1958
1959 styles[model] = {
1960 get() {
1961 const level = this.level;
1962 return function () {
1963 const open = index$6.color[levelMapping[level]][model].apply(null, arguments);
1964 const codes = {
1965 open,
1966 close: index$6.color.close,
1967 closeRe: index$6.color.closeRe
1968 };
1969 return build.call(this, this._styles ? this._styles.concat(codes) : [codes], model);
1970 };
1971 }
1972 };
1973}
1974
1975index$6.bgColor.closeRe = new RegExp(index$4(index$6.bgColor.close), 'g');
1976for (const model of Object.keys(index$6.bgColor.ansi)) {
1977 if (skipModels.has(model)) {
1978 continue;
1979 }
1980
1981 const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
1982 styles[bgModel] = {
1983 get() {
1984 const level = this.level;
1985 return function () {
1986 const open = index$6.bgColor[levelMapping[level]][model].apply(null, arguments);
1987 const codes = {
1988 open,
1989 close: index$6.bgColor.close,
1990 closeRe: index$6.bgColor.closeRe
1991 };
1992 return build.call(this, this._styles ? this._styles.concat(codes) : [codes], model);
1993 };
1994 }
1995 };
1996}
1997
1998const proto = Object.defineProperties(() => {}, styles);
1999
2000function build(_styles, key) {
2001 const builder = function () {
2002 return applyStyle.apply(builder, arguments);
2003 };
2004
2005 builder._styles = _styles;
2006
2007 const self = this;
2008
2009 Object.defineProperty(builder, 'level', {
2010 enumerable: true,
2011 get() {
2012 return self.level;
2013 },
2014 set(level) {
2015 self.level = level;
2016 }
2017 });
2018
2019 Object.defineProperty(builder, 'enabled', {
2020 enumerable: true,
2021 get() {
2022 return self.enabled;
2023 },
2024 set(enabled) {
2025 self.enabled = enabled;
2026 }
2027 });
2028
2029 // See below for fix regarding invisible grey/dim combination on Windows
2030 builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey';
2031
2032 // `__proto__` is used because we must return a function, but there is
2033 // no way to create a function with a different prototype
2034 builder.__proto__ = proto; // eslint-disable-line no-proto
2035
2036 return builder;
2037}
2038
2039function applyStyle() {
2040 // Support varags, but simply cast to string in case there's only one arg
2041 const args = arguments;
2042 const argsLen = args.length;
2043 let str = String(arguments[0]);
2044
2045 if (argsLen === 0) {
2046 return '';
2047 }
2048
2049 if (argsLen > 1) {
2050 // Don't slice `arguments`, it prevents V8 optimizations
2051 for (let a = 1; a < argsLen; a++) {
2052 str += ' ' + args[a];
2053 }
2054 }
2055
2056 if (!this.enabled || this.level <= 0 || !str) {
2057 return str;
2058 }
2059
2060 // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
2061 // see https://github.com/chalk/chalk/issues/58
2062 // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
2063 const originalDim = index$6.dim.open;
2064 if (isSimpleWindowsTerm && this.hasGrey) {
2065 index$6.dim.open = '';
2066 }
2067
2068 for (const code of this._styles.slice().reverse()) {
2069 // Replace any instances already present with a re-opening code
2070 // otherwise only the part of the string until said closing code
2071 // will be colored, and the rest will simply be 'plain'.
2072 str = code.open + str.replace(code.closeRe, code.open) + code.close;
2073
2074 // Close the styling before a linebreak and reopen
2075 // after next line to fix a bleed issue on macOS
2076 // https://github.com/chalk/chalk/pull/92
2077 str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
2078 }
2079
2080 // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
2081 index$6.dim.open = originalDim;
2082
2083 return str;
2084}
2085
2086function chalkTag(chalk, strings) {
2087 if (!Array.isArray(strings)) {
2088 // If chalk() was called by itself or with a string,
2089 // return the string itself as a string.
2090 return [].slice.call(arguments, 1).join(' ');
2091 }
2092
2093 const args = [].slice.call(arguments, 2);
2094 const parts = [strings.raw[0]];
2095
2096 for (let i = 1; i < strings.length; i++) {
2097 parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
2098 parts.push(String(strings.raw[i]));
2099 }
2100
2101 return templates(chalk, parts.join(''));
2102}
2103
2104Object.defineProperties(Chalk.prototype, styles);
2105
2106var index$3 = Chalk(); // eslint-disable-line new-cap
2107var supportsColor_1 = index$12;
2108
2109index$3.supportsColor = supportsColor_1;
2110
2111const absolutePath = /^(?:\/|(?:[A-Za-z]:)?[\\|/])/;
2112
2113
2114function isAbsolute ( path$$1 ) {
2115 return absolutePath.test( path$$1 );
2116}
2117
2118function relativeId ( id ) {
2119 if ( typeof process === 'undefined' || !isAbsolute( id ) ) { return id; }
2120 return path.relative( process.cwd(), id );
2121}
2122
2123if ( !process.stderr.isTTY ) { index$3.enabled = false; }
2124
2125// log to stderr to keep `rollup main.js > bundle.js` from breaking
2126const stderr = console.error.bind( console ); // eslint-disable-line no-console
2127
2128function handleError ( err, recover ) {
2129 let description = err.message || err;
2130 if (err.name) { description = `${err.name}: ${description}`; }
2131 const message = (err.plugin ? `(${err.plugin} plugin) ${description}` : description) || err;
2132
2133 stderr( index$3.bold.red( `[!] ${index$3.bold( message )}` ) );
2134
2135 // TODO should this be "err.url || (err.file && err.loc.file) || err.id"?
2136 if ( err.url ) {
2137 stderr( index$3.cyan( err.url ) );
2138 }
2139
2140 if ( err.loc ) {
2141 stderr( `${relativeId( err.loc.file || err.id )} (${err.loc.line}:${err.loc.column})` );
2142 } else if ( err.id ) {
2143 stderr( relativeId( err.id ) );
2144 }
2145
2146 if ( err.frame ) {
2147 stderr( index$3.dim( err.frame ) );
2148 } else if ( err.stack ) {
2149 stderr( index$3.dim( err.stack ) );
2150 }
2151
2152 stderr( '' );
2153
2154 if ( !recover ) { process.exit( 1 ); }
2155}
2156
2157function batchWarnings () {
2158 let allWarnings = new Map();
2159 let count = 0;
2160
2161 return {
2162 get count() {
2163 return count;
2164 },
2165
2166 add: warning => {
2167 if ( typeof warning === 'string' ) {
2168 warning = { code: 'UNKNOWN', message: warning };
2169 }
2170
2171 if ( warning.code in immediateHandlers ) {
2172 immediateHandlers[ warning.code ]( warning );
2173 return;
2174 }
2175
2176 if ( !allWarnings.has( warning.code ) ) { allWarnings.set( warning.code, [] ); }
2177 allWarnings.get( warning.code ).push( warning );
2178
2179 count += 1;
2180 },
2181
2182 flush: () => {
2183 if ( count === 0 ) { return; }
2184
2185 const codes = Array.from( allWarnings.keys() )
2186 .sort( ( a, b ) => {
2187 if ( deferredHandlers[a] && deferredHandlers[b] ) {
2188 return deferredHandlers[a].priority - deferredHandlers[b].priority;
2189 }
2190
2191 if ( deferredHandlers[a] ) { return -1; }
2192 if ( deferredHandlers[b] ) { return 1; }
2193 return allWarnings.get( b ).length - allWarnings.get( a ).length;
2194 });
2195
2196 codes.forEach( code => {
2197 const handler = deferredHandlers[ code ];
2198 const warnings = allWarnings.get( code );
2199
2200 if ( handler ) {
2201 handler.fn( warnings );
2202 } else {
2203 warnings.forEach( warning => {
2204 stderr( `${index$3.bold.yellow('(!)')} ${index$3.bold.yellow( warning.message )}` );
2205
2206 if ( warning.url ) { info( warning.url ); }
2207
2208 const id = warning.loc && warning.loc.file || warning.id;
2209 if ( id ) {
2210 const loc = warning.loc ?
2211 `${relativeId( id )}: (${warning.loc.line}:${warning.loc.column})` :
2212 relativeId( id );
2213
2214 stderr( index$3.bold( relativeId( loc ) ) );
2215 }
2216
2217 if ( warning.frame ) { info( warning.frame ); }
2218 });
2219 }
2220 });
2221
2222 allWarnings = new Map();
2223 count = 0;
2224 }
2225 };
2226}
2227
2228const immediateHandlers = {
2229 MISSING_NODE_BUILTINS: warning => {
2230 title( `Missing shims for Node.js built-ins` );
2231
2232 const detail = warning.modules.length === 1 ?
2233 `'${warning.modules[0]}'` :
2234 `${warning.modules.slice( 0, -1 ).map( name => `'${name}'` ).join( ', ' )} and '${warning.modules.slice( -1 )}'`;
2235 stderr( `Creating a browser bundle that depends on ${detail}. You might need to include https://www.npmjs.com/package/rollup-plugin-node-builtins` );
2236 },
2237
2238 MIXED_EXPORTS: () => {
2239 title( 'Mixing named and default exports' );
2240 stderr( `Consumers of your bundle will have to use bundle['default'] to access the default export, which may not be what you want. Use \`exports: 'named'\` to disable this warning` );
2241 },
2242
2243 EMPTY_BUNDLE: () => {
2244 title( `Generated an empty bundle` );
2245 }
2246};
2247
2248// TODO select sensible priorities
2249const deferredHandlers = {
2250 UNUSED_EXTERNAL_IMPORT: {
2251 priority: 1,
2252 fn: warnings => {
2253 title( 'Unused external imports' );
2254 warnings.forEach( warning => {
2255 stderr( `${warning.names} imported from external module '${warning.source}' but never used` );
2256 });
2257 }
2258 },
2259
2260 UNRESOLVED_IMPORT: {
2261 priority: 1,
2262 fn: warnings => {
2263 title( 'Unresolved dependencies' );
2264 info( 'https://github.com/rollup/rollup/wiki/Troubleshooting#treating-module-as-external-dependency' );
2265
2266 const dependencies = new Map();
2267 warnings.forEach( warning => {
2268 if ( !dependencies.has( warning.source ) ) { dependencies.set( warning.source, [] ); }
2269 dependencies.get( warning.source ).push( warning.importer );
2270 });
2271
2272 Array.from( dependencies.keys() ).forEach( dependency => {
2273 const importers = dependencies.get( dependency );
2274 stderr( `${index$3.bold( dependency )} (imported by ${importers.join( ', ' )})` );
2275 });
2276 }
2277 },
2278
2279 MISSING_EXPORT: {
2280 priority: 1,
2281 fn: warnings => {
2282 title( 'Missing exports' );
2283 info( 'https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module' );
2284
2285 warnings.forEach( warning => {
2286 stderr( index$3.bold( warning.importer ) );
2287 stderr( `${warning.missing} is not exported by ${warning.exporter}` );
2288 stderr( index$3.grey( warning.frame ) );
2289 });
2290 }
2291 },
2292
2293 THIS_IS_UNDEFINED: {
2294 priority: 1,
2295 fn: warnings => {
2296 title( '`this` has been rewritten to `undefined`' );
2297 info( 'https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined' );
2298 showTruncatedWarnings(warnings);
2299 }
2300 },
2301
2302 EVAL: {
2303 priority: 1,
2304 fn: warnings => {
2305 title( 'Use of eval is strongly discouraged' );
2306 info( 'https://github.com/rollup/rollup/wiki/Troubleshooting#avoiding-eval' );
2307 showTruncatedWarnings(warnings);
2308 }
2309 },
2310
2311 NON_EXISTENT_EXPORT: {
2312 priority: 1,
2313 fn: warnings => {
2314 title( `Import of non-existent ${warnings.length > 1 ? 'exports' : 'export'}` );
2315 showTruncatedWarnings(warnings);
2316 }
2317 },
2318
2319 NAMESPACE_CONFLICT: {
2320 priority: 1,
2321 fn: warnings => {
2322 title( `Conflicting re-exports` );
2323 warnings.forEach(warning => {
2324 stderr( `${index$3.bold(relativeId(warning.reexporter))} re-exports '${warning.name}' from both ${relativeId(warning.sources[0])} and ${relativeId(warning.sources[1])} (will be ignored)` );
2325 });
2326 }
2327 },
2328
2329 MISSING_GLOBAL_NAME: {
2330 priority: 1,
2331 fn: warnings => {
2332 title( `Missing global variable ${warnings.length > 1 ? 'names' : 'name'}` );
2333 stderr( `Use options.globals to specify browser global variable names corresponding to external modules` );
2334 warnings.forEach(warning => {
2335 stderr(`${index$3.bold(warning.source)} (guessing '${warning.guess}')`);
2336 });
2337 }
2338 },
2339
2340 SOURCEMAP_BROKEN: {
2341 priority: 1,
2342 fn: warnings => {
2343 title( `Broken sourcemap` );
2344 info( 'https://github.com/rollup/rollup/wiki/Troubleshooting#sourcemap-is-likely-to-be-incorrect' );
2345
2346 const plugins = Array.from( new Set( warnings.map( w => w.plugin ).filter( Boolean ) ) );
2347 const detail = plugins.length === 0 ? '' : plugins.length > 1 ?
2348 ` (such as ${plugins.slice(0, -1).map(p => `'${p}'`).join(', ')} and '${plugins.slice(-1)}')` :
2349 ` (such as '${plugins[0]}')`;
2350
2351 stderr( `Plugins that transform code${detail} should generate accompanying sourcemaps` );
2352 }
2353 },
2354
2355 PLUGIN_WARNING: {
2356 priority: 1,
2357 fn: warnings => {
2358 const nestedByPlugin = nest(warnings, 'plugin');
2359
2360 nestedByPlugin.forEach((ref) => {
2361 var plugin = ref.key;
2362 var items = ref.items;
2363
2364 const nestedByMessage = nest(items, 'message');
2365
2366 let lastUrl;
2367
2368 nestedByMessage.forEach((ref) => {
2369 var message = ref.key;
2370 var items = ref.items;
2371
2372 title( `${plugin} plugin: ${message}` );
2373 items.forEach(warning => {
2374 if ( warning.url !== lastUrl ) { info( lastUrl = warning.url ); }
2375
2376 const loc = warning.loc ?
2377 `${relativeId( warning.id )}: (${warning.loc.line}:${warning.loc.column})` :
2378 relativeId( warning.id );
2379
2380 stderr( index$3.bold( relativeId( loc ) ) );
2381 if ( warning.frame ) { info( warning.frame ); }
2382 });
2383 });
2384 });
2385 }
2386 }
2387};
2388
2389function title ( str ) {
2390 stderr( `${index$3.bold.yellow('(!)')} ${index$3.bold.yellow( str )}` );
2391}
2392
2393function info ( url ) {
2394 stderr( index$3.grey( url ) );
2395}
2396
2397function nest(array, prop) {
2398 const nested = [];
2399 const lookup = new Map();
2400
2401 array.forEach(item => {
2402 const key = item[prop];
2403 if (!lookup.has(key)) {
2404 lookup.set(key, {
2405 key,
2406 items: []
2407 });
2408
2409 nested.push(lookup.get(key));
2410 }
2411
2412 lookup.get(key).items.push(item);
2413 });
2414
2415 return nested;
2416}
2417
2418function showTruncatedWarnings(warnings) {
2419 const nestedByModule = nest(warnings, 'id');
2420
2421 const sliced = nestedByModule.length > 5 ? nestedByModule.slice(0, 3) : nestedByModule;
2422 sliced.forEach((ref) => {
2423 var id = ref.key;
2424 var items = ref.items;
2425
2426 stderr( index$3.bold( relativeId( id ) ) );
2427 stderr( index$3.grey( items[0].frame ) );
2428
2429 if ( items.length > 1 ) {
2430 stderr( `...and ${items.length - 1} other ${items.length > 2 ? 'occurrences' : 'occurrence'}` );
2431 }
2432 });
2433
2434 if ( nestedByModule.length > sliced.length ) {
2435 stderr( `\n...and ${nestedByModule.length - sliced.length} other files` );
2436 }
2437}
2438
2439const equivalents = {
2440 useStrict: 'useStrict',
2441 banner: 'banner',
2442 footer: 'footer',
2443 format: 'format',
2444 globals: 'globals',
2445 id: 'moduleId',
2446 indent: 'indent',
2447 interop: 'interop',
2448 input: 'entry',
2449 intro: 'intro',
2450 legacy: 'legacy',
2451 name: 'moduleName',
2452 output: 'dest',
2453 outro: 'outro',
2454 sourcemap: 'sourceMap',
2455 treeshake: 'treeshake'
2456};
2457
2458function mergeOptions ( config, command ) {
2459 const options = Object.assign( {}, config );
2460
2461 let external;
2462
2463 const commandExternal = ( command.external || '' ).split( ',' );
2464 const optionsExternal = options.external;
2465
2466 if ( command.globals ) {
2467 const globals = Object.create( null );
2468
2469 command.globals.split( ',' ).forEach( str => {
2470 const names = str.split( ':' );
2471 globals[ names[0] ] = names[1];
2472
2473 // Add missing Module IDs to external.
2474 if ( commandExternal.indexOf( names[0] ) === -1 ) {
2475 commandExternal.push( names[0] );
2476 }
2477 });
2478
2479 command.globals = globals;
2480 }
2481
2482 if ( typeof optionsExternal === 'function' ) {
2483 external = id => {
2484 return optionsExternal( id ) || ~commandExternal.indexOf( id );
2485 };
2486 } else {
2487 external = ( optionsExternal || [] ).concat( commandExternal );
2488 }
2489
2490 if (typeof command.extend !== 'undefined') {
2491 options.extend = command.extend;
2492 }
2493
2494 if (command.silent) {
2495 options.onwarn = () => {};
2496 }
2497
2498 options.external = external;
2499
2500 // Use any options passed through the CLI as overrides.
2501 Object.keys( equivalents ).forEach( cliOption => {
2502 if ( command.hasOwnProperty( cliOption ) ) {
2503 options[ equivalents[ cliOption ] ] = command[ cliOption ];
2504 }
2505 });
2506
2507 const targets = options.dest ? [{ dest: options.dest, format: options.format }] : options.targets;
2508 options.targets = targets;
2509 delete options.dest;
2510
2511 return options;
2512}
2513
2514function loadConfigFile (configFile, silent) {
2515 const warnings = batchWarnings();
2516
2517 return rollup.rollup({
2518 entry: configFile,
2519 external: id => {
2520 return (id[0] !== '.' && !path__default.isAbsolute(id)) || id.slice(-5,id.length) === '.json';
2521 },
2522 onwarn: warnings.add
2523 })
2524 .then( bundle => {
2525 if ( !silent && warnings.count > 0 ) {
2526 stderr( index$3.bold( `loaded ${relativeId( configFile )} with warnings` ) );
2527 warnings.flush();
2528 }
2529
2530 return bundle.generate({
2531 format: 'cjs'
2532 });
2533 })
2534 .then( (ref) => {
2535 var code = ref.code;
2536
2537 // temporarily override require
2538 const defaultLoader = require.extensions[ '.js' ];
2539 require.extensions[ '.js' ] = ( m, filename ) => {
2540 if ( filename === configFile ) {
2541 m._compile( code, filename );
2542 } else {
2543 defaultLoader( m, filename );
2544 }
2545 };
2546
2547 delete require.cache[configFile];
2548 const configs = require( configFile );
2549 if ( Object.keys( configs ).length === 0 ) {
2550 handleError({
2551 code: 'MISSING_CONFIG',
2552 message: 'Config file must export an options object, or an array of options objects',
2553 url: 'https://github.com/rollup/rollup/wiki/Command-Line-Interface#using-a-config-file'
2554 });
2555 }
2556
2557 require.extensions[ '.js' ] = defaultLoader;
2558
2559 return Array.isArray( configs ) ? configs : [configs];
2560 });
2561}
2562
2563function sequence ( array, fn ) {
2564 const results = [];
2565 let promise = Promise.resolve();
2566
2567 function next ( member, i ) {
2568 return fn( member ).then( value => results[i] = value );
2569 }
2570
2571 for ( let i = 0; i < array.length; i += 1 ) {
2572 promise = promise.then( () => next( array[i], i ) );
2573 }
2574
2575 return promise.then( () => results );
2576}
2577
2578var index$17 = function (ms) {
2579 if (typeof ms !== 'number') {
2580 throw new TypeError('Expected a number');
2581 }
2582
2583 var roundTowardZero = ms > 0 ? Math.floor : Math.ceil;
2584
2585 return {
2586 days: roundTowardZero(ms / 86400000),
2587 hours: roundTowardZero(ms / 3600000) % 24,
2588 minutes: roundTowardZero(ms / 60000) % 60,
2589 seconds: roundTowardZero(ms / 1000) % 60,
2590 milliseconds: roundTowardZero(ms) % 1000
2591 };
2592};
2593
2594var addendum = "addenda";
2595var aircraft = "aircraft";
2596var alga = "algae";
2597var alumna = "alumnae";
2598var alumnus = "alumni";
2599var amoeba = "amoebae";
2600var analysis = "analyses";
2601var antenna = "antennae";
2602var antithesis = "antitheses";
2603var apex = "apices";
2604var appendix = "appendices";
2605var automaton = "automata";
2606var axis = "axes";
2607var bacillus = "bacilli";
2608var bacterium = "bacteria";
2609var barracks = "barracks";
2610var basis = "bases";
2611var beau = "beaux";
2612var bison = "bison";
2613var buffalo = "buffalo";
2614var bureau = "bureaus";
2615var cactus = "cacti";
2616var calf = "calves";
2617var carp = "carp";
2618var census = "censuses";
2619var chassis = "chassis";
2620var cherub = "cherubim";
2621var child = "children";
2622var cod = "cod";
2623var codex = "codices";
2624var concerto = "concerti";
2625var corpus = "corpora";
2626var crisis = "crises";
2627var criterion = "criteria";
2628var curriculum = "curricula";
2629var datum = "data";
2630var deer = "deer";
2631var diagnosis = "diagnoses";
2632var die = "dice";
2633var dwarf = "dwarfs";
2634var echo = "echoes";
2635var elf = "elves";
2636var elk = "elk";
2637var ellipsis = "ellipses";
2638var embargo = "embargoes";
2639var emphasis = "emphases";
2640var erratum = "errata";
2641var fez = "fezes";
2642var firmware = "firmware";
2643var fish = "fish";
2644var focus = "foci";
2645var foot = "feet";
2646var formula = "formulae";
2647var fungus = "fungi";
2648var gallows = "gallows";
2649var genus = "genera";
2650var goose = "geese";
2651var graffito = "graffiti";
2652var grouse = "grouse";
2653var half = "halves";
2654var hero = "heroes";
2655var hoof = "hooves";
2656var hovercraft = "hovercraft";
2657var hypothesis = "hypotheses";
2658var index$21 = "indices";
2659var kakapo = "kakapo";
2660var knife = "knives";
2661var larva = "larvae";
2662var leaf = "leaves";
2663var libretto = "libretti";
2664var life = "lives";
2665var loaf = "loaves";
2666var locus = "loci";
2667var louse = "lice";
2668var man = "men";
2669var matrix = "matrices";
2670var means = "means";
2671var medium = "media";
2672var memorandum = "memoranda";
2673var millennium = "millennia";
2674var minutia = "minutiae";
2675var moose = "moose";
2676var mouse = "mice";
2677var nebula = "nebulae";
2678var nemesis = "nemeses";
2679var neurosis = "neuroses";
2680var news = "news";
2681var nucleus = "nuclei";
2682var oasis = "oases";
2683var offspring = "offspring";
2684var opus = "opera";
2685var ovum = "ova";
2686var ox = "oxen";
2687var paralysis = "paralyses";
2688var parenthesis = "parentheses";
2689var person = "people";
2690var phenomenon = "phenomena";
2691var phylum = "phyla";
2692var pike = "pike";
2693var polyhedron = "polyhedra";
2694var potato = "potatoes";
2695var prognosis = "prognoses";
2696var quiz = "quizzes";
2697var radius = "radii";
2698var referendum = "referenda";
2699var salmon = "salmon";
2700var scarf = "scarves";
2701var self$1 = "selves";
2702var series = "series";
2703var sheep = "sheep";
2704var shelf = "shelves";
2705var shrimp = "shrimp";
2706var spacecraft = "spacecraft";
2707var species = "species";
2708var spectrum = "spectra";
2709var squid = "squid";
2710var stimulus = "stimuli";
2711var stratum = "strata";
2712var swine = "swine";
2713var syllabus = "syllabi";
2714var symposium = "symposia";
2715var synopsis = "synopses";
2716var synthesis = "syntheses";
2717var tableau = "tableaus";
2718var that = "those";
2719var thesis = "theses";
2720var thief = "thieves";
2721var tomato = "tomatoes";
2722var tooth = "teeth";
2723var trout = "trout";
2724var tuna = "tuna";
2725var vertebra = "vertebrae";
2726var vertex = "vertices";
2727var veto = "vetoes";
2728var vita = "vitae";
2729var vortex = "vortices";
2730var watercraft = "watercraft";
2731var wharf = "wharves";
2732var wife = "wives";
2733var wolf = "wolves";
2734var woman = "women";
2735var irregularPlurals = {
2736 addendum: addendum,
2737 aircraft: aircraft,
2738 alga: alga,
2739 alumna: alumna,
2740 alumnus: alumnus,
2741 amoeba: amoeba,
2742 analysis: analysis,
2743 antenna: antenna,
2744 antithesis: antithesis,
2745 apex: apex,
2746 appendix: appendix,
2747 automaton: automaton,
2748 axis: axis,
2749 bacillus: bacillus,
2750 bacterium: bacterium,
2751 barracks: barracks,
2752 basis: basis,
2753 beau: beau,
2754 bison: bison,
2755 buffalo: buffalo,
2756 bureau: bureau,
2757 cactus: cactus,
2758 calf: calf,
2759 carp: carp,
2760 census: census,
2761 chassis: chassis,
2762 cherub: cherub,
2763 child: child,
2764 cod: cod,
2765 codex: codex,
2766 concerto: concerto,
2767 corpus: corpus,
2768 crisis: crisis,
2769 criterion: criterion,
2770 curriculum: curriculum,
2771 datum: datum,
2772 deer: deer,
2773 diagnosis: diagnosis,
2774 die: die,
2775 dwarf: dwarf,
2776 echo: echo,
2777 elf: elf,
2778 elk: elk,
2779 ellipsis: ellipsis,
2780 embargo: embargo,
2781 emphasis: emphasis,
2782 erratum: erratum,
2783 fez: fez,
2784 firmware: firmware,
2785 fish: fish,
2786 focus: focus,
2787 foot: foot,
2788 formula: formula,
2789 fungus: fungus,
2790 gallows: gallows,
2791 genus: genus,
2792 goose: goose,
2793 graffito: graffito,
2794 grouse: grouse,
2795 half: half,
2796 hero: hero,
2797 hoof: hoof,
2798 hovercraft: hovercraft,
2799 hypothesis: hypothesis,
2800 index: index$21,
2801 kakapo: kakapo,
2802 knife: knife,
2803 larva: larva,
2804 leaf: leaf,
2805 libretto: libretto,
2806 life: life,
2807 loaf: loaf,
2808 locus: locus,
2809 louse: louse,
2810 man: man,
2811 matrix: matrix,
2812 means: means,
2813 medium: medium,
2814 memorandum: memorandum,
2815 millennium: millennium,
2816 minutia: minutia,
2817 moose: moose,
2818 mouse: mouse,
2819 nebula: nebula,
2820 nemesis: nemesis,
2821 neurosis: neurosis,
2822 news: news,
2823 nucleus: nucleus,
2824 oasis: oasis,
2825 offspring: offspring,
2826 opus: opus,
2827 ovum: ovum,
2828 ox: ox,
2829 paralysis: paralysis,
2830 parenthesis: parenthesis,
2831 person: person,
2832 phenomenon: phenomenon,
2833 phylum: phylum,
2834 pike: pike,
2835 polyhedron: polyhedron,
2836 potato: potato,
2837 prognosis: prognosis,
2838 quiz: quiz,
2839 radius: radius,
2840 referendum: referendum,
2841 salmon: salmon,
2842 scarf: scarf,
2843 self: self$1,
2844 series: series,
2845 sheep: sheep,
2846 shelf: shelf,
2847 shrimp: shrimp,
2848 spacecraft: spacecraft,
2849 species: species,
2850 spectrum: spectrum,
2851 squid: squid,
2852 stimulus: stimulus,
2853 stratum: stratum,
2854 swine: swine,
2855 syllabus: syllabus,
2856 symposium: symposium,
2857 synopsis: synopsis,
2858 synthesis: synthesis,
2859 tableau: tableau,
2860 that: that,
2861 thesis: thesis,
2862 thief: thief,
2863 tomato: tomato,
2864 tooth: tooth,
2865 trout: trout,
2866 tuna: tuna,
2867 vertebra: vertebra,
2868 vertex: vertex,
2869 veto: veto,
2870 vita: vita,
2871 vortex: vortex,
2872 watercraft: watercraft,
2873 wharf: wharf,
2874 wife: wife,
2875 wolf: wolf,
2876 woman: woman,
2877 "château": "châteaus",
2878 "faux pas": "faux pas"
2879};
2880
2881var irregularPlurals$1 = Object.freeze({
2882 addendum: addendum,
2883 aircraft: aircraft,
2884 alga: alga,
2885 alumna: alumna,
2886 alumnus: alumnus,
2887 amoeba: amoeba,
2888 analysis: analysis,
2889 antenna: antenna,
2890 antithesis: antithesis,
2891 apex: apex,
2892 appendix: appendix,
2893 automaton: automaton,
2894 axis: axis,
2895 bacillus: bacillus,
2896 bacterium: bacterium,
2897 barracks: barracks,
2898 basis: basis,
2899 beau: beau,
2900 bison: bison,
2901 buffalo: buffalo,
2902 bureau: bureau,
2903 cactus: cactus,
2904 calf: calf,
2905 carp: carp,
2906 census: census,
2907 chassis: chassis,
2908 cherub: cherub,
2909 child: child,
2910 cod: cod,
2911 codex: codex,
2912 concerto: concerto,
2913 corpus: corpus,
2914 crisis: crisis,
2915 criterion: criterion,
2916 curriculum: curriculum,
2917 datum: datum,
2918 deer: deer,
2919 diagnosis: diagnosis,
2920 die: die,
2921 dwarf: dwarf,
2922 echo: echo,
2923 elf: elf,
2924 elk: elk,
2925 ellipsis: ellipsis,
2926 embargo: embargo,
2927 emphasis: emphasis,
2928 erratum: erratum,
2929 fez: fez,
2930 firmware: firmware,
2931 fish: fish,
2932 focus: focus,
2933 foot: foot,
2934 formula: formula,
2935 fungus: fungus,
2936 gallows: gallows,
2937 genus: genus,
2938 goose: goose,
2939 graffito: graffito,
2940 grouse: grouse,
2941 half: half,
2942 hero: hero,
2943 hoof: hoof,
2944 hovercraft: hovercraft,
2945 hypothesis: hypothesis,
2946 index: index$21,
2947 kakapo: kakapo,
2948 knife: knife,
2949 larva: larva,
2950 leaf: leaf,
2951 libretto: libretto,
2952 life: life,
2953 loaf: loaf,
2954 locus: locus,
2955 louse: louse,
2956 man: man,
2957 matrix: matrix,
2958 means: means,
2959 medium: medium,
2960 memorandum: memorandum,
2961 millennium: millennium,
2962 minutia: minutia,
2963 moose: moose,
2964 mouse: mouse,
2965 nebula: nebula,
2966 nemesis: nemesis,
2967 neurosis: neurosis,
2968 news: news,
2969 nucleus: nucleus,
2970 oasis: oasis,
2971 offspring: offspring,
2972 opus: opus,
2973 ovum: ovum,
2974 ox: ox,
2975 paralysis: paralysis,
2976 parenthesis: parenthesis,
2977 person: person,
2978 phenomenon: phenomenon,
2979 phylum: phylum,
2980 pike: pike,
2981 polyhedron: polyhedron,
2982 potato: potato,
2983 prognosis: prognosis,
2984 quiz: quiz,
2985 radius: radius,
2986 referendum: referendum,
2987 salmon: salmon,
2988 scarf: scarf,
2989 self: self$1,
2990 series: series,
2991 sheep: sheep,
2992 shelf: shelf,
2993 shrimp: shrimp,
2994 spacecraft: spacecraft,
2995 species: species,
2996 spectrum: spectrum,
2997 squid: squid,
2998 stimulus: stimulus,
2999 stratum: stratum,
3000 swine: swine,
3001 syllabus: syllabus,
3002 symposium: symposium,
3003 synopsis: synopsis,
3004 synthesis: synthesis,
3005 tableau: tableau,
3006 that: that,
3007 thesis: thesis,
3008 thief: thief,
3009 tomato: tomato,
3010 tooth: tooth,
3011 trout: trout,
3012 tuna: tuna,
3013 vertebra: vertebra,
3014 vertex: vertex,
3015 veto: veto,
3016 vita: vita,
3017 vortex: vortex,
3018 watercraft: watercraft,
3019 wharf: wharf,
3020 wife: wife,
3021 wolf: wolf,
3022 woman: woman,
3023 default: irregularPlurals
3024});
3025
3026var irregularPlurals$2 = ( irregularPlurals$1 && irregularPlurals ) || irregularPlurals$1;
3027
3028var index$19 = function (str, plural, count) {
3029 if (typeof plural === 'number') {
3030 count = plural;
3031 }
3032
3033 if (str in irregularPlurals$2) {
3034 plural = irregularPlurals$2[str];
3035 } else if (typeof plural !== 'string') {
3036 plural = (str.replace(/(?:s|x|z|ch|sh)$/i, '$&e').replace(/([^aeiou])y$/i, '$1ie') + 's')
3037 .replace(/i?e?s$/i, function (m) {
3038 var isTailLowerCase = str.slice(-1) === str.slice(-1).toLowerCase();
3039 return isTailLowerCase ? m.toLowerCase() : m.toUpperCase();
3040 });
3041 }
3042
3043 return count === 1 ? str : plural;
3044};
3045
3046var index$16 = createCommonjsModule(function (module) {
3047'use strict';
3048
3049
3050
3051module.exports = (ms, opts) => {
3052 if (!Number.isFinite(ms)) {
3053 throw new TypeError('Expected a finite number');
3054 }
3055
3056 opts = opts || {};
3057
3058 if (ms < 1000) {
3059 const msDecimalDigits = typeof opts.msDecimalDigits === 'number' ? opts.msDecimalDigits : 0;
3060 return (msDecimalDigits ? ms.toFixed(msDecimalDigits) : Math.ceil(ms)) + (opts.verbose ? ' ' + index$19('millisecond', Math.ceil(ms)) : 'ms');
3061 }
3062
3063 const ret = [];
3064
3065 const add = (val, long, short, valStr) => {
3066 if (val === 0) {
3067 return;
3068 }
3069
3070 const postfix = opts.verbose ? ' ' + index$19(long, val) : short;
3071
3072 ret.push((valStr || val) + postfix);
3073 };
3074
3075 const parsed = index$17(ms);
3076
3077 add(Math.trunc(parsed.days / 365), 'year', 'y');
3078 add(parsed.days % 365, 'day', 'd');
3079 add(parsed.hours, 'hour', 'h');
3080 add(parsed.minutes, 'minute', 'm');
3081
3082 if (opts.compact) {
3083 add(parsed.seconds, 'second', 's');
3084 return '~' + ret[0];
3085 }
3086
3087 const sec = ms / 1000 % 60;
3088 const secDecimalDigits = typeof opts.secDecimalDigits === 'number' ? opts.secDecimalDigits : 1;
3089 const secStr = sec.toFixed(secDecimalDigits).replace(/\.0$/, '');
3090 add(sec, 'second', 's', secStr);
3091
3092 return ret.join(' ');
3093};
3094});
3095
3096function mapSequence ( array, fn ) {
3097 const results = [];
3098 let promise = Promise.resolve();
3099
3100 function next ( member, i ) {
3101 return fn( member ).then( value => results[i] = value );
3102 }
3103
3104 for ( let i = 0; i < array.length; i += 1 ) {
3105 promise = promise.then( () => next( array[i], i ) );
3106 }
3107
3108 return promise.then( () => results );
3109}
3110
3111let SOURCEMAPPING_URL = 'sourceMa';
3112SOURCEMAPPING_URL += 'ppingURL';
3113
3114var SOURCEMAPPING_URL$1 = SOURCEMAPPING_URL;
3115
3116function build$1 ( options, warnings, silent ) {
3117 const useStdout = !options.targets && !options.dest;
3118 const targets = options.targets ? options.targets : [{ dest: options.dest, format: options.format }];
3119
3120 const start = Date.now();
3121 const dests = useStdout ? [ 'stdout' ] : targets.map( t => relativeId( t.dest ) );
3122 if ( !silent ) { stderr( index$3.cyan( `\n${index$3.bold( options.entry )} → ${index$3.bold( dests.join( ', ' ) )}...` ) ); }
3123
3124 return rollup.rollup( options )
3125 .then( bundle => {
3126 if ( useStdout ) {
3127 if ( options.sourceMap && options.sourceMap !== 'inline' ) {
3128 handleError({
3129 code: 'MISSING_OUTPUT_OPTION',
3130 message: 'You must specify an --output (-o) option when creating a file with a sourcemap'
3131 });
3132 }
3133
3134 return bundle.generate(options).then( (ref) => {
3135 var code = ref.code;
3136 var map = ref.map;
3137
3138 if ( options.sourceMap === 'inline' ) {
3139 code += `\n//# ${SOURCEMAPPING_URL$1}=${map.toUrl()}\n`;
3140 }
3141
3142 process.stdout.write( code );
3143 });
3144 }
3145
3146 return mapSequence( targets, target => {
3147 return bundle.write( assign( clone( options ), target ) );
3148 });
3149 })
3150 .then( () => {
3151 warnings.flush();
3152 if ( !silent ) { stderr( index$3.green( `created ${index$3.bold( dests.join( ', ' ) )} in ${index$3.bold(index$16( Date.now() - start))}` ) ); }
3153 })
3154 .catch( handleError );
3155}
3156
3157function clone ( object ) {
3158 return assign( {}, object );
3159}
3160
3161function assign ( target, source ) {
3162 Object.keys( source ).forEach( key => {
3163 target[ key ] = source[ key ];
3164 });
3165 return target;
3166}
3167
3168function watch$1(configFile, configs, command, silent) {
3169 process.stderr.write('\x1b[?1049h'); // alternate screen buffer
3170
3171 const warnings = batchWarnings();
3172
3173 configs = configs.map(options => {
3174 const merged = mergeOptions(options, command);
3175
3176 const onwarn = merged.onwarn;
3177 if ( onwarn ) {
3178 merged.onwarn = warning => {
3179 onwarn( warning, warnings.add );
3180 };
3181 } else {
3182 merged.onwarn = warnings.add;
3183 }
3184
3185 return merged;
3186 });
3187
3188 let watcher;
3189 let configWatcher;
3190 let closed = false;
3191
3192 function start(configs) {
3193 stderr(`\x1B[2J\x1B[0f${index$3.underline( `rollup v${rollup.VERSION}` )}`); // clear, move to top-left
3194
3195 watcher = rollup.watch(configs);
3196
3197 watcher.on('event', event => {
3198 switch (event.code) {
3199 case 'FATAL':
3200 process.stderr.write('\x1b[?1049l'); // reset screen buffer
3201 handleError(event.error, true);
3202 process.exit(1);
3203 break;
3204
3205 case 'ERROR':
3206 warnings.flush();
3207 handleError(event.error, true);
3208 break;
3209
3210 case 'START':
3211 stderr(`\x1B[2J\x1B[0f${index$3.underline( `rollup v${rollup.VERSION}` )}`); // clear, move to top-left
3212 break;
3213
3214 case 'BUNDLE_START':
3215 if ( !silent ) { stderr( index$3.cyan( `\n${index$3.bold( event.input )} → ${index$3.bold( event.output.map( relativeId ).join( ', ' ) )}...` ) ); }
3216 break;
3217
3218 case 'BUNDLE_END':
3219 warnings.flush();
3220 if ( !silent ) { stderr( index$3.green( `created ${index$3.bold( event.output.map( relativeId ).join( ', ' ) )} in ${index$3.bold(index$16(event.duration))}` ) ); }
3221 break;
3222
3223 case 'END':
3224 if ( !silent ) { stderr( `\nwaiting for changes...` ); }
3225 }
3226 });
3227 }
3228
3229 const close = () => {
3230 if (!closed) {
3231 process.stderr.write('\x1b[?1049l'); // reset screen buffer
3232 closed = true;
3233 watcher.close();
3234
3235 if (configWatcher) { configWatcher.close(); }
3236 }
3237 };
3238 process.on('SIGINT', close); // ctrl-c
3239 process.on('SIGTERM', close); // killall node
3240 process.on('uncaughtException', close); // on error
3241 process.stdin.on('end', close); // in case we ever support stdin!
3242
3243 start(configs);
3244
3245 if (configFile && !configFile.startsWith('node:')) {
3246 let restarting = false;
3247 let aborted = false;
3248 let configFileData = fs__default.readFileSync(configFile, 'utf-8');
3249
3250 const restart = () => {
3251 const newConfigFileData = fs__default.readFileSync(configFile, 'utf-8');
3252 if (newConfigFileData === configFileData) { return; }
3253 configFileData = newConfigFileData;
3254
3255 if (restarting) {
3256 aborted = true;
3257 return;
3258 }
3259
3260 restarting = true;
3261
3262 loadConfigFile(configFile, silent)
3263 .then(configs => {
3264 restarting = false;
3265
3266 if (aborted) {
3267 aborted = false;
3268 restart();
3269 } else {
3270 watcher.close();
3271 start(configs);
3272 }
3273 })
3274 .catch(err => {
3275 handleError(err, true);
3276 });
3277 };
3278
3279 configWatcher = fs__default.watch(configFile, event => {
3280 if (event === 'change') { restart(); }
3281 });
3282 }
3283}
3284
3285function runRollup ( command ) {
3286 if ( command._.length > 1 ) {
3287 handleError({
3288 code: 'ONE_AT_A_TIME',
3289 message: 'rollup can only bundle one file at a time'
3290 });
3291 }
3292
3293 if ( command._.length === 1 ) {
3294 if ( command.input ) {
3295 handleError({
3296 code: 'DUPLICATE_IMPORT_OPTIONS',
3297 message: 'use --input, or pass input path as argument'
3298 });
3299 }
3300
3301 command.input = command._[0];
3302 }
3303
3304 if ( command.environment ) {
3305 command.environment.split( ',' ).forEach( pair => {
3306 const index = pair.indexOf( ':' );
3307 if ( ~index ) {
3308 process.env[ pair.slice( 0, index ) ] = pair.slice( index + 1 );
3309 } else {
3310 process.env[ pair ] = true;
3311 }
3312 });
3313 }
3314
3315 let configFile = command.config === true ? 'rollup.config.js' : command.config;
3316
3317 if ( configFile ) {
3318 if ( configFile.slice( 0, 5 ) === 'node:' ) {
3319 const pkgName = configFile.slice( 5 );
3320 try {
3321 configFile = index$2.resolve( `rollup-config-${pkgName}`, process.cwd() );
3322 } catch ( err ) {
3323 try {
3324 configFile = index$2.resolve( pkgName, process.cwd() );
3325 } catch ( err ) {
3326 if ( err.code === 'MODULE_NOT_FOUND' ) {
3327 handleError({
3328 code: 'MISSING_EXTERNAL_CONFIG',
3329 message: `Could not resolve config file ${configFile}`
3330 });
3331 }
3332
3333 throw err;
3334 }
3335 }
3336 } else {
3337 // find real path of config so it matches what Node provides to callbacks in require.extensions
3338 configFile = fs.realpathSync( configFile );
3339 }
3340
3341 loadConfigFile(configFile, command.silent)
3342 .then(normalized => execute( configFile, normalized, command ))
3343 .catch(handleError);
3344 } else {
3345 return execute( configFile, [{}], command );
3346 }
3347}
3348
3349function execute ( configFile, configs, command ) {
3350 if ( command.watch ) {
3351 process.env.ROLLUP_WATCH = 'true';
3352 watch$1( configFile, configs, command, command.silent );
3353 } else {
3354 return sequence( configs, config => {
3355 const options = mergeOptions( config, command );
3356
3357 const warnings = batchWarnings();
3358
3359 const onwarn = options.onwarn;
3360 if ( onwarn ) {
3361 options.onwarn = warning => {
3362 onwarn( warning, warnings.add );
3363 };
3364 } else {
3365 options.onwarn = warnings.add;
3366 }
3367
3368 return build$1( options, warnings, command.silent );
3369 });
3370 }
3371}
3372
3373const command = index$1( process.argv.slice( 2 ), {
3374 alias: {
3375 // Aliases
3376 strict: 'useStrict',
3377
3378 // Short options
3379 c: 'config',
3380 d: 'indent',
3381 e: 'external',
3382 f: 'format',
3383 g: 'globals',
3384 h: 'help',
3385 i: 'input',
3386 l: 'legacy',
3387 m: 'sourcemap',
3388 n: 'name',
3389 o: 'output',
3390 u: 'id',
3391 v: 'version',
3392 w: 'watch'
3393 }
3394});
3395
3396if ( command.help || ( process.argv.length <= 2 && process.stdin.isTTY ) ) {
3397 console.log( `\n${help.replace('__VERSION__', version)}\n` ); // eslint-disable-line no-console
3398}
3399
3400else if ( command.version ) {
3401 console.log( `rollup version ${version}` ); // eslint-disable-line no-console
3402}
3403
3404else {
3405 runRollup( command );
3406}