UNPKG

173 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('vega'), require('vega-lite')) :
3 typeof define === 'function' && define.amd ? define(['vega', 'vega-lite'], factory) :
4 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.vegaEmbed = factory(global.vega, global.vegaLite));
5}(this, (function (vegaImport, vegaLiteImport) { 'use strict';
6
7 function _interopNamespace(e) {
8 if (e && e.__esModule) return e;
9 var n = Object.create(null);
10 if (e) {
11 Object.keys(e).forEach(function (k) {
12 if (k !== 'default') {
13 var d = Object.getOwnPropertyDescriptor(e, k);
14 Object.defineProperty(n, k, d.get ? d : {
15 enumerable: true,
16 get: function () {
17 return e[k];
18 }
19 });
20 }
21 });
22 }
23 n['default'] = e;
24 return Object.freeze(n);
25 }
26
27 var vegaImport__namespace = /*#__PURE__*/_interopNamespace(vegaImport);
28 var vegaLiteImport__namespace = /*#__PURE__*/_interopNamespace(vegaLiteImport);
29
30 var name$1 = "vega-embed";
31 var version$2 = "6.19.1";
32 var description$1 = "Publish Vega visualizations as embedded web components.";
33 var keywords$1 = ["vega", "data", "visualization", "component", "embed"];
34 var repository$1 = {
35 type: "git",
36 url: "http://github.com/vega/vega-embed.git"
37 };
38 var author$1 = {
39 name: "UW Interactive Data Lab",
40 url: "http://idl.cs.washington.edu"
41 };
42 var contributors$1 = [{
43 name: "Dominik Moritz",
44 url: "https://www.domoritz.de"
45 }];
46 var bugs = {
47 url: "https://github.com/vega/vega-embed/issues"
48 };
49 var homepage = "https://github.com/vega/vega-embed#readme";
50 var license$1 = "BSD-3-Clause";
51 var main$1 = "build/vega-embed.js";
52 var module$1 = "build/vega-embed.module.js";
53 var unpkg$1 = "build/vega-embed.min.js";
54 var jsdelivr$1 = "build/vega-embed.min.js";
55 var types$1 = "build/vega-embed.module.d.ts";
56 var files$1 = ["src", "build", "build-es5"];
57 var devDependencies$1 = {
58 "@auto-it/conventional-commits": "^10.32.0",
59 "@auto-it/first-time-contributor": "^10.32.0",
60 "@rollup/plugin-commonjs": "20.0.0",
61 "@rollup/plugin-json": "^4.1.0",
62 "@rollup/plugin-node-resolve": "^13.0.4",
63 "@types/semver": "^7.3.8",
64 "@wessberg/rollup-plugin-ts": "^1.3.14",
65 auto: "^10.32.0",
66 "browser-sync": "^2.27.5",
67 concurrently: "^6.2.1",
68 "del-cli": "^4.0.1",
69 "jest-canvas-mock": "^2.3.1",
70 "node-sass": "^6.0.1",
71 "rollup-plugin-bundle-size": "^1.0.3",
72 "rollup-plugin-terser": "^7.0.2",
73 rollup: "2.56.3",
74 typescript: "^4.4.3",
75 "vega-lite-dev-config": "^0.18.0",
76 "vega-lite": "^5.0.0",
77 vega: "^5.19.1"
78 };
79 var peerDependencies$1 = {
80 vega: "^5.20.2",
81 "vega-lite": "*"
82 };
83 var dependencies = {
84 "fast-json-patch": "^3.1.0",
85 "json-stringify-pretty-compact": "^3.0.0",
86 semver: "^7.3.5",
87 tslib: "^2.3.1",
88 "vega-interpreter": "^1.0.4",
89 "vega-schema-url-parser": "^2.2.0",
90 "vega-themes": "^2.10.0",
91 "vega-tooltip": "^0.27.0"
92 };
93 var scripts$1 = {
94 prebuild: "yarn clean && yarn build:style",
95 build: "rollup -c",
96 "build:style": "./build-style.sh",
97 clean: "del-cli build build-es5 src/style.ts",
98 prepublishOnly: "yarn clean && yarn build",
99 preversion: "yarn lint && yarn test",
100 serve: "browser-sync start --directory -s -f build *.html",
101 start: "yarn build && concurrently --kill-others -n Server,Rollup 'yarn serve' 'rollup -c -w'",
102 pretest: "yarn build:style",
103 test: "beemo jest --stdio stream",
104 "test:inspect": "node --inspect-brk ./node_modules/.bin/jest --runInBand",
105 prepare: "beemo create-config",
106 prettierbase: "beemo prettier '*.{css,scss,html}'",
107 eslintbase: "beemo eslint .",
108 format: "yarn eslintbase --fix && yarn prettierbase --write",
109 lint: "yarn eslintbase && yarn prettierbase --check",
110 release: "auto shipit"
111 };
112 var pkg$1 = {
113 name: name$1,
114 version: version$2,
115 description: description$1,
116 keywords: keywords$1,
117 repository: repository$1,
118 author: author$1,
119 contributors: contributors$1,
120 bugs: bugs,
121 homepage: homepage,
122 license: license$1,
123 main: main$1,
124 module: module$1,
125 unpkg: unpkg$1,
126 jsdelivr: jsdelivr$1,
127 types: types$1,
128 files: files$1,
129 devDependencies: devDependencies$1,
130 peerDependencies: peerDependencies$1,
131 dependencies: dependencies,
132 scripts: scripts$1
133 };
134
135 /*!
136 * https://github.com/Starcounter-Jack/JSON-Patch
137 * (c) 2017 Joachim Wester
138 * MIT license
139 */
140 var __extends = undefined && undefined.__extends || function () {
141 var extendStatics = function (d, b) {
142 extendStatics = Object.setPrototypeOf || {
143 __proto__: []
144 } instanceof Array && function (d, b) {
145 d.__proto__ = b;
146 } || function (d, b) {
147 for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
148 };
149
150 return extendStatics(d, b);
151 };
152
153 return function (d, b) {
154 extendStatics(d, b);
155
156 function __() {
157 this.constructor = d;
158 }
159
160 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
161 };
162 }();
163
164 var _hasOwnProperty = Object.prototype.hasOwnProperty;
165 function hasOwnProperty(obj, key) {
166 return _hasOwnProperty.call(obj, key);
167 }
168 function _objectKeys(obj) {
169 if (Array.isArray(obj)) {
170 var keys = new Array(obj.length);
171
172 for (var k = 0; k < keys.length; k++) {
173 keys[k] = "" + k;
174 }
175
176 return keys;
177 }
178
179 if (Object.keys) {
180 return Object.keys(obj);
181 }
182
183 var keys = [];
184
185 for (var i in obj) {
186 if (hasOwnProperty(obj, i)) {
187 keys.push(i);
188 }
189 }
190
191 return keys;
192 }
193 /**
194 * Deeply clone the object.
195 * https://jsperf.com/deep-copy-vs-json-stringify-json-parse/25 (recursiveDeepCopy)
196 * @param {any} obj value to clone
197 * @return {any} cloned obj
198 */
199
200 function _deepClone(obj) {
201 switch (typeof obj) {
202 case "object":
203 return JSON.parse(JSON.stringify(obj));
204 //Faster than ES5 clone - http://jsperf.com/deep-cloning-of-objects/5
205
206 case "undefined":
207 return null;
208 //this is how JSON.stringify behaves for array items
209
210 default:
211 return obj;
212 //no need to clone primitives
213 }
214 } //3x faster than cached /^\d+$/.test(str)
215
216 function isInteger(str) {
217 var i = 0;
218 var len = str.length;
219 var charCode;
220
221 while (i < len) {
222 charCode = str.charCodeAt(i);
223
224 if (charCode >= 48 && charCode <= 57) {
225 i++;
226 continue;
227 }
228
229 return false;
230 }
231
232 return true;
233 }
234 /**
235 * Escapes a json pointer path
236 * @param path The raw pointer
237 * @return the Escaped path
238 */
239
240 function escapePathComponent(path) {
241 if (path.indexOf('/') === -1 && path.indexOf('~') === -1) return path;
242 return path.replace(/~/g, '~0').replace(/\//g, '~1');
243 }
244 /**
245 * Unescapes a json pointer path
246 * @param path The escaped pointer
247 * @return The unescaped path
248 */
249
250 function unescapePathComponent(path) {
251 return path.replace(/~1/g, '/').replace(/~0/g, '~');
252 }
253 /**
254 * Recursively checks whether an object has any undefined values inside.
255 */
256
257 function hasUndefined(obj) {
258 if (obj === undefined) {
259 return true;
260 }
261
262 if (obj) {
263 if (Array.isArray(obj)) {
264 for (var i = 0, len = obj.length; i < len; i++) {
265 if (hasUndefined(obj[i])) {
266 return true;
267 }
268 }
269 } else if (typeof obj === "object") {
270 var objKeys = _objectKeys(obj);
271
272 var objKeysLength = objKeys.length;
273
274 for (var i = 0; i < objKeysLength; i++) {
275 if (hasUndefined(obj[objKeys[i]])) {
276 return true;
277 }
278 }
279 }
280 }
281
282 return false;
283 }
284
285 function patchErrorMessageFormatter(message, args) {
286 var messageParts = [message];
287
288 for (var key in args) {
289 var value = typeof args[key] === 'object' ? JSON.stringify(args[key], null, 2) : args[key]; // pretty print
290
291 if (typeof value !== 'undefined') {
292 messageParts.push(key + ": " + value);
293 }
294 }
295
296 return messageParts.join('\n');
297 }
298
299 var PatchError = function (_super) {
300 __extends(PatchError, _super);
301
302 function PatchError(message, name, index, operation, tree) {
303 var _newTarget = this.constructor;
304
305 var _this = _super.call(this, patchErrorMessageFormatter(message, {
306 name: name,
307 index: index,
308 operation: operation,
309 tree: tree
310 })) || this;
311
312 _this.name = name;
313 _this.index = index;
314 _this.operation = operation;
315 _this.tree = tree;
316 Object.setPrototypeOf(_this, _newTarget.prototype); // restore prototype chain, see https://stackoverflow.com/a/48342359
317
318 _this.message = patchErrorMessageFormatter(message, {
319 name: name,
320 index: index,
321 operation: operation,
322 tree: tree
323 });
324 return _this;
325 }
326
327 return PatchError;
328 }(Error);
329
330 var JsonPatchError = PatchError;
331 var deepClone = _deepClone;
332 /* We use a Javascript hash to store each
333 function. Each hash entry (property) uses
334 the operation identifiers specified in rfc6902.
335 In this way, we can map each patch operation
336 to its dedicated function in efficient way.
337 */
338
339 /* The operations applicable to an object */
340
341 var objOps = {
342 add: function (obj, key, document) {
343 obj[key] = this.value;
344 return {
345 newDocument: document
346 };
347 },
348 remove: function (obj, key, document) {
349 var removed = obj[key];
350 delete obj[key];
351 return {
352 newDocument: document,
353 removed: removed
354 };
355 },
356 replace: function (obj, key, document) {
357 var removed = obj[key];
358 obj[key] = this.value;
359 return {
360 newDocument: document,
361 removed: removed
362 };
363 },
364 move: function (obj, key, document) {
365 /* in case move target overwrites an existing value,
366 return the removed value, this can be taxing performance-wise,
367 and is potentially unneeded */
368 var removed = getValueByPointer(document, this.path);
369
370 if (removed) {
371 removed = _deepClone(removed);
372 }
373
374 var originalValue = applyOperation(document, {
375 op: "remove",
376 path: this.from
377 }).removed;
378 applyOperation(document, {
379 op: "add",
380 path: this.path,
381 value: originalValue
382 });
383 return {
384 newDocument: document,
385 removed: removed
386 };
387 },
388 copy: function (obj, key, document) {
389 var valueToCopy = getValueByPointer(document, this.from); // enforce copy by value so further operations don't affect source (see issue #177)
390
391 applyOperation(document, {
392 op: "add",
393 path: this.path,
394 value: _deepClone(valueToCopy)
395 });
396 return {
397 newDocument: document
398 };
399 },
400 test: function (obj, key, document) {
401 return {
402 newDocument: document,
403 test: _areEquals(obj[key], this.value)
404 };
405 },
406 _get: function (obj, key, document) {
407 this.value = obj[key];
408 return {
409 newDocument: document
410 };
411 }
412 };
413 /* The operations applicable to an array. Many are the same as for the object */
414
415 var arrOps = {
416 add: function (arr, i, document) {
417 if (isInteger(i)) {
418 arr.splice(i, 0, this.value);
419 } else {
420 // array props
421 arr[i] = this.value;
422 } // this may be needed when using '-' in an array
423
424
425 return {
426 newDocument: document,
427 index: i
428 };
429 },
430 remove: function (arr, i, document) {
431 var removedList = arr.splice(i, 1);
432 return {
433 newDocument: document,
434 removed: removedList[0]
435 };
436 },
437 replace: function (arr, i, document) {
438 var removed = arr[i];
439 arr[i] = this.value;
440 return {
441 newDocument: document,
442 removed: removed
443 };
444 },
445 move: objOps.move,
446 copy: objOps.copy,
447 test: objOps.test,
448 _get: objOps._get
449 };
450 /**
451 * Retrieves a value from a JSON document by a JSON pointer.
452 * Returns the value.
453 *
454 * @param document The document to get the value from
455 * @param pointer an escaped JSON pointer
456 * @return The retrieved value
457 */
458
459 function getValueByPointer(document, pointer) {
460 if (pointer == '') {
461 return document;
462 }
463
464 var getOriginalDestination = {
465 op: "_get",
466 path: pointer
467 };
468 applyOperation(document, getOriginalDestination);
469 return getOriginalDestination.value;
470 }
471 /**
472 * Apply a single JSON Patch Operation on a JSON document.
473 * Returns the {newDocument, result} of the operation.
474 * It modifies the `document` and `operation` objects - it gets the values by reference.
475 * If you would like to avoid touching your values, clone them:
476 * `jsonpatch.applyOperation(document, jsonpatch._deepClone(operation))`.
477 *
478 * @param document The document to patch
479 * @param operation The operation to apply
480 * @param validateOperation `false` is without validation, `true` to use default jsonpatch's validation, or you can pass a `validateOperation` callback to be used for validation.
481 * @param mutateDocument Whether to mutate the original document or clone it before applying
482 * @param banPrototypeModifications Whether to ban modifications to `__proto__`, defaults to `true`.
483 * @return `{newDocument, result}` after the operation
484 */
485
486 function applyOperation(document, operation, validateOperation, mutateDocument, banPrototypeModifications, index) {
487 if (validateOperation === void 0) {
488 validateOperation = false;
489 }
490
491 if (mutateDocument === void 0) {
492 mutateDocument = true;
493 }
494
495 if (banPrototypeModifications === void 0) {
496 banPrototypeModifications = true;
497 }
498
499 if (index === void 0) {
500 index = 0;
501 }
502
503 if (validateOperation) {
504 if (typeof validateOperation == 'function') {
505 validateOperation(operation, 0, document, operation.path);
506 } else {
507 validator(operation, 0);
508 }
509 }
510 /* ROOT OPERATIONS */
511
512
513 if (operation.path === "") {
514 var returnValue = {
515 newDocument: document
516 };
517
518 if (operation.op === 'add') {
519 returnValue.newDocument = operation.value;
520 return returnValue;
521 } else if (operation.op === 'replace') {
522 returnValue.newDocument = operation.value;
523 returnValue.removed = document; //document we removed
524
525 return returnValue;
526 } else if (operation.op === 'move' || operation.op === 'copy') {
527 // it's a move or copy to root
528 returnValue.newDocument = getValueByPointer(document, operation.from); // get the value by json-pointer in `from` field
529
530 if (operation.op === 'move') {
531 // report removed item
532 returnValue.removed = document;
533 }
534
535 return returnValue;
536 } else if (operation.op === 'test') {
537 returnValue.test = _areEquals(document, operation.value);
538
539 if (returnValue.test === false) {
540 throw new JsonPatchError("Test operation failed", 'TEST_OPERATION_FAILED', index, operation, document);
541 }
542
543 returnValue.newDocument = document;
544 return returnValue;
545 } else if (operation.op === 'remove') {
546 // a remove on root
547 returnValue.removed = document;
548 returnValue.newDocument = null;
549 return returnValue;
550 } else if (operation.op === '_get') {
551 operation.value = document;
552 return returnValue;
553 } else {
554 /* bad operation */
555 if (validateOperation) {
556 throw new JsonPatchError('Operation `op` property is not one of operations defined in RFC-6902', 'OPERATION_OP_INVALID', index, operation, document);
557 } else {
558 return returnValue;
559 }
560 }
561 }
562 /* END ROOT OPERATIONS */
563 else {
564 if (!mutateDocument) {
565 document = _deepClone(document);
566 }
567
568 var path = operation.path || "";
569 var keys = path.split('/');
570 var obj = document;
571 var t = 1; //skip empty element - http://jsperf.com/to-shift-or-not-to-shift
572
573 var len = keys.length;
574 var existingPathFragment = undefined;
575 var key = void 0;
576 var validateFunction = void 0;
577
578 if (typeof validateOperation == 'function') {
579 validateFunction = validateOperation;
580 } else {
581 validateFunction = validator;
582 }
583
584 while (true) {
585 key = keys[t];
586
587 if (key && key.indexOf('~') != -1) {
588 key = unescapePathComponent(key);
589 }
590
591 if (banPrototypeModifications && key == '__proto__') {
592 throw new TypeError('JSON-Patch: modifying `__proto__` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README');
593 }
594
595 if (validateOperation) {
596 if (existingPathFragment === undefined) {
597 if (obj[key] === undefined) {
598 existingPathFragment = keys.slice(0, t).join('/');
599 } else if (t == len - 1) {
600 existingPathFragment = operation.path;
601 }
602
603 if (existingPathFragment !== undefined) {
604 validateFunction(operation, 0, document, existingPathFragment);
605 }
606 }
607 }
608
609 t++;
610
611 if (Array.isArray(obj)) {
612 if (key === '-') {
613 key = obj.length;
614 } else {
615 if (validateOperation && !isInteger(key)) {
616 throw new JsonPatchError("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index", "OPERATION_PATH_ILLEGAL_ARRAY_INDEX", index, operation, document);
617 } // only parse key when it's an integer for `arr.prop` to work
618 else if (isInteger(key)) {
619 key = ~~key;
620 }
621 }
622
623 if (t >= len) {
624 if (validateOperation && operation.op === "add" && key > obj.length) {
625 throw new JsonPatchError("The specified index MUST NOT be greater than the number of elements in the array", "OPERATION_VALUE_OUT_OF_BOUNDS", index, operation, document);
626 }
627
628 var returnValue = arrOps[operation.op].call(operation, obj, key, document); // Apply patch
629
630 if (returnValue.test === false) {
631 throw new JsonPatchError("Test operation failed", 'TEST_OPERATION_FAILED', index, operation, document);
632 }
633
634 return returnValue;
635 }
636 } else {
637 if (t >= len) {
638 var returnValue = objOps[operation.op].call(operation, obj, key, document); // Apply patch
639
640 if (returnValue.test === false) {
641 throw new JsonPatchError("Test operation failed", 'TEST_OPERATION_FAILED', index, operation, document);
642 }
643
644 return returnValue;
645 }
646 }
647
648 obj = obj[key]; // If we have more keys in the path, but the next value isn't a non-null object,
649 // throw an OPERATION_PATH_UNRESOLVABLE error instead of iterating again.
650
651 if (validateOperation && t < len && (!obj || typeof obj !== "object")) {
652 throw new JsonPatchError('Cannot perform operation at the desired path', 'OPERATION_PATH_UNRESOLVABLE', index, operation, document);
653 }
654 }
655 }
656 }
657 /**
658 * Apply a full JSON Patch array on a JSON document.
659 * Returns the {newDocument, result} of the patch.
660 * It modifies the `document` object and `patch` - it gets the values by reference.
661 * If you would like to avoid touching your values, clone them:
662 * `jsonpatch.applyPatch(document, jsonpatch._deepClone(patch))`.
663 *
664 * @param document The document to patch
665 * @param patch The patch to apply
666 * @param validateOperation `false` is without validation, `true` to use default jsonpatch's validation, or you can pass a `validateOperation` callback to be used for validation.
667 * @param mutateDocument Whether to mutate the original document or clone it before applying
668 * @param banPrototypeModifications Whether to ban modifications to `__proto__`, defaults to `true`.
669 * @return An array of `{newDocument, result}` after the patch
670 */
671
672 function applyPatch(document, patch, validateOperation, mutateDocument, banPrototypeModifications) {
673 if (mutateDocument === void 0) {
674 mutateDocument = true;
675 }
676
677 if (banPrototypeModifications === void 0) {
678 banPrototypeModifications = true;
679 }
680
681 if (validateOperation) {
682 if (!Array.isArray(patch)) {
683 throw new JsonPatchError('Patch sequence must be an array', 'SEQUENCE_NOT_AN_ARRAY');
684 }
685 }
686
687 if (!mutateDocument) {
688 document = _deepClone(document);
689 }
690
691 var results = new Array(patch.length);
692
693 for (var i = 0, length_1 = patch.length; i < length_1; i++) {
694 // we don't need to pass mutateDocument argument because if it was true, we already deep cloned the object, we'll just pass `true`
695 results[i] = applyOperation(document, patch[i], validateOperation, true, banPrototypeModifications, i);
696 document = results[i].newDocument; // in case root was replaced
697 }
698
699 results.newDocument = document;
700 return results;
701 }
702 /**
703 * Apply a single JSON Patch Operation on a JSON document.
704 * Returns the updated document.
705 * Suitable as a reducer.
706 *
707 * @param document The document to patch
708 * @param operation The operation to apply
709 * @return The updated document
710 */
711
712 function applyReducer(document, operation, index) {
713 var operationResult = applyOperation(document, operation);
714
715 if (operationResult.test === false) {
716 // failed test
717 throw new JsonPatchError("Test operation failed", 'TEST_OPERATION_FAILED', index, operation, document);
718 }
719
720 return operationResult.newDocument;
721 }
722 /**
723 * Validates a single operation. Called from `jsonpatch.validate`. Throws `JsonPatchError` in case of an error.
724 * @param {object} operation - operation object (patch)
725 * @param {number} index - index of operation in the sequence
726 * @param {object} [document] - object where the operation is supposed to be applied
727 * @param {string} [existingPathFragment] - comes along with `document`
728 */
729
730 function validator(operation, index, document, existingPathFragment) {
731 if (typeof operation !== 'object' || operation === null || Array.isArray(operation)) {
732 throw new JsonPatchError('Operation is not an object', 'OPERATION_NOT_AN_OBJECT', index, operation, document);
733 } else if (!objOps[operation.op]) {
734 throw new JsonPatchError('Operation `op` property is not one of operations defined in RFC-6902', 'OPERATION_OP_INVALID', index, operation, document);
735 } else if (typeof operation.path !== 'string') {
736 throw new JsonPatchError('Operation `path` property is not a string', 'OPERATION_PATH_INVALID', index, operation, document);
737 } else if (operation.path.indexOf('/') !== 0 && operation.path.length > 0) {
738 // paths that aren't empty string should start with "/"
739 throw new JsonPatchError('Operation `path` property must start with "/"', 'OPERATION_PATH_INVALID', index, operation, document);
740 } else if ((operation.op === 'move' || operation.op === 'copy') && typeof operation.from !== 'string') {
741 throw new JsonPatchError('Operation `from` property is not present (applicable in `move` and `copy` operations)', 'OPERATION_FROM_REQUIRED', index, operation, document);
742 } else if ((operation.op === 'add' || operation.op === 'replace' || operation.op === 'test') && operation.value === undefined) {
743 throw new JsonPatchError('Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)', 'OPERATION_VALUE_REQUIRED', index, operation, document);
744 } else if ((operation.op === 'add' || operation.op === 'replace' || operation.op === 'test') && hasUndefined(operation.value)) {
745 throw new JsonPatchError('Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)', 'OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED', index, operation, document);
746 } else if (document) {
747 if (operation.op == "add") {
748 var pathLen = operation.path.split("/").length;
749 var existingPathLen = existingPathFragment.split("/").length;
750
751 if (pathLen !== existingPathLen + 1 && pathLen !== existingPathLen) {
752 throw new JsonPatchError('Cannot perform an `add` operation at the desired path', 'OPERATION_PATH_CANNOT_ADD', index, operation, document);
753 }
754 } else if (operation.op === 'replace' || operation.op === 'remove' || operation.op === '_get') {
755 if (operation.path !== existingPathFragment) {
756 throw new JsonPatchError('Cannot perform the operation at a path that does not exist', 'OPERATION_PATH_UNRESOLVABLE', index, operation, document);
757 }
758 } else if (operation.op === 'move' || operation.op === 'copy') {
759 var existingValue = {
760 op: "_get",
761 path: operation.from,
762 value: undefined
763 };
764 var error = validate([existingValue], document);
765
766 if (error && error.name === 'OPERATION_PATH_UNRESOLVABLE') {
767 throw new JsonPatchError('Cannot perform the operation from a path that does not exist', 'OPERATION_FROM_UNRESOLVABLE', index, operation, document);
768 }
769 }
770 }
771 }
772 /**
773 * Validates a sequence of operations. If `document` parameter is provided, the sequence is additionally validated against the object document.
774 * If error is encountered, returns a JsonPatchError object
775 * @param sequence
776 * @param document
777 * @returns {JsonPatchError|undefined}
778 */
779
780 function validate(sequence, document, externalValidator) {
781 try {
782 if (!Array.isArray(sequence)) {
783 throw new JsonPatchError('Patch sequence must be an array', 'SEQUENCE_NOT_AN_ARRAY');
784 }
785
786 if (document) {
787 //clone document and sequence so that we can safely try applying operations
788 applyPatch(_deepClone(document), _deepClone(sequence), externalValidator || true);
789 } else {
790 externalValidator = externalValidator || validator;
791
792 for (var i = 0; i < sequence.length; i++) {
793 externalValidator(sequence[i], i, document, undefined);
794 }
795 }
796 } catch (e) {
797 if (e instanceof JsonPatchError) {
798 return e;
799 } else {
800 throw e;
801 }
802 }
803 } // based on https://github.com/epoberezkin/fast-deep-equal
804 // MIT License
805 // Copyright (c) 2017 Evgeny Poberezkin
806 // Permission is hereby granted, free of charge, to any person obtaining a copy
807 // of this software and associated documentation files (the "Software"), to deal
808 // in the Software without restriction, including without limitation the rights
809 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
810 // copies of the Software, and to permit persons to whom the Software is
811 // furnished to do so, subject to the following conditions:
812 // The above copyright notice and this permission notice shall be included in all
813 // copies or substantial portions of the Software.
814 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
815 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
816 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
817 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
818 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
819 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
820 // SOFTWARE.
821
822 function _areEquals(a, b) {
823 if (a === b) return true;
824
825 if (a && b && typeof a == 'object' && typeof b == 'object') {
826 var arrA = Array.isArray(a),
827 arrB = Array.isArray(b),
828 i,
829 length,
830 key;
831
832 if (arrA && arrB) {
833 length = a.length;
834 if (length != b.length) return false;
835
836 for (i = length; i-- !== 0;) if (!_areEquals(a[i], b[i])) return false;
837
838 return true;
839 }
840
841 if (arrA != arrB) return false;
842 var keys = Object.keys(a);
843 length = keys.length;
844 if (length !== Object.keys(b).length) return false;
845
846 for (i = length; i-- !== 0;) if (!b.hasOwnProperty(keys[i])) return false;
847
848 for (i = length; i-- !== 0;) {
849 key = keys[i];
850 if (!_areEquals(a[key], b[key])) return false;
851 }
852
853 return true;
854 }
855
856 return a !== a && b !== b;
857 }
858
859 var core = /*#__PURE__*/Object.freeze({
860 __proto__: null,
861 JsonPatchError: JsonPatchError,
862 deepClone: deepClone,
863 getValueByPointer: getValueByPointer,
864 applyOperation: applyOperation,
865 applyPatch: applyPatch,
866 applyReducer: applyReducer,
867 validator: validator,
868 validate: validate,
869 _areEquals: _areEquals
870 });
871
872 /*!
873 * https://github.com/Starcounter-Jack/JSON-Patch
874 * (c) 2017 Joachim Wester
875 * MIT license
876 */
877 var beforeDict = new WeakMap();
878
879 var Mirror = function () {
880 function Mirror(obj) {
881 this.observers = new Map();
882 this.obj = obj;
883 }
884
885 return Mirror;
886 }();
887
888 var ObserverInfo = function () {
889 function ObserverInfo(callback, observer) {
890 this.callback = callback;
891 this.observer = observer;
892 }
893
894 return ObserverInfo;
895 }();
896
897 function getMirror(obj) {
898 return beforeDict.get(obj);
899 }
900
901 function getObserverFromMirror(mirror, callback) {
902 return mirror.observers.get(callback);
903 }
904
905 function removeObserverFromMirror(mirror, observer) {
906 mirror.observers.delete(observer.callback);
907 }
908 /**
909 * Detach an observer from an object
910 */
911
912
913 function unobserve(root, observer) {
914 observer.unobserve();
915 }
916 /**
917 * Observes changes made to an object, which can then be retrieved using generate
918 */
919
920 function observe(obj, callback) {
921 var patches = [];
922 var observer;
923 var mirror = getMirror(obj);
924
925 if (!mirror) {
926 mirror = new Mirror(obj);
927 beforeDict.set(obj, mirror);
928 } else {
929 var observerInfo = getObserverFromMirror(mirror, callback);
930 observer = observerInfo && observerInfo.observer;
931 }
932
933 if (observer) {
934 return observer;
935 }
936
937 observer = {};
938 mirror.value = _deepClone(obj);
939
940 if (callback) {
941 observer.callback = callback;
942 observer.next = null;
943
944 var dirtyCheck = function () {
945 generate(observer);
946 };
947
948 var fastCheck = function () {
949 clearTimeout(observer.next);
950 observer.next = setTimeout(dirtyCheck);
951 };
952
953 if (typeof window !== 'undefined') {
954 //not Node
955 window.addEventListener('mouseup', fastCheck);
956 window.addEventListener('keyup', fastCheck);
957 window.addEventListener('mousedown', fastCheck);
958 window.addEventListener('keydown', fastCheck);
959 window.addEventListener('change', fastCheck);
960 }
961 }
962
963 observer.patches = patches;
964 observer.object = obj;
965
966 observer.unobserve = function () {
967 generate(observer);
968 clearTimeout(observer.next);
969 removeObserverFromMirror(mirror, observer);
970
971 if (typeof window !== 'undefined') {
972 window.removeEventListener('mouseup', fastCheck);
973 window.removeEventListener('keyup', fastCheck);
974 window.removeEventListener('mousedown', fastCheck);
975 window.removeEventListener('keydown', fastCheck);
976 window.removeEventListener('change', fastCheck);
977 }
978 };
979
980 mirror.observers.set(callback, new ObserverInfo(callback, observer));
981 return observer;
982 }
983 /**
984 * Generate an array of patches from an observer
985 */
986
987 function generate(observer, invertible) {
988 if (invertible === void 0) {
989 invertible = false;
990 }
991
992 var mirror = beforeDict.get(observer.object);
993
994 _generate(mirror.value, observer.object, observer.patches, "", invertible);
995
996 if (observer.patches.length) {
997 applyPatch(mirror.value, observer.patches);
998 }
999
1000 var temp = observer.patches;
1001
1002 if (temp.length > 0) {
1003 observer.patches = [];
1004
1005 if (observer.callback) {
1006 observer.callback(temp);
1007 }
1008 }
1009
1010 return temp;
1011 } // Dirty check if obj is different from mirror, generate patches and update mirror
1012
1013 function _generate(mirror, obj, patches, path, invertible) {
1014 if (obj === mirror) {
1015 return;
1016 }
1017
1018 if (typeof obj.toJSON === "function") {
1019 obj = obj.toJSON();
1020 }
1021
1022 var newKeys = _objectKeys(obj);
1023
1024 var oldKeys = _objectKeys(mirror);
1025 var deleted = false; //if ever "move" operation is implemented here, make sure this test runs OK: "should not generate the same patch twice (move)"
1026
1027 for (var t = oldKeys.length - 1; t >= 0; t--) {
1028 var key = oldKeys[t];
1029 var oldVal = mirror[key];
1030
1031 if (hasOwnProperty(obj, key) && !(obj[key] === undefined && oldVal !== undefined && Array.isArray(obj) === false)) {
1032 var newVal = obj[key];
1033
1034 if (typeof oldVal == "object" && oldVal != null && typeof newVal == "object" && newVal != null && Array.isArray(oldVal) === Array.isArray(newVal)) {
1035 _generate(oldVal, newVal, patches, path + "/" + escapePathComponent(key), invertible);
1036 } else {
1037 if (oldVal !== newVal) {
1038
1039 if (invertible) {
1040 patches.push({
1041 op: "test",
1042 path: path + "/" + escapePathComponent(key),
1043 value: _deepClone(oldVal)
1044 });
1045 }
1046
1047 patches.push({
1048 op: "replace",
1049 path: path + "/" + escapePathComponent(key),
1050 value: _deepClone(newVal)
1051 });
1052 }
1053 }
1054 } else if (Array.isArray(mirror) === Array.isArray(obj)) {
1055 if (invertible) {
1056 patches.push({
1057 op: "test",
1058 path: path + "/" + escapePathComponent(key),
1059 value: _deepClone(oldVal)
1060 });
1061 }
1062
1063 patches.push({
1064 op: "remove",
1065 path: path + "/" + escapePathComponent(key)
1066 });
1067 deleted = true; // property has been deleted
1068 } else {
1069 if (invertible) {
1070 patches.push({
1071 op: "test",
1072 path: path,
1073 value: mirror
1074 });
1075 }
1076
1077 patches.push({
1078 op: "replace",
1079 path: path,
1080 value: obj
1081 });
1082 }
1083 }
1084
1085 if (!deleted && newKeys.length == oldKeys.length) {
1086 return;
1087 }
1088
1089 for (var t = 0; t < newKeys.length; t++) {
1090 var key = newKeys[t];
1091
1092 if (!hasOwnProperty(mirror, key) && obj[key] !== undefined) {
1093 patches.push({
1094 op: "add",
1095 path: path + "/" + escapePathComponent(key),
1096 value: _deepClone(obj[key])
1097 });
1098 }
1099 }
1100 }
1101 /**
1102 * Create an array of patches from the differences in two objects
1103 */
1104
1105
1106 function compare$b(tree1, tree2, invertible) {
1107 if (invertible === void 0) {
1108 invertible = false;
1109 }
1110
1111 var patches = [];
1112
1113 _generate(tree1, tree2, patches, '', invertible);
1114
1115 return patches;
1116 }
1117
1118 var duplex = /*#__PURE__*/Object.freeze({
1119 __proto__: null,
1120 unobserve: unobserve,
1121 observe: observe,
1122 generate: generate,
1123 compare: compare$b
1124 });
1125
1126 Object.assign({}, core, duplex, {
1127 JsonPatchError: PatchError,
1128 deepClone: _deepClone,
1129 escapePathComponent,
1130 unescapePathComponent
1131 });
1132
1133 // working on the output of `JSON.stringify` we know that only valid strings
1134 // are present (unless the user supplied a weird `options.indent` but in
1135 // that case we don’t care since the output would be invalid anyway).
1136
1137
1138 var stringOrChar = /("(?:[^\\"]|\\.)*")|[:,]/g;
1139
1140 var jsonStringifyPrettyCompact = function stringify(passedObj, options) {
1141 var indent, maxLength, replacer;
1142 options = options || {};
1143 indent = JSON.stringify([1], undefined, options.indent === undefined ? 2 : options.indent).slice(2, -3);
1144 maxLength = indent === "" ? Infinity : options.maxLength === undefined ? 80 : options.maxLength;
1145 replacer = options.replacer;
1146 return function _stringify(obj, currentIndent, reserved) {
1147 // prettier-ignore
1148 var end, index, items, key, keyPart, keys, length, nextIndent, prettified, start, string, value;
1149
1150 if (obj && typeof obj.toJSON === "function") {
1151 obj = obj.toJSON();
1152 }
1153
1154 string = JSON.stringify(obj, replacer);
1155
1156 if (string === undefined) {
1157 return string;
1158 }
1159
1160 length = maxLength - currentIndent.length - reserved;
1161
1162 if (string.length <= length) {
1163 prettified = string.replace(stringOrChar, function (match, stringLiteral) {
1164 return stringLiteral || match + " ";
1165 });
1166
1167 if (prettified.length <= length) {
1168 return prettified;
1169 }
1170 }
1171
1172 if (replacer != null) {
1173 obj = JSON.parse(string);
1174 replacer = undefined;
1175 }
1176
1177 if (typeof obj === "object" && obj !== null) {
1178 nextIndent = currentIndent + indent;
1179 items = [];
1180 index = 0;
1181
1182 if (Array.isArray(obj)) {
1183 start = "[";
1184 end = "]";
1185 length = obj.length;
1186
1187 for (; index < length; index++) {
1188 items.push(_stringify(obj[index], nextIndent, index === length - 1 ? 0 : 1) || "null");
1189 }
1190 } else {
1191 start = "{";
1192 end = "}";
1193 keys = Object.keys(obj);
1194 length = keys.length;
1195
1196 for (; index < length; index++) {
1197 key = keys[index];
1198 keyPart = JSON.stringify(key) + ": ";
1199 value = _stringify(obj[key], nextIndent, keyPart.length + (index === length - 1 ? 0 : 1));
1200
1201 if (value !== undefined) {
1202 items.push(keyPart + value);
1203 }
1204 }
1205 }
1206
1207 if (items.length > 0) {
1208 return [start, indent + items.join(",\n" + nextIndent), end].join("\n" + currentIndent);
1209 }
1210 }
1211
1212 return string;
1213 }(passedObj, "", 0);
1214 };
1215
1216 var re$5 = {exports: {}};
1217
1218 // Not necessarily the package version of this code.
1219
1220 const SEMVER_SPEC_VERSION = '2.0.0';
1221 const MAX_LENGTH$2 = 256;
1222 const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER ||
1223 /* istanbul ignore next */
1224 9007199254740991; // Max safe segment length for coercion.
1225
1226 const MAX_SAFE_COMPONENT_LENGTH = 16;
1227 var constants = {
1228 SEMVER_SPEC_VERSION,
1229 MAX_LENGTH: MAX_LENGTH$2,
1230 MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
1231 MAX_SAFE_COMPONENT_LENGTH
1232 };
1233
1234 const debug$3 = typeof process === 'object' && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error('SEMVER', ...args) : () => {};
1235 var debug_1 = debug$3;
1236
1237 (function (module, exports) {
1238 const {
1239 MAX_SAFE_COMPONENT_LENGTH
1240 } = constants;
1241 const debug = debug_1;
1242 exports = module.exports = {}; // The actual regexps go on exports.re
1243
1244 const re = exports.re = [];
1245 const src = exports.src = [];
1246 const t = exports.t = {};
1247 let R = 0;
1248
1249 const createToken = (name, value, isGlobal) => {
1250 const index = R++;
1251 debug(index, value);
1252 t[name] = index;
1253 src[index] = value;
1254 re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
1255 }; // The following Regular Expressions can be used for tokenizing,
1256 // validating, and parsing SemVer version strings.
1257 // ## Numeric Identifier
1258 // A single `0`, or a non-zero digit followed by zero or more digits.
1259
1260
1261 createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
1262 createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+'); // ## Non-numeric Identifier
1263 // Zero or more digits, followed by a letter or hyphen, and then zero or
1264 // more letters, digits, or hyphens.
1265
1266 createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*'); // ## Main Version
1267 // Three dot-separated numeric identifiers.
1268
1269 createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})`);
1270 createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})`); // ## Pre-release Version Identifier
1271 // A numeric identifier, or a non-numeric identifier.
1272
1273 createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]}|${src[t.NONNUMERICIDENTIFIER]})`);
1274 createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]}|${src[t.NONNUMERICIDENTIFIER]})`); // ## Pre-release Version
1275 // Hyphen, followed by one or more dot-separated pre-release version
1276 // identifiers.
1277
1278 createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
1279 createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`); // ## Build Metadata Identifier
1280 // Any combination of digits, letters, or hyphens.
1281
1282 createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+'); // ## Build Metadata
1283 // Plus sign, followed by one or more period-separated build metadata
1284 // identifiers.
1285
1286 createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`); // ## Full Version String
1287 // A main version, followed optionally by a pre-release version and
1288 // build metadata.
1289 // Note that the only major, minor, patch, and pre-release sections of
1290 // the version string are capturing groups. The build metadata is not a
1291 // capturing group, because it should not ever be used in version
1292 // comparison.
1293
1294 createToken('FULLPLAIN', `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
1295 createToken('FULL', `^${src[t.FULLPLAIN]}$`); // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
1296 // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
1297 // common in the npm registry.
1298
1299 createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
1300 createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
1301 createToken('GTLT', '((?:<|>)?=?)'); // Something like "2.*" or "1.2.x".
1302 // Note that "x.x" is a valid xRange identifer, meaning "any version"
1303 // Only the first item is strictly required.
1304
1305 createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
1306 createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
1307 createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?` + `)?)?`);
1308 createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?` + `)?)?`);
1309 createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
1310 createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`); // Coercion.
1311 // Extract anything that could conceivably be a part of a valid semver
1312
1313 createToken('COERCE', `${'(^|[^\\d])' + '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + `(?:$|[^\\d])`);
1314 createToken('COERCERTL', src[t.COERCE], true); // Tilde ranges.
1315 // Meaning is "reasonably at or greater than"
1316
1317 createToken('LONETILDE', '(?:~>?)');
1318 createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
1319 exports.tildeTrimReplace = '$1~';
1320 createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
1321 createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`); // Caret ranges.
1322 // Meaning is "at least and backwards compatible with"
1323
1324 createToken('LONECARET', '(?:\\^)');
1325 createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
1326 exports.caretTrimReplace = '$1^';
1327 createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
1328 createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`); // A simple gt/lt/eq thing, or just "" to indicate "any version"
1329
1330 createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
1331 createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`); // An expression to strip any whitespace between the gtlt and the thing
1332 // it modifies, so that `> 1.2.3` ==> `>1.2.3`
1333
1334 createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
1335 exports.comparatorTrimReplace = '$1$2$3'; // Something like `1.2.3 - 1.2.4`
1336 // Note that these all use the loose form, because they'll be
1337 // checked against either the strict or loose comparator form
1338 // later.
1339
1340 createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAIN]})` + `\\s*$`);
1341 createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAINLOOSE]})` + `\\s*$`); // Star ranges basically just allow anything at all.
1342
1343 createToken('STAR', '(<|>)?=?\\s*\\*'); // >=0.0.0 is like a star
1344
1345 createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$');
1346 createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$');
1347 })(re$5, re$5.exports);
1348
1349 // obj with keys in a consistent order.
1350
1351 const opts = ['includePrerelease', 'loose', 'rtl'];
1352
1353 const parseOptions$4 = options => !options ? {} : typeof options !== 'object' ? {
1354 loose: true
1355 } : opts.filter(k => options[k]).reduce((options, k) => {
1356 options[k] = true;
1357 return options;
1358 }, {});
1359
1360 var parseOptions_1 = parseOptions$4;
1361
1362 const numeric = /^[0-9]+$/;
1363
1364 const compareIdentifiers$1 = (a, b) => {
1365 const anum = numeric.test(a);
1366 const bnum = numeric.test(b);
1367
1368 if (anum && bnum) {
1369 a = +a;
1370 b = +b;
1371 }
1372
1373 return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
1374 };
1375
1376 const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
1377
1378 var identifiers = {
1379 compareIdentifiers: compareIdentifiers$1,
1380 rcompareIdentifiers
1381 };
1382
1383 const debug$2 = debug_1;
1384 const {
1385 MAX_LENGTH: MAX_LENGTH$1,
1386 MAX_SAFE_INTEGER
1387 } = constants;
1388 const {
1389 re: re$4,
1390 t: t$4
1391 } = re$5.exports;
1392 const parseOptions$3 = parseOptions_1;
1393 const {
1394 compareIdentifiers
1395 } = identifiers;
1396
1397 class SemVer$e {
1398 constructor(version, options) {
1399 options = parseOptions$3(options);
1400
1401 if (version instanceof SemVer$e) {
1402 if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
1403 return version;
1404 } else {
1405 version = version.version;
1406 }
1407 } else if (typeof version !== 'string') {
1408 throw new TypeError(`Invalid Version: ${version}`);
1409 }
1410
1411 if (version.length > MAX_LENGTH$1) {
1412 throw new TypeError(`version is longer than ${MAX_LENGTH$1} characters`);
1413 }
1414
1415 debug$2('SemVer', version, options);
1416 this.options = options;
1417 this.loose = !!options.loose; // this isn't actually relevant for versions, but keep it so that we
1418 // don't run into trouble passing this.options around.
1419
1420 this.includePrerelease = !!options.includePrerelease;
1421 const m = version.trim().match(options.loose ? re$4[t$4.LOOSE] : re$4[t$4.FULL]);
1422
1423 if (!m) {
1424 throw new TypeError(`Invalid Version: ${version}`);
1425 }
1426
1427 this.raw = version; // these are actually numbers
1428
1429 this.major = +m[1];
1430 this.minor = +m[2];
1431 this.patch = +m[3];
1432
1433 if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
1434 throw new TypeError('Invalid major version');
1435 }
1436
1437 if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
1438 throw new TypeError('Invalid minor version');
1439 }
1440
1441 if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
1442 throw new TypeError('Invalid patch version');
1443 } // numberify any prerelease numeric ids
1444
1445
1446 if (!m[4]) {
1447 this.prerelease = [];
1448 } else {
1449 this.prerelease = m[4].split('.').map(id => {
1450 if (/^[0-9]+$/.test(id)) {
1451 const num = +id;
1452
1453 if (num >= 0 && num < MAX_SAFE_INTEGER) {
1454 return num;
1455 }
1456 }
1457
1458 return id;
1459 });
1460 }
1461
1462 this.build = m[5] ? m[5].split('.') : [];
1463 this.format();
1464 }
1465
1466 format() {
1467 this.version = `${this.major}.${this.minor}.${this.patch}`;
1468
1469 if (this.prerelease.length) {
1470 this.version += `-${this.prerelease.join('.')}`;
1471 }
1472
1473 return this.version;
1474 }
1475
1476 toString() {
1477 return this.version;
1478 }
1479
1480 compare(other) {
1481 debug$2('SemVer.compare', this.version, this.options, other);
1482
1483 if (!(other instanceof SemVer$e)) {
1484 if (typeof other === 'string' && other === this.version) {
1485 return 0;
1486 }
1487
1488 other = new SemVer$e(other, this.options);
1489 }
1490
1491 if (other.version === this.version) {
1492 return 0;
1493 }
1494
1495 return this.compareMain(other) || this.comparePre(other);
1496 }
1497
1498 compareMain(other) {
1499 if (!(other instanceof SemVer$e)) {
1500 other = new SemVer$e(other, this.options);
1501 }
1502
1503 return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
1504 }
1505
1506 comparePre(other) {
1507 if (!(other instanceof SemVer$e)) {
1508 other = new SemVer$e(other, this.options);
1509 } // NOT having a prerelease is > having one
1510
1511
1512 if (this.prerelease.length && !other.prerelease.length) {
1513 return -1;
1514 } else if (!this.prerelease.length && other.prerelease.length) {
1515 return 1;
1516 } else if (!this.prerelease.length && !other.prerelease.length) {
1517 return 0;
1518 }
1519
1520 let i = 0;
1521
1522 do {
1523 const a = this.prerelease[i];
1524 const b = other.prerelease[i];
1525 debug$2('prerelease compare', i, a, b);
1526
1527 if (a === undefined && b === undefined) {
1528 return 0;
1529 } else if (b === undefined) {
1530 return 1;
1531 } else if (a === undefined) {
1532 return -1;
1533 } else if (a === b) {
1534 continue;
1535 } else {
1536 return compareIdentifiers(a, b);
1537 }
1538 } while (++i);
1539 }
1540
1541 compareBuild(other) {
1542 if (!(other instanceof SemVer$e)) {
1543 other = new SemVer$e(other, this.options);
1544 }
1545
1546 let i = 0;
1547
1548 do {
1549 const a = this.build[i];
1550 const b = other.build[i];
1551 debug$2('prerelease compare', i, a, b);
1552
1553 if (a === undefined && b === undefined) {
1554 return 0;
1555 } else if (b === undefined) {
1556 return 1;
1557 } else if (a === undefined) {
1558 return -1;
1559 } else if (a === b) {
1560 continue;
1561 } else {
1562 return compareIdentifiers(a, b);
1563 }
1564 } while (++i);
1565 } // preminor will bump the version up to the next minor release, and immediately
1566 // down to pre-release. premajor and prepatch work the same way.
1567
1568
1569 inc(release, identifier) {
1570 switch (release) {
1571 case 'premajor':
1572 this.prerelease.length = 0;
1573 this.patch = 0;
1574 this.minor = 0;
1575 this.major++;
1576 this.inc('pre', identifier);
1577 break;
1578
1579 case 'preminor':
1580 this.prerelease.length = 0;
1581 this.patch = 0;
1582 this.minor++;
1583 this.inc('pre', identifier);
1584 break;
1585
1586 case 'prepatch':
1587 // If this is already a prerelease, it will bump to the next version
1588 // drop any prereleases that might already exist, since they are not
1589 // relevant at this point.
1590 this.prerelease.length = 0;
1591 this.inc('patch', identifier);
1592 this.inc('pre', identifier);
1593 break;
1594 // If the input is a non-prerelease version, this acts the same as
1595 // prepatch.
1596
1597 case 'prerelease':
1598 if (this.prerelease.length === 0) {
1599 this.inc('patch', identifier);
1600 }
1601
1602 this.inc('pre', identifier);
1603 break;
1604
1605 case 'major':
1606 // If this is a pre-major version, bump up to the same major version.
1607 // Otherwise increment major.
1608 // 1.0.0-5 bumps to 1.0.0
1609 // 1.1.0 bumps to 2.0.0
1610 if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
1611 this.major++;
1612 }
1613
1614 this.minor = 0;
1615 this.patch = 0;
1616 this.prerelease = [];
1617 break;
1618
1619 case 'minor':
1620 // If this is a pre-minor version, bump up to the same minor version.
1621 // Otherwise increment minor.
1622 // 1.2.0-5 bumps to 1.2.0
1623 // 1.2.1 bumps to 1.3.0
1624 if (this.patch !== 0 || this.prerelease.length === 0) {
1625 this.minor++;
1626 }
1627
1628 this.patch = 0;
1629 this.prerelease = [];
1630 break;
1631
1632 case 'patch':
1633 // If this is not a pre-release version, it will increment the patch.
1634 // If it is a pre-release it will bump up to the same patch version.
1635 // 1.2.0-5 patches to 1.2.0
1636 // 1.2.0 patches to 1.2.1
1637 if (this.prerelease.length === 0) {
1638 this.patch++;
1639 }
1640
1641 this.prerelease = [];
1642 break;
1643 // This probably shouldn't be used publicly.
1644 // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
1645
1646 case 'pre':
1647 if (this.prerelease.length === 0) {
1648 this.prerelease = [0];
1649 } else {
1650 let i = this.prerelease.length;
1651
1652 while (--i >= 0) {
1653 if (typeof this.prerelease[i] === 'number') {
1654 this.prerelease[i]++;
1655 i = -2;
1656 }
1657 }
1658
1659 if (i === -1) {
1660 // didn't increment anything
1661 this.prerelease.push(0);
1662 }
1663 }
1664
1665 if (identifier) {
1666 // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
1667 // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
1668 if (this.prerelease[0] === identifier) {
1669 if (isNaN(this.prerelease[1])) {
1670 this.prerelease = [identifier, 0];
1671 }
1672 } else {
1673 this.prerelease = [identifier, 0];
1674 }
1675 }
1676
1677 break;
1678
1679 default:
1680 throw new Error(`invalid increment argument: ${release}`);
1681 }
1682
1683 this.format();
1684 this.raw = this.version;
1685 return this;
1686 }
1687
1688 }
1689
1690 var semver$1 = SemVer$e;
1691
1692 const {
1693 MAX_LENGTH
1694 } = constants;
1695 const {
1696 re: re$3,
1697 t: t$3
1698 } = re$5.exports;
1699 const SemVer$d = semver$1;
1700 const parseOptions$2 = parseOptions_1;
1701
1702 const parse$5 = (version, options) => {
1703 options = parseOptions$2(options);
1704
1705 if (version instanceof SemVer$d) {
1706 return version;
1707 }
1708
1709 if (typeof version !== 'string') {
1710 return null;
1711 }
1712
1713 if (version.length > MAX_LENGTH) {
1714 return null;
1715 }
1716
1717 const r = options.loose ? re$3[t$3.LOOSE] : re$3[t$3.FULL];
1718
1719 if (!r.test(version)) {
1720 return null;
1721 }
1722
1723 try {
1724 return new SemVer$d(version, options);
1725 } catch (er) {
1726 return null;
1727 }
1728 };
1729
1730 var parse_1 = parse$5;
1731
1732 const parse$4 = parse_1;
1733
1734 const valid$1 = (version, options) => {
1735 const v = parse$4(version, options);
1736 return v ? v.version : null;
1737 };
1738
1739 var valid_1 = valid$1;
1740
1741 const parse$3 = parse_1;
1742
1743 const clean = (version, options) => {
1744 const s = parse$3(version.trim().replace(/^[=v]+/, ''), options);
1745 return s ? s.version : null;
1746 };
1747
1748 var clean_1 = clean;
1749
1750 const SemVer$c = semver$1;
1751
1752 const inc = (version, release, options, identifier) => {
1753 if (typeof options === 'string') {
1754 identifier = options;
1755 options = undefined;
1756 }
1757
1758 try {
1759 return new SemVer$c(version, options).inc(release, identifier).version;
1760 } catch (er) {
1761 return null;
1762 }
1763 };
1764
1765 var inc_1 = inc;
1766
1767 const SemVer$b = semver$1;
1768
1769 const compare$a = (a, b, loose) => new SemVer$b(a, loose).compare(new SemVer$b(b, loose));
1770
1771 var compare_1 = compare$a;
1772
1773 const compare$9 = compare_1;
1774
1775 const eq$2 = (a, b, loose) => compare$9(a, b, loose) === 0;
1776
1777 var eq_1 = eq$2;
1778
1779 const parse$2 = parse_1;
1780 const eq$1 = eq_1;
1781
1782 const diff = (version1, version2) => {
1783 if (eq$1(version1, version2)) {
1784 return null;
1785 } else {
1786 const v1 = parse$2(version1);
1787 const v2 = parse$2(version2);
1788 const hasPre = v1.prerelease.length || v2.prerelease.length;
1789 const prefix = hasPre ? 'pre' : '';
1790 const defaultResult = hasPre ? 'prerelease' : '';
1791
1792 for (const key in v1) {
1793 if (key === 'major' || key === 'minor' || key === 'patch') {
1794 if (v1[key] !== v2[key]) {
1795 return prefix + key;
1796 }
1797 }
1798 }
1799
1800 return defaultResult; // may be undefined
1801 }
1802 };
1803
1804 var diff_1 = diff;
1805
1806 const SemVer$a = semver$1;
1807
1808 const major = (a, loose) => new SemVer$a(a, loose).major;
1809
1810 var major_1 = major;
1811
1812 const SemVer$9 = semver$1;
1813
1814 const minor = (a, loose) => new SemVer$9(a, loose).minor;
1815
1816 var minor_1 = minor;
1817
1818 const SemVer$8 = semver$1;
1819
1820 const patch = (a, loose) => new SemVer$8(a, loose).patch;
1821
1822 var patch_1 = patch;
1823
1824 const parse$1 = parse_1;
1825
1826 const prerelease = (version, options) => {
1827 const parsed = parse$1(version, options);
1828 return parsed && parsed.prerelease.length ? parsed.prerelease : null;
1829 };
1830
1831 var prerelease_1 = prerelease;
1832
1833 const compare$8 = compare_1;
1834
1835 const rcompare = (a, b, loose) => compare$8(b, a, loose);
1836
1837 var rcompare_1 = rcompare;
1838
1839 const compare$7 = compare_1;
1840
1841 const compareLoose = (a, b) => compare$7(a, b, true);
1842
1843 var compareLoose_1 = compareLoose;
1844
1845 const SemVer$7 = semver$1;
1846
1847 const compareBuild$2 = (a, b, loose) => {
1848 const versionA = new SemVer$7(a, loose);
1849 const versionB = new SemVer$7(b, loose);
1850 return versionA.compare(versionB) || versionA.compareBuild(versionB);
1851 };
1852
1853 var compareBuild_1 = compareBuild$2;
1854
1855 const compareBuild$1 = compareBuild_1;
1856
1857 const sort = (list, loose) => list.sort((a, b) => compareBuild$1(a, b, loose));
1858
1859 var sort_1 = sort;
1860
1861 const compareBuild = compareBuild_1;
1862
1863 const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
1864
1865 var rsort_1 = rsort;
1866
1867 const compare$6 = compare_1;
1868
1869 const gt$3 = (a, b, loose) => compare$6(a, b, loose) > 0;
1870
1871 var gt_1 = gt$3;
1872
1873 const compare$5 = compare_1;
1874
1875 const lt$2 = (a, b, loose) => compare$5(a, b, loose) < 0;
1876
1877 var lt_1 = lt$2;
1878
1879 const compare$4 = compare_1;
1880
1881 const neq$1 = (a, b, loose) => compare$4(a, b, loose) !== 0;
1882
1883 var neq_1 = neq$1;
1884
1885 const compare$3 = compare_1;
1886
1887 const gte$2 = (a, b, loose) => compare$3(a, b, loose) >= 0;
1888
1889 var gte_1 = gte$2;
1890
1891 const compare$2 = compare_1;
1892
1893 const lte$2 = (a, b, loose) => compare$2(a, b, loose) <= 0;
1894
1895 var lte_1 = lte$2;
1896
1897 const eq = eq_1;
1898 const neq = neq_1;
1899 const gt$2 = gt_1;
1900 const gte$1 = gte_1;
1901 const lt$1 = lt_1;
1902 const lte$1 = lte_1;
1903
1904 const cmp$1 = (a, op, b, loose) => {
1905 switch (op) {
1906 case '===':
1907 if (typeof a === 'object') a = a.version;
1908 if (typeof b === 'object') b = b.version;
1909 return a === b;
1910
1911 case '!==':
1912 if (typeof a === 'object') a = a.version;
1913 if (typeof b === 'object') b = b.version;
1914 return a !== b;
1915
1916 case '':
1917 case '=':
1918 case '==':
1919 return eq(a, b, loose);
1920
1921 case '!=':
1922 return neq(a, b, loose);
1923
1924 case '>':
1925 return gt$2(a, b, loose);
1926
1927 case '>=':
1928 return gte$1(a, b, loose);
1929
1930 case '<':
1931 return lt$1(a, b, loose);
1932
1933 case '<=':
1934 return lte$1(a, b, loose);
1935
1936 default:
1937 throw new TypeError(`Invalid operator: ${op}`);
1938 }
1939 };
1940
1941 var cmp_1 = cmp$1;
1942
1943 const SemVer$6 = semver$1;
1944 const parse = parse_1;
1945 const {
1946 re: re$2,
1947 t: t$2
1948 } = re$5.exports;
1949
1950 const coerce = (version, options) => {
1951 if (version instanceof SemVer$6) {
1952 return version;
1953 }
1954
1955 if (typeof version === 'number') {
1956 version = String(version);
1957 }
1958
1959 if (typeof version !== 'string') {
1960 return null;
1961 }
1962
1963 options = options || {};
1964 let match = null;
1965
1966 if (!options.rtl) {
1967 match = version.match(re$2[t$2.COERCE]);
1968 } else {
1969 // Find the right-most coercible string that does not share
1970 // a terminus with a more left-ward coercible string.
1971 // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
1972 //
1973 // Walk through the string checking with a /g regexp
1974 // Manually set the index so as to pick up overlapping matches.
1975 // Stop when we get a match that ends at the string end, since no
1976 // coercible string can be more right-ward without the same terminus.
1977 let next;
1978
1979 while ((next = re$2[t$2.COERCERTL].exec(version)) && (!match || match.index + match[0].length !== version.length)) {
1980 if (!match || next.index + next[0].length !== match.index + match[0].length) {
1981 match = next;
1982 }
1983
1984 re$2[t$2.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
1985 } // leave it in a clean state
1986
1987
1988 re$2[t$2.COERCERTL].lastIndex = -1;
1989 }
1990
1991 if (match === null) return null;
1992 return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options);
1993 };
1994
1995 var coerce_1 = coerce;
1996
1997 var iterator = function (Yallist) {
1998 Yallist.prototype[Symbol.iterator] = function* () {
1999 for (let walker = this.head; walker; walker = walker.next) {
2000 yield walker.value;
2001 }
2002 };
2003 };
2004
2005 var yallist = Yallist$1;
2006 Yallist$1.Node = Node;
2007 Yallist$1.create = Yallist$1;
2008
2009 function Yallist$1(list) {
2010 var self = this;
2011
2012 if (!(self instanceof Yallist$1)) {
2013 self = new Yallist$1();
2014 }
2015
2016 self.tail = null;
2017 self.head = null;
2018 self.length = 0;
2019
2020 if (list && typeof list.forEach === 'function') {
2021 list.forEach(function (item) {
2022 self.push(item);
2023 });
2024 } else if (arguments.length > 0) {
2025 for (var i = 0, l = arguments.length; i < l; i++) {
2026 self.push(arguments[i]);
2027 }
2028 }
2029
2030 return self;
2031 }
2032
2033 Yallist$1.prototype.removeNode = function (node) {
2034 if (node.list !== this) {
2035 throw new Error('removing node which does not belong to this list');
2036 }
2037
2038 var next = node.next;
2039 var prev = node.prev;
2040
2041 if (next) {
2042 next.prev = prev;
2043 }
2044
2045 if (prev) {
2046 prev.next = next;
2047 }
2048
2049 if (node === this.head) {
2050 this.head = next;
2051 }
2052
2053 if (node === this.tail) {
2054 this.tail = prev;
2055 }
2056
2057 node.list.length--;
2058 node.next = null;
2059 node.prev = null;
2060 node.list = null;
2061 return next;
2062 };
2063
2064 Yallist$1.prototype.unshiftNode = function (node) {
2065 if (node === this.head) {
2066 return;
2067 }
2068
2069 if (node.list) {
2070 node.list.removeNode(node);
2071 }
2072
2073 var head = this.head;
2074 node.list = this;
2075 node.next = head;
2076
2077 if (head) {
2078 head.prev = node;
2079 }
2080
2081 this.head = node;
2082
2083 if (!this.tail) {
2084 this.tail = node;
2085 }
2086
2087 this.length++;
2088 };
2089
2090 Yallist$1.prototype.pushNode = function (node) {
2091 if (node === this.tail) {
2092 return;
2093 }
2094
2095 if (node.list) {
2096 node.list.removeNode(node);
2097 }
2098
2099 var tail = this.tail;
2100 node.list = this;
2101 node.prev = tail;
2102
2103 if (tail) {
2104 tail.next = node;
2105 }
2106
2107 this.tail = node;
2108
2109 if (!this.head) {
2110 this.head = node;
2111 }
2112
2113 this.length++;
2114 };
2115
2116 Yallist$1.prototype.push = function () {
2117 for (var i = 0, l = arguments.length; i < l; i++) {
2118 push(this, arguments[i]);
2119 }
2120
2121 return this.length;
2122 };
2123
2124 Yallist$1.prototype.unshift = function () {
2125 for (var i = 0, l = arguments.length; i < l; i++) {
2126 unshift(this, arguments[i]);
2127 }
2128
2129 return this.length;
2130 };
2131
2132 Yallist$1.prototype.pop = function () {
2133 if (!this.tail) {
2134 return undefined;
2135 }
2136
2137 var res = this.tail.value;
2138 this.tail = this.tail.prev;
2139
2140 if (this.tail) {
2141 this.tail.next = null;
2142 } else {
2143 this.head = null;
2144 }
2145
2146 this.length--;
2147 return res;
2148 };
2149
2150 Yallist$1.prototype.shift = function () {
2151 if (!this.head) {
2152 return undefined;
2153 }
2154
2155 var res = this.head.value;
2156 this.head = this.head.next;
2157
2158 if (this.head) {
2159 this.head.prev = null;
2160 } else {
2161 this.tail = null;
2162 }
2163
2164 this.length--;
2165 return res;
2166 };
2167
2168 Yallist$1.prototype.forEach = function (fn, thisp) {
2169 thisp = thisp || this;
2170
2171 for (var walker = this.head, i = 0; walker !== null; i++) {
2172 fn.call(thisp, walker.value, i, this);
2173 walker = walker.next;
2174 }
2175 };
2176
2177 Yallist$1.prototype.forEachReverse = function (fn, thisp) {
2178 thisp = thisp || this;
2179
2180 for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
2181 fn.call(thisp, walker.value, i, this);
2182 walker = walker.prev;
2183 }
2184 };
2185
2186 Yallist$1.prototype.get = function (n) {
2187 for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
2188 // abort out of the list early if we hit a cycle
2189 walker = walker.next;
2190 }
2191
2192 if (i === n && walker !== null) {
2193 return walker.value;
2194 }
2195 };
2196
2197 Yallist$1.prototype.getReverse = function (n) {
2198 for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
2199 // abort out of the list early if we hit a cycle
2200 walker = walker.prev;
2201 }
2202
2203 if (i === n && walker !== null) {
2204 return walker.value;
2205 }
2206 };
2207
2208 Yallist$1.prototype.map = function (fn, thisp) {
2209 thisp = thisp || this;
2210 var res = new Yallist$1();
2211
2212 for (var walker = this.head; walker !== null;) {
2213 res.push(fn.call(thisp, walker.value, this));
2214 walker = walker.next;
2215 }
2216
2217 return res;
2218 };
2219
2220 Yallist$1.prototype.mapReverse = function (fn, thisp) {
2221 thisp = thisp || this;
2222 var res = new Yallist$1();
2223
2224 for (var walker = this.tail; walker !== null;) {
2225 res.push(fn.call(thisp, walker.value, this));
2226 walker = walker.prev;
2227 }
2228
2229 return res;
2230 };
2231
2232 Yallist$1.prototype.reduce = function (fn, initial) {
2233 var acc;
2234 var walker = this.head;
2235
2236 if (arguments.length > 1) {
2237 acc = initial;
2238 } else if (this.head) {
2239 walker = this.head.next;
2240 acc = this.head.value;
2241 } else {
2242 throw new TypeError('Reduce of empty list with no initial value');
2243 }
2244
2245 for (var i = 0; walker !== null; i++) {
2246 acc = fn(acc, walker.value, i);
2247 walker = walker.next;
2248 }
2249
2250 return acc;
2251 };
2252
2253 Yallist$1.prototype.reduceReverse = function (fn, initial) {
2254 var acc;
2255 var walker = this.tail;
2256
2257 if (arguments.length > 1) {
2258 acc = initial;
2259 } else if (this.tail) {
2260 walker = this.tail.prev;
2261 acc = this.tail.value;
2262 } else {
2263 throw new TypeError('Reduce of empty list with no initial value');
2264 }
2265
2266 for (var i = this.length - 1; walker !== null; i--) {
2267 acc = fn(acc, walker.value, i);
2268 walker = walker.prev;
2269 }
2270
2271 return acc;
2272 };
2273
2274 Yallist$1.prototype.toArray = function () {
2275 var arr = new Array(this.length);
2276
2277 for (var i = 0, walker = this.head; walker !== null; i++) {
2278 arr[i] = walker.value;
2279 walker = walker.next;
2280 }
2281
2282 return arr;
2283 };
2284
2285 Yallist$1.prototype.toArrayReverse = function () {
2286 var arr = new Array(this.length);
2287
2288 for (var i = 0, walker = this.tail; walker !== null; i++) {
2289 arr[i] = walker.value;
2290 walker = walker.prev;
2291 }
2292
2293 return arr;
2294 };
2295
2296 Yallist$1.prototype.slice = function (from, to) {
2297 to = to || this.length;
2298
2299 if (to < 0) {
2300 to += this.length;
2301 }
2302
2303 from = from || 0;
2304
2305 if (from < 0) {
2306 from += this.length;
2307 }
2308
2309 var ret = new Yallist$1();
2310
2311 if (to < from || to < 0) {
2312 return ret;
2313 }
2314
2315 if (from < 0) {
2316 from = 0;
2317 }
2318
2319 if (to > this.length) {
2320 to = this.length;
2321 }
2322
2323 for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
2324 walker = walker.next;
2325 }
2326
2327 for (; walker !== null && i < to; i++, walker = walker.next) {
2328 ret.push(walker.value);
2329 }
2330
2331 return ret;
2332 };
2333
2334 Yallist$1.prototype.sliceReverse = function (from, to) {
2335 to = to || this.length;
2336
2337 if (to < 0) {
2338 to += this.length;
2339 }
2340
2341 from = from || 0;
2342
2343 if (from < 0) {
2344 from += this.length;
2345 }
2346
2347 var ret = new Yallist$1();
2348
2349 if (to < from || to < 0) {
2350 return ret;
2351 }
2352
2353 if (from < 0) {
2354 from = 0;
2355 }
2356
2357 if (to > this.length) {
2358 to = this.length;
2359 }
2360
2361 for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
2362 walker = walker.prev;
2363 }
2364
2365 for (; walker !== null && i > from; i--, walker = walker.prev) {
2366 ret.push(walker.value);
2367 }
2368
2369 return ret;
2370 };
2371
2372 Yallist$1.prototype.splice = function (start, deleteCount, ...nodes) {
2373 if (start > this.length) {
2374 start = this.length - 1;
2375 }
2376
2377 if (start < 0) {
2378 start = this.length + start;
2379 }
2380
2381 for (var i = 0, walker = this.head; walker !== null && i < start; i++) {
2382 walker = walker.next;
2383 }
2384
2385 var ret = [];
2386
2387 for (var i = 0; walker && i < deleteCount; i++) {
2388 ret.push(walker.value);
2389 walker = this.removeNode(walker);
2390 }
2391
2392 if (walker === null) {
2393 walker = this.tail;
2394 }
2395
2396 if (walker !== this.head && walker !== this.tail) {
2397 walker = walker.prev;
2398 }
2399
2400 for (var i = 0; i < nodes.length; i++) {
2401 walker = insert(this, walker, nodes[i]);
2402 }
2403
2404 return ret;
2405 };
2406
2407 Yallist$1.prototype.reverse = function () {
2408 var head = this.head;
2409 var tail = this.tail;
2410
2411 for (var walker = head; walker !== null; walker = walker.prev) {
2412 var p = walker.prev;
2413 walker.prev = walker.next;
2414 walker.next = p;
2415 }
2416
2417 this.head = tail;
2418 this.tail = head;
2419 return this;
2420 };
2421
2422 function insert(self, node, value) {
2423 var inserted = node === self.head ? new Node(value, null, node, self) : new Node(value, node, node.next, self);
2424
2425 if (inserted.next === null) {
2426 self.tail = inserted;
2427 }
2428
2429 if (inserted.prev === null) {
2430 self.head = inserted;
2431 }
2432
2433 self.length++;
2434 return inserted;
2435 }
2436
2437 function push(self, item) {
2438 self.tail = new Node(item, self.tail, null, self);
2439
2440 if (!self.head) {
2441 self.head = self.tail;
2442 }
2443
2444 self.length++;
2445 }
2446
2447 function unshift(self, item) {
2448 self.head = new Node(item, null, self.head, self);
2449
2450 if (!self.tail) {
2451 self.tail = self.head;
2452 }
2453
2454 self.length++;
2455 }
2456
2457 function Node(value, prev, next, list) {
2458 if (!(this instanceof Node)) {
2459 return new Node(value, prev, next, list);
2460 }
2461
2462 this.list = list;
2463 this.value = value;
2464
2465 if (prev) {
2466 prev.next = this;
2467 this.prev = prev;
2468 } else {
2469 this.prev = null;
2470 }
2471
2472 if (next) {
2473 next.prev = this;
2474 this.next = next;
2475 } else {
2476 this.next = null;
2477 }
2478 }
2479
2480 try {
2481 // add if support for Symbol.iterator is present
2482 iterator(Yallist$1);
2483 } catch (er) {}
2484
2485 const Yallist = yallist;
2486 const MAX = Symbol('max');
2487 const LENGTH = Symbol('length');
2488 const LENGTH_CALCULATOR = Symbol('lengthCalculator');
2489 const ALLOW_STALE = Symbol('allowStale');
2490 const MAX_AGE = Symbol('maxAge');
2491 const DISPOSE = Symbol('dispose');
2492 const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet');
2493 const LRU_LIST = Symbol('lruList');
2494 const CACHE = Symbol('cache');
2495 const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet');
2496
2497 const naiveLength = () => 1; // lruList is a yallist where the head is the youngest
2498 // item, and the tail is the oldest. the list contains the Hit
2499 // objects as the entries.
2500 // Each Hit object has a reference to its Yallist.Node. This
2501 // never changes.
2502 //
2503 // cache is a Map (or PseudoMap) that matches the keys to
2504 // the Yallist.Node object.
2505
2506
2507 class LRUCache {
2508 constructor(options) {
2509 if (typeof options === 'number') options = {
2510 max: options
2511 };
2512 if (!options) options = {};
2513 if (options.max && (typeof options.max !== 'number' || options.max < 0)) throw new TypeError('max must be a non-negative number'); // Kind of weird to have a default max of Infinity, but oh well.
2514
2515 this[MAX] = options.max || Infinity;
2516 const lc = options.length || naiveLength;
2517 this[LENGTH_CALCULATOR] = typeof lc !== 'function' ? naiveLength : lc;
2518 this[ALLOW_STALE] = options.stale || false;
2519 if (options.maxAge && typeof options.maxAge !== 'number') throw new TypeError('maxAge must be a number');
2520 this[MAX_AGE] = options.maxAge || 0;
2521 this[DISPOSE] = options.dispose;
2522 this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
2523 this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false;
2524 this.reset();
2525 } // resize the cache when the max changes.
2526
2527
2528 set max(mL) {
2529 if (typeof mL !== 'number' || mL < 0) throw new TypeError('max must be a non-negative number');
2530 this[MAX] = mL || Infinity;
2531 trim(this);
2532 }
2533
2534 get max() {
2535 return this[MAX];
2536 }
2537
2538 set allowStale(allowStale) {
2539 this[ALLOW_STALE] = !!allowStale;
2540 }
2541
2542 get allowStale() {
2543 return this[ALLOW_STALE];
2544 }
2545
2546 set maxAge(mA) {
2547 if (typeof mA !== 'number') throw new TypeError('maxAge must be a non-negative number');
2548 this[MAX_AGE] = mA;
2549 trim(this);
2550 }
2551
2552 get maxAge() {
2553 return this[MAX_AGE];
2554 } // resize the cache when the lengthCalculator changes.
2555
2556
2557 set lengthCalculator(lC) {
2558 if (typeof lC !== 'function') lC = naiveLength;
2559
2560 if (lC !== this[LENGTH_CALCULATOR]) {
2561 this[LENGTH_CALCULATOR] = lC;
2562 this[LENGTH] = 0;
2563 this[LRU_LIST].forEach(hit => {
2564 hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
2565 this[LENGTH] += hit.length;
2566 });
2567 }
2568
2569 trim(this);
2570 }
2571
2572 get lengthCalculator() {
2573 return this[LENGTH_CALCULATOR];
2574 }
2575
2576 get length() {
2577 return this[LENGTH];
2578 }
2579
2580 get itemCount() {
2581 return this[LRU_LIST].length;
2582 }
2583
2584 rforEach(fn, thisp) {
2585 thisp = thisp || this;
2586
2587 for (let walker = this[LRU_LIST].tail; walker !== null;) {
2588 const prev = walker.prev;
2589 forEachStep(this, fn, walker, thisp);
2590 walker = prev;
2591 }
2592 }
2593
2594 forEach(fn, thisp) {
2595 thisp = thisp || this;
2596
2597 for (let walker = this[LRU_LIST].head; walker !== null;) {
2598 const next = walker.next;
2599 forEachStep(this, fn, walker, thisp);
2600 walker = next;
2601 }
2602 }
2603
2604 keys() {
2605 return this[LRU_LIST].toArray().map(k => k.key);
2606 }
2607
2608 values() {
2609 return this[LRU_LIST].toArray().map(k => k.value);
2610 }
2611
2612 reset() {
2613 if (this[DISPOSE] && this[LRU_LIST] && this[LRU_LIST].length) {
2614 this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value));
2615 }
2616
2617 this[CACHE] = new Map(); // hash of items by key
2618
2619 this[LRU_LIST] = new Yallist(); // list of items in order of use recency
2620
2621 this[LENGTH] = 0; // length of items in the list
2622 }
2623
2624 dump() {
2625 return this[LRU_LIST].map(hit => isStale(this, hit) ? false : {
2626 k: hit.key,
2627 v: hit.value,
2628 e: hit.now + (hit.maxAge || 0)
2629 }).toArray().filter(h => h);
2630 }
2631
2632 dumpLru() {
2633 return this[LRU_LIST];
2634 }
2635
2636 set(key, value, maxAge) {
2637 maxAge = maxAge || this[MAX_AGE];
2638 if (maxAge && typeof maxAge !== 'number') throw new TypeError('maxAge must be a number');
2639 const now = maxAge ? Date.now() : 0;
2640 const len = this[LENGTH_CALCULATOR](value, key);
2641
2642 if (this[CACHE].has(key)) {
2643 if (len > this[MAX]) {
2644 del(this, this[CACHE].get(key));
2645 return false;
2646 }
2647
2648 const node = this[CACHE].get(key);
2649 const item = node.value; // dispose of the old one before overwriting
2650 // split out into 2 ifs for better coverage tracking
2651
2652 if (this[DISPOSE]) {
2653 if (!this[NO_DISPOSE_ON_SET]) this[DISPOSE](key, item.value);
2654 }
2655
2656 item.now = now;
2657 item.maxAge = maxAge;
2658 item.value = value;
2659 this[LENGTH] += len - item.length;
2660 item.length = len;
2661 this.get(key);
2662 trim(this);
2663 return true;
2664 }
2665
2666 const hit = new Entry(key, value, len, now, maxAge); // oversized objects fall out of cache automatically.
2667
2668 if (hit.length > this[MAX]) {
2669 if (this[DISPOSE]) this[DISPOSE](key, value);
2670 return false;
2671 }
2672
2673 this[LENGTH] += hit.length;
2674 this[LRU_LIST].unshift(hit);
2675 this[CACHE].set(key, this[LRU_LIST].head);
2676 trim(this);
2677 return true;
2678 }
2679
2680 has(key) {
2681 if (!this[CACHE].has(key)) return false;
2682 const hit = this[CACHE].get(key).value;
2683 return !isStale(this, hit);
2684 }
2685
2686 get(key) {
2687 return get(this, key, true);
2688 }
2689
2690 peek(key) {
2691 return get(this, key, false);
2692 }
2693
2694 pop() {
2695 const node = this[LRU_LIST].tail;
2696 if (!node) return null;
2697 del(this, node);
2698 return node.value;
2699 }
2700
2701 del(key) {
2702 del(this, this[CACHE].get(key));
2703 }
2704
2705 load(arr) {
2706 // reset the cache
2707 this.reset();
2708 const now = Date.now(); // A previous serialized cache has the most recent items first
2709
2710 for (let l = arr.length - 1; l >= 0; l--) {
2711 const hit = arr[l];
2712 const expiresAt = hit.e || 0;
2713 if (expiresAt === 0) // the item was created without expiration in a non aged cache
2714 this.set(hit.k, hit.v);else {
2715 const maxAge = expiresAt - now; // dont add already expired items
2716
2717 if (maxAge > 0) {
2718 this.set(hit.k, hit.v, maxAge);
2719 }
2720 }
2721 }
2722 }
2723
2724 prune() {
2725 this[CACHE].forEach((value, key) => get(this, key, false));
2726 }
2727
2728 }
2729
2730 const get = (self, key, doUse) => {
2731 const node = self[CACHE].get(key);
2732
2733 if (node) {
2734 const hit = node.value;
2735
2736 if (isStale(self, hit)) {
2737 del(self, node);
2738 if (!self[ALLOW_STALE]) return undefined;
2739 } else {
2740 if (doUse) {
2741 if (self[UPDATE_AGE_ON_GET]) node.value.now = Date.now();
2742 self[LRU_LIST].unshiftNode(node);
2743 }
2744 }
2745
2746 return hit.value;
2747 }
2748 };
2749
2750 const isStale = (self, hit) => {
2751 if (!hit || !hit.maxAge && !self[MAX_AGE]) return false;
2752 const diff = Date.now() - hit.now;
2753 return hit.maxAge ? diff > hit.maxAge : self[MAX_AGE] && diff > self[MAX_AGE];
2754 };
2755
2756 const trim = self => {
2757 if (self[LENGTH] > self[MAX]) {
2758 for (let walker = self[LRU_LIST].tail; self[LENGTH] > self[MAX] && walker !== null;) {
2759 // We know that we're about to delete this one, and also
2760 // what the next least recently used key will be, so just
2761 // go ahead and set it now.
2762 const prev = walker.prev;
2763 del(self, walker);
2764 walker = prev;
2765 }
2766 }
2767 };
2768
2769 const del = (self, node) => {
2770 if (node) {
2771 const hit = node.value;
2772 if (self[DISPOSE]) self[DISPOSE](hit.key, hit.value);
2773 self[LENGTH] -= hit.length;
2774 self[CACHE].delete(hit.key);
2775 self[LRU_LIST].removeNode(node);
2776 }
2777 };
2778
2779 class Entry {
2780 constructor(key, value, length, now, maxAge) {
2781 this.key = key;
2782 this.value = value;
2783 this.length = length;
2784 this.now = now;
2785 this.maxAge = maxAge || 0;
2786 }
2787
2788 }
2789
2790 const forEachStep = (self, fn, node, thisp) => {
2791 let hit = node.value;
2792
2793 if (isStale(self, hit)) {
2794 del(self, node);
2795 if (!self[ALLOW_STALE]) hit = undefined;
2796 }
2797
2798 if (hit) fn.call(thisp, hit.value, hit.key, self);
2799 };
2800
2801 var lruCache = LRUCache;
2802
2803 class Range$a {
2804 constructor(range, options) {
2805 options = parseOptions$1(options);
2806
2807 if (range instanceof Range$a) {
2808 if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
2809 return range;
2810 } else {
2811 return new Range$a(range.raw, options);
2812 }
2813 }
2814
2815 if (range instanceof Comparator$3) {
2816 // just put it in the set and return
2817 this.raw = range.value;
2818 this.set = [[range]];
2819 this.format();
2820 return this;
2821 }
2822
2823 this.options = options;
2824 this.loose = !!options.loose;
2825 this.includePrerelease = !!options.includePrerelease; // First, split based on boolean or ||
2826
2827 this.raw = range;
2828 this.set = range.split(/\s*\|\|\s*/) // map the range to a 2d array of comparators
2829 .map(range => this.parseRange(range.trim())) // throw out any comparator lists that are empty
2830 // this generally means that it was not a valid range, which is allowed
2831 // in loose mode, but will still throw if the WHOLE range is invalid.
2832 .filter(c => c.length);
2833
2834 if (!this.set.length) {
2835 throw new TypeError(`Invalid SemVer Range: ${range}`);
2836 } // if we have any that are not the null set, throw out null sets.
2837
2838
2839 if (this.set.length > 1) {
2840 // keep the first one, in case they're all null sets
2841 const first = this.set[0];
2842 this.set = this.set.filter(c => !isNullSet(c[0]));
2843 if (this.set.length === 0) this.set = [first];else if (this.set.length > 1) {
2844 // if we have any that are *, then the range is just *
2845 for (const c of this.set) {
2846 if (c.length === 1 && isAny(c[0])) {
2847 this.set = [c];
2848 break;
2849 }
2850 }
2851 }
2852 }
2853
2854 this.format();
2855 }
2856
2857 format() {
2858 this.range = this.set.map(comps => {
2859 return comps.join(' ').trim();
2860 }).join('||').trim();
2861 return this.range;
2862 }
2863
2864 toString() {
2865 return this.range;
2866 }
2867
2868 parseRange(range) {
2869 range = range.trim(); // memoize range parsing for performance.
2870 // this is a very hot path, and fully deterministic.
2871
2872 const memoOpts = Object.keys(this.options).join(',');
2873 const memoKey = `parseRange:${memoOpts}:${range}`;
2874 const cached = cache.get(memoKey);
2875 if (cached) return cached;
2876 const loose = this.options.loose; // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
2877
2878 const hr = loose ? re$1[t$1.HYPHENRANGELOOSE] : re$1[t$1.HYPHENRANGE];
2879 range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
2880 debug$1('hyphen replace', range); // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
2881
2882 range = range.replace(re$1[t$1.COMPARATORTRIM], comparatorTrimReplace);
2883 debug$1('comparator trim', range, re$1[t$1.COMPARATORTRIM]); // `~ 1.2.3` => `~1.2.3`
2884
2885 range = range.replace(re$1[t$1.TILDETRIM], tildeTrimReplace); // `^ 1.2.3` => `^1.2.3`
2886
2887 range = range.replace(re$1[t$1.CARETTRIM], caretTrimReplace); // normalize spaces
2888
2889 range = range.split(/\s+/).join(' '); // At this point, the range is completely trimmed and
2890 // ready to be split into comparators.
2891
2892 const compRe = loose ? re$1[t$1.COMPARATORLOOSE] : re$1[t$1.COMPARATOR];
2893 const rangeList = range.split(' ').map(comp => parseComparator(comp, this.options)).join(' ').split(/\s+/) // >=0.0.0 is equivalent to *
2894 .map(comp => replaceGTE0(comp, this.options)) // in loose mode, throw out any that are not valid comparators
2895 .filter(this.options.loose ? comp => !!comp.match(compRe) : () => true).map(comp => new Comparator$3(comp, this.options)); // if any comparators are the null set, then replace with JUST null set
2896 // if more than one comparator, remove any * comparators
2897 // also, don't include the same comparator more than once
2898
2899 rangeList.length;
2900 const rangeMap = new Map();
2901
2902 for (const comp of rangeList) {
2903 if (isNullSet(comp)) return [comp];
2904 rangeMap.set(comp.value, comp);
2905 }
2906
2907 if (rangeMap.size > 1 && rangeMap.has('')) rangeMap.delete('');
2908 const result = [...rangeMap.values()];
2909 cache.set(memoKey, result);
2910 return result;
2911 }
2912
2913 intersects(range, options) {
2914 if (!(range instanceof Range$a)) {
2915 throw new TypeError('a Range is required');
2916 }
2917
2918 return this.set.some(thisComparators => {
2919 return isSatisfiable(thisComparators, options) && range.set.some(rangeComparators => {
2920 return isSatisfiable(rangeComparators, options) && thisComparators.every(thisComparator => {
2921 return rangeComparators.every(rangeComparator => {
2922 return thisComparator.intersects(rangeComparator, options);
2923 });
2924 });
2925 });
2926 });
2927 } // if ANY of the sets match ALL of its comparators, then pass
2928
2929
2930 test(version) {
2931 if (!version) {
2932 return false;
2933 }
2934
2935 if (typeof version === 'string') {
2936 try {
2937 version = new SemVer$5(version, this.options);
2938 } catch (er) {
2939 return false;
2940 }
2941 }
2942
2943 for (let i = 0; i < this.set.length; i++) {
2944 if (testSet(this.set[i], version, this.options)) {
2945 return true;
2946 }
2947 }
2948
2949 return false;
2950 }
2951
2952 }
2953
2954 var range = Range$a;
2955 const LRU = lruCache;
2956 const cache = new LRU({
2957 max: 1000
2958 });
2959 const parseOptions$1 = parseOptions_1;
2960 const Comparator$3 = comparator;
2961 const debug$1 = debug_1;
2962 const SemVer$5 = semver$1;
2963 const {
2964 re: re$1,
2965 t: t$1,
2966 comparatorTrimReplace,
2967 tildeTrimReplace,
2968 caretTrimReplace
2969 } = re$5.exports;
2970
2971 const isNullSet = c => c.value === '<0.0.0-0';
2972
2973 const isAny = c => c.value === ''; // take a set of comparators and determine whether there
2974 // exists a version which can satisfy it
2975
2976
2977 const isSatisfiable = (comparators, options) => {
2978 let result = true;
2979 const remainingComparators = comparators.slice();
2980 let testComparator = remainingComparators.pop();
2981
2982 while (result && remainingComparators.length) {
2983 result = remainingComparators.every(otherComparator => {
2984 return testComparator.intersects(otherComparator, options);
2985 });
2986 testComparator = remainingComparators.pop();
2987 }
2988
2989 return result;
2990 }; // comprised of xranges, tildes, stars, and gtlt's at this point.
2991 // already replaced the hyphen ranges
2992 // turn into a set of JUST comparators.
2993
2994
2995 const parseComparator = (comp, options) => {
2996 debug$1('comp', comp, options);
2997 comp = replaceCarets(comp, options);
2998 debug$1('caret', comp);
2999 comp = replaceTildes(comp, options);
3000 debug$1('tildes', comp);
3001 comp = replaceXRanges(comp, options);
3002 debug$1('xrange', comp);
3003 comp = replaceStars(comp, options);
3004 debug$1('stars', comp);
3005 return comp;
3006 };
3007
3008 const isX = id => !id || id.toLowerCase() === 'x' || id === '*'; // ~, ~> --> * (any, kinda silly)
3009 // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
3010 // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
3011 // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
3012 // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
3013 // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
3014
3015
3016 const replaceTildes = (comp, options) => comp.trim().split(/\s+/).map(comp => {
3017 return replaceTilde(comp, options);
3018 }).join(' ');
3019
3020 const replaceTilde = (comp, options) => {
3021 const r = options.loose ? re$1[t$1.TILDELOOSE] : re$1[t$1.TILDE];
3022 return comp.replace(r, (_, M, m, p, pr) => {
3023 debug$1('tilde', comp, _, M, m, p, pr);
3024 let ret;
3025
3026 if (isX(M)) {
3027 ret = '';
3028 } else if (isX(m)) {
3029 ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
3030 } else if (isX(p)) {
3031 // ~1.2 == >=1.2.0 <1.3.0-0
3032 ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
3033 } else if (pr) {
3034 debug$1('replaceTilde pr', pr);
3035 ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
3036 } else {
3037 // ~1.2.3 == >=1.2.3 <1.3.0-0
3038 ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
3039 }
3040
3041 debug$1('tilde return', ret);
3042 return ret;
3043 });
3044 }; // ^ --> * (any, kinda silly)
3045 // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
3046 // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
3047 // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
3048 // ^1.2.3 --> >=1.2.3 <2.0.0-0
3049 // ^1.2.0 --> >=1.2.0 <2.0.0-0
3050
3051
3052 const replaceCarets = (comp, options) => comp.trim().split(/\s+/).map(comp => {
3053 return replaceCaret(comp, options);
3054 }).join(' ');
3055
3056 const replaceCaret = (comp, options) => {
3057 debug$1('caret', comp, options);
3058 const r = options.loose ? re$1[t$1.CARETLOOSE] : re$1[t$1.CARET];
3059 const z = options.includePrerelease ? '-0' : '';
3060 return comp.replace(r, (_, M, m, p, pr) => {
3061 debug$1('caret', comp, _, M, m, p, pr);
3062 let ret;
3063
3064 if (isX(M)) {
3065 ret = '';
3066 } else if (isX(m)) {
3067 ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
3068 } else if (isX(p)) {
3069 if (M === '0') {
3070 ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
3071 } else {
3072 ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
3073 }
3074 } else if (pr) {
3075 debug$1('replaceCaret pr', pr);
3076
3077 if (M === '0') {
3078 if (m === '0') {
3079 ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
3080 } else {
3081 ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
3082 }
3083 } else {
3084 ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
3085 }
3086 } else {
3087 debug$1('no pr');
3088
3089 if (M === '0') {
3090 if (m === '0') {
3091 ret = `>=${M}.${m}.${p}${z} <${M}.${m}.${+p + 1}-0`;
3092 } else {
3093 ret = `>=${M}.${m}.${p}${z} <${M}.${+m + 1}.0-0`;
3094 }
3095 } else {
3096 ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
3097 }
3098 }
3099
3100 debug$1('caret return', ret);
3101 return ret;
3102 });
3103 };
3104
3105 const replaceXRanges = (comp, options) => {
3106 debug$1('replaceXRanges', comp, options);
3107 return comp.split(/\s+/).map(comp => {
3108 return replaceXRange(comp, options);
3109 }).join(' ');
3110 };
3111
3112 const replaceXRange = (comp, options) => {
3113 comp = comp.trim();
3114 const r = options.loose ? re$1[t$1.XRANGELOOSE] : re$1[t$1.XRANGE];
3115 return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
3116 debug$1('xRange', comp, ret, gtlt, M, m, p, pr);
3117 const xM = isX(M);
3118 const xm = xM || isX(m);
3119 const xp = xm || isX(p);
3120 const anyX = xp;
3121
3122 if (gtlt === '=' && anyX) {
3123 gtlt = '';
3124 } // if we're including prereleases in the match, then we need
3125 // to fix this to -0, the lowest possible prerelease value
3126
3127
3128 pr = options.includePrerelease ? '-0' : '';
3129
3130 if (xM) {
3131 if (gtlt === '>' || gtlt === '<') {
3132 // nothing is allowed
3133 ret = '<0.0.0-0';
3134 } else {
3135 // nothing is forbidden
3136 ret = '*';
3137 }
3138 } else if (gtlt && anyX) {
3139 // we know patch is an x, because we have any x at all.
3140 // replace X with 0
3141 if (xm) {
3142 m = 0;
3143 }
3144
3145 p = 0;
3146
3147 if (gtlt === '>') {
3148 // >1 => >=2.0.0
3149 // >1.2 => >=1.3.0
3150 gtlt = '>=';
3151
3152 if (xm) {
3153 M = +M + 1;
3154 m = 0;
3155 p = 0;
3156 } else {
3157 m = +m + 1;
3158 p = 0;
3159 }
3160 } else if (gtlt === '<=') {
3161 // <=0.7.x is actually <0.8.0, since any 0.7.x should
3162 // pass. Similarly, <=7.x is actually <8.0.0, etc.
3163 gtlt = '<';
3164
3165 if (xm) {
3166 M = +M + 1;
3167 } else {
3168 m = +m + 1;
3169 }
3170 }
3171
3172 if (gtlt === '<') pr = '-0';
3173 ret = `${gtlt + M}.${m}.${p}${pr}`;
3174 } else if (xm) {
3175 ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
3176 } else if (xp) {
3177 ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
3178 }
3179
3180 debug$1('xRange return', ret);
3181 return ret;
3182 });
3183 }; // Because * is AND-ed with everything else in the comparator,
3184 // and '' means "any version", just remove the *s entirely.
3185
3186
3187 const replaceStars = (comp, options) => {
3188 debug$1('replaceStars', comp, options); // Looseness is ignored here. star is always as loose as it gets!
3189
3190 return comp.trim().replace(re$1[t$1.STAR], '');
3191 };
3192
3193 const replaceGTE0 = (comp, options) => {
3194 debug$1('replaceGTE0', comp, options);
3195 return comp.trim().replace(re$1[options.includePrerelease ? t$1.GTE0PRE : t$1.GTE0], '');
3196 }; // This function is passed to string.replace(re[t.HYPHENRANGE])
3197 // M, m, patch, prerelease, build
3198 // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
3199 // 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do
3200 // 1.2 - 3.4 => >=1.2.0 <3.5.0-0
3201
3202
3203 const hyphenReplace = incPr => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) => {
3204 if (isX(fM)) {
3205 from = '';
3206 } else if (isX(fm)) {
3207 from = `>=${fM}.0.0${incPr ? '-0' : ''}`;
3208 } else if (isX(fp)) {
3209 from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`;
3210 } else if (fpr) {
3211 from = `>=${from}`;
3212 } else {
3213 from = `>=${from}${incPr ? '-0' : ''}`;
3214 }
3215
3216 if (isX(tM)) {
3217 to = '';
3218 } else if (isX(tm)) {
3219 to = `<${+tM + 1}.0.0-0`;
3220 } else if (isX(tp)) {
3221 to = `<${tM}.${+tm + 1}.0-0`;
3222 } else if (tpr) {
3223 to = `<=${tM}.${tm}.${tp}-${tpr}`;
3224 } else if (incPr) {
3225 to = `<${tM}.${tm}.${+tp + 1}-0`;
3226 } else {
3227 to = `<=${to}`;
3228 }
3229
3230 return `${from} ${to}`.trim();
3231 };
3232
3233 const testSet = (set, version, options) => {
3234 for (let i = 0; i < set.length; i++) {
3235 if (!set[i].test(version)) {
3236 return false;
3237 }
3238 }
3239
3240 if (version.prerelease.length && !options.includePrerelease) {
3241 // Find the set of versions that are allowed to have prereleases
3242 // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
3243 // That should allow `1.2.3-pr.2` to pass.
3244 // However, `1.2.4-alpha.notready` should NOT be allowed,
3245 // even though it's within the range set by the comparators.
3246 for (let i = 0; i < set.length; i++) {
3247 debug$1(set[i].semver);
3248
3249 if (set[i].semver === Comparator$3.ANY) {
3250 continue;
3251 }
3252
3253 if (set[i].semver.prerelease.length > 0) {
3254 const allowed = set[i].semver;
3255
3256 if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
3257 return true;
3258 }
3259 }
3260 } // Version has a -pre, but it's not one of the ones we like.
3261
3262
3263 return false;
3264 }
3265
3266 return true;
3267 };
3268
3269 const ANY$2 = Symbol('SemVer ANY'); // hoisted class for cyclic dependency
3270
3271 class Comparator$2 {
3272 static get ANY() {
3273 return ANY$2;
3274 }
3275
3276 constructor(comp, options) {
3277 options = parseOptions(options);
3278
3279 if (comp instanceof Comparator$2) {
3280 if (comp.loose === !!options.loose) {
3281 return comp;
3282 } else {
3283 comp = comp.value;
3284 }
3285 }
3286
3287 debug('comparator', comp, options);
3288 this.options = options;
3289 this.loose = !!options.loose;
3290 this.parse(comp);
3291
3292 if (this.semver === ANY$2) {
3293 this.value = '';
3294 } else {
3295 this.value = this.operator + this.semver.version;
3296 }
3297
3298 debug('comp', this);
3299 }
3300
3301 parse(comp) {
3302 const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
3303 const m = comp.match(r);
3304
3305 if (!m) {
3306 throw new TypeError(`Invalid comparator: ${comp}`);
3307 }
3308
3309 this.operator = m[1] !== undefined ? m[1] : '';
3310
3311 if (this.operator === '=') {
3312 this.operator = '';
3313 } // if it literally is just '>' or '' then allow anything.
3314
3315
3316 if (!m[2]) {
3317 this.semver = ANY$2;
3318 } else {
3319 this.semver = new SemVer$4(m[2], this.options.loose);
3320 }
3321 }
3322
3323 toString() {
3324 return this.value;
3325 }
3326
3327 test(version) {
3328 debug('Comparator.test', version, this.options.loose);
3329
3330 if (this.semver === ANY$2 || version === ANY$2) {
3331 return true;
3332 }
3333
3334 if (typeof version === 'string') {
3335 try {
3336 version = new SemVer$4(version, this.options);
3337 } catch (er) {
3338 return false;
3339 }
3340 }
3341
3342 return cmp(version, this.operator, this.semver, this.options);
3343 }
3344
3345 intersects(comp, options) {
3346 if (!(comp instanceof Comparator$2)) {
3347 throw new TypeError('a Comparator is required');
3348 }
3349
3350 if (!options || typeof options !== 'object') {
3351 options = {
3352 loose: !!options,
3353 includePrerelease: false
3354 };
3355 }
3356
3357 if (this.operator === '') {
3358 if (this.value === '') {
3359 return true;
3360 }
3361
3362 return new Range$9(comp.value, options).test(this.value);
3363 } else if (comp.operator === '') {
3364 if (comp.value === '') {
3365 return true;
3366 }
3367
3368 return new Range$9(this.value, options).test(comp.semver);
3369 }
3370
3371 const sameDirectionIncreasing = (this.operator === '>=' || this.operator === '>') && (comp.operator === '>=' || comp.operator === '>');
3372 const sameDirectionDecreasing = (this.operator === '<=' || this.operator === '<') && (comp.operator === '<=' || comp.operator === '<');
3373 const sameSemVer = this.semver.version === comp.semver.version;
3374 const differentDirectionsInclusive = (this.operator === '>=' || this.operator === '<=') && (comp.operator === '>=' || comp.operator === '<=');
3375 const oppositeDirectionsLessThan = cmp(this.semver, '<', comp.semver, options) && (this.operator === '>=' || this.operator === '>') && (comp.operator === '<=' || comp.operator === '<');
3376 const oppositeDirectionsGreaterThan = cmp(this.semver, '>', comp.semver, options) && (this.operator === '<=' || this.operator === '<') && (comp.operator === '>=' || comp.operator === '>');
3377 return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
3378 }
3379
3380 }
3381
3382 var comparator = Comparator$2;
3383 const parseOptions = parseOptions_1;
3384 const {
3385 re,
3386 t
3387 } = re$5.exports;
3388 const cmp = cmp_1;
3389 const debug = debug_1;
3390 const SemVer$4 = semver$1;
3391 const Range$9 = range;
3392
3393 const Range$8 = range;
3394
3395 const satisfies$3 = (version, range, options) => {
3396 try {
3397 range = new Range$8(range, options);
3398 } catch (er) {
3399 return false;
3400 }
3401
3402 return range.test(version);
3403 };
3404
3405 var satisfies_1 = satisfies$3;
3406
3407 const Range$7 = range; // Mostly just for testing and legacy API reasons
3408
3409 const toComparators = (range, options) => new Range$7(range, options).set.map(comp => comp.map(c => c.value).join(' ').trim().split(' '));
3410
3411 var toComparators_1 = toComparators;
3412
3413 const SemVer$3 = semver$1;
3414 const Range$6 = range;
3415
3416 const maxSatisfying = (versions, range, options) => {
3417 let max = null;
3418 let maxSV = null;
3419 let rangeObj = null;
3420
3421 try {
3422 rangeObj = new Range$6(range, options);
3423 } catch (er) {
3424 return null;
3425 }
3426
3427 versions.forEach(v => {
3428 if (rangeObj.test(v)) {
3429 // satisfies(v, range, options)
3430 if (!max || maxSV.compare(v) === -1) {
3431 // compare(max, v, true)
3432 max = v;
3433 maxSV = new SemVer$3(max, options);
3434 }
3435 }
3436 });
3437 return max;
3438 };
3439
3440 var maxSatisfying_1 = maxSatisfying;
3441
3442 const SemVer$2 = semver$1;
3443 const Range$5 = range;
3444
3445 const minSatisfying = (versions, range, options) => {
3446 let min = null;
3447 let minSV = null;
3448 let rangeObj = null;
3449
3450 try {
3451 rangeObj = new Range$5(range, options);
3452 } catch (er) {
3453 return null;
3454 }
3455
3456 versions.forEach(v => {
3457 if (rangeObj.test(v)) {
3458 // satisfies(v, range, options)
3459 if (!min || minSV.compare(v) === 1) {
3460 // compare(min, v, true)
3461 min = v;
3462 minSV = new SemVer$2(min, options);
3463 }
3464 }
3465 });
3466 return min;
3467 };
3468
3469 var minSatisfying_1 = minSatisfying;
3470
3471 const SemVer$1 = semver$1;
3472 const Range$4 = range;
3473 const gt$1 = gt_1;
3474
3475 const minVersion = (range, loose) => {
3476 range = new Range$4(range, loose);
3477 let minver = new SemVer$1('0.0.0');
3478
3479 if (range.test(minver)) {
3480 return minver;
3481 }
3482
3483 minver = new SemVer$1('0.0.0-0');
3484
3485 if (range.test(minver)) {
3486 return minver;
3487 }
3488
3489 minver = null;
3490
3491 for (let i = 0; i < range.set.length; ++i) {
3492 const comparators = range.set[i];
3493 let setMin = null;
3494 comparators.forEach(comparator => {
3495 // Clone to avoid manipulating the comparator's semver object.
3496 const compver = new SemVer$1(comparator.semver.version);
3497
3498 switch (comparator.operator) {
3499 case '>':
3500 if (compver.prerelease.length === 0) {
3501 compver.patch++;
3502 } else {
3503 compver.prerelease.push(0);
3504 }
3505
3506 compver.raw = compver.format();
3507
3508 /* fallthrough */
3509
3510 case '':
3511 case '>=':
3512 if (!setMin || gt$1(compver, setMin)) {
3513 setMin = compver;
3514 }
3515
3516 break;
3517
3518 case '<':
3519 case '<=':
3520 /* Ignore maximum versions */
3521 break;
3522
3523 /* istanbul ignore next */
3524
3525 default:
3526 throw new Error(`Unexpected operation: ${comparator.operator}`);
3527 }
3528 });
3529 if (setMin && (!minver || gt$1(minver, setMin))) minver = setMin;
3530 }
3531
3532 if (minver && range.test(minver)) {
3533 return minver;
3534 }
3535
3536 return null;
3537 };
3538
3539 var minVersion_1 = minVersion;
3540
3541 const Range$3 = range;
3542
3543 const validRange = (range, options) => {
3544 try {
3545 // Return '*' instead of '' so that truthiness works.
3546 // This will throw if it's invalid anyway
3547 return new Range$3(range, options).range || '*';
3548 } catch (er) {
3549 return null;
3550 }
3551 };
3552
3553 var valid = validRange;
3554
3555 const SemVer = semver$1;
3556 const Comparator$1 = comparator;
3557 const {
3558 ANY: ANY$1
3559 } = Comparator$1;
3560 const Range$2 = range;
3561 const satisfies$2 = satisfies_1;
3562 const gt = gt_1;
3563 const lt = lt_1;
3564 const lte = lte_1;
3565 const gte = gte_1;
3566
3567 const outside$2 = (version, range, hilo, options) => {
3568 version = new SemVer(version, options);
3569 range = new Range$2(range, options);
3570 let gtfn, ltefn, ltfn, comp, ecomp;
3571
3572 switch (hilo) {
3573 case '>':
3574 gtfn = gt;
3575 ltefn = lte;
3576 ltfn = lt;
3577 comp = '>';
3578 ecomp = '>=';
3579 break;
3580
3581 case '<':
3582 gtfn = lt;
3583 ltefn = gte;
3584 ltfn = gt;
3585 comp = '<';
3586 ecomp = '<=';
3587 break;
3588
3589 default:
3590 throw new TypeError('Must provide a hilo val of "<" or ">"');
3591 } // If it satisfies the range it is not outside
3592
3593
3594 if (satisfies$2(version, range, options)) {
3595 return false;
3596 } // From now on, variable terms are as if we're in "gtr" mode.
3597 // but note that everything is flipped for the "ltr" function.
3598
3599
3600 for (let i = 0; i < range.set.length; ++i) {
3601 const comparators = range.set[i];
3602 let high = null;
3603 let low = null;
3604 comparators.forEach(comparator => {
3605 if (comparator.semver === ANY$1) {
3606 comparator = new Comparator$1('>=0.0.0');
3607 }
3608
3609 high = high || comparator;
3610 low = low || comparator;
3611
3612 if (gtfn(comparator.semver, high.semver, options)) {
3613 high = comparator;
3614 } else if (ltfn(comparator.semver, low.semver, options)) {
3615 low = comparator;
3616 }
3617 }); // If the edge version comparator has a operator then our version
3618 // isn't outside it
3619
3620 if (high.operator === comp || high.operator === ecomp) {
3621 return false;
3622 } // If the lowest version comparator has an operator and our version
3623 // is less than it then it isn't higher than the range
3624
3625
3626 if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
3627 return false;
3628 } else if (low.operator === ecomp && ltfn(version, low.semver)) {
3629 return false;
3630 }
3631 }
3632
3633 return true;
3634 };
3635
3636 var outside_1 = outside$2;
3637
3638 const outside$1 = outside_1;
3639
3640 const gtr = (version, range, options) => outside$1(version, range, '>', options);
3641
3642 var gtr_1 = gtr;
3643
3644 const outside = outside_1; // Determine if version is less than all the versions possible in the range
3645
3646 const ltr = (version, range, options) => outside(version, range, '<', options);
3647
3648 var ltr_1 = ltr;
3649
3650 const Range$1 = range;
3651
3652 const intersects = (r1, r2, options) => {
3653 r1 = new Range$1(r1, options);
3654 r2 = new Range$1(r2, options);
3655 return r1.intersects(r2);
3656 };
3657
3658 var intersects_1 = intersects;
3659
3660 // that includes the same versions that the original range does
3661 // If the original range is shorter than the simplified one, return that.
3662
3663 const satisfies$1 = satisfies_1;
3664 const compare$1 = compare_1;
3665
3666 var simplify = (versions, range, options) => {
3667 const set = [];
3668 let min = null;
3669 let prev = null;
3670 const v = versions.sort((a, b) => compare$1(a, b, options));
3671
3672 for (const version of v) {
3673 const included = satisfies$1(version, range, options);
3674
3675 if (included) {
3676 prev = version;
3677 if (!min) min = version;
3678 } else {
3679 if (prev) {
3680 set.push([min, prev]);
3681 }
3682
3683 prev = null;
3684 min = null;
3685 }
3686 }
3687
3688 if (min) set.push([min, null]);
3689 const ranges = [];
3690
3691 for (const [min, max] of set) {
3692 if (min === max) ranges.push(min);else if (!max && min === v[0]) ranges.push('*');else if (!max) ranges.push(`>=${min}`);else if (min === v[0]) ranges.push(`<=${max}`);else ranges.push(`${min} - ${max}`);
3693 }
3694
3695 const simplified = ranges.join(' || ');
3696 const original = typeof range.raw === 'string' ? range.raw : String(range);
3697 return simplified.length < original.length ? simplified : range;
3698 };
3699
3700 const Range = range;
3701 const Comparator = comparator;
3702 const {
3703 ANY
3704 } = Comparator;
3705 const satisfies = satisfies_1;
3706 const compare = compare_1; // Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff:
3707 // - Every simple range `r1, r2, ...` is a null set, OR
3708 // - Every simple range `r1, r2, ...` which is not a null set is a subset of
3709 // some `R1, R2, ...`
3710 //
3711 // Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff:
3712 // - If c is only the ANY comparator
3713 // - If C is only the ANY comparator, return true
3714 // - Else if in prerelease mode, return false
3715 // - else replace c with `[>=0.0.0]`
3716 // - If C is only the ANY comparator
3717 // - if in prerelease mode, return true
3718 // - else replace C with `[>=0.0.0]`
3719 // - Let EQ be the set of = comparators in c
3720 // - If EQ is more than one, return true (null set)
3721 // - Let GT be the highest > or >= comparator in c
3722 // - Let LT be the lowest < or <= comparator in c
3723 // - If GT and LT, and GT.semver > LT.semver, return true (null set)
3724 // - If any C is a = range, and GT or LT are set, return false
3725 // - If EQ
3726 // - If GT, and EQ does not satisfy GT, return true (null set)
3727 // - If LT, and EQ does not satisfy LT, return true (null set)
3728 // - If EQ satisfies every C, return true
3729 // - Else return false
3730 // - If GT
3731 // - If GT.semver is lower than any > or >= comp in C, return false
3732 // - If GT is >=, and GT.semver does not satisfy every C, return false
3733 // - If GT.semver has a prerelease, and not in prerelease mode
3734 // - If no C has a prerelease and the GT.semver tuple, return false
3735 // - If LT
3736 // - If LT.semver is greater than any < or <= comp in C, return false
3737 // - If LT is <=, and LT.semver does not satisfy every C, return false
3738 // - If GT.semver has a prerelease, and not in prerelease mode
3739 // - If no C has a prerelease and the LT.semver tuple, return false
3740 // - Else return true
3741
3742 const subset = (sub, dom, options = {}) => {
3743 if (sub === dom) return true;
3744 sub = new Range(sub, options);
3745 dom = new Range(dom, options);
3746 let sawNonNull = false;
3747
3748 OUTER: for (const simpleSub of sub.set) {
3749 for (const simpleDom of dom.set) {
3750 const isSub = simpleSubset(simpleSub, simpleDom, options);
3751 sawNonNull = sawNonNull || isSub !== null;
3752 if (isSub) continue OUTER;
3753 } // the null set is a subset of everything, but null simple ranges in
3754 // a complex range should be ignored. so if we saw a non-null range,
3755 // then we know this isn't a subset, but if EVERY simple range was null,
3756 // then it is a subset.
3757
3758
3759 if (sawNonNull) return false;
3760 }
3761
3762 return true;
3763 };
3764
3765 const simpleSubset = (sub, dom, options) => {
3766 if (sub === dom) return true;
3767
3768 if (sub.length === 1 && sub[0].semver === ANY) {
3769 if (dom.length === 1 && dom[0].semver === ANY) return true;else if (options.includePrerelease) sub = [new Comparator('>=0.0.0-0')];else sub = [new Comparator('>=0.0.0')];
3770 }
3771
3772 if (dom.length === 1 && dom[0].semver === ANY) {
3773 if (options.includePrerelease) return true;else dom = [new Comparator('>=0.0.0')];
3774 }
3775
3776 const eqSet = new Set();
3777 let gt, lt;
3778
3779 for (const c of sub) {
3780 if (c.operator === '>' || c.operator === '>=') gt = higherGT(gt, c, options);else if (c.operator === '<' || c.operator === '<=') lt = lowerLT(lt, c, options);else eqSet.add(c.semver);
3781 }
3782
3783 if (eqSet.size > 1) return null;
3784 let gtltComp;
3785
3786 if (gt && lt) {
3787 gtltComp = compare(gt.semver, lt.semver, options);
3788 if (gtltComp > 0) return null;else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) return null;
3789 } // will iterate one or zero times
3790
3791
3792 for (const eq of eqSet) {
3793 if (gt && !satisfies(eq, String(gt), options)) return null;
3794 if (lt && !satisfies(eq, String(lt), options)) return null;
3795
3796 for (const c of dom) {
3797 if (!satisfies(eq, String(c), options)) return false;
3798 }
3799
3800 return true;
3801 }
3802
3803 let higher, lower;
3804 let hasDomLT, hasDomGT; // if the subset has a prerelease, we need a comparator in the superset
3805 // with the same tuple and a prerelease, or it's not a subset
3806
3807 let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
3808 let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false; // exception: <1.2.3-0 is the same as <1.2.3
3809
3810 if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === '<' && needDomLTPre.prerelease[0] === 0) {
3811 needDomLTPre = false;
3812 }
3813
3814 for (const c of dom) {
3815 hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>=';
3816 hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<=';
3817
3818 if (gt) {
3819 if (needDomGTPre) {
3820 if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) {
3821 needDomGTPre = false;
3822 }
3823 }
3824
3825 if (c.operator === '>' || c.operator === '>=') {
3826 higher = higherGT(gt, c, options);
3827 if (higher === c && higher !== gt) return false;
3828 } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) return false;
3829 }
3830
3831 if (lt) {
3832 if (needDomLTPre) {
3833 if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) {
3834 needDomLTPre = false;
3835 }
3836 }
3837
3838 if (c.operator === '<' || c.operator === '<=') {
3839 lower = lowerLT(lt, c, options);
3840 if (lower === c && lower !== lt) return false;
3841 } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) return false;
3842 }
3843
3844 if (!c.operator && (lt || gt) && gtltComp !== 0) return false;
3845 } // if there was a < or >, and nothing in the dom, then must be false
3846 // UNLESS it was limited by another range in the other direction.
3847 // Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0
3848
3849
3850 if (gt && hasDomLT && !lt && gtltComp !== 0) return false;
3851 if (lt && hasDomGT && !gt && gtltComp !== 0) return false; // we needed a prerelease range in a specific tuple, but didn't get one
3852 // then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0,
3853 // because it includes prereleases in the 1.2.3 tuple
3854
3855 if (needDomGTPre || needDomLTPre) return false;
3856 return true;
3857 }; // >=1.2.3 is lower than >1.2.3
3858
3859
3860 const higherGT = (a, b, options) => {
3861 if (!a) return b;
3862 const comp = compare(a.semver, b.semver, options);
3863 return comp > 0 ? a : comp < 0 ? b : b.operator === '>' && a.operator === '>=' ? b : a;
3864 }; // <=1.2.3 is higher than <1.2.3
3865
3866
3867 const lowerLT = (a, b, options) => {
3868 if (!a) return b;
3869 const comp = compare(a.semver, b.semver, options);
3870 return comp < 0 ? a : comp > 0 ? b : b.operator === '<' && a.operator === '<=' ? b : a;
3871 };
3872
3873 var subset_1 = subset;
3874
3875 const internalRe = re$5.exports;
3876 var semver = {
3877 re: internalRe.re,
3878 src: internalRe.src,
3879 tokens: internalRe.t,
3880 SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
3881 SemVer: semver$1,
3882 compareIdentifiers: identifiers.compareIdentifiers,
3883 rcompareIdentifiers: identifiers.rcompareIdentifiers,
3884 parse: parse_1,
3885 valid: valid_1,
3886 clean: clean_1,
3887 inc: inc_1,
3888 diff: diff_1,
3889 major: major_1,
3890 minor: minor_1,
3891 patch: patch_1,
3892 prerelease: prerelease_1,
3893 compare: compare_1,
3894 rcompare: rcompare_1,
3895 compareLoose: compareLoose_1,
3896 compareBuild: compareBuild_1,
3897 sort: sort_1,
3898 rsort: rsort_1,
3899 gt: gt_1,
3900 lt: lt_1,
3901 eq: eq_1,
3902 neq: neq_1,
3903 gte: gte_1,
3904 lte: lte_1,
3905 cmp: cmp_1,
3906 coerce: coerce_1,
3907 Comparator: comparator,
3908 Range: range,
3909 satisfies: satisfies_1,
3910 toComparators: toComparators_1,
3911 maxSatisfying: maxSatisfying_1,
3912 minSatisfying: minSatisfying_1,
3913 minVersion: minVersion_1,
3914 validRange: valid,
3915 outside: outside_1,
3916 gtr: gtr_1,
3917 ltr: ltr_1,
3918 intersects: intersects_1,
3919 simplifyRange: simplify,
3920 subset: subset_1
3921 };
3922
3923 function adjustSpatial(item, encode, swap) {
3924 let t;
3925
3926 if (encode.x2) {
3927 if (encode.x) {
3928 if (swap && item.x > item.x2) {
3929 t = item.x;
3930 item.x = item.x2;
3931 item.x2 = t;
3932 }
3933
3934 item.width = item.x2 - item.x;
3935 } else {
3936 item.x = item.x2 - (item.width || 0);
3937 }
3938 }
3939
3940 if (encode.xc) {
3941 item.x = item.xc - (item.width || 0) / 2;
3942 }
3943
3944 if (encode.y2) {
3945 if (encode.y) {
3946 if (swap && item.y > item.y2) {
3947 t = item.y;
3948 item.y = item.y2;
3949 item.y2 = t;
3950 }
3951
3952 item.height = item.y2 - item.y;
3953 } else {
3954 item.y = item.y2 - (item.height || 0);
3955 }
3956 }
3957
3958 if (encode.yc) {
3959 item.y = item.yc - (item.height || 0) / 2;
3960 }
3961 }
3962
3963 var Constants = {
3964 NaN: NaN,
3965 E: Math.E,
3966 LN2: Math.LN2,
3967 LN10: Math.LN10,
3968 LOG2E: Math.LOG2E,
3969 LOG10E: Math.LOG10E,
3970 PI: Math.PI,
3971 SQRT1_2: Math.SQRT1_2,
3972 SQRT2: Math.SQRT2,
3973 MIN_VALUE: Number.MIN_VALUE,
3974 MAX_VALUE: Number.MAX_VALUE
3975 };
3976 var Ops = {
3977 '*': (a, b) => a * b,
3978 '+': (a, b) => a + b,
3979 '-': (a, b) => a - b,
3980 '/': (a, b) => a / b,
3981 '%': (a, b) => a % b,
3982 '>': (a, b) => a > b,
3983 '<': (a, b) => a < b,
3984 '<=': (a, b) => a <= b,
3985 '>=': (a, b) => a >= b,
3986 '==': (a, b) => a == b,
3987 '!=': (a, b) => a != b,
3988 '===': (a, b) => a === b,
3989 '!==': (a, b) => a !== b,
3990 '&': (a, b) => a & b,
3991 '|': (a, b) => a | b,
3992 '^': (a, b) => a ^ b,
3993 '<<': (a, b) => a << b,
3994 '>>': (a, b) => a >> b,
3995 '>>>': (a, b) => a >>> b
3996 };
3997 var Unary = {
3998 '+': a => +a,
3999 '-': a => -a,
4000 '~': a => ~a,
4001 '!': a => !a
4002 };
4003 const slice = Array.prototype.slice;
4004
4005 const apply = (m, args, cast) => {
4006 const obj = cast ? cast(args[0]) : args[0];
4007 return obj[m].apply(obj, slice.call(args, 1));
4008 };
4009
4010 const datetime = (y, m, d, H, M, S, ms) => new Date(y, m || 0, d != null ? d : 1, H || 0, M || 0, S || 0, ms || 0);
4011
4012 var Functions = {
4013 // math functions
4014 isNaN: Number.isNaN,
4015 isFinite: Number.isFinite,
4016 abs: Math.abs,
4017 acos: Math.acos,
4018 asin: Math.asin,
4019 atan: Math.atan,
4020 atan2: Math.atan2,
4021 ceil: Math.ceil,
4022 cos: Math.cos,
4023 exp: Math.exp,
4024 floor: Math.floor,
4025 log: Math.log,
4026 max: Math.max,
4027 min: Math.min,
4028 pow: Math.pow,
4029 random: Math.random,
4030 round: Math.round,
4031 sin: Math.sin,
4032 sqrt: Math.sqrt,
4033 tan: Math.tan,
4034 clamp: (a, b, c) => Math.max(b, Math.min(c, a)),
4035 // date functions
4036 now: Date.now,
4037 utc: Date.UTC,
4038 datetime: datetime,
4039 date: d => new Date(d).getDate(),
4040 day: d => new Date(d).getDay(),
4041 year: d => new Date(d).getFullYear(),
4042 month: d => new Date(d).getMonth(),
4043 hours: d => new Date(d).getHours(),
4044 minutes: d => new Date(d).getMinutes(),
4045 seconds: d => new Date(d).getSeconds(),
4046 milliseconds: d => new Date(d).getMilliseconds(),
4047 time: d => new Date(d).getTime(),
4048 timezoneoffset: d => new Date(d).getTimezoneOffset(),
4049 utcdate: d => new Date(d).getUTCDate(),
4050 utcday: d => new Date(d).getUTCDay(),
4051 utcyear: d => new Date(d).getUTCFullYear(),
4052 utcmonth: d => new Date(d).getUTCMonth(),
4053 utchours: d => new Date(d).getUTCHours(),
4054 utcminutes: d => new Date(d).getUTCMinutes(),
4055 utcseconds: d => new Date(d).getUTCSeconds(),
4056 utcmilliseconds: d => new Date(d).getUTCMilliseconds(),
4057 // sequence functions
4058 length: x => x.length,
4059 join: function () {
4060 return apply('join', arguments);
4061 },
4062 indexof: function () {
4063 return apply('indexOf', arguments);
4064 },
4065 lastindexof: function () {
4066 return apply('lastIndexOf', arguments);
4067 },
4068 slice: function () {
4069 return apply('slice', arguments);
4070 },
4071 reverse: x => x.slice().reverse(),
4072 // string functions
4073 parseFloat: parseFloat,
4074 parseInt: parseInt,
4075 upper: x => String(x).toUpperCase(),
4076 lower: x => String(x).toLowerCase(),
4077 substring: function () {
4078 return apply('substring', arguments, String);
4079 },
4080 split: function () {
4081 return apply('split', arguments, String);
4082 },
4083 replace: function () {
4084 return apply('replace', arguments, String);
4085 },
4086 trim: x => String(x).trim(),
4087 // regexp functions
4088 regexp: RegExp,
4089 test: (r, t) => RegExp(r).test(t)
4090 };
4091 const EventFunctions = ['view', 'item', 'group', 'xy', 'x', 'y'];
4092 const Visitors = {
4093 Literal: ($, n) => n.value,
4094 Identifier: ($, n) => {
4095 const id = n.name;
4096 return $.memberDepth > 0 ? id : id === 'datum' ? $.datum : id === 'event' ? $.event : id === 'item' ? $.item : Constants[id] || $.params['$' + id];
4097 },
4098 MemberExpression: ($, n) => {
4099 const d = !n.computed,
4100 o = $(n.object);
4101 if (d) $.memberDepth += 1;
4102 const p = $(n.property);
4103 if (d) $.memberDepth -= 1;
4104 return o[p];
4105 },
4106 CallExpression: ($, n) => {
4107 const args = n.arguments;
4108 let name = n.callee.name; // handle special internal functions used by encoders
4109 // re-route to corresponding standard function
4110
4111 if (name.startsWith('_')) {
4112 name = name.slice(1);
4113 } // special case "if" due to conditional evaluation of branches
4114
4115
4116 return name === 'if' ? $(args[0]) ? $(args[1]) : $(args[2]) : ($.fn[name] || Functions[name]).apply($.fn, args.map($));
4117 },
4118 ArrayExpression: ($, n) => n.elements.map($),
4119 BinaryExpression: ($, n) => Ops[n.operator]($(n.left), $(n.right)),
4120 UnaryExpression: ($, n) => Unary[n.operator]($(n.argument)),
4121 ConditionalExpression: ($, n) => $(n.test) ? $(n.consequent) : $(n.alternate),
4122 LogicalExpression: ($, n) => n.operator === '&&' ? $(n.left) && $(n.right) : $(n.left) || $(n.right),
4123 ObjectExpression: ($, n) => n.properties.reduce((o, p) => {
4124 $.memberDepth += 1;
4125 const k = $(p.key);
4126 $.memberDepth -= 1;
4127 o[k] = $(p.value);
4128 return o;
4129 }, {})
4130 };
4131
4132 function interpret(ast, fn, params, datum, event, item) {
4133 const $ = n => Visitors[n.type]($, n);
4134
4135 $.memberDepth = 0;
4136 $.fn = Object.create(fn);
4137 $.params = params;
4138 $.datum = datum;
4139 $.event = event;
4140 $.item = item; // route event functions to annotated vega event context
4141
4142 EventFunctions.forEach(f => $.fn[f] = (...args) => event.vega[f](...args));
4143 return $(ast);
4144 }
4145
4146 var expression = {
4147 /**
4148 * Parse an expression used to update an operator value.
4149 */
4150 operator(ctx, expr) {
4151 const ast = expr.ast,
4152 fn = ctx.functions;
4153 return _ => interpret(ast, fn, _);
4154 },
4155
4156 /**
4157 * Parse an expression provided as an operator parameter value.
4158 */
4159 parameter(ctx, expr) {
4160 const ast = expr.ast,
4161 fn = ctx.functions;
4162 return (datum, _) => interpret(ast, fn, _, datum);
4163 },
4164
4165 /**
4166 * Parse an expression applied to an event stream.
4167 */
4168 event(ctx, expr) {
4169 const ast = expr.ast,
4170 fn = ctx.functions;
4171 return event => interpret(ast, fn, undefined, undefined, event);
4172 },
4173
4174 /**
4175 * Parse an expression used to handle an event-driven operator update.
4176 */
4177 handler(ctx, expr) {
4178 const ast = expr.ast,
4179 fn = ctx.functions;
4180 return (_, event) => {
4181 const datum = event.item && event.item.datum;
4182 return interpret(ast, fn, _, datum, event);
4183 };
4184 },
4185
4186 /**
4187 * Parse an expression that performs visual encoding.
4188 */
4189 encode(ctx, encode) {
4190 const {
4191 marktype,
4192 channels
4193 } = encode,
4194 fn = ctx.functions,
4195 swap = marktype === 'group' || marktype === 'image' || marktype === 'rect';
4196 return (item, _) => {
4197 const datum = item.datum;
4198 let m = 0,
4199 v;
4200
4201 for (const name in channels) {
4202 v = interpret(channels[name].ast, fn, _, datum, undefined, item);
4203
4204 if (item[name] !== v) {
4205 item[name] = v;
4206 m = 1;
4207 }
4208 }
4209
4210 if (marktype !== 'rule') {
4211 adjustSpatial(item, channels, swap);
4212 }
4213
4214 return m;
4215 };
4216 }
4217
4218 };
4219
4220 function e(e) {
4221 const [n, r] = /schema\/([\w-]+)\/([\w\.\-]+)\.json$/g.exec(e).slice(1, 3);
4222 return {
4223 library: n,
4224 version: r
4225 };
4226 }
4227
4228 var name = "vega-themes";
4229 var version = "2.10.0";
4230 var description = "Themes for stylized Vega and Vega-Lite visualizations.";
4231 var keywords = ["vega", "vega-lite", "themes", "style"];
4232 var license = "BSD-3-Clause";
4233 var author = {
4234 name: "UW Interactive Data Lab",
4235 url: "https://idl.cs.washington.edu"
4236 };
4237 var contributors = [{
4238 name: "Emily Gu",
4239 url: "https://github.com/emilygu"
4240 }, {
4241 name: "Arvind Satyanarayan",
4242 url: "http://arvindsatya.com"
4243 }, {
4244 name: "Jeffrey Heer",
4245 url: "https://idl.cs.washington.edu"
4246 }, {
4247 name: "Dominik Moritz",
4248 url: "https://www.domoritz.de"
4249 }];
4250 var main = "build/vega-themes.js";
4251 var module = "build/vega-themes.module.js";
4252 var unpkg = "build/vega-themes.min.js";
4253 var jsdelivr = "build/vega-themes.min.js";
4254 var types = "build/vega-themes.module.d.ts";
4255 var repository = {
4256 type: "git",
4257 url: "https://github.com/vega/vega-themes.git"
4258 };
4259 var files = ["src", "build"];
4260 var scripts = {
4261 prebuild: "yarn clean",
4262 build: "rollup -c",
4263 clean: "rimraf build && rimraf examples/build",
4264 "copy:data": "rsync -r node_modules/vega-datasets/data/* examples/data",
4265 "copy:build": "rsync -r build/* examples/build",
4266 "deploy:gh": "yarn build && mkdir -p examples/build && rsync -r build/* examples/build && gh-pages -d examples",
4267 prepublishOnly: "yarn clean && yarn build",
4268 preversion: "yarn lint",
4269 serve: "browser-sync start -s -f build examples --serveStatic examples",
4270 start: "yarn build && concurrently --kill-others -n Server,Rollup 'yarn serve' 'rollup -c -w'",
4271 prepare: "beemo create-config",
4272 eslintbase: "beemo eslint .",
4273 format: "yarn eslintbase --fix",
4274 lint: "yarn eslintbase"
4275 };
4276 var devDependencies = {
4277 "@rollup/plugin-json": "^4.1.0",
4278 "@rollup/plugin-node-resolve": "^11.2.0",
4279 "@wessberg/rollup-plugin-ts": "^1.3.8",
4280 "browser-sync": "^2.26.14",
4281 concurrently: "^6.0.0",
4282 "gh-pages": "^3.1.0",
4283 rollup: "^2.39.1",
4284 "rollup-plugin-bundle-size": "^1.0.3",
4285 "rollup-plugin-terser": "^7.0.2",
4286 typescript: "^4.2.2",
4287 vega: "^5.19.1",
4288 "vega-lite": "^5.0.0",
4289 "vega-lite-dev-config": "^0.16.1"
4290 };
4291 var peerDependencies = {
4292 vega: "*",
4293 "vega-lite": "*"
4294 };
4295 var pkg = {
4296 name: name,
4297 version: version,
4298 description: description,
4299 keywords: keywords,
4300 license: license,
4301 author: author,
4302 contributors: contributors,
4303 main: main,
4304 module: module,
4305 unpkg: unpkg,
4306 jsdelivr: jsdelivr,
4307 types: types,
4308 repository: repository,
4309 files: files,
4310 scripts: scripts,
4311 devDependencies: devDependencies,
4312 peerDependencies: peerDependencies
4313 };
4314 const lightColor = '#fff';
4315 const medColor = '#888';
4316 const darkTheme = {
4317 background: '#333',
4318 title: {
4319 color: lightColor,
4320 subtitleColor: lightColor
4321 },
4322 style: {
4323 'guide-label': {
4324 fill: lightColor
4325 },
4326 'guide-title': {
4327 fill: lightColor
4328 }
4329 },
4330 axis: {
4331 domainColor: lightColor,
4332 gridColor: medColor,
4333 tickColor: lightColor
4334 }
4335 };
4336 const markColor = '#4572a7';
4337 const excelTheme = {
4338 background: '#fff',
4339 arc: {
4340 fill: markColor
4341 },
4342 area: {
4343 fill: markColor
4344 },
4345 line: {
4346 stroke: markColor,
4347 strokeWidth: 2
4348 },
4349 path: {
4350 stroke: markColor
4351 },
4352 rect: {
4353 fill: markColor
4354 },
4355 shape: {
4356 stroke: markColor
4357 },
4358 symbol: {
4359 fill: markColor,
4360 strokeWidth: 1.5,
4361 size: 50
4362 },
4363 axis: {
4364 bandPosition: 0.5,
4365 grid: true,
4366 gridColor: '#000000',
4367 gridOpacity: 1,
4368 gridWidth: 0.5,
4369 labelPadding: 10,
4370 tickSize: 5,
4371 tickWidth: 0.5
4372 },
4373 axisBand: {
4374 grid: false,
4375 tickExtra: true
4376 },
4377 legend: {
4378 labelBaseline: 'middle',
4379 labelFontSize: 11,
4380 symbolSize: 50,
4381 symbolType: 'square'
4382 },
4383 range: {
4384 category: ['#4572a7', '#aa4643', '#8aa453', '#71598e', '#4598ae', '#d98445', '#94aace', '#d09393', '#b9cc98', '#a99cbc']
4385 }
4386 };
4387 const markColor$1 = '#30a2da';
4388 const axisColor = '#cbcbcb';
4389 const guideLabelColor = '#999';
4390 const guideTitleColor = '#333';
4391 const backgroundColor = '#f0f0f0';
4392 const blackTitle = '#333';
4393 const fiveThirtyEightTheme = {
4394 arc: {
4395 fill: markColor$1
4396 },
4397 area: {
4398 fill: markColor$1
4399 },
4400 axis: {
4401 domainColor: axisColor,
4402 grid: true,
4403 gridColor: axisColor,
4404 gridWidth: 1,
4405 labelColor: guideLabelColor,
4406 labelFontSize: 10,
4407 titleColor: guideTitleColor,
4408 tickColor: axisColor,
4409 tickSize: 10,
4410 titleFontSize: 14,
4411 titlePadding: 10,
4412 labelPadding: 4
4413 },
4414 axisBand: {
4415 grid: false
4416 },
4417 background: backgroundColor,
4418 group: {
4419 fill: backgroundColor
4420 },
4421 legend: {
4422 labelColor: blackTitle,
4423 labelFontSize: 11,
4424 padding: 1,
4425 symbolSize: 30,
4426 symbolType: 'square',
4427 titleColor: blackTitle,
4428 titleFontSize: 14,
4429 titlePadding: 10
4430 },
4431 line: {
4432 stroke: markColor$1,
4433 strokeWidth: 2
4434 },
4435 path: {
4436 stroke: markColor$1,
4437 strokeWidth: 0.5
4438 },
4439 rect: {
4440 fill: markColor$1
4441 },
4442 range: {
4443 category: ['#30a2da', '#fc4f30', '#e5ae38', '#6d904f', '#8b8b8b', '#b96db8', '#ff9e27', '#56cc60', '#52d2ca', '#52689e', '#545454', '#9fe4f8'],
4444 diverging: ['#cc0020', '#e77866', '#f6e7e1', '#d6e8ed', '#91bfd9', '#1d78b5'],
4445 heatmap: ['#d6e8ed', '#cee0e5', '#91bfd9', '#549cc6', '#1d78b5']
4446 },
4447 point: {
4448 filled: true,
4449 shape: 'circle'
4450 },
4451 shape: {
4452 stroke: markColor$1
4453 },
4454 bar: {
4455 binSpacing: 2,
4456 fill: markColor$1,
4457 stroke: null
4458 },
4459 title: {
4460 anchor: 'start',
4461 fontSize: 24,
4462 fontWeight: 600,
4463 offset: 20
4464 }
4465 };
4466 const markColor$2 = '#000';
4467 const ggplot2Theme = {
4468 group: {
4469 fill: '#e5e5e5'
4470 },
4471 arc: {
4472 fill: markColor$2
4473 },
4474 area: {
4475 fill: markColor$2
4476 },
4477 line: {
4478 stroke: markColor$2
4479 },
4480 path: {
4481 stroke: markColor$2
4482 },
4483 rect: {
4484 fill: markColor$2
4485 },
4486 shape: {
4487 stroke: markColor$2
4488 },
4489 symbol: {
4490 fill: markColor$2,
4491 size: 40
4492 },
4493 axis: {
4494 domain: false,
4495 grid: true,
4496 gridColor: '#FFFFFF',
4497 gridOpacity: 1,
4498 labelColor: '#7F7F7F',
4499 labelPadding: 4,
4500 tickColor: '#7F7F7F',
4501 tickSize: 5.67,
4502 titleFontSize: 16,
4503 titleFontWeight: 'normal'
4504 },
4505 legend: {
4506 labelBaseline: 'middle',
4507 labelFontSize: 11,
4508 symbolSize: 40
4509 },
4510 range: {
4511 category: ['#000000', '#7F7F7F', '#1A1A1A', '#999999', '#333333', '#B0B0B0', '#4D4D4D', '#C9C9C9', '#666666', '#DCDCDC']
4512 }
4513 };
4514 const headlineFontSize = 22;
4515 const headlineFontWeight = 'normal';
4516 const labelFont = 'Benton Gothic, sans-serif';
4517 const labelFontSize = 11.5;
4518 const labelFontWeight = 'normal';
4519 const markColor$3 = '#82c6df'; // const markHighlight = '#006d8f';
4520 // const markDemocrat = '#5789b8';
4521 // const markRepublican = '#d94f54';
4522
4523 const titleFont = 'Benton Gothic Bold, sans-serif';
4524 const titleFontWeight = 'normal';
4525 const titleFontSize = 13;
4526 const colorSchemes = {
4527 'category-6': ['#ec8431', '#829eb1', '#c89d29', '#3580b1', '#adc839', '#ab7fb4'],
4528 'fire-7': ['#fbf2c7', '#f9e39c', '#f8d36e', '#f4bb6a', '#e68a4f', '#d15a40', '#ab4232'],
4529 'fireandice-6': ['#e68a4f', '#f4bb6a', '#f9e39c', '#dadfe2', '#a6b7c6', '#849eae'],
4530 'ice-7': ['#edefee', '#dadfe2', '#c4ccd2', '#a6b7c6', '#849eae', '#607785', '#47525d']
4531 };
4532 const latimesTheme = {
4533 background: '#ffffff',
4534 title: {
4535 anchor: 'start',
4536 color: '#000000',
4537 font: titleFont,
4538 fontSize: headlineFontSize,
4539 fontWeight: headlineFontWeight
4540 },
4541 arc: {
4542 fill: markColor$3
4543 },
4544 area: {
4545 fill: markColor$3
4546 },
4547 line: {
4548 stroke: markColor$3,
4549 strokeWidth: 2
4550 },
4551 path: {
4552 stroke: markColor$3
4553 },
4554 rect: {
4555 fill: markColor$3
4556 },
4557 shape: {
4558 stroke: markColor$3
4559 },
4560 symbol: {
4561 fill: markColor$3,
4562 size: 30
4563 },
4564 axis: {
4565 labelFont,
4566 labelFontSize,
4567 labelFontWeight,
4568 titleFont,
4569 titleFontSize,
4570 titleFontWeight
4571 },
4572 axisX: {
4573 labelAngle: 0,
4574 labelPadding: 4,
4575 tickSize: 3
4576 },
4577 axisY: {
4578 labelBaseline: 'middle',
4579 maxExtent: 45,
4580 minExtent: 45,
4581 tickSize: 2,
4582 titleAlign: 'left',
4583 titleAngle: 0,
4584 titleX: -45,
4585 titleY: -11
4586 },
4587 legend: {
4588 labelFont,
4589 labelFontSize,
4590 symbolType: 'square',
4591 titleFont,
4592 titleFontSize,
4593 titleFontWeight
4594 },
4595 range: {
4596 category: colorSchemes['category-6'],
4597 diverging: colorSchemes['fireandice-6'],
4598 heatmap: colorSchemes['fire-7'],
4599 ordinal: colorSchemes['fire-7'],
4600 ramp: colorSchemes['fire-7']
4601 }
4602 };
4603 const markColor$4 = '#ab5787';
4604 const axisColor$1 = '#979797';
4605 const quartzTheme = {
4606 background: '#f9f9f9',
4607 arc: {
4608 fill: markColor$4
4609 },
4610 area: {
4611 fill: markColor$4
4612 },
4613 line: {
4614 stroke: markColor$4
4615 },
4616 path: {
4617 stroke: markColor$4
4618 },
4619 rect: {
4620 fill: markColor$4
4621 },
4622 shape: {
4623 stroke: markColor$4
4624 },
4625 symbol: {
4626 fill: markColor$4,
4627 size: 30
4628 },
4629 axis: {
4630 domainColor: axisColor$1,
4631 domainWidth: 0.5,
4632 gridWidth: 0.2,
4633 labelColor: axisColor$1,
4634 tickColor: axisColor$1,
4635 tickWidth: 0.2,
4636 titleColor: axisColor$1
4637 },
4638 axisBand: {
4639 grid: false
4640 },
4641 axisX: {
4642 grid: true,
4643 tickSize: 10
4644 },
4645 axisY: {
4646 domain: false,
4647 grid: true,
4648 tickSize: 0
4649 },
4650 legend: {
4651 labelFontSize: 11,
4652 padding: 1,
4653 symbolSize: 30,
4654 symbolType: 'square'
4655 },
4656 range: {
4657 category: ['#ab5787', '#51b2e5', '#703c5c', '#168dd9', '#d190b6', '#00609f', '#d365ba', '#154866', '#666666', '#c4c4c4']
4658 }
4659 };
4660 const markColor$5 = '#3e5c69';
4661 const voxTheme = {
4662 background: '#fff',
4663 arc: {
4664 fill: markColor$5
4665 },
4666 area: {
4667 fill: markColor$5
4668 },
4669 line: {
4670 stroke: markColor$5
4671 },
4672 path: {
4673 stroke: markColor$5
4674 },
4675 rect: {
4676 fill: markColor$5
4677 },
4678 shape: {
4679 stroke: markColor$5
4680 },
4681 symbol: {
4682 fill: markColor$5
4683 },
4684 axis: {
4685 domainWidth: 0.5,
4686 grid: true,
4687 labelPadding: 2,
4688 tickSize: 5,
4689 tickWidth: 0.5,
4690 titleFontWeight: 'normal'
4691 },
4692 axisBand: {
4693 grid: false
4694 },
4695 axisX: {
4696 gridWidth: 0.2
4697 },
4698 axisY: {
4699 gridDash: [3],
4700 gridWidth: 0.4
4701 },
4702 legend: {
4703 labelFontSize: 11,
4704 padding: 1,
4705 symbolType: 'square'
4706 },
4707 range: {
4708 category: ['#3e5c69', '#6793a6', '#182429', '#0570b0', '#3690c0', '#74a9cf', '#a6bddb', '#e2ddf2']
4709 }
4710 };
4711 const markColor$6 = '#1696d2';
4712 const axisColor$2 = '#000000';
4713 const backgroundColor$1 = '#FFFFFF';
4714 const font = 'Lato';
4715 const labelFont$1 = 'Lato';
4716 const sourceFont = 'Lato';
4717 const gridColor = '#DEDDDD';
4718 const titleFontSize$1 = 18;
4719 const colorSchemes$1 = {
4720 'main-colors': ['#1696d2', '#d2d2d2', '#000000', '#fdbf11', '#ec008b', '#55b748', '#5c5859', '#db2b27'],
4721 'shades-blue': ['#CFE8F3', '#A2D4EC', '#73BFE2', '#46ABDB', '#1696D2', '#12719E', '#0A4C6A', '#062635'],
4722 'shades-gray': ['#F5F5F5', '#ECECEC', '#E3E3E3', '#DCDBDB', '#D2D2D2', '#9D9D9D', '#696969', '#353535'],
4723 'shades-yellow': ['#FFF2CF', '#FCE39E', '#FDD870', '#FCCB41', '#FDBF11', '#E88E2D', '#CA5800', '#843215'],
4724 'shades-magenta': ['#F5CBDF', '#EB99C2', '#E46AA7', '#E54096', '#EC008B', '#AF1F6B', '#761548', '#351123'],
4725 'shades-green': ['#DCEDD9', '#BCDEB4', '#98CF90', '#78C26D', '#55B748', '#408941', '#2C5C2D', '#1A2E19'],
4726 'shades-black': ['#D5D5D4', '#ADABAC', '#848081', '#5C5859', '#332D2F', '#262223', '#1A1717', '#0E0C0D'],
4727 'shades-red': ['#F8D5D4', '#F1AAA9', '#E9807D', '#E25552', '#DB2B27', '#A4201D', '#6E1614', '#370B0A'],
4728 'one-group': ['#1696d2', '#000000'],
4729 'two-groups-cat-1': ['#1696d2', '#000000'],
4730 'two-groups-cat-2': ['#1696d2', '#fdbf11'],
4731 'two-groups-cat-3': ['#1696d2', '#db2b27'],
4732 'two-groups-seq': ['#a2d4ec', '#1696d2'],
4733 'three-groups-cat': ['#1696d2', '#fdbf11', '#000000'],
4734 'three-groups-seq': ['#a2d4ec', '#1696d2', '#0a4c6a'],
4735 'four-groups-cat-1': ['#000000', '#d2d2d2', '#fdbf11', '#1696d2'],
4736 'four-groups-cat-2': ['#1696d2', '#ec0008b', '#fdbf11', '#5c5859'],
4737 'four-groups-seq': ['#cfe8f3', '#73bf42', '#1696d2', '#0a4c6a'],
4738 'five-groups-cat-1': ['#1696d2', '#fdbf11', '#d2d2d2', '#ec008b', '#000000'],
4739 'five-groups-cat-2': ['#1696d2', '#0a4c6a', '#d2d2d2', '#fdbf11', '#332d2f'],
4740 'five-groups-seq': ['#cfe8f3', '#73bf42', '#1696d2', '#0a4c6a', '#000000'],
4741 'six-groups-cat-1': ['#1696d2', '#ec008b', '#fdbf11', '#000000', '#d2d2d2', '#55b748'],
4742 'six-groups-cat-2': ['#1696d2', '#d2d2d2', '#ec008b', '#fdbf11', '#332d2f', '#0a4c6a'],
4743 'six-groups-seq': ['#cfe8f3', '#a2d4ec', '#73bfe2', '#46abdb', '#1696d2', '#12719e'],
4744 'diverging-colors': ['#ca5800', '#fdbf11', '#fdd870', '#fff2cf', '#cfe8f3', '#73bfe2', '#1696d2', '#0a4c6a']
4745 };
4746 const urbanInstituteTheme = {
4747 background: backgroundColor$1,
4748 title: {
4749 anchor: 'start',
4750 fontSize: titleFontSize$1,
4751 font: font
4752 },
4753 axisX: {
4754 domain: true,
4755 domainColor: axisColor$2,
4756 domainWidth: 1,
4757 grid: false,
4758 labelFontSize: 12,
4759 labelFont: labelFont$1,
4760 labelAngle: 0,
4761 tickColor: axisColor$2,
4762 tickSize: 5,
4763 titleFontSize: 12,
4764 titlePadding: 10,
4765 titleFont: font
4766 },
4767 axisY: {
4768 domain: false,
4769 domainWidth: 1,
4770 grid: true,
4771 gridColor: gridColor,
4772 gridWidth: 1,
4773 labelFontSize: 12,
4774 labelFont: labelFont$1,
4775 labelPadding: 8,
4776 ticks: false,
4777 titleFontSize: 12,
4778 titlePadding: 10,
4779 titleFont: font,
4780 titleAngle: 0,
4781 titleY: -10,
4782 titleX: 18
4783 },
4784 legend: {
4785 labelFontSize: 12,
4786 labelFont: labelFont$1,
4787 symbolSize: 100,
4788 titleFontSize: 12,
4789 titlePadding: 10,
4790 titleFont: font,
4791 orient: 'right',
4792 offset: 10
4793 },
4794 view: {
4795 stroke: 'transparent'
4796 },
4797 range: {
4798 category: colorSchemes$1['six-groups-cat-1'],
4799 diverging: colorSchemes$1['diverging-colors'],
4800 heatmap: colorSchemes$1['diverging-colors'],
4801 ordinal: colorSchemes$1['six-groups-seq'],
4802 ramp: colorSchemes$1['shades-blue']
4803 },
4804 area: {
4805 fill: markColor$6
4806 },
4807 rect: {
4808 fill: markColor$6
4809 },
4810 line: {
4811 color: markColor$6,
4812 stroke: markColor$6,
4813 strokeWidth: 5
4814 },
4815 trail: {
4816 color: markColor$6,
4817 stroke: markColor$6,
4818 strokeWidth: 0,
4819 size: 1
4820 },
4821 path: {
4822 stroke: markColor$6,
4823 strokeWidth: 0.5
4824 },
4825 point: {
4826 filled: true
4827 },
4828 text: {
4829 font: sourceFont,
4830 color: markColor$6,
4831 fontSize: 11,
4832 align: 'center',
4833 fontWeight: 400,
4834 size: 11
4835 },
4836 style: {
4837 bar: {
4838 fill: markColor$6,
4839 stroke: null
4840 }
4841 },
4842 arc: {
4843 fill: markColor$6
4844 },
4845 shape: {
4846 stroke: markColor$6
4847 },
4848 symbol: {
4849 fill: markColor$6,
4850 size: 30
4851 }
4852 };
4853 /**
4854 * Copyright 2020 Google LLC.
4855 *
4856 * Use of this source code is governed by a BSD-style
4857 * license that can be found in the LICENSE file or at
4858 * https://developers.google.com/open-source/licenses/bsd
4859 */
4860
4861 const markColor$7 = '#3366CC';
4862 const gridColor$1 = '#ccc';
4863 const defaultFont = 'Arial, sans-serif';
4864 const googlechartsTheme = {
4865 arc: {
4866 fill: markColor$7
4867 },
4868 area: {
4869 fill: markColor$7
4870 },
4871 path: {
4872 stroke: markColor$7
4873 },
4874 rect: {
4875 fill: markColor$7
4876 },
4877 shape: {
4878 stroke: markColor$7
4879 },
4880 symbol: {
4881 stroke: markColor$7
4882 },
4883 circle: {
4884 fill: markColor$7
4885 },
4886 background: '#fff',
4887 padding: {
4888 top: 10,
4889 right: 10,
4890 bottom: 10,
4891 left: 10
4892 },
4893 style: {
4894 'guide-label': {
4895 font: defaultFont,
4896 fontSize: 12
4897 },
4898 'guide-title': {
4899 font: defaultFont,
4900 fontSize: 12
4901 },
4902 'group-title': {
4903 font: defaultFont,
4904 fontSize: 12
4905 }
4906 },
4907 title: {
4908 font: defaultFont,
4909 fontSize: 14,
4910 fontWeight: 'bold',
4911 dy: -3,
4912 anchor: 'start'
4913 },
4914 axis: {
4915 gridColor: gridColor$1,
4916 tickColor: gridColor$1,
4917 domain: false,
4918 grid: true
4919 },
4920 range: {
4921 category: ['#4285F4', '#DB4437', '#F4B400', '#0F9D58', '#AB47BC', '#00ACC1', '#FF7043', '#9E9D24', '#5C6BC0', '#F06292', '#00796B', '#C2185B'],
4922 heatmap: ['#c6dafc', '#5e97f6', '#2a56c6']
4923 }
4924 };
4925 const version$1 = pkg.version;
4926
4927 var themes = /*#__PURE__*/Object.freeze({
4928 __proto__: null,
4929 dark: darkTheme,
4930 excel: excelTheme,
4931 fivethirtyeight: fiveThirtyEightTheme,
4932 ggplot2: ggplot2Theme,
4933 googlecharts: googlechartsTheme,
4934 latimes: latimesTheme,
4935 quartz: quartzTheme,
4936 urbaninstitute: urbanInstituteTheme,
4937 version: version$1,
4938 vox: voxTheme
4939 });
4940
4941 function accessor(fn, fields, name) {
4942 fn.fields = fields || [];
4943 fn.fname = name;
4944 return fn;
4945 }
4946
4947 function getter(path) {
4948 return path.length === 1 ? get1(path[0]) : getN(path);
4949 }
4950
4951 const get1 = field => function (obj) {
4952 return obj[field];
4953 };
4954
4955 const getN = path => {
4956 const len = path.length;
4957 return function (obj) {
4958 for (let i = 0; i < len; ++i) {
4959 obj = obj[path[i]];
4960 }
4961
4962 return obj;
4963 };
4964 };
4965
4966 function error(message) {
4967 throw Error(message);
4968 }
4969
4970 function splitAccessPath(p) {
4971 const path = [],
4972 n = p.length;
4973 let q = null,
4974 b = 0,
4975 s = '',
4976 i,
4977 j,
4978 c;
4979 p = p + '';
4980
4981 function push() {
4982 path.push(s + p.substring(i, j));
4983 s = '';
4984 i = j + 1;
4985 }
4986
4987 for (i = j = 0; j < n; ++j) {
4988 c = p[j];
4989
4990 if (c === '\\') {
4991 s += p.substring(i, j);
4992 s += p.substring(++j, ++j);
4993 i = j;
4994 } else if (c === q) {
4995 push();
4996 q = null;
4997 b = -1;
4998 } else if (q) {
4999 continue;
5000 } else if (i === b && c === '"') {
5001 i = j + 1;
5002 q = c;
5003 } else if (i === b && c === "'") {
5004 i = j + 1;
5005 q = c;
5006 } else if (c === '.' && !b) {
5007 if (j > i) {
5008 push();
5009 } else {
5010 i = j + 1;
5011 }
5012 } else if (c === '[') {
5013 if (j > i) push();
5014 b = i = j + 1;
5015 } else if (c === ']') {
5016 if (!b) error('Access path missing open bracket: ' + p);
5017 if (b > 0) push();
5018 b = 0;
5019 i = j + 1;
5020 }
5021 }
5022
5023 if (b) error('Access path missing closing bracket: ' + p);
5024 if (q) error('Access path missing closing quote: ' + p);
5025
5026 if (j > i) {
5027 j++;
5028 push();
5029 }
5030
5031 return path;
5032 }
5033
5034 function field(field, name, opt) {
5035 const path = splitAccessPath(field);
5036 field = path.length === 1 ? path[0] : field;
5037 return accessor((opt && opt.get || getter)(path), [field], name || field);
5038 }
5039
5040 field('id');
5041 accessor(_ => _, [], 'identity');
5042 accessor(() => 0, [], 'zero');
5043 accessor(() => 1, [], 'one');
5044 accessor(() => true, [], 'true');
5045 accessor(() => false, [], 'false');
5046
5047 var isArray = Array.isArray;
5048
5049 function isObject(_) {
5050 return _ === Object(_);
5051 }
5052
5053 function isString(_) {
5054 return typeof _ === 'string';
5055 }
5056
5057 /*! *****************************************************************************
5058 Copyright (c) Microsoft Corporation.
5059
5060 Permission to use, copy, modify, and/or distribute this software for any
5061 purpose with or without fee is hereby granted.
5062
5063 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
5064 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
5065 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
5066 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
5067 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
5068 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
5069 PERFORMANCE OF THIS SOFTWARE.
5070 ***************************************************************************** */
5071
5072 function __rest(s, e) {
5073 var t = {};
5074
5075 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
5076
5077 if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
5078 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
5079 }
5080 return t;
5081 }
5082 /**
5083 * Format the value to be shown in the tooltip.
5084 *
5085 * @param value The value to show in the tooltip.
5086 * @param valueToHtml Function to convert a single cell value to an HTML string
5087 */
5088
5089
5090 function formatValue(value, valueToHtml, maxDepth) {
5091 if (isArray(value)) {
5092 return `[${value.map(v => valueToHtml(isString(v) ? v : stringify(v, maxDepth))).join(', ')}]`;
5093 }
5094
5095 if (isObject(value)) {
5096 let content = '';
5097
5098 const _a = value,
5099 {
5100 title,
5101 image
5102 } = _a,
5103 rest = __rest(_a, ["title", "image"]);
5104
5105 if (title) {
5106 content += `<h2>${valueToHtml(title)}</h2>`;
5107 }
5108
5109 if (image) {
5110 content += `<img src="${valueToHtml(image)}">`;
5111 }
5112
5113 const keys = Object.keys(rest);
5114
5115 if (keys.length > 0) {
5116 content += '<table>';
5117
5118 for (const key of keys) {
5119 let val = rest[key]; // ignore undefined properties
5120
5121 if (val === undefined) {
5122 continue;
5123 }
5124
5125 if (isObject(val)) {
5126 val = stringify(val, maxDepth);
5127 }
5128
5129 content += `<tr><td class="key">${valueToHtml(key)}:</td><td class="value">${valueToHtml(val)}</td></tr>`;
5130 }
5131
5132 content += `</table>`;
5133 }
5134
5135 return content || '{}'; // show empty object if there are no properties
5136 }
5137
5138 return valueToHtml(value);
5139 }
5140
5141 function replacer(maxDepth) {
5142 const stack = [];
5143 return function (key, value) {
5144 if (typeof value !== 'object' || value === null) {
5145 return value;
5146 }
5147
5148 const pos = stack.indexOf(this) + 1;
5149 stack.length = pos;
5150
5151 if (stack.length > maxDepth) {
5152 return '[Object]';
5153 }
5154
5155 if (stack.indexOf(value) >= 0) {
5156 return '[Circular]';
5157 }
5158
5159 stack.push(value);
5160 return value;
5161 };
5162 }
5163 /**
5164 * Stringify any JS object to valid JSON
5165 */
5166
5167
5168 function stringify(obj, maxDepth) {
5169 return JSON.stringify(obj, replacer(maxDepth));
5170 } // generated with build-style.sh
5171
5172
5173 var defaultStyle = `#vg-tooltip-element {
5174 visibility: hidden;
5175 padding: 8px;
5176 position: fixed;
5177 z-index: 1000;
5178 font-family: sans-serif;
5179 font-size: 11px;
5180 border-radius: 3px;
5181 box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
5182 /* The default theme is the light theme. */
5183 background-color: rgba(255, 255, 255, 0.95);
5184 border: 1px solid #d9d9d9;
5185 color: black; }
5186 #vg-tooltip-element.visible {
5187 visibility: visible; }
5188 #vg-tooltip-element h2 {
5189 margin-top: 0;
5190 margin-bottom: 10px;
5191 font-size: 13px; }
5192 #vg-tooltip-element img {
5193 max-width: 200px;
5194 max-height: 200px; }
5195 #vg-tooltip-element table {
5196 border-spacing: 0; }
5197 #vg-tooltip-element table tr {
5198 border: none; }
5199 #vg-tooltip-element table tr td {
5200 overflow: hidden;
5201 text-overflow: ellipsis;
5202 padding-top: 2px;
5203 padding-bottom: 2px; }
5204 #vg-tooltip-element table tr td.key {
5205 color: #808080;
5206 max-width: 150px;
5207 text-align: right;
5208 padding-right: 4px; }
5209 #vg-tooltip-element table tr td.value {
5210 display: block;
5211 max-width: 300px;
5212 max-height: 7em;
5213 text-align: left; }
5214 #vg-tooltip-element.dark-theme {
5215 background-color: rgba(32, 32, 32, 0.9);
5216 border: 1px solid #f5f5f5;
5217 color: white; }
5218 #vg-tooltip-element.dark-theme td.key {
5219 color: #bfbfbf; }
5220`;
5221 const EL_ID = 'vg-tooltip-element';
5222 const DEFAULT_OPTIONS = {
5223 /**
5224 * X offset.
5225 */
5226 offsetX: 10,
5227
5228 /**
5229 * Y offset.
5230 */
5231 offsetY: 10,
5232
5233 /**
5234 * ID of the tooltip element.
5235 */
5236 id: EL_ID,
5237
5238 /**
5239 * ID of the tooltip CSS style.
5240 */
5241 styleId: 'vega-tooltip-style',
5242
5243 /**
5244 * The name of the theme. You can use the CSS class called [THEME]-theme to style the tooltips.
5245 *
5246 * There are two predefined themes: "light" (default) and "dark".
5247 */
5248 theme: 'light',
5249
5250 /**
5251 * Do not use the default styles provided by Vega Tooltip. If you enable this option, you need to use your own styles. It is not necessary to disable the default style when using a custom theme.
5252 */
5253 disableDefaultStyle: false,
5254
5255 /**
5256 * HTML sanitizer function that removes dangerous HTML to prevent XSS.
5257 *
5258 * This should be a function from string to string. You may replace it with a formatter such as a markdown formatter.
5259 */
5260 sanitize: escapeHTML,
5261
5262 /**
5263 * The maximum recursion depth when printing objects in the tooltip.
5264 */
5265 maxDepth: 2,
5266
5267 /**
5268 * A function to customize the rendered HTML of the tooltip.
5269 * @param value A value string, or object of value strings keyed by field
5270 * @param sanitize The `sanitize` function from `options.sanitize`
5271 * @returns {string} The returned string will become the `innerHTML` of the tooltip element
5272 */
5273 formatTooltip: formatValue
5274 };
5275 /**
5276 * Escape special HTML characters.
5277 *
5278 * @param value A value to convert to string and HTML-escape.
5279 */
5280
5281 function escapeHTML(value) {
5282 return String(value).replace(/&/g, '&amp;').replace(/</g, '&lt;');
5283 }
5284
5285 function createDefaultStyle(id) {
5286 // Just in case this id comes from a user, ensure these is no security issues
5287 if (!/^[A-Za-z]+[-:.\w]*$/.test(id)) {
5288 throw new Error('Invalid HTML ID');
5289 }
5290
5291 return defaultStyle.toString().replace(EL_ID, id);
5292 }
5293 /**
5294 * Position the tooltip
5295 *
5296 * @param event The mouse event.
5297 * @param tooltipBox
5298 * @param offsetX Horizontal offset.
5299 * @param offsetY Vertical offset.
5300 */
5301
5302
5303 function calculatePosition(event, tooltipBox, offsetX, offsetY) {
5304 let x = event.clientX + offsetX;
5305
5306 if (x + tooltipBox.width > window.innerWidth) {
5307 x = +event.clientX - offsetX - tooltipBox.width;
5308 }
5309
5310 let y = event.clientY + offsetY;
5311
5312 if (y + tooltipBox.height > window.innerHeight) {
5313 y = +event.clientY - offsetY - tooltipBox.height;
5314 }
5315
5316 return {
5317 x,
5318 y
5319 };
5320 }
5321 /**
5322 * The tooltip handler class.
5323 */
5324
5325
5326 class Handler {
5327 /**
5328 * Create the tooltip handler and initialize the element and style.
5329 *
5330 * @param options Tooltip Options
5331 */
5332 constructor(options) {
5333 this.options = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
5334 const elementId = this.options.id;
5335 this.el = null; // bind this to call
5336
5337 this.call = this.tooltipHandler.bind(this); // prepend a default stylesheet for tooltips to the head
5338
5339 if (!this.options.disableDefaultStyle && !document.getElementById(this.options.styleId)) {
5340 const style = document.createElement('style');
5341 style.setAttribute('id', this.options.styleId);
5342 style.innerHTML = createDefaultStyle(elementId);
5343 const head = document.head;
5344
5345 if (head.childNodes.length > 0) {
5346 head.insertBefore(style, head.childNodes[0]);
5347 } else {
5348 head.appendChild(style);
5349 }
5350 }
5351 }
5352 /**
5353 * The tooltip handler function.
5354 */
5355
5356
5357 tooltipHandler(handler, event, item, value) {
5358 // console.log(handler, event, item, value);
5359 var _a; // append a div element that we use as a tooltip unless it already exists
5360
5361
5362 this.el = document.getElementById(this.options.id);
5363
5364 if (!this.el) {
5365 this.el = document.createElement('div');
5366 this.el.setAttribute('id', this.options.id);
5367 this.el.classList.add('vg-tooltip');
5368 document.body.appendChild(this.el);
5369 }
5370
5371 const tooltipContainer = (_a = document.fullscreenElement) !== null && _a !== void 0 ? _a : document.body;
5372 tooltipContainer.appendChild(this.el); // hide tooltip for null, undefined, or empty string values
5373
5374 if (value == null || value === '') {
5375 this.el.classList.remove('visible', `${this.options.theme}-theme`);
5376 return;
5377 } // set the tooltip content
5378
5379
5380 this.el.innerHTML = this.options.formatTooltip(value, this.options.sanitize, this.options.maxDepth); // make the tooltip visible
5381
5382 this.el.classList.add('visible', `${this.options.theme}-theme`);
5383 const {
5384 x,
5385 y
5386 } = calculatePosition(event, this.el.getBoundingClientRect(), this.options.offsetX, this.options.offsetY);
5387 this.el.setAttribute('style', `top: ${y}px; left: ${x}px`);
5388 }
5389
5390 }
5391
5392 /**
5393 * Open editor url in a new window, and pass a message.
5394 */
5395 function post (window, url, data) {
5396 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
5397 const editor = window.open(url);
5398 const wait = 10000;
5399 const step = 250;
5400 const {
5401 origin
5402 } = new URL(url); // eslint-disable-next-line no-bitwise
5403
5404 let count = ~~(wait / step);
5405
5406 function listen(evt) {
5407 if (evt.source === editor) {
5408 count = 0;
5409 window.removeEventListener('message', listen, false);
5410 }
5411 }
5412
5413 window.addEventListener('message', listen, false); // send message
5414 // periodically resend until ack received or timeout
5415
5416 function send() {
5417 if (count <= 0) {
5418 return;
5419 }
5420
5421 editor.postMessage(data, origin);
5422 setTimeout(send, step);
5423 count -= 1;
5424 }
5425
5426 setTimeout(send, step);
5427 }
5428
5429 // generated with build-style.sh
5430 var embedStyle = `.vega-embed {
5431 position: relative;
5432 display: inline-block;
5433 box-sizing: border-box; }
5434 .vega-embed.has-actions {
5435 padding-right: 38px; }
5436 .vega-embed details:not([open]) > :not(summary) {
5437 display: none !important; }
5438 .vega-embed summary {
5439 list-style: none;
5440 position: absolute;
5441 top: 0;
5442 right: 0;
5443 padding: 6px;
5444 z-index: 1000;
5445 background: white;
5446 box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);
5447 color: #1b1e23;
5448 border: 1px solid #aaa;
5449 border-radius: 999px;
5450 opacity: 0.2;
5451 transition: opacity 0.4s ease-in;
5452 outline: none;
5453 cursor: pointer;
5454 line-height: 0px; }
5455 .vega-embed summary::-webkit-details-marker {
5456 display: none; }
5457 .vega-embed summary:active {
5458 box-shadow: #aaa 0px 0px 0px 1px inset; }
5459 .vega-embed summary svg {
5460 width: 14px;
5461 height: 14px; }
5462 .vega-embed details[open] summary {
5463 opacity: 0.7; }
5464 .vega-embed:hover summary,
5465 .vega-embed:focus summary {
5466 opacity: 1 !important;
5467 transition: opacity 0.2s ease; }
5468 .vega-embed .vega-actions {
5469 position: absolute;
5470 z-index: 1001;
5471 top: 35px;
5472 right: -9px;
5473 display: flex;
5474 flex-direction: column;
5475 padding-bottom: 8px;
5476 padding-top: 8px;
5477 border-radius: 4px;
5478 box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.2);
5479 border: 1px solid #d9d9d9;
5480 background: white;
5481 animation-duration: 0.15s;
5482 animation-name: scale-in;
5483 animation-timing-function: cubic-bezier(0.2, 0, 0.13, 1.5);
5484 text-align: left; }
5485 .vega-embed .vega-actions a {
5486 padding: 8px 16px;
5487 font-family: sans-serif;
5488 font-size: 14px;
5489 font-weight: 600;
5490 white-space: nowrap;
5491 color: #434a56;
5492 text-decoration: none; }
5493 .vega-embed .vega-actions a:hover {
5494 background-color: #f7f7f9;
5495 color: black; }
5496 .vega-embed .vega-actions::before, .vega-embed .vega-actions::after {
5497 content: "";
5498 display: inline-block;
5499 position: absolute; }
5500 .vega-embed .vega-actions::before {
5501 left: auto;
5502 right: 14px;
5503 top: -16px;
5504 border: 8px solid #0000;
5505 border-bottom-color: #d9d9d9; }
5506 .vega-embed .vega-actions::after {
5507 left: auto;
5508 right: 15px;
5509 top: -14px;
5510 border: 7px solid #0000;
5511 border-bottom-color: #fff; }
5512 .vega-embed .chart-wrapper.fit-x {
5513 width: 100%; }
5514 .vega-embed .chart-wrapper.fit-y {
5515 height: 100%; }
5516
5517.vega-embed-wrapper {
5518 max-width: 100%;
5519 overflow: auto;
5520 padding-right: 14px; }
5521
5522@keyframes scale-in {
5523 from {
5524 opacity: 0;
5525 transform: scale(0.6); }
5526 to {
5527 opacity: 1;
5528 transform: scale(1); } }
5529`;
5530
5531 if (!String.prototype.startsWith) {
5532 // eslint-disable-next-line no-extend-native,func-names
5533 String.prototype.startsWith = function (search, pos) {
5534 return this.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
5535 };
5536 }
5537
5538 function isURL(s) {
5539 return s.startsWith('http://') || s.startsWith('https://') || s.startsWith('//');
5540 }
5541 function mergeDeep(dest, ...src) {
5542 for (const s of src) {
5543 deepMerge_(dest, s);
5544 }
5545
5546 return dest;
5547 }
5548
5549 function deepMerge_(dest, src) {
5550 for (const property of Object.keys(src)) {
5551 vegaImport.writeConfig(dest, property, src[property], true);
5552 }
5553 }
5554
5555 var _w$vl;
5556 const vega = vegaImport__namespace;
5557 let vegaLite = vegaLiteImport__namespace; // For backwards compatibility with Vega-Lite before v4.
5558
5559 const w = typeof window !== 'undefined' ? window : undefined;
5560
5561 if (vegaLite === undefined && w !== null && w !== void 0 && (_w$vl = w['vl']) !== null && _w$vl !== void 0 && _w$vl.compile) {
5562 vegaLite = w['vl'];
5563 }
5564
5565 const DEFAULT_ACTIONS = {
5566 export: {
5567 svg: true,
5568 png: true
5569 },
5570 source: true,
5571 compiled: true,
5572 editor: true
5573 };
5574 const I18N = {
5575 CLICK_TO_VIEW_ACTIONS: 'Click to view actions',
5576 COMPILED_ACTION: 'View Compiled Vega',
5577 EDITOR_ACTION: 'Open in Vega Editor',
5578 PNG_ACTION: 'Save as PNG',
5579 SOURCE_ACTION: 'View Source',
5580 SVG_ACTION: 'Save as SVG'
5581 };
5582 const NAMES = {
5583 vega: 'Vega',
5584 'vega-lite': 'Vega-Lite'
5585 };
5586 const VERSION = {
5587 vega: vega.version,
5588 'vega-lite': vegaLite ? vegaLite.version : 'not available'
5589 };
5590 const PREPROCESSOR = {
5591 vega: vgSpec => vgSpec,
5592 'vega-lite': (vlSpec, config) => vegaLite.compile(vlSpec, {
5593 config: config
5594 }).spec
5595 };
5596 const SVG_CIRCLES = `
5597<svg viewBox="0 0 16 16" fill="currentColor" stroke="none" stroke-width="1" stroke-linecap="round" stroke-linejoin="round">
5598 <circle r="2" cy="8" cx="2"></circle>
5599 <circle r="2" cy="8" cx="8"></circle>
5600 <circle r="2" cy="8" cx="14"></circle>
5601</svg>`;
5602 const CHART_WRAPPER_CLASS = 'chart-wrapper';
5603
5604 function isTooltipHandler(h) {
5605 return typeof h === 'function';
5606 }
5607
5608 function viewSource(source, sourceHeader, sourceFooter, mode) {
5609 const header = `<html><head>${sourceHeader}</head><body><pre><code class="json">`;
5610 const footer = `</code></pre>${sourceFooter}</body></html>`; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
5611
5612 const win = window.open('');
5613 win.document.write(header + source + footer);
5614 win.document.title = `${NAMES[mode]} JSON Source`;
5615 }
5616 /**
5617 * Try to guess the type of spec.
5618 *
5619 * @param spec Vega or Vega-Lite spec.
5620 */
5621
5622
5623 function guessMode(spec, providedMode) {
5624 // Decide mode
5625 if (spec.$schema) {
5626 const parsed = e(spec.$schema);
5627
5628 if (providedMode && providedMode !== parsed.library) {
5629 var _NAMES$providedMode;
5630
5631 console.warn(`The given visualization spec is written in ${NAMES[parsed.library]}, but mode argument sets ${(_NAMES$providedMode = NAMES[providedMode]) !== null && _NAMES$providedMode !== void 0 ? _NAMES$providedMode : providedMode}.`);
5632 }
5633
5634 const mode = parsed.library;
5635
5636 if (!semver.satisfies(VERSION[mode], `^${parsed.version.slice(1)}`)) {
5637 console.warn(`The input spec uses ${NAMES[mode]} ${parsed.version}, but the current version of ${NAMES[mode]} is v${VERSION[mode]}.`);
5638 }
5639
5640 return mode;
5641 } // try to guess from the provided spec
5642
5643
5644 if ('mark' in spec || 'encoding' in spec || 'layer' in spec || 'hconcat' in spec || 'vconcat' in spec || 'facet' in spec || 'repeat' in spec) {
5645 return 'vega-lite';
5646 }
5647
5648 if ('marks' in spec || 'signals' in spec || 'scales' in spec || 'axes' in spec) {
5649 return 'vega';
5650 }
5651
5652 return providedMode !== null && providedMode !== void 0 ? providedMode : 'vega';
5653 }
5654
5655 function isLoader(o) {
5656 return !!(o && 'load' in o);
5657 }
5658
5659 function createLoader(opts) {
5660 return isLoader(opts) ? opts : vega.loader(opts);
5661 }
5662
5663 function embedOptionsFromUsermeta(parsedSpec) {
5664 var _ref;
5665
5666 return (_ref = parsedSpec.usermeta && parsedSpec.usermeta['embedOptions']) !== null && _ref !== void 0 ? _ref : {};
5667 }
5668 /**
5669 * Embed a Vega visualization component in a web page. This function returns a promise.
5670 *
5671 * @param el DOM element in which to place component (DOM node or CSS selector).
5672 * @param spec String : A URL string from which to load the Vega specification.
5673 * Object : The Vega/Vega-Lite specification as a parsed JSON object.
5674 * @param opts A JavaScript object containing options for embedding.
5675 */
5676
5677
5678 async function embed(el, spec, opts = {}) {
5679 var _parsedOpts$config, _usermetaOpts$config;
5680
5681 let parsedSpec;
5682 let loader;
5683
5684 if (vegaImport.isString(spec)) {
5685 loader = createLoader(opts.loader);
5686 parsedSpec = JSON.parse(await loader.load(spec));
5687 } else {
5688 parsedSpec = spec;
5689 }
5690
5691 const usermetaLoader = embedOptionsFromUsermeta(parsedSpec).loader; // either create the loader for the first time or create a new loader if the spec has new loader options
5692
5693 if (!loader || usermetaLoader) {
5694 var _opts$loader;
5695
5696 loader = createLoader((_opts$loader = opts.loader) !== null && _opts$loader !== void 0 ? _opts$loader : usermetaLoader);
5697 }
5698
5699 const usermetaOpts = await loadOpts(embedOptionsFromUsermeta(parsedSpec), loader);
5700 const parsedOpts = await loadOpts(opts, loader);
5701 const mergedOpts = { ...mergeDeep(parsedOpts, usermetaOpts),
5702 config: vegaImport.mergeConfig((_parsedOpts$config = parsedOpts.config) !== null && _parsedOpts$config !== void 0 ? _parsedOpts$config : {}, (_usermetaOpts$config = usermetaOpts.config) !== null && _usermetaOpts$config !== void 0 ? _usermetaOpts$config : {})
5703 };
5704 return await _embed(el, parsedSpec, mergedOpts, loader);
5705 }
5706
5707 async function loadOpts(opt, loader) {
5708 var _opt$config;
5709
5710 const config = vegaImport.isString(opt.config) ? JSON.parse(await loader.load(opt.config)) : (_opt$config = opt.config) !== null && _opt$config !== void 0 ? _opt$config : {};
5711 const patch = vegaImport.isString(opt.patch) ? JSON.parse(await loader.load(opt.patch)) : opt.patch;
5712 return { ...opt,
5713 ...(patch ? {
5714 patch
5715 } : {}),
5716 ...(config ? {
5717 config
5718 } : {})
5719 };
5720 }
5721
5722 function getRoot(el) {
5723 const possibleRoot = el.getRootNode ? el.getRootNode() : document;
5724
5725 if (possibleRoot instanceof ShadowRoot) {
5726 return {
5727 root: possibleRoot,
5728 rootContainer: possibleRoot
5729 };
5730 } else {
5731 var _document$head;
5732
5733 return {
5734 root: document,
5735 rootContainer: (_document$head = document.head) !== null && _document$head !== void 0 ? _document$head : document.body
5736 };
5737 }
5738 }
5739
5740 async function _embed(el, spec, opts = {}, loader) {
5741 var _opts$config, _opts$actions, _opts$renderer, _opts$logLevel, _opts$downloadFileNam, _ref2, _vega$expressionInter;
5742
5743 const config = opts.theme ? vegaImport.mergeConfig(themes[opts.theme], (_opts$config = opts.config) !== null && _opts$config !== void 0 ? _opts$config : {}) : opts.config;
5744 const actions = vegaImport.isBoolean(opts.actions) ? opts.actions : mergeDeep({}, DEFAULT_ACTIONS, (_opts$actions = opts.actions) !== null && _opts$actions !== void 0 ? _opts$actions : {});
5745 const i18n = { ...I18N,
5746 ...opts.i18n
5747 };
5748 const renderer = (_opts$renderer = opts.renderer) !== null && _opts$renderer !== void 0 ? _opts$renderer : 'canvas';
5749 const logLevel = (_opts$logLevel = opts.logLevel) !== null && _opts$logLevel !== void 0 ? _opts$logLevel : vega.Warn;
5750 const downloadFileName = (_opts$downloadFileNam = opts.downloadFileName) !== null && _opts$downloadFileNam !== void 0 ? _opts$downloadFileNam : 'visualization';
5751 const element = typeof el === 'string' ? document.querySelector(el) : el;
5752
5753 if (!element) {
5754 throw new Error(`${el} does not exist`);
5755 }
5756
5757 if (opts.defaultStyle !== false) {
5758 // Add a default stylesheet to the head of the document.
5759 const ID = 'vega-embed-style';
5760 const {
5761 root,
5762 rootContainer
5763 } = getRoot(element);
5764
5765 if (!root.getElementById(ID)) {
5766 const style = document.createElement('style');
5767 style.id = ID;
5768 style.innerText = opts.defaultStyle === undefined || opts.defaultStyle === true ? (embedStyle ).toString() : opts.defaultStyle;
5769 rootContainer.appendChild(style);
5770 }
5771 }
5772
5773 const mode = guessMode(spec, opts.mode);
5774 let vgSpec = PREPROCESSOR[mode](spec, config);
5775
5776 if (mode === 'vega-lite') {
5777 if (vgSpec.$schema) {
5778 const parsed = e(vgSpec.$schema);
5779
5780 if (!semver.satisfies(VERSION.vega, `^${parsed.version.slice(1)}`)) {
5781 console.warn(`The compiled spec uses Vega ${parsed.version}, but current version is v${VERSION.vega}.`);
5782 }
5783 }
5784 }
5785
5786 element.classList.add('vega-embed');
5787
5788 if (actions) {
5789 element.classList.add('has-actions');
5790 }
5791
5792 element.innerHTML = ''; // clear container
5793
5794 let container = element;
5795
5796 if (actions) {
5797 const chartWrapper = document.createElement('div');
5798 chartWrapper.classList.add(CHART_WRAPPER_CLASS);
5799 element.appendChild(chartWrapper);
5800 container = chartWrapper;
5801 }
5802
5803 const patch = opts.patch;
5804
5805 if (patch) {
5806 if (patch instanceof Function) {
5807 vgSpec = patch(vgSpec);
5808 } else {
5809 vgSpec = applyPatch(vgSpec, patch, true, false).newDocument;
5810 }
5811 } // Set locale. Note that this is a global setting.
5812
5813
5814 if (opts.formatLocale) {
5815 vega.formatLocale(opts.formatLocale);
5816 }
5817
5818 if (opts.timeFormatLocale) {
5819 vega.timeFormatLocale(opts.timeFormatLocale);
5820 }
5821
5822 const {
5823 ast
5824 } = opts; // Do not apply the config to Vega when we have already applied it to Vega-Lite.
5825 // This call may throw an Error if parsing fails.
5826
5827 const runtime = vega.parse(vgSpec, mode === 'vega-lite' ? {} : config, {
5828 ast
5829 });
5830 const view = new (opts.viewClass || vega.View)(runtime, {
5831 loader,
5832 logLevel,
5833 renderer,
5834 ...(ast ? {
5835 expr: (_ref2 = (_vega$expressionInter = vega.expressionInterpreter) !== null && _vega$expressionInter !== void 0 ? _vega$expressionInter : opts.expr) !== null && _ref2 !== void 0 ? _ref2 : expression
5836 } : {})
5837 });
5838 view.addSignalListener('autosize', (_, autosize) => {
5839 const {
5840 type
5841 } = autosize;
5842
5843 if (type == 'fit-x') {
5844 container.classList.add('fit-x');
5845 container.classList.remove('fit-y');
5846 } else if (type == 'fit-y') {
5847 container.classList.remove('fit-x');
5848 container.classList.add('fit-y');
5849 } else if (type == 'fit') {
5850 container.classList.add('fit-x', 'fit-y');
5851 } else {
5852 container.classList.remove('fit-x', 'fit-y');
5853 }
5854 });
5855
5856 if (opts.tooltip !== false) {
5857 let handler;
5858
5859 if (isTooltipHandler(opts.tooltip)) {
5860 handler = opts.tooltip;
5861 } else {
5862 // user provided boolean true or tooltip options
5863 handler = new Handler(opts.tooltip === true ? {} : opts.tooltip).call;
5864 }
5865
5866 view.tooltip(handler);
5867 }
5868
5869 let {
5870 hover
5871 } = opts;
5872
5873 if (hover === undefined) {
5874 hover = mode === 'vega';
5875 }
5876
5877 if (hover) {
5878 const {
5879 hoverSet,
5880 updateSet
5881 } = typeof hover === 'boolean' ? {} : hover;
5882 view.hover(hoverSet, updateSet);
5883 }
5884
5885 if (opts) {
5886 if (opts.width != null) {
5887 view.width(opts.width);
5888 }
5889
5890 if (opts.height != null) {
5891 view.height(opts.height);
5892 }
5893
5894 if (opts.padding != null) {
5895 view.padding(opts.padding);
5896 }
5897 }
5898
5899 await view.initialize(container, opts.bind).runAsync();
5900 let documentClickHandler;
5901
5902 if (actions !== false) {
5903 let wrapper = element;
5904
5905 if (opts.defaultStyle !== false) {
5906 const details = document.createElement('details');
5907 details.title = i18n.CLICK_TO_VIEW_ACTIONS;
5908 element.append(details);
5909 wrapper = details;
5910 const summary = document.createElement('summary');
5911 summary.innerHTML = SVG_CIRCLES;
5912 details.append(summary);
5913
5914 documentClickHandler = ev => {
5915 if (!details.contains(ev.target)) {
5916 details.removeAttribute('open');
5917 }
5918 };
5919
5920 document.addEventListener('click', documentClickHandler);
5921 }
5922
5923 const ctrl = document.createElement('div');
5924 wrapper.append(ctrl);
5925 ctrl.classList.add('vega-actions'); // add 'Export' action
5926
5927 if (actions === true || actions.export !== false) {
5928 for (const ext of ['svg', 'png']) {
5929 if (actions === true || actions.export === true || actions.export[ext]) {
5930 const i18nExportAction = i18n[`${ext.toUpperCase()}_ACTION`];
5931 const exportLink = document.createElement('a');
5932 exportLink.text = i18nExportAction;
5933 exportLink.href = '#';
5934 exportLink.target = '_blank';
5935 exportLink.download = `${downloadFileName}.${ext}`; // add link on mousedown so that it's correct when the click happens
5936
5937 exportLink.addEventListener('mousedown', async function (e) {
5938 e.preventDefault();
5939 const url = await view.toImageURL(ext, opts.scaleFactor);
5940 this.href = url;
5941 });
5942 ctrl.append(exportLink);
5943 }
5944 }
5945 } // add 'View Source' action
5946
5947
5948 if (actions === true || actions.source !== false) {
5949 const viewSourceLink = document.createElement('a');
5950 viewSourceLink.text = i18n.SOURCE_ACTION;
5951 viewSourceLink.href = '#';
5952 viewSourceLink.addEventListener('click', function (e) {
5953 var _opts$sourceHeader, _opts$sourceFooter;
5954
5955 viewSource(jsonStringifyPrettyCompact(spec), (_opts$sourceHeader = opts.sourceHeader) !== null && _opts$sourceHeader !== void 0 ? _opts$sourceHeader : '', (_opts$sourceFooter = opts.sourceFooter) !== null && _opts$sourceFooter !== void 0 ? _opts$sourceFooter : '', mode);
5956 e.preventDefault();
5957 });
5958 ctrl.append(viewSourceLink);
5959 } // add 'View Compiled' action
5960
5961
5962 if (mode === 'vega-lite' && (actions === true || actions.compiled !== false)) {
5963 const compileLink = document.createElement('a');
5964 compileLink.text = i18n.COMPILED_ACTION;
5965 compileLink.href = '#';
5966 compileLink.addEventListener('click', function (e) {
5967 var _opts$sourceHeader2, _opts$sourceFooter2;
5968
5969 viewSource(jsonStringifyPrettyCompact(vgSpec), (_opts$sourceHeader2 = opts.sourceHeader) !== null && _opts$sourceHeader2 !== void 0 ? _opts$sourceHeader2 : '', (_opts$sourceFooter2 = opts.sourceFooter) !== null && _opts$sourceFooter2 !== void 0 ? _opts$sourceFooter2 : '', 'vega');
5970 e.preventDefault();
5971 });
5972 ctrl.append(compileLink);
5973 } // add 'Open in Vega Editor' action
5974
5975
5976 if (actions === true || actions.editor !== false) {
5977 var _opts$editorUrl;
5978
5979 const editorUrl = (_opts$editorUrl = opts.editorUrl) !== null && _opts$editorUrl !== void 0 ? _opts$editorUrl : 'https://vega.github.io/editor/';
5980 const editorLink = document.createElement('a');
5981 editorLink.text = i18n.EDITOR_ACTION;
5982 editorLink.href = '#';
5983 editorLink.addEventListener('click', function (e) {
5984 post(window, editorUrl, {
5985 config: config,
5986 mode,
5987 renderer,
5988 spec: jsonStringifyPrettyCompact(spec)
5989 });
5990 e.preventDefault();
5991 });
5992 ctrl.append(editorLink);
5993 }
5994 }
5995
5996 function finalize() {
5997 if (documentClickHandler) {
5998 document.removeEventListener('click', documentClickHandler);
5999 }
6000
6001 view.finalize();
6002 }
6003
6004 return {
6005 view,
6006 spec,
6007 vgSpec,
6008 finalize
6009 };
6010 }
6011
6012 /**
6013 * Create a promise to an HTML Div element with an embedded Vega-Lite or Vega visualization.
6014 * The element has a value property with the view. By default all actions except for the editor action are disabled.
6015 *
6016 * The main use case is in [Observable](https://observablehq.com/).
6017 */
6018
6019 async function container (spec, opt = {}) {
6020 var _opt$actions;
6021
6022 const wrapper = document.createElement('div');
6023 wrapper.classList.add('vega-embed-wrapper');
6024 const div = document.createElement('div');
6025 wrapper.appendChild(div);
6026 const actions = opt.actions === true || opt.actions === false ? opt.actions : {
6027 export: true,
6028 source: false,
6029 compiled: true,
6030 editor: true,
6031 ...((_opt$actions = opt.actions) !== null && _opt$actions !== void 0 ? _opt$actions : {})
6032 };
6033 const result = await embed(div, spec, {
6034 actions,
6035 ...(opt !== null && opt !== void 0 ? opt : {})
6036 });
6037 wrapper.value = result.view;
6038 return wrapper;
6039 }
6040
6041 /**
6042 * Returns true if the object is an HTML element.
6043 */
6044
6045 function isElement(obj) {
6046 return obj instanceof HTMLElement;
6047 }
6048
6049 const wrapper = (...args) => {
6050 if (args.length > 1 && (vegaImport.isString(args[0]) && !isURL(args[0]) || isElement(args[0]) || args.length === 3)) {
6051 return embed(args[0], args[1], args[2]);
6052 }
6053
6054 return container(args[0], args[1]);
6055 };
6056
6057 wrapper.vegaLite = vegaLite;
6058 wrapper.vl = vegaLite; // backwards compatibility
6059
6060 wrapper.container = container;
6061 wrapper.embed = embed;
6062 wrapper.vega = vega;
6063 wrapper.default = embed;
6064 wrapper.version = pkg$1.version;
6065
6066 return wrapper;
6067
6068})));
6069//# sourceMappingURL=vega-embed.js.map