diff --git a/package-lock.json b/package-lock.json index 530b2ae9..8c252ac4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,11 +21,11 @@ "jquery": "^3.6.0", "moment": "^2.29.1", "moment-timezone": "^0.5.33", - "plotly.js": "^1.58.4", + "plotly.js": "^2.0.0", "popper.js": "^1.16.1", "pulltorefreshjs": "^0.1.22", "pump": "^3.0.0", - "stylelint": "^13.12.0", + "stylelint": "^13.13.1", "stylelint-config-recommended-scss": "^4.2.0", "stylelint-order": "^4.1.0", "stylelint-scss": "^3.19.0", @@ -482,6 +482,12 @@ "node": ">= 8" } }, + "node_modules/@plotly/d3": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/@plotly/d3/-/d3-3.6.0.tgz", + "integrity": "sha512-5p6+3TlVn4k/xEfnohYzC2sWQBLW+4l0JbRdNJpO5dAVMOuNTXd0Bdbcsu299u/AjVHmBAGsXPrSNQSXugBrHA==", + "dev": true + }, "node_modules/@plotly/d3-sankey": { "version": "0.7.2", "resolved": "https://registry.npmjs.org/@plotly/d3-sankey/-/d3-sankey-0.7.2.tgz", @@ -2476,12 +2482,6 @@ "type": "^1.0.1" } }, - "node_modules/d3": { - "version": "3.5.17", - "resolved": "https://registry.npmjs.org/d3/-/d3-3.5.17.tgz", - "integrity": "sha1-vEZ0gAQ3iyGjYMn8fPUjF5B2L7g=", - "dev": true - }, "node_modules/d3-array": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-1.2.4.tgz", @@ -2977,12 +2977,6 @@ "es6-symbol": "^3.1.1" } }, - "node_modules/es6-promise": { - "version": "4.2.8", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", - "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==", - "dev": true - }, "node_modules/es6-symbol": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", @@ -3985,23 +3979,6 @@ "integrity": "sha1-WXpQTjZHUP9QJTqjX43qevSl0jM=", "dev": true }, - "node_modules/gl-contour2d": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/gl-contour2d/-/gl-contour2d-1.1.7.tgz", - "integrity": "sha512-GdebvJ9DtT3pJDpoE+eU2q+Wo9S3MijPpPz5arZbhK85w2bARmpFpVfPaDlZqWkB644W3BlH8TVyvAo1KE4Bhw==", - "dev": true, - "dependencies": { - "binary-search-bounds": "^2.0.4", - "cdt2d": "^1.0.0", - "clean-pslg": "^1.1.2", - "gl-buffer": "^2.1.2", - "gl-shader": "^4.2.1", - "glslify": "^7.0.0", - "iota-array": "^1.0.0", - "ndarray": "^1.0.18", - "surface-nets": "^1.0.2" - } - }, "node_modules/gl-error3d": { "version": "1.0.16", "resolved": "https://registry.npmjs.org/gl-error3d/-/gl-error3d-1.0.16.tgz", @@ -5460,6 +5437,18 @@ "npm": ">=1.3.7" } }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/ieee754": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", @@ -5500,18 +5489,6 @@ "quantize": "^1.0.2" } }, - "node_modules/image-size": { - "version": "0.7.5", - "resolved": "https://registry.npmjs.org/image-size/-/image-size-0.7.5.tgz", - "integrity": "sha512-Hiyv+mXHfFEP7LzUL/llg9RwFxxY+o9N3JVLIeG5E7iFIFAalxvRU9UZthBdYDEVnzHMgjnKJPPpay5BWf1g9g==", - "dev": true, - "bin": { - "image-size": "bin/image-size.js" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", @@ -6380,6 +6357,12 @@ "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=", "dev": true }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true + }, "node_modules/lodash.truncate": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz", @@ -7377,6 +7360,12 @@ "node": ">=0.10.0" } }, + "node_modules/native-promise-only": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/native-promise-only/-/native-promise-only-0.8.1.tgz", + "integrity": "sha1-IKMYwwy0X3H+et+/eyHJnBRy7xE=", + "dev": true + }, "node_modules/ndarray": { "version": "1.0.19", "resolved": "https://registry.npmjs.org/ndarray/-/ndarray-1.0.19.tgz", @@ -7451,6 +7440,38 @@ "typedarray-pool": "^1.0.0" } }, + "node_modules/needle": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/needle/-/needle-2.6.0.tgz", + "integrity": "sha512-KKYdza4heMsEfSWD7VPUIz3zX2XDwOyX2d+geb4vrERZMT5RMU6ujjaD+I5Yr54uZxQ2w6XRTAhHBbSCyovZBg==", + "dev": true, + "dependencies": { + "debug": "^3.2.6", + "iconv-lite": "^0.4.4", + "sax": "^1.2.4" + }, + "bin": { + "needle": "bin/needle" + }, + "engines": { + "node": ">= 4.4.x" + } + }, + "node_modules/needle/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/needle/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, "node_modules/next-tick": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", @@ -8310,11 +8331,12 @@ } }, "node_modules/plotly.js": { - "version": "1.58.4", - "resolved": "https://registry.npmjs.org/plotly.js/-/plotly.js-1.58.4.tgz", - "integrity": "sha512-hdt/aEvkPjS1HJ7tJKcPqsqi9ErEZPhUFs4d2ANTLeBim+AmVcHzS1rtwr7ZrVCINgliW/+92u81omJoy+lbUw==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/plotly.js/-/plotly.js-2.0.0.tgz", + "integrity": "sha512-h3Qt6arIEBFnR3Vgw04SrORmjJEcsdGK29R6o6pyUqejJjXiRVR7zNBwQsPPfTP7JP5IHpXFs2sIukSSREmSAQ==", "dev": true, "dependencies": { + "@plotly/d3": "^3.6.0", "@plotly/d3-sankey": "0.7.2", "@plotly/d3-sankey-circular": "0.33.1", "@plotly/point-cluster": "^3.1.9", @@ -8329,18 +8351,15 @@ "color-rgba": "2.1.1", "convex-hull": "^1.0.3", "country-regex": "^1.1.0", - "d3": "^3.5.17", "d3-force": "^1.2.1", "d3-hierarchy": "^1.1.9", "d3-interpolate": "^1.4.0", "d3-time-format": "^2.2.3", "delaunay-triangulate": "^1.1.6", - "es6-promise": "^4.2.8", "fast-isnumeric": "^1.1.4", "gl-cone3d": "^1.5.2", - "gl-contour2d": "^1.1.7", "gl-error3d": "^1.0.16", - "gl-heatmap2d": "^1.1.0", + "gl-heatmap2d": "^1.1.1", "gl-line3d": "1.2.1", "gl-mat4": "^1.2.0", "gl-mesh3d": "^2.3.1", @@ -8356,25 +8375,25 @@ "glslify": "^7.1.1", "has-hover": "^1.0.1", "has-passive-events": "^1.0.0", - "image-size": "^0.7.5", "is-mobile": "^2.2.2", "mapbox-gl": "1.10.1", "matrix-camera-controller": "^2.1.3", "mouse-change": "^1.4.0", "mouse-event-offset": "^3.0.2", "mouse-wheel": "^1.2.0", + "native-promise-only": "^0.8.1", "ndarray": "^1.0.19", "ndarray-linear-interpolate": "^1.0.0", "parse-svg-path": "^0.1.2", "polybooljs": "^1.2.0", + "probe-image-size": "^7.1.0", "regl": "^1.6.1", "regl-error2d": "^2.0.11", - "regl-line2d": "^3.0.18", - "regl-scatter2d": "^3.2.1", - "regl-splom": "^1.0.12", + "regl-line2d": "^3.1.0", + "regl-scatter2d": "^3.2.3", + "regl-splom": "^1.0.14", "right-now": "^1.0.0", "robust-orientation": "^1.1.3", - "sane-topojson": "^4.0.0", "strongly-connected-components": "^1.0.1", "superscript-text": "^1.0.0", "svg-path-sdf": "^1.1.3", @@ -8650,6 +8669,17 @@ "node": ">= 0.8" } }, + "node_modules/probe-image-size": { + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/probe-image-size/-/probe-image-size-7.2.1.tgz", + "integrity": "sha512-d+6L3NvQBCNt4peRDoEfA7r9bPm6/qy18FnLKwg4NWBC5JrJm0pMLRg1kF4XNsPe1bUdt3WIMonPJzQWN2HXjQ==", + "dev": true, + "dependencies": { + "lodash.merge": "^4.6.2", + "needle": "^2.5.2", + "stream-parser": "~0.3.1" + } + }, "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -9677,12 +9707,6 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true }, - "node_modules/sane-topojson": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/sane-topojson/-/sane-topojson-4.0.0.tgz", - "integrity": "sha512-bJILrpBboQfabG3BNnHI2hZl52pbt80BE09u4WhnrmzuF2JbMKZdl62G5glXskJ46p+gxE2IzOwGj/awR4g8AA==", - "dev": true - }, "node_modules/sass-graph": { "version": "2.2.5", "resolved": "https://registry.npmjs.org/sass-graph/-/sass-graph-2.2.5.tgz", @@ -9843,6 +9867,12 @@ "decamelize": "^1.2.0" } }, + "node_modules/sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", + "dev": true + }, "node_modules/scss-tokenizer": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/scss-tokenizer/-/scss-tokenizer-0.2.3.tgz", @@ -10425,6 +10455,15 @@ "integrity": "sha512-b/qaq/GlBK5xaq1yrK9/zFcyRSTNxmcZwFLGSTG0mXgZl/4Z6GgiyYOXOvY7N3eEvFRAG1bkDRz5EPGSvPYQlw==", "dev": true }, + "node_modules/stream-parser": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/stream-parser/-/stream-parser-0.3.1.tgz", + "integrity": "sha1-FhhUhpRCACGhGC/wrxkRwSl2F3M=", + "dev": true, + "dependencies": { + "debug": "2" + } + }, "node_modules/stream-shift": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz", @@ -13137,6 +13176,12 @@ "fastq": "^1.6.0" } }, + "@plotly/d3": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/@plotly/d3/-/d3-3.6.0.tgz", + "integrity": "sha512-5p6+3TlVn4k/xEfnohYzC2sWQBLW+4l0JbRdNJpO5dAVMOuNTXd0Bdbcsu299u/AjVHmBAGsXPrSNQSXugBrHA==", + "dev": true + }, "@plotly/d3-sankey": { "version": "0.7.2", "resolved": "https://registry.npmjs.org/@plotly/d3-sankey/-/d3-sankey-0.7.2.tgz", @@ -14831,12 +14876,6 @@ "type": "^1.0.1" } }, - "d3": { - "version": "3.5.17", - "resolved": "https://registry.npmjs.org/d3/-/d3-3.5.17.tgz", - "integrity": "sha1-vEZ0gAQ3iyGjYMn8fPUjF5B2L7g=", - "dev": true - }, "d3-array": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-1.2.4.tgz", @@ -15282,12 +15321,6 @@ "es6-symbol": "^3.1.1" } }, - "es6-promise": { - "version": "4.2.8", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", - "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==", - "dev": true - }, "es6-symbol": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", @@ -16116,23 +16149,6 @@ "integrity": "sha1-WXpQTjZHUP9QJTqjX43qevSl0jM=", "dev": true }, - "gl-contour2d": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/gl-contour2d/-/gl-contour2d-1.1.7.tgz", - "integrity": "sha512-GdebvJ9DtT3pJDpoE+eU2q+Wo9S3MijPpPz5arZbhK85w2bARmpFpVfPaDlZqWkB644W3BlH8TVyvAo1KE4Bhw==", - "dev": true, - "requires": { - "binary-search-bounds": "^2.0.4", - "cdt2d": "^1.0.0", - "clean-pslg": "^1.1.2", - "gl-buffer": "^2.1.2", - "gl-shader": "^4.2.1", - "glslify": "^7.0.0", - "iota-array": "^1.0.0", - "ndarray": "^1.0.18", - "surface-nets": "^1.0.2" - } - }, "gl-error3d": { "version": "1.0.16", "resolved": "https://registry.npmjs.org/gl-error3d/-/gl-error3d-1.0.16.tgz", @@ -17416,6 +17432,15 @@ "sshpk": "^1.7.0" } }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, "ieee754": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", @@ -17439,12 +17464,6 @@ "quantize": "^1.0.2" } }, - "image-size": { - "version": "0.7.5", - "resolved": "https://registry.npmjs.org/image-size/-/image-size-0.7.5.tgz", - "integrity": "sha512-Hiyv+mXHfFEP7LzUL/llg9RwFxxY+o9N3JVLIeG5E7iFIFAalxvRU9UZthBdYDEVnzHMgjnKJPPpay5BWf1g9g==", - "dev": true - }, "import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", @@ -18129,6 +18148,12 @@ "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=", "dev": true }, + "lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true + }, "lodash.truncate": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz", @@ -18932,6 +18957,12 @@ } } }, + "native-promise-only": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/native-promise-only/-/native-promise-only-0.8.1.tgz", + "integrity": "sha1-IKMYwwy0X3H+et+/eyHJnBRy7xE=", + "dev": true + }, "ndarray": { "version": "1.0.19", "resolved": "https://registry.npmjs.org/ndarray/-/ndarray-1.0.19.tgz", @@ -19006,6 +19037,34 @@ "typedarray-pool": "^1.0.0" } }, + "needle": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/needle/-/needle-2.6.0.tgz", + "integrity": "sha512-KKYdza4heMsEfSWD7VPUIz3zX2XDwOyX2d+geb4vrERZMT5RMU6ujjaD+I5Yr54uZxQ2w6XRTAhHBbSCyovZBg==", + "dev": true, + "requires": { + "debug": "^3.2.6", + "iconv-lite": "^0.4.4", + "sax": "^1.2.4" + }, + "dependencies": { + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + } + } + }, "next-tick": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", @@ -19694,11 +19753,12 @@ } }, "plotly.js": { - "version": "1.58.4", - "resolved": "https://registry.npmjs.org/plotly.js/-/plotly.js-1.58.4.tgz", - "integrity": "sha512-hdt/aEvkPjS1HJ7tJKcPqsqi9ErEZPhUFs4d2ANTLeBim+AmVcHzS1rtwr7ZrVCINgliW/+92u81omJoy+lbUw==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/plotly.js/-/plotly.js-2.0.0.tgz", + "integrity": "sha512-h3Qt6arIEBFnR3Vgw04SrORmjJEcsdGK29R6o6pyUqejJjXiRVR7zNBwQsPPfTP7JP5IHpXFs2sIukSSREmSAQ==", "dev": true, "requires": { + "@plotly/d3": "^3.6.0", "@plotly/d3-sankey": "0.7.2", "@plotly/d3-sankey-circular": "0.33.1", "@plotly/point-cluster": "^3.1.9", @@ -19713,18 +19773,15 @@ "color-rgba": "2.1.1", "convex-hull": "^1.0.3", "country-regex": "^1.1.0", - "d3": "^3.5.17", "d3-force": "^1.2.1", "d3-hierarchy": "^1.1.9", "d3-interpolate": "^1.4.0", "d3-time-format": "^2.2.3", "delaunay-triangulate": "^1.1.6", - "es6-promise": "^4.2.8", "fast-isnumeric": "^1.1.4", "gl-cone3d": "^1.5.2", - "gl-contour2d": "^1.1.7", "gl-error3d": "^1.0.16", - "gl-heatmap2d": "^1.1.0", + "gl-heatmap2d": "^1.1.1", "gl-line3d": "1.2.1", "gl-mat4": "^1.2.0", "gl-mesh3d": "^2.3.1", @@ -19740,25 +19797,25 @@ "glslify": "^7.1.1", "has-hover": "^1.0.1", "has-passive-events": "^1.0.0", - "image-size": "^0.7.5", "is-mobile": "^2.2.2", "mapbox-gl": "1.10.1", "matrix-camera-controller": "^2.1.3", "mouse-change": "^1.4.0", "mouse-event-offset": "^3.0.2", "mouse-wheel": "^1.2.0", + "native-promise-only": "^0.8.1", "ndarray": "^1.0.19", "ndarray-linear-interpolate": "^1.0.0", "parse-svg-path": "^0.1.2", "polybooljs": "^1.2.0", + "probe-image-size": "^7.1.0", "regl": "^1.6.1", "regl-error2d": "^2.0.11", - "regl-line2d": "^3.0.18", - "regl-scatter2d": "^3.2.1", - "regl-splom": "^1.0.12", + "regl-line2d": "^3.1.0", + "regl-scatter2d": "^3.2.3", + "regl-splom": "^1.0.14", "right-now": "^1.0.0", "robust-orientation": "^1.1.3", - "sane-topojson": "^4.0.0", "strongly-connected-components": "^1.0.1", "superscript-text": "^1.0.0", "svg-path-sdf": "^1.1.3", @@ -19981,6 +20038,17 @@ "integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=", "dev": true }, + "probe-image-size": { + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/probe-image-size/-/probe-image-size-7.2.1.tgz", + "integrity": "sha512-d+6L3NvQBCNt4peRDoEfA7r9bPm6/qy18FnLKwg4NWBC5JrJm0pMLRg1kF4XNsPe1bUdt3WIMonPJzQWN2HXjQ==", + "dev": true, + "requires": { + "lodash.merge": "^4.6.2", + "needle": "^2.5.2", + "stream-parser": "~0.3.1" + } + }, "process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -20822,12 +20890,6 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true }, - "sane-topojson": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/sane-topojson/-/sane-topojson-4.0.0.tgz", - "integrity": "sha512-bJILrpBboQfabG3BNnHI2hZl52pbt80BE09u4WhnrmzuF2JbMKZdl62G5glXskJ46p+gxE2IzOwGj/awR4g8AA==", - "dev": true - }, "sass-graph": { "version": "2.2.5", "resolved": "https://registry.npmjs.org/sass-graph/-/sass-graph-2.2.5.tgz", @@ -20963,6 +21025,12 @@ } } }, + "sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", + "dev": true + }, "scss-tokenizer": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/scss-tokenizer/-/scss-tokenizer-0.2.3.tgz", @@ -21462,6 +21530,15 @@ "integrity": "sha512-b/qaq/GlBK5xaq1yrK9/zFcyRSTNxmcZwFLGSTG0mXgZl/4Z6GgiyYOXOvY7N3eEvFRAG1bkDRz5EPGSvPYQlw==", "dev": true }, + "stream-parser": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/stream-parser/-/stream-parser-0.3.1.tgz", + "integrity": "sha1-FhhUhpRCACGhGC/wrxkRwSl2F3M=", + "dev": true, + "requires": { + "debug": "2" + } + }, "stream-shift": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz", @@ -22235,14 +22312,24 @@ "resolved": "https://registry.npmjs.org/tempusdominus-bootstrap-4/-/tempusdominus-bootstrap-4-5.39.0.tgz", "integrity": "sha512-vYnkmQYQq4+A51WyRc/6e03eM0BHDoPaxd556K1pd4Nhr0eGeB3+Mi9b+3CDx4189fg3gQlrsKzgJiHPRwSX3Q==", "dev": true, - "requires": {} + "requires": { + "bootstrap": "^4.5.2", + "jquery": "^3.5.1", + "moment": "^2.29.0", + "moment-timezone": "^0.5.31", + "popper.js": "^1.16.1" + } }, "tempusdominus-core": { "version": "5.19.0", "resolved": "https://registry.npmjs.org/tempusdominus-core/-/tempusdominus-core-5.19.0.tgz", "integrity": "sha512-7a4oBQw4cjz6C87BLRg3KHVvzpnPlnRTkuDZ7SwcJayQQ4QgOryX5u6wj0q07TXhgtMQLCntZO6nVhHIKPaeUw==", "dev": true, - "requires": {} + "requires": { + "jquery": "^3.5.0", + "moment": "~2.24.0", + "moment-timezone": "^0.5.28" + } }, "text-cache": { "version": "4.2.2", diff --git a/package.json b/package.json index 712c6676..70a85130 100644 --- a/package.json +++ b/package.json @@ -22,11 +22,11 @@ "jquery": "^3.6.0", "moment": "^2.29.1", "moment-timezone": "^0.5.33", - "plotly.js": "^1.58.4", + "plotly.js": "^2.0.0", "popper.js": "^1.16.1", "pulltorefreshjs": "^0.1.22", "pump": "^3.0.0", - "stylelint": "^13.12.0", + "stylelint": "^13.13.1", "stylelint-config-recommended-scss": "^4.2.0", "stylelint-order": "^4.1.0", "stylelint-scss": "^3.19.0", diff --git a/static/babybuddy/js/graph.455350929c2f.js b/static/babybuddy/js/graph.09e32032c8ef.js similarity index 82% rename from static/babybuddy/js/graph.455350929c2f.js rename to static/babybuddy/js/graph.09e32032c8ef.js index 87e8690c..b966640e 100644 --- a/static/babybuddy/js/graph.455350929c2f.js +++ b/static/babybuddy/js/graph.09e32032c8ef.js @@ -1,6 +1,6 @@ /** -* plotly.js (cartesian) v1.58.4 -* Copyright 2012-2020, Plotly, Inc. +* plotly.js (cartesian) v2.0.0 +* Copyright 2012-2021, Plotly, Inc. * All rights reserved. * Licensed under the MIT license */ @@ -72,3694 +72,126 @@ for(var selector in rules) { Lib.addStyleRule(fullSelector, rules[selector]); } -},{"../src/lib":233}],2:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +},{"../src/lib":285}],2:[function(_dereq_,module,exports){ +'use strict'; +module.exports = _dereq_('../src/transforms/aggregate'); + +},{"../src/transforms/aggregate":541}],3:[function(_dereq_,module,exports){ 'use strict'; module.exports = _dereq_('../src/traces/bar'); -},{"../src/traces/bar":344}],3:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../src/traces/bar":391}],4:[function(_dereq_,module,exports){ 'use strict'; module.exports = _dereq_('../src/traces/box'); -},{"../src/traces/box":359}],4:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +},{"../src/traces/box":406}],5:[function(_dereq_,module,exports){ +'use strict'; +module.exports = _dereq_('../src/components/calendars'); + +},{"../src/components/calendars":153}],6:[function(_dereq_,module,exports){ 'use strict'; module.exports = _dereq_('../src/traces/contour'); -},{"../src/traces/contour":379}],5:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../src/traces/contour":426}],7:[function(_dereq_,module,exports){ 'use strict'; module.exports = _dereq_('../src/core'); -},{"../src/core":214}],6:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +},{"../src/core":267}],8:[function(_dereq_,module,exports){ +'use strict'; +module.exports = _dereq_('../src/transforms/filter'); + +},{"../src/transforms/filter":542}],9:[function(_dereq_,module,exports){ +'use strict'; + +module.exports = _dereq_('../src/transforms/groupby'); + +},{"../src/transforms/groupby":543}],10:[function(_dereq_,module,exports){ 'use strict'; module.exports = _dereq_('../src/traces/heatmap'); -},{"../src/traces/heatmap":395}],7:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../src/traces/heatmap":442}],11:[function(_dereq_,module,exports){ 'use strict'; module.exports = _dereq_('../src/traces/histogram'); -},{"../src/traces/histogram":413}],8:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../src/traces/histogram":460}],12:[function(_dereq_,module,exports){ 'use strict'; module.exports = _dereq_('../src/traces/histogram2d'); -},{"../src/traces/histogram2d":419}],9:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../src/traces/histogram2d":466}],13:[function(_dereq_,module,exports){ 'use strict'; module.exports = _dereq_('../src/traces/histogram2dcontour'); -},{"../src/traces/histogram2dcontour":423}],10:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../src/traces/histogram2dcontour":470}],14:[function(_dereq_,module,exports){ 'use strict'; module.exports = _dereq_('../src/traces/image'); -},{"../src/traces/image":431}],11:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../src/traces/image":478}],15:[function(_dereq_,module,exports){ 'use strict'; var Plotly = _dereq_('./core'); Plotly.register([ + // traces _dereq_('./bar'), _dereq_('./box'), _dereq_('./heatmap'), _dereq_('./histogram'), _dereq_('./histogram2d'), _dereq_('./histogram2dcontour'), - _dereq_('./image'), - _dereq_('./pie'), _dereq_('./contour'), _dereq_('./scatterternary'), - _dereq_('./violin') + _dereq_('./violin'), + _dereq_('./image'), + _dereq_('./pie'), + + // transforms + _dereq_('./aggregate'), + _dereq_('./filter'), + _dereq_('./groupby'), + _dereq_('./sort'), + + // components + _dereq_('./calendars'), ]); module.exports = Plotly; -},{"./bar":2,"./box":3,"./contour":4,"./core":5,"./heatmap":6,"./histogram":7,"./histogram2d":8,"./histogram2dcontour":9,"./image":10,"./pie":12,"./scatterternary":13,"./violin":14}],12:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"./aggregate":2,"./bar":3,"./box":4,"./calendars":5,"./contour":6,"./core":7,"./filter":8,"./groupby":9,"./heatmap":10,"./histogram":11,"./histogram2d":12,"./histogram2dcontour":13,"./image":14,"./pie":16,"./scatterternary":17,"./sort":18,"./violin":19}],16:[function(_dereq_,module,exports){ 'use strict'; module.exports = _dereq_('../src/traces/pie'); -},{"../src/traces/pie":440}],13:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../src/traces/pie":487}],17:[function(_dereq_,module,exports){ 'use strict'; module.exports = _dereq_('../src/traces/scatterternary'); -},{"../src/traces/scatterternary":481}],14:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +},{"../src/traces/scatterternary":528}],18:[function(_dereq_,module,exports){ +'use strict'; +module.exports = _dereq_('../src/transforms/sort'); + +},{"../src/transforms/sort":545}],19:[function(_dereq_,module,exports){ 'use strict'; module.exports = _dereq_('../src/traces/violin'); -},{"../src/traces/violin":489}],15:[function(_dereq_,module,exports){ -'use strict' - -exports.byteLength = byteLength -exports.toByteArray = toByteArray -exports.fromByteArray = fromByteArray - -var lookup = [] -var revLookup = [] -var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array - -var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' -for (var i = 0, len = code.length; i < len; ++i) { - lookup[i] = code[i] - revLookup[code.charCodeAt(i)] = i -} - -// Support decoding URL-safe base64 strings, as Node.js does. -// See: https://en.wikipedia.org/wiki/Base64#URL_applications -revLookup['-'.charCodeAt(0)] = 62 -revLookup['_'.charCodeAt(0)] = 63 - -function getLens (b64) { - var len = b64.length - - if (len % 4 > 0) { - throw new Error('Invalid string. Length must be a multiple of 4') - } - - // Trim off extra bytes after placeholder bytes are found - // See: https://github.com/beatgammit/base64-js/issues/42 - var validLen = b64.indexOf('=') - if (validLen === -1) validLen = len - - var placeHoldersLen = validLen === len - ? 0 - : 4 - (validLen % 4) - - return [validLen, placeHoldersLen] -} - -// base64 is 4/3 + up to two characters of the original data -function byteLength (b64) { - var lens = getLens(b64) - var validLen = lens[0] - var placeHoldersLen = lens[1] - return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen -} - -function _byteLength (b64, validLen, placeHoldersLen) { - return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen -} - -function toByteArray (b64) { - var tmp - var lens = getLens(b64) - var validLen = lens[0] - var placeHoldersLen = lens[1] - - var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) - - var curByte = 0 - - // if there are placeholders, only get up to the last complete 4 chars - var len = placeHoldersLen > 0 - ? validLen - 4 - : validLen - - var i - for (i = 0; i < len; i += 4) { - tmp = - (revLookup[b64.charCodeAt(i)] << 18) | - (revLookup[b64.charCodeAt(i + 1)] << 12) | - (revLookup[b64.charCodeAt(i + 2)] << 6) | - revLookup[b64.charCodeAt(i + 3)] - arr[curByte++] = (tmp >> 16) & 0xFF - arr[curByte++] = (tmp >> 8) & 0xFF - arr[curByte++] = tmp & 0xFF - } - - if (placeHoldersLen === 2) { - tmp = - (revLookup[b64.charCodeAt(i)] << 2) | - (revLookup[b64.charCodeAt(i + 1)] >> 4) - arr[curByte++] = tmp & 0xFF - } - - if (placeHoldersLen === 1) { - tmp = - (revLookup[b64.charCodeAt(i)] << 10) | - (revLookup[b64.charCodeAt(i + 1)] << 4) | - (revLookup[b64.charCodeAt(i + 2)] >> 2) - arr[curByte++] = (tmp >> 8) & 0xFF - arr[curByte++] = tmp & 0xFF - } - - return arr -} - -function tripletToBase64 (num) { - return lookup[num >> 18 & 0x3F] + - lookup[num >> 12 & 0x3F] + - lookup[num >> 6 & 0x3F] + - lookup[num & 0x3F] -} - -function encodeChunk (uint8, start, end) { - var tmp - var output = [] - for (var i = start; i < end; i += 3) { - tmp = - ((uint8[i] << 16) & 0xFF0000) + - ((uint8[i + 1] << 8) & 0xFF00) + - (uint8[i + 2] & 0xFF) - output.push(tripletToBase64(tmp)) - } - return output.join('') -} - -function fromByteArray (uint8) { - var tmp - var len = uint8.length - var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes - var parts = [] - var maxChunkLength = 16383 // must be multiple of 3 - - // go through the array every three bytes, we'll deal with trailing stuff later - for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { - parts.push(encodeChunk( - uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) - )) - } - - // pad the end with zeros, but make sure to not forget the extra bytes - if (extraBytes === 1) { - tmp = uint8[len - 1] - parts.push( - lookup[tmp >> 2] + - lookup[(tmp << 4) & 0x3F] + - '==' - ) - } else if (extraBytes === 2) { - tmp = (uint8[len - 2] << 8) + uint8[len - 1] - parts.push( - lookup[tmp >> 10] + - lookup[(tmp >> 4) & 0x3F] + - lookup[(tmp << 2) & 0x3F] + - '=' - ) - } - - return parts.join('') -} - -},{}],16:[function(_dereq_,module,exports){ - -},{}],17:[function(_dereq_,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; - -var R = typeof Reflect === 'object' ? Reflect : null -var ReflectApply = R && typeof R.apply === 'function' - ? R.apply - : function ReflectApply(target, receiver, args) { - return Function.prototype.apply.call(target, receiver, args); - } - -var ReflectOwnKeys -if (R && typeof R.ownKeys === 'function') { - ReflectOwnKeys = R.ownKeys -} else if (Object.getOwnPropertySymbols) { - ReflectOwnKeys = function ReflectOwnKeys(target) { - return Object.getOwnPropertyNames(target) - .concat(Object.getOwnPropertySymbols(target)); - }; -} else { - ReflectOwnKeys = function ReflectOwnKeys(target) { - return Object.getOwnPropertyNames(target); - }; -} - -function ProcessEmitWarning(warning) { - if (console && console.warn) console.warn(warning); -} - -var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) { - return value !== value; -} - -function EventEmitter() { - EventEmitter.init.call(this); -} -module.exports = EventEmitter; -module.exports.once = once; - -// Backwards-compat with node 0.10.x -EventEmitter.EventEmitter = EventEmitter; - -EventEmitter.prototype._events = undefined; -EventEmitter.prototype._eventsCount = 0; -EventEmitter.prototype._maxListeners = undefined; - -// By default EventEmitters will print a warning if more than 10 listeners are -// added to it. This is a useful default which helps finding memory leaks. -var defaultMaxListeners = 10; - -function checkListener(listener) { - if (typeof listener !== 'function') { - throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); - } -} - -Object.defineProperty(EventEmitter, 'defaultMaxListeners', { - enumerable: true, - get: function() { - return defaultMaxListeners; - }, - set: function(arg) { - if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) { - throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.'); - } - defaultMaxListeners = arg; - } -}); - -EventEmitter.init = function() { - - if (this._events === undefined || - this._events === Object.getPrototypeOf(this)._events) { - this._events = Object.create(null); - this._eventsCount = 0; - } - - this._maxListeners = this._maxListeners || undefined; -}; - -// Obviously not all Emitters should be limited to 10. This function allows -// that to be increased. Set to zero for unlimited. -EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { - if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) { - throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.'); - } - this._maxListeners = n; - return this; -}; - -function _getMaxListeners(that) { - if (that._maxListeners === undefined) - return EventEmitter.defaultMaxListeners; - return that._maxListeners; -} - -EventEmitter.prototype.getMaxListeners = function getMaxListeners() { - return _getMaxListeners(this); -}; - -EventEmitter.prototype.emit = function emit(type) { - var args = []; - for (var i = 1; i < arguments.length; i++) args.push(arguments[i]); - var doError = (type === 'error'); - - var events = this._events; - if (events !== undefined) - doError = (doError && events.error === undefined); - else if (!doError) - return false; - - // If there is no 'error' event listener then throw. - if (doError) { - var er; - if (args.length > 0) - er = args[0]; - if (er instanceof Error) { - // Note: The comments on the `throw` lines are intentional, they show - // up in Node's output if this results in an unhandled exception. - throw er; // Unhandled 'error' event - } - // At least give some kind of context to the user - var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : '')); - err.context = er; - throw err; // Unhandled 'error' event - } - - var handler = events[type]; - - if (handler === undefined) - return false; - - if (typeof handler === 'function') { - ReflectApply(handler, this, args); - } else { - var len = handler.length; - var listeners = arrayClone(handler, len); - for (var i = 0; i < len; ++i) - ReflectApply(listeners[i], this, args); - } - - return true; -}; - -function _addListener(target, type, listener, prepend) { - var m; - var events; - var existing; - - checkListener(listener); - - events = target._events; - if (events === undefined) { - events = target._events = Object.create(null); - target._eventsCount = 0; - } else { - // To avoid recursion in the case that type === "newListener"! Before - // adding it to the listeners, first emit "newListener". - if (events.newListener !== undefined) { - target.emit('newListener', type, - listener.listener ? listener.listener : listener); - - // Re-assign `events` because a newListener handler could have caused the - // this._events to be assigned to a new object - events = target._events; - } - existing = events[type]; - } - - if (existing === undefined) { - // Optimize the case of one listener. Don't need the extra array object. - existing = events[type] = listener; - ++target._eventsCount; - } else { - if (typeof existing === 'function') { - // Adding the second element, need to change to array. - existing = events[type] = - prepend ? [listener, existing] : [existing, listener]; - // If we've already got an array, just append. - } else if (prepend) { - existing.unshift(listener); - } else { - existing.push(listener); - } - - // Check for listener leak - m = _getMaxListeners(target); - if (m > 0 && existing.length > m && !existing.warned) { - existing.warned = true; - // No error code for this since it is a Warning - // eslint-disable-next-line no-restricted-syntax - var w = new Error('Possible EventEmitter memory leak detected. ' + - existing.length + ' ' + String(type) + ' listeners ' + - 'added. Use emitter.setMaxListeners() to ' + - 'increase limit'); - w.name = 'MaxListenersExceededWarning'; - w.emitter = target; - w.type = type; - w.count = existing.length; - ProcessEmitWarning(w); - } - } - - return target; -} - -EventEmitter.prototype.addListener = function addListener(type, listener) { - return _addListener(this, type, listener, false); -}; - -EventEmitter.prototype.on = EventEmitter.prototype.addListener; - -EventEmitter.prototype.prependListener = - function prependListener(type, listener) { - return _addListener(this, type, listener, true); - }; - -function onceWrapper() { - if (!this.fired) { - this.target.removeListener(this.type, this.wrapFn); - this.fired = true; - if (arguments.length === 0) - return this.listener.call(this.target); - return this.listener.apply(this.target, arguments); - } -} - -function _onceWrap(target, type, listener) { - var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener }; - var wrapped = onceWrapper.bind(state); - wrapped.listener = listener; - state.wrapFn = wrapped; - return wrapped; -} - -EventEmitter.prototype.once = function once(type, listener) { - checkListener(listener); - this.on(type, _onceWrap(this, type, listener)); - return this; -}; - -EventEmitter.prototype.prependOnceListener = - function prependOnceListener(type, listener) { - checkListener(listener); - this.prependListener(type, _onceWrap(this, type, listener)); - return this; - }; - -// Emits a 'removeListener' event if and only if the listener was removed. -EventEmitter.prototype.removeListener = - function removeListener(type, listener) { - var list, events, position, i, originalListener; - - checkListener(listener); - - events = this._events; - if (events === undefined) - return this; - - list = events[type]; - if (list === undefined) - return this; - - if (list === listener || list.listener === listener) { - if (--this._eventsCount === 0) - this._events = Object.create(null); - else { - delete events[type]; - if (events.removeListener) - this.emit('removeListener', type, list.listener || listener); - } - } else if (typeof list !== 'function') { - position = -1; - - for (i = list.length - 1; i >= 0; i--) { - if (list[i] === listener || list[i].listener === listener) { - originalListener = list[i].listener; - position = i; - break; - } - } - - if (position < 0) - return this; - - if (position === 0) - list.shift(); - else { - spliceOne(list, position); - } - - if (list.length === 1) - events[type] = list[0]; - - if (events.removeListener !== undefined) - this.emit('removeListener', type, originalListener || listener); - } - - return this; - }; - -EventEmitter.prototype.off = EventEmitter.prototype.removeListener; - -EventEmitter.prototype.removeAllListeners = - function removeAllListeners(type) { - var listeners, events, i; - - events = this._events; - if (events === undefined) - return this; - - // not listening for removeListener, no need to emit - if (events.removeListener === undefined) { - if (arguments.length === 0) { - this._events = Object.create(null); - this._eventsCount = 0; - } else if (events[type] !== undefined) { - if (--this._eventsCount === 0) - this._events = Object.create(null); - else - delete events[type]; - } - return this; - } - - // emit removeListener for all listeners on all events - if (arguments.length === 0) { - var keys = Object.keys(events); - var key; - for (i = 0; i < keys.length; ++i) { - key = keys[i]; - if (key === 'removeListener') continue; - this.removeAllListeners(key); - } - this.removeAllListeners('removeListener'); - this._events = Object.create(null); - this._eventsCount = 0; - return this; - } - - listeners = events[type]; - - if (typeof listeners === 'function') { - this.removeListener(type, listeners); - } else if (listeners !== undefined) { - // LIFO order - for (i = listeners.length - 1; i >= 0; i--) { - this.removeListener(type, listeners[i]); - } - } - - return this; - }; - -function _listeners(target, type, unwrap) { - var events = target._events; - - if (events === undefined) - return []; - - var evlistener = events[type]; - if (evlistener === undefined) - return []; - - if (typeof evlistener === 'function') - return unwrap ? [evlistener.listener || evlistener] : [evlistener]; - - return unwrap ? - unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length); -} - -EventEmitter.prototype.listeners = function listeners(type) { - return _listeners(this, type, true); -}; - -EventEmitter.prototype.rawListeners = function rawListeners(type) { - return _listeners(this, type, false); -}; - -EventEmitter.listenerCount = function(emitter, type) { - if (typeof emitter.listenerCount === 'function') { - return emitter.listenerCount(type); - } else { - return listenerCount.call(emitter, type); - } -}; - -EventEmitter.prototype.listenerCount = listenerCount; -function listenerCount(type) { - var events = this._events; - - if (events !== undefined) { - var evlistener = events[type]; - - if (typeof evlistener === 'function') { - return 1; - } else if (evlistener !== undefined) { - return evlistener.length; - } - } - - return 0; -} - -EventEmitter.prototype.eventNames = function eventNames() { - return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []; -}; - -function arrayClone(arr, n) { - var copy = new Array(n); - for (var i = 0; i < n; ++i) - copy[i] = arr[i]; - return copy; -} - -function spliceOne(list, index) { - for (; index + 1 < list.length; index++) - list[index] = list[index + 1]; - list.pop(); -} - -function unwrapListeners(arr) { - var ret = new Array(arr.length); - for (var i = 0; i < ret.length; ++i) { - ret[i] = arr[i].listener || arr[i]; - } - return ret; -} - -function once(emitter, name) { - return new Promise(function (resolve, reject) { - function eventListener() { - if (errorListener !== undefined) { - emitter.removeListener('error', errorListener); - } - resolve([].slice.call(arguments)); - }; - var errorListener; - - // Adding an error listener is not optional because - // if an error is thrown on an event emitter we cannot - // guarantee that the actual event we are waiting will - // be fired. The result could be a silent way to create - // memory or file descriptor leaks, which is something - // we should avoid. - if (name !== 'error') { - errorListener = function errorListener(err) { - emitter.removeListener(name, eventListener); - reject(err); - }; - - emitter.once('error', errorListener); - } - - emitter.once(name, eventListener); - }); -} - -},{}],18:[function(_dereq_,module,exports){ -(function (Buffer){(function (){ -/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ -/* eslint-disable no-proto */ - -'use strict' - -var base64 = _dereq_('base64-js') -var ieee754 = _dereq_('ieee754') - -exports.Buffer = Buffer -exports.SlowBuffer = SlowBuffer -exports.INSPECT_MAX_BYTES = 50 - -var K_MAX_LENGTH = 0x7fffffff -exports.kMaxLength = K_MAX_LENGTH - -/** - * If `Buffer.TYPED_ARRAY_SUPPORT`: - * === true Use Uint8Array implementation (fastest) - * === false Print warning and recommend using `buffer` v4.x which has an Object - * implementation (most compatible, even IE6) - * - * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, - * Opera 11.6+, iOS 4.2+. - * - * We report that the browser does not support typed arrays if the are not subclassable - * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` - * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support - * for __proto__ and has a buggy typed array implementation. - */ -Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() - -if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && - typeof console.error === 'function') { - console.error( - 'This browser lacks typed array (Uint8Array) support which is required by ' + - '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' - ) -} - -function typedArraySupport () { - // Can typed array instances can be augmented? - try { - var arr = new Uint8Array(1) - arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } } - return arr.foo() === 42 - } catch (e) { - return false - } -} - -Object.defineProperty(Buffer.prototype, 'parent', { - enumerable: true, - get: function () { - if (!Buffer.isBuffer(this)) return undefined - return this.buffer - } -}) - -Object.defineProperty(Buffer.prototype, 'offset', { - enumerable: true, - get: function () { - if (!Buffer.isBuffer(this)) return undefined - return this.byteOffset - } -}) - -function createBuffer (length) { - if (length > K_MAX_LENGTH) { - throw new RangeError('The value "' + length + '" is invalid for option "size"') - } - // Return an augmented `Uint8Array` instance - var buf = new Uint8Array(length) - buf.__proto__ = Buffer.prototype - return buf -} - -/** - * The Buffer constructor returns instances of `Uint8Array` that have their - * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of - * `Uint8Array`, so the returned instances will have all the node `Buffer` methods - * and the `Uint8Array` methods. Square bracket notation works as expected -- it - * returns a single octet. - * - * The `Uint8Array` prototype remains unmodified. - */ - -function Buffer (arg, encodingOrOffset, length) { - // Common case. - if (typeof arg === 'number') { - if (typeof encodingOrOffset === 'string') { - throw new TypeError( - 'The "string" argument must be of type string. Received type number' - ) - } - return allocUnsafe(arg) - } - return from(arg, encodingOrOffset, length) -} - -// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 -if (typeof Symbol !== 'undefined' && Symbol.species != null && - Buffer[Symbol.species] === Buffer) { - Object.defineProperty(Buffer, Symbol.species, { - value: null, - configurable: true, - enumerable: false, - writable: false - }) -} - -Buffer.poolSize = 8192 // not used by this implementation - -function from (value, encodingOrOffset, length) { - if (typeof value === 'string') { - return fromString(value, encodingOrOffset) - } - - if (ArrayBuffer.isView(value)) { - return fromArrayLike(value) - } - - if (value == null) { - throw TypeError( - 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + - 'or Array-like Object. Received type ' + (typeof value) - ) - } - - if (isInstance(value, ArrayBuffer) || - (value && isInstance(value.buffer, ArrayBuffer))) { - return fromArrayBuffer(value, encodingOrOffset, length) - } - - if (typeof value === 'number') { - throw new TypeError( - 'The "value" argument must not be of type number. Received type number' - ) - } - - var valueOf = value.valueOf && value.valueOf() - if (valueOf != null && valueOf !== value) { - return Buffer.from(valueOf, encodingOrOffset, length) - } - - var b = fromObject(value) - if (b) return b - - if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && - typeof value[Symbol.toPrimitive] === 'function') { - return Buffer.from( - value[Symbol.toPrimitive]('string'), encodingOrOffset, length - ) - } - - throw new TypeError( - 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + - 'or Array-like Object. Received type ' + (typeof value) - ) -} - -/** - * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError - * if value is a number. - * Buffer.from(str[, encoding]) - * Buffer.from(array) - * Buffer.from(buffer) - * Buffer.from(arrayBuffer[, byteOffset[, length]]) - **/ -Buffer.from = function (value, encodingOrOffset, length) { - return from(value, encodingOrOffset, length) -} - -// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: -// https://github.com/feross/buffer/pull/148 -Buffer.prototype.__proto__ = Uint8Array.prototype -Buffer.__proto__ = Uint8Array - -function assertSize (size) { - if (typeof size !== 'number') { - throw new TypeError('"size" argument must be of type number') - } else if (size < 0) { - throw new RangeError('The value "' + size + '" is invalid for option "size"') - } -} - -function alloc (size, fill, encoding) { - assertSize(size) - if (size <= 0) { - return createBuffer(size) - } - if (fill !== undefined) { - // Only pay attention to encoding if it's a string. This - // prevents accidentally sending in a number that would - // be interpretted as a start offset. - return typeof encoding === 'string' - ? createBuffer(size).fill(fill, encoding) - : createBuffer(size).fill(fill) - } - return createBuffer(size) -} - -/** - * Creates a new filled Buffer instance. - * alloc(size[, fill[, encoding]]) - **/ -Buffer.alloc = function (size, fill, encoding) { - return alloc(size, fill, encoding) -} - -function allocUnsafe (size) { - assertSize(size) - return createBuffer(size < 0 ? 0 : checked(size) | 0) -} - -/** - * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. - * */ -Buffer.allocUnsafe = function (size) { - return allocUnsafe(size) -} -/** - * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. - */ -Buffer.allocUnsafeSlow = function (size) { - return allocUnsafe(size) -} - -function fromString (string, encoding) { - if (typeof encoding !== 'string' || encoding === '') { - encoding = 'utf8' - } - - if (!Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) - } - - var length = byteLength(string, encoding) | 0 - var buf = createBuffer(length) - - var actual = buf.write(string, encoding) - - if (actual !== length) { - // Writing a hex string, for example, that contains invalid characters will - // cause everything after the first invalid character to be ignored. (e.g. - // 'abxxcd' will be treated as 'ab') - buf = buf.slice(0, actual) - } - - return buf -} - -function fromArrayLike (array) { - var length = array.length < 0 ? 0 : checked(array.length) | 0 - var buf = createBuffer(length) - for (var i = 0; i < length; i += 1) { - buf[i] = array[i] & 255 - } - return buf -} - -function fromArrayBuffer (array, byteOffset, length) { - if (byteOffset < 0 || array.byteLength < byteOffset) { - throw new RangeError('"offset" is outside of buffer bounds') - } - - if (array.byteLength < byteOffset + (length || 0)) { - throw new RangeError('"length" is outside of buffer bounds') - } - - var buf - if (byteOffset === undefined && length === undefined) { - buf = new Uint8Array(array) - } else if (length === undefined) { - buf = new Uint8Array(array, byteOffset) - } else { - buf = new Uint8Array(array, byteOffset, length) - } - - // Return an augmented `Uint8Array` instance - buf.__proto__ = Buffer.prototype - return buf -} - -function fromObject (obj) { - if (Buffer.isBuffer(obj)) { - var len = checked(obj.length) | 0 - var buf = createBuffer(len) - - if (buf.length === 0) { - return buf - } - - obj.copy(buf, 0, 0, len) - return buf - } - - if (obj.length !== undefined) { - if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { - return createBuffer(0) - } - return fromArrayLike(obj) - } - - if (obj.type === 'Buffer' && Array.isArray(obj.data)) { - return fromArrayLike(obj.data) - } -} - -function checked (length) { - // Note: cannot use `length < K_MAX_LENGTH` here because that fails when - // length is NaN (which is otherwise coerced to zero.) - if (length >= K_MAX_LENGTH) { - throw new RangeError('Attempt to allocate Buffer larger than maximum ' + - 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') - } - return length | 0 -} - -function SlowBuffer (length) { - if (+length != length) { // eslint-disable-line eqeqeq - length = 0 - } - return Buffer.alloc(+length) -} - -Buffer.isBuffer = function isBuffer (b) { - return b != null && b._isBuffer === true && - b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false -} - -Buffer.compare = function compare (a, b) { - if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength) - if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength) - if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { - throw new TypeError( - 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array' - ) - } - - if (a === b) return 0 - - var x = a.length - var y = b.length - - for (var i = 0, len = Math.min(x, y); i < len; ++i) { - if (a[i] !== b[i]) { - x = a[i] - y = b[i] - break - } - } - - if (x < y) return -1 - if (y < x) return 1 - return 0 -} - -Buffer.isEncoding = function isEncoding (encoding) { - switch (String(encoding).toLowerCase()) { - case 'hex': - case 'utf8': - case 'utf-8': - case 'ascii': - case 'latin1': - case 'binary': - case 'base64': - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return true - default: - return false - } -} - -Buffer.concat = function concat (list, length) { - if (!Array.isArray(list)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } - - if (list.length === 0) { - return Buffer.alloc(0) - } - - var i - if (length === undefined) { - length = 0 - for (i = 0; i < list.length; ++i) { - length += list[i].length - } - } - - var buffer = Buffer.allocUnsafe(length) - var pos = 0 - for (i = 0; i < list.length; ++i) { - var buf = list[i] - if (isInstance(buf, Uint8Array)) { - buf = Buffer.from(buf) - } - if (!Buffer.isBuffer(buf)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } - buf.copy(buffer, pos) - pos += buf.length - } - return buffer -} - -function byteLength (string, encoding) { - if (Buffer.isBuffer(string)) { - return string.length - } - if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { - return string.byteLength - } - if (typeof string !== 'string') { - throw new TypeError( - 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + - 'Received type ' + typeof string - ) - } - - var len = string.length - var mustMatch = (arguments.length > 2 && arguments[2] === true) - if (!mustMatch && len === 0) return 0 - - // Use a for loop to avoid recursion - var loweredCase = false - for (;;) { - switch (encoding) { - case 'ascii': - case 'latin1': - case 'binary': - return len - case 'utf8': - case 'utf-8': - return utf8ToBytes(string).length - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return len * 2 - case 'hex': - return len >>> 1 - case 'base64': - return base64ToBytes(string).length - default: - if (loweredCase) { - return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8 - } - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } -} -Buffer.byteLength = byteLength - -function slowToString (encoding, start, end) { - var loweredCase = false - - // No need to verify that "this.length <= MAX_UINT32" since it's a read-only - // property of a typed array. - - // This behaves neither like String nor Uint8Array in that we set start/end - // to their upper/lower bounds if the value passed is out of range. - // undefined is handled specially as per ECMA-262 6th Edition, - // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. - if (start === undefined || start < 0) { - start = 0 - } - // Return early if start > this.length. Done here to prevent potential uint32 - // coercion fail below. - if (start > this.length) { - return '' - } - - if (end === undefined || end > this.length) { - end = this.length - } - - if (end <= 0) { - return '' - } - - // Force coersion to uint32. This will also coerce falsey/NaN values to 0. - end >>>= 0 - start >>>= 0 - - if (end <= start) { - return '' - } - - if (!encoding) encoding = 'utf8' - - while (true) { - switch (encoding) { - case 'hex': - return hexSlice(this, start, end) - - case 'utf8': - case 'utf-8': - return utf8Slice(this, start, end) - - case 'ascii': - return asciiSlice(this, start, end) - - case 'latin1': - case 'binary': - return latin1Slice(this, start, end) - - case 'base64': - return base64Slice(this, start, end) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return utf16leSlice(this, start, end) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = (encoding + '').toLowerCase() - loweredCase = true - } - } -} - -// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) -// to detect a Buffer instance. It's not possible to use `instanceof Buffer` -// reliably in a browserify context because there could be multiple different -// copies of the 'buffer' package in use. This method works even for Buffer -// instances that were created from another copy of the `buffer` package. -// See: https://github.com/feross/buffer/issues/154 -Buffer.prototype._isBuffer = true - -function swap (b, n, m) { - var i = b[n] - b[n] = b[m] - b[m] = i -} - -Buffer.prototype.swap16 = function swap16 () { - var len = this.length - if (len % 2 !== 0) { - throw new RangeError('Buffer size must be a multiple of 16-bits') - } - for (var i = 0; i < len; i += 2) { - swap(this, i, i + 1) - } - return this -} - -Buffer.prototype.swap32 = function swap32 () { - var len = this.length - if (len % 4 !== 0) { - throw new RangeError('Buffer size must be a multiple of 32-bits') - } - for (var i = 0; i < len; i += 4) { - swap(this, i, i + 3) - swap(this, i + 1, i + 2) - } - return this -} - -Buffer.prototype.swap64 = function swap64 () { - var len = this.length - if (len % 8 !== 0) { - throw new RangeError('Buffer size must be a multiple of 64-bits') - } - for (var i = 0; i < len; i += 8) { - swap(this, i, i + 7) - swap(this, i + 1, i + 6) - swap(this, i + 2, i + 5) - swap(this, i + 3, i + 4) - } - return this -} - -Buffer.prototype.toString = function toString () { - var length = this.length - if (length === 0) return '' - if (arguments.length === 0) return utf8Slice(this, 0, length) - return slowToString.apply(this, arguments) -} - -Buffer.prototype.toLocaleString = Buffer.prototype.toString - -Buffer.prototype.equals = function equals (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - if (this === b) return true - return Buffer.compare(this, b) === 0 -} - -Buffer.prototype.inspect = function inspect () { - var str = '' - var max = exports.INSPECT_MAX_BYTES - str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim() - if (this.length > max) str += ' ... ' - return '' -} - -Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { - if (isInstance(target, Uint8Array)) { - target = Buffer.from(target, target.offset, target.byteLength) - } - if (!Buffer.isBuffer(target)) { - throw new TypeError( - 'The "target" argument must be one of type Buffer or Uint8Array. ' + - 'Received type ' + (typeof target) - ) - } - - if (start === undefined) { - start = 0 - } - if (end === undefined) { - end = target ? target.length : 0 - } - if (thisStart === undefined) { - thisStart = 0 - } - if (thisEnd === undefined) { - thisEnd = this.length - } - - if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { - throw new RangeError('out of range index') - } - - if (thisStart >= thisEnd && start >= end) { - return 0 - } - if (thisStart >= thisEnd) { - return -1 - } - if (start >= end) { - return 1 - } - - start >>>= 0 - end >>>= 0 - thisStart >>>= 0 - thisEnd >>>= 0 - - if (this === target) return 0 - - var x = thisEnd - thisStart - var y = end - start - var len = Math.min(x, y) - - var thisCopy = this.slice(thisStart, thisEnd) - var targetCopy = target.slice(start, end) - - for (var i = 0; i < len; ++i) { - if (thisCopy[i] !== targetCopy[i]) { - x = thisCopy[i] - y = targetCopy[i] - break - } - } - - if (x < y) return -1 - if (y < x) return 1 - return 0 -} - -// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, -// OR the last index of `val` in `buffer` at offset <= `byteOffset`. -// -// Arguments: -// - buffer - a Buffer to search -// - val - a string, Buffer, or number -// - byteOffset - an index into `buffer`; will be clamped to an int32 -// - encoding - an optional encoding, relevant is val is a string -// - dir - true for indexOf, false for lastIndexOf -function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { - // Empty buffer means no match - if (buffer.length === 0) return -1 - - // Normalize byteOffset - if (typeof byteOffset === 'string') { - encoding = byteOffset - byteOffset = 0 - } else if (byteOffset > 0x7fffffff) { - byteOffset = 0x7fffffff - } else if (byteOffset < -0x80000000) { - byteOffset = -0x80000000 - } - byteOffset = +byteOffset // Coerce to Number. - if (numberIsNaN(byteOffset)) { - // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer - byteOffset = dir ? 0 : (buffer.length - 1) - } - - // Normalize byteOffset: negative offsets start from the end of the buffer - if (byteOffset < 0) byteOffset = buffer.length + byteOffset - if (byteOffset >= buffer.length) { - if (dir) return -1 - else byteOffset = buffer.length - 1 - } else if (byteOffset < 0) { - if (dir) byteOffset = 0 - else return -1 - } - - // Normalize val - if (typeof val === 'string') { - val = Buffer.from(val, encoding) - } - - // Finally, search either indexOf (if dir is true) or lastIndexOf - if (Buffer.isBuffer(val)) { - // Special case: looking for empty string/buffer always fails - if (val.length === 0) { - return -1 - } - return arrayIndexOf(buffer, val, byteOffset, encoding, dir) - } else if (typeof val === 'number') { - val = val & 0xFF // Search for a byte value [0-255] - if (typeof Uint8Array.prototype.indexOf === 'function') { - if (dir) { - return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) - } else { - return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) - } - } - return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) - } - - throw new TypeError('val must be string, number or Buffer') -} - -function arrayIndexOf (arr, val, byteOffset, encoding, dir) { - var indexSize = 1 - var arrLength = arr.length - var valLength = val.length - - if (encoding !== undefined) { - encoding = String(encoding).toLowerCase() - if (encoding === 'ucs2' || encoding === 'ucs-2' || - encoding === 'utf16le' || encoding === 'utf-16le') { - if (arr.length < 2 || val.length < 2) { - return -1 - } - indexSize = 2 - arrLength /= 2 - valLength /= 2 - byteOffset /= 2 - } - } - - function read (buf, i) { - if (indexSize === 1) { - return buf[i] - } else { - return buf.readUInt16BE(i * indexSize) - } - } - - var i - if (dir) { - var foundIndex = -1 - for (i = byteOffset; i < arrLength; i++) { - if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { - if (foundIndex === -1) foundIndex = i - if (i - foundIndex + 1 === valLength) return foundIndex * indexSize - } else { - if (foundIndex !== -1) i -= i - foundIndex - foundIndex = -1 - } - } - } else { - if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength - for (i = byteOffset; i >= 0; i--) { - var found = true - for (var j = 0; j < valLength; j++) { - if (read(arr, i + j) !== read(val, j)) { - found = false - break - } - } - if (found) return i - } - } - - return -1 -} - -Buffer.prototype.includes = function includes (val, byteOffset, encoding) { - return this.indexOf(val, byteOffset, encoding) !== -1 -} - -Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, true) -} - -Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, false) -} - -function hexWrite (buf, string, offset, length) { - offset = Number(offset) || 0 - var remaining = buf.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining - } - } - - var strLen = string.length - - if (length > strLen / 2) { - length = strLen / 2 - } - for (var i = 0; i < length; ++i) { - var parsed = parseInt(string.substr(i * 2, 2), 16) - if (numberIsNaN(parsed)) return i - buf[offset + i] = parsed - } - return i -} - -function utf8Write (buf, string, offset, length) { - return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) -} - -function asciiWrite (buf, string, offset, length) { - return blitBuffer(asciiToBytes(string), buf, offset, length) -} - -function latin1Write (buf, string, offset, length) { - return asciiWrite(buf, string, offset, length) -} - -function base64Write (buf, string, offset, length) { - return blitBuffer(base64ToBytes(string), buf, offset, length) -} - -function ucs2Write (buf, string, offset, length) { - return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) -} - -Buffer.prototype.write = function write (string, offset, length, encoding) { - // Buffer#write(string) - if (offset === undefined) { - encoding = 'utf8' - length = this.length - offset = 0 - // Buffer#write(string, encoding) - } else if (length === undefined && typeof offset === 'string') { - encoding = offset - length = this.length - offset = 0 - // Buffer#write(string, offset[, length][, encoding]) - } else if (isFinite(offset)) { - offset = offset >>> 0 - if (isFinite(length)) { - length = length >>> 0 - if (encoding === undefined) encoding = 'utf8' - } else { - encoding = length - length = undefined - } - } else { - throw new Error( - 'Buffer.write(string, encoding, offset[, length]) is no longer supported' - ) - } - - var remaining = this.length - offset - if (length === undefined || length > remaining) length = remaining - - if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { - throw new RangeError('Attempt to write outside buffer bounds') - } - - if (!encoding) encoding = 'utf8' - - var loweredCase = false - for (;;) { - switch (encoding) { - case 'hex': - return hexWrite(this, string, offset, length) - - case 'utf8': - case 'utf-8': - return utf8Write(this, string, offset, length) - - case 'ascii': - return asciiWrite(this, string, offset, length) - - case 'latin1': - case 'binary': - return latin1Write(this, string, offset, length) - - case 'base64': - // Warning: maxLength not taken into account in base64Write - return base64Write(this, string, offset, length) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return ucs2Write(this, string, offset, length) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } -} - -Buffer.prototype.toJSON = function toJSON () { - return { - type: 'Buffer', - data: Array.prototype.slice.call(this._arr || this, 0) - } -} - -function base64Slice (buf, start, end) { - if (start === 0 && end === buf.length) { - return base64.fromByteArray(buf) - } else { - return base64.fromByteArray(buf.slice(start, end)) - } -} - -function utf8Slice (buf, start, end) { - end = Math.min(buf.length, end) - var res = [] - - var i = start - while (i < end) { - var firstByte = buf[i] - var codePoint = null - var bytesPerSequence = (firstByte > 0xEF) ? 4 - : (firstByte > 0xDF) ? 3 - : (firstByte > 0xBF) ? 2 - : 1 - - if (i + bytesPerSequence <= end) { - var secondByte, thirdByte, fourthByte, tempCodePoint - - switch (bytesPerSequence) { - case 1: - if (firstByte < 0x80) { - codePoint = firstByte - } - break - case 2: - secondByte = buf[i + 1] - if ((secondByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) - if (tempCodePoint > 0x7F) { - codePoint = tempCodePoint - } - } - break - case 3: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) - if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { - codePoint = tempCodePoint - } - } - break - case 4: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - fourthByte = buf[i + 3] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) - if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { - codePoint = tempCodePoint - } - } - } - } - - if (codePoint === null) { - // we did not generate a valid codePoint so insert a - // replacement char (U+FFFD) and advance only 1 byte - codePoint = 0xFFFD - bytesPerSequence = 1 - } else if (codePoint > 0xFFFF) { - // encode to utf16 (surrogate pair dance) - codePoint -= 0x10000 - res.push(codePoint >>> 10 & 0x3FF | 0xD800) - codePoint = 0xDC00 | codePoint & 0x3FF - } - - res.push(codePoint) - i += bytesPerSequence - } - - return decodeCodePointsArray(res) -} - -// Based on http://stackoverflow.com/a/22747272/680742, the browser with -// the lowest limit is Chrome, with 0x10000 args. -// We go 1 magnitude less, for safety -var MAX_ARGUMENTS_LENGTH = 0x1000 - -function decodeCodePointsArray (codePoints) { - var len = codePoints.length - if (len <= MAX_ARGUMENTS_LENGTH) { - return String.fromCharCode.apply(String, codePoints) // avoid extra slice() - } - - // Decode in chunks to avoid "call stack size exceeded". - var res = '' - var i = 0 - while (i < len) { - res += String.fromCharCode.apply( - String, - codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) - ) - } - return res -} - -function asciiSlice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i] & 0x7F) - } - return ret -} - -function latin1Slice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i]) - } - return ret -} - -function hexSlice (buf, start, end) { - var len = buf.length - - if (!start || start < 0) start = 0 - if (!end || end < 0 || end > len) end = len - - var out = '' - for (var i = start; i < end; ++i) { - out += toHex(buf[i]) - } - return out -} - -function utf16leSlice (buf, start, end) { - var bytes = buf.slice(start, end) - var res = '' - for (var i = 0; i < bytes.length; i += 2) { - res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) - } - return res -} - -Buffer.prototype.slice = function slice (start, end) { - var len = this.length - start = ~~start - end = end === undefined ? len : ~~end - - if (start < 0) { - start += len - if (start < 0) start = 0 - } else if (start > len) { - start = len - } - - if (end < 0) { - end += len - if (end < 0) end = 0 - } else if (end > len) { - end = len - } - - if (end < start) end = start - - var newBuf = this.subarray(start, end) - // Return an augmented `Uint8Array` instance - newBuf.__proto__ = Buffer.prototype - return newBuf -} - -/* - * Need to make sure that buffer isn't trying to write out of bounds. - */ -function checkOffset (offset, ext, length) { - if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') - if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') -} - -Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - - return val -} - -Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - checkOffset(offset, byteLength, this.length) - } - - var val = this[offset + --byteLength] - var mul = 1 - while (byteLength > 0 && (mul *= 0x100)) { - val += this[offset + --byteLength] * mul - } - - return val -} - -Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 1, this.length) - return this[offset] -} - -Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - return this[offset] | (this[offset + 1] << 8) -} - -Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - return (this[offset] << 8) | this[offset + 1] -} - -Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return ((this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16)) + - (this[offset + 3] * 0x1000000) -} - -Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] * 0x1000000) + - ((this[offset + 1] << 16) | - (this[offset + 2] << 8) | - this[offset + 3]) -} - -Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val -} - -Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var i = byteLength - var mul = 1 - var val = this[offset + --i] - while (i > 0 && (mul *= 0x100)) { - val += this[offset + --i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val -} - -Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 1, this.length) - if (!(this[offset] & 0x80)) return (this[offset]) - return ((0xff - this[offset] + 1) * -1) -} - -Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset] | (this[offset + 1] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} - -Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset + 1] | (this[offset] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} - -Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16) | - (this[offset + 3] << 24) -} - -Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] << 24) | - (this[offset + 1] << 16) | - (this[offset + 2] << 8) | - (this[offset + 3]) -} - -Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, true, 23, 4) -} - -Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, false, 23, 4) -} - -Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, true, 52, 8) -} - -Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, false, 52, 8) -} - -function checkInt (buf, value, offset, ext, max, min) { - if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') - if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') - if (offset + ext > buf.length) throw new RangeError('Index out of range') -} - -Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } - - var mul = 1 - var i = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } - - var i = byteLength - 1 - var mul = 1 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) - this[offset] = (value & 0xff) - return offset + 1 -} - -Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - return offset + 2 -} - -Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - return offset + 2 -} - -Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - this[offset + 3] = (value >>> 24) - this[offset + 2] = (value >>> 16) - this[offset + 1] = (value >>> 8) - this[offset] = (value & 0xff) - return offset + 4 -} - -Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - return offset + 4 -} - -Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - var limit = Math.pow(2, (8 * byteLength) - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - var i = 0 - var mul = 1 - var sub = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { - sub = 1 - } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - var limit = Math.pow(2, (8 * byteLength) - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - var i = byteLength - 1 - var mul = 1 - var sub = 0 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { - sub = 1 - } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) - if (value < 0) value = 0xff + value + 1 - this[offset] = (value & 0xff) - return offset + 1 -} - -Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - return offset + 2 -} - -Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - return offset + 2 -} - -Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - this[offset + 2] = (value >>> 16) - this[offset + 3] = (value >>> 24) - return offset + 4 -} - -Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (value < 0) value = 0xffffffff + value + 1 - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - return offset + 4 -} - -function checkIEEE754 (buf, value, offset, ext, max, min) { - if (offset + ext > buf.length) throw new RangeError('Index out of range') - if (offset < 0) throw new RangeError('Index out of range') -} - -function writeFloat (buf, value, offset, littleEndian, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) - } - ieee754.write(buf, value, offset, littleEndian, 23, 4) - return offset + 4 -} - -Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { - return writeFloat(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { - return writeFloat(this, value, offset, false, noAssert) -} - -function writeDouble (buf, value, offset, littleEndian, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) - } - ieee754.write(buf, value, offset, littleEndian, 52, 8) - return offset + 8 -} - -Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { - return writeDouble(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { - return writeDouble(this, value, offset, false, noAssert) -} - -// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) -Buffer.prototype.copy = function copy (target, targetStart, start, end) { - if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') - if (!start) start = 0 - if (!end && end !== 0) end = this.length - if (targetStart >= target.length) targetStart = target.length - if (!targetStart) targetStart = 0 - if (end > 0 && end < start) end = start - - // Copy 0 bytes; we're done - if (end === start) return 0 - if (target.length === 0 || this.length === 0) return 0 - - // Fatal error conditions - if (targetStart < 0) { - throw new RangeError('targetStart out of bounds') - } - if (start < 0 || start >= this.length) throw new RangeError('Index out of range') - if (end < 0) throw new RangeError('sourceEnd out of bounds') - - // Are we oob? - if (end > this.length) end = this.length - if (target.length - targetStart < end - start) { - end = target.length - targetStart + start - } - - var len = end - start - - if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { - // Use built-in when available, missing from IE11 - this.copyWithin(targetStart, start, end) - } else if (this === target && start < targetStart && targetStart < end) { - // descending copy from end - for (var i = len - 1; i >= 0; --i) { - target[i + targetStart] = this[i + start] - } - } else { - Uint8Array.prototype.set.call( - target, - this.subarray(start, end), - targetStart - ) - } - - return len -} - -// Usage: -// buffer.fill(number[, offset[, end]]) -// buffer.fill(buffer[, offset[, end]]) -// buffer.fill(string[, offset[, end]][, encoding]) -Buffer.prototype.fill = function fill (val, start, end, encoding) { - // Handle string cases: - if (typeof val === 'string') { - if (typeof start === 'string') { - encoding = start - start = 0 - end = this.length - } else if (typeof end === 'string') { - encoding = end - end = this.length - } - if (encoding !== undefined && typeof encoding !== 'string') { - throw new TypeError('encoding must be a string') - } - if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) - } - if (val.length === 1) { - var code = val.charCodeAt(0) - if ((encoding === 'utf8' && code < 128) || - encoding === 'latin1') { - // Fast path: If `val` fits into a single byte, use that numeric value. - val = code - } - } - } else if (typeof val === 'number') { - val = val & 255 - } - - // Invalid ranges are not set to a default, so can range check early. - if (start < 0 || this.length < start || this.length < end) { - throw new RangeError('Out of range index') - } - - if (end <= start) { - return this - } - - start = start >>> 0 - end = end === undefined ? this.length : end >>> 0 - - if (!val) val = 0 - - var i - if (typeof val === 'number') { - for (i = start; i < end; ++i) { - this[i] = val - } - } else { - var bytes = Buffer.isBuffer(val) - ? val - : Buffer.from(val, encoding) - var len = bytes.length - if (len === 0) { - throw new TypeError('The value "' + val + - '" is invalid for argument "value"') - } - for (i = 0; i < end - start; ++i) { - this[i + start] = bytes[i % len] - } - } - - return this -} - -// HELPER FUNCTIONS -// ================ - -var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g - -function base64clean (str) { - // Node takes equal signs as end of the Base64 encoding - str = str.split('=')[0] - // Node strips out invalid characters like \n and \t from the string, base64-js does not - str = str.trim().replace(INVALID_BASE64_RE, '') - // Node converts strings with length < 2 to '' - if (str.length < 2) return '' - // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not - while (str.length % 4 !== 0) { - str = str + '=' - } - return str -} - -function toHex (n) { - if (n < 16) return '0' + n.toString(16) - return n.toString(16) -} - -function utf8ToBytes (string, units) { - units = units || Infinity - var codePoint - var length = string.length - var leadSurrogate = null - var bytes = [] - - for (var i = 0; i < length; ++i) { - codePoint = string.charCodeAt(i) - - // is surrogate component - if (codePoint > 0xD7FF && codePoint < 0xE000) { - // last char was a lead - if (!leadSurrogate) { - // no lead yet - if (codePoint > 0xDBFF) { - // unexpected trail - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } else if (i + 1 === length) { - // unpaired lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } - - // valid lead - leadSurrogate = codePoint - - continue - } - - // 2 leads in a row - if (codePoint < 0xDC00) { - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = codePoint - continue - } - - // valid surrogate pair - codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 - } else if (leadSurrogate) { - // valid bmp char, but last char was a lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - } - - leadSurrogate = null - - // encode utf8 - if (codePoint < 0x80) { - if ((units -= 1) < 0) break - bytes.push(codePoint) - } else if (codePoint < 0x800) { - if ((units -= 2) < 0) break - bytes.push( - codePoint >> 0x6 | 0xC0, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x10000) { - if ((units -= 3) < 0) break - bytes.push( - codePoint >> 0xC | 0xE0, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x110000) { - if ((units -= 4) < 0) break - bytes.push( - codePoint >> 0x12 | 0xF0, - codePoint >> 0xC & 0x3F | 0x80, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else { - throw new Error('Invalid code point') - } - } - - return bytes -} - -function asciiToBytes (str) { - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - // Node's code seems to be doing this and not & 0x7F.. - byteArray.push(str.charCodeAt(i) & 0xFF) - } - return byteArray -} - -function utf16leToBytes (str, units) { - var c, hi, lo - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - if ((units -= 2) < 0) break - - c = str.charCodeAt(i) - hi = c >> 8 - lo = c % 256 - byteArray.push(lo) - byteArray.push(hi) - } - - return byteArray -} - -function base64ToBytes (str) { - return base64.toByteArray(base64clean(str)) -} - -function blitBuffer (src, dst, offset, length) { - for (var i = 0; i < length; ++i) { - if ((i + offset >= dst.length) || (i >= src.length)) break - dst[i + offset] = src[i] - } - return i -} - -// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass -// the `instanceof` check but they should be treated as of that type. -// See: https://github.com/feross/buffer/issues/166 -function isInstance (obj, type) { - return obj instanceof type || - (obj != null && obj.constructor != null && obj.constructor.name != null && - obj.constructor.name === type.name) -} -function numberIsNaN (obj) { - // For IE11 support - return obj !== obj // eslint-disable-line no-self-compare -} - -}).call(this)}).call(this,_dereq_("buffer").Buffer) -},{"base64-js":15,"buffer":18,"ieee754":56}],19:[function(_dereq_,module,exports){ -// https://d3js.org/d3-time-format/ v2.2.3 Copyright 2019 Mike Bostock -(function (global, factory) { -typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, _dereq_('d3-time')) : -typeof define === 'function' && define.amd ? define(['exports', 'd3-time'], factory) : -(global = global || self, factory(global.d3 = global.d3 || {}, global.d3)); -}(this, function (exports, d3Time) { 'use strict'; - -function localDate(d) { - if (0 <= d.y && d.y < 100) { - var date = new Date(-1, d.m, d.d, d.H, d.M, d.S, d.L); - date.setFullYear(d.y); - return date; - } - return new Date(d.y, d.m, d.d, d.H, d.M, d.S, d.L); -} - -function utcDate(d) { - if (0 <= d.y && d.y < 100) { - var date = new Date(Date.UTC(-1, d.m, d.d, d.H, d.M, d.S, d.L)); - date.setUTCFullYear(d.y); - return date; - } - return new Date(Date.UTC(d.y, d.m, d.d, d.H, d.M, d.S, d.L)); -} - -function newDate(y, m, d) { - return {y: y, m: m, d: d, H: 0, M: 0, S: 0, L: 0}; -} - -function formatLocale(locale) { - var locale_dateTime = locale.dateTime, - locale_date = locale.date, - locale_time = locale.time, - locale_periods = locale.periods, - locale_weekdays = locale.days, - locale_shortWeekdays = locale.shortDays, - locale_months = locale.months, - locale_shortMonths = locale.shortMonths; - - var periodRe = formatRe(locale_periods), - periodLookup = formatLookup(locale_periods), - weekdayRe = formatRe(locale_weekdays), - weekdayLookup = formatLookup(locale_weekdays), - shortWeekdayRe = formatRe(locale_shortWeekdays), - shortWeekdayLookup = formatLookup(locale_shortWeekdays), - monthRe = formatRe(locale_months), - monthLookup = formatLookup(locale_months), - shortMonthRe = formatRe(locale_shortMonths), - shortMonthLookup = formatLookup(locale_shortMonths); - - var formats = { - "a": formatShortWeekday, - "A": formatWeekday, - "b": formatShortMonth, - "B": formatMonth, - "c": null, - "d": formatDayOfMonth, - "e": formatDayOfMonth, - "f": formatMicroseconds, - "H": formatHour24, - "I": formatHour12, - "j": formatDayOfYear, - "L": formatMilliseconds, - "m": formatMonthNumber, - "M": formatMinutes, - "p": formatPeriod, - "q": formatQuarter, - "Q": formatUnixTimestamp, - "s": formatUnixTimestampSeconds, - "S": formatSeconds, - "u": formatWeekdayNumberMonday, - "U": formatWeekNumberSunday, - "V": formatWeekNumberISO, - "w": formatWeekdayNumberSunday, - "W": formatWeekNumberMonday, - "x": null, - "X": null, - "y": formatYear, - "Y": formatFullYear, - "Z": formatZone, - "%": formatLiteralPercent - }; - - var utcFormats = { - "a": formatUTCShortWeekday, - "A": formatUTCWeekday, - "b": formatUTCShortMonth, - "B": formatUTCMonth, - "c": null, - "d": formatUTCDayOfMonth, - "e": formatUTCDayOfMonth, - "f": formatUTCMicroseconds, - "H": formatUTCHour24, - "I": formatUTCHour12, - "j": formatUTCDayOfYear, - "L": formatUTCMilliseconds, - "m": formatUTCMonthNumber, - "M": formatUTCMinutes, - "p": formatUTCPeriod, - "q": formatUTCQuarter, - "Q": formatUnixTimestamp, - "s": formatUnixTimestampSeconds, - "S": formatUTCSeconds, - "u": formatUTCWeekdayNumberMonday, - "U": formatUTCWeekNumberSunday, - "V": formatUTCWeekNumberISO, - "w": formatUTCWeekdayNumberSunday, - "W": formatUTCWeekNumberMonday, - "x": null, - "X": null, - "y": formatUTCYear, - "Y": formatUTCFullYear, - "Z": formatUTCZone, - "%": formatLiteralPercent - }; - - var parses = { - "a": parseShortWeekday, - "A": parseWeekday, - "b": parseShortMonth, - "B": parseMonth, - "c": parseLocaleDateTime, - "d": parseDayOfMonth, - "e": parseDayOfMonth, - "f": parseMicroseconds, - "H": parseHour24, - "I": parseHour24, - "j": parseDayOfYear, - "L": parseMilliseconds, - "m": parseMonthNumber, - "M": parseMinutes, - "p": parsePeriod, - "q": parseQuarter, - "Q": parseUnixTimestamp, - "s": parseUnixTimestampSeconds, - "S": parseSeconds, - "u": parseWeekdayNumberMonday, - "U": parseWeekNumberSunday, - "V": parseWeekNumberISO, - "w": parseWeekdayNumberSunday, - "W": parseWeekNumberMonday, - "x": parseLocaleDate, - "X": parseLocaleTime, - "y": parseYear, - "Y": parseFullYear, - "Z": parseZone, - "%": parseLiteralPercent - }; - - // These recursive directive definitions must be deferred. - formats.x = newFormat(locale_date, formats); - formats.X = newFormat(locale_time, formats); - formats.c = newFormat(locale_dateTime, formats); - utcFormats.x = newFormat(locale_date, utcFormats); - utcFormats.X = newFormat(locale_time, utcFormats); - utcFormats.c = newFormat(locale_dateTime, utcFormats); - - function newFormat(specifier, formats) { - return function(date) { - var string = [], - i = -1, - j = 0, - n = specifier.length, - c, - pad, - format; - - if (!(date instanceof Date)) date = new Date(+date); - - while (++i < n) { - if (specifier.charCodeAt(i) === 37) { - string.push(specifier.slice(j, i)); - if ((pad = pads[c = specifier.charAt(++i)]) != null) c = specifier.charAt(++i); - else pad = c === "e" ? " " : "0"; - if (format = formats[c]) c = format(date, pad); - string.push(c); - j = i + 1; - } - } - - string.push(specifier.slice(j, i)); - return string.join(""); - }; - } - - function newParse(specifier, Z) { - return function(string) { - var d = newDate(1900, undefined, 1), - i = parseSpecifier(d, specifier, string += "", 0), - week, day; - if (i != string.length) return null; - - // If a UNIX timestamp is specified, return it. - if ("Q" in d) return new Date(d.Q); - if ("s" in d) return new Date(d.s * 1000 + ("L" in d ? d.L : 0)); - - // If this is utcParse, never use the local timezone. - if (Z && !("Z" in d)) d.Z = 0; - - // The am-pm flag is 0 for AM, and 1 for PM. - if ("p" in d) d.H = d.H % 12 + d.p * 12; - - // If the month was not specified, inherit from the quarter. - if (d.m === undefined) d.m = "q" in d ? d.q : 0; - - // Convert day-of-week and week-of-year to day-of-year. - if ("V" in d) { - if (d.V < 1 || d.V > 53) return null; - if (!("w" in d)) d.w = 1; - if ("Z" in d) { - week = utcDate(newDate(d.y, 0, 1)), day = week.getUTCDay(); - week = day > 4 || day === 0 ? d3Time.utcMonday.ceil(week) : d3Time.utcMonday(week); - week = d3Time.utcDay.offset(week, (d.V - 1) * 7); - d.y = week.getUTCFullYear(); - d.m = week.getUTCMonth(); - d.d = week.getUTCDate() + (d.w + 6) % 7; - } else { - week = localDate(newDate(d.y, 0, 1)), day = week.getDay(); - week = day > 4 || day === 0 ? d3Time.timeMonday.ceil(week) : d3Time.timeMonday(week); - week = d3Time.timeDay.offset(week, (d.V - 1) * 7); - d.y = week.getFullYear(); - d.m = week.getMonth(); - d.d = week.getDate() + (d.w + 6) % 7; - } - } else if ("W" in d || "U" in d) { - if (!("w" in d)) d.w = "u" in d ? d.u % 7 : "W" in d ? 1 : 0; - day = "Z" in d ? utcDate(newDate(d.y, 0, 1)).getUTCDay() : localDate(newDate(d.y, 0, 1)).getDay(); - d.m = 0; - d.d = "W" in d ? (d.w + 6) % 7 + d.W * 7 - (day + 5) % 7 : d.w + d.U * 7 - (day + 6) % 7; - } - - // If a time zone is specified, all fields are interpreted as UTC and then - // offset according to the specified time zone. - if ("Z" in d) { - d.H += d.Z / 100 | 0; - d.M += d.Z % 100; - return utcDate(d); - } - - // Otherwise, all fields are in local time. - return localDate(d); - }; - } - - function parseSpecifier(d, specifier, string, j) { - var i = 0, - n = specifier.length, - m = string.length, - c, - parse; - - while (i < n) { - if (j >= m) return -1; - c = specifier.charCodeAt(i++); - if (c === 37) { - c = specifier.charAt(i++); - parse = parses[c in pads ? specifier.charAt(i++) : c]; - if (!parse || ((j = parse(d, string, j)) < 0)) return -1; - } else if (c != string.charCodeAt(j++)) { - return -1; - } - } - - return j; - } - - function parsePeriod(d, string, i) { - var n = periodRe.exec(string.slice(i)); - return n ? (d.p = periodLookup[n[0].toLowerCase()], i + n[0].length) : -1; - } - - function parseShortWeekday(d, string, i) { - var n = shortWeekdayRe.exec(string.slice(i)); - return n ? (d.w = shortWeekdayLookup[n[0].toLowerCase()], i + n[0].length) : -1; - } - - function parseWeekday(d, string, i) { - var n = weekdayRe.exec(string.slice(i)); - return n ? (d.w = weekdayLookup[n[0].toLowerCase()], i + n[0].length) : -1; - } - - function parseShortMonth(d, string, i) { - var n = shortMonthRe.exec(string.slice(i)); - return n ? (d.m = shortMonthLookup[n[0].toLowerCase()], i + n[0].length) : -1; - } - - function parseMonth(d, string, i) { - var n = monthRe.exec(string.slice(i)); - return n ? (d.m = monthLookup[n[0].toLowerCase()], i + n[0].length) : -1; - } - - function parseLocaleDateTime(d, string, i) { - return parseSpecifier(d, locale_dateTime, string, i); - } - - function parseLocaleDate(d, string, i) { - return parseSpecifier(d, locale_date, string, i); - } - - function parseLocaleTime(d, string, i) { - return parseSpecifier(d, locale_time, string, i); - } - - function formatShortWeekday(d) { - return locale_shortWeekdays[d.getDay()]; - } - - function formatWeekday(d) { - return locale_weekdays[d.getDay()]; - } - - function formatShortMonth(d) { - return locale_shortMonths[d.getMonth()]; - } - - function formatMonth(d) { - return locale_months[d.getMonth()]; - } - - function formatPeriod(d) { - return locale_periods[+(d.getHours() >= 12)]; - } - - function formatQuarter(d) { - return 1 + ~~(d.getMonth() / 3); - } - - function formatUTCShortWeekday(d) { - return locale_shortWeekdays[d.getUTCDay()]; - } - - function formatUTCWeekday(d) { - return locale_weekdays[d.getUTCDay()]; - } - - function formatUTCShortMonth(d) { - return locale_shortMonths[d.getUTCMonth()]; - } - - function formatUTCMonth(d) { - return locale_months[d.getUTCMonth()]; - } - - function formatUTCPeriod(d) { - return locale_periods[+(d.getUTCHours() >= 12)]; - } - - function formatUTCQuarter(d) { - return 1 + ~~(d.getUTCMonth() / 3); - } - - return { - format: function(specifier) { - var f = newFormat(specifier += "", formats); - f.toString = function() { return specifier; }; - return f; - }, - parse: function(specifier) { - var p = newParse(specifier += "", false); - p.toString = function() { return specifier; }; - return p; - }, - utcFormat: function(specifier) { - var f = newFormat(specifier += "", utcFormats); - f.toString = function() { return specifier; }; - return f; - }, - utcParse: function(specifier) { - var p = newParse(specifier += "", true); - p.toString = function() { return specifier; }; - return p; - } - }; -} - -var pads = {"-": "", "_": " ", "0": "0"}, - numberRe = /^\s*\d+/, // note: ignores next directive - percentRe = /^%/, - requoteRe = /[\\^$*+?|[\]().{}]/g; - -function pad(value, fill, width) { - var sign = value < 0 ? "-" : "", - string = (sign ? -value : value) + "", - length = string.length; - return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string); -} - -function requote(s) { - return s.replace(requoteRe, "\\$&"); -} - -function formatRe(names) { - return new RegExp("^(?:" + names.map(requote).join("|") + ")", "i"); -} - -function formatLookup(names) { - var map = {}, i = -1, n = names.length; - while (++i < n) map[names[i].toLowerCase()] = i; - return map; -} - -function parseWeekdayNumberSunday(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 1)); - return n ? (d.w = +n[0], i + n[0].length) : -1; -} - -function parseWeekdayNumberMonday(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 1)); - return n ? (d.u = +n[0], i + n[0].length) : -1; -} - -function parseWeekNumberSunday(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.U = +n[0], i + n[0].length) : -1; -} - -function parseWeekNumberISO(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.V = +n[0], i + n[0].length) : -1; -} - -function parseWeekNumberMonday(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.W = +n[0], i + n[0].length) : -1; -} - -function parseFullYear(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 4)); - return n ? (d.y = +n[0], i + n[0].length) : -1; -} - -function parseYear(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.y = +n[0] + (+n[0] > 68 ? 1900 : 2000), i + n[0].length) : -1; -} - -function parseZone(d, string, i) { - var n = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(string.slice(i, i + 6)); - return n ? (d.Z = n[1] ? 0 : -(n[2] + (n[3] || "00")), i + n[0].length) : -1; -} - -function parseQuarter(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 1)); - return n ? (d.q = n[0] * 3 - 3, i + n[0].length) : -1; -} - -function parseMonthNumber(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.m = n[0] - 1, i + n[0].length) : -1; -} - -function parseDayOfMonth(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.d = +n[0], i + n[0].length) : -1; -} - -function parseDayOfYear(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 3)); - return n ? (d.m = 0, d.d = +n[0], i + n[0].length) : -1; -} - -function parseHour24(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.H = +n[0], i + n[0].length) : -1; -} - -function parseMinutes(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.M = +n[0], i + n[0].length) : -1; -} - -function parseSeconds(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.S = +n[0], i + n[0].length) : -1; -} - -function parseMilliseconds(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 3)); - return n ? (d.L = +n[0], i + n[0].length) : -1; -} - -function parseMicroseconds(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 6)); - return n ? (d.L = Math.floor(n[0] / 1000), i + n[0].length) : -1; -} - -function parseLiteralPercent(d, string, i) { - var n = percentRe.exec(string.slice(i, i + 1)); - return n ? i + n[0].length : -1; -} - -function parseUnixTimestamp(d, string, i) { - var n = numberRe.exec(string.slice(i)); - return n ? (d.Q = +n[0], i + n[0].length) : -1; -} - -function parseUnixTimestampSeconds(d, string, i) { - var n = numberRe.exec(string.slice(i)); - return n ? (d.s = +n[0], i + n[0].length) : -1; -} - -function formatDayOfMonth(d, p) { - return pad(d.getDate(), p, 2); -} - -function formatHour24(d, p) { - return pad(d.getHours(), p, 2); -} - -function formatHour12(d, p) { - return pad(d.getHours() % 12 || 12, p, 2); -} - -function formatDayOfYear(d, p) { - return pad(1 + d3Time.timeDay.count(d3Time.timeYear(d), d), p, 3); -} - -function formatMilliseconds(d, p) { - return pad(d.getMilliseconds(), p, 3); -} - -function formatMicroseconds(d, p) { - return formatMilliseconds(d, p) + "000"; -} - -function formatMonthNumber(d, p) { - return pad(d.getMonth() + 1, p, 2); -} - -function formatMinutes(d, p) { - return pad(d.getMinutes(), p, 2); -} - -function formatSeconds(d, p) { - return pad(d.getSeconds(), p, 2); -} - -function formatWeekdayNumberMonday(d) { - var day = d.getDay(); - return day === 0 ? 7 : day; -} - -function formatWeekNumberSunday(d, p) { - return pad(d3Time.timeSunday.count(d3Time.timeYear(d) - 1, d), p, 2); -} - -function formatWeekNumberISO(d, p) { - var day = d.getDay(); - d = (day >= 4 || day === 0) ? d3Time.timeThursday(d) : d3Time.timeThursday.ceil(d); - return pad(d3Time.timeThursday.count(d3Time.timeYear(d), d) + (d3Time.timeYear(d).getDay() === 4), p, 2); -} - -function formatWeekdayNumberSunday(d) { - return d.getDay(); -} - -function formatWeekNumberMonday(d, p) { - return pad(d3Time.timeMonday.count(d3Time.timeYear(d) - 1, d), p, 2); -} - -function formatYear(d, p) { - return pad(d.getFullYear() % 100, p, 2); -} - -function formatFullYear(d, p) { - return pad(d.getFullYear() % 10000, p, 4); -} - -function formatZone(d) { - var z = d.getTimezoneOffset(); - return (z > 0 ? "-" : (z *= -1, "+")) - + pad(z / 60 | 0, "0", 2) - + pad(z % 60, "0", 2); -} - -function formatUTCDayOfMonth(d, p) { - return pad(d.getUTCDate(), p, 2); -} - -function formatUTCHour24(d, p) { - return pad(d.getUTCHours(), p, 2); -} - -function formatUTCHour12(d, p) { - return pad(d.getUTCHours() % 12 || 12, p, 2); -} - -function formatUTCDayOfYear(d, p) { - return pad(1 + d3Time.utcDay.count(d3Time.utcYear(d), d), p, 3); -} - -function formatUTCMilliseconds(d, p) { - return pad(d.getUTCMilliseconds(), p, 3); -} - -function formatUTCMicroseconds(d, p) { - return formatUTCMilliseconds(d, p) + "000"; -} - -function formatUTCMonthNumber(d, p) { - return pad(d.getUTCMonth() + 1, p, 2); -} - -function formatUTCMinutes(d, p) { - return pad(d.getUTCMinutes(), p, 2); -} - -function formatUTCSeconds(d, p) { - return pad(d.getUTCSeconds(), p, 2); -} - -function formatUTCWeekdayNumberMonday(d) { - var dow = d.getUTCDay(); - return dow === 0 ? 7 : dow; -} - -function formatUTCWeekNumberSunday(d, p) { - return pad(d3Time.utcSunday.count(d3Time.utcYear(d) - 1, d), p, 2); -} - -function formatUTCWeekNumberISO(d, p) { - var day = d.getUTCDay(); - d = (day >= 4 || day === 0) ? d3Time.utcThursday(d) : d3Time.utcThursday.ceil(d); - return pad(d3Time.utcThursday.count(d3Time.utcYear(d), d) + (d3Time.utcYear(d).getUTCDay() === 4), p, 2); -} - -function formatUTCWeekdayNumberSunday(d) { - return d.getUTCDay(); -} - -function formatUTCWeekNumberMonday(d, p) { - return pad(d3Time.utcMonday.count(d3Time.utcYear(d) - 1, d), p, 2); -} - -function formatUTCYear(d, p) { - return pad(d.getUTCFullYear() % 100, p, 2); -} - -function formatUTCFullYear(d, p) { - return pad(d.getUTCFullYear() % 10000, p, 4); -} - -function formatUTCZone() { - return "+0000"; -} - -function formatLiteralPercent() { - return "%"; -} - -function formatUnixTimestamp(d) { - return +d; -} - -function formatUnixTimestampSeconds(d) { - return Math.floor(+d / 1000); -} - -var locale; - -defaultLocale({ - dateTime: "%x, %X", - date: "%-m/%-d/%Y", - time: "%-I:%M:%S %p", - periods: ["AM", "PM"], - days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], - shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], - months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], - shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] -}); - -function defaultLocale(definition) { - locale = formatLocale(definition); - exports.timeFormat = locale.format; - exports.timeParse = locale.parse; - exports.utcFormat = locale.utcFormat; - exports.utcParse = locale.utcParse; - return locale; -} - -var isoSpecifier = "%Y-%m-%dT%H:%M:%S.%LZ"; - -function formatIsoNative(date) { - return date.toISOString(); -} - -var formatIso = Date.prototype.toISOString - ? formatIsoNative - : exports.utcFormat(isoSpecifier); - -function parseIsoNative(string) { - var date = new Date(string); - return isNaN(date) ? null : date; -} - -var parseIso = +new Date("2000-01-01T00:00:00.000Z") - ? parseIsoNative - : exports.utcParse(isoSpecifier); - -exports.isoFormat = formatIso; -exports.isoParse = parseIso; -exports.timeFormatDefaultLocale = defaultLocale; -exports.timeFormatLocale = formatLocale; - -Object.defineProperty(exports, '__esModule', { value: true }); - -})); - -},{"d3-time":20}],20:[function(_dereq_,module,exports){ -// https://d3js.org/d3-time/ v1.1.0 Copyright 2019 Mike Bostock -(function (global, factory) { -typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : -typeof define === 'function' && define.amd ? define(['exports'], factory) : -(global = global || self, factory(global.d3 = global.d3 || {})); -}(this, function (exports) { 'use strict'; - -var t0 = new Date, - t1 = new Date; - -function newInterval(floori, offseti, count, field) { - - function interval(date) { - return floori(date = arguments.length === 0 ? new Date : new Date(+date)), date; - } - - interval.floor = function(date) { - return floori(date = new Date(+date)), date; - }; - - interval.ceil = function(date) { - return floori(date = new Date(date - 1)), offseti(date, 1), floori(date), date; - }; - - interval.round = function(date) { - var d0 = interval(date), - d1 = interval.ceil(date); - return date - d0 < d1 - date ? d0 : d1; - }; - - interval.offset = function(date, step) { - return offseti(date = new Date(+date), step == null ? 1 : Math.floor(step)), date; - }; - - interval.range = function(start, stop, step) { - var range = [], previous; - start = interval.ceil(start); - step = step == null ? 1 : Math.floor(step); - if (!(start < stop) || !(step > 0)) return range; // also handles Invalid Date - do range.push(previous = new Date(+start)), offseti(start, step), floori(start); - while (previous < start && start < stop); - return range; - }; - - interval.filter = function(test) { - return newInterval(function(date) { - if (date >= date) while (floori(date), !test(date)) date.setTime(date - 1); - }, function(date, step) { - if (date >= date) { - if (step < 0) while (++step <= 0) { - while (offseti(date, -1), !test(date)) {} // eslint-disable-line no-empty - } else while (--step >= 0) { - while (offseti(date, +1), !test(date)) {} // eslint-disable-line no-empty - } - } - }); - }; - - if (count) { - interval.count = function(start, end) { - t0.setTime(+start), t1.setTime(+end); - floori(t0), floori(t1); - return Math.floor(count(t0, t1)); - }; - - interval.every = function(step) { - step = Math.floor(step); - return !isFinite(step) || !(step > 0) ? null - : !(step > 1) ? interval - : interval.filter(field - ? function(d) { return field(d) % step === 0; } - : function(d) { return interval.count(0, d) % step === 0; }); - }; - } - - return interval; -} - -var millisecond = newInterval(function() { - // noop -}, function(date, step) { - date.setTime(+date + step); -}, function(start, end) { - return end - start; -}); - -// An optimized implementation for this simple case. -millisecond.every = function(k) { - k = Math.floor(k); - if (!isFinite(k) || !(k > 0)) return null; - if (!(k > 1)) return millisecond; - return newInterval(function(date) { - date.setTime(Math.floor(date / k) * k); - }, function(date, step) { - date.setTime(+date + step * k); - }, function(start, end) { - return (end - start) / k; - }); -}; -var milliseconds = millisecond.range; - -var durationSecond = 1e3; -var durationMinute = 6e4; -var durationHour = 36e5; -var durationDay = 864e5; -var durationWeek = 6048e5; - -var second = newInterval(function(date) { - date.setTime(date - date.getMilliseconds()); -}, function(date, step) { - date.setTime(+date + step * durationSecond); -}, function(start, end) { - return (end - start) / durationSecond; -}, function(date) { - return date.getUTCSeconds(); -}); -var seconds = second.range; - -var minute = newInterval(function(date) { - date.setTime(date - date.getMilliseconds() - date.getSeconds() * durationSecond); -}, function(date, step) { - date.setTime(+date + step * durationMinute); -}, function(start, end) { - return (end - start) / durationMinute; -}, function(date) { - return date.getMinutes(); -}); -var minutes = minute.range; - -var hour = newInterval(function(date) { - date.setTime(date - date.getMilliseconds() - date.getSeconds() * durationSecond - date.getMinutes() * durationMinute); -}, function(date, step) { - date.setTime(+date + step * durationHour); -}, function(start, end) { - return (end - start) / durationHour; -}, function(date) { - return date.getHours(); -}); -var hours = hour.range; - -var day = newInterval(function(date) { - date.setHours(0, 0, 0, 0); -}, function(date, step) { - date.setDate(date.getDate() + step); -}, function(start, end) { - return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationDay; -}, function(date) { - return date.getDate() - 1; -}); -var days = day.range; - -function weekday(i) { - return newInterval(function(date) { - date.setDate(date.getDate() - (date.getDay() + 7 - i) % 7); - date.setHours(0, 0, 0, 0); - }, function(date, step) { - date.setDate(date.getDate() + step * 7); - }, function(start, end) { - return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationWeek; - }); -} - -var sunday = weekday(0); -var monday = weekday(1); -var tuesday = weekday(2); -var wednesday = weekday(3); -var thursday = weekday(4); -var friday = weekday(5); -var saturday = weekday(6); - -var sundays = sunday.range; -var mondays = monday.range; -var tuesdays = tuesday.range; -var wednesdays = wednesday.range; -var thursdays = thursday.range; -var fridays = friday.range; -var saturdays = saturday.range; - -var month = newInterval(function(date) { - date.setDate(1); - date.setHours(0, 0, 0, 0); -}, function(date, step) { - date.setMonth(date.getMonth() + step); -}, function(start, end) { - return end.getMonth() - start.getMonth() + (end.getFullYear() - start.getFullYear()) * 12; -}, function(date) { - return date.getMonth(); -}); -var months = month.range; - -var year = newInterval(function(date) { - date.setMonth(0, 1); - date.setHours(0, 0, 0, 0); -}, function(date, step) { - date.setFullYear(date.getFullYear() + step); -}, function(start, end) { - return end.getFullYear() - start.getFullYear(); -}, function(date) { - return date.getFullYear(); -}); - -// An optimized implementation for this simple case. -year.every = function(k) { - return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : newInterval(function(date) { - date.setFullYear(Math.floor(date.getFullYear() / k) * k); - date.setMonth(0, 1); - date.setHours(0, 0, 0, 0); - }, function(date, step) { - date.setFullYear(date.getFullYear() + step * k); - }); -}; -var years = year.range; - -var utcMinute = newInterval(function(date) { - date.setUTCSeconds(0, 0); -}, function(date, step) { - date.setTime(+date + step * durationMinute); -}, function(start, end) { - return (end - start) / durationMinute; -}, function(date) { - return date.getUTCMinutes(); -}); -var utcMinutes = utcMinute.range; - -var utcHour = newInterval(function(date) { - date.setUTCMinutes(0, 0, 0); -}, function(date, step) { - date.setTime(+date + step * durationHour); -}, function(start, end) { - return (end - start) / durationHour; -}, function(date) { - return date.getUTCHours(); -}); -var utcHours = utcHour.range; - -var utcDay = newInterval(function(date) { - date.setUTCHours(0, 0, 0, 0); -}, function(date, step) { - date.setUTCDate(date.getUTCDate() + step); -}, function(start, end) { - return (end - start) / durationDay; -}, function(date) { - return date.getUTCDate() - 1; -}); -var utcDays = utcDay.range; - -function utcWeekday(i) { - return newInterval(function(date) { - date.setUTCDate(date.getUTCDate() - (date.getUTCDay() + 7 - i) % 7); - date.setUTCHours(0, 0, 0, 0); - }, function(date, step) { - date.setUTCDate(date.getUTCDate() + step * 7); - }, function(start, end) { - return (end - start) / durationWeek; - }); -} - -var utcSunday = utcWeekday(0); -var utcMonday = utcWeekday(1); -var utcTuesday = utcWeekday(2); -var utcWednesday = utcWeekday(3); -var utcThursday = utcWeekday(4); -var utcFriday = utcWeekday(5); -var utcSaturday = utcWeekday(6); - -var utcSundays = utcSunday.range; -var utcMondays = utcMonday.range; -var utcTuesdays = utcTuesday.range; -var utcWednesdays = utcWednesday.range; -var utcThursdays = utcThursday.range; -var utcFridays = utcFriday.range; -var utcSaturdays = utcSaturday.range; - -var utcMonth = newInterval(function(date) { - date.setUTCDate(1); - date.setUTCHours(0, 0, 0, 0); -}, function(date, step) { - date.setUTCMonth(date.getUTCMonth() + step); -}, function(start, end) { - return end.getUTCMonth() - start.getUTCMonth() + (end.getUTCFullYear() - start.getUTCFullYear()) * 12; -}, function(date) { - return date.getUTCMonth(); -}); -var utcMonths = utcMonth.range; - -var utcYear = newInterval(function(date) { - date.setUTCMonth(0, 1); - date.setUTCHours(0, 0, 0, 0); -}, function(date, step) { - date.setUTCFullYear(date.getUTCFullYear() + step); -}, function(start, end) { - return end.getUTCFullYear() - start.getUTCFullYear(); -}, function(date) { - return date.getUTCFullYear(); -}); - -// An optimized implementation for this simple case. -utcYear.every = function(k) { - return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : newInterval(function(date) { - date.setUTCFullYear(Math.floor(date.getUTCFullYear() / k) * k); - date.setUTCMonth(0, 1); - date.setUTCHours(0, 0, 0, 0); - }, function(date, step) { - date.setUTCFullYear(date.getUTCFullYear() + step * k); - }); -}; -var utcYears = utcYear.range; - -exports.timeDay = day; -exports.timeDays = days; -exports.timeFriday = friday; -exports.timeFridays = fridays; -exports.timeHour = hour; -exports.timeHours = hours; -exports.timeInterval = newInterval; -exports.timeMillisecond = millisecond; -exports.timeMilliseconds = milliseconds; -exports.timeMinute = minute; -exports.timeMinutes = minutes; -exports.timeMonday = monday; -exports.timeMondays = mondays; -exports.timeMonth = month; -exports.timeMonths = months; -exports.timeSaturday = saturday; -exports.timeSaturdays = saturdays; -exports.timeSecond = second; -exports.timeSeconds = seconds; -exports.timeSunday = sunday; -exports.timeSundays = sundays; -exports.timeThursday = thursday; -exports.timeThursdays = thursdays; -exports.timeTuesday = tuesday; -exports.timeTuesdays = tuesdays; -exports.timeWednesday = wednesday; -exports.timeWednesdays = wednesdays; -exports.timeWeek = sunday; -exports.timeWeeks = sundays; -exports.timeYear = year; -exports.timeYears = years; -exports.utcDay = utcDay; -exports.utcDays = utcDays; -exports.utcFriday = utcFriday; -exports.utcFridays = utcFridays; -exports.utcHour = utcHour; -exports.utcHours = utcHours; -exports.utcMillisecond = millisecond; -exports.utcMilliseconds = milliseconds; -exports.utcMinute = utcMinute; -exports.utcMinutes = utcMinutes; -exports.utcMonday = utcMonday; -exports.utcMondays = utcMondays; -exports.utcMonth = utcMonth; -exports.utcMonths = utcMonths; -exports.utcSaturday = utcSaturday; -exports.utcSaturdays = utcSaturdays; -exports.utcSecond = second; -exports.utcSeconds = seconds; -exports.utcSunday = utcSunday; -exports.utcSundays = utcSundays; -exports.utcThursday = utcThursday; -exports.utcThursdays = utcThursdays; -exports.utcTuesday = utcTuesday; -exports.utcTuesdays = utcTuesdays; -exports.utcWednesday = utcWednesday; -exports.utcWednesdays = utcWednesdays; -exports.utcWeek = utcSunday; -exports.utcWeeks = utcSundays; -exports.utcYear = utcYear; -exports.utcYears = utcYears; - -Object.defineProperty(exports, '__esModule', { value: true }); - -})); - -},{}],21:[function(_dereq_,module,exports){ +},{"../src/traces/violin":536}],20:[function(_dereq_,module,exports){ !function() { var d3 = { - version: "3.5.17" + version: "3.6.0" }; var d3_arraySlice = [].slice, d3_array = function(list) { return d3_arraySlice.call(list); @@ -5796,9 +2228,14 @@ Object.defineProperty(exports, '__esModule', { value: true }); var o; return dsv.parseRows(text, function(row, i) { if (o) return o(row, i - 1); - var a = new Function("d", "return {" + row.map(function(name, i) { - return JSON.stringify(name) + ": d[" + i + "]"; - }).join(",") + "}"); + var a = function(d) { + var obj = {}; + var len = row.length; + for (var k = 0; k < len; ++k) { + obj[row[k]] = d[k]; + } + return obj; + }; o = f ? function(row, i) { return f(a(row), i); } : a; @@ -13310,1186 +9747,4639 @@ Object.defineProperty(exports, '__esModule', { value: true }); return request.responseXML; }); if (typeof define === "function" && define.amd) this.d3 = d3, define(d3); else if (typeof module === "object" && module.exports) module.exports = d3; else this.d3 = d3; -}(); -},{}],22:[function(_dereq_,module,exports){ -(function (process,global){(function (){ +}.apply(self); +},{}],21:[function(_dereq_,module,exports){ +(function (global){(function (){ +'use strict'; + +var objectAssign = _dereq_('object-assign'); + +// compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js +// original notice: + /*! - * @overview es6-promise - a tiny implementation of Promises/A+. - * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) - * @license Licensed under MIT license - * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE - * @version v4.2.8+1e68dce6 + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT */ +function compare(a, b) { + if (a === b) { + return 0; + } -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global.ES6Promise = factory()); -}(this, (function () { 'use strict'; + var x = a.length; + var y = b.length; -function objectOrFunction(x) { - var type = typeof x; - return x !== null && (type === 'object' || type === 'function'); + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i]; + y = b[i]; + break; + } + } + + if (x < y) { + return -1; + } + if (y < x) { + return 1; + } + return 0; +} +function isBuffer(b) { + if (global.Buffer && typeof global.Buffer.isBuffer === 'function') { + return global.Buffer.isBuffer(b); + } + return !!(b != null && b._isBuffer); } -function isFunction(x) { - return typeof x === 'function'; +// based on node assert, original notice: +// NB: The URL to the CommonJS spec is kept just for tradition. +// node-assert has evolved a lot since then, both in API and behavior. + +// http://wiki.commonjs.org/wiki/Unit_Testing/1.0 +// +// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8! +// +// Originally from narwhal.js (http://narwhaljs.org) +// Copyright (c) 2009 Thomas Robinson <280north.com> +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the 'Software'), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +var util = _dereq_('util/'); +var hasOwn = Object.prototype.hasOwnProperty; +var pSlice = Array.prototype.slice; +var functionsHaveNames = (function () { + return function foo() {}.name === 'foo'; +}()); +function pToString (obj) { + return Object.prototype.toString.call(obj); } - - - -var _isArray = void 0; -if (Array.isArray) { - _isArray = Array.isArray; -} else { - _isArray = function (x) { - return Object.prototype.toString.call(x) === '[object Array]'; - }; +function isView(arrbuf) { + if (isBuffer(arrbuf)) { + return false; + } + if (typeof global.ArrayBuffer !== 'function') { + return false; + } + if (typeof ArrayBuffer.isView === 'function') { + return ArrayBuffer.isView(arrbuf); + } + if (!arrbuf) { + return false; + } + if (arrbuf instanceof DataView) { + return true; + } + if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) { + return true; + } + return false; } +// 1. The assert module provides functions that throw +// AssertionError's when particular conditions are not met. The +// assert module must conform to the following interface. -var isArray = _isArray; +var assert = module.exports = ok; -var len = 0; -var vertxNext = void 0; -var customSchedulerFn = void 0; +// 2. The AssertionError is defined in assert. +// new assert.AssertionError({ message: message, +// actual: actual, +// expected: expected }) -var asap = function asap(callback, arg) { - queue[len] = callback; - queue[len + 1] = arg; - len += 2; - if (len === 2) { - // If len is 2, that means that we need to schedule an async flush. - // If additional callbacks are queued before the queue is flushed, they - // will be processed by this flush that we are scheduling. - if (customSchedulerFn) { - customSchedulerFn(flush); - } else { - scheduleFlush(); +var regex = /\s*function\s+([^\(\s]*)\s*/; +// based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js +function getName(func) { + if (!util.isFunction(func)) { + return; + } + if (functionsHaveNames) { + return func.name; + } + var str = func.toString(); + var match = str.match(regex); + return match && match[1]; +} +assert.AssertionError = function AssertionError(options) { + this.name = 'AssertionError'; + this.actual = options.actual; + this.expected = options.expected; + this.operator = options.operator; + if (options.message) { + this.message = options.message; + this.generatedMessage = false; + } else { + this.message = getMessage(this); + this.generatedMessage = true; + } + var stackStartFunction = options.stackStartFunction || fail; + if (Error.captureStackTrace) { + Error.captureStackTrace(this, stackStartFunction); + } else { + // non v8 browsers so we can have a stacktrace + var err = new Error(); + if (err.stack) { + var out = err.stack; + + // try to strip useless frames + var fn_name = getName(stackStartFunction); + var idx = out.indexOf('\n' + fn_name); + if (idx >= 0) { + // once we have located the function frame + // we need to strip out everything before it (and its line) + var next_line = out.indexOf('\n', idx + 1); + out = out.substring(next_line + 1); + } + + this.stack = out; } } }; -function setScheduler(scheduleFn) { - customSchedulerFn = scheduleFn; +// assert.AssertionError instanceof Error +util.inherits(assert.AssertionError, Error); + +function truncate(s, n) { + if (typeof s === 'string') { + return s.length < n ? s : s.slice(0, n); + } else { + return s; + } +} +function inspect(something) { + if (functionsHaveNames || !util.isFunction(something)) { + return util.inspect(something); + } + var rawname = getName(something); + var name = rawname ? ': ' + rawname : ''; + return '[Function' + name + ']'; +} +function getMessage(self) { + return truncate(inspect(self.actual), 128) + ' ' + + self.operator + ' ' + + truncate(inspect(self.expected), 128); } -function setAsap(asapFn) { - asap = asapFn; +// At present only the three keys mentioned above are used and +// understood by the spec. Implementations or sub modules can pass +// other keys to the AssertionError's constructor - they will be +// ignored. + +// 3. All of the following functions must throw an AssertionError +// when a corresponding condition is not met, with a message that +// may be undefined if not provided. All assertion methods provide +// both the actual and expected values to the assertion error for +// display purposes. + +function fail(actual, expected, message, operator, stackStartFunction) { + throw new assert.AssertionError({ + message: message, + actual: actual, + expected: expected, + operator: operator, + stackStartFunction: stackStartFunction + }); } -var browserWindow = typeof window !== 'undefined' ? window : undefined; -var browserGlobal = browserWindow || {}; -var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; -var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'; +// EXTENSION! allows for well behaved errors defined elsewhere. +assert.fail = fail; -// test for web worker but not in IE10 -var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined'; +// 4. Pure assertion tests whether a value is truthy, as determined +// by !!guard. +// assert.ok(guard, message_opt); +// This statement is equivalent to assert.equal(true, !!guard, +// message_opt);. To test strictly for the value true, use +// assert.strictEqual(true, guard, message_opt);. -// node -function useNextTick() { - // node version 0.10.x displays a deprecation warning when nextTick is used recursively - // see https://github.com/cujojs/when/issues/410 for details - return function () { - return process.nextTick(flush); +function ok(value, message) { + if (!value) fail(value, true, message, '==', assert.ok); +} +assert.ok = ok; + +// 5. The equality assertion tests shallow, coercive equality with +// ==. +// assert.equal(actual, expected, message_opt); + +assert.equal = function equal(actual, expected, message) { + if (actual != expected) fail(actual, expected, message, '==', assert.equal); +}; + +// 6. The non-equality assertion tests for whether two objects are not equal +// with != assert.notEqual(actual, expected, message_opt); + +assert.notEqual = function notEqual(actual, expected, message) { + if (actual == expected) { + fail(actual, expected, message, '!=', assert.notEqual); + } +}; + +// 7. The equivalence assertion tests a deep equality relation. +// assert.deepEqual(actual, expected, message_opt); + +assert.deepEqual = function deepEqual(actual, expected, message) { + if (!_deepEqual(actual, expected, false)) { + fail(actual, expected, message, 'deepEqual', assert.deepEqual); + } +}; + +assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) { + if (!_deepEqual(actual, expected, true)) { + fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual); + } +}; + +function _deepEqual(actual, expected, strict, memos) { + // 7.1. All identical values are equivalent, as determined by ===. + if (actual === expected) { + return true; + } else if (isBuffer(actual) && isBuffer(expected)) { + return compare(actual, expected) === 0; + + // 7.2. If the expected value is a Date object, the actual value is + // equivalent if it is also a Date object that refers to the same time. + } else if (util.isDate(actual) && util.isDate(expected)) { + return actual.getTime() === expected.getTime(); + + // 7.3 If the expected value is a RegExp object, the actual value is + // equivalent if it is also a RegExp object with the same source and + // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`). + } else if (util.isRegExp(actual) && util.isRegExp(expected)) { + return actual.source === expected.source && + actual.global === expected.global && + actual.multiline === expected.multiline && + actual.lastIndex === expected.lastIndex && + actual.ignoreCase === expected.ignoreCase; + + // 7.4. Other pairs that do not both pass typeof value == 'object', + // equivalence is determined by ==. + } else if ((actual === null || typeof actual !== 'object') && + (expected === null || typeof expected !== 'object')) { + return strict ? actual === expected : actual == expected; + + // If both values are instances of typed arrays, wrap their underlying + // ArrayBuffers in a Buffer each to increase performance + // This optimization requires the arrays to have the same type as checked by + // Object.prototype.toString (aka pToString). Never perform binary + // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their + // bit patterns are not identical. + } else if (isView(actual) && isView(expected) && + pToString(actual) === pToString(expected) && + !(actual instanceof Float32Array || + actual instanceof Float64Array)) { + return compare(new Uint8Array(actual.buffer), + new Uint8Array(expected.buffer)) === 0; + + // 7.5 For all other Object pairs, including Array objects, equivalence is + // determined by having the same number of owned properties (as verified + // with Object.prototype.hasOwnProperty.call), the same set of keys + // (although not necessarily the same order), equivalent values for every + // corresponding key, and an identical 'prototype' property. Note: this + // accounts for both named and indexed properties on Arrays. + } else if (isBuffer(actual) !== isBuffer(expected)) { + return false; + } else { + memos = memos || {actual: [], expected: []}; + + var actualIndex = memos.actual.indexOf(actual); + if (actualIndex !== -1) { + if (actualIndex === memos.expected.indexOf(expected)) { + return true; + } + } + + memos.actual.push(actual); + memos.expected.push(expected); + + return objEquiv(actual, expected, strict, memos); + } +} + +function isArguments(object) { + return Object.prototype.toString.call(object) == '[object Arguments]'; +} + +function objEquiv(a, b, strict, actualVisitedObjects) { + if (a === null || a === undefined || b === null || b === undefined) + return false; + // if one is a primitive, the other must be same + if (util.isPrimitive(a) || util.isPrimitive(b)) + return a === b; + if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) + return false; + var aIsArgs = isArguments(a); + var bIsArgs = isArguments(b); + if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs)) + return false; + if (aIsArgs) { + a = pSlice.call(a); + b = pSlice.call(b); + return _deepEqual(a, b, strict); + } + var ka = objectKeys(a); + var kb = objectKeys(b); + var key, i; + // having the same number of owned properties (keys incorporates + // hasOwnProperty) + if (ka.length !== kb.length) + return false; + //the same set of keys (although not necessarily the same order), + ka.sort(); + kb.sort(); + //~~~cheap key test + for (i = ka.length - 1; i >= 0; i--) { + if (ka[i] !== kb[i]) + return false; + } + //equivalent values for every corresponding key, and + //~~~possibly expensive deep test + for (i = ka.length - 1; i >= 0; i--) { + key = ka[i]; + if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects)) + return false; + } + return true; +} + +// 8. The non-equivalence assertion tests for any deep inequality. +// assert.notDeepEqual(actual, expected, message_opt); + +assert.notDeepEqual = function notDeepEqual(actual, expected, message) { + if (_deepEqual(actual, expected, false)) { + fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual); + } +}; + +assert.notDeepStrictEqual = notDeepStrictEqual; +function notDeepStrictEqual(actual, expected, message) { + if (_deepEqual(actual, expected, true)) { + fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual); + } +} + + +// 9. The strict equality assertion tests strict equality, as determined by ===. +// assert.strictEqual(actual, expected, message_opt); + +assert.strictEqual = function strictEqual(actual, expected, message) { + if (actual !== expected) { + fail(actual, expected, message, '===', assert.strictEqual); + } +}; + +// 10. The strict non-equality assertion tests for strict inequality, as +// determined by !==. assert.notStrictEqual(actual, expected, message_opt); + +assert.notStrictEqual = function notStrictEqual(actual, expected, message) { + if (actual === expected) { + fail(actual, expected, message, '!==', assert.notStrictEqual); + } +}; + +function expectedException(actual, expected) { + if (!actual || !expected) { + return false; + } + + if (Object.prototype.toString.call(expected) == '[object RegExp]') { + return expected.test(actual); + } + + try { + if (actual instanceof expected) { + return true; + } + } catch (e) { + // Ignore. The instanceof check doesn't work for arrow functions. + } + + if (Error.isPrototypeOf(expected)) { + return false; + } + + return expected.call({}, actual) === true; +} + +function _tryBlock(block) { + var error; + try { + block(); + } catch (e) { + error = e; + } + return error; +} + +function _throws(shouldThrow, block, expected, message) { + var actual; + + if (typeof block !== 'function') { + throw new TypeError('"block" argument must be a function'); + } + + if (typeof expected === 'string') { + message = expected; + expected = null; + } + + actual = _tryBlock(block); + + message = (expected && expected.name ? ' (' + expected.name + ').' : '.') + + (message ? ' ' + message : '.'); + + if (shouldThrow && !actual) { + fail(actual, expected, 'Missing expected exception' + message); + } + + var userProvidedMessage = typeof message === 'string'; + var isUnwantedException = !shouldThrow && util.isError(actual); + var isUnexpectedException = !shouldThrow && actual && !expected; + + if ((isUnwantedException && + userProvidedMessage && + expectedException(actual, expected)) || + isUnexpectedException) { + fail(actual, expected, 'Got unwanted exception' + message); + } + + if ((shouldThrow && actual && expected && + !expectedException(actual, expected)) || (!shouldThrow && actual)) { + throw actual; + } +} + +// 11. Expected to throw an error: +// assert.throws(block, Error_opt, message_opt); + +assert.throws = function(block, /*optional*/error, /*optional*/message) { + _throws(true, block, error, message); +}; + +// EXTENSION! This is annoying to write outside this module. +assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) { + _throws(false, block, error, message); +}; + +assert.ifError = function(err) { if (err) throw err; }; + +// Expose a strict only variant of assert +function strict(value, message) { + if (!value) fail(value, true, message, '==', strict); +} +assert.strict = objectAssign(strict, assert, { + equal: assert.strictEqual, + deepEqual: assert.deepStrictEqual, + notEqual: assert.notStrictEqual, + notDeepEqual: assert.notDeepStrictEqual +}); +assert.strict.strict = assert.strict; + +var objectKeys = Object.keys || function (obj) { + var keys = []; + for (var key in obj) { + if (hasOwn.call(obj, key)) keys.push(key); + } + return keys; +}; + +}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"object-assign":71,"util/":24}],22:[function(_dereq_,module,exports){ +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } } -// vertx -function useVertxTimer() { - if (typeof vertxNext !== 'undefined') { - return function () { - vertxNext(flush); +},{}],23:[function(_dereq_,module,exports){ +module.exports = function isBuffer(arg) { + return arg && typeof arg === 'object' + && typeof arg.copy === 'function' + && typeof arg.fill === 'function' + && typeof arg.readUInt8 === 'function'; +} +},{}],24:[function(_dereq_,module,exports){ +(function (process,global){(function (){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var formatRegExp = /%[sdj%]/g; +exports.format = function(f) { + if (!isString(f)) { + var objects = []; + for (var i = 0; i < arguments.length; i++) { + objects.push(inspect(arguments[i])); + } + return objects.join(' '); + } + + var i = 1; + var args = arguments; + var len = args.length; + var str = String(f).replace(formatRegExp, function(x) { + if (x === '%%') return '%'; + if (i >= len) return x; + switch (x) { + case '%s': return String(args[i++]); + case '%d': return Number(args[i++]); + case '%j': + try { + return JSON.stringify(args[i++]); + } catch (_) { + return '[Circular]'; + } + default: + return x; + } + }); + for (var x = args[i]; i < len; x = args[++i]) { + if (isNull(x) || !isObject(x)) { + str += ' ' + x; + } else { + str += ' ' + inspect(x); + } + } + return str; +}; + + +// Mark that a method should not be used. +// Returns a modified function which warns once by default. +// If --no-deprecation is set, then it is a no-op. +exports.deprecate = function(fn, msg) { + // Allow for deprecating things in the process of starting up. + if (isUndefined(global.process)) { + return function() { + return exports.deprecate(fn, msg).apply(this, arguments); }; } - return useSetTimeout(); -} - -function useMutationObserver() { - var iterations = 0; - var observer = new BrowserMutationObserver(flush); - var node = document.createTextNode(''); - observer.observe(node, { characterData: true }); - - return function () { - node.data = iterations = ++iterations % 2; - }; -} - -// web worker -function useMessageChannel() { - var channel = new MessageChannel(); - channel.port1.onmessage = flush; - return function () { - return channel.port2.postMessage(0); - }; -} - -function useSetTimeout() { - // Store setTimeout reference so es6-promise will be unaffected by - // other code modifying setTimeout (like sinon.useFakeTimers()) - var globalSetTimeout = setTimeout; - return function () { - return globalSetTimeout(flush, 1); - }; -} - -var queue = new Array(1000); -function flush() { - for (var i = 0; i < len; i += 2) { - var callback = queue[i]; - var arg = queue[i + 1]; - - callback(arg); - - queue[i] = undefined; - queue[i + 1] = undefined; + if (process.noDeprecation === true) { + return fn; } - len = 0; -} - -function attemptVertx() { - try { - var vertx = Function('return this')().require('vertx'); - vertxNext = vertx.runOnLoop || vertx.runOnContext; - return useVertxTimer(); - } catch (e) { - return useSetTimeout(); - } -} - -var scheduleFlush = void 0; -// Decide what async method to use to triggering processing of queued callbacks: -if (isNode) { - scheduleFlush = useNextTick(); -} else if (BrowserMutationObserver) { - scheduleFlush = useMutationObserver(); -} else if (isWorker) { - scheduleFlush = useMessageChannel(); -} else if (browserWindow === undefined && typeof _dereq_ === 'function') { - scheduleFlush = attemptVertx(); -} else { - scheduleFlush = useSetTimeout(); -} - -function then(onFulfillment, onRejection) { - var parent = this; - - var child = new this.constructor(noop); - - if (child[PROMISE_ID] === undefined) { - makePromise(child); - } - - var _state = parent._state; - - - if (_state) { - var callback = arguments[_state - 1]; - asap(function () { - return invokeCallback(_state, child, callback, parent._result); - }); - } else { - subscribe(parent, child, onFulfillment, onRejection); - } - - return child; -} - -/** - `Promise.resolve` returns a promise that will become resolved with the - passed `value`. It is shorthand for the following: - - ```javascript - let promise = new Promise(function(resolve, reject){ - resolve(1); - }); - - promise.then(function(value){ - // value === 1 - }); - ``` - - Instead of writing the above, your code now simply becomes the following: - - ```javascript - let promise = Promise.resolve(1); - - promise.then(function(value){ - // value === 1 - }); - ``` - - @method resolve - @static - @param {Any} value value that the returned promise will be resolved with - Useful for tooling. - @return {Promise} a promise that will become fulfilled with the given - `value` -*/ -function resolve$1(object) { - /*jshint validthis:true */ - var Constructor = this; - - if (object && typeof object === 'object' && object.constructor === Constructor) { - return object; - } - - var promise = new Constructor(noop); - resolve(promise, object); - return promise; -} - -var PROMISE_ID = Math.random().toString(36).substring(2); - -function noop() {} - -var PENDING = void 0; -var FULFILLED = 1; -var REJECTED = 2; - -function selfFulfillment() { - return new TypeError("You cannot resolve a promise with itself"); -} - -function cannotReturnOwn() { - return new TypeError('A promises callback cannot return that same promise.'); -} - -function tryThen(then$$1, value, fulfillmentHandler, rejectionHandler) { - try { - then$$1.call(value, fulfillmentHandler, rejectionHandler); - } catch (e) { - return e; - } -} - -function handleForeignThenable(promise, thenable, then$$1) { - asap(function (promise) { - var sealed = false; - var error = tryThen(then$$1, thenable, function (value) { - if (sealed) { - return; - } - sealed = true; - if (thenable !== value) { - resolve(promise, value); + var warned = false; + function deprecated() { + if (!warned) { + if (process.throwDeprecation) { + throw new Error(msg); + } else if (process.traceDeprecation) { + console.trace(msg); } else { - fulfill(promise, value); + console.error(msg); } - }, function (reason) { - if (sealed) { - return; - } - sealed = true; - - reject(promise, reason); - }, 'Settle: ' + (promise._label || ' unknown promise')); - - if (!sealed && error) { - sealed = true; - reject(promise, error); + warned = true; } - }, promise); -} - -function handleOwnThenable(promise, thenable) { - if (thenable._state === FULFILLED) { - fulfill(promise, thenable._result); - } else if (thenable._state === REJECTED) { - reject(promise, thenable._result); - } else { - subscribe(thenable, undefined, function (value) { - return resolve(promise, value); - }, function (reason) { - return reject(promise, reason); - }); - } -} - -function handleMaybeThenable(promise, maybeThenable, then$$1) { - if (maybeThenable.constructor === promise.constructor && then$$1 === then && maybeThenable.constructor.resolve === resolve$1) { - handleOwnThenable(promise, maybeThenable); - } else { - if (then$$1 === undefined) { - fulfill(promise, maybeThenable); - } else if (isFunction(then$$1)) { - handleForeignThenable(promise, maybeThenable, then$$1); - } else { - fulfill(promise, maybeThenable); - } - } -} - -function resolve(promise, value) { - if (promise === value) { - reject(promise, selfFulfillment()); - } else if (objectOrFunction(value)) { - var then$$1 = void 0; - try { - then$$1 = value.then; - } catch (error) { - reject(promise, error); - return; - } - handleMaybeThenable(promise, value, then$$1); - } else { - fulfill(promise, value); - } -} - -function publishRejection(promise) { - if (promise._onerror) { - promise._onerror(promise._result); + return fn.apply(this, arguments); } - publish(promise); -} - -function fulfill(promise, value) { - if (promise._state !== PENDING) { - return; - } - - promise._result = value; - promise._state = FULFILLED; - - if (promise._subscribers.length !== 0) { - asap(publish, promise); - } -} - -function reject(promise, reason) { - if (promise._state !== PENDING) { - return; - } - promise._state = REJECTED; - promise._result = reason; - - asap(publishRejection, promise); -} - -function subscribe(parent, child, onFulfillment, onRejection) { - var _subscribers = parent._subscribers; - var length = _subscribers.length; - - - parent._onerror = null; - - _subscribers[length] = child; - _subscribers[length + FULFILLED] = onFulfillment; - _subscribers[length + REJECTED] = onRejection; - - if (length === 0 && parent._state) { - asap(publish, parent); - } -} - -function publish(promise) { - var subscribers = promise._subscribers; - var settled = promise._state; - - if (subscribers.length === 0) { - return; - } - - var child = void 0, - callback = void 0, - detail = promise._result; - - for (var i = 0; i < subscribers.length; i += 3) { - child = subscribers[i]; - callback = subscribers[i + settled]; - - if (child) { - invokeCallback(settled, child, callback, detail); - } else { - callback(detail); - } - } - - promise._subscribers.length = 0; -} - -function invokeCallback(settled, promise, callback, detail) { - var hasCallback = isFunction(callback), - value = void 0, - error = void 0, - succeeded = true; - - if (hasCallback) { - try { - value = callback(detail); - } catch (e) { - succeeded = false; - error = e; - } - - if (promise === value) { - reject(promise, cannotReturnOwn()); - return; - } - } else { - value = detail; - } - - if (promise._state !== PENDING) { - // noop - } else if (hasCallback && succeeded) { - resolve(promise, value); - } else if (succeeded === false) { - reject(promise, error); - } else if (settled === FULFILLED) { - fulfill(promise, value); - } else if (settled === REJECTED) { - reject(promise, value); - } -} - -function initializePromise(promise, resolver) { - try { - resolver(function resolvePromise(value) { - resolve(promise, value); - }, function rejectPromise(reason) { - reject(promise, reason); - }); - } catch (e) { - reject(promise, e); - } -} - -var id = 0; -function nextId() { - return id++; -} - -function makePromise(promise) { - promise[PROMISE_ID] = id++; - promise._state = undefined; - promise._result = undefined; - promise._subscribers = []; -} - -function validationError() { - return new Error('Array Methods must be provided an Array'); -} - -var Enumerator = function () { - function Enumerator(Constructor, input) { - this._instanceConstructor = Constructor; - this.promise = new Constructor(noop); - - if (!this.promise[PROMISE_ID]) { - makePromise(this.promise); - } - - if (isArray(input)) { - this.length = input.length; - this._remaining = input.length; - - this._result = new Array(this.length); - - if (this.length === 0) { - fulfill(this.promise, this._result); - } else { - this.length = this.length || 0; - this._enumerate(input); - if (this._remaining === 0) { - fulfill(this.promise, this._result); - } - } - } else { - reject(this.promise, validationError()); - } - } - - Enumerator.prototype._enumerate = function _enumerate(input) { - for (var i = 0; this._state === PENDING && i < input.length; i++) { - this._eachEntry(input[i], i); - } - }; - - Enumerator.prototype._eachEntry = function _eachEntry(entry, i) { - var c = this._instanceConstructor; - var resolve$$1 = c.resolve; - - - if (resolve$$1 === resolve$1) { - var _then = void 0; - var error = void 0; - var didError = false; - try { - _then = entry.then; - } catch (e) { - didError = true; - error = e; - } - - if (_then === then && entry._state !== PENDING) { - this._settledAt(entry._state, i, entry._result); - } else if (typeof _then !== 'function') { - this._remaining--; - this._result[i] = entry; - } else if (c === Promise$1) { - var promise = new c(noop); - if (didError) { - reject(promise, error); - } else { - handleMaybeThenable(promise, entry, _then); - } - this._willSettleAt(promise, i); - } else { - this._willSettleAt(new c(function (resolve$$1) { - return resolve$$1(entry); - }), i); - } - } else { - this._willSettleAt(resolve$$1(entry), i); - } - }; - - Enumerator.prototype._settledAt = function _settledAt(state, i, value) { - var promise = this.promise; - - - if (promise._state === PENDING) { - this._remaining--; - - if (state === REJECTED) { - reject(promise, value); - } else { - this._result[i] = value; - } - } - - if (this._remaining === 0) { - fulfill(promise, this._result); - } - }; - - Enumerator.prototype._willSettleAt = function _willSettleAt(promise, i) { - var enumerator = this; - - subscribe(promise, undefined, function (value) { - return enumerator._settledAt(FULFILLED, i, value); - }, function (reason) { - return enumerator._settledAt(REJECTED, i, reason); - }); - }; - - return Enumerator; -}(); - -/** - `Promise.all` accepts an array of promises, and returns a new promise which - is fulfilled with an array of fulfillment values for the passed promises, or - rejected with the reason of the first passed promise to be rejected. It casts all - elements of the passed iterable to promises as it runs this algorithm. - - Example: - - ```javascript - let promise1 = resolve(1); - let promise2 = resolve(2); - let promise3 = resolve(3); - let promises = [ promise1, promise2, promise3 ]; - - Promise.all(promises).then(function(array){ - // The array here would be [ 1, 2, 3 ]; - }); - ``` - - If any of the `promises` given to `all` are rejected, the first promise - that is rejected will be given as an argument to the returned promises's - rejection handler. For example: - - Example: - - ```javascript - let promise1 = resolve(1); - let promise2 = reject(new Error("2")); - let promise3 = reject(new Error("3")); - let promises = [ promise1, promise2, promise3 ]; - - Promise.all(promises).then(function(array){ - // Code here never runs because there are rejected promises! - }, function(error) { - // error.message === "2" - }); - ``` - - @method all - @static - @param {Array} entries array of promises - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled when all `promises` have been - fulfilled, or rejected if any of them become rejected. - @static -*/ -function all(entries) { - return new Enumerator(this, entries).promise; -} - -/** - `Promise.race` returns a new promise which is settled in the same way as the - first passed promise to settle. - - Example: - - ```javascript - let promise1 = new Promise(function(resolve, reject){ - setTimeout(function(){ - resolve('promise 1'); - }, 200); - }); - - let promise2 = new Promise(function(resolve, reject){ - setTimeout(function(){ - resolve('promise 2'); - }, 100); - }); - - Promise.race([promise1, promise2]).then(function(result){ - // result === 'promise 2' because it was resolved before promise1 - // was resolved. - }); - ``` - - `Promise.race` is deterministic in that only the state of the first - settled promise matters. For example, even if other promises given to the - `promises` array argument are resolved, but the first settled promise has - become rejected before the other promises became fulfilled, the returned - promise will become rejected: - - ```javascript - let promise1 = new Promise(function(resolve, reject){ - setTimeout(function(){ - resolve('promise 1'); - }, 200); - }); - - let promise2 = new Promise(function(resolve, reject){ - setTimeout(function(){ - reject(new Error('promise 2')); - }, 100); - }); - - Promise.race([promise1, promise2]).then(function(result){ - // Code here never runs - }, function(reason){ - // reason.message === 'promise 2' because promise 2 became rejected before - // promise 1 became fulfilled - }); - ``` - - An example real-world use case is implementing timeouts: - - ```javascript - Promise.race([ajax('foo.json'), timeout(5000)]) - ``` - - @method race - @static - @param {Array} promises array of promises to observe - Useful for tooling. - @return {Promise} a promise which settles in the same way as the first passed - promise to settle. -*/ -function race(entries) { - /*jshint validthis:true */ - var Constructor = this; - - if (!isArray(entries)) { - return new Constructor(function (_, reject) { - return reject(new TypeError('You must pass an array to race.')); - }); - } else { - return new Constructor(function (resolve, reject) { - var length = entries.length; - for (var i = 0; i < length; i++) { - Constructor.resolve(entries[i]).then(resolve, reject); - } - }); - } -} - -/** - `Promise.reject` returns a promise rejected with the passed `reason`. - It is shorthand for the following: - - ```javascript - let promise = new Promise(function(resolve, reject){ - reject(new Error('WHOOPS')); - }); - - promise.then(function(value){ - // Code here doesn't run because the promise is rejected! - }, function(reason){ - // reason.message === 'WHOOPS' - }); - ``` - - Instead of writing the above, your code now simply becomes the following: - - ```javascript - let promise = Promise.reject(new Error('WHOOPS')); - - promise.then(function(value){ - // Code here doesn't run because the promise is rejected! - }, function(reason){ - // reason.message === 'WHOOPS' - }); - ``` - - @method reject - @static - @param {Any} reason value that the returned promise will be rejected with. - Useful for tooling. - @return {Promise} a promise rejected with the given `reason`. -*/ -function reject$1(reason) { - /*jshint validthis:true */ - var Constructor = this; - var promise = new Constructor(noop); - reject(promise, reason); - return promise; -} - -function needsResolver() { - throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); -} - -function needsNew() { - throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); -} - -/** - Promise objects represent the eventual result of an asynchronous operation. The - primary way of interacting with a promise is through its `then` method, which - registers callbacks to receive either a promise's eventual value or the reason - why the promise cannot be fulfilled. - - Terminology - ----------- - - - `promise` is an object or function with a `then` method whose behavior conforms to this specification. - - `thenable` is an object or function that defines a `then` method. - - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). - - `exception` is a value that is thrown using the throw statement. - - `reason` is a value that indicates why a promise was rejected. - - `settled` the final resting state of a promise, fulfilled or rejected. - - A promise can be in one of three states: pending, fulfilled, or rejected. - - Promises that are fulfilled have a fulfillment value and are in the fulfilled - state. Promises that are rejected have a rejection reason and are in the - rejected state. A fulfillment value is never a thenable. - - Promises can also be said to *resolve* a value. If this value is also a - promise, then the original promise's settled state will match the value's - settled state. So a promise that *resolves* a promise that rejects will - itself reject, and a promise that *resolves* a promise that fulfills will - itself fulfill. - - - Basic Usage: - ------------ - - ```js - let promise = new Promise(function(resolve, reject) { - // on success - resolve(value); - - // on failure - reject(reason); - }); - - promise.then(function(value) { - // on fulfillment - }, function(reason) { - // on rejection - }); - ``` - - Advanced Usage: - --------------- - - Promises shine when abstracting away asynchronous interactions such as - `XMLHttpRequest`s. - - ```js - function getJSON(url) { - return new Promise(function(resolve, reject){ - let xhr = new XMLHttpRequest(); - - xhr.open('GET', url); - xhr.onreadystatechange = handler; - xhr.responseType = 'json'; - xhr.setRequestHeader('Accept', 'application/json'); - xhr.send(); - - function handler() { - if (this.readyState === this.DONE) { - if (this.status === 200) { - resolve(this.response); - } else { - reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); - } - } + return deprecated; +}; + + +var debugs = {}; +var debugEnviron; +exports.debuglog = function(set) { + if (isUndefined(debugEnviron)) + debugEnviron = process.env.NODE_DEBUG || ''; + set = set.toUpperCase(); + if (!debugs[set]) { + if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { + var pid = process.pid; + debugs[set] = function() { + var msg = exports.format.apply(exports, arguments); + console.error('%s %d: %s', set, pid, msg); }; - }); - } - - getJSON('/posts.json').then(function(json) { - // on fulfillment - }, function(reason) { - // on rejection - }); - ``` - - Unlike callbacks, promises are great composable primitives. - - ```js - Promise.all([ - getJSON('/posts'), - getJSON('/comments') - ]).then(function(values){ - values[0] // => postsJSON - values[1] // => commentsJSON - - return values; - }); - ``` - - @class Promise - @param {Function} resolver - Useful for tooling. - @constructor -*/ - -var Promise$1 = function () { - function Promise(resolver) { - this[PROMISE_ID] = nextId(); - this._result = this._state = undefined; - this._subscribers = []; - - if (noop !== resolver) { - typeof resolver !== 'function' && needsResolver(); - this instanceof Promise ? initializePromise(this, resolver) : needsNew(); - } - } - - /** - The primary way of interacting with a promise is through its `then` method, - which registers callbacks to receive either a promise's eventual value or the - reason why the promise cannot be fulfilled. - ```js - findUser().then(function(user){ - // user is available - }, function(reason){ - // user is unavailable, and you are given the reason why - }); - ``` - Chaining - -------- - The return value of `then` is itself a promise. This second, 'downstream' - promise is resolved with the return value of the first promise's fulfillment - or rejection handler, or rejected if the handler throws an exception. - ```js - findUser().then(function (user) { - return user.name; - }, function (reason) { - return 'default name'; - }).then(function (userName) { - // If `findUser` fulfilled, `userName` will be the user's name, otherwise it - // will be `'default name'` - }); - findUser().then(function (user) { - throw new Error('Found user, but still unhappy'); - }, function (reason) { - throw new Error('`findUser` rejected and we're unhappy'); - }).then(function (value) { - // never reached - }, function (reason) { - // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. - // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. - }); - ``` - If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. - ```js - findUser().then(function (user) { - throw new PedagogicalException('Upstream error'); - }).then(function (value) { - // never reached - }).then(function (value) { - // never reached - }, function (reason) { - // The `PedgagocialException` is propagated all the way down to here - }); - ``` - Assimilation - ------------ - Sometimes the value you want to propagate to a downstream promise can only be - retrieved asynchronously. This can be achieved by returning a promise in the - fulfillment or rejection handler. The downstream promise will then be pending - until the returned promise is settled. This is called *assimilation*. - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // The user's comments are now available - }); - ``` - If the assimliated promise rejects, then the downstream promise will also reject. - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // If `findCommentsByAuthor` fulfills, we'll have the value here - }, function (reason) { - // If `findCommentsByAuthor` rejects, we'll have the reason here - }); - ``` - Simple Example - -------------- - Synchronous Example - ```javascript - let result; - try { - result = findResult(); - // success - } catch(reason) { - // failure - } - ``` - Errback Example - ```js - findResult(function(result, err){ - if (err) { - // failure } else { - // success + debugs[set] = function() {}; } - }); - ``` - Promise Example; - ```javascript - findResult().then(function(result){ - // success - }, function(reason){ - // failure - }); - ``` - Advanced Example - -------------- - Synchronous Example - ```javascript - let author, books; - try { - author = findAuthor(); - books = findBooksByAuthor(author); - // success - } catch(reason) { - // failure } - ``` - Errback Example - ```js - function foundBooks(books) { - } - function failure(reason) { - } - findAuthor(function(author, err){ - if (err) { - failure(err); - // failure - } else { - try { - findBoooksByAuthor(author, function(books, err) { - if (err) { - failure(err); - } else { - try { - foundBooks(books); - } catch(reason) { - failure(reason); - } - } - }); - } catch(error) { - failure(err); - } - // success - } - }); - ``` - Promise Example; - ```javascript - findAuthor(). - then(findBooksByAuthor). - then(function(books){ - // found books - }).catch(function(reason){ - // something went wrong - }); - ``` - @method then - @param {Function} onFulfilled - @param {Function} onRejected - Useful for tooling. - @return {Promise} - */ - - /** - `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same - as the catch block of a try/catch statement. - ```js - function findAuthor(){ - throw new Error('couldn't find that author'); - } - // synchronous - try { - findAuthor(); - } catch(reason) { - // something went wrong - } - // async with promises - findAuthor().catch(function(reason){ - // something went wrong - }); - ``` - @method catch - @param {Function} onRejection - Useful for tooling. - @return {Promise} - */ + return debugs[set]; +}; - Promise.prototype.catch = function _catch(onRejection) { - return this.then(null, onRejection); +/** + * Echos the value of a value. Trys to print the value out + * in the best way possible given the different types. + * + * @param {Object} obj The object to print out. + * @param {Object} opts Optional options object that alters the output. + */ +/* legacy: obj, showHidden, depth, colors*/ +function inspect(obj, opts) { + // default options + var ctx = { + seen: [], + stylize: stylizeNoColor }; - - /** - `finally` will be invoked regardless of the promise's fate just as native - try/catch/finally behaves - - Synchronous example: - - ```js - findAuthor() { - if (Math.random() > 0.5) { - throw new Error(); - } - return new Author(); - } - - try { - return findAuthor(); // succeed or fail - } catch(error) { - return findOtherAuther(); - } finally { - // always runs - // doesn't affect the return value - } - ``` - - Asynchronous example: - - ```js - findAuthor().catch(function(reason){ - return findOtherAuther(); - }).finally(function(){ - // author was either found, or not - }); - ``` - - @method finally - @param {Function} callback - @return {Promise} - */ + // legacy... + if (arguments.length >= 3) ctx.depth = arguments[2]; + if (arguments.length >= 4) ctx.colors = arguments[3]; + if (isBoolean(opts)) { + // legacy... + ctx.showHidden = opts; + } else if (opts) { + // got an "options" object + exports._extend(ctx, opts); + } + // set default options + if (isUndefined(ctx.showHidden)) ctx.showHidden = false; + if (isUndefined(ctx.depth)) ctx.depth = 2; + if (isUndefined(ctx.colors)) ctx.colors = false; + if (isUndefined(ctx.customInspect)) ctx.customInspect = true; + if (ctx.colors) ctx.stylize = stylizeWithColor; + return formatValue(ctx, obj, ctx.depth); +} +exports.inspect = inspect; - Promise.prototype.finally = function _finally(callback) { - var promise = this; - var constructor = promise.constructor; +// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics +inspect.colors = { + 'bold' : [1, 22], + 'italic' : [3, 23], + 'underline' : [4, 24], + 'inverse' : [7, 27], + 'white' : [37, 39], + 'grey' : [90, 39], + 'black' : [30, 39], + 'blue' : [34, 39], + 'cyan' : [36, 39], + 'green' : [32, 39], + 'magenta' : [35, 39], + 'red' : [31, 39], + 'yellow' : [33, 39] +}; - if (isFunction(callback)) { - return promise.then(function (value) { - return constructor.resolve(callback()).then(function () { - return value; - }); - }, function (reason) { - return constructor.resolve(callback()).then(function () { - throw reason; - }); - }); - } +// Don't use 'blue' not visible on cmd.exe +inspect.styles = { + 'special': 'cyan', + 'number': 'yellow', + 'boolean': 'yellow', + 'undefined': 'grey', + 'null': 'bold', + 'string': 'green', + 'date': 'magenta', + // "name": intentionally not styling + 'regexp': 'red' +}; - return promise.then(callback, callback); - }; - return Promise; -}(); +function stylizeWithColor(str, styleType) { + var style = inspect.styles[styleType]; -Promise$1.prototype.then = then; -Promise$1.all = all; -Promise$1.race = race; -Promise$1.resolve = resolve$1; -Promise$1.reject = reject$1; -Promise$1._setScheduler = setScheduler; -Promise$1._setAsap = setAsap; -Promise$1._asap = asap; - -/*global self*/ -function polyfill() { - var local = void 0; - - if (typeof global !== 'undefined') { - local = global; - } else if (typeof self !== 'undefined') { - local = self; + if (style) { + return '\u001b[' + inspect.colors[style][0] + 'm' + str + + '\u001b[' + inspect.colors[style][1] + 'm'; } else { - try { - local = Function('return this')(); - } catch (e) { - throw new Error('polyfill failed because global object is unavailable in this environment'); - } + return str; } - - var P = local.Promise; - - if (P) { - var promiseToString = null; - try { - promiseToString = Object.prototype.toString.call(P.resolve()); - } catch (e) { - // silently ignored - } - - if (promiseToString === '[object Promise]' && !P.cast) { - return; - } - } - - local.Promise = Promise$1; } -// Strange compat.. -Promise$1.polyfill = polyfill; -Promise$1.Promise = Promise$1; -return Promise$1; - -}))); +function stylizeNoColor(str, styleType) { + return str; +} +function arrayToHash(array) { + var hash = {}; + + array.forEach(function(val, idx) { + hash[val] = true; + }); + + return hash; +} +function formatValue(ctx, value, recurseTimes) { + // Provide a hook for user-specified inspect functions. + // Check that value is an object with an inspect function on it + if (ctx.customInspect && + value && + isFunction(value.inspect) && + // Filter out the util module, it's inspect function is special + value.inspect !== exports.inspect && + // Also filter out any prototype objects using the circular check. + !(value.constructor && value.constructor.prototype === value)) { + var ret = value.inspect(recurseTimes, ctx); + if (!isString(ret)) { + ret = formatValue(ctx, ret, recurseTimes); + } + return ret; + } + + // Primitive types cannot have properties + var primitive = formatPrimitive(ctx, value); + if (primitive) { + return primitive; + } + + // Look up the keys of the object. + var keys = Object.keys(value); + var visibleKeys = arrayToHash(keys); + + if (ctx.showHidden) { + keys = Object.getOwnPropertyNames(value); + } + + // IE doesn't make error fields non-enumerable + // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx + if (isError(value) + && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { + return formatError(value); + } + + // Some type of object without properties can be shortcutted. + if (keys.length === 0) { + if (isFunction(value)) { + var name = value.name ? ': ' + value.name : ''; + return ctx.stylize('[Function' + name + ']', 'special'); + } + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } + if (isDate(value)) { + return ctx.stylize(Date.prototype.toString.call(value), 'date'); + } + if (isError(value)) { + return formatError(value); + } + } + + var base = '', array = false, braces = ['{', '}']; + + // Make Array say that they are Array + if (isArray(value)) { + array = true; + braces = ['[', ']']; + } + + // Make functions say that they are functions + if (isFunction(value)) { + var n = value.name ? ': ' + value.name : ''; + base = ' [Function' + n + ']'; + } + + // Make RegExps say that they are RegExps + if (isRegExp(value)) { + base = ' ' + RegExp.prototype.toString.call(value); + } + + // Make dates with properties first say the date + if (isDate(value)) { + base = ' ' + Date.prototype.toUTCString.call(value); + } + + // Make error with message first say the error + if (isError(value)) { + base = ' ' + formatError(value); + } + + if (keys.length === 0 && (!array || value.length == 0)) { + return braces[0] + base + braces[1]; + } + + if (recurseTimes < 0) { + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } else { + return ctx.stylize('[Object]', 'special'); + } + } + + ctx.seen.push(value); + + var output; + if (array) { + output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); + } else { + output = keys.map(function(key) { + return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); + }); + } + + ctx.seen.pop(); + + return reduceToSingleString(output, base, braces); +} + + +function formatPrimitive(ctx, value) { + if (isUndefined(value)) + return ctx.stylize('undefined', 'undefined'); + if (isString(value)) { + var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') + .replace(/'/g, "\\'") + .replace(/\\"/g, '"') + '\''; + return ctx.stylize(simple, 'string'); + } + if (isNumber(value)) + return ctx.stylize('' + value, 'number'); + if (isBoolean(value)) + return ctx.stylize('' + value, 'boolean'); + // For some reason typeof null is "object", so special case here. + if (isNull(value)) + return ctx.stylize('null', 'null'); +} + + +function formatError(value) { + return '[' + Error.prototype.toString.call(value) + ']'; +} + + +function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { + var output = []; + for (var i = 0, l = value.length; i < l; ++i) { + if (hasOwnProperty(value, String(i))) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + String(i), true)); + } else { + output.push(''); + } + } + keys.forEach(function(key) { + if (!key.match(/^\d+$/)) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + key, true)); + } + }); + return output; +} + + +function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { + var name, str, desc; + desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; + if (desc.get) { + if (desc.set) { + str = ctx.stylize('[Getter/Setter]', 'special'); + } else { + str = ctx.stylize('[Getter]', 'special'); + } + } else { + if (desc.set) { + str = ctx.stylize('[Setter]', 'special'); + } + } + if (!hasOwnProperty(visibleKeys, key)) { + name = '[' + key + ']'; + } + if (!str) { + if (ctx.seen.indexOf(desc.value) < 0) { + if (isNull(recurseTimes)) { + str = formatValue(ctx, desc.value, null); + } else { + str = formatValue(ctx, desc.value, recurseTimes - 1); + } + if (str.indexOf('\n') > -1) { + if (array) { + str = str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n').substr(2); + } else { + str = '\n' + str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n'); + } + } + } else { + str = ctx.stylize('[Circular]', 'special'); + } + } + if (isUndefined(name)) { + if (array && key.match(/^\d+$/)) { + return str; + } + name = JSON.stringify('' + key); + if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { + name = name.substr(1, name.length - 2); + name = ctx.stylize(name, 'name'); + } else { + name = name.replace(/'/g, "\\'") + .replace(/\\"/g, '"') + .replace(/(^"|"$)/g, "'"); + name = ctx.stylize(name, 'string'); + } + } + + return name + ': ' + str; +} + + +function reduceToSingleString(output, base, braces) { + var numLinesEst = 0; + var length = output.reduce(function(prev, cur) { + numLinesEst++; + if (cur.indexOf('\n') >= 0) numLinesEst++; + return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; + }, 0); + + if (length > 60) { + return braces[0] + + (base === '' ? '' : base + '\n ') + + ' ' + + output.join(',\n ') + + ' ' + + braces[1]; + } + + return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; +} + + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. +function isArray(ar) { + return Array.isArray(ar); +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return isObject(d) && objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return isObject(e) && + (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +exports.isBuffer = _dereq_('./support/isBuffer'); + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + + +function pad(n) { + return n < 10 ? '0' + n.toString(10) : n.toString(10); +} + + +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', + 'Oct', 'Nov', 'Dec']; + +// 26 Feb 16:19:34 +function timestamp() { + var d = new Date(); + var time = [pad(d.getHours()), + pad(d.getMinutes()), + pad(d.getSeconds())].join(':'); + return [d.getDate(), months[d.getMonth()], time].join(' '); +} + + +// log is just a thin wrapper to console.log that prepends a timestamp +exports.log = function() { + console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); +}; + + +/** + * Inherit the prototype methods from one constructor into another. + * + * The Function.prototype.inherits from lang.js rewritten as a standalone + * function (not on Function.prototype). NOTE: If this file is to be loaded + * during bootstrapping this function needs to be rewritten using some native + * functions as prototype setup using normal JavaScript does not work as + * expected during bootstrapping (see mirror.js in r114903). + * + * @param {function} ctor Constructor function which needs to inherit the + * prototype. + * @param {function} superCtor Constructor function to inherit prototype from. + */ +exports.inherits = _dereq_('inherits'); + +exports._extend = function(origin, add) { + // Don't do anything if add isn't an object + if (!add || !isObject(add)) return origin; + + var keys = Object.keys(add); + var i = keys.length; + while (i--) { + origin[keys[i]] = add[keys[i]]; + } + return origin; +}; + +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} }).call(this)}).call(this,_dereq_('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":87}],23:[function(_dereq_,module,exports){ +},{"./support/isBuffer":23,"_process":96,"inherits":22}],25:[function(_dereq_,module,exports){ +'use strict' + +exports.byteLength = byteLength +exports.toByteArray = toByteArray +exports.fromByteArray = fromByteArray + +var lookup = [] +var revLookup = [] +var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array + +var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' +for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i] + revLookup[code.charCodeAt(i)] = i +} + +// Support decoding URL-safe base64 strings, as Node.js does. +// See: https://en.wikipedia.org/wiki/Base64#URL_applications +revLookup['-'.charCodeAt(0)] = 62 +revLookup['_'.charCodeAt(0)] = 63 + +function getLens (b64) { + var len = b64.length + + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // Trim off extra bytes after placeholder bytes are found + // See: https://github.com/beatgammit/base64-js/issues/42 + var validLen = b64.indexOf('=') + if (validLen === -1) validLen = len + + var placeHoldersLen = validLen === len + ? 0 + : 4 - (validLen % 4) + + return [validLen, placeHoldersLen] +} + +// base64 is 4/3 + up to two characters of the original data +function byteLength (b64) { + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen +} + +function _byteLength (b64, validLen, placeHoldersLen) { + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen +} + +function toByteArray (b64) { + var tmp + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + + var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) + + var curByte = 0 + + // if there are placeholders, only get up to the last complete 4 chars + var len = placeHoldersLen > 0 + ? validLen - 4 + : validLen + + var i + for (i = 0; i < len; i += 4) { + tmp = + (revLookup[b64.charCodeAt(i)] << 18) | + (revLookup[b64.charCodeAt(i + 1)] << 12) | + (revLookup[b64.charCodeAt(i + 2)] << 6) | + revLookup[b64.charCodeAt(i + 3)] + arr[curByte++] = (tmp >> 16) & 0xFF + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } + + if (placeHoldersLen === 2) { + tmp = + (revLookup[b64.charCodeAt(i)] << 2) | + (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[curByte++] = tmp & 0xFF + } + + if (placeHoldersLen === 1) { + tmp = + (revLookup[b64.charCodeAt(i)] << 10) | + (revLookup[b64.charCodeAt(i + 1)] << 4) | + (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } + + return arr +} + +function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + + lookup[num >> 12 & 0x3F] + + lookup[num >> 6 & 0x3F] + + lookup[num & 0x3F] +} + +function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = + ((uint8[i] << 16) & 0xFF0000) + + ((uint8[i + 1] << 8) & 0xFF00) + + (uint8[i + 2] & 0xFF) + output.push(tripletToBase64(tmp)) + } + return output.join('') +} + +function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk( + uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) + )) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + parts.push( + lookup[tmp >> 2] + + lookup[(tmp << 4) & 0x3F] + + '==' + ) + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + uint8[len - 1] + parts.push( + lookup[tmp >> 10] + + lookup[(tmp >> 4) & 0x3F] + + lookup[(tmp << 2) & 0x3F] + + '=' + ) + } + + return parts.join('') +} + +},{}],26:[function(_dereq_,module,exports){ + +},{}],27:[function(_dereq_,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +'use strict'; + +var R = typeof Reflect === 'object' ? Reflect : null +var ReflectApply = R && typeof R.apply === 'function' + ? R.apply + : function ReflectApply(target, receiver, args) { + return Function.prototype.apply.call(target, receiver, args); + } + +var ReflectOwnKeys +if (R && typeof R.ownKeys === 'function') { + ReflectOwnKeys = R.ownKeys +} else if (Object.getOwnPropertySymbols) { + ReflectOwnKeys = function ReflectOwnKeys(target) { + return Object.getOwnPropertyNames(target) + .concat(Object.getOwnPropertySymbols(target)); + }; +} else { + ReflectOwnKeys = function ReflectOwnKeys(target) { + return Object.getOwnPropertyNames(target); + }; +} + +function ProcessEmitWarning(warning) { + if (console && console.warn) console.warn(warning); +} + +var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) { + return value !== value; +} + +function EventEmitter() { + EventEmitter.init.call(this); +} +module.exports = EventEmitter; +module.exports.once = once; + +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; + +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._eventsCount = 0; +EventEmitter.prototype._maxListeners = undefined; + +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +var defaultMaxListeners = 10; + +function checkListener(listener) { + if (typeof listener !== 'function') { + throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); + } +} + +Object.defineProperty(EventEmitter, 'defaultMaxListeners', { + enumerable: true, + get: function() { + return defaultMaxListeners; + }, + set: function(arg) { + if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) { + throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.'); + } + defaultMaxListeners = arg; + } +}); + +EventEmitter.init = function() { + + if (this._events === undefined || + this._events === Object.getPrototypeOf(this)._events) { + this._events = Object.create(null); + this._eventsCount = 0; + } + + this._maxListeners = this._maxListeners || undefined; +}; + +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { + if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) { + throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.'); + } + this._maxListeners = n; + return this; +}; + +function _getMaxListeners(that) { + if (that._maxListeners === undefined) + return EventEmitter.defaultMaxListeners; + return that._maxListeners; +} + +EventEmitter.prototype.getMaxListeners = function getMaxListeners() { + return _getMaxListeners(this); +}; + +EventEmitter.prototype.emit = function emit(type) { + var args = []; + for (var i = 1; i < arguments.length; i++) args.push(arguments[i]); + var doError = (type === 'error'); + + var events = this._events; + if (events !== undefined) + doError = (doError && events.error === undefined); + else if (!doError) + return false; + + // If there is no 'error' event listener then throw. + if (doError) { + var er; + if (args.length > 0) + er = args[0]; + if (er instanceof Error) { + // Note: The comments on the `throw` lines are intentional, they show + // up in Node's output if this results in an unhandled exception. + throw er; // Unhandled 'error' event + } + // At least give some kind of context to the user + var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : '')); + err.context = er; + throw err; // Unhandled 'error' event + } + + var handler = events[type]; + + if (handler === undefined) + return false; + + if (typeof handler === 'function') { + ReflectApply(handler, this, args); + } else { + var len = handler.length; + var listeners = arrayClone(handler, len); + for (var i = 0; i < len; ++i) + ReflectApply(listeners[i], this, args); + } + + return true; +}; + +function _addListener(target, type, listener, prepend) { + var m; + var events; + var existing; + + checkListener(listener); + + events = target._events; + if (events === undefined) { + events = target._events = Object.create(null); + target._eventsCount = 0; + } else { + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (events.newListener !== undefined) { + target.emit('newListener', type, + listener.listener ? listener.listener : listener); + + // Re-assign `events` because a newListener handler could have caused the + // this._events to be assigned to a new object + events = target._events; + } + existing = events[type]; + } + + if (existing === undefined) { + // Optimize the case of one listener. Don't need the extra array object. + existing = events[type] = listener; + ++target._eventsCount; + } else { + if (typeof existing === 'function') { + // Adding the second element, need to change to array. + existing = events[type] = + prepend ? [listener, existing] : [existing, listener]; + // If we've already got an array, just append. + } else if (prepend) { + existing.unshift(listener); + } else { + existing.push(listener); + } + + // Check for listener leak + m = _getMaxListeners(target); + if (m > 0 && existing.length > m && !existing.warned) { + existing.warned = true; + // No error code for this since it is a Warning + // eslint-disable-next-line no-restricted-syntax + var w = new Error('Possible EventEmitter memory leak detected. ' + + existing.length + ' ' + String(type) + ' listeners ' + + 'added. Use emitter.setMaxListeners() to ' + + 'increase limit'); + w.name = 'MaxListenersExceededWarning'; + w.emitter = target; + w.type = type; + w.count = existing.length; + ProcessEmitWarning(w); + } + } + + return target; +} + +EventEmitter.prototype.addListener = function addListener(type, listener) { + return _addListener(this, type, listener, false); +}; + +EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +EventEmitter.prototype.prependListener = + function prependListener(type, listener) { + return _addListener(this, type, listener, true); + }; + +function onceWrapper() { + if (!this.fired) { + this.target.removeListener(this.type, this.wrapFn); + this.fired = true; + if (arguments.length === 0) + return this.listener.call(this.target); + return this.listener.apply(this.target, arguments); + } +} + +function _onceWrap(target, type, listener) { + var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener }; + var wrapped = onceWrapper.bind(state); + wrapped.listener = listener; + state.wrapFn = wrapped; + return wrapped; +} + +EventEmitter.prototype.once = function once(type, listener) { + checkListener(listener); + this.on(type, _onceWrap(this, type, listener)); + return this; +}; + +EventEmitter.prototype.prependOnceListener = + function prependOnceListener(type, listener) { + checkListener(listener); + this.prependListener(type, _onceWrap(this, type, listener)); + return this; + }; + +// Emits a 'removeListener' event if and only if the listener was removed. +EventEmitter.prototype.removeListener = + function removeListener(type, listener) { + var list, events, position, i, originalListener; + + checkListener(listener); + + events = this._events; + if (events === undefined) + return this; + + list = events[type]; + if (list === undefined) + return this; + + if (list === listener || list.listener === listener) { + if (--this._eventsCount === 0) + this._events = Object.create(null); + else { + delete events[type]; + if (events.removeListener) + this.emit('removeListener', type, list.listener || listener); + } + } else if (typeof list !== 'function') { + position = -1; + + for (i = list.length - 1; i >= 0; i--) { + if (list[i] === listener || list[i].listener === listener) { + originalListener = list[i].listener; + position = i; + break; + } + } + + if (position < 0) + return this; + + if (position === 0) + list.shift(); + else { + spliceOne(list, position); + } + + if (list.length === 1) + events[type] = list[0]; + + if (events.removeListener !== undefined) + this.emit('removeListener', type, originalListener || listener); + } + + return this; + }; + +EventEmitter.prototype.off = EventEmitter.prototype.removeListener; + +EventEmitter.prototype.removeAllListeners = + function removeAllListeners(type) { + var listeners, events, i; + + events = this._events; + if (events === undefined) + return this; + + // not listening for removeListener, no need to emit + if (events.removeListener === undefined) { + if (arguments.length === 0) { + this._events = Object.create(null); + this._eventsCount = 0; + } else if (events[type] !== undefined) { + if (--this._eventsCount === 0) + this._events = Object.create(null); + else + delete events[type]; + } + return this; + } + + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + var keys = Object.keys(events); + var key; + for (i = 0; i < keys.length; ++i) { + key = keys[i]; + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = Object.create(null); + this._eventsCount = 0; + return this; + } + + listeners = events[type]; + + if (typeof listeners === 'function') { + this.removeListener(type, listeners); + } else if (listeners !== undefined) { + // LIFO order + for (i = listeners.length - 1; i >= 0; i--) { + this.removeListener(type, listeners[i]); + } + } + + return this; + }; + +function _listeners(target, type, unwrap) { + var events = target._events; + + if (events === undefined) + return []; + + var evlistener = events[type]; + if (evlistener === undefined) + return []; + + if (typeof evlistener === 'function') + return unwrap ? [evlistener.listener || evlistener] : [evlistener]; + + return unwrap ? + unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length); +} + +EventEmitter.prototype.listeners = function listeners(type) { + return _listeners(this, type, true); +}; + +EventEmitter.prototype.rawListeners = function rawListeners(type) { + return _listeners(this, type, false); +}; + +EventEmitter.listenerCount = function(emitter, type) { + if (typeof emitter.listenerCount === 'function') { + return emitter.listenerCount(type); + } else { + return listenerCount.call(emitter, type); + } +}; + +EventEmitter.prototype.listenerCount = listenerCount; +function listenerCount(type) { + var events = this._events; + + if (events !== undefined) { + var evlistener = events[type]; + + if (typeof evlistener === 'function') { + return 1; + } else if (evlistener !== undefined) { + return evlistener.length; + } + } + + return 0; +} + +EventEmitter.prototype.eventNames = function eventNames() { + return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []; +}; + +function arrayClone(arr, n) { + var copy = new Array(n); + for (var i = 0; i < n; ++i) + copy[i] = arr[i]; + return copy; +} + +function spliceOne(list, index) { + for (; index + 1 < list.length; index++) + list[index] = list[index + 1]; + list.pop(); +} + +function unwrapListeners(arr) { + var ret = new Array(arr.length); + for (var i = 0; i < ret.length; ++i) { + ret[i] = arr[i].listener || arr[i]; + } + return ret; +} + +function once(emitter, name) { + return new Promise(function (resolve, reject) { + function eventListener() { + if (errorListener !== undefined) { + emitter.removeListener('error', errorListener); + } + resolve([].slice.call(arguments)); + }; + var errorListener; + + // Adding an error listener is not optional because + // if an error is thrown on an event emitter we cannot + // guarantee that the actual event we are waiting will + // be fired. The result could be a silent way to create + // memory or file descriptor leaks, which is something + // we should avoid. + if (name !== 'error') { + errorListener = function errorListener(err) { + emitter.removeListener(name, eventListener); + reject(err); + }; + + emitter.once('error', errorListener); + } + + emitter.once(name, eventListener); + }); +} + +},{}],28:[function(_dereq_,module,exports){ +(function (Buffer){(function (){ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +/* eslint-disable no-proto */ + +'use strict' + +var base64 = _dereq_('base64-js') +var ieee754 = _dereq_('ieee754') + +exports.Buffer = Buffer +exports.SlowBuffer = SlowBuffer +exports.INSPECT_MAX_BYTES = 50 + +var K_MAX_LENGTH = 0x7fffffff +exports.kMaxLength = K_MAX_LENGTH + +/** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Print warning and recommend using `buffer` v4.x which has an Object + * implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * We report that the browser does not support typed arrays if the are not subclassable + * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` + * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support + * for __proto__ and has a buggy typed array implementation. + */ +Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() + +if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && + typeof console.error === 'function') { + console.error( + 'This browser lacks typed array (Uint8Array) support which is required by ' + + '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' + ) +} + +function typedArraySupport () { + // Can typed array instances can be augmented? + try { + var arr = new Uint8Array(1) + arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } } + return arr.foo() === 42 + } catch (e) { + return false + } +} + +Object.defineProperty(Buffer.prototype, 'parent', { + enumerable: true, + get: function () { + if (!Buffer.isBuffer(this)) return undefined + return this.buffer + } +}) + +Object.defineProperty(Buffer.prototype, 'offset', { + enumerable: true, + get: function () { + if (!Buffer.isBuffer(this)) return undefined + return this.byteOffset + } +}) + +function createBuffer (length) { + if (length > K_MAX_LENGTH) { + throw new RangeError('The value "' + length + '" is invalid for option "size"') + } + // Return an augmented `Uint8Array` instance + var buf = new Uint8Array(length) + buf.__proto__ = Buffer.prototype + return buf +} + +/** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ + +function Buffer (arg, encodingOrOffset, length) { + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new TypeError( + 'The "string" argument must be of type string. Received type number' + ) + } + return allocUnsafe(arg) + } + return from(arg, encodingOrOffset, length) +} + +// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 +if (typeof Symbol !== 'undefined' && Symbol.species != null && + Buffer[Symbol.species] === Buffer) { + Object.defineProperty(Buffer, Symbol.species, { + value: null, + configurable: true, + enumerable: false, + writable: false + }) +} + +Buffer.poolSize = 8192 // not used by this implementation + +function from (value, encodingOrOffset, length) { + if (typeof value === 'string') { + return fromString(value, encodingOrOffset) + } + + if (ArrayBuffer.isView(value)) { + return fromArrayLike(value) + } + + if (value == null) { + throw TypeError( + 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + + 'or Array-like Object. Received type ' + (typeof value) + ) + } + + if (isInstance(value, ArrayBuffer) || + (value && isInstance(value.buffer, ArrayBuffer))) { + return fromArrayBuffer(value, encodingOrOffset, length) + } + + if (typeof value === 'number') { + throw new TypeError( + 'The "value" argument must not be of type number. Received type number' + ) + } + + var valueOf = value.valueOf && value.valueOf() + if (valueOf != null && valueOf !== value) { + return Buffer.from(valueOf, encodingOrOffset, length) + } + + var b = fromObject(value) + if (b) return b + + if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && + typeof value[Symbol.toPrimitive] === 'function') { + return Buffer.from( + value[Symbol.toPrimitive]('string'), encodingOrOffset, length + ) + } + + throw new TypeError( + 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + + 'or Array-like Object. Received type ' + (typeof value) + ) +} + +/** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ +Buffer.from = function (value, encodingOrOffset, length) { + return from(value, encodingOrOffset, length) +} + +// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: +// https://github.com/feross/buffer/pull/148 +Buffer.prototype.__proto__ = Uint8Array.prototype +Buffer.__proto__ = Uint8Array + +function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be of type number') + } else if (size < 0) { + throw new RangeError('The value "' + size + '" is invalid for option "size"') + } +} + +function alloc (size, fill, encoding) { + assertSize(size) + if (size <= 0) { + return createBuffer(size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + return typeof encoding === 'string' + ? createBuffer(size).fill(fill, encoding) + : createBuffer(size).fill(fill) + } + return createBuffer(size) +} + +/** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ +Buffer.alloc = function (size, fill, encoding) { + return alloc(size, fill, encoding) +} + +function allocUnsafe (size) { + assertSize(size) + return createBuffer(size < 0 ? 0 : checked(size) | 0) +} + +/** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ +Buffer.allocUnsafe = function (size) { + return allocUnsafe(size) +} +/** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ +Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(size) +} + +function fromString (string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8' + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + + var length = byteLength(string, encoding) | 0 + var buf = createBuffer(length) + + var actual = buf.write(string, encoding) + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + buf = buf.slice(0, actual) + } + + return buf +} + +function fromArrayLike (array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0 + var buf = createBuffer(length) + for (var i = 0; i < length; i += 1) { + buf[i] = array[i] & 255 + } + return buf +} + +function fromArrayBuffer (array, byteOffset, length) { + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('"offset" is outside of buffer bounds') + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('"length" is outside of buffer bounds') + } + + var buf + if (byteOffset === undefined && length === undefined) { + buf = new Uint8Array(array) + } else if (length === undefined) { + buf = new Uint8Array(array, byteOffset) + } else { + buf = new Uint8Array(array, byteOffset, length) + } + + // Return an augmented `Uint8Array` instance + buf.__proto__ = Buffer.prototype + return buf +} + +function fromObject (obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0 + var buf = createBuffer(len) + + if (buf.length === 0) { + return buf + } + + obj.copy(buf, 0, 0, len) + return buf + } + + if (obj.length !== undefined) { + if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { + return createBuffer(0) + } + return fromArrayLike(obj) + } + + if (obj.type === 'Buffer' && Array.isArray(obj.data)) { + return fromArrayLike(obj.data) + } +} + +function checked (length) { + // Note: cannot use `length < K_MAX_LENGTH` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= K_MAX_LENGTH) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') + } + return length | 0 +} + +function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0 + } + return Buffer.alloc(+length) +} + +Buffer.isBuffer = function isBuffer (b) { + return b != null && b._isBuffer === true && + b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false +} + +Buffer.compare = function compare (a, b) { + if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength) + if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength) + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError( + 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array' + ) + } + + if (a === b) return 0 + + var x = a.length + var y = b.length + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i] + y = b[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } +} + +Buffer.concat = function concat (list, length) { + if (!Array.isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + + if (list.length === 0) { + return Buffer.alloc(0) + } + + var i + if (length === undefined) { + length = 0 + for (i = 0; i < list.length; ++i) { + length += list[i].length + } + } + + var buffer = Buffer.allocUnsafe(length) + var pos = 0 + for (i = 0; i < list.length; ++i) { + var buf = list[i] + if (isInstance(buf, Uint8Array)) { + buf = Buffer.from(buf) + } + if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + buf.copy(buffer, pos) + pos += buf.length + } + return buffer +} + +function byteLength (string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length + } + if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { + return string.byteLength + } + if (typeof string !== 'string') { + throw new TypeError( + 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + + 'Received type ' + typeof string + ) + } + + var len = string.length + var mustMatch = (arguments.length > 2 && arguments[2] === true) + if (!mustMatch && len === 0) return 0 + + // Use a for loop to avoid recursion + var loweredCase = false + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len + case 'utf8': + case 'utf-8': + return utf8ToBytes(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) { + return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8 + } + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} +Buffer.byteLength = byteLength + +function slowToString (encoding, start, end) { + var loweredCase = false + + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0 + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } + + if (end === undefined || end > this.length) { + end = this.length + } + + if (end <= 0) { + return '' + } + + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0 + start >>>= 0 + + if (end <= start) { + return '' + } + + if (!encoding) encoding = 'utf8' + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) + + case 'ascii': + return asciiSlice(this, start, end) + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true + } + } +} + +// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) +// to detect a Buffer instance. It's not possible to use `instanceof Buffer` +// reliably in a browserify context because there could be multiple different +// copies of the 'buffer' package in use. This method works even for Buffer +// instances that were created from another copy of the `buffer` package. +// See: https://github.com/feross/buffer/issues/154 +Buffer.prototype._isBuffer = true + +function swap (b, n, m) { + var i = b[n] + b[n] = b[m] + b[m] = i +} + +Buffer.prototype.swap16 = function swap16 () { + var len = this.length + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1) + } + return this +} + +Buffer.prototype.swap32 = function swap32 () { + var len = this.length + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3) + swap(this, i + 1, i + 2) + } + return this +} + +Buffer.prototype.swap64 = function swap64 () { + var len = this.length + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7) + swap(this, i + 1, i + 6) + swap(this, i + 2, i + 5) + swap(this, i + 3, i + 4) + } + return this +} + +Buffer.prototype.toString = function toString () { + var length = this.length + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) +} + +Buffer.prototype.toLocaleString = Buffer.prototype.toString + +Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 +} + +Buffer.prototype.inspect = function inspect () { + var str = '' + var max = exports.INSPECT_MAX_BYTES + str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim() + if (this.length > max) str += ' ... ' + return '' +} + +Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (isInstance(target, Uint8Array)) { + target = Buffer.from(target, target.offset, target.byteLength) + } + if (!Buffer.isBuffer(target)) { + throw new TypeError( + 'The "target" argument must be one of type Buffer or Uint8Array. ' + + 'Received type ' + (typeof target) + ) + } + + if (start === undefined) { + start = 0 + } + if (end === undefined) { + end = target ? target.length : 0 + } + if (thisStart === undefined) { + thisStart = 0 + } + if (thisEnd === undefined) { + thisEnd = this.length + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } + + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } + + start >>>= 0 + end >>>= 0 + thisStart >>>= 0 + thisEnd >>>= 0 + + if (this === target) return 0 + + var x = thisEnd - thisStart + var y = end - start + var len = Math.min(x, y) + + var thisCopy = this.slice(thisStart, thisEnd) + var targetCopy = target.slice(start, end) + + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i] + y = targetCopy[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, +// OR the last index of `val` in `buffer` at offset <= `byteOffset`. +// +// Arguments: +// - buffer - a Buffer to search +// - val - a string, Buffer, or number +// - byteOffset - an index into `buffer`; will be clamped to an int32 +// - encoding - an optional encoding, relevant is val is a string +// - dir - true for indexOf, false for lastIndexOf +function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset + byteOffset = 0 + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000 + } + byteOffset = +byteOffset // Coerce to Number. + if (numberIsNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1) + } + + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1 + } else if (byteOffset < 0) { + if (dir) byteOffset = 0 + else return -1 + } + + // Normalize val + if (typeof val === 'string') { + val = Buffer.from(val, encoding) + } + + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF // Search for a byte value [0-255] + if (typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } + } + return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) + } + + throw new TypeError('val must be string, number or Buffer') +} + +function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + var indexSize = 1 + var arrLength = arr.length + var valLength = val.length + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase() + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2 + arrLength /= 2 + valLength /= 2 + byteOffset /= 2 + } + } + + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } + + var i + if (dir) { + var foundIndex = -1 + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex + foundIndex = -1 + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength + for (i = byteOffset; i >= 0; i--) { + var found = true + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false + break + } + } + if (found) return i + } + } + + return -1 +} + +Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 +} + +Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) +} + +Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) +} + +function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + var remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } + } + + var strLen = string.length + + if (length > strLen / 2) { + length = strLen / 2 + } + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (numberIsNaN(parsed)) return i + buf[offset + i] = parsed + } + return i +} + +function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) +} + +function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) +} + +function latin1Write (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) +} + +function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) +} + +function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) +} + +Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8' + length = this.length + offset = 0 + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset + length = this.length + offset = 0 + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset >>> 0 + if (isFinite(length)) { + length = length >>> 0 + if (encoding === undefined) encoding = 'utf8' + } else { + encoding = length + length = undefined + } + } else { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) + } + + var remaining = this.length - offset + if (length === undefined || length > remaining) length = remaining + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds') + } + + if (!encoding) encoding = 'utf8' + + var loweredCase = false + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + return asciiWrite(this, string, offset, length) + + case 'latin1': + case 'binary': + return latin1Write(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} + +Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } +} + +function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) + } +} + +function utf8Slice (buf, start, end) { + end = Math.min(buf.length, end) + var res = [] + + var i = start + while (i < end) { + var firstByte = buf[i] + var codePoint = null + var bytesPerSequence = (firstByte > 0xEF) ? 4 + : (firstByte > 0xDF) ? 3 + : (firstByte > 0xBF) ? 2 + : 1 + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte + } + break + case 2: + secondByte = buf[i + 1] + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint + } + } + break + case 3: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint + } + } + break + case 4: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + fourthByte = buf[i + 3] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint + } + } + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD + bytesPerSequence = 1 + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000 + res.push(codePoint >>> 10 & 0x3FF | 0xD800) + codePoint = 0xDC00 | codePoint & 0x3FF + } + + res.push(codePoint) + i += bytesPerSequence + } + + return decodeCodePointsArray(res) +} + +// Based on http://stackoverflow.com/a/22747272/680742, the browser with +// the lowest limit is Chrome, with 0x10000 args. +// We go 1 magnitude less, for safety +var MAX_ARGUMENTS_LENGTH = 0x1000 + +function decodeCodePointsArray (codePoints) { + var len = codePoints.length + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + } + + // Decode in chunks to avoid "call stack size exceeded". + var res = '' + var i = 0 + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ) + } + return res +} + +function asciiSlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F) + } + return ret +} + +function latin1Slice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]) + } + return ret +} + +function hexSlice (buf, start, end) { + var len = buf.length + + if (!start || start < 0) start = 0 + if (!end || end < 0 || end > len) end = len + + var out = '' + for (var i = start; i < end; ++i) { + out += toHex(buf[i]) + } + return out +} + +function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end) + var res = '' + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) + } + return res +} + +Buffer.prototype.slice = function slice (start, end) { + var len = this.length + start = ~~start + end = end === undefined ? len : ~~end + + if (start < 0) { + start += len + if (start < 0) start = 0 + } else if (start > len) { + start = len + } + + if (end < 0) { + end += len + if (end < 0) end = 0 + } else if (end > len) { + end = len + } + + if (end < start) end = start + + var newBuf = this.subarray(start, end) + // Return an augmented `Uint8Array` instance + newBuf.__proto__ = Buffer.prototype + return newBuf +} + +/* + * Need to make sure that buffer isn't trying to write out of bounds. + */ +function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') +} + +Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + + return val +} + +Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + checkOffset(offset, byteLength, this.length) + } + + var val = this[offset + --byteLength] + var mul = 1 + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul + } + + return val +} + +Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + return this[offset] +} + +Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return this[offset] | (this[offset + 1] << 8) +} + +Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return (this[offset] << 8) | this[offset + 1] +} + +Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) +} + +Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) +} + +Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var i = byteLength + var mul = 1 + var val = this[offset + --i] + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) +} + +Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset] | (this[offset + 1] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset + 1] | (this[offset] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) +} + +Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) +} + +Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, true, 23, 4) +} + +Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, false, 23, 4) +} + +Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, true, 52, 8) +} + +Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, false, 52, 8) +} + +function checkInt (buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') +} + +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var mul = 1 + var i = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) + this[offset] = (value & 0xff) + return offset + 1 +} + +Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 +} + +Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 +} + +Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = (value & 0xff) + return offset + 4 +} + +Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 +} + +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + var limit = Math.pow(2, (8 * byteLength) - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = 0 + var mul = 1 + var sub = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + var limit = Math.pow(2, (8 * byteLength) - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = byteLength - 1 + var mul = 1 + var sub = 0 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) + if (value < 0) value = 0xff + value + 1 + this[offset] = (value & 0xff) + return offset + 1 +} + +Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 +} + +Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 +} + +Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) + return offset + 4 +} + +Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (value < 0) value = 0xffffffff + value + 1 + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 +} + +function checkIEEE754 (buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') +} + +function writeFloat (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } + ieee754.write(buf, value, offset, littleEndian, 23, 4) + return offset + 4 +} + +Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) +} + +function writeDouble (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } + ieee754.write(buf, value, offset, littleEndian, 52, 8) + return offset + 8 +} + +Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) +} + +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer.prototype.copy = function copy (target, targetStart, start, end) { + if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (targetStart >= target.length) targetStart = target.length + if (!targetStart) targetStart = 0 + if (end > 0 && end < start) end = start + + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 + + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('Index out of range') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start + } + + var len = end - start + + if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { + // Use built-in when available, missing from IE11 + this.copyWithin(targetStart, start, end) + } else if (this === target && start < targetStart && targetStart < end) { + // descending copy from end + for (var i = len - 1; i >= 0; --i) { + target[i + targetStart] = this[i + start] + } + } else { + Uint8Array.prototype.set.call( + target, + this.subarray(start, end), + targetStart + ) + } + + return len +} + +// Usage: +// buffer.fill(number[, offset[, end]]) +// buffer.fill(buffer[, offset[, end]]) +// buffer.fill(string[, offset[, end]][, encoding]) +Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start + start = 0 + end = this.length + } else if (typeof end === 'string') { + encoding = end + end = this.length + } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') + } + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + if (val.length === 1) { + var code = val.charCodeAt(0) + if ((encoding === 'utf8' && code < 128) || + encoding === 'latin1') { + // Fast path: If `val` fits into a single byte, use that numeric value. + val = code + } + } + } else if (typeof val === 'number') { + val = val & 255 + } + + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } + + if (end <= start) { + return this + } + + start = start >>> 0 + end = end === undefined ? this.length : end >>> 0 + + if (!val) val = 0 + + var i + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val + } + } else { + var bytes = Buffer.isBuffer(val) + ? val + : Buffer.from(val, encoding) + var len = bytes.length + if (len === 0) { + throw new TypeError('The value "' + val + + '" is invalid for argument "value"') + } + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len] + } + } + + return this +} + +// HELPER FUNCTIONS +// ================ + +var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g + +function base64clean (str) { + // Node takes equal signs as end of the Base64 encoding + str = str.split('=')[0] + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = str.trim().replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '=' + } + return str +} + +function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) +} + +function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] + + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } + + // valid lead + leadSurrogate = codePoint + + continue + } + + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } + + // valid surrogate pair + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + } + + leadSurrogate = null + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') + } + } + + return bytes +} + +function asciiToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) + } + return byteArray +} + +function utf16leToBytes (str, units) { + var c, hi, lo + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break + + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) + } + + return byteArray +} + +function base64ToBytes (str) { + return base64.toByteArray(base64clean(str)) +} + +function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i] + } + return i +} + +// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass +// the `instanceof` check but they should be treated as of that type. +// See: https://github.com/feross/buffer/issues/166 +function isInstance (obj, type) { + return obj instanceof type || + (obj != null && obj.constructor != null && obj.constructor.name != null && + obj.constructor.name === type.name) +} +function numberIsNaN (obj) { + // For IE11 support + return obj !== obj // eslint-disable-line no-self-compare +} + +}).call(this)}).call(this,_dereq_("buffer").Buffer) +},{"base64-js":25,"buffer":28,"ieee754":64}],29:[function(_dereq_,module,exports){ +// https://d3js.org/d3-time-format/ v2.2.3 Copyright 2019 Mike Bostock +(function (global, factory) { +typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, _dereq_('d3-time')) : +typeof define === 'function' && define.amd ? define(['exports', 'd3-time'], factory) : +(global = global || self, factory(global.d3 = global.d3 || {}, global.d3)); +}(this, function (exports, d3Time) { 'use strict'; + +function localDate(d) { + if (0 <= d.y && d.y < 100) { + var date = new Date(-1, d.m, d.d, d.H, d.M, d.S, d.L); + date.setFullYear(d.y); + return date; + } + return new Date(d.y, d.m, d.d, d.H, d.M, d.S, d.L); +} + +function utcDate(d) { + if (0 <= d.y && d.y < 100) { + var date = new Date(Date.UTC(-1, d.m, d.d, d.H, d.M, d.S, d.L)); + date.setUTCFullYear(d.y); + return date; + } + return new Date(Date.UTC(d.y, d.m, d.d, d.H, d.M, d.S, d.L)); +} + +function newDate(y, m, d) { + return {y: y, m: m, d: d, H: 0, M: 0, S: 0, L: 0}; +} + +function formatLocale(locale) { + var locale_dateTime = locale.dateTime, + locale_date = locale.date, + locale_time = locale.time, + locale_periods = locale.periods, + locale_weekdays = locale.days, + locale_shortWeekdays = locale.shortDays, + locale_months = locale.months, + locale_shortMonths = locale.shortMonths; + + var periodRe = formatRe(locale_periods), + periodLookup = formatLookup(locale_periods), + weekdayRe = formatRe(locale_weekdays), + weekdayLookup = formatLookup(locale_weekdays), + shortWeekdayRe = formatRe(locale_shortWeekdays), + shortWeekdayLookup = formatLookup(locale_shortWeekdays), + monthRe = formatRe(locale_months), + monthLookup = formatLookup(locale_months), + shortMonthRe = formatRe(locale_shortMonths), + shortMonthLookup = formatLookup(locale_shortMonths); + + var formats = { + "a": formatShortWeekday, + "A": formatWeekday, + "b": formatShortMonth, + "B": formatMonth, + "c": null, + "d": formatDayOfMonth, + "e": formatDayOfMonth, + "f": formatMicroseconds, + "H": formatHour24, + "I": formatHour12, + "j": formatDayOfYear, + "L": formatMilliseconds, + "m": formatMonthNumber, + "M": formatMinutes, + "p": formatPeriod, + "q": formatQuarter, + "Q": formatUnixTimestamp, + "s": formatUnixTimestampSeconds, + "S": formatSeconds, + "u": formatWeekdayNumberMonday, + "U": formatWeekNumberSunday, + "V": formatWeekNumberISO, + "w": formatWeekdayNumberSunday, + "W": formatWeekNumberMonday, + "x": null, + "X": null, + "y": formatYear, + "Y": formatFullYear, + "Z": formatZone, + "%": formatLiteralPercent + }; + + var utcFormats = { + "a": formatUTCShortWeekday, + "A": formatUTCWeekday, + "b": formatUTCShortMonth, + "B": formatUTCMonth, + "c": null, + "d": formatUTCDayOfMonth, + "e": formatUTCDayOfMonth, + "f": formatUTCMicroseconds, + "H": formatUTCHour24, + "I": formatUTCHour12, + "j": formatUTCDayOfYear, + "L": formatUTCMilliseconds, + "m": formatUTCMonthNumber, + "M": formatUTCMinutes, + "p": formatUTCPeriod, + "q": formatUTCQuarter, + "Q": formatUnixTimestamp, + "s": formatUnixTimestampSeconds, + "S": formatUTCSeconds, + "u": formatUTCWeekdayNumberMonday, + "U": formatUTCWeekNumberSunday, + "V": formatUTCWeekNumberISO, + "w": formatUTCWeekdayNumberSunday, + "W": formatUTCWeekNumberMonday, + "x": null, + "X": null, + "y": formatUTCYear, + "Y": formatUTCFullYear, + "Z": formatUTCZone, + "%": formatLiteralPercent + }; + + var parses = { + "a": parseShortWeekday, + "A": parseWeekday, + "b": parseShortMonth, + "B": parseMonth, + "c": parseLocaleDateTime, + "d": parseDayOfMonth, + "e": parseDayOfMonth, + "f": parseMicroseconds, + "H": parseHour24, + "I": parseHour24, + "j": parseDayOfYear, + "L": parseMilliseconds, + "m": parseMonthNumber, + "M": parseMinutes, + "p": parsePeriod, + "q": parseQuarter, + "Q": parseUnixTimestamp, + "s": parseUnixTimestampSeconds, + "S": parseSeconds, + "u": parseWeekdayNumberMonday, + "U": parseWeekNumberSunday, + "V": parseWeekNumberISO, + "w": parseWeekdayNumberSunday, + "W": parseWeekNumberMonday, + "x": parseLocaleDate, + "X": parseLocaleTime, + "y": parseYear, + "Y": parseFullYear, + "Z": parseZone, + "%": parseLiteralPercent + }; + + // These recursive directive definitions must be deferred. + formats.x = newFormat(locale_date, formats); + formats.X = newFormat(locale_time, formats); + formats.c = newFormat(locale_dateTime, formats); + utcFormats.x = newFormat(locale_date, utcFormats); + utcFormats.X = newFormat(locale_time, utcFormats); + utcFormats.c = newFormat(locale_dateTime, utcFormats); + + function newFormat(specifier, formats) { + return function(date) { + var string = [], + i = -1, + j = 0, + n = specifier.length, + c, + pad, + format; + + if (!(date instanceof Date)) date = new Date(+date); + + while (++i < n) { + if (specifier.charCodeAt(i) === 37) { + string.push(specifier.slice(j, i)); + if ((pad = pads[c = specifier.charAt(++i)]) != null) c = specifier.charAt(++i); + else pad = c === "e" ? " " : "0"; + if (format = formats[c]) c = format(date, pad); + string.push(c); + j = i + 1; + } + } + + string.push(specifier.slice(j, i)); + return string.join(""); + }; + } + + function newParse(specifier, Z) { + return function(string) { + var d = newDate(1900, undefined, 1), + i = parseSpecifier(d, specifier, string += "", 0), + week, day; + if (i != string.length) return null; + + // If a UNIX timestamp is specified, return it. + if ("Q" in d) return new Date(d.Q); + if ("s" in d) return new Date(d.s * 1000 + ("L" in d ? d.L : 0)); + + // If this is utcParse, never use the local timezone. + if (Z && !("Z" in d)) d.Z = 0; + + // The am-pm flag is 0 for AM, and 1 for PM. + if ("p" in d) d.H = d.H % 12 + d.p * 12; + + // If the month was not specified, inherit from the quarter. + if (d.m === undefined) d.m = "q" in d ? d.q : 0; + + // Convert day-of-week and week-of-year to day-of-year. + if ("V" in d) { + if (d.V < 1 || d.V > 53) return null; + if (!("w" in d)) d.w = 1; + if ("Z" in d) { + week = utcDate(newDate(d.y, 0, 1)), day = week.getUTCDay(); + week = day > 4 || day === 0 ? d3Time.utcMonday.ceil(week) : d3Time.utcMonday(week); + week = d3Time.utcDay.offset(week, (d.V - 1) * 7); + d.y = week.getUTCFullYear(); + d.m = week.getUTCMonth(); + d.d = week.getUTCDate() + (d.w + 6) % 7; + } else { + week = localDate(newDate(d.y, 0, 1)), day = week.getDay(); + week = day > 4 || day === 0 ? d3Time.timeMonday.ceil(week) : d3Time.timeMonday(week); + week = d3Time.timeDay.offset(week, (d.V - 1) * 7); + d.y = week.getFullYear(); + d.m = week.getMonth(); + d.d = week.getDate() + (d.w + 6) % 7; + } + } else if ("W" in d || "U" in d) { + if (!("w" in d)) d.w = "u" in d ? d.u % 7 : "W" in d ? 1 : 0; + day = "Z" in d ? utcDate(newDate(d.y, 0, 1)).getUTCDay() : localDate(newDate(d.y, 0, 1)).getDay(); + d.m = 0; + d.d = "W" in d ? (d.w + 6) % 7 + d.W * 7 - (day + 5) % 7 : d.w + d.U * 7 - (day + 6) % 7; + } + + // If a time zone is specified, all fields are interpreted as UTC and then + // offset according to the specified time zone. + if ("Z" in d) { + d.H += d.Z / 100 | 0; + d.M += d.Z % 100; + return utcDate(d); + } + + // Otherwise, all fields are in local time. + return localDate(d); + }; + } + + function parseSpecifier(d, specifier, string, j) { + var i = 0, + n = specifier.length, + m = string.length, + c, + parse; + + while (i < n) { + if (j >= m) return -1; + c = specifier.charCodeAt(i++); + if (c === 37) { + c = specifier.charAt(i++); + parse = parses[c in pads ? specifier.charAt(i++) : c]; + if (!parse || ((j = parse(d, string, j)) < 0)) return -1; + } else if (c != string.charCodeAt(j++)) { + return -1; + } + } + + return j; + } + + function parsePeriod(d, string, i) { + var n = periodRe.exec(string.slice(i)); + return n ? (d.p = periodLookup[n[0].toLowerCase()], i + n[0].length) : -1; + } + + function parseShortWeekday(d, string, i) { + var n = shortWeekdayRe.exec(string.slice(i)); + return n ? (d.w = shortWeekdayLookup[n[0].toLowerCase()], i + n[0].length) : -1; + } + + function parseWeekday(d, string, i) { + var n = weekdayRe.exec(string.slice(i)); + return n ? (d.w = weekdayLookup[n[0].toLowerCase()], i + n[0].length) : -1; + } + + function parseShortMonth(d, string, i) { + var n = shortMonthRe.exec(string.slice(i)); + return n ? (d.m = shortMonthLookup[n[0].toLowerCase()], i + n[0].length) : -1; + } + + function parseMonth(d, string, i) { + var n = monthRe.exec(string.slice(i)); + return n ? (d.m = monthLookup[n[0].toLowerCase()], i + n[0].length) : -1; + } + + function parseLocaleDateTime(d, string, i) { + return parseSpecifier(d, locale_dateTime, string, i); + } + + function parseLocaleDate(d, string, i) { + return parseSpecifier(d, locale_date, string, i); + } + + function parseLocaleTime(d, string, i) { + return parseSpecifier(d, locale_time, string, i); + } + + function formatShortWeekday(d) { + return locale_shortWeekdays[d.getDay()]; + } + + function formatWeekday(d) { + return locale_weekdays[d.getDay()]; + } + + function formatShortMonth(d) { + return locale_shortMonths[d.getMonth()]; + } + + function formatMonth(d) { + return locale_months[d.getMonth()]; + } + + function formatPeriod(d) { + return locale_periods[+(d.getHours() >= 12)]; + } + + function formatQuarter(d) { + return 1 + ~~(d.getMonth() / 3); + } + + function formatUTCShortWeekday(d) { + return locale_shortWeekdays[d.getUTCDay()]; + } + + function formatUTCWeekday(d) { + return locale_weekdays[d.getUTCDay()]; + } + + function formatUTCShortMonth(d) { + return locale_shortMonths[d.getUTCMonth()]; + } + + function formatUTCMonth(d) { + return locale_months[d.getUTCMonth()]; + } + + function formatUTCPeriod(d) { + return locale_periods[+(d.getUTCHours() >= 12)]; + } + + function formatUTCQuarter(d) { + return 1 + ~~(d.getUTCMonth() / 3); + } + + return { + format: function(specifier) { + var f = newFormat(specifier += "", formats); + f.toString = function() { return specifier; }; + return f; + }, + parse: function(specifier) { + var p = newParse(specifier += "", false); + p.toString = function() { return specifier; }; + return p; + }, + utcFormat: function(specifier) { + var f = newFormat(specifier += "", utcFormats); + f.toString = function() { return specifier; }; + return f; + }, + utcParse: function(specifier) { + var p = newParse(specifier += "", true); + p.toString = function() { return specifier; }; + return p; + } + }; +} + +var pads = {"-": "", "_": " ", "0": "0"}, + numberRe = /^\s*\d+/, // note: ignores next directive + percentRe = /^%/, + requoteRe = /[\\^$*+?|[\]().{}]/g; + +function pad(value, fill, width) { + var sign = value < 0 ? "-" : "", + string = (sign ? -value : value) + "", + length = string.length; + return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string); +} + +function requote(s) { + return s.replace(requoteRe, "\\$&"); +} + +function formatRe(names) { + return new RegExp("^(?:" + names.map(requote).join("|") + ")", "i"); +} + +function formatLookup(names) { + var map = {}, i = -1, n = names.length; + while (++i < n) map[names[i].toLowerCase()] = i; + return map; +} + +function parseWeekdayNumberSunday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 1)); + return n ? (d.w = +n[0], i + n[0].length) : -1; +} + +function parseWeekdayNumberMonday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 1)); + return n ? (d.u = +n[0], i + n[0].length) : -1; +} + +function parseWeekNumberSunday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.U = +n[0], i + n[0].length) : -1; +} + +function parseWeekNumberISO(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.V = +n[0], i + n[0].length) : -1; +} + +function parseWeekNumberMonday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.W = +n[0], i + n[0].length) : -1; +} + +function parseFullYear(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 4)); + return n ? (d.y = +n[0], i + n[0].length) : -1; +} + +function parseYear(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.y = +n[0] + (+n[0] > 68 ? 1900 : 2000), i + n[0].length) : -1; +} + +function parseZone(d, string, i) { + var n = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(string.slice(i, i + 6)); + return n ? (d.Z = n[1] ? 0 : -(n[2] + (n[3] || "00")), i + n[0].length) : -1; +} + +function parseQuarter(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 1)); + return n ? (d.q = n[0] * 3 - 3, i + n[0].length) : -1; +} + +function parseMonthNumber(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.m = n[0] - 1, i + n[0].length) : -1; +} + +function parseDayOfMonth(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.d = +n[0], i + n[0].length) : -1; +} + +function parseDayOfYear(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 3)); + return n ? (d.m = 0, d.d = +n[0], i + n[0].length) : -1; +} + +function parseHour24(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.H = +n[0], i + n[0].length) : -1; +} + +function parseMinutes(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.M = +n[0], i + n[0].length) : -1; +} + +function parseSeconds(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.S = +n[0], i + n[0].length) : -1; +} + +function parseMilliseconds(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 3)); + return n ? (d.L = +n[0], i + n[0].length) : -1; +} + +function parseMicroseconds(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 6)); + return n ? (d.L = Math.floor(n[0] / 1000), i + n[0].length) : -1; +} + +function parseLiteralPercent(d, string, i) { + var n = percentRe.exec(string.slice(i, i + 1)); + return n ? i + n[0].length : -1; +} + +function parseUnixTimestamp(d, string, i) { + var n = numberRe.exec(string.slice(i)); + return n ? (d.Q = +n[0], i + n[0].length) : -1; +} + +function parseUnixTimestampSeconds(d, string, i) { + var n = numberRe.exec(string.slice(i)); + return n ? (d.s = +n[0], i + n[0].length) : -1; +} + +function formatDayOfMonth(d, p) { + return pad(d.getDate(), p, 2); +} + +function formatHour24(d, p) { + return pad(d.getHours(), p, 2); +} + +function formatHour12(d, p) { + return pad(d.getHours() % 12 || 12, p, 2); +} + +function formatDayOfYear(d, p) { + return pad(1 + d3Time.timeDay.count(d3Time.timeYear(d), d), p, 3); +} + +function formatMilliseconds(d, p) { + return pad(d.getMilliseconds(), p, 3); +} + +function formatMicroseconds(d, p) { + return formatMilliseconds(d, p) + "000"; +} + +function formatMonthNumber(d, p) { + return pad(d.getMonth() + 1, p, 2); +} + +function formatMinutes(d, p) { + return pad(d.getMinutes(), p, 2); +} + +function formatSeconds(d, p) { + return pad(d.getSeconds(), p, 2); +} + +function formatWeekdayNumberMonday(d) { + var day = d.getDay(); + return day === 0 ? 7 : day; +} + +function formatWeekNumberSunday(d, p) { + return pad(d3Time.timeSunday.count(d3Time.timeYear(d) - 1, d), p, 2); +} + +function formatWeekNumberISO(d, p) { + var day = d.getDay(); + d = (day >= 4 || day === 0) ? d3Time.timeThursday(d) : d3Time.timeThursday.ceil(d); + return pad(d3Time.timeThursday.count(d3Time.timeYear(d), d) + (d3Time.timeYear(d).getDay() === 4), p, 2); +} + +function formatWeekdayNumberSunday(d) { + return d.getDay(); +} + +function formatWeekNumberMonday(d, p) { + return pad(d3Time.timeMonday.count(d3Time.timeYear(d) - 1, d), p, 2); +} + +function formatYear(d, p) { + return pad(d.getFullYear() % 100, p, 2); +} + +function formatFullYear(d, p) { + return pad(d.getFullYear() % 10000, p, 4); +} + +function formatZone(d) { + var z = d.getTimezoneOffset(); + return (z > 0 ? "-" : (z *= -1, "+")) + + pad(z / 60 | 0, "0", 2) + + pad(z % 60, "0", 2); +} + +function formatUTCDayOfMonth(d, p) { + return pad(d.getUTCDate(), p, 2); +} + +function formatUTCHour24(d, p) { + return pad(d.getUTCHours(), p, 2); +} + +function formatUTCHour12(d, p) { + return pad(d.getUTCHours() % 12 || 12, p, 2); +} + +function formatUTCDayOfYear(d, p) { + return pad(1 + d3Time.utcDay.count(d3Time.utcYear(d), d), p, 3); +} + +function formatUTCMilliseconds(d, p) { + return pad(d.getUTCMilliseconds(), p, 3); +} + +function formatUTCMicroseconds(d, p) { + return formatUTCMilliseconds(d, p) + "000"; +} + +function formatUTCMonthNumber(d, p) { + return pad(d.getUTCMonth() + 1, p, 2); +} + +function formatUTCMinutes(d, p) { + return pad(d.getUTCMinutes(), p, 2); +} + +function formatUTCSeconds(d, p) { + return pad(d.getUTCSeconds(), p, 2); +} + +function formatUTCWeekdayNumberMonday(d) { + var dow = d.getUTCDay(); + return dow === 0 ? 7 : dow; +} + +function formatUTCWeekNumberSunday(d, p) { + return pad(d3Time.utcSunday.count(d3Time.utcYear(d) - 1, d), p, 2); +} + +function formatUTCWeekNumberISO(d, p) { + var day = d.getUTCDay(); + d = (day >= 4 || day === 0) ? d3Time.utcThursday(d) : d3Time.utcThursday.ceil(d); + return pad(d3Time.utcThursday.count(d3Time.utcYear(d), d) + (d3Time.utcYear(d).getUTCDay() === 4), p, 2); +} + +function formatUTCWeekdayNumberSunday(d) { + return d.getUTCDay(); +} + +function formatUTCWeekNumberMonday(d, p) { + return pad(d3Time.utcMonday.count(d3Time.utcYear(d) - 1, d), p, 2); +} + +function formatUTCYear(d, p) { + return pad(d.getUTCFullYear() % 100, p, 2); +} + +function formatUTCFullYear(d, p) { + return pad(d.getUTCFullYear() % 10000, p, 4); +} + +function formatUTCZone() { + return "+0000"; +} + +function formatLiteralPercent() { + return "%"; +} + +function formatUnixTimestamp(d) { + return +d; +} + +function formatUnixTimestampSeconds(d) { + return Math.floor(+d / 1000); +} + +var locale; + +defaultLocale({ + dateTime: "%x, %X", + date: "%-m/%-d/%Y", + time: "%-I:%M:%S %p", + periods: ["AM", "PM"], + days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], + shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], + months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], + shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] +}); + +function defaultLocale(definition) { + locale = formatLocale(definition); + exports.timeFormat = locale.format; + exports.timeParse = locale.parse; + exports.utcFormat = locale.utcFormat; + exports.utcParse = locale.utcParse; + return locale; +} + +var isoSpecifier = "%Y-%m-%dT%H:%M:%S.%LZ"; + +function formatIsoNative(date) { + return date.toISOString(); +} + +var formatIso = Date.prototype.toISOString + ? formatIsoNative + : exports.utcFormat(isoSpecifier); + +function parseIsoNative(string) { + var date = new Date(string); + return isNaN(date) ? null : date; +} + +var parseIso = +new Date("2000-01-01T00:00:00.000Z") + ? parseIsoNative + : exports.utcParse(isoSpecifier); + +exports.isoFormat = formatIso; +exports.isoParse = parseIso; +exports.timeFormatDefaultLocale = defaultLocale; +exports.timeFormatLocale = formatLocale; + +Object.defineProperty(exports, '__esModule', { value: true }); + +})); + +},{"d3-time":30}],30:[function(_dereq_,module,exports){ +// https://d3js.org/d3-time/ v1.1.0 Copyright 2019 Mike Bostock +(function (global, factory) { +typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : +typeof define === 'function' && define.amd ? define(['exports'], factory) : +(global = global || self, factory(global.d3 = global.d3 || {})); +}(this, function (exports) { 'use strict'; + +var t0 = new Date, + t1 = new Date; + +function newInterval(floori, offseti, count, field) { + + function interval(date) { + return floori(date = arguments.length === 0 ? new Date : new Date(+date)), date; + } + + interval.floor = function(date) { + return floori(date = new Date(+date)), date; + }; + + interval.ceil = function(date) { + return floori(date = new Date(date - 1)), offseti(date, 1), floori(date), date; + }; + + interval.round = function(date) { + var d0 = interval(date), + d1 = interval.ceil(date); + return date - d0 < d1 - date ? d0 : d1; + }; + + interval.offset = function(date, step) { + return offseti(date = new Date(+date), step == null ? 1 : Math.floor(step)), date; + }; + + interval.range = function(start, stop, step) { + var range = [], previous; + start = interval.ceil(start); + step = step == null ? 1 : Math.floor(step); + if (!(start < stop) || !(step > 0)) return range; // also handles Invalid Date + do range.push(previous = new Date(+start)), offseti(start, step), floori(start); + while (previous < start && start < stop); + return range; + }; + + interval.filter = function(test) { + return newInterval(function(date) { + if (date >= date) while (floori(date), !test(date)) date.setTime(date - 1); + }, function(date, step) { + if (date >= date) { + if (step < 0) while (++step <= 0) { + while (offseti(date, -1), !test(date)) {} // eslint-disable-line no-empty + } else while (--step >= 0) { + while (offseti(date, +1), !test(date)) {} // eslint-disable-line no-empty + } + } + }); + }; + + if (count) { + interval.count = function(start, end) { + t0.setTime(+start), t1.setTime(+end); + floori(t0), floori(t1); + return Math.floor(count(t0, t1)); + }; + + interval.every = function(step) { + step = Math.floor(step); + return !isFinite(step) || !(step > 0) ? null + : !(step > 1) ? interval + : interval.filter(field + ? function(d) { return field(d) % step === 0; } + : function(d) { return interval.count(0, d) % step === 0; }); + }; + } + + return interval; +} + +var millisecond = newInterval(function() { + // noop +}, function(date, step) { + date.setTime(+date + step); +}, function(start, end) { + return end - start; +}); + +// An optimized implementation for this simple case. +millisecond.every = function(k) { + k = Math.floor(k); + if (!isFinite(k) || !(k > 0)) return null; + if (!(k > 1)) return millisecond; + return newInterval(function(date) { + date.setTime(Math.floor(date / k) * k); + }, function(date, step) { + date.setTime(+date + step * k); + }, function(start, end) { + return (end - start) / k; + }); +}; +var milliseconds = millisecond.range; + +var durationSecond = 1e3; +var durationMinute = 6e4; +var durationHour = 36e5; +var durationDay = 864e5; +var durationWeek = 6048e5; + +var second = newInterval(function(date) { + date.setTime(date - date.getMilliseconds()); +}, function(date, step) { + date.setTime(+date + step * durationSecond); +}, function(start, end) { + return (end - start) / durationSecond; +}, function(date) { + return date.getUTCSeconds(); +}); +var seconds = second.range; + +var minute = newInterval(function(date) { + date.setTime(date - date.getMilliseconds() - date.getSeconds() * durationSecond); +}, function(date, step) { + date.setTime(+date + step * durationMinute); +}, function(start, end) { + return (end - start) / durationMinute; +}, function(date) { + return date.getMinutes(); +}); +var minutes = minute.range; + +var hour = newInterval(function(date) { + date.setTime(date - date.getMilliseconds() - date.getSeconds() * durationSecond - date.getMinutes() * durationMinute); +}, function(date, step) { + date.setTime(+date + step * durationHour); +}, function(start, end) { + return (end - start) / durationHour; +}, function(date) { + return date.getHours(); +}); +var hours = hour.range; + +var day = newInterval(function(date) { + date.setHours(0, 0, 0, 0); +}, function(date, step) { + date.setDate(date.getDate() + step); +}, function(start, end) { + return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationDay; +}, function(date) { + return date.getDate() - 1; +}); +var days = day.range; + +function weekday(i) { + return newInterval(function(date) { + date.setDate(date.getDate() - (date.getDay() + 7 - i) % 7); + date.setHours(0, 0, 0, 0); + }, function(date, step) { + date.setDate(date.getDate() + step * 7); + }, function(start, end) { + return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationWeek; + }); +} + +var sunday = weekday(0); +var monday = weekday(1); +var tuesday = weekday(2); +var wednesday = weekday(3); +var thursday = weekday(4); +var friday = weekday(5); +var saturday = weekday(6); + +var sundays = sunday.range; +var mondays = monday.range; +var tuesdays = tuesday.range; +var wednesdays = wednesday.range; +var thursdays = thursday.range; +var fridays = friday.range; +var saturdays = saturday.range; + +var month = newInterval(function(date) { + date.setDate(1); + date.setHours(0, 0, 0, 0); +}, function(date, step) { + date.setMonth(date.getMonth() + step); +}, function(start, end) { + return end.getMonth() - start.getMonth() + (end.getFullYear() - start.getFullYear()) * 12; +}, function(date) { + return date.getMonth(); +}); +var months = month.range; + +var year = newInterval(function(date) { + date.setMonth(0, 1); + date.setHours(0, 0, 0, 0); +}, function(date, step) { + date.setFullYear(date.getFullYear() + step); +}, function(start, end) { + return end.getFullYear() - start.getFullYear(); +}, function(date) { + return date.getFullYear(); +}); + +// An optimized implementation for this simple case. +year.every = function(k) { + return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : newInterval(function(date) { + date.setFullYear(Math.floor(date.getFullYear() / k) * k); + date.setMonth(0, 1); + date.setHours(0, 0, 0, 0); + }, function(date, step) { + date.setFullYear(date.getFullYear() + step * k); + }); +}; +var years = year.range; + +var utcMinute = newInterval(function(date) { + date.setUTCSeconds(0, 0); +}, function(date, step) { + date.setTime(+date + step * durationMinute); +}, function(start, end) { + return (end - start) / durationMinute; +}, function(date) { + return date.getUTCMinutes(); +}); +var utcMinutes = utcMinute.range; + +var utcHour = newInterval(function(date) { + date.setUTCMinutes(0, 0, 0); +}, function(date, step) { + date.setTime(+date + step * durationHour); +}, function(start, end) { + return (end - start) / durationHour; +}, function(date) { + return date.getUTCHours(); +}); +var utcHours = utcHour.range; + +var utcDay = newInterval(function(date) { + date.setUTCHours(0, 0, 0, 0); +}, function(date, step) { + date.setUTCDate(date.getUTCDate() + step); +}, function(start, end) { + return (end - start) / durationDay; +}, function(date) { + return date.getUTCDate() - 1; +}); +var utcDays = utcDay.range; + +function utcWeekday(i) { + return newInterval(function(date) { + date.setUTCDate(date.getUTCDate() - (date.getUTCDay() + 7 - i) % 7); + date.setUTCHours(0, 0, 0, 0); + }, function(date, step) { + date.setUTCDate(date.getUTCDate() + step * 7); + }, function(start, end) { + return (end - start) / durationWeek; + }); +} + +var utcSunday = utcWeekday(0); +var utcMonday = utcWeekday(1); +var utcTuesday = utcWeekday(2); +var utcWednesday = utcWeekday(3); +var utcThursday = utcWeekday(4); +var utcFriday = utcWeekday(5); +var utcSaturday = utcWeekday(6); + +var utcSundays = utcSunday.range; +var utcMondays = utcMonday.range; +var utcTuesdays = utcTuesday.range; +var utcWednesdays = utcWednesday.range; +var utcThursdays = utcThursday.range; +var utcFridays = utcFriday.range; +var utcSaturdays = utcSaturday.range; + +var utcMonth = newInterval(function(date) { + date.setUTCDate(1); + date.setUTCHours(0, 0, 0, 0); +}, function(date, step) { + date.setUTCMonth(date.getUTCMonth() + step); +}, function(start, end) { + return end.getUTCMonth() - start.getUTCMonth() + (end.getUTCFullYear() - start.getUTCFullYear()) * 12; +}, function(date) { + return date.getUTCMonth(); +}); +var utcMonths = utcMonth.range; + +var utcYear = newInterval(function(date) { + date.setUTCMonth(0, 1); + date.setUTCHours(0, 0, 0, 0); +}, function(date, step) { + date.setUTCFullYear(date.getUTCFullYear() + step); +}, function(start, end) { + return end.getUTCFullYear() - start.getUTCFullYear(); +}, function(date) { + return date.getUTCFullYear(); +}); + +// An optimized implementation for this simple case. +utcYear.every = function(k) { + return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : newInterval(function(date) { + date.setUTCFullYear(Math.floor(date.getUTCFullYear() / k) * k); + date.setUTCMonth(0, 1); + date.setUTCHours(0, 0, 0, 0); + }, function(date, step) { + date.setUTCFullYear(date.getUTCFullYear() + step * k); + }); +}; +var utcYears = utcYear.range; + +exports.timeDay = day; +exports.timeDays = days; +exports.timeFriday = friday; +exports.timeFridays = fridays; +exports.timeHour = hour; +exports.timeHours = hours; +exports.timeInterval = newInterval; +exports.timeMillisecond = millisecond; +exports.timeMilliseconds = milliseconds; +exports.timeMinute = minute; +exports.timeMinutes = minutes; +exports.timeMonday = monday; +exports.timeMondays = mondays; +exports.timeMonth = month; +exports.timeMonths = months; +exports.timeSaturday = saturday; +exports.timeSaturdays = saturdays; +exports.timeSecond = second; +exports.timeSeconds = seconds; +exports.timeSunday = sunday; +exports.timeSundays = sundays; +exports.timeThursday = thursday; +exports.timeThursdays = thursdays; +exports.timeTuesday = tuesday; +exports.timeTuesdays = tuesdays; +exports.timeWednesday = wednesday; +exports.timeWednesdays = wednesdays; +exports.timeWeek = sunday; +exports.timeWeeks = sundays; +exports.timeYear = year; +exports.timeYears = years; +exports.utcDay = utcDay; +exports.utcDays = utcDays; +exports.utcFriday = utcFriday; +exports.utcFridays = utcFridays; +exports.utcHour = utcHour; +exports.utcHours = utcHours; +exports.utcMillisecond = millisecond; +exports.utcMilliseconds = milliseconds; +exports.utcMinute = utcMinute; +exports.utcMinutes = utcMinutes; +exports.utcMonday = utcMonday; +exports.utcMondays = utcMondays; +exports.utcMonth = utcMonth; +exports.utcMonths = utcMonths; +exports.utcSaturday = utcSaturday; +exports.utcSaturdays = utcSaturdays; +exports.utcSecond = second; +exports.utcSeconds = seconds; +exports.utcSunday = utcSunday; +exports.utcSundays = utcSundays; +exports.utcThursday = utcThursday; +exports.utcThursdays = utcThursdays; +exports.utcTuesday = utcTuesday; +exports.utcTuesdays = utcTuesdays; +exports.utcWednesday = utcWednesday; +exports.utcWednesdays = utcWednesdays; +exports.utcWeek = utcSunday; +exports.utcWeeks = utcSundays; +exports.utcYear = utcYear; +exports.utcYears = utcYears; + +Object.defineProperty(exports, '__esModule', { value: true }); + +})); + +},{}],31:[function(_dereq_,module,exports){ /** * inspired by is-number * but significantly simplified and sped up by ignoring number and string constructors @@ -14515,7 +14405,7 @@ module.exports = function(n) { return n - n < 1; }; -},{"is-string-blank":75}],24:[function(_dereq_,module,exports){ +},{"is-string-blank":68}],32:[function(_dereq_,module,exports){ module.exports = adjoint; /** @@ -14549,7 +14439,7 @@ function adjoint(out, a) { out[15] = (a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11)); return out; }; -},{}],25:[function(_dereq_,module,exports){ +},{}],33:[function(_dereq_,module,exports){ module.exports = clone; /** @@ -14578,7 +14468,7 @@ function clone(a) { out[15] = a[15]; return out; }; -},{}],26:[function(_dereq_,module,exports){ +},{}],34:[function(_dereq_,module,exports){ module.exports = copy; /** @@ -14607,7 +14497,7 @@ function copy(out, a) { out[15] = a[15]; return out; }; -},{}],27:[function(_dereq_,module,exports){ +},{}],35:[function(_dereq_,module,exports){ module.exports = create; /** @@ -14635,7 +14525,7 @@ function create() { out[15] = 1; return out; }; -},{}],28:[function(_dereq_,module,exports){ +},{}],36:[function(_dereq_,module,exports){ module.exports = determinant; /** @@ -14666,7 +14556,7 @@ function determinant(a) { // Calculate the determinant return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; }; -},{}],29:[function(_dereq_,module,exports){ +},{}],37:[function(_dereq_,module,exports){ module.exports = fromQuat; /** @@ -14714,7 +14604,7 @@ function fromQuat(out, q) { return out; }; -},{}],30:[function(_dereq_,module,exports){ +},{}],38:[function(_dereq_,module,exports){ module.exports = fromRotation /** @@ -14769,7 +14659,7 @@ function fromRotation(out, rad, axis) { return out } -},{}],31:[function(_dereq_,module,exports){ +},{}],39:[function(_dereq_,module,exports){ module.exports = fromRotationTranslation; /** @@ -14823,7 +14713,7 @@ function fromRotationTranslation(out, q, v) { return out; }; -},{}],32:[function(_dereq_,module,exports){ +},{}],40:[function(_dereq_,module,exports){ module.exports = fromScaling /** @@ -14857,7 +14747,7 @@ function fromScaling(out, v) { return out } -},{}],33:[function(_dereq_,module,exports){ +},{}],41:[function(_dereq_,module,exports){ module.exports = fromTranslation /** @@ -14891,7 +14781,7 @@ function fromTranslation(out, v) { return out } -},{}],34:[function(_dereq_,module,exports){ +},{}],42:[function(_dereq_,module,exports){ module.exports = fromXRotation /** @@ -14928,7 +14818,7 @@ function fromXRotation(out, rad) { out[15] = 1 return out } -},{}],35:[function(_dereq_,module,exports){ +},{}],43:[function(_dereq_,module,exports){ module.exports = fromYRotation /** @@ -14965,7 +14855,7 @@ function fromYRotation(out, rad) { out[15] = 1 return out } -},{}],36:[function(_dereq_,module,exports){ +},{}],44:[function(_dereq_,module,exports){ module.exports = fromZRotation /** @@ -15002,7 +14892,7 @@ function fromZRotation(out, rad) { out[15] = 1 return out } -},{}],37:[function(_dereq_,module,exports){ +},{}],45:[function(_dereq_,module,exports){ module.exports = frustum; /** @@ -15039,7 +14929,7 @@ function frustum(out, left, right, bottom, top, near, far) { out[15] = 0; return out; }; -},{}],38:[function(_dereq_,module,exports){ +},{}],46:[function(_dereq_,module,exports){ module.exports = identity; /** @@ -15067,7 +14957,7 @@ function identity(out) { out[15] = 1; return out; }; -},{}],39:[function(_dereq_,module,exports){ +},{}],47:[function(_dereq_,module,exports){ module.exports = { create: _dereq_('./create') , clone: _dereq_('./clone') @@ -15100,7 +14990,7 @@ module.exports = { , str: _dereq_('./str') } -},{"./adjoint":24,"./clone":25,"./copy":26,"./create":27,"./determinant":28,"./fromQuat":29,"./fromRotation":30,"./fromRotationTranslation":31,"./fromScaling":32,"./fromTranslation":33,"./fromXRotation":34,"./fromYRotation":35,"./fromZRotation":36,"./frustum":37,"./identity":38,"./invert":40,"./lookAt":41,"./multiply":42,"./ortho":43,"./perspective":44,"./perspectiveFromFieldOfView":45,"./rotate":46,"./rotateX":47,"./rotateY":48,"./rotateZ":49,"./scale":50,"./str":51,"./translate":52,"./transpose":53}],40:[function(_dereq_,module,exports){ +},{"./adjoint":32,"./clone":33,"./copy":34,"./create":35,"./determinant":36,"./fromQuat":37,"./fromRotation":38,"./fromRotationTranslation":39,"./fromScaling":40,"./fromTranslation":41,"./fromXRotation":42,"./fromYRotation":43,"./fromZRotation":44,"./frustum":45,"./identity":46,"./invert":48,"./lookAt":49,"./multiply":50,"./ortho":51,"./perspective":52,"./perspectiveFromFieldOfView":53,"./rotate":54,"./rotateX":55,"./rotateY":56,"./rotateZ":57,"./scale":58,"./str":59,"./translate":60,"./transpose":61}],48:[function(_dereq_,module,exports){ module.exports = invert; /** @@ -15156,7 +15046,7 @@ function invert(out, a) { return out; }; -},{}],41:[function(_dereq_,module,exports){ +},{}],49:[function(_dereq_,module,exports){ var identity = _dereq_('./identity'); module.exports = lookAt; @@ -15247,7 +15137,7 @@ function lookAt(out, eye, center, up) { return out; }; -},{"./identity":38}],42:[function(_dereq_,module,exports){ +},{"./identity":46}],50:[function(_dereq_,module,exports){ module.exports = multiply; /** @@ -15290,7 +15180,7 @@ function multiply(out, a, b) { out[15] = b0*a03 + b1*a13 + b2*a23 + b3*a33; return out; }; -},{}],43:[function(_dereq_,module,exports){ +},{}],51:[function(_dereq_,module,exports){ module.exports = ortho; /** @@ -15327,7 +15217,7 @@ function ortho(out, left, right, bottom, top, near, far) { out[15] = 1; return out; }; -},{}],44:[function(_dereq_,module,exports){ +},{}],52:[function(_dereq_,module,exports){ module.exports = perspective; /** @@ -15361,7 +15251,7 @@ function perspective(out, fovy, aspect, near, far) { out[15] = 0; return out; }; -},{}],45:[function(_dereq_,module,exports){ +},{}],53:[function(_dereq_,module,exports){ module.exports = perspectiveFromFieldOfView; /** @@ -15403,7 +15293,7 @@ function perspectiveFromFieldOfView(out, fov, near, far) { } -},{}],46:[function(_dereq_,module,exports){ +},{}],54:[function(_dereq_,module,exports){ module.exports = rotate; /** @@ -15468,7 +15358,7 @@ function rotate(out, a, rad, axis) { } return out; }; -},{}],47:[function(_dereq_,module,exports){ +},{}],55:[function(_dereq_,module,exports){ module.exports = rotateX; /** @@ -15513,7 +15403,7 @@ function rotateX(out, a, rad) { out[11] = a23 * c - a13 * s; return out; }; -},{}],48:[function(_dereq_,module,exports){ +},{}],56:[function(_dereq_,module,exports){ module.exports = rotateY; /** @@ -15558,7 +15448,7 @@ function rotateY(out, a, rad) { out[11] = a03 * s + a23 * c; return out; }; -},{}],49:[function(_dereq_,module,exports){ +},{}],57:[function(_dereq_,module,exports){ module.exports = rotateZ; /** @@ -15603,7 +15493,7 @@ function rotateZ(out, a, rad) { out[7] = a13 * c - a03 * s; return out; }; -},{}],50:[function(_dereq_,module,exports){ +},{}],58:[function(_dereq_,module,exports){ module.exports = scale; /** @@ -15635,7 +15525,7 @@ function scale(out, a, v) { out[15] = a[15]; return out; }; -},{}],51:[function(_dereq_,module,exports){ +},{}],59:[function(_dereq_,module,exports){ module.exports = str; /** @@ -15650,7 +15540,7 @@ function str(a) { a[8] + ', ' + a[9] + ', ' + a[10] + ', ' + a[11] + ', ' + a[12] + ', ' + a[13] + ', ' + a[14] + ', ' + a[15] + ')'; }; -},{}],52:[function(_dereq_,module,exports){ +},{}],60:[function(_dereq_,module,exports){ module.exports = translate; /** @@ -15689,7 +15579,7 @@ function translate(out, a, v) { return out; }; -},{}],53:[function(_dereq_,module,exports){ +},{}],61:[function(_dereq_,module,exports){ module.exports = transpose; /** @@ -15739,7 +15629,7 @@ function transpose(out, a) { return out; }; -},{}],54:[function(_dereq_,module,exports){ +},{}],62:[function(_dereq_,module,exports){ (function (global){(function (){ 'use strict' @@ -15756,7 +15646,7 @@ else { module.exports = hasHover }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"is-browser":73}],55:[function(_dereq_,module,exports){ +},{"is-browser":66}],63:[function(_dereq_,module,exports){ 'use strict' var isBrowser = _dereq_('is-browser') @@ -15782,7 +15672,7 @@ function detect() { module.exports = isBrowser && detect() -},{"is-browser":73}],56:[function(_dereq_,module,exports){ +},{"is-browser":66}],64:[function(_dereq_,module,exports){ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m var eLen = (nBytes * 8) - mLen - 1 @@ -15868,987 +15758,38 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -},{}],57:[function(_dereq_,module,exports){ -'use strict'; - -var typeHandlers = _dereq_('./types'); - -module.exports = function (buffer, filepath) { - var type, result; - for (type in typeHandlers) { - result = typeHandlers[type].detect(buffer, filepath); - if (result) { - return type; - } - } -}; - -},{"./types":60}],58:[function(_dereq_,module,exports){ -(function (Buffer){(function (){ -'use strict'; - -var fs = _dereq_('fs'); -var path = _dereq_('path'); - -var typeHandlers = _dereq_('./types'); -var detector = _dereq_('./detector'); - -// Maximum buffer size, with a default of 512 kilobytes. -// TO-DO: make this adaptive based on the initial signature of the image -var MaxBufferSize = 512*1024; - -/** - * Return size information based on a buffer - * - * @param {Buffer} buffer - * @param {String} filepath - * @returns {Object} - */ -function lookup (buffer, filepath) { - // detect the file type.. don't rely on the extension - var type = detector(buffer, filepath); - - // find an appropriate handler for this file type - if (type in typeHandlers) { - var size = typeHandlers[type].calculate(buffer, filepath); - if (size !== false) { - size.type = type; - return size; - } - } - - // throw up, if we don't understand the file - throw new TypeError('unsupported file type: ' + type + ' (file: ' + filepath + ')'); -} - -/** - * Reads a file into a buffer. - * - * The callback will be called after the process has completed. The - * callback's first argument will be an error (or null). The second argument - * will be the Buffer, if the operation was successful. - * - * @param {String} filepath - * @param {Function} callback - */ -function asyncFileToBuffer (filepath, callback) { - // open the file in read only mode - fs.open(filepath, 'r', function (err, descriptor) { - if (err) { return callback(err); } - fs.fstat(descriptor, function (err, stats) { - if (err) { return callback(err); } - var size = stats.size; - if (size <= 0) { - return callback(new Error('File size is not greater than 0 —— ' + filepath)); - } - var bufferSize = Math.min(size, MaxBufferSize); - var buffer = Buffer.alloc(bufferSize); - // read first buffer block from the file, asynchronously - fs.read(descriptor, buffer, 0, bufferSize, 0, function (err) { - if (err) { return callback(err); } - // close the file, we are done - fs.close(descriptor, function (err) { - callback(err, buffer); - }); - }); - }); - }); -} - -/** - * Synchronously reads a file into a buffer, blocking the nodejs process. - * - * @param {String} filepath - * @returns {Buffer} - */ -function syncFileToBuffer (filepath) { - // read from the file, synchronously - var descriptor = fs.openSync(filepath, 'r'); - var size = fs.fstatSync(descriptor).size; - var bufferSize = Math.min(size, MaxBufferSize); - var buffer = Buffer.alloc(bufferSize); - fs.readSync(descriptor, buffer, 0, bufferSize, 0); - fs.closeSync(descriptor); - return buffer; -} - -/** - * @param {Buffer|string} input - buffer or relative/absolute path of the image file - * @param {Function=} callback - optional function for async detection - */ -module.exports = function (input, callback) { - - // Handle buffer input - if (Buffer.isBuffer(input)) { - return lookup(input); - } - - // input should be a string at this point - if (typeof input !== 'string') { - throw new TypeError('invalid invocation'); - } - - // resolve the file path - var filepath = path.resolve(input); - - if (typeof callback === 'function') { - asyncFileToBuffer(filepath, function (err, buffer) { - if (err) { return callback(err); } - - // return the dimensions - var dimensions; - try { - dimensions = lookup(buffer, filepath); - } catch (e) { - err = e; - } - callback(err, dimensions); - }); - } else { - var buffer = syncFileToBuffer(filepath); - return lookup(buffer, filepath); - } -}; - -module.exports.types = Object.keys(typeHandlers); - -}).call(this)}).call(this,_dereq_("buffer").Buffer) -},{"./detector":57,"./types":60,"buffer":18,"fs":16,"path":78}],59:[function(_dereq_,module,exports){ -'use strict'; - -// Abstract reading multi-byte unsigned integers -function readUInt (buffer, bits, offset, isBigEndian) { - offset = offset || 0; - var endian = isBigEndian ? 'BE' : 'LE'; - var method = buffer['readUInt' + bits + endian]; - return method.call(buffer, offset); -} - -module.exports = readUInt; - -},{}],60:[function(_dereq_,module,exports){ -'use strict'; - -// load all available handlers for browserify support -var typeHandlers = { - bmp: _dereq_('./types/bmp'), - cur: _dereq_('./types/cur'), - dds: _dereq_('./types/dds'), - gif: _dereq_('./types/gif'), - icns: _dereq_('./types/icns'), - ico: _dereq_('./types/ico'), - jpg: _dereq_('./types/jpg'), - png: _dereq_('./types/png'), - psd: _dereq_('./types/psd'), - svg: _dereq_('./types/svg'), - tiff: _dereq_('./types/tiff'), - webp: _dereq_('./types/webp'), -}; - -module.exports = typeHandlers; - -},{"./types/bmp":61,"./types/cur":62,"./types/dds":63,"./types/gif":64,"./types/icns":65,"./types/ico":66,"./types/jpg":67,"./types/png":68,"./types/psd":69,"./types/svg":70,"./types/tiff":71,"./types/webp":72}],61:[function(_dereq_,module,exports){ -'use strict'; - -function isBMP (buffer) { - return ('BM' === buffer.toString('ascii', 0, 2)); -} - -function calculate (buffer) { - return { - 'width': buffer.readUInt32LE(18), - 'height': Math.abs(buffer.readInt32LE(22)) - }; -} - -module.exports = { - 'detect': isBMP, - 'calculate': calculate -}; - -},{}],62:[function(_dereq_,module,exports){ -'use strict'; - -var TYPE_CURSOR = 2; - -function isCUR (buffer) { - var type; - if (buffer.readUInt16LE(0) !== 0) { - return false; - } - type = buffer.readUInt16LE(2); - return type === TYPE_CURSOR; -} - -module.exports = { - 'detect': isCUR, - 'calculate': _dereq_('./ico').calculate -}; - -},{"./ico":66}],63:[function(_dereq_,module,exports){ -'use strict'; - -function isDDS(buffer){ - return buffer.readUInt32LE(0) === 0x20534444; -} - -function calculate(buffer){ - // read file resolution metadata - return { - 'height': buffer.readUInt32LE(12), - 'width': buffer.readUInt32LE(16) - }; -} - -module.exports = { - 'detect': isDDS, - 'calculate': calculate -}; - -},{}],64:[function(_dereq_,module,exports){ -'use strict'; - -var gifRegexp = /^GIF8[79]a/; -function isGIF (buffer) { - var signature = buffer.toString('ascii', 0, 6); - return (gifRegexp.test(signature)); -} - -function calculate(buffer) { - return { - 'width': buffer.readUInt16LE(6), - 'height': buffer.readUInt16LE(8) - }; -} - -module.exports = { - 'detect': isGIF, - 'calculate': calculate -}; - },{}],65:[function(_dereq_,module,exports){ -'use strict'; - -/** - * ICNS Header - * - * | Offset | Size | Purpose | - * | 0 | 4 | Magic literal, must be "icns" (0x69, 0x63, 0x6e, 0x73) | - * | 4 | 4 | Length of file, in bytes, msb first. | - * - **/ -var SIZE_HEADER = 4 + 4; // 8 -var FILE_LENGTH_OFFSET = 4; // MSB => BIG ENDIAN - -/** - * Image Entry - * - * | Offset | Size | Purpose | - * | 0 | 4 | Icon type, see OSType below. | - * | 4 | 4 | Length of data, in bytes (including type and length), msb first. | - * | 8 | n | Icon data | - * - **/ -var ENTRY_LENGTH_OFFSET = 4; // MSB => BIG ENDIAN - -function isICNS (buffer) { - return ('icns' === buffer.toString('ascii', 0, 4)); -} - -var ICON_TYPE_SIZE = { - ICON: 32, - 'ICN#': 32, - // m => 16 x 16 - 'icm#': 16, - icm4: 16, - icm8: 16, - // s => 16 x 16 - 'ics#': 16, - ics4: 16, - ics8: 16, - is32: 16, - s8mk: 16, - icp4: 16, - // l => 32 x 32 - icl4: 32, - icl8: 32, - il32: 32, - l8mk: 32, - icp5: 32, - ic11: 32, - // h => 48 x 48 - ich4: 48, - ich8: 48, - ih32: 48, - h8mk: 48, - // . => 64 x 64 - icp6: 64, - ic12: 32, - // t => 128 x 128 - it32: 128, - t8mk: 128, - ic07: 128, - // . => 256 x 256 - ic08: 256, - ic13: 256, - // . => 512 x 512 - ic09: 512, - ic14: 512, - // . => 1024 x 1024 - ic10: 1024, -}; - -function readImageHeader(buffer, imageOffset) { - var imageLengthOffset = imageOffset + ENTRY_LENGTH_OFFSET; - // returns [type, length] - return [ - buffer.toString('ascii', imageOffset, imageLengthOffset), - buffer.readUInt32BE(imageLengthOffset) - ]; -} - -function getImageSize(type) { - var size = ICON_TYPE_SIZE[type]; - return { width: size, height: size, type: type }; -} - -function calculate (buffer) { - var - bufferLength = buffer.length, - imageOffset = SIZE_HEADER, - fileLength = buffer.readUInt32BE(FILE_LENGTH_OFFSET), - imageHeader, - imageSize, - result; - - imageHeader = readImageHeader(buffer, imageOffset); - imageSize = getImageSize(imageHeader[0]); - imageOffset += imageHeader[1]; - - if (imageOffset === fileLength) { - return imageSize; - } - - result = { - width: imageSize.width, - height: imageSize.height, - images: [imageSize] +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }) + } }; - - while (imageOffset < fileLength && imageOffset < bufferLength) { - imageHeader = readImageHeader(buffer, imageOffset); - imageSize = getImageSize(imageHeader[0]); - imageOffset += imageHeader[1]; - result.images.push(imageSize); +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } } - - return result; } -module.exports = { - 'detect': isICNS, - 'calculate': calculate -}; - },{}],66:[function(_dereq_,module,exports){ -'use strict'; - -var TYPE_ICON = 1; - -/** - * ICON Header - * - * | Offset | Size | Purpose | - * | 0 | 2 | Reserved. Must always be 0. | - * | 2 | 2 | Image type: 1 for icon (.ICO) image, 2 for cursor (.CUR) image. Other values are invalid. | - * | 4 | 2 | Number of images in the file. | - * - **/ -var SIZE_HEADER = 2 + 2 + 2; // 6 - -/** - * Image Entry - * - * | Offset | Size | Purpose | - * | 0 | 1 | Image width in pixels. Can be any number between 0 and 255. Value 0 means width is 256 pixels. | - * | 1 | 1 | Image height in pixels. Can be any number between 0 and 255. Value 0 means height is 256 pixels. | - * | 2 | 1 | Number of colors in the color palette. Should be 0 if the image does not use a color palette. | - * | 3 | 1 | Reserved. Should be 0. | - * | 4 | 2 | ICO format: Color planes. Should be 0 or 1. | - * | | | CUR format: The horizontal coordinates of the hotspot in number of pixels from the left. | - * | 6 | 2 | ICO format: Bits per pixel. | - * | | | CUR format: The vertical coordinates of the hotspot in number of pixels from the top. | - * | 8 | 4 | The size of the image's data in bytes | - * | 12 | 4 | The offset of BMP or PNG data from the beginning of the ICO/CUR file | - * - **/ -var SIZE_IMAGE_ENTRY = 1 + 1 + 1 + 1 + 2 + 2 + 4 + 4; // 16 - -function isICO (buffer) { - var type; - if (buffer.readUInt16LE(0) !== 0) { - return false; - } - type = buffer.readUInt16LE(2); - return type === TYPE_ICON; -} - -function getSizeFromOffset(buffer, offset) { - var value = buffer.readUInt8(offset); - return value === 0 ? 256 : value; -} - -function getImageSize(buffer, imageIndex) { - var offset = SIZE_HEADER + (imageIndex * SIZE_IMAGE_ENTRY); - return { - 'width': getSizeFromOffset(buffer, offset), - 'height': getSizeFromOffset(buffer, offset + 1) - }; -} - -function calculate (buffer) { - var - nbImages = buffer.readUInt16LE(4), - result = getImageSize(buffer, 0), - imageIndex; - - if (nbImages === 1) { - return result; - } - - result.images = [{ - width: result.width, - height: result.height - }]; - - for (imageIndex = 1; imageIndex < nbImages; imageIndex += 1) { - result.images.push(getImageSize(buffer, imageIndex)); - } - - return result; -} - -module.exports = { - 'detect': isICO, - 'calculate': calculate -}; - -},{}],67:[function(_dereq_,module,exports){ -'use strict'; - -var readUInt = _dereq_('../readUInt'); - -// NOTE: we only support baseline and progressive JPGs here -// due to the structure of the loader class, we only get a buffer -// with a maximum size of 4096 bytes. so if the SOF marker is outside -// if this range we can't detect the file size correctly. - -function isJPG (buffer) { //, filepath - var SOIMarker = buffer.toString('hex', 0, 2); - return ('ffd8' === SOIMarker); -} - -function isEXIF (buffer) { //, filepath - var exifMarker = buffer.toString('hex', 2, 6); - return (exifMarker === '45786966'); // 'Exif' -} - -function extractSize (buffer, i) { - return { - 'height' : buffer.readUInt16BE(i), - 'width' : buffer.readUInt16BE(i + 2) - }; -} - -var APP1_DATA_SIZE_BYTES = 2; -var EXIF_HEADER_BYTES = 6; -var TIFF_BYTE_ALIGN_BYTES = 2; -var BIG_ENDIAN_BYTE_ALIGN = '4d4d'; -var LITTLE_ENDIAN_BYTE_ALIGN = '4949'; - -// Each entry is exactly 12 bytes -var IDF_ENTRY_BYTES = 12; -var NUM_DIRECTORY_ENTRIES_BYTES = 2; - -function validateExifBlock (buffer, i) { - // Skip APP1 Data Size - var exifBlock = buffer.slice(APP1_DATA_SIZE_BYTES, i); - - // Consider byte alignment - var byteAlign = exifBlock.toString('hex', EXIF_HEADER_BYTES, EXIF_HEADER_BYTES + TIFF_BYTE_ALIGN_BYTES); - - // Ignore Empty EXIF. Validate byte alignment - var isBigEndian = byteAlign === BIG_ENDIAN_BYTE_ALIGN; - var isLittleEndian = byteAlign === LITTLE_ENDIAN_BYTE_ALIGN; - - if (isBigEndian || isLittleEndian) { - return extractOrientation(exifBlock, isBigEndian); - } -} - -function extractOrientation (exifBlock, isBigEndian) { - // TODO: assert that this contains 0x002A - // var STATIC_MOTOROLA_TIFF_HEADER_BYTES = 2; - // var TIFF_IMAGE_FILE_DIRECTORY_BYTES = 4; - - // TODO: derive from TIFF_IMAGE_FILE_DIRECTORY_BYTES - var idfOffset = 8; - - // IDF osset works from right after the header bytes - // (so the offset includes the tiff byte align) - var offset = EXIF_HEADER_BYTES + idfOffset; - - var idfDirectoryEntries = readUInt(exifBlock, 16, offset, isBigEndian); - - var start; - var end; - for (var directoryEntryNumber = 0; directoryEntryNumber < idfDirectoryEntries; directoryEntryNumber++) { - start = offset + NUM_DIRECTORY_ENTRIES_BYTES + (directoryEntryNumber * IDF_ENTRY_BYTES); - end = start + IDF_ENTRY_BYTES; - - // Skip on corrupt EXIF blocks - if (start > exifBlock.length) { - return; - } - - var block = exifBlock.slice(start, end); - var tagNumber = readUInt(block, 16, 0, isBigEndian); - - // 0x0112 (decimal: 274) is the `orientation` tag ID - if (tagNumber === 274) { - var dataFormat = readUInt(block, 16, 2, isBigEndian); - if (dataFormat !== 3) { - return; - } - - // unsinged int has 2 bytes per component - // if there would more than 4 bytes in total it's a pointer - var numberOfComponents = readUInt(block, 32, 4, isBigEndian); - if (numberOfComponents !== 1) { - return; - } - - return readUInt(block, 16, 8, isBigEndian); - } - } -} - -function validateBuffer (buffer, i) { - // index should be within buffer limits - if (i > buffer.length) { - throw new TypeError('Corrupt JPG, exceeded buffer limits'); - } - // Every JPEG block must begin with a 0xFF - if (buffer[i] !== 0xFF) { - throw new TypeError('Invalid JPG, marker table corrupted'); - } -} - -function calculate (buffer) { - // Skip 4 chars, they are for signature - buffer = buffer.slice(4); - - var orientation; - - var i, next; - while (buffer.length) { - // read length of the next block - i = buffer.readUInt16BE(0); - - if (isEXIF(buffer)) { - orientation = validateExifBlock(buffer, i); - } - - // ensure correct format - validateBuffer(buffer, i); - - // 0xFFC0 is baseline standard(SOF) - // 0xFFC1 is baseline optimized(SOF) - // 0xFFC2 is progressive(SOF2) - next = buffer[i + 1]; - if (next === 0xC0 || next === 0xC1 || next === 0xC2) { - var size = extractSize(buffer, i + 5); - - if (!orientation) { - return size; - } - - return { - width: size.width, - height: size.height, - orientation: orientation - }; - } - - // move to the next block - buffer = buffer.slice(i + 2); - } - - throw new TypeError('Invalid JPG, no size found'); -} - -module.exports = { - 'detect': isJPG, - 'calculate': calculate -}; - -},{"../readUInt":59}],68:[function(_dereq_,module,exports){ -'use strict'; - -var pngSignature = 'PNG\r\n\x1a\n'; -var pngImageHeaderChunkName = 'IHDR'; - -// Used to detect "fried" png's: http://www.jongware.com/pngdefry.html -var pngFriedChunkName = 'CgBI'; - -function isPNG (buffer) { - if (pngSignature === buffer.toString('ascii', 1, 8)) { - var chunkName = buffer.toString('ascii', 12, 16); - if (chunkName === pngFriedChunkName) { - chunkName = buffer.toString('ascii', 28, 32); - } - if (chunkName !== pngImageHeaderChunkName) { - throw new TypeError('invalid png'); - } - return true; - } -} - -function calculate (buffer) { - if (buffer.toString('ascii', 12, 16) === pngFriedChunkName) { - return { - 'width': buffer.readUInt32BE(32), - 'height': buffer.readUInt32BE(36) - }; - } - return { - 'width': buffer.readUInt32BE(16), - 'height': buffer.readUInt32BE(20) - }; -} - -module.exports = { - 'detect': isPNG, - 'calculate': calculate -}; - -},{}],69:[function(_dereq_,module,exports){ -'use strict'; - -function isPSD (buffer) { - return ('8BPS' === buffer.toString('ascii', 0, 4)); -} - -function calculate (buffer) { - return { - 'width': buffer.readUInt32BE(18), - 'height': buffer.readUInt32BE(14) - }; -} - -module.exports = { - 'detect': isPSD, - 'calculate': calculate -}; - -},{}],70:[function(_dereq_,module,exports){ -'use strict'; - -var svgReg = /"']|"[^"]*"|'[^']*')*>/; -function isSVG (buffer) { - return svgReg.test(buffer); -} - -var extractorRegExps = { - 'root': svgReg, - 'width': /\swidth=(['"])([^%]+?)\1/, - 'height': /\sheight=(['"])([^%]+?)\1/, - 'viewbox': /\sviewBox=(['"])(.+?)\1/ -}; - -var units = { - 'cm': 96/2.54, - 'mm': 96/2.54/10, - 'm': 96/2.54*100, - 'pt': 96/72, - 'pc': 96/72/12, - 'em': 16, - 'ex': 8, -}; - -function parseLength (len) { - var m = /([0-9.]+)([a-z]*)/.exec(len); - if (!m) { - return undefined; - } - return Math.round(parseFloat(m[1]) * (units[m[2]] || 1)); -} - -function parseViewbox (viewbox) { - var bounds = viewbox.split(' '); - return { - 'width': parseLength(bounds[2]), - 'height': parseLength(bounds[3]) - }; -} - -function parseAttributes (root) { - var width = root.match(extractorRegExps.width); - var height = root.match(extractorRegExps.height); - var viewbox = root.match(extractorRegExps.viewbox); - return { - 'width': width && parseLength(width[2]), - 'height': height && parseLength(height[2]), - 'viewbox': viewbox && parseViewbox(viewbox[2]) - }; -} - -function calculateByDimensions (attrs) { - return { - 'width': attrs.width, - 'height': attrs.height - }; -} - -function calculateByViewbox (attrs) { - var ratio = attrs.viewbox.width / attrs.viewbox.height; - if (attrs.width) { - return { - 'width': attrs.width, - 'height': Math.floor(attrs.width / ratio) - }; - } - if (attrs.height) { - return { - 'width': Math.floor(attrs.height * ratio), - 'height': attrs.height - }; - } - return { - 'width': attrs.viewbox.width, - 'height': attrs.viewbox.height - }; -} - -function calculate (buffer) { - var root = buffer.toString('utf8').match(extractorRegExps.root); - if (root) { - var attrs = parseAttributes(root[0]); - if (attrs.width && attrs.height) { - return calculateByDimensions(attrs); - } - if (attrs.viewbox) { - return calculateByViewbox(attrs); - } - } - throw new TypeError('invalid svg'); -} - -module.exports = { - 'detect': isSVG, - 'calculate': calculate -}; - -},{}],71:[function(_dereq_,module,exports){ -(function (Buffer){(function (){ -'use strict'; - -// based on http://www.compix.com/fileformattif.htm -// TO-DO: support big-endian as well - -var fs = _dereq_('fs'); -var readUInt = _dereq_('../readUInt'); - -function isTIFF (buffer) { - var hex4 = buffer.toString('hex', 0, 4); - return ('49492a00' === hex4 || '4d4d002a' === hex4); -} - -// Read IFD (image-file-directory) into a buffer -function readIFD (buffer, filepath, isBigEndian) { - - var ifdOffset = readUInt(buffer, 32, 4, isBigEndian); - - // read only till the end of the file - var bufferSize = 1024; - var fileSize = fs.statSync(filepath).size; - if (ifdOffset + bufferSize > fileSize) { - bufferSize = fileSize - ifdOffset - 10; - } - - // populate the buffer - var endBuffer = Buffer.alloc(bufferSize); - var descriptor = fs.openSync(filepath, 'r'); - fs.readSync(descriptor, endBuffer, 0, bufferSize, ifdOffset); - - // var ifdLength = readUInt(endBuffer, 16, 0, isBigEndian); - var ifdBuffer = endBuffer.slice(2); //, 2 + 12 * ifdLength); - return ifdBuffer; -} - -// TIFF values seem to be messed up on Big-Endian, this helps -function readValue (buffer, isBigEndian) { - var low = readUInt(buffer, 16, 8, isBigEndian); - var high = readUInt(buffer, 16, 10, isBigEndian); - return (high << 16) + low; -} - -// move to the next tag -function nextTag (buffer) { - if (buffer.length > 24) { - return buffer.slice(12); - } -} - -// Extract IFD tags from TIFF metadata -/* eslint-disable complexity */ -function extractTags (buffer, isBigEndian) { - var tags = {}; - var code, type, length; - - while (buffer && buffer.length) { - code = readUInt(buffer, 16, 0, isBigEndian); - type = readUInt(buffer, 16, 2, isBigEndian); - length = readUInt(buffer, 32, 4, isBigEndian); - - // 0 means end of IFD - if (code === 0) { - break; - } else { - // 256 is width, 257 is height - // if (code === 256 || code === 257) { - if (length === 1 && (type === 3 || type === 4)) { - tags[code] = readValue(buffer, isBigEndian); - } - - // move to the next tag - buffer = nextTag(buffer); - } - } - return tags; -} -/* eslint-enable complexity */ - -// Test if the TIFF is Big Endian or Little Endian -function determineEndianness (buffer) { - var signature = buffer.toString('ascii', 0, 2); - if ('II' === signature) { - return 'LE'; - } else if ('MM' === signature) { - return 'BE'; - } -} - -function calculate (buffer, filepath) { - - if (!filepath) { - throw new TypeError('Tiff doesn\'t support buffer'); - } - - // Determine BE/LE - var isBigEndian = determineEndianness(buffer) === 'BE'; - - // read the IFD - var ifdBuffer = readIFD(buffer, filepath, isBigEndian); - - // extract the tags from the IFD - var tags = extractTags(ifdBuffer, isBigEndian); - - var width = tags[256]; - var height = tags[257]; - - if (!width || !height) { - throw new TypeError('Invalid Tiff, missing tags'); - } - - return { - 'width': width, - 'height': height - }; -} - -module.exports = { - 'detect': isTIFF, - 'calculate': calculate -}; - -}).call(this)}).call(this,_dereq_("buffer").Buffer) -},{"../readUInt":59,"buffer":18,"fs":16}],72:[function(_dereq_,module,exports){ -'use strict'; - -// based on https://developers.google.com/speed/webp/docs/riff_container - -function isWebP (buffer) { - var riffHeader = 'RIFF' === buffer.toString('ascii', 0, 4); - var webpHeader = 'WEBP' === buffer.toString('ascii', 8, 12); - var vp8Header = 'VP8' === buffer.toString('ascii', 12, 15); - return (riffHeader && webpHeader && vp8Header); -} - -/* eslint-disable complexity */ -function calculate (buffer) { - var chunkHeader = buffer.toString('ascii', 12, 16); - buffer = buffer.slice(20, 30); - - // Extended webp stream signature - if (chunkHeader === 'VP8X') { - var extendedHeader = buffer[0]; - var validStart = (extendedHeader & 0xc0) === 0; - var validEnd = (extendedHeader & 0x01) === 0; - if (validStart && validEnd) { - return calculateExtended(buffer); - } else { - return false; - } - } - - // Lossless webp stream signature - if (chunkHeader === 'VP8 ' && buffer[0] !== 0x2f) { - return calculateLossy(buffer); - } - - // Lossy webp stream signature - var signature = buffer.toString('hex', 3, 6); - if (chunkHeader === 'VP8L' && signature !== '9d012a') { - return calculateLossless(buffer); - } - - return false; -} -/* eslint-enable complexity */ - -function calculateExtended (buffer) { - return { - 'width': 1 + buffer.readUIntLE(4, 3), - 'height': 1 + buffer.readUIntLE(7, 3) - }; -} - -function calculateLossless (buffer) { - return { - 'width': 1 + (((buffer[2] & 0x3F) << 8) | buffer[1]), - 'height': 1 + (((buffer[4] & 0xF) << 10) | (buffer[3] << 2) | - ((buffer[2] & 0xC0) >> 6)) - }; -} - -function calculateLossy (buffer) { - // `& 0x3fff` returns the last 14 bits - // TO-DO: include webp scaling in the calculations - return { - 'width': buffer.readInt16LE(6) & 0x3fff, - 'height': buffer.readInt16LE(8) & 0x3fff - }; -} - -module.exports = { - 'detect': isWebP, - 'calculate': calculate -}; - -},{}],73:[function(_dereq_,module,exports){ module.exports = true; -},{}],74:[function(_dereq_,module,exports){ +},{}],67:[function(_dereq_,module,exports){ 'use strict' module.exports = isMobile @@ -16885,7 +15826,7 @@ function isMobile (opts) { return result } -},{}],75:[function(_dereq_,module,exports){ +},{}],68:[function(_dereq_,module,exports){ 'use strict'; /** @@ -16922,7 +15863,7 @@ module.exports = function(str){ return true; } -},{}],76:[function(_dereq_,module,exports){ +},{}],69:[function(_dereq_,module,exports){ var rootPosition = { left: 0, top: 0 } module.exports = mouseEventOffset @@ -16949,7 +15890,476 @@ function getBoundingClientOffset (element) { } } -},{}],77:[function(_dereq_,module,exports){ +},{}],70:[function(_dereq_,module,exports){ +(function (global,setImmediate){(function (){ +/*! Native Promise Only + v0.8.1 (c) Kyle Simpson + MIT License: http://getify.mit-license.org +*/ + +(function UMD(name,context,definition){ + // special form of UMD for polyfilling across evironments + context[name] = context[name] || definition(); + if (typeof module != "undefined" && module.exports) { module.exports = context[name]; } + else if (typeof define == "function" && define.amd) { define(function $AMD$(){ return context[name]; }); } +})("Promise",typeof global != "undefined" ? global : this,function DEF(){ + /*jshint validthis:true */ + "use strict"; + + var builtInProp, cycle, scheduling_queue, + ToString = Object.prototype.toString, + timer = (typeof setImmediate != "undefined") ? + function timer(fn) { return setImmediate(fn); } : + setTimeout + ; + + // dammit, IE8. + try { + Object.defineProperty({},"x",{}); + builtInProp = function builtInProp(obj,name,val,config) { + return Object.defineProperty(obj,name,{ + value: val, + writable: true, + configurable: config !== false + }); + }; + } + catch (err) { + builtInProp = function builtInProp(obj,name,val) { + obj[name] = val; + return obj; + }; + } + + // Note: using a queue instead of array for efficiency + scheduling_queue = (function Queue() { + var first, last, item; + + function Item(fn,self) { + this.fn = fn; + this.self = self; + this.next = void 0; + } + + return { + add: function add(fn,self) { + item = new Item(fn,self); + if (last) { + last.next = item; + } + else { + first = item; + } + last = item; + item = void 0; + }, + drain: function drain() { + var f = first; + first = last = cycle = void 0; + + while (f) { + f.fn.call(f.self); + f = f.next; + } + } + }; + })(); + + function schedule(fn,self) { + scheduling_queue.add(fn,self); + if (!cycle) { + cycle = timer(scheduling_queue.drain); + } + } + + // promise duck typing + function isThenable(o) { + var _then, o_type = typeof o; + + if (o != null && + ( + o_type == "object" || o_type == "function" + ) + ) { + _then = o.then; + } + return typeof _then == "function" ? _then : false; + } + + function notify() { + for (var i=0; i 0) { + schedule(notify,self); + } + } + } + catch (err) { + reject.call(new MakeDefWrapper(self),err); + } + } + + function reject(msg) { + var self = this; + + // already triggered? + if (self.triggered) { return; } + + self.triggered = true; + + // unwrap + if (self.def) { + self = self.def; + } + + self.msg = msg; + self.state = 2; + if (self.chain.length > 0) { + schedule(notify,self); + } + } + + function iteratePromises(Constructor,arr,resolver,rejecter) { + for (var idx=0; idx 2) { - var lastSlashIndex = res.lastIndexOf('/'); - if (lastSlashIndex !== res.length - 1) { - if (lastSlashIndex === -1) { - res = ''; - lastSegmentLength = 0; - } else { - res = res.slice(0, lastSlashIndex); - lastSegmentLength = res.length - 1 - res.lastIndexOf('/'); - } - lastSlash = i; - dots = 0; - continue; - } - } else if (res.length === 2 || res.length === 1) { - res = ''; - lastSegmentLength = 0; - lastSlash = i; - dots = 0; - continue; - } - } - if (allowAboveRoot) { - if (res.length > 0) - res += '/..'; - else - res = '..'; - lastSegmentLength = 2; - } - } else { - if (res.length > 0) - res += '/' + path.slice(lastSlash + 1, i); - else - res = path.slice(lastSlash + 1, i); - lastSegmentLength = i - lastSlash - 1; - } - lastSlash = i; - dots = 0; - } else if (code === 46 /*.*/ && dots !== -1) { - ++dots; - } else { - dots = -1; - } - } - return res; -} - -function _format(sep, pathObject) { - var dir = pathObject.dir || pathObject.root; - var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || ''); - if (!dir) { - return base; - } - if (dir === pathObject.root) { - return dir + base; - } - return dir + sep + base; -} - -var posix = { - // path.resolve([from ...], to) - resolve: function resolve() { - var resolvedPath = ''; - var resolvedAbsolute = false; - var cwd; - - for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { - var path; - if (i >= 0) - path = arguments[i]; - else { - if (cwd === undefined) - cwd = process.cwd(); - path = cwd; - } - - assertPath(path); - - // Skip empty entries - if (path.length === 0) { - continue; - } - - resolvedPath = path + '/' + resolvedPath; - resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/; - } - - // At this point the path should be resolved to a full absolute path, but - // handle relative paths to be safe (might happen when process.cwd() fails) - - // Normalize the path - resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute); - - if (resolvedAbsolute) { - if (resolvedPath.length > 0) - return '/' + resolvedPath; - else - return '/'; - } else if (resolvedPath.length > 0) { - return resolvedPath; - } else { - return '.'; - } - }, - - normalize: function normalize(path) { - assertPath(path); - - if (path.length === 0) return '.'; - - var isAbsolute = path.charCodeAt(0) === 47 /*/*/; - var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/; - - // Normalize the path - path = normalizeStringPosix(path, !isAbsolute); - - if (path.length === 0 && !isAbsolute) path = '.'; - if (path.length > 0 && trailingSeparator) path += '/'; - - if (isAbsolute) return '/' + path; - return path; - }, - - isAbsolute: function isAbsolute(path) { - assertPath(path); - return path.length > 0 && path.charCodeAt(0) === 47 /*/*/; - }, - - join: function join() { - if (arguments.length === 0) - return '.'; - var joined; - for (var i = 0; i < arguments.length; ++i) { - var arg = arguments[i]; - assertPath(arg); - if (arg.length > 0) { - if (joined === undefined) - joined = arg; - else - joined += '/' + arg; - } - } - if (joined === undefined) - return '.'; - return posix.normalize(joined); - }, - - relative: function relative(from, to) { - assertPath(from); - assertPath(to); - - if (from === to) return ''; - - from = posix.resolve(from); - to = posix.resolve(to); - - if (from === to) return ''; - - // Trim any leading backslashes - var fromStart = 1; - for (; fromStart < from.length; ++fromStart) { - if (from.charCodeAt(fromStart) !== 47 /*/*/) - break; - } - var fromEnd = from.length; - var fromLen = fromEnd - fromStart; - - // Trim any leading backslashes - var toStart = 1; - for (; toStart < to.length; ++toStart) { - if (to.charCodeAt(toStart) !== 47 /*/*/) - break; - } - var toEnd = to.length; - var toLen = toEnd - toStart; - - // Compare paths to find the longest common path from root - var length = fromLen < toLen ? fromLen : toLen; - var lastCommonSep = -1; - var i = 0; - for (; i <= length; ++i) { - if (i === length) { - if (toLen > length) { - if (to.charCodeAt(toStart + i) === 47 /*/*/) { - // We get here if `from` is the exact base path for `to`. - // For example: from='/foo/bar'; to='/foo/bar/baz' - return to.slice(toStart + i + 1); - } else if (i === 0) { - // We get here if `from` is the root - // For example: from='/'; to='/foo' - return to.slice(toStart + i); - } - } else if (fromLen > length) { - if (from.charCodeAt(fromStart + i) === 47 /*/*/) { - // We get here if `to` is the exact base path for `from`. - // For example: from='/foo/bar/baz'; to='/foo/bar' - lastCommonSep = i; - } else if (i === 0) { - // We get here if `to` is the root. - // For example: from='/foo'; to='/' - lastCommonSep = 0; - } - } - break; - } - var fromCode = from.charCodeAt(fromStart + i); - var toCode = to.charCodeAt(toStart + i); - if (fromCode !== toCode) - break; - else if (fromCode === 47 /*/*/) - lastCommonSep = i; - } - - var out = ''; - // Generate the relative path based on the path difference between `to` - // and `from` - for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) { - if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) { - if (out.length === 0) - out += '..'; - else - out += '/..'; - } - } - - // Lastly, append the rest of the destination (`to`) path that comes after - // the common path parts - if (out.length > 0) - return out + to.slice(toStart + lastCommonSep); - else { - toStart += lastCommonSep; - if (to.charCodeAt(toStart) === 47 /*/*/) - ++toStart; - return to.slice(toStart); - } - }, - - _makeLong: function _makeLong(path) { - return path; - }, - - dirname: function dirname(path) { - assertPath(path); - if (path.length === 0) return '.'; - var code = path.charCodeAt(0); - var hasRoot = code === 47 /*/*/; - var end = -1; - var matchedSlash = true; - for (var i = path.length - 1; i >= 1; --i) { - code = path.charCodeAt(i); - if (code === 47 /*/*/) { - if (!matchedSlash) { - end = i; - break; - } - } else { - // We saw the first non-path separator - matchedSlash = false; - } - } - - if (end === -1) return hasRoot ? '/' : '.'; - if (hasRoot && end === 1) return '//'; - return path.slice(0, end); - }, - - basename: function basename(path, ext) { - if (ext !== undefined && typeof ext !== 'string') throw new TypeError('"ext" argument must be a string'); - assertPath(path); - - var start = 0; - var end = -1; - var matchedSlash = true; - var i; - - if (ext !== undefined && ext.length > 0 && ext.length <= path.length) { - if (ext.length === path.length && ext === path) return ''; - var extIdx = ext.length - 1; - var firstNonSlashEnd = -1; - for (i = path.length - 1; i >= 0; --i) { - var code = path.charCodeAt(i); - if (code === 47 /*/*/) { - // If we reached a path separator that was not part of a set of path - // separators at the end of the string, stop now - if (!matchedSlash) { - start = i + 1; - break; - } - } else { - if (firstNonSlashEnd === -1) { - // We saw the first non-path separator, remember this index in case - // we need it if the extension ends up not matching - matchedSlash = false; - firstNonSlashEnd = i + 1; - } - if (extIdx >= 0) { - // Try to match the explicit extension - if (code === ext.charCodeAt(extIdx)) { - if (--extIdx === -1) { - // We matched the extension, so mark this as the end of our path - // component - end = i; - } - } else { - // Extension does not match, so our result is the entire path - // component - extIdx = -1; - end = firstNonSlashEnd; - } - } - } - } - - if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length; - return path.slice(start, end); - } else { - for (i = path.length - 1; i >= 0; --i) { - if (path.charCodeAt(i) === 47 /*/*/) { - // If we reached a path separator that was not part of a set of path - // separators at the end of the string, stop now - if (!matchedSlash) { - start = i + 1; - break; - } - } else if (end === -1) { - // We saw the first non-path separator, mark this as the end of our - // path component - matchedSlash = false; - end = i + 1; - } - } - - if (end === -1) return ''; - return path.slice(start, end); - } - }, - - extname: function extname(path) { - assertPath(path); - var startDot = -1; - var startPart = 0; - var end = -1; - var matchedSlash = true; - // Track the state of characters (if any) we see before our first dot and - // after any path separator we find - var preDotState = 0; - for (var i = path.length - 1; i >= 0; --i) { - var code = path.charCodeAt(i); - if (code === 47 /*/*/) { - // If we reached a path separator that was not part of a set of path - // separators at the end of the string, stop now - if (!matchedSlash) { - startPart = i + 1; - break; - } - continue; - } - if (end === -1) { - // We saw the first non-path separator, mark this as the end of our - // extension - matchedSlash = false; - end = i + 1; - } - if (code === 46 /*.*/) { - // If this is our first dot, mark it as the start of our extension - if (startDot === -1) - startDot = i; - else if (preDotState !== 1) - preDotState = 1; - } else if (startDot !== -1) { - // We saw a non-dot and non-path separator before our dot, so we should - // have a good chance at having a non-empty extension - preDotState = -1; - } - } - - if (startDot === -1 || end === -1 || - // We saw a non-dot character immediately before the dot - preDotState === 0 || - // The (right-most) trimmed path component is exactly '..' - preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { - return ''; - } - return path.slice(startDot, end); - }, - - format: function format(pathObject) { - if (pathObject === null || typeof pathObject !== 'object') { - throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject); - } - return _format('/', pathObject); - }, - - parse: function parse(path) { - assertPath(path); - - var ret = { root: '', dir: '', base: '', ext: '', name: '' }; - if (path.length === 0) return ret; - var code = path.charCodeAt(0); - var isAbsolute = code === 47 /*/*/; - var start; - if (isAbsolute) { - ret.root = '/'; - start = 1; - } else { - start = 0; - } - var startDot = -1; - var startPart = 0; - var end = -1; - var matchedSlash = true; - var i = path.length - 1; - - // Track the state of characters (if any) we see before our first dot and - // after any path separator we find - var preDotState = 0; - - // Get non-dir info - for (; i >= start; --i) { - code = path.charCodeAt(i); - if (code === 47 /*/*/) { - // If we reached a path separator that was not part of a set of path - // separators at the end of the string, stop now - if (!matchedSlash) { - startPart = i + 1; - break; - } - continue; - } - if (end === -1) { - // We saw the first non-path separator, mark this as the end of our - // extension - matchedSlash = false; - end = i + 1; - } - if (code === 46 /*.*/) { - // If this is our first dot, mark it as the start of our extension - if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1; - } else if (startDot !== -1) { - // We saw a non-dot and non-path separator before our dot, so we should - // have a good chance at having a non-empty extension - preDotState = -1; - } - } - - if (startDot === -1 || end === -1 || - // We saw a non-dot character immediately before the dot - preDotState === 0 || - // The (right-most) trimmed path component is exactly '..' - preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { - if (end !== -1) { - if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end); - } - } else { - if (startPart === 0 && isAbsolute) { - ret.name = path.slice(1, startDot); - ret.base = path.slice(1, end); - } else { - ret.name = path.slice(startPart, startDot); - ret.base = path.slice(startPart, end); - } - ret.ext = path.slice(startDot, end); - } - - if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/'; - - return ret; - }, - - sep: '/', - delimiter: ':', - win32: null, - posix: null -}; - -posix.posix = posix; - -module.exports = posix; - -}).call(this)}).call(this,_dereq_('_process')) -},{"_process":87}],79:[function(_dereq_,module,exports){ +},{}],73:[function(_dereq_,module,exports){ /* * @copyright 2016 Sean Connelly (@voidqk), http://syntheti.cc * @license MIT @@ -17669,7 +16546,7 @@ if (typeof window === 'object') module.exports = PolyBool; -},{"./lib/build-log":80,"./lib/epsilon":81,"./lib/geojson":82,"./lib/intersecter":83,"./lib/segment-chainer":85,"./lib/segment-selector":86}],80:[function(_dereq_,module,exports){ +},{"./lib/build-log":74,"./lib/epsilon":75,"./lib/geojson":76,"./lib/intersecter":77,"./lib/segment-chainer":79,"./lib/segment-selector":80}],74:[function(_dereq_,module,exports){ // (c) Copyright 2016, Sean Connelly (@voidqk), http://syntheti.cc // MIT License // Project Home: https://github.com/voidqk/polybooljs @@ -17784,7 +16661,7 @@ function BuildLog(){ module.exports = BuildLog; -},{}],81:[function(_dereq_,module,exports){ +},{}],75:[function(_dereq_,module,exports){ // (c) Copyright 2016, Sean Connelly (@voidqk), http://syntheti.cc // MIT License // Project Home: https://github.com/voidqk/polybooljs @@ -17956,7 +16833,7 @@ function Epsilon(eps){ module.exports = Epsilon; -},{}],82:[function(_dereq_,module,exports){ +},{}],76:[function(_dereq_,module,exports){ // (c) Copyright 2017, Sean Connelly (@voidqk), http://syntheti.cc // MIT License // Project Home: https://github.com/voidqk/polybooljs @@ -18146,7 +17023,7 @@ var GeoJSON = { module.exports = GeoJSON; -},{}],83:[function(_dereq_,module,exports){ +},{}],77:[function(_dereq_,module,exports){ // (c) Copyright 2016, Sean Connelly (@voidqk), http://syntheti.cc // MIT License // Project Home: https://github.com/voidqk/polybooljs @@ -18653,7 +17530,7 @@ function Intersecter(selfIntersection, eps, buildLog){ module.exports = Intersecter; -},{"./linked-list":84}],84:[function(_dereq_,module,exports){ +},{"./linked-list":78}],78:[function(_dereq_,module,exports){ // (c) Copyright 2016, Sean Connelly (@voidqk), http://syntheti.cc // MIT License // Project Home: https://github.com/voidqk/polybooljs @@ -18736,7 +17613,7 @@ var LinkedList = { module.exports = LinkedList; -},{}],85:[function(_dereq_,module,exports){ +},{}],79:[function(_dereq_,module,exports){ // (c) Copyright 2016, Sean Connelly (@voidqk), http://syntheti.cc // MIT License // Project Home: https://github.com/voidqk/polybooljs @@ -18990,7 +17867,7 @@ function SegmentChainer(segments, eps, buildLog){ module.exports = SegmentChainer; -},{}],86:[function(_dereq_,module,exports){ +},{}],80:[function(_dereq_,module,exports){ // (c) Copyright 2016, Sean Connelly (@voidqk), http://syntheti.cc // MIT License // Project Home: https://github.com/voidqk/polybooljs @@ -19158,7 +18035,1391 @@ var SegmentSelector = { module.exports = SegmentSelector; -},{}],87:[function(_dereq_,module,exports){ +},{}],81:[function(_dereq_,module,exports){ +'use strict'; + + +var Transform = _dereq_('stream').Transform; +var streamParser = _dereq_('stream-parser'); + + +function ParserStream() { + Transform.call(this, { readableObjectMode: true }); +} + +// Inherit from Transform +ParserStream.prototype = Object.create(Transform.prototype); +ParserStream.prototype.constructor = ParserStream; + +streamParser(ParserStream.prototype); + + +exports.ParserStream = ParserStream; + + +exports.sliceEq = function (src, start, dest) { + for (var i = start, j = 0; j < dest.length;) { + if (src[i++] !== dest[j++]) return false; + } + return true; +}; + +exports.str2arr = function (str, format) { + var arr = [], i = 0; + + if (format && format === 'hex') { + while (i < str.length) { + arr.push(parseInt(str.slice(i, i + 2), 16)); + i += 2; + } + } else { + for (; i < str.length; i++) { + /* eslint-disable no-bitwise */ + arr.push(str.charCodeAt(i) & 0xFF); + } + } + + return arr; +}; + +exports.readUInt16LE = function (data, offset) { + return data[offset] | (data[offset + 1] << 8); +}; + +exports.readUInt16BE = function (data, offset) { + return data[offset + 1] | (data[offset] << 8); +}; + +exports.readUInt32LE = function (data, offset) { + return data[offset] | + (data[offset + 1] << 8) | + (data[offset + 2] << 16) | + (data[offset + 3] * 0x1000000); +}; + +exports.readUInt32BE = function (data, offset) { + return data[offset + 3] | + (data[offset + 2] << 8) | + (data[offset + 1] << 16) | + (data[offset] * 0x1000000); +}; + + +function ProbeError(message, code, statusCode) { + Error.call(this); + Error.captureStackTrace(this, this.constructor); + + this.name = this.constructor.name; + + this.message = message; + if (code) this.code = code; + if (statusCode) this.statusCode = statusCode; +} + +// Inherit from Error +ProbeError.prototype = Object.create(Error.prototype); +ProbeError.prototype.constructor = ProbeError; + + +exports.ProbeError = ProbeError; + +},{"stream":98,"stream-parser":114}],82:[function(_dereq_,module,exports){ + +/* eslint-disable no-bitwise */ +/* eslint-disable consistent-return */ + +'use strict'; + +////////////////////////////////////////////////////////////////////////// +// Helpers +// +function error(message, code) { + var err = new Error(message); + err.code = code; + return err; +} + + +function utf8_decode(str) { + try { + return decodeURIComponent(escape(str)); + } catch (_) { + return str; + } +} + + +////////////////////////////////////////////////////////////////////////// +// Exif parser +// +// Input: +// - jpeg_bin: Uint8Array - jpeg file +// - exif_start: Number - start of TIFF header (after Exif\0\0) +// - exif_end: Number - end of Exif segment +// - on_entry: Number - callback +// +function ExifParser(jpeg_bin, exif_start, exif_end) { + // Uint8Array, exif without signature (which isn't included in offsets) + this.input = jpeg_bin.subarray(exif_start, exif_end); + + // offset correction for `on_entry` callback + this.start = exif_start; + + // Check TIFF header (includes byte alignment and first IFD offset) + var sig = String.fromCharCode.apply(null, this.input.subarray(0, 4)); + + if (sig !== 'II\x2A\0' && sig !== 'MM\0\x2A') { + throw error('invalid TIFF signature', 'EBADDATA'); + } + + // true if motorola (big endian) byte alignment, false if intel + this.big_endian = sig[0] === 'M'; +} + + +ExifParser.prototype.each = function (on_entry) { + // allow premature exit + this.aborted = false; + + var offset = this.read_uint32(4); + + this.ifds_to_read = [ { + id: 0, + offset: offset + } ]; + + while (this.ifds_to_read.length > 0 && !this.aborted) { + var i = this.ifds_to_read.shift(); + if (!i.offset) continue; + this.scan_ifd(i.id, i.offset, on_entry); + } +}; + + +ExifParser.prototype.read_uint16 = function (offset) { + var d = this.input; + if (offset + 2 > d.length) throw error('unexpected EOF', 'EBADDATA'); + + return this.big_endian ? + d[offset] * 0x100 + d[offset + 1] : + d[offset] + d[offset + 1] * 0x100; +}; + + +ExifParser.prototype.read_uint32 = function (offset) { + var d = this.input; + if (offset + 4 > d.length) throw error('unexpected EOF', 'EBADDATA'); + + return this.big_endian ? + d[offset] * 0x1000000 + d[offset + 1] * 0x10000 + d[offset + 2] * 0x100 + d[offset + 3] : + d[offset] + d[offset + 1] * 0x100 + d[offset + 2] * 0x10000 + d[offset + 3] * 0x1000000; +}; + + +ExifParser.prototype.is_subifd_link = function (ifd, tag) { + return (ifd === 0 && tag === 0x8769) || // SubIFD + (ifd === 0 && tag === 0x8825) || // GPS Info + (ifd === 0x8769 && tag === 0xA005); // Interop IFD +}; + + +// Returns byte length of a single component of a given format +// +ExifParser.prototype.exif_format_length = function (format) { + switch (format) { + case 1: // byte + case 2: // ascii + case 6: // sbyte + case 7: // undefined + return 1; + + case 3: // short + case 8: // sshort + return 2; + + case 4: // long + case 9: // slong + case 11: // float + return 4; + + case 5: // rational + case 10: // srational + case 12: // double + return 8; + + default: + // unknown type + return 0; + } +}; + + +// Reads Exif data +// +ExifParser.prototype.exif_format_read = function (format, offset) { + var v; + + switch (format) { + case 1: // byte + case 2: // ascii + v = this.input[offset]; + return v; + + case 6: // sbyte + v = this.input[offset]; + return v | (v & 0x80) * 0x1fffffe; + + case 3: // short + v = this.read_uint16(offset); + return v; + + case 8: // sshort + v = this.read_uint16(offset); + return v | (v & 0x8000) * 0x1fffe; + + case 4: // long + v = this.read_uint32(offset); + return v; + + case 9: // slong + v = this.read_uint32(offset); + return v | 0; + + case 5: // rational + case 10: // srational + case 11: // float + case 12: // double + return null; // not implemented + + case 7: // undefined + return null; // blob + + default: + // unknown type + return null; + } +}; + + +ExifParser.prototype.scan_ifd = function (ifd_no, offset, on_entry) { + var entry_count = this.read_uint16(offset); + + offset += 2; + + for (var i = 0; i < entry_count; i++) { + var tag = this.read_uint16(offset); + var format = this.read_uint16(offset + 2); + var count = this.read_uint32(offset + 4); + + var comp_length = this.exif_format_length(format); + var data_length = count * comp_length; + var data_offset = data_length <= 4 ? offset + 8 : this.read_uint32(offset + 8); + var is_subifd_link = false; + + if (data_offset + data_length > this.input.length) { + throw error('unexpected EOF', 'EBADDATA'); + } + + var value = []; + var comp_offset = data_offset; + + for (var j = 0; j < count; j++, comp_offset += comp_length) { + var item = this.exif_format_read(format, comp_offset); + if (item === null) { + value = null; + break; + } + value.push(item); + } + + if (Array.isArray(value) && format === 2) { + value = utf8_decode(String.fromCharCode.apply(null, value)); + if (value && value[value.length - 1] === '\0') value = value.slice(0, -1); + } + + if (this.is_subifd_link(ifd_no, tag)) { + if (Array.isArray(value) && Number.isInteger(value[0]) && value[0] > 0) { + this.ifds_to_read.push({ + id: tag, + offset: value[0] + }); + is_subifd_link = true; + } + } + + var entry = { + is_big_endian: this.big_endian, + ifd: ifd_no, + tag: tag, + format: format, + count: count, + entry_offset: offset + this.start, + data_length: data_length, + data_offset: data_offset + this.start, + value: value, + is_subifd_link: is_subifd_link + }; + + if (on_entry(entry) === false) { + this.aborted = true; + return; + } + + offset += 12; + } + + if (ifd_no === 0) { + this.ifds_to_read.push({ + id: 1, + offset: this.read_uint32(offset) + }); + } +}; + + +module.exports.ExifParser = ExifParser; + +// returns orientation stored in Exif (1-8), 0 if none was found, -1 if error +module.exports.get_orientation = function (data) { + var orientation = 0; + try { + new ExifParser(data, 0, data.length).each(function (entry) { + if (entry.ifd === 0 && entry.tag === 0x112 && Array.isArray(entry.value)) { + orientation = entry.value[0]; + return false; + } + }); + return orientation; + } catch (err) { + return -1; + } +}; + +},{}],83:[function(_dereq_,module,exports){ +// Utils used to parse miaf-based files (avif/heic/heif) +// +// ISO media file spec: +// https://web.archive.org/web/20180219054429/http://l.web.umkc.edu/lizhu/teaching/2016sp.video-communication/ref/mp4.pdf +// +// ISO image file format spec: +// https://standards.iso.org/ittf/PubliclyAvailableStandards/c066067_ISO_IEC_23008-12_2017.zip +// + +'use strict'; + +/* eslint-disable consistent-return */ +/* eslint-disable no-bitwise */ + +var readUInt16BE = _dereq_('./common').readUInt16BE; +var readUInt32BE = _dereq_('./common').readUInt32BE; + +/* + * interface Box { + * size: uint32; // if size == 0, box lasts until EOF + * boxtype: char[4]; + * largesize?: uint64; // only if size == 1 + * usertype?: char[16]; // only if boxtype == 'uuid' + * } + */ +function unbox(data, offset) { + if (data.length < 4 + offset) return null; + + var size = readUInt32BE(data, offset); + + // size includes first 4 bytes (length) + if (data.length < size + offset || size < 8) return null; + + // if size === 1, real size is following uint64 (only for big boxes, not needed) + // if size === 0, real size is until the end of the file (only for big boxes, not needed) + + return { + boxtype: String.fromCharCode.apply(null, data.slice(offset + 4, offset + 8)), + data: data.slice(offset + 8, offset + size), + end: offset + size + }; +} + + +module.exports.unbox = unbox; + + +// parses `meta` -> `iprp` -> `ipco` box, returns: +// { +// sizes: [ { width, height } ], +// transforms: [ { type, value } ] +// } +function scan_ipco(data, sandbox) { + var offset = 0; + + for (;;) { + var box = unbox(data, offset); + if (!box) break; + + switch (box.boxtype) { + case 'ispe': + sandbox.sizes.push({ + width: readUInt32BE(box.data, 4), + height: readUInt32BE(box.data, 8) + }); + break; + + case 'irot': + sandbox.transforms.push({ + type: 'irot', + value: box.data[0] & 3 + }); + break; + + case 'imir': + sandbox.transforms.push({ + type: 'imir', + value: box.data[0] & 1 + }); + break; + } + + offset = box.end; + } +} + + +function readUIntBE(data, offset, size) { + var result = 0; + + for (var i = 0; i < size; i++) { + result = result * 256 + (data[offset + i] || 0); + } + + return result; +} + + +// parses `meta` -> `iloc` box +function scan_iloc(data, sandbox) { + var offset_size = (data[4] >> 4) & 0xF; + var length_size = data[4] & 0xF; + var base_offset_size = (data[5] >> 4) & 0xF; + var item_count = readUInt16BE(data, 6); + var offset = 8; + + for (var i = 0; i < item_count; i++) { + var item_ID = readUInt16BE(data, offset); + offset += 2; + + var data_reference_index = readUInt16BE(data, offset); + offset += 2; + + var base_offset = readUIntBE(data, offset, base_offset_size); + offset += base_offset_size; + + var extent_count = readUInt16BE(data, offset); + offset += 2; + + if (data_reference_index === 0 && extent_count === 1) { + var first_extent_offset = readUIntBE(data, offset, offset_size); + var first_extent_length = readUIntBE(data, offset + offset_size, length_size); + sandbox.item_loc[item_ID] = { length: first_extent_length, offset: first_extent_offset + base_offset }; + } + + offset += extent_count * (offset_size + length_size); + } +} + + +// parses `meta` -> `iinf` box +function scan_iinf(data, sandbox) { + var item_count = readUInt16BE(data, 4); + var offset = 6; + + for (var i = 0; i < item_count; i++) { + var box = unbox(data, offset); + if (!box) break; + if (box.boxtype === 'infe') { + var item_id = readUInt16BE(box.data, 4); + var item_name = ''; + + for (var pos = 8; pos < box.data.length && box.data[pos]; pos++) { + item_name += String.fromCharCode(box.data[pos]); + } + + sandbox.item_inf[item_name] = item_id; + } + offset = box.end; + } +} + + +// parses `meta` -> `iprp` box +function scan_iprp(data, sandbox) { + var offset = 0; + + for (;;) { + var box = unbox(data, offset); + if (!box) break; + if (box.boxtype === 'ipco') scan_ipco(box.data, sandbox); + offset = box.end; + } +} + + +// parses `meta` box +function scan_meta(data, sandbox) { + var offset = 4; // version + flags + + for (;;) { + var box = unbox(data, offset); + if (!box) break; + if (box.boxtype === 'iprp') scan_iprp(box.data, sandbox); + if (box.boxtype === 'iloc') scan_iloc(box.data, sandbox); + if (box.boxtype === 'iinf') scan_iinf(box.data, sandbox); + offset = box.end; + } +} + + +// get image with largest single dimension as base +function getMaxSize(sizes) { + var maxWidthSize = sizes.reduce(function (a, b) { + return a.width > b.width || (a.width === b.width && a.height > b.height) ? a : b; + }); + + var maxHeightSize = sizes.reduce(function (a, b) { + return a.height > b.height || (a.height === b.height && a.width > b.width) ? a : b; + }); + + var maxSize; + + if (maxWidthSize.width > maxHeightSize.height || + (maxWidthSize.width === maxHeightSize.height && maxWidthSize.height > maxHeightSize.width)) { + maxSize = maxWidthSize; + } else { + maxSize = maxHeightSize; + } + + return maxSize; +} + + +module.exports.readSizeFromMeta = function (data) { + var sandbox = { + sizes: [], + transforms: [], + item_inf: {}, + item_loc: {} + }; + + scan_meta(data, sandbox); + + if (!sandbox.sizes.length) return; + + var maxSize = getMaxSize(sandbox.sizes); + + var orientation = 1; + + // convert imir/irot to exif orientation + sandbox.transforms.forEach(function (transform) { + var rotate_ccw = { 1: 6, 2: 5, 3: 8, 4: 7, 5: 4, 6: 3, 7: 2, 8: 1 }; + var mirror_vert = { 1: 4, 2: 3, 3: 2, 4: 1, 5: 6, 6: 5, 7: 8, 8: 7 }; + + if (transform.type === 'imir') { + if (transform.value === 0) { + // vertical flip + orientation = mirror_vert[orientation]; + } else { + // horizontal flip = vertical flip + 180 deg rotation + orientation = mirror_vert[orientation]; + orientation = rotate_ccw[orientation]; + orientation = rotate_ccw[orientation]; + } + } + + if (transform.type === 'irot') { + // counter-clockwise rotation 90 deg 0-3 times + for (var i = 0; i < transform.value; i++) { + orientation = rotate_ccw[orientation]; + } + } + }); + + var exif_location = null; + + if (sandbox.item_inf.Exif) { + exif_location = sandbox.item_loc[sandbox.item_inf.Exif]; + } + + return { + width: maxSize.width, + height: maxSize.height, + orientation: sandbox.transforms.length ? orientation : null, + variants: sandbox.sizes, + exif_location: exif_location + }; +}; + + +module.exports.getMimeType = function (data) { + var brand = String.fromCharCode.apply(null, data.slice(0, 4)); + var compat = {}; + + compat[brand] = true; + + for (var i = 8; i < data.length; i += 4) { + compat[String.fromCharCode.apply(null, data.slice(i, i + 4))] = true; + } + + // heic and avif are superset of miaf, so they should all list mif1 as compatible + if (!compat.mif1 && !compat.msf1 && !compat.miaf) return; + + if (brand === 'avif' || brand === 'avis' || brand === 'avio') { + // `.avifs` and `image/avif-sequence` are removed from spec, all files have single type + return { type: 'avif', mime: 'image/avif' }; + } + + // https://nokiatech.github.io/heif/technical.html + if (brand === 'heic' || brand === 'heix') { + return { type: 'heic', mime: 'image/heic' }; + } + + if (brand === 'hevc' || brand === 'hevx') { + return { type: 'heic', mime: 'image/heic-sequence' }; + } + + if (compat.avif || compat.avis) { + return { type: 'avif', mime: 'image/avif' }; + } + + if (compat.heic || compat.heix || compat.hevc || compat.hevx || compat.heis) { + if (compat.msf1) { + return { type: 'heif', mime: 'image/heif-sequence' }; + } + return { type: 'heif', mime: 'image/heif' }; + } + + return { type: 'avif', mime: 'image/avif' }; +}; + +},{"./common":81}],84:[function(_dereq_,module,exports){ +// Utils used to parse miaf-based files (avif/heic/heif) +// +// - image collections are not supported (only last size is reported) +// - images with metadata encoded after image data are not supported +// - images without any `ispe` box are not supported +// + +/* eslint-disable consistent-return */ + +'use strict'; + + +var str2arr = _dereq_('../common').str2arr; +var sliceEq = _dereq_('../common').sliceEq; +var readUInt32BE = _dereq_('../common').readUInt32BE; +var miaf = _dereq_('../miaf_utils'); +var exif = _dereq_('../exif_utils'); + +var SIG_FTYP = str2arr('ftyp'); + + +module.exports = function (data) { + // ISO media file (avif format) starts with ftyp box: + // 0000 0020 6674 7970 6176 6966 + // (length) f t y p a v i f + // + if (!sliceEq(data, 4, SIG_FTYP)) return; + + var firstBox = miaf.unbox(data, 0); + if (!firstBox) return; + + var fileType = miaf.getMimeType(firstBox.data); + if (!fileType) return; + + var meta, offset = firstBox.end; + + for (;;) { + var box = miaf.unbox(data, offset); + if (!box) break; + offset = box.end; + + // mdat block SHOULD be last (but not strictly required), + // so it's unlikely that metadata is after it + if (box.boxtype === 'mdat') return; + if (box.boxtype === 'meta') { + meta = box.data; + break; + } + } + + if (!meta) return; + + var imgSize = miaf.readSizeFromMeta(meta); + + if (!imgSize) return; + + var result = { + width: imgSize.width, + height: imgSize.height, + type: fileType.type, + mime: fileType.mime, + wUnits: 'px', + hUnits: 'px' + }; + + if (imgSize.variants.length > 1) { + result.variants = imgSize.variants; + } + + if (imgSize.orientation) { + result.orientation = imgSize.orientation; + } + + if (imgSize.exif_location && + imgSize.exif_location.offset + imgSize.exif_location.length <= data.length) { + + var sig_offset = readUInt32BE(data, imgSize.exif_location.offset); + var exif_data = data.slice( + imgSize.exif_location.offset + sig_offset + 4, + imgSize.exif_location.offset + imgSize.exif_location.length); + + var orientation = exif.get_orientation(exif_data); + + if (orientation > 0) result.orientation = orientation; + } + + return result; +}; + +},{"../common":81,"../exif_utils":82,"../miaf_utils":83}],85:[function(_dereq_,module,exports){ +'use strict'; + +/* eslint-disable consistent-return */ + +var str2arr = _dereq_('../common').str2arr; +var sliceEq = _dereq_('../common').sliceEq; +var readUInt16LE = _dereq_('../common').readUInt16LE; + +var SIG_BM = str2arr('BM'); + + +module.exports = function (data) { + if (data.length < 26) return; + + if (!sliceEq(data, 0, SIG_BM)) return; + + return { + width: readUInt16LE(data, 18), + height: readUInt16LE(data, 22), + type: 'bmp', + mime: 'image/bmp', + wUnits: 'px', + hUnits: 'px' + }; +}; + +},{"../common":81}],86:[function(_dereq_,module,exports){ +'use strict'; + +/* eslint-disable consistent-return */ + +var str2arr = _dereq_('../common').str2arr; +var sliceEq = _dereq_('../common').sliceEq; +var readUInt16LE = _dereq_('../common').readUInt16LE; + + +var SIG_GIF87a = str2arr('GIF87a'); +var SIG_GIF89a = str2arr('GIF89a'); + + +module.exports = function (data) { + if (data.length < 10) return; + + if (!sliceEq(data, 0, SIG_GIF87a) && !sliceEq(data, 0, SIG_GIF89a)) return; + + return { + width: readUInt16LE(data, 6), + height: readUInt16LE(data, 8), + type: 'gif', + mime: 'image/gif', + wUnits: 'px', + hUnits: 'px' + }; +}; + +},{"../common":81}],87:[function(_dereq_,module,exports){ +'use strict'; + +/* eslint-disable consistent-return */ + +var readUInt16LE = _dereq_('../common').readUInt16LE; + +var HEADER = 0; +var TYPE_ICO = 1; +var INDEX_SIZE = 16; + +// Format specification: +// https://en.wikipedia.org/wiki/ICO_(file_format)#Icon_resource_structure +module.exports = function (data) { + var header = readUInt16LE(data, 0); + var type = readUInt16LE(data, 2); + var numImages = readUInt16LE(data, 4); + + if (header !== HEADER || type !== TYPE_ICO || !numImages) { + return; + } + + var variants = []; + var maxSize = { width: 0, height: 0 }; + + for (var i = 0; i < numImages; i++) { + var width = data[6 + INDEX_SIZE * i] || 256; + var height = data[6 + INDEX_SIZE * i + 1] || 256; + var size = { width: width, height: height }; + variants.push(size); + + if (width > maxSize.width || height > maxSize.height) { + maxSize = size; + } + } + + return { + width: maxSize.width, + height: maxSize.height, + variants: variants, + type: 'ico', + mime: 'image/x-icon', + wUnits: 'px', + hUnits: 'px' + }; +}; + +},{"../common":81}],88:[function(_dereq_,module,exports){ +'use strict'; + +/* eslint-disable consistent-return */ + +var readUInt16BE = _dereq_('../common').readUInt16BE; +var str2arr = _dereq_('../common').str2arr; +var sliceEq = _dereq_('../common').sliceEq; +var exif = _dereq_('../exif_utils'); + + +var SIG_EXIF = str2arr('Exif\0\0'); + + +module.exports = function (data) { + if (data.length < 2) return; + + // first marker of the file MUST be 0xFFD8 + if (data[0] !== 0xFF || data[1] !== 0xD8) return; + + var offset = 2; + + for (;;) { + if (data.length - offset < 2) return; + // not a JPEG marker + if (data[offset++] !== 0xFF) return; + + var code = data[offset++]; + var length; + + // skip padding bytes + while (code === 0xFF) code = data[offset++]; + + // standalone markers, according to JPEG 1992, + // http://www.w3.org/Graphics/JPEG/itu-t81.pdf, see Table B.1 + if ((0xD0 <= code && code <= 0xD9) || code === 0x01) { + length = 0; + } else if (0xC0 <= code && code <= 0xFE) { + // the rest of the unreserved markers + if (data.length - offset < 2) return; + + length = readUInt16BE(data, offset) - 2; + offset += 2; + } else { + // unknown markers + return; + } + + if (code === 0xD9 /* EOI */ || code === 0xDA /* SOS */) { + // end of the datastream + return; + } + + var orientation; + + // try to get orientation from Exif segment + if (code === 0xE1 && length >= 10 && sliceEq(data, offset, SIG_EXIF)) { + orientation = exif.get_orientation(data.slice(offset + 6, offset + length)); + } + + if (length >= 5 && + (0xC0 <= code && code <= 0xCF) && + code !== 0xC4 && code !== 0xC8 && code !== 0xCC) { + + if (data.length - offset < length) return; + + var result = { + width: readUInt16BE(data, offset + 3), + height: readUInt16BE(data, offset + 1), + type: 'jpg', + mime: 'image/jpeg', + wUnits: 'px', + hUnits: 'px' + }; + + if (orientation > 0) { + result.orientation = orientation; + } + + return result; + } + + offset += length; + } +}; + +},{"../common":81,"../exif_utils":82}],89:[function(_dereq_,module,exports){ +'use strict'; + +/* eslint-disable consistent-return */ + +var str2arr = _dereq_('../common').str2arr; +var sliceEq = _dereq_('../common').sliceEq; +var readUInt32BE = _dereq_('../common').readUInt32BE; + + +var SIG_PNG = str2arr('\x89PNG\r\n\x1a\n'); +var SIG_IHDR = str2arr('IHDR'); + + +module.exports = function (data) { + if (data.length < 24) return; + + // check PNG signature + if (!sliceEq(data, 0, SIG_PNG)) return; + + // check that first chunk is IHDR + if (!sliceEq(data, 12, SIG_IHDR)) return; + + return { + width: readUInt32BE(data, 16), + height: readUInt32BE(data, 20), + type: 'png', + mime: 'image/png', + wUnits: 'px', + hUnits: 'px' + }; +}; + +},{"../common":81}],90:[function(_dereq_,module,exports){ +'use strict'; + +/* eslint-disable consistent-return */ + +var str2arr = _dereq_('../common').str2arr; +var sliceEq = _dereq_('../common').sliceEq; +var readUInt32BE = _dereq_('../common').readUInt32BE; + + +var SIG_8BPS = str2arr('8BPS\x00\x01'); + + +module.exports = function (data) { + if (data.length < 6 + 16) return; + + // signature + version + if (!sliceEq(data, 0, SIG_8BPS)) return; + + return { + width: readUInt32BE(data, 6 + 12), + height: readUInt32BE(data, 6 + 8), + type: 'psd', + mime: 'image/vnd.adobe.photoshop', + wUnits: 'px', + hUnits: 'px' + }; +}; + +},{"../common":81}],91:[function(_dereq_,module,exports){ +'use strict'; + +/* eslint-disable consistent-return */ + +function isWhiteSpace(chr) { + return chr === 0x20 || chr === 0x09 || chr === 0x0D || chr === 0x0A; +} + +// Filter NaN, Infinity, < 0 +function isFinitePositive(val) { + return typeof val === 'number' && isFinite(val) && val > 0; +} + +function canBeSvg(buf) { + var i = 0, max = buf.length; + + while (i < max && isWhiteSpace(buf[i])) i++; + + if (i === max) return false; + return buf[i] === 0x3c; /* < */ +} + + +var SVG_HEADER_RE = /]+>/; +var SVG_WIDTH_RE = /[^-]\bwidth="([^%]+?)"|[^-]\bwidth='([^%]+?)'/; +var SVG_HEIGHT_RE = /\bheight="([^%]+?)"|\bheight='([^%]+?)'/; +var SVG_VIEWBOX_RE = /\bview[bB]ox="(.+?)"|\bview[bB]ox='(.+?)'/; +var SVG_UNITS_RE = /in$|mm$|cm$|pt$|pc$|px$|em$|ex$/; + +function svgAttrs(str) { + var width = str.match(SVG_WIDTH_RE); + var height = str.match(SVG_HEIGHT_RE); + var viewbox = str.match(SVG_VIEWBOX_RE); + + return { + width: width && (width[1] || width[2]), + height: height && (height[1] || height[2]), + viewbox: viewbox && (viewbox[1] || viewbox[2]) + }; +} + + +function units(str) { + if (!SVG_UNITS_RE.test(str)) return 'px'; + + return str.match(SVG_UNITS_RE)[0]; +} + + +module.exports = function (data) { + if (!canBeSvg(data)) return; + + var str = ''; + + for (var i = 0; i < data.length; i++) { + // 1. We can't rely on buffer features + // 2. Don't care about UTF16 because ascii is enougth for our goals + str += String.fromCharCode(data[i]); + } + + if (!SVG_HEADER_RE.test(str)) return; + + var attrs = svgAttrs(str.match(SVG_HEADER_RE)[0]); + var width = parseFloat(attrs.width); + var height = parseFloat(attrs.height); + + // Extract from direct values + + if (attrs.width && attrs.height) { + if (!isFinitePositive(width) || !isFinitePositive(height)) return; + + return { + width: width, + height: height, + type: 'svg', + mime: 'image/svg+xml', + wUnits: units(attrs.width), + hUnits: units(attrs.height) + }; + } + + // Extract from viewbox + + var parts = (attrs.viewbox || '').split(' '); + var viewbox = { + width: parts[2], + height: parts[3] + }; + var vbWidth = parseFloat(viewbox.width); + var vbHeight = parseFloat(viewbox.height); + + if (!isFinitePositive(vbWidth) || !isFinitePositive(vbHeight)) return; + if (units(viewbox.width) !== units(viewbox.height)) return; + + var ratio = vbWidth / vbHeight; + + if (attrs.width) { + if (!isFinitePositive(width)) return; + + return { + width: width, + height: width / ratio, + type: 'svg', + mime: 'image/svg+xml', + wUnits: units(attrs.width), + hUnits: units(attrs.width) + }; + } + + if (attrs.height) { + if (!isFinitePositive(height)) return; + + return { + width: height * ratio, + height: height, + type: 'svg', + mime: 'image/svg+xml', + wUnits: units(attrs.height), + hUnits: units(attrs.height) + }; + } + + return { + width: vbWidth, + height: vbHeight, + type: 'svg', + mime: 'image/svg+xml', + wUnits: units(viewbox.width), + hUnits: units(viewbox.height) + }; +}; + +},{}],92:[function(_dereq_,module,exports){ +'use strict'; + +/* eslint-disable consistent-return */ + +var str2arr = _dereq_('../common').str2arr; +var sliceEq = _dereq_('../common').sliceEq; +var readUInt16LE = _dereq_('../common').readUInt16LE; +var readUInt16BE = _dereq_('../common').readUInt16BE; +var readUInt32LE = _dereq_('../common').readUInt32LE; +var readUInt32BE = _dereq_('../common').readUInt32BE; + + +var SIG_1 = str2arr('II\x2A\0'); +var SIG_2 = str2arr('MM\0\x2A'); + + +function readUInt16(buffer, offset, is_big_endian) { + return is_big_endian ? readUInt16BE(buffer, offset) : readUInt16LE(buffer, offset); +} + +function readUInt32(buffer, offset, is_big_endian) { + return is_big_endian ? readUInt32BE(buffer, offset) : readUInt32LE(buffer, offset); +} + +function readIFDValue(data, data_offset, is_big_endian) { + var type = readUInt16(data, data_offset + 2, is_big_endian); + var values = readUInt32(data, data_offset + 4, is_big_endian); + + if (values !== 1 || (type !== 3 && type !== 4)) return null; + + if (type === 3) { + return readUInt16(data, data_offset + 8, is_big_endian); + } + + return readUInt32(data, data_offset + 8, is_big_endian); +} + +module.exports = function (data) { + if (data.length < 8) return; + + // check TIFF signature + if (!sliceEq(data, 0, SIG_1) && !sliceEq(data, 0, SIG_2)) return; + + var is_big_endian = (data[0] === 77 /* 'MM' */); + var count = readUInt32(data, 4, is_big_endian) - 8; + + if (count < 0) return; + + // skip until IFD + var offset = count + 8; + + if (data.length - offset < 2) return; + + // read number of IFD entries + var ifd_size = readUInt16(data, offset + 0, is_big_endian) * 12; + + if (ifd_size <= 0) return; + + offset += 2; + + // read all IFD entries + if (data.length - offset < ifd_size) return; + + var i, width, height, tag; + + for (i = 0; i < ifd_size; i += 12) { + tag = readUInt16(data, offset + i, is_big_endian); + + if (tag === 256) { + width = readIFDValue(data, offset + i, is_big_endian); + } else if (tag === 257) { + height = readIFDValue(data, offset + i, is_big_endian); + } + } + + if (width && height) { + return { + width: width, + height: height, + type: 'tiff', + mime: 'image/tiff', + wUnits: 'px', + hUnits: 'px' + }; + } +}; + +},{"../common":81}],93:[function(_dereq_,module,exports){ +'use strict'; + +/* eslint-disable no-bitwise */ +/* eslint-disable consistent-return */ + +var str2arr = _dereq_('../common').str2arr; +var sliceEq = _dereq_('../common').sliceEq; +var readUInt16LE = _dereq_('../common').readUInt16LE; +var readUInt32LE = _dereq_('../common').readUInt32LE; +var exif = _dereq_('../exif_utils'); + + +var SIG_RIFF = str2arr('RIFF'); +var SIG_WEBP = str2arr('WEBP'); + + +function parseVP8(data, offset) { + if (data[offset + 3] !== 0x9D || data[offset + 4] !== 0x01 || data[offset + 5] !== 0x2A) { + // bad code block signature + return; + } + + return { + width: readUInt16LE(data, offset + 6) & 0x3FFF, + height: readUInt16LE(data, offset + 8) & 0x3FFF, + type: 'webp', + mime: 'image/webp', + wUnits: 'px', + hUnits: 'px' + }; +} + + +function parseVP8L(data, offset) { + if (data[offset] !== 0x2F) return; + + var bits = readUInt32LE(data, offset + 1); + + return { + width: (bits & 0x3FFF) + 1, + height: ((bits >> 14) & 0x3FFF) + 1, + type: 'webp', + mime: 'image/webp', + wUnits: 'px', + hUnits: 'px' + }; +} + + +function parseVP8X(data, offset) { + return { + // TODO: replace with `data.readUIntLE(8, 3) + 1` + // when 0.10 support is dropped + width: ((data[offset + 6] << 16) | (data[offset + 5] << 8) | data[offset + 4]) + 1, + height: ((data[offset + 9] << offset) | (data[offset + 8] << 8) | data[offset + 7]) + 1, + type: 'webp', + mime: 'image/webp', + wUnits: 'px', + hUnits: 'px' + }; +} + + +module.exports = function (data) { + if (data.length < 16) return; + + // check /^RIFF....WEBPVP8([ LX])$/ signature + if (!sliceEq(data, 0, SIG_RIFF) && !sliceEq(data, 8, SIG_WEBP)) return; + + var offset = 12; + var result = null; + var exif_orientation = 0; + var fileLength = readUInt32LE(data, 4) + 8; + + if (fileLength > data.length) return; + + while (offset + 8 < fileLength) { + if (data[offset] === 0) { + // after each chunk of odd size there should be 0 byte of padding, skip those + offset++; + continue; + } + + var header = String.fromCharCode.apply(null, data.slice(offset, offset + 4)); + var length = readUInt32LE(data, offset + 4); + + if (header === 'VP8 ' && length >= 10) { + result = result || parseVP8(data, offset + 8); + } else if (header === 'VP8L' && length >= 9) { + result = result || parseVP8L(data, offset + 8); + } else if (header === 'VP8X' && length >= 10) { + result = result || parseVP8X(data, offset + 8); + } else if (header === 'EXIF') { + exif_orientation = exif.get_orientation(data.slice(offset + 8, offset + 8 + length)); + + // exif is the last chunk we care about, stop after it + offset = Infinity; + } + + offset += 8 + length; + } + + if (!result) return; + + if (exif_orientation > 0) { + result.orientation = exif_orientation; + } + + return result; +}; + +},{"../common":81,"../exif_utils":82}],94:[function(_dereq_,module,exports){ +'use strict'; + + +module.exports = { + avif: _dereq_('./parse_sync/avif'), + bmp: _dereq_('./parse_sync/bmp'), + gif: _dereq_('./parse_sync/gif'), + ico: _dereq_('./parse_sync/ico'), + jpeg: _dereq_('./parse_sync/jpeg'), + png: _dereq_('./parse_sync/png'), + psd: _dereq_('./parse_sync/psd'), + svg: _dereq_('./parse_sync/svg'), + tiff: _dereq_('./parse_sync/tiff'), + webp: _dereq_('./parse_sync/webp') +}; + +},{"./parse_sync/avif":84,"./parse_sync/bmp":85,"./parse_sync/gif":86,"./parse_sync/ico":87,"./parse_sync/jpeg":88,"./parse_sync/png":89,"./parse_sync/psd":90,"./parse_sync/svg":91,"./parse_sync/tiff":92,"./parse_sync/webp":93}],95:[function(_dereq_,module,exports){ +'use strict'; + + +var parsers = _dereq_('./lib/parsers_sync'); + + +function probeBuffer(buffer) { + var parser_names = Object.keys(parsers); + + for (var i = 0; i < parser_names.length; i++) { + var result = parsers[parser_names[i]](buffer); + + if (result) return result; + } + + return null; +} + + +/////////////////////////////////////////////////////////////////////// +// Exports +// + +module.exports = function get_image_size(src) { + return probeBuffer(src); +}; + +module.exports.parsers = parsers; + +},{"./lib/parsers_sync":94}],96:[function(_dereq_,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -19344,7 +19605,4538 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],88:[function(_dereq_,module,exports){ +},{}],97:[function(_dereq_,module,exports){ +/* eslint-disable node/no-deprecated-api */ +var buffer = _dereq_('buffer') +var Buffer = buffer.Buffer + +// alternative to using Object.keys for old browsers +function copyProps (src, dst) { + for (var key in src) { + dst[key] = src[key] + } +} +if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { + module.exports = buffer +} else { + // Copy properties from require('buffer') + copyProps(buffer, exports) + exports.Buffer = SafeBuffer +} + +function SafeBuffer (arg, encodingOrOffset, length) { + return Buffer(arg, encodingOrOffset, length) +} + +SafeBuffer.prototype = Object.create(Buffer.prototype) + +// Copy static methods from Buffer +copyProps(Buffer, SafeBuffer) + +SafeBuffer.from = function (arg, encodingOrOffset, length) { + if (typeof arg === 'number') { + throw new TypeError('Argument must not be a number') + } + return Buffer(arg, encodingOrOffset, length) +} + +SafeBuffer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + var buf = Buffer(size) + if (fill !== undefined) { + if (typeof encoding === 'string') { + buf.fill(fill, encoding) + } else { + buf.fill(fill) + } + } else { + buf.fill(0) + } + return buf +} + +SafeBuffer.allocUnsafe = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return Buffer(size) +} + +SafeBuffer.allocUnsafeSlow = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return buffer.SlowBuffer(size) +} + +},{"buffer":28}],98:[function(_dereq_,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +module.exports = Stream; + +var EE = _dereq_('events').EventEmitter; +var inherits = _dereq_('inherits'); + +inherits(Stream, EE); +Stream.Readable = _dereq_('readable-stream/lib/_stream_readable.js'); +Stream.Writable = _dereq_('readable-stream/lib/_stream_writable.js'); +Stream.Duplex = _dereq_('readable-stream/lib/_stream_duplex.js'); +Stream.Transform = _dereq_('readable-stream/lib/_stream_transform.js'); +Stream.PassThrough = _dereq_('readable-stream/lib/_stream_passthrough.js'); +Stream.finished = _dereq_('readable-stream/lib/internal/streams/end-of-stream.js') +Stream.pipeline = _dereq_('readable-stream/lib/internal/streams/pipeline.js') + +// Backwards-compat with node 0.4.x +Stream.Stream = Stream; + + + +// old-style streams. Note that the pipe method (the only relevant +// part of this class) is overridden in the Readable class. + +function Stream() { + EE.call(this); +} + +Stream.prototype.pipe = function(dest, options) { + var source = this; + + function ondata(chunk) { + if (dest.writable) { + if (false === dest.write(chunk) && source.pause) { + source.pause(); + } + } + } + + source.on('data', ondata); + + function ondrain() { + if (source.readable && source.resume) { + source.resume(); + } + } + + dest.on('drain', ondrain); + + // If the 'end' option is not supplied, dest.end() will be called when + // source gets the 'end' or 'close' events. Only dest.end() once. + if (!dest._isStdio && (!options || options.end !== false)) { + source.on('end', onend); + source.on('close', onclose); + } + + var didOnEnd = false; + function onend() { + if (didOnEnd) return; + didOnEnd = true; + + dest.end(); + } + + + function onclose() { + if (didOnEnd) return; + didOnEnd = true; + + if (typeof dest.destroy === 'function') dest.destroy(); + } + + // don't leave dangling pipes when there are errors. + function onerror(er) { + cleanup(); + if (EE.listenerCount(this, 'error') === 0) { + throw er; // Unhandled stream error in pipe. + } + } + + source.on('error', onerror); + dest.on('error', onerror); + + // remove all the event listeners that were added. + function cleanup() { + source.removeListener('data', ondata); + dest.removeListener('drain', ondrain); + + source.removeListener('end', onend); + source.removeListener('close', onclose); + + source.removeListener('error', onerror); + dest.removeListener('error', onerror); + + source.removeListener('end', cleanup); + source.removeListener('close', cleanup); + + dest.removeListener('close', cleanup); + } + + source.on('end', cleanup); + source.on('close', cleanup); + + dest.on('close', cleanup); + + dest.emit('pipe', source); + + // Allow for unix-like usage: A.pipe(B).pipe(C) + return dest; +}; + +},{"events":27,"inherits":65,"readable-stream/lib/_stream_duplex.js":100,"readable-stream/lib/_stream_passthrough.js":101,"readable-stream/lib/_stream_readable.js":102,"readable-stream/lib/_stream_transform.js":103,"readable-stream/lib/_stream_writable.js":104,"readable-stream/lib/internal/streams/end-of-stream.js":108,"readable-stream/lib/internal/streams/pipeline.js":110}],99:[function(_dereq_,module,exports){ +'use strict'; + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } + +var codes = {}; + +function createErrorType(code, message, Base) { + if (!Base) { + Base = Error; + } + + function getMessage(arg1, arg2, arg3) { + if (typeof message === 'string') { + return message; + } else { + return message(arg1, arg2, arg3); + } + } + + var NodeError = + /*#__PURE__*/ + function (_Base) { + _inheritsLoose(NodeError, _Base); + + function NodeError(arg1, arg2, arg3) { + return _Base.call(this, getMessage(arg1, arg2, arg3)) || this; + } + + return NodeError; + }(Base); + + NodeError.prototype.name = Base.name; + NodeError.prototype.code = code; + codes[code] = NodeError; +} // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js + + +function oneOf(expected, thing) { + if (Array.isArray(expected)) { + var len = expected.length; + expected = expected.map(function (i) { + return String(i); + }); + + if (len > 2) { + return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1]; + } else if (len === 2) { + return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]); + } else { + return "of ".concat(thing, " ").concat(expected[0]); + } + } else { + return "of ".concat(thing, " ").concat(String(expected)); + } +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith + + +function startsWith(str, search, pos) { + return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search; +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith + + +function endsWith(str, search, this_len) { + if (this_len === undefined || this_len > str.length) { + this_len = str.length; + } + + return str.substring(this_len - search.length, this_len) === search; +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes + + +function includes(str, search, start) { + if (typeof start !== 'number') { + start = 0; + } + + if (start + search.length > str.length) { + return false; + } else { + return str.indexOf(search, start) !== -1; + } +} + +createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) { + return 'The value "' + value + '" is invalid for option "' + name + '"'; +}, TypeError); +createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) { + // determiner: 'must be' or 'must not be' + var determiner; + + if (typeof expected === 'string' && startsWith(expected, 'not ')) { + determiner = 'must not be'; + expected = expected.replace(/^not /, ''); + } else { + determiner = 'must be'; + } + + var msg; + + if (endsWith(name, ' argument')) { + // For cases like 'first argument' + msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type')); + } else { + var type = includes(name, '.') ? 'property' : 'argument'; + msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type')); + } + + msg += ". Received type ".concat(typeof actual); + return msg; +}, TypeError); +createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF'); +createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) { + return 'The ' + name + ' method is not implemented'; +}); +createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close'); +createErrorType('ERR_STREAM_DESTROYED', function (name) { + return 'Cannot call ' + name + ' after a stream was destroyed'; +}); +createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times'); +createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable'); +createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end'); +createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError); +createErrorType('ERR_UNKNOWN_ENCODING', function (arg) { + return 'Unknown encoding: ' + arg; +}, TypeError); +createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event'); +module.exports.codes = codes; + +},{}],100:[function(_dereq_,module,exports){ +(function (process){(function (){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. +// a duplex stream is just a stream that is both readable and writable. +// Since JS doesn't have multiple prototypal inheritance, this class +// prototypally inherits from Readable, and then parasitically from +// Writable. +'use strict'; +/**/ + +var objectKeys = Object.keys || function (obj) { + var keys = []; + + for (var key in obj) { + keys.push(key); + } + + return keys; +}; +/**/ + + +module.exports = Duplex; + +var Readable = _dereq_('./_stream_readable'); + +var Writable = _dereq_('./_stream_writable'); + +_dereq_('inherits')(Duplex, Readable); + +{ + // Allow the keys array to be GC'ed. + var keys = objectKeys(Writable.prototype); + + for (var v = 0; v < keys.length; v++) { + var method = keys[v]; + if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; + } +} + +function Duplex(options) { + if (!(this instanceof Duplex)) return new Duplex(options); + Readable.call(this, options); + Writable.call(this, options); + this.allowHalfOpen = true; + + if (options) { + if (options.readable === false) this.readable = false; + if (options.writable === false) this.writable = false; + + if (options.allowHalfOpen === false) { + this.allowHalfOpen = false; + this.once('end', onend); + } + } +} + +Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.highWaterMark; + } +}); +Object.defineProperty(Duplex.prototype, 'writableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState && this._writableState.getBuffer(); + } +}); +Object.defineProperty(Duplex.prototype, 'writableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.length; + } +}); // the no-half-open enforcer + +function onend() { + // If the writable side ended, then we're ok. + if (this._writableState.ended) return; // no more data can be written. + // But allow more writes to happen in this tick. + + process.nextTick(onEndNT, this); +} + +function onEndNT(self) { + self.end(); +} + +Object.defineProperty(Duplex.prototype, 'destroyed', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + if (this._readableState === undefined || this._writableState === undefined) { + return false; + } + + return this._readableState.destroyed && this._writableState.destroyed; + }, + set: function set(value) { + // we ignore the value if the stream + // has not been initialized yet + if (this._readableState === undefined || this._writableState === undefined) { + return; + } // backward compatibility, the user is explicitly + // managing destroyed + + + this._readableState.destroyed = value; + this._writableState.destroyed = value; + } +}); +}).call(this)}).call(this,_dereq_('_process')) +},{"./_stream_readable":102,"./_stream_writable":104,"_process":96,"inherits":65}],101:[function(_dereq_,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. +// a passthrough stream. +// basically just the most minimal sort of Transform stream. +// Every written chunk gets output as-is. +'use strict'; + +module.exports = PassThrough; + +var Transform = _dereq_('./_stream_transform'); + +_dereq_('inherits')(PassThrough, Transform); + +function PassThrough(options) { + if (!(this instanceof PassThrough)) return new PassThrough(options); + Transform.call(this, options); +} + +PassThrough.prototype._transform = function (chunk, encoding, cb) { + cb(null, chunk); +}; +},{"./_stream_transform":103,"inherits":65}],102:[function(_dereq_,module,exports){ +(function (process,global){(function (){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + +module.exports = Readable; +/**/ + +var Duplex; +/**/ + +Readable.ReadableState = ReadableState; +/**/ + +var EE = _dereq_('events').EventEmitter; + +var EElistenerCount = function EElistenerCount(emitter, type) { + return emitter.listeners(type).length; +}; +/**/ + +/**/ + + +var Stream = _dereq_('./internal/streams/stream'); +/**/ + + +var Buffer = _dereq_('buffer').Buffer; + +var OurUint8Array = global.Uint8Array || function () {}; + +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} + +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} +/**/ + + +var debugUtil = _dereq_('util'); + +var debug; + +if (debugUtil && debugUtil.debuglog) { + debug = debugUtil.debuglog('stream'); +} else { + debug = function debug() {}; +} +/**/ + + +var BufferList = _dereq_('./internal/streams/buffer_list'); + +var destroyImpl = _dereq_('./internal/streams/destroy'); + +var _require = _dereq_('./internal/streams/state'), + getHighWaterMark = _require.getHighWaterMark; + +var _require$codes = _dereq_('../errors').codes, + ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, + ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF, + ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, + ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; // Lazy loaded to improve the startup performance. + + +var StringDecoder; +var createReadableStreamAsyncIterator; +var from; + +_dereq_('inherits')(Readable, Stream); + +var errorOrDestroy = destroyImpl.errorOrDestroy; +var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; + +function prependListener(emitter, event, fn) { + // Sadly this is not cacheable as some libraries bundle their own + // event emitter implementation with them. + if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); // This is a hack to make sure that our error handler is attached before any + // userland ones. NEVER DO THIS. This is here only because this code needs + // to continue to work with older versions of Node.js that do not include + // the prependListener() method. The goal is to eventually remove this hack. + + if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; +} + +function ReadableState(options, stream, isDuplex) { + Duplex = Duplex || _dereq_('./_stream_duplex'); + options = options || {}; // Duplex streams are both readable and writable, but share + // the same options object. + // However, some cases require setting options to different + // values for the readable and the writable sides of the duplex stream. + // These options can be provided separately as readableXXX and writableXXX. + + if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag. Used to make read(n) ignore n and to + // make all the buffer merging and length checks go away + + this.objectMode = !!options.objectMode; + if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer + // Note: 0 is a valid value, means "don't call _read preemptively ever" + + this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex); // A linked list is used to store data chunks instead of an array because the + // linked list can remove elements from the beginning faster than + // array.shift() + + this.buffer = new BufferList(); + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = null; + this.ended = false; + this.endEmitted = false; + this.reading = false; // a flag to be able to tell if the event 'readable'/'data' is emitted + // immediately, or on a later tick. We set this to true at first, because + // any actions that shouldn't happen until "later" should generally also + // not happen before the first read call. + + this.sync = true; // whenever we return null, then we set a flag to say + // that we're awaiting a 'readable' event emission. + + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + this.resumeScheduled = false; + this.paused = true; // Should close be emitted on destroy. Defaults to true. + + this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'end' (and potentially 'finish') + + this.autoDestroy = !!options.autoDestroy; // has it been destroyed + + this.destroyed = false; // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + + this.defaultEncoding = options.defaultEncoding || 'utf8'; // the number of writers that are awaiting a drain event in .pipe()s + + this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled + + this.readingMore = false; + this.decoder = null; + this.encoding = null; + + if (options.encoding) { + if (!StringDecoder) StringDecoder = _dereq_('string_decoder/').StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } +} + +function Readable(options) { + Duplex = Duplex || _dereq_('./_stream_duplex'); + if (!(this instanceof Readable)) return new Readable(options); // Checking for a Stream.Duplex instance is faster here instead of inside + // the ReadableState constructor, at least with V8 6.5 + + var isDuplex = this instanceof Duplex; + this._readableState = new ReadableState(options, this, isDuplex); // legacy + + this.readable = true; + + if (options) { + if (typeof options.read === 'function') this._read = options.read; + if (typeof options.destroy === 'function') this._destroy = options.destroy; + } + + Stream.call(this); +} + +Object.defineProperty(Readable.prototype, 'destroyed', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + if (this._readableState === undefined) { + return false; + } + + return this._readableState.destroyed; + }, + set: function set(value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._readableState) { + return; + } // backward compatibility, the user is explicitly + // managing destroyed + + + this._readableState.destroyed = value; + } +}); +Readable.prototype.destroy = destroyImpl.destroy; +Readable.prototype._undestroy = destroyImpl.undestroy; + +Readable.prototype._destroy = function (err, cb) { + cb(err); +}; // Manually shove something into the read() buffer. +// This returns true if the highWaterMark has not been hit yet, +// similar to how Writable.write() returns true if you should +// write() some more. + + +Readable.prototype.push = function (chunk, encoding) { + var state = this._readableState; + var skipChunkCheck; + + if (!state.objectMode) { + if (typeof chunk === 'string') { + encoding = encoding || state.defaultEncoding; + + if (encoding !== state.encoding) { + chunk = Buffer.from(chunk, encoding); + encoding = ''; + } + + skipChunkCheck = true; + } + } else { + skipChunkCheck = true; + } + + return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); +}; // Unshift should *always* be something directly out of read() + + +Readable.prototype.unshift = function (chunk) { + return readableAddChunk(this, chunk, null, true, false); +}; + +function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { + debug('readableAddChunk', chunk); + var state = stream._readableState; + + if (chunk === null) { + state.reading = false; + onEofChunk(stream, state); + } else { + var er; + if (!skipChunkCheck) er = chunkInvalid(state, chunk); + + if (er) { + errorOrDestroy(stream, er); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { + chunk = _uint8ArrayToBuffer(chunk); + } + + if (addToFront) { + if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true); + } else if (state.ended) { + errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF()); + } else if (state.destroyed) { + return false; + } else { + state.reading = false; + + if (state.decoder && !encoding) { + chunk = state.decoder.write(chunk); + if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state); + } else { + addChunk(stream, state, chunk, false); + } + } + } else if (!addToFront) { + state.reading = false; + maybeReadMore(stream, state); + } + } // We can push more data if we are below the highWaterMark. + // Also, if we have no data yet, we can stand some more bytes. + // This is to work around cases where hwm=0, such as the repl. + + + return !state.ended && (state.length < state.highWaterMark || state.length === 0); +} + +function addChunk(stream, state, chunk, addToFront) { + if (state.flowing && state.length === 0 && !state.sync) { + state.awaitDrain = 0; + stream.emit('data', chunk); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); + if (state.needReadable) emitReadable(stream); + } + + maybeReadMore(stream, state); +} + +function chunkInvalid(state, chunk) { + var er; + + if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk); + } + + return er; +} + +Readable.prototype.isPaused = function () { + return this._readableState.flowing === false; +}; // backwards compatibility. + + +Readable.prototype.setEncoding = function (enc) { + if (!StringDecoder) StringDecoder = _dereq_('string_decoder/').StringDecoder; + var decoder = new StringDecoder(enc); + this._readableState.decoder = decoder; // If setEncoding(null), decoder.encoding equals utf8 + + this._readableState.encoding = this._readableState.decoder.encoding; // Iterate over current buffer to convert already stored Buffers: + + var p = this._readableState.buffer.head; + var content = ''; + + while (p !== null) { + content += decoder.write(p.data); + p = p.next; + } + + this._readableState.buffer.clear(); + + if (content !== '') this._readableState.buffer.push(content); + this._readableState.length = content.length; + return this; +}; // Don't raise the hwm > 1GB + + +var MAX_HWM = 0x40000000; + +function computeNewHighWaterMark(n) { + if (n >= MAX_HWM) { + // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE. + n = MAX_HWM; + } else { + // Get the next highest power of 2 to prevent increasing hwm excessively in + // tiny amounts + n--; + n |= n >>> 1; + n |= n >>> 2; + n |= n >>> 4; + n |= n >>> 8; + n |= n >>> 16; + n++; + } + + return n; +} // This function is designed to be inlinable, so please take care when making +// changes to the function body. + + +function howMuchToRead(n, state) { + if (n <= 0 || state.length === 0 && state.ended) return 0; + if (state.objectMode) return 1; + + if (n !== n) { + // Only flow one buffer at a time + if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; + } // If we're asking for more than the current hwm, then raise the hwm. + + + if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); + if (n <= state.length) return n; // Don't have enough + + if (!state.ended) { + state.needReadable = true; + return 0; + } + + return state.length; +} // you can override either this method, or the async _read(n) below. + + +Readable.prototype.read = function (n) { + debug('read', n); + n = parseInt(n, 10); + var state = this._readableState; + var nOrig = n; + if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we + // already have a bunch of data in the buffer, then just trigger + // the 'readable' event and move on. + + if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) { + debug('read: emitReadable', state.length, state.ended); + if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); + return null; + } + + n = howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up. + + if (n === 0 && state.ended) { + if (state.length === 0) endReadable(this); + return null; + } // All the actual chunk generation logic needs to be + // *below* the call to _read. The reason is that in certain + // synthetic stream cases, such as passthrough streams, _read + // may be a completely synchronous operation which may change + // the state of the read buffer, providing enough data when + // before there was *not* enough. + // + // So, the steps are: + // 1. Figure out what the state of things will be after we do + // a read from the buffer. + // + // 2. If that resulting state will trigger a _read, then call _read. + // Note that this may be asynchronous, or synchronous. Yes, it is + // deeply ugly to write APIs this way, but that still doesn't mean + // that the Readable class should behave improperly, as streams are + // designed to be sync/async agnostic. + // Take note if the _read call is sync or async (ie, if the read call + // has returned yet), so that we know whether or not it's safe to emit + // 'readable' etc. + // + // 3. Actually pull the requested chunks out of the buffer and return. + // if we need a readable event, then we need to do some reading. + + + var doRead = state.needReadable; + debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read some + + if (state.length === 0 || state.length - n < state.highWaterMark) { + doRead = true; + debug('length less than watermark', doRead); + } // however, if we've ended, then there's no point, and if we're already + // reading, then it's unnecessary. + + + if (state.ended || state.reading) { + doRead = false; + debug('reading or ended', doRead); + } else if (doRead) { + debug('do read'); + state.reading = true; + state.sync = true; // if the length is currently zero, then we *need* a readable event. + + if (state.length === 0) state.needReadable = true; // call internal read method + + this._read(state.highWaterMark); + + state.sync = false; // If _read pushed data synchronously, then `reading` will be false, + // and we need to re-evaluate how much data we can return to the user. + + if (!state.reading) n = howMuchToRead(nOrig, state); + } + + var ret; + if (n > 0) ret = fromList(n, state);else ret = null; + + if (ret === null) { + state.needReadable = state.length <= state.highWaterMark; + n = 0; + } else { + state.length -= n; + state.awaitDrain = 0; + } + + if (state.length === 0) { + // If we have nothing in the buffer, then we want to know + // as soon as we *do* get something into the buffer. + if (!state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick. + + if (nOrig !== n && state.ended) endReadable(this); + } + + if (ret !== null) this.emit('data', ret); + return ret; +}; + +function onEofChunk(stream, state) { + debug('onEofChunk'); + if (state.ended) return; + + if (state.decoder) { + var chunk = state.decoder.end(); + + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; + } + } + + state.ended = true; + + if (state.sync) { + // if we are sync, wait until next tick to emit the data. + // Otherwise we risk emitting data in the flow() + // the readable code triggers during a read() call + emitReadable(stream); + } else { + // emit 'readable' now to make sure it gets picked up. + state.needReadable = false; + + if (!state.emittedReadable) { + state.emittedReadable = true; + emitReadable_(stream); + } + } +} // Don't emit readable right away in sync mode, because this can trigger +// another read() call => stack overflow. This way, it might trigger +// a nextTick recursion warning, but that's not so bad. + + +function emitReadable(stream) { + var state = stream._readableState; + debug('emitReadable', state.needReadable, state.emittedReadable); + state.needReadable = false; + + if (!state.emittedReadable) { + debug('emitReadable', state.flowing); + state.emittedReadable = true; + process.nextTick(emitReadable_, stream); + } +} + +function emitReadable_(stream) { + var state = stream._readableState; + debug('emitReadable_', state.destroyed, state.length, state.ended); + + if (!state.destroyed && (state.length || state.ended)) { + stream.emit('readable'); + state.emittedReadable = false; + } // The stream needs another readable event if + // 1. It is not flowing, as the flow mechanism will take + // care of it. + // 2. It is not ended. + // 3. It is below the highWaterMark, so we can schedule + // another readable later. + + + state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark; + flow(stream); +} // at this point, the user has presumably seen the 'readable' event, +// and called read() to consume some data. that may have triggered +// in turn another _read(n) call, in which case reading = true if +// it's in progress. +// However, if we're not ended, or reading, and the length < hwm, +// then go ahead and try to read some more preemptively. + + +function maybeReadMore(stream, state) { + if (!state.readingMore) { + state.readingMore = true; + process.nextTick(maybeReadMore_, stream, state); + } +} + +function maybeReadMore_(stream, state) { + // Attempt to read more data if we should. + // + // The conditions for reading more data are (one of): + // - Not enough data buffered (state.length < state.highWaterMark). The loop + // is responsible for filling the buffer with enough data if such data + // is available. If highWaterMark is 0 and we are not in the flowing mode + // we should _not_ attempt to buffer any extra data. We'll get more data + // when the stream consumer calls read() instead. + // - No data in the buffer, and the stream is in flowing mode. In this mode + // the loop below is responsible for ensuring read() is called. Failing to + // call read here would abort the flow and there's no other mechanism for + // continuing the flow if the stream consumer has just subscribed to the + // 'data' event. + // + // In addition to the above conditions to keep reading data, the following + // conditions prevent the data from being read: + // - The stream has ended (state.ended). + // - There is already a pending 'read' operation (state.reading). This is a + // case where the the stream has called the implementation defined _read() + // method, but they are processing the call asynchronously and have _not_ + // called push() with new data. In this case we skip performing more + // read()s. The execution ends in this method again after the _read() ends + // up calling push() with more data. + while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) { + var len = state.length; + debug('maybeReadMore read 0'); + stream.read(0); + if (len === state.length) // didn't get any data, stop spinning. + break; + } + + state.readingMore = false; +} // abstract method. to be overridden in specific implementation classes. +// call cb(er, data) where data is <= n in length. +// for virtual (non-string, non-buffer) streams, "length" is somewhat +// arbitrary, and perhaps not very meaningful. + + +Readable.prototype._read = function (n) { + errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()')); +}; + +Readable.prototype.pipe = function (dest, pipeOpts) { + var src = this; + var state = this._readableState; + + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + + case 1: + state.pipes = [state.pipes, dest]; + break; + + default: + state.pipes.push(dest); + break; + } + + state.pipesCount += 1; + debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); + var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; + var endFn = doEnd ? onend : unpipe; + if (state.endEmitted) process.nextTick(endFn);else src.once('end', endFn); + dest.on('unpipe', onunpipe); + + function onunpipe(readable, unpipeInfo) { + debug('onunpipe'); + + if (readable === src) { + if (unpipeInfo && unpipeInfo.hasUnpiped === false) { + unpipeInfo.hasUnpiped = true; + cleanup(); + } + } + } + + function onend() { + debug('onend'); + dest.end(); + } // when the dest drains, it reduces the awaitDrain counter + // on the source. This would be more elegant with a .once() + // handler in flow(), but adding and removing repeatedly is + // too slow. + + + var ondrain = pipeOnDrain(src); + dest.on('drain', ondrain); + var cleanedUp = false; + + function cleanup() { + debug('cleanup'); // cleanup event handlers once the pipe is broken + + dest.removeListener('close', onclose); + dest.removeListener('finish', onfinish); + dest.removeListener('drain', ondrain); + dest.removeListener('error', onerror); + dest.removeListener('unpipe', onunpipe); + src.removeListener('end', onend); + src.removeListener('end', unpipe); + src.removeListener('data', ondata); + cleanedUp = true; // if the reader is waiting for a drain event from this + // specific writer, then it would cause it to never start + // flowing again. + // So, if this is awaiting a drain, then we just call it now. + // If we don't know, then assume that we are waiting for one. + + if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); + } + + src.on('data', ondata); + + function ondata(chunk) { + debug('ondata'); + var ret = dest.write(chunk); + debug('dest.write', ret); + + if (ret === false) { + // If the user unpiped during `dest.write()`, it is possible + // to get stuck in a permanently paused state if that write + // also returned false. + // => Check whether `dest` is still a piping destination. + if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { + debug('false write response, pause', state.awaitDrain); + state.awaitDrain++; + } + + src.pause(); + } + } // if the dest has an error, then stop piping into it. + // however, don't suppress the throwing behavior for this. + + + function onerror(er) { + debug('onerror', er); + unpipe(); + dest.removeListener('error', onerror); + if (EElistenerCount(dest, 'error') === 0) errorOrDestroy(dest, er); + } // Make sure our error handler is attached before userland ones. + + + prependListener(dest, 'error', onerror); // Both close and finish should trigger unpipe, but only once. + + function onclose() { + dest.removeListener('finish', onfinish); + unpipe(); + } + + dest.once('close', onclose); + + function onfinish() { + debug('onfinish'); + dest.removeListener('close', onclose); + unpipe(); + } + + dest.once('finish', onfinish); + + function unpipe() { + debug('unpipe'); + src.unpipe(dest); + } // tell the dest that it's being piped to + + + dest.emit('pipe', src); // start the flow if it hasn't been started already. + + if (!state.flowing) { + debug('pipe resume'); + src.resume(); + } + + return dest; +}; + +function pipeOnDrain(src) { + return function pipeOnDrainFunctionResult() { + var state = src._readableState; + debug('pipeOnDrain', state.awaitDrain); + if (state.awaitDrain) state.awaitDrain--; + + if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { + state.flowing = true; + flow(src); + } + }; +} + +Readable.prototype.unpipe = function (dest) { + var state = this._readableState; + var unpipeInfo = { + hasUnpiped: false + }; // if we're not piping anywhere, then do nothing. + + if (state.pipesCount === 0) return this; // just one destination. most common case. + + if (state.pipesCount === 1) { + // passed in one, but it's not the right one. + if (dest && dest !== state.pipes) return this; + if (!dest) dest = state.pipes; // got a match. + + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + if (dest) dest.emit('unpipe', this, unpipeInfo); + return this; + } // slow case. multiple pipe destinations. + + + if (!dest) { + // remove all. + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + + for (var i = 0; i < len; i++) { + dests[i].emit('unpipe', this, { + hasUnpiped: false + }); + } + + return this; + } // try to find the right one. + + + var index = indexOf(state.pipes, dest); + if (index === -1) return this; + state.pipes.splice(index, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) state.pipes = state.pipes[0]; + dest.emit('unpipe', this, unpipeInfo); + return this; +}; // set up data events if they are asked for +// Ensure readable listeners eventually get something + + +Readable.prototype.on = function (ev, fn) { + var res = Stream.prototype.on.call(this, ev, fn); + var state = this._readableState; + + if (ev === 'data') { + // update readableListening so that resume() may be a no-op + // a few lines down. This is needed to support once('readable'). + state.readableListening = this.listenerCount('readable') > 0; // Try start flowing on next tick if stream isn't explicitly paused + + if (state.flowing !== false) this.resume(); + } else if (ev === 'readable') { + if (!state.endEmitted && !state.readableListening) { + state.readableListening = state.needReadable = true; + state.flowing = false; + state.emittedReadable = false; + debug('on readable', state.length, state.reading); + + if (state.length) { + emitReadable(this); + } else if (!state.reading) { + process.nextTick(nReadingNextTick, this); + } + } + } + + return res; +}; + +Readable.prototype.addListener = Readable.prototype.on; + +Readable.prototype.removeListener = function (ev, fn) { + var res = Stream.prototype.removeListener.call(this, ev, fn); + + if (ev === 'readable') { + // We need to check if there is someone still listening to + // readable and reset the state. However this needs to happen + // after readable has been emitted but before I/O (nextTick) to + // support once('readable', fn) cycles. This means that calling + // resume within the same tick will have no + // effect. + process.nextTick(updateReadableListening, this); + } + + return res; +}; + +Readable.prototype.removeAllListeners = function (ev) { + var res = Stream.prototype.removeAllListeners.apply(this, arguments); + + if (ev === 'readable' || ev === undefined) { + // We need to check if there is someone still listening to + // readable and reset the state. However this needs to happen + // after readable has been emitted but before I/O (nextTick) to + // support once('readable', fn) cycles. This means that calling + // resume within the same tick will have no + // effect. + process.nextTick(updateReadableListening, this); + } + + return res; +}; + +function updateReadableListening(self) { + var state = self._readableState; + state.readableListening = self.listenerCount('readable') > 0; + + if (state.resumeScheduled && !state.paused) { + // flowing needs to be set to true now, otherwise + // the upcoming resume will not flow. + state.flowing = true; // crude way to check if we should resume + } else if (self.listenerCount('data') > 0) { + self.resume(); + } +} + +function nReadingNextTick(self) { + debug('readable nexttick read 0'); + self.read(0); +} // pause() and resume() are remnants of the legacy readable stream API +// If the user uses them, then switch into old mode. + + +Readable.prototype.resume = function () { + var state = this._readableState; + + if (!state.flowing) { + debug('resume'); // we flow only if there is no one listening + // for readable, but we still have to call + // resume() + + state.flowing = !state.readableListening; + resume(this, state); + } + + state.paused = false; + return this; +}; + +function resume(stream, state) { + if (!state.resumeScheduled) { + state.resumeScheduled = true; + process.nextTick(resume_, stream, state); + } +} + +function resume_(stream, state) { + debug('resume', state.reading); + + if (!state.reading) { + stream.read(0); + } + + state.resumeScheduled = false; + stream.emit('resume'); + flow(stream); + if (state.flowing && !state.reading) stream.read(0); +} + +Readable.prototype.pause = function () { + debug('call pause flowing=%j', this._readableState.flowing); + + if (this._readableState.flowing !== false) { + debug('pause'); + this._readableState.flowing = false; + this.emit('pause'); + } + + this._readableState.paused = true; + return this; +}; + +function flow(stream) { + var state = stream._readableState; + debug('flow', state.flowing); + + while (state.flowing && stream.read() !== null) { + ; + } +} // wrap an old-style stream as the async data source. +// This is *not* part of the readable stream interface. +// It is an ugly unfortunate mess of history. + + +Readable.prototype.wrap = function (stream) { + var _this = this; + + var state = this._readableState; + var paused = false; + stream.on('end', function () { + debug('wrapped end'); + + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) _this.push(chunk); + } + + _this.push(null); + }); + stream.on('data', function (chunk) { + debug('wrapped data'); + if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode + + if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; + + var ret = _this.push(chunk); + + if (!ret) { + paused = true; + stream.pause(); + } + }); // proxy all the other methods. + // important when wrapping filters and duplexes. + + for (var i in stream) { + if (this[i] === undefined && typeof stream[i] === 'function') { + this[i] = function methodWrap(method) { + return function methodWrapReturnFunction() { + return stream[method].apply(stream, arguments); + }; + }(i); + } + } // proxy certain important events. + + + for (var n = 0; n < kProxyEvents.length; n++) { + stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); + } // when we try to consume some more bytes, simply unpause the + // underlying stream. + + + this._read = function (n) { + debug('wrapped _read', n); + + if (paused) { + paused = false; + stream.resume(); + } + }; + + return this; +}; + +if (typeof Symbol === 'function') { + Readable.prototype[Symbol.asyncIterator] = function () { + if (createReadableStreamAsyncIterator === undefined) { + createReadableStreamAsyncIterator = _dereq_('./internal/streams/async_iterator'); + } + + return createReadableStreamAsyncIterator(this); + }; +} + +Object.defineProperty(Readable.prototype, 'readableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState.highWaterMark; + } +}); +Object.defineProperty(Readable.prototype, 'readableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState && this._readableState.buffer; + } +}); +Object.defineProperty(Readable.prototype, 'readableFlowing', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState.flowing; + }, + set: function set(state) { + if (this._readableState) { + this._readableState.flowing = state; + } + } +}); // exposed for testing purposes only. + +Readable._fromList = fromList; +Object.defineProperty(Readable.prototype, 'readableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState.length; + } +}); // Pluck off n bytes from an array of buffers. +// Length is the combined lengths of all the buffers in the list. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. + +function fromList(n, state) { + // nothing buffered + if (state.length === 0) return null; + var ret; + if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { + // read it all, truncate the list + if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.first();else ret = state.buffer.concat(state.length); + state.buffer.clear(); + } else { + // read part of list + ret = state.buffer.consume(n, state.decoder); + } + return ret; +} + +function endReadable(stream) { + var state = stream._readableState; + debug('endReadable', state.endEmitted); + + if (!state.endEmitted) { + state.ended = true; + process.nextTick(endReadableNT, state, stream); + } +} + +function endReadableNT(state, stream) { + debug('endReadableNT', state.endEmitted, state.length); // Check that we didn't get one last unshift. + + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream.readable = false; + stream.emit('end'); + + if (state.autoDestroy) { + // In case of duplex streams we need a way to detect + // if the writable side is ready for autoDestroy as well + var wState = stream._writableState; + + if (!wState || wState.autoDestroy && wState.finished) { + stream.destroy(); + } + } + } +} + +if (typeof Symbol === 'function') { + Readable.from = function (iterable, opts) { + if (from === undefined) { + from = _dereq_('./internal/streams/from'); + } + + return from(Readable, iterable, opts); + }; +} + +function indexOf(xs, x) { + for (var i = 0, l = xs.length; i < l; i++) { + if (xs[i] === x) return i; + } + + return -1; +} +}).call(this)}).call(this,_dereq_('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"../errors":99,"./_stream_duplex":100,"./internal/streams/async_iterator":105,"./internal/streams/buffer_list":106,"./internal/streams/destroy":107,"./internal/streams/from":109,"./internal/streams/state":111,"./internal/streams/stream":112,"_process":96,"buffer":28,"events":27,"inherits":65,"string_decoder/":113,"util":26}],103:[function(_dereq_,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. +// a transform stream is a readable/writable stream where you do +// something with the data. Sometimes it's called a "filter", +// but that's not a great name for it, since that implies a thing where +// some bits pass through, and others are simply ignored. (That would +// be a valid example of a transform, of course.) +// +// While the output is causally related to the input, it's not a +// necessarily symmetric or synchronous transformation. For example, +// a zlib stream might take multiple plain-text writes(), and then +// emit a single compressed chunk some time in the future. +// +// Here's how this works: +// +// The Transform stream has all the aspects of the readable and writable +// stream classes. When you write(chunk), that calls _write(chunk,cb) +// internally, and returns false if there's a lot of pending writes +// buffered up. When you call read(), that calls _read(n) until +// there's enough pending readable data buffered up. +// +// In a transform stream, the written data is placed in a buffer. When +// _read(n) is called, it transforms the queued up data, calling the +// buffered _write cb's as it consumes chunks. If consuming a single +// written chunk would result in multiple output chunks, then the first +// outputted bit calls the readcb, and subsequent chunks just go into +// the read buffer, and will cause it to emit 'readable' if necessary. +// +// This way, back-pressure is actually determined by the reading side, +// since _read has to be called to start processing a new chunk. However, +// a pathological inflate type of transform can cause excessive buffering +// here. For example, imagine a stream where every byte of input is +// interpreted as an integer from 0-255, and then results in that many +// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in +// 1kb of data being output. In this case, you could write a very small +// amount of input, and end up with a very large amount of output. In +// such a pathological inflating mechanism, there'd be no way to tell +// the system to stop doing the transform. A single 4MB write could +// cause the system to run out of memory. +// +// However, even in such a pathological case, only a single written chunk +// would be consumed, and then the rest would wait (un-transformed) until +// the results of the previous transformed chunk were consumed. +'use strict'; + +module.exports = Transform; + +var _require$codes = _dereq_('../errors').codes, + ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, + ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, + ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING, + ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0; + +var Duplex = _dereq_('./_stream_duplex'); + +_dereq_('inherits')(Transform, Duplex); + +function afterTransform(er, data) { + var ts = this._transformState; + ts.transforming = false; + var cb = ts.writecb; + + if (cb === null) { + return this.emit('error', new ERR_MULTIPLE_CALLBACK()); + } + + ts.writechunk = null; + ts.writecb = null; + if (data != null) // single equals check for both `null` and `undefined` + this.push(data); + cb(er); + var rs = this._readableState; + rs.reading = false; + + if (rs.needReadable || rs.length < rs.highWaterMark) { + this._read(rs.highWaterMark); + } +} + +function Transform(options) { + if (!(this instanceof Transform)) return new Transform(options); + Duplex.call(this, options); + this._transformState = { + afterTransform: afterTransform.bind(this), + needTransform: false, + transforming: false, + writecb: null, + writechunk: null, + writeencoding: null + }; // start out asking for a readable event once data is transformed. + + this._readableState.needReadable = true; // we have implemented the _read method, and done the other things + // that Readable wants before the first _read call, so unset the + // sync guard flag. + + this._readableState.sync = false; + + if (options) { + if (typeof options.transform === 'function') this._transform = options.transform; + if (typeof options.flush === 'function') this._flush = options.flush; + } // When the writable side finishes, then flush out anything remaining. + + + this.on('prefinish', prefinish); +} + +function prefinish() { + var _this = this; + + if (typeof this._flush === 'function' && !this._readableState.destroyed) { + this._flush(function (er, data) { + done(_this, er, data); + }); + } else { + done(this, null, null); + } +} + +Transform.prototype.push = function (chunk, encoding) { + this._transformState.needTransform = false; + return Duplex.prototype.push.call(this, chunk, encoding); +}; // This is the part where you do stuff! +// override this function in implementation classes. +// 'chunk' is an input chunk. +// +// Call `push(newChunk)` to pass along transformed output +// to the readable side. You may call 'push' zero or more times. +// +// Call `cb(err)` when you are done with this chunk. If you pass +// an error, then that'll put the hurt on the whole operation. If you +// never call cb(), then you'll never get another chunk. + + +Transform.prototype._transform = function (chunk, encoding, cb) { + cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()')); +}; + +Transform.prototype._write = function (chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); + } +}; // Doesn't matter what the args are here. +// _transform does all the work. +// That we got here means that the readable side wants more data. + + +Transform.prototype._read = function (n) { + var ts = this._transformState; + + if (ts.writechunk !== null && !ts.transforming) { + ts.transforming = true; + + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + // mark that we need a transform, so that any data that comes in + // will get processed, now that we've asked for it. + ts.needTransform = true; + } +}; + +Transform.prototype._destroy = function (err, cb) { + Duplex.prototype._destroy.call(this, err, function (err2) { + cb(err2); + }); +}; + +function done(stream, er, data) { + if (er) return stream.emit('error', er); + if (data != null) // single equals check for both `null` and `undefined` + stream.push(data); // TODO(BridgeAR): Write a test for these two error cases + // if there's nothing in the write buffer, then that means + // that nothing more will ever be provided + + if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0(); + if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING(); + return stream.push(null); +} +},{"../errors":99,"./_stream_duplex":100,"inherits":65}],104:[function(_dereq_,module,exports){ +(function (process,global){(function (){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. +// A bit simpler than readable streams. +// Implement an async ._write(chunk, encoding, cb), and it'll handle all +// the drain event emission and buffering. +'use strict'; + +module.exports = Writable; +/* */ + +function WriteReq(chunk, encoding, cb) { + this.chunk = chunk; + this.encoding = encoding; + this.callback = cb; + this.next = null; +} // It seems a linked list but it is not +// there will be only 2 of these for each stream + + +function CorkedRequest(state) { + var _this = this; + + this.next = null; + this.entry = null; + + this.finish = function () { + onCorkedFinish(_this, state); + }; +} +/* */ + +/**/ + + +var Duplex; +/**/ + +Writable.WritableState = WritableState; +/**/ + +var internalUtil = { + deprecate: _dereq_('util-deprecate') +}; +/**/ + +/**/ + +var Stream = _dereq_('./internal/streams/stream'); +/**/ + + +var Buffer = _dereq_('buffer').Buffer; + +var OurUint8Array = global.Uint8Array || function () {}; + +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} + +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} + +var destroyImpl = _dereq_('./internal/streams/destroy'); + +var _require = _dereq_('./internal/streams/state'), + getHighWaterMark = _require.getHighWaterMark; + +var _require$codes = _dereq_('../errors').codes, + ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, + ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, + ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, + ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE, + ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED, + ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES, + ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END, + ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING; + +var errorOrDestroy = destroyImpl.errorOrDestroy; + +_dereq_('inherits')(Writable, Stream); + +function nop() {} + +function WritableState(options, stream, isDuplex) { + Duplex = Duplex || _dereq_('./_stream_duplex'); + options = options || {}; // Duplex streams are both readable and writable, but share + // the same options object. + // However, some cases require setting options to different + // values for the readable and the writable sides of the duplex stream, + // e.g. options.readableObjectMode vs. options.writableObjectMode, etc. + + if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag to indicate whether or not this stream + // contains buffers or objects. + + this.objectMode = !!options.objectMode; + if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false + // Note: 0 is a valid value, means that we always return false if + // the entire buffer is not flushed immediately on write() + + this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex); // if _final has been called + + this.finalCalled = false; // drain event flag. + + this.needDrain = false; // at the start of calling end() + + this.ending = false; // when end() has been called, and returned + + this.ended = false; // when 'finish' is emitted + + this.finished = false; // has it been destroyed + + this.destroyed = false; // should we decode strings into buffers before passing to _write? + // this is here so that some node-core streams can optimize string + // handling at a lower level. + + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + + this.defaultEncoding = options.defaultEncoding || 'utf8'; // not an actual buffer we keep track of, but a measurement + // of how much we're waiting to get pushed to some underlying + // socket or file. + + this.length = 0; // a flag to see when we're in the middle of a write. + + this.writing = false; // when true all writes will be buffered until .uncork() call + + this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + + this.sync = true; // a flag to know if we're processing previously buffered items, which + // may call the _write() callback in the same tick, so that we don't + // end up in an overlapped onwrite situation. + + this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb) + + this.onwrite = function (er) { + onwrite(stream, er); + }; // the callback that the user supplies to write(chunk,encoding,cb) + + + this.writecb = null; // the amount that is being written when _write is called. + + this.writelen = 0; + this.bufferedRequest = null; + this.lastBufferedRequest = null; // number of pending user-supplied write callbacks + // this must be 0 before 'finish' can be emitted + + this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs + // This is relevant for synchronous Transform streams + + this.prefinished = false; // True if the error was already emitted and should not be thrown again + + this.errorEmitted = false; // Should close be emitted on destroy. Defaults to true. + + this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'finish' (and potentially 'end') + + this.autoDestroy = !!options.autoDestroy; // count buffered requests + + this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always + // one allocated and free to use, and we maintain at most two + + this.corkedRequestsFree = new CorkedRequest(this); +} + +WritableState.prototype.getBuffer = function getBuffer() { + var current = this.bufferedRequest; + var out = []; + + while (current) { + out.push(current); + current = current.next; + } + + return out; +}; + +(function () { + try { + Object.defineProperty(WritableState.prototype, 'buffer', { + get: internalUtil.deprecate(function writableStateBufferGetter() { + return this.getBuffer(); + }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') + }); + } catch (_) {} +})(); // Test _writableState for inheritance to account for Duplex streams, +// whose prototype chain only points to Readable. + + +var realHasInstance; + +if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { + realHasInstance = Function.prototype[Symbol.hasInstance]; + Object.defineProperty(Writable, Symbol.hasInstance, { + value: function value(object) { + if (realHasInstance.call(this, object)) return true; + if (this !== Writable) return false; + return object && object._writableState instanceof WritableState; + } + }); +} else { + realHasInstance = function realHasInstance(object) { + return object instanceof this; + }; +} + +function Writable(options) { + Duplex = Duplex || _dereq_('./_stream_duplex'); // Writable ctor is applied to Duplexes, too. + // `realHasInstance` is necessary because using plain `instanceof` + // would return false, as no `_writableState` property is attached. + // Trying to use the custom `instanceof` for Writable here will also break the + // Node.js LazyTransform implementation, which has a non-trivial getter for + // `_writableState` that would lead to infinite recursion. + // Checking for a Stream.Duplex instance is faster here instead of inside + // the WritableState constructor, at least with V8 6.5 + + var isDuplex = this instanceof Duplex; + if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options); + this._writableState = new WritableState(options, this, isDuplex); // legacy. + + this.writable = true; + + if (options) { + if (typeof options.write === 'function') this._write = options.write; + if (typeof options.writev === 'function') this._writev = options.writev; + if (typeof options.destroy === 'function') this._destroy = options.destroy; + if (typeof options.final === 'function') this._final = options.final; + } + + Stream.call(this); +} // Otherwise people can pipe Writable streams, which is just wrong. + + +Writable.prototype.pipe = function () { + errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE()); +}; + +function writeAfterEnd(stream, cb) { + var er = new ERR_STREAM_WRITE_AFTER_END(); // TODO: defer error events consistently everywhere, not just the cb + + errorOrDestroy(stream, er); + process.nextTick(cb, er); +} // Checks that a user-supplied chunk is valid, especially for the particular +// mode the stream is in. Currently this means that `null` is never accepted +// and undefined/non-string values are only allowed in object mode. + + +function validChunk(stream, state, chunk, cb) { + var er; + + if (chunk === null) { + er = new ERR_STREAM_NULL_VALUES(); + } else if (typeof chunk !== 'string' && !state.objectMode) { + er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk); + } + + if (er) { + errorOrDestroy(stream, er); + process.nextTick(cb, er); + return false; + } + + return true; +} + +Writable.prototype.write = function (chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + + var isBuf = !state.objectMode && _isUint8Array(chunk); + + if (isBuf && !Buffer.isBuffer(chunk)) { + chunk = _uint8ArrayToBuffer(chunk); + } + + if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; + if (typeof cb !== 'function') cb = nop; + if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { + state.pendingcb++; + ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); + } + return ret; +}; + +Writable.prototype.cork = function () { + this._writableState.corked++; +}; + +Writable.prototype.uncork = function () { + var state = this._writableState; + + if (state.corked) { + state.corked--; + if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); + } +}; + +Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { + // node::ParseEncoding() requires lower case. + if (typeof encoding === 'string') encoding = encoding.toLowerCase(); + if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding); + this._writableState.defaultEncoding = encoding; + return this; +}; + +Object.defineProperty(Writable.prototype, 'writableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState && this._writableState.getBuffer(); + } +}); + +function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { + chunk = Buffer.from(chunk, encoding); + } + + return chunk; +} + +Object.defineProperty(Writable.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.highWaterMark; + } +}); // if we're already writing something, then just put this +// in the queue, and wait our turn. Otherwise, call _write +// If we return false, then we need a drain event, so set that flag. + +function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { + if (!isBuf) { + var newChunk = decodeChunk(state, chunk, encoding); + + if (chunk !== newChunk) { + isBuf = true; + encoding = 'buffer'; + chunk = newChunk; + } + } + + var len = state.objectMode ? 1 : chunk.length; + state.length += len; + var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false. + + if (!ret) state.needDrain = true; + + if (state.writing || state.corked) { + var last = state.lastBufferedRequest; + state.lastBufferedRequest = { + chunk: chunk, + encoding: encoding, + isBuf: isBuf, + callback: cb, + next: null + }; + + if (last) { + last.next = state.lastBufferedRequest; + } else { + state.bufferedRequest = state.lastBufferedRequest; + } + + state.bufferedRequestCount += 1; + } else { + doWrite(stream, state, false, len, chunk, encoding, cb); + } + + return ret; +} + +function doWrite(stream, state, writev, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); + state.sync = false; +} + +function onwriteError(stream, state, sync, er, cb) { + --state.pendingcb; + + if (sync) { + // defer the callback if we are being called synchronously + // to avoid piling up things on the stack + process.nextTick(cb, er); // this can emit finish, and it will always happen + // after error + + process.nextTick(finishMaybe, stream, state); + stream._writableState.errorEmitted = true; + errorOrDestroy(stream, er); + } else { + // the caller expect this to happen before if + // it is async + cb(er); + stream._writableState.errorEmitted = true; + errorOrDestroy(stream, er); // this can emit finish, but finish must + // always follow error + + finishMaybe(stream, state); + } +} + +function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; +} + +function onwrite(stream, er) { + var state = stream._writableState; + var sync = state.sync; + var cb = state.writecb; + if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK(); + onwriteStateUpdate(state); + if (er) onwriteError(stream, state, sync, er, cb);else { + // Check if we're actually ready to finish, but don't emit yet + var finished = needFinish(state) || stream.destroyed; + + if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { + clearBuffer(stream, state); + } + + if (sync) { + process.nextTick(afterWrite, stream, state, finished, cb); + } else { + afterWrite(stream, state, finished, cb); + } + } +} + +function afterWrite(stream, state, finished, cb) { + if (!finished) onwriteDrain(stream, state); + state.pendingcb--; + cb(); + finishMaybe(stream, state); +} // Must force callback to be called on nextTick, so that we don't +// emit 'drain' before the write() consumer gets the 'false' return +// value, and has a chance to attach a 'drain' listener. + + +function onwriteDrain(stream, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream.emit('drain'); + } +} // if there's something in the buffer waiting, then process it + + +function clearBuffer(stream, state) { + state.bufferProcessing = true; + var entry = state.bufferedRequest; + + if (stream._writev && entry && entry.next) { + // Fast case, write everything using _writev() + var l = state.bufferedRequestCount; + var buffer = new Array(l); + var holder = state.corkedRequestsFree; + holder.entry = entry; + var count = 0; + var allBuffers = true; + + while (entry) { + buffer[count] = entry; + if (!entry.isBuf) allBuffers = false; + entry = entry.next; + count += 1; + } + + buffer.allBuffers = allBuffers; + doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time + // as the hot path ends with doWrite + + state.pendingcb++; + state.lastBufferedRequest = null; + + if (holder.next) { + state.corkedRequestsFree = holder.next; + holder.next = null; + } else { + state.corkedRequestsFree = new CorkedRequest(state); + } + + state.bufferedRequestCount = 0; + } else { + // Slow case, write chunks one-by-one + while (entry) { + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; + doWrite(stream, state, false, len, chunk, encoding, cb); + entry = entry.next; + state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then + // it means that we need to wait until it does. + // also, that means that the chunk and cb are currently + // being processed, so move the buffer counter past them. + + if (state.writing) { + break; + } + } + + if (entry === null) state.lastBufferedRequest = null; + } + + state.bufferedRequest = entry; + state.bufferProcessing = false; +} + +Writable.prototype._write = function (chunk, encoding, cb) { + cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()')); +}; + +Writable.prototype._writev = null; + +Writable.prototype.end = function (chunk, encoding, cb) { + var state = this._writableState; + + if (typeof chunk === 'function') { + cb = chunk; + chunk = null; + encoding = null; + } else if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks + + if (state.corked) { + state.corked = 1; + this.uncork(); + } // ignore unnecessary end() calls. + + + if (!state.ending) endWritable(this, state, cb); + return this; +}; + +Object.defineProperty(Writable.prototype, 'writableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.length; + } +}); + +function needFinish(state) { + return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; +} + +function callFinal(stream, state) { + stream._final(function (err) { + state.pendingcb--; + + if (err) { + errorOrDestroy(stream, err); + } + + state.prefinished = true; + stream.emit('prefinish'); + finishMaybe(stream, state); + }); +} + +function prefinish(stream, state) { + if (!state.prefinished && !state.finalCalled) { + if (typeof stream._final === 'function' && !state.destroyed) { + state.pendingcb++; + state.finalCalled = true; + process.nextTick(callFinal, stream, state); + } else { + state.prefinished = true; + stream.emit('prefinish'); + } + } +} + +function finishMaybe(stream, state) { + var need = needFinish(state); + + if (need) { + prefinish(stream, state); + + if (state.pendingcb === 0) { + state.finished = true; + stream.emit('finish'); + + if (state.autoDestroy) { + // In case of duplex streams we need a way to detect + // if the readable side is ready for autoDestroy as well + var rState = stream._readableState; + + if (!rState || rState.autoDestroy && rState.endEmitted) { + stream.destroy(); + } + } + } + } + + return need; +} + +function endWritable(stream, state, cb) { + state.ending = true; + finishMaybe(stream, state); + + if (cb) { + if (state.finished) process.nextTick(cb);else stream.once('finish', cb); + } + + state.ended = true; + stream.writable = false; +} + +function onCorkedFinish(corkReq, state, err) { + var entry = corkReq.entry; + corkReq.entry = null; + + while (entry) { + var cb = entry.callback; + state.pendingcb--; + cb(err); + entry = entry.next; + } // reuse the free corkReq. + + + state.corkedRequestsFree.next = corkReq; +} + +Object.defineProperty(Writable.prototype, 'destroyed', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + if (this._writableState === undefined) { + return false; + } + + return this._writableState.destroyed; + }, + set: function set(value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._writableState) { + return; + } // backward compatibility, the user is explicitly + // managing destroyed + + + this._writableState.destroyed = value; + } +}); +Writable.prototype.destroy = destroyImpl.destroy; +Writable.prototype._undestroy = destroyImpl.undestroy; + +Writable.prototype._destroy = function (err, cb) { + cb(err); +}; +}).call(this)}).call(this,_dereq_('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"../errors":99,"./_stream_duplex":100,"./internal/streams/destroy":107,"./internal/streams/state":111,"./internal/streams/stream":112,"_process":96,"buffer":28,"inherits":65,"util-deprecate":120}],105:[function(_dereq_,module,exports){ +(function (process){(function (){ +'use strict'; + +var _Object$setPrototypeO; + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var finished = _dereq_('./end-of-stream'); + +var kLastResolve = Symbol('lastResolve'); +var kLastReject = Symbol('lastReject'); +var kError = Symbol('error'); +var kEnded = Symbol('ended'); +var kLastPromise = Symbol('lastPromise'); +var kHandlePromise = Symbol('handlePromise'); +var kStream = Symbol('stream'); + +function createIterResult(value, done) { + return { + value: value, + done: done + }; +} + +function readAndResolve(iter) { + var resolve = iter[kLastResolve]; + + if (resolve !== null) { + var data = iter[kStream].read(); // we defer if data is null + // we can be expecting either 'end' or + // 'error' + + if (data !== null) { + iter[kLastPromise] = null; + iter[kLastResolve] = null; + iter[kLastReject] = null; + resolve(createIterResult(data, false)); + } + } +} + +function onReadable(iter) { + // we wait for the next tick, because it might + // emit an error with process.nextTick + process.nextTick(readAndResolve, iter); +} + +function wrapForNext(lastPromise, iter) { + return function (resolve, reject) { + lastPromise.then(function () { + if (iter[kEnded]) { + resolve(createIterResult(undefined, true)); + return; + } + + iter[kHandlePromise](resolve, reject); + }, reject); + }; +} + +var AsyncIteratorPrototype = Object.getPrototypeOf(function () {}); +var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = { + get stream() { + return this[kStream]; + }, + + next: function next() { + var _this = this; + + // if we have detected an error in the meanwhile + // reject straight away + var error = this[kError]; + + if (error !== null) { + return Promise.reject(error); + } + + if (this[kEnded]) { + return Promise.resolve(createIterResult(undefined, true)); + } + + if (this[kStream].destroyed) { + // We need to defer via nextTick because if .destroy(err) is + // called, the error will be emitted via nextTick, and + // we cannot guarantee that there is no error lingering around + // waiting to be emitted. + return new Promise(function (resolve, reject) { + process.nextTick(function () { + if (_this[kError]) { + reject(_this[kError]); + } else { + resolve(createIterResult(undefined, true)); + } + }); + }); + } // if we have multiple next() calls + // we will wait for the previous Promise to finish + // this logic is optimized to support for await loops, + // where next() is only called once at a time + + + var lastPromise = this[kLastPromise]; + var promise; + + if (lastPromise) { + promise = new Promise(wrapForNext(lastPromise, this)); + } else { + // fast path needed to support multiple this.push() + // without triggering the next() queue + var data = this[kStream].read(); + + if (data !== null) { + return Promise.resolve(createIterResult(data, false)); + } + + promise = new Promise(this[kHandlePromise]); + } + + this[kLastPromise] = promise; + return promise; + } +}, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () { + return this; +}), _defineProperty(_Object$setPrototypeO, "return", function _return() { + var _this2 = this; + + // destroy(err, cb) is a private API + // we can guarantee we have that here, because we control the + // Readable class this is attached to + return new Promise(function (resolve, reject) { + _this2[kStream].destroy(null, function (err) { + if (err) { + reject(err); + return; + } + + resolve(createIterResult(undefined, true)); + }); + }); +}), _Object$setPrototypeO), AsyncIteratorPrototype); + +var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) { + var _Object$create; + + var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, { + value: stream, + writable: true + }), _defineProperty(_Object$create, kLastResolve, { + value: null, + writable: true + }), _defineProperty(_Object$create, kLastReject, { + value: null, + writable: true + }), _defineProperty(_Object$create, kError, { + value: null, + writable: true + }), _defineProperty(_Object$create, kEnded, { + value: stream._readableState.endEmitted, + writable: true + }), _defineProperty(_Object$create, kHandlePromise, { + value: function value(resolve, reject) { + var data = iterator[kStream].read(); + + if (data) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + resolve(createIterResult(data, false)); + } else { + iterator[kLastResolve] = resolve; + iterator[kLastReject] = reject; + } + }, + writable: true + }), _Object$create)); + iterator[kLastPromise] = null; + finished(stream, function (err) { + if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') { + var reject = iterator[kLastReject]; // reject if we are waiting for data in the Promise + // returned by next() and store the error + + if (reject !== null) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + reject(err); + } + + iterator[kError] = err; + return; + } + + var resolve = iterator[kLastResolve]; + + if (resolve !== null) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + resolve(createIterResult(undefined, true)); + } + + iterator[kEnded] = true; + }); + stream.on('readable', onReadable.bind(null, iterator)); + return iterator; +}; + +module.exports = createReadableStreamAsyncIterator; +}).call(this)}).call(this,_dereq_('_process')) +},{"./end-of-stream":108,"_process":96}],106:[function(_dereq_,module,exports){ +'use strict'; + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +var _require = _dereq_('buffer'), + Buffer = _require.Buffer; + +var _require2 = _dereq_('util'), + inspect = _require2.inspect; + +var custom = inspect && inspect.custom || 'inspect'; + +function copyBuffer(src, target, offset) { + Buffer.prototype.copy.call(src, target, offset); +} + +module.exports = +/*#__PURE__*/ +function () { + function BufferList() { + _classCallCheck(this, BufferList); + + this.head = null; + this.tail = null; + this.length = 0; + } + + _createClass(BufferList, [{ + key: "push", + value: function push(v) { + var entry = { + data: v, + next: null + }; + if (this.length > 0) this.tail.next = entry;else this.head = entry; + this.tail = entry; + ++this.length; + } + }, { + key: "unshift", + value: function unshift(v) { + var entry = { + data: v, + next: this.head + }; + if (this.length === 0) this.tail = entry; + this.head = entry; + ++this.length; + } + }, { + key: "shift", + value: function shift() { + if (this.length === 0) return; + var ret = this.head.data; + if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; + --this.length; + return ret; + } + }, { + key: "clear", + value: function clear() { + this.head = this.tail = null; + this.length = 0; + } + }, { + key: "join", + value: function join(s) { + if (this.length === 0) return ''; + var p = this.head; + var ret = '' + p.data; + + while (p = p.next) { + ret += s + p.data; + } + + return ret; + } + }, { + key: "concat", + value: function concat(n) { + if (this.length === 0) return Buffer.alloc(0); + var ret = Buffer.allocUnsafe(n >>> 0); + var p = this.head; + var i = 0; + + while (p) { + copyBuffer(p.data, ret, i); + i += p.data.length; + p = p.next; + } + + return ret; + } // Consumes a specified amount of bytes or characters from the buffered data. + + }, { + key: "consume", + value: function consume(n, hasStrings) { + var ret; + + if (n < this.head.data.length) { + // `slice` is the same for buffers and strings. + ret = this.head.data.slice(0, n); + this.head.data = this.head.data.slice(n); + } else if (n === this.head.data.length) { + // First chunk is a perfect match. + ret = this.shift(); + } else { + // Result spans more than one buffer. + ret = hasStrings ? this._getString(n) : this._getBuffer(n); + } + + return ret; + } + }, { + key: "first", + value: function first() { + return this.head.data; + } // Consumes a specified amount of characters from the buffered data. + + }, { + key: "_getString", + value: function _getString(n) { + var p = this.head; + var c = 1; + var ret = p.data; + n -= ret.length; + + while (p = p.next) { + var str = p.data; + var nb = n > str.length ? str.length : n; + if (nb === str.length) ret += str;else ret += str.slice(0, n); + n -= nb; + + if (n === 0) { + if (nb === str.length) { + ++c; + if (p.next) this.head = p.next;else this.head = this.tail = null; + } else { + this.head = p; + p.data = str.slice(nb); + } + + break; + } + + ++c; + } + + this.length -= c; + return ret; + } // Consumes a specified amount of bytes from the buffered data. + + }, { + key: "_getBuffer", + value: function _getBuffer(n) { + var ret = Buffer.allocUnsafe(n); + var p = this.head; + var c = 1; + p.data.copy(ret); + n -= p.data.length; + + while (p = p.next) { + var buf = p.data; + var nb = n > buf.length ? buf.length : n; + buf.copy(ret, ret.length - n, 0, nb); + n -= nb; + + if (n === 0) { + if (nb === buf.length) { + ++c; + if (p.next) this.head = p.next;else this.head = this.tail = null; + } else { + this.head = p; + p.data = buf.slice(nb); + } + + break; + } + + ++c; + } + + this.length -= c; + return ret; + } // Make sure the linked list only shows the minimal necessary information. + + }, { + key: custom, + value: function value(_, options) { + return inspect(this, _objectSpread({}, options, { + // Only inspect one level. + depth: 0, + // It should not recurse. + customInspect: false + })); + } + }]); + + return BufferList; +}(); +},{"buffer":28,"util":26}],107:[function(_dereq_,module,exports){ +(function (process){(function (){ +'use strict'; // undocumented cb() API, needed for core, not for public API + +function destroy(err, cb) { + var _this = this; + + var readableDestroyed = this._readableState && this._readableState.destroyed; + var writableDestroyed = this._writableState && this._writableState.destroyed; + + if (readableDestroyed || writableDestroyed) { + if (cb) { + cb(err); + } else if (err) { + if (!this._writableState) { + process.nextTick(emitErrorNT, this, err); + } else if (!this._writableState.errorEmitted) { + this._writableState.errorEmitted = true; + process.nextTick(emitErrorNT, this, err); + } + } + + return this; + } // we set destroyed to true before firing error callbacks in order + // to make it re-entrance safe in case destroy() is called within callbacks + + + if (this._readableState) { + this._readableState.destroyed = true; + } // if this is a duplex stream mark the writable part as destroyed as well + + + if (this._writableState) { + this._writableState.destroyed = true; + } + + this._destroy(err || null, function (err) { + if (!cb && err) { + if (!_this._writableState) { + process.nextTick(emitErrorAndCloseNT, _this, err); + } else if (!_this._writableState.errorEmitted) { + _this._writableState.errorEmitted = true; + process.nextTick(emitErrorAndCloseNT, _this, err); + } else { + process.nextTick(emitCloseNT, _this); + } + } else if (cb) { + process.nextTick(emitCloseNT, _this); + cb(err); + } else { + process.nextTick(emitCloseNT, _this); + } + }); + + return this; +} + +function emitErrorAndCloseNT(self, err) { + emitErrorNT(self, err); + emitCloseNT(self); +} + +function emitCloseNT(self) { + if (self._writableState && !self._writableState.emitClose) return; + if (self._readableState && !self._readableState.emitClose) return; + self.emit('close'); +} + +function undestroy() { + if (this._readableState) { + this._readableState.destroyed = false; + this._readableState.reading = false; + this._readableState.ended = false; + this._readableState.endEmitted = false; + } + + if (this._writableState) { + this._writableState.destroyed = false; + this._writableState.ended = false; + this._writableState.ending = false; + this._writableState.finalCalled = false; + this._writableState.prefinished = false; + this._writableState.finished = false; + this._writableState.errorEmitted = false; + } +} + +function emitErrorNT(self, err) { + self.emit('error', err); +} + +function errorOrDestroy(stream, err) { + // We have tests that rely on errors being emitted + // in the same tick, so changing this is semver major. + // For now when you opt-in to autoDestroy we allow + // the error to be emitted nextTick. In a future + // semver major update we should change the default to this. + var rState = stream._readableState; + var wState = stream._writableState; + if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err); +} + +module.exports = { + destroy: destroy, + undestroy: undestroy, + errorOrDestroy: errorOrDestroy +}; +}).call(this)}).call(this,_dereq_('_process')) +},{"_process":96}],108:[function(_dereq_,module,exports){ +// Ported from https://github.com/mafintosh/end-of-stream with +// permission from the author, Mathias Buus (@mafintosh). +'use strict'; + +var ERR_STREAM_PREMATURE_CLOSE = _dereq_('../../../errors').codes.ERR_STREAM_PREMATURE_CLOSE; + +function once(callback) { + var called = false; + return function () { + if (called) return; + called = true; + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + callback.apply(this, args); + }; +} + +function noop() {} + +function isRequest(stream) { + return stream.setHeader && typeof stream.abort === 'function'; +} + +function eos(stream, opts, callback) { + if (typeof opts === 'function') return eos(stream, null, opts); + if (!opts) opts = {}; + callback = once(callback || noop); + var readable = opts.readable || opts.readable !== false && stream.readable; + var writable = opts.writable || opts.writable !== false && stream.writable; + + var onlegacyfinish = function onlegacyfinish() { + if (!stream.writable) onfinish(); + }; + + var writableEnded = stream._writableState && stream._writableState.finished; + + var onfinish = function onfinish() { + writable = false; + writableEnded = true; + if (!readable) callback.call(stream); + }; + + var readableEnded = stream._readableState && stream._readableState.endEmitted; + + var onend = function onend() { + readable = false; + readableEnded = true; + if (!writable) callback.call(stream); + }; + + var onerror = function onerror(err) { + callback.call(stream, err); + }; + + var onclose = function onclose() { + var err; + + if (readable && !readableEnded) { + if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE(); + return callback.call(stream, err); + } + + if (writable && !writableEnded) { + if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE(); + return callback.call(stream, err); + } + }; + + var onrequest = function onrequest() { + stream.req.on('finish', onfinish); + }; + + if (isRequest(stream)) { + stream.on('complete', onfinish); + stream.on('abort', onclose); + if (stream.req) onrequest();else stream.on('request', onrequest); + } else if (writable && !stream._writableState) { + // legacy streams + stream.on('end', onlegacyfinish); + stream.on('close', onlegacyfinish); + } + + stream.on('end', onend); + stream.on('finish', onfinish); + if (opts.error !== false) stream.on('error', onerror); + stream.on('close', onclose); + return function () { + stream.removeListener('complete', onfinish); + stream.removeListener('abort', onclose); + stream.removeListener('request', onrequest); + if (stream.req) stream.req.removeListener('finish', onfinish); + stream.removeListener('end', onlegacyfinish); + stream.removeListener('close', onlegacyfinish); + stream.removeListener('finish', onfinish); + stream.removeListener('end', onend); + stream.removeListener('error', onerror); + stream.removeListener('close', onclose); + }; +} + +module.exports = eos; +},{"../../../errors":99}],109:[function(_dereq_,module,exports){ +module.exports = function () { + throw new Error('Readable.from is not available in the browser') +}; + +},{}],110:[function(_dereq_,module,exports){ +// Ported from https://github.com/mafintosh/pump with +// permission from the author, Mathias Buus (@mafintosh). +'use strict'; + +var eos; + +function once(callback) { + var called = false; + return function () { + if (called) return; + called = true; + callback.apply(void 0, arguments); + }; +} + +var _require$codes = _dereq_('../../../errors').codes, + ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS, + ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED; + +function noop(err) { + // Rethrow the error if it exists to avoid swallowing it + if (err) throw err; +} + +function isRequest(stream) { + return stream.setHeader && typeof stream.abort === 'function'; +} + +function destroyer(stream, reading, writing, callback) { + callback = once(callback); + var closed = false; + stream.on('close', function () { + closed = true; + }); + if (eos === undefined) eos = _dereq_('./end-of-stream'); + eos(stream, { + readable: reading, + writable: writing + }, function (err) { + if (err) return callback(err); + closed = true; + callback(); + }); + var destroyed = false; + return function (err) { + if (closed) return; + if (destroyed) return; + destroyed = true; // request.destroy just do .end - .abort is what we want + + if (isRequest(stream)) return stream.abort(); + if (typeof stream.destroy === 'function') return stream.destroy(); + callback(err || new ERR_STREAM_DESTROYED('pipe')); + }; +} + +function call(fn) { + fn(); +} + +function pipe(from, to) { + return from.pipe(to); +} + +function popCallback(streams) { + if (!streams.length) return noop; + if (typeof streams[streams.length - 1] !== 'function') return noop; + return streams.pop(); +} + +function pipeline() { + for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) { + streams[_key] = arguments[_key]; + } + + var callback = popCallback(streams); + if (Array.isArray(streams[0])) streams = streams[0]; + + if (streams.length < 2) { + throw new ERR_MISSING_ARGS('streams'); + } + + var error; + var destroys = streams.map(function (stream, i) { + var reading = i < streams.length - 1; + var writing = i > 0; + return destroyer(stream, reading, writing, function (err) { + if (!error) error = err; + if (err) destroys.forEach(call); + if (reading) return; + destroys.forEach(call); + callback(error); + }); + }); + return streams.reduce(pipe); +} + +module.exports = pipeline; +},{"../../../errors":99,"./end-of-stream":108}],111:[function(_dereq_,module,exports){ +'use strict'; + +var ERR_INVALID_OPT_VALUE = _dereq_('../../../errors').codes.ERR_INVALID_OPT_VALUE; + +function highWaterMarkFrom(options, isDuplex, duplexKey) { + return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null; +} + +function getHighWaterMark(state, options, duplexKey, isDuplex) { + var hwm = highWaterMarkFrom(options, isDuplex, duplexKey); + + if (hwm != null) { + if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) { + var name = isDuplex ? duplexKey : 'highWaterMark'; + throw new ERR_INVALID_OPT_VALUE(name, hwm); + } + + return Math.floor(hwm); + } // Default value + + + return state.objectMode ? 16 : 16 * 1024; +} + +module.exports = { + getHighWaterMark: getHighWaterMark +}; +},{"../../../errors":99}],112:[function(_dereq_,module,exports){ +module.exports = _dereq_('events').EventEmitter; + +},{"events":27}],113:[function(_dereq_,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +'use strict'; + +/**/ + +var Buffer = _dereq_('safe-buffer').Buffer; +/**/ + +var isEncoding = Buffer.isEncoding || function (encoding) { + encoding = '' + encoding; + switch (encoding && encoding.toLowerCase()) { + case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw': + return true; + default: + return false; + } +}; + +function _normalizeEncoding(enc) { + if (!enc) return 'utf8'; + var retried; + while (true) { + switch (enc) { + case 'utf8': + case 'utf-8': + return 'utf8'; + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return 'utf16le'; + case 'latin1': + case 'binary': + return 'latin1'; + case 'base64': + case 'ascii': + case 'hex': + return enc; + default: + if (retried) return; // undefined + enc = ('' + enc).toLowerCase(); + retried = true; + } + } +}; + +// Do not cache `Buffer.isEncoding` when checking encoding names as some +// modules monkey-patch it to support additional encodings +function normalizeEncoding(enc) { + var nenc = _normalizeEncoding(enc); + if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); + return nenc || enc; +} + +// StringDecoder provides an interface for efficiently splitting a series of +// buffers into a series of JS strings without breaking apart multi-byte +// characters. +exports.StringDecoder = StringDecoder; +function StringDecoder(encoding) { + this.encoding = normalizeEncoding(encoding); + var nb; + switch (this.encoding) { + case 'utf16le': + this.text = utf16Text; + this.end = utf16End; + nb = 4; + break; + case 'utf8': + this.fillLast = utf8FillLast; + nb = 4; + break; + case 'base64': + this.text = base64Text; + this.end = base64End; + nb = 3; + break; + default: + this.write = simpleWrite; + this.end = simpleEnd; + return; + } + this.lastNeed = 0; + this.lastTotal = 0; + this.lastChar = Buffer.allocUnsafe(nb); +} + +StringDecoder.prototype.write = function (buf) { + if (buf.length === 0) return ''; + var r; + var i; + if (this.lastNeed) { + r = this.fillLast(buf); + if (r === undefined) return ''; + i = this.lastNeed; + this.lastNeed = 0; + } else { + i = 0; + } + if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i); + return r || ''; +}; + +StringDecoder.prototype.end = utf8End; + +// Returns only complete characters in a Buffer +StringDecoder.prototype.text = utf8Text; + +// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer +StringDecoder.prototype.fillLast = function (buf) { + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); + } + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length); + this.lastNeed -= buf.length; +}; + +// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a +// continuation byte. If an invalid byte is detected, -2 is returned. +function utf8CheckByte(byte) { + if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; + return byte >> 6 === 0x02 ? -1 : -2; +} + +// Checks at most 3 bytes at the end of a Buffer in order to detect an +// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4) +// needed to complete the UTF-8 character (if applicable) are returned. +function utf8CheckIncomplete(self, buf, i) { + var j = buf.length - 1; + if (j < i) return 0; + var nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 1; + return nb; + } + if (--j < i || nb === -2) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 2; + return nb; + } + if (--j < i || nb === -2) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) { + if (nb === 2) nb = 0;else self.lastNeed = nb - 3; + } + return nb; + } + return 0; +} + +// Validates as many continuation bytes for a multi-byte UTF-8 character as +// needed or are available. If we see a non-continuation byte where we expect +// one, we "replace" the validated continuation bytes we've seen so far with +// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding +// behavior. The continuation byte check is included three times in the case +// where all of the continuation bytes for a character exist in the same buffer. +// It is also done this way as a slight performance increase instead of using a +// loop. +function utf8CheckExtraBytes(self, buf, p) { + if ((buf[0] & 0xC0) !== 0x80) { + self.lastNeed = 0; + return '\ufffd'; + } + if (self.lastNeed > 1 && buf.length > 1) { + if ((buf[1] & 0xC0) !== 0x80) { + self.lastNeed = 1; + return '\ufffd'; + } + if (self.lastNeed > 2 && buf.length > 2) { + if ((buf[2] & 0xC0) !== 0x80) { + self.lastNeed = 2; + return '\ufffd'; + } + } + } +} + +// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer. +function utf8FillLast(buf) { + var p = this.lastTotal - this.lastNeed; + var r = utf8CheckExtraBytes(this, buf, p); + if (r !== undefined) return r; + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, p, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); + } + buf.copy(this.lastChar, p, 0, buf.length); + this.lastNeed -= buf.length; +} + +// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a +// partial character, the character's bytes are buffered until the required +// number of bytes are available. +function utf8Text(buf, i) { + var total = utf8CheckIncomplete(this, buf, i); + if (!this.lastNeed) return buf.toString('utf8', i); + this.lastTotal = total; + var end = buf.length - (total - this.lastNeed); + buf.copy(this.lastChar, 0, end); + return buf.toString('utf8', i, end); +} + +// For UTF-8, a replacement character is added when ending on a partial +// character. +function utf8End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + '\ufffd'; + return r; +} + +// UTF-16LE typically needs two bytes per character, but even if we have an even +// number of bytes available, we need to check if we end on a leading/high +// surrogate. In that case, we need to wait for the next two bytes in order to +// decode the last character properly. +function utf16Text(buf, i) { + if ((buf.length - i) % 2 === 0) { + var r = buf.toString('utf16le', i); + if (r) { + var c = r.charCodeAt(r.length - 1); + if (c >= 0xD800 && c <= 0xDBFF) { + this.lastNeed = 2; + this.lastTotal = 4; + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + return r.slice(0, -1); + } + } + return r; + } + this.lastNeed = 1; + this.lastTotal = 2; + this.lastChar[0] = buf[buf.length - 1]; + return buf.toString('utf16le', i, buf.length - 1); +} + +// For UTF-16LE we do not explicitly append special replacement characters if we +// end on a partial character, we simply let v8 handle that. +function utf16End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) { + var end = this.lastTotal - this.lastNeed; + return r + this.lastChar.toString('utf16le', 0, end); + } + return r; +} + +function base64Text(buf, i) { + var n = (buf.length - i) % 3; + if (n === 0) return buf.toString('base64', i); + this.lastNeed = 3 - n; + this.lastTotal = 3; + if (n === 1) { + this.lastChar[0] = buf[buf.length - 1]; + } else { + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + } + return buf.toString('base64', i, buf.length - n); +} + +function base64End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed); + return r; +} + +// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex) +function simpleWrite(buf) { + return buf.toString(this.encoding); +} + +function simpleEnd(buf) { + return buf && buf.length ? this.write(buf) : ''; +} +},{"safe-buffer":97}],114:[function(_dereq_,module,exports){ +(function (process,Buffer){(function (){ + +/** + * Module dependencies. + */ + +var assert = _dereq_('assert'); +var debug = _dereq_('debug')('stream-parser'); + +/** + * Module exports. + */ + +module.exports = Parser; + +/** + * Parser states. + */ + +var INIT = -1; +var BUFFERING = 0; +var SKIPPING = 1; +var PASSTHROUGH = 2; + +/** + * The `Parser` stream mixin works with either `Writable` or `Transform` stream + * instances/subclasses. Provides a convenient generic "parsing" API: + * + * _bytes(n, cb) - buffers "n" bytes and then calls "cb" with the "chunk" + * _skipBytes(n, cb) - skips "n" bytes and then calls "cb" when done + * + * If you extend a `Transform` stream, then the `_passthrough()` function is also + * added: + * + * _passthrough(n, cb) - passes through "n" bytes untouched and then calls "cb" + * + * @param {Stream} stream Transform or Writable stream instance to extend + * @api public + */ + +function Parser (stream) { + var isTransform = stream && 'function' == typeof stream._transform; + var isWritable = stream && 'function' == typeof stream._write; + + if (!isTransform && !isWritable) throw new Error('must pass a Writable or Transform stream in'); + debug('extending Parser into stream'); + + // Transform streams and Writable streams get `_bytes()` and `_skipBytes()` + stream._bytes = _bytes; + stream._skipBytes = _skipBytes; + + // only Transform streams get the `_passthrough()` function + if (isTransform) stream._passthrough = _passthrough; + + // take control of the streams2 callback functions for this stream + if (isTransform) { + stream._transform = transform; + } else { + stream._write = write; + } +} + +function init (stream) { + debug('initializing parser stream'); + + // number of bytes left to parser for the next "chunk" + stream._parserBytesLeft = 0; + + // array of Buffer instances that make up the next "chunk" + stream._parserBuffers = []; + + // number of bytes parsed so far for the next "chunk" + stream._parserBuffered = 0; + + // flag that keeps track of if what the parser should do with bytes received + stream._parserState = INIT; + + // the callback for the next "chunk" + stream._parserCallback = null; + + // XXX: backwards compat with the old Transform API... remove at some point.. + if ('function' == typeof stream.push) { + stream._parserOutput = stream.push.bind(stream); + } + + stream._parserInit = true; +} + +/** + * Buffers `n` bytes and then invokes `fn` once that amount has been collected. + * + * @param {Number} n the number of bytes to buffer + * @param {Function} fn callback function to invoke when `n` bytes are buffered + * @api public + */ + +function _bytes (n, fn) { + assert(!this._parserCallback, 'there is already a "callback" set!'); + assert(isFinite(n) && n > 0, 'can only buffer a finite number of bytes > 0, got "' + n + '"'); + if (!this._parserInit) init(this); + debug('buffering %o bytes', n); + this._parserBytesLeft = n; + this._parserCallback = fn; + this._parserState = BUFFERING; +} + +/** + * Skips over the next `n` bytes, then invokes `fn` once that amount has + * been discarded. + * + * @param {Number} n the number of bytes to discard + * @param {Function} fn callback function to invoke when `n` bytes have been skipped + * @api public + */ + +function _skipBytes (n, fn) { + assert(!this._parserCallback, 'there is already a "callback" set!'); + assert(n > 0, 'can only skip > 0 bytes, got "' + n + '"'); + if (!this._parserInit) init(this); + debug('skipping %o bytes', n); + this._parserBytesLeft = n; + this._parserCallback = fn; + this._parserState = SKIPPING; +} + +/** + * Passes through `n` bytes to the readable side of this stream untouched, + * then invokes `fn` once that amount has been passed through. + * + * @param {Number} n the number of bytes to pass through + * @param {Function} fn callback function to invoke when `n` bytes have passed through + * @api public + */ + +function _passthrough (n, fn) { + assert(!this._parserCallback, 'There is already a "callback" set!'); + assert(n > 0, 'can only pass through > 0 bytes, got "' + n + '"'); + if (!this._parserInit) init(this); + debug('passing through %o bytes', n); + this._parserBytesLeft = n; + this._parserCallback = fn; + this._parserState = PASSTHROUGH; +} + +/** + * The `_write()` callback function implementation. + * + * @api private + */ + +function write (chunk, encoding, fn) { + if (!this._parserInit) init(this); + debug('write(%o bytes)', chunk.length); + + // XXX: old Writable stream API compat... remove at some point... + if ('function' == typeof encoding) fn = encoding; + + data(this, chunk, null, fn); +} + +/** + * The `_transform()` callback function implementation. + * + * @api private + */ + + +function transform (chunk, output, fn) { + if (!this._parserInit) init(this); + debug('transform(%o bytes)', chunk.length); + + // XXX: old Transform stream API compat... remove at some point... + if ('function' != typeof output) { + output = this._parserOutput; + } + + data(this, chunk, output, fn); +} + +/** + * The internal buffering/passthrough logic... + * + * This `_data` function get's "trampolined" to prevent stack overflows for tight + * loops. This technique requires us to return a "thunk" function for any + * synchronous action. Async stuff breaks the trampoline, but that's ok since it's + * working with a new stack at that point anyway. + * + * @api private + */ + +function _data (stream, chunk, output, fn) { + if (stream._parserBytesLeft <= 0) { + return fn(new Error('got data but not currently parsing anything')); + } + + if (chunk.length <= stream._parserBytesLeft) { + // small buffer fits within the "_parserBytesLeft" window + return function () { + return process(stream, chunk, output, fn); + }; + } else { + // large buffer needs to be sliced on "_parserBytesLeft" and processed + return function () { + var b = chunk.slice(0, stream._parserBytesLeft); + return process(stream, b, output, function (err) { + if (err) return fn(err); + if (chunk.length > b.length) { + return function () { + return _data(stream, chunk.slice(b.length), output, fn); + }; + } + }); + }; + } +} + +/** + * The internal `process` function gets called by the `data` function when + * something "interesting" happens. This function takes care of buffering the + * bytes when buffering, passing through the bytes when doing that, and invoking + * the user callback when the number of bytes has been reached. + * + * @api private + */ + +function process (stream, chunk, output, fn) { + stream._parserBytesLeft -= chunk.length; + debug('%o bytes left for stream piece', stream._parserBytesLeft); + + if (stream._parserState === BUFFERING) { + // buffer + stream._parserBuffers.push(chunk); + stream._parserBuffered += chunk.length; + } else if (stream._parserState === PASSTHROUGH) { + // passthrough + output(chunk); + } + // don't need to do anything for the SKIPPING case + + if (0 === stream._parserBytesLeft) { + // done with stream "piece", invoke the callback + var cb = stream._parserCallback; + if (cb && stream._parserState === BUFFERING && stream._parserBuffers.length > 1) { + chunk = Buffer.concat(stream._parserBuffers, stream._parserBuffered); + } + if (stream._parserState !== BUFFERING) { + chunk = null; + } + stream._parserCallback = null; + stream._parserBuffered = 0; + stream._parserState = INIT; + stream._parserBuffers.splice(0); // empty + + if (cb) { + var args = []; + if (chunk) { + // buffered + args.push(chunk); + } else { + // passthrough + } + if (output) { + // on a Transform stream, has "output" function + args.push(output); + } + var async = cb.length > args.length; + if (async) { + args.push(trampoline(fn)); + } + // invoke cb + var rtn = cb.apply(stream, args); + if (!async || fn === rtn) return fn; + } + } else { + // need more bytes + return fn; + } +} + +var data = trampoline(_data); + +/** + * Generic thunk-based "trampoline" helper function. + * + * @param {Function} input function + * @return {Function} "trampolined" function + * @api private + */ + +function trampoline (fn) { + return function () { + var result = fn.apply(this, arguments); + + while ('function' == typeof result) { + result = result(); + } + + return result; + }; +} + +}).call(this)}).call(this,_dereq_('_process'),_dereq_("buffer").Buffer) +},{"_process":96,"assert":21,"buffer":28,"debug":115}],115:[function(_dereq_,module,exports){ +(function (process){(function (){ +/** + * This is the web browser implementation of `debug()`. + * + * Expose `debug()` as the module. + */ + +exports = module.exports = _dereq_('./debug'); +exports.log = log; +exports.formatArgs = formatArgs; +exports.save = save; +exports.load = load; +exports.useColors = useColors; +exports.storage = 'undefined' != typeof chrome + && 'undefined' != typeof chrome.storage + ? chrome.storage.local + : localstorage(); + +/** + * Colors. + */ + +exports.colors = [ + 'lightseagreen', + 'forestgreen', + 'goldenrod', + 'dodgerblue', + 'darkorchid', + 'crimson' +]; + +/** + * Currently only WebKit-based Web Inspectors, Firefox >= v31, + * and the Firebug extension (any Firefox version) are known + * to support "%c" CSS customizations. + * + * TODO: add a `localStorage` variable to explicitly enable/disable colors + */ + +function useColors() { + // NB: In an Electron preload script, document will be defined but not fully + // initialized. Since we know we're in Chrome, we'll just detect this case + // explicitly + if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') { + return true; + } + + // is webkit? http://stackoverflow.com/a/16459606/376773 + // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 + return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || + // is firebug? http://stackoverflow.com/a/398120/376773 + (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || + // is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + // double check webkit in userAgent just in case we are in a worker + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); +} + +/** + * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. + */ + +exports.formatters.j = function(v) { + try { + return JSON.stringify(v); + } catch (err) { + return '[UnexpectedJSONParseError]: ' + err.message; + } +}; + + +/** + * Colorize log arguments if enabled. + * + * @api public + */ + +function formatArgs(args) { + var useColors = this.useColors; + + args[0] = (useColors ? '%c' : '') + + this.namespace + + (useColors ? ' %c' : ' ') + + args[0] + + (useColors ? '%c ' : ' ') + + '+' + exports.humanize(this.diff); + + if (!useColors) return; + + var c = 'color: ' + this.color; + args.splice(1, 0, c, 'color: inherit') + + // the final "%c" is somewhat tricky, because there could be other + // arguments passed either before or after the %c, so we need to + // figure out the correct index to insert the CSS into + var index = 0; + var lastC = 0; + args[0].replace(/%[a-zA-Z%]/g, function(match) { + if ('%%' === match) return; + index++; + if ('%c' === match) { + // we only are interested in the *last* %c + // (the user may have provided their own) + lastC = index; + } + }); + + args.splice(lastC, 0, c); +} + +/** + * Invokes `console.log()` when available. + * No-op when `console.log` is not a "function". + * + * @api public + */ + +function log() { + // this hackery is required for IE8/9, where + // the `console.log` function doesn't have 'apply' + return 'object' === typeof console + && console.log + && Function.prototype.apply.call(console.log, console, arguments); +} + +/** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ + +function save(namespaces) { + try { + if (null == namespaces) { + exports.storage.removeItem('debug'); + } else { + exports.storage.debug = namespaces; + } + } catch(e) {} +} + +/** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ + +function load() { + var r; + try { + r = exports.storage.debug; + } catch(e) {} + + // If debug isn't set in LS, and we're in Electron, try to load $DEBUG + if (!r && typeof process !== 'undefined' && 'env' in process) { + r = process.env.DEBUG; + } + + return r; +} + +/** + * Enable namespaces listed in `localStorage.debug` initially. + */ + +exports.enable(load()); + +/** + * Localstorage attempts to return the localstorage. + * + * This is necessary because safari throws + * when a user disables cookies/localstorage + * and you attempt to access it. + * + * @return {LocalStorage} + * @api private + */ + +function localstorage() { + try { + return window.localStorage; + } catch (e) {} +} + +}).call(this)}).call(this,_dereq_('_process')) +},{"./debug":116,"_process":96}],116:[function(_dereq_,module,exports){ + +/** + * This is the common logic for both the Node.js and web browser + * implementations of `debug()`. + * + * Expose `debug()` as the module. + */ + +exports = module.exports = createDebug.debug = createDebug['default'] = createDebug; +exports.coerce = coerce; +exports.disable = disable; +exports.enable = enable; +exports.enabled = enabled; +exports.humanize = _dereq_('ms'); + +/** + * The currently active debug mode names, and names to skip. + */ + +exports.names = []; +exports.skips = []; + +/** + * Map of special "%n" handling functions, for the debug "format" argument. + * + * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". + */ + +exports.formatters = {}; + +/** + * Previous log timestamp. + */ + +var prevTime; + +/** + * Select a color. + * @param {String} namespace + * @return {Number} + * @api private + */ + +function selectColor(namespace) { + var hash = 0, i; + + for (i in namespace) { + hash = ((hash << 5) - hash) + namespace.charCodeAt(i); + hash |= 0; // Convert to 32bit integer + } + + return exports.colors[Math.abs(hash) % exports.colors.length]; +} + +/** + * Create a debugger with the given `namespace`. + * + * @param {String} namespace + * @return {Function} + * @api public + */ + +function createDebug(namespace) { + + function debug() { + // disabled? + if (!debug.enabled) return; + + var self = debug; + + // set `diff` timestamp + var curr = +new Date(); + var ms = curr - (prevTime || curr); + self.diff = ms; + self.prev = prevTime; + self.curr = curr; + prevTime = curr; + + // turn the `arguments` into a proper Array + var args = new Array(arguments.length); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i]; + } + + args[0] = exports.coerce(args[0]); + + if ('string' !== typeof args[0]) { + // anything else let's inspect with %O + args.unshift('%O'); + } + + // apply any `formatters` transformations + var index = 0; + args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { + // if we encounter an escaped % then don't increase the array index + if (match === '%%') return match; + index++; + var formatter = exports.formatters[format]; + if ('function' === typeof formatter) { + var val = args[index]; + match = formatter.call(self, val); + + // now we need to remove `args[index]` since it's inlined in the `format` + args.splice(index, 1); + index--; + } + return match; + }); + + // apply env-specific formatting (colors, etc.) + exports.formatArgs.call(self, args); + + var logFn = debug.log || exports.log || console.log.bind(console); + logFn.apply(self, args); + } + + debug.namespace = namespace; + debug.enabled = exports.enabled(namespace); + debug.useColors = exports.useColors(); + debug.color = selectColor(namespace); + + // env-specific initialization logic for debug instances + if ('function' === typeof exports.init) { + exports.init(debug); + } + + return debug; +} + +/** + * Enables a debug mode by namespaces. This can include modes + * separated by a colon and wildcards. + * + * @param {String} namespaces + * @api public + */ + +function enable(namespaces) { + exports.save(namespaces); + + exports.names = []; + exports.skips = []; + + var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); + var len = split.length; + + for (var i = 0; i < len; i++) { + if (!split[i]) continue; // ignore empty strings + namespaces = split[i].replace(/\*/g, '.*?'); + if (namespaces[0] === '-') { + exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); + } else { + exports.names.push(new RegExp('^' + namespaces + '$')); + } + } +} + +/** + * Disable debug output. + * + * @api public + */ + +function disable() { + exports.enable(''); +} + +/** + * Returns true if the given mode name is enabled, false otherwise. + * + * @param {String} name + * @return {Boolean} + * @api public + */ + +function enabled(name) { + var i, len; + for (i = 0, len = exports.skips.length; i < len; i++) { + if (exports.skips[i].test(name)) { + return false; + } + } + for (i = 0, len = exports.names.length; i < len; i++) { + if (exports.names[i].test(name)) { + return true; + } + } + return false; +} + +/** + * Coerce `val`. + * + * @param {Mixed} val + * @return {Mixed} + * @api private + */ + +function coerce(val) { + if (val instanceof Error) return val.stack || val.message; + return val; +} + +},{"ms":117}],117:[function(_dereq_,module,exports){ +/** + * Helpers. + */ + +var s = 1000; +var m = s * 60; +var h = m * 60; +var d = h * 24; +var y = d * 365.25; + +/** + * Parse or format the given `val`. + * + * Options: + * + * - `long` verbose formatting [false] + * + * @param {String|Number} val + * @param {Object} [options] + * @throws {Error} throw an error if val is not a non-empty string or a number + * @return {String|Number} + * @api public + */ + +module.exports = function(val, options) { + options = options || {}; + var type = typeof val; + if (type === 'string' && val.length > 0) { + return parse(val); + } else if (type === 'number' && isNaN(val) === false) { + return options.long ? fmtLong(val) : fmtShort(val); + } + throw new Error( + 'val is not a non-empty string or a valid number. val=' + + JSON.stringify(val) + ); +}; + +/** + * Parse the given `str` and return milliseconds. + * + * @param {String} str + * @return {Number} + * @api private + */ + +function parse(str) { + str = String(str); + if (str.length > 100) { + return; + } + var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec( + str + ); + if (!match) { + return; + } + var n = parseFloat(match[1]); + var type = (match[2] || 'ms').toLowerCase(); + switch (type) { + case 'years': + case 'year': + case 'yrs': + case 'yr': + case 'y': + return n * y; + case 'days': + case 'day': + case 'd': + return n * d; + case 'hours': + case 'hour': + case 'hrs': + case 'hr': + case 'h': + return n * h; + case 'minutes': + case 'minute': + case 'mins': + case 'min': + case 'm': + return n * m; + case 'seconds': + case 'second': + case 'secs': + case 'sec': + case 's': + return n * s; + case 'milliseconds': + case 'millisecond': + case 'msecs': + case 'msec': + case 'ms': + return n; + default: + return undefined; + } +} + +/** + * Short format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + +function fmtShort(ms) { + if (ms >= d) { + return Math.round(ms / d) + 'd'; + } + if (ms >= h) { + return Math.round(ms / h) + 'h'; + } + if (ms >= m) { + return Math.round(ms / m) + 'm'; + } + if (ms >= s) { + return Math.round(ms / s) + 's'; + } + return ms + 'ms'; +} + +/** + * Long format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + +function fmtLong(ms) { + return plural(ms, d, 'day') || + plural(ms, h, 'hour') || + plural(ms, m, 'minute') || + plural(ms, s, 'second') || + ms + ' ms'; +} + +/** + * Pluralization helper. + */ + +function plural(ms, n, name) { + if (ms < n) { + return; + } + if (ms < n * 1.5) { + return Math.floor(ms / n) + ' ' + name; + } + return Math.ceil(ms / n) + ' ' + name + 's'; +} + +},{}],118:[function(_dereq_,module,exports){ +(function (setImmediate,clearImmediate){(function (){ +var nextTick = _dereq_('process/browser.js').nextTick; +var apply = Function.prototype.apply; +var slice = Array.prototype.slice; +var immediateIds = {}; +var nextImmediateId = 0; + +// DOM APIs, for completeness + +exports.setTimeout = function() { + return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout); +}; +exports.setInterval = function() { + return new Timeout(apply.call(setInterval, window, arguments), clearInterval); +}; +exports.clearTimeout = +exports.clearInterval = function(timeout) { timeout.close(); }; + +function Timeout(id, clearFn) { + this._id = id; + this._clearFn = clearFn; +} +Timeout.prototype.unref = Timeout.prototype.ref = function() {}; +Timeout.prototype.close = function() { + this._clearFn.call(window, this._id); +}; + +// Does not start the time, just sets up the members needed. +exports.enroll = function(item, msecs) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = msecs; +}; + +exports.unenroll = function(item) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = -1; +}; + +exports._unrefActive = exports.active = function(item) { + clearTimeout(item._idleTimeoutId); + + var msecs = item._idleTimeout; + if (msecs >= 0) { + item._idleTimeoutId = setTimeout(function onTimeout() { + if (item._onTimeout) + item._onTimeout(); + }, msecs); + } +}; + +// That's not how node.js implements it but the exposed api is the same. +exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) { + var id = nextImmediateId++; + var args = arguments.length < 2 ? false : slice.call(arguments, 1); + + immediateIds[id] = true; + + nextTick(function onNextTick() { + if (immediateIds[id]) { + // fn.call() is faster so we optimize for the common use-case + // @see http://jsperf.com/call-apply-segu + if (args) { + fn.apply(null, args); + } else { + fn.call(null); + } + // Prevent ids from leaking + exports.clearImmediate(id); + } + }); + + return id; +}; + +exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) { + delete immediateIds[id]; +}; +}).call(this)}).call(this,_dereq_("timers").setImmediate,_dereq_("timers").clearImmediate) +},{"process/browser.js":96,"timers":118}],119:[function(_dereq_,module,exports){ // TinyColor v1.4.2 // https://github.com/bgrins/TinyColor // Brian Grinstead, MIT License @@ -20541,15 +25333,5277 @@ else { })(Math); -},{}],89:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +},{}],120:[function(_dereq_,module,exports){ +(function (global){(function (){ +/** + * Module exports. + */ + +module.exports = deprecate; + +/** + * Mark that a method should not be used. + * Returns a modified function which warns once by default. + * + * If `localStorage.noDeprecation = true` is set, then it is a no-op. + * + * If `localStorage.throwDeprecation = true` is set, then deprecated functions + * will throw an Error when invoked. + * + * If `localStorage.traceDeprecation = true` is set, then deprecated functions + * will invoke `console.trace()` instead of `console.error()`. + * + * @param {Function} fn - the function to deprecate + * @param {String} msg - the string to print to the console when `fn` is invoked + * @returns {Function} a new "deprecated" version of `fn` + * @api public + */ + +function deprecate (fn, msg) { + if (config('noDeprecation')) { + return fn; + } + + var warned = false; + function deprecated() { + if (!warned) { + if (config('throwDeprecation')) { + throw new Error(msg); + } else if (config('traceDeprecation')) { + console.trace(msg); + } else { + console.warn(msg); + } + warned = true; + } + return fn.apply(this, arguments); + } + + return deprecated; +} + +/** + * Checks `localStorage` for boolean values for the given `name`. + * + * @param {String} name + * @returns {Boolean} + * @api private + */ + +function config (name) { + // accessing global.localStorage can trigger a DOMException in sandboxed iframes + try { + if (!global.localStorage) return false; + } catch (_) { + return false; + } + var val = global.localStorage[name]; + if (null == val) return false; + return String(val).toLowerCase() === 'true'; +} + +}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],121:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Traditional Chinese calendar for jQuery v2.0.2. + Written by Nicolas Riesco (enquiries@nicolasriesco.net) December 2016. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +var gregorianCalendar = main.instance(); + +/** Implementation of the traditional Chinese calendar. + Source of calendar tables https://github.com/isee15/Lunar-Solar-Calendar-Converter . + @class ChineseCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function ChineseCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +ChineseCalendar.prototype = new main.baseCalendar; + +assign(ChineseCalendar.prototype, { + /** The calendar name. + @memberof ChineseCalendar */ + name: 'Chinese', + /** Julian date of start of Gregorian epoch: 1 January 0001 CE. + @memberof GregorianCalendar */ + jdEpoch: 1721425.5, + /** true if has a year zero, false if not. + @memberof ChineseCalendar */ + hasYearZero: false, + /** The minimum month number. + This calendar uses month indices to account for intercalary months. + @memberof ChineseCalendar */ + minMonth: 0, + /** The first month in the year. + This calendar uses month indices to account for intercalary months. + @memberof ChineseCalendar */ + firstMonth: 0, + /** The minimum day number. + @memberof ChineseCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof ChineseCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Chinese', + epochs: ['BEC', 'EC'], + monthNumbers: function(date, padded) { + if (typeof date === 'string') { + var match = date.match(MONTH_NUMBER_REGEXP); + return (match) ? match[0] : ''; + } + + var year = this._validateYear(date); + var monthIndex = date.month(); + + var month = '' + this.toChineseMonth(year, monthIndex); + + if (padded && month.length < 2) { + month = "0" + month; + } + + if (this.isIntercalaryMonth(year, monthIndex)) { + month += 'i'; + } + + return month; + }, + monthNames: function(date) { + if (typeof date === 'string') { + var match = date.match(MONTH_NAME_REGEXP); + return (match) ? match[0] : ''; + } + + var year = this._validateYear(date); + var monthIndex = date.month(); + + var month = this.toChineseMonth(year, monthIndex); + + var monthName = ['一月','二月','三月','四月','五月','六月', + '七月','八月','九月','十月','十一月','十二月'][month - 1]; + + if (this.isIntercalaryMonth(year, monthIndex)) { + monthName = '闰' + monthName; + } + + return monthName; + }, + monthNamesShort: function(date) { + if (typeof date === 'string') { + var match = date.match(MONTH_SHORT_NAME_REGEXP); + return (match) ? match[0] : ''; + } + + var year = this._validateYear(date); + var monthIndex = date.month(); + + var month = this.toChineseMonth(year, monthIndex); + + var monthName = ['一','二','三','四','五','六', + '七','八','九','十','十一','十二'][month - 1]; + + if (this.isIntercalaryMonth(year, monthIndex)) { + monthName = '闰' + monthName; + } + + return monthName; + }, + parseMonth: function(year, monthString) { + year = this._validateYear(year); + var month = parseInt(monthString); + var isIntercalary; + + if (!isNaN(month)) { + var i = monthString[monthString.length - 1]; + isIntercalary = (i === 'i' || i === 'I'); + } else { + if (monthString[0] === '闰') { + isIntercalary = true; + monthString = monthString.substring(1); + } + if (monthString[monthString.length - 1] === '月') { + monthString = monthString.substring(0, monthString.length - 1); + } + month = 1 + + ['一','二','三','四','五','六', + '七','八','九','十','十一','十二'].indexOf(monthString); + } + + var monthIndex = this.toMonthIndex(year, month, isIntercalary); + return monthIndex; + }, + dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], + dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], + dayNamesMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], + digits: null, + dateFormat: 'yyyy/mm/dd', + firstDay: 1, + isRTL: false + } + }, + + /** Check that a candidate date is from the same calendar and is valid. + @memberof BaseCalendar + @private + @param year {CDate|number} The date or the year to validate. + @param error {string} Error message if invalid. + @return {number} The year. + @throws Error if year out of range. */ + _validateYear: function(year, error) { + if (year.year) { + year = year.year(); + } + + if (typeof year !== 'number' || year < 1888 || year > 2111) { + throw error.replace(/\{0\}/, this.local.name); + } + + return year; + }, + + /** Retrieve the month index (i.e. accounting for intercalary months). + @memberof ChineseCalendar + @param year {number} The year. + @param month {number} The month (1 for first month). + @param [isIntercalary=false] {boolean} If month is intercalary. + @return {number} The month index (0 for first month). + @throws Error if an invalid month/year or a different calendar used. */ + toMonthIndex: function(year, month, isIntercalary) { + // compute intercalary month in the year (0 if none) + var intercalaryMonth = this.intercalaryMonth(year); + + // validate month + var invalidIntercalaryMonth = + (isIntercalary && month !== intercalaryMonth); + if (invalidIntercalaryMonth || month < 1 || month > 12) { + throw main.local.invalidMonth + .replace(/\{0\}/, this.local.name); + } + + // compute month index + var monthIndex; + + if (!intercalaryMonth) { + monthIndex = month - 1; + } else if(!isIntercalary && month <= intercalaryMonth) { + monthIndex = month - 1; + } else { + monthIndex = month; + } + + return monthIndex; + }, + + /** Retrieve the month (i.e. accounting for intercalary months). + @memberof ChineseCalendar + @param year {CDate|number} The date or the year to examine. + @param monthIndex {number} The month index (0 for first month). + @return {number} The month (1 for first month). + @throws Error if an invalid month/year or a different calendar used. */ + toChineseMonth: function(year, monthIndex) { + if (year.year) { + year = year.year(); + monthIndex = year.month(); + } + + // compute intercalary month in the year (0 if none) + var intercalaryMonth = this.intercalaryMonth(year); + + // validate month + var maxMonthIndex = (intercalaryMonth) ? 12 : 11; + if (monthIndex < 0 || monthIndex > maxMonthIndex) { + throw main.local.invalidMonth + .replace(/\{0\}/, this.local.name); + } + + // compute Chinese month + var month; + + if (!intercalaryMonth) { + month = monthIndex + 1; + } else if(monthIndex < intercalaryMonth) { + month = monthIndex + 1; + } else { + month = monthIndex; + } + + return month; + }, + + /** Determine the intercalary month of a year (if any). + @memberof ChineseCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The intercalary month number, or 0 if none. + @throws Error if an invalid year or a different calendar used. */ + intercalaryMonth: function(year) { + year = this._validateYear(year); + + var monthDaysTable = LUNAR_MONTH_DAYS[year - LUNAR_MONTH_DAYS[0]]; + var intercalaryMonth = monthDaysTable >> 13; + + return intercalaryMonth; + }, + + /** Determine whether this date is an intercalary month. + @memberof ChineseCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [monthIndex] {number} The month index to examine. + @return {boolean} true if this is an intercalary month, false if not. + @throws Error if an invalid year or a different calendar used. */ + isIntercalaryMonth: function(year, monthIndex) { + if (year.year) { + year = year.year(); + monthIndex = year.month(); + } + + var intercalaryMonth = this.intercalaryMonth(year); + + return !!intercalaryMonth && intercalaryMonth === monthIndex; + }, + + /** Determine whether this date is in a leap year. + @memberof ChineseCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + return (this.intercalaryMonth(year) !== 0); + }, + + /** Determine the week of the year for a date - ISO 8601. + @memberof ChineseCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [monthIndex] {number} The month index to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, monthIndex, day) { + // compute Chinese new year + var validatedYear = + this._validateYear(year, main.local.invalidyear); + var packedDate = + CHINESE_NEW_YEAR[validatedYear - CHINESE_NEW_YEAR[0]]; + + var y = (packedDate >> 9) & 0xFFF; + var m = (packedDate >> 5) & 0x0F; + var d = packedDate & 0x1F; + + // find first Thrusday of the year + var firstThursday; + firstThursday = gregorianCalendar.newDate(y, m, d); + firstThursday.add(4 - (firstThursday.dayOfWeek() || 7), 'd'); + + // compute days from first Thursday + var offset = + this.toJD(year, monthIndex, day) - firstThursday.toJD(); + return 1 + Math.floor(offset / 7); + }, + + /** Retrieve the number of months in a year. + @memberof ChineseCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of months. + @throws Error if an invalid year or a different calendar used. */ + monthsInYear: function(year) { + return (this.leapYear(year)) ? 13 : 12; + }, + + /** Retrieve the number of days in a month. + @memberof ChineseCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [monthIndex] {number} The month index. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, monthIndex) { + if (year.year) { + monthIndex = year.month(); + year = year.year(); + } + + year = this._validateYear(year); + + var monthDaysTable = LUNAR_MONTH_DAYS[year - LUNAR_MONTH_DAYS[0]]; + + var intercalaryMonth = monthDaysTable >> 13; + var maxMonthIndex = (intercalaryMonth) ? 12 : 11; + if (monthIndex > maxMonthIndex) { + throw main.local.invalidMonth + .replace(/\{0\}/, this.local.name); + } + + var daysInMonth = (monthDaysTable & (1 << (12 - monthIndex))) ? + 30 : 29; + + return daysInMonth; + }, + + /** Determine whether this date is a week day. + @memberof ChineseCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [monthIndex] {number} The month index to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, monthIndex, day) { + return (this.dayOfWeek(year, monthIndex, day) || 7) < 6; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof ChineseCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [monthIndex] {number} The month index to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, monthIndex, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + year = this._validateYear(date.year()); + monthIndex = date.month(); + day = date.day(); + + var isIntercalary = this.isIntercalaryMonth(year, monthIndex); + var month = this.toChineseMonth(year, monthIndex); + + var solar = toSolar(year, month, day, isIntercalary); + + return gregorianCalendar.toJD(solar.year, solar.month, solar.day); + }, + + /** Create a new date from a Julian date. + @memberof ChineseCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + var date = gregorianCalendar.fromJD(jd); + var lunar = toLunar(date.year(), date.month(), date.day()); + var monthIndex = this.toMonthIndex( + lunar.year, lunar.month, lunar.isIntercalary); + return this.newDate(lunar.year, monthIndex, lunar.day); + }, + + /** Create a new date from a string. + @memberof ChineseCalendar + @param dateString {string} String representing a Chinese date + @return {CDate} The new date. + @throws Error if an invalid date. */ + fromString: function(dateString) { + var match = dateString.match(DATE_REGEXP); + + var year = this._validateYear(+match[1]); + + var month = +match[2]; + var isIntercalary = !!match[3]; + var monthIndex = this.toMonthIndex(year, month, isIntercalary); + + var day = +match[4]; + + return this.newDate(year, monthIndex, day); + }, + + /** Add period(s) to a date. + Cater for no year zero. + @memberof ChineseCalendar + @param date {CDate} The starting date. + @param offset {number} The number of periods to adjust by. + @param period {string} One of 'y' for year, 'm' for month, 'w' for week, 'd' for day. + @return {CDate} The updated date. + @throws Error if a different calendar used. */ + add: function(date, offset, period) { + var year = date.year(); + var monthIndex = date.month(); + var isIntercalary = this.isIntercalaryMonth(year, monthIndex); + var month = this.toChineseMonth(year, monthIndex); + + var cdate = Object.getPrototypeOf(ChineseCalendar.prototype) + .add.call(this, date, offset, period); + + if (period === 'y') { + // Resync month + var resultYear = cdate.year(); + var resultMonthIndex = cdate.month(); + + // Using the fact the month index of an intercalary month + // equals its month number: + var resultCanBeIntercalaryMonth = + this.isIntercalaryMonth(resultYear, month); + + var correctedMonthIndex = + (isIntercalary && resultCanBeIntercalaryMonth) ? + this.toMonthIndex(resultYear, month, true) : + this.toMonthIndex(resultYear, month, false); + + if (correctedMonthIndex !== resultMonthIndex) { + cdate.month(correctedMonthIndex); + } + } + + return cdate; + }, +}); + +// Used by ChineseCalendar.prototype.fromString +var DATE_REGEXP = /^\s*(-?\d\d\d\d|\d\d)[-/](\d?\d)([iI]?)[-/](\d?\d)/m; +var MONTH_NUMBER_REGEXP = /^\d?\d[iI]?/m; +var MONTH_NAME_REGEXP = /^闰?十?[一二三四五六七八九]?月/m; +var MONTH_SHORT_NAME_REGEXP = /^闰?十?[一二三四五六七八九]?/m; + +// Chinese calendar implementation +main.calendars.chinese = ChineseCalendar; + +// Chinese calendar tables from year 1888 to 2111 +// +// Source: +// https://github.com/isee15/Lunar-Solar-Calendar-Converter.git + +// Table of intercalary months and days per month from year 1888 to 2111 +// +// bit (12 - i): days in the i^th month +// (= 0 if i^th lunar month has 29 days) +// (= 1 if i^th lunar month has 30 days) +// (first month in lunar year is i = 0) +// bits (13,14,15,16): intercalary month +// (= 0 if lunar year has no intercalary month) +var LUNAR_MONTH_DAYS = [1887, 0x1694, 0x16aa, 0x4ad5, + 0xab6, 0xc4b7, 0x4ae, 0xa56, 0xb52a, 0x1d2a, 0xd54, 0x75aa, 0x156a, + 0x1096d, 0x95c, 0x14ae, 0xaa4d, 0x1a4c, 0x1b2a, 0x8d55, 0xad4, + 0x135a, 0x495d, 0x95c, 0xd49b, 0x149a, 0x1a4a, 0xbaa5, 0x16a8, + 0x1ad4, 0x52da, 0x12b6, 0xe937, 0x92e, 0x1496, 0xb64b, 0xd4a, + 0xda8, 0x95b5, 0x56c, 0x12ae, 0x492f, 0x92e, 0xcc96, 0x1a94, + 0x1d4a, 0xada9, 0xb5a, 0x56c, 0x726e, 0x125c, 0xf92d, 0x192a, + 0x1a94, 0xdb4a, 0x16aa, 0xad4, 0x955b, 0x4ba, 0x125a, 0x592b, + 0x152a, 0xf695, 0xd94, 0x16aa, 0xaab5, 0x9b4, 0x14b6, 0x6a57, + 0xa56, 0x1152a, 0x1d2a, 0xd54, 0xd5aa, 0x156a, 0x96c, 0x94ae, + 0x14ae, 0xa4c, 0x7d26, 0x1b2a, 0xeb55, 0xad4, 0x12da, 0xa95d, + 0x95a, 0x149a, 0x9a4d, 0x1a4a, 0x11aa5, 0x16a8, 0x16d4, 0xd2da, + 0x12b6, 0x936, 0x9497, 0x1496, 0x1564b, 0xd4a, 0xda8, 0xd5b4, + 0x156c, 0x12ae, 0xa92f, 0x92e, 0xc96, 0x6d4a, 0x1d4a, 0x10d65, + 0xb58, 0x156c, 0xb26d, 0x125c, 0x192c, 0x9a95, 0x1a94, 0x1b4a, + 0x4b55, 0xad4, 0xf55b, 0x4ba, 0x125a, 0xb92b, 0x152a, 0x1694, + 0x96aa, 0x15aa, 0x12ab5, 0x974, 0x14b6, 0xca57, 0xa56, 0x1526, + 0x8e95, 0xd54, 0x15aa, 0x49b5, 0x96c, 0xd4ae, 0x149c, 0x1a4c, + 0xbd26, 0x1aa6, 0xb54, 0x6d6a, 0x12da, 0x1695d, 0x95a, 0x149a, + 0xda4b, 0x1a4a, 0x1aa4, 0xbb54, 0x16b4, 0xada, 0x495b, 0x936, + 0xf497, 0x1496, 0x154a, 0xb6a5, 0xda4, 0x15b4, 0x6ab6, 0x126e, + 0x1092f, 0x92e, 0xc96, 0xcd4a, 0x1d4a, 0xd64, 0x956c, 0x155c, + 0x125c, 0x792e, 0x192c, 0xfa95, 0x1a94, 0x1b4a, 0xab55, 0xad4, + 0x14da, 0x8a5d, 0xa5a, 0x1152b, 0x152a, 0x1694, 0xd6aa, 0x15aa, + 0xab4, 0x94ba, 0x14b6, 0xa56, 0x7527, 0xd26, 0xee53, 0xd54, 0x15aa, + 0xa9b5, 0x96c, 0x14ae, 0x8a4e, 0x1a4c, 0x11d26, 0x1aa4, 0x1b54, + 0xcd6a, 0xada, 0x95c, 0x949d, 0x149a, 0x1a2a, 0x5b25, 0x1aa4, + 0xfb52, 0x16b4, 0xaba, 0xa95b, 0x936, 0x1496, 0x9a4b, 0x154a, + 0x136a5, 0xda4, 0x15ac]; + +// Table of Chinese New Years from year 1888 to 2111 +// +// bits (0 to 4): solar day +// bits (5 to 8): solar month +// bits (9 to 20): solar year +var CHINESE_NEW_YEAR = [1887, 0xec04c, 0xec23f, 0xec435, 0xec649, + 0xec83e, 0xeca51, 0xecc46, 0xece3a, 0xed04d, 0xed242, 0xed436, + 0xed64a, 0xed83f, 0xeda53, 0xedc48, 0xede3d, 0xee050, 0xee244, + 0xee439, 0xee64d, 0xee842, 0xeea36, 0xeec4a, 0xeee3e, 0xef052, + 0xef246, 0xef43a, 0xef64e, 0xef843, 0xefa37, 0xefc4b, 0xefe41, + 0xf0054, 0xf0248, 0xf043c, 0xf0650, 0xf0845, 0xf0a38, 0xf0c4d, + 0xf0e42, 0xf1037, 0xf124a, 0xf143e, 0xf1651, 0xf1846, 0xf1a3a, + 0xf1c4e, 0xf1e44, 0xf2038, 0xf224b, 0xf243f, 0xf2653, 0xf2848, + 0xf2a3b, 0xf2c4f, 0xf2e45, 0xf3039, 0xf324d, 0xf3442, 0xf3636, + 0xf384a, 0xf3a3d, 0xf3c51, 0xf3e46, 0xf403b, 0xf424e, 0xf4443, + 0xf4638, 0xf484c, 0xf4a3f, 0xf4c52, 0xf4e48, 0xf503c, 0xf524f, + 0xf5445, 0xf5639, 0xf584d, 0xf5a42, 0xf5c35, 0xf5e49, 0xf603e, + 0xf6251, 0xf6446, 0xf663b, 0xf684f, 0xf6a43, 0xf6c37, 0xf6e4b, + 0xf703f, 0xf7252, 0xf7447, 0xf763c, 0xf7850, 0xf7a45, 0xf7c39, + 0xf7e4d, 0xf8042, 0xf8254, 0xf8449, 0xf863d, 0xf8851, 0xf8a46, + 0xf8c3b, 0xf8e4f, 0xf9044, 0xf9237, 0xf944a, 0xf963f, 0xf9853, + 0xf9a47, 0xf9c3c, 0xf9e50, 0xfa045, 0xfa238, 0xfa44c, 0xfa641, + 0xfa836, 0xfaa49, 0xfac3d, 0xfae52, 0xfb047, 0xfb23a, 0xfb44e, + 0xfb643, 0xfb837, 0xfba4a, 0xfbc3f, 0xfbe53, 0xfc048, 0xfc23c, + 0xfc450, 0xfc645, 0xfc839, 0xfca4c, 0xfcc41, 0xfce36, 0xfd04a, + 0xfd23d, 0xfd451, 0xfd646, 0xfd83a, 0xfda4d, 0xfdc43, 0xfde37, + 0xfe04b, 0xfe23f, 0xfe453, 0xfe648, 0xfe83c, 0xfea4f, 0xfec44, + 0xfee38, 0xff04c, 0xff241, 0xff436, 0xff64a, 0xff83e, 0xffa51, + 0xffc46, 0xffe3a, 0x10004e, 0x100242, 0x100437, 0x10064b, 0x100841, + 0x100a53, 0x100c48, 0x100e3c, 0x10104f, 0x101244, 0x101438, + 0x10164c, 0x101842, 0x101a35, 0x101c49, 0x101e3d, 0x102051, + 0x102245, 0x10243a, 0x10264e, 0x102843, 0x102a37, 0x102c4b, + 0x102e3f, 0x103053, 0x103247, 0x10343b, 0x10364f, 0x103845, + 0x103a38, 0x103c4c, 0x103e42, 0x104036, 0x104249, 0x10443d, + 0x104651, 0x104846, 0x104a3a, 0x104c4e, 0x104e43, 0x105038, + 0x10524a, 0x10543e, 0x105652, 0x105847, 0x105a3b, 0x105c4f, + 0x105e45, 0x106039, 0x10624c, 0x106441, 0x106635, 0x106849, + 0x106a3d, 0x106c51, 0x106e47, 0x10703c, 0x10724f, 0x107444, + 0x107638, 0x10784c, 0x107a3f, 0x107c53, 0x107e48]; + +function toLunar(yearOrDate, monthOrResult, day, result) { + var solarDate; + var lunarDate; + + if(typeof yearOrDate === 'object') { + solarDate = yearOrDate; + lunarDate = monthOrResult || {}; + + } else { + var isValidYear = (typeof yearOrDate === 'number') && + (yearOrDate >= 1888) && (yearOrDate <= 2111); + if(!isValidYear) + throw new Error("Solar year outside range 1888-2111"); + + var isValidMonth = (typeof monthOrResult === 'number') && + (monthOrResult >= 1) && (monthOrResult <= 12); + if(!isValidMonth) + throw new Error("Solar month outside range 1 - 12"); + + var isValidDay = (typeof day === 'number') && (day >= 1) && (day <= 31); + if(!isValidDay) + throw new Error("Solar day outside range 1 - 31"); + + solarDate = { + year: yearOrDate, + month: monthOrResult, + day: day, + }; + lunarDate = result || {}; + } + + // Compute Chinese new year and lunar year + var chineseNewYearPackedDate = + CHINESE_NEW_YEAR[solarDate.year - CHINESE_NEW_YEAR[0]]; + + var packedDate = (solarDate.year << 9) | (solarDate.month << 5) + | solarDate.day; + + lunarDate.year = (packedDate >= chineseNewYearPackedDate) ? + solarDate.year : + solarDate.year - 1; + + chineseNewYearPackedDate = + CHINESE_NEW_YEAR[lunarDate.year - CHINESE_NEW_YEAR[0]]; + + var y = (chineseNewYearPackedDate >> 9) & 0xFFF; + var m = (chineseNewYearPackedDate >> 5) & 0x0F; + var d = chineseNewYearPackedDate & 0x1F; + + // Compute days from new year + var daysFromNewYear; + + var chineseNewYearJSDate = new Date(y, m -1, d); + var jsDate = new Date(solarDate.year, solarDate.month - 1, solarDate.day); + + daysFromNewYear = Math.round( + (jsDate - chineseNewYearJSDate) / (24 * 3600 * 1000)); + + // Compute lunar month and day + var monthDaysTable = LUNAR_MONTH_DAYS[lunarDate.year - LUNAR_MONTH_DAYS[0]]; + + var i; + for(i = 0; i < 13; i++) { + var daysInMonth = (monthDaysTable & (1 << (12 - i))) ? 30 : 29; + + if (daysFromNewYear < daysInMonth) { + break; + } + + daysFromNewYear -= daysInMonth; + } + + var intercalaryMonth = monthDaysTable >> 13; + if (!intercalaryMonth || i < intercalaryMonth) { + lunarDate.isIntercalary = false; + lunarDate.month = 1 + i; + } else if (i === intercalaryMonth) { + lunarDate.isIntercalary = true; + lunarDate.month = i; + } else { + lunarDate.isIntercalary = false; + lunarDate.month = i; + } + + lunarDate.day = 1 + daysFromNewYear; + + return lunarDate; +} + +function toSolar(yearOrDate, monthOrResult, day, isIntercalaryOrResult, result) { + var solarDate; + var lunarDate; + + if(typeof yearOrDate === 'object') { + lunarDate = yearOrDate; + solarDate = monthOrResult || {}; + + } else { + var isValidYear = (typeof yearOrDate === 'number') && + (yearOrDate >= 1888) && (yearOrDate <= 2111); + if(!isValidYear) + throw new Error("Lunar year outside range 1888-2111"); + + var isValidMonth = (typeof monthOrResult === 'number') && + (monthOrResult >= 1) && (monthOrResult <= 12); + if(!isValidMonth) + throw new Error("Lunar month outside range 1 - 12"); + + var isValidDay = (typeof day === 'number') && (day >= 1) && (day <= 30); + if(!isValidDay) + throw new Error("Lunar day outside range 1 - 30"); + + var isIntercalary; + if(typeof isIntercalaryOrResult === 'object') { + isIntercalary = false; + solarDate = isIntercalaryOrResult; + } else { + isIntercalary = !!isIntercalaryOrResult; + solarDate = result || {}; + } + + lunarDate = { + year: yearOrDate, + month: monthOrResult, + day: day, + isIntercalary: isIntercalary, + }; + } + + // Compute days from new year + var daysFromNewYear; + + daysFromNewYear = lunarDate.day - 1; + + var monthDaysTable = LUNAR_MONTH_DAYS[lunarDate.year - LUNAR_MONTH_DAYS[0]]; + var intercalaryMonth = monthDaysTable >> 13; + + var monthsFromNewYear; + if (!intercalaryMonth) { + monthsFromNewYear = lunarDate.month - 1; + } else if (lunarDate.month > intercalaryMonth) { + monthsFromNewYear = lunarDate.month; + } else if (lunarDate.isIntercalary) { + monthsFromNewYear = lunarDate.month; + } else { + monthsFromNewYear = lunarDate.month - 1; + } + + for(var i = 0; i < monthsFromNewYear; i++) { + var daysInMonth = (monthDaysTable & (1 << (12 - i))) ? 30 : 29; + daysFromNewYear += daysInMonth; + } + + // Compute Chinese new year + var packedDate = CHINESE_NEW_YEAR[lunarDate.year - CHINESE_NEW_YEAR[0]]; + + var y = (packedDate >> 9) & 0xFFF; + var m = (packedDate >> 5) & 0x0F; + var d = packedDate & 0x1F; + + // Compute solar date + var jsDate = new Date(y, m - 1, d + daysFromNewYear); + + solarDate.year = jsDate.getFullYear(); + solarDate.month = 1 + jsDate.getMonth(); + solarDate.day = jsDate.getDate(); + + return solarDate; +} + + +},{"../main":135,"object-assign":71}],122:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Coptic calendar for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) February 2010. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +/** Implementation of the Coptic calendar. + See http://en.wikipedia.org/wiki/Coptic_calendar. + See also Calendrical Calculations: The Millennium Edition + (http://emr.cs.iit.edu/home/reingold/calendar-book/index.shtml). + @class CopticCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function CopticCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +CopticCalendar.prototype = new main.baseCalendar; + +assign(CopticCalendar.prototype, { + /** The calendar name. + @memberof CopticCalendar */ + name: 'Coptic', + /** Julian date of start of Coptic epoch: 29 August 284 CE (Gregorian). + @memberof CopticCalendar */ + jdEpoch: 1825029.5, + /** Days per month in a common year. + @memberof CopticCalendar */ + daysPerMonth: [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 5], + /** true if has a year zero, false if not. + @memberof CopticCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof CopticCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof CopticCalendar */ + firstMonth: 1, + /** The minimum day number. + @memberof CopticCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof CopticCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Coptic', + epochs: ['BAM', 'AM'], + monthNames: ['Thout', 'Paopi', 'Hathor', 'Koiak', 'Tobi', 'Meshir', + 'Paremhat', 'Paremoude', 'Pashons', 'Paoni', 'Epip', 'Mesori', 'Pi Kogi Enavot'], + monthNamesShort: ['Tho', 'Pao', 'Hath', 'Koi', 'Tob', 'Mesh', + 'Pat', 'Pad', 'Pash', 'Pao', 'Epi', 'Meso', 'PiK'], + dayNames: ['Tkyriaka', 'Pesnau', 'Pshoment', 'Peftoou', 'Ptiou', 'Psoou', 'Psabbaton'], + dayNamesShort: ['Tky', 'Pes', 'Psh', 'Pef', 'Pti', 'Pso', 'Psa'], + dayNamesMin: ['Tk', 'Pes', 'Psh', 'Pef', 'Pt', 'Pso', 'Psa'], + digits: null, + dateFormat: 'dd/mm/yyyy', + firstDay: 0, + isRTL: false + } + }, + + /** Determine whether this date is in a leap year. + @memberof CopticCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + var year = date.year() + (date.year() < 0 ? 1 : 0); // No year zero + return year % 4 === 3 || year % 4 === -1; + }, + + /** Retrieve the number of months in a year. + @memberof CopticCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of months. + @throws Error if an invalid year or a different calendar used. */ + monthsInYear: function(year) { + this._validate(year, this.minMonth, this.minDay, + main.local.invalidYear || main.regionalOptions[''].invalidYear); + return 13; + }, + + /** Determine the week of the year for a date. + @memberof CopticCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number) the month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + // Find Sunday of this week starting on Sunday + var checkDate = this.newDate(year, month, day); + checkDate.add(-checkDate.dayOfWeek(), 'd'); + return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1; + }, + + /** Retrieve the number of days in a month. + @memberof CopticCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + var date = this._validate(year, month, this.minDay, main.local.invalidMonth); + return this.daysPerMonth[date.month() - 1] + + (date.month() === 13 && this.leapYear(date.year()) ? 1 : 0); + }, + + /** Determine whether this date is a week day. + @memberof CopticCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param month {number} The month to examine. + @param day {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + return (this.dayOfWeek(year, month, day) || 7) < 6; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof CopticCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number) the month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + year = date.year(); + if (year < 0) { year++; } // No year zero + return date.day() + (date.month() - 1) * 30 + + (year - 1) * 365 + Math.floor(year / 4) + this.jdEpoch - 1; + }, + + /** Create a new date from a Julian date. + @memberof CopticCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + var c = Math.floor(jd) + 0.5 - this.jdEpoch; + var year = Math.floor((c - Math.floor((c + 366) / 1461)) / 365) + 1; + if (year <= 0) { year--; } // No year zero + c = Math.floor(jd) + 0.5 - this.newDate(year, 1, 1).toJD(); + var month = Math.floor(c / 30) + 1; + var day = c - (month - 1) * 30 + 1; + return this.newDate(year, month, day); + } +}); + +// Coptic calendar implementation +main.calendars.coptic = CopticCalendar; + + +},{"../main":135,"object-assign":71}],123:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Discworld calendar for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) January 2016. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +/** Implementation of the Discworld calendar - Unseen University version. + See also http://wiki.lspace.org/mediawiki/Discworld_calendar + and http://discworld.wikia.com/wiki/Discworld_calendar. + @class DiscworldCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function DiscworldCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +DiscworldCalendar.prototype = new main.baseCalendar; + +assign(DiscworldCalendar.prototype, { + /** The calendar name. + @memberof DiscworldCalendar */ + name: 'Discworld', + /** Julian date of start of Discworld epoch: 1 January 0001 CE. + @memberof DiscworldCalendar */ + jdEpoch: 1721425.5, + /** Days per month in a common year. + @memberof DiscworldCalendar */ + daysPerMonth: [16, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32], + /** true if has a year zero, false if not. + @memberof DiscworldCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof DiscworldCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof DiscworldCalendar */ + firstMonth: 1, + /** The minimum day number. + @memberof DiscworldCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof DiscworldCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Discworld', + epochs: ['BUC', 'UC'], + monthNames: ['Ick', 'Offle', 'February', 'March', 'April', 'May', 'June', + 'Grune', 'August', 'Spune', 'Sektober', 'Ember', 'December'], + monthNamesShort: ['Ick', 'Off', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Gru', 'Aug', 'Spu', 'Sek', 'Emb', 'Dec'], + dayNames: ['Sunday', 'Octeday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], + dayNamesShort: ['Sun', 'Oct', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], + dayNamesMin: ['Su', 'Oc', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], + digits: null, + dateFormat: 'yyyy/mm/dd', + firstDay: 2, + isRTL: false + } + }, + + /** Determine whether this date is in a leap year. + @memberof DiscworldCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + return false; + }, + + /** Retrieve the number of months in a year. + @memberof DiscworldCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of months. + @throws Error if an invalid year or a different calendar used. */ + monthsInYear: function(year) { + this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + return 13; + }, + + /** Retrieve the number of days in a year. + @memberof DiscworldCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of days. + @throws Error if an invalid year or a different calendar used. */ + daysInYear: function(year) { + this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + return 400; + }, + + /** Determine the week of the year for a date. + @memberof DiscworldCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + // Find Sunday of this week starting on Sunday + var checkDate = this.newDate(year, month, day); + checkDate.add(-checkDate.dayOfWeek(), 'd'); + return Math.floor((checkDate.dayOfYear() - 1) / 8) + 1; + }, + + /** Retrieve the number of days in a month. + @memberof DiscworldCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + var date = this._validate(year, month, this.minDay, main.local.invalidMonth); + return this.daysPerMonth[date.month() - 1]; + }, + + /** Retrieve the number of days in a week. + @memberof DiscworldCalendar + @return {number} The number of days. */ + daysInWeek: function() { + return 8; + }, + + /** Retrieve the day of the week for a date. + @memberof DiscworldCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The day of the week: 0 to number of days - 1. + @throws Error if an invalid date or a different calendar used. */ + dayOfWeek: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + return (date.day() + 1) % 8; + }, + + /** Determine whether this date is a week day. + @memberof DiscworldCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + var dow = this.dayOfWeek(year, month, day); + return (dow >= 2 && dow <= 6); + }, + + /** Retrieve additional information about a date. + @memberof DiscworldCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {object} Additional information - contents depends on calendar. + @throws Error if an invalid date or a different calendar used. */ + extraInfo: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + return {century: centuries[Math.floor((date.year() - 1) / 100) + 1] || ''}; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof DiscworldCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + year = date.year() + (date.year() < 0 ? 1 : 0); + month = date.month(); + day = date.day(); + return day + (month > 1 ? 16 : 0) + (month > 2 ? (month - 2) * 32 : 0) + + (year - 1) * 400 + this.jdEpoch - 1; + }, + + /** Create a new date from a Julian date. + @memberof DiscworldCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + jd = Math.floor(jd + 0.5) - Math.floor(this.jdEpoch) - 1; + var year = Math.floor(jd / 400) + 1; + jd -= (year - 1) * 400; + jd += (jd > 15 ? 16 : 0); + var month = Math.floor(jd / 32) + 1; + var day = jd - (month - 1) * 32 + 1; + return this.newDate(year <= 0 ? year - 1 : year, month, day); + } +}); + +// Names of the centuries +var centuries = { + 20: 'Fruitbat', + 21: 'Anchovy' +}; + +// Discworld calendar implementation +main.calendars.discworld = DiscworldCalendar; + + +},{"../main":135,"object-assign":71}],124:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Ethiopian calendar for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) February 2010. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +/** Implementation of the Ethiopian calendar. + See http://en.wikipedia.org/wiki/Ethiopian_calendar. + See also Calendrical Calculations: The Millennium Edition + (http://emr.cs.iit.edu/home/reingold/calendar-book/index.shtml). + @class EthiopianCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function EthiopianCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +EthiopianCalendar.prototype = new main.baseCalendar; + +assign(EthiopianCalendar.prototype, { + /** The calendar name. + @memberof EthiopianCalendar */ + name: 'Ethiopian', + /** Julian date of start of Ethiopian epoch: 27 August 8 CE (Gregorian). + @memberof EthiopianCalendar */ + jdEpoch: 1724220.5, + /** Days per month in a common year. + @memberof EthiopianCalendar */ + daysPerMonth: [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 5], + /** true if has a year zero, false if not. + @memberof EthiopianCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof EthiopianCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof EthiopianCalendar */ + firstMonth: 1, + /** The minimum day number. + @memberof EthiopianCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof EthiopianCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Ethiopian', + epochs: ['BEE', 'EE'], + monthNames: ['Meskerem', 'Tikemet', 'Hidar', 'Tahesas', 'Tir', 'Yekatit', + 'Megabit', 'Miazia', 'Genbot', 'Sene', 'Hamle', 'Nehase', 'Pagume'], + monthNamesShort: ['Mes', 'Tik', 'Hid', 'Tah', 'Tir', 'Yek', + 'Meg', 'Mia', 'Gen', 'Sen', 'Ham', 'Neh', 'Pag'], + dayNames: ['Ehud', 'Segno', 'Maksegno', 'Irob', 'Hamus', 'Arb', 'Kidame'], + dayNamesShort: ['Ehu', 'Seg', 'Mak', 'Iro', 'Ham', 'Arb', 'Kid'], + dayNamesMin: ['Eh', 'Se', 'Ma', 'Ir', 'Ha', 'Ar', 'Ki'], + digits: null, + dateFormat: 'dd/mm/yyyy', + firstDay: 0, + isRTL: false + } + }, + + /** Determine whether this date is in a leap year. + @memberof EthiopianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + var year = date.year() + (date.year() < 0 ? 1 : 0); // No year zero + return year % 4 === 3 || year % 4 === -1; + }, + + /** Retrieve the number of months in a year. + @memberof EthiopianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of months. + @throws Error if an invalid year or a different calendar used. */ + monthsInYear: function(year) { + this._validate(year, this.minMonth, this.minDay, + main.local.invalidYear || main.regionalOptions[''].invalidYear); + return 13; + }, + + /** Determine the week of the year for a date. + @memberof EthiopianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + // Find Sunday of this week starting on Sunday + var checkDate = this.newDate(year, month, day); + checkDate.add(-checkDate.dayOfWeek(), 'd'); + return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1; + }, + + /** Retrieve the number of days in a month. + @memberof EthiopianCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + var date = this._validate(year, month, this.minDay, main.local.invalidMonth); + return this.daysPerMonth[date.month() - 1] + + (date.month() === 13 && this.leapYear(date.year()) ? 1 : 0); + }, + + /** Determine whether this date is a week day. + @memberof EthiopianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + return (this.dayOfWeek(year, month, day) || 7) < 6; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof EthiopianCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + year = date.year(); + if (year < 0) { year++; } // No year zero + return date.day() + (date.month() - 1) * 30 + + (year - 1) * 365 + Math.floor(year / 4) + this.jdEpoch - 1; + }, + + /** Create a new date from a Julian date. + @memberof EthiopianCalendar + @param jd {number} the Julian date to convert. + @return {CDate} the equivalent date. */ + fromJD: function(jd) { + var c = Math.floor(jd) + 0.5 - this.jdEpoch; + var year = Math.floor((c - Math.floor((c + 366) / 1461)) / 365) + 1; + if (year <= 0) { year--; } // No year zero + c = Math.floor(jd) + 0.5 - this.newDate(year, 1, 1).toJD(); + var month = Math.floor(c / 30) + 1; + var day = c - (month - 1) * 30 + 1; + return this.newDate(year, month, day); + } +}); + +// Ethiopian calendar implementation +main.calendars.ethiopian = EthiopianCalendar; + + +},{"../main":135,"object-assign":71}],125:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Hebrew calendar for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) August 2009. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +/** Implementation of the Hebrew civil calendar. + Based on code from http://www.fourmilab.ch/documents/calendar/. + See also http://en.wikipedia.org/wiki/Hebrew_calendar. + @class HebrewCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function HebrewCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +HebrewCalendar.prototype = new main.baseCalendar; + +assign(HebrewCalendar.prototype, { + /** The calendar name. + @memberof HebrewCalendar */ + name: 'Hebrew', + /** Julian date of start of Hebrew epoch: 7 October 3761 BCE. + @memberof HebrewCalendar */ + jdEpoch: 347995.5, + /** Days per month in a common year. + @memberof HebrewCalendar */ + daysPerMonth: [30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 29], + /** true if has a year zero, false if not. + @memberof HebrewCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof HebrewCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof HebrewCalendar */ + firstMonth: 7, + /** The minimum day number. + @memberof HebrewCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof HebrewCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Hebrew', + epochs: ['BAM', 'AM'], + monthNames: ['Nisan', 'Iyar', 'Sivan', 'Tammuz', 'Av', 'Elul', + 'Tishrei', 'Cheshvan', 'Kislev', 'Tevet', 'Shevat', 'Adar', 'Adar II'], + monthNamesShort: ['Nis', 'Iya', 'Siv', 'Tam', 'Av', 'Elu', 'Tis', 'Che', 'Kis', 'Tev', 'She', 'Ada', 'Ad2'], + dayNames: ['Yom Rishon', 'Yom Sheni', 'Yom Shlishi', 'Yom Revi\'i', 'Yom Chamishi', 'Yom Shishi', 'Yom Shabbat'], + dayNamesShort: ['Ris', 'She', 'Shl', 'Rev', 'Cha', 'Shi', 'Sha'], + dayNamesMin: ['Ri','She','Shl','Re','Ch','Shi','Sha'], + digits: null, + dateFormat: 'dd/mm/yyyy', + firstDay: 0, + isRTL: false + } + }, + + /** Determine whether this date is in a leap year. + @memberof HebrewCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + return this._leapYear(date.year()); + }, + + /** Determine whether this date is in a leap year. + @memberof HebrewCalendar + @private + @param year {number} The year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + _leapYear: function(year) { + year = (year < 0 ? year + 1 : year); + return mod(year * 7 + 1, 19) < 7; + }, + + /** Retrieve the number of months in a year. + @memberof HebrewCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of months. + @throws Error if an invalid year or a different calendar used. */ + monthsInYear: function(year) { + this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + return this._leapYear(year.year ? year.year() : year) ? 13 : 12; + }, + + /** Determine the week of the year for a date. + @memberof HebrewCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + // Find Sunday of this week starting on Sunday + var checkDate = this.newDate(year, month, day); + checkDate.add(-checkDate.dayOfWeek(), 'd'); + return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1; + }, + + /** Retrieve the number of days in a year. + @memberof HebrewCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of days. + @throws Error if an invalid year or a different calendar used. */ + daysInYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + year = date.year(); + return this.toJD((year === -1 ? +1 : year + 1), 7, 1) - this.toJD(year, 7, 1); + }, + + /** Retrieve the number of days in a month. + @memberof HebrewCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + if (year.year) { + month = year.month(); + year = year.year(); + } + this._validate(year, month, this.minDay, main.local.invalidMonth); + return (month === 12 && this.leapYear(year) ? 30 : // Adar I + (month === 8 && mod(this.daysInYear(year), 10) === 5 ? 30 : // Cheshvan in shlemah year + (month === 9 && mod(this.daysInYear(year), 10) === 3 ? 29 : // Kislev in chaserah year + this.daysPerMonth[month - 1]))); + }, + + /** Determine whether this date is a week day. + @memberof HebrewCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + return this.dayOfWeek(year, month, day) !== 6; + }, + + /** Retrieve additional information about a date - year type. + @memberof HebrewCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {object} Additional information - contents depends on calendar. + @throws Error if an invalid date or a different calendar used. */ + extraInfo: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + return {yearType: (this.leapYear(date) ? 'embolismic' : 'common') + ' ' + + ['deficient', 'regular', 'complete'][this.daysInYear(date) % 10 - 3]}; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof HebrewCalendar + @param year {CDate)|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + year = date.year(); + month = date.month(); + day = date.day(); + var adjYear = (year <= 0 ? year + 1 : year); + var jd = this.jdEpoch + this._delay1(adjYear) + + this._delay2(adjYear) + day + 1; + if (month < 7) { + for (var m = 7; m <= this.monthsInYear(year); m++) { + jd += this.daysInMonth(year, m); + } + for (var m = 1; m < month; m++) { + jd += this.daysInMonth(year, m); + } + } + else { + for (var m = 7; m < month; m++) { + jd += this.daysInMonth(year, m); + } + } + return jd; + }, + + /** Test for delay of start of new year and to avoid + Sunday, Wednesday, or Friday as start of the new year. + @memberof HebrewCalendar + @private + @param year {number} The year to examine. + @return {number} The days to offset by. */ + _delay1: function(year) { + var months = Math.floor((235 * year - 234) / 19); + var parts = 12084 + 13753 * months; + var day = months * 29 + Math.floor(parts / 25920); + if (mod(3 * (day + 1), 7) < 3) { + day++; + } + return day; + }, + + /** Check for delay in start of new year due to length of adjacent years. + @memberof HebrewCalendar + @private + @param year {number} The year to examine. + @return {number} The days to offset by. */ + _delay2: function(year) { + var last = this._delay1(year - 1); + var present = this._delay1(year); + var next = this._delay1(year + 1); + return ((next - present) === 356 ? 2 : ((present - last) === 382 ? 1 : 0)); + }, + + /** Create a new date from a Julian date. + @memberof HebrewCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + jd = Math.floor(jd) + 0.5; + var year = Math.floor(((jd - this.jdEpoch) * 98496.0) / 35975351.0) - 1; + while (jd >= this.toJD((year === -1 ? +1 : year + 1), 7, 1)) { + year++; + } + var month = (jd < this.toJD(year, 1, 1)) ? 7 : 1; + while (jd > this.toJD(year, month, this.daysInMonth(year, month))) { + month++; + } + var day = jd - this.toJD(year, month, 1) + 1; + return this.newDate(year, month, day); + } +}); + +// Modulus function which works for non-integers. +function mod(a, b) { + return a - (b * Math.floor(a / b)); +} + +// Hebrew calendar implementation +main.calendars.hebrew = HebrewCalendar; + + +},{"../main":135,"object-assign":71}],126:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Islamic calendar for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) August 2009. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +/** Implementation of the Islamic or '16 civil' calendar. + Based on code from http://www.iranchamber.com/calendar/converter/iranian_calendar_converter.php. + See also http://en.wikipedia.org/wiki/Islamic_calendar. + @class IslamicCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function IslamicCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +IslamicCalendar.prototype = new main.baseCalendar; + +assign(IslamicCalendar.prototype, { + /** The calendar name. + @memberof IslamicCalendar */ + name: 'Islamic', + /** Julian date of start of Islamic epoch: 16 July 622 CE. + @memberof IslamicCalendar */ + jdEpoch: 1948439.5, + /** Days per month in a common year. + @memberof IslamicCalendar */ + daysPerMonth: [30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29], + /** true if has a year zero, false if not. + @memberof IslamicCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof IslamicCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof IslamicCalendar */ + firstMonth: 1, + /** The minimum day number. + @memberof IslamicCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof IslamicCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Islamic', + epochs: ['BH', 'AH'], + monthNames: ['Muharram', 'Safar', 'Rabi\' al-awwal', 'Rabi\' al-thani', 'Jumada al-awwal', 'Jumada al-thani', + 'Rajab', 'Sha\'aban', 'Ramadan', 'Shawwal', 'Dhu al-Qi\'dah', 'Dhu al-Hijjah'], + monthNamesShort: ['Muh', 'Saf', 'Rab1', 'Rab2', 'Jum1', 'Jum2', 'Raj', 'Sha\'', 'Ram', 'Shaw', 'DhuQ', 'DhuH'], + dayNames: ['Yawm al-ahad', 'Yawm al-ithnayn', 'Yawm ath-thulaathaa\'', + 'Yawm al-arbi\'aa\'', 'Yawm al-khamīs', 'Yawm al-jum\'a', 'Yawm as-sabt'], + dayNamesShort: ['Aha', 'Ith', 'Thu', 'Arb', 'Kha', 'Jum', 'Sab'], + dayNamesMin: ['Ah','It','Th','Ar','Kh','Ju','Sa'], + digits: null, + dateFormat: 'yyyy/mm/dd', + firstDay: 6, + isRTL: false + } + }, + + /** Determine whether this date is in a leap year. + @memberof IslamicCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + return (date.year() * 11 + 14) % 30 < 11; + }, + + /** Determine the week of the year for a date. + @memberof IslamicCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + // Find Sunday of this week starting on Sunday + var checkDate = this.newDate(year, month, day); + checkDate.add(-checkDate.dayOfWeek(), 'd'); + return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1; + }, + + /** Retrieve the number of days in a year. + @memberof IslamicCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of days. + @throws Error if an invalid year or a different calendar used. */ + daysInYear: function(year) { + return (this.leapYear(year) ? 355 : 354); + }, + + /** Retrieve the number of days in a month. + @memberof IslamicCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + var date = this._validate(year, month, this.minDay, main.local.invalidMonth); + return this.daysPerMonth[date.month() - 1] + + (date.month() === 12 && this.leapYear(date.year()) ? 1 : 0); + }, + + /** Determine whether this date is a week day. + @memberof IslamicCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + return this.dayOfWeek(year, month, day) !== 5; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof IslamicCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + year = date.year(); + month = date.month(); + day = date.day(); + year = (year <= 0 ? year + 1 : year); + return day + Math.ceil(29.5 * (month - 1)) + (year - 1) * 354 + + Math.floor((3 + (11 * year)) / 30) + this.jdEpoch - 1; + }, + + /** Create a new date from a Julian date. + @memberof IslamicCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + jd = Math.floor(jd) + 0.5; + var year = Math.floor((30 * (jd - this.jdEpoch) + 10646) / 10631); + year = (year <= 0 ? year - 1 : year); + var month = Math.min(12, Math.ceil((jd - 29 - this.toJD(year, 1, 1)) / 29.5) + 1); + var day = jd - this.toJD(year, month, 1) + 1; + return this.newDate(year, month, day); + } +}); + +// Islamic (16 civil) calendar implementation +main.calendars.islamic = IslamicCalendar; + + +},{"../main":135,"object-assign":71}],127:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Julian calendar for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) August 2009. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +/** Implementation of the Julian calendar. + Based on code from http://www.fourmilab.ch/documents/calendar/. + See also http://en.wikipedia.org/wiki/Julian_calendar. + @class JulianCalendar + @augments BaseCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function JulianCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +JulianCalendar.prototype = new main.baseCalendar; + +assign(JulianCalendar.prototype, { + /** The calendar name. + @memberof JulianCalendar */ + name: 'Julian', + /** Julian date of start of Julian epoch: 1 January 0001 AD = 30 December 0001 BCE. + @memberof JulianCalendar */ + jdEpoch: 1721423.5, + /** Days per month in a common year. + @memberof JulianCalendar */ + daysPerMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], + /** true if has a year zero, false if not. + @memberof JulianCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof JulianCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof JulianCalendar */ + firstMonth: 1, + /** The minimum day number. + @memberof JulianCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof JulianCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Julian', + epochs: ['BC', 'AD'], + monthNames: ['January', 'February', 'March', 'April', 'May', 'June', + 'July', 'August', 'September', 'October', 'November', 'December'], + monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], + dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], + dayNamesMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], + digits: null, + dateFormat: 'mm/dd/yyyy', + firstDay: 0, + isRTL: false + } + }, + + /** Determine whether this date is in a leap year. + @memberof JulianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + var year = (date.year() < 0 ? date.year() + 1 : date.year()); // No year zero + return (year % 4) === 0; + }, + + /** Determine the week of the year for a date - ISO 8601. + @memberof JulianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + // Find Thursday of this week starting on Monday + var checkDate = this.newDate(year, month, day); + checkDate.add(4 - (checkDate.dayOfWeek() || 7), 'd'); + return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1; + }, + + /** Retrieve the number of days in a month. + @memberof JulianCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + var date = this._validate(year, month, this.minDay, main.local.invalidMonth); + return this.daysPerMonth[date.month() - 1] + + (date.month() === 2 && this.leapYear(date.year()) ? 1 : 0); + }, + + /** Determine whether this date is a week day. + @memberof JulianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} True if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + return (this.dayOfWeek(year, month, day) || 7) < 6; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof JulianCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + year = date.year(); + month = date.month(); + day = date.day(); + if (year < 0) { year++; } // No year zero + // Jean Meeus algorithm, "Astronomical Algorithms", 1991 + if (month <= 2) { + year--; + month += 12; + } + return Math.floor(365.25 * (year + 4716)) + + Math.floor(30.6001 * (month + 1)) + day - 1524.5; + }, + + /** Create a new date from a Julian date. + @memberof JulianCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + // Jean Meeus algorithm, "Astronomical Algorithms", 1991 + var a = Math.floor(jd + 0.5); + var b = a + 1524; + var c = Math.floor((b - 122.1) / 365.25); + var d = Math.floor(365.25 * c); + var e = Math.floor((b - d) / 30.6001); + var month = e - Math.floor(e < 14 ? 1 : 13); + var year = c - Math.floor(month > 2 ? 4716 : 4715); + var day = b - d - Math.floor(30.6001 * e); + if (year <= 0) { year--; } // No year zero + return this.newDate(year, month, day); + } +}); + +// Julian calendar implementation +main.calendars.julian = JulianCalendar; + + +},{"../main":135,"object-assign":71}],128:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Mayan calendar for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) August 2009. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +/** Implementation of the Mayan Long Count calendar. + See also http://en.wikipedia.org/wiki/Mayan_calendar. + @class MayanCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function MayanCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +MayanCalendar.prototype = new main.baseCalendar; + +assign(MayanCalendar.prototype, { + /** The calendar name. + @memberof MayanCalendar */ + name: 'Mayan', + /** Julian date of start of Mayan epoch: 11 August 3114 BCE. + @memberof MayanCalendar */ + jdEpoch: 584282.5, + /** true if has a year zero, false if not. + @memberof MayanCalendar */ + hasYearZero: true, + /** The minimum month number. + @memberof MayanCalendar */ + minMonth: 0, + /** The first month in the year. + @memberof MayanCalendar */ + firstMonth: 0, + /** The minimum day number. + @memberof MayanCalendar */ + minDay: 0, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof MayanCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. + @property haabMonths {string[]} The names of the Haab months. + @property tzolkinMonths {string[]} The names of the Tzolkin months. */ + regionalOptions: { // Localisations + '': { + name: 'Mayan', + epochs: ['', ''], + monthNames: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '10', '11', '12', '13', '14', '15', '16', '17'], + monthNamesShort: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '10', '11', '12', '13', '14', '15', '16', '17'], + dayNames: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '10', '11', '12', '13', '14', '15', '16', '17', '18', '19'], + dayNamesShort: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '10', '11', '12', '13', '14', '15', '16', '17', '18', '19'], + dayNamesMin: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '10', '11', '12', '13', '14', '15', '16', '17', '18', '19'], + digits: null, + dateFormat: 'YYYY.m.d', + firstDay: 0, + isRTL: false, + haabMonths: ['Pop', 'Uo', 'Zip', 'Zotz', 'Tzec', 'Xul', 'Yaxkin', 'Mol', 'Chen', 'Yax', + 'Zac', 'Ceh', 'Mac', 'Kankin', 'Muan', 'Pax', 'Kayab', 'Cumku', 'Uayeb'], + tzolkinMonths: ['Imix', 'Ik', 'Akbal', 'Kan', 'Chicchan', 'Cimi', 'Manik', 'Lamat', 'Muluc', 'Oc', + 'Chuen', 'Eb', 'Ben', 'Ix', 'Men', 'Cib', 'Caban', 'Etznab', 'Cauac', 'Ahau'] + } + }, + + /** Determine whether this date is in a leap year. + @memberof MayanCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + return false; + }, + + /** Format the year, if not a simple sequential number. + @memberof MayanCalendar + @param year {CDate|number} The date to format or the year to format. + @return {string} The formatted year. + @throws Error if an invalid year or a different calendar used. */ + formatYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + year = date.year(); + var baktun = Math.floor(year / 400); + year = year % 400; + year += (year < 0 ? 400 : 0); + var katun = Math.floor(year / 20); + return baktun + '.' + katun + '.' + (year % 20); + }, + + /** Convert from the formatted year back to a single number. + @memberof MayanCalendar + @param years {string} The year as n.n.n. + @return {number} The sequential year. + @throws Error if an invalid value is supplied. */ + forYear: function(years) { + years = years.split('.'); + if (years.length < 3) { + throw 'Invalid Mayan year'; + } + var year = 0; + for (var i = 0; i < years.length; i++) { + var y = parseInt(years[i], 10); + if (Math.abs(y) > 19 || (i > 0 && y < 0)) { + throw 'Invalid Mayan year'; + } + year = year * 20 + y; + } + return year; + }, + + /** Retrieve the number of months in a year. + @memberof MayanCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of months. + @throws Error if an invalid year or a different calendar used. */ + monthsInYear: function(year) { + this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + return 18; + }, + + /** Determine the week of the year for a date. + @memberof MayanCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + this._validate(year, month, day, main.local.invalidDate); + return 0; + }, + + /** Retrieve the number of days in a year. + @memberof MayanCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of days. + @throws Error if an invalid year or a different calendar used. */ + daysInYear: function(year) { + this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + return 360; + }, + + /** Retrieve the number of days in a month. + @memberof MayanCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + this._validate(year, month, this.minDay, main.local.invalidMonth); + return 20; + }, + + /** Retrieve the number of days in a week. + @memberof MayanCalendar + @return {number} The number of days. */ + daysInWeek: function() { + return 5; // Just for formatting + }, + + /** Retrieve the day of the week for a date. + @memberof MayanCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The day of the week: 0 to number of days - 1. + @throws Error if an invalid date or a different calendar used. */ + dayOfWeek: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + return date.day(); + }, + + /** Determine whether this date is a week day. + @memberof MayanCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + this._validate(year, month, day, main.local.invalidDate); + return true; + }, + + /** Retrieve additional information about a date - Haab and Tzolkin equivalents. + @memberof MayanCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {object} Additional information - contents depends on calendar. + @throws Error if an invalid date or a different calendar used. */ + extraInfo: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + var jd = date.toJD(); + var haab = this._toHaab(jd); + var tzolkin = this._toTzolkin(jd); + return {haabMonthName: this.local.haabMonths[haab[0] - 1], + haabMonth: haab[0], haabDay: haab[1], + tzolkinDayName: this.local.tzolkinMonths[tzolkin[0] - 1], + tzolkinDay: tzolkin[0], tzolkinTrecena: tzolkin[1]}; + }, + + /** Retrieve Haab date from a Julian date. + @memberof MayanCalendar + @private + @param jd {number} The Julian date. + @return {number[]} Corresponding Haab month and day. */ + _toHaab: function(jd) { + jd -= this.jdEpoch; + var day = mod(jd + 8 + ((18 - 1) * 20), 365); + return [Math.floor(day / 20) + 1, mod(day, 20)]; + }, + + /** Retrieve Tzolkin date from a Julian date. + @memberof MayanCalendar + @private + @param jd {number} The Julian date. + @return {number[]} Corresponding Tzolkin day and trecena. */ + _toTzolkin: function(jd) { + jd -= this.jdEpoch; + return [amod(jd + 20, 20), amod(jd + 4, 13)]; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof MayanCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + return date.day() + (date.month() * 20) + (date.year() * 360) + this.jdEpoch; + }, + + /** Create a new date from a Julian date. + @memberof MayanCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + jd = Math.floor(jd) + 0.5 - this.jdEpoch; + var year = Math.floor(jd / 360); + jd = jd % 360; + jd += (jd < 0 ? 360 : 0); + var month = Math.floor(jd / 20); + var day = jd % 20; + return this.newDate(year, month, day); + } +}); + +// Modulus function which works for non-integers. +function mod(a, b) { + return a - (b * Math.floor(a / b)); +} + +// Modulus function which returns numerator if modulus is zero. +function amod(a, b) { + return mod(a - 1, b) + 1; +} + +// Mayan calendar implementation +main.calendars.mayan = MayanCalendar; + + +},{"../main":135,"object-assign":71}],129:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Nanakshahi calendar for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) January 2016. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +/** Implementation of the Nanakshahi calendar. + See also https://en.wikipedia.org/wiki/Nanakshahi_calendar. + @class NanakshahiCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function NanakshahiCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +NanakshahiCalendar.prototype = new main.baseCalendar; + +var gregorian = main.instance('gregorian'); + +assign(NanakshahiCalendar.prototype, { + /** The calendar name. + @memberof NanakshahiCalendar */ + name: 'Nanakshahi', + /** Julian date of start of Nanakshahi epoch: 14 March 1469 CE. + @memberof NanakshahiCalendar */ + jdEpoch: 2257673.5, + /** Days per month in a common year. + @memberof NanakshahiCalendar */ + daysPerMonth: [31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 30], + /** true if has a year zero, false if not. + @memberof NanakshahiCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof NanakshahiCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof NanakshahiCalendar */ + firstMonth: 1, + /** The minimum day number. + @memberof NanakshahiCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof NanakshahiCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Nanakshahi', + epochs: ['BN', 'AN'], + monthNames: ['Chet', 'Vaisakh', 'Jeth', 'Harh', 'Sawan', 'Bhadon', + 'Assu', 'Katak', 'Maghar', 'Poh', 'Magh', 'Phagun'], + monthNamesShort: ['Che', 'Vai', 'Jet', 'Har', 'Saw', 'Bha', 'Ass', 'Kat', 'Mgr', 'Poh', 'Mgh', 'Pha'], + dayNames: ['Somvaar', 'Mangalvar', 'Budhvaar', 'Veervaar', 'Shukarvaar', 'Sanicharvaar', 'Etvaar'], + dayNamesShort: ['Som', 'Mangal', 'Budh', 'Veer', 'Shukar', 'Sanichar', 'Et'], + dayNamesMin: ['So', 'Ma', 'Bu', 'Ve', 'Sh', 'Sa', 'Et'], + digits: null, + dateFormat: 'dd-mm-yyyy', + firstDay: 0, + isRTL: false + } + }, + + /** Determine whether this date is in a leap year. + @memberof NanakshahiCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, + main.local.invalidYear || main.regionalOptions[''].invalidYear); + return gregorian.leapYear(date.year() + (date.year() < 1 ? 1 : 0) + 1469); + }, + + /** Determine the week of the year for a date. + @memberof NanakshahiCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + // Find Monday of this week starting on Monday + var checkDate = this.newDate(year, month, day); + checkDate.add(1 - (checkDate.dayOfWeek() || 7), 'd'); + return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1; + }, + + /** Retrieve the number of days in a month. + @memberof NanakshahiCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + var date = this._validate(year, month, this.minDay, main.local.invalidMonth); + return this.daysPerMonth[date.month() - 1] + + (date.month() === 12 && this.leapYear(date.year()) ? 1 : 0); + }, + + /** Determine whether this date is a week day. + @memberof NanakshahiCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + return (this.dayOfWeek(year, month, day) || 7) < 6; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof NanakshahiCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidMonth); + var year = date.year(); + if (year < 0) { year++; } // No year zero + var doy = date.day(); + for (var m = 1; m < date.month(); m++) { + doy += this.daysPerMonth[m - 1]; + } + return doy + gregorian.toJD(year + 1468, 3, 13); + }, + + /** Create a new date from a Julian date. + @memberof NanakshahiCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + jd = Math.floor(jd + 0.5); + var year = Math.floor((jd - (this.jdEpoch - 1)) / 366); + while (jd >= this.toJD(year + 1, 1, 1)) { + year++; + } + var day = jd - Math.floor(this.toJD(year, 1, 1) + 0.5) + 1; + var month = 1; + while (day > this.daysInMonth(year, month)) { + day -= this.daysInMonth(year, month); + month++; + } + return this.newDate(year, month, day); + } +}); + +// Nanakshahi calendar implementation +main.calendars.nanakshahi = NanakshahiCalendar; + + +},{"../main":135,"object-assign":71}],130:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Nepali calendar for jQuery v2.0.2. + Written by Artur Neumann (ict.projects{at}nepal.inf.org) April 2013. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +/** Implementation of the Nepali civil calendar. + Based on the ideas from + http://codeissue.com/articles/a04e050dea7468f/algorithm-to-convert-english-date-to-nepali-date-using-c-net + and http://birenj2ee.blogspot.com/2011/04/nepali-calendar-in-java.html + See also http://en.wikipedia.org/wiki/Nepali_calendar + and https://en.wikipedia.org/wiki/Bikram_Samwat. + @class NepaliCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function NepaliCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +NepaliCalendar.prototype = new main.baseCalendar; + +assign(NepaliCalendar.prototype, { + /** The calendar name. + @memberof NepaliCalendar */ + name: 'Nepali', + /** Julian date of start of Nepali epoch: 14 April 57 BCE. + @memberof NepaliCalendar */ + jdEpoch: 1700709.5, + /** Days per month in a common year. + @memberof NepaliCalendar */ + daysPerMonth: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + /** true if has a year zero, false if not. + @memberof NepaliCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof NepaliCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof NepaliCalendar */ + firstMonth: 1, + /** The minimum day number. + @memberof NepaliCalendar */ + minDay: 1, + /** The number of days in the year. + @memberof NepaliCalendar */ + daysPerYear: 365, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof NepaliCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Nepali', + epochs: ['BBS', 'ABS'], + monthNames: ['Baisakh', 'Jestha', 'Ashadh', 'Shrawan', 'Bhadra', 'Ashwin', + 'Kartik', 'Mangsir', 'Paush', 'Mangh', 'Falgun', 'Chaitra'], + monthNamesShort: ['Bai', 'Je', 'As', 'Shra', 'Bha', 'Ash', 'Kar', 'Mang', 'Pau', 'Ma', 'Fal', 'Chai'], + dayNames: ['Aaitabaar', 'Sombaar', 'Manglbaar', 'Budhabaar', 'Bihibaar', 'Shukrabaar', 'Shanibaar'], + dayNamesShort: ['Aaita', 'Som', 'Mangl', 'Budha', 'Bihi', 'Shukra', 'Shani'], + dayNamesMin: ['Aai', 'So', 'Man', 'Bu', 'Bi', 'Shu', 'Sha'], + digits: null, + dateFormat: 'dd/mm/yyyy', + firstDay: 1, + isRTL: false + } + }, + + /** Determine whether this date is in a leap year. + @memberof NepaliCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + return this.daysInYear(year) !== this.daysPerYear; + }, + + /** Determine the week of the year for a date. + @memberof NepaliCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + // Find Sunday of this week starting on Sunday + var checkDate = this.newDate(year, month, day); + checkDate.add(-checkDate.dayOfWeek(), 'd'); + return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1; + }, + + /** Retrieve the number of days in a year. + @memberof NepaliCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of days. + @throws Error if an invalid year or a different calendar used. */ + daysInYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + year = date.year(); + if (typeof this.NEPALI_CALENDAR_DATA[year] === 'undefined') { + return this.daysPerYear; + } + var daysPerYear = 0; + for (var month_number = this.minMonth; month_number <= 12; month_number++) { + daysPerYear += this.NEPALI_CALENDAR_DATA[year][month_number]; + } + return daysPerYear; + }, + + /** Retrieve the number of days in a month. + @memberof NepaliCalendar + @param year {CDate|number| The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + if (year.year) { + month = year.month(); + year = year.year(); + } + this._validate(year, month, this.minDay, main.local.invalidMonth); + return (typeof this.NEPALI_CALENDAR_DATA[year] === 'undefined' ? + this.daysPerMonth[month - 1] : this.NEPALI_CALENDAR_DATA[year][month]); + }, + + /** Determine whether this date is a week day. + @memberof NepaliCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + return this.dayOfWeek(year, month, day) !== 6; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof NepaliCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(nepaliYear, nepaliMonth, nepaliDay) { + var date = this._validate(nepaliYear, nepaliMonth, nepaliDay, main.local.invalidDate); + nepaliYear = date.year(); + nepaliMonth = date.month(); + nepaliDay = date.day(); + var gregorianCalendar = main.instance(); + var gregorianDayOfYear = 0; // We will add all the days that went by since + // the 1st. January and then we can get the Gregorian Date + var nepaliMonthToCheck = nepaliMonth; + var nepaliYearToCheck = nepaliYear; + this._createMissingCalendarData(nepaliYear); + // Get the correct year + var gregorianYear = nepaliYear - (nepaliMonthToCheck > 9 || (nepaliMonthToCheck === 9 && + nepaliDay >= this.NEPALI_CALENDAR_DATA[nepaliYearToCheck][0]) ? 56 : 57); + // First we add the amount of days in the actual Nepali month as the day of year in the + // Gregorian one because at least this days are gone since the 1st. Jan. + if (nepaliMonth !== 9) { + gregorianDayOfYear = nepaliDay; + nepaliMonthToCheck--; + } + // Now we loop throw all Nepali month and add the amount of days to gregorianDayOfYear + // we do this till we reach Paush (9th month). 1st. January always falls in this month + while (nepaliMonthToCheck !== 9) { + if (nepaliMonthToCheck <= 0) { + nepaliMonthToCheck = 12; + nepaliYearToCheck--; + } + gregorianDayOfYear += this.NEPALI_CALENDAR_DATA[nepaliYearToCheck][nepaliMonthToCheck]; + nepaliMonthToCheck--; + } + // If the date that has to be converted is in Paush (month no. 9) we have to do some other calculation + if (nepaliMonth === 9) { + // Add the days that are passed since the first day of Paush and substract the + // amount of days that lie between 1st. Jan and 1st Paush + gregorianDayOfYear += nepaliDay - this.NEPALI_CALENDAR_DATA[nepaliYearToCheck][0]; + // For the first days of Paush we are now in negative values, + // because in the end of the gregorian year we substract + // 365 / 366 days (P.S. remember math in school + - gives -) + if (gregorianDayOfYear < 0) { + gregorianDayOfYear += gregorianCalendar.daysInYear(gregorianYear); + } + } + else { + gregorianDayOfYear += this.NEPALI_CALENDAR_DATA[nepaliYearToCheck][9] - + this.NEPALI_CALENDAR_DATA[nepaliYearToCheck][0]; + } + return gregorianCalendar.newDate(gregorianYear, 1 ,1).add(gregorianDayOfYear, 'd').toJD(); + }, + + /** Create a new date from a Julian date. + @memberof NepaliCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + var gregorianCalendar = main.instance(); + var gregorianDate = gregorianCalendar.fromJD(jd); + var gregorianYear = gregorianDate.year(); + var gregorianDayOfYear = gregorianDate.dayOfYear(); + var nepaliYear = gregorianYear + 56; //this is not final, it could be also +57 but +56 is always true for 1st Jan. + this._createMissingCalendarData(nepaliYear); + var nepaliMonth = 9; // Jan 1 always fall in Nepali month Paush which is the 9th month of Nepali calendar. + // Get the Nepali day in Paush (month 9) of 1st January + var dayOfFirstJanInPaush = this.NEPALI_CALENDAR_DATA[nepaliYear][0]; + // Check how many days are left of Paush . + // Days calculated from 1st Jan till the end of the actual Nepali month, + // we use this value to check if the gregorian Date is in the actual Nepali month. + var daysSinceJanFirstToEndOfNepaliMonth = + this.NEPALI_CALENDAR_DATA[nepaliYear][nepaliMonth] - dayOfFirstJanInPaush + 1; + // If the gregorian day-of-year is smaller o equal than the sum of days between the 1st January and + // the end of the actual nepali month we found the correct nepali month. + // Example: + // The 4th February 2011 is the gregorianDayOfYear 35 (31 days of January + 4) + // 1st January 2011 is in the nepali year 2067, where 1st. January is in the 17th day of Paush (9th month) + // In 2067 Paush has 30days, This means (30-17+1=14) there are 14days between 1st January and end of Paush + // (including 17th January) + // The gregorianDayOfYear (35) is bigger than 14, so we check the next month + // The next nepali month (Mangh) has 29 days + // 29+14=43, this is bigger than gregorianDayOfYear(35) so, we found the correct nepali month + while (gregorianDayOfYear > daysSinceJanFirstToEndOfNepaliMonth) { + nepaliMonth++; + if (nepaliMonth > 12) { + nepaliMonth = 1; + nepaliYear++; + } + daysSinceJanFirstToEndOfNepaliMonth += this.NEPALI_CALENDAR_DATA[nepaliYear][nepaliMonth]; + } + // The last step is to calculate the nepali day-of-month + // to continue our example from before: + // we calculated there are 43 days from 1st. January (17 Paush) till end of Mangh (29 days) + // when we subtract from this 43 days the day-of-year of the the Gregorian date (35), + // we know how far the searched day is away from the end of the Nepali month. + // So we simply subtract this number from the amount of days in this month (30) + var nepaliDayOfMonth = this.NEPALI_CALENDAR_DATA[nepaliYear][nepaliMonth] - + (daysSinceJanFirstToEndOfNepaliMonth - gregorianDayOfYear); + return this.newDate(nepaliYear, nepaliMonth, nepaliDayOfMonth); + }, + + /** Creates missing data in the NEPALI_CALENDAR_DATA table. + This data will not be correct but just give an estimated result. Mostly -/+ 1 day + @private + @param nepaliYear {number} The missing year number. */ + _createMissingCalendarData: function(nepaliYear) { + var tmp_calendar_data = this.daysPerMonth.slice(0); + tmp_calendar_data.unshift(17); + for (var nepaliYearToCreate = (nepaliYear - 1); nepaliYearToCreate < (nepaliYear + 2); nepaliYearToCreate++) { + if (typeof this.NEPALI_CALENDAR_DATA[nepaliYearToCreate] === 'undefined') { + this.NEPALI_CALENDAR_DATA[nepaliYearToCreate] = tmp_calendar_data; + } + } + }, + + NEPALI_CALENDAR_DATA: { + // These data are from http://www.ashesh.com.np + 1970: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 1971: [18, 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30], + 1972: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], + 1973: [19, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + 1974: [19, 31, 31, 32, 30, 31, 31, 30, 29, 30, 29, 30, 30], + 1975: [18, 31, 31, 32, 32, 30, 31, 30, 29, 30, 29, 30, 30], + 1976: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 1977: [18, 31, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31], + 1978: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 1979: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 1980: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 1981: [18, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], + 1982: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 1983: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 1984: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 1985: [18, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], + 1986: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 1987: [18, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 1988: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 1989: [18, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], + 1990: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 1991: [18, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30], + // These data are from http://nepalicalendar.rat32.com/index.php + 1992: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + 1993: [18, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], + 1994: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 1995: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], + 1996: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + 1997: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 1998: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 1999: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2000: [17, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + 2001: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2002: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2003: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2004: [17, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + 2005: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2006: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2007: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2008: [17, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31], + 2009: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2010: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2011: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2012: [17, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], + 2013: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2014: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2015: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2016: [17, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], + 2017: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2018: [18, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2019: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + 2020: [17, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], + 2021: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2022: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], + 2023: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + 2024: [17, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], + 2025: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2026: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2027: [17, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + 2028: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2029: [18, 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30], + 2030: [17, 31, 32, 31, 32, 31, 30, 30, 30, 30, 30, 30, 31], + 2031: [17, 31, 32, 31, 32, 31, 31, 31, 31, 31, 31, 31, 31], + 2032: [17, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32], + 2033: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2034: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2035: [17, 30, 32, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31], + 2036: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2037: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2038: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2039: [17, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], + 2040: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2041: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2042: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2043: [17, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], + 2044: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2045: [18, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2046: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2047: [17, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], + 2048: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2049: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], + 2050: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + 2051: [17, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], + 2052: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2053: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], + 2054: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + 2055: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 30, 29, 30], + 2056: [17, 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30], + 2057: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2058: [17, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + 2059: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2060: [17, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2061: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2062: [17, 30, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31], + 2063: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2064: [17, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2065: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2066: [17, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31], + 2067: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2068: [17, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2069: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2070: [17, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], + 2071: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2072: [17, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2073: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2074: [17, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], + 2075: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2076: [16, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], + 2077: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + 2078: [17, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], + 2079: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2080: [16, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], + // These data are from http://www.ashesh.com.np/nepali-calendar/ + 2081: [17, 31, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30], + 2082: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30], + 2083: [17, 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30], + 2084: [17, 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30], + 2085: [17, 31, 32, 31, 32, 31, 31, 30, 30, 29, 30, 30, 30], + 2086: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30], + 2087: [16, 31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30], + 2088: [16, 30, 31, 32, 32, 30, 31, 30, 30, 29, 30, 30, 30], + 2089: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30], + 2090: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30], + 2091: [16, 31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30], + 2092: [16, 31, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30], + 2093: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30], + 2094: [17, 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30], + 2095: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 30, 30, 30], + 2096: [17, 30, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2097: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30], + 2098: [17, 31, 31, 32, 31, 31, 31, 29, 30, 29, 30, 30, 31], + 2099: [17, 31, 31, 32, 31, 31, 31, 30, 29, 29, 30, 30, 30], + 2100: [17, 31, 32, 31, 32, 30, 31, 30, 29, 30, 29, 30, 30] + } +}); + +// Nepali calendar implementation +main.calendars.nepali = NepaliCalendar; + + +},{"../main":135,"object-assign":71}],131:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Persian calendar for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) August 2009. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +/** Implementation of the Persian or Jalali calendar. + Based on code from http://www.iranchamber.com/calendar/converter/iranian_calendar_converter.php. + See also http://en.wikipedia.org/wiki/Iranian_calendar. + @class PersianCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function PersianCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +PersianCalendar.prototype = new main.baseCalendar; + +assign(PersianCalendar.prototype, { + /** The calendar name. + @memberof PersianCalendar */ + name: 'Persian', + /** Julian date of start of Persian epoch: 19 March 622 CE. + @memberof PersianCalendar */ + jdEpoch: 1948320.5, + /** Days per month in a common year. + @memberof PersianCalendar */ + daysPerMonth: [31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29], + /** true if has a year zero, false if not. + @memberof PersianCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof PersianCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof PersianCalendar */ + firstMonth: 1, + /** The minimum day number. + @memberof PersianCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof PersianCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Persian', + epochs: ['BP', 'AP'], + monthNames: ['Farvardin', 'Ordibehesht', 'Khordad', 'Tir', 'Mordad', 'Shahrivar', + 'Mehr', 'Aban', 'Azar', 'Day', 'Bahman', 'Esfand'], + monthNamesShort: ['Far', 'Ord', 'Kho', 'Tir', 'Mor', 'Sha', 'Meh', 'Aba', 'Aza', 'Day', 'Bah', 'Esf'], + dayNames: ['Yekshambe', 'Doshambe', 'Seshambe', 'Chæharshambe', 'Panjshambe', 'Jom\'e', 'Shambe'], + dayNamesShort: ['Yek', 'Do', 'Se', 'Chæ', 'Panj', 'Jom', 'Sha'], + dayNamesMin: ['Ye','Do','Se','Ch','Pa','Jo','Sh'], + digits: null, + dateFormat: 'yyyy/mm/dd', + firstDay: 6, + isRTL: false + } + }, + + /** Determine whether this date is in a leap year. + @memberof PersianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + return (((((date.year() - (date.year() > 0 ? 474 : 473)) % 2820) + + 474 + 38) * 682) % 2816) < 682; + }, + + /** Determine the week of the year for a date. + @memberof PersianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + // Find Saturday of this week starting on Saturday + var checkDate = this.newDate(year, month, day); + checkDate.add(-((checkDate.dayOfWeek() + 1) % 7), 'd'); + return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1; + }, + + /** Retrieve the number of days in a month. + @memberof PersianCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + var date = this._validate(year, month, this.minDay, main.local.invalidMonth); + return this.daysPerMonth[date.month() - 1] + + (date.month() === 12 && this.leapYear(date.year()) ? 1 : 0); + }, + + /** Determine whether this date is a week day. + @memberof PersianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + return this.dayOfWeek(year, month, day) !== 5; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof PersianCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + year = date.year(); + month = date.month(); + day = date.day(); + var epBase = year - (year >= 0 ? 474 : 473); + var epYear = 474 + mod(epBase, 2820); + return day + (month <= 7 ? (month - 1) * 31 : (month - 1) * 30 + 6) + + Math.floor((epYear * 682 - 110) / 2816) + (epYear - 1) * 365 + + Math.floor(epBase / 2820) * 1029983 + this.jdEpoch - 1; + }, + + /** Create a new date from a Julian date. + @memberof PersianCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + jd = Math.floor(jd) + 0.5; + var depoch = jd - this.toJD(475, 1, 1); + var cycle = Math.floor(depoch / 1029983); + var cyear = mod(depoch, 1029983); + var ycycle = 2820; + if (cyear !== 1029982) { + var aux1 = Math.floor(cyear / 366); + var aux2 = mod(cyear, 366); + ycycle = Math.floor(((2134 * aux1) + (2816 * aux2) + 2815) / 1028522) + aux1 + 1; + } + var year = ycycle + (2820 * cycle) + 474; + year = (year <= 0 ? year - 1 : year); + var yday = jd - this.toJD(year, 1, 1) + 1; + var month = (yday <= 186 ? Math.ceil(yday / 31) : Math.ceil((yday - 6) / 30)); + var day = jd - this.toJD(year, month, 1) + 1; + return this.newDate(year, month, day); + } +}); + +// Modulus function which works for non-integers. +function mod(a, b) { + return a - (b * Math.floor(a / b)); +} + +// Persian (Jalali) calendar implementation +main.calendars.persian = PersianCalendar; +main.calendars.jalali = PersianCalendar; + + +},{"../main":135,"object-assign":71}],132:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Taiwanese (Minguo) calendar for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) February 2010. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +var gregorianCalendar = main.instance(); + +/** Implementation of the Taiwanese calendar. + See http://en.wikipedia.org/wiki/Minguo_calendar. + @class TaiwanCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function TaiwanCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +TaiwanCalendar.prototype = new main.baseCalendar; + +assign(TaiwanCalendar.prototype, { + /** The calendar name. + @memberof TaiwanCalendar */ + name: 'Taiwan', + /** Julian date of start of Taiwan epoch: 1 January 1912 CE (Gregorian). + @memberof TaiwanCalendar */ + jdEpoch: 2419402.5, + /** Difference in years between Taiwan and Gregorian calendars. + @memberof TaiwanCalendar */ + yearsOffset: 1911, + /** Days per month in a common year. + @memberof TaiwanCalendar */ + daysPerMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], + /** true if has a year zero, false if not. + @memberof TaiwanCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof TaiwanCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof TaiwanCalendar */ + firstMonth: 1, + /** The minimum day number. + @memberof TaiwanCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof TaiwanCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Taiwan', + epochs: ['BROC', 'ROC'], + monthNames: ['January', 'February', 'March', 'April', 'May', 'June', + 'July', 'August', 'September', 'October', 'November', 'December'], + monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], + dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], + dayNamesMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], + digits: null, + dateFormat: 'yyyy/mm/dd', + firstDay: 1, + isRTL: false + } + }, + + /** Determine whether this date is in a leap year. + @memberof TaiwanCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + var year = this._t2gYear(date.year()); + return gregorianCalendar.leapYear(year); + }, + + /** Determine the week of the year for a date - ISO 8601. + @memberof TaiwanCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + var year = this._t2gYear(date.year()); + return gregorianCalendar.weekOfYear(year, date.month(), date.day()); + }, + + /** Retrieve the number of days in a month. + @memberof TaiwanCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + var date = this._validate(year, month, this.minDay, main.local.invalidMonth); + return this.daysPerMonth[date.month() - 1] + + (date.month() === 2 && this.leapYear(date.year()) ? 1 : 0); + }, + + /** Determine whether this date is a week day. + @memberof TaiwanCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + return (this.dayOfWeek(year, month, day) || 7) < 6; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof TaiwanCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + var year = this._t2gYear(date.year()); + return gregorianCalendar.toJD(year, date.month(), date.day()); + }, + + /** Create a new date from a Julian date. + @memberof TaiwanCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + var date = gregorianCalendar.fromJD(jd); + var year = this._g2tYear(date.year()); + return this.newDate(year, date.month(), date.day()); + }, + + /** Convert Taiwanese to Gregorian year. + @memberof TaiwanCalendar + @private + @param year {number} The Taiwanese year. + @return {number} The corresponding Gregorian year. */ + _t2gYear: function(year) { + return year + this.yearsOffset + (year >= -this.yearsOffset && year <= -1 ? 1 : 0); + }, + + /** Convert Gregorian to Taiwanese year. + @memberof TaiwanCalendar + @private + @param year {number} The Gregorian year. + @return {number} The corresponding Taiwanese year. */ + _g2tYear: function(year) { + return year - this.yearsOffset - (year >= 1 && year <= this.yearsOffset ? 1 : 0); + } +}); + +// Taiwan calendar implementation +main.calendars.taiwan = TaiwanCalendar; + + +},{"../main":135,"object-assign":71}],133:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Thai calendar for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) February 2010. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +var gregorianCalendar = main.instance(); + +/** Implementation of the Thai calendar. + See http://en.wikipedia.org/wiki/Thai_calendar. + @class ThaiCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function ThaiCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +ThaiCalendar.prototype = new main.baseCalendar; + +assign(ThaiCalendar.prototype, { + /** The calendar name. + @memberof ThaiCalendar */ + name: 'Thai', + /** Julian date of start of Thai epoch: 1 January 543 BCE (Gregorian). + @memberof ThaiCalendar */ + jdEpoch: 1523098.5, + /** Difference in years between Thai and Gregorian calendars. + @memberof ThaiCalendar */ + yearsOffset: 543, + /** Days per month in a common year. + @memberof ThaiCalendar */ + daysPerMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], + /** true if has a year zero, false if not. + @memberof ThaiCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof ThaiCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof ThaiCalendar */ + firstMonth: 1, + /** The minimum day number. + @memberof ThaiCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof ThaiCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Thai', + epochs: ['BBE', 'BE'], + monthNames: ['January', 'February', 'March', 'April', 'May', 'June', + 'July', 'August', 'September', 'October', 'November', 'December'], + monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], + dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], + dayNamesMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], + digits: null, + dateFormat: 'dd/mm/yyyy', + firstDay: 0, + isRTL: false + } + }, + + /** Determine whether this date is in a leap year. + @memberof ThaiCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + var year = this._t2gYear(date.year()); + return gregorianCalendar.leapYear(year); + }, + + /** Determine the week of the year for a date - ISO 8601. + @memberof ThaiCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + var year = this._t2gYear(date.year()); + return gregorianCalendar.weekOfYear(year, date.month(), date.day()); + }, + + /** Retrieve the number of days in a month. + @memberof ThaiCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + var date = this._validate(year, month, this.minDay, main.local.invalidMonth); + return this.daysPerMonth[date.month() - 1] + + (date.month() === 2 && this.leapYear(date.year()) ? 1 : 0); + }, + + /** Determine whether this date is a week day. + @memberof ThaiCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + return (this.dayOfWeek(year, month, day) || 7) < 6; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof ThaiCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + var year = this._t2gYear(date.year()); + return gregorianCalendar.toJD(year, date.month(), date.day()); + }, + + /** Create a new date from a Julian date. + @memberof ThaiCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + var date = gregorianCalendar.fromJD(jd); + var year = this._g2tYear(date.year()); + return this.newDate(year, date.month(), date.day()); + }, + + /** Convert Thai to Gregorian year. + @memberof ThaiCalendar + @private + @param year {number} The Thai year. + @return {number} The corresponding Gregorian year. */ + _t2gYear: function(year) { + return year - this.yearsOffset - (year >= 1 && year <= this.yearsOffset ? 1 : 0); + }, + + /** Convert Gregorian to Thai year. + @memberof ThaiCalendar + @private + @param year {number} The Gregorian year. + @return {number} The corresponding Thai year. */ + _g2tYear: function(year) { + return year + this.yearsOffset + (year >= -this.yearsOffset && year <= -1 ? 1 : 0); + } +}); + +// Thai calendar implementation +main.calendars.thai = ThaiCalendar; + + +},{"../main":135,"object-assign":71}],134:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + UmmAlQura calendar for jQuery v2.0.2. + Written by Amro Osama March 2013. + Modified by Binnooh.com & www.elm.sa - 2014 - Added dates back to 1276 Hijri year. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +/** Implementation of the UmmAlQura or 'saudi' calendar. + See also http://en.wikipedia.org/wiki/Islamic_calendar#Saudi_Arabia.27s_Umm_al-Qura_calendar. + http://www.ummulqura.org.sa/About.aspx + http://www.staff.science.uu.nl/~gent0113/islam/ummalqura.htm + @class UmmAlQuraCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function UmmAlQuraCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +UmmAlQuraCalendar.prototype = new main.baseCalendar; + +assign(UmmAlQuraCalendar.prototype, { + /** The calendar name. + @memberof UmmAlQuraCalendar */ + name: 'UmmAlQura', + //jdEpoch: 1948440, // Julian date of start of UmmAlQura epoch: 14 March 1937 CE + //daysPerMonth: // Days per month in a common year, replaced by a method. + /** true if has a year zero, false if not. + @memberof UmmAlQuraCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof UmmAlQuraCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof UmmAlQuraCalendar */ + firstMonth: 1, + /** The minimum day number. + @memberof UmmAlQuraCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof UmmAlQuraCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Umm al-Qura', + epochs: ['BH', 'AH'], + monthNames: ['Al-Muharram', 'Safar', 'Rabi\' al-awwal', 'Rabi\' Al-Thani', 'Jumada Al-Awwal', 'Jumada Al-Thani', + 'Rajab', 'Sha\'aban', 'Ramadan', 'Shawwal', 'Dhu al-Qi\'dah', 'Dhu al-Hijjah'], + monthNamesShort: ['Muh', 'Saf', 'Rab1', 'Rab2', 'Jum1', 'Jum2', 'Raj', 'Sha\'', 'Ram', 'Shaw', 'DhuQ', 'DhuH'], + dayNames: ['Yawm al-Ahad', 'Yawm al-Ithnain', 'Yawm al-Thalāthā’', 'Yawm al-Arba‘ā’', 'Yawm al-Khamīs', 'Yawm al-Jum‘a', 'Yawm al-Sabt'], + dayNamesMin: ['Ah', 'Ith', 'Th', 'Ar', 'Kh', 'Ju', 'Sa'], + digits: null, + dateFormat: 'yyyy/mm/dd', + firstDay: 6, + isRTL: true + } + }, + + /** Determine whether this date is in a leap year. + @memberof UmmAlQuraCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function (year) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + return (this.daysInYear(date.year()) === 355); + }, + + /** Determine the week of the year for a date. + @memberof UmmAlQuraCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function (year, month, day) { + // Find Sunday of this week starting on Sunday + var checkDate = this.newDate(year, month, day); + checkDate.add(-checkDate.dayOfWeek(), 'd'); + return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1; + }, + + /** Retrieve the number of days in a year. + @memberof UmmAlQuraCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of days. + @throws Error if an invalid year or a different calendar used. */ + daysInYear: function (year) { + var daysCount = 0; + for (var i = 1; i <= 12; i++) { + daysCount += this.daysInMonth(year, i); + } + return daysCount; + }, + + /** Retrieve the number of days in a month. + @memberof UmmAlQuraCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function (year, month) { + var date = this._validate(year, month, this.minDay, main.local.invalidMonth); + var mcjdn = date.toJD() - 2400000 + 0.5; // Modified Chronological Julian Day Number (MCJDN) + // the MCJDN's of the start of the lunations in the Umm al-Qura calendar are stored in the 'ummalqura_dat' array + var index = 0; + for (var i = 0; i < ummalqura_dat.length; i++) { + if (ummalqura_dat[i] > mcjdn) { + return (ummalqura_dat[index] - ummalqura_dat[index - 1]); + } + index++; + } + return 30; // Unknown outside + }, + + /** Determine whether this date is a week day. + @memberof UmmAlQuraCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function (year, month, day) { + return this.dayOfWeek(year, month, day) !== 5; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof UmmAlQuraCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function (year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + var index = (12 * (date.year() - 1)) + date.month() - 15292; + var mcjdn = date.day() + ummalqura_dat[index - 1] - 1; + return mcjdn + 2400000 - 0.5; // Modified Chronological Julian Day Number (MCJDN) + }, + + /** Create a new date from a Julian date. + @memberof UmmAlQuraCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function (jd) { + var mcjdn = jd - 2400000 + 0.5; // Modified Chronological Julian Day Number (MCJDN) + // the MCJDN's of the start of the lunations in the Umm al-Qura calendar + // are stored in the 'ummalqura_dat' array + var index = 0; + for (var i = 0; i < ummalqura_dat.length; i++) { + if (ummalqura_dat[i] > mcjdn) break; + index++; + } + var lunation = index + 15292; //UmmAlQura Lunation Number + var ii = Math.floor((lunation - 1) / 12); + var year = ii + 1; + var month = lunation - 12 * ii; + var day = mcjdn - ummalqura_dat[index - 1] + 1; + return this.newDate(year, month, day); + }, + + /** Determine whether a date is valid for this calendar. + @memberof UmmAlQuraCalendar + @param year {number} The year to examine. + @param month {number} The month to examine. + @param day {number} The day to examine. + @return {boolean} true if a valid date, false if not. */ + isValid: function(year, month, day) { + var valid = main.baseCalendar.prototype.isValid.apply(this, arguments); + if (valid) { + year = (year.year != null ? year.year : year); + valid = (year >= 1276 && year <= 1500); + } + return valid; + }, + + /** Check that a candidate date is from the same calendar and is valid. + @memberof UmmAlQuraCalendar + @private + @param year {CDate|number} The date to validate or the year to validate. + @param month {number} The month to validate. + @param day {number} The day to validate. + @param error {string} Error message if invalid. + @throws Error if different calendars used or invalid date. */ + _validate: function(year, month, day, error) { + var date = main.baseCalendar.prototype._validate.apply(this, arguments); + if (date.year < 1276 || date.year > 1500) { + throw error.replace(/\{0\}/, this.local.name); + } + return date; + } +}); + +// UmmAlQura calendar implementation +main.calendars.ummalqura = UmmAlQuraCalendar; + +var ummalqura_dat = [ + 20, 50, 79, 109, 138, 168, 197, 227, 256, 286, 315, 345, 374, 404, 433, 463, 492, 522, 551, 581, + 611, 641, 670, 700, 729, 759, 788, 818, 847, 877, 906, 936, 965, 995, 1024, 1054, 1083, 1113, 1142, 1172, + 1201, 1231, 1260, 1290, 1320, 1350, 1379, 1409, 1438, 1468, 1497, 1527, 1556, 1586, 1615, 1645, 1674, 1704, 1733, 1763, + 1792, 1822, 1851, 1881, 1910, 1940, 1969, 1999, 2028, 2058, 2087, 2117, 2146, 2176, 2205, 2235, 2264, 2294, 2323, 2353, + 2383, 2413, 2442, 2472, 2501, 2531, 2560, 2590, 2619, 2649, 2678, 2708, 2737, 2767, 2796, 2826, 2855, 2885, 2914, 2944, + 2973, 3003, 3032, 3062, 3091, 3121, 3150, 3180, 3209, 3239, 3268, 3298, 3327, 3357, 3386, 3416, 3446, 3476, 3505, 3535, + 3564, 3594, 3623, 3653, 3682, 3712, 3741, 3771, 3800, 3830, 3859, 3889, 3918, 3948, 3977, 4007, 4036, 4066, 4095, 4125, + 4155, 4185, 4214, 4244, 4273, 4303, 4332, 4362, 4391, 4421, 4450, 4480, 4509, 4539, 4568, 4598, 4627, 4657, 4686, 4716, + 4745, 4775, 4804, 4834, 4863, 4893, 4922, 4952, 4981, 5011, 5040, 5070, 5099, 5129, 5158, 5188, 5218, 5248, 5277, 5307, + 5336, 5366, 5395, 5425, 5454, 5484, 5513, 5543, 5572, 5602, 5631, 5661, 5690, 5720, 5749, 5779, 5808, 5838, 5867, 5897, + 5926, 5956, 5985, 6015, 6044, 6074, 6103, 6133, 6162, 6192, 6221, 6251, 6281, 6311, 6340, 6370, 6399, 6429, 6458, 6488, + 6517, 6547, 6576, 6606, 6635, 6665, 6694, 6724, 6753, 6783, 6812, 6842, 6871, 6901, 6930, 6960, 6989, 7019, 7048, 7078, + 7107, 7137, 7166, 7196, 7225, 7255, 7284, 7314, 7344, 7374, 7403, 7433, 7462, 7492, 7521, 7551, 7580, 7610, 7639, 7669, + 7698, 7728, 7757, 7787, 7816, 7846, 7875, 7905, 7934, 7964, 7993, 8023, 8053, 8083, 8112, 8142, 8171, 8201, 8230, 8260, + 8289, 8319, 8348, 8378, 8407, 8437, 8466, 8496, 8525, 8555, 8584, 8614, 8643, 8673, 8702, 8732, 8761, 8791, 8821, 8850, + 8880, 8909, 8938, 8968, 8997, 9027, 9056, 9086, 9115, 9145, 9175, 9205, 9234, 9264, 9293, 9322, 9352, 9381, 9410, 9440, + 9470, 9499, 9529, 9559, 9589, 9618, 9648, 9677, 9706, 9736, 9765, 9794, 9824, 9853, 9883, 9913, 9943, 9972, 10002, 10032, + 10061, 10090, 10120, 10149, 10178, 10208, 10237, 10267, 10297, 10326, 10356, 10386, 10415, 10445, 10474, 10504, 10533, 10562, 10592, 10621, + 10651, 10680, 10710, 10740, 10770, 10799, 10829, 10858, 10888, 10917, 10947, 10976, 11005, 11035, 11064, 11094, 11124, 11153, 11183, 11213, + 11242, 11272, 11301, 11331, 11360, 11389, 11419, 11448, 11478, 11507, 11537, 11567, 11596, 11626, 11655, 11685, 11715, 11744, 11774, 11803, + 11832, 11862, 11891, 11921, 11950, 11980, 12010, 12039, 12069, 12099, 12128, 12158, 12187, 12216, 12246, 12275, 12304, 12334, 12364, 12393, + 12423, 12453, 12483, 12512, 12542, 12571, 12600, 12630, 12659, 12688, 12718, 12747, 12777, 12807, 12837, 12866, 12896, 12926, 12955, 12984, + 13014, 13043, 13072, 13102, 13131, 13161, 13191, 13220, 13250, 13280, 13310, 13339, 13368, 13398, 13427, 13456, 13486, 13515, 13545, 13574, + 13604, 13634, 13664, 13693, 13723, 13752, 13782, 13811, 13840, 13870, 13899, 13929, 13958, 13988, 14018, 14047, 14077, 14107, 14136, 14166, + 14195, 14224, 14254, 14283, 14313, 14342, 14372, 14401, 14431, 14461, 14490, 14520, 14550, 14579, 14609, 14638, 14667, 14697, 14726, 14756, + 14785, 14815, 14844, 14874, 14904, 14933, 14963, 14993, 15021, 15051, 15081, 15110, 15140, 15169, 15199, 15228, 15258, 15287, 15317, 15347, + 15377, 15406, 15436, 15465, 15494, 15524, 15553, 15582, 15612, 15641, 15671, 15701, 15731, 15760, 15790, 15820, 15849, 15878, 15908, 15937, + 15966, 15996, 16025, 16055, 16085, 16114, 16144, 16174, 16204, 16233, 16262, 16292, 16321, 16350, 16380, 16409, 16439, 16468, 16498, 16528, + 16558, 16587, 16617, 16646, 16676, 16705, 16734, 16764, 16793, 16823, 16852, 16882, 16912, 16941, 16971, 17001, 17030, 17060, 17089, 17118, + 17148, 17177, 17207, 17236, 17266, 17295, 17325, 17355, 17384, 17414, 17444, 17473, 17502, 17532, 17561, 17591, 17620, 17650, 17679, 17709, + 17738, 17768, 17798, 17827, 17857, 17886, 17916, 17945, 17975, 18004, 18034, 18063, 18093, 18122, 18152, 18181, 18211, 18241, 18270, 18300, + 18330, 18359, 18388, 18418, 18447, 18476, 18506, 18535, 18565, 18595, 18625, 18654, 18684, 18714, 18743, 18772, 18802, 18831, 18860, 18890, + 18919, 18949, 18979, 19008, 19038, 19068, 19098, 19127, 19156, 19186, 19215, 19244, 19274, 19303, 19333, 19362, 19392, 19422, 19452, 19481, + 19511, 19540, 19570, 19599, 19628, 19658, 19687, 19717, 19746, 19776, 19806, 19836, 19865, 19895, 19924, 19954, 19983, 20012, 20042, 20071, + 20101, 20130, 20160, 20190, 20219, 20249, 20279, 20308, 20338, 20367, 20396, 20426, 20455, 20485, 20514, 20544, 20573, 20603, 20633, 20662, + 20692, 20721, 20751, 20780, 20810, 20839, 20869, 20898, 20928, 20957, 20987, 21016, 21046, 21076, 21105, 21135, 21164, 21194, 21223, 21253, + 21282, 21312, 21341, 21371, 21400, 21430, 21459, 21489, 21519, 21548, 21578, 21607, 21637, 21666, 21696, 21725, 21754, 21784, 21813, 21843, + 21873, 21902, 21932, 21962, 21991, 22021, 22050, 22080, 22109, 22138, 22168, 22197, 22227, 22256, 22286, 22316, 22346, 22375, 22405, 22434, + 22464, 22493, 22522, 22552, 22581, 22611, 22640, 22670, 22700, 22730, 22759, 22789, 22818, 22848, 22877, 22906, 22936, 22965, 22994, 23024, + 23054, 23083, 23113, 23143, 23173, 23202, 23232, 23261, 23290, 23320, 23349, 23379, 23408, 23438, 23467, 23497, 23527, 23556, 23586, 23616, + 23645, 23674, 23704, 23733, 23763, 23792, 23822, 23851, 23881, 23910, 23940, 23970, 23999, 24029, 24058, 24088, 24117, 24147, 24176, 24206, + 24235, 24265, 24294, 24324, 24353, 24383, 24413, 24442, 24472, 24501, 24531, 24560, 24590, 24619, 24648, 24678, 24707, 24737, 24767, 24796, + 24826, 24856, 24885, 24915, 24944, 24974, 25003, 25032, 25062, 25091, 25121, 25150, 25180, 25210, 25240, 25269, 25299, 25328, 25358, 25387, + 25416, 25446, 25475, 25505, 25534, 25564, 25594, 25624, 25653, 25683, 25712, 25742, 25771, 25800, 25830, 25859, 25888, 25918, 25948, 25977, + 26007, 26037, 26067, 26096, 26126, 26155, 26184, 26214, 26243, 26272, 26302, 26332, 26361, 26391, 26421, 26451, 26480, 26510, 26539, 26568, + 26598, 26627, 26656, 26686, 26715, 26745, 26775, 26805, 26834, 26864, 26893, 26923, 26952, 26982, 27011, 27041, 27070, 27099, 27129, 27159, + 27188, 27218, 27248, 27277, 27307, 27336, 27366, 27395, 27425, 27454, 27484, 27513, 27542, 27572, 27602, 27631, 27661, 27691, 27720, 27750, + 27779, 27809, 27838, 27868, 27897, 27926, 27956, 27985, 28015, 28045, 28074, 28104, 28134, 28163, 28193, 28222, 28252, 28281, 28310, 28340, + 28369, 28399, 28428, 28458, 28488, 28517, 28547, 28577, + // From 1356 + 28607, 28636, 28665, 28695, 28724, 28754, 28783, 28813, 28843, 28872, 28901, 28931, 28960, 28990, 29019, 29049, 29078, 29108, 29137, 29167, + 29196, 29226, 29255, 29285, 29315, 29345, 29375, 29404, 29434, 29463, 29492, 29522, 29551, 29580, 29610, 29640, 29669, 29699, 29729, 29759, + 29788, 29818, 29847, 29876, 29906, 29935, 29964, 29994, 30023, 30053, 30082, 30112, 30141, 30171, 30200, 30230, 30259, 30289, 30318, 30348, + 30378, 30408, 30437, 30467, 30496, 30526, 30555, 30585, 30614, 30644, 30673, 30703, 30732, 30762, 30791, 30821, 30850, 30880, 30909, 30939, + 30968, 30998, 31027, 31057, 31086, 31116, 31145, 31175, 31204, 31234, 31263, 31293, 31322, 31352, 31381, 31411, 31441, 31471, 31500, 31530, + 31559, 31589, 31618, 31648, 31676, 31706, 31736, 31766, 31795, 31825, 31854, 31884, 31913, 31943, 31972, 32002, 32031, 32061, 32090, 32120, + 32150, 32180, 32209, 32239, 32268, 32298, 32327, 32357, 32386, 32416, 32445, 32475, 32504, 32534, 32563, 32593, 32622, 32652, 32681, 32711, + 32740, 32770, 32799, 32829, 32858, 32888, 32917, 32947, 32976, 33006, 33035, 33065, 33094, 33124, 33153, 33183, 33213, 33243, 33272, 33302, + 33331, 33361, 33390, 33420, 33450, 33479, 33509, 33539, 33568, 33598, 33627, 33657, 33686, 33716, 33745, 33775, 33804, 33834, 33863, 33893, + 33922, 33952, 33981, 34011, 34040, 34069, 34099, 34128, 34158, 34187, 34217, 34247, 34277, 34306, 34336, 34365, 34395, 34424, 34454, 34483, + 34512, 34542, 34571, 34601, 34631, 34660, 34690, 34719, 34749, 34778, 34808, 34837, 34867, 34896, 34926, 34955, 34985, 35015, 35044, 35074, + 35103, 35133, 35162, 35192, 35222, 35251, 35280, 35310, 35340, 35370, 35399, 35429, 35458, 35488, 35517, 35547, 35576, 35605, 35635, 35665, + 35694, 35723, 35753, 35782, 35811, 35841, 35871, 35901, 35930, 35960, 35989, 36019, 36048, 36078, 36107, 36136, 36166, 36195, 36225, 36254, + 36284, 36314, 36343, 36373, 36403, 36433, 36462, 36492, 36521, 36551, 36580, 36610, 36639, 36669, 36698, 36728, 36757, 36786, 36816, 36845, + 36875, 36904, 36934, 36963, 36993, 37022, 37052, 37081, 37111, 37141, 37170, 37200, 37229, 37259, 37288, 37318, 37347, 37377, 37406, 37436, + 37465, 37495, 37524, 37554, 37584, 37613, 37643, 37672, 37701, 37731, 37760, 37790, 37819, 37849, 37878, 37908, 37938, 37967, 37997, 38027, + 38056, 38085, 38115, 38144, 38174, 38203, 38233, 38262, 38292, 38322, 38351, 38381, 38410, 38440, 38469, 38499, 38528, 38558, 38587, 38617, + 38646, 38676, 38705, 38735, 38764, 38794, 38823, 38853, 38882, 38912, 38941, 38971, 39001, 39030, 39059, 39089, 39118, 39148, 39178, 39208, + 39237, 39267, 39297, 39326, 39355, 39385, 39414, 39444, 39473, 39503, 39532, 39562, 39592, 39621, 39650, 39680, 39709, 39739, 39768, 39798, + 39827, 39857, 39886, 39916, 39946, 39975, 40005, 40035, 40064, 40094, 40123, 40153, 40182, 40212, 40241, 40271, 40300, 40330, 40359, 40389, + 40418, 40448, 40477, 40507, 40536, 40566, 40595, 40625, 40655, 40685, 40714, 40744, 40773, 40803, 40832, 40862, 40892, 40921, 40951, 40980, + 41009, 41039, 41068, 41098, 41127, 41157, 41186, 41216, 41245, 41275, 41304, 41334, 41364, 41393, 41422, 41452, 41481, 41511, 41540, 41570, + 41599, 41629, 41658, 41688, 41718, 41748, 41777, 41807, 41836, 41865, 41894, 41924, 41953, 41983, 42012, 42042, 42072, 42102, 42131, 42161, + 42190, 42220, 42249, 42279, 42308, 42337, 42367, 42397, 42426, 42456, 42485, 42515, 42545, 42574, 42604, 42633, 42662, 42692, 42721, 42751, + 42780, 42810, 42839, 42869, 42899, 42929, 42958, 42988, 43017, 43046, 43076, 43105, 43135, 43164, 43194, 43223, 43253, 43283, 43312, 43342, + 43371, 43401, 43430, 43460, 43489, 43519, 43548, 43578, 43607, 43637, 43666, 43696, 43726, 43755, 43785, 43814, 43844, 43873, 43903, 43932, + 43962, 43991, 44021, 44050, 44080, 44109, 44139, 44169, 44198, 44228, 44258, 44287, 44317, 44346, 44375, 44405, 44434, 44464, 44493, 44523, + 44553, 44582, 44612, 44641, 44671, 44700, 44730, 44759, 44788, 44818, 44847, 44877, 44906, 44936, 44966, 44996, 45025, 45055, 45084, 45114, + 45143, 45172, 45202, 45231, 45261, 45290, 45320, 45350, 45380, 45409, 45439, 45468, 45498, 45527, 45556, 45586, 45615, 45644, 45674, 45704, + 45733, 45763, 45793, 45823, 45852, 45882, 45911, 45940, 45970, 45999, 46028, 46058, 46088, 46117, 46147, 46177, 46206, 46236, 46265, 46295, + 46324, 46354, 46383, 46413, 46442, 46472, 46501, 46531, 46560, 46590, 46620, 46649, 46679, 46708, 46738, 46767, 46797, 46826, 46856, 46885, + 46915, 46944, 46974, 47003, 47033, 47063, 47092, 47122, 47151, 47181, 47210, 47240, 47269, 47298, 47328, 47357, 47387, 47417, 47446, 47476, + 47506, 47535, 47565, 47594, 47624, 47653, 47682, 47712, 47741, 47771, 47800, 47830, 47860, 47890, 47919, 47949, 47978, 48008, 48037, 48066, + 48096, 48125, 48155, 48184, 48214, 48244, 48273, 48303, 48333, 48362, 48392, 48421, 48450, 48480, 48509, 48538, 48568, 48598, 48627, 48657, + 48687, 48717, 48746, 48776, 48805, 48834, 48864, 48893, 48922, 48952, 48982, 49011, 49041, 49071, 49100, 49130, 49160, 49189, 49218, 49248, + 49277, 49306, 49336, 49365, 49395, 49425, 49455, 49484, 49514, 49543, 49573, 49602, 49632, 49661, 49690, 49720, 49749, 49779, 49809, 49838, + 49868, 49898, 49927, 49957, 49986, 50016, 50045, 50075, 50104, 50133, 50163, 50192, 50222, 50252, 50281, 50311, 50340, 50370, 50400, 50429, + 50459, 50488, 50518, 50547, 50576, 50606, 50635, 50665, 50694, 50724, 50754, 50784, 50813, 50843, 50872, 50902, 50931, 50960, 50990, 51019, + 51049, 51078, 51108, 51138, 51167, 51197, 51227, 51256, 51286, 51315, 51345, 51374, 51403, 51433, 51462, 51492, 51522, 51552, 51582, 51611, + 51641, 51670, 51699, 51729, 51758, 51787, 51816, 51846, 51876, 51906, 51936, 51965, 51995, 52025, 52054, 52083, 52113, 52142, 52171, 52200, + 52230, 52260, 52290, 52319, 52349, 52379, 52408, 52438, 52467, 52497, 52526, 52555, 52585, 52614, 52644, 52673, 52703, 52733, 52762, 52792, + 52822, 52851, 52881, 52910, 52939, 52969, 52998, 53028, 53057, 53087, 53116, 53146, 53176, 53205, 53235, 53264, 53294, 53324, 53353, 53383, + 53412, 53441, 53471, 53500, 53530, 53559, 53589, 53619, 53648, 53678, 53708, 53737, 53767, 53796, 53825, 53855, 53884, 53913, 53943, 53973, + 54003, 54032, 54062, 54092, 54121, 54151, 54180, 54209, 54239, 54268, 54297, 54327, 54357, 54387, 54416, 54446, 54476, 54505, 54535, 54564, + 54593, 54623, 54652, 54681, 54711, 54741, 54770, 54800, 54830, 54859, 54889, 54919, 54948, 54977, 55007, 55036, 55066, 55095, 55125, 55154, + 55184, 55213, 55243, 55273, 55302, 55332, 55361, 55391, 55420, 55450, 55479, 55508, 55538, 55567, 55597, 55627, 55657, 55686, 55716, 55745, + 55775, 55804, 55834, 55863, 55892, 55922, 55951, 55981, 56011, 56040, 56070, 56100, 56129, 56159, 56188, 56218, 56247, 56276, 56306, 56335, + 56365, 56394, 56424, 56454, 56483, 56513, 56543, 56572, 56601, 56631, 56660, 56690, 56719, 56749, 56778, 56808, 56837, 56867, 56897, 56926, + 56956, 56985, 57015, 57044, 57074, 57103, 57133, 57162, 57192, 57221, 57251, 57280, 57310, 57340, 57369, 57399, 57429, 57458, 57487, 57517, + 57546, 57576, 57605, 57634, 57664, 57694, 57723, 57753, 57783, 57813, 57842, 57871, 57901, 57930, 57959, 57989, 58018, 58048, 58077, 58107, + 58137, 58167, 58196, 58226, 58255, 58285, 58314, 58343, 58373, 58402, 58432, 58461, 58491, 58521, 58551, 58580, 58610, 58639, 58669, 58698, + 58727, 58757, 58786, 58816, 58845, 58875, 58905, 58934, 58964, 58994, 59023, 59053, 59082, 59111, 59141, 59170, 59200, 59229, 59259, 59288, + 59318, 59348, 59377, 59407, 59436, 59466, 59495, 59525, 59554, 59584, 59613, 59643, 59672, 59702, 59731, 59761, 59791, 59820, 59850, 59879, + 59909, 59939, 59968, 59997, 60027, 60056, 60086, 60115, 60145, 60174, 60204, 60234, 60264, 60293, 60323, 60352, 60381, 60411, 60440, 60469, + 60499, 60528, 60558, 60588, 60618, 60648, 60677, 60707, 60736, 60765, 60795, 60824, 60853, 60883, 60912, 60942, 60972, 61002, 61031, 61061, + 61090, 61120, 61149, 61179, 61208, 61237, 61267, 61296, 61326, 61356, 61385, 61415, 61445, 61474, 61504, 61533, 61563, 61592, 61621, 61651, + 61680, 61710, 61739, 61769, 61799, 61828, 61858, 61888, 61917, 61947, 61976, 62006, 62035, 62064, 62094, 62123, 62153, 62182, 62212, 62242, + 62271, 62301, 62331, 62360, 62390, 62419, 62448, 62478, 62507, 62537, 62566, 62596, 62625, 62655, 62685, 62715, 62744, 62774, 62803, 62832, + 62862, 62891, 62921, 62950, 62980, 63009, 63039, 63069, 63099, 63128, 63157, 63187, 63216, 63246, 63275, 63305, 63334, 63363, 63393, 63423, + 63453, 63482, 63512, 63541, 63571, 63600, 63630, 63659, 63689, 63718, 63747, 63777, 63807, 63836, 63866, 63895, 63925, 63955, 63984, 64014, + 64043, 64073, 64102, 64131, 64161, 64190, 64220, 64249, 64279, 64309, 64339, 64368, 64398, 64427, 64457, 64486, 64515, 64545, 64574, 64603, + 64633, 64663, 64692, 64722, 64752, 64782, 64811, 64841, 64870, 64899, 64929, 64958, 64987, 65017, 65047, 65076, 65106, 65136, 65166, 65195, + 65225, 65254, 65283, 65313, 65342, 65371, 65401, 65431, 65460, 65490, 65520, 65549, 65579, 65608, 65638, 65667, 65697, 65726, 65755, 65785, + 65815, 65844, 65874, 65903, 65933, 65963, 65992, 66022, 66051, 66081, 66110, 66140, 66169, 66199, 66228, 66258, 66287, 66317, 66346, 66376, + 66405, 66435, 66465, 66494, 66524, 66553, 66583, 66612, 66641, 66671, 66700, 66730, 66760, 66789, 66819, 66849, 66878, 66908, 66937, 66967, + 66996, 67025, 67055, 67084, 67114, 67143, 67173, 67203, 67233, 67262, 67292, 67321, 67351, 67380, 67409, 67439, 67468, 67497, 67527, 67557, + 67587, 67617, 67646, 67676, 67705, 67735, 67764, 67793, 67823, 67852, 67882, 67911, 67941, 67971, 68000, 68030, 68060, 68089, 68119, 68148, + 68177, 68207, 68236, 68266, 68295, 68325, 68354, 68384, 68414, 68443, 68473, 68502, 68532, 68561, 68591, 68620, 68650, 68679, 68708, 68738, + 68768, 68797, 68827, 68857, 68886, 68916, 68946, 68975, 69004, 69034, 69063, 69092, 69122, 69152, 69181, 69211, 69240, 69270, 69300, 69330, + 69359, 69388, 69418, 69447, 69476, 69506, 69535, 69565, 69595, 69624, 69654, 69684, 69713, 69743, 69772, 69802, 69831, 69861, 69890, 69919, + 69949, 69978, 70008, 70038, 70067, 70097, 70126, 70156, 70186, 70215, 70245, 70274, 70303, 70333, 70362, 70392, 70421, 70451, 70481, 70510, + 70540, 70570, 70599, 70629, 70658, 70687, 70717, 70746, 70776, 70805, 70835, 70864, 70894, 70924, 70954, 70983, 71013, 71042, 71071, 71101, + 71130, 71159, 71189, 71218, 71248, 71278, 71308, 71337, 71367, 71397, 71426, 71455, 71485, 71514, 71543, 71573, 71602, 71632, 71662, 71691, + 71721, 71751, 71781, 71810, 71839, 71869, 71898, 71927, 71957, 71986, 72016, 72046, 72075, 72105, 72135, 72164, 72194, 72223, 72253, 72282, + 72311, 72341, 72370, 72400, 72429, 72459, 72489, 72518, 72548, 72577, 72607, 72637, 72666, 72695, 72725, 72754, 72784, 72813, 72843, 72872, + 72902, 72931, 72961, 72991, 73020, 73050, 73080, 73109, 73139, 73168, 73197, 73227, 73256, 73286, 73315, 73345, 73375, 73404, 73434, 73464, + 73493, 73523, 73552, 73581, 73611, 73640, 73669, 73699, 73729, 73758, 73788, 73818, 73848, 73877, 73907, 73936, 73965, 73995, 74024, 74053, + 74083, 74113, 74142, 74172, 74202, 74231, 74261, 74291, 74320, 74349, 74379, 74408, 74437, 74467, 74497, 74526, 74556, 74586, 74615, 74645, + 74675, 74704, 74733, 74763, 74792, 74822, 74851, 74881, 74910, 74940, 74969, 74999, 75029, 75058, 75088, 75117, 75147, 75176, 75206, 75235, + 75264, 75294, 75323, 75353, 75383, 75412, 75442, 75472, 75501, 75531, 75560, 75590, 75619, 75648, 75678, 75707, 75737, 75766, 75796, 75826, + 75856, 75885, 75915, 75944, 75974, 76003, 76032, 76062, 76091, 76121, 76150, 76180, 76210, 76239, 76269, 76299, 76328, 76358, 76387, 76416, + 76446, 76475, 76505, 76534, 76564, 76593, 76623, 76653, 76682, 76712, 76741, 76771, 76801, 76830, 76859, 76889, 76918, 76948, 76977, 77007, + 77036, 77066, 77096, 77125, 77155, 77185, 77214, 77243, 77273, 77302, 77332, 77361, 77390, 77420, 77450, 77479, 77509, 77539, 77569, 77598, + 77627, 77657, 77686, 77715, 77745, 77774, 77804, 77833, 77863, 77893, 77923, 77952, 77982, 78011, 78041, 78070, 78099, 78129, 78158, 78188, + 78217, 78247, 78277, 78307, 78336, 78366, 78395, 78425, 78454, 78483, 78513, 78542, 78572, 78601, 78631, 78661, 78690, 78720, 78750, 78779, + 78808, 78838, 78867, 78897, 78926, 78956, 78985, 79015, 79044, 79074, 79104, 79133, 79163, 79192, 79222, 79251, 79281, 79310, 79340, 79369, + 79399, 79428, 79458, 79487, 79517, 79546, 79576, 79606, 79635, 79665, 79695, 79724, 79753, 79783, 79812, 79841, 79871, 79900, 79930, 79960, + 79990]; + + +},{"../main":135,"object-assign":71}],135:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Calendars for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) August 2009. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var assign = _dereq_('object-assign'); + + +function Calendars() { + this.regionalOptions = []; + this.regionalOptions[''] = { + invalidCalendar: 'Calendar {0} not found', + invalidDate: 'Invalid {0} date', + invalidMonth: 'Invalid {0} month', + invalidYear: 'Invalid {0} year', + differentCalendars: 'Cannot mix {0} and {1} dates' + }; + this.local = this.regionalOptions['']; + this.calendars = {}; + this._localCals = {}; +} + +/** Create the calendars plugin. +

Provides support for various world calendars in a consistent manner.

+ @class Calendars + @example _exports.instance('julian').newDate(2014, 12, 25) */ +assign(Calendars.prototype, { + + /** Obtain a calendar implementation and localisation. + @memberof Calendars + @param [name='gregorian'] {string} The name of the calendar, e.g. 'gregorian', 'persian', 'islamic'. + @param [language=''] {string} The language code to use for localisation (default is English). + @return {Calendar} The calendar and localisation. + @throws Error if calendar not found. */ + instance: function(name, language) { + name = (name || 'gregorian').toLowerCase(); + language = language || ''; + var cal = this._localCals[name + '-' + language]; + if (!cal && this.calendars[name]) { + cal = new this.calendars[name](language); + this._localCals[name + '-' + language] = cal; + } + if (!cal) { + throw (this.local.invalidCalendar || this.regionalOptions[''].invalidCalendar). + replace(/\{0\}/, name); + } + return cal; + }, + + /** Create a new date - for today if no other parameters given. + @memberof Calendars + @param year {CDate|number} The date to copy or the year for the date. + @param [month] {number} The month for the date. + @param [day] {number} The day for the date. + @param [calendar='gregorian'] {BaseCalendar|string} The underlying calendar or the name of the calendar. + @param [language=''] {string} The language to use for localisation (default English). + @return {CDate} The new date. + @throws Error if an invalid date. */ + newDate: function(year, month, day, calendar, language) { + calendar = (year != null && year.year ? year.calendar() : (typeof calendar === 'string' ? + this.instance(calendar, language) : calendar)) || this.instance(); + return calendar.newDate(year, month, day); + }, + + /** A simple digit substitution function for localising numbers via the Calendar digits option. + @member Calendars + @param digits {string[]} The substitute digits, for 0 through 9. + @return {function} The substitution function. */ + substituteDigits: function(digits) { + return function(value) { + return (value + '').replace(/[0-9]/g, function(digit) { + return digits[digit]; + }); + } + }, + + /** Digit substitution function for localising Chinese style numbers via the Calendar digits option. + @member Calendars + @param digits {string[]} The substitute digits, for 0 through 9. + @param powers {string[]} The characters denoting powers of 10, i.e. 1, 10, 100, 1000. + @return {function} The substitution function. */ + substituteChineseDigits: function(digits, powers) { + return function(value) { + var localNumber = ''; + var power = 0; + while (value > 0) { + var units = value % 10; + localNumber = (units === 0 ? '' : digits[units] + powers[power]) + localNumber; + power++; + value = Math.floor(value / 10); + } + if (localNumber.indexOf(digits[1] + powers[1]) === 0) { + localNumber = localNumber.substr(1); + } + return localNumber || digits[0]; + } + } +}); + +/** Generic date, based on a particular calendar. + @class CDate + @param calendar {BaseCalendar} The underlying calendar implementation. + @param year {number} The year for this date. + @param month {number} The month for this date. + @param day {number} The day for this date. + @return {CDate} The date object. + @throws Error if an invalid date. */ +function CDate(calendar, year, month, day) { + this._calendar = calendar; + this._year = year; + this._month = month; + this._day = day; + if (this._calendar._validateLevel === 0 && + !this._calendar.isValid(this._year, this._month, this._day)) { + throw (_exports.local.invalidDate || _exports.regionalOptions[''].invalidDate). + replace(/\{0\}/, this._calendar.local.name); + } +} + +/** Pad a numeric value with leading zeroes. + @private + @param value {number} The number to format. + @param length {number} The minimum length. + @return {string} The formatted number. */ +function pad(value, length) { + value = '' + value; + return '000000'.substring(0, length - value.length) + value; +} + +assign(CDate.prototype, { + + /** Create a new date. + @memberof CDate + @param [year] {CDate|number} The date to copy or the year for the date (default this date). + @param [month] {number} The month for the date. + @param [day] {number} The day for the date. + @return {CDate} The new date. + @throws Error if an invalid date. */ + newDate: function(year, month, day) { + return this._calendar.newDate((year == null ? this : year), month, day); + }, + + /** Set or retrieve the year for this date. + @memberof CDate + @param [year] {number} The year for the date. + @return {number|CDate} The date's year (if no parameter) or the updated date. + @throws Error if an invalid date. */ + year: function(year) { + return (arguments.length === 0 ? this._year : this.set(year, 'y')); + }, + + /** Set or retrieve the month for this date. + @memberof CDate + @param [month] {number} The month for the date. + @return {number|CDate} The date's month (if no parameter) or the updated date. + @throws Error if an invalid date. */ + month: function(month) { + return (arguments.length === 0 ? this._month : this.set(month, 'm')); + }, + + /** Set or retrieve the day for this date. + @memberof CDate + @param [day] {number} The day for the date. + @return {number|CData} The date's day (if no parameter) or the updated date. + @throws Error if an invalid date. */ + day: function(day) { + return (arguments.length === 0 ? this._day : this.set(day, 'd')); + }, + + /** Set new values for this date. + @memberof CDate + @param year {number} The year for the date. + @param month {number} The month for the date. + @param day {number} The day for the date. + @return {CDate} The updated date. + @throws Error if an invalid date. */ + date: function(year, month, day) { + if (!this._calendar.isValid(year, month, day)) { + throw (_exports.local.invalidDate || _exports.regionalOptions[''].invalidDate). + replace(/\{0\}/, this._calendar.local.name); + } + this._year = year; + this._month = month; + this._day = day; + return this; + }, + + /** Determine whether this date is in a leap year. + @memberof CDate + @return {boolean} true if this is a leap year, false if not. */ + leapYear: function() { + return this._calendar.leapYear(this); + }, + + /** Retrieve the epoch designator for this date, e.g. BCE or CE. + @memberof CDate + @return {string} The current epoch. */ + epoch: function() { + return this._calendar.epoch(this); + }, + + /** Format the year, if not a simple sequential number. + @memberof CDate + @return {string} The formatted year. */ + formatYear: function() { + return this._calendar.formatYear(this); + }, + + /** Retrieve the month of the year for this date, + i.e. the month's position within a numbered year. + @memberof CDate + @return {number} The month of the year: minMonth to months per year. */ + monthOfYear: function() { + return this._calendar.monthOfYear(this); + }, + + /** Retrieve the week of the year for this date. + @memberof CDate + @return {number} The week of the year: 1 to weeks per year. */ + weekOfYear: function() { + return this._calendar.weekOfYear(this); + }, + + /** Retrieve the number of days in the year for this date. + @memberof CDate + @return {number} The number of days in this year. */ + daysInYear: function() { + return this._calendar.daysInYear(this); + }, + + /** Retrieve the day of the year for this date. + @memberof CDate + @return {number} The day of the year: 1 to days per year. */ + dayOfYear: function() { + return this._calendar.dayOfYear(this); + }, + + /** Retrieve the number of days in the month for this date. + @memberof CDate + @return {number} The number of days. */ + daysInMonth: function() { + return this._calendar.daysInMonth(this); + }, + + /** Retrieve the day of the week for this date. + @memberof CDate + @return {number} The day of the week: 0 to number of days - 1. */ + dayOfWeek: function() { + return this._calendar.dayOfWeek(this); + }, + + /** Determine whether this date is a week day. + @memberof CDate + @return {boolean} true if a week day, false if not. */ + weekDay: function() { + return this._calendar.weekDay(this); + }, + + /** Retrieve additional information about this date. + @memberof CDate + @return {object} Additional information - contents depends on calendar. */ + extraInfo: function() { + return this._calendar.extraInfo(this); + }, + + /** Add period(s) to a date. + @memberof CDate + @param offset {number} The number of periods to adjust by. + @param period {string} One of 'y' for year, 'm' for month, 'w' for week, 'd' for day. + @return {CDate} The updated date. */ + add: function(offset, period) { + return this._calendar.add(this, offset, period); + }, + + /** Set a portion of the date. + @memberof CDate + @param value {number} The new value for the period. + @param period {string} One of 'y' for year, 'm' for month, 'd' for day. + @return {CDate} The updated date. + @throws Error if not a valid date. */ + set: function(value, period) { + return this._calendar.set(this, value, period); + }, + + /** Compare this date to another date. + @memberof CDate + @param date {CDate} The other date. + @return {number} -1 if this date is before the other date, + 0 if they are equal, or +1 if this date is after the other date. */ + compareTo: function(date) { + if (this._calendar.name !== date._calendar.name) { + throw (_exports.local.differentCalendars || _exports.regionalOptions[''].differentCalendars). + replace(/\{0\}/, this._calendar.local.name).replace(/\{1\}/, date._calendar.local.name); + } + var c = (this._year !== date._year ? this._year - date._year : + this._month !== date._month ? this.monthOfYear() - date.monthOfYear() : + this._day - date._day); + return (c === 0 ? 0 : (c < 0 ? -1 : +1)); + }, + + /** Retrieve the calendar backing this date. + @memberof CDate + @return {BaseCalendar} The calendar implementation. */ + calendar: function() { + return this._calendar; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof CDate + @return {number} The equivalent Julian date. */ + toJD: function() { + return this._calendar.toJD(this); + }, + + /** Create a new date from a Julian date. + @memberof CDate + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + return this._calendar.fromJD(jd); + }, + + /** Convert this date to a standard (Gregorian) JavaScript Date. + @memberof CDate + @return {Date} The equivalent JavaScript date. */ + toJSDate: function() { + return this._calendar.toJSDate(this); + }, + + /** Create a new date from a standard (Gregorian) JavaScript Date. + @memberof CDate + @param jsd {Date} The JavaScript date to convert. + @return {CDate} The equivalent date. */ + fromJSDate: function(jsd) { + return this._calendar.fromJSDate(jsd); + }, + + /** Convert to a string for display. + @memberof CDate + @return {string} This date as a string. */ + toString: function() { + return (this.year() < 0 ? '-' : '') + pad(Math.abs(this.year()), 4) + + '-' + pad(this.month(), 2) + '-' + pad(this.day(), 2); + } +}); + +/** Basic functionality for all calendars. + Other calendars should extend this: +
OtherCalendar.prototype = new BaseCalendar;
+ @class BaseCalendar */ +function BaseCalendar() { + this.shortYearCutoff = '+10'; +} + +assign(BaseCalendar.prototype, { + _validateLevel: 0, // "Stack" to turn validation on/off + + /** Create a new date within this calendar - today if no parameters given. + @memberof BaseCalendar + @param year {CDate|number} The date to duplicate or the year for the date. + @param [month] {number} The month for the date. + @param [day] {number} The day for the date. + @return {CDate} The new date. + @throws Error if not a valid date or a different calendar used. */ + newDate: function(year, month, day) { + if (year == null) { + return this.today(); + } + if (year.year) { + this._validate(year, month, day, + _exports.local.invalidDate || _exports.regionalOptions[''].invalidDate); + day = year.day(); + month = year.month(); + year = year.year(); + } + return new CDate(this, year, month, day); + }, + + /** Create a new date for today. + @memberof BaseCalendar + @return {CDate} Today's date. */ + today: function() { + return this.fromJSDate(new Date()); + }, + + /** Retrieve the epoch designator for this date. + @memberof BaseCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {string} The current epoch. + @throws Error if an invalid year or a different calendar used. */ + epoch: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, + _exports.local.invalidYear || _exports.regionalOptions[''].invalidYear); + return (date.year() < 0 ? this.local.epochs[0] : this.local.epochs[1]); + }, + + /** Format the year, if not a simple sequential number + @memberof BaseCalendar + @param year {CDate|number} The date to format or the year to format. + @return {string} The formatted year. + @throws Error if an invalid year or a different calendar used. */ + formatYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, + _exports.local.invalidYear || _exports.regionalOptions[''].invalidYear); + return (date.year() < 0 ? '-' : '') + pad(Math.abs(date.year()), 4) + }, + + /** Retrieve the number of months in a year. + @memberof BaseCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of months. + @throws Error if an invalid year or a different calendar used. */ + monthsInYear: function(year) { + this._validate(year, this.minMonth, this.minDay, + _exports.local.invalidYear || _exports.regionalOptions[''].invalidYear); + return 12; + }, + + /** Calculate the month's ordinal position within the year - + for those calendars that don't start at month 1! + @memberof BaseCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param month {number} The month to examine. + @return {number} The ordinal position, starting from minMonth. + @throws Error if an invalid year/month or a different calendar used. */ + monthOfYear: function(year, month) { + var date = this._validate(year, month, this.minDay, + _exports.local.invalidMonth || _exports.regionalOptions[''].invalidMonth); + return (date.month() + this.monthsInYear(date) - this.firstMonth) % + this.monthsInYear(date) + this.minMonth; + }, + + /** Calculate actual month from ordinal position, starting from minMonth. + @memberof BaseCalendar + @param year {number} The year to examine. + @param ord {number} The month's ordinal position. + @return {number} The month's number. + @throws Error if an invalid year/month. */ + fromMonthOfYear: function(year, ord) { + var m = (ord + this.firstMonth - 2 * this.minMonth) % + this.monthsInYear(year) + this.minMonth; + this._validate(year, m, this.minDay, + _exports.local.invalidMonth || _exports.regionalOptions[''].invalidMonth); + return m; + }, + + /** Retrieve the number of days in a year. + @memberof BaseCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of days. + @throws Error if an invalid year or a different calendar used. */ + daysInYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, + _exports.local.invalidYear || _exports.regionalOptions[''].invalidYear); + return (this.leapYear(date) ? 366 : 365); + }, + + /** Retrieve the day of the year for a date. + @memberof BaseCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The day of the year. + @throws Error if an invalid date or a different calendar used. */ + dayOfYear: function(year, month, day) { + var date = this._validate(year, month, day, + _exports.local.invalidDate || _exports.regionalOptions[''].invalidDate); + return date.toJD() - this.newDate(date.year(), + this.fromMonthOfYear(date.year(), this.minMonth), this.minDay).toJD() + 1; + }, + + /** Retrieve the number of days in a week. + @memberof BaseCalendar + @return {number} The number of days. */ + daysInWeek: function() { + return 7; + }, + + /** Retrieve the day of the week for a date. + @memberof BaseCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The day of the week: 0 to number of days - 1. + @throws Error if an invalid date or a different calendar used. */ + dayOfWeek: function(year, month, day) { + var date = this._validate(year, month, day, + _exports.local.invalidDate || _exports.regionalOptions[''].invalidDate); + return (Math.floor(this.toJD(date)) + 2) % this.daysInWeek(); + }, + + /** Retrieve additional information about a date. + @memberof BaseCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {object} Additional information - contents depends on calendar. + @throws Error if an invalid date or a different calendar used. */ + extraInfo: function(year, month, day) { + this._validate(year, month, day, + _exports.local.invalidDate || _exports.regionalOptions[''].invalidDate); + return {}; + }, + + /** Add period(s) to a date. + Cater for no year zero. + @memberof BaseCalendar + @param date {CDate} The starting date. + @param offset {number} The number of periods to adjust by. + @param period {string} One of 'y' for year, 'm' for month, 'w' for week, 'd' for day. + @return {CDate} The updated date. + @throws Error if a different calendar used. */ + add: function(date, offset, period) { + this._validate(date, this.minMonth, this.minDay, + _exports.local.invalidDate || _exports.regionalOptions[''].invalidDate); + return this._correctAdd(date, this._add(date, offset, period), offset, period); + }, + + /** Add period(s) to a date. + @memberof BaseCalendar + @private + @param date {CDate} The starting date. + @param offset {number} The number of periods to adjust by. + @param period {string} One of 'y' for year, 'm' for month, 'w' for week, 'd' for day. + @return {CDate} The updated date. */ + _add: function(date, offset, period) { + this._validateLevel++; + if (period === 'd' || period === 'w') { + var jd = date.toJD() + offset * (period === 'w' ? this.daysInWeek() : 1); + var d = date.calendar().fromJD(jd); + this._validateLevel--; + return [d.year(), d.month(), d.day()]; + } + try { + var y = date.year() + (period === 'y' ? offset : 0); + var m = date.monthOfYear() + (period === 'm' ? offset : 0); + var d = date.day();// + (period === 'd' ? offset : 0) + + //(period === 'w' ? offset * this.daysInWeek() : 0); + var resyncYearMonth = function(calendar) { + while (m < calendar.minMonth) { + y--; + m += calendar.monthsInYear(y); + } + var yearMonths = calendar.monthsInYear(y); + while (m > yearMonths - 1 + calendar.minMonth) { + y++; + m -= yearMonths; + yearMonths = calendar.monthsInYear(y); + } + }; + if (period === 'y') { + if (date.month() !== this.fromMonthOfYear(y, m)) { // Hebrew + m = this.newDate(y, date.month(), this.minDay).monthOfYear(); + } + m = Math.min(m, this.monthsInYear(y)); + d = Math.min(d, this.daysInMonth(y, this.fromMonthOfYear(y, m))); + } + else if (period === 'm') { + resyncYearMonth(this); + d = Math.min(d, this.daysInMonth(y, this.fromMonthOfYear(y, m))); + } + var ymd = [y, this.fromMonthOfYear(y, m), d]; + this._validateLevel--; + return ymd; + } + catch (e) { + this._validateLevel--; + throw e; + } + }, + + /** Correct a candidate date after adding period(s) to a date. + Handle no year zero if necessary. + @memberof BaseCalendar + @private + @param date {CDate} The starting date. + @param ymd {number[]} The added date. + @param offset {number} The number of periods to adjust by. + @param period {string} One of 'y' for year, 'm' for month, 'w' for week, 'd' for day. + @return {CDate} The updated date. */ + _correctAdd: function(date, ymd, offset, period) { + if (!this.hasYearZero && (period === 'y' || period === 'm')) { + if (ymd[0] === 0 || // In year zero + (date.year() > 0) !== (ymd[0] > 0)) { // Crossed year zero + var adj = {y: [1, 1, 'y'], m: [1, this.monthsInYear(-1), 'm'], + w: [this.daysInWeek(), this.daysInYear(-1), 'd'], + d: [1, this.daysInYear(-1), 'd']}[period]; + var dir = (offset < 0 ? -1 : +1); + ymd = this._add(date, offset * adj[0] + dir * adj[1], adj[2]); + } + } + return date.date(ymd[0], ymd[1], ymd[2]); + }, + + /** Set a portion of the date. + @memberof BaseCalendar + @param date {CDate} The starting date. + @param value {number} The new value for the period. + @param period {string} One of 'y' for year, 'm' for month, 'd' for day. + @return {CDate} The updated date. + @throws Error if an invalid date or a different calendar used. */ + set: function(date, value, period) { + this._validate(date, this.minMonth, this.minDay, + _exports.local.invalidDate || _exports.regionalOptions[''].invalidDate); + var y = (period === 'y' ? value : date.year()); + var m = (period === 'm' ? value : date.month()); + var d = (period === 'd' ? value : date.day()); + if (period === 'y' || period === 'm') { + d = Math.min(d, this.daysInMonth(y, m)); + } + return date.date(y, m, d); + }, + + /** Determine whether a date is valid for this calendar. + @memberof BaseCalendar + @param year {number} The year to examine. + @param month {number} The month to examine. + @param day {number} The day to examine. + @return {boolean} true if a valid date, false if not. */ + isValid: function(year, month, day) { + this._validateLevel++; + var valid = (this.hasYearZero || year !== 0); + if (valid) { + var date = this.newDate(year, month, this.minDay); + valid = (month >= this.minMonth && month - this.minMonth < this.monthsInYear(date)) && + (day >= this.minDay && day - this.minDay < this.daysInMonth(date)); + } + this._validateLevel--; + return valid; + }, + + /** Convert the date to a standard (Gregorian) JavaScript Date. + @memberof BaseCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {Date} The equivalent JavaScript date. + @throws Error if an invalid date or a different calendar used. */ + toJSDate: function(year, month, day) { + var date = this._validate(year, month, day, + _exports.local.invalidDate || _exports.regionalOptions[''].invalidDate); + return _exports.instance().fromJD(this.toJD(date)).toJSDate(); + }, + + /** Convert the date from a standard (Gregorian) JavaScript Date. + @memberof BaseCalendar + @param jsd {Date} The JavaScript date. + @return {CDate} The equivalent calendar date. */ + fromJSDate: function(jsd) { + return this.fromJD(_exports.instance().fromJSDate(jsd).toJD()); + }, + + /** Check that a candidate date is from the same calendar and is valid. + @memberof BaseCalendar + @private + @param year {CDate|number} The date to validate or the year to validate. + @param [month] {number} The month to validate. + @param [day] {number} The day to validate. + @param error {string} Rrror message if invalid. + @throws Error if different calendars used or invalid date. */ + _validate: function(year, month, day, error) { + if (year.year) { + if (this._validateLevel === 0 && this.name !== year.calendar().name) { + throw (_exports.local.differentCalendars || _exports.regionalOptions[''].differentCalendars). + replace(/\{0\}/, this.local.name).replace(/\{1\}/, year.calendar().local.name); + } + return year; + } + try { + this._validateLevel++; + if (this._validateLevel === 1 && !this.isValid(year, month, day)) { + throw error.replace(/\{0\}/, this.local.name); + } + var date = this.newDate(year, month, day); + this._validateLevel--; + return date; + } + catch (e) { + this._validateLevel--; + throw e; + } + } +}); + +/** Implementation of the Proleptic Gregorian Calendar. + See http://en.wikipedia.org/wiki/Gregorian_calendar + and http://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar. + @class GregorianCalendar + @augments BaseCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function GregorianCalendar(language) { + this.local = this.regionalOptions[language] || this.regionalOptions['']; +} + +GregorianCalendar.prototype = new BaseCalendar; + +assign(GregorianCalendar.prototype, { + /** The calendar name. + @memberof GregorianCalendar */ + name: 'Gregorian', + /** Julian date of start of Gregorian epoch: 1 January 0001 CE. + @memberof GregorianCalendar */ + jdEpoch: 1721425.5, + /** Days per month in a common year. + @memberof GregorianCalendar */ + daysPerMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], + /** true if has a year zero, false if not. + @memberof GregorianCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof GregorianCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof GregorianCalendar */ + firstMonth: 1, + /** The minimum day number. + @memberof GregorianCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof GregorianCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Gregorian', + epochs: ['BCE', 'CE'], + monthNames: ['January', 'February', 'March', 'April', 'May', 'June', + 'July', 'August', 'September', 'October', 'November', 'December'], + monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], + dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], + dayNamesMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], + digits: null, + dateFormat: 'mm/dd/yyyy', + firstDay: 0, + isRTL: false + } + }, + + /** Determine whether this date is in a leap year. + @memberof GregorianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, + _exports.local.invalidYear || _exports.regionalOptions[''].invalidYear); + var year = date.year() + (date.year() < 0 ? 1 : 0); // No year zero + return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0); + }, + + /** Determine the week of the year for a date - ISO 8601. + @memberof GregorianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year, starting from 1. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + // Find Thursday of this week starting on Monday + var checkDate = this.newDate(year, month, day); + checkDate.add(4 - (checkDate.dayOfWeek() || 7), 'd'); + return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1; + }, + + /** Retrieve the number of days in a month. + @memberof GregorianCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + var date = this._validate(year, month, this.minDay, + _exports.local.invalidMonth || _exports.regionalOptions[''].invalidMonth); + return this.daysPerMonth[date.month() - 1] + + (date.month() === 2 && this.leapYear(date.year()) ? 1 : 0); + }, + + /** Determine whether this date is a week day. + @memberof GregorianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + return (this.dayOfWeek(year, month, day) || 7) < 6; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof GregorianCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, month, day) { + var date = this._validate(year, month, day, + _exports.local.invalidDate || _exports.regionalOptions[''].invalidDate); + year = date.year(); + month = date.month(); + day = date.day(); + if (year < 0) { year++; } // No year zero + // Jean Meeus algorithm, "Astronomical Algorithms", 1991 + if (month < 3) { + month += 12; + year--; + } + var a = Math.floor(year / 100); + var b = 2 - a + Math.floor(a / 4); + return Math.floor(365.25 * (year + 4716)) + + Math.floor(30.6001 * (month + 1)) + day + b - 1524.5; + }, + + /** Create a new date from a Julian date. + @memberof GregorianCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + // Jean Meeus algorithm, "Astronomical Algorithms", 1991 + var z = Math.floor(jd + 0.5); + var a = Math.floor((z - 1867216.25) / 36524.25); + a = z + 1 + a - Math.floor(a / 4); + var b = a + 1524; + var c = Math.floor((b - 122.1) / 365.25); + var d = Math.floor(365.25 * c); + var e = Math.floor((b - d) / 30.6001); + var day = b - d - Math.floor(e * 30.6001); + var month = e - (e > 13.5 ? 13 : 1); + var year = c - (month > 2.5 ? 4716 : 4715); + if (year <= 0) { year--; } // No year zero + return this.newDate(year, month, day); + }, + + /** Convert this date to a standard (Gregorian) JavaScript Date. + @memberof GregorianCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {Date} The equivalent JavaScript date. + @throws Error if an invalid date or a different calendar used. */ + toJSDate: function(year, month, day) { + var date = this._validate(year, month, day, + _exports.local.invalidDate || _exports.regionalOptions[''].invalidDate); + var jsd = new Date(date.year(), date.month() - 1, date.day()); + jsd.setHours(0); + jsd.setMinutes(0); + jsd.setSeconds(0); + jsd.setMilliseconds(0); + // Hours may be non-zero on daylight saving cut-over: + // > 12 when midnight changeover, but then cannot generate + // midnight datetime, so jump to 1AM, otherwise reset. + jsd.setHours(jsd.getHours() > 12 ? jsd.getHours() + 2 : 0); + return jsd; + }, + + /** Create a new date from a standard (Gregorian) JavaScript Date. + @memberof GregorianCalendar + @param jsd {Date} The JavaScript date to convert. + @return {CDate} The equivalent date. */ + fromJSDate: function(jsd) { + return this.newDate(jsd.getFullYear(), jsd.getMonth() + 1, jsd.getDate()); + } +}); + +// Singleton manager +var _exports = module.exports = new Calendars(); + +// Date template +_exports.cdate = CDate; + +// Base calendar template +_exports.baseCalendar = BaseCalendar; + +// Gregorian calendar implementation +_exports.calendars.gregorian = GregorianCalendar; + + +},{"object-assign":71}],136:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Calendars extras for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) August 2009. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var assign = _dereq_('object-assign'); +var main = _dereq_('./main'); + + +assign(main.regionalOptions[''], { + invalidArguments: 'Invalid arguments', + invalidFormat: 'Cannot format a date from another calendar', + missingNumberAt: 'Missing number at position {0}', + unknownNameAt: 'Unknown name at position {0}', + unexpectedLiteralAt: 'Unexpected literal at position {0}', + unexpectedText: 'Additional text found at end' +}); +main.local = main.regionalOptions['']; + +assign(main.cdate.prototype, { + + /** Format this date. + Found in the jquery.calendars.plus.js module. + @memberof CDate + @param [format] {string} The date format to use (see formatDate). + @param [settings] {object} Options for the formatDate function. + @return {string} The formatted date. */ + formatDate: function(format, settings) { + if (typeof format !== 'string') { + settings = format; + format = ''; + } + return this._calendar.formatDate(format || '', this, settings); + } +}); + +assign(main.baseCalendar.prototype, { + + UNIX_EPOCH: main.instance().newDate(1970, 1, 1).toJD(), + SECS_PER_DAY: 24 * 60 * 60, + TICKS_EPOCH: main.instance().jdEpoch, // 1 January 0001 CE + TICKS_PER_DAY: 24 * 60 * 60 * 10000000, + + /** Date form for ATOM (RFC 3339/ISO 8601). + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + ATOM: 'yyyy-mm-dd', + /** Date form for cookies. + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + COOKIE: 'D, dd M yyyy', + /** Date form for full date. + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + FULL: 'DD, MM d, yyyy', + /** Date form for ISO 8601. + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + ISO_8601: 'yyyy-mm-dd', + /** Date form for Julian date. + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + JULIAN: 'J', + /** Date form for RFC 822. + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + RFC_822: 'D, d M yy', + /** Date form for RFC 850. + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + RFC_850: 'DD, dd-M-yy', + /** Date form for RFC 1036. + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + RFC_1036: 'D, d M yy', + /** Date form for RFC 1123. + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + RFC_1123: 'D, d M yyyy', + /** Date form for RFC 2822. + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + RFC_2822: 'D, d M yyyy', + /** Date form for RSS (RFC 822). + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + RSS: 'D, d M yy', + /** Date form for Windows ticks. + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + TICKS: '!', + /** Date form for Unix timestamp. + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + TIMESTAMP: '@', + /** Date form for W3c (ISO 8601). + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + W3C: 'yyyy-mm-dd', + + /** Format a date object into a string value. + The format can be combinations of the following: +
    +
  • d - day of month (no leading zero)
  • +
  • dd - day of month (two digit)
  • +
  • o - day of year (no leading zeros)
  • +
  • oo - day of year (three digit)
  • +
  • D - day name short
  • +
  • DD - day name long
  • +
  • w - week of year (no leading zero)
  • +
  • ww - week of year (two digit)
  • +
  • m - month of year (no leading zero)
  • +
  • mm - month of year (two digit)
  • +
  • M - month name short
  • +
  • MM - month name long
  • +
  • yy - year (two digit)
  • +
  • yyyy - year (four digit)
  • +
  • YYYY - formatted year
  • +
  • J - Julian date (days since January 1, 4713 BCE Greenwich noon)
  • +
  • @ - Unix timestamp (s since 01/01/1970)
  • +
  • ! - Windows ticks (100ns since 01/01/0001)
  • +
  • '...' - literal text
  • +
  • '' - single quote
  • +
+ Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar + @param [format] {string} The desired format of the date (defaults to calendar format). + @param date {CDate} The date value to format. + @param [settings] {object} Addition options, whose attributes include: + @property [dayNamesShort] {string[]} Abbreviated names of the days from Sunday. + @property [dayNames] {string[]} Names of the days from Sunday. + @property [monthNamesShort] {string[]} Abbreviated names of the months. + @property [monthNames] {string[]} Names of the months. + @property [calculateWeek] {CalendarsPickerCalculateWeek} Function that determines week of the year. + @property [localNumbers=false] {boolean} true to localise numbers (if available), + false to use normal Arabic numerals. + @return {string} The date in the above format. + @throws Errors if the date is from a different calendar. */ + formatDate: function(format, date, settings) { + if (typeof format !== 'string') { + settings = date; + date = format; + format = ''; + } + if (!date) { + return ''; + } + if (date.calendar() !== this) { + throw main.local.invalidFormat || main.regionalOptions[''].invalidFormat; + } + format = format || this.local.dateFormat; + settings = settings || {}; + var dayNamesShort = settings.dayNamesShort || this.local.dayNamesShort; + var dayNames = settings.dayNames || this.local.dayNames; + var monthNumbers = settings.monthNumbers || this.local.monthNumbers; + var monthNamesShort = settings.monthNamesShort || this.local.monthNamesShort; + var monthNames = settings.monthNames || this.local.monthNames; + var calculateWeek = settings.calculateWeek || this.local.calculateWeek; + // Check whether a format character is doubled + var doubled = function(match, step) { + var matches = 1; + while (iFormat + matches < format.length && format.charAt(iFormat + matches) === match) { + matches++; + } + iFormat += matches - 1; + return Math.floor(matches / (step || 1)) > 1; + }; + // Format a number, with leading zeroes if necessary + var formatNumber = function(match, value, len, step) { + var num = '' + value; + if (doubled(match, step)) { + while (num.length < len) { + num = '0' + num; + } + } + return num; + }; + // Format a name, short or long as requested + var formatName = function(match, value, shortNames, longNames) { + return (doubled(match) ? longNames[value] : shortNames[value]); + }; + // Format month number + // (e.g. Chinese calendar needs to account for intercalary months) + var calendar = this; + var formatMonth = function(date) { + return (typeof monthNumbers === 'function') ? + monthNumbers.call(calendar, date, doubled('m')) : + localiseNumbers(formatNumber('m', date.month(), 2)); + }; + // Format a month name, short or long as requested + var formatMonthName = function(date, useLongName) { + if (useLongName) { + return (typeof monthNames === 'function') ? + monthNames.call(calendar, date) : + monthNames[date.month() - calendar.minMonth]; + } else { + return (typeof monthNamesShort === 'function') ? + monthNamesShort.call(calendar, date) : + monthNamesShort[date.month() - calendar.minMonth]; + } + }; + // Localise numbers if requested and available + var digits = this.local.digits; + var localiseNumbers = function(value) { + return (settings.localNumbers && digits ? digits(value) : value); + }; + var output = ''; + var literal = false; + for (var iFormat = 0; iFormat < format.length; iFormat++) { + if (literal) { + if (format.charAt(iFormat) === "'" && !doubled("'")) { + literal = false; + } + else { + output += format.charAt(iFormat); + } + } + else { + switch (format.charAt(iFormat)) { + case 'd': output += localiseNumbers(formatNumber('d', date.day(), 2)); break; + case 'D': output += formatName('D', date.dayOfWeek(), + dayNamesShort, dayNames); break; + case 'o': output += formatNumber('o', date.dayOfYear(), 3); break; + case 'w': output += formatNumber('w', date.weekOfYear(), 2); break; + case 'm': output += formatMonth(date); break; + case 'M': output += formatMonthName(date, doubled('M')); break; + case 'y': + output += (doubled('y', 2) ? date.year() : + (date.year() % 100 < 10 ? '0' : '') + date.year() % 100); + break; + case 'Y': + doubled('Y', 2); + output += date.formatYear(); + break; + case 'J': output += date.toJD(); break; + case '@': output += (date.toJD() - this.UNIX_EPOCH) * this.SECS_PER_DAY; break; + case '!': output += (date.toJD() - this.TICKS_EPOCH) * this.TICKS_PER_DAY; break; + case "'": + if (doubled("'")) { + output += "'"; + } + else { + literal = true; + } + break; + default: + output += format.charAt(iFormat); + } + } + } + return output; + }, + + /** Parse a string value into a date object. + See formatDate for the possible formats, plus: +
    +
  • * - ignore rest of string
  • +
+ Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar + @param format {string} The expected format of the date ('' for default calendar format). + @param value {string} The date in the above format. + @param [settings] {object} Additional options whose attributes include: + @property [shortYearCutoff] {number} The cutoff year for determining the century. + @property [dayNamesShort] {string[]} Abbreviated names of the days from Sunday. + @property [dayNames] {string[]} Names of the days from Sunday. + @property [monthNamesShort] {string[]} Abbreviated names of the months. + @property [monthNames] {string[]} Names of the months. + @return {CDate} The extracted date value or null if value is blank. + @throws Errors if the format and/or value are missing, + if the value doesn't match the format, or if the date is invalid. */ + parseDate: function(format, value, settings) { + if (value == null) { + throw main.local.invalidArguments || main.regionalOptions[''].invalidArguments; + } + value = (typeof value === 'object' ? value.toString() : value + ''); + if (value === '') { + return null; + } + format = format || this.local.dateFormat; + settings = settings || {}; + var shortYearCutoff = settings.shortYearCutoff || this.shortYearCutoff; + shortYearCutoff = (typeof shortYearCutoff !== 'string' ? shortYearCutoff : + this.today().year() % 100 + parseInt(shortYearCutoff, 10)); + var dayNamesShort = settings.dayNamesShort || this.local.dayNamesShort; + var dayNames = settings.dayNames || this.local.dayNames; + var parseMonth = settings.parseMonth || this.local.parseMonth; + var monthNumbers = settings.monthNumbers || this.local.monthNumbers; + var monthNamesShort = settings.monthNamesShort || this.local.monthNamesShort; + var monthNames = settings.monthNames || this.local.monthNames; + var jd = -1; + var year = -1; + var month = -1; + var day = -1; + var doy = -1; + var shortYear = false; + var literal = false; + // Check whether a format character is doubled + var doubled = function(match, step) { + var matches = 1; + while (iFormat + matches < format.length && format.charAt(iFormat + matches) === match) { + matches++; + } + iFormat += matches - 1; + return Math.floor(matches / (step || 1)) > 1; + }; + // Extract a number from the string value + var getNumber = function(match, step) { + var isDoubled = doubled(match, step); + var size = [2, 3, isDoubled ? 4 : 2, isDoubled ? 4 : 2, 10, 11, 20]['oyYJ@!'.indexOf(match) + 1]; + var digits = new RegExp('^-?\\d{1,' + size + '}'); + var num = value.substring(iValue).match(digits); + if (!num) { + throw (main.local.missingNumberAt || main.regionalOptions[''].missingNumberAt). + replace(/\{0\}/, iValue); + } + iValue += num[0].length; + return parseInt(num[0], 10); + }; + // Extract a month number from the string value + var calendar = this; + var getMonthNumber = function() { + if (typeof monthNumbers === 'function') { + doubled('m'); // update iFormat + var month = monthNumbers.call(calendar, value.substring(iValue)); + iValue += month.length; + return month; + } + + return getNumber('m'); + }; + // Extract a name from the string value and convert to an index + var getName = function(match, shortNames, longNames, step) { + var names = (doubled(match, step) ? longNames : shortNames); + for (var i = 0; i < names.length; i++) { + if (value.substr(iValue, names[i].length).toLowerCase() === names[i].toLowerCase()) { + iValue += names[i].length; + return i + calendar.minMonth; + } + } + throw (main.local.unknownNameAt || main.regionalOptions[''].unknownNameAt). + replace(/\{0\}/, iValue); + }; + // Extract a month number from the string value + var getMonthName = function() { + if (typeof monthNames === 'function') { + var month = doubled('M') ? + monthNames.call(calendar, value.substring(iValue)) : + monthNamesShort.call(calendar, value.substring(iValue)); + iValue += month.length; + return month; + } + + return getName('M', monthNamesShort, monthNames); + }; + // Confirm that a literal character matches the string value + var checkLiteral = function() { + if (value.charAt(iValue) !== format.charAt(iFormat)) { + throw (main.local.unexpectedLiteralAt || + main.regionalOptions[''].unexpectedLiteralAt).replace(/\{0\}/, iValue); + } + iValue++; + }; + var iValue = 0; + for (var iFormat = 0; iFormat < format.length; iFormat++) { + if (literal) { + if (format.charAt(iFormat) === "'" && !doubled("'")) { + literal = false; + } + else { + checkLiteral(); + } + } + else { + switch (format.charAt(iFormat)) { + case 'd': day = getNumber('d'); break; + case 'D': getName('D', dayNamesShort, dayNames); break; + case 'o': doy = getNumber('o'); break; + case 'w': getNumber('w'); break; + case 'm': month = getMonthNumber(); break; + case 'M': month = getMonthName(); break; + case 'y': + var iSave = iFormat; + shortYear = !doubled('y', 2); + iFormat = iSave; + year = getNumber('y', 2); + break; + case 'Y': year = getNumber('Y', 2); break; + case 'J': + jd = getNumber('J') + 0.5; + if (value.charAt(iValue) === '.') { + iValue++; + getNumber('J'); + } + break; + case '@': jd = getNumber('@') / this.SECS_PER_DAY + this.UNIX_EPOCH; break; + case '!': jd = getNumber('!') / this.TICKS_PER_DAY + this.TICKS_EPOCH; break; + case '*': iValue = value.length; break; + case "'": + if (doubled("'")) { + checkLiteral(); + } + else { + literal = true; + } + break; + default: checkLiteral(); + } + } + } + if (iValue < value.length) { + throw main.local.unexpectedText || main.regionalOptions[''].unexpectedText; + } + if (year === -1) { + year = this.today().year(); + } + else if (year < 100 && shortYear) { + year += (shortYearCutoff === -1 ? 1900 : this.today().year() - + this.today().year() % 100 - (year <= shortYearCutoff ? 0 : 100)); + } + if (typeof month === 'string') { + month = parseMonth.call(this, year, month); + } + if (doy > -1) { + month = 1; + day = doy; + for (var dim = this.daysInMonth(year, month); day > dim; dim = this.daysInMonth(year, month)) { + month++; + day -= dim; + } + } + return (jd > -1 ? this.fromJD(jd) : this.newDate(year, month, day)); + }, + + /** A date may be specified as an exact value or a relative one. + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar + @param dateSpec {CDate|number|string} The date as an object or string in the given format or + an offset - numeric days from today, or string amounts and periods, e.g. '+1m +2w'. + @param defaultDate {CDate} The date to use if no other supplied, may be null. + @param currentDate {CDate} The current date as a possible basis for relative dates, + if null today is used (optional) + @param [dateFormat] {string} The expected date format - see formatDate. + @param [settings] {object} Additional options whose attributes include: + @property [shortYearCutoff] {number} The cutoff year for determining the century. + @property [dayNamesShort] {string[]} Abbreviated names of the days from Sunday. + @property [dayNames] {string[]} Names of the days from Sunday. + @property [monthNamesShort] {string[]} Abbreviated names of the months. + @property [monthNames] {string[]} Names of the months. + @return {CDate} The decoded date. */ + determineDate: function(dateSpec, defaultDate, currentDate, dateFormat, settings) { + if (currentDate && typeof currentDate !== 'object') { + settings = dateFormat; + dateFormat = currentDate; + currentDate = null; + } + if (typeof dateFormat !== 'string') { + settings = dateFormat; + dateFormat = ''; + } + var calendar = this; + var offsetString = function(offset) { + try { + return calendar.parseDate(dateFormat, offset, settings); + } + catch (e) { + // Ignore + } + offset = offset.toLowerCase(); + var date = (offset.match(/^c/) && currentDate ? + currentDate.newDate() : null) || calendar.today(); + var pattern = /([+-]?[0-9]+)\s*(d|w|m|y)?/g; + var matches = pattern.exec(offset); + while (matches) { + date.add(parseInt(matches[1], 10), matches[2] || 'd'); + matches = pattern.exec(offset); + } + return date; + }; + defaultDate = (defaultDate ? defaultDate.newDate() : null); + dateSpec = (dateSpec == null ? defaultDate : + (typeof dateSpec === 'string' ? offsetString(dateSpec) : (typeof dateSpec === 'number' ? + (isNaN(dateSpec) || dateSpec === Infinity || dateSpec === -Infinity ? defaultDate : + calendar.today().add(dateSpec, 'd')) : calendar.newDate(dateSpec)))); + return dateSpec; + } +}); + + +},{"./main":135,"object-assign":71}],137:[function(_dereq_,module,exports){ 'use strict'; /** @@ -20612,15 +30666,7 @@ module.exports = [ } ]; -},{}],90:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],138:[function(_dereq_,module,exports){ 'use strict'; var ARROWPATHS = _dereq_('./arrow_paths'); @@ -20659,192 +30705,143 @@ function arrowCoordinateDescription(axis, lower, upper) { module.exports = templatedArray('annotation', { visible: { valType: 'boolean', - dflt: true, editType: 'calc+arraydraw', - }, text: { valType: 'string', - editType: 'calc+arraydraw', - }, textangle: { valType: 'angle', dflt: 0, - editType: 'calc+arraydraw', - }, font: fontAttrs({ editType: 'calc+arraydraw', colorEditType: 'arraydraw', - }), width: { valType: 'number', min: 1, dflt: null, - editType: 'calc+arraydraw', - }, height: { valType: 'number', min: 1, dflt: null, - editType: 'calc+arraydraw', - }, opacity: { valType: 'number', min: 0, max: 1, dflt: 1, - editType: 'arraydraw', - }, align: { valType: 'enumerated', values: ['left', 'center', 'right'], dflt: 'center', - editType: 'arraydraw', - }, valign: { valType: 'enumerated', values: ['top', 'middle', 'bottom'], dflt: 'middle', - editType: 'arraydraw', - }, bgcolor: { valType: 'color', dflt: 'rgba(0,0,0,0)', - editType: 'arraydraw', - }, bordercolor: { valType: 'color', dflt: 'rgba(0,0,0,0)', - editType: 'arraydraw', - }, borderpad: { valType: 'number', min: 0, dflt: 1, - editType: 'calc+arraydraw', - }, borderwidth: { valType: 'number', min: 0, dflt: 1, - editType: 'calc+arraydraw', - }, // arrow showarrow: { valType: 'boolean', dflt: true, - editType: 'calc+arraydraw', - }, arrowcolor: { valType: 'color', - editType: 'arraydraw', - }, arrowhead: { valType: 'integer', min: 0, max: ARROWPATHS.length, dflt: 1, - editType: 'arraydraw', - }, startarrowhead: { valType: 'integer', min: 0, max: ARROWPATHS.length, dflt: 1, - editType: 'arraydraw', - }, arrowside: { valType: 'flaglist', flags: ['end', 'start'], extras: ['none'], dflt: 'end', - editType: 'arraydraw', - }, arrowsize: { valType: 'number', min: 0.3, dflt: 1, - editType: 'calc+arraydraw', - }, startarrowsize: { valType: 'number', min: 0.3, dflt: 1, - editType: 'calc+arraydraw', - }, arrowwidth: { valType: 'number', min: 0.1, - editType: 'calc+arraydraw', - }, standoff: { valType: 'number', min: 0, dflt: 0, - editType: 'calc+arraydraw', - }, startstandoff: { valType: 'number', min: 0, dflt: 0, - editType: 'calc+arraydraw', - }, ax: { valType: 'any', - editType: 'calc+arraydraw', - }, ay: { valType: 'any', - editType: 'calc+arraydraw', - }, axref: { valType: 'enumerated', @@ -20853,9 +30850,7 @@ module.exports = templatedArray('annotation', { 'pixel', cartesianConstants.idRegex.x.toString() ], - editType: 'calc', - }, ayref: { valType: 'enumerated', @@ -20864,9 +30859,7 @@ module.exports = templatedArray('annotation', { 'pixel', cartesianConstants.idRegex.y.toString() ], - editType: 'calc', - }, // positioning xref: { @@ -20875,30 +30868,22 @@ module.exports = templatedArray('annotation', { 'paper', cartesianConstants.idRegex.x.toString() ], - editType: 'calc', - }, x: { valType: 'any', - editType: 'calc+arraydraw', - }, xanchor: { valType: 'enumerated', values: ['auto', 'left', 'center', 'right'], dflt: 'auto', - editType: 'calc+arraydraw', - }, xshift: { valType: 'number', dflt: 0, - editType: 'calc+arraydraw', - }, yref: { valType: 'enumerated', @@ -20906,104 +30891,70 @@ module.exports = templatedArray('annotation', { 'paper', cartesianConstants.idRegex.y.toString() ], - editType: 'calc', - }, y: { valType: 'any', - editType: 'calc+arraydraw', - }, yanchor: { valType: 'enumerated', values: ['auto', 'top', 'middle', 'bottom'], dflt: 'auto', - editType: 'calc+arraydraw', - }, yshift: { valType: 'number', dflt: 0, - editType: 'calc+arraydraw', - }, clicktoshow: { valType: 'enumerated', values: [false, 'onoff', 'onout'], dflt: false, - editType: 'arraydraw', - }, xclick: { valType: 'any', - editType: 'arraydraw', - }, yclick: { valType: 'any', - editType: 'arraydraw', - }, hovertext: { valType: 'string', - editType: 'arraydraw', - }, hoverlabel: { bgcolor: { valType: 'color', - editType: 'arraydraw', - }, bordercolor: { valType: 'color', - editType: 'arraydraw', - }, font: fontAttrs({ editType: 'arraydraw', - }), editType: 'arraydraw' }, captureevents: { valType: 'boolean', - editType: 'arraydraw', - }, editType: 'calc', _deprecated: { ref: { valType: 'string', - editType: 'calc', - } } }); -},{"../../constants/axis_placeable_objects":208,"../../plot_api/plot_template":268,"../../plots/cartesian/constants":285,"../../plots/font_attributes":307,"./arrow_paths":89}],91:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../constants/axis_placeable_objects":261,"../../plot_api/plot_template":320,"../../plots/cartesian/constants":337,"../../plots/font_attributes":359,"./arrow_paths":137}],139:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -21085,15 +31036,7 @@ function calcAxisExpansion(ann, ax) { ann._extremes[axId] = extremes; } -},{"../../lib":233,"../../plots/cartesian/axes":279,"./draw":96}],92:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/cartesian/axes":331,"./draw":144}],140:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -21218,20 +31161,12 @@ function getToggleSets(gd, hoverData) { return {on: onSet, off: offSet, explicitOff: explicitOffSet}; } -// to handle log axes until v2 +// to handle log axes until v3 function clickData2r(d, ax) { return ax.type === 'log' ? ax.l2r(d) : ax.d2r(d); } -},{"../../lib":233,"../../plot_api/plot_template":268,"../../registry":326}],93:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plot_api/plot_template":320,"../../registry":373}],141:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -21302,16 +31237,7 @@ module.exports = function handleAnnotationCommonDefaults(annIn, annOut, fullLayo coerce('captureevents', !!hoverText); }; -},{"../../lib":233,"../color":105}],94:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../color":155}],142:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -21321,7 +31247,7 @@ var toLogRange = _dereq_('../../lib/to_log_range'); * convertCoords: when converting an axis between log and linear * you need to alter any annotations on that axis to keep them * pointing at the same data point. - * In v2.0 this will become obsolete + * In v3.0 this will become obsolete * * gd: the plot div * ax: the axis being changed @@ -21365,16 +31291,7 @@ module.exports = function convertCoords(gd, ax, newType, doExtra) { } }; -},{"../../lib/to_log_range":257,"fast-isnumeric":23}],95:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib/to_log_range":309,"fast-isnumeric":31}],143:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -21473,18 +31390,10 @@ function handleAnnotationDefaults(annIn, annOut, fullLayout) { } } -},{"../../lib":233,"../../plots/array_container_defaults":274,"../../plots/cartesian/axes":279,"./attributes":90,"./common_defaults":93}],96:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/array_container_defaults":326,"../../plots/cartesian/axes":331,"./attributes":138,"./common_defaults":141}],144:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Registry = _dereq_('../../registry'); var Plots = _dereq_('../../plots/plots'); @@ -22234,19 +32143,10 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { } else annText.call(textLayout); } -},{"../../lib":233,"../../lib/setcursor":253,"../../lib/svg_text_utils":255,"../../plot_api/plot_template":268,"../../plots/cartesian/axes":279,"../../plots/plots":313,"../../registry":326,"../color":105,"../dragelement":124,"../drawing":127,"../fx":145,"./draw_arrow_head":97,"d3":21}],97:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../lib/setcursor":305,"../../lib/svg_text_utils":307,"../../plot_api/plot_template":320,"../../plots/cartesian/axes":331,"../../plots/plots":366,"../../registry":373,"../color":155,"../dragelement":174,"../drawing":177,"../fx":195,"./draw_arrow_head":145,"@plotly/d3":20}],145:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Color = _dereq_('../color'); @@ -22390,16 +32290,7 @@ module.exports = function drawArrowHead(el3, ends, options) { if(doEnd) drawhead(headStyle, end, endRot, scale); }; -},{"../../lib":233,"../color":105,"./arrow_paths":89,"d3":21}],98:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../color":155,"./arrow_paths":137,"@plotly/d3":20}],146:[function(_dereq_,module,exports){ 'use strict'; var drawModule = _dereq_('./draw'); @@ -22424,16 +32315,7 @@ module.exports = { convertCoords: _dereq_('./convert_coords') }; -},{"../../plots/cartesian/include_components":291,"./attributes":90,"./calc_autorange":91,"./click":92,"./convert_coords":94,"./defaults":95,"./draw":96}],99:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../plots/cartesian/include_components":343,"./attributes":138,"./calc_autorange":139,"./click":140,"./convert_coords":142,"./defaults":143,"./draw":144}],147:[function(_dereq_,module,exports){ 'use strict'; var annAttrs = _dereq_('../annotations/attributes'); @@ -22444,28 +32326,18 @@ module.exports = overrideAll(templatedArray('annotation', { visible: annAttrs.visible, x: { valType: 'any', - - }, y: { valType: 'any', - - }, z: { valType: 'any', - - }, ax: { valType: 'number', - - }, ay: { valType: 'number', - - }, xanchor: annAttrs.xanchor, @@ -22512,15 +32384,7 @@ module.exports = overrideAll(templatedArray('annotation', { // zref: 'z' }), 'calc', 'from-root'); -},{"../../plot_api/edit_types":261,"../../plot_api/plot_template":268,"../annotations/attributes":90}],100:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plot_api/edit_types":313,"../../plot_api/plot_template":320,"../annotations/attributes":138}],148:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -22577,15 +32441,7 @@ function mockAnnAxes(ann, scene) { }; } -},{"../../lib":233,"../../plots/cartesian/axes":279}],101:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/cartesian/axes":331}],149:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -22653,15 +32509,7 @@ function handleAnnotationDefaults(annIn, annOut, sceneLayout, opts) { } } -},{"../../lib":233,"../../plots/array_container_defaults":274,"../../plots/cartesian/axes":279,"../annotations/common_defaults":93,"./attributes":99}],102:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/array_container_defaults":326,"../../plots/cartesian/axes":331,"../annotations/common_defaults":141,"./attributes":147}],150:[function(_dereq_,module,exports){ 'use strict'; var drawRaw = _dereq_('../annotations/draw').drawRaw; @@ -22705,15 +32553,7 @@ module.exports = function draw(scene) { } }; -},{"../../plots/gl3d/project":310,"../annotations/draw":96}],103:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/gl3d/project":362,"../annotations/draw":144}],151:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -22753,15 +32593,298 @@ function includeGL3D(layoutIn, layoutOut) { } } -},{"../../lib":233,"../../registry":326,"./attributes":99,"./convert":100,"./defaults":101,"./draw":102}],104:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +},{"../../lib":285,"../../registry":373,"./attributes":147,"./convert":148,"./defaults":149,"./draw":150}],152:[function(_dereq_,module,exports){ +'use strict'; +// a trimmed down version of: +// https://github.com/alexcjohnson/world-calendars/blob/master/dist/index.js + +module.exports = _dereq_('world-calendars/dist/main'); + +_dereq_('world-calendars/dist/plus'); + +_dereq_('world-calendars/dist/calendars/chinese'); +_dereq_('world-calendars/dist/calendars/coptic'); +_dereq_('world-calendars/dist/calendars/discworld'); +_dereq_('world-calendars/dist/calendars/ethiopian'); +_dereq_('world-calendars/dist/calendars/hebrew'); +_dereq_('world-calendars/dist/calendars/islamic'); +_dereq_('world-calendars/dist/calendars/julian'); +_dereq_('world-calendars/dist/calendars/mayan'); +_dereq_('world-calendars/dist/calendars/nanakshahi'); +_dereq_('world-calendars/dist/calendars/nepali'); +_dereq_('world-calendars/dist/calendars/persian'); +_dereq_('world-calendars/dist/calendars/taiwan'); +_dereq_('world-calendars/dist/calendars/thai'); +_dereq_('world-calendars/dist/calendars/ummalqura'); + +},{"world-calendars/dist/calendars/chinese":121,"world-calendars/dist/calendars/coptic":122,"world-calendars/dist/calendars/discworld":123,"world-calendars/dist/calendars/ethiopian":124,"world-calendars/dist/calendars/hebrew":125,"world-calendars/dist/calendars/islamic":126,"world-calendars/dist/calendars/julian":127,"world-calendars/dist/calendars/mayan":128,"world-calendars/dist/calendars/nanakshahi":129,"world-calendars/dist/calendars/nepali":130,"world-calendars/dist/calendars/persian":131,"world-calendars/dist/calendars/taiwan":132,"world-calendars/dist/calendars/thai":133,"world-calendars/dist/calendars/ummalqura":134,"world-calendars/dist/main":135,"world-calendars/dist/plus":136}],153:[function(_dereq_,module,exports){ +'use strict'; + +var calendars = _dereq_('./calendars'); + +var Lib = _dereq_('../../lib'); +var constants = _dereq_('../../constants/numerical'); + +var EPOCHJD = constants.EPOCHJD; +var ONEDAY = constants.ONEDAY; + +var attributes = { + valType: 'enumerated', + values: Object.keys(calendars.calendars), + editType: 'calc', + dflt: 'gregorian' +}; + +var handleDefaults = function(contIn, contOut, attr, dflt) { + var attrs = {}; + attrs[attr] = attributes; + + return Lib.coerce(contIn, contOut, attrs, attr, dflt); +}; + +var handleTraceDefaults = function(traceIn, traceOut, coords, layout) { + for(var i = 0; i < coords.length; i++) { + handleDefaults(traceIn, traceOut, coords[i] + 'calendar', layout.calendar); + } +}; + +// each calendar needs its own default canonical tick. I would love to use +// 2000-01-01 (or even 0000-01-01) for them all but they don't necessarily +// all support either of those dates. Instead I'll use the most significant +// number they *do* support, biased toward the present day. +var CANONICAL_TICK = { + chinese: '2000-01-01', + coptic: '2000-01-01', + discworld: '2000-01-01', + ethiopian: '2000-01-01', + hebrew: '5000-01-01', + islamic: '1000-01-01', + julian: '2000-01-01', + mayan: '5000-01-01', + nanakshahi: '1000-01-01', + nepali: '2000-01-01', + persian: '1000-01-01', + jalali: '1000-01-01', + taiwan: '1000-01-01', + thai: '2000-01-01', + ummalqura: '1400-01-01' +}; + +// Start on a Sunday - for week ticks +// Discworld and Mayan calendars don't have 7-day weeks but we're going to give them +// 7-day week ticks so start on our Sundays. +// If anyone really cares we can customize the auto tick spacings for these calendars. +var CANONICAL_SUNDAY = { + chinese: '2000-01-02', + coptic: '2000-01-03', + discworld: '2000-01-03', + ethiopian: '2000-01-05', + hebrew: '5000-01-01', + islamic: '1000-01-02', + julian: '2000-01-03', + mayan: '5000-01-01', + nanakshahi: '1000-01-05', + nepali: '2000-01-05', + persian: '1000-01-01', + jalali: '1000-01-01', + taiwan: '1000-01-04', + thai: '2000-01-04', + ummalqura: '1400-01-06' +}; + +var DFLTRANGE = { + chinese: ['2000-01-01', '2001-01-01'], + coptic: ['1700-01-01', '1701-01-01'], + discworld: ['1800-01-01', '1801-01-01'], + ethiopian: ['2000-01-01', '2001-01-01'], + hebrew: ['5700-01-01', '5701-01-01'], + islamic: ['1400-01-01', '1401-01-01'], + julian: ['2000-01-01', '2001-01-01'], + mayan: ['5200-01-01', '5201-01-01'], + nanakshahi: ['0500-01-01', '0501-01-01'], + nepali: ['2000-01-01', '2001-01-01'], + persian: ['1400-01-01', '1401-01-01'], + jalali: ['1400-01-01', '1401-01-01'], + taiwan: ['0100-01-01', '0101-01-01'], + thai: ['2500-01-01', '2501-01-01'], + ummalqura: ['1400-01-01', '1401-01-01'] +}; + +/* + * convert d3 templates to world-calendars templates, so our users only need + * to know d3's specifiers. Map space padding to no padding, and unknown fields + * to an ugly placeholder + */ +var UNKNOWN = '##'; +var d3ToWorldCalendars = { + 'd': {'0': 'dd', '-': 'd'}, // 2-digit or unpadded day of month + 'e': {'0': 'd', '-': 'd'}, // alternate, always unpadded day of month + 'a': {'0': 'D', '-': 'D'}, // short weekday name + 'A': {'0': 'DD', '-': 'DD'}, // full weekday name + 'j': {'0': 'oo', '-': 'o'}, // 3-digit or unpadded day of the year + 'W': {'0': 'ww', '-': 'w'}, // 2-digit or unpadded week of the year (Monday first) + 'm': {'0': 'mm', '-': 'm'}, // 2-digit or unpadded month number + 'b': {'0': 'M', '-': 'M'}, // short month name + 'B': {'0': 'MM', '-': 'MM'}, // full month name + 'y': {'0': 'yy', '-': 'yy'}, // 2-digit year (map unpadded to zero-padded) + 'Y': {'0': 'yyyy', '-': 'yyyy'}, // 4-digit year (map unpadded to zero-padded) + 'U': UNKNOWN, // Sunday-first week of the year + 'w': UNKNOWN, // day of the week [0(sunday),6] + // combined format, we replace the date part with the world-calendar version + // and the %X stays there for d3 to handle with time parts + 'c': {'0': 'D M d %X yyyy', '-': 'D M d %X yyyy'}, + 'x': {'0': 'mm/dd/yyyy', '-': 'mm/dd/yyyy'} +}; + +function worldCalFmt(fmt, x, calendar) { + var dateJD = Math.floor((x + 0.05) / ONEDAY) + EPOCHJD; + var cDate = getCal(calendar).fromJD(dateJD); + var i = 0; + var modifier, directive, directiveLen, directiveObj, replacementPart; + + while((i = fmt.indexOf('%', i)) !== -1) { + modifier = fmt.charAt(i + 1); + if(modifier === '0' || modifier === '-' || modifier === '_') { + directiveLen = 3; + directive = fmt.charAt(i + 2); + if(modifier === '_') modifier = '-'; + } else { + directive = modifier; + modifier = '0'; + directiveLen = 2; + } + directiveObj = d3ToWorldCalendars[directive]; + if(!directiveObj) { + i += directiveLen; + } else { + // code is recognized as a date part but world-calendars doesn't support it + if(directiveObj === UNKNOWN) replacementPart = UNKNOWN; + + // format the cDate according to the translated directive + else replacementPart = cDate.formatDate(directiveObj[modifier]); + + fmt = fmt.substr(0, i) + replacementPart + fmt.substr(i + directiveLen); + i += replacementPart.length; + } + } + return fmt; +} + +// cache world calendars, so we don't have to reinstantiate +// during each date-time conversion +var allCals = {}; +function getCal(calendar) { + var calendarObj = allCals[calendar]; + if(calendarObj) return calendarObj; + + calendarObj = allCals[calendar] = calendars.instance(calendar); + return calendarObj; +} + +function makeAttrs(description) { + return Lib.extendFlat({}, attributes, { description: description }); +} + +function makeTraceAttrsDescription(coord) { + return 'Sets the calendar system to use with `' + coord + '` date data.'; +} + +var xAttrs = { + xcalendar: makeAttrs(makeTraceAttrsDescription('x')) +}; + +var xyAttrs = Lib.extendFlat({}, xAttrs, { + ycalendar: makeAttrs(makeTraceAttrsDescription('y')) +}); + +var xyzAttrs = Lib.extendFlat({}, xyAttrs, { + zcalendar: makeAttrs(makeTraceAttrsDescription('z')) +}); + +var axisAttrs = makeAttrs([ + 'Sets the calendar system to use for `range` and `tick0`', + 'if this is a date axis. This does not set the calendar for', + 'interpreting data on this axis, that\'s specified in the trace', + 'or via the global `layout.calendar`' +].join(' ')); + +module.exports = { + moduleType: 'component', + name: 'calendars', + + schema: { + traces: { + scatter: xyAttrs, + bar: xyAttrs, + box: xyAttrs, + heatmap: xyAttrs, + contour: xyAttrs, + histogram: xyAttrs, + histogram2d: xyAttrs, + histogram2dcontour: xyAttrs, + scatter3d: xyzAttrs, + surface: xyzAttrs, + mesh3d: xyzAttrs, + scattergl: xyAttrs, + ohlc: xAttrs, + candlestick: xAttrs + }, + layout: { + calendar: makeAttrs([ + 'Sets the default calendar system to use for interpreting and', + 'displaying dates throughout the plot.' + ].join(' ')) + }, + subplots: { + xaxis: {calendar: axisAttrs}, + yaxis: {calendar: axisAttrs}, + scene: { + xaxis: {calendar: axisAttrs}, + // TODO: it's actually redundant to include yaxis and zaxis here + // because in the scene attributes these are the same object so merging + // into one merges into them all. However, I left them in for parity with + // cartesian, where yaxis is unused until we Plotschema.get() when we + // use its presence or absence to determine whether to delete attributes + // from yaxis if they only apply to x (rangeselector/rangeslider) + yaxis: {calendar: axisAttrs}, + zaxis: {calendar: axisAttrs} + }, + polar: { + radialaxis: {calendar: axisAttrs} + } + }, + transforms: { + filter: { + valuecalendar: makeAttrs([ + 'WARNING: All transforms are deprecated and may be removed from the API in next major version.', + 'Sets the calendar system to use for `value`, if it is a date.' + ].join(' ')), + targetcalendar: makeAttrs([ + 'WARNING: All transforms are deprecated and may be removed from the API in next major version.', + 'Sets the calendar system to use for `target`, if it is an', + 'array of dates. If `target` is a string (eg *x*) we use the', + 'corresponding trace attribute (eg `xcalendar`) if it exists,', + 'even if `targetcalendar` is provided.' + ].join(' ')) + } + } + }, + + layoutAttributes: attributes, + + handleDefaults: handleDefaults, + handleTraceDefaults: handleTraceDefaults, + + CANONICAL_SUNDAY: CANONICAL_SUNDAY, + CANONICAL_TICK: CANONICAL_TICK, + DFLTRANGE: DFLTRANGE, + + getCal: getCal, + worldCalFmt: worldCalFmt +}; + +},{"../../constants/numerical":265,"../../lib":285,"./calendars":152}],154:[function(_dereq_,module,exports){ 'use strict'; @@ -22793,20 +32916,12 @@ exports.borderLine = '#BEC8D9'; // gives back exactly lightLine if the other colors are defaults. exports.lightFraction = 100 * (0xe - 0x4) / (0xf - 0x4); -},{}],105:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],155:[function(_dereq_,module,exports){ 'use strict'; var tinycolor = _dereq_('tinycolor2'); var isNumeric = _dereq_('fast-isnumeric'); +var isTypedArray = _dereq_('../../lib/array').isTypedArray; var color = module.exports = {}; @@ -22921,7 +33036,7 @@ color.clean = function(container) { if(!Array.isArray(el0) && el0 && typeof el0 === 'object') { for(j = 0; j < val.length; j++) color.clean(val[j]); } - } else if(val && typeof val === 'object') color.clean(val); + } else if(val && typeof val === 'object' && !isTypedArray(val)) color.clean(val); } }; @@ -22967,15 +33082,7 @@ function cleanOne(val) { return 'rgb(' + rgbStr + ')'; } -},{"./attributes":104,"fast-isnumeric":23,"tinycolor2":88}],106:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib/array":271,"./attributes":154,"fast-isnumeric":31,"tinycolor2":119}],156:[function(_dereq_,module,exports){ 'use strict'; var axesAttrs = _dereq_('../../plots/cartesian/layout_attributes'); @@ -22988,82 +33095,61 @@ module.exports = overrideAll({ // TODO: only right is supported currently // orient: { // valType: 'enumerated', -// // values: ['left', 'right', 'top', 'bottom'], // dflt: 'right', -// +// // }, thicknessmode: { valType: 'enumerated', values: ['fraction', 'pixels'], - dflt: 'pixels', - }, thickness: { valType: 'number', - min: 0, dflt: 30, - }, lenmode: { valType: 'enumerated', values: ['fraction', 'pixels'], - dflt: 'fraction', - }, len: { valType: 'number', min: 0, dflt: 1, - - }, x: { valType: 'number', dflt: 1.02, min: -2, max: 3, - - }, xanchor: { valType: 'enumerated', values: ['left', 'center', 'right'], dflt: 'left', - - }, xpad: { valType: 'number', - min: 0, dflt: 10, - }, y: { valType: 'number', - dflt: 0.5, min: -2, max: 3, - }, yanchor: { valType: 'enumerated', values: ['top', 'middle', 'bottom'], - dflt: 'middle', - }, ypad: { valType: 'number', - min: 0, dflt: 10, - }, // a possible line around the bar itself outlinecolor: axesAttrs.linecolor, @@ -23073,16 +33159,12 @@ module.exports = overrideAll({ bordercolor: axesAttrs.linecolor, borderwidth: { valType: 'number', - min: 0, dflt: 0, - }, bgcolor: { valType: 'color', - dflt: 'rgba(0,0,0,0)', - }, // tick and title properties named and function exactly as in axes tickmode: axesAttrs.tickmode, @@ -23092,6 +33174,8 @@ module.exports = overrideAll({ tickvals: axesAttrs.tickvals, ticktext: axesAttrs.ticktext, ticks: extendFlat({}, axesAttrs.ticks, {dflt: ''}), + ticklabeloverflow: extendFlat({}, axesAttrs.ticklabeloverflow, { + }), ticklabelposition: { valType: 'enumerated', values: [ @@ -23100,15 +33184,12 @@ module.exports = overrideAll({ 'outside bottom', 'inside bottom' ], dflt: 'outside', - - }, ticklen: axesAttrs.ticklen, tickwidth: axesAttrs.tickwidth, tickcolor: axesAttrs.tickcolor, showticklabels: axesAttrs.showticklabels, tickfont: fontAttrs({ - }), tickangle: axesAttrs.tickangle, tickformat: axesAttrs.tickformat, @@ -23124,49 +33205,31 @@ module.exports = overrideAll({ title: { text: { valType: 'string', - - }, font: fontAttrs({ - }), side: { valType: 'enumerated', values: ['right', 'top', 'bottom'], - dflt: 'top', - } }, _deprecated: { title: { valType: 'string', - - }, titlefont: fontAttrs({ - }), titleside: { valType: 'enumerated', values: ['right', 'top', 'bottom'], - dflt: 'top', - } } }, 'colorbars', 'from-root'); -},{"../../lib/extend":227,"../../plot_api/edit_types":261,"../../plots/cartesian/layout_attributes":293,"../../plots/font_attributes":307}],107:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib/extend":279,"../../plot_api/edit_types":313,"../../plots/cartesian/layout_attributes":345,"../../plots/font_attributes":359}],157:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -23186,16 +33249,7 @@ module.exports = { } }; -},{}],108:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],158:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -23240,11 +33294,14 @@ module.exports = function colorbarDefaults(containerIn, containerOut, layout) { coerce('bordercolor'); coerce('borderwidth'); coerce('bgcolor'); + var ticklabelposition = coerce('ticklabelposition'); + coerce('ticklabeloverflow', ticklabelposition.indexOf('inside') !== -1 ? 'hide past domain' : 'hide past div'); handleTickValueDefaults(colorbarIn, colorbarOut, coerce, 'linear'); - var opts = {outerTicks: false, font: layout.font}; + var font = layout.font; + var opts = {outerTicks: false, font: font}; if(ticklabelposition.indexOf('inside') !== -1) { opts.bgColor = 'black'; // could we instead use the average of colors in the scale? } @@ -23252,22 +33309,20 @@ module.exports = function colorbarDefaults(containerIn, containerOut, layout) { handleTickMarkDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts); coerce('title.text', layout._dfltTitle.colorbar); - Lib.coerceFont(coerce, 'title.font', layout.font); + + var tickFont = colorbarOut.tickfont; + var dfltTitleFont = Lib.extendFlat({}, tickFont, { + color: font.color, + size: Lib.bigFont(tickFont.size) + }); + Lib.coerceFont(coerce, 'title.font', dfltTitleFont); coerce('title.side'); }; -},{"../../lib":233,"../../plot_api/plot_template":268,"../../plots/cartesian/tick_label_defaults":300,"../../plots/cartesian/tick_mark_defaults":301,"../../plots/cartesian/tick_value_defaults":302,"./attributes":106}],109:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plot_api/plot_template":320,"../../plots/cartesian/tick_label_defaults":352,"../../plots/cartesian/tick_mark_defaults":353,"../../plots/cartesian/tick_value_defaults":354,"./attributes":156}],159:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var tinycolor = _dereq_('tinycolor2'); var Plots = _dereq_('../../plots/plots'); @@ -23944,6 +33999,7 @@ function mockColorBarAxis(gd, opts, zrange) { tickcolor: opts.tickcolor, showticklabels: opts.showticklabels, ticklabelposition: opts.ticklabelposition, + ticklabeloverflow: opts.ticklabeloverflow, tickfont: opts.tickfont, tickangle: opts.tickangle, tickformat: opts.tickformat, @@ -23990,16 +34046,7 @@ module.exports = { draw: draw }; -},{"../../constants/alignment":207,"../../lib":233,"../../lib/extend":227,"../../lib/setcursor":253,"../../lib/svg_text_utils":255,"../../plots/cartesian/axes":279,"../../plots/cartesian/axis_defaults":281,"../../plots/cartesian/layout_attributes":293,"../../plots/cartesian/position_defaults":296,"../../plots/plots":313,"../../registry":326,"../color":105,"../colorscale/helpers":116,"../dragelement":124,"../drawing":127,"../titles":200,"./constants":107,"d3":21,"tinycolor2":88}],110:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../constants/alignment":260,"../../lib":285,"../../lib/extend":279,"../../lib/setcursor":305,"../../lib/svg_text_utils":307,"../../plots/cartesian/axes":331,"../../plots/cartesian/axis_defaults":333,"../../plots/cartesian/layout_attributes":345,"../../plots/cartesian/position_defaults":348,"../../plots/plots":366,"../../registry":373,"../color":155,"../colorscale/helpers":166,"../dragelement":174,"../drawing":177,"../titles":253,"./constants":157,"@plotly/d3":20,"tinycolor2":119}],160:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -24009,15 +34056,7 @@ module.exports = function hasColorbar(container) { return Lib.isPlainObject(container.colorbar); }; -},{"../../lib":233}],111:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],161:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -24031,15 +34070,7 @@ module.exports = { hasColorbar: _dereq_('./has_colorbar') }; -},{"./attributes":106,"./defaults":108,"./draw":109,"./has_colorbar":110}],112:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"./attributes":156,"./defaults":158,"./draw":159,"./has_colorbar":160}],162:[function(_dereq_,module,exports){ 'use strict'; var colorbarAttrs = _dereq_('../colorbar/attributes'); @@ -24140,9 +34171,7 @@ module.exports = function colorScaleAttrs(context, opts) { attrs.color = { valType: 'color', arrayOk: true, - editType: editTypeOverride || 'style', - }; if(opts.anim) { @@ -24152,74 +34181,58 @@ module.exports = function colorScaleAttrs(context, opts) { attrs[auto] = { valType: 'boolean', - dflt: true, editType: 'calc', impliedEdits: autoImpliedEdits, - }; attrs[min] = { valType: 'number', - dflt: null, editType: editTypeOverride || 'plot', impliedEdits: minmaxImpliedEdits, - }; attrs[max] = { valType: 'number', - dflt: null, editType: editTypeOverride || 'plot', impliedEdits: minmaxImpliedEdits, - }; attrs[mid] = { valType: 'number', - dflt: null, editType: 'calc', impliedEdits: autoImpliedEdits, - }; attrs.colorscale = { valType: 'colorscale', - editType: 'calc', dflt: colorscaleDflt, impliedEdits: {autocolorscale: false}, - }; attrs.autocolorscale = { valType: 'boolean', - // gets overrode in 'heatmap' & 'surface' for backwards comp. dflt: opts.autoColorDflt === false ? false : true, editType: 'calc', impliedEdits: {colorscale: undefined}, - }; attrs.reversescale = { valType: 'boolean', - dflt: false, editType: 'plot', - }; if(!noScale) { attrs.showscale = { valType: 'boolean', - dflt: showScaleDflt, editType: 'calc', - }; attrs.colorbar = colorbarAttrs; @@ -24228,26 +34241,16 @@ module.exports = function colorScaleAttrs(context, opts) { if(!opts.noColorAxis) { attrs.coloraxis = { valType: 'subplotid', - regex: counterRegex('coloraxis'), dflt: null, editType: 'calc', - }; } return attrs; }; -},{"../../lib/regex":249,"../colorbar/attributes":106,"./scales.js":120}],113:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib/regex":301,"../colorbar/attributes":156,"./scales.js":170}],163:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -24318,15 +34321,7 @@ module.exports = function calc(gd, trace, opts) { } }; -},{"../../lib":233,"./helpers":116,"fast-isnumeric":23}],114:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"./helpers":166,"fast-isnumeric":31}],164:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -24395,15 +34390,7 @@ module.exports = function crossTraceDefaults(fullData, fullLayout) { } }; -},{"../../lib":233,"./helpers":116}],115:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"./helpers":166}],165:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -24520,18 +34507,10 @@ module.exports = function colorScaleDefaults(parentContIn, parentContOut, layout } }; -},{"../../lib":233,"../../registry":326,"../colorbar/defaults":108,"../colorbar/has_colorbar":110,"./scales":120,"fast-isnumeric":23}],116:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../registry":373,"../colorbar/defaults":158,"../colorbar/has_colorbar":160,"./scales":170,"fast-isnumeric":31}],166:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var tinycolor = _dereq_('tinycolor2'); var isNumeric = _dereq_('fast-isnumeric'); @@ -24573,7 +34552,7 @@ var letterAttrs = ['min', 'max', 'mid', 'auto']; /** * Extract 'c' / 'z', trace / color axis colorscale options * - * Note that it would be nice to replace all z* with c* equivalents in v2 + * Note that it would be nice to replace all z* with c* equivalents in v3 * * @param {object} cont : attribute container * @return {object}: @@ -24760,15 +34739,7 @@ module.exports = { makeColorScaleFuncFromTrace: makeColorScaleFuncFromTrace }; -},{"../../lib":233,"../color":105,"./scales":120,"d3":21,"fast-isnumeric":23,"tinycolor2":88}],117:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../color":155,"./scales":170,"@plotly/d3":20,"fast-isnumeric":31,"tinycolor2":119}],167:[function(_dereq_,module,exports){ 'use strict'; var scales = _dereq_('./scales'); @@ -24802,15 +34773,7 @@ module.exports = { makeColorScaleFuncFromTrace: helpers.makeColorScaleFuncFromTrace }; -},{"./attributes":112,"./calc":113,"./cross_trace_defaults":114,"./defaults":115,"./helpers":116,"./layout_attributes":118,"./layout_defaults":119,"./scales":120}],118:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"./attributes":162,"./calc":163,"./cross_trace_defaults":164,"./defaults":165,"./helpers":166,"./layout_attributes":168,"./layout_defaults":169,"./scales":170}],168:[function(_dereq_,module,exports){ 'use strict'; var extendFlat = _dereq_('../../lib/extend').extendFlat; @@ -24829,23 +34792,17 @@ module.exports = { sequential: { valType: 'colorscale', dflt: scales.Reds, - editType: 'calc', - }, sequentialminus: { valType: 'colorscale', dflt: scales.Blues, - editType: 'calc', - }, diverging: { valType: 'colorscale', dflt: scales.RdBu, - editType: 'calc', - } }, @@ -24855,7 +34812,6 @@ module.exports = { // support yaxis, yaxis2, yaxis3, ... counters _isSubplotObj: true, editType: 'calc', - }, colorScaleAttrs('', { colorAttr: 'corresponding trace color array(s)', noColorAxis: true, @@ -24863,15 +34819,7 @@ module.exports = { })) }; -},{"../../lib/extend":227,"./attributes":112,"./scales":120}],119:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib/extend":279,"./attributes":162,"./scales":170}],169:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -24914,15 +34862,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) { } }; -},{"../../lib":233,"../../plot_api/plot_template":268,"./defaults":115,"./layout_attributes":118}],120:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plot_api/plot_template":320,"./defaults":165,"./layout_attributes":168}],170:[function(_dereq_,module,exports){ 'use strict'; var tinycolor = _dereq_('tinycolor2'); @@ -25118,16 +35058,7 @@ module.exports = { isValid: isValidScale }; -},{"tinycolor2":88}],121:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"tinycolor2":119}],171:[function(_dereq_,module,exports){ 'use strict'; @@ -25151,16 +35082,7 @@ module.exports = function align(v, dv, v0, v1, anchor) { return vc; }; -},{}],122:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],172:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -25189,15 +35111,7 @@ module.exports = function getCursor(x, y, xanchor, yanchor) { return cursorset[y][x]; }; -},{"../../lib":233}],123:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],173:[function(_dereq_,module,exports){ 'use strict'; exports.selectMode = function(dragmode) { @@ -25248,15 +35162,7 @@ exports.selectingOrDrawing = function(dragmode) { ); }; -},{}],124:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],174:[function(_dereq_,module,exports){ 'use strict'; var mouseOffset = _dereq_('mouse-event-offset'); @@ -25431,7 +35337,7 @@ dragElement.init = function init(options) { if(dx || dy) { gd._dragged = true; - dragElement.unhover(gd); + dragElement.unhover(gd, e); } if(gd._dragged && options.moveFn && !rightClick) { @@ -25540,15 +35446,7 @@ function pointerOffset(e) { ); } -},{"../../lib":233,"../../plots/cartesian/constants":285,"./align":121,"./cursor":122,"./unhover":125,"has-hover":54,"has-passive-events":55,"mouse-event-offset":76}],125:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/cartesian/constants":337,"./align":171,"./cursor":172,"./unhover":175,"has-hover":62,"has-passive-events":63,"mouse-event-offset":69}],175:[function(_dereq_,module,exports){ 'use strict'; var Events = _dereq_('../../lib/events'); @@ -25577,7 +35475,7 @@ unhover.raw = function raw(gd, evt) { var oldhoverdata = gd._hoverdata; if(!evt) evt = {}; - if(evt.target && + if(evt.target && !gd._dragged && Events.triggerHandler(gd, 'plotly_beforehover', evt) === false) { return; } @@ -25595,16 +35493,7 @@ unhover.raw = function raw(gd, evt) { } }; -},{"../../lib/dom":225,"../../lib/events":226,"../../lib/throttle":256,"../fx/constants":139}],126:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib/dom":277,"../../lib/events":278,"../../lib/throttle":308,"../fx/constants":189}],176:[function(_dereq_,module,exports){ 'use strict'; exports.dash = { @@ -25615,24 +35504,44 @@ exports.dash = { // dash lengths in px, and it will be honored values: ['solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'], dflt: 'solid', - editType: 'style', - }; -},{}],127:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +exports.pattern = { + shape: { + valType: 'enumerated', + values: ['', '/', '\\', 'x', '-', '|', '+', '.'], + dflt: '', + arrayOk: true, + editType: 'style', + }, + bgcolor: { + valType: 'color', + arrayOk: true, + editType: 'style', + }, + size: { + valType: 'number', + min: 0, + dflt: 8, + arrayOk: true, + editType: 'style', + }, + solidity: { + valType: 'number', + min: 0, + max: 1, + dflt: 0.3, + arrayOk: true, + editType: 'style', + }, + editType: 'style' +}; +},{}],177:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var isNumeric = _dereq_('fast-isnumeric'); var tinycolor = _dereq_('tinycolor2'); @@ -25986,6 +35895,185 @@ drawing.gradient = function(sel, gd, gradientID, type, colorscale, prop) { fullLayout._gradientUrlQueryParts[k] = 1; }; +/** + * pattern: create and apply a pattern fill + * + * @param {object} sel: d3 selection to apply this pattern to + * You can use `selection.call(Drawing.pattern, ...)` + * @param {DOM element} gd: the graph div `sel` is part of + * @param {string} patternID: a unique (within this plot) identifier + * for this pattern, so that we don't create unnecessary definitions + * @param {string} bgcolor: background color for this pattern + * @param {string} fgcolor: foreground color for this pattern + * @param {number} size: size of unit squares for repetition of this pattern + * @param {number} solidity: how solid lines of this pattern are + * @param {string} prop: the property to apply to, 'fill' or 'stroke' + */ +drawing.pattern = function(sel, gd, patternID, shape, bgcolor, fgcolor, size, solidity, prop) { + var fullLayout = gd._fullLayout; + var fullID = 'p' + fullLayout._uid + '-' + patternID; + var width, height; + + // linear interpolation + var linearFn = function(x, x0, x1, y0, y1) { + return y0 + (y1 - y0) * (x - x0) / (x1 - x0); + }; + + var path, linewidth, radius; + var patternTag; + var patternAttrs = {}; + switch(shape) { + case '/': + width = size * Math.sqrt(2); + height = size * Math.sqrt(2); + path = 'M-' + (width / 4) + ',' + (height / 4) + 'l' + (width / 2) + ',-' + (height / 2) + + 'M0,' + height + 'L' + width + ',0' + + 'M' + (width / 4 * 3) + ',' + (height / 4 * 5) + 'l' + (width / 2) + ',-' + (height / 2); + linewidth = solidity * size; + patternTag = 'path'; + patternAttrs = { + 'd': path, + 'stroke': fgcolor, + 'stroke-width': linewidth + 'px' + }; + break; + case '\\': + width = size * Math.sqrt(2); + height = size * Math.sqrt(2); + path = 'M' + (width / 4 * 3) + ',-' + (height / 4) + 'l' + (width / 2) + ',' + (height / 2) + + 'M0,0L' + width + ',' + height + + 'M-' + (width / 4) + ',' + (height / 4 * 3) + 'l' + (width / 2) + ',' + (height / 2); + linewidth = solidity * size; + patternTag = 'path'; + patternAttrs = { + 'd': path, + 'stroke': fgcolor, + 'stroke-width': linewidth + 'px' + }; + break; + case 'x': + width = size * Math.sqrt(2); + height = size * Math.sqrt(2); + path = 'M-' + (width / 4) + ',' + (height / 4) + 'l' + (width / 2) + ',-' + (height / 2) + + 'M0,' + height + 'L' + width + ',0' + + 'M' + (width / 4 * 3) + ',' + (height / 4 * 5) + 'l' + (width / 2) + ',-' + (height / 2) + + 'M' + (width / 4 * 3) + ',-' + (height / 4) + 'l' + (width / 2) + ',' + (height / 2) + + 'M0,0L' + width + ',' + height + + 'M-' + (width / 4) + ',' + (height / 4 * 3) + 'l' + (width / 2) + ',' + (height / 2); + linewidth = size - size * Math.sqrt(1.0 - solidity); + patternTag = 'path'; + patternAttrs = { + 'd': path, + 'stroke': fgcolor, + 'stroke-width': linewidth + 'px' + }; + break; + case '|': + width = size; + height = size; + patternTag = 'path'; + path = 'M' + (width / 2) + ',0L' + (width / 2) + ',' + height; + linewidth = solidity * size; + patternTag = 'path'; + patternAttrs = { + 'd': path, + 'stroke': fgcolor, + 'stroke-width': linewidth + 'px' + }; + break; + case '-': + width = size; + height = size; + patternTag = 'path'; + path = 'M0,' + (height / 2) + 'L' + width + ',' + (height / 2); + linewidth = solidity * size; + patternTag = 'path'; + patternAttrs = { + 'd': path, + 'stroke': fgcolor, + 'stroke-width': linewidth + 'px' + }; + break; + case '+': + width = size; + height = size; + patternTag = 'path'; + path = 'M' + (width / 2) + ',0L' + (width / 2) + ',' + height + + 'M0,' + (height / 2) + 'L' + width + ',' + (height / 2); + linewidth = size - size * Math.sqrt(1.0 - solidity); + patternTag = 'path'; + patternAttrs = { + 'd': path, + 'stroke': fgcolor, + 'stroke-width': linewidth + 'px' + }; + break; + case '.': + width = size; + height = size; + if(solidity < Math.PI / 4) { + radius = Math.sqrt(solidity * size * size / Math.PI); + } else { + radius = linearFn(solidity, Math.PI / 4, 1.0, size / 2, size / Math.sqrt(2)); + } + patternTag = 'circle'; + patternAttrs = { + 'cx': width / 2, + 'cy': height / 2, + 'r': radius, + 'fill': fgcolor + }; + break; + } + + var pattern = fullLayout._defs.select('.patterns') + .selectAll('#' + fullID) + .data([shape + ';' + bgcolor + ';' + fgcolor + ';' + size + ';' + solidity], Lib.identity); + + pattern.exit().remove(); + + pattern.enter() + .append('pattern') + .each(function() { + var el = d3.select(this); + + el.attr({ + 'id': fullID, + 'width': width + 'px', + 'height': height + 'px', + 'patternUnits': 'userSpaceOnUse' + }); + + if(bgcolor) { + var rects = el.selectAll('rect').data([0]); + rects.exit().remove(); + rects.enter() + .append('rect') + .attr({ + 'width': width + 'px', + 'height': height + 'px', + 'fill': bgcolor + }); + } + + var patterns = el.selectAll(patternTag).data([0]); + patterns.exit().remove(); + patterns.enter() + .append(patternTag) + .attr(patternAttrs); + }); + + sel.style(prop, getFullUrl(fullID, gd)) + .style(prop + '-opacity', null); + + sel.classed('pattern_filled', true); + var className2query = function(s) { + return '.' + s.attr('class').replace(/\s/g, '.'); + }; + var k = className2query(d3.select(sel.node().parentNode)) + '>.pattern_filled'; + fullLayout._patternUrlQueryParts[k] = 1; +}; + /* * Make the gradients container and clear out any previous gradients. * We never collect all the gradients we need in one place, @@ -26004,6 +36092,23 @@ drawing.initGradients = function(gd) { fullLayout._gradientUrlQueryParts = {}; }; +drawing.initPatterns = function(gd) { + var fullLayout = gd._fullLayout; + + var patternsGroup = Lib.ensureSingle(fullLayout._defs, 'g', 'patterns'); + patternsGroup.selectAll('pattern').remove(); + + // initialize stash of query parts filled in Drawing.pattern, + // used to fix URL strings during image exports + fullLayout._patternUrlQueryParts = {}; +}; + +drawing.getPatternAttr = function(mp, i, dflt) { + if(mp && Lib.isArrayOrTypedArray(mp)) { + return i < mp.length ? mp[i] : dflt; + } + return mp; +}; drawing.pointStyle = function(s, trace, gd) { if(!s.size()) return; @@ -26109,11 +36214,14 @@ drawing.singlePointStyle = function(d, sel, trace, fns, gd) { // for legend - arrays will propagate through here, but we don't need // to treat it as per-point. - if(Array.isArray(gradientType)) { + if(Lib.isArrayOrTypedArray(gradientType)) { gradientType = gradientType[0]; if(!gradientInfo[gradientType]) gradientType = 0; } + var markerPattern = marker.pattern; + var patternShape = markerPattern && drawing.getPatternAttr(markerPattern.shape, d.i, ''); + if(gradientType && gradientType !== 'none') { var gradientColor = d.mgc; if(gradientColor) perPointGradient = true; @@ -26124,6 +36232,20 @@ drawing.singlePointStyle = function(d, sel, trace, fns, gd) { drawing.gradient(sel, gd, gradientID, gradientType, [[0, gradientColor], [1, fillColor]], 'fill'); + } else if(patternShape) { + var patternBGColor = drawing.getPatternAttr(markerPattern.bgcolor, d.i, null); + var patternSize = drawing.getPatternAttr(markerPattern.size, d.i, 8); + var patternSolidity = drawing.getPatternAttr(markerPattern.solidity, d.i, 0.3); + var perPointPattern = Lib.isArrayOrTypedArray(markerPattern.shape) || + Lib.isArrayOrTypedArray(markerPattern.bgcolor) || + Lib.isArrayOrTypedArray(markerPattern.size) || + Lib.isArrayOrTypedArray(markerPattern.solidity); + + var patternID = trace.uid; + if(perPointPattern) patternID += '-' + d.i; + + drawing.pattern(sel, gd, patternID, patternShape, patternBGColor, fillColor, + patternSize, patternSolidity, 'fill'); } else { Color.fill(sel, fillColor); } @@ -26362,7 +36484,8 @@ drawing.textPointStyle = function(s, trace, gd) { } if(texttemplate) { - var labels = trace._module.formatLabels ? trace._module.formatLabels(d, trace, fullLayout) : {}; + var fn = trace._module.formatLabels; + var labels = fn ? fn(d, trace, fullLayout) : {}; var pointValues = {}; appendArrayPointValue(pointValues, trace, d.i); var meta = trace._meta || {}; @@ -26688,7 +36811,9 @@ function getFullUrl(localId, gd) { var context = gd._context; var baseUrl = context._exportedPlot ? '' : (context._baseUrl || ''); - return 'url(\'' + baseUrl + '#' + localId + '\')'; + return baseUrl ? + 'url(\'' + baseUrl + '#' + localId + '\')' : + 'url(#' + localId + ')'; } drawing.getTranslate = function(element) { @@ -26817,19 +36942,10 @@ drawing.setTextPointsScale = function(selection, xScale, yScale) { }); }; -},{"../../components/fx/helpers":141,"../../constants/alignment":207,"../../constants/interactions":211,"../../constants/xmlns_namespaces":213,"../../lib":233,"../../lib/svg_text_utils":255,"../../registry":326,"../../traces/scatter/make_bubble_size_func":464,"../../traces/scatter/subtypes":472,"../color":105,"../colorscale":117,"./symbol_defs":128,"d3":21,"fast-isnumeric":23,"tinycolor2":88}],128:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/fx/helpers":191,"../../constants/alignment":260,"../../constants/interactions":264,"../../constants/xmlns_namespaces":266,"../../lib":285,"../../lib/svg_text_utils":307,"../../registry":373,"../../traces/scatter/make_bubble_size_func":511,"../../traces/scatter/subtypes":519,"../color":155,"../colorscale":167,"./symbol_defs":178,"@plotly/d3":20,"fast-isnumeric":31,"tinycolor2":119}],178:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); /** Marker symbol definitions * users can specify markers either by number or name @@ -27381,130 +37497,90 @@ module.exports = { } }; -},{"d3":21}],129:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"@plotly/d3":20}],179:[function(_dereq_,module,exports){ 'use strict'; module.exports = { visible: { valType: 'boolean', - editType: 'calc', - }, type: { valType: 'enumerated', values: ['percent', 'constant', 'sqrt', 'data'], - editType: 'calc', - }, symmetric: { valType: 'boolean', - editType: 'calc', - }, array: { valType: 'data_array', editType: 'calc', - }, arrayminus: { valType: 'data_array', editType: 'calc', - }, value: { valType: 'number', min: 0, dflt: 10, - editType: 'calc', - }, valueminus: { valType: 'number', min: 0, dflt: 10, - editType: 'calc', - }, traceref: { valType: 'integer', min: 0, dflt: 0, - editType: 'style' }, tracerefminus: { valType: 'integer', min: 0, dflt: 0, - editType: 'style' }, copy_ystyle: { valType: 'boolean', - editType: 'plot' }, copy_zstyle: { valType: 'boolean', - editType: 'style' }, color: { valType: 'color', - editType: 'style', - }, thickness: { valType: 'number', min: 0, dflt: 2, - editType: 'style', - }, width: { valType: 'number', min: 0, - editType: 'plot', - }, editType: 'calc', _deprecated: { opacity: { valType: 'number', - editType: 'style', - } } }; -},{}],130:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],180:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -27582,16 +37658,7 @@ function calcOneAxis(calcTrace, trace, axis, coord) { baseExtremes.max = baseExtremes.max.concat(extremes.max); } -},{"../../lib":233,"../../plots/cartesian/axes":279,"../../registry":326,"./compute_error":131,"fast-isnumeric":23}],131:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../plots/cartesian/axes":331,"../../registry":373,"./compute_error":181,"fast-isnumeric":31}],181:[function(_dereq_,module,exports){ 'use strict'; @@ -27683,15 +37750,7 @@ function makeComputeErrorValue(type, value) { } } -},{}],132:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],182:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -27758,15 +37817,7 @@ module.exports = function(traceIn, traceOut, defaultColor, opts) { } }; -},{"../../lib":233,"../../plot_api/plot_template":268,"../../registry":326,"./attributes":129,"fast-isnumeric":23}],133:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plot_api/plot_template":320,"../../registry":373,"./attributes":179,"fast-isnumeric":31}],183:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -27827,19 +37878,10 @@ function hoverInfo(calcPoint, trace, hoverPoint) { } } -},{"../../lib":233,"../../plot_api/edit_types":261,"./attributes":129,"./calc":130,"./compute_error":131,"./defaults":132,"./plot":134,"./style":135}],134:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../plot_api/edit_types":313,"./attributes":179,"./calc":180,"./compute_error":181,"./defaults":182,"./plot":184,"./style":185}],184:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var isNumeric = _dereq_('fast-isnumeric'); var Drawing = _dereq_('../drawing'); @@ -27999,19 +38041,10 @@ function errorCoords(d, xa, ya) { return out; } -},{"../../traces/scatter/subtypes":472,"../drawing":127,"d3":21,"fast-isnumeric":23}],135:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../traces/scatter/subtypes":519,"../drawing":177,"@plotly/d3":20,"fast-isnumeric":31}],185:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Color = _dereq_('../color'); @@ -28036,15 +38069,7 @@ module.exports = function style(traces) { }); }; -},{"../color":105,"d3":21}],136:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../color":155,"@plotly/d3":20}],186:[function(_dereq_,module,exports){ 'use strict'; var fontAttrs = _dereq_('../../plots/font_attributes'); @@ -28055,16 +38080,13 @@ module.exports = { hoverlabel: { bgcolor: extendFlat({}, hoverLabelAttrs.bgcolor, { arrayOk: true, - }), bordercolor: extendFlat({}, hoverLabelAttrs.bordercolor, { arrayOk: true, - }), font: fontAttrs({ arrayOk: true, editType: 'none', - }), align: extendFlat({}, hoverLabelAttrs.align, {arrayOk: true}), namelength: extendFlat({}, hoverLabelAttrs.namelength, {arrayOk: true}), @@ -28072,15 +38094,7 @@ module.exports = { } }; -},{"../../lib/extend":227,"../../plots/font_attributes":307,"./layout_attributes":146}],137:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib/extend":279,"../../plots/font_attributes":359,"./layout_attributes":196}],187:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -28131,15 +38145,7 @@ function paste(traceAttr, cd, cdAttr, fn) { } } -},{"../../lib":233,"../../registry":326}],138:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../registry":373}],188:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -28168,15 +38174,7 @@ module.exports = function click(gd, evt, subplot) { } }; -},{"../../registry":326,"./hover":142}],139:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../registry":373,"./hover":192}],189:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -28200,15 +38198,7 @@ module.exports = { HOVERID: '-hover' }; -},{}],140:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],190:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -28226,15 +38216,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleHoverLabelDefaults(traceIn, traceOut, coerce, opts); }; -},{"../../lib":233,"./attributes":136,"./hoverlabel_defaults":143}],141:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"./attributes":186,"./hoverlabel_defaults":193}],191:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -28488,18 +38470,10 @@ exports.isXYhover = function(hovermode) { return !!xyHoverMode[hovermode]; }; -},{"../../lib":233}],142:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],192:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var isNumeric = _dereq_('fast-isnumeric'); var tinycolor = _dereq_('tinycolor2'); @@ -28538,6 +38512,13 @@ var YSHIFTY = Math.sin(YA_RADIANS); var HOVERARROWSIZE = constants.HOVERARROWSIZE; var HOVERTEXTPAD = constants.HOVERTEXTPAD; +var multipleHoverPoints = { + box: true, + ohlc: true, + violin: true, + candlestick: true +}; + // fx.hover: highlight data on hover // evt can be a mousemove event, or an object with data about what points // to hover on @@ -28747,8 +38728,11 @@ function _hover(gd, evt, subplot, noHoverEvent) { return dragElement.unhoverRaw(gd, evt); } - var hoverdistance = fullLayout.hoverdistance === -1 ? Infinity : fullLayout.hoverdistance; - var spikedistance = fullLayout.spikedistance === -1 ? Infinity : fullLayout.spikedistance; + var hoverdistance = fullLayout.hoverdistance; + if(hoverdistance === -1) hoverdistance = Infinity; + + var spikedistance = fullLayout.spikedistance; + if(spikedistance === -1) spikedistance = Infinity; // hoverData: the set of candidate points we've found to highlight var hoverData = []; @@ -28763,7 +38747,7 @@ function _hover(gd, evt, subplot, noHoverEvent) { // mapped onto each of the currently selected overlaid subplots var xvalArray, yvalArray; - var itemnum, curvenum, cd, trace, subplotId, subploti, mode, + var itemnum, curvenum, cd, trace, subplotId, subploti, _mode, xval, yval, pointData, closedataPreviousLength; // spikePoints: the set of candidate points we've found to draw spikes to @@ -28826,7 +38810,13 @@ function _hover(gd, evt, subplot, noHoverEvent) { return; } - var dbb = evt.target.getBoundingClientRect(); + // Discover event target, traversing open shadow roots. + var target = evt.composedPath && evt.composedPath()[0]; + if(!target) { + // Fallback for browsers not supporting composedPath + target = evt.target; + } + var dbb = target.getBoundingClientRect(); xpx = evt.clientX - dbb.left; ypx = evt.clientY - dbb.top; @@ -28892,9 +38882,9 @@ function _hover(gd, evt, subplot, noHoverEvent) { } // within one trace mode can sometimes be overridden - mode = hovermode; - if(helpers.isUnifiedHover(mode)) { - mode = mode.charAt(0); + _mode = hovermode; + if(helpers.isUnifiedHover(_mode)) { + _mode = _mode.charAt(0); } // container for new point, also used to pass info into module.hoverPoints @@ -28952,20 +38942,20 @@ function _hover(gd, evt, subplot, noHoverEvent) { // for a highlighting array, figure out what // we're searching for with this element - if(mode === 'array') { + if(_mode === 'array') { var selection = evt[curvenum]; if('pointNumber' in selection) { pointData.index = selection.pointNumber; - mode = 'closest'; + _mode = 'closest'; } else { - mode = ''; + _mode = ''; if('xval' in selection) { xval = selection.xval; - mode = 'x'; + _mode = 'x'; } if('yval' in selection) { yval = selection.yval; - mode = mode ? 'closest' : 'y'; + _mode = _mode ? 'closest' : 'y'; } } } else if(customXVal !== undefined && customYVal !== undefined) { @@ -28979,7 +38969,11 @@ function _hover(gd, evt, subplot, noHoverEvent) { // Now if there is range to look in, find the points to hover. if(hoverdistance !== 0) { if(trace._module && trace._module.hoverPoints) { - var newPoints = trace._module.hoverPoints(pointData, xval, yval, mode, fullLayout._hoverlayer); + var newPoints = trace._module.hoverPoints(pointData, xval, yval, _mode, { + finiteRange: true, + hoverLayer: fullLayout._hoverlayer + }); + if(newPoints) { var newPoint; for(var newPointNum = 0; newPointNum < newPoints.length; newPointNum++) { @@ -29008,7 +39002,9 @@ function _hover(gd, evt, subplot, noHoverEvent) { if(hoverData.length === 0) { pointData.distance = spikedistance; pointData.index = false; - var closestPoints = trace._module.hoverPoints(pointData, xval, yval, 'closest', fullLayout._hoverlayer); + var closestPoints = trace._module.hoverPoints(pointData, xval, yval, 'closest', { + hoverLayer: fullLayout._hoverlayer + }); if(closestPoints) { closestPoints = closestPoints.filter(function(point) { // some hover points, like scatter fills, do not allow spikes, @@ -29127,46 +39123,70 @@ function _hover(gd, evt, subplot, noHoverEvent) { } } - hoverData.sort(function(d1, d2) { return d1.distance - d2.distance; }); + var sortHoverData = function() { + hoverData.sort(function(d1, d2) { return d1.distance - d2.distance; }); + + // move period positioned points and box/bar-like traces to the end of the list + hoverData = orderRangePoints(hoverData, hovermode); + }; + sortHoverData(); - // If in compare mode, select every point at position if( - helpers.isXYhover(mode) && + helpers.isXYhover(_mode) && hoverData[0].length !== 0 && hoverData[0].trace.type !== 'splom' // TODO: add support for splom ) { - var hd = hoverData[0]; - var cd0 = hd.cd[hd.index]; - var isGrouped = (fullLayout.boxmode === 'group' || fullLayout.violinmode === 'group'); - - var xVal = hd.xVal; - var ax = hd.xa; - if(ax.type === 'category') xVal = ax._categoriesMap[xVal]; - if(ax.type === 'date') xVal = ax.d2c(xVal); - if(cd0 && cd0.t && cd0.t.posLetter === ax._id && isGrouped) { - xVal += cd0.t.dPos; + // pick winning point + var winningPoint = hoverData[0]; + // discard other points + if(multipleHoverPoints[winningPoint.trace.type]) { + hoverData = hoverData.filter(function(d) { + return d.trace.index === winningPoint.trace.index; + }); + } else { + hoverData = [winningPoint]; } + var initLen = hoverData.length; - var yVal = hd.yVal; - ax = hd.ya; - if(ax.type === 'category') yVal = ax._categoriesMap[yVal]; - if(ax.type === 'date') yVal = ax.d2c(yVal); - if(cd0 && cd0.t && cd0.t.posLetter === ax._id && isGrouped) { - yVal += cd0.t.dPos; - } + var winX = getCoord('x', winningPoint, fullLayout); + var winY = getCoord('y', winningPoint, fullLayout); - findHoverPoints(xVal, yVal); + // in compare mode, select every point at position + findHoverPoints(winX, winY); - // Remove duplicated hoverData points - // note that d3 also filters identical points in the rendering steps - var repeated = {}; - hoverData = hoverData.filter(function(hd) { - var key = hoverDataKey(hd); - if(!repeated[key]) { - repeated[key] = true; - return repeated[key]; + var finalPoints = []; + var seen = {}; + var id = 0; + var insert = function(newHd) { + var key = multipleHoverPoints[newHd.trace.type] ? hoverDataKey(newHd) : newHd.trace.index; + if(!seen[key]) { + id++; + seen[key] = id; + finalPoints.push(newHd); + } else { + var oldId = seen[key] - 1; + var oldHd = finalPoints[oldId]; + if(oldId > 0 && + Math.abs(newHd.distance) < + Math.abs(oldHd.distance) + ) { + // replace with closest + finalPoints[oldId] = newHd; + } } - }); + }; + + var k; + // insert the winnig point(s) first + for(k = 0; k < initLen; k++) { + insert(hoverData[k]); + } + // override from the end + for(k = hoverData.length - 1; k > initLen - 1; k--) { + insert(hoverData[k]); + } + hoverData = finalPoints; + sortHoverData(); } // lastly, emit custom hover/unhover events @@ -29269,9 +39289,8 @@ function createHoverText(hoverData, opts, gd) { var c0 = hoverData[0]; var xa = c0.xa; var ya = c0.ya; - var commonAttr = hovermode.charAt(0) === 'y' ? 'yLabel' : 'xLabel'; - var t0 = c0[commonAttr]; - var t00 = (String(t0) || '').split(' ')[0]; + var axLetter = hovermode.charAt(0); + var t0 = c0[axLetter + 'Label']; var outerContainerBB = outerContainer.node().getBoundingClientRect(); var outerTop = outerContainerBB.top; var outerWidth = outerContainerBB.width; @@ -29460,27 +39479,13 @@ function createHoverText(hoverData, opts, gd) { } label.attr('transform', strTranslate(lx, ly)); - - // remove the "close but not quite" points - // because of error bars, only take up to a space - hoverData = filterClosePoints(hoverData); }); - function filterClosePoints(hoverData) { - return hoverData.filter(function(d) { - return (d.zLabelVal !== undefined) || - (d[commonAttr] || '').split(' ')[0] === t00; - }); - } - // Show a single hover label if(helpers.isUnifiedHover(hovermode)) { // Delete leftover hover labels from other hovermodes container.selectAll('g.hovertext').remove(); - // similarly to compare mode, we remove the "close but not quite together" points - if((t0 !== undefined) && (c0.distance <= opts.hoverdistance)) hoverData = filterClosePoints(hoverData); - // Return early if nothing is hovered on if(hoverData.length === 0) return; @@ -29500,10 +39505,10 @@ function createHoverText(hoverData, opts, gd) { }; var mockLayoutOut = {}; legendSupplyDefaults(mockLayoutIn, mockLayoutOut, gd._fullData); - var legendOpts = mockLayoutOut.legend; + var mockLegend = mockLayoutOut.legend; // prepare items for the legend - legendOpts.entries = []; + mockLegend.entries = []; for(var j = 0; j < hoverData.length; j++) { var texts = getHoverLabelText(hoverData[j], true, hovermode, fullLayout, t0); var text = texts[0]; @@ -29529,17 +39534,19 @@ function createHoverText(hoverData, opts, gd) { } pt._distinct = true; - legendOpts.entries.push([pt]); + mockLegend.entries.push([pt]); } - legendOpts.entries.sort(function(a, b) { return a[0].trace.index - b[0].trace.index;}); - legendOpts.layer = container; + mockLegend.entries.sort(function(a, b) { return a[0].trace.index - b[0].trace.index;}); + mockLegend.layer = container; // Draw unified hover label - legendDraw(gd, legendOpts); + mockLegend._inHover = true; + legendDraw(gd, mockLegend); // Position the hover - var ly = Lib.mean(hoverData.map(function(c) {return (c.y0 + c.y1) / 2;})); - var lx = Lib.mean(hoverData.map(function(c) {return (c.x0 + c.x1) / 2;})); + var winningPoint = hoverData[0]; + var ly = (winningPoint.y0 + winningPoint.y1) / 2; + var lx = (winningPoint.x0 + winningPoint.x1) / 2; var legendContainer = container.select('g.legend'); var tbb = legendContainer.node().getBoundingClientRect(); lx += xa._offset; @@ -29736,14 +39743,17 @@ function getHoverLabelText(d, showCommonLabel, hovermode, fullLayout, t0, g) { name = plainText(d.name, d.nameLength); } + var h0 = hovermode.charAt(0); + var h1 = h0 === 'x' ? 'y' : 'x'; + if(d.zLabel !== undefined) { if(d.xLabel !== undefined) text += 'x: ' + d.xLabel + '
'; if(d.yLabel !== undefined) text += 'y: ' + d.yLabel + '
'; if(d.trace.type !== 'choropleth' && d.trace.type !== 'choroplethmapbox') { text += (text ? 'z: ' : '') + d.zLabel; } - } else if(showCommonLabel && d[hovermode.charAt(0) + 'Label'] === t0) { - text = d[(hovermode.charAt(0) === 'x' ? 'y' : 'x') + 'Label'] || ''; + } else if(showCommonLabel && d[h0 + 'Label'] === t0) { + text = d[h1 + 'Label'] || ''; } else if(d.xLabel === undefined) { if(d.yLabel !== undefined && d.trace.type !== 'scattercarpet') { text = d.yLabel; @@ -29772,16 +39782,20 @@ function getHoverLabelText(d, showCommonLabel, hovermode, fullLayout, t0, g) { } // hovertemplate - var d3locale = fullLayout._d3locale; var hovertemplate = d.hovertemplate || false; - var hovertemplateLabels = d.hovertemplateLabels || d; - var eventData = d.eventData[0] || {}; if(hovertemplate) { + var labels = d.hovertemplateLabels || d; + + if(d[h0 + 'Label'] !== t0) { + labels[h0 + 'other'] = labels[h0 + 'Val']; + labels[h0 + 'otherLabel'] = labels[h0 + 'Label']; + } + text = Lib.hovertemplateString( hovertemplate, - hovertemplateLabels, - d3locale, - eventData, + labels, + fullLayout._d3locale, + d.eventData[0] || {}, d.trace._meta ); @@ -30098,11 +40112,11 @@ function cleanPoint(d, hovermode) { // and convert the x and y label values into formatted text if(d.xLabelVal !== undefined) { - d.xLabel = ('xLabel' in d) ? d.xLabel : Axes.hoverLabelText(d.xa, d.xLabelVal); + d.xLabel = ('xLabel' in d) ? d.xLabel : Axes.hoverLabelText(d.xa, d.xLabelVal, trace.xhoverformat); d.xVal = d.xa.c2d(d.xLabelVal); } if(d.yLabelVal !== undefined) { - d.yLabel = ('yLabel' in d) ? d.yLabel : Axes.hoverLabelText(d.ya, d.yLabelVal); + d.yLabel = ('yLabel' in d) ? d.yLabel : Axes.hoverLabelText(d.ya, d.yLabelVal, trace.yhoverformat); d.yVal = d.ya.c2d(d.yLabelVal); } @@ -30360,15 +40374,52 @@ function plainText(s, len) { }); } -},{"../../lib":233,"../../lib/events":226,"../../lib/override_cursor":244,"../../lib/svg_text_utils":255,"../../plots/cartesian/axes":279,"../../registry":326,"../color":105,"../dragelement":124,"../drawing":127,"../legend/defaults":157,"../legend/draw":158,"./constants":139,"./helpers":141,"d3":21,"fast-isnumeric":23,"tinycolor2":88}],143:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +function orderRangePoints(hoverData, hovermode) { + var axLetter = hovermode.charAt(0); + var first = []; + var second = []; + var last = []; + + for(var i = 0; i < hoverData.length; i++) { + var d = hoverData[i]; + + if( + Registry.traceIs(d.trace, 'bar-like') || + Registry.traceIs(d.trace, 'box-violin') + ) { + last.push(d); + } else if(d.trace[axLetter + 'period']) { + second.push(d); + } else { + first.push(d); + } + } + + return first.concat(second).concat(last); +} + +function getCoord(axLetter, winningPoint, fullLayout) { + var ax = winningPoint[axLetter + 'a']; + var val = winningPoint[axLetter + 'Val']; + + if(ax.type === 'category') val = ax._categoriesMap[val]; + else if(ax.type === 'date') val = ax.d2c(val); + + var cd0 = winningPoint.cd[winningPoint.index]; + if(cd0 && cd0.t && cd0.t.posLetter === ax._id) { + if( + fullLayout.boxmode === 'group' || + fullLayout.violinmode === 'group' + ) { + val += cd0.t.dPos; + } + } + + return val; +} + +},{"../../lib":285,"../../lib/events":278,"../../lib/override_cursor":296,"../../lib/svg_text_utils":307,"../../plots/cartesian/axes":331,"../../registry":373,"../color":155,"../dragelement":174,"../drawing":177,"../legend/defaults":207,"../legend/draw":208,"./constants":189,"./helpers":191,"@plotly/d3":20,"fast-isnumeric":31,"tinycolor2":119}],193:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -30406,21 +40457,13 @@ module.exports = function handleHoverLabelDefaults(contIn, contOut, coerce, opts coerce('hoverlabel.align', opts.align); }; -},{"../../lib":233,"../color":105,"./helpers":141}],144:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../color":155,"./helpers":191}],194:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); var layoutAttributes = _dereq_('./layout_attributes'); -module.exports = function handleHoverModeDefaults(layoutIn, layoutOut, fullData) { +module.exports = function handleHoverModeDefaults(layoutIn, layoutOut) { function coerce(attr, dflt) { // don't coerce if it is already coerced in other place e.g. in cartesian defaults if(layoutOut[attr] !== undefined) return layoutOut[attr]; @@ -30428,52 +40471,14 @@ module.exports = function handleHoverModeDefaults(layoutIn, layoutOut, fullData) return Lib.coerce(layoutIn, layoutOut, layoutAttributes, attr, dflt); } - var clickmode = coerce('clickmode'); - - var hovermodeDflt; - if(layoutOut._has('cartesian')) { - if(clickmode.indexOf('select') > -1) { - hovermodeDflt = 'closest'; - } else { - // flag for 'horizontal' plots: - // determines the state of the mode bar 'compare' hovermode button - layoutOut._isHoriz = isHoriz(fullData, layoutOut); - hovermodeDflt = layoutOut._isHoriz ? 'y' : 'x'; - } - } else hovermodeDflt = 'closest'; - - return coerce('hovermode', hovermodeDflt); + coerce('clickmode'); + return coerce('hovermode'); }; -function isHoriz(fullData, fullLayout) { - var stackOpts = fullLayout._scatterStackOpts || {}; - - for(var i = 0; i < fullData.length; i++) { - var trace = fullData[i]; - var subplot = trace.xaxis + trace.yaxis; - var subplotStackOpts = stackOpts[subplot] || {}; - var groupOpts = subplotStackOpts[trace.stackgroup] || {}; - - if(trace.orientation !== 'h' && groupOpts.orientation !== 'h') { - return false; - } - } - - return true; -} - -},{"../../lib":233,"./layout_attributes":146}],145:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"./layout_attributes":196}],195:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Lib = _dereq_('../../lib'); var dragElement = _dereq_('../dragelement'); var helpers = _dereq_('./helpers'); @@ -30541,22 +40546,13 @@ function castHoverinfo(trace, fullLayout, ptNumber) { return Lib.castOption(trace, ptNumber, 'hoverinfo', _coerce); } -},{"../../lib":233,"../dragelement":124,"./attributes":136,"./calc":137,"./click":138,"./constants":139,"./defaults":140,"./helpers":141,"./hover":142,"./layout_attributes":146,"./layout_defaults":147,"./layout_global_defaults":148,"d3":21}],146:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../dragelement":174,"./attributes":186,"./calc":187,"./click":188,"./constants":189,"./defaults":190,"./helpers":191,"./hover":192,"./layout_attributes":196,"./layout_defaults":197,"./layout_global_defaults":198,"@plotly/d3":20}],196:[function(_dereq_,module,exports){ 'use strict'; var constants = _dereq_('./constants'); var fontAttrs = _dereq_('../../plots/font_attributes')({ editType: 'none', - }); fontAttrs.family.dflt = constants.HOVERFONT; fontAttrs.size.dflt = constants.HOVERFONTSIZE; @@ -30564,16 +40560,13 @@ fontAttrs.size.dflt = constants.HOVERFONTSIZE; module.exports = { clickmode: { valType: 'flaglist', - flags: ['event', 'select'], dflt: 'event', editType: 'plot', extras: ['none'], - }, dragmode: { valType: 'enumerated', - values: [ 'zoom', 'pan', @@ -30590,99 +40583,74 @@ module.exports = { ], dflt: 'zoom', editType: 'modebar', - }, hovermode: { valType: 'enumerated', - values: ['x', 'y', 'closest', false, 'x unified', 'y unified'], + dflt: 'closest', editType: 'modebar', - }, hoverdistance: { valType: 'integer', min: -1, dflt: 20, - editType: 'none', - }, spikedistance: { valType: 'integer', min: -1, - dflt: 20, - + dflt: -1, editType: 'none', - }, hoverlabel: { bgcolor: { valType: 'color', - editType: 'none', - }, bordercolor: { valType: 'color', - editType: 'none', - }, font: fontAttrs, align: { valType: 'enumerated', values: ['left', 'right', 'auto'], dflt: 'auto', - editType: 'none', - }, namelength: { valType: 'integer', min: -1, dflt: 15, - editType: 'none', - }, editType: 'none' }, selectdirection: { valType: 'enumerated', - values: ['h', 'v', 'd', 'any'], dflt: 'any', - editType: 'none' } }; -},{"../../plots/font_attributes":307,"./constants":139}],147:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/font_attributes":359,"./constants":189}],197:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); -var isUnifiedHover = _dereq_('./helpers').isUnifiedHover; var layoutAttributes = _dereq_('./layout_attributes'); var handleHoverModeDefaults = _dereq_('./hovermode_defaults'); var handleHoverLabelDefaults = _dereq_('./hoverlabel_defaults'); -module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { +module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) { function coerce(attr, dflt) { return Lib.coerce(layoutIn, layoutOut, layoutAttributes, attr, dflt); } - var hoverMode = handleHoverModeDefaults(layoutIn, layoutOut, fullData); + var hoverMode = handleHoverModeDefaults(layoutIn, layoutOut); if(hoverMode) { coerce('hoverdistance'); - coerce('spikedistance', isUnifiedHover(hoverMode) ? -1 : undefined); + coerce('spikedistance'); } var dragMode = coerce('dragmode'); @@ -30705,15 +40673,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { handleHoverLabelDefaults(layoutIn, layoutOut, coerce); }; -},{"../../lib":233,"./helpers":141,"./hoverlabel_defaults":143,"./hovermode_defaults":144,"./layout_attributes":146}],148:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"./hoverlabel_defaults":193,"./hovermode_defaults":194,"./layout_attributes":196}],198:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -30728,15 +40688,7 @@ module.exports = function supplyLayoutGlobalDefaults(layoutIn, layoutOut) { handleHoverLabelDefaults(layoutIn, layoutOut, coerce); }; -},{"../../lib":233,"./hoverlabel_defaults":143,"./layout_attributes":146}],149:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"./hoverlabel_defaults":193,"./layout_attributes":196}],199:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -30749,92 +40701,69 @@ var gridAttrs = { rows: { valType: 'integer', min: 1, - editType: 'plot', - }, roworder: { valType: 'enumerated', values: ['top to bottom', 'bottom to top'], dflt: 'top to bottom', - editType: 'plot', - }, columns: { valType: 'integer', min: 1, - editType: 'plot', - }, subplots: { valType: 'info_array', freeLength: true, dimensions: 2, items: {valType: 'enumerated', values: [counterRegex('xy').toString(), ''], editType: 'plot'}, - editType: 'plot', - }, xaxes: { valType: 'info_array', freeLength: true, items: {valType: 'enumerated', values: [cartesianIdRegex.x.toString(), ''], editType: 'plot'}, - editType: 'plot', - }, yaxes: { valType: 'info_array', freeLength: true, items: {valType: 'enumerated', values: [cartesianIdRegex.y.toString(), ''], editType: 'plot'}, - editType: 'plot', - }, pattern: { valType: 'enumerated', values: ['independent', 'coupled'], dflt: 'coupled', - editType: 'plot', - }, xgap: { valType: 'number', min: 0, max: 1, - editType: 'plot', - }, ygap: { valType: 'number', min: 0, max: 1, - editType: 'plot', - }, domain: domainAttrs({name: 'grid', editType: 'plot', noGridCell: true}, { - }), xside: { valType: 'enumerated', values: ['bottom', 'bottom plot', 'top plot', 'top'], dflt: 'bottom plot', - editType: 'plot', - }, yside: { valType: 'enumerated', values: ['left', 'left plot', 'right plot', 'right'], dflt: 'left plot', - editType: 'plot', - }, editType: 'plot' }; @@ -31102,15 +41031,7 @@ module.exports = { contentDefaults: contentDefaults }; -},{"../../lib":233,"../../lib/regex":249,"../../plot_api/plot_template":268,"../../plots/cartesian/constants":285,"../../plots/domain":306}],150:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../lib/regex":301,"../../plot_api/plot_template":320,"../../plots/cartesian/constants":337,"../../plots/domain":358}],200:[function(_dereq_,module,exports){ 'use strict'; var cartesianConstants = _dereq_('../../plots/cartesian/constants'); @@ -31121,95 +41042,73 @@ var axisPlaceableObjs = _dereq_('../../constants/axis_placeable_objects'); module.exports = templatedArray('image', { visible: { valType: 'boolean', - dflt: true, editType: 'arraydraw', - }, source: { valType: 'string', - editType: 'arraydraw', - }, layer: { valType: 'enumerated', values: ['below', 'above'], dflt: 'above', - editType: 'arraydraw', - }, sizex: { valType: 'number', - dflt: 0, editType: 'arraydraw', - }, sizey: { valType: 'number', - dflt: 0, editType: 'arraydraw', - }, sizing: { valType: 'enumerated', values: ['fill', 'contain', 'stretch'], dflt: 'contain', - editType: 'arraydraw', - }, opacity: { valType: 'number', - min: 0, max: 1, dflt: 1, editType: 'arraydraw', - }, x: { valType: 'any', - dflt: 0, editType: 'arraydraw', - }, y: { valType: 'any', - dflt: 0, editType: 'arraydraw', - }, xanchor: { valType: 'enumerated', values: ['left', 'center', 'right'], dflt: 'left', - editType: 'arraydraw', - }, yanchor: { valType: 'enumerated', values: ['top', 'middle', 'bottom'], dflt: 'top', - editType: 'arraydraw', - }, xref: { @@ -31219,9 +41118,7 @@ module.exports = templatedArray('image', { cartesianConstants.idRegex.x.toString() ], dflt: 'paper', - editType: 'arraydraw', - }, yref: { @@ -31231,23 +41128,12 @@ module.exports = templatedArray('image', { cartesianConstants.idRegex.y.toString() ], dflt: 'paper', - editType: 'arraydraw', - }, editType: 'arraydraw' }); -},{"../../constants/axis_placeable_objects":208,"../../plot_api/plot_template":268,"../../plots/cartesian/constants":285}],151:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../constants/axis_placeable_objects":261,"../../plot_api/plot_template":320,"../../plots/cartesian/constants":337}],201:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -31257,7 +41143,7 @@ var toLogRange = _dereq_('../../lib/to_log_range'); * convertCoords: when converting an axis between log and linear * you need to alter any images on that axis to keep them * pointing at the same data point. - * In v2.0 this will become obsolete (or perhaps size will still need conversion?) + * In v3.0 this will become obsolete (or perhaps size will still need conversion?) * we convert size by declaring that the maximum extent *in data units* should be * the same, assuming the image is anchored by its center (could remove that restriction * if we think it's important) even though the actual left and right values will not be @@ -31319,15 +41205,7 @@ module.exports = function convertCoords(gd, ax, newType, doExtra) { } }; -},{"../../lib/to_log_range":257,"fast-isnumeric":23}],152:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib/to_log_range":309,"fast-isnumeric":31}],202:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -31384,18 +41262,10 @@ function imageDefaults(imageIn, imageOut, fullLayout) { return imageOut; } -},{"../../lib":233,"../../plots/array_container_defaults":274,"../../plots/cartesian/axes":279,"./attributes":150}],153:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/array_container_defaults":326,"../../plots/cartesian/axes":331,"./attributes":200}],203:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Drawing = _dereq_('../drawing'); var Axes = _dereq_('../../plots/cartesian/axes'); var axisIds = _dereq_('../../plots/cartesian/axis_ids'); @@ -31623,7 +41493,7 @@ module.exports = function draw(gd) { subplot = allSubplots[i]; var subplotObj = fullLayout._plots[subplot]; - // filter out overlaid plots (which havd their images on the main plot) + // filter out overlaid plots (which have their images on the main plot) // and gl2d plots (which don't support below images, at least not yet) if(!subplotObj.imagelayer) continue; @@ -31642,15 +41512,7 @@ module.exports = function draw(gd) { } }; -},{"../../constants/xmlns_namespaces":213,"../../plots/cartesian/axes":279,"../../plots/cartesian/axis_ids":282,"../drawing":127,"d3":21}],154:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/xmlns_namespaces":266,"../../plots/cartesian/axes":331,"../../plots/cartesian/axis_ids":334,"../drawing":177,"@plotly/d3":20}],204:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -31666,15 +41528,7 @@ module.exports = { convertCoords: _dereq_('./convert_coords') }; -},{"../../plots/cartesian/include_components":291,"./attributes":150,"./convert_coords":151,"./defaults":152,"./draw":153}],155:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian/include_components":343,"./attributes":200,"./convert_coords":201,"./defaults":202,"./draw":203}],205:[function(_dereq_,module,exports){ 'use strict'; var fontAttrs = _dereq_('../../plots/font_attributes'); @@ -31684,150 +41538,112 @@ var colorAttrs = _dereq_('../color/attributes'); module.exports = { bgcolor: { valType: 'color', - editType: 'legend', - }, bordercolor: { valType: 'color', dflt: colorAttrs.defaultLine, - editType: 'legend', - }, borderwidth: { valType: 'number', min: 0, dflt: 0, - editType: 'legend', - }, font: fontAttrs({ editType: 'legend', - }), orientation: { valType: 'enumerated', values: ['v', 'h'], dflt: 'v', - editType: 'legend', - }, traceorder: { valType: 'flaglist', flags: ['reversed', 'grouped'], extras: ['normal'], - editType: 'legend', - }, tracegroupgap: { valType: 'number', min: 0, dflt: 10, - editType: 'legend', - }, itemsizing: { valType: 'enumerated', values: ['trace', 'constant'], dflt: 'trace', - editType: 'legend', - }, itemwidth: { valType: 'number', min: 30, dflt: 30, - editType: 'legend', - }, itemclick: { valType: 'enumerated', values: ['toggle', 'toggleothers', false], dflt: 'toggle', - editType: 'legend', - }, itemdoubleclick: { valType: 'enumerated', values: ['toggle', 'toggleothers', false], dflt: 'toggleothers', - editType: 'legend', - }, x: { valType: 'number', min: -2, max: 3, - editType: 'legend', - }, xanchor: { valType: 'enumerated', values: ['auto', 'left', 'center', 'right'], dflt: 'left', - editType: 'legend', - }, y: { valType: 'number', min: -2, max: 3, - editType: 'legend', - }, yanchor: { valType: 'enumerated', values: ['auto', 'top', 'middle', 'bottom'], - editType: 'legend', - }, uirevision: { valType: 'any', - editType: 'none', - }, valign: { valType: 'enumerated', values: ['top', 'middle', 'bottom'], dflt: 'middle', - editType: 'legend', - }, title: { text: { valType: 'string', dflt: '', - editType: 'legend', - }, font: fontAttrs({ editType: 'legend', - }), side: { valType: 'enumerated', values: ['top', 'left', 'top left'], - editType: 'legend', - }, editType: 'legend', }, @@ -31835,15 +41651,7 @@ module.exports = { editType: 'legend' }; -},{"../../plots/font_attributes":307,"../color/attributes":104}],156:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/font_attributes":359,"../color/attributes":154}],206:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -31859,15 +41667,7 @@ module.exports = { itemGap: 5 }; -},{}],157:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],207:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -31947,12 +41747,13 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { coerce('bgcolor', layoutOut.paper_bgcolor); coerce('bordercolor'); coerce('borderwidth'); - Lib.coerceFont(coerce, 'font', layoutOut.font); + var itemFont = Lib.coerceFont(coerce, 'font', layoutOut.font); var orientation = coerce('orientation'); + var isHorizontal = orientation === 'h'; var defaultX, defaultY, defaultYAnchor; - if(orientation === 'h') { + if(isHorizontal) { defaultX = 0; if(Registry.getComponentMethod('rangeslider', 'isVisible')(layoutIn.xaxis)) { @@ -31961,7 +41762,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { } else { // maybe use y=1.1 / yanchor=bottom as above // to avoid https://github.com/plotly/plotly.js/issues/1199 - // in v2 + // in v3 defaultY = -0.1; defaultYAnchor = 'top'; } @@ -31989,23 +41790,19 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { var titleText = coerce('title.text'); if(titleText) { - coerce('title.side', orientation === 'h' ? 'left' : 'top'); - Lib.coerceFont(coerce, 'title.font', layoutOut.font); + coerce('title.side', isHorizontal ? 'left' : 'top'); + var dfltTitleFont = Lib.extendFlat({}, itemFont, { + size: Lib.bigFont(itemFont.size) + }); + + Lib.coerceFont(coerce, 'title.font', dfltTitleFont); } }; -},{"../../lib":233,"../../plot_api/plot_template":268,"../../plots/layout_attributes":311,"../../registry":326,"./attributes":155,"./helpers":161}],158:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plot_api/plot_template":320,"../../plots/layout_attributes":364,"../../registry":373,"./attributes":205,"./helpers":211}],208:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Lib = _dereq_('../../lib'); var Plots = _dereq_('../../plots/plots'); @@ -32027,19 +41824,24 @@ var getLegendData = _dereq_('./get_legend_data'); var style = _dereq_('./style'); var helpers = _dereq_('./helpers'); +var MAIN_TITLE = 1; + module.exports = function draw(gd, opts) { + if(!opts) opts = gd._fullLayout.legend || {}; + return _draw(gd, opts); +}; + +function _draw(gd, legendObj) { var fullLayout = gd._fullLayout; var clipId = 'legend' + fullLayout._uid; var layer; - // Check whether this is the main legend (ie. called without any opts) - if(!opts) { - opts = fullLayout.legend || {}; - opts._main = true; - layer = fullLayout._infolayer; - } else { - layer = opts.layer; + var inHover = legendObj._inHover; + if(inHover) { + layer = legendObj.layer; clipId += '-hover'; + } else { + layer = fullLayout._infolayer; } if(!layer) return; @@ -32047,24 +41849,24 @@ module.exports = function draw(gd, opts) { if(!gd._legendMouseDownTime) gd._legendMouseDownTime = 0; var legendData; - if(opts._main) { + if(!inHover) { if(!gd.calcdata) return; - legendData = fullLayout.showlegend && getLegendData(gd.calcdata, opts); + legendData = fullLayout.showlegend && getLegendData(gd.calcdata, legendObj); } else { - if(!opts.entries) return; - legendData = getLegendData(opts.entries, opts); + if(!legendObj.entries) return; + legendData = getLegendData(legendObj.entries, legendObj); } var hiddenSlices = fullLayout.hiddenlabels || []; - if(opts._main && (!fullLayout.showlegend || !legendData.length)) { + if(!inHover && (!fullLayout.showlegend || !legendData.length)) { layer.selectAll('.legend').remove(); fullLayout._topdefs.select('#' + clipId).remove(); return Plots.autoMargin(gd, 'legend'); } var legend = Lib.ensureSingle(layer, 'g', 'legend', function(s) { - if(opts._main) s.attr('pointer-events', 'all'); + if(!inHover) s.attr('pointer-events', 'all'); }); var clipPath = Lib.ensureSingleById(fullLayout._topdefs, 'clipPath', clipId, function(s) { @@ -32074,22 +41876,22 @@ module.exports = function draw(gd, opts) { var bg = Lib.ensureSingle(legend, 'rect', 'bg', function(s) { s.attr('shape-rendering', 'crispEdges'); }); - bg.call(Color.stroke, opts.bordercolor) - .call(Color.fill, opts.bgcolor) - .style('stroke-width', opts.borderwidth + 'px'); + bg.call(Color.stroke, legendObj.bordercolor) + .call(Color.fill, legendObj.bgcolor) + .style('stroke-width', legendObj.borderwidth + 'px'); var scrollBox = Lib.ensureSingle(legend, 'g', 'scrollbox'); - var title = opts.title; - opts._titleWidth = 0; - opts._titleHeight = 0; + var title = legendObj.title; + legendObj._titleWidth = 0; + legendObj._titleHeight = 0; if(title.text) { var titleEl = Lib.ensureSingle(scrollBox, 'text', 'legendtitletext'); titleEl.attr('text-anchor', 'start') .call(Drawing.font, title.font) .text(title.text); - textLayout(titleEl, scrollBox, gd, opts); // handle mathjax or multi-line text and compute title height + textLayout(titleEl, scrollBox, gd, legendObj, MAIN_TITLE); // handle mathjax or multi-line text and compute title height } else { scrollBox.selectAll('.legendtitletext').remove(); } @@ -32115,31 +41917,31 @@ module.exports = function draw(gd, opts) { return trace.visible === 'legendonly' ? 0.5 : 1; } }) - .each(function() { d3.select(this).call(drawTexts, gd, opts); }) - .call(style, gd, opts) - .each(function() { if(opts._main) d3.select(this).call(setupTraceToggle, gd); }); + .each(function() { d3.select(this).call(drawTexts, gd, legendObj); }) + .call(style, gd, legendObj) + .each(function() { if(!inHover) d3.select(this).call(setupTraceToggle, gd); }); Lib.syncOrAsync([ Plots.previousPromises, - function() { return computeLegendDimensions(gd, groups, traces, opts); }, + function() { return computeLegendDimensions(gd, groups, traces, legendObj); }, function() { // IF expandMargin return a Promise (which is truthy), // we're under a doAutoMargin redraw, so we don't have to // draw the remaining pieces below - if(opts._main && expandMargin(gd)) return; + if(!inHover && expandMargin(gd)) return; var gs = fullLayout._size; - var bw = opts.borderwidth; + var bw = legendObj.borderwidth; - var lx = gs.l + gs.w * opts.x - FROM_TL[getXanchor(opts)] * opts._width; - var ly = gs.t + gs.h * (1 - opts.y) - FROM_TL[getYanchor(opts)] * opts._effHeight; + var lx = gs.l + gs.w * legendObj.x - FROM_TL[getXanchor(legendObj)] * legendObj._width; + var ly = gs.t + gs.h * (1 - legendObj.y) - FROM_TL[getYanchor(legendObj)] * legendObj._effHeight; - if(opts._main && fullLayout.margin.autoexpand) { + if(!inHover && fullLayout.margin.autoexpand) { var lx0 = lx; var ly0 = ly; - lx = Lib.constrain(lx, 0, fullLayout.width - opts._width); - ly = Lib.constrain(ly, 0, fullLayout.height - opts._effHeight); + lx = Lib.constrain(lx, 0, fullLayout.width - legendObj._width); + ly = Lib.constrain(ly, 0, fullLayout.height - legendObj._effHeight); if(lx !== lx0) { Lib.log('Constrain legend.x to make legend fit inside graph'); @@ -32151,21 +41953,21 @@ module.exports = function draw(gd, opts) { // Set size and position of all the elements that make up a legend: // legend, background and border, scroll box and scroll bar as well as title - if(opts._main) Drawing.setTranslate(legend, lx, ly); + if(!inHover) Drawing.setTranslate(legend, lx, ly); // to be safe, remove previous listeners scrollBar.on('.drag', null); legend.on('wheel', null); - if(!opts._main || opts._height <= opts._maxHeight || gd._context.staticPlot) { + if(inHover || legendObj._height <= legendObj._maxHeight || gd._context.staticPlot) { // if scrollbar should not be shown. - var height = opts._effHeight; + var height = legendObj._effHeight; - // if not the main legend, let it be its full size - if(!opts._main) height = opts._height; + // if unified hover, let it be its full size + if(inHover) height = legendObj._height; bg.attr({ - width: opts._width - bw, + width: legendObj._width - bw, height: height - bw, x: bw / 2, y: bw / 2 @@ -32174,7 +41976,7 @@ module.exports = function draw(gd, opts) { Drawing.setTranslate(scrollBox, 0, 0); clipPath.select('rect').attr({ - width: opts._width - 2 * bw, + width: legendObj._width - 2 * bw, height: height - 2 * bw, x: bw, y: bw @@ -32183,36 +41985,36 @@ module.exports = function draw(gd, opts) { Drawing.setClipUrl(scrollBox, clipId, gd); Drawing.setRect(scrollBar, 0, 0, 0, 0); - delete opts._scrollY; + delete legendObj._scrollY; } else { var scrollBarHeight = Math.max(constants.scrollBarMinHeight, - opts._effHeight * opts._effHeight / opts._height); - var scrollBarYMax = opts._effHeight - + legendObj._effHeight * legendObj._effHeight / legendObj._height); + var scrollBarYMax = legendObj._effHeight - scrollBarHeight - 2 * constants.scrollBarMargin; - var scrollBoxYMax = opts._height - opts._effHeight; + var scrollBoxYMax = legendObj._height - legendObj._effHeight; var scrollRatio = scrollBarYMax / scrollBoxYMax; - var scrollBoxY = Math.min(opts._scrollY || 0, scrollBoxYMax); + var scrollBoxY = Math.min(legendObj._scrollY || 0, scrollBoxYMax); // increase the background and clip-path width // by the scrollbar width and margin bg.attr({ - width: opts._width - + width: legendObj._width - 2 * bw + constants.scrollBarWidth + constants.scrollBarMargin, - height: opts._effHeight - bw, + height: legendObj._effHeight - bw, x: bw / 2, y: bw / 2 }); clipPath.select('rect').attr({ - width: opts._width - + width: legendObj._width - 2 * bw + constants.scrollBarWidth + constants.scrollBarMargin, - height: opts._effHeight - 2 * bw, + height: legendObj._effHeight - 2 * bw, x: bw, y: bw + scrollBoxY }); @@ -32224,7 +42026,7 @@ module.exports = function draw(gd, opts) { // scroll legend by mousewheel or touchpad swipe up/down legend.on('wheel', function() { scrollBoxY = Lib.constrain( - opts._scrollY + + legendObj._scrollY + ((d3.event.deltaY / scrollBarYMax) * scrollBoxYMax), 0, scrollBoxYMax); scrollHandler(scrollBoxY, scrollBarHeight, scrollRatio); @@ -32290,12 +42092,12 @@ module.exports = function draw(gd, opts) { } function scrollHandler(scrollBoxY, scrollBarHeight, scrollRatio) { - opts._scrollY = gd._fullLayout.legend._scrollY = scrollBoxY; + legendObj._scrollY = gd._fullLayout.legend._scrollY = scrollBoxY; Drawing.setTranslate(scrollBox, 0, -scrollBoxY); Drawing.setRect( scrollBar, - opts._width, + legendObj._width, constants.scrollBarMargin + scrollBoxY * scrollRatio, constants.scrollBarWidth, scrollBarHeight @@ -32322,8 +42124,8 @@ module.exports = function draw(gd, opts) { Drawing.setTranslate(legend, newX, newY); - xf = dragElement.align(newX, 0, gs.l, gs.l + gs.w, opts.xanchor); - yf = dragElement.align(newY, 0, gs.t + gs.h, gs.t, opts.yanchor); + xf = dragElement.align(newX, 0, gs.l, gs.l + gs.w, legendObj.xanchor); + yf = dragElement.align(newY, 0, gs.t + gs.h, gs.t, legendObj.yanchor); }, doneFn: function() { if(xf !== undefined && yf !== undefined) { @@ -32345,7 +42147,7 @@ module.exports = function draw(gd, opts) { }); } }], gd); -}; +} function clickOrDoubleClick(gd, legend, legendItem, numClicks, evt) { var trace = legendItem.data()[0][0].trace; @@ -32374,6 +42176,7 @@ function clickOrDoubleClick(gd, legend, legendItem, numClicks, evt) { if(numClicks === 1) { legend._clickTimeout = setTimeout(function() { + if(!gd._fullLayout) return; handleClick(legendItem, gd, numClicks); }, gd._context.doubleClickDelay); } else if(numClicks === 2) { @@ -32385,16 +42188,15 @@ function clickOrDoubleClick(gd, legend, legendItem, numClicks, evt) { } } -function drawTexts(g, gd, opts) { +function drawTexts(g, gd, legendObj) { var legendItem = g.data()[0][0]; var trace = legendItem.trace; var isPieLike = Registry.traceIs(trace, 'pie-like'); - var traceIndex = trace.index; - var isEditable = opts._main && gd._context.edits.legendText && !isPieLike; - var maxNameLength = opts._maxNameLength; + var isEditable = !legendObj._inHover && gd._context.edits.legendText && !isPieLike; + var maxNameLength = legendObj._maxNameLength; var name; - if(!opts.entries) { + if(!legendObj.entries) { name = isPieLike ? legendItem.label : trace.name; if(trace._meta) { name = Lib.templateString(name, trace._meta); @@ -32406,18 +42208,18 @@ function drawTexts(g, gd, opts) { var textEl = Lib.ensureSingle(g, 'text', 'legendtext'); textEl.attr('text-anchor', 'start') - .call(Drawing.font, opts.font) + .call(Drawing.font, legendObj.font) .text(isEditable ? ensureLength(name, maxNameLength) : name); - var textGap = opts.itemwidth + constants.itemGap * 2; + var textGap = legendObj.itemwidth + constants.itemGap * 2; svgTextUtils.positionText(textEl, textGap, 0); if(isEditable) { textEl.call(svgTextUtils.makeEditable, {gd: gd, text: name}) - .call(textLayout, g, gd, opts) + .call(textLayout, g, gd, legendObj) .on('edit', function(newName) { this.text(ensureLength(newName, maxNameLength)) - .call(textLayout, g, gd, opts); + .call(textLayout, g, gd, legendObj); var fullInput = legendItem.trace._fullInput || {}; var update = {}; @@ -32435,10 +42237,10 @@ function drawTexts(g, gd, opts) { update.name = newName; } - return Registry.call('_guiRestyle', gd, update, traceIndex); + return Registry.call('_guiRestyle', gd, update, trace.index); }); } else { - textLayout(textEl, g, gd, opts); + textLayout(textEl, g, gd, legendObj); } } @@ -32494,25 +42296,25 @@ function setupTraceToggle(g, gd) { }); } -function textLayout(s, g, gd, opts) { - if(!opts._main) s.attr('data-notex', true); // do not process MathJax if not main +function textLayout(s, g, gd, legendObj, aTitle) { + if(legendObj._inHover) s.attr('data-notex', true); // do not process MathJax for unified hover svgTextUtils.convertToTspans(s, gd, function() { - computeTextDimensions(g, gd, opts); + computeTextDimensions(g, gd, legendObj, aTitle); }); } -function computeTextDimensions(g, gd, opts) { +function computeTextDimensions(g, gd, legendObj, aTitle) { var legendItem = g.data()[0][0]; - if(opts._main && legendItem && !legendItem.trace.showlegend) { + if(!legendObj._inHover && legendItem && !legendItem.trace.showlegend) { g.remove(); return; } var mathjaxGroup = g.select('g[class*=math-group]'); var mathjaxNode = mathjaxGroup.node(); - if(!opts) opts = gd._fullLayout.legend; - var bw = opts.borderwidth; - var lineHeight = (legendItem ? opts : opts.title).font.size * LINE_SPACING; + if(!legendObj) legendObj = gd._fullLayout.legend; + var bw = legendObj.borderwidth; + var lineHeight = (aTitle === MAIN_TITLE ? legendObj.title : legendObj).font.size * LINE_SPACING; var height, width; if(mathjaxNode) { @@ -32521,14 +42323,14 @@ function computeTextDimensions(g, gd, opts) { height = mathjaxBB.height; width = mathjaxBB.width; - if(legendItem) { + if(aTitle === MAIN_TITLE) { + Drawing.setTranslate(mathjaxGroup, bw, bw + height * 0.75); + } else { // legend item Drawing.setTranslate(mathjaxGroup, 0, height * 0.25); - } else { // case of title - Drawing.setTranslate(mathjaxGroup, bw, height * 0.75 + bw); } } else { - var textEl = g.select(legendItem ? - '.legendtext' : '.legendtitletext' + var textEl = g.select(aTitle === MAIN_TITLE ? + '.legendtitletext' : '.legendtext' ); var textLines = svgTextUtils.lineCount(textEl); var textNode = textEl.node(); @@ -32538,36 +42340,45 @@ function computeTextDimensions(g, gd, opts) { // approximation to height offset to center the font // to avoid getBoundingClientRect - var textY = lineHeight * ((textLines - 1) / 2 - 0.3); - if(legendItem) { - var textGap = opts.itemwidth + constants.itemGap * 2; - svgTextUtils.positionText(textEl, textGap, -textY); - } else { // case of title - svgTextUtils.positionText(textEl, constants.titlePad + bw, lineHeight + bw); + if(aTitle === MAIN_TITLE) { + if(legendObj.title.side === 'left') { + // add extra space between legend title and itmes + width += constants.itemGap * 2; + } + + svgTextUtils.positionText(textEl, + bw + constants.titlePad, + bw + lineHeight + ); + } else { // legend item + svgTextUtils.positionText(textEl, + legendObj.itemwidth + constants.itemGap * 2, + -lineHeight * ((textLines - 1) / 2 - 0.3) + ); } } - if(legendItem) { + if(aTitle === MAIN_TITLE) { + legendObj._titleWidth = width; + legendObj._titleHeight = height; + } else { // legend item legendItem.lineHeight = lineHeight; legendItem.height = Math.max(height, 16) + 3; legendItem.width = width; - } else { // case of title - opts._titleWidth = width; - opts._titleHeight = height; } } -function getTitleSize(opts) { +function getTitleSize(legendObj) { var w = 0; var h = 0; - var side = opts.title.side; + var side = legendObj.title.side; if(side) { if(side.indexOf('left') !== -1) { - w = opts._titleWidth; + w = legendObj._titleWidth; } if(side.indexOf('top') !== -1) { - h = opts._titleHeight; + h = legendObj._titleHeight; } } @@ -32584,68 +42395,70 @@ function getTitleSize(opts) { * - _width: legend width * - _maxWidth (for orientation:h only): maximum width before starting new row */ -function computeLegendDimensions(gd, groups, traces, opts) { +function computeLegendDimensions(gd, groups, traces, legendObj) { var fullLayout = gd._fullLayout; - if(!opts) opts = fullLayout.legend; + if(!legendObj) legendObj = fullLayout.legend; var gs = fullLayout._size; - var isVertical = helpers.isVertical(opts); - var isGrouped = helpers.isGrouped(opts); + var isVertical = helpers.isVertical(legendObj); + var isGrouped = helpers.isGrouped(legendObj); - var bw = opts.borderwidth; + var bw = legendObj.borderwidth; var bw2 = 2 * bw; var itemGap = constants.itemGap; - var textGap = opts.itemwidth + itemGap * 2; + var textGap = legendObj.itemwidth + itemGap * 2; var endPad = 2 * (bw + itemGap); - var yanchor = getYanchor(opts); - var isBelowPlotArea = opts.y < 0 || (opts.y === 0 && yanchor === 'top'); - var isAbovePlotArea = opts.y > 1 || (opts.y === 1 && yanchor === 'bottom'); + var yanchor = getYanchor(legendObj); + var isBelowPlotArea = legendObj.y < 0 || (legendObj.y === 0 && yanchor === 'top'); + var isAbovePlotArea = legendObj.y > 1 || (legendObj.y === 1 && yanchor === 'bottom'); + + var traceGroupGap = legendObj.tracegroupgap; // - if below/above plot area, give it the maximum potential margin-push value // - otherwise, extend the height of the plot area - opts._maxHeight = Math.max( + legendObj._maxHeight = Math.max( (isBelowPlotArea || isAbovePlotArea) ? fullLayout.height / 2 : gs.h, 30 ); var toggleRectWidth = 0; - opts._width = 0; - opts._height = 0; - var titleSize = getTitleSize(opts); + legendObj._width = 0; + legendObj._height = 0; + var titleSize = getTitleSize(legendObj); if(isVertical) { traces.each(function(d) { var h = d[0].height; Drawing.setTranslate(this, bw + titleSize[0], - bw + titleSize[1] + opts._height + h / 2 + itemGap + bw + titleSize[1] + legendObj._height + h / 2 + itemGap ); - opts._height += h; - opts._width = Math.max(opts._width, d[0].width); + legendObj._height += h; + legendObj._width = Math.max(legendObj._width, d[0].width); }); - toggleRectWidth = textGap + opts._width; - opts._width += itemGap + textGap + bw2; - opts._height += endPad; + toggleRectWidth = textGap + legendObj._width; + legendObj._width += itemGap + textGap + bw2; + legendObj._height += endPad; if(isGrouped) { groups.each(function(d, i) { - Drawing.setTranslate(this, 0, i * opts.tracegroupgap); + Drawing.setTranslate(this, 0, i * legendObj.tracegroupgap); }); - opts._height += (opts._lgroupsLength - 1) * opts.tracegroupgap; + legendObj._height += (legendObj._lgroupsLength - 1) * legendObj.tracegroupgap; } } else { - var xanchor = getXanchor(opts); - var isLeftOfPlotArea = opts.x < 0 || (opts.x === 0 && xanchor === 'right'); - var isRightOfPlotArea = opts.x > 1 || (opts.x === 1 && xanchor === 'left'); + var xanchor = getXanchor(legendObj); + var isLeftOfPlotArea = legendObj.x < 0 || (legendObj.x === 0 && xanchor === 'right'); + var isRightOfPlotArea = legendObj.x > 1 || (legendObj.x === 1 && xanchor === 'left'); var isBeyondPlotAreaY = isAbovePlotArea || isBelowPlotArea; var hw = fullLayout.width / 2; // - if placed within x-margins, extend the width of the plot area // - else if below/above plot area and anchored in the margin, extend to opposite margin, // - otherwise give it the maximum potential margin-push value - opts._maxWidth = Math.max( + legendObj._maxWidth = Math.max( isLeftOfPlotArea ? ((isBeyondPlotAreaY && xanchor === 'left') ? gs.l + gs.w : hw) : isRightOfPlotArea ? ((isBeyondPlotAreaY && xanchor === 'right') ? gs.r + gs.w : hw) : gs.w, @@ -32681,10 +42494,10 @@ function computeLegendDimensions(gd, groups, traces, opts) { var next = maxWidthInGroup + itemGap; - if((next + bw + groupOffsetX) > opts._maxWidth) { + if((next + bw + groupOffsetX) > legendObj._maxWidth) { maxRowWidth = Math.max(maxRowWidth, groupOffsetX); groupOffsetX = 0; - groupOffsetY += maxGroupHeightInRow + opts.tracegroupgap; + groupOffsetY += maxGroupHeightInRow + traceGroupGap; maxGroupHeightInRow = offsetY; } @@ -32693,11 +42506,11 @@ function computeLegendDimensions(gd, groups, traces, opts) { groupOffsetX += next; }); - opts._width = Math.max(maxRowWidth, groupOffsetX) + bw; - opts._height = groupOffsetY + maxGroupHeightInRow + endPad; + legendObj._width = Math.max(maxRowWidth, groupOffsetX) + bw; + legendObj._height = groupOffsetY + maxGroupHeightInRow + endPad; } else { var nTraces = traces.size(); - var oneRowLegend = (combinedItemWidth + bw2 + (nTraces - 1) * itemGap) < opts._maxWidth; + var oneRowLegend = (combinedItemWidth + bw2 + (nTraces - 1) * itemGap) < legendObj._maxWidth; var maxItemHeightInRow = 0; var offsetX = 0; @@ -32708,11 +42521,11 @@ function computeLegendDimensions(gd, groups, traces, opts) { var w = textGap + d[0].width; var next = (oneRowLegend ? w : maxItemWidth) + itemGap; - if((next + bw + offsetX - itemGap) >= opts._maxWidth) { + if((next + bw + offsetX - itemGap) >= legendObj._maxWidth) { maxRowWidth = Math.max(maxRowWidth, rowWidth); offsetX = 0; offsetY += maxItemHeightInRow; - opts._height += maxItemHeightInRow; + legendObj._height += maxItemHeightInRow; maxItemHeightInRow = 0; } @@ -32727,30 +42540,30 @@ function computeLegendDimensions(gd, groups, traces, opts) { }); if(oneRowLegend) { - opts._width = offsetX + bw2; - opts._height = maxItemHeightInRow + endPad; + legendObj._width = offsetX + bw2; + legendObj._height = maxItemHeightInRow + endPad; } else { - opts._width = Math.max(maxRowWidth, rowWidth) + bw2; - opts._height += maxItemHeightInRow + endPad; + legendObj._width = Math.max(maxRowWidth, rowWidth) + bw2; + legendObj._height += maxItemHeightInRow + endPad; } } } - opts._width = Math.ceil( + legendObj._width = Math.ceil( Math.max( - opts._width + titleSize[0], - opts._titleWidth + 2 * (bw + constants.titlePad) + legendObj._width + titleSize[0], + legendObj._titleWidth + 2 * (bw + constants.titlePad) ) ); - opts._height = Math.ceil( + legendObj._height = Math.ceil( Math.max( - opts._height + titleSize[1], - opts._titleHeight + 2 * (bw + constants.itemGap) + legendObj._height + titleSize[1], + legendObj._titleHeight + 2 * (bw + constants.itemGap) ) ); - opts._effHeight = Math.min(opts._height, opts._maxHeight); + legendObj._effHeight = Math.min(legendObj._height, legendObj._maxHeight); var edits = gd._context.edits; var isEditable = edits.legendText || edits.legendPosition; @@ -32765,41 +42578,33 @@ function computeLegendDimensions(gd, groups, traces, opts) { function expandMargin(gd) { var fullLayout = gd._fullLayout; - var opts = fullLayout.legend; - var xanchor = getXanchor(opts); - var yanchor = getYanchor(opts); + var legendObj = fullLayout.legend; + var xanchor = getXanchor(legendObj); + var yanchor = getYanchor(legendObj); return Plots.autoMargin(gd, 'legend', { - x: opts.x, - y: opts.y, - l: opts._width * (FROM_TL[xanchor]), - r: opts._width * (FROM_BR[xanchor]), - b: opts._effHeight * (FROM_BR[yanchor]), - t: opts._effHeight * (FROM_TL[yanchor]) + x: legendObj.x, + y: legendObj.y, + l: legendObj._width * (FROM_TL[xanchor]), + r: legendObj._width * (FROM_BR[xanchor]), + b: legendObj._effHeight * (FROM_BR[yanchor]), + t: legendObj._effHeight * (FROM_TL[yanchor]) }); } -function getXanchor(opts) { - return Lib.isRightAnchor(opts) ? 'right' : - Lib.isCenterAnchor(opts) ? 'center' : +function getXanchor(legendObj) { + return Lib.isRightAnchor(legendObj) ? 'right' : + Lib.isCenterAnchor(legendObj) ? 'center' : 'left'; } -function getYanchor(opts) { - return Lib.isBottomAnchor(opts) ? 'bottom' : - Lib.isMiddleAnchor(opts) ? 'middle' : +function getYanchor(legendObj) { + return Lib.isBottomAnchor(legendObj) ? 'bottom' : + Lib.isMiddleAnchor(legendObj) ? 'middle' : 'top'; } -},{"../../constants/alignment":207,"../../lib":233,"../../lib/events":226,"../../lib/svg_text_utils":255,"../../plots/plots":313,"../../registry":326,"../color":105,"../dragelement":124,"../drawing":127,"./constants":156,"./get_legend_data":159,"./handle_click":160,"./helpers":161,"./style":163,"d3":21}],159:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/alignment":260,"../../lib":285,"../../lib/events":278,"../../lib/svg_text_utils":307,"../../plots/plots":366,"../../registry":373,"../color":155,"../dragelement":174,"../drawing":177,"./constants":206,"./get_legend_data":209,"./handle_click":210,"./helpers":211,"./style":213,"@plotly/d3":20}],209:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -32813,7 +42618,6 @@ module.exports = function getLegendData(calcdata, opts) { var lgroupi = 0; var maxNameLength = 0; var i, j; - var main = opts._main; function addOneItem(legendGroup, legendItem) { // each '' legend group is treated as a separate group @@ -32839,7 +42643,7 @@ module.exports = function getLegendData(calcdata, opts) { var trace = cd0.trace; var lgroup = trace.legendgroup; - if(main && (!trace.visible || !trace.showlegend)) continue; + if(!opts._inHover && (!trace.visible || !trace.showlegend)) continue; if(Registry.traceIs(trace, 'pie-like')) { if(!slicesShown[lgroup]) slicesShown[lgroup] = {}; @@ -32900,15 +42704,7 @@ module.exports = function getLegendData(calcdata, opts) { return legendData; }; -},{"../../registry":326,"./helpers":161}],160:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../registry":373,"./helpers":211}],210:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -33139,16 +42935,7 @@ module.exports = function handleClick(g, gd, numClicks) { } }; -},{"../../lib":233,"../../registry":326}],161:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../registry":373}],211:[function(_dereq_,module,exports){ 'use strict'; exports.isGrouped = function isGrouped(legendLayout) { @@ -33163,16 +42950,7 @@ exports.isReversed = function isReversed(legendLayout) { return (legendLayout.traceorder || '').indexOf('reversed') !== -1; }; -},{}],162:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],212:[function(_dereq_,module,exports){ 'use strict'; @@ -33187,18 +42965,10 @@ module.exports = { style: _dereq_('./style') }; -},{"./attributes":155,"./defaults":157,"./draw":158,"./style":163}],163:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"./attributes":205,"./defaults":207,"./draw":208,"./style":213}],213:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Registry = _dereq_('../../registry'); var Lib = _dereq_('../../lib'); @@ -33293,13 +43063,16 @@ module.exports = function style(s, gd, legend) { .each(styleOHLC); function styleLines(d) { + var styleGuide = getStyleGuide(d); + var showFill = styleGuide.showFill; + var showLine = styleGuide.showLine; + var showGradientLine = styleGuide.showGradientLine; + var showGradientFill = styleGuide.showGradientFill; + var anyFill = styleGuide.anyFill; + var anyLine = styleGuide.anyLine; + var d0 = d[0]; var trace = d0.trace; - var showFill = trace.visible && trace.fill && trace.fill !== 'none'; - var showLine = subTypes.hasLines(trace); - var contours = trace.contours; - var showGradientLine = false; - var showGradientFill = false; var dMod, tMod; var cOpts = extractOpts(trace); @@ -33325,28 +43098,10 @@ module.exports = function style(s, gd, legend) { } }; - if(contours) { - var coloring = contours.coloring; - - if(coloring === 'lines') { - showGradientLine = true; - } else { - showLine = coloring === 'none' || coloring === 'heatmap' || contours.showlines; - } - - if(contours.type === 'constraint') { - showFill = contours._operation !== '='; - } else if(coloring === 'fill' || coloring === 'heatmap') { - showGradientFill = true; - } - } - // with fill and no markers or text, move the line and fill up a bit // so it's more centered - var markersOrText = subTypes.hasMarkers(trace) || subTypes.hasText(trace); - var anyFill = showFill || showGradientFill; - var anyLine = showLine || showGradientLine; - var pathStart = (markersOrText || !anyFill) ? 'M5,0' : + + var pathStart = (subTypes.hasMarkers(trace) || !anyFill) ? 'M5,0' : // with a line leave it slightly below center, to leave room for the // line thickness and because the line is usually more prominent anyLine ? 'M5,-2' : 'M5,-3'; @@ -33382,11 +43137,15 @@ module.exports = function style(s, gd, legend) { } function stylePoints(d) { + var styleGuide = getStyleGuide(d); + var anyFill = styleGuide.anyFill; + var anyLine = styleGuide.anyLine; + var showLine = styleGuide.showLine; + var showMarker = styleGuide.showMarker; + var d0 = d[0]; var trace = d0.trace; - var showMarkers = subTypes.hasMarkers(trace); - var showText = subTypes.hasText(trace); - var showLines = subTypes.hasLines(trace); + var showText = !showMarker && !anyLine && !anyFill && subTypes.hasText(trace); var dMod, tMod; // 'scatter3d' don't use gd.calcdata, @@ -33415,11 +43174,11 @@ module.exports = function style(s, gd, legend) { } // constrain text, markers, etc so they'll fit on the legend - if(showMarkers || showText || showLines) { + if(showMarker || showText || showLine) { var dEdit = {}; var tEdit = {}; - if(showMarkers) { + if(showMarker) { dEdit.mc = boundVal('marker.color', pickFirst); dEdit.mx = boundVal('marker.symbol', pickFirst); dEdit.mo = boundVal('marker.opacity', Lib.mean, [0.2, 1]); @@ -33436,7 +43195,7 @@ module.exports = function style(s, gd, legend) { tEdit.marker.size = ms; } - if(showLines) { + if(showLine) { tEdit.line = { width: boundVal('line.width', pickFirst, [0, 10], CST_LINE_WIDTH) }; @@ -33463,7 +43222,7 @@ module.exports = function style(s, gd, legend) { var ptgroup = d3.select(this).select('g.legendpoints'); var pts = ptgroup.selectAll('path.scatterpts') - .data(showMarkers ? dMod : []); + .data(showMarker ? dMod : []); // make sure marker is on the bottom, in case it enters after text pts.enter().insert('path', ':first-child') .classed('scatterpts', true) @@ -33473,7 +43232,7 @@ module.exports = function style(s, gd, legend) { // 'mrc' is set in pointStyle and used in textPointStyle: // constrain it here - if(showMarkers) dMod[0].mrc = 3; + if(showMarker) dMod[0].mrc = 3; var txt = ptgroup.selectAll('g.pointtext') .data(showText ? dMod : []); @@ -33555,8 +43314,23 @@ module.exports = function style(s, gd, legend) { var d0 = d[0]; var w = boundLineWidth(d0.mlw, marker.line, MAX_MARKER_LINE_WIDTH, CST_MARKER_LINE_WIDTH); - p.style('stroke-width', w + 'px') - .call(Color.fill, d0.mc || marker.color); + p.style('stroke-width', w + 'px'); + + var fillColor = d0.mc || marker.color; + + var markerPattern = marker.pattern; + var patternShape = markerPattern && Drawing.getPatternAttr(markerPattern.shape, 0, ''); + + if(patternShape) { + var patternBGColor = Drawing.getPatternAttr(markerPattern.bgcolor, 0, null); + var patternSize = Math.min(12, Drawing.getPatternAttr(markerPattern.size, 0, 8)); + var patternSolidity = Drawing.getPatternAttr(markerPattern.solidity, 0, 0.3); + var patternID = 'legend-' + trace.uid; + p.call(Drawing.pattern, gd, patternID, patternShape, patternBGColor, + fillColor, patternSize, patternSolidity, 'fill'); + } else { + p.call(Color.fill, fillColor); + } if(w) Color.stroke(p, d0.mlc || markerLine.color); }); @@ -33820,15 +43594,88 @@ function getGradientDirection(reversescale, isRadial) { return str + (reversescale ? '' : 'reversed'); } -},{"../../lib":233,"../../registry":326,"../../traces/pie/helpers":439,"../../traces/pie/style_one":445,"../../traces/scatter/subtypes":472,"../color":105,"../colorscale/helpers":116,"../drawing":127,"./constants":156,"d3":21}],164:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +function getStyleGuide(d) { + var trace = d[0].trace; + var contours = trace.contours; + var showLine = subTypes.hasLines(trace); + var showMarker = subTypes.hasMarkers(trace); + var showFill = trace.visible && trace.fill && trace.fill !== 'none'; + var showGradientLine = false; + var showGradientFill = false; + + if(contours) { + var coloring = contours.coloring; + + if(coloring === 'lines') { + showGradientLine = true; + } else { + showLine = coloring === 'none' || coloring === 'heatmap' || contours.showlines; + } + + if(contours.type === 'constraint') { + showFill = contours._operation !== '='; + } else if(coloring === 'fill' || coloring === 'heatmap') { + showGradientFill = true; + } + } + + return { + showMarker: showMarker, + showLine: showLine, + showFill: showFill, + showGradientLine: showGradientLine, + showGradientFill: showGradientFill, + anyLine: showLine || showGradientLine, + anyFill: showFill || showGradientFill, + }; +} + +},{"../../lib":285,"../../registry":373,"../../traces/pie/helpers":486,"../../traces/pie/style_one":492,"../../traces/scatter/subtypes":519,"../color":155,"../colorscale/helpers":166,"../drawing":177,"./constants":206,"@plotly/d3":20}],214:[function(_dereq_,module,exports){ +'use strict'; + +var constants = _dereq_('./constants'); + +module.exports = { + editType: 'modebar', + + orientation: { + valType: 'enumerated', + values: ['v', 'h'], + dflt: 'h', + editType: 'modebar', + }, + bgcolor: { + valType: 'color', + editType: 'modebar', + }, + color: { + valType: 'color', + editType: 'modebar', + }, + activecolor: { + valType: 'color', + editType: 'modebar', + }, + uirevision: { + valType: 'any', + editType: 'none', + }, + add: { + valType: 'string', + arrayOk: true, + dflt: '', + editType: 'modebar', + }, + remove: { + valType: 'string', + arrayOk: true, + dflt: '', + editType: 'modebar', + } +}; + +},{"./constants":216}],215:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -33923,6 +43770,7 @@ modeBarButtons.editInChartStudio = { modeBarButtons.zoom2d = { name: 'zoom2d', + _cat: 'zoom', title: function(gd) { return _(gd, 'Zoom'); }, attr: 'dragmode', val: 'zoom', @@ -33932,6 +43780,7 @@ modeBarButtons.zoom2d = { modeBarButtons.pan2d = { name: 'pan2d', + _cat: 'pan', title: function(gd) { return _(gd, 'Pan'); }, attr: 'dragmode', val: 'pan', @@ -33941,6 +43790,7 @@ modeBarButtons.pan2d = { modeBarButtons.select2d = { name: 'select2d', + _cat: 'select', title: function(gd) { return _(gd, 'Box Select'); }, attr: 'dragmode', val: 'select', @@ -33950,6 +43800,7 @@ modeBarButtons.select2d = { modeBarButtons.lasso2d = { name: 'lasso2d', + _cat: 'lasso', title: function(gd) { return _(gd, 'Lasso Select'); }, attr: 'dragmode', val: 'lasso', @@ -34011,6 +43862,7 @@ modeBarButtons.eraseshape = { modeBarButtons.zoomIn2d = { name: 'zoomIn2d', + _cat: 'zoomin', title: function(gd) { return _(gd, 'Zoom in'); }, attr: 'zoom', val: 'in', @@ -34020,6 +43872,7 @@ modeBarButtons.zoomIn2d = { modeBarButtons.zoomOut2d = { name: 'zoomOut2d', + _cat: 'zoomout', title: function(gd) { return _(gd, 'Zoom out'); }, attr: 'zoom', val: 'out', @@ -34029,6 +43882,7 @@ modeBarButtons.zoomOut2d = { modeBarButtons.autoScale2d = { name: 'autoScale2d', + _cat: 'autoscale', title: function(gd) { return _(gd, 'Autoscale'); }, attr: 'zoom', val: 'auto', @@ -34038,6 +43892,7 @@ modeBarButtons.autoScale2d = { modeBarButtons.resetScale2d = { name: 'resetScale2d', + _cat: 'resetscale', title: function(gd) { return _(gd, 'Reset axes'); }, attr: 'zoom', val: 'reset', @@ -34047,6 +43902,7 @@ modeBarButtons.resetScale2d = { modeBarButtons.hoverClosestCartesian = { name: 'hoverClosestCartesian', + _cat: 'hoverclosest', title: function(gd) { return _(gd, 'Show closest data on hover'); }, attr: 'hovermode', val: 'closest', @@ -34057,6 +43913,7 @@ modeBarButtons.hoverClosestCartesian = { modeBarButtons.hoverCompareCartesian = { name: 'hoverCompareCartesian', + _cat: 'hoverCompare', title: function(gd) { return _(gd, 'Compare data on hover'); }, attr: 'hovermode', val: function(gd) { @@ -34140,6 +43997,7 @@ function handleCartesian(gd, ev) { modeBarButtons.zoom3d = { name: 'zoom3d', + _cat: 'zoom', title: function(gd) { return _(gd, 'Zoom'); }, attr: 'scene.dragmode', val: 'zoom', @@ -34149,6 +44007,7 @@ modeBarButtons.zoom3d = { modeBarButtons.pan3d = { name: 'pan3d', + _cat: 'pan', title: function(gd) { return _(gd, 'Pan'); }, attr: 'scene.dragmode', val: 'pan', @@ -34196,6 +44055,7 @@ function handleDrag3d(gd, ev) { modeBarButtons.resetCameraDefault3d = { name: 'resetCameraDefault3d', + _cat: 'resetCameraDefault', title: function(gd) { return _(gd, 'Reset camera to default'); }, attr: 'resetDefault', icon: Icons.home, @@ -34204,6 +44064,7 @@ modeBarButtons.resetCameraDefault3d = { modeBarButtons.resetCameraLastSave3d = { name: 'resetCameraLastSave3d', + _cat: 'resetCameraLastSave', title: function(gd) { return _(gd, 'Reset camera to last save'); }, attr: 'resetLastSave', icon: Icons.movie, @@ -34253,6 +44114,7 @@ function handleCamera3d(gd, ev) { modeBarButtons.hoverClosest3d = { name: 'hoverClosest3d', + _cat: 'hoverclosest', title: function(gd) { return _(gd, 'Toggle show closest data on hover'); }, attr: 'hovermode', val: null, @@ -34307,6 +44169,7 @@ function handleHover3d(gd, ev) { modeBarButtons.zoomInGeo = { name: 'zoomInGeo', + _cat: 'zoomin', title: function(gd) { return _(gd, 'Zoom in'); }, attr: 'zoom', val: 'in', @@ -34316,6 +44179,7 @@ modeBarButtons.zoomInGeo = { modeBarButtons.zoomOutGeo = { name: 'zoomOutGeo', + _cat: 'zoomout', title: function(gd) { return _(gd, 'Zoom out'); }, attr: 'zoom', val: 'out', @@ -34325,6 +44189,7 @@ modeBarButtons.zoomOutGeo = { modeBarButtons.resetGeo = { name: 'resetGeo', + _cat: 'reset', title: function(gd) { return _(gd, 'Reset'); }, attr: 'reset', val: null, @@ -34334,6 +44199,7 @@ modeBarButtons.resetGeo = { modeBarButtons.hoverClosestGeo = { name: 'hoverClosestGeo', + _cat: 'hoverclosest', title: function(gd) { return _(gd, 'Toggle show closest data on hover'); }, attr: 'hovermode', val: null, @@ -34369,6 +44235,7 @@ function handleGeo(gd, ev) { modeBarButtons.hoverClosestGl2d = { name: 'hoverClosestGl2d', + _cat: 'hoverclosest', title: function(gd) { return _(gd, 'Toggle show closest data on hover'); }, attr: 'hovermode', val: null, @@ -34380,6 +44247,7 @@ modeBarButtons.hoverClosestGl2d = { modeBarButtons.hoverClosestPie = { name: 'hoverClosestPie', + _cat: 'hoverclosest', title: function(gd) { return _(gd, 'Toggle show closest data on hover'); }, attr: 'hovermode', val: 'closest', @@ -34492,6 +44360,7 @@ function setSpikelineVisibility(gd) { modeBarButtons.resetViewMapbox = { name: 'resetViewMapbox', + _cat: 'resetView', title: function(gd) { return _(gd, 'Reset view'); }, attr: 'reset', icon: Icons.home, @@ -34502,6 +44371,7 @@ modeBarButtons.resetViewMapbox = { modeBarButtons.zoomInMapbox = { name: 'zoomInMapbox', + _cat: 'zoomin', title: function(gd) { return _(gd, 'Zoom in'); }, attr: 'zoom', val: 'in', @@ -34511,6 +44381,7 @@ modeBarButtons.zoomInMapbox = { modeBarButtons.zoomOutMapbox = { name: 'zoomOutMapbox', + _cat: 'zoomout', title: function(gd) { return _(gd, 'Zoom out'); }, attr: 'zoom', val: 'out', @@ -34556,30 +44427,89 @@ function resetView(gd, subplotType) { Registry.call('_guiRelayout', gd, aObj); } -},{"../../fonts/ploticon":216,"../../lib":233,"../../plots/cartesian/axis_ids":282,"../../plots/plots":313,"../../registry":326,"../shapes/draw":186}],165:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../fonts/ploticon":268,"../../lib":285,"../../plots/cartesian/axis_ids":334,"../../plots/plots":366,"../../registry":373,"../shapes/draw":239}],216:[function(_dereq_,module,exports){ 'use strict'; -exports.manage = _dereq_('./manage'); +var modeBarButtons = _dereq_('./buttons'); +var buttonList = Object.keys(modeBarButtons); -},{"./manage":166}],166:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +var DRAW_MODES = [ + 'drawline', + 'drawopenpath', + 'drawclosedpath', + 'drawcircle', + 'drawrect', + 'eraseshape' +]; +var backButtons = [ + 'v1hovermode', + 'hoverclosest', + 'hovercompare', + 'togglehover', + 'togglespikelines' +].concat(DRAW_MODES); +var foreButtons = []; +var addToForeButtons = function(b) { + if(backButtons.indexOf(b._cat || b.name) !== -1) return; + // for convenience add lowercase shotname e.g. zoomin as well fullname zoomInGeo + var name = b.name; + var _cat = (b._cat || b.name).toLowerCase(); + if(foreButtons.indexOf(name) === -1) foreButtons.push(name); + if(foreButtons.indexOf(_cat) === -1) foreButtons.push(_cat); +}; +buttonList.forEach(function(k) { + addToForeButtons(modeBarButtons[k]); +}); +foreButtons.sort(); + +module.exports = { + DRAW_MODES: DRAW_MODES, + backButtons: backButtons, + foreButtons: foreButtons +}; + +},{"./buttons":215}],217:[function(_dereq_,module,exports){ +'use strict'; + +var Lib = _dereq_('../../lib'); +var Color = _dereq_('../color'); +var Template = _dereq_('../../plot_api/plot_template'); +var attributes = _dereq_('./attributes'); + +module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) { + var containerIn = layoutIn.modebar || {}; + var containerOut = Template.newContainer(layoutOut, 'modebar'); + + function coerce(attr, dflt) { + return Lib.coerce(containerIn, containerOut, attributes, attr, dflt); + } + + coerce('orientation'); + coerce('bgcolor', Color.addOpacity(layoutOut.paper_bgcolor, 0.5)); + var defaultColor = Color.contrast(Color.rgb(layoutOut.modebar.bgcolor)); + coerce('color', Color.addOpacity(defaultColor, 0.3)); + coerce('activecolor', Color.addOpacity(defaultColor, 0.7)); + coerce('uirevision', layoutOut.uirevision); + coerce('add'); + coerce('remove'); +}; + +},{"../../lib":285,"../../plot_api/plot_template":320,"../color":155,"./attributes":214}],218:[function(_dereq_,module,exports){ +'use strict'; + +module.exports = { + moduleType: 'component', + name: 'modebar', + + layoutAttributes: _dereq_('./attributes'), + supplyLayoutDefaults: _dereq_('./defaults'), + + manage: _dereq_('./manage') +}; + +},{"./attributes":214,"./defaults":217,"./manage":219}],219:[function(_dereq_,module,exports){ 'use strict'; var axisIds = _dereq_('../../plots/cartesian/axis_ids'); @@ -34589,6 +44519,7 @@ var isUnifiedHover = _dereq_('../fx/helpers').isUnifiedHover; var createModeBar = _dereq_('./modebar'); var modeBarButtons = _dereq_('./buttons'); +var DRAW_MODES = _dereq_('./constants').DRAW_MODES; /** * ModeBar wrapper around 'create' and 'update', @@ -34640,22 +44571,47 @@ module.exports = function manageModeBar(gd) { else fullLayout._modeBar = createModeBar(gd, buttonGroups); }; -var DRAW_MODES = [ - 'drawline', - 'drawopenpath', - 'drawclosedpath', - 'drawcircle', - 'drawrect', - 'eraseshape' -]; - // logic behind which buttons are displayed by default function getButtonGroups(gd) { var fullLayout = gd._fullLayout; var fullData = gd._fullData; var context = gd._context; - var buttonsToRemove = context.modeBarButtonsToRemove; - var buttonsToAdd = context.modeBarButtonsToAdd; + + function match(name, B) { + if(typeof B === 'string') { + if(B.toLowerCase() === name.toLowerCase()) return true; + } else { + var v0 = B.name; + var v1 = (B._cat || B.name); + + if(v0 === name || v1 === name.toLowerCase()) return true; + } + return false; + } + + var layoutAdd = fullLayout.modebar.add; + if(typeof layoutAdd === 'string') layoutAdd = [layoutAdd]; + + var layoutRemove = fullLayout.modebar.remove; + if(typeof layoutRemove === 'string') layoutRemove = [layoutRemove]; + + var buttonsToAdd = context.modeBarButtonsToAdd.concat( + layoutAdd.filter(function(e) { + for(var i = 0; i < context.modeBarButtonsToRemove.length; i++) { + if(match(e, context.modeBarButtonsToRemove[i])) return false; + } + return true; + }) + ); + + var buttonsToRemove = context.modeBarButtonsToRemove.concat( + layoutRemove.filter(function(e) { + for(var i = 0; i < context.modeBarButtonsToAdd.length; i++) { + if(match(e, context.modeBarButtonsToAdd[i])) return false; + } + return true; + }) + ); var hasCartesian = fullLayout._has('cartesian'); var hasGL3D = fullLayout._has('gl3d'); @@ -34678,9 +44634,20 @@ function getButtonGroups(gd) { var out = []; for(var i = 0; i < newGroup.length; i++) { - var button = newGroup[i]; - if(buttonsToRemove.indexOf(button) !== -1) continue; - out.push(modeBarButtons[button]); + var name = newGroup[i]; + var B = modeBarButtons[name]; + var v0 = B.name.toLowerCase(); + var v1 = (B._cat || B.name).toLowerCase(); + var found = false; + for(var q = 0; q < buttonsToRemove.length; q++) { + var t = buttonsToRemove[q].toLowerCase(); + if(t === v0 || t === v1) { + found = true; + break; + } + } + if(found) continue; + out.push(modeBarButtons[name]); } groups.push(out); @@ -34752,19 +44719,50 @@ function getButtonGroups(gd) { dragModeGroup.push('select2d', 'lasso2d'); } - // accept pre-defined buttons as string + var enabledHoverGroup = []; + var enableHover = function(a) { + // return if already added + if(enabledHoverGroup.indexOf(a) !== -1) return; + // should be in hoverGroup + if(hoverGroup.indexOf(a) !== -1) { + enabledHoverGroup.push(a); + } + }; if(Array.isArray(buttonsToAdd)) { var newList = []; for(var i = 0; i < buttonsToAdd.length; i++) { var b = buttonsToAdd[i]; if(typeof b === 'string') { + b = b.toLowerCase(); + if(DRAW_MODES.indexOf(b) !== -1) { + // accept pre-defined drag modes i.e. shape drawing features as string if( fullLayout._has('mapbox') || // draw shapes in paper coordinate (could be improved in future to support data coordinate, when there is no pitch) fullLayout._has('cartesian') // draw shapes in data coordinate ) { dragModeGroup.push(b); } + } else if(b === 'togglespikelines') { + enableHover('toggleSpikelines'); + } else if(b === 'togglehover') { + enableHover('toggleHover'); + } else if(b === 'hovercompare') { + enableHover('hoverCompareCartesian'); + } else if(b === 'hoverclosest') { + enableHover('hoverClosestCartesian'); + enableHover('hoverClosestGeo'); + enableHover('hoverClosest3d'); + enableHover('hoverClosestGl2d'); + enableHover('hoverClosestPie'); + } else if(b === 'v1hovermode') { + enableHover('toggleHover'); + enableHover('hoverClosestCartesian'); + enableHover('hoverCompareCartesian'); + enableHover('hoverClosestGeo'); + enableHover('hoverClosest3d'); + enableHover('hoverClosestGl2d'); + enableHover('hoverClosestPie'); } } else newList.push(b); } @@ -34773,7 +44771,7 @@ function getButtonGroups(gd) { addGroup(dragModeGroup); addGroup(zoomGroup.concat(resetGroup)); - addGroup(hoverGroup); + addGroup(enabledHoverGroup); return appendButtonsToGroups(groups, buttonsToAdd); } @@ -34866,19 +44864,10 @@ function fillCustomButton(customButtons) { return customButtons; } -},{"../../plots/cartesian/axis_ids":282,"../../registry":326,"../../traces/scatter/subtypes":472,"../fx/helpers":141,"./buttons":164,"./modebar":167}],167:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../plots/cartesian/axis_ids":334,"../../registry":373,"../../traces/scatter/subtypes":519,"../fx/helpers":191,"./buttons":215,"./constants":216,"./modebar":220}],220:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); @@ -35212,15 +45201,7 @@ function createModeBar(gd, buttons) { module.exports = createModeBar; -},{"../../fonts/ploticon":216,"../../lib":233,"d3":21,"fast-isnumeric":23}],168:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../fonts/ploticon":268,"../../lib":285,"@plotly/d3":20,"fast-isnumeric":31}],221:[function(_dereq_,module,exports){ 'use strict'; var fontAttrs = _dereq_('../../plots/font_attributes'); @@ -35230,51 +45211,38 @@ var templatedArray = _dereq_('../../plot_api/plot_template').templatedArray; var buttonAttrs = templatedArray('button', { visible: { valType: 'boolean', - dflt: true, editType: 'plot', - }, step: { valType: 'enumerated', - values: ['month', 'year', 'day', 'hour', 'minute', 'second', 'all'], dflt: 'month', editType: 'plot', - }, stepmode: { valType: 'enumerated', - values: ['backward', 'todate'], dflt: 'backward', editType: 'plot', - }, count: { valType: 'number', - min: 0, dflt: 1, editType: 'plot', - }, label: { valType: 'string', - editType: 'plot', - }, editType: 'plot', - }); module.exports = { visible: { valType: 'boolean', - editType: 'plot', - }, buttons: buttonAttrs, @@ -35283,80 +45251,55 @@ module.exports = { valType: 'number', min: -2, max: 3, - editType: 'plot', - }, xanchor: { valType: 'enumerated', values: ['auto', 'left', 'center', 'right'], dflt: 'left', - editType: 'plot', - }, y: { valType: 'number', min: -2, max: 3, - editType: 'plot', - }, yanchor: { valType: 'enumerated', values: ['auto', 'top', 'middle', 'bottom'], dflt: 'bottom', - editType: 'plot', - }, font: fontAttrs({ editType: 'plot', - }), bgcolor: { valType: 'color', dflt: colorAttrs.lightLine, - editType: 'plot', - }, activecolor: { valType: 'color', - editType: 'plot', - }, bordercolor: { valType: 'color', dflt: colorAttrs.defaultLine, - editType: 'plot', - }, borderwidth: { valType: 'number', min: 0, dflt: 0, - editType: 'plot', - }, editType: 'plot' }; -},{"../../plot_api/plot_template":268,"../../plots/font_attributes":307,"../color/attributes":104}],169:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plot_api/plot_template":320,"../../plots/font_attributes":359,"../color/attributes":154}],222:[function(_dereq_,module,exports){ 'use strict'; @@ -35377,15 +45320,7 @@ module.exports = { darkAmount: 10 }; -},{}],170:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],223:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -35469,18 +45404,10 @@ function getPosDflt(containerOut, layout, counterAxes) { return [containerOut.domain[0], posY + constants.yPad]; } -},{"../../lib":233,"../../plot_api/plot_template":268,"../../plots/array_container_defaults":274,"../color":105,"./attributes":168,"./constants":169}],171:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plot_api/plot_template":320,"../../plots/array_container_defaults":326,"../color":155,"./attributes":221,"./constants":222}],224:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Registry = _dereq_('../../registry'); var Plots = _dereq_('../../plots/plots'); @@ -35724,19 +45651,10 @@ function reposition(gd, buttons, opts, axName, selector) { selector.attr('transform', strTranslate(lx, ly)); } -},{"../../constants/alignment":207,"../../lib":233,"../../lib/svg_text_utils":255,"../../plots/cartesian/axis_ids":282,"../../plots/plots":313,"../../registry":326,"../color":105,"../drawing":127,"./constants":169,"./get_update_object":172,"d3":21}],172:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../constants/alignment":260,"../../lib":285,"../../lib/svg_text_utils":307,"../../plots/cartesian/axis_ids":334,"../../plots/plots":366,"../../registry":373,"../color":155,"../drawing":177,"./constants":222,"./get_update_object":225,"@plotly/d3":20}],225:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); module.exports = function getUpdateObject(axisLayout, buttonLayout) { var axName = axisLayout._name; @@ -35778,15 +45696,7 @@ function getXRange(axisLayout, buttonLayout) { return [range0, range1]; } -},{"d3":21}],173:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"@plotly/d3":20}],226:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -35805,15 +45715,7 @@ module.exports = { draw: _dereq_('./draw') }; -},{"./attributes":168,"./defaults":170,"./draw":171}],174:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"./attributes":221,"./defaults":223,"./draw":224}],227:[function(_dereq_,module,exports){ 'use strict'; var colorAttributes = _dereq_('../color/attributes'); @@ -35822,72 +45724,50 @@ module.exports = { bgcolor: { valType: 'color', dflt: colorAttributes.background, - editType: 'plot', - }, bordercolor: { valType: 'color', dflt: colorAttributes.defaultLine, - editType: 'plot', - }, borderwidth: { valType: 'integer', dflt: 0, min: 0, - editType: 'plot', - }, autorange: { valType: 'boolean', dflt: true, - editType: 'calc', impliedEdits: {'range[0]': undefined, 'range[1]': undefined}, - }, range: { valType: 'info_array', - items: [ {valType: 'any', editType: 'calc', impliedEdits: {'^autorange': false}}, {valType: 'any', editType: 'calc', impliedEdits: {'^autorange': false}} ], editType: 'calc', impliedEdits: {'autorange': false}, - }, thickness: { valType: 'number', dflt: 0.15, min: 0, max: 1, - editType: 'plot', - }, visible: { valType: 'boolean', dflt: true, - editType: 'calc', - }, editType: 'calc' }; -},{"../color/attributes":104}],175:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../color/attributes":154}],228:[function(_dereq_,module,exports){ 'use strict'; var listAxes = _dereq_('../../plots/cartesian/axis_ids').list; @@ -35913,15 +45793,7 @@ module.exports = function calcAutorange(gd) { } }; -},{"../../plots/cartesian/autorange":278,"../../plots/cartesian/axis_ids":282,"./constants":176}],176:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian/autorange":330,"../../plots/cartesian/axis_ids":334,"./constants":229}],229:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -35969,15 +45841,7 @@ module.exports = { extraPad: 15 }; -},{}],177:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],230:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -36055,18 +45919,10 @@ module.exports = function handleDefaults(layoutIn, layoutOut, axName) { containerOut._input = containerIn; }; -},{"../../lib":233,"../../plot_api/plot_template":268,"../../plots/cartesian/axis_ids":282,"./attributes":174,"./oppaxis_attributes":181}],178:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plot_api/plot_template":320,"../../plots/cartesian/axis_ids":334,"./attributes":227,"./oppaxis_attributes":234}],231:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Registry = _dereq_('../../registry'); var Plots = _dereq_('../../plots/plots'); @@ -36699,15 +46555,7 @@ function drawGrabbers(rangeSlider, gd, axisOpts, opts) { grabAreaMax.attr('height', opts._height); } -},{"../../lib":233,"../../lib/setcursor":253,"../../plots/cartesian":292,"../../plots/cartesian/axis_ids":282,"../../plots/plots":313,"../../registry":326,"../color":105,"../dragelement":124,"../drawing":127,"../titles":200,"./constants":176,"d3":21}],179:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../lib/setcursor":305,"../../plots/cartesian":344,"../../plots/cartesian/axis_ids":334,"../../plots/plots":366,"../../registry":373,"../color":155,"../dragelement":174,"../drawing":177,"../titles":253,"./constants":229,"@plotly/d3":20}],232:[function(_dereq_,module,exports){ 'use strict'; var axisIDs = _dereq_('../../plots/cartesian/axis_ids'); @@ -36774,15 +46622,7 @@ exports.autoMarginOpts = function(gd, ax) { }; }; -},{"../../constants/alignment":207,"../../lib/svg_text_utils":255,"../../plots/cartesian/axis_ids":282,"./constants":176}],180:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/alignment":260,"../../lib/svg_text_utils":307,"../../plots/cartesian/axis_ids":334,"./constants":229}],233:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -36813,15 +46653,7 @@ module.exports = { autoMarginOpts: helpers.autoMarginOpts }; -},{"../../lib":233,"./attributes":174,"./calc_autorange":175,"./defaults":177,"./draw":178,"./helpers":179,"./oppaxis_attributes":181}],181:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"./attributes":227,"./calc_autorange":228,"./defaults":230,"./draw":231,"./helpers":232,"./oppaxis_attributes":234}],234:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -36834,32 +46666,20 @@ module.exports = { valType: 'enumerated', values: ['auto', 'fixed', 'match'], dflt: 'match', - editType: 'calc', - }, range: { valType: 'info_array', - items: [ {valType: 'any', editType: 'plot'}, {valType: 'any', editType: 'plot'} ], editType: 'plot', - }, editType: 'calc' }; -},{}],182:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],235:[function(_dereq_,module,exports){ 'use strict'; var annAttrs = _dereq_('../annotations/attributes'); @@ -36872,94 +46692,68 @@ var axisPlaceableObjs = _dereq_('../../constants/axis_placeable_objects'); module.exports = templatedArray('shape', { visible: { valType: 'boolean', - dflt: true, editType: 'calc+arraydraw', - }, type: { valType: 'enumerated', values: ['circle', 'rect', 'path', 'line'], - editType: 'calc+arraydraw', - }, layer: { valType: 'enumerated', values: ['below', 'above'], dflt: 'above', - editType: 'arraydraw', - }, xref: extendFlat({}, annAttrs.xref, { - }), xsizemode: { valType: 'enumerated', values: ['scaled', 'pixel'], dflt: 'scaled', - editType: 'calc+arraydraw', - }, xanchor: { valType: 'any', - editType: 'calc+arraydraw', - }, x0: { valType: 'any', - editType: 'calc+arraydraw', - }, x1: { valType: 'any', - editType: 'calc+arraydraw', - }, yref: extendFlat({}, annAttrs.yref, { - }), ysizemode: { valType: 'enumerated', values: ['scaled', 'pixel'], dflt: 'scaled', - editType: 'calc+arraydraw', - }, yanchor: { valType: 'any', - editType: 'calc+arraydraw', - }, y0: { valType: 'any', - editType: 'calc+arraydraw', - }, y1: { valType: 'any', - editType: 'calc+arraydraw', - }, path: { valType: 'string', - editType: 'calc+arraydraw', - }, opacity: { @@ -36967,52 +46761,35 @@ module.exports = templatedArray('shape', { min: 0, max: 1, dflt: 1, - editType: 'arraydraw', - }, line: { color: extendFlat({}, scatterLineAttrs.color, {editType: 'arraydraw'}), width: extendFlat({}, scatterLineAttrs.width, {editType: 'calc+arraydraw'}), dash: extendFlat({}, dash, {editType: 'arraydraw'}), - editType: 'calc+arraydraw' }, fillcolor: { valType: 'color', dflt: 'rgba(0,0,0,0)', - editType: 'arraydraw', - }, fillrule: { valType: 'enumerated', values: ['evenodd', 'nonzero'], dflt: 'evenodd', - editType: 'arraydraw', - }, editable: { valType: 'boolean', - dflt: false, editType: 'calc+arraydraw', - }, editType: 'arraydraw' }); -},{"../../constants/axis_placeable_objects":208,"../../lib/extend":227,"../../plot_api/plot_template":268,"../../traces/scatter/attributes":447,"../annotations/attributes":90,"../drawing/attributes":126}],183:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/axis_placeable_objects":261,"../../lib/extend":279,"../../plot_api/plot_template":320,"../../traces/scatter/attributes":494,"../annotations/attributes":138,"../drawing/attributes":176}],236:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -37124,16 +46901,7 @@ function shapeBounds(ax, v0, v1, path, paramsToUse) { if(max >= min) return [min, max]; } -},{"../../lib":233,"../../plots/cartesian/axes":279,"./constants":184,"./helpers":193}],184:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../plots/cartesian/axes":331,"./constants":237,"./helpers":246}],237:[function(_dereq_,module,exports){ 'use strict'; @@ -37188,16 +46956,7 @@ module.exports = { } }; -},{}],185:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],238:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -37272,7 +47031,7 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) { var dflt0 = 0.25; var dflt1 = 0.75; - // hack until V2.0 when log has regular range behavior - make it look like other + // hack until V3.0 when log has regular range behavior - make it look like other // ranges to send to coerce, then put it back after // this is all to give reasonable default position behavior on log axes, which is // a pretty unimportant edge case so we could just ignore this. @@ -37319,16 +47078,7 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) { } } -},{"../../lib":233,"../../plots/array_container_defaults":274,"../../plots/cartesian/axes":279,"./attributes":182,"./helpers":193}],186:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../plots/array_container_defaults":326,"../../plots/cartesian/axes":331,"./attributes":235,"./helpers":246}],239:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -38093,15 +47843,7 @@ function eraseActiveShape(gd) { } } -},{"../../lib":233,"../../lib/setcursor":253,"../../plot_api/plot_template":268,"../../plots/cartesian/axes":279,"../../plots/cartesian/handle_outline":289,"../../registry":326,"../color":105,"../dragelement":124,"../drawing":127,"./constants":184,"./draw_newshape/display_outlines":190,"./draw_newshape/helpers":191,"./helpers":193}],187:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../lib/setcursor":305,"../../plot_api/plot_template":320,"../../plots/cartesian/axes":331,"../../plots/cartesian/handle_outline":341,"../../registry":373,"../color":155,"../dragelement":174,"../drawing":177,"./constants":237,"./draw_newshape/display_outlines":243,"./draw_newshape/helpers":244,"./helpers":246}],240:[function(_dereq_,module,exports){ 'use strict'; var dash = _dereq_('../../drawing/attributes').dash; @@ -38113,63 +47855,48 @@ module.exports = { color: { valType: 'color', editType: 'none', - - }, width: { valType: 'number', min: 0, dflt: 4, - editType: 'none', - }, dash: extendFlat({}, dash, { dflt: 'solid', editType: 'none' }), - editType: 'none' }, fillcolor: { valType: 'color', dflt: 'rgba(0,0,0,0)', - editType: 'none', - }, fillrule: { valType: 'enumerated', values: ['evenodd', 'nonzero'], dflt: 'evenodd', - editType: 'none', - }, opacity: { valType: 'number', min: 0, max: 1, dflt: 1, - editType: 'none', - }, layer: { valType: 'enumerated', values: ['below', 'above'], dflt: 'above', - editType: 'none', - }, drawdirection: { valType: 'enumerated', - values: ['ortho', 'horizontal', 'vertical', 'diagonal'], dflt: 'diagonal', editType: 'none', - }, editType: 'none' @@ -38179,32 +47906,20 @@ module.exports = { fillcolor: { valType: 'color', dflt: 'rgb(255,0,255)', - editType: 'none', - }, opacity: { valType: 'number', min: 0, max: 1, dflt: 0.5, - editType: 'none', - }, editType: 'none' } }; -},{"../../../lib/extend":227,"../../drawing/attributes":126}],188:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../../lib/extend":279,"../../drawing/attributes":176}],241:[function(_dereq_,module,exports){ 'use strict'; var CIRCLE_SIDES = 32; // should be divisible by 4 @@ -38220,16 +47935,7 @@ module.exports = { SQRT2: Math.sqrt(2) }; -},{}],189:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],242:[function(_dereq_,module,exports){ 'use strict'; var Color = _dereq_('../../color'); @@ -38252,16 +47958,7 @@ module.exports = function supplyDrawNewShapeDefaults(layoutIn, layoutOut, coerce coerce('activeshape.opacity'); }; -},{"../../color":105}],190:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../color":155}],243:[function(_dereq_,module,exports){ 'use strict'; var dragElement = _dereq_('../../dragelement'); @@ -38547,16 +48244,7 @@ function recordPositions(polygonsOut, polygonsIn) { return polygonsOut; } -},{"../../../plots/cartesian/handle_outline":289,"../../../registry":326,"../../dragelement":124,"../../dragelement/helpers":123,"./constants":188,"./helpers":191,"./newshapes":192}],191:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../../plots/cartesian/handle_outline":341,"../../../registry":373,"../../dragelement":174,"../../dragelement/helpers":173,"./constants":241,"./helpers":244,"./newshapes":245}],244:[function(_dereq_,module,exports){ 'use strict'; var parseSvgPath = _dereq_('parse-svg-path'); @@ -38885,16 +48573,7 @@ exports.ellipseOver = function(pos) { }; }; -},{"../../../plots/cartesian/helpers":290,"./constants":188,"parse-svg-path":77}],192:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../../plots/cartesian/helpers":342,"./constants":241,"parse-svg-path":72}],245:[function(_dereq_,module,exports){ 'use strict'; var dragHelpers = _dereq_('../../dragelement/helpers'); @@ -39144,16 +48823,7 @@ function fixDatesForPaths(polygons, xaxis, yaxis) { return polygons; } -},{"../../../plots/cartesian/handle_outline":289,"../../../plots/cartesian/helpers":290,"../../dragelement/helpers":123,"./constants":188,"./helpers":191}],193:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../../plots/cartesian/handle_outline":341,"../../../plots/cartesian/helpers":342,"../../dragelement/helpers":173,"./constants":241,"./helpers":244}],246:[function(_dereq_,module,exports){ 'use strict'; var constants = _dereq_('./constants'); @@ -39165,7 +48835,7 @@ var Lib = _dereq_('../../lib'); // so these have to be specified in terms of the category serial numbers, // but can take fractional values. Other axis types we specify position based on // the actual data values. -// TODO: in V2.0 (when log axis ranges are in data units) range and shape position +// TODO: in V3.0 (when log axis ranges are in data units) range and shape position // will be identical, so rangeToShapePosition and shapePositionToRange can be // removed entirely. @@ -39302,16 +48972,7 @@ exports.makeOptionsAndPlotinfo = function(gd, index) { }; }; -},{"../../lib":233,"./constants":184}],194:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"./constants":237}],247:[function(_dereq_,module,exports){ 'use strict'; var drawModule = _dereq_('./draw'); @@ -39330,15 +48991,7 @@ module.exports = { drawOne: drawModule.drawOne }; -},{"../../plots/cartesian/include_components":291,"./attributes":182,"./calc_autorange":183,"./defaults":185,"./draw":186,"./draw_newshape/defaults":189}],195:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian/include_components":343,"./attributes":235,"./calc_autorange":236,"./defaults":238,"./draw":239,"./draw_newshape/defaults":242}],248:[function(_dereq_,module,exports){ 'use strict'; var fontAttrs = _dereq_('../../plots/font_attributes'); @@ -39352,60 +49005,44 @@ var constants = _dereq_('./constants'); var stepsAttrs = templatedArray('step', { visible: { valType: 'boolean', - dflt: true, - }, method: { valType: 'enumerated', values: ['restyle', 'relayout', 'animate', 'update', 'skip'], dflt: 'restyle', - - }, args: { valType: 'info_array', - freeLength: true, items: [ { valType: 'any' }, { valType: 'any' }, { valType: 'any' } ], - }, label: { valType: 'string', - - }, value: { valType: 'string', - - }, execute: { valType: 'boolean', - dflt: true, - } }); module.exports = overrideAll(templatedArray('slider', { visible: { valType: 'boolean', - dflt: true, - }, active: { valType: 'number', - min: 0, dflt: 0, - }, steps: stepsAttrs, @@ -39413,176 +49050,122 @@ module.exports = overrideAll(templatedArray('slider', { lenmode: { valType: 'enumerated', values: ['fraction', 'pixels'], - dflt: 'fraction', - }, len: { valType: 'number', min: 0, dflt: 1, - - }, x: { valType: 'number', min: -2, max: 3, dflt: 0, - - }, pad: extendDeepAll(padAttrs({editType: 'arraydraw'}), { - }, {t: {dflt: 20}}), xanchor: { valType: 'enumerated', values: ['auto', 'left', 'center', 'right'], dflt: 'left', - - }, y: { valType: 'number', min: -2, max: 3, dflt: 0, - - }, yanchor: { valType: 'enumerated', values: ['auto', 'top', 'middle', 'bottom'], dflt: 'top', - - }, transition: { duration: { valType: 'number', - min: 0, dflt: 150, - }, easing: { valType: 'enumerated', values: animationAttrs.transition.easing.values, - dflt: 'cubic-in-out', - } }, currentvalue: { visible: { valType: 'boolean', - dflt: true, - }, xanchor: { valType: 'enumerated', values: ['left', 'center', 'right'], dflt: 'left', - - }, offset: { valType: 'number', dflt: 10, - - }, prefix: { valType: 'string', - - }, suffix: { valType: 'string', - - }, font: fontAttrs({ - }) }, font: fontAttrs({ - }), activebgcolor: { valType: 'color', - dflt: constants.gripBgActiveColor, - }, bgcolor: { valType: 'color', - dflt: constants.railBgColor, - }, bordercolor: { valType: 'color', dflt: constants.railBorderColor, - - }, borderwidth: { valType: 'number', min: 0, dflt: constants.railBorderWidth, - - }, ticklen: { valType: 'number', min: 0, dflt: constants.tickLength, - - }, tickcolor: { valType: 'color', dflt: constants.tickColor, - - }, tickwidth: { valType: 'number', min: 0, dflt: 1, - - }, minorticklen: { valType: 'number', min: 0, dflt: constants.minorTickLength, - - } }), 'arraydraw', 'from-root'); -},{"../../lib/extend":227,"../../plot_api/edit_types":261,"../../plot_api/plot_template":268,"../../plots/animation_attributes":273,"../../plots/font_attributes":307,"../../plots/pad_attributes":312,"./constants":196}],196:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib/extend":279,"../../plot_api/edit_types":313,"../../plot_api/plot_template":320,"../../plots/animation_attributes":325,"../../plots/font_attributes":359,"../../plots/pad_attributes":365,"./constants":249}],249:[function(_dereq_,module,exports){ 'use strict'; @@ -39667,15 +49250,7 @@ module.exports = { currentValueInset: 0, }; -},{}],197:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],250:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -39782,18 +49357,10 @@ function stepDefaults(valueIn, valueOut) { } } -},{"../../lib":233,"../../plots/array_container_defaults":274,"./attributes":195,"./constants":196}],198:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/array_container_defaults":326,"./attributes":248,"./constants":249}],251:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Plots = _dereq_('../../plots/plots'); var Color = _dereq_('../color'); @@ -40413,15 +49980,7 @@ function drawRail(sliderGroup, sliderOpts) { ); } -},{"../../constants/alignment":207,"../../lib":233,"../../lib/svg_text_utils":255,"../../plot_api/plot_template":268,"../../plots/plots":313,"../color":105,"../drawing":127,"./constants":196,"d3":21}],199:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/alignment":260,"../../lib":285,"../../lib/svg_text_utils":307,"../../plot_api/plot_template":320,"../../plots/plots":366,"../color":155,"../drawing":177,"./constants":249,"@plotly/d3":20}],252:[function(_dereq_,module,exports){ 'use strict'; var constants = _dereq_('./constants'); @@ -40436,19 +49995,10 @@ module.exports = { draw: _dereq_('./draw') }; -},{"./attributes":195,"./constants":196,"./defaults":197,"./draw":198}],200:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"./attributes":248,"./constants":249,"./defaults":250,"./draw":251}],253:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var isNumeric = _dereq_('fast-isnumeric'); var Plots = _dereq_('../../plots/plots'); @@ -40704,15 +50254,7 @@ module.exports = { draw: draw }; -},{"../../constants/alignment":207,"../../constants/interactions":211,"../../lib":233,"../../lib/svg_text_utils":255,"../../plots/plots":313,"../../registry":326,"../color":105,"../drawing":127,"d3":21,"fast-isnumeric":23}],201:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/alignment":260,"../../constants/interactions":264,"../../lib":285,"../../lib/svg_text_utils":307,"../../plots/plots":366,"../../registry":373,"../color":155,"../drawing":177,"@plotly/d3":20,"fast-isnumeric":31}],254:[function(_dereq_,module,exports){ 'use strict'; var fontAttrs = _dereq_('../../plots/font_attributes'); @@ -40725,49 +50267,37 @@ var templatedArray = _dereq_('../../plot_api/plot_template').templatedArray; var buttonsAttrs = templatedArray('button', { visible: { valType: 'boolean', - - }, method: { valType: 'enumerated', values: ['restyle', 'relayout', 'animate', 'update', 'skip'], dflt: 'restyle', - - }, args: { valType: 'info_array', - freeLength: true, items: [ {valType: 'any'}, {valType: 'any'}, {valType: 'any'} ], - }, args2: { valType: 'info_array', - freeLength: true, items: [ {valType: 'any'}, {valType: 'any'}, {valType: 'any'} ], - }, label: { valType: 'string', - dflt: '', - }, execute: { valType: 'boolean', - dflt: true, - } }); @@ -40776,39 +50306,29 @@ module.exports = overrideAll(templatedArray('updatemenu', { visible: { valType: 'boolean', - - }, type: { valType: 'enumerated', values: ['dropdown', 'buttons'], dflt: 'dropdown', - - }, direction: { valType: 'enumerated', values: ['left', 'right', 'up', 'down'], dflt: 'down', - - }, active: { valType: 'integer', - min: -1, dflt: 0, - }, showactive: { valType: 'boolean', - dflt: true, - }, buttons: buttonsAttrs, @@ -40818,71 +50338,46 @@ module.exports = overrideAll(templatedArray('updatemenu', { min: -2, max: 3, dflt: -0.05, - - }, xanchor: { valType: 'enumerated', values: ['auto', 'left', 'center', 'right'], dflt: 'right', - - }, y: { valType: 'number', min: -2, max: 3, dflt: 1, - - }, yanchor: { valType: 'enumerated', values: ['auto', 'top', 'middle', 'bottom'], dflt: 'top', - - }, pad: extendFlat(padAttrs({editType: 'arraydraw'}), { - }), font: fontAttrs({ - }), bgcolor: { valType: 'color', - - }, bordercolor: { valType: 'color', dflt: colorAttrs.borderLine, - - }, borderwidth: { valType: 'number', min: 0, dflt: 1, - editType: 'arraydraw', - } }), 'arraydraw', 'from-root'); -},{"../../lib/extend":227,"../../plot_api/edit_types":261,"../../plot_api/plot_template":268,"../../plots/font_attributes":307,"../../plots/pad_attributes":312,"../color/attributes":104}],202:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib/extend":279,"../../plot_api/edit_types":313,"../../plot_api/plot_template":320,"../../plots/font_attributes":359,"../../plots/pad_attributes":365,"../color/attributes":154}],255:[function(_dereq_,module,exports){ 'use strict'; @@ -40954,15 +50449,7 @@ module.exports = { } }; -},{}],203:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],256:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -41037,19 +50524,10 @@ function buttonDefaults(buttonIn, buttonOut) { } } -},{"../../lib":233,"../../plots/array_container_defaults":274,"./attributes":201,"./constants":202}],204:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../plots/array_container_defaults":326,"./attributes":254,"./constants":255}],257:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Plots = _dereq_('../../plots/plots'); var Color = _dereq_('../color'); @@ -41688,22 +51166,14 @@ function removeAllButtons(gButton, newMenuIndexAttr) { .selectAll('g.' + constants.dropdownButtonClassName).remove(); } -},{"../../constants/alignment":207,"../../lib":233,"../../lib/svg_text_utils":255,"../../plot_api/plot_template":268,"../../plots/plots":313,"../color":105,"../drawing":127,"./constants":202,"./scrollbox":206,"d3":21}],205:[function(_dereq_,module,exports){ -arguments[4][199][0].apply(exports,arguments) -},{"./attributes":201,"./constants":202,"./defaults":203,"./draw":204,"dup":199}],206:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/alignment":260,"../../lib":285,"../../lib/svg_text_utils":307,"../../plot_api/plot_template":320,"../../plots/plots":366,"../color":155,"../drawing":177,"./constants":255,"./scrollbox":259,"@plotly/d3":20}],258:[function(_dereq_,module,exports){ +arguments[4][252][0].apply(exports,arguments) +},{"./attributes":254,"./constants":255,"./defaults":256,"./draw":257,"dup":252}],259:[function(_dereq_,module,exports){ 'use strict'; module.exports = ScrollBox; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Color = _dereq_('../color'); var Drawing = _dereq_('../drawing'); @@ -42155,15 +51625,7 @@ ScrollBox.prototype.setTranslate = function setTranslate(translateX, translateY) } }; -},{"../../lib":233,"../color":105,"../drawing":127,"d3":21}],207:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../color":155,"../drawing":177,"@plotly/d3":20}],260:[function(_dereq_,module,exports){ 'use strict'; // fraction of some size to get to a named position @@ -42220,16 +51682,7 @@ module.exports = { } }; -},{}],208:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],261:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -42252,15 +51705,7 @@ module.exports = { } }; -},{}],209:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],262:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -42268,15 +51713,7 @@ module.exports = { DATE_FORMAT_LINK: 'https://github.com/d3/d3-time-format#locale_format' }; -},{}],210:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],263:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -42306,15 +51743,7 @@ module.exports = { } }; -},{}],211:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],264:[function(_dereq_,module,exports){ 'use strict'; @@ -42329,15 +51758,7 @@ module.exports = { DESELECTDIM: 0.2 }; -},{}],212:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],265:[function(_dereq_,module,exports){ 'use strict'; @@ -42355,7 +51776,7 @@ module.exports = { * to avoid glitches: Make sure that even when you multiply it by the * number of pixels on a giant screen it still works */ - FP_SAFE: Number.MAX_VALUE / 10000, + FP_SAFE: Number.MAX_VALUE * 1e-4, /* * conversion of date units to milliseconds @@ -42402,16 +51823,7 @@ module.exports = { MINUS_SIGN: '\u2212' }; -},{}],213:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],266:[function(_dereq_,module,exports){ 'use strict'; @@ -42426,28 +51838,17 @@ exports.svgAttrs = { 'xmlns:xlink': exports.xlink }; -},{}],214:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],267:[function(_dereq_,module,exports){ 'use strict'; exports.version = _dereq_('./version').version; // inject promise polyfill -_dereq_('es6-promise').polyfill(); +_dereq_('native-promise-only'); // inject plot css _dereq_('../build/plotcss'); -// inject default MathJax config -_dereq_('./fonts/mathjax_config')(); - // include registry module and expose register method var Registry = _dereq_('./registry'); var register = exports.register = Registry.register; @@ -42484,7 +51885,8 @@ register([ _dereq_('./components/grid'), _dereq_('./components/errorbars'), _dereq_('./components/colorscale'), - _dereq_('./components/colorbar') + _dereq_('./components/colorbar'), + _dereq_('./components/modebar') ]); // locales en and en-US are required for default behavior @@ -42503,55 +51905,24 @@ if(window.PlotlyLocales && Array.isArray(window.PlotlyLocales)) { exports.Icons = _dereq_('./fonts/ploticon'); // unofficial 'beta' plot methods, use at your own risk -exports.Plots = _dereq_('./plots/plots'); -exports.Fx = _dereq_('./components/fx'); +var Fx = _dereq_('./components/fx'); +var Plots = _dereq_('./plots/plots'); + +exports.Plots = { + resize: Plots.resize, + graphJson: Plots.graphJson, + sendDataToCloud: Plots.sendDataToCloud +}; +exports.Fx = { + hover: Fx.hover, + unhover: Fx.unhover, + loneHover: Fx.loneHover, + loneUnhover: Fx.loneUnhover +}; exports.Snapshot = _dereq_('./snapshot'); exports.PlotSchema = _dereq_('./plot_api/plot_schema'); -exports.Queue = _dereq_('./lib/queue'); - -// export d3 used in the bundle -exports.d3 = _dereq_('d3'); - -},{"../build/plotcss":1,"./components/annotations":98,"./components/annotations3d":103,"./components/colorbar":111,"./components/colorscale":117,"./components/errorbars":133,"./components/fx":145,"./components/grid":149,"./components/images":154,"./components/legend":162,"./components/rangeselector":173,"./components/rangeslider":180,"./components/shapes":194,"./components/sliders":199,"./components/updatemenus":205,"./fonts/mathjax_config":215,"./fonts/ploticon":216,"./lib/queue":248,"./locale-en":259,"./locale-en-us":258,"./plot_api":263,"./plot_api/plot_schema":267,"./plots/plots":313,"./registry":326,"./snapshot":331,"./traces/scatter":459,"./version":494,"d3":21,"es6-promise":22}],215:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - -'use strict'; - -/* global MathJax:false */ - -module.exports = function() { - if(typeof MathJax !== 'undefined') { - var globalConfig = (window.PlotlyConfig || {}).MathJaxConfig !== 'local'; - - if(globalConfig) { - MathJax.Hub.Config({ - messageStyle: 'none', - skipStartupTypeset: true, - displayAlign: 'left', - tex2jax: { - inlineMath: [['$', '$'], ['\\(', '\\)']] - } - }); - MathJax.Hub.Configured(); - } - } -}; - -},{}],216:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +},{"../build/plotcss":1,"./components/annotations":146,"./components/annotations3d":151,"./components/colorbar":161,"./components/colorscale":167,"./components/errorbars":183,"./components/fx":195,"./components/grid":199,"./components/images":204,"./components/legend":212,"./components/modebar":218,"./components/rangeselector":226,"./components/rangeslider":233,"./components/shapes":247,"./components/sliders":252,"./components/updatemenus":258,"./fonts/ploticon":268,"./locale-en":311,"./locale-en-us":310,"./plot_api":315,"./plot_api/plot_schema":319,"./plots/plots":366,"./registry":373,"./snapshot":378,"./traces/scatter":506,"./version":546,"native-promise-only":70}],268:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -42723,16 +52094,7 @@ module.exports = { } }; -},{}],217:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],269:[function(_dereq_,module,exports){ 'use strict'; @@ -42787,15 +52149,7 @@ exports.isBottomAnchor = function isBottomAnchor(opts) { ); }; -},{}],218:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],270:[function(_dereq_,module,exports){ 'use strict'; var modModule = _dereq_('./mod'); @@ -43028,28 +52382,13 @@ module.exports = { pathAnnulus: pathAnnulus }; -},{"./mod":240}],219:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"./mod":292}],271:[function(_dereq_,module,exports){ 'use strict'; var isArray = Array.isArray; -// IE9 fallbacks - -var ab = (typeof ArrayBuffer === 'undefined' || !ArrayBuffer.isView) ? - {isView: function() { return false; }} : - ArrayBuffer; - -var dv = (typeof DataView === 'undefined') ? - function() {} : - DataView; +var ab = ArrayBuffer; +var dv = DataView; function isTypedArray(a) { return ab.isView(a) && !(a instanceof dv); @@ -43185,16 +52524,7 @@ function _rowLength(z, fn, len0) { return 0; } -},{}],220:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],272:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -43218,15 +52548,7 @@ module.exports = function cleanNumber(v) { return BADNUM; }; -},{"../constants/numerical":212,"fast-isnumeric":23}],221:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../constants/numerical":265,"fast-isnumeric":31}],273:[function(_dereq_,module,exports){ 'use strict'; /** @@ -43246,15 +52568,7 @@ module.exports = function clearGlCanvases(gd) { } }; -},{}],222:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],274:[function(_dereq_,module,exports){ 'use strict'; /** @@ -43269,15 +52583,7 @@ module.exports = function clearResponsive(gd) { } }; -},{}],223:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],275:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -43295,9 +52601,6 @@ var isArrayOrTypedArray = _dereq_('./array').isArrayOrTypedArray; exports.valObjectMeta = { data_array: { // You can use *dflt=[] to force said array to exist though. - - - coerceFunction: function(v, propOut, dflt) { // TODO maybe `v: {type: 'float32', vals: [/* ... */]}` also if(isArrayOrTypedArray(v)) propOut.set(v); @@ -43305,9 +52608,6 @@ exports.valObjectMeta = { } }, enumerated: { - - - coerceFunction: function(v, propOut, dflt, opts) { if(opts.coerceNumber) v = +v; if(opts.values.indexOf(v) === -1) propOut.set(dflt); @@ -43329,18 +52629,12 @@ exports.valObjectMeta = { } }, 'boolean': { - - - coerceFunction: function(v, propOut, dflt) { if(v === true || v === false) propOut.set(v); else propOut.set(dflt); } }, number: { - - - coerceFunction: function(v, propOut, dflt, opts) { if(!isNumeric(v) || (opts.min !== undefined && v < opts.min) || @@ -43350,9 +52644,6 @@ exports.valObjectMeta = { } }, integer: { - - - coerceFunction: function(v, propOut, dflt, opts) { if(v % 1 || !isNumeric(v) || (opts.min !== undefined && v < opts.min) || @@ -43362,10 +52653,7 @@ exports.valObjectMeta = { } }, string: { - - // TODO 'values shouldn't be in there (edge case: 'dash' in Scatter) - coerceFunction: function(v, propOut, dflt, opts) { if(typeof v !== 'string') { var okToCoerce = (typeof v === 'number'); @@ -43377,18 +52665,12 @@ exports.valObjectMeta = { } }, color: { - - - coerceFunction: function(v, propOut, dflt) { if(tinycolor(v).isValid()) propOut.set(v); else propOut.set(dflt); } }, colorlist: { - - - coerceFunction: function(v, propOut, dflt) { function isColor(color) { return tinycolor(color).isValid(); @@ -43399,17 +52681,11 @@ exports.valObjectMeta = { } }, colorscale: { - - - coerceFunction: function(v, propOut, dflt) { propOut.set(colorscales.get(v, dflt)); } }, angle: { - - - coerceFunction: function(v, propOut, dflt) { if(v === 'auto') propOut.set('auto'); else if(!isNumeric(v)) propOut.set(dflt); @@ -43417,9 +52693,6 @@ exports.valObjectMeta = { } }, subplotid: { - - - coerceFunction: function(v, propOut, dflt, opts) { var regex = opts.regex || counterRegex(dflt); if(typeof v === 'string' && regex.test(v)) { @@ -43439,9 +52712,6 @@ exports.valObjectMeta = { } }, flaglist: { - - - coerceFunction: function(v, propOut, dflt, opts) { if(typeof v !== 'string') { propOut.set(dflt); @@ -43464,23 +52734,17 @@ exports.valObjectMeta = { } }, any: { - - - coerceFunction: function(v, propOut, dflt) { if(v === undefined) propOut.set(dflt); else propOut.set(v); } }, info_array: { - - // set `dimensions=2` for a 2D array or '1-2' for either // `items` may be a single object instead of an array, in which case // `freeLength` must be true. // if `dimensions='1-2'` and items is a 1D array, then the value can // either be a matching 1D array or an array of such matching 1D arrays - coerceFunction: function(v, propOut, dflt, opts) { // simplified coerce function just for array items function coercePart(v, opts, dflt) { @@ -43651,6 +52915,18 @@ exports.coerceFont = function(coerce, attr, dfltObj) { return out; }; +/* + * Shortcut to coerce the pattern attributes + */ +exports.coercePattern = function(coerce, attr) { + var shape = coerce(attr + '.shape'); + if(shape) { + coerce(attr + '.size'); + coerce(attr + '.bgcolor'); + coerce(attr + '.solidity'); + } +}; + /** Coerce shortcut for 'hoverinfo' * handling 1-vs-multi-trace dflt logic * @@ -43733,16 +53009,7 @@ function validate(value, opts) { } exports.validate = validate; -},{"../components/colorscale/scales":120,"../constants/interactions":211,"../plots/attributes":275,"./array":219,"./mod":240,"./nested_property":241,"./regex":249,"fast-isnumeric":23,"tinycolor2":88}],224:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../components/colorscale/scales":170,"../constants/interactions":264,"../plots/attributes":327,"./array":271,"./mod":292,"./nested_property":293,"./regex":301,"fast-isnumeric":31,"tinycolor2":119}],276:[function(_dereq_,module,exports){ 'use strict'; var timeFormat = _dereq_('d3-time-format').timeFormat; @@ -44334,18 +53601,10 @@ exports.findExactDates = function(data, calendar) { }; }; -},{"../constants/numerical":212,"../registry":326,"./loggers":237,"./mod":240,"d3-time-format":19,"fast-isnumeric":23}],225:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../constants/numerical":265,"../registry":373,"./loggers":289,"./mod":292,"d3-time-format":29,"fast-isnumeric":31}],277:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var loggers = _dereq_('./loggers'); var matrix = _dereq_('./matrix'); var mat4X4 = _dereq_('gl-mat4'); @@ -44512,16 +53771,7 @@ module.exports = { equalDomRects: equalDomRects }; -},{"./loggers":237,"./matrix":239,"d3":21,"gl-mat4":39}],226:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"./loggers":289,"./matrix":291,"@plotly/d3":20,"gl-mat4":47}],278:[function(_dereq_,module,exports){ 'use strict'; /* global jQuery:false */ @@ -44685,16 +53935,7 @@ var Events = { module.exports = Events; -},{"events":17}],227:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"events":27}],279:[function(_dereq_,module,exports){ 'use strict'; var isPlainObject = _dereq_('./is_plain_object.js'); @@ -44799,16 +54040,7 @@ function _extend(inputs, isDeep, keepAllKeys, noArrayCopies) { return target; } -},{"./is_plain_object.js":234}],228:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"./is_plain_object.js":286}],280:[function(_dereq_,module,exports){ 'use strict'; @@ -44850,15 +54082,7 @@ module.exports = function filterUnique(array) { return out; }; -},{}],229:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],281:[function(_dereq_,module,exports){ 'use strict'; /** Filter out object items with visible !== true @@ -44898,15 +54122,7 @@ function isCalcData(cont) { ); } -},{}],230:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],282:[function(_dereq_,module,exports){ 'use strict'; var mod = _dereq_('./mod').mod; @@ -45142,15 +54358,7 @@ exports.findPointOnPath = function findPointOnPath(path, val, coord, opts) { return pt; }; -},{"./mod":240}],231:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"./mod":292}],283:[function(_dereq_,module,exports){ 'use strict'; // Simple helper functions @@ -45158,16 +54366,7 @@ exports.findPointOnPath = function findPointOnPath(path, val, coord, opts) { module.exports = function identity(d) { return d; }; -},{}],232:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],284:[function(_dereq_,module,exports){ 'use strict'; module.exports = function incrementNumeric(x, delta) { @@ -45200,23 +54399,16 @@ module.exports = function incrementNumeric(x, delta) { return newX; }; -},{}],233:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],285:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var utcFormat = _dereq_('d3-time-format').utcFormat; var isNumeric = _dereq_('fast-isnumeric'); var numConstants = _dereq_('../constants/numerical'); -var FP_SAFE = numConstants.FP_SAFE; +var MAX_SAFE = numConstants.FP_SAFE; +var MIN_SAFE = -MAX_SAFE; var BADNUM = numConstants.BADNUM; var lib = module.exports = {}; @@ -45246,6 +54438,7 @@ lib.valObjectMeta = coerceModule.valObjectMeta; lib.coerce = coerceModule.coerce; lib.coerce2 = coerceModule.coerce2; lib.coerceFont = coerceModule.coerceFont; +lib.coercePattern = coerceModule.coercePattern; lib.coerceHoverinfo = coerceModule.coerceHoverinfo; lib.coerceSelectionMarkerOpacity = coerceModule.coerceSelectionMarkerOpacity; lib.validate = coerceModule.validate; @@ -45376,8 +54569,7 @@ lib.cleanNumber = _dereq_('./clean_number'); lib.ensureNumber = function ensureNumber(v) { if(!isNumeric(v)) return BADNUM; v = Number(v); - if(v < -FP_SAFE || v > FP_SAFE) return BADNUM; - return isNumeric(v) ? Number(v) : BADNUM; + return (v > MAX_SAFE || v < MIN_SAFE) ? BADNUM : v; }; /** @@ -45915,11 +55107,6 @@ lib.isIE = function() { return typeof window.navigator.msSaveBlob !== 'undefined'; }; -var IS_IE9_OR_BELOW_REGEX = /MSIE [1-9]\./; -lib.isIE9orBelow = function() { - return lib.isIE() && IS_IE9_OR_BELOW_REGEX.test(window.navigator.userAgent); -}; - var IS_SAFARI_REGEX = /Version\/[\d\.]+.*Safari/; lib.isSafari = function() { return IS_SAFARI_REGEX.test(window.navigator.userAgent); @@ -45930,12 +55117,20 @@ lib.isIOS = function() { return IS_IOS_REGEX.test(window.navigator.userAgent); }; -/** - * Duck typing to recognize a d3 selection, mostly for IE9's benefit - * because it doesn't handle instanceof like modern browsers - */ +var FIREFOX_VERSION_REGEX = /Firefox\/(\d+)\.\d+/; +lib.getFirefoxVersion = function() { + var match = FIREFOX_VERSION_REGEX.exec(window.navigator.userAgent); + if(match && match.length === 2) { + var versionInt = parseInt(match[1]); + if(!isNaN(versionInt)) { + return versionInt; + } + } + return null; +}; + lib.isD3Selection = function(obj) { - return obj && (typeof obj.classed === 'function'); + return obj instanceof d3.selection; }; /** @@ -46262,21 +55457,50 @@ function templateFormatString(string, labels, d3locale) { // just in case it speeds things up *slightly*: var getterCache = {}; - return string.replace(lib.TEMPLATE_STRING_REGEX, function(match, key, format) { - var obj, value, i; - for(i = 3; i < args.length; i++) { - obj = args[i]; - if(!obj) continue; - if(obj.hasOwnProperty(key)) { - value = obj[key]; - break; - } + return string.replace(lib.TEMPLATE_STRING_REGEX, function(match, rawKey, format) { + var isOther = + rawKey === 'xother' || + rawKey === 'yother'; - if(!SIMPLE_PROPERTY_REGEX.test(key)) { - value = getterCache[key] || lib.nestedProperty(obj, key).get(); - if(value) getterCache[key] = value; + var isSpaceOther = + rawKey === '_xother' || + rawKey === '_yother'; + + var isSpaceOtherSpace = + rawKey === '_xother_' || + rawKey === '_yother_'; + + var isOtherSpace = + rawKey === 'xother_' || + rawKey === 'yother_'; + + var hasOther = isOther || isSpaceOther || isOtherSpace || isSpaceOtherSpace; + + var key = rawKey; + if(isSpaceOther || isSpaceOtherSpace) key = key.substring(1); + if(isOtherSpace || isSpaceOtherSpace) key = key.substring(0, key.length - 1); + + var value; + if(hasOther) { + value = labels[key]; + if(value === undefined) return ''; + } else { + var obj, i; + for(i = 3; i < args.length; i++) { + obj = args[i]; + if(!obj) continue; + if(obj.hasOwnProperty(key)) { + value = obj[key]; + break; + } + + if(!SIMPLE_PROPERTY_REGEX.test(key)) { + value = lib.nestedProperty(obj, key).get(); + value = getterCache[key] || lib.nestedProperty(obj, key).get(); + if(value) getterCache[key] = value; + } + if(value !== undefined) break; } - if(value !== undefined) break; } if(value === undefined && opts) { @@ -46306,8 +55530,16 @@ function templateFormatString(string, labels, d3locale) { value = lib.formatDate(ms, format.replace(TEMPLATE_STRING_FORMAT_SEPARATOR, ''), false, fmt); } } else { - if(labels.hasOwnProperty(key + 'Label')) value = labels[key + 'Label']; + var keyLabel = key + 'Label'; + if(labels.hasOwnProperty(keyLabel)) value = labels[keyLabel]; } + + if(hasOther) { + value = '(' + value + ')'; + if(isSpaceOther || isSpaceOtherSpace) value = ' ' + value; + if(isOtherSpace || isSpaceOtherSpace) value = value + ' '; + } + return value; }); } @@ -46483,16 +55715,35 @@ lib.join2 = function(arr, mainSeparator, lastSeparator) { return arr.join(mainSeparator); }; -},{"../constants/numerical":212,"./anchor_utils":217,"./angles":218,"./array":219,"./clean_number":220,"./clear_responsive":222,"./coerce":223,"./dates":224,"./dom":225,"./extend":227,"./filter_unique":228,"./filter_visible":229,"./geometry2d":230,"./identity":231,"./increment":232,"./is_plain_object":234,"./keyed_container":235,"./localize":236,"./loggers":237,"./make_trace_groups":238,"./matrix":239,"./mod":240,"./nested_property":241,"./noop":242,"./notifier":243,"./preserve_drawing_buffer":246,"./push_unique":247,"./regex":249,"./relative_attr":250,"./relink_private":251,"./search":252,"./stats":254,"./throttle":256,"./to_log_range":257,"d3":21,"d3-time-format":19,"fast-isnumeric":23}],234:[function(_dereq_,module,exports){ +lib.bigFont = function(size) { + return Math.round(1.2 * size); +}; + +var firefoxVersion = lib.getFirefoxVersion(); +// see https://bugzilla.mozilla.org/show_bug.cgi?id=1684973 +var isProblematicFirefox = firefoxVersion !== null && firefoxVersion < 86; + /** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - + * Return the mouse position from the last event registered by D3. + * @returns An array with two numbers, representing the x and y coordinates of the mouse pointer + * at the event relative to the targeted node. + */ +lib.getPositionFromD3Event = function() { + if(isProblematicFirefox) { + // layerX and layerY are non-standard, so we only fallback to them when we have to: + return [ + d3.event.layerX, + d3.event.layerY + ]; + } else { + return [ + d3.event.offsetX, + d3.event.offsetY + ]; + } +}; +},{"../constants/numerical":265,"./anchor_utils":269,"./angles":270,"./array":271,"./clean_number":272,"./clear_responsive":274,"./coerce":275,"./dates":276,"./dom":277,"./extend":279,"./filter_unique":280,"./filter_visible":281,"./geometry2d":282,"./identity":283,"./increment":284,"./is_plain_object":286,"./keyed_container":287,"./localize":288,"./loggers":289,"./make_trace_groups":290,"./matrix":291,"./mod":292,"./nested_property":293,"./noop":294,"./notifier":295,"./preserve_drawing_buffer":298,"./push_unique":299,"./regex":301,"./relative_attr":302,"./relink_private":303,"./search":304,"./stats":306,"./throttle":308,"./to_log_range":309,"@plotly/d3":20,"d3-time-format":29,"fast-isnumeric":31}],286:[function(_dereq_,module,exports){ 'use strict'; // more info: http://stackoverflow.com/questions/18531624/isplainobject-thing @@ -46507,19 +55758,11 @@ module.exports = function isPlainObject(obj) { return ( Object.prototype.toString.call(obj) === '[object Object]' && - Object.getPrototypeOf(obj) === Object.prototype + Object.getPrototypeOf(obj).hasOwnProperty('hasOwnProperty') ); }; -},{}],235:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],287:[function(_dereq_,module,exports){ 'use strict'; var nestedProperty = _dereq_('./nested_property'); @@ -46704,16 +55947,7 @@ module.exports = function keyedContainer(baseObj, path, keyName, valueName) { return obj; }; -},{"./nested_property":241}],236:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"./nested_property":293}],288:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../registry'); @@ -46760,15 +55994,7 @@ module.exports = function localize(gd, s) { return s; }; -},{"../registry":326}],237:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../registry":373}],289:[function(_dereq_,module,exports){ 'use strict'; /* eslint-disable no-console */ @@ -46793,7 +56019,7 @@ loggers.log = function() { for(i = 0; i < arguments.length; i++) { messages.push(arguments[i]); } - apply(console.trace || console.log, messages); + console.trace.apply(console, messages); } if(dfltConfig.notifyOnLogging > 1) { @@ -46813,7 +56039,7 @@ loggers.warn = function() { for(i = 0; i < arguments.length; i++) { messages.push(arguments[i]); } - apply(console.trace || console.log, messages); + console.trace.apply(console, messages); } if(dfltConfig.notifyOnLogging > 0) { @@ -46833,7 +56059,7 @@ loggers.error = function() { for(i = 0; i < arguments.length; i++) { messages.push(arguments[i]); } - apply(console.error, messages); + console.error.apply(console, messages); } if(dfltConfig.notifyOnLogging > 0) { @@ -46845,43 +56071,10 @@ loggers.error = function() { } }; -/* - * Robust apply, for IE9 where console.log doesn't support - * apply like other functions do - */ -function apply(f, args) { - if(f && f.apply) { - try { - // `this` should always be console, since here we're always - // applying a method of the console object. - f.apply(console, args); - return; - } catch(e) { /* in case apply failed, fall back on the code below */ } - } - - // no apply - just try calling the function on each arg independently - for(var i = 0; i < args.length; i++) { - try { - f(args[i]); - } catch(e) { - // still fails - last resort simple console.log - console.log(args[i]); - } - } -} - -},{"../plot_api/plot_config":266,"./notifier":243}],238:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../plot_api/plot_config":318,"./notifier":295}],290:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); /** * General helper to manage trace groups based on calcdata @@ -46913,16 +56106,7 @@ module.exports = function makeTraceGroups(traceLayer, cdModule, cls) { return traces; }; -},{"d3":21}],239:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"@plotly/d3":20}],291:[function(_dereq_,module,exports){ 'use strict'; var mat4X4 = _dereq_('gl-mat4'); @@ -47065,15 +56249,7 @@ exports.inverseTransformMatrix = function(m) { ]; }; -},{"gl-mat4":39}],240:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"gl-mat4":47}],292:[function(_dereq_,module,exports){ 'use strict'; /** @@ -47100,16 +56276,7 @@ module.exports = { modHalf: modHalf }; -},{}],241:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],293:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -47346,15 +56513,7 @@ function badContainer(container, propStr, propParts) { }; } -},{"./array":219,"fast-isnumeric":23}],242:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"./array":271,"fast-isnumeric":31}],294:[function(_dereq_,module,exports){ 'use strict'; // Simple helper functions @@ -47362,19 +56521,10 @@ function badContainer(container, propStr, propParts) { module.exports = function noop() {}; -},{}],243:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],295:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var isNumeric = _dereq_('fast-isnumeric'); var NOTEDATA = []; @@ -47450,16 +56600,7 @@ module.exports = function(text, displayLength) { }); }; -},{"d3":21,"fast-isnumeric":23}],244:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"@plotly/d3":20,"fast-isnumeric":31}],296:[function(_dereq_,module,exports){ 'use strict'; var setCursor = _dereq_('./setcursor'); @@ -47498,16 +56639,7 @@ module.exports = function overrideCursor(el3, csr) { } }; -},{"./setcursor":253}],245:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"./setcursor":305}],297:[function(_dereq_,module,exports){ 'use strict'; var dot = _dereq_('./matrix').dot; @@ -47750,15 +56882,7 @@ polygon.filter = function filter(pts, tolerance) { }; }; -},{"../constants/numerical":212,"./matrix":239}],246:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../constants/numerical":265,"./matrix":291}],298:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -47820,15 +56944,7 @@ function getUserAgent() { return ua; } -},{"fast-isnumeric":23,"is-mobile":74}],247:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"fast-isnumeric":31,"is-mobile":67}],299:[function(_dereq_,module,exports){ 'use strict'; /** @@ -47858,15 +56974,7 @@ module.exports = function pushUnique(array, item) { return array; }; -},{}],248:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],300:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../lib'); @@ -47987,10 +57095,6 @@ queue.stopSequence = function(gd) { queue.undo = function undo(gd) { var queueObj, i; - if(gd.framework && gd.framework.isPolar) { - gd.framework.undo(); - return; - } if(gd.undoQueue === undefined || isNaN(gd.undoQueue.index) || gd.undoQueue.index <= 0) { @@ -48020,10 +57124,6 @@ queue.undo = function undo(gd) { queue.redo = function redo(gd) { var queueObj, i; - if(gd.framework && gd.framework.isPolar) { - gd.framework.redo(); - return; - } if(gd.undoQueue === undefined || isNaN(gd.undoQueue.index) || gd.undoQueue.index >= gd.undoQueue.queue.length) { @@ -48066,15 +57166,7 @@ queue.plotDo = function(gd, func, args) { module.exports = queue; -},{"../lib":233,"../plot_api/plot_config":266}],249:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285,"../plot_api/plot_config":318}],301:[function(_dereq_,module,exports){ 'use strict'; /* @@ -48096,16 +57188,7 @@ exports.counter = function(head, tail, openEnded, matchBeginning) { return new RegExp(startWithPrefix + head + '([2-9]|[1-9][0-9]+)?' + fullTail); }; -},{}],250:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],302:[function(_dereq_,module,exports){ 'use strict'; // ASCEND: chop off the last nesting level - either [] or . - to ascend @@ -48149,16 +57232,7 @@ module.exports = function(baseAttr, relativeAttr) { return baseAttr + relativeAttr; }; -},{}],251:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],303:[function(_dereq_,module,exports){ 'use strict'; var isArrayOrTypedArray = _dereq_('./array').isArrayOrTypedArray; @@ -48206,16 +57280,7 @@ module.exports = function relinkPrivateKeys(toContainer, fromContainer) { } }; -},{"./array":219,"./is_plain_object":234}],252:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"./array":271,"./is_plain_object":286}],304:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -48411,16 +57476,7 @@ exports.findIndexOfMin = function(arr, fn) { return ind; }; -},{"../constants/numerical":212,"./identity":231,"./loggers":237,"fast-isnumeric":23}],253:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../constants/numerical":265,"./identity":283,"./loggers":289,"fast-isnumeric":31}],305:[function(_dereq_,module,exports){ 'use strict'; // works with our CSS cursor classes (see css/_cursor.scss) @@ -48434,16 +57490,7 @@ module.exports = function setCursor(el3, csr) { if(csr) el3.classed('cursor-' + csr, true); }; -},{}],254:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],306:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -48544,21 +57591,12 @@ exports.interp = function(arr, n) { return frac * arr[Math.ceil(n)] + (1 - frac) * arr[Math.floor(n)]; }; -},{"./array":219,"fast-isnumeric":23}],255:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"./array":271,"fast-isnumeric":31}],307:[function(_dereq_,module,exports){ 'use strict'; /* global MathJax:false */ -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Lib = _dereq_('../lib'); var strTranslate = Lib.strTranslate; @@ -49311,6 +58349,18 @@ function alignHTMLWith(_base, container, options) { }; } +var onePx = '1px '; + +exports.makeTextShadow = function(color) { + var x = onePx; + var y = onePx; + var b = onePx; + return x + y + b + color + ', ' + + '-' + x + '-' + y + b + color + ', ' + + x + '-' + y + b + color + ', ' + + '-' + x + y + b + color; +}; + /* * Editable title * @param {d3.selection} context: the element being edited. Normally text, @@ -49435,15 +58485,7 @@ exports.makeEditable = function(context, options) { return d3.rebind(context, dispatch, 'on'); }; -},{"../constants/alignment":207,"../constants/xmlns_namespaces":213,"../lib":233,"d3":21}],256:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../constants/alignment":260,"../constants/xmlns_namespaces":266,"../lib":285,"@plotly/d3":20}],308:[function(_dereq_,module,exports){ 'use strict'; var timerCache = {}; @@ -49538,15 +58580,7 @@ function _clearTimeout(cache) { } } -},{}],257:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],309:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -49566,15 +58600,7 @@ module.exports = function toLogRange(val, range) { return newVal; }; -},{"fast-isnumeric":23}],258:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"fast-isnumeric":31}],310:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -49588,15 +58614,7 @@ module.exports = { } }; -},{}],259:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],311:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -49631,16 +58649,7 @@ module.exports = { } }; -},{}],260:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],312:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../registry'); @@ -49689,15 +58698,7 @@ module.exports = function containerArrayMatch(astr) { return {array: arrayStr, index: Number(match[1]), property: match[3] || ''}; }; -},{"../registry":326}],261:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../registry":373}],313:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../lib'); @@ -49708,7 +58709,6 @@ var traceOpts = { valType: 'flaglist', extras: ['none'], flags: ['calc', 'clearAxisTypes', 'plot', 'style', 'markerSize', 'colorbars'], - }; var layoutOpts = { @@ -49718,7 +58718,6 @@ var layoutOpts = { 'calc', 'plot', 'legend', 'ticks', 'axrange', 'layoutstyle', 'modebar', 'camera', 'arraydraw', 'colorbars' ], - }; // flags for inside restyle/relayout include a few extras @@ -49814,15 +58813,7 @@ function overrideOne(attr, editTypeOverride, overrideContainers, key) { } } -},{"../lib":233}],262:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285}],314:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -50516,20 +59507,12 @@ exports.clearAxisTypes = function(gd, traces, layoutUpdate) { } }; -},{"../components/color":105,"../lib":233,"../plots/cartesian/axis_ids":282,"../plots/plots":313,"../registry":326,"fast-isnumeric":23,"gl-mat4/fromQuat":29}],263:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../components/color":155,"../lib":285,"../plots/cartesian/axis_ids":334,"../plots/plots":366,"../registry":373,"fast-isnumeric":31,"gl-mat4/fromQuat":37}],315:[function(_dereq_,module,exports){ 'use strict'; var main = _dereq_('./plot_api'); -exports.plot = main.plot; +exports._doPlot = main._doPlot; exports.newPlot = main.newPlot; exports.restyle = main.restyle; exports.relayout = main.relayout; @@ -50559,16 +59542,7 @@ var templateApi = _dereq_('./template_api'); exports.makeTemplate = templateApi.makeTemplate; exports.validateTemplate = templateApi.validateTemplate; -},{"../snapshot/download":328,"./plot_api":265,"./template_api":270,"./to_image":271,"./validate":272}],264:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../snapshot/download":375,"./plot_api":317,"./template_api":322,"./to_image":323,"./validate":324}],316:[function(_dereq_,module,exports){ 'use strict'; var isPlainObject = _dereq_('../lib/is_plain_object'); @@ -50772,18 +59746,10 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, return true; }; -},{"../lib/is_plain_object":234,"../lib/loggers":237,"../lib/noop":242,"../lib/search":252,"../registry":326,"./container_array_match":260}],265:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib/is_plain_object":286,"../lib/loggers":289,"../lib/noop":294,"../lib/search":304,"../registry":373,"./container_array_match":312}],317:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var isNumeric = _dereq_('fast-isnumeric'); var hasHover = _dereq_('has-hover'); @@ -50796,14 +59762,12 @@ var Queue = _dereq_('../lib/queue'); var Registry = _dereq_('../registry'); var PlotSchema = _dereq_('./plot_schema'); var Plots = _dereq_('../plots/plots'); -var Polar = _dereq_('../plots/polar/legacy'); var Axes = _dereq_('../plots/cartesian/axes'); var Drawing = _dereq_('../components/drawing'); var Color = _dereq_('../components/color'); var initInteractions = _dereq_('../plots/cartesian/graph_interact').initInteractions; var xmlnsNamespaces = _dereq_('../constants/xmlns_namespaces'); -var svgTextUtils = _dereq_('../lib/svg_text_utils'); var clearSelect = _dereq_('../plots/cartesian/select').clearSelect; var dfltConfig = _dereq_('./plot_config').dfltConfig; @@ -50818,7 +59782,7 @@ var numericNameWarningCount = 0; var numericNameWarningCountLimit = 5; /** - * Main plot-creation function + * Internal plot-creation function * * @param {string id or DOM element} gd * the id or DOM element of the graph container div @@ -50838,7 +59802,7 @@ var numericNameWarningCountLimit = 5; * object containing `data`, `layout`, `config`, and `frames` members * */ -function plot(gd, data, layout, config) { +function _doPlot(gd, data, layout, config) { var frames; gd = Lib.getGraphDiv(gd); @@ -50860,7 +59824,7 @@ function plot(gd, data, layout, config) { // if there's no data or layout, and this isn't yet a plotly plot // container, log a warning to help plotly.js users debug if(!data && !layout && !Lib.isPlotDiv(gd)) { - Lib.warn('Calling Plotly.plot as if redrawing ' + + Lib.warn('Calling _doPlot as if redrawing ' + 'but this container doesn\'t yet have a plot.', gd); } @@ -50916,13 +59880,7 @@ function plot(gd, data, layout, config) { var fullLayout = gd._fullLayout; var hasCartesian = fullLayout._has('cartesian'); - // Legacy polar plots - if(!fullLayout._has('polar') && data && data[0] && data[0].r) { - Lib.log('Legacy polar charts are deprecated!'); - return plotLegacyPolar(gd, data, layout); - } - - // so we don't try to re-call Plotly.plot from inside + // so we don't try to re-call _doPlot from inside // legend and colorbar, if margins changed fullLayout._replotting = true; @@ -50935,14 +59893,9 @@ function plot(gd, data, layout, config) { } } - // polar need a different framework - if(gd.framework !== makePlotFramework) { - gd.framework = makePlotFramework; - makePlotFramework(gd); - } - - // clear gradient defs on each .plot call, because we know we'll loop through all traces + // clear gradient and pattern defs on each .plot call, because we know we'll loop through all traces Drawing.initGradients(gd); + Drawing.initPatterns(gd); // save initial show spikes once per graph if(graphWasEmpty) Axes.saveShowSpikeInitial(gd); @@ -50950,7 +59903,7 @@ function plot(gd, data, layout, config) { // prepare the data and find the autorange // generate calcdata, if we need to - // to force redoing calcdata, just delete it before calling Plotly.plot + // to force redoing calcdata, just delete it before calling _doPlot var recalc = !gd.calcdata || gd.calcdata.length !== (gd._fullData || []).length; if(recalc) Plots.doCalcdata(gd); @@ -51322,99 +60275,6 @@ function setPlotContext(gd, config) { } } -function plotLegacyPolar(gd, data, layout) { - // build or reuse the container skeleton - var plotContainer = d3.select(gd).selectAll('.plot-container') - .data([0]); - plotContainer.enter() - .insert('div', ':first-child') - .classed('plot-container plotly', true); - var paperDiv = plotContainer.selectAll('.svg-container') - .data([0]); - paperDiv.enter().append('div') - .classed('svg-container', true) - .style('position', 'relative'); - - // empty it everytime for now - paperDiv.html(''); - - // fulfill gd requirements - if(data) gd.data = data; - if(layout) gd.layout = layout; - Polar.manager.fillLayout(gd); - - // resize canvas - paperDiv.style({ - width: gd._fullLayout.width + 'px', - height: gd._fullLayout.height + 'px' - }); - - // instantiate framework - gd.framework = Polar.manager.framework(gd); - - // plot - gd.framework({data: gd.data, layout: gd.layout}, paperDiv.node()); - - // set undo point - gd.framework.setUndoPoint(); - - // get the resulting svg for extending it - var polarPlotSVG = gd.framework.svg(); - - // editable title - var opacity = 1; - var txt = gd._fullLayout.title ? gd._fullLayout.title.text : ''; - if(txt === '' || !txt) opacity = 0; - - var titleLayout = function() { - this.call(svgTextUtils.convertToTspans, gd); - // TODO: html/mathjax - // TODO: center title - }; - - var title = polarPlotSVG.select('.title-group text') - .call(titleLayout); - - if(gd._context.edits.titleText) { - var placeholderText = Lib._(gd, 'Click to enter Plot title'); - if(!txt || txt === placeholderText) { - opacity = 0.2; - // placeholder is not going through convertToTspans - // so needs explicit data-unformatted - title.attr({'data-unformatted': placeholderText}) - .text(placeholderText) - .style({opacity: opacity}) - .on('mouseover.opacity', function() { - d3.select(this).transition().duration(100) - .style('opacity', 1); - }) - .on('mouseout.opacity', function() { - d3.select(this).transition().duration(1000) - .style('opacity', 0); - }); - } - - var setContenteditable = function() { - this.call(svgTextUtils.makeEditable, {gd: gd}) - .on('edit', function(text) { - gd.framework({layout: {title: {text: text}}}); - this.text(text) - .call(titleLayout); - this.call(setContenteditable); - }) - .on('cancel', function() { - var txt = this.attr('data-unformatted'); - this.text(txt).call(titleLayout); - }); - }; - title.call(setContenteditable); - } - - gd._context.setBackground(gd, gd._fullLayout.paper_bgcolor); - Plots.addLinks(gd); - - return Promise.resolve(); -} // convenience function to force a full redraw, mostly for use by plotly.js function redraw(gd) { @@ -51428,7 +60288,7 @@ function redraw(gd) { helpers.cleanLayout(gd.layout); gd.calcdata = undefined; - return exports.plot(gd).then(function() { + return exports._doPlot(gd).then(function() { gd.emit('plotly_redraw'); return gd; }); @@ -51449,7 +60309,7 @@ function newPlot(gd, data, layout, config) { Plots.cleanPlot([], {}, gd._fullData || [], gd._fullLayout || {}); Plots.purge(gd); - return exports.plot(gd, data, layout, config); + return exports._doPlot(gd, data, layout, config); } /** @@ -52160,7 +61020,7 @@ function restyle(gd, astr, val, _traces) { var seq = []; if(flags.fullReplot) { - seq.push(exports.plot); + seq.push(exports._doPlot); } else { seq.push(Plots.previousPromises); @@ -52646,10 +61506,6 @@ function relayout(gd, astr, val) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); - if(gd.framework && gd.framework.isPolar) { - return Promise.resolve(gd); - } - var aobj = {}; if(typeof astr === 'string') { aobj[astr] = val; @@ -53159,10 +62015,6 @@ function update(gd, traceUpdate, layoutUpdate, _traces) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); - if(gd.framework && gd.framework.isPolar) { - return Promise.resolve(gd); - } - if(!Lib.isPlainObject(traceUpdate)) traceUpdate = {}; if(!Lib.isPlainObject(layoutUpdate)) layoutUpdate = {}; @@ -53189,7 +62041,7 @@ function update(gd, traceUpdate, layoutUpdate, _traces) { // relayoutFlags.layoutReplot and restyleFlags.fullReplot are true seq.push(subroutines.layoutReplot); } else if(restyleFlags.fullReplot) { - seq.push(exports.plot); + seq.push(exports._doPlot); } else { seq.push(Plots.previousPromises); axRangeSupplyDefaultsByPass(gd, relayoutFlags, relayoutSpecs) || Plots.supplyDefaults(gd); @@ -53581,7 +62433,7 @@ function react(gd, data, layout, config) { }); } else if(restyleFlags.fullReplot || relayoutFlags.layoutReplot || configChanged) { gd._fullLayout._skipDefaults = true; - seq.push(exports.plot); + seq.push(exports._doPlot); } else { for(var componentType in relayoutFlags.arrays) { var indices = relayoutFlags.arrays[componentType]; @@ -54480,7 +63332,7 @@ function deleteFrames(gd, frameList) { } /** - * Purge a graph container div back to its initial pre-Plotly.plot state + * Purge a graph container div back to its initial pre-_doPlot state * * @param {string id or DOM element} gd * the id or DOM element of the graph container div @@ -54503,7 +63355,7 @@ function purge(gd) { // remove plot container if(fullLayout._container) fullLayout._container.remove(); - // in contrast to Plotly.Plots.purge which does NOT clear _context! + // in contrast to _doPlots.purge which does NOT clear _context! delete gd._context; return gd; @@ -54684,7 +63536,7 @@ exports.moveTraces = moveTraces; exports.prependTraces = prependTraces; exports.newPlot = newPlot; -exports.plot = plot; +exports._doPlot = _doPlot; exports.purge = purge; exports.react = react; @@ -54702,20 +63554,12 @@ exports._guiUpdate = guiEdit(update); exports._storeDirectGUIEdit = _storeDirectGUIEdit; -},{"../components/color":105,"../components/drawing":127,"../constants/xmlns_namespaces":213,"../lib":233,"../lib/events":226,"../lib/queue":248,"../lib/svg_text_utils":255,"../plots/cartesian/axes":279,"../plots/cartesian/constants":285,"../plots/cartesian/graph_interact":288,"../plots/cartesian/select":298,"../plots/plots":313,"../plots/polar/legacy":316,"../registry":326,"./edit_types":261,"./helpers":262,"./manage_arrays":264,"./plot_config":266,"./plot_schema":267,"./subroutines":269,"d3":21,"fast-isnumeric":23,"has-hover":54}],266:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../components/color":155,"../components/drawing":177,"../constants/xmlns_namespaces":266,"../lib":285,"../lib/events":278,"../lib/queue":300,"../plots/cartesian/axes":331,"../plots/cartesian/constants":337,"../plots/cartesian/graph_interact":340,"../plots/cartesian/select":350,"../plots/plots":366,"../registry":373,"./edit_types":313,"./helpers":314,"./manage_arrays":316,"./plot_config":318,"./plot_schema":319,"./subroutines":321,"@plotly/d3":20,"fast-isnumeric":31,"has-hover":62}],318:[function(_dereq_,module,exports){ 'use strict'; /** * This will be transferred over to gd and overridden by - * config args to Plotly.plot. + * config args to Plotly.newPlot. * * The defaults are the appropriate settings for plotly.js, * so we get the right experience without any config argument. @@ -54729,94 +63573,77 @@ var configAttributes = { staticPlot: { valType: 'boolean', dflt: false, - }, plotlyServerURL: { valType: 'string', dflt: '', - }, editable: { valType: 'boolean', dflt: false, - }, edits: { annotationPosition: { valType: 'boolean', dflt: false, - }, annotationTail: { valType: 'boolean', dflt: false, - }, annotationText: { valType: 'boolean', dflt: false, - }, axisTitleText: { valType: 'boolean', dflt: false, - }, colorbarPosition: { valType: 'boolean', dflt: false, - }, colorbarTitleText: { valType: 'boolean', dflt: false, - }, legendPosition: { valType: 'boolean', dflt: false, - }, legendText: { valType: 'boolean', dflt: false, - }, shapePosition: { valType: 'boolean', dflt: false, - }, titleText: { valType: 'boolean', dflt: false, - } }, autosizable: { valType: 'boolean', dflt: false, - }, responsive: { valType: 'boolean', dflt: false, - }, fillFrame: { valType: 'boolean', dflt: false, - }, frameMargins: { valType: 'number', dflt: 0, min: 0, max: 0.5, - }, scrollZoom: { @@ -54824,105 +63651,86 @@ var configAttributes = { flags: ['cartesian', 'gl3d', 'geo', 'mapbox'], extras: [true, false], dflt: 'gl3d+geo+mapbox', - }, doubleClick: { valType: 'enumerated', values: [false, 'reset', 'autosize', 'reset+autosize'], dflt: 'reset+autosize', - }, doubleClickDelay: { valType: 'number', dflt: 300, min: 0, - }, showAxisDragHandles: { valType: 'boolean', dflt: true, - }, showAxisRangeEntryBoxes: { valType: 'boolean', dflt: true, - }, showTips: { valType: 'boolean', dflt: true, - }, showLink: { valType: 'boolean', dflt: false, - }, linkText: { valType: 'string', dflt: 'Edit chart', noBlank: true, - }, sendData: { valType: 'boolean', dflt: true, - }, showSources: { valType: 'any', dflt: false, - }, displayModeBar: { valType: 'enumerated', values: ['hover', true, false], dflt: 'hover', - }, showSendToCloud: { valType: 'boolean', dflt: false, - }, showEditInChartStudio: { valType: 'boolean', dflt: false, - }, modeBarButtonsToRemove: { valType: 'any', dflt: [], - }, modeBarButtonsToAdd: { valType: 'any', dflt: [], - }, modeBarButtons: { valType: 'any', dflt: false, - }, toImageButtonOptions: { valType: 'any', dflt: {}, - }, displaylogo: { valType: 'boolean', dflt: true, - }, watermark: { valType: 'boolean', dflt: false, - }, plotGlPixelRatio: { @@ -54930,26 +63738,22 @@ var configAttributes = { dflt: 2, min: 1, max: 4, - }, setBackground: { valType: 'any', dflt: 'transparent', - }, topojsonURL: { valType: 'string', noBlank: true, dflt: 'https://cdn.plot.ly/', - }, mapboxAccessToken: { valType: 'string', dflt: null, - }, logging: { @@ -54957,7 +63761,6 @@ var configAttributes = { min: 0, max: 2, dflt: 1, - }, notifyOnLogging: { @@ -54965,32 +63768,27 @@ var configAttributes = { min: 0, max: 2, dflt: 0, - }, queueLength: { valType: 'integer', min: 0, dflt: 0, - }, globalTransforms: { valType: 'any', dflt: [], - }, locale: { valType: 'string', dflt: 'en-US', - }, locales: { valType: 'any', dflt: {}, - } }; @@ -55017,15 +63815,7 @@ module.exports = { dfltConfig: dfltConfig }; -},{}],267:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],319:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../registry'); @@ -55037,13 +63827,8 @@ var frameAttributes = _dereq_('../plots/frame_attributes'); var animationAttributes = _dereq_('../plots/animation_attributes'); var configAttributes = _dereq_('./plot_config').configAttributes; -// polar attributes are not part of the Registry yet -var polarAreaAttrs = _dereq_('../plots/polar/legacy/area_attributes'); -var polarAxisAttrs = _dereq_('../plots/polar/legacy/axis_attributes'); - var editTypes = _dereq_('./edit_types'); -var extendFlat = Lib.extendFlat; var extendDeepAll = Lib.extendDeepAll; var isPlainObject = Lib.isPlainObject; var isArrayOrTypedArray = Lib.isArrayOrTypedArray; @@ -55075,7 +63860,7 @@ exports.UNDERSCORE_ATTRS = UNDERSCORE_ATTRS; exports.get = function() { var traces = {}; - Registry.allTypes.concat('area').forEach(function(type) { + Registry.allTypes.forEach(function(type) { traces[type] = getTraceAttributes(type); }); @@ -55094,7 +63879,6 @@ exports.get = function() { layout: editTypes.layout }, impliedEdits: { - } }, @@ -55287,8 +64071,6 @@ exports.getTraceValObject = function(trace, parts) { moduleAttrs = (Registry.transformsRegistry[transforms[tNum].type] || {}).attributes; valObject = moduleAttrs && moduleAttrs[parts[2]]; i = 3; // start recursing only inside the transform - } else if(trace.type === 'area') { - valObject = polarAreaAttrs[head]; } else { // first look in the module for this trace // components have already merged their trace attributes in here @@ -55389,12 +64171,7 @@ function layoutHeadAttr(fullLayout, head) { if(head in baseLayoutAttributes) return baseLayoutAttributes[head]; - // Polar doesn't populate _modules or _basePlotModules - // just fall back on these when the others fail - if(head === 'radialaxis' || head === 'angularaxis') { - return polarAxisAttrs[head]; - } - return polarAxisAttrs.layout[head] || false; + return false; } function recurseIntoValObject(valObject, parts, i) { @@ -55452,13 +64229,8 @@ function isIndex(val) { function getTraceAttributes(type) { var _module, basePlotModule; - if(type === 'area') { - _module = { attributes: polarAreaAttrs }; - basePlotModule = {}; - } else { - _module = Registry.modules[type]._module, - basePlotModule = _module.basePlotModule; - } + _module = Registry.modules[type]._module, + basePlotModule = _module.basePlotModule; var attributes = {}; @@ -55556,9 +64328,6 @@ function getLayoutAttributes() { } } - // polar layout attributes - layoutAttributes = assignPolarLayoutAttrs(layoutAttributes); - // add registered components layout attributes for(key in Registry.componentsRegistry) { _module = Registry.componentsRegistry[key]; @@ -55636,21 +64405,14 @@ function mergeValTypeAndRole(attrs) { function makeSrcAttr(attrName) { return { valType: 'string', - - editType: 'none' }; } function callback(attr, attrName, attrs) { if(exports.isValObject(attr)) { - if(attr.valType === 'data_array') { - // all 'data_array' attrs have role 'data' - attr.role = 'data'; - // all 'data_array' attrs have a corresponding 'src' attr - attrs[attrName + 'src'] = makeSrcAttr(attrName); - } else if(attr.arrayOk === true) { - // all 'arrayOk' attrs have a corresponding 'src' attr + if(attr.arrayOk === true || attr.valType === 'data_array') { + // all 'arrayOk' and 'data_array' attrs have a corresponding 'src' attr attrs[attrName + 'src'] = makeSrcAttr(attrName); } } else if(isPlainObject(attr)) { @@ -55703,16 +64465,6 @@ function stringify(attrs) { walk(attrs); } -function assignPolarLayoutAttrs(layoutAttributes) { - extendFlat(layoutAttributes, { - radialaxis: polarAxisAttrs.radialaxis, - angularaxis: polarAxisAttrs.angularaxis - }); - - extendFlat(layoutAttributes, polarAxisAttrs.layout); - - return layoutAttributes; -} function handleBasePlotModule(layoutAttributes, _module, astr) { var np = nestedProperty(layoutAttributes, astr); @@ -55728,16 +64480,7 @@ function insertAttrs(baseAttrs, newAttrs, astr) { np.set(extendDeepAll(np.get() || {}, newAttrs)); } -},{"../lib":233,"../plots/animation_attributes":273,"../plots/attributes":275,"../plots/frame_attributes":308,"../plots/layout_attributes":311,"../plots/polar/legacy/area_attributes":314,"../plots/polar/legacy/axis_attributes":315,"../registry":326,"./edit_types":261,"./plot_config":266}],268:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../lib":285,"../plots/animation_attributes":325,"../plots/attributes":327,"../plots/frame_attributes":360,"../plots/layout_attributes":364,"../registry":373,"./edit_types":313,"./plot_config":318}],320:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../lib'); @@ -55748,16 +64491,12 @@ var TEMPLATEITEMNAME = 'templateitemname'; var templateAttrs = { name: { valType: 'string', - editType: 'none', - } }; templateAttrs[TEMPLATEITEMNAME] = { valType: 'string', - editType: 'calc', - }; /** @@ -56040,18 +64779,10 @@ exports.arrayEditor = function(parentIn, containerStr, itemOut) { }; }; -},{"../lib":233,"../plots/attributes":275}],269:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285,"../plots/attributes":327}],321:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Registry = _dereq_('../registry'); var Plots = _dereq_('../plots/plots'); @@ -56579,7 +65310,7 @@ exports.doColorBars = function(gd) { exports.layoutReplot = function(gd) { var layout = gd.layout; gd.layout = undefined; - return Registry.call('plot', gd, '', layout); + return Registry.call('_doPlot', gd, '', layout); }; exports.doLegend = function(gd) { @@ -56764,16 +65495,7 @@ exports.drawMarginPushers = function(gd) { Registry.getComponentMethod('colorbar', 'draw')(gd); }; -},{"../components/color":105,"../components/drawing":127,"../components/modebar":165,"../components/titles":200,"../constants/alignment":207,"../lib":233,"../lib/clear_gl_canvases":221,"../plots/cartesian/autorange":278,"../plots/cartesian/axes":279,"../plots/cartesian/constraints":286,"../plots/plots":313,"../registry":326,"d3":21}],270:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../components/color":155,"../components/drawing":177,"../components/modebar":218,"../components/titles":253,"../constants/alignment":260,"../lib":285,"../lib/clear_gl_canvases":273,"../plots/cartesian/autorange":330,"../plots/cartesian/axes":331,"../plots/cartesian/constraints":338,"../plots/plots":366,"../registry":373,"@plotly/d3":20}],322:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../lib'); @@ -57226,15 +65948,7 @@ function format(opts) { return opts; } -},{"../lib":233,"../plots/attributes":275,"../plots/plots":313,"./plot_config":266,"./plot_schema":267,"./plot_template":268}],271:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285,"../plots/attributes":327,"../plots/plots":366,"./plot_config":318,"./plot_schema":319,"./plot_template":320}],323:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -57253,33 +65967,27 @@ var attrs = { valType: 'enumerated', values: ['png', 'jpeg', 'webp', 'svg', 'full-json'], dflt: 'png', - }, width: { valType: 'number', min: 1, - }, height: { valType: 'number', min: 1, - }, scale: { valType: 'number', min: 0, dflt: 1, - }, setBackground: { valType: 'any', dflt: false, - }, imageDataOnly: { valType: 'boolean', dflt: false, - } }; @@ -57436,7 +66144,7 @@ function toImage(gd, opts) { } return new Promise(function(resolve, reject) { - plotApi.plot(clonedGd, data, layoutImage, configImage) + plotApi.newPlot(clonedGd, data, layoutImage, configImage) .then(redrawFunc) .then(wait) .then(convert) @@ -57447,15 +66155,7 @@ function toImage(gd, opts) { module.exports = toImage; -},{"../lib":233,"../plots/plots":313,"../snapshot/helpers":330,"../snapshot/svgtoimg":332,"../snapshot/tosvg":334,"../version":494,"./plot_api":265,"fast-isnumeric":23}],272:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285,"../plots/plots":366,"../snapshot/helpers":377,"../snapshot/svgtoimg":379,"../snapshot/tosvg":381,"../version":546,"./plot_api":317,"fast-isnumeric":31}],324:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../lib'); @@ -57878,61 +66578,41 @@ function convertPathToAttributeString(path) { return astr; } -},{"../lib":233,"../plots/plots":313,"./plot_config":266,"./plot_schema":267}],273:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285,"../plots/plots":366,"./plot_config":318,"./plot_schema":319}],325:[function(_dereq_,module,exports){ 'use strict'; module.exports = { mode: { valType: 'enumerated', dflt: 'afterall', - values: ['immediate', 'next', 'afterall'], - }, direction: { valType: 'enumerated', - values: ['forward', 'reverse'], dflt: 'forward', - }, fromcurrent: { valType: 'boolean', dflt: false, - - }, frame: { duration: { valType: 'number', - min: 0, dflt: 500, - }, redraw: { valType: 'boolean', - dflt: true, - }, }, transition: { duration: { valType: 'number', - min: 0, dflt: 500, editType: 'none', - }, easing: { valType: 'enumerated', @@ -57975,30 +66655,18 @@ module.exports = { 'back-in-out', 'bounce-in-out' ], - editType: 'none', - }, ordering: { valType: 'enumerated', values: ['layout first', 'traces first'], dflt: 'layout first', - editType: 'none', - } } }; -},{}],274:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],326:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../lib'); @@ -58085,15 +66753,7 @@ module.exports = function handleArrayContainerDefaults(parentObjIn, parentObjOut return contOut; }; -},{"../lib":233,"../plot_api/plot_template":268}],275:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285,"../plot_api/plot_template":320}],327:[function(_dereq_,module,exports){ 'use strict'; var fxAttrs = _dereq_('../components/fx/attributes'); @@ -58101,7 +66761,6 @@ var fxAttrs = _dereq_('../components/fx/attributes'); module.exports = { type: { valType: 'enumerated', - values: [], // listed dynamically dflt: 'scatter', editType: 'calc+clearAxisTypes', @@ -58110,64 +66769,48 @@ module.exports = { visible: { valType: 'enumerated', values: [true, false, 'legendonly'], - dflt: true, editType: 'calc', - }, showlegend: { valType: 'boolean', - dflt: true, editType: 'style', - }, legendgroup: { valType: 'string', - dflt: '', editType: 'style', - }, opacity: { valType: 'number', - min: 0, max: 1, dflt: 1, editType: 'style', - }, name: { valType: 'string', - editType: 'style', - }, uid: { valType: 'string', - editType: 'plot', anim: true, - }, ids: { valType: 'data_array', editType: 'calc', anim: true, - }, customdata: { valType: 'data_array', editType: 'calc', - }, meta: { valType: 'any', arrayOk: true, - editType: 'plot', - }, // N.B. these cannot be 'data_array' as they do not have the same length as @@ -58177,20 +66820,16 @@ module.exports = { // https://github.com/plotly/plotly.js/issues/1894 selectedpoints: { valType: 'any', - editType: 'calc', - }, hoverinfo: { valType: 'flaglist', - flags: ['x', 'y', 'z', 'text', 'name'], extras: ['all', 'none', 'skip'], arrayOk: true, dflt: 'all', editType: 'none', - }, hoverlabel: fxAttrs.hoverlabel, stream: { @@ -58198,43 +66837,28 @@ module.exports = { valType: 'string', noBlank: true, strict: true, - editType: 'calc', - }, maxpoints: { valType: 'number', min: 0, max: 10000, dflt: 500, - editType: 'calc', - }, editType: 'calc' }, transforms: { _isLinkedToArray: 'transform', editType: 'calc', - }, uirevision: { valType: 'any', - editType: 'none', - } }; -},{"../components/fx/attributes":136}],276:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../components/fx/attributes":186}],328:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -58318,51 +66942,33 @@ module.exports = function alignPeriod(trace, ax, axLetter, vals) { return newVals; }; -},{"../../constants/numerical":212,"../../lib":233,"fast-isnumeric":23}],277:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/numerical":265,"../../lib":285,"fast-isnumeric":31}],329:[function(_dereq_,module,exports){ 'use strict'; module.exports = { xaxis: { valType: 'subplotid', - dflt: 'x', editType: 'calc+clearAxisTypes', - }, yaxis: { valType: 'subplotid', - dflt: 'y', editType: 'calc+clearAxisTypes', - } }; -},{}],278:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],330:[function(_dereq_,module,exports){ 'use strict'; +var d3 = _dereq_('@plotly/d3'); var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); var FP_SAFE = _dereq_('../../constants/numerical').FP_SAFE; var Registry = _dereq_('../../registry'); +var Drawing = _dereq_('../../components/drawing'); var axIds = _dereq_('./axis_ids'); var getFromId = axIds.getFromId; @@ -58575,7 +67181,7 @@ function makePadFn(fullLayout, ax, max) { var zero = 0; if(!isLinked(fullLayout, ax._id)) { - zero = padInsideLabelsOnAnchorAxis(ax, max); + zero = padInsideLabelsOnAnchorAxis(fullLayout, ax, max); } extrappad = Math.max(zero, extrappad); @@ -58594,45 +67200,69 @@ function makePadFn(fullLayout, ax, max) { var TEXTPAD = 3; -function padInsideLabelsOnAnchorAxis(ax, max) { +function padInsideLabelsOnAnchorAxis(fullLayout, ax, max) { var pad = 0; - var anchorAxis = ax._anchorAxis || {}; - if((anchorAxis.ticklabelposition || '').indexOf('inside') !== -1) { - // increase padding to make more room for inside tick labels of the counter axis - if(( - !max && ( - anchorAxis.side === 'left' || - anchorAxis.side === 'bottom' - ) - ) || ( - max && ( - anchorAxis.side === 'top' || - anchorAxis.side === 'right' - ) - )) { - var isX = ax._id.charAt(0) === 'x'; - if(anchorAxis._vals) { - var rad = Lib.deg2rad(anchorAxis._tickAngles[anchorAxis._id + 'tick'] || 0); - var cosA = Math.abs(Math.cos(rad)); - var sinA = Math.abs(Math.sin(rad)); + var isX = ax._id.charAt(0) === 'x'; - // use bounding boxes - anchorAxis._vals.forEach(function(t) { - if(t.bb) { - var w = 2 * TEXTPAD + t.bb.width; - var h = 2 * TEXTPAD + t.bb.height; + for(var subplot in fullLayout._plots) { + var plotinfo = fullLayout._plots[subplot]; - pad = Math.max(pad, isX ? - Math.max(w * cosA, h * sinA) : - Math.max(h * cosA, w * sinA) - ); + if(ax._id !== plotinfo.xaxis._id && ax._id !== plotinfo.yaxis._id) continue; + + var anchorAxis = (isX ? plotinfo.yaxis : plotinfo.xaxis) || {}; + + if((anchorAxis.ticklabelposition || '').indexOf('inside') !== -1) { + // increase padding to make more room for inside tick labels of the counter axis + if(( + !max && ( + anchorAxis.side === 'left' || + anchorAxis.side === 'bottom' + ) + ) || ( + max && ( + anchorAxis.side === 'top' || + anchorAxis.side === 'right' + ) + )) { + if(anchorAxis._vals) { + var rad = Lib.deg2rad(anchorAxis._tickAngles[anchorAxis._id + 'tick'] || 0); + var cosA = Math.abs(Math.cos(rad)); + var sinA = Math.abs(Math.sin(rad)); + + // no stashed bounding boxes - stash bounding boxes + if(!anchorAxis._vals[0].bb) { + var cls = anchorAxis._id + 'tick'; + var tickLabels = anchorAxis._selections[cls]; + tickLabels.each(function(d) { + var thisLabel = d3.select(this); + var mathjaxGroup = thisLabel.select('.text-math-group'); + if(mathjaxGroup.empty()) { + d.bb = Drawing.bBox(thisLabel.node()); + } + }); } - }); - } - if(anchorAxis.ticks === 'inside' && anchorAxis.ticklabelposition === 'inside') { - pad += anchorAxis.ticklen || 0; + // use bounding boxes + for(var i = 0; i < anchorAxis._vals.length; i++) { + var t = anchorAxis._vals[i]; + var bb = t.bb; + + if(bb) { + var w = 2 * TEXTPAD + bb.width; + var h = 2 * TEXTPAD + bb.height; + + pad = Math.max(pad, isX ? + Math.max(w * cosA, h * sinA) : + Math.max(h * cosA, w * sinA) + ); + } + } + } + + if(anchorAxis.ticks === 'inside' && anchorAxis.ticklabelposition === 'inside') { + pad += anchorAxis.ticklen || 0; + } } } } @@ -58956,18 +67586,10 @@ function goodNumber(v) { function lessOrEqual(v0, v1) { return v0 <= v1; } function greaterOrEqual(v0, v1) { return v0 >= v1; } -},{"../../constants/numerical":212,"../../lib":233,"../../registry":326,"./axis_ids":282,"fast-isnumeric":23}],279:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/drawing":177,"../../constants/numerical":265,"../../lib":285,"../../registry":373,"./axis_ids":334,"@plotly/d3":20,"fast-isnumeric":31}],331:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var isNumeric = _dereq_('fast-isnumeric'); var Plots = _dereq_('../../plots/plots'); @@ -59001,6 +67623,11 @@ var ONESEC = constants.ONESEC; var MINUS_SIGN = constants.MINUS_SIGN; var BADNUM = constants.BADNUM; +var ZERO_PATH = { K: 'zeroline' }; +var GRID_PATH = { K: 'gridline', L: 'path' }; +var TICK_PATH = { K: 'tick', L: 'path' }; +var TICK_TEXT = { K: 'tick', L: 'text' }; + var alignmentConstants = _dereq_('../../constants/alignment'); var MID_SHIFT = alignmentConstants.MID_SHIFT; var CAP_SHIFT = alignmentConstants.CAP_SHIFT; @@ -59516,7 +68143,7 @@ axes.prepTicks = function(ax, opts) { if(!nt) { if(ax.type === 'category' || ax.type === 'multicategory') { - minPx = ax.tickfont ? (ax.tickfont.size || 12) * 1.2 : 15; + minPx = ax.tickfont ? Lib.bigFont(ax.tickfont.size || 12) : 15; nt = ax._length / minPx; } else { minPx = ax._id.charAt(0) === 'y' ? 40 : 80; @@ -60323,16 +68950,23 @@ axes.tickText = function(ax, x, hover, noSuffixPrefix) { * log axes (where negative values can't be displayed but can appear in hover text) * * @param {object} ax: the axis to format text for - * @param {number} val: calcdata value to format - * @param {Optional(number)} val2: a second value to display + * @param {number or array of numbers} values: calcdata value(s) to format + * @param {Optional(string)} hoverformat: trace (x|y)hoverformat to override axis.hoverformat * * @returns {string} `val` formatted as a string appropriate to this axis, or - * `val` and `val2` as a range (ie ' - ') if `val2` is provided and - * it's different from `val`. + * first value and second value as a range (ie ' - ') if the second value is provided and + * it's different from the first value. */ -axes.hoverLabelText = function(ax, val, val2) { - if(val2 !== BADNUM && val2 !== val) { - return axes.hoverLabelText(ax, val) + ' - ' + axes.hoverLabelText(ax, val2); +axes.hoverLabelText = function(ax, values, hoverformat) { + if(hoverformat) ax = Lib.extendFlat({}, ax, {hoverformat: hoverformat}); + + var val = Array.isArray(values) ? values[0] : values; + var val2 = Array.isArray(values) ? values[1] : undefined; + if(val2 !== undefined && val2 !== val) { + return ( + axes.hoverLabelText(ax, val, hoverformat) + ' - ' + + axes.hoverLabelText(ax, val2, hoverformat) + ); } var logOffScale = (ax.type === 'log' && val <= 0); @@ -60416,7 +69050,7 @@ function formatDate(ax, out, hover, extraPrecision) { ax._prevDateHead = headStr; dateStr += '
' + headStr; } else { - var isInside = (ax.ticklabelposition || '').indexOf('inside') !== -1; + var isInside = insideTicklabelposition(ax); var side = ax._realSide || ax.side; // polar mocks the side of the radial axis if( (!isInside && side === 'top') || @@ -61147,6 +69781,7 @@ axes.drawOne = function(gd, ax, opts) { return axes.drawLabels(gd, ax, { vals: vals, layer: mainAxLayer, + plotinfo: plotinfo, transFn: transTickLabelFn, labelFns: axes.makeLabelFns(ax, mainLinePosition) }); @@ -61765,7 +70400,10 @@ axes.drawTicks = function(gd, ax, opts) { .classed('crisp', opts.crisp !== false) .call(Color.stroke, ax.tickcolor) .style('stroke-width', Drawing.crispRound(gd, ax.tickwidth, 1) + 'px') - .attr('d', opts.path); + .attr('d', opts.path) + .style('display', null); // visible + + hideCounterAxisInsideTickLabels(ax, [TICK_PATH]); ticks.attr('transform', opts.transFn); }; @@ -61828,7 +70466,10 @@ axes.drawGrid = function(gd, ax, opts) { grid.attr('transform', opts.transFn) .attr('d', opts.path) .call(Color.stroke, ax.gridcolor || '#ddd') - .style('stroke-width', ax._gw + 'px'); + .style('stroke-width', ax._gw + 'px') + .style('display', null); // visible + + hideCounterAxisInsideTickLabels(ax, [GRID_PATH]); if(typeof opts.path === 'function') grid.attr('d', opts.path); }; @@ -61877,7 +70518,10 @@ axes.drawZeroLine = function(gd, ax, opts) { zl.attr('transform', opts.transFn) .attr('d', opts.path) .call(Color.stroke, ax.zerolinecolor || Color.defaultLine) - .style('stroke-width', Drawing.crispRound(gd, ax.zerolinewidth, ax._gw || 1) + 'px'); + .style('stroke-width', Drawing.crispRound(gd, ax.zerolinewidth, ax._gw || 1) + 'px') + .style('display', null); // visible + + hideCounterAxisInsideTickLabels(ax, [ZERO_PATH]); }; /** @@ -61952,6 +70596,8 @@ axes.drawLabels = function(gd, ax, opts) { } }); + hideCounterAxisInsideTickLabels(ax, [TICK_TEXT]); + tickLabels.exit().remove(); if(opts.repositionOnUpdate) { @@ -61962,8 +70608,6 @@ axes.drawLabels = function(gd, ax, opts) { } function positionLabels(s, angle) { - var isInside = (ax.ticklabelposition || '').indexOf('inside') !== -1; - s.each(function(d) { var thisLabel = d3.select(this); var mathjaxGroup = thisLabel.select('.text-math-group'); @@ -61991,13 +70635,10 @@ axes.drawLabels = function(gd, ax, opts) { 'text-anchor': anchor }); - if(isInside) { - // ensure visible - thisText.style({ opacity: 100 }); + thisText.style('opacity', 1); // visible - if(ax._hideOutOfRangeInsideTickLabels) { - ax._hideOutOfRangeInsideTickLabels(); - } + if(ax._adjustTickLabelsOverflow) { + ax._adjustTickLabelsOverflow(); } } else { var mjWidth = Drawing.bBox(mathjaxGroup.node()).width; @@ -62007,39 +70648,135 @@ axes.drawLabels = function(gd, ax, opts) { }); } - ax._hideOutOfRangeInsideTickLabels = undefined; - if((ax.ticklabelposition || '').indexOf('inside') !== -1) { - ax._hideOutOfRangeInsideTickLabels = function() { + ax._adjustTickLabelsOverflow = function() { + var ticklabeloverflow = ax.ticklabeloverflow; + if(!ticklabeloverflow || ticklabeloverflow === 'allow') return; + + var hideOverflow = ticklabeloverflow.indexOf('hide') !== -1; + + var isX = ax._id.charAt(0) === 'x'; + // div positions + var p0 = 0; + var p1 = isX ? + gd._fullLayout.width : + gd._fullLayout.height; + + if(ticklabeloverflow.indexOf('domain') !== -1) { + // domain positions var rl = Lib.simpleMap(ax.range, ax.r2l); + p0 = ax.l2p(rl[0]) + ax._offset; + p1 = ax.l2p(rl[1]) + ax._offset; + } - // hide inside tick labels that go outside axis end points - var p0 = ax.l2p(rl[0]); - var p1 = ax.l2p(rl[1]); + var min = Math.min(p0, p1); + var max = Math.max(p0, p1); - var min = Math.min(p0, p1) + ax._offset; - var max = Math.max(p0, p1) + ax._offset; + var side = ax.side; - var isX = ax._id.charAt(0) === 'x'; + var visibleLabelMin = Infinity; + var visibleLabelMax = -Infinity; - tickLabels.each(function(d) { - var thisLabel = d3.select(this); - var mathjaxGroup = thisLabel.select('.text-math-group'); + tickLabels.each(function(d) { + var thisLabel = d3.select(this); + var mathjaxGroup = thisLabel.select('.text-math-group'); - if(mathjaxGroup.empty()) { - var bb = Drawing.bBox(thisLabel.node()); - var hide = false; - if(isX) { - if(bb.right > max) hide = true; - else if(bb.left < min) hide = true; + if(mathjaxGroup.empty()) { + var bb = Drawing.bBox(thisLabel.node()); + var adjust = 0; + if(isX) { + if(bb.right > max) adjust = 1; + else if(bb.left < min) adjust = 1; + } else { + if(bb.bottom > max) adjust = 1; + else if(bb.top + (ax.tickangle ? 0 : d.fontSize / 4) < min) adjust = 1; + } + + var t = thisLabel.select('text'); + if(adjust) { + if(hideOverflow) t.style('opacity', 0); // hidden + } else { + t.style('opacity', 1); // visible + + if(side === 'bottom' || side === 'right') { + visibleLabelMin = Math.min(visibleLabelMin, isX ? bb.top : bb.left); } else { - if(bb.bottom > max) hide = true; - else if(bb.top + (ax.tickangle ? 0 : d.fontSize / 4) < min) hide = true; + visibleLabelMin = -Infinity; } - if(hide) thisLabel.select('text').style({ opacity: 0 }); - } // TODO: hide mathjax? - }); - }; - } + + if(side === 'top' || side === 'left') { + visibleLabelMax = Math.max(visibleLabelMax, isX ? bb.bottom : bb.right); + } else { + visibleLabelMax = Infinity; + } + } + } // TODO: hide mathjax? + }); + + for(var subplot in fullLayout._plots) { + var plotinfo = fullLayout._plots[subplot]; + if(ax._id !== plotinfo.xaxis._id && ax._id !== plotinfo.yaxis._id) continue; + var anchorAx = isX ? plotinfo.yaxis : plotinfo.xaxis; + if(anchorAx) { + anchorAx['_visibleLabelMin_' + ax._id] = visibleLabelMin; + anchorAx['_visibleLabelMax_' + ax._id] = visibleLabelMax; + } + } + }; + + ax._hideCounterAxisInsideTickLabels = function(partialOpts) { + var isX = ax._id.charAt(0) === 'x'; + + var anchoredAxes = []; + for(var subplot in fullLayout._plots) { + var plotinfo = fullLayout._plots[subplot]; + if(ax._id !== plotinfo.xaxis._id && ax._id !== plotinfo.yaxis._id) continue; + anchoredAxes.push(isX ? plotinfo.yaxis : plotinfo.xaxis); + } + + anchoredAxes.forEach(function(anchorAx, idx) { + if(anchorAx && insideTicklabelposition(anchorAx)) { + (partialOpts || [ + ZERO_PATH, + GRID_PATH, + TICK_PATH, + TICK_TEXT + ]).forEach(function(e) { + var isPeriodLabel = + e.K === 'tick' && + e.L === 'text' && + ax.ticklabelmode === 'period'; + + var mainPlotinfo = fullLayout._plots[ax._mainSubplot]; + + var sel; + if(e.K === ZERO_PATH.K) sel = mainPlotinfo.zerolinelayer.selectAll('.' + ax._id + 'zl'); + else if(e.K === GRID_PATH.K) sel = mainPlotinfo.gridlayer.selectAll('.' + ax._id); + else sel = mainPlotinfo[ax._id.charAt(0) + 'axislayer']; + + sel.each(function() { + var w = d3.select(this); + if(e.L) w = w.selectAll(e.L); + + w.each(function(d) { + var q = ax.l2p( + isPeriodLabel ? getPosX(d) : d.x + ) + ax._offset; + + var t = d3.select(this); + if( + q < ax['_visibleLabelMax_' + anchorAx._id] && + q > ax['_visibleLabelMin_' + anchorAx._id] + ) { + t.style('display', 'none'); // hidden + } else if(e.K === 'tick' && !idx) { + t.style('display', null); // visible + } + }); + }); + }); + } + }); + }; // make sure all labels are correctly positioned at their base angle // the positionLabels call above is only for newly drawn labels. @@ -62168,7 +70905,7 @@ axes.drawLabels = function(gd, ax, opts) { var anchorAx = ax._anchorAxis; if( anchorAx && anchorAx.autorange && - (ax.ticklabelposition || '').indexOf('inside') !== -1 && + insideTicklabelposition(ax) && !isLinked(fullLayout, ax._id) ) { if(!fullLayout._insideTickLabelsAutorange) { @@ -62180,7 +70917,10 @@ axes.drawLabels = function(gd, ax, opts) { function computeFinalTickLabelBoundingBoxes() { tickLabels.each(function(d, i) { var thisLabel = selectTickLabel(this); - ax._vals[i].bb = Drawing.bBox(thisLabel.node()); + var mathjaxGroup = thisLabel.select('.text-math-group'); + if(mathjaxGroup.empty()) { + ax._vals[i].bb = Drawing.bBox(thisLabel.node()); + } }); } ); @@ -62317,7 +71057,7 @@ function drawTitle(gd, ax) { if(ax.title.hasOwnProperty('standoff')) { titleStandoff = ax._depth + ax.title.standoff + approxTitleDepth(ax); } else { - var isInside = (ax.ticklabelposition || '').indexOf('inside') !== -1; + var isInside = insideTicklabelposition(ax); if(ax.type === 'multicategory') { titleStandoff = ax._depth; @@ -62676,16 +71416,19 @@ function moveOutsideBreak(v, ax) { return v; } -},{"../../components/color":105,"../../components/drawing":127,"../../components/titles":200,"../../constants/alignment":207,"../../constants/numerical":212,"../../lib":233,"../../lib/svg_text_utils":255,"../../plots/plots":313,"../../registry":326,"./autorange":278,"./axis_autotype":280,"./axis_ids":282,"./clean_ticks":284,"./layout_attributes":293,"./set_convert":299,"d3":21,"fast-isnumeric":23}],280:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +function insideTicklabelposition(ax) { + return ((ax.ticklabelposition || '').indexOf('inside') !== -1); +} +function hideCounterAxisInsideTickLabels(ax, opts) { + if(insideTicklabelposition(ax._anchorAxis || {})) { + if(ax._hideCounterAxisInsideTickLabels) { + ax._hideCounterAxisInsideTickLabels(opts); + } + } +} +},{"../../components/color":155,"../../components/drawing":177,"../../components/titles":253,"../../constants/alignment":260,"../../constants/numerical":265,"../../lib":285,"../../lib/svg_text_utils":307,"../../plots/plots":366,"../../registry":373,"./autorange":330,"./axis_autotype":332,"./axis_ids":334,"./clean_ticks":336,"./layout_attributes":345,"./set_convert":351,"@plotly/d3":20,"fast-isnumeric":31}],332:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -62807,15 +71550,7 @@ function multiCategory(a) { return isArrayOrTypedArray(a[0]) && isArrayOrTypedArray(a[1]); } -},{"../../constants/numerical":212,"../../lib":233,"fast-isnumeric":23}],281:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/numerical":265,"../../lib":285,"fast-isnumeric":31}],333:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -62874,8 +71609,9 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, } } + var ticklabelposition = ''; if(!options.noTicklabelposition || axType === 'multicategory') { - Lib.coerce(containerIn, containerOut, { + ticklabelposition = Lib.coerce(containerIn, containerOut, { ticklabelposition: { valType: 'enumerated', dflt: 'outside', @@ -62893,6 +71629,17 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, }, 'ticklabelposition'); } + if(!options.noTicklabeloverflow) { + coerce('ticklabeloverflow', + ticklabelposition.indexOf('inside') !== -1 ? + 'hide past domain' : + axType === 'category' || + axType === 'multicategory' ? + 'allow' : + 'hide past div' + ); + } + setConvert(containerOut, layoutOut); var autorangeDflt = !containerOut.isValidRange(containerIn.range); @@ -62922,7 +71669,7 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, coerce('title.text', dfltTitle); Lib.coerceFont(coerce, 'title.font', { family: font.family, - size: Math.round(font.size * 1.2), + size: Lib.bigFont(font.size), color: dfltFontColor }); @@ -63115,15 +71862,7 @@ function indexOfDay(v) { ]; } -},{"../../lib":233,"../../registry":326,"../array_container_defaults":274,"./category_order_defaults":283,"./constants":285,"./layout_attributes":293,"./line_grid_defaults":295,"./set_convert":299,"./tick_label_defaults":300,"./tick_mark_defaults":301,"./tick_value_defaults":302,"fast-isnumeric":23}],282:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../registry":373,"../array_container_defaults":326,"./category_order_defaults":335,"./constants":337,"./layout_attributes":345,"./line_grid_defaults":347,"./set_convert":351,"./tick_label_defaults":352,"./tick_mark_defaults":353,"./tick_value_defaults":354,"fast-isnumeric":31}],334:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -63271,15 +72010,7 @@ exports.isLinked = function(fullLayout, axId) { ); }; -},{"../../registry":326,"./constants":285}],283:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../registry":373,"./constants":337}],335:[function(_dereq_,module,exports){ 'use strict'; function findCategories(ax, opts) { @@ -63365,15 +72096,7 @@ module.exports = function handleCategoryOrderDefaults(containerIn, containerOut, } }; -},{}],284:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],336:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -63457,15 +72180,7 @@ exports.tick0 = function(tick0, axType, calendar, dtick) { return isNumeric(tick0) ? Number(tick0) : 0; }; -},{"../../constants/numerical":212,"../../lib":233,"fast-isnumeric":23}],285:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/numerical":265,"../../lib":285,"fast-isnumeric":31}],337:[function(_dereq_,module,exports){ 'use strict'; var counterRegex = _dereq_('../../lib/regex').counter; @@ -63549,15 +72264,7 @@ module.exports = { } }; -},{"../../lib/regex":249}],286:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib/regex":301}],338:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -64200,18 +72907,10 @@ function updateDomain(ax, factor) { ax.setScale(); } -},{"../../constants/alignment":207,"../../constants/numerical":212,"../../lib":233,"./autorange":278,"./axis_ids":282,"./layout_attributes":293,"./scale_zoom":297,"./set_convert":299}],287:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/alignment":260,"../../constants/numerical":265,"../../lib":285,"./autorange":330,"./axis_ids":334,"./layout_attributes":345,"./scale_zoom":349,"./set_convert":351}],339:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var tinycolor = _dereq_('tinycolor2'); var supportsPassive = _dereq_('has-passive-events'); @@ -64746,6 +73445,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { // then replot after a delay to make sure // no more scrolling is coming redrawTimer = setTimeout(function() { + if(!gd._fullLayout) return; scrollViewBox = [0, 0, pw, ph]; dragTail(); }, REDRAWDELAY); @@ -65538,19 +74238,10 @@ module.exports = { attachWheelEventHandler: attachWheelEventHandler }; -},{"../../components/color":105,"../../components/dragelement":124,"../../components/dragelement/helpers":123,"../../components/drawing":127,"../../components/fx":145,"../../constants/alignment":207,"../../lib":233,"../../lib/clear_gl_canvases":221,"../../lib/setcursor":253,"../../lib/svg_text_utils":255,"../../plot_api/subroutines":269,"../../registry":326,"../plots":313,"./axes":279,"./axis_ids":282,"./constants":285,"./scale_zoom":297,"./select":298,"d3":21,"has-passive-events":55,"tinycolor2":88}],288:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/color":155,"../../components/dragelement":174,"../../components/dragelement/helpers":173,"../../components/drawing":177,"../../components/fx":195,"../../constants/alignment":260,"../../lib":285,"../../lib/clear_gl_canvases":273,"../../lib/setcursor":305,"../../lib/svg_text_utils":307,"../../plot_api/subroutines":321,"../../registry":373,"../plots":366,"./axes":331,"./axis_ids":334,"./constants":337,"./scale_zoom":349,"./select":350,"@plotly/d3":20,"has-passive-events":63,"tinycolor2":119}],340:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Fx = _dereq_('../../components/fx'); var dragElement = _dereq_('../../components/dragelement'); @@ -65706,16 +74397,7 @@ exports.updateFx = function(gd) { setCursor(fullLayout._draggers, cursor); }; -},{"../../components/dragelement":124,"../../components/fx":145,"../../lib/setcursor":253,"./constants":285,"./dragbox":287,"d3":21}],289:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/dragelement":174,"../../components/fx":195,"../../lib/setcursor":305,"./constants":337,"./dragbox":339,"@plotly/d3":20}],341:[function(_dereq_,module,exports){ 'use strict'; function clearOutlineControllers(gd) { @@ -65742,21 +74424,12 @@ module.exports = { clearSelect: clearSelect }; -},{}],290:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],342:[function(_dereq_,module,exports){ 'use strict'; var strTranslate = _dereq_('../../lib').strTranslate; -// in v2 (once log ranges are fixed), +// in v3 (once log ranges are fixed), // we'll be able to p2r here for all axis types function p2r(ax, v) { switch(ax.type) { @@ -65799,16 +74472,7 @@ module.exports = { getTransform: getTransform }; -},{"../../lib":233}],291:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285}],343:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -65877,19 +74541,10 @@ module.exports = function makeIncludeComponents(containerArrayName) { }; }; -},{"../../lib":233,"../../registry":326,"./axis_ids":282}],292:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../registry":373,"./axis_ids":334}],344:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Registry = _dereq_('../../registry'); var Lib = _dereq_('../../lib'); @@ -66495,15 +75150,7 @@ exports.toSVG = function(gd) { exports.updateFx = _dereq_('./graph_interact').updateFx; -},{"../../components/drawing":127,"../../constants/xmlns_namespaces":213,"../../lib":233,"../../registry":326,"../get_data":309,"../plots":313,"./attributes":277,"./axis_ids":282,"./constants":285,"./graph_interact":288,"./layout_attributes":293,"./layout_defaults":294,"./transition_axes":303,"d3":21}],293:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/drawing":177,"../../constants/xmlns_namespaces":266,"../../lib":285,"../../registry":373,"../get_data":361,"../plots":366,"./attributes":329,"./axis_ids":334,"./constants":337,"./graph_interact":340,"./layout_attributes":345,"./layout_defaults":346,"./transition_axes":355,"@plotly/d3":20}],345:[function(_dereq_,module,exports){ 'use strict'; var fontAttrs = _dereq_('../font_attributes'); @@ -66512,8 +75159,10 @@ var dash = _dereq_('../../components/drawing/attributes').dash; var extendFlat = _dereq_('../../lib/extend').extendFlat; var templatedArray = _dereq_('../../plot_api/plot_template').templatedArray; -var FORMAT_LINK = _dereq_('../../constants/docs').FORMAT_LINK; -var DATE_FORMAT_LINK = _dereq_('../../constants/docs').DATE_FORMAT_LINK; +var docs = _dereq_('../../constants/docs'); +var FORMAT_LINK = docs.FORMAT_LINK; +var DATE_FORMAT_LINK = docs.DATE_FORMAT_LINK; + var ONEDAY = _dereq_('../../constants/numerical').ONEDAY; var constants = _dereq_('./constants'); var HOUR = constants.HOUR_PATTERN; @@ -66522,34 +75171,25 @@ var DAY_OF_WEEK = constants.WEEKDAY_PATTERN; module.exports = { visible: { valType: 'boolean', - editType: 'plot', - }, color: { valType: 'color', dflt: colorAttrs.defaultLine, - editType: 'ticks', - }, title: { text: { valType: 'string', - editType: 'ticks', - }, font: fontAttrs({ editType: 'ticks', - }), standoff: { valType: 'number', - min: 0, editType: 'ticks', - }, editType: 'ticks' }, @@ -66560,43 +75200,34 @@ module.exports = { // to gd.data like the others are. values: ['-', 'linear', 'log', 'date', 'category', 'multicategory'], dflt: '-', - editType: 'calc', // we forget when an axis has been autotyped, just writing the auto // value back to the input - so it doesn't make sense to template this. // Note: we do NOT prohibit this in `coerce`, so if someone enters a // type in the template explicitly it will be honored as the default. _noTemplating: true, - }, autotypenumbers: { valType: 'enumerated', values: ['convert types', 'strict'], dflt: 'convert types', - editType: 'calc', - }, autorange: { valType: 'enumerated', values: [true, false, 'reversed'], dflt: true, - editType: 'axrange', impliedEdits: {'range[0]': undefined, 'range[1]': undefined}, - }, rangemode: { valType: 'enumerated', values: ['normal', 'tozero', 'nonnegative'], dflt: 'normal', - editType: 'plot', - }, range: { valType: 'info_array', - items: [ {valType: 'any', editType: 'axrange', impliedEdits: {'^autorange': false}, anim: true}, {valType: 'any', editType: 'axrange', impliedEdits: {'^autorange': false}, anim: true} @@ -66604,14 +75235,11 @@ module.exports = { editType: 'axrange', impliedEdits: {'autorange': false}, anim: true, - }, fixedrange: { valType: 'boolean', dflt: false, - editType: 'calc', - }, // scaleanchor: not used directly, just put here for reference // values are any opposite-letter axis id @@ -66621,32 +75249,24 @@ module.exports = { constants.idRegex.x.toString(), constants.idRegex.y.toString() ], - editType: 'plot', - }, scaleratio: { valType: 'number', min: 0, dflt: 1, - editType: 'plot', - }, constrain: { valType: 'enumerated', values: ['range', 'domain'], - editType: 'plot', - }, // constraintoward: not used directly, just put here for reference constraintoward: { valType: 'enumerated', values: ['left', 'center', 'right', 'top', 'middle', 'bottom'], - editType: 'plot', - }, matches: { valType: 'enumerated', @@ -66654,58 +75274,46 @@ module.exports = { constants.idRegex.x.toString(), constants.idRegex.y.toString() ], - editType: 'calc', - }, rangebreaks: templatedArray('rangebreak', { enabled: { valType: 'boolean', - dflt: true, editType: 'calc', - }, bounds: { valType: 'info_array', - items: [ {valType: 'any', editType: 'calc'}, {valType: 'any', editType: 'calc'} ], editType: 'calc', - }, pattern: { valType: 'enumerated', values: [DAY_OF_WEEK, HOUR, ''], - editType: 'calc', - }, values: { valType: 'info_array', freeLength: true, - editType: 'calc', items: { valType: 'any', editType: 'calc' }, - }, dvalue: { // TODO could become 'any' to add support for 'months', 'years' valType: 'number', - editType: 'calc', min: 0, dflt: ONEDAY, - }, /* @@ -66714,16 +75322,12 @@ module.exports = { min: 0, dflt: 0, // for *date* axes, maybe something else for *linear* editType: 'calc', - - }, gapmode: { valType: 'enumerated', values: ['pixels', 'fraction'], dflt: 'pixels', editType: 'calc', - - }, */ @@ -66740,65 +75344,49 @@ module.exports = { tickmode: { valType: 'enumerated', values: ['auto', 'linear', 'array'], - editType: 'ticks', impliedEdits: {tick0: undefined, dtick: undefined}, - }, nticks: { valType: 'integer', min: 0, dflt: 0, - editType: 'ticks', - }, tick0: { valType: 'any', - editType: 'ticks', impliedEdits: {tickmode: 'linear'}, - }, dtick: { valType: 'any', - editType: 'ticks', impliedEdits: {tickmode: 'linear'}, - }, tickvals: { valType: 'data_array', editType: 'ticks', - }, ticktext: { valType: 'data_array', editType: 'ticks', - }, ticks: { valType: 'enumerated', values: ['outside', 'inside', ''], - editType: 'ticks', - }, tickson: { valType: 'enumerated', values: ['labels', 'boundaries'], - dflt: 'labels', editType: 'ticks', - }, ticklabelmode: { valType: 'enumerated', values: ['instant', 'period'], dflt: 'instant', - editType: 'ticks', - }, // ticklabelposition: not used directly, as values depend on direction (similar to side) // left/right options are for x axes, and top/bottom options are for y axes @@ -66812,291 +75400,223 @@ module.exports = { 'outside bottom', 'inside bottom' ], dflt: 'outside', - editType: 'calc', - + }, + ticklabeloverflow: { + valType: 'enumerated', + values: [ + 'allow', + 'hide past div', + 'hide past domain' + ], + editType: 'calc', }, mirror: { valType: 'enumerated', values: [true, 'ticks', false, 'all', 'allticks'], dflt: false, - editType: 'ticks+layoutstyle', - }, ticklen: { valType: 'number', min: 0, dflt: 5, - editType: 'ticks', - }, tickwidth: { valType: 'number', min: 0, dflt: 1, - editType: 'ticks', - }, tickcolor: { valType: 'color', dflt: colorAttrs.defaultLine, - editType: 'ticks', - }, showticklabels: { valType: 'boolean', dflt: true, - editType: 'ticks', - }, automargin: { valType: 'boolean', dflt: false, - editType: 'ticks', - }, showspikes: { valType: 'boolean', dflt: false, - editType: 'modebar', - }, spikecolor: { valType: 'color', dflt: null, - editType: 'none', - }, spikethickness: { valType: 'number', dflt: 3, - editType: 'none', - }, spikedash: extendFlat({}, dash, {dflt: 'dash', editType: 'none'}), spikemode: { valType: 'flaglist', flags: ['toaxis', 'across', 'marker'], - dflt: 'toaxis', editType: 'none', - }, spikesnap: { valType: 'enumerated', values: ['data', 'cursor', 'hovered data'], - dflt: 'data', - + dflt: 'hovered data', editType: 'none', - }, tickfont: fontAttrs({ editType: 'ticks', - }), tickangle: { valType: 'angle', dflt: 'auto', - editType: 'ticks', - }, tickprefix: { valType: 'string', dflt: '', - editType: 'ticks', - }, showtickprefix: { valType: 'enumerated', values: ['all', 'first', 'last', 'none'], dflt: 'all', - editType: 'ticks', - }, ticksuffix: { valType: 'string', dflt: '', - editType: 'ticks', - }, showticksuffix: { valType: 'enumerated', values: ['all', 'first', 'last', 'none'], dflt: 'all', - editType: 'ticks', - }, showexponent: { valType: 'enumerated', values: ['all', 'first', 'last', 'none'], dflt: 'all', - editType: 'ticks', - }, exponentformat: { valType: 'enumerated', values: ['none', 'e', 'E', 'power', 'SI', 'B'], dflt: 'B', - editType: 'ticks', - }, minexponent: { valType: 'number', dflt: 3, min: 0, - editType: 'ticks', - }, separatethousands: { valType: 'boolean', dflt: false, - editType: 'ticks', - }, tickformat: { valType: 'string', dflt: '', - editType: 'ticks', - }, tickformatstops: templatedArray('tickformatstop', { enabled: { valType: 'boolean', - dflt: true, editType: 'ticks', - }, dtickrange: { valType: 'info_array', - items: [ {valType: 'any', editType: 'ticks'}, {valType: 'any', editType: 'ticks'} ], editType: 'ticks', - }, value: { valType: 'string', dflt: '', - editType: 'ticks', - }, editType: 'ticks' }), hoverformat: { valType: 'string', dflt: '', - editType: 'none', - }, // lines and grids showline: { valType: 'boolean', dflt: false, - editType: 'ticks+layoutstyle', - }, linecolor: { valType: 'color', dflt: colorAttrs.defaultLine, - editType: 'layoutstyle', - }, linewidth: { valType: 'number', min: 0, dflt: 1, - editType: 'ticks+layoutstyle', - }, showgrid: { valType: 'boolean', - editType: 'ticks', - }, gridcolor: { valType: 'color', dflt: colorAttrs.lightLine, - editType: 'ticks', - }, gridwidth: { valType: 'number', min: 0, dflt: 1, - editType: 'ticks', - }, zeroline: { valType: 'boolean', - editType: 'ticks', - }, zerolinecolor: { valType: 'color', dflt: colorAttrs.defaultLine, - editType: 'ticks', - }, zerolinewidth: { valType: 'number', dflt: 1, - editType: 'ticks', - }, showdividers: { valType: 'boolean', dflt: true, - editType: 'ticks', - }, dividercolor: { valType: 'color', dflt: colorAttrs.defaultLine, - editType: 'ticks', - }, dividerwidth: { valType: 'number', dflt: 1, - editType: 'ticks', - }, // TODO dividerlen: that would override "to label base" length? @@ -67110,18 +75630,14 @@ module.exports = { constants.idRegex.x.toString(), constants.idRegex.y.toString() ], - editType: 'plot', - }, // side: not used directly, as values depend on direction // values are top, bottom for x axes, and left, right for y side: { valType: 'enumerated', values: ['top', 'bottom', 'left', 'right'], - editType: 'plot', - }, // overlaying: not used directly, just put here for reference // values are false and any other same-letter axis id that's not @@ -67133,37 +75649,29 @@ module.exports = { constants.idRegex.x.toString(), constants.idRegex.y.toString() ], - editType: 'plot', - }, layer: { valType: 'enumerated', values: ['above traces', 'below traces'], dflt: 'above traces', - editType: 'plot', - }, domain: { valType: 'info_array', - items: [ {valType: 'number', min: 0, max: 1, editType: 'plot'}, {valType: 'number', min: 0, max: 1, editType: 'plot'} ], dflt: [0, 1], editType: 'plot', - }, position: { valType: 'number', min: 0, max: 1, dflt: 0, - editType: 'plot', - }, categoryorder: { valType: 'enumerated', @@ -67177,54 +75685,34 @@ module.exports = { 'median ascending', 'median descending' ], dflt: 'trace', - editType: 'calc', - }, categoryarray: { valType: 'data_array', - editType: 'calc', - }, uirevision: { valType: 'any', - editType: 'none', - }, editType: 'calc', _deprecated: { autotick: { valType: 'boolean', - editType: 'ticks', - }, title: { valType: 'string', - editType: 'ticks', - }, titlefont: fontAttrs({ editType: 'ticks', - }) } }; -},{"../../components/color/attributes":104,"../../components/drawing/attributes":126,"../../constants/docs":209,"../../constants/numerical":212,"../../lib/extend":227,"../../plot_api/plot_template":268,"../font_attributes":307,"./constants":285}],294:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/color/attributes":154,"../../components/drawing/attributes":176,"../../constants/docs":262,"../../constants/numerical":265,"../../lib/extend":279,"../../plot_api/plot_template":320,"../font_attributes":359,"./constants":337}],346:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -67427,7 +75915,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { } } - var hovermode = handleHoverModeDefaults(layoutIn, layoutOut, fullData); + var hovermode = handleHoverModeDefaults(layoutIn, layoutOut); var unifiedHover = isUnifiedHover(hovermode); // first pass creates the containers, determines types, and handles most of the settings @@ -67480,7 +75968,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { var spikethickness = coerce2('spikethickness', unifiedHover ? 1.5 : undefined); var spikedash = coerce2('spikedash', unifiedHover ? 'dot' : undefined); var spikemode = coerce2('spikemode', unifiedHover ? 'across' : undefined); - var spikesnap = coerce2('spikesnap', unifiedHover ? 'hovered data' : undefined); + var spikesnap = coerce2('spikesnap'); var showSpikes = coerce('showspikes', !!unifiedSpike || !!spikecolor || !!spikethickness || !!spikedash || !!spikemode || !!spikesnap); if(!showSpikes) { @@ -67602,15 +76090,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { }); }; -},{"../../components/color":105,"../../components/fx/helpers":141,"../../components/fx/hovermode_defaults":144,"../../lib":233,"../../plot_api/plot_template":268,"../../registry":326,"../layout_attributes":311,"./axis_defaults":281,"./axis_ids":282,"./constants":285,"./constraints":286,"./layout_attributes":293,"./position_defaults":296,"./type_defaults":304}],295:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../components/fx/helpers":191,"../../components/fx/hovermode_defaults":194,"../../lib":285,"../../plot_api/plot_template":320,"../../registry":373,"../layout_attributes":364,"./axis_defaults":333,"./axis_ids":334,"./constants":337,"./constraints":338,"./layout_attributes":345,"./position_defaults":348,"./type_defaults":356}],347:[function(_dereq_,module,exports){ 'use strict'; var colorMix = _dereq_('tinycolor2').mix; @@ -67667,16 +76147,7 @@ module.exports = function handleLineGridDefaults(containerIn, containerOut, coer } }; -},{"../../components/color/attributes":104,"../../lib":233,"tinycolor2":88}],296:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/color/attributes":154,"../../lib":285,"tinycolor2":119}],348:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -67755,16 +76226,7 @@ module.exports = function handlePositionDefaults(containerIn, containerOut, coer return containerOut; }; -},{"../../lib":233,"fast-isnumeric":23}],297:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"fast-isnumeric":31}],349:[function(_dereq_,module,exports){ 'use strict'; var FROM_BL = _dereq_('../../constants/alignment').FROM_BL; @@ -67784,16 +76246,7 @@ module.exports = function scaleZoom(ax, factor, centerFraction) { ax.setScale(); }; -},{"../../constants/alignment":207}],298:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../constants/alignment":260}],350:[function(_dereq_,module,exports){ 'use strict'; var polybool = _dereq_('polybooljs'); @@ -68142,9 +76595,9 @@ function prepSelect(e, startX, startY, dragOptions, mode) { } if(clickmode === 'event') { - // TODO: remove in v2 - this was probably never intended to work as it does, + // TODO: remove in v3 - this was probably never intended to work as it does, // but in case anyone depends on it we don't want to break it now. - // Note that click-to-select introduced pre v2 also emitts proper + // Note that click-to-select introduced pre v3 also emitts proper // event data when clickmode is having 'select' in its flag list. gd.emit('plotly_selected', undefined); } @@ -68727,18 +77180,10 @@ module.exports = { selectOnClick: selectOnClick }; -},{"../../components/color":105,"../../components/dragelement/helpers":123,"../../components/drawing":127,"../../components/fx":145,"../../components/fx/helpers":141,"../../components/shapes/draw_newshape/display_outlines":190,"../../components/shapes/draw_newshape/helpers":191,"../../components/shapes/draw_newshape/newshapes":192,"../../lib":233,"../../lib/clear_gl_canvases":221,"../../lib/polygon":245,"../../lib/throttle":256,"../../plot_api/subroutines":269,"../../registry":326,"./axis_ids":282,"./constants":285,"./handle_outline":289,"./helpers":290,"polybooljs":79}],299:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../components/dragelement/helpers":173,"../../components/drawing":177,"../../components/fx":195,"../../components/fx/helpers":191,"../../components/shapes/draw_newshape/display_outlines":243,"../../components/shapes/draw_newshape/helpers":244,"../../components/shapes/draw_newshape/newshapes":245,"../../lib":285,"../../lib/clear_gl_canvases":273,"../../lib/polygon":297,"../../lib/throttle":308,"../../plot_api/subroutines":321,"../../registry":373,"./axis_ids":334,"./constants":337,"./handle_outline":341,"./helpers":342,"polybooljs":73}],351:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var utcFormat = _dereq_('d3-time-format').utcFormat; var isNumeric = _dereq_('fast-isnumeric'); @@ -68788,7 +77233,7 @@ function isValidCategory(v) { * - category: calcdata format (c), and will stay that way because * the data format has no continuous mapping * - log: linearized (l) format - * TODO: in v2.0 we plan to change it to data format. At that point + * TODO: in v3.0 we plan to change it to data format. At that point * shapes will work the same way as ranges, tick0, and annotations * so they can use this conversion too. * @@ -68825,7 +77270,7 @@ module.exports = function setConvert(ax, fullLayout) { if((opts || {}).msUTC && isNumeric(v)) { // For now it is only used // to fix bar length in milliseconds & gl3d ticks - // It could be applied in other places in v2 + // It could be applied in other places in v3 return +v; } @@ -69685,16 +78130,7 @@ module.exports = function setConvert(ax, fullLayout) { delete ax._forceTick0; }; -},{"../../constants/numerical":212,"../../lib":233,"./axis_ids":282,"./constants":285,"d3":21,"d3-time-format":19,"fast-isnumeric":23}],300:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../constants/numerical":265,"../../lib":285,"./axis_ids":334,"./constants":337,"@plotly/d3":20,"d3-time-format":29,"fast-isnumeric":31}],352:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -69812,16 +78248,7 @@ function tickformatstopDefaults(valueIn, valueOut) { } } -},{"../../components/color":105,"../../lib":233,"../array_container_defaults":274,"./layout_attributes":293}],301:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/color":155,"../../lib":285,"../array_container_defaults":326,"./layout_attributes":345}],353:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -69845,15 +78272,7 @@ module.exports = function handleTickDefaults(containerIn, containerOut, coerce, } }; -},{"../../lib":233,"./layout_attributes":293}],302:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"./layout_attributes":345}],354:[function(_dereq_,module,exports){ 'use strict'; var cleanTicks = _dereq_('./clean_ticks'); @@ -69892,18 +78311,10 @@ module.exports = function handleTickValueDefaults(containerIn, containerOut, coe } }; -},{"../../lib":233,"./clean_ticks":284}],303:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"./clean_ticks":336}],355:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Registry = _dereq_('../../registry'); var Lib = _dereq_('../../lib'); @@ -70105,15 +78516,7 @@ module.exports = function transitionAxes(gd, edits, transitionOpts, makeOnComple return Promise.resolve(); }; -},{"../../components/drawing":127,"../../lib":233,"../../registry":326,"./axes":279,"d3":21}],304:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/drawing":177,"../../lib":285,"../../registry":373,"./axes":331,"@plotly/d3":20}],356:[function(_dereq_,module,exports){ 'use strict'; var traceIs = _dereq_('../../registry').traceIs; @@ -70245,15 +78648,7 @@ function isBoxWithoutPositionCoords(trace, axLetter) { ); } -},{"../../registry":326,"./axis_autotype":280}],305:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../registry":373,"./axis_autotype":332}],357:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../registry'); @@ -70672,15 +79067,7 @@ function crawl(attrs, callback, path, depth) { }); } -},{"../lib":233,"../registry":326}],306:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285,"../registry":373}],358:[function(_dereq_,module,exports){ 'use strict'; var extendFlat = _dereq_('../lib/extend').extendFlat; @@ -70712,7 +79099,6 @@ exports.attributes = function(opts, extra) { var base = { valType: 'info_array', - editType: opts.editType, items: [ {valType: 'number', min: 0, max: 1, editType: opts.editType}, @@ -70727,10 +79113,8 @@ exports.attributes = function(opts, extra) { var out = { x: extendFlat({}, base, { - }), y: extendFlat({}, base, { - }), editType: opts.editType }; @@ -70740,17 +79124,13 @@ exports.attributes = function(opts, extra) { valType: 'integer', min: 0, dflt: 0, - editType: opts.editType, - }; out.column = { valType: 'integer', min: 0, dflt: 0, - editType: opts.editType, - }; } @@ -70784,15 +79164,7 @@ exports.defaults = function(containerOut, layout, coerce, dfltDomains) { if(!(y[0] < y[1])) containerOut.domain.y = dfltY.slice(); }; -},{"../lib/extend":227}],307:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib/extend":279}],359:[function(_dereq_,module,exports){ 'use strict'; /* @@ -70817,27 +79189,22 @@ module.exports = function(opts) { var attrs = { family: { valType: 'string', - noBlank: true, strict: true, editType: editType, - }, size: { valType: 'number', - min: 1, editType: editType }, color: { valType: 'color', - editType: colorEditType }, editType: editType, // blank strings so compress_attributes can remove // TODO - that's uber hacky... better solution? - }; if(opts.arrayOk) { @@ -70849,15 +79216,7 @@ module.exports = function(opts) { return attrs; }; -},{}],308:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],360:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -70865,45 +79224,25 @@ module.exports = { group: { valType: 'string', - - }, name: { valType: 'string', - - }, traces: { valType: 'any', - - }, baseframe: { valType: 'string', - - }, data: { valType: 'any', - - }, layout: { valType: 'any', - - } }; -},{}],309:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],361:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../registry'); @@ -71024,16 +79363,7 @@ exports.getSubplotData = function getSubplotData(data, type, subplotId) { return subplotData; }; -},{"../registry":326,"./cartesian/constants":285}],310:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../registry":373,"./cartesian/constants":337}],362:[function(_dereq_,module,exports){ 'use strict'; function xformMatrix(m, v) { @@ -71058,15 +79388,22 @@ function project(camera, v) { module.exports = project; -},{}],311:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +},{}],363:[function(_dereq_,module,exports){ +'use strict'; +var docs = _dereq_('../constants/docs'); +var FORMAT_LINK = docs.FORMAT_LINK; +var DATE_FORMAT_LINK = docs.DATE_FORMAT_LINK; + +module.exports = function axisHoverFormat(x, noDates) { + return { + valType: 'string', + dflt: '', + editType: 'none', + }; +}; + +},{"../constants/docs":262}],364:[function(_dereq_,module,exports){ 'use strict'; var fontAttrs = _dereq_('./font_attributes'); @@ -71078,7 +79415,6 @@ var extendFlat = _dereq_('../lib/extend').extendFlat; var globalFont = fontAttrs({ editType: 'calc', - }); globalFont.family.dflt = '"Open Sans", verdana, arial, sans-serif'; globalFont.size.dflt = 12; @@ -71089,66 +79425,50 @@ module.exports = { title: { text: { valType: 'string', - editType: 'layoutstyle', - }, font: fontAttrs({ editType: 'layoutstyle', - }), xref: { valType: 'enumerated', dflt: 'container', values: ['container', 'paper'], - editType: 'layoutstyle', - }, yref: { valType: 'enumerated', dflt: 'container', values: ['container', 'paper'], - editType: 'layoutstyle', - }, x: { valType: 'number', min: 0, max: 1, dflt: 0.5, - editType: 'layoutstyle', - }, y: { valType: 'number', min: 0, max: 1, dflt: 'auto', - editType: 'layoutstyle', - }, xanchor: { valType: 'enumerated', dflt: 'auto', values: ['auto', 'left', 'center', 'right'], - editType: 'layoutstyle', - }, yanchor: { valType: 'enumerated', dflt: 'auto', values: ['auto', 'top', 'middle', 'bottom'], - editType: 'layoutstyle', - }, pad: extendFlat(padAttrs({editType: 'layoutstyle'}), { - }), editType: 'layoutstyle' }, @@ -71157,217 +79477,134 @@ module.exports = { valType: 'enumerated', values: [false, 'hide', 'show'], dflt: false, - editType: 'plot', - }, minsize: { valType: 'number', min: 0, dflt: 0, - editType: 'plot', - }, editType: 'plot' }, autosize: { valType: 'boolean', - dflt: false, // autosize, width, and height get special editType treatment in _relayout // so we can handle noop resizes more efficiently editType: 'none', - }, width: { valType: 'number', - min: 10, dflt: 700, editType: 'plot', - }, height: { valType: 'number', - min: 10, dflt: 450, editType: 'plot', - }, margin: { l: { valType: 'number', - min: 0, dflt: 80, editType: 'plot', - }, r: { valType: 'number', - min: 0, dflt: 80, editType: 'plot', - }, t: { valType: 'number', - min: 0, dflt: 100, editType: 'plot', - }, b: { valType: 'number', - min: 0, dflt: 80, editType: 'plot', - }, pad: { valType: 'number', - min: 0, dflt: 0, editType: 'plot', - }, autoexpand: { valType: 'boolean', - dflt: true, editType: 'plot', - }, editType: 'plot' }, computed: { valType: 'any', - editType: 'none', - }, paper_bgcolor: { valType: 'color', - dflt: colorAttrs.background, editType: 'plot', - }, plot_bgcolor: { // defined here, but set in cartesian.supplyLayoutDefaults // because it needs to know if there are (2D) axes or not valType: 'color', - dflt: colorAttrs.background, editType: 'layoutstyle', - }, autotypenumbers: { valType: 'enumerated', values: ['convert types', 'strict'], dflt: 'convert types', - editType: 'calc', - }, separators: { valType: 'string', - editType: 'plot', - }, hidesources: { valType: 'boolean', - dflt: false, editType: 'plot', - }, showlegend: { // handled in legend.supplyLayoutDefaults // but included here because it's not in the legend object valType: 'boolean', - editType: 'legend', - }, colorway: { valType: 'colorlist', dflt: colorAttrs.defaults, - editType: 'calc', - }, datarevision: { valType: 'any', - editType: 'calc', - }, uirevision: { valType: 'any', - editType: 'none', - }, editrevision: { valType: 'any', - editType: 'none', - }, selectionrevision: { valType: 'any', - editType: 'none', - }, template: { valType: 'any', - editType: 'calc', - - }, - modebar: { - orientation: { - valType: 'enumerated', - values: ['v', 'h'], - dflt: 'h', - - editType: 'modebar', - - }, - bgcolor: { - valType: 'color', - - editType: 'modebar', - - }, - color: { - valType: 'color', - - editType: 'modebar', - - }, - activecolor: { - valType: 'color', - - editType: 'modebar', - - }, - uirevision: { - valType: 'any', - - editType: 'none', - - }, - editType: 'modebar' }, newshape: drawNewShapeAttrs.newshape, @@ -71376,38 +79613,24 @@ module.exports = { meta: { valType: 'any', arrayOk: true, - editType: 'plot', - }, transition: extendFlat({}, animationAttrs.transition, { - editType: 'none' }), _deprecated: { title: { valType: 'string', - editType: 'layoutstyle', - }, titlefont: fontAttrs({ editType: 'layoutstyle', - }) } }; -},{"../components/color/attributes":104,"../components/shapes/draw_newshape/attributes":187,"../lib/extend":227,"./animation_attributes":273,"./font_attributes":307,"./pad_attributes":312}],312:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../components/color/attributes":154,"../components/shapes/draw_newshape/attributes":240,"../lib/extend":279,"./animation_attributes":325,"./font_attributes":359,"./pad_attributes":365}],365:[function(_dereq_,module,exports){ 'use strict'; /** @@ -71425,47 +79648,31 @@ module.exports = function(opts) { t: { valType: 'number', dflt: 0, - editType: editType, - }, r: { valType: 'number', dflt: 0, - editType: editType, - }, b: { valType: 'number', dflt: 0, - editType: editType, - }, l: { valType: 'number', dflt: 0, - editType: editType, - }, editType: editType }; }; -},{}],313:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],366:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var timeFormatLocale = _dereq_('d3-time-format').timeFormatLocale; var isNumeric = _dereq_('fast-isnumeric'); @@ -71514,15 +79721,9 @@ plots.hasSimpleAPICommandBindings = commandModule.hasSimpleAPICommandBindings; plots.redrawText = function(gd) { gd = Lib.getGraphDiv(gd); - var fullLayout = gd._fullLayout || {}; - var hasPolar = fullLayout._has && fullLayout._has('polar'); - var hasLegacyPolar = !hasPolar && gd.data && gd.data[0] && gd.data[0].r; - - // do not work if polar is present - if(hasLegacyPolar) return; - return new Promise(function(resolve) { setTimeout(function() { + if(!gd._fullLayout) return; Registry.getComponentMethod('annotations', 'draw')(gd); Registry.getComponentMethod('legend', 'draw')(gd); Registry.getComponentMethod('colorbar', 'draw')(gd); @@ -71588,7 +79789,7 @@ plots.previousPromises = function(gd) { /** * Adds the 'Edit chart' link. - * Note that now Plotly.plot() calls this so it can regenerate whenever it replots + * Note that now _doPlot calls this so it can regenerate whenever it replots * * Add source links to your graph inside the 'showSources' config argument. */ @@ -71925,15 +80126,6 @@ plots.supplyDefaults = function(gd, opts) { newFullLayout.images.length === 0 ); - // TODO remove in v2.0.0 - // add has-plot-type refs to fullLayout for backward compatibility - newFullLayout._hasCartesian = newFullLayout._has('cartesian'); - newFullLayout._hasGeo = newFullLayout._has('geo'); - newFullLayout._hasGL3D = newFullLayout._has('gl3d'); - newFullLayout._hasGL2D = newFullLayout._has('gl2d'); - newFullLayout._hasTernary = newFullLayout._has('ternary'); - newFullLayout._hasPie = newFullLayout._has('pie'); - // relink / initialize subplot axis objects plots.linkSubplots(newFullData, newFullLayout, oldFullData, oldFullLayout); @@ -72168,7 +80360,7 @@ function getFormatObj(gd, formatKeys) { /** * getFormatter: combine the final separators with the locale formatting object * we pulled earlier to generate number and time formatters - * TODO: remove separators in v2, only use locale, so we don't need this step? + * TODO: remove separators in v3, only use locale, so we don't need this step? * * @param {object} formatObj: d3.locale format object * @param {string} separators: length-2 string to override decimal and thousands @@ -72969,7 +81161,7 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) { // layouts with no set width and height were set temporary set to 'initial' // to pass through the autosize routine // - // This behavior is subject to change in v2. + // This behavior is subject to change in v3. coerce('autosize', !(layoutIn.width && layoutIn.height)); coerce('width'); @@ -72997,12 +81189,10 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) { coerce('editrevision', uirevision); coerce('selectionrevision', uirevision); - coerce('modebar.orientation'); - coerce('modebar.bgcolor', Color.addOpacity(layoutOut.paper_bgcolor, 0.5)); - var modebarDefaultColor = Color.contrast(Color.rgb(layoutOut.modebar.bgcolor)); - coerce('modebar.color', Color.addOpacity(modebarDefaultColor, 0.3)); - coerce('modebar.activecolor', Color.addOpacity(modebarDefaultColor, 0.7)); - coerce('modebar.uirevision', uirevision); + Registry.getComponentMethod( + 'modebar', + 'supplyLayoutDefaults' + )(layoutIn, layoutOut); Registry.getComponentMethod( 'shapes', @@ -73213,7 +81403,6 @@ plots.purge = function(gd) { delete gd._fullData; delete gd._fullLayout; delete gd.calcdata; - delete gd.framework; delete gd.empty; delete gd.fid; @@ -73223,7 +81412,7 @@ plots.purge = function(gd) { delete gd.autoplay; // are we doing an action that doesn't go in undo queue? delete gd.changed; - // these get recreated on Plotly.plot anyway, but just to be safe + // these get recreated on _doPlot anyway, but just to be safe // (and to have a record of them...) delete gd._promises; delete gd._redrawTimer; @@ -73550,24 +81739,28 @@ plots.doAutoMargin = function(gd) { var maxNumberOfRedraws = 3 * (1 + Object.keys(pushMarginIds).length); if(fullLayout._redrawFromAutoMarginCount < maxNumberOfRedraws) { - return Registry.call('plot', gd); + return Registry.call('_doPlot', gd); } else { fullLayout._size = oldMargins; Lib.warn('Too many auto-margin redraws.'); } } - hideOutOfRangeInsideTickLabels(gd); + refineTicks(gd); }; -function hideOutOfRangeInsideTickLabels(gd) { +function refineTicks(gd) { var axList = axisIDs.list(gd, '', true); - for(var i = 0; i < axList.length; i++) { - var ax = axList[i]; - var hideFn = ax._hideOutOfRangeInsideTickLabels; - if(hideFn) hideFn(); - } + [ + '_adjustTickLabelsOverflow', + '_hideCounterAxisInsideTickLabels' + ].forEach(function(k) { + for(var i = 0; i < axList.length; i++) { + var hideFn = axList[i][k]; + if(hideFn) hideFn(); + } + }); } var marginKeys = ['l', 'r', 't', 'b', 'p', 'w', 'h']; @@ -73708,8 +81901,6 @@ plots.graphJson = function(gd, dataonly, mode, output, useDefaults, includeConfi } } - if(gd.framework && gd.framework.isPolar) obj = gd.framework.getConfig(); - if(frames) obj.frames = stripObj(frames); if(includeConfig) obj.config = stripObj(gd._context, true); @@ -74204,6 +82395,7 @@ plots.transitionFromReact = function(gd, restyleFlags, relayoutFlags, oldFullLay } function transitionAxes() { + if(!gd._fullLayout) return; for(var j = 0; j < basePlotModules.length; j++) { if(basePlotModules[j].transitionAxes) { basePlotModules[j].transitionAxes(gd, axEdits, axisTransitionOpts, makeCallback); @@ -74212,6 +82404,7 @@ plots.transitionFromReact = function(gd, restyleFlags, relayoutFlags, oldFullLay } function transitionTraces() { + if(!gd._fullLayout) return; for(var j = 0; j < basePlotModules.length; j++) { basePlotModules[j].plot(gd, transitionedTraces, traceTransitionOpts, makeCallback); } @@ -74881,1769 +83074,7 @@ plots.cleanBasePlot = function(desiredType, newFullData, newFullLayout, oldFullD } }; -},{"../components/color":105,"../constants/numerical":212,"../lib":233,"../plot_api/plot_schema":267,"../plot_api/plot_template":268,"../plots/get_data":309,"../registry":326,"./animation_attributes":273,"./attributes":275,"./cartesian/axis_ids":282,"./cartesian/handle_outline":289,"./command":305,"./font_attributes":307,"./frame_attributes":308,"./layout_attributes":311,"d3":21,"d3-time-format":19,"fast-isnumeric":23}],314:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - -'use strict'; - -var scatterAttrs = _dereq_('../../../traces/scatter/attributes'); -var scatterMarkerAttrs = scatterAttrs.marker; -var extendFlat = _dereq_('../../../lib/extend').extendFlat; - -var deprecationWarning = [ - 'Area traces are deprecated!', - 'Please switch to the *barpolar* trace type.' -].join(' '); - -module.exports = { - r: extendFlat({}, scatterAttrs.r, { - - }), - t: extendFlat({}, scatterAttrs.t, { - - }), - marker: { - color: extendFlat({}, scatterMarkerAttrs.color, { - - }), - size: extendFlat({}, scatterMarkerAttrs.size, { - - }), - symbol: extendFlat({}, scatterMarkerAttrs.symbol, { - - }), - opacity: extendFlat({}, scatterMarkerAttrs.opacity, { - - }), - editType: 'calc' - } -}; - -},{"../../../lib/extend":227,"../../../traces/scatter/attributes":447}],315:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var axesAttrs = _dereq_('../../cartesian/layout_attributes'); -var extendFlat = _dereq_('../../../lib/extend').extendFlat; -var overrideAll = _dereq_('../../../plot_api/edit_types').overrideAll; - -var deprecationWarning = [ - 'Legacy polar charts are deprecated!', - 'Please switch to *polar* subplots.' -].join(' '); - -var domainAttr = extendFlat({}, axesAttrs.domain, { - -}); - -function mergeAttrs(axisName, nonCommonAttrs) { - var commonAttrs = { - showline: { - valType: 'boolean', - - - }, - showticklabels: { - valType: 'boolean', - - - }, - tickorientation: { - valType: 'enumerated', - values: ['horizontal', 'vertical'], - - - }, - ticklen: { - valType: 'number', - min: 0, - - - }, - tickcolor: { - valType: 'color', - - - }, - ticksuffix: { - valType: 'string', - - - }, - endpadding: { - valType: 'number', - - description: deprecationWarning, - }, - visible: { - valType: 'boolean', - - - } - }; - - return extendFlat({}, nonCommonAttrs, commonAttrs); -} - -module.exports = overrideAll({ - radialaxis: mergeAttrs('radial', { - range: { - valType: 'info_array', - - items: [ - { valType: 'number' }, - { valType: 'number' } - ], - - }, - domain: domainAttr, - orientation: { - valType: 'number', - - - } - }), - - angularaxis: mergeAttrs('angular', { - range: { - valType: 'info_array', - - items: [ - { valType: 'number', dflt: 0 }, - { valType: 'number', dflt: 360 } - ], - - }, - domain: domainAttr - }), - - // attributes that appear at layout root - layout: { - direction: { - valType: 'enumerated', - values: ['clockwise', 'counterclockwise'], - - - }, - orientation: { - valType: 'angle', - - - } - } -}, 'plot', 'nested'); - -},{"../../../lib/extend":227,"../../../plot_api/edit_types":261,"../../cartesian/layout_attributes":293}],316:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - -'use strict'; - -var Polar = module.exports = _dereq_('./micropolar'); - -Polar.manager = _dereq_('./micropolar_manager'); - -},{"./micropolar":317,"./micropolar_manager":318}],317:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - -var d3 = _dereq_('d3'); -var Lib = _dereq_('../../../lib'); -var extendDeepAll = Lib.extendDeepAll; -var MID_SHIFT = _dereq_('../../../constants/alignment').MID_SHIFT; - -var µ = module.exports = { version: '0.2.2' }; - -µ.Axis = function module() { - var config = { - data: [], - layout: {} - }, inputConfig = {}, liveConfig = {}; - var svg, container, dispatch = d3.dispatch('hover'), radialScale, angularScale; - var exports = {}; - function render(_container) { - container = _container || container; - var data = config.data; - var axisConfig = config.layout; - if (typeof container == 'string' || container.nodeName) container = d3.select(container); - container.datum(data).each(function(_data, _index) { - var dataOriginal = _data.slice(); - liveConfig = { - data: µ.util.cloneJson(dataOriginal), - layout: µ.util.cloneJson(axisConfig) - }; - var colorIndex = 0; - dataOriginal.forEach(function(d, i) { - if (!d.color) { - d.color = axisConfig.defaultColorRange[colorIndex]; - colorIndex = (colorIndex + 1) % axisConfig.defaultColorRange.length; - } - if (!d.strokeColor) { - d.strokeColor = d.geometry === 'LinePlot' ? d.color : d3.rgb(d.color).darker().toString(); - } - liveConfig.data[i].color = d.color; - liveConfig.data[i].strokeColor = d.strokeColor; - liveConfig.data[i].strokeDash = d.strokeDash; - liveConfig.data[i].strokeSize = d.strokeSize; - }); - var data = dataOriginal.filter(function(d, i) { - var visible = d.visible; - return typeof visible === 'undefined' || visible === true; - }); - var isStacked = false; - var dataWithGroupId = data.map(function(d, i) { - isStacked = isStacked || typeof d.groupId !== 'undefined'; - return d; - }); - if (isStacked) { - var grouped = d3.nest().key(function(d, i) { - return typeof d.groupId != 'undefined' ? d.groupId : 'unstacked'; - }).entries(dataWithGroupId); - var dataYStack = []; - var stacked = grouped.map(function(d, i) { - if (d.key === 'unstacked') return d.values; else { - var prevArray = d.values[0].r.map(function(d, i) { - return 0; - }); - d.values.forEach(function(d, i, a) { - d.yStack = [ prevArray ]; - dataYStack.push(prevArray); - prevArray = µ.util.sumArrays(d.r, prevArray); - }); - return d.values; - } - }); - data = d3.merge(stacked); - } - data.forEach(function(d, i) { - d.t = Array.isArray(d.t[0]) ? d.t : [ d.t ]; - d.r = Array.isArray(d.r[0]) ? d.r : [ d.r ]; - }); - var radius = Math.min(axisConfig.width - axisConfig.margin.left - axisConfig.margin.right, axisConfig.height - axisConfig.margin.top - axisConfig.margin.bottom) / 2; - radius = Math.max(10, radius); - var chartCenter = [ axisConfig.margin.left + radius, axisConfig.margin.top + radius ]; - var extent; - if (isStacked) { - var highestStackedValue = d3.max(µ.util.sumArrays(µ.util.arrayLast(data).r[0], µ.util.arrayLast(dataYStack))); - extent = [ 0, highestStackedValue ]; - } else extent = d3.extent(µ.util.flattenArray(data.map(function(d, i) { - return d.r; - }))); - if (axisConfig.radialAxis.domain != µ.DATAEXTENT) extent[0] = 0; - radialScale = d3.scale.linear().domain(axisConfig.radialAxis.domain != µ.DATAEXTENT && axisConfig.radialAxis.domain ? axisConfig.radialAxis.domain : extent).range([ 0, radius ]); - liveConfig.layout.radialAxis.domain = radialScale.domain(); - var angularDataMerged = µ.util.flattenArray(data.map(function(d, i) { - return d.t; - })); - var isOrdinal = typeof angularDataMerged[0] === 'string'; - var ticks; - if (isOrdinal) { - angularDataMerged = µ.util.deduplicate(angularDataMerged); - ticks = angularDataMerged.slice(); - angularDataMerged = d3.range(angularDataMerged.length); - data = data.map(function(d, i) { - var result = d; - d.t = [ angularDataMerged ]; - if (isStacked) result.yStack = d.yStack; - return result; - }); - } - var hasOnlyLineOrDotPlot = data.filter(function(d, i) { - return d.geometry === 'LinePlot' || d.geometry === 'DotPlot'; - }).length === data.length; - var needsEndSpacing = axisConfig.needsEndSpacing === null ? isOrdinal || !hasOnlyLineOrDotPlot : axisConfig.needsEndSpacing; - var useProvidedDomain = axisConfig.angularAxis.domain && axisConfig.angularAxis.domain != µ.DATAEXTENT && !isOrdinal && axisConfig.angularAxis.domain[0] >= 0; - var angularDomain = useProvidedDomain ? axisConfig.angularAxis.domain : d3.extent(angularDataMerged); - var angularDomainStep = Math.abs(angularDataMerged[1] - angularDataMerged[0]); - if (hasOnlyLineOrDotPlot && !isOrdinal) angularDomainStep = 0; - var angularDomainWithPadding = angularDomain.slice(); - if (needsEndSpacing && isOrdinal) angularDomainWithPadding[1] += angularDomainStep; - var tickCount = axisConfig.angularAxis.ticksCount || 4; - if (tickCount > 8) tickCount = tickCount / (tickCount / 8) + tickCount % 8; - if (axisConfig.angularAxis.ticksStep) { - tickCount = (angularDomainWithPadding[1] - angularDomainWithPadding[0]) / tickCount; - } - var angularTicksStep = axisConfig.angularAxis.ticksStep || (angularDomainWithPadding[1] - angularDomainWithPadding[0]) / (tickCount * (axisConfig.minorTicks + 1)); - if (ticks) angularTicksStep = Math.max(Math.round(angularTicksStep), 1); - if (!angularDomainWithPadding[2]) angularDomainWithPadding[2] = angularTicksStep; - var angularAxisRange = d3.range.apply(this, angularDomainWithPadding); - angularAxisRange = angularAxisRange.map(function(d, i) { - return parseFloat(d.toPrecision(12)); - }); - angularScale = d3.scale.linear().domain(angularDomainWithPadding.slice(0, 2)).range(axisConfig.direction === 'clockwise' ? [ 0, 360 ] : [ 360, 0 ]); - liveConfig.layout.angularAxis.domain = angularScale.domain(); - liveConfig.layout.angularAxis.endPadding = needsEndSpacing ? angularDomainStep : 0; - svg = d3.select(this).select('svg.chart-root'); - if (typeof svg === 'undefined' || svg.empty()) { - var skeleton = "' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '"; - var doc = new DOMParser().parseFromString(skeleton, 'application/xml'); - var newSvg = this.appendChild(this.ownerDocument.importNode(doc.documentElement, true)); - svg = d3.select(newSvg); - } - svg.select('.guides-group').style({ - 'pointer-events': 'none' - }); - svg.select('.angular.axis-group').style({ - 'pointer-events': 'none' - }); - svg.select('.radial.axis-group').style({ - 'pointer-events': 'none' - }); - var chartGroup = svg.select('.chart-group'); - var lineStyle = { - fill: 'none', - stroke: axisConfig.tickColor - }; - var fontStyle = { - 'font-size': axisConfig.font.size, - 'font-family': axisConfig.font.family, - fill: axisConfig.font.color, - 'text-shadow': [ '-1px 0px', '1px -1px', '-1px 1px', '1px 1px' ].map(function(d, i) { - return ' ' + d + ' 0 ' + axisConfig.font.outlineColor; - }).join(',') - }; - var legendContainer; - if (axisConfig.showLegend) { - legendContainer = svg.select('.legend-group').attr({ - transform: 'translate(' + [ radius, axisConfig.margin.top ] + ')' - }).style({ - display: 'block' - }); - var elements = data.map(function(d, i) { - var datumClone = µ.util.cloneJson(d); - datumClone.symbol = d.geometry === 'DotPlot' ? d.dotType || 'circle' : d.geometry != 'LinePlot' ? 'square' : 'line'; - datumClone.visibleInLegend = typeof d.visibleInLegend === 'undefined' || d.visibleInLegend; - datumClone.color = d.geometry === 'LinePlot' ? d.strokeColor : d.color; - return datumClone; - }); - - µ.Legend().config({ - data: data.map(function(d, i) { - return d.name || 'Element' + i; - }), - legendConfig: extendDeepAll({}, - µ.Legend.defaultConfig().legendConfig, - { - container: legendContainer, - elements: elements, - reverseOrder: axisConfig.legend.reverseOrder - } - ) - })(); - - var legendBBox = legendContainer.node().getBBox(); - radius = Math.min(axisConfig.width - legendBBox.width - axisConfig.margin.left - axisConfig.margin.right, axisConfig.height - axisConfig.margin.top - axisConfig.margin.bottom) / 2; - radius = Math.max(10, radius); - chartCenter = [ axisConfig.margin.left + radius, axisConfig.margin.top + radius ]; - radialScale.range([ 0, radius ]); - liveConfig.layout.radialAxis.domain = radialScale.domain(); - legendContainer.attr('transform', 'translate(' + [ chartCenter[0] + radius, chartCenter[1] - radius ] + ')'); - } else { - legendContainer = svg.select('.legend-group').style({ - display: 'none' - }); - } - svg.attr({ - width: axisConfig.width, - height: axisConfig.height - }).style({ - opacity: axisConfig.opacity - }); - chartGroup.attr('transform', 'translate(' + chartCenter + ')').style({ - cursor: 'crosshair' - }); - var centeringOffset = [ (axisConfig.width - (axisConfig.margin.left + axisConfig.margin.right + radius * 2 + (legendBBox ? legendBBox.width : 0))) / 2, (axisConfig.height - (axisConfig.margin.top + axisConfig.margin.bottom + radius * 2)) / 2 ]; - centeringOffset[0] = Math.max(0, centeringOffset[0]); - centeringOffset[1] = Math.max(0, centeringOffset[1]); - svg.select('.outer-group').attr('transform', 'translate(' + centeringOffset + ')'); - if (axisConfig.title && axisConfig.title.text) { - var title = svg.select('g.title-group text').style(fontStyle).text(axisConfig.title.text); - var titleBBox = title.node().getBBox(); - title.attr({ - x: chartCenter[0] - titleBBox.width / 2, - y: chartCenter[1] - radius - 20 - }); - } - var radialAxis = svg.select('.radial.axis-group'); - if (axisConfig.radialAxis.gridLinesVisible) { - var gridCircles = radialAxis.selectAll('circle.grid-circle').data(radialScale.ticks(5)); - gridCircles.enter().append('circle').attr({ - 'class': 'grid-circle' - }).style(lineStyle); - gridCircles.attr('r', radialScale); - gridCircles.exit().remove(); - } - radialAxis.select('circle.outside-circle').attr({ - r: radius - }).style(lineStyle); - var backgroundCircle = svg.select('circle.background-circle').attr({ - r: radius - }).style({ - fill: axisConfig.backgroundColor, - stroke: axisConfig.stroke - }); - function currentAngle(d, i) { - return angularScale(d) % 360 + axisConfig.orientation; - } - if (axisConfig.radialAxis.visible) { - var axis = d3.svg.axis().scale(radialScale).ticks(5).tickSize(5); - radialAxis.call(axis).attr({ - transform: 'rotate(' + axisConfig.radialAxis.orientation + ')' - }); - radialAxis.selectAll('.domain').style(lineStyle); - radialAxis.selectAll('g>text').text(function(d, i) { - return this.textContent + axisConfig.radialAxis.ticksSuffix; - }).style(fontStyle).style({ - 'text-anchor': 'start' - }).attr({ - x: 0, - y: 0, - dx: 0, - dy: 0, - transform: function(d, i) { - if (axisConfig.radialAxis.tickOrientation === 'horizontal') { - return 'rotate(' + -axisConfig.radialAxis.orientation + ') translate(' + [ 0, fontStyle['font-size'] ] + ')'; - } else return 'translate(' + [ 0, fontStyle['font-size'] ] + ')'; - } - }); - radialAxis.selectAll('g>line').style({ - stroke: 'black' - }); - } - var angularAxis = svg.select('.angular.axis-group').selectAll('g.angular-tick').data(angularAxisRange); - var angularAxisEnter = angularAxis.enter().append('g').classed('angular-tick', true); - angularAxis.attr({ - transform: function(d, i) { - return 'rotate(' + currentAngle(d, i) + ')'; - } - }).style({ - display: axisConfig.angularAxis.visible ? 'block' : 'none' - }); - angularAxis.exit().remove(); - angularAxisEnter.append('line').classed('grid-line', true).classed('major', function(d, i) { - return i % (axisConfig.minorTicks + 1) == 0; - }).classed('minor', function(d, i) { - return !(i % (axisConfig.minorTicks + 1) == 0); - }).style(lineStyle); - angularAxisEnter.selectAll('.minor').style({ - stroke: axisConfig.minorTickColor - }); - angularAxis.select('line.grid-line').attr({ - x1: axisConfig.tickLength ? radius - axisConfig.tickLength : 0, - x2: radius - }).style({ - display: axisConfig.angularAxis.gridLinesVisible ? 'block' : 'none' - }); - angularAxisEnter.append('text').classed('axis-text', true).style(fontStyle); - var ticksText = angularAxis.select('text.axis-text').attr({ - x: radius + axisConfig.labelOffset, - dy: MID_SHIFT + 'em', - transform: function(d, i) { - var angle = currentAngle(d, i); - var rad = radius + axisConfig.labelOffset; - var orient = axisConfig.angularAxis.tickOrientation; - if (orient == 'horizontal') return 'rotate(' + -angle + ' ' + rad + ' 0)'; else if (orient == 'radial') return angle < 270 && angle > 90 ? 'rotate(180 ' + rad + ' 0)' : null; else return 'rotate(' + (angle <= 180 && angle > 0 ? -90 : 90) + ' ' + rad + ' 0)'; - } - }).style({ - 'text-anchor': 'middle', - display: axisConfig.angularAxis.labelsVisible ? 'block' : 'none' - }).text(function(d, i) { - if (i % (axisConfig.minorTicks + 1) != 0) return ''; - if (ticks) { - return ticks[d] + axisConfig.angularAxis.ticksSuffix; - } else return d + axisConfig.angularAxis.ticksSuffix; - }).style(fontStyle); - if (axisConfig.angularAxis.rewriteTicks) ticksText.text(function(d, i) { - if (i % (axisConfig.minorTicks + 1) != 0) return ''; - return axisConfig.angularAxis.rewriteTicks(this.textContent, i); - }); - var rightmostTickEndX = d3.max(chartGroup.selectAll('.angular-tick text')[0].map(function(d, i) { - return d.getCTM().e + d.getBBox().width; - })); - legendContainer.attr({ - transform: 'translate(' + [ radius + rightmostTickEndX, axisConfig.margin.top ] + ')' - }); - var hasGeometry = svg.select('g.geometry-group').selectAll('g').size() > 0; - var geometryContainer = svg.select('g.geometry-group').selectAll('g.geometry').data(data); - geometryContainer.enter().append('g').attr({ - 'class': function(d, i) { - return 'geometry geometry' + i; - } - }); - geometryContainer.exit().remove(); - if (data[0] || hasGeometry) { - var geometryConfigs = []; - data.forEach(function(d, i) { - var geometryConfig = {}; - geometryConfig.radialScale = radialScale; - geometryConfig.angularScale = angularScale; - geometryConfig.container = geometryContainer.filter(function(dB, iB) { - return iB == i; - }); - geometryConfig.geometry = d.geometry; - geometryConfig.orientation = axisConfig.orientation; - geometryConfig.direction = axisConfig.direction; - geometryConfig.index = i; - geometryConfigs.push({ - data: d, - geometryConfig: geometryConfig - }); - }); - var geometryConfigsGrouped = d3.nest().key(function(d, i) { - return typeof d.data.groupId != 'undefined' || 'unstacked'; - }).entries(geometryConfigs); - var geometryConfigsGrouped2 = []; - geometryConfigsGrouped.forEach(function(d, i) { - if (d.key === 'unstacked') geometryConfigsGrouped2 = geometryConfigsGrouped2.concat(d.values.map(function(d, i) { - return [ d ]; - })); else geometryConfigsGrouped2.push(d.values); - }); - geometryConfigsGrouped2.forEach(function(d, i) { - var geometry; - if (Array.isArray(d)) geometry = d[0].geometryConfig.geometry; else geometry = d.geometryConfig.geometry; - var finalGeometryConfig = d.map(function(dB, iB) { - return extendDeepAll(µ[geometry].defaultConfig(), dB); - }); - µ[geometry]().config(finalGeometryConfig)(); - }); - } - var guides = svg.select('.guides-group'); - var tooltipContainer = svg.select('.tooltips-group'); - var angularTooltip = µ.tooltipPanel().config({ - container: tooltipContainer, - fontSize: 8 - })(); - var radialTooltip = µ.tooltipPanel().config({ - container: tooltipContainer, - fontSize: 8 - })(); - var geometryTooltip = µ.tooltipPanel().config({ - container: tooltipContainer, - hasTick: true - })(); - var angularValue, radialValue; - if (!isOrdinal) { - var angularGuideLine = guides.select('line').attr({ - x1: 0, - y1: 0, - y2: 0 - }).style({ - stroke: 'grey', - 'pointer-events': 'none' - }); - chartGroup.on('mousemove.angular-guide', function(d, i) { - var mouseAngle = µ.util.getMousePos(backgroundCircle).angle; - angularGuideLine.attr({ - x2: -radius, - transform: 'rotate(' + mouseAngle + ')' - }).style({ - opacity: .5 - }); - var angleWithOriginOffset = (mouseAngle + 180 + 360 - axisConfig.orientation) % 360; - angularValue = angularScale.invert(angleWithOriginOffset); - var pos = µ.util.convertToCartesian(radius + 12, mouseAngle + 180); - angularTooltip.text(µ.util.round(angularValue)).move([ pos[0] + chartCenter[0], pos[1] + chartCenter[1] ]); - }).on('mouseout.angular-guide', function(d, i) { - guides.select('line').style({ - opacity: 0 - }); - }); - } - var angularGuideCircle = guides.select('circle').style({ - stroke: 'grey', - fill: 'none' - }); - chartGroup.on('mousemove.radial-guide', function(d, i) { - var r = µ.util.getMousePos(backgroundCircle).radius; - angularGuideCircle.attr({ - r: r - }).style({ - opacity: .5 - }); - radialValue = radialScale.invert(µ.util.getMousePos(backgroundCircle).radius); - var pos = µ.util.convertToCartesian(r, axisConfig.radialAxis.orientation); - radialTooltip.text(µ.util.round(radialValue)).move([ pos[0] + chartCenter[0], pos[1] + chartCenter[1] ]); - }).on('mouseout.radial-guide', function(d, i) { - angularGuideCircle.style({ - opacity: 0 - }); - geometryTooltip.hide(); - angularTooltip.hide(); - radialTooltip.hide(); - }); - svg.selectAll('.geometry-group .mark').on('mouseover.tooltip', function(d, i) { - var el = d3.select(this); - var color = this.style.fill; - var newColor = 'black'; - var opacity = this.style.opacity || 1; - el.attr({ - 'data-opacity': opacity - }); - if (color && color !== 'none') { - el.attr({ - 'data-fill': color - }); - newColor = d3.hsl(color).darker().toString(); - el.style({ - fill: newColor, - opacity: 1 - }); - var textData = { - t: µ.util.round(d[0]), - r: µ.util.round(d[1]) - }; - if (isOrdinal) textData.t = ticks[d[0]]; - var text = 't: ' + textData.t + ', r: ' + textData.r; - var bbox = this.getBoundingClientRect(); - var svgBBox = svg.node().getBoundingClientRect(); - var pos = [ bbox.left + bbox.width / 2 - centeringOffset[0] - svgBBox.left, bbox.top + bbox.height / 2 - centeringOffset[1] - svgBBox.top ]; - geometryTooltip.config({ - color: newColor - }).text(text); - geometryTooltip.move(pos); - } else { - color = this.style.stroke || 'black'; - el.attr({ - 'data-stroke': color - }); - newColor = d3.hsl(color).darker().toString(); - el.style({ - stroke: newColor, - opacity: 1 - }); - } - }).on('mousemove.tooltip', function(d, i) { - if (d3.event.which != 0) return false; - if (d3.select(this).attr('data-fill')) geometryTooltip.show(); - }).on('mouseout.tooltip', function(d, i) { - geometryTooltip.hide(); - var el = d3.select(this); - var fillColor = el.attr('data-fill'); - if (fillColor) el.style({ - fill: fillColor, - opacity: el.attr('data-opacity') - }); else el.style({ - stroke: el.attr('data-stroke'), - opacity: el.attr('data-opacity') - }); - }); - }); - return exports; - } - exports.render = function(_container) { - render(_container); - return this; - }; - exports.config = function(_x) { - if (!arguments.length) return config; - var xClone = µ.util.cloneJson(_x); - xClone.data.forEach(function(d, i) { - if (!config.data[i]) config.data[i] = {}; - extendDeepAll(config.data[i], µ.Axis.defaultConfig().data[0]); - extendDeepAll(config.data[i], d); - }); - extendDeepAll(config.layout, µ.Axis.defaultConfig().layout); - extendDeepAll(config.layout, xClone.layout); - return this; - }; - exports.getLiveConfig = function() { - return liveConfig; - }; - exports.getinputConfig = function() { - return inputConfig; - }; - exports.radialScale = function(_x) { - return radialScale; - }; - exports.angularScale = function(_x) { - return angularScale; - }; - exports.svg = function() { - return svg; - }; - d3.rebind(exports, dispatch, 'on'); - return exports; -}; - -µ.Axis.defaultConfig = function(d, i) { - var config = { - data: [ { - t: [ 1, 2, 3, 4 ], - r: [ 10, 11, 12, 13 ], - name: 'Line1', - geometry: 'LinePlot', - color: null, - strokeDash: 'solid', - strokeColor: null, - strokeSize: '1', - visibleInLegend: true, - opacity: 1 - } ], - layout: { - defaultColorRange: d3.scale.category10().range(), - title: null, - height: 450, - width: 500, - margin: { - top: 40, - right: 40, - bottom: 40, - left: 40 - }, - font: { - size: 12, - color: 'gray', - outlineColor: 'white', - family: 'Tahoma, sans-serif' - }, - direction: 'clockwise', - orientation: 0, - labelOffset: 10, - radialAxis: { - domain: null, - orientation: -45, - ticksSuffix: '', - visible: true, - gridLinesVisible: true, - tickOrientation: 'horizontal', - rewriteTicks: null - }, - angularAxis: { - domain: [ 0, 360 ], - ticksSuffix: '', - visible: true, - gridLinesVisible: true, - labelsVisible: true, - tickOrientation: 'horizontal', - rewriteTicks: null, - ticksCount: null, - ticksStep: null - }, - minorTicks: 0, - tickLength: null, - tickColor: 'silver', - minorTickColor: '#eee', - backgroundColor: 'none', - needsEndSpacing: null, - showLegend: true, - legend: { - reverseOrder: false - }, - opacity: 1 - } - }; - return config; -}; - -µ.util = {}; - -µ.DATAEXTENT = 'dataExtent'; - -µ.AREA = 'AreaChart'; - -µ.LINE = 'LinePlot'; - -µ.DOT = 'DotPlot'; - -µ.BAR = 'BarChart'; - -µ.util._override = function(_objA, _objB) { - for (var x in _objA) if (x in _objB) _objB[x] = _objA[x]; -}; - -µ.util._extend = function(_objA, _objB) { - for (var x in _objA) _objB[x] = _objA[x]; -}; - -µ.util._rndSnd = function() { - return Math.random() * 2 - 1 + (Math.random() * 2 - 1) + (Math.random() * 2 - 1); -}; - -µ.util.dataFromEquation2 = function(_equation, _step) { - var step = _step || 6; - var data = d3.range(0, 360 + step, step).map(function(deg, index) { - var theta = deg * Math.PI / 180; - var radius = _equation(theta); - return [ deg, radius ]; - }); - return data; -}; - -µ.util.dataFromEquation = function(_equation, _step, _name) { - var step = _step || 6; - var t = [], r = []; - d3.range(0, 360 + step, step).forEach(function(deg, index) { - var theta = deg * Math.PI / 180; - var radius = _equation(theta); - t.push(deg); - r.push(radius); - }); - var result = { - t: t, - r: r - }; - if (_name) result.name = _name; - return result; -}; - -µ.util.ensureArray = function(_val, _count) { - if (typeof _val === 'undefined') return null; - var arr = [].concat(_val); - return d3.range(_count).map(function(d, i) { - return arr[i] || arr[0]; - }); -}; - -µ.util.fillArrays = function(_obj, _valueNames, _count) { - _valueNames.forEach(function(d, i) { - _obj[d] = µ.util.ensureArray(_obj[d], _count); - }); - return _obj; -}; - -µ.util.cloneJson = function(json) { - return JSON.parse(JSON.stringify(json)); -}; - -µ.util.validateKeys = function(obj, keys) { - if (typeof keys === 'string') keys = keys.split('.'); - var next = keys.shift(); - return obj[next] && (!keys.length || objHasKeys(obj[next], keys)); -}; - -µ.util.sumArrays = function(a, b) { - return d3.zip(a, b).map(function(d, i) { - return d3.sum(d); - }); -}; - -µ.util.arrayLast = function(a) { - return a[a.length - 1]; -}; - -µ.util.arrayEqual = function(a, b) { - var i = Math.max(a.length, b.length, 1); - while (i-- >= 0 && a[i] === b[i]) ; - return i === -2; -}; - -µ.util.flattenArray = function(arr) { - var r = []; - while (!µ.util.arrayEqual(r, arr)) { - r = arr; - arr = [].concat.apply([], arr); - } - return arr; -}; - -µ.util.deduplicate = function(arr) { - return arr.filter(function(v, i, a) { - return a.indexOf(v) == i; - }); -}; - -µ.util.convertToCartesian = function(radius, theta) { - var thetaRadians = theta * Math.PI / 180; - var x = radius * Math.cos(thetaRadians); - var y = radius * Math.sin(thetaRadians); - return [ x, y ]; -}; - -µ.util.round = function(_value, _digits) { - var digits = _digits || 2; - var mult = Math.pow(10, digits); - return Math.round(_value * mult) / mult; -}; - -µ.util.getMousePos = function(_referenceElement) { - var mousePos = d3.mouse(_referenceElement.node()); - var mouseX = mousePos[0]; - var mouseY = mousePos[1]; - var mouse = {}; - mouse.x = mouseX; - mouse.y = mouseY; - mouse.pos = mousePos; - mouse.angle = (Math.atan2(mouseY, mouseX) + Math.PI) * 180 / Math.PI; - mouse.radius = Math.sqrt(mouseX * mouseX + mouseY * mouseY); - return mouse; -}; - -µ.util.duplicatesCount = function(arr) { - var uniques = {}, val; - var dups = {}; - for (var i = 0, len = arr.length; i < len; i++) { - val = arr[i]; - if (val in uniques) { - uniques[val]++; - dups[val] = uniques[val]; - } else { - uniques[val] = 1; - } - } - return dups; -}; - -µ.util.duplicates = function(arr) { - return Object.keys(µ.util.duplicatesCount(arr)); -}; - -µ.util.translator = function(obj, sourceBranch, targetBranch, reverse) { - if (reverse) { - var targetBranchCopy = targetBranch.slice(); - targetBranch = sourceBranch; - sourceBranch = targetBranchCopy; - } - var value = sourceBranch.reduce(function(previousValue, currentValue) { - if (typeof previousValue != 'undefined') return previousValue[currentValue]; - }, obj); - if (typeof value === 'undefined') return; - sourceBranch.reduce(function(previousValue, currentValue, index) { - if (typeof previousValue == 'undefined') return; - if (index === sourceBranch.length - 1) delete previousValue[currentValue]; - return previousValue[currentValue]; - }, obj); - targetBranch.reduce(function(previousValue, currentValue, index) { - if (typeof previousValue[currentValue] === 'undefined') previousValue[currentValue] = {}; - if (index === targetBranch.length - 1) previousValue[currentValue] = value; - return previousValue[currentValue]; - }, obj); -}; - -µ.PolyChart = function module() { - var config = [ µ.PolyChart.defaultConfig() ]; - var dispatch = d3.dispatch('hover'); - var dashArray = { - solid: 'none', - dash: [ 5, 2 ], - dot: [ 2, 5 ] - }; - var colorScale; - function exports() { - var geometryConfig = config[0].geometryConfig; - var container = geometryConfig.container; - if (typeof container == 'string') container = d3.select(container); - container.datum(config).each(function(_config, _index) { - var isStack = !!_config[0].data.yStack; - var data = _config.map(function(d, i) { - if (isStack) return d3.zip(d.data.t[0], d.data.r[0], d.data.yStack[0]); else return d3.zip(d.data.t[0], d.data.r[0]); - }); - var angularScale = geometryConfig.angularScale; - var domainMin = geometryConfig.radialScale.domain()[0]; - var generator = {}; - generator.bar = function(d, i, pI) { - var dataConfig = _config[pI].data; - var h = geometryConfig.radialScale(d[1]) - geometryConfig.radialScale(0); - var stackTop = geometryConfig.radialScale(d[2] || 0); - var w = dataConfig.barWidth; - d3.select(this).attr({ - 'class': 'mark bar', - d: 'M' + [ [ h + stackTop, -w / 2 ], [ h + stackTop, w / 2 ], [ stackTop, w / 2 ], [ stackTop, -w / 2 ] ].join('L') + 'Z', - transform: function(d, i) { - return 'rotate(' + (geometryConfig.orientation + angularScale(d[0])) + ')'; - } - }); - }; - generator.dot = function(d, i, pI) { - var stackedData = d[2] ? [ d[0], d[1] + d[2] ] : d; - var symbol = d3.svg.symbol().size(_config[pI].data.dotSize).type(_config[pI].data.dotType)(d, i); - d3.select(this).attr({ - 'class': 'mark dot', - d: symbol, - transform: function(d, i) { - var coord = convertToCartesian(getPolarCoordinates(stackedData)); - return 'translate(' + [ coord.x, coord.y ] + ')'; - } - }); - }; - var line = d3.svg.line.radial().interpolate(_config[0].data.lineInterpolation).radius(function(d) { - return geometryConfig.radialScale(d[1]); - }).angle(function(d) { - return geometryConfig.angularScale(d[0]) * Math.PI / 180; - }); - generator.line = function(d, i, pI) { - var lineData = d[2] ? data[pI].map(function(d, i) { - return [ d[0], d[1] + d[2] ]; - }) : data[pI]; - d3.select(this).each(generator['dot']).style({ - opacity: function(dB, iB) { - return +_config[pI].data.dotVisible; - }, - fill: markStyle.stroke(d, i, pI) - }).attr({ - 'class': 'mark dot' - }); - if (i > 0) return; - var lineSelection = d3.select(this.parentNode).selectAll('path.line').data([ 0 ]); - lineSelection.enter().insert('path'); - lineSelection.attr({ - 'class': 'line', - d: line(lineData), - transform: function(dB, iB) { - return 'rotate(' + (geometryConfig.orientation + 90) + ')'; - }, - 'pointer-events': 'none' - }).style({ - fill: function(dB, iB) { - return markStyle.fill(d, i, pI); - }, - 'fill-opacity': 0, - stroke: function(dB, iB) { - return markStyle.stroke(d, i, pI); - }, - 'stroke-width': function(dB, iB) { - return markStyle['stroke-width'](d, i, pI); - }, - 'stroke-dasharray': function(dB, iB) { - return markStyle['stroke-dasharray'](d, i, pI); - }, - opacity: function(dB, iB) { - return markStyle.opacity(d, i, pI); - }, - display: function(dB, iB) { - return markStyle.display(d, i, pI); - } - }); - }; - var angularRange = geometryConfig.angularScale.range(); - var triangleAngle = Math.abs(angularRange[1] - angularRange[0]) / data[0].length * Math.PI / 180; - var arc = d3.svg.arc().startAngle(function(d) { - return -triangleAngle / 2; - }).endAngle(function(d) { - return triangleAngle / 2; - }).innerRadius(function(d) { - return geometryConfig.radialScale(domainMin + (d[2] || 0)); - }).outerRadius(function(d) { - return geometryConfig.radialScale(domainMin + (d[2] || 0)) + geometryConfig.radialScale(d[1]); - }); - generator.arc = function(d, i, pI) { - d3.select(this).attr({ - 'class': 'mark arc', - d: arc, - transform: function(d, i) { - return 'rotate(' + (geometryConfig.orientation + angularScale(d[0]) + 90) + ')'; - } - }); - }; - var markStyle = { - fill: function(d, i, pI) { - return _config[pI].data.color; - }, - stroke: function(d, i, pI) { - return _config[pI].data.strokeColor; - }, - 'stroke-width': function(d, i, pI) { - return _config[pI].data.strokeSize + 'px'; - }, - 'stroke-dasharray': function(d, i, pI) { - return dashArray[_config[pI].data.strokeDash]; - }, - opacity: function(d, i, pI) { - return _config[pI].data.opacity; - }, - display: function(d, i, pI) { - return typeof _config[pI].data.visible === 'undefined' || _config[pI].data.visible ? 'block' : 'none'; - } - }; - var geometryLayer = d3.select(this).selectAll('g.layer').data(data); - geometryLayer.enter().append('g').attr({ - 'class': 'layer' - }); - var geometry = geometryLayer.selectAll('path.mark').data(function(d, i) { - return d; - }); - geometry.enter().append('path').attr({ - 'class': 'mark' - }); - geometry.style(markStyle).each(generator[geometryConfig.geometryType]); - geometry.exit().remove(); - geometryLayer.exit().remove(); - function getPolarCoordinates(d, i) { - var r = geometryConfig.radialScale(d[1]); - var t = (geometryConfig.angularScale(d[0]) + geometryConfig.orientation) * Math.PI / 180; - return { - r: r, - t: t - }; - } - function convertToCartesian(polarCoordinates) { - var x = polarCoordinates.r * Math.cos(polarCoordinates.t); - var y = polarCoordinates.r * Math.sin(polarCoordinates.t); - return { - x: x, - y: y - }; - } - }); - } - exports.config = function(_x) { - if (!arguments.length) return config; - _x.forEach(function(d, i) { - if (!config[i]) config[i] = {}; - extendDeepAll(config[i], µ.PolyChart.defaultConfig()); - extendDeepAll(config[i], d); - }); - return this; - }; - exports.getColorScale = function() { - return colorScale; - }; - d3.rebind(exports, dispatch, 'on'); - return exports; -}; - -µ.PolyChart.defaultConfig = function() { - var config = { - data: { - name: 'geom1', - t: [ [ 1, 2, 3, 4 ] ], - r: [ [ 1, 2, 3, 4 ] ], - dotType: 'circle', - dotSize: 64, - dotVisible: false, - barWidth: 20, - color: '#ffa500', - strokeSize: 1, - strokeColor: 'silver', - strokeDash: 'solid', - opacity: 1, - index: 0, - visible: true, - visibleInLegend: true - }, - geometryConfig: { - geometry: 'LinePlot', - geometryType: 'arc', - direction: 'clockwise', - orientation: 0, - container: 'body', - radialScale: null, - angularScale: null, - colorScale: d3.scale.category20() - } - }; - return config; -}; - -µ.BarChart = function module() { - return µ.PolyChart(); -}; - -µ.BarChart.defaultConfig = function() { - var config = { - geometryConfig: { - geometryType: 'bar' - } - }; - return config; -}; - -µ.AreaChart = function module() { - return µ.PolyChart(); -}; - -µ.AreaChart.defaultConfig = function() { - var config = { - geometryConfig: { - geometryType: 'arc' - } - }; - return config; -}; - -µ.DotPlot = function module() { - return µ.PolyChart(); -}; - -µ.DotPlot.defaultConfig = function() { - var config = { - geometryConfig: { - geometryType: 'dot', - dotType: 'circle' - } - }; - return config; -}; - -µ.LinePlot = function module() { - return µ.PolyChart(); -}; - -µ.LinePlot.defaultConfig = function() { - var config = { - geometryConfig: { - geometryType: 'line' - } - }; - return config; -}; - -µ.Legend = function module() { - var config = µ.Legend.defaultConfig(); - var dispatch = d3.dispatch('hover'); - function exports() { - var legendConfig = config.legendConfig; - var flattenData = config.data.map(function(d, i) { - return [].concat(d).map(function(dB, iB) { - var element = extendDeepAll({}, legendConfig.elements[i]); - element.name = dB; - element.color = [].concat(legendConfig.elements[i].color)[iB]; - return element; - }); - }); - var data = d3.merge(flattenData); - data = data.filter(function(d, i) { - return legendConfig.elements[i] && (legendConfig.elements[i].visibleInLegend || typeof legendConfig.elements[i].visibleInLegend === 'undefined'); - }); - if (legendConfig.reverseOrder) data = data.reverse(); - var container = legendConfig.container; - if (typeof container == 'string' || container.nodeName) container = d3.select(container); - var colors = data.map(function(d, i) { - return d.color; - }); - var lineHeight = legendConfig.fontSize; - var isContinuous = legendConfig.isContinuous == null ? typeof data[0] === 'number' : legendConfig.isContinuous; - var height = isContinuous ? legendConfig.height : lineHeight * data.length; - var legendContainerGroup = container.classed('legend-group', true); - var svg = legendContainerGroup.selectAll('svg').data([ 0 ]); - var svgEnter = svg.enter().append('svg').attr({ - width: 300, - height: height + lineHeight, - xmlns: 'http://www.w3.org/2000/svg', - 'xmlns:xlink': 'http://www.w3.org/1999/xlink', - version: '1.1' - }); - svgEnter.append('g').classed('legend-axis', true); - svgEnter.append('g').classed('legend-marks', true); - var dataNumbered = d3.range(data.length); - var colorScale = d3.scale[isContinuous ? 'linear' : 'ordinal']().domain(dataNumbered).range(colors); - var dataScale = d3.scale[isContinuous ? 'linear' : 'ordinal']().domain(dataNumbered)[isContinuous ? 'range' : 'rangePoints']([ 0, height ]); - var shapeGenerator = function(_type, _size) { - var squareSize = _size * 3; - if (_type === 'line') { - return 'M' + [ [ -_size / 2, -_size / 12 ], [ _size / 2, -_size / 12 ], [ _size / 2, _size / 12 ], [ -_size / 2, _size / 12 ] ] + 'Z'; - } else if (d3.svg.symbolTypes.indexOf(_type) != -1) return d3.svg.symbol().type(_type).size(squareSize)(); else return d3.svg.symbol().type('square').size(squareSize)(); - }; - if (isContinuous) { - var gradient = svg.select('.legend-marks').append('defs').append('linearGradient').attr({ - id: 'grad1', - x1: '0%', - y1: '0%', - x2: '0%', - y2: '100%' - }).selectAll('stop').data(colors); - gradient.enter().append('stop'); - gradient.attr({ - offset: function(d, i) { - return i / (colors.length - 1) * 100 + '%'; - } - }).style({ - 'stop-color': function(d, i) { - return d; - } - }); - svg.append('rect').classed('legend-mark', true).attr({ - height: legendConfig.height, - width: legendConfig.colorBandWidth, - fill: 'url(#grad1)' - }); - } else { - var legendElement = svg.select('.legend-marks').selectAll('path.legend-mark').data(data); - legendElement.enter().append('path').classed('legend-mark', true); - legendElement.attr({ - transform: function(d, i) { - return 'translate(' + [ lineHeight / 2, dataScale(i) + lineHeight / 2 ] + ')'; - }, - d: function(d, i) { - var symbolType = d.symbol; - return shapeGenerator(symbolType, lineHeight); - }, - fill: function(d, i) { - return colorScale(i); - } - }); - legendElement.exit().remove(); - } - var legendAxis = d3.svg.axis().scale(dataScale).orient('right'); - var axis = svg.select('g.legend-axis').attr({ - transform: 'translate(' + [ isContinuous ? legendConfig.colorBandWidth : lineHeight, lineHeight / 2 ] + ')' - }).call(legendAxis); - axis.selectAll('.domain').style({ - fill: 'none', - stroke: 'none' - }); - axis.selectAll('line').style({ - fill: 'none', - stroke: isContinuous ? legendConfig.textColor : 'none' - }); - axis.selectAll('text').style({ - fill: legendConfig.textColor, - 'font-size': legendConfig.fontSize - }).text(function(d, i) { - return data[i].name; - }); - return exports; - } - exports.config = function(_x) { - if (!arguments.length) return config; - extendDeepAll(config, _x); - return this; - }; - d3.rebind(exports, dispatch, 'on'); - return exports; -}; - -µ.Legend.defaultConfig = function(d, i) { - var config = { - data: [ 'a', 'b', 'c' ], - legendConfig: { - elements: [ { - symbol: 'line', - color: 'red' - }, { - symbol: 'square', - color: 'yellow' - }, { - symbol: 'diamond', - color: 'limegreen' - } ], - height: 150, - colorBandWidth: 30, - fontSize: 12, - container: 'body', - isContinuous: null, - textColor: 'grey', - reverseOrder: false - } - }; - return config; -}; - -µ.tooltipPanel = function() { - var tooltipEl, tooltipTextEl, backgroundEl; - var config = { - container: null, - hasTick: false, - fontSize: 12, - color: 'white', - padding: 5 - }; - var id = 'tooltip-' + µ.tooltipPanel.uid++; - var tickSize = 10; - var exports = function() { - tooltipEl = config.container.selectAll('g.' + id).data([ 0 ]); - var tooltipEnter = tooltipEl.enter().append('g').classed(id, true).style({ - 'pointer-events': 'none', - display: 'none' - }); - backgroundEl = tooltipEnter.append('path').style({ - fill: 'white', - 'fill-opacity': .9 - }).attr({ - d: 'M0 0' - }); - tooltipTextEl = tooltipEnter.append('text').attr({ - dx: config.padding + tickSize, - dy: +config.fontSize * .3 - }); - return exports; - }; - exports.text = function(_text) { - var l = d3.hsl(config.color).l; - var strokeColor = l >= .5 ? '#aaa' : 'white'; - var fillColor = l >= .5 ? 'black' : 'white'; - var text = _text || ''; - tooltipTextEl.style({ - fill: fillColor, - 'font-size': config.fontSize + 'px' - }).text(text); - var padding = config.padding; - var bbox = tooltipTextEl.node().getBBox(); - var boxStyle = { - fill: config.color, - stroke: strokeColor, - 'stroke-width': '2px' - }; - var backGroundW = bbox.width + padding * 2 + tickSize; - var backGroundH = bbox.height + padding * 2; - backgroundEl.attr({ - d: 'M' + [ [ tickSize, -backGroundH / 2 ], [ tickSize, -backGroundH / 4 ], [ config.hasTick ? 0 : tickSize, 0 ], [ tickSize, backGroundH / 4 ], [ tickSize, backGroundH / 2 ], [ backGroundW, backGroundH / 2 ], [ backGroundW, -backGroundH / 2 ] ].join('L') + 'Z' - }).style(boxStyle); - tooltipEl.attr({ - transform: 'translate(' + [ tickSize, -backGroundH / 2 + padding * 2 ] + ')' - }); - tooltipEl.style({ - display: 'block' - }); - return exports; - }; - exports.move = function(_pos) { - if (!tooltipEl) return; - tooltipEl.attr({ - transform: 'translate(' + [ _pos[0], _pos[1] ] + ')' - }).style({ - display: 'block' - }); - return exports; - }; - exports.hide = function() { - if (!tooltipEl) return; - tooltipEl.style({ - display: 'none' - }); - return exports; - }; - exports.show = function() { - if (!tooltipEl) return; - tooltipEl.style({ - display: 'block' - }); - return exports; - }; - exports.config = function(_x) { - extendDeepAll(config, _x); - return exports; - }; - return exports; -}; - -µ.tooltipPanel.uid = 1; - -µ.adapter = {}; - -µ.adapter.plotly = function module() { - var exports = {}; - exports.convert = function(_inputConfig, reverse) { - var outputConfig = {}; - if (_inputConfig.data) { - outputConfig.data = _inputConfig.data.map(function(d, i) { - var r = extendDeepAll({}, d); - var toTranslate = [ - [ r, [ 'marker', 'color' ], [ 'color' ] ], - [ r, [ 'marker', 'opacity' ], [ 'opacity' ] ], - [ r, [ 'marker', 'line', 'color' ], [ 'strokeColor' ] ], - [ r, [ 'marker', 'line', 'dash' ], [ 'strokeDash' ] ], - [ r, [ 'marker', 'line', 'width' ], [ 'strokeSize' ] ], - [ r, [ 'marker', 'symbol' ], [ 'dotType' ] ], - [ r, [ 'marker', 'size' ], [ 'dotSize' ] ], - [ r, [ 'marker', 'barWidth' ], [ 'barWidth' ] ], - [ r, [ 'line', 'interpolation' ], [ 'lineInterpolation' ] ], - [ r, [ 'showlegend' ], [ 'visibleInLegend' ] ] - ]; - toTranslate.forEach(function(d, i) { - µ.util.translator.apply(null, d.concat(reverse)); - }); - - if (!reverse) delete r.marker; - if (reverse) delete r.groupId; - if (!reverse) { - if (r.type === 'scatter') { - if (r.mode === 'lines') r.geometry = 'LinePlot'; else if (r.mode === 'markers') r.geometry = 'DotPlot'; else if (r.mode === 'lines+markers') { - r.geometry = 'LinePlot'; - r.dotVisible = true; - } - } else if (r.type === 'area') r.geometry = 'AreaChart'; else if (r.type === 'bar') r.geometry = 'BarChart'; - delete r.mode; - delete r.type; - } else { - if (r.geometry === 'LinePlot') { - r.type = 'scatter'; - if (r.dotVisible === true) { - delete r.dotVisible; - r.mode = 'lines+markers'; - } else r.mode = 'lines'; - } else if (r.geometry === 'DotPlot') { - r.type = 'scatter'; - r.mode = 'markers'; - } else if (r.geometry === 'AreaChart') r.type = 'area'; else if (r.geometry === 'BarChart') r.type = 'bar'; - delete r.geometry; - } - return r; - }); - if (!reverse && _inputConfig.layout && _inputConfig.layout.barmode === 'stack') { - var duplicates = µ.util.duplicates(outputConfig.data.map(function(d, i) { - return d.geometry; - })); - outputConfig.data.forEach(function(d, i) { - var idx = duplicates.indexOf(d.geometry); - if (idx != -1) outputConfig.data[i].groupId = idx; - }); - } - } - if (_inputConfig.layout) { - var r = extendDeepAll({}, _inputConfig.layout); - var toTranslate = [ - [ r, [ 'plot_bgcolor' ], [ 'backgroundColor' ] ], - [ r, [ 'showlegend' ], [ 'showLegend' ] ], - [ r, [ 'radialaxis' ], [ 'radialAxis' ] ], - [ r, [ 'angularaxis' ], [ 'angularAxis' ] ], - [ r.angularaxis, [ 'showline' ], [ 'gridLinesVisible' ] ], - [ r.angularaxis, [ 'showticklabels' ], [ 'labelsVisible' ] ], - [ r.angularaxis, [ 'nticks' ], [ 'ticksCount' ] ], - [ r.angularaxis, [ 'tickorientation' ], [ 'tickOrientation' ] ], - [ r.angularaxis, [ 'ticksuffix' ], [ 'ticksSuffix' ] ], - [ r.angularaxis, [ 'range' ], [ 'domain' ] ], - [ r.angularaxis, [ 'endpadding' ], [ 'endPadding' ] ], - [ r.radialaxis, [ 'showline' ], [ 'gridLinesVisible' ] ], - [ r.radialaxis, [ 'tickorientation' ], [ 'tickOrientation' ] ], - [ r.radialaxis, [ 'ticksuffix' ], [ 'ticksSuffix' ] ], - [ r.radialaxis, [ 'range' ], [ 'domain' ] ], - [ r.angularAxis, [ 'showline' ], [ 'gridLinesVisible' ] ], - [ r.angularAxis, [ 'showticklabels' ], [ 'labelsVisible' ] ], - [ r.angularAxis, [ 'nticks' ], [ 'ticksCount' ] ], - [ r.angularAxis, [ 'tickorientation' ], [ 'tickOrientation' ] ], - [ r.angularAxis, [ 'ticksuffix' ], [ 'ticksSuffix' ] ], - [ r.angularAxis, [ 'range' ], [ 'domain' ] ], - [ r.angularAxis, [ 'endpadding' ], [ 'endPadding' ] ], - [ r.radialAxis, [ 'showline' ], [ 'gridLinesVisible' ] ], - [ r.radialAxis, [ 'tickorientation' ], [ 'tickOrientation' ] ], - [ r.radialAxis, [ 'ticksuffix' ], [ 'ticksSuffix' ] ], - [ r.radialAxis, [ 'range' ], [ 'domain' ] ], - [ r.font, [ 'outlinecolor' ], [ 'outlineColor' ] ], - [ r.legend, [ 'traceorder' ], [ 'reverseOrder' ] ], - [ r, [ 'labeloffset' ], [ 'labelOffset' ] ], - [ r, [ 'defaultcolorrange' ], [ 'defaultColorRange' ] ] - ]; - toTranslate.forEach(function(d, i) { - µ.util.translator.apply(null, d.concat(reverse)); - }); - - if (!reverse) { - if (r.angularAxis && typeof r.angularAxis.ticklen !== 'undefined') r.tickLength = r.angularAxis.ticklen; - if (r.angularAxis && typeof r.angularAxis.tickcolor !== 'undefined') r.tickColor = r.angularAxis.tickcolor; - } else { - if (typeof r.tickLength !== 'undefined') { - r.angularaxis.ticklen = r.tickLength; - delete r.tickLength; - } - if (r.tickColor) { - r.angularaxis.tickcolor = r.tickColor; - delete r.tickColor; - } - } - if (r.legend && typeof r.legend.reverseOrder != 'boolean') { - r.legend.reverseOrder = r.legend.reverseOrder != 'normal'; - } - if (r.legend && typeof r.legend.traceorder == 'boolean') { - r.legend.traceorder = r.legend.traceorder ? 'reversed' : 'normal'; - delete r.legend.reverseOrder; - } - if (r.margin && typeof r.margin.t != 'undefined') { - var source = [ 't', 'r', 'b', 'l', 'pad' ]; - var target = [ 'top', 'right', 'bottom', 'left', 'pad' ]; - var margin = {}; - d3.entries(r.margin).forEach(function(dB, iB) { - margin[target[source.indexOf(dB.key)]] = dB.value; - }); - r.margin = margin; - } - if (reverse) { - delete r.needsEndSpacing; - delete r.minorTickColor; - delete r.minorTicks; - delete r.angularaxis.ticksCount; - delete r.angularaxis.ticksCount; - delete r.angularaxis.ticksStep; - delete r.angularaxis.rewriteTicks; - delete r.angularaxis.nticks; - delete r.radialaxis.ticksCount; - delete r.radialaxis.ticksCount; - delete r.radialaxis.ticksStep; - delete r.radialaxis.rewriteTicks; - delete r.radialaxis.nticks; - } - outputConfig.layout = r; - } - return outputConfig; - }; - return exports; -}; - -},{"../../../constants/alignment":207,"../../../lib":233,"d3":21}],318:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - -/* eslint-disable new-cap */ - -'use strict'; - -var d3 = _dereq_('d3'); -var Lib = _dereq_('../../../lib'); -var Color = _dereq_('../../../components/color'); - -var micropolar = _dereq_('./micropolar'); -var UndoManager = _dereq_('./undo_manager'); -var extendDeepAll = Lib.extendDeepAll; - -var manager = module.exports = {}; - -manager.framework = function(_gd) { - var config, previousConfigClone, plot, convertedInput, container; - var undoManager = new UndoManager(); - - function exports(_inputConfig, _container) { - if(_container) container = _container; - d3.select(d3.select(container).node().parentNode).selectAll('.svg-container>*:not(.chart-root)').remove(); - - config = (!config) ? - _inputConfig : - extendDeepAll(config, _inputConfig); - - if(!plot) plot = micropolar.Axis(); - convertedInput = micropolar.adapter.plotly().convert(config); - plot.config(convertedInput).render(container); - _gd.data = config.data; - _gd.layout = config.layout; - manager.fillLayout(_gd); - return config; - } - exports.isPolar = true; - exports.svg = function() { return plot.svg(); }; - exports.getConfig = function() { return config; }; - exports.getLiveConfig = function() { - return micropolar.adapter.plotly().convert(plot.getLiveConfig(), true); - }; - exports.getLiveScales = function() { return {t: plot.angularScale(), r: plot.radialScale()}; }; - exports.setUndoPoint = function() { - var that = this; - var configClone = micropolar.util.cloneJson(config); - (function(_configClone, _previousConfigClone) { - undoManager.add({ - undo: function() { - if(_previousConfigClone) that(_previousConfigClone); - }, - redo: function() { - that(_configClone); - } - }); - })(configClone, previousConfigClone); - previousConfigClone = micropolar.util.cloneJson(configClone); - }; - exports.undo = function() { undoManager.undo(); }; - exports.redo = function() { undoManager.redo(); }; - return exports; -}; - -manager.fillLayout = function(_gd) { - var container = d3.select(_gd).selectAll('.plot-container'); - var paperDiv = container.selectAll('.svg-container'); - var paper = _gd.framework && _gd.framework.svg && _gd.framework.svg(); - var dflts = { - width: 800, - height: 600, - paper_bgcolor: Color.background, - _container: container, - _paperdiv: paperDiv, - _paper: paper - }; - - _gd._fullLayout = extendDeepAll(dflts, _gd.layout); -}; - -},{"../../../components/color":105,"../../../lib":233,"./micropolar":317,"./undo_manager":319,"d3":21}],319:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - -'use strict'; - -// Modified from https://github.com/ArthurClemens/Javascript-Undo-Manager -// Copyright (c) 2010-2013 Arthur Clemens, arthur@visiblearea.com -module.exports = function UndoManager() { - var undoCommands = []; - var index = -1; - var isExecuting = false; - var callback; - - function execute(command, action) { - if(!command) return this; - - isExecuting = true; - command[action](); - isExecuting = false; - - return this; - } - - return { - add: function(command) { - if(isExecuting) return this; - undoCommands.splice(index + 1, undoCommands.length - index); - undoCommands.push(command); - index = undoCommands.length - 1; - return this; - }, - setCallback: function(callbackFunc) { callback = callbackFunc; }, - undo: function() { - var command = undoCommands[index]; - if(!command) return this; - execute(command, 'undo'); - index -= 1; - if(callback) callback(command.undo); - return this; - }, - redo: function() { - var command = undoCommands[index + 1]; - if(!command) return this; - execute(command, 'redo'); - index += 1; - if(callback) callback(command.redo); - return this; - }, - clear: function() { - undoCommands = []; - index = -1; - }, - hasUndo: function() { return index !== -1; }, - hasRedo: function() { return index < (undoCommands.length - 1); }, - getCommands: function() { return undoCommands; }, - getPreviousCommand: function() { return undoCommands[index - 1]; }, - getIndex: function() { return index; } - }; -}; - -},{}],320:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../components/color":155,"../constants/numerical":265,"../lib":285,"../plot_api/plot_schema":319,"../plot_api/plot_template":320,"../plots/get_data":361,"../registry":373,"./animation_attributes":325,"./attributes":327,"./cartesian/axis_ids":334,"./cartesian/handle_outline":341,"./command":357,"./font_attributes":359,"./frame_attributes":360,"./layout_attributes":364,"@plotly/d3":20,"d3-time-format":29,"fast-isnumeric":31}],367:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../lib'); @@ -76719,29 +83150,31 @@ module.exports = function handleSubplotDefaults(layoutIn, layoutOut, fullData, o } }; -},{"../lib":233,"../plot_api/plot_template":268,"./domain":306}],321:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285,"../plot_api/plot_template":320,"./domain":358}],368:[function(_dereq_,module,exports){ 'use strict'; -var FORMAT_LINK = _dereq_('../constants/docs').FORMAT_LINK; -var DATE_FORMAT_LINK = _dereq_('../constants/docs').DATE_FORMAT_LINK; +var docs = _dereq_('../constants/docs'); +var FORMAT_LINK = docs.FORMAT_LINK; +var DATE_FORMAT_LINK = docs.DATE_FORMAT_LINK; -var templateFormatStringDescription = [ - 'Variables are inserted using %{variable}, for example "y: %{y}".', - 'Numbers are formatted using d3-format\'s syntax %{variable:d3-format}, for example "Price: %{y:$.2f}".', - FORMAT_LINK, - 'for details on the formatting syntax.', - 'Dates are formatted using d3-time-format\'s syntax %{variable|d3-time-format}, for example "Day: %{2019-01-01|%A}".', - DATE_FORMAT_LINK, - 'for details on the date formatting syntax.' -].join(' '); +function templateFormatStringDescription(opts) { + var supportOther = opts && opts.supportOther; + + return [ + 'Variables are inserted using %{variable},', + 'for example "y: %{y}"' + ( + supportOther ? + ' as well as %{xother}, {%_xother}, {%_xother_}, {%xother_}. When showing info for several points, *xother* will be added to those with different x positions from the first point. An underscore before or after *(x|y)other* will add a space on that side, only when this field is shown.' : + '.' + ), + 'Numbers are formatted using d3-format\'s syntax %{variable:d3-format}, for example "Price: %{y:$.2f}".', + FORMAT_LINK, + 'for details on the formatting syntax.', + 'Dates are formatted using d3-time-format\'s syntax %{variable|d3-time-format}, for example "Day: %{2019-01-01|%A}".', + DATE_FORMAT_LINK, + 'for details on the date formatting syntax.' + ].join(' '); +} function describeVariables(extra) { var descPart = extra.description ? ' ' + extra.description : ''; @@ -76769,10 +83202,8 @@ exports.hovertemplateAttrs = function(opts, extra) { var hovertemplate = { valType: 'string', - dflt: '', editType: opts.editType || 'none', - }; if(opts.arrayOk !== false) { @@ -76790,10 +83221,8 @@ exports.texttemplateAttrs = function(opts, extra) { var texttemplate = { valType: 'string', - dflt: '', editType: opts.editType || 'calc', - }; if(opts.arrayOk !== false) { @@ -76802,16 +83231,7 @@ exports.texttemplateAttrs = function(opts, extra) { return texttemplate; }; -},{"../constants/docs":209}],322:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../constants/docs":262}],369:[function(_dereq_,module,exports){ 'use strict'; var Ternary = _dereq_('./ternary'); @@ -76831,10 +83251,8 @@ exports.idRegex = exports.attrRegex = counterRegex(TERNARY); var attributes = exports.attributes = {}; attributes[attr] = { valType: 'subplotid', - dflt: 'ternary', editType: 'calc', - }; exports.layoutAttributes = _dereq_('./layout_attributes'); @@ -76886,15 +83304,7 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) } }; -},{"../../lib":233,"../../plots/get_data":309,"./layout_attributes":323,"./layout_defaults":324,"./ternary":325}],323:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/get_data":361,"./layout_attributes":370,"./layout_defaults":371,"./ternary":372}],370:[function(_dereq_,module,exports){ 'use strict'; var colorAttrs = _dereq_('../../components/color/attributes'); @@ -76948,9 +83358,7 @@ var ternaryAxesAttrs = { min: { valType: 'number', dflt: 0, - min: 0, - }, _deprecated: { title: axesAttrs._deprecated.title, @@ -76963,16 +83371,12 @@ var attrs = module.exports = overrideAll({ bgcolor: { valType: 'color', - dflt: colorAttrs.background, - }, sum: { valType: 'number', - dflt: 1, min: 0, - }, aaxis: ternaryAxesAttrs, baxis: ternaryAxesAttrs, @@ -76982,27 +83386,15 @@ var attrs = module.exports = overrideAll({ // set uirevisions outside of `overrideAll` so we can get `editType: none` attrs.uirevision = { valType: 'any', - editType: 'none', - }; attrs.aaxis.uirevision = attrs.baxis.uirevision = attrs.caxis.uirevision = { valType: 'any', - editType: 'none', - }; -},{"../../components/color/attributes":104,"../../lib/extend":227,"../../plot_api/edit_types":261,"../cartesian/layout_attributes":293,"../domain":306}],324:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color/attributes":154,"../../lib/extend":279,"../../plot_api/edit_types":313,"../cartesian/layout_attributes":345,"../domain":358}],371:[function(_dereq_,module,exports){ 'use strict'; var Color = _dereq_('../../components/color'); @@ -77087,7 +83479,7 @@ function handleAxisDefaults(containerIn, containerOut, options, ternaryLayoutOut Lib.coerceFont(coerce, 'title.font', { family: options.font.family, - size: Math.round(options.font.size * 1.2), + size: Lib.bigFont(options.font.size), color: dfltFontColor }); @@ -77126,19 +83518,10 @@ function handleAxisDefaults(containerIn, containerOut, options, ternaryLayoutOut coerce('layer'); } -},{"../../components/color":105,"../../lib":233,"../../plot_api/plot_template":268,"../cartesian/line_grid_defaults":295,"../cartesian/tick_label_defaults":300,"../cartesian/tick_mark_defaults":301,"../cartesian/tick_value_defaults":302,"../subplot_defaults":320,"./layout_attributes":323}],325:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/color":155,"../../lib":285,"../../plot_api/plot_template":320,"../cartesian/line_grid_defaults":347,"../cartesian/tick_label_defaults":352,"../cartesian/tick_mark_defaults":353,"../cartesian/tick_value_defaults":354,"../subplot_defaults":367,"./layout_attributes":370}],372:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var tinycolor = _dereq_('tinycolor2'); var Registry = _dereq_('../../registry'); @@ -77907,15 +84290,7 @@ function removeZoombox(gd) { .remove(); } -},{"../../components/color":105,"../../components/dragelement":124,"../../components/dragelement/helpers":123,"../../components/drawing":127,"../../components/fx":145,"../../components/titles":200,"../../lib":233,"../../lib/extend":227,"../../registry":326,"../cartesian/axes":279,"../cartesian/constants":285,"../cartesian/select":298,"../cartesian/set_convert":299,"../plots":313,"d3":21,"tinycolor2":88}],326:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../components/dragelement":174,"../../components/dragelement/helpers":173,"../../components/drawing":177,"../../components/fx":195,"../../components/titles":253,"../../lib":285,"../../lib/extend":279,"../../registry":373,"../cartesian/axes":331,"../cartesian/constants":337,"../cartesian/select":350,"../cartesian/set_convert":351,"../plots":366,"@plotly/d3":20,"tinycolor2":119}],373:[function(_dereq_,module,exports){ 'use strict'; var Loggers = _dereq_('./lib/loggers'); @@ -78054,7 +84429,7 @@ exports.traceIs = function(traceType, category) { var _module = exports.modules[traceType]; if(!_module) { - if(traceType && traceType !== 'area') { + if(traceType) { Loggers.log('Unrecognized trace type ' + traceType + '.'); } @@ -78373,15 +84748,7 @@ function getTraceType(traceType) { return traceType; } -},{"./lib/dom":225,"./lib/extend":227,"./lib/is_plain_object":234,"./lib/loggers":237,"./lib/noop":242,"./lib/push_unique":247,"./plots/attributes":275,"./plots/layout_attributes":311}],327:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"./lib/dom":277,"./lib/extend":279,"./lib/is_plain_object":286,"./lib/loggers":289,"./lib/noop":294,"./lib/push_unique":299,"./plots/attributes":327,"./plots/layout_attributes":364}],374:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../registry'); @@ -78434,11 +84801,6 @@ function keyIsAxis(keyName) { module.exports = function clonePlot(graphObj, options) { - // Polar plot compatibility - if(graphObj.framework && graphObj.framework.isPolar) { - graphObj = graphObj.framework.getConfig(); - } - var i; var oldData = graphObj.data; var oldLayout = graphObj.layout; @@ -78546,15 +84908,7 @@ module.exports = function clonePlot(graphObj, options) { return plotTile; }; -},{"../lib":233,"../registry":326}],328:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285,"../registry":373}],375:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../lib'); @@ -78618,15 +84972,7 @@ function downloadImage(gd, opts) { module.exports = downloadImage; -},{"../lib":233,"../plot_api/to_image":271,"./filesaver":329,"./helpers":330}],329:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285,"../plot_api/to_image":323,"./filesaver":376,"./helpers":377}],376:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../lib'); @@ -78652,10 +84998,6 @@ function fileSaver(url, name, format) { var blob; var objectUrl; - if(Lib.isIE9orBelow()) { - reject(new Error('IE < 10 unsupported')); - } - // Safari doesn't allow downloading of blob urls if(Lib.isSafari()) { var prefix = format === 'svg' ? ',' : ';base64,'; @@ -78698,15 +85040,7 @@ function fileSaver(url, name, format) { module.exports = fileSaver; -},{"../lib":233,"./helpers":330}],330:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285,"./helpers":377}],377:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../registry'); @@ -78723,13 +85057,7 @@ exports.getDelay = function(fullLayout) { exports.getRedrawFunc = function(gd) { return function() { - var fullLayout = gd._fullLayout || {}; - var hasPolar = fullLayout._has && fullLayout._has('polar'); - var hasLegacyPolar = !hasPolar && gd.data && gd.data[0] && gd.data[0].r; - - if(!hasLegacyPolar) { - Registry.getComponentMethod('colorbar', 'draw')(gd); - } + Registry.getComponentMethod('colorbar', 'draw')(gd); }; }; @@ -78781,16 +85109,7 @@ exports.IMAGE_URL_PREFIX = /^data:image\/\w+;base64,/; exports.MSG_IE_BAD_FORMAT = 'Sorry IE does not support downloading from canvas. Try {format:\'svg\'} instead.'; -},{"../registry":326}],331:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../registry":373}],378:[function(_dereq_,module,exports){ 'use strict'; var helpers = _dereq_('./helpers'); @@ -78807,15 +85126,7 @@ var Snapshot = { module.exports = Snapshot; -},{"./cloneplot":327,"./download":328,"./helpers":330,"./svgtoimg":332,"./toimage":333,"./tosvg":334}],332:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"./cloneplot":374,"./download":375,"./helpers":377,"./svgtoimg":379,"./toimage":380,"./tosvg":381}],379:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../lib'); @@ -78855,7 +85166,7 @@ function svgToImg(opts) { var img = new Image(); var svgBlob, url; - if(format === 'svg' || Lib.isIE9orBelow() || Lib.isSafari()) { + if(format === 'svg' || Lib.isSafari()) { url = helpers.encodeSVG(svg); } else { svgBlob = helpers.createBlob(svg, 'svg'); @@ -78934,15 +85245,7 @@ function svgToImg(opts) { module.exports = svgToImg; -},{"../lib":233,"./helpers":330,"events":17}],333:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285,"./helpers":377,"events":27}],380:[function(_dereq_,module,exports){ 'use strict'; var EventEmitter = _dereq_('events').EventEmitter; @@ -78998,7 +85301,7 @@ function toImage(gd, opts) { var redrawFunc = helpers.getRedrawFunc(clonedGd); - Registry.call('plot', clonedGd, clone.data, clone.layout, clone.config) + Registry.call('_doPlot', clonedGd, clone.data, clone.layout, clone.config) .then(redrawFunc) .then(wait) .catch(function(err) { @@ -79011,19 +85314,10 @@ function toImage(gd, opts) { module.exports = toImage; -},{"../lib":233,"../registry":326,"./cloneplot":327,"./helpers":330,"./svgtoimg":332,"./tosvg":334,"events":17}],334:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../lib":285,"../registry":373,"./cloneplot":374,"./helpers":377,"./svgtoimg":379,"./tosvg":381,"events":27}],381:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Lib = _dereq_('../lib'); var Drawing = _dereq_('../components/drawing'); @@ -79056,7 +85350,7 @@ module.exports = function toSVG(gd, format, scale) { var toppaper = fullLayout._toppaper; var width = fullLayout.width; var height = fullLayout.height; - var i; + var i, k; // make background color a rect in the svg, then revert after scraping // all other alterations have been dealt with by properly preparing the svg @@ -79129,28 +85423,31 @@ module.exports = function toSVG(gd, format, scale) { } }); - + var queryParts = []; if(fullLayout._gradientUrlQueryParts) { - var queryParts = []; - for(var k in fullLayout._gradientUrlQueryParts) queryParts.push(k); + for(k in fullLayout._gradientUrlQueryParts) queryParts.push(k); + } - if(queryParts.length) { - svg.selectAll(queryParts.join(',')).each(function() { - var pt = d3.select(this); + if(fullLayout._patternUrlQueryParts) { + for(k in fullLayout._patternUrlQueryParts) queryParts.push(k); + } - // similar to font family styles above, - // we must remove " after the SVG DOM has been serialized - var fill = this.style.fill; - if(fill && fill.indexOf('url(') !== -1) { - pt.style('fill', fill.replace(DOUBLEQUOTE_REGEX, DUMMY_SUB)); - } + if(queryParts.length) { + svg.selectAll(queryParts.join(',')).each(function() { + var pt = d3.select(this); - var stroke = this.style.stroke; - if(stroke && stroke.indexOf('url(') !== -1) { - pt.style('stroke', stroke.replace(DOUBLEQUOTE_REGEX, DUMMY_SUB)); - } - }); - } + // similar to font family styles above, + // we must remove " after the SVG DOM has been serialized + var fill = this.style.fill; + if(fill && fill.indexOf('url(') !== -1) { + pt.style('fill', fill.replace(DOUBLEQUOTE_REGEX, DUMMY_SUB)); + } + + var stroke = this.style.stroke; + if(stroke && stroke.indexOf('url(') !== -1) { + pt.style('stroke', stroke.replace(DOUBLEQUOTE_REGEX, DUMMY_SUB)); + } + }); } if(format === 'pdf' || format === 'eps') { @@ -79178,6 +85475,8 @@ module.exports = function toSVG(gd, format, scale) { // Fix quotations around font strings and gradient URLs s = s.replace(DUMMY_REGEX, '\''); + // Do we need this process now that IE9 and IE10 are not supported? + // IE is very strict, so we will need to clean // svg with the following regex // yes this is messy, but do not know a better way @@ -79200,15 +85499,7 @@ module.exports = function toSVG(gd, format, scale) { return s; }; -},{"../components/color":105,"../components/drawing":127,"../constants/xmlns_namespaces":213,"../lib":233,"d3":21}],335:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../components/color":155,"../components/drawing":177,"../constants/xmlns_namespaces":266,"../lib":285,"@plotly/d3":20}],382:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -79233,23 +85524,17 @@ module.exports = function arraysToCalcdata(cd, trace) { } }; -},{"../../lib":233}],336:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],383:[function(_dereq_,module,exports){ 'use strict'; var scatterAttrs = _dereq_('../scatter/attributes'); +var axisHoverFormat = _dereq_('../../plots/hoverformat_attributes'); var hovertemplateAttrs = _dereq_('../../plots/template_attributes').hovertemplateAttrs; var texttemplateAttrs = _dereq_('../../plots/template_attributes').texttemplateAttrs; var colorScaleAttrs = _dereq_('../../components/colorscale/attributes'); var fontAttrs = _dereq_('../../plots/font_attributes'); var constants = _dereq_('./constants'); +var pattern = _dereq_('../../components/drawing/attributes').pattern; var extendFlat = _dereq_('../../lib/extend').extendFlat; @@ -79257,7 +85542,6 @@ var textFontAttrs = fontAttrs({ editType: 'calc', arrayOk: true, colorEditType: 'style', - }); var scatterMarkerAttrs = scatterAttrs.marker; @@ -79281,10 +85565,9 @@ var marker = extendFlat({ dflt: 1, min: 0, max: 1, - editType: 'style', - - } + }, + pattern: pattern }); module.exports = { @@ -79301,6 +85584,8 @@ module.exports = { yperiod0: scatterAttrs.yperiod0, xperiodalignment: scatterAttrs.xperiodalignment, yperiodalignment: scatterAttrs.yperiodalignment, + xhoverformat: axisHoverFormat('x'), + yhoverformat: axisHoverFormat('y'), text: scatterAttrs.text, texttemplate: texttemplateAttrs({editType: 'plot'}, { @@ -79313,80 +85598,62 @@ module.exports = { textposition: { valType: 'enumerated', - values: ['inside', 'outside', 'auto', 'none'], - dflt: 'none', + dflt: 'auto', arrayOk: true, editType: 'calc', - }, insidetextanchor: { valType: 'enumerated', values: ['end', 'middle', 'start'], dflt: 'end', - editType: 'plot', - }, textangle: { valType: 'angle', dflt: 'auto', - editType: 'plot', - }, textfont: extendFlat({}, textFontAttrs, { - }), insidetextfont: extendFlat({}, textFontAttrs, { - }), outsidetextfont: extendFlat({}, textFontAttrs, { - }), constraintext: { valType: 'enumerated', values: ['inside', 'outside', 'both', 'none'], - dflt: 'both', editType: 'calc', - }, cliponaxis: extendFlat({}, scatterAttrs.cliponaxis, { - }), orientation: { valType: 'enumerated', - values: ['v', 'h'], editType: 'calc+clearAxisTypes', - }, base: { valType: 'any', dflt: null, arrayOk: true, - editType: 'calc', - }, offset: { valType: 'number', dflt: null, arrayOk: true, - editType: 'calc', - }, width: { @@ -79394,26 +85661,20 @@ module.exports = { dflt: null, min: 0, arrayOk: true, - editType: 'calc', - }, marker: marker, offsetgroup: { valType: 'string', - dflt: '', editType: 'calc', - }, alignmentgroup: { valType: 'string', - dflt: '', editType: 'calc', - }, selected: { @@ -79435,29 +85696,16 @@ module.exports = { editType: 'style' }, - r: scatterAttrs.r, - t: scatterAttrs.t, - _deprecated: { bardir: { valType: 'enumerated', - editType: 'calc', values: ['v', 'h'], - } } }; -},{"../../components/colorscale/attributes":112,"../../lib/extend":227,"../../plots/font_attributes":307,"../../plots/template_attributes":321,"../scatter/attributes":447,"./constants":338}],337:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale/attributes":162,"../../components/drawing/attributes":176,"../../lib/extend":279,"../../plots/font_attributes":359,"../../plots/hoverformat_attributes":363,"../../plots/template_attributes":368,"../scatter/attributes":494,"./constants":385}],384:[function(_dereq_,module,exports){ 'use strict'; var Axes = _dereq_('../../plots/cartesian/axes'); @@ -79528,16 +85776,7 @@ module.exports = function calc(gd, trace) { return cd; }; -},{"../../components/colorscale/calc":113,"../../components/colorscale/helpers":116,"../../plots/cartesian/align_period":276,"../../plots/cartesian/axes":279,"../scatter/calc_selection":449,"./arrays_to_calcdata":335}],338:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/colorscale/calc":163,"../../components/colorscale/helpers":166,"../../plots/cartesian/align_period":328,"../../plots/cartesian/axes":331,"../scatter/calc_selection":496,"./arrays_to_calcdata":382}],385:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -79550,15 +85789,7 @@ module.exports = { eventDataKeys: ['value', 'label'] }; -},{}],339:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],386:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -80330,15 +86561,7 @@ module.exports = { setGroupPositions: setGroupPositions }; -},{"../../constants/numerical":212,"../../lib":233,"../../plots/cartesian/axes":279,"../../plots/cartesian/constraints":286,"../../registry":326,"./sieve.js":349,"fast-isnumeric":23}],340:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/numerical":265,"../../lib":285,"../../plots/cartesian/axes":331,"../../plots/cartesian/constraints":338,"../../registry":373,"./sieve.js":396,"fast-isnumeric":31}],387:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -80365,6 +86588,8 @@ function supplyDefaults(traceIn, traceOut, defaultColor, layout) { } handlePeriodDefaults(traceIn, traceOut, layout, coerce); + coerce('xhoverformat'); + coerce('yhoverformat'); coerce('orientation', (traceOut.x && !traceOut.y) ? 'h' : 'v'); coerce('base'); @@ -80515,15 +86740,7 @@ module.exports = { handleText: handleText }; -},{"../../components/color":105,"../../lib":233,"../../plots/cartesian/constraints":286,"../../registry":326,"../scatter/period_defaults":467,"../scatter/xy_defaults":474,"./attributes":336,"./style_defaults":351}],341:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../lib":285,"../../plots/cartesian/constraints":338,"../../registry":373,"../scatter/period_defaults":514,"../scatter/xy_defaults":521,"./attributes":383,"./style_defaults":398}],388:[function(_dereq_,module,exports){ 'use strict'; module.exports = function eventData(out, pt, trace) { @@ -80544,15 +86761,7 @@ module.exports = function eventData(out, pt, trace) { return out; }; -},{}],342:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],389:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -80622,16 +86831,7 @@ exports.getLineWidth = function(trace, di) { return w; }; -},{"../../lib":233,"fast-isnumeric":23,"tinycolor2":88}],343:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"fast-isnumeric":31,"tinycolor2":119}],390:[function(_dereq_,module,exports){ 'use strict'; var Fx = _dereq_('../../components/fx'); @@ -80643,8 +86843,8 @@ var getLineWidth = _dereq_('./helpers').getLineWidth; var hoverLabelText = _dereq_('../../plots/cartesian/axes').hoverLabelText; var BADNUM = _dereq_('../../constants/numerical').BADNUM; -function hoverPoints(pointData, xval, yval, hovermode) { - var barPointData = hoverOnBars(pointData, xval, yval, hovermode); +function hoverPoints(pointData, xval, yval, hovermode, opts) { + var barPointData = hoverOnBars(pointData, xval, yval, hovermode, opts); if(barPointData) { var cd = barPointData.cd; @@ -80658,20 +86858,46 @@ function hoverPoints(pointData, xval, yval, hovermode) { } } -function hoverOnBars(pointData, xval, yval, hovermode) { +function hoverOnBars(pointData, xval, yval, hovermode, opts) { var cd = pointData.cd; var trace = cd[0].trace; var t = cd[0].t; var isClosest = (hovermode === 'closest'); var isWaterfall = (trace.type === 'waterfall'); var maxHoverDistance = pointData.maxHoverDistance; + var maxSpikeDistance = pointData.maxSpikeDistance; var posVal, sizeVal, posLetter, sizeLetter, dx, dy, pRangeCalc; - function thisBarMinPos(di) { return di[posLetter] - di.w / 2; } - function thisBarMaxPos(di) { return di[posLetter] + di.w / 2; } + if(trace.orientation === 'h') { + posVal = yval; + sizeVal = xval; + posLetter = 'y'; + sizeLetter = 'x'; + dx = sizeFn; + dy = positionFn; + } else { + posVal = xval; + sizeVal = yval; + posLetter = 'x'; + sizeLetter = 'y'; + dy = sizeFn; + dx = positionFn; + } - var minPos = isClosest ? + var period = trace[posLetter + 'period']; + + function thisBarMinPos(di) { return thisBarExtPos(di, -1); } + function thisBarMaxPos(di) { return thisBarExtPos(di, 1); } + + function thisBarExtPos(di, sgn) { + if(period) { + return di.p + sgn * Math.abs(di.p - di.orig_p); + } + return di[posLetter] + sgn * di.w / 2; + } + + var minPos = isClosest || period ? thisBarMinPos : function(di) { /* @@ -80689,60 +86915,62 @@ function hoverOnBars(pointData, xval, yval, hovermode) { return Math.min(thisBarMinPos(di), di.p - t.bardelta / 2); }; - var maxPos = isClosest ? + var maxPos = isClosest || period ? thisBarMaxPos : function(di) { return Math.max(thisBarMaxPos(di), di.p + t.bardelta / 2); }; - function _positionFn(_minPos, _maxPos) { + function inbox(_minPos, _maxPos, maxDistance) { + if(opts.finiteRange) maxDistance = 0; + // add a little to the pseudo-distance for wider bars, so that like scatter, // if you are over two overlapping bars, the narrower one wins. return Fx.inbox(_minPos - posVal, _maxPos - posVal, - maxHoverDistance + Math.min(1, Math.abs(_maxPos - _minPos) / pRangeCalc) - 1); + maxDistance + Math.min(1, Math.abs(_maxPos - _minPos) / pRangeCalc) - 1); } function positionFn(di) { - return _positionFn(minPos(di), maxPos(di)); + return inbox(minPos(di), maxPos(di), maxHoverDistance); } function thisBarPositionFn(di) { - return _positionFn(thisBarMinPos(di), thisBarMaxPos(di)); + return inbox(thisBarMinPos(di), thisBarMaxPos(di), maxSpikeDistance); + } + + function getSize(di) { + var s = di[sizeLetter]; + + if(isWaterfall) { + var rawS = Math.abs(di.rawS) || 0; + if(sizeVal > 0) { + s += rawS; + } else if(sizeVal < 0) { + s -= rawS; + } + } + + return s; } function sizeFn(di) { var v = sizeVal; var b = di.b; - var s = di[sizeLetter]; - - if(isWaterfall) { - var rawS = Math.abs(di.rawS) || 0; - if(v > 0) { - s += rawS; - } else if(v < 0) { - s -= rawS; - } - } + var s = getSize(di); // add a gradient so hovering near the end of a // bar makes it a little closer match return Fx.inbox(b - v, s - v, maxHoverDistance + (s - v) / (s - b) - 1); } - if(trace.orientation === 'h') { - posVal = yval; - sizeVal = xval; - posLetter = 'y'; - sizeLetter = 'x'; - dx = sizeFn; - dy = positionFn; - } else { - posVal = xval; - sizeVal = yval; - posLetter = 'x'; - sizeLetter = 'y'; - dy = sizeFn; - dx = positionFn; + function thisBarSizeFn(di) { + var v = sizeVal; + var b = di.b; + var s = getSize(di); + + // add a gradient so hovering near the end of a + // bar makes it a little closer match + return Fx.inbox(b - v, s - v, maxSpikeDistance + (s - v) / (s - b) - 1); } var pa = pointData[posLetter + 'a']; @@ -80787,12 +87015,12 @@ function hoverOnBars(pointData, xval, yval, hovermode) { var hasPeriod = di.orig_p !== undefined; pointData[posLetter + 'LabelVal'] = hasPeriod ? di.orig_p : di.p; - pointData.labelLabel = hoverLabelText(pa, pointData[posLetter + 'LabelVal']); - pointData.valueLabel = hoverLabelText(sa, pointData[sizeLetter + 'LabelVal']); - pointData.baseLabel = hoverLabelText(sa, di.b); + pointData.labelLabel = hoverLabelText(pa, pointData[posLetter + 'LabelVal'], trace[posLetter + 'hoverformat']); + pointData.valueLabel = hoverLabelText(sa, pointData[sizeLetter + 'LabelVal'], trace[sizeLetter + 'hoverformat']); + pointData.baseLabel = hoverLabelText(sa, di.b, trace[sizeLetter + 'hoverformat']); // spikelines always want "closest" distance regardless of hovermode - pointData.spikeDistance = (sizeFn(di) + thisBarPositionFn(di)) / 2 - maxHoverDistance; + pointData.spikeDistance = (thisBarSizeFn(di) + thisBarPositionFn(di)) / 2; // they also want to point to the data value, regardless of where the label goes // in case of bars shifted within groups pointData[posLetter + 'Spike'] = pa.c2p(di.p, true); @@ -80818,15 +87046,7 @@ module.exports = { getTraceColor: getTraceColor }; -},{"../../components/color":105,"../../components/fx":145,"../../constants/numerical":212,"../../lib":233,"../../plots/cartesian/axes":279,"../../registry":326,"./helpers":342}],344:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../components/fx":195,"../../constants/numerical":265,"../../lib":285,"../../plots/cartesian/axes":331,"../../registry":373,"./helpers":389}],391:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -80852,19 +87072,10 @@ module.exports = { categories: ['bar-like', 'cartesian', 'svg', 'bar', 'oriented', 'errorBarsOK', 'showLegend', 'zoomScale'], animatable: true, meta: { - } }; -},{"../../plots/cartesian":292,"../scatter/marker_colorbar":465,"./arrays_to_calcdata":335,"./attributes":336,"./calc":337,"./cross_trace_calc":339,"./defaults":340,"./event_data":341,"./hover":343,"./layout_attributes":345,"./layout_defaults":346,"./plot":347,"./select":348,"./style":350}],345:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian":344,"../scatter/marker_colorbar":512,"./arrays_to_calcdata":382,"./attributes":383,"./calc":384,"./cross_trace_calc":386,"./defaults":387,"./event_data":388,"./hover":390,"./layout_attributes":392,"./layout_defaults":393,"./plot":394,"./select":395,"./style":397}],392:[function(_dereq_,module,exports){ 'use strict'; @@ -80873,46 +87084,30 @@ module.exports = { valType: 'enumerated', values: ['stack', 'group', 'overlay', 'relative'], dflt: 'group', - editType: 'calc', - }, barnorm: { valType: 'enumerated', values: ['', 'fraction', 'percent'], dflt: '', - editType: 'calc', - }, bargap: { valType: 'number', min: 0, max: 1, - editType: 'calc', - }, bargroupgap: { valType: 'number', min: 0, max: 1, dflt: 0, - editType: 'calc', - } }; -},{}],346:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],393:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -80964,18 +87159,10 @@ module.exports = function(layoutIn, layoutOut, fullData) { coerce('bargroupgap'); }; -},{"../../lib":233,"../../plots/cartesian/axes":279,"../../registry":326,"./layout_attributes":345}],347:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/cartesian/axes":331,"../../registry":373,"./layout_attributes":392}],394:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); @@ -81622,11 +87809,11 @@ function calcTexttemplate(fullLayout, cd, index, xa, ya) { } function formatLabel(u) { - return tickText(pAxis, u, true).text; + return tickText(pAxis, pAxis.c2l(u), true).text; } function formatNumber(v) { - return tickText(vAxis, +v, true).text; + return tickText(vAxis, vAxis.c2l(v), true).text; } var cdi = cd[index]; @@ -81749,15 +87936,7 @@ module.exports = { toMoveInsideBar: toMoveInsideBar }; -},{"../../components/color":105,"../../components/drawing":127,"../../components/fx/helpers":141,"../../lib":233,"../../lib/svg_text_utils":255,"../../plots/cartesian/axes":279,"../../registry":326,"./attributes":336,"./constants":338,"./helpers":342,"./style":350,"./uniform_text":352,"d3":21,"fast-isnumeric":23}],348:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../components/drawing":177,"../../components/fx/helpers":191,"../../lib":285,"../../lib/svg_text_utils":307,"../../plots/cartesian/axes":331,"../../registry":373,"./attributes":383,"./constants":385,"./helpers":389,"./style":397,"./uniform_text":399,"@plotly/d3":20,"fast-isnumeric":31}],395:[function(_dereq_,module,exports){ 'use strict'; module.exports = function selectPoints(searchInfo, selectionTester) { @@ -81813,15 +87992,7 @@ function getCentroid(d, xa, ya, isHorizontal, isFunnel) { } } -},{}],349:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],396:[function(_dereq_,module,exports){ 'use strict'; module.exports = Sieve; @@ -81927,18 +88098,10 @@ Sieve.prototype.getLabel = function getLabel(position, value) { return prefix + label; }; -},{"../../constants/numerical":212,"../../lib":233}],350:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/numerical":265,"../../lib":285}],397:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Color = _dereq_('../../components/color'); var Drawing = _dereq_('../../components/drawing'); var Lib = _dereq_('../../lib'); @@ -82096,7 +88259,7 @@ function getBarColor(cd, trace) { if(trace.type === 'waterfall') { return trace[cd.dir].marker.color; } - return cd.mc || trace.marker.color; + return cd.mcc || cd.mc || trace.marker.color; } module.exports = { @@ -82109,20 +88272,13 @@ module.exports = { resizeText: resizeText }; -},{"../../components/color":105,"../../components/drawing":127,"../../lib":233,"../../registry":326,"./attributes":336,"./helpers":342,"./uniform_text":352,"d3":21}],351:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../components/drawing":177,"../../lib":285,"../../registry":373,"./attributes":383,"./helpers":389,"./uniform_text":399,"@plotly/d3":20}],398:[function(_dereq_,module,exports){ 'use strict'; var Color = _dereq_('../../components/color'); var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); +var coercePattern = _dereq_('../../lib').coercePattern; module.exports = function handleStyleDefaults(traceIn, traceOut, coerce, defaultColor, layout) { coerce('marker.color', defaultColor); @@ -82143,22 +88299,16 @@ module.exports = function handleStyleDefaults(traceIn, traceOut, coerce, default coerce('marker.line.width'); coerce('marker.opacity'); + coercePattern(coerce, 'marker.pattern'); + coerce('selected.marker.color'); coerce('unselected.marker.color'); }; -},{"../../components/color":105,"../../components/colorscale/defaults":115,"../../components/colorscale/helpers":116}],352:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../components/colorscale/defaults":165,"../../components/colorscale/helpers":166,"../../lib":285}],399:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Lib = _dereq_('../../lib'); function resizeText(gd, gTrace, traceType) { @@ -82233,20 +88383,13 @@ module.exports = { resizeText: resizeText }; -},{"../../lib":233,"d3":21}],353:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"@plotly/d3":20}],400:[function(_dereq_,module,exports){ 'use strict'; var scatterAttrs = _dereq_('../scatter/attributes'); var barAttrs = _dereq_('../bar/attributes'); var colorAttrs = _dereq_('../../components/color/attributes'); +var axisHoverFormat = _dereq_('../../plots/hoverformat_attributes'); var hovertemplateAttrs = _dereq_('../../plots/template_attributes').hovertemplateAttrs; var extendFlat = _dereq_('../../lib/extend').extendFlat; @@ -82257,37 +88400,27 @@ module.exports = { y: { valType: 'data_array', editType: 'calc+clearAxisTypes', - }, x: { valType: 'data_array', editType: 'calc+clearAxisTypes', - }, x0: { valType: 'any', - editType: 'calc+clearAxisTypes', - }, y0: { valType: 'any', - editType: 'calc+clearAxisTypes', - }, dx: { valType: 'number', - editType: 'calc', - }, dy: { valType: 'number', - editType: 'calc', - }, xperiod: scatterAttrs.xperiod, @@ -82296,65 +88429,49 @@ module.exports = { yperiod0: scatterAttrs.yperiod0, xperiodalignment: scatterAttrs.xperiodalignment, yperiodalignment: scatterAttrs.yperiodalignment, + xhoverformat: axisHoverFormat('x'), + yhoverformat: axisHoverFormat('y'), name: { valType: 'string', - editType: 'calc+clearAxisTypes', - }, q1: { valType: 'data_array', - editType: 'calc+clearAxisTypes', - }, median: { valType: 'data_array', - editType: 'calc+clearAxisTypes', - }, q3: { valType: 'data_array', - editType: 'calc+clearAxisTypes', - }, lowerfence: { valType: 'data_array', - editType: 'calc', - }, upperfence: { valType: 'data_array', - editType: 'calc', - }, notched: { valType: 'boolean', - editType: 'calc', - }, notchwidth: { valType: 'number', min: 0, max: 0.5, dflt: 0.25, - editType: 'calc', - }, notchspan: { valType: 'data_array', - editType: 'calc', - }, // TODO @@ -82365,80 +88482,60 @@ module.exports = { boxpoints: { valType: 'enumerated', values: ['all', 'outliers', 'suspectedoutliers', false], - editType: 'calc', - }, jitter: { valType: 'number', min: 0, max: 1, - editType: 'calc', - }, pointpos: { valType: 'number', min: -2, max: 2, - editType: 'calc', - }, boxmean: { valType: 'enumerated', values: [true, 'sd', false], - editType: 'calc', - }, mean: { valType: 'data_array', - editType: 'calc', - }, sd: { valType: 'data_array', - editType: 'calc', - }, orientation: { valType: 'enumerated', values: ['v', 'h'], - editType: 'calc+clearAxisTypes', - }, quartilemethod: { valType: 'enumerated', values: ['linear', 'exclusive', 'inclusive'], dflt: 'linear', - editType: 'calc', - }, width: { valType: 'number', min: 0, - dflt: 0, editType: 'calc', - }, marker: { outliercolor: { valType: 'color', dflt: 'rgba(0, 0, 0, 0)', - editType: 'style', - }, symbol: extendFlat({}, scatterMarkerAttrs.symbol, {arrayOk: false, editType: 'plot'}), @@ -82457,17 +88554,13 @@ module.exports = { ), outliercolor: { valType: 'color', - editType: 'style', - }, outlierwidth: { valType: 'number', min: 0, dflt: 1, - editType: 'style', - }, editType: 'style' }, @@ -82477,17 +88570,13 @@ module.exports = { line: { color: { valType: 'color', - editType: 'style', - }, width: { valType: 'number', - min: 0, dflt: 2, editType: 'style', - }, editType: 'plot' }, @@ -82499,9 +88588,7 @@ module.exports = { min: 0, max: 1, dflt: 0.5, - editType: 'calc', - }, offsetgroup: barAttrs.offsetgroup, @@ -82517,34 +88604,21 @@ module.exports = { }, text: extendFlat({}, scatterAttrs.text, { - }), hovertext: extendFlat({}, scatterAttrs.hovertext, { - }), hovertemplate: hovertemplateAttrs({ - }), hoveron: { valType: 'flaglist', flags: ['boxes', 'points'], dflt: 'boxes+points', - editType: 'style', - } }; -},{"../../components/color/attributes":104,"../../lib/extend":227,"../../plots/template_attributes":321,"../bar/attributes":336,"../scatter/attributes":447}],354:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color/attributes":154,"../../lib/extend":279,"../../plots/hoverformat_attributes":363,"../../plots/template_attributes":368,"../bar/attributes":383,"../scatter/attributes":494}],401:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -82990,15 +89064,7 @@ function computeNotchSpan(cdi, N) { return 1.57 * (cdi.q3 - cdi.q1) / Math.sqrt(N); } -},{"../../constants/numerical":212,"../../lib":233,"../../plots/cartesian/align_period":276,"../../plots/cartesian/axes":279,"fast-isnumeric":23}],355:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/numerical":265,"../../lib":285,"../../plots/cartesian/align_period":328,"../../plots/cartesian/axes":331,"fast-isnumeric":31}],402:[function(_dereq_,module,exports){ 'use strict'; var Axes = _dereq_('../../plots/cartesian/axes'); @@ -83222,15 +89288,7 @@ module.exports = { setPositionOffset: setPositionOffset }; -},{"../../lib":233,"../../plots/cartesian/axes":279,"../../plots/cartesian/constraints":286}],356:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/cartesian/axes":331,"../../plots/cartesian/constraints":338}],403:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -83250,6 +89308,8 @@ function supplyDefaults(traceIn, traceOut, defaultColor, layout) { if(traceOut.visible === false) return; handlePeriodDefaults(traceIn, traceOut, layout, coerce); + coerce('xhoverformat'); + coerce('yhoverformat'); var hasPreCompStats = traceOut._hasPreCompStats; @@ -83538,15 +89598,7 @@ module.exports = { handlePointsDefaults: handlePointsDefaults }; -},{"../../components/color":105,"../../lib":233,"../../plots/cartesian/axis_autotype":280,"../../registry":326,"../bar/defaults":340,"../scatter/period_defaults":467,"./attributes":353}],357:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../lib":285,"../../plots/cartesian/axis_autotype":332,"../../registry":373,"../bar/defaults":387,"../scatter/period_defaults":514,"./attributes":400}],404:[function(_dereq_,module,exports){ 'use strict'; module.exports = function eventData(out, pt) { @@ -83563,15 +89615,7 @@ module.exports = function eventData(out, pt) { return out; }; -},{}],358:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],405:[function(_dereq_,module,exports){ 'use strict'; var Axes = _dereq_('../../plots/cartesian/axes'); @@ -83740,7 +89784,7 @@ function hoverOnBoxes(pointData, xval, yval, hovermode) { pointData2.attr = attr; pointData2[vLetter + '0'] = pointData2[vLetter + '1'] = valPx; pointData2[vLetter + 'LabelVal'] = val; - pointData2[vLetter + 'Label'] = (t.labels ? t.labels[attr] + ' ' : '') + Axes.hoverLabelText(vAxis, val); + pointData2[vLetter + 'Label'] = (t.labels ? t.labels[attr] + ' ' : '') + Axes.hoverLabelText(vAxis, val, trace[vLetter + 'hoverformat']); // Note: introduced to be able to distinguish a // clicked point from a box during click-to-select @@ -83850,15 +89894,7 @@ module.exports = { hoverOnPoints: hoverOnPoints }; -},{"../../components/color":105,"../../components/fx":145,"../../lib":233,"../../plots/cartesian/axes":279}],359:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../components/fx":195,"../../lib":285,"../../plots/cartesian/axes":331}],406:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -83881,19 +89917,10 @@ module.exports = { basePlotModule: _dereq_('../../plots/cartesian'), categories: ['cartesian', 'svg', 'symbols', 'oriented', 'box-violin', 'showLegend', 'boxLayout', 'zoomScale'], meta: { - } }; -},{"../../plots/cartesian":292,"./attributes":353,"./calc":354,"./cross_trace_calc":355,"./defaults":356,"./event_data":357,"./hover":358,"./layout_attributes":360,"./layout_defaults":361,"./plot":362,"./select":363,"./style":364}],360:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian":344,"./attributes":400,"./calc":401,"./cross_trace_calc":402,"./defaults":403,"./event_data":404,"./hover":405,"./layout_attributes":407,"./layout_defaults":408,"./plot":409,"./select":410,"./style":411}],407:[function(_dereq_,module,exports){ 'use strict'; @@ -83902,39 +89929,25 @@ module.exports = { valType: 'enumerated', values: ['group', 'overlay'], dflt: 'overlay', - editType: 'calc', - }, boxgap: { valType: 'number', min: 0, max: 1, dflt: 0.3, - editType: 'calc', - }, boxgroupgap: { valType: 'number', min: 0, max: 1, dflt: 0.3, - editType: 'calc', - } }; -},{}],361:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],408:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -83972,18 +89985,10 @@ module.exports = { _supply: _supply }; -},{"../../lib":233,"../../registry":326,"./layout_attributes":360}],362:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../registry":373,"./layout_attributes":407}],409:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Lib = _dereq_('../../lib'); var Drawing = _dereq_('../../components/drawing'); @@ -84322,15 +90327,7 @@ module.exports = { plotBoxMean: plotBoxMean }; -},{"../../components/drawing":127,"../../lib":233,"d3":21}],363:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/drawing":177,"../../lib":285,"@plotly/d3":20}],410:[function(_dereq_,module,exports){ 'use strict'; module.exports = function selectPoints(searchInfo, selectionTester) { @@ -84371,18 +90368,10 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{}],364:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],411:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Color = _dereq_('../../components/color'); var Drawing = _dereq_('../../components/drawing'); @@ -84445,19 +90434,12 @@ module.exports = { styleOnSelect: styleOnSelect }; -},{"../../components/color":105,"../../components/drawing":127,"d3":21}],365:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../components/drawing":177,"@plotly/d3":20}],412:[function(_dereq_,module,exports){ 'use strict'; var heatmapAttrs = _dereq_('../heatmap/attributes'); var scatterAttrs = _dereq_('../scatter/attributes'); +var axisHoverFormat = _dereq_('../../plots/hoverformat_attributes'); var colorScaleAttrs = _dereq_('../../components/colorscale/attributes'); var dash = _dereq_('../../components/drawing/attributes').dash; var fontAttrs = _dereq_('../../plots/font_attributes'); @@ -84492,39 +90474,34 @@ module.exports = extendFlat({ transpose: heatmapAttrs.transpose, xtype: heatmapAttrs.xtype, ytype: heatmapAttrs.ytype, - zhoverformat: heatmapAttrs.zhoverformat, + xhoverformat: axisHoverFormat('x'), + yhoverformat: axisHoverFormat('y'), + zhoverformat: axisHoverFormat('z', 1), hovertemplate: heatmapAttrs.hovertemplate, hoverongaps: heatmapAttrs.hoverongaps, connectgaps: extendFlat({}, heatmapAttrs.connectgaps, { - }), fillcolor: { valType: 'color', - editType: 'calc', - }, autocontour: { valType: 'boolean', dflt: true, - editType: 'calc', impliedEdits: { 'contours.start': undefined, 'contours.end': undefined, 'contours.size': undefined }, - }, ncontours: { valType: 'integer', dflt: 15, min: 1, - editType: 'calc', - }, contours: { @@ -84532,83 +90509,62 @@ module.exports = extendFlat({ valType: 'enumerated', values: ['levels', 'constraint'], dflt: 'levels', - editType: 'calc', - }, start: { valType: 'number', dflt: null, - editType: 'plot', impliedEdits: {'^autocontour': false}, - }, end: { valType: 'number', dflt: null, - editType: 'plot', impliedEdits: {'^autocontour': false}, - }, size: { valType: 'number', dflt: null, min: 0, - editType: 'plot', impliedEdits: {'^autocontour': false}, - }, coloring: { valType: 'enumerated', values: ['fill', 'heatmap', 'lines', 'none'], dflt: 'fill', - editType: 'calc', - }, showlines: { valType: 'boolean', dflt: true, - editType: 'plot', - }, showlabels: { valType: 'boolean', dflt: false, - editType: 'plot', - }, labelfont: fontAttrs({ editType: 'plot', colorEditType: 'style', - }), labelformat: { valType: 'string', dflt: '', - editType: 'plot', - }, operation: { valType: 'enumerated', values: [].concat(COMPARISON_OPS2).concat(INTERVAL_OPS), - dflt: '=', editType: 'calc', - }, value: { valType: 'any', dflt: 0, - editType: 'calc', - }, editType: 'calc', impliedEdits: {'autocontour': false} @@ -84617,18 +90573,14 @@ module.exports = extendFlat({ line: { color: extendFlat({}, scatterLineAttrs.color, { editType: 'style+colorbars', - }), width: { valType: 'number', min: 0, - editType: 'style+colorbars', - }, dash: dash, smoothing: extendFlat({}, scatterLineAttrs.smoothing, { - }), editType: 'plot' } @@ -84640,15 +90592,7 @@ module.exports = extendFlat({ }) ); -},{"../../components/colorscale/attributes":112,"../../components/drawing/attributes":126,"../../constants/docs":209,"../../constants/filter_ops":210,"../../lib/extend":227,"../../plots/font_attributes":307,"../heatmap/attributes":387,"../scatter/attributes":447}],366:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale/attributes":162,"../../components/drawing/attributes":176,"../../constants/docs":262,"../../constants/filter_ops":263,"../../lib/extend":279,"../../plots/font_attributes":359,"../../plots/hoverformat_attributes":363,"../heatmap/attributes":434,"../scatter/attributes":494}],413:[function(_dereq_,module,exports){ 'use strict'; var Colorscale = _dereq_('../../components/colorscale'); @@ -84693,15 +90637,7 @@ module.exports = function calc(gd, trace) { return cd; }; -},{"../../components/colorscale":117,"../heatmap/calc":388,"./end_plus":376,"./set_contours":384}],367:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale":167,"../heatmap/calc":435,"./end_plus":423,"./set_contours":431}],414:[function(_dereq_,module,exports){ 'use strict'; module.exports = function(pathinfo, contours) { @@ -84783,15 +90719,7 @@ module.exports = function(pathinfo, contours) { } }; -},{}],368:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],415:[function(_dereq_,module,exports){ 'use strict'; var Colorscale = _dereq_('../../components/colorscale'); @@ -84834,15 +90762,7 @@ module.exports = { calc: calc }; -},{"../../components/colorscale":117,"./end_plus":376,"./make_color_map":381}],369:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale":167,"./end_plus":423,"./make_color_map":428}],416:[function(_dereq_,module,exports){ 'use strict'; module.exports = { // some constants to help with marching squares algorithm @@ -84912,16 +90832,7 @@ module.exports = { } }; -},{}],370:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],417:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -85006,15 +90917,7 @@ function handleConstraintValueDefaults(coerce, contours) { } } -},{"../../components/color":105,"../../constants/filter_ops":210,"./label_defaults":380,"fast-isnumeric":23}],371:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../constants/filter_ops":263,"./label_defaults":427,"fast-isnumeric":31}],418:[function(_dereq_,module,exports){ 'use strict'; var filterOps = _dereq_('../../constants/filter_ops'); @@ -85085,15 +90988,7 @@ function makeInequalitySettings(operation) { }; } -},{"../../constants/filter_ops":210,"fast-isnumeric":23}],372:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/filter_ops":263,"fast-isnumeric":31}],419:[function(_dereq_,module,exports){ 'use strict'; module.exports = function handleContourDefaults(traceIn, traceOut, coerce, coerce2) { @@ -85114,15 +91009,7 @@ module.exports = function handleContourDefaults(traceIn, traceOut, coerce, coerc if(autoContour || !contourSize) coerce('ncontours'); }; -},{}],373:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],420:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -85214,15 +91101,7 @@ function copyPathinfo(pi) { }); } -},{"../../lib":233}],374:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],421:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -85251,6 +91130,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout } handlePeriodDefaults(traceIn, traceOut, layout, coerce); + coerce('xhoverformat'); + coerce('yhoverformat'); coerce('text'); coerce('hovertext'); @@ -85268,15 +91149,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout } }; -},{"../../lib":233,"../heatmap/xyz_defaults":401,"../scatter/period_defaults":467,"./attributes":365,"./constraint_defaults":370,"./contours_defaults":372,"./style_defaults":386}],375:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../heatmap/xyz_defaults":448,"../scatter/period_defaults":514,"./attributes":412,"./constraint_defaults":417,"./contours_defaults":419,"./style_defaults":433}],422:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -85332,16 +91205,7 @@ module.exports = function emptyPathinfo(contours, plotinfo, cd0) { return pathinfo; }; -},{"../../lib":233,"./constraint_mapping":371,"./end_plus":376}],376:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"./constraint_mapping":418,"./end_plus":423}],423:[function(_dereq_,module,exports){ 'use strict'; /* @@ -85352,15 +91216,7 @@ module.exports = function endPlus(contours) { return contours.end + contours.size / 1e6; }; -},{}],377:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],424:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -85646,24 +91502,18 @@ function getInterpPx(pi, loc, step) { } } -},{"../../lib":233,"./constants":369}],378:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"./constants":416}],425:[function(_dereq_,module,exports){ 'use strict'; var Color = _dereq_('../../components/color'); var heatmapHoverPoints = _dereq_('../heatmap/hover'); -module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLayer) { - var hoverData = heatmapHoverPoints(pointData, xval, yval, hovermode, hoverLayer, true); +module.exports = function hoverPoints(pointData, xval, yval, hovermode, opts) { + if(!opts) opts = {}; + opts.isContour = true; + + var hoverData = heatmapHoverPoints(pointData, xval, yval, hovermode, opts); if(hoverData) { hoverData.forEach(function(hoverPt) { @@ -85681,15 +91531,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay return hoverData; }; -},{"../../components/color":105,"../heatmap/hover":394}],379:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../heatmap/hover":441}],426:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -85706,20 +91548,10 @@ module.exports = { basePlotModule: _dereq_('../../plots/cartesian'), categories: ['cartesian', 'svg', '2dMap', 'contour', 'showLegend'], meta: { - } }; -},{"../../plots/cartesian":292,"./attributes":365,"./calc":366,"./colorbar":368,"./defaults":374,"./hover":378,"./plot":383,"./style":385}],380:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../plots/cartesian":344,"./attributes":412,"./calc":413,"./colorbar":415,"./defaults":421,"./hover":425,"./plot":430,"./style":432}],427:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -85740,18 +91572,10 @@ module.exports = function handleLabelDefaults(coerce, layout, lineColor, opts) { if(opts.hasHover !== false) coerce('zhoverformat'); }; -},{"../../lib":233}],381:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],428:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Colorscale = _dereq_('../../components/colorscale'); var endPlus = _dereq_('./end_plus'); @@ -85824,15 +91648,7 @@ module.exports = function makeColorMap(trace) { ); }; -},{"../../components/colorscale":117,"./end_plus":376,"d3":21}],382:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale":167,"./end_plus":423,"@plotly/d3":20}],429:[function(_dereq_,module,exports){ 'use strict'; var constants = _dereq_('./constants'); @@ -85916,19 +91732,10 @@ function getMarchingIndex(val, corners) { return (mi === 15) ? 0 : mi; } -},{"./constants":369}],383:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"./constants":416}],430:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Lib = _dereq_('../../lib'); var Drawing = _dereq_('../../components/drawing'); @@ -86607,15 +92414,7 @@ function makeClipMask(cd0) { return z; } -},{"../../components/colorscale":117,"../../components/drawing":127,"../../lib":233,"../../lib/svg_text_utils":255,"../../plots/cartesian/axes":279,"../../plots/cartesian/set_convert":299,"../heatmap/plot":398,"./close_boundaries":367,"./constants":369,"./convert_to_constraints":373,"./empty_pathinfo":375,"./find_all_paths":377,"./make_crossings":382,"d3":21}],384:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale":167,"../../components/drawing":177,"../../lib":285,"../../lib/svg_text_utils":307,"../../plots/cartesian/axes":331,"../../plots/cartesian/set_convert":351,"../heatmap/plot":445,"./close_boundaries":414,"./constants":416,"./convert_to_constraints":420,"./empty_pathinfo":422,"./find_all_paths":424,"./make_crossings":429,"@plotly/d3":20}],431:[function(_dereq_,module,exports){ 'use strict'; var Axes = _dereq_('../../plots/cartesian/axes'); @@ -86711,19 +92510,10 @@ function autoContours(start, end, ncontours) { return dummyAx; } -},{"../../lib":233,"../../plots/cartesian/axes":279}],385:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../plots/cartesian/axes":331}],432:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Drawing = _dereq_('../../components/drawing'); var heatmapStyle = _dereq_('../heatmap/style'); @@ -86792,16 +92582,7 @@ module.exports = function style(gd) { heatmapStyle(gd); }; -},{"../../components/drawing":127,"../heatmap/style":399,"./make_color_map":381,"d3":21}],386:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/drawing":177,"../heatmap/style":446,"./make_color_map":428,"@plotly/d3":20}],433:[function(_dereq_,module,exports){ 'use strict'; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); @@ -86837,22 +92618,14 @@ module.exports = function handleStyleDefaults(traceIn, traceOut, coerce, layout, handleLabelDefaults(coerce, layout, lineColor, opts); }; -},{"../../components/colorscale/defaults":115,"./label_defaults":380}],387:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale/defaults":165,"./label_defaults":427}],434:[function(_dereq_,module,exports){ 'use strict'; var scatterAttrs = _dereq_('../scatter/attributes'); var baseAttrs = _dereq_('../../plots/attributes'); +var axisHoverFormat = _dereq_('../../plots/hoverformat_attributes'); var hovertemplateAttrs = _dereq_('../../plots/template_attributes').hovertemplateAttrs; var colorScaleAttrs = _dereq_('../../components/colorscale/attributes'); -var FORMAT_LINK = _dereq_('../../constants/docs').FORMAT_LINK; var extendFlat = _dereq_('../../lib/extend').extendFlat; @@ -86860,7 +92633,6 @@ module.exports = extendFlat({ z: { valType: 'data_array', editType: 'calc', - }, x: extendFlat({}, scatterAttrs.x, {impliedEdits: {xtype: 'array'}}), x0: extendFlat({}, scatterAttrs.x0, {impliedEdits: {xtype: 'scaled'}}), @@ -86879,78 +92651,57 @@ module.exports = extendFlat({ text: { valType: 'data_array', editType: 'calc', - }, hovertext: { valType: 'data_array', editType: 'calc', - }, transpose: { valType: 'boolean', dflt: false, - editType: 'calc', - }, xtype: { valType: 'enumerated', values: ['array', 'scaled'], - editType: 'calc+clearAxisTypes', - }, ytype: { valType: 'enumerated', values: ['array', 'scaled'], - editType: 'calc+clearAxisTypes', - }, zsmooth: { valType: 'enumerated', values: ['fast', 'best', false], dflt: false, - editType: 'calc', - }, hoverongaps: { valType: 'boolean', dflt: true, - editType: 'none', - }, connectgaps: { valType: 'boolean', - editType: 'calc', - }, xgap: { valType: 'number', dflt: 0, min: 0, - editType: 'plot', - }, ygap: { valType: 'number', dflt: 0, min: 0, - editType: 'plot', - - }, - zhoverformat: { - valType: 'string', - dflt: '', - - editType: 'none', - }, + xhoverformat: axisHoverFormat('x'), + yhoverformat: axisHoverFormat('y'), + zhoverformat: axisHoverFormat('z', 1), + hovertemplate: hovertemplateAttrs(), showlegend: extendFlat({}, baseAttrs.showlegend, {dflt: false}) }, { @@ -86959,15 +92710,7 @@ module.exports = extendFlat({ colorScaleAttrs('', {cLetter: 'z', autoColorDflt: false}) ); -},{"../../components/colorscale/attributes":112,"../../constants/docs":209,"../../lib/extend":227,"../../plots/attributes":275,"../../plots/template_attributes":321,"../scatter/attributes":447}],388:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale/attributes":162,"../../lib/extend":279,"../../plots/attributes":327,"../../plots/hoverformat_attributes":363,"../../plots/template_attributes":368,"../scatter/attributes":494}],435:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -87168,15 +92911,7 @@ function dropZonBreaks(x, y, z) { return newZ; } -},{"../../components/colorscale/calc":113,"../../constants/numerical":212,"../../lib":233,"../../plots/cartesian/align_period":276,"../../plots/cartesian/axes":279,"../../registry":326,"../histogram2d/calc":416,"./clean_2d_array":389,"./convert_column_xyz":391,"./find_empties":393,"./interp2d":396,"./make_bound_array":397}],389:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale/calc":163,"../../constants/numerical":265,"../../lib":285,"../../plots/cartesian/align_period":328,"../../plots/cartesian/axes":331,"../../registry":373,"../histogram2d/calc":463,"./clean_2d_array":436,"./convert_column_xyz":438,"./find_empties":440,"./interp2d":443,"./make_bound_array":444}],436:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -87245,15 +92980,7 @@ module.exports = function clean2dArray(zOld, trace, xa, ya) { return zNew; }; -},{"../../constants/numerical":212,"../../lib":233,"fast-isnumeric":23}],390:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/numerical":265,"../../lib":285,"fast-isnumeric":31}],437:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -87261,16 +92988,7 @@ module.exports = { max: 'zmax' }; -},{}],391:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],438:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -87351,16 +93069,7 @@ module.exports = function convertColumnData(trace, ax1, ax2, var1Name, var2Name, trace._after2before = after2before; }; -},{"../../constants/numerical":212,"../../lib":233,"../../plots/cartesian/align_period":276}],392:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../constants/numerical":265,"../../lib":285,"../../plots/cartesian/align_period":328}],439:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -87384,6 +93093,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout } handlePeriodDefaults(traceIn, traceOut, layout, coerce); + coerce('xhoverformat'); + coerce('yhoverformat'); coerce('text'); coerce('hovertext'); @@ -87397,15 +93108,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: '', cLetter: 'z'}); }; -},{"../../components/colorscale/defaults":115,"../../lib":233,"../scatter/period_defaults":467,"./attributes":387,"./style_defaults":400,"./xyz_defaults":401}],393:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale/defaults":165,"../../lib":285,"../scatter/period_defaults":514,"./attributes":434,"./style_defaults":447,"./xyz_defaults":448}],440:[function(_dereq_,module,exports){ 'use strict'; var maxRowLength = _dereq_('../../lib').maxRowLength; @@ -87502,15 +93205,7 @@ module.exports = function findEmpties(z) { return empties.sort(function(a, b) { return b[2] - a[2]; }); }; -},{"../../lib":233}],394:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],441:[function(_dereq_,module,exports){ 'use strict'; var Fx = _dereq_('../../components/fx'); @@ -87518,7 +93213,10 @@ var Lib = _dereq_('../../lib'); var Axes = _dereq_('../../plots/cartesian/axes'); var extractOpts = _dereq_('../../components/colorscale').extractOpts; -module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLayer, contour) { +module.exports = function hoverPoints(pointData, xval, yval, hovermode, opts) { + if(!opts) opts = {}; + var isContour = opts.isContour; + var cd0 = pointData.cd[0]; var trace = cd0.trace; var xa = pointData.xa; @@ -87551,7 +93249,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay Fx.inbox(yval - y[0], yval - y[y.length - 1], 0) > 0) { return; } else { - if(contour) { + if(isContour) { var i2; x2 = [2 * x[0] - x[1]]; @@ -87576,7 +93274,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay var y1 = ya.c2p(y[ny + 1]); var _x, _y; - if(contour) { + if(isContour) { _x = cd0.orig_x || x; _y = cd0.orig_y || y; @@ -87640,15 +93338,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay })]; }; -},{"../../components/colorscale":117,"../../components/fx":145,"../../lib":233,"../../plots/cartesian/axes":279}],395:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale":167,"../../components/fx":195,"../../lib":285,"../../plots/cartesian/axes":331}],442:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -87665,19 +93355,10 @@ module.exports = { basePlotModule: _dereq_('../../plots/cartesian'), categories: ['cartesian', 'svg', '2dMap', 'showLegend'], meta: { - } }; -},{"../../plots/cartesian":292,"./attributes":387,"./calc":388,"./colorbar":390,"./defaults":392,"./hover":394,"./plot":398,"./style":399}],396:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian":344,"./attributes":434,"./calc":435,"./colorbar":437,"./defaults":439,"./hover":441,"./plot":445,"./style":446}],443:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -87802,15 +93483,7 @@ function iterateInterp2d(z, emptyPoints, overshoot) { return maxFractionalChange; } -},{"../../lib":233}],397:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],444:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -87890,19 +93563,10 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks, return arrayOut; }; -},{"../../lib":233,"../../registry":326}],398:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../registry":373}],445:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var tinycolor = _dereq_('tinycolor2'); var Registry = _dereq_('../../registry'); @@ -88295,19 +93959,10 @@ function putColor(pixels, pxIndex, c) { pixels[pxIndex + 3] = Math.round(c[3] * 255); } -},{"../../components/colorscale":117,"../../constants/xmlns_namespaces":213,"../../lib":233,"../../registry":326,"d3":21,"tinycolor2":88}],399:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/colorscale":167,"../../constants/xmlns_namespaces":266,"../../lib":285,"../../registry":373,"@plotly/d3":20,"tinycolor2":119}],446:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); module.exports = function style(gd) { d3.select(gd).selectAll('.hm image') @@ -88316,16 +93971,7 @@ module.exports = function style(gd) { }); }; -},{"d3":21}],400:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"@plotly/d3":20}],447:[function(_dereq_,module,exports){ 'use strict'; module.exports = function handleStyleDefaults(traceIn, traceOut, coerce) { @@ -88339,15 +93985,7 @@ module.exports = function handleStyleDefaults(traceIn, traceOut, coerce) { coerce('zhoverformat'); }; -},{}],401:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],448:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -88386,10 +94024,7 @@ module.exports = function handleXYZDefaults(traceIn, traceOut, coerce, layout, x traceOut._length = null; } - if( - traceIn.type === 'heatmapgl' || - traceIn.type === 'contourgl' - ) return true; // skip calendars until we handle them in those traces + if(traceIn.type === 'heatmapgl') return true; // skip calendars until we handle them in those traces var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults'); handleCalendarDefaults(traceIn, traceOut, [xName, yName], layout); @@ -88441,18 +94076,11 @@ function isValidZ(z) { return (allRowsAreArrays && oneRowIsFilled && hasOneNumber); } -},{"../../lib":233,"../../registry":326,"fast-isnumeric":23}],402:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../registry":373,"fast-isnumeric":31}],449:[function(_dereq_,module,exports){ 'use strict'; var barAttrs = _dereq_('../bar/attributes'); +var axisHoverFormat = _dereq_('../../plots/hoverformat_attributes'); var hovertemplateAttrs = _dereq_('../../plots/template_attributes').hovertemplateAttrs; var makeBinAttrs = _dereq_('./bin_attributes'); var constants = _dereq_('./constants'); @@ -88462,64 +94090,53 @@ module.exports = { x: { valType: 'data_array', editType: 'calc+clearAxisTypes', - }, y: { valType: 'data_array', editType: 'calc+clearAxisTypes', - }, + xhoverformat: axisHoverFormat('x'), + yhoverformat: axisHoverFormat('y'), + text: extendFlat({}, barAttrs.text, { - }), hovertext: extendFlat({}, barAttrs.hovertext, { - }), orientation: barAttrs.orientation, histfunc: { valType: 'enumerated', values: ['count', 'sum', 'avg', 'min', 'max'], - dflt: 'count', editType: 'calc', - }, histnorm: { valType: 'enumerated', values: ['', 'percent', 'probability', 'density', 'probability density'], dflt: '', - editType: 'calc', - }, cumulative: { enabled: { valType: 'boolean', dflt: false, - editType: 'calc', - }, direction: { valType: 'enumerated', values: ['increasing', 'decreasing'], dflt: 'increasing', - editType: 'calc', - }, currentbin: { valType: 'enumerated', values: ['include', 'exclude', 'half'], dflt: 'include', - editType: 'calc', - }, editType: 'calc' }, @@ -88527,9 +94144,7 @@ module.exports = { valType: 'integer', min: 0, dflt: 0, - editType: 'calc', - }, xbins: makeBinAttrs('x', true), @@ -88537,32 +94152,24 @@ module.exports = { valType: 'integer', min: 0, dflt: 0, - editType: 'calc', - }, ybins: makeBinAttrs('y', true), autobinx: { valType: 'boolean', dflt: null, - editType: 'calc', - }, autobiny: { valType: 'boolean', dflt: null, - editType: 'calc', - }, bingroup: { valType: 'string', - dflt: '', editType: 'calc', - }, hovertemplate: hovertemplateAttrs({}, { @@ -88582,16 +94189,7 @@ module.exports = { } }; -},{"../../lib/extend":227,"../../plots/template_attributes":321,"../bar/attributes":336,"./bin_attributes":404,"./constants":408}],403:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib/extend":279,"../../plots/hoverformat_attributes":363,"../../plots/template_attributes":368,"../bar/attributes":383,"./bin_attributes":451,"./constants":455}],450:[function(_dereq_,module,exports){ 'use strict'; @@ -88607,51 +94205,28 @@ module.exports = function doAvg(size, counts) { return total; }; -},{}],404:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],451:[function(_dereq_,module,exports){ 'use strict'; module.exports = function makeBinAttrs(axLetter, match) { return { start: { valType: 'any', // for date axes - editType: 'calc', - }, end: { valType: 'any', // for date axes - editType: 'calc', - }, size: { valType: 'any', // for date axes - editType: 'calc', - }, editType: 'calc' }; }; -},{}],405:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],452:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -88716,16 +94291,7 @@ module.exports = { } }; -},{"fast-isnumeric":23}],406:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"fast-isnumeric":31}],453:[function(_dereq_,module,exports){ 'use strict'; var numConstants = _dereq_('../../constants/numerical'); @@ -88892,15 +94458,7 @@ function dateParts(v, pa, calendar) { return parts; } -},{"../../constants/numerical":212,"../../plots/cartesian/axes":279}],407:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/numerical":265,"../../plots/cartesian/axes":331}],454:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -89471,31 +95029,14 @@ module.exports = { calcAllAutoBins: calcAllAutoBins }; -},{"../../lib":233,"../../plots/cartesian/axes":279,"../../registry":326,"../bar/arrays_to_calcdata":335,"./average":403,"./bin_functions":405,"./bin_label_vals":406,"./norm_functions":414,"fast-isnumeric":23}],408:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../plots/cartesian/axes":331,"../../registry":373,"../bar/arrays_to_calcdata":382,"./average":450,"./bin_functions":452,"./bin_label_vals":453,"./norm_functions":461,"fast-isnumeric":31}],455:[function(_dereq_,module,exports){ 'use strict'; module.exports = { eventDataKeys: ['binNumber'] }; -},{}],409:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],456:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -89764,15 +95305,7 @@ module.exports = function crossTraceDefaults(fullData, fullLayout) { } }; -},{"../../lib":233,"../../plots/cartesian/axis_ids":282,"../../plots/cartesian/constraints":286,"../../registry":326,"../bar/defaults":340}],410:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/cartesian/axis_ids":334,"../../plots/cartesian/constraints":338,"../../registry":373,"../bar/defaults":387}],457:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -89799,6 +95332,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout coerce('text'); coerce('hovertext'); coerce('hovertemplate'); + coerce('xhoverformat'); + coerce('yhoverformat'); var orientation = coerce('orientation', (y && !x) ? 'h' : 'v'); var sampleLetter = orientation === 'v' ? 'x' : 'y'; @@ -89838,15 +95373,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout errorBarsSupplyDefaults(traceIn, traceOut, lineColor || Color.defaultLine, {axis: 'x', inherit: 'y'}); }; -},{"../../components/color":105,"../../lib":233,"../../registry":326,"../bar/style_defaults":351,"./attributes":402}],411:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../lib":285,"../../registry":373,"../bar/style_defaults":398,"./attributes":449}],458:[function(_dereq_,module,exports){ 'use strict'; module.exports = function eventData(out, pt, trace, cd, pointNumber) { @@ -89887,23 +95414,14 @@ module.exports = function eventData(out, pt, trace, cd, pointNumber) { return out; }; -},{}],412:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],459:[function(_dereq_,module,exports){ 'use strict'; var barHover = _dereq_('../bar/hover').hoverPoints; var hoverLabelText = _dereq_('../../plots/cartesian/axes').hoverLabelText; -module.exports = function hoverPoints(pointData, xval, yval, hovermode) { - var pts = barHover(pointData, xval, yval, hovermode); +module.exports = function hoverPoints(pointData, xval, yval, hovermode, opts) { + var pts = barHover(pointData, xval, yval, hovermode, opts); if(!pts) return; @@ -89914,21 +95432,13 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { if(!trace.cumulative.enabled) { var posLetter = trace.orientation === 'h' ? 'y' : 'x'; - pointData[posLetter + 'Label'] = hoverLabelText(pointData[posLetter + 'a'], di.ph0, di.ph1); + pointData[posLetter + 'Label'] = hoverLabelText(pointData[posLetter + 'a'], [di.ph0, di.ph1], trace[posLetter + 'hoverformat']); } return pts; }; -},{"../../plots/cartesian/axes":279,"../bar/hover":343}],413:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian/axes":331,"../bar/hover":390}],460:[function(_dereq_,module,exports){ 'use strict'; /** @@ -89966,20 +95476,10 @@ module.exports = { basePlotModule: _dereq_('../../plots/cartesian'), categories: ['bar-like', 'cartesian', 'svg', 'bar', 'histogram', 'oriented', 'errorBarsOK', 'showLegend'], meta: { - } }; -},{"../../plots/cartesian":292,"../bar/cross_trace_calc":339,"../bar/layout_attributes":345,"../bar/layout_defaults":346,"../bar/plot":347,"../bar/select":348,"../bar/style":350,"../scatter/marker_colorbar":465,"./attributes":402,"./calc":407,"./cross_trace_defaults":409,"./defaults":410,"./event_data":411,"./hover":412}],414:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../plots/cartesian":344,"../bar/cross_trace_calc":386,"../bar/layout_attributes":392,"../bar/layout_defaults":393,"../bar/plot":394,"../bar/select":395,"../bar/style":397,"../scatter/marker_colorbar":512,"./attributes":449,"./calc":454,"./cross_trace_defaults":456,"./defaults":457,"./event_data":458,"./hover":459}],461:[function(_dereq_,module,exports){ 'use strict'; @@ -90005,21 +95505,14 @@ module.exports = { } }; -},{}],415:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],462:[function(_dereq_,module,exports){ 'use strict'; var histogramAttrs = _dereq_('../histogram/attributes'); var makeBinAttrs = _dereq_('../histogram/bin_attributes'); var heatmapAttrs = _dereq_('../heatmap/attributes'); var baseAttrs = _dereq_('../../plots/attributes'); +var axisHoverFormat = _dereq_('../../plots/hoverformat_attributes'); var hovertemplateAttrs = _dereq_('../../plots/template_attributes').hovertemplateAttrs; var colorScaleAttrs = _dereq_('../../components/colorscale/attributes'); @@ -90033,13 +95526,11 @@ module.exports = extendFlat( z: { valType: 'data_array', editType: 'calc', - }, marker: { color: { valType: 'data_array', editType: 'calc', - }, editType: 'calc' }, @@ -90054,34 +95545,25 @@ module.exports = extendFlat( autobiny: histogramAttrs.autobiny, bingroup: extendFlat({}, histogramAttrs.bingroup, { - }), xbingroup: extendFlat({}, histogramAttrs.bingroup, { - }), ybingroup: extendFlat({}, histogramAttrs.bingroup, { - }), xgap: heatmapAttrs.xgap, ygap: heatmapAttrs.ygap, zsmooth: heatmapAttrs.zsmooth, - zhoverformat: heatmapAttrs.zhoverformat, + xhoverformat: axisHoverFormat('x'), + yhoverformat: axisHoverFormat('y'), + zhoverformat: axisHoverFormat('z', 1), hovertemplate: hovertemplateAttrs({}, {keys: 'z'}), showlegend: extendFlat({}, baseAttrs.showlegend, {dflt: false}) }, colorScaleAttrs('', {cLetter: 'z', autoColorDflt: false}) ); -},{"../../components/colorscale/attributes":112,"../../lib/extend":227,"../../plots/attributes":275,"../../plots/template_attributes":321,"../heatmap/attributes":387,"../histogram/attributes":402,"../histogram/bin_attributes":404}],416:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale/attributes":162,"../../lib/extend":279,"../../plots/attributes":327,"../../plots/hoverformat_attributes":363,"../../plots/template_attributes":368,"../heatmap/attributes":434,"../histogram/attributes":449,"../histogram/bin_attributes":451}],463:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -90292,16 +95774,7 @@ function getRanges(edges, uniqueVals, gapLow, gapHigh, ax, calendar) { return out; } -},{"../../lib":233,"../../plots/cartesian/axes":279,"../histogram/average":403,"../histogram/bin_functions":405,"../histogram/bin_label_vals":406,"../histogram/calc":407,"../histogram/norm_functions":414}],417:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../plots/cartesian/axes":331,"../histogram/average":450,"../histogram/bin_functions":452,"../histogram/bin_label_vals":453,"../histogram/calc":454,"../histogram/norm_functions":461}],464:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -90323,25 +95796,18 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleStyleDefaults(traceIn, traceOut, coerce, layout); colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: '', cLetter: 'z'}); coerce('hovertemplate'); + coerce('xhoverformat'); + coerce('yhoverformat'); }; -},{"../../components/colorscale/defaults":115,"../../lib":233,"../heatmap/style_defaults":400,"./attributes":415,"./sample_defaults":420}],418:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/colorscale/defaults":165,"../../lib":285,"../heatmap/style_defaults":447,"./attributes":462,"./sample_defaults":467}],465:[function(_dereq_,module,exports){ 'use strict'; var heatmapHover = _dereq_('../heatmap/hover'); var hoverLabelText = _dereq_('../../plots/cartesian/axes').hoverLabelText; -module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLayer, contour) { - var pts = heatmapHover(pointData, xval, yval, hovermode, hoverLayer, contour); +module.exports = function hoverPoints(pointData, xval, yval, hovermode, opts) { + var pts = heatmapHover(pointData, xval, yval, hovermode, opts); if(!pts) return; @@ -90350,24 +95816,17 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay var ny = indices[0]; var nx = indices[1]; var cd0 = pointData.cd[0]; + var trace = cd0.trace; var xRange = cd0.xRanges[nx]; var yRange = cd0.yRanges[ny]; - pointData.xLabel = hoverLabelText(pointData.xa, xRange[0], xRange[1]); - pointData.yLabel = hoverLabelText(pointData.ya, yRange[0], yRange[1]); + pointData.xLabel = hoverLabelText(pointData.xa, [xRange[0], xRange[1]], trace.xhoverformat); + pointData.yLabel = hoverLabelText(pointData.ya, [yRange[0], yRange[1]], trace.yhoverformat); return pts; }; -},{"../../plots/cartesian/axes":279,"../heatmap/hover":394}],419:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian/axes":331,"../heatmap/hover":441}],466:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -90387,20 +95846,10 @@ module.exports = { basePlotModule: _dereq_('../../plots/cartesian'), categories: ['cartesian', 'svg', '2dMap', 'histogram', 'showLegend'], meta: { - - } }; -},{"../../plots/cartesian":292,"../heatmap/calc":388,"../heatmap/colorbar":390,"../heatmap/plot":398,"../heatmap/style":399,"../histogram/cross_trace_defaults":409,"../histogram/event_data":411,"./attributes":415,"./defaults":417,"./hover":418}],420:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian":344,"../heatmap/calc":435,"../heatmap/colorbar":437,"../heatmap/plot":445,"../heatmap/style":446,"../histogram/cross_trace_defaults":456,"../histogram/event_data":458,"./attributes":462,"./defaults":464,"./hover":465}],467:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -90437,20 +95886,13 @@ module.exports = function handleSampleDefaults(traceIn, traceOut, coerce, layout coerce('autobiny'); }; -},{"../../lib":233,"../../registry":326}],421:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../registry":373}],468:[function(_dereq_,module,exports){ 'use strict'; var histogram2dAttrs = _dereq_('../histogram2d/attributes'); var contourAttrs = _dereq_('../contour/attributes'); var colorScaleAttrs = _dereq_('../../components/colorscale/attributes'); +var axisHoverFormat = _dereq_('../../plots/hoverformat_attributes'); var extendFlat = _dereq_('../../lib/extend').extendFlat; @@ -90480,13 +95922,14 @@ module.exports = extendFlat({ color: contourAttrs.line.color, width: extendFlat({}, contourAttrs.line.width, { dflt: 0.5, - }), dash: contourAttrs.line.dash, smoothing: contourAttrs.line.smoothing, editType: 'plot' }, - zhoverformat: histogram2dAttrs.zhoverformat, + xhoverformat: axisHoverFormat('x'), + yhoverformat: axisHoverFormat('y'), + zhoverformat: axisHoverFormat('z', 1), hovertemplate: histogram2dAttrs.hovertemplate }, colorScaleAttrs('', { @@ -90495,16 +95938,7 @@ module.exports = extendFlat({ }) ); -},{"../../components/colorscale/attributes":112,"../../lib/extend":227,"../contour/attributes":365,"../histogram2d/attributes":415}],422:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/colorscale/attributes":162,"../../lib/extend":279,"../../plots/hoverformat_attributes":363,"../contour/attributes":412,"../histogram2d/attributes":462}],469:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -90530,17 +95964,11 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleContoursDefaults(traceIn, traceOut, coerce, coerce2); handleStyleDefaults(traceIn, traceOut, coerce, layout); coerce('hovertemplate'); + coerce('xhoverformat'); + coerce('yhoverformat'); }; -},{"../../lib":233,"../contour/contours_defaults":372,"../contour/style_defaults":386,"../histogram2d/sample_defaults":420,"./attributes":421}],423:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../contour/contours_defaults":419,"../contour/style_defaults":433,"../histogram2d/sample_defaults":467,"./attributes":468}],470:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -90559,20 +95987,10 @@ module.exports = { basePlotModule: _dereq_('../../plots/cartesian'), categories: ['cartesian', 'svg', '2dMap', 'contour', 'histogram', 'showLegend'], meta: { - - } }; -},{"../../plots/cartesian":292,"../contour/calc":366,"../contour/colorbar":368,"../contour/hover":378,"../contour/plot":383,"../contour/style":385,"../histogram/cross_trace_defaults":409,"./attributes":421,"./defaults":422}],424:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian":344,"../contour/calc":413,"../contour/colorbar":415,"../contour/hover":425,"../contour/plot":430,"../contour/style":432,"../histogram/cross_trace_defaults":456,"./attributes":468,"./defaults":469}],471:[function(_dereq_,module,exports){ 'use strict'; var baseAttrs = _dereq_('../../plots/attributes'); @@ -90592,22 +96010,22 @@ for(var i = 0; i < cm.length; i++) { module.exports = extendFlat({ source: { valType: 'string', - editType: 'calc', - }, z: { valType: 'data_array', - editType: 'calc', - }, colormodel: { valType: 'enumerated', values: cm, - editType: 'calc', - + }, + zsmooth: { + valType: 'enumerated', + values: ['fast', false], + dflt: false, + editType: 'plot', }, zmin: { valType: 'info_array', @@ -90617,9 +96035,7 @@ module.exports = extendFlat({ {valType: 'number', editType: 'calc'}, {valType: 'number', editType: 'calc'} ], - editType: 'calc', - }, zmax: { valType: 'info_array', @@ -90629,47 +96045,35 @@ module.exports = extendFlat({ {valType: 'number', editType: 'calc'}, {valType: 'number', editType: 'calc'} ], - editType: 'calc', - }, x0: { valType: 'any', dflt: 0, - editType: 'calc+clearAxisTypes', - }, y0: { valType: 'any', dflt: 0, - editType: 'calc+clearAxisTypes', - }, dx: { valType: 'number', dflt: 1, - editType: 'calc', - }, dy: { valType: 'number', dflt: 1, - editType: 'calc', - }, text: { valType: 'data_array', editType: 'plot', - }, hovertext: { valType: 'data_array', editType: 'plot', - }, hoverinfo: extendFlat({}, baseAttrs.hoverinfo, { flags: ['x', 'y', 'z', 'color', 'name', 'text'], @@ -90682,15 +96086,7 @@ module.exports = extendFlat({ transforms: undefined }); -},{"../../lib/extend":227,"../../plots/attributes":275,"../../plots/template_attributes":321,"./constants":426}],425:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib/extend":279,"../../plots/attributes":327,"../../plots/template_attributes":368,"./constants":473}],472:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -90780,15 +96176,7 @@ function makeScaler(trace) { }; } -},{"../../lib":233,"../../plots/cartesian/axes":279,"./constants":426,"./helpers":429,"fast-isnumeric":23}],426:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/cartesian/axes":331,"./constants":473,"./helpers":476,"fast-isnumeric":31}],473:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -90838,18 +96226,23 @@ module.exports = { }, suffix: ['°', '%', '%', ''] } - } + }, + // For pixelated image rendering + // http://phrogz.net/tmp/canvas_image_zoom.html + // https://developer.mozilla.org/en-US/docs/Web/CSS/image-rendering + pixelatedStyle: [ + 'image-rendering: optimizeSpeed', + 'image-rendering: -moz-crisp-edges', + 'image-rendering: -o-crisp-edges', + 'image-rendering: -webkit-optimize-contrast', + 'image-rendering: optimize-contrast', + 'image-rendering: crisp-edges', + 'image-rendering: pixelated', + '' + ].join('; ') }; -},{}],427:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],474:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -90891,6 +96284,7 @@ module.exports = function supplyDefaults(traceIn, traceOut) { traceOut.zmax = cm.zmaxDflt; } + coerce('zsmooth'); coerce('text'); coerce('hovertext'); coerce('hovertemplate'); @@ -90898,15 +96292,7 @@ module.exports = function supplyDefaults(traceIn, traceOut) { traceOut._length = null; }; -},{"../../lib":233,"../../snapshot/helpers":330,"./attributes":424,"./constants":426}],428:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../snapshot/helpers":377,"./attributes":471,"./constants":473}],475:[function(_dereq_,module,exports){ 'use strict'; module.exports = function eventData(out, pt) { @@ -90920,36 +96306,20 @@ module.exports = function eventData(out, pt) { return out; }; -},{}],429:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],476:[function(_dereq_,module,exports){ 'use strict'; -var sizeOf = _dereq_('image-size'); +var probeSync = _dereq_('probe-image-size/sync'); var dataUri = _dereq_('../../snapshot/helpers').IMAGE_URL_PREFIX; var Buffer = _dereq_('buffer/').Buffer; // note: the trailing slash is important! exports.getImageSize = function(src) { var data = src.replace(dataUri, ''); var buff = new Buffer(data, 'base64'); - return sizeOf(buff); + return probeSync(buff); }; -},{"../../snapshot/helpers":330,"buffer/":18,"image-size":58}],430:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../snapshot/helpers":377,"buffer/":28,"probe-image-size/sync":95}],477:[function(_dereq_,module,exports){ 'use strict'; var Fx = _dereq_('../../components/fx'); @@ -91041,15 +96411,7 @@ module.exports = function hoverPoints(pointData, xval, yval) { })]; }; -},{"../../components/fx":145,"../../lib":233,"./constants":426}],431:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/fx":195,"../../lib":285,"./constants":473}],478:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -91067,22 +96429,13 @@ module.exports = { categories: ['cartesian', 'svg', '2dMap', 'noSortingByValue'], animatable: false, meta: { - } }; -},{"../../plots/cartesian":292,"./attributes":424,"./calc":425,"./defaults":427,"./event_data":428,"./hover":430,"./plot":432,"./style":433}],432:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian":344,"./attributes":471,"./calc":472,"./defaults":474,"./event_data":475,"./hover":477,"./plot":479,"./style":480}],479:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Lib = _dereq_('../../lib'); var strTranslate = Lib.strTranslate; var xmlnsNamespaces = _dereq_('../../constants/xmlns_namespaces'); @@ -91100,8 +96453,11 @@ module.exports = function plot(gd, plotinfo, cdimage, imageLayer) { var plotGroup = d3.select(this); var cd0 = cd[0]; var trace = cd0.trace; - var fastImage = supportsPixelatedImage && !trace._hasZ && trace._hasSource && xa.type === 'linear' && ya.type === 'linear'; - trace._fastImage = fastImage; + var realImage = ( + ((trace.zsmooth === 'fast') || (trace.zsmooth === false && supportsPixelatedImage)) && + !trace._hasZ && trace._hasSource && xa.type === 'linear' && ya.type === 'linear' + ); + trace._realImage = realImage; var z = cd0.z; var x0 = cd0.x0; @@ -91147,7 +96503,7 @@ module.exports = function plot(gd, plotinfo, cdimage, imageLayer) { } // Reduce image size when zoomed in to save memory - if(!fastImage) { + if(!realImage) { var extra = 0.5; // half the axis size left = Math.max(-extra * xa._length, left); right = Math.min((1 + extra) * xa._length, right); @@ -91210,11 +96566,9 @@ module.exports = function plot(gd, plotinfo, cdimage, imageLayer) { image3.exit().remove(); - // Pixelated image rendering - // http://phrogz.net/tmp/canvas_image_zoom.html - // https://developer.mozilla.org/en-US/docs/Web/CSS/image-rendering - var style = 'image-rendering: optimizeSpeed; image-rendering: -moz-crisp-edges; image-rendering: -o-crisp-edges; image-rendering: -webkit-optimize-contrast; image-rendering: optimize-contrast; image-rendering: crisp-edges; image-rendering: pixelated;'; - if(fastImage) { + var style = (trace.zsmooth === false) ? constants.pixelatedStyle : ''; + + if(realImage) { var xRange = Lib.simpleMap(xa.range, xa.r2l); var yRange = Lib.simpleMap(ya.range, ya.r2l); @@ -91270,7 +96624,7 @@ module.exports = function plot(gd, plotinfo, cdimage, imageLayer) { canvas = drawMagnifiedPixelsOnCanvas(function(i, j) {return z[j][i];}); href = canvas.toDataURL('image/png'); } else if(trace._hasSource) { - if(fastImage) { + if(realImage) { href = trace.source; } else { var context = trace._canvas.el.getContext('2d'); @@ -91301,18 +96655,10 @@ module.exports = function plot(gd, plotinfo, cdimage, imageLayer) { }); }; -},{"../../constants/xmlns_namespaces":213,"../../lib":233,"./constants":426,"d3":21}],433:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/xmlns_namespaces":266,"../../lib":285,"./constants":473,"@plotly/d3":20}],480:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); module.exports = function style(gd) { d3.select(gd).selectAll('.im image') @@ -91321,15 +96667,7 @@ module.exports = function style(gd) { }); }; -},{"d3":21}],434:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"@plotly/d3":20}],481:[function(_dereq_,module,exports){ 'use strict'; var baseAttrs = _dereq_('../../plots/attributes'); @@ -91345,61 +96683,49 @@ var textFontAttrs = fontAttrs({ editType: 'plot', arrayOk: true, colorEditType: 'plot', - }); module.exports = { labels: { valType: 'data_array', editType: 'calc', - }, // equivalent of x0 and dx, if label is missing label0: { valType: 'number', - dflt: 0, editType: 'calc', - }, dlabel: { valType: 'number', - dflt: 1, editType: 'calc', - }, values: { valType: 'data_array', editType: 'calc', - }, marker: { colors: { valType: 'data_array', // TODO 'color_array' ? editType: 'calc', - }, line: { color: { valType: 'color', - dflt: colorAttrs.defaultLine, arrayOk: true, editType: 'style', - }, width: { valType: 'number', - min: 0, dflt: 0, arrayOk: true, editType: 'style', - }, editType: 'calc' }, @@ -91409,15 +96735,12 @@ module.exports = { text: { valType: 'data_array', editType: 'plot', - }, hovertext: { valType: 'string', - dflt: '', arrayOk: true, editType: 'style', - }, // 'see eg:' @@ -91426,20 +96749,16 @@ module.exports = { // 'of its own. but the point is the size of the whole pie is important.)' scalegroup: { valType: 'string', - dflt: '', editType: 'calc', - }, // labels (legend is handled by plots.attributes.showlegend and layout.hiddenlabels) textinfo: { valType: 'flaglist', - flags: ['label', 'text', 'value', 'percent'], extras: ['none'], editType: 'calc', - }, hoverinfo: extendFlat({}, baseAttrs.hoverinfo, { flags: ['label', 'text', 'value', 'percent', 'name'] @@ -91452,48 +96771,36 @@ module.exports = { }), textposition: { valType: 'enumerated', - values: ['inside', 'outside', 'auto', 'none'], dflt: 'auto', arrayOk: true, editType: 'plot', - }, textfont: extendFlat({}, textFontAttrs, { - }), insidetextorientation: { valType: 'enumerated', - values: ['horizontal', 'radial', 'tangential', 'auto'], dflt: 'auto', editType: 'plot', - }, insidetextfont: extendFlat({}, textFontAttrs, { - }), outsidetextfont: extendFlat({}, textFontAttrs, { - }), automargin: { valType: 'boolean', dflt: false, - editType: 'plot', - }, title: { text: { valType: 'string', dflt: '', - editType: 'plot', - }, font: extendFlat({}, textFontAttrs, { - }), position: { valType: 'enumerated', @@ -91502,9 +96809,7 @@ module.exports = { 'middle center', 'bottom left', 'bottom center', 'bottom right' ], - editType: 'plot', - }, editType: 'plot' @@ -91515,21 +96820,17 @@ module.exports = { hole: { valType: 'number', - min: 0, max: 1, dflt: 0, editType: 'calc', - }, // ordering and direction sort: { valType: 'boolean', - dflt: true, editType: 'calc', - }, direction: { /** @@ -91541,42 +96842,33 @@ module.exports = { */ valType: 'enumerated', values: ['clockwise', 'counterclockwise'], - dflt: 'counterclockwise', editType: 'calc', - }, rotation: { valType: 'number', - min: -360, max: 360, dflt: 0, editType: 'calc', - }, pull: { valType: 'number', - min: 0, max: 1, dflt: 0, arrayOk: true, editType: 'calc', - }, _deprecated: { title: { valType: 'string', dflt: '', - editType: 'calc', - }, titlefont: extendFlat({}, textFontAttrs, { - }), titleposition: { valType: 'enumerated', @@ -91585,22 +96877,12 @@ module.exports = { 'middle center', 'bottom left', 'bottom center', 'bottom right' ], - editType: 'calc', - } } }; -},{"../../components/color/attributes":104,"../../lib/extend":227,"../../plots/attributes":275,"../../plots/domain":306,"../../plots/font_attributes":307,"../../plots/template_attributes":321}],435:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color/attributes":154,"../../lib/extend":279,"../../plots/attributes":327,"../../plots/domain":358,"../../plots/font_attributes":359,"../../plots/template_attributes":368}],482:[function(_dereq_,module,exports){ 'use strict'; var plots = _dereq_('../../plots/plots'); @@ -91615,15 +96897,7 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) plots.cleanBasePlot(exports.name, newFullData, newFullLayout, oldFullData, oldFullLayout); }; -},{"../../plots/plots":313}],436:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/plots":366}],483:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -91798,15 +97072,7 @@ module.exports = { generateExtendedColors: generateExtendedColors }; -},{"../../components/color":105,"fast-isnumeric":23,"tinycolor2":88}],437:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"fast-isnumeric":31,"tinycolor2":119}],484:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -91929,15 +97195,7 @@ module.exports = { supplyDefaults: supplyDefaults }; -},{"../../lib":233,"../../plots/domain":306,"../bar/defaults":340,"./attributes":434,"fast-isnumeric":23}],438:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/domain":358,"../bar/defaults":387,"./attributes":481,"fast-isnumeric":31}],485:[function(_dereq_,module,exports){ 'use strict'; var appendArrayMultiPointValues = _dereq_('../../components/fx/helpers').appendArrayMultiPointValues; @@ -91978,15 +97236,7 @@ module.exports = function eventData(pt, trace) { return out; }; -},{"../../components/fx/helpers":141}],439:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/fx/helpers":191}],486:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -92026,15 +97276,7 @@ exports.getRotationAngle = function(rotation) { return (rotation === 'auto' ? 0 : rotation) * Math.PI / 180; }; -},{"../../lib":233}],440:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],487:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -92055,52 +97297,29 @@ module.exports = { basePlotModule: _dereq_('./base_plot'), categories: ['pie-like', 'pie', 'showLegend'], meta: { - } }; -},{"./attributes":434,"./base_plot":435,"./calc":436,"./defaults":437,"./layout_attributes":441,"./layout_defaults":442,"./plot":443,"./style":444,"./style_one":445}],441:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"./attributes":481,"./base_plot":482,"./calc":483,"./defaults":484,"./layout_attributes":488,"./layout_defaults":489,"./plot":490,"./style":491,"./style_one":492}],488:[function(_dereq_,module,exports){ 'use strict'; module.exports = { hiddenlabels: { valType: 'data_array', - editType: 'calc', - }, piecolorway: { valType: 'colorlist', - editType: 'calc', - }, extendpiecolors: { valType: 'boolean', dflt: true, - editType: 'calc', - } }; -},{}],442:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],489:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -92117,18 +97336,10 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) { coerce('extendpiecolors'); }; -},{"../../lib":233,"./layout_attributes":441}],443:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"./layout_attributes":488}],490:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Plots = _dereq_('../../plots/plots'); var Fx = _dereq_('../../components/fx'); @@ -93297,18 +98508,10 @@ module.exports = { computeTransform: computeTransform }; -},{"../../components/color":105,"../../components/drawing":127,"../../components/fx":145,"../../lib":233,"../../lib/svg_text_utils":255,"../../plots/plots":313,"../bar/constants":338,"../bar/uniform_text":352,"./event_data":438,"./helpers":439,"d3":21}],444:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../components/drawing":177,"../../components/fx":195,"../../lib":285,"../../lib/svg_text_utils":307,"../../plots/plots":366,"../bar/constants":385,"../bar/uniform_text":399,"./event_data":485,"./helpers":486,"@plotly/d3":20}],491:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var styleOne = _dereq_('./style_one'); var resizeText = _dereq_('../bar/uniform_text').resizeText; @@ -93330,15 +98533,7 @@ module.exports = function style(gd) { }); }; -},{"../bar/uniform_text":352,"./style_one":445,"d3":21}],445:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../bar/uniform_text":399,"./style_one":492,"@plotly/d3":20}],492:[function(_dereq_,module,exports){ 'use strict'; var Color = _dereq_('../../components/color'); @@ -93354,16 +98549,7 @@ module.exports = function styleOne(s, pt, trace) { .call(Color.stroke, lineColor); }; -},{"../../components/color":105,"./helpers":439}],446:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/color":155,"./helpers":486}],493:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -93406,17 +98592,10 @@ module.exports = function arraysToCalcdata(cd, trace) { } }; -},{"../../lib":233}],447:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],494:[function(_dereq_,module,exports){ 'use strict'; +var axisHoverFormat = _dereq_('../../plots/hoverformat_attributes'); var texttemplateAttrs = _dereq_('../../plots/template_attributes').texttemplateAttrs; var hovertemplateAttrs = _dereq_('../../plots/template_attributes').hovertemplateAttrs; var colorScaleAttrs = _dereq_('../../components/colorscale/attributes'); @@ -93432,18 +98611,14 @@ function axisPeriod(axis) { return { valType: 'any', dflt: 0, - editType: 'calc', - }; } function axisPeriod0(axis) { return { valType: 'any', - editType: 'calc', - }; } @@ -93454,9 +98629,7 @@ function axisPeriodAlignment(axis) { 'start', 'middle', 'end' ], dflt: 'middle', - editType: 'calc', - }; } @@ -93465,45 +98638,35 @@ module.exports = { valType: 'data_array', editType: 'calc+clearAxisTypes', anim: true, - }, x0: { valType: 'any', dflt: 0, - editType: 'calc+clearAxisTypes', anim: true, - }, dx: { valType: 'number', dflt: 1, - editType: 'calc', anim: true, - }, y: { valType: 'data_array', editType: 'calc+clearAxisTypes', anim: true, - }, y0: { valType: 'any', dflt: 0, - editType: 'calc+clearAxisTypes', anim: true, - }, dy: { valType: 'number', dflt: 1, - editType: 'calc', anim: true, - }, xperiod: axisPeriod('x'), @@ -93512,45 +98675,37 @@ module.exports = { yperiod0: axisPeriod0('y0'), xperiodalignment: axisPeriodAlignment('x'), yperiodalignment: axisPeriodAlignment('y'), + xhoverformat: axisHoverFormat('x'), + yhoverformat: axisHoverFormat('y'), stackgroup: { valType: 'string', - dflt: '', editType: 'calc', - }, orientation: { valType: 'enumerated', - values: ['v', 'h'], editType: 'calc', - }, groupnorm: { valType: 'enumerated', values: ['', 'fraction', 'percent'], dflt: '', - editType: 'calc', - }, stackgaps: { valType: 'enumerated', values: ['infer zero', 'interpolate'], dflt: 'infer zero', - editType: 'calc', - }, text: { valType: 'string', - dflt: '', arrayOk: true, editType: 'calc', - }, texttemplate: texttemplateAttrs({}, { @@ -93558,71 +98713,56 @@ module.exports = { }), hovertext: { valType: 'string', - dflt: '', arrayOk: true, editType: 'style', - }, mode: { valType: 'flaglist', flags: ['lines', 'markers', 'text'], extras: ['none'], - editType: 'calc', - }, hoveron: { valType: 'flaglist', flags: ['points', 'fills'], - editType: 'style', - }, hovertemplate: hovertemplateAttrs({}, { keys: constants.eventDataKeys }), + line: { color: { valType: 'color', - editType: 'style', anim: true, - }, width: { valType: 'number', min: 0, dflt: 2, - editType: 'style', anim: true, - }, shape: { valType: 'enumerated', values: ['linear', 'spline', 'hv', 'vh', 'hvh', 'vhv'], dflt: 'linear', - editType: 'plot', - }, smoothing: { valType: 'number', min: 0, max: 1.3, dflt: 1, - editType: 'plot', - }, dash: extendFlat({}, dash, {editType: 'style'}), simplify: { valType: 'boolean', dflt: true, - editType: 'plot', - }, editType: 'plot' }, @@ -93630,31 +98770,23 @@ module.exports = { connectgaps: { valType: 'boolean', dflt: false, - editType: 'calc', - }, cliponaxis: { valType: 'boolean', dflt: true, - editType: 'plot', - }, fill: { valType: 'enumerated', values: ['none', 'tozeroy', 'tozerox', 'tonexty', 'tonextx', 'toself', 'tonext'], - editType: 'calc', - }, fillcolor: { valType: 'color', - editType: 'style', anim: true, - }, marker: extendFlat({ symbol: { @@ -93662,60 +98794,46 @@ module.exports = { values: Drawing.symbolList, dflt: 'circle', arrayOk: true, - editType: 'style', - }, opacity: { valType: 'number', min: 0, max: 1, arrayOk: true, - editType: 'style', anim: true, - }, size: { valType: 'number', min: 0, dflt: 6, arrayOk: true, - editType: 'calc', anim: true, - }, maxdisplayed: { valType: 'number', min: 0, dflt: 0, - editType: 'plot', - }, sizeref: { valType: 'number', dflt: 1, - editType: 'calc', - }, sizemin: { valType: 'number', min: 0, dflt: 0, - editType: 'calc', - }, sizemode: { valType: 'enumerated', values: ['diameter', 'area'], dflt: 'diameter', - editType: 'calc', - }, line: extendFlat({ @@ -93723,10 +98841,8 @@ module.exports = { valType: 'number', min: 0, arrayOk: true, - editType: 'style', anim: true, - }, editType: 'calc' }, @@ -93738,16 +98854,12 @@ module.exports = { values: ['radial', 'horizontal', 'vertical', 'none'], arrayOk: true, dflt: 'none', - editType: 'calc', - }, color: { valType: 'color', arrayOk: true, - editType: 'calc', - }, editType: 'calc' }, @@ -93761,31 +98873,23 @@ module.exports = { valType: 'number', min: 0, max: 1, - editType: 'style', - }, color: { valType: 'color', - editType: 'style', - }, size: { valType: 'number', min: 0, - editType: 'style', - }, editType: 'style' }, textfont: { color: { valType: 'color', - editType: 'style', - }, editType: 'style' }, @@ -93797,31 +98901,23 @@ module.exports = { valType: 'number', min: 0, max: 1, - editType: 'style', - }, color: { valType: 'color', - editType: 'style', - }, size: { valType: 'number', min: 0, - editType: 'style', - }, editType: 'style' }, textfont: { color: { valType: 'color', - editType: 'style', - }, editType: 'style' }, @@ -93837,38 +98933,16 @@ module.exports = { ], dflt: 'middle center', arrayOk: true, - editType: 'calc', - }, textfont: fontAttrs({ editType: 'calc', colorEditType: 'style', arrayOk: true, - }), - - r: { - valType: 'data_array', - editType: 'calc', - - }, - t: { - valType: 'data_array', - editType: 'calc', - - } }; -},{"../../components/colorscale/attributes":112,"../../components/drawing":127,"../../components/drawing/attributes":126,"../../lib/extend":227,"../../plots/font_attributes":307,"../../plots/template_attributes":321,"./constants":451}],448:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale/attributes":162,"../../components/drawing":177,"../../components/drawing/attributes":176,"../../lib/extend":279,"../../plots/font_attributes":359,"../../plots/hoverformat_attributes":363,"../../plots/template_attributes":368,"./constants":498}],495:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -94159,15 +99233,7 @@ module.exports = { getStackOpts: getStackOpts }; -},{"../../constants/numerical":212,"../../lib":233,"../../plots/cartesian/align_period":276,"../../plots/cartesian/axes":279,"./arrays_to_calcdata":446,"./calc_selection":449,"./colorscale_calc":450,"./subtypes":472,"fast-isnumeric":23}],449:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/numerical":265,"../../lib":285,"../../plots/cartesian/align_period":328,"../../plots/cartesian/axes":331,"./arrays_to_calcdata":493,"./calc_selection":496,"./colorscale_calc":497,"./subtypes":519,"fast-isnumeric":31}],496:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -94178,15 +99244,7 @@ module.exports = function calcSelection(cd, trace) { } }; -},{"../../lib":233}],450:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],497:[function(_dereq_,module,exports){ 'use strict'; var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; @@ -94221,16 +99279,7 @@ module.exports = function calcMarkerColorscale(gd, trace) { } }; -},{"../../components/colorscale/calc":113,"../../components/colorscale/helpers":116,"./subtypes":472}],451:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/colorscale/calc":163,"../../components/colorscale/helpers":166,"./subtypes":519}],498:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -94250,16 +99299,7 @@ module.exports = { eventDataKeys: [] }; -},{}],452:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],499:[function(_dereq_,module,exports){ 'use strict'; var calc = _dereq_('./calc'); @@ -94431,16 +99471,7 @@ function getInterp(calcTrace, index, position, posAttr) { return pt0.s + (pt1.s - pt0.s) * (position - pt0[posAttr]) / (pt1[posAttr] - pt0[posAttr]); } -},{"./calc":448}],453:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"./calc":495}],500:[function(_dereq_,module,exports){ 'use strict'; @@ -94470,15 +99501,7 @@ module.exports = function crossTraceDefaults(fullData) { } }; -},{}],454:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],501:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -94507,6 +99530,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout if(!traceOut.visible) return; handlePeriodDefaults(traceIn, traceOut, layout, coerce); + coerce('xhoverformat'); + coerce('yhoverformat'); var stackGroupOpts = handleStackDefaults(traceIn, traceOut, layout, coerce); @@ -94563,16 +99588,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":233,"../../registry":326,"./attributes":447,"./constants":451,"./fillcolor_defaults":455,"./line_defaults":460,"./line_shape_defaults":462,"./marker_defaults":466,"./period_defaults":467,"./stack_defaults":470,"./subtypes":472,"./text_defaults":473,"./xy_defaults":474}],455:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../registry":373,"./attributes":494,"./constants":498,"./fillcolor_defaults":502,"./line_defaults":507,"./line_shape_defaults":509,"./marker_defaults":513,"./period_defaults":514,"./stack_defaults":517,"./subtypes":519,"./text_defaults":520,"./xy_defaults":521}],502:[function(_dereq_,module,exports){ 'use strict'; var Color = _dereq_('../../components/color'); @@ -94600,15 +99616,7 @@ module.exports = function fillColorDefaults(traceIn, traceOut, defaultColor, coe )); }; -},{"../../components/color":105,"../../lib":233}],456:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../lib":285}],503:[function(_dereq_,module,exports){ 'use strict'; var Axes = _dereq_('../../plots/cartesian/axes'); @@ -94620,22 +99628,13 @@ module.exports = function formatLabels(cdi, trace, fullLayout) { var xa = Axes.getFromTrace(mockGd, trace, 'x'); var ya = Axes.getFromTrace(mockGd, trace, 'y'); - labels.xLabel = Axes.tickText(xa, cdi.x, true).text; - labels.yLabel = Axes.tickText(ya, cdi.y, true).text; + labels.xLabel = Axes.tickText(xa, xa.c2l(cdi.x), true).text; + labels.yLabel = Axes.tickText(ya, ya.c2l(cdi.y), true).text; return labels; }; -},{"../../plots/cartesian/axes":279}],457:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../plots/cartesian/axes":331}],504:[function(_dereq_,module,exports){ 'use strict'; var Color = _dereq_('../../components/color'); @@ -94675,15 +99674,7 @@ module.exports = function getTraceColor(trace, di) { } }; -},{"../../components/color":105,"./subtypes":472}],458:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"./subtypes":519}],505:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -94714,13 +99705,14 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { var rad = Math.max(3, di.mrc || 0); var kink = 1 - 1 / rad; var dxRaw = Math.abs(xa.c2p(di.x) - xpx); - var d = (dxRaw < rad) ? (kink * dxRaw / rad) : (dxRaw - rad + kink); - return d; + if(di.orig_x !== undefined) dxRaw += xa.c2p(di.orig_x) - xa.c2p(di.x); + return (dxRaw < rad) ? (kink * dxRaw / rad) : (dxRaw - rad + kink); }; var dy = function(di) { var rad = Math.max(3, di.mrc || 0); var kink = 1 - 1 / rad; var dyRaw = Math.abs(ya.c2p(di.y) - ypx); + if(di.orig_y !== undefined) dyRaw += ya.c2p(di.orig_y) - ya.c2p(di.y); return (dyRaw < rad) ? (kink * dyRaw / rad) : (dyRaw - rad + kink); }; var dxy = function(di) { @@ -94870,15 +99862,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { } }; -},{"../../components/color":105,"../../components/fx":145,"../../lib":233,"../../registry":326,"./get_trace_color":457}],459:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../components/fx":195,"../../lib":285,"../../registry":373,"./get_trace_color":504}],506:[function(_dereq_,module,exports){ 'use strict'; var subtypes = _dereq_('./subtypes'); @@ -94912,19 +99896,10 @@ module.exports = { 'zoomScale' ], meta: { - } }; -},{"../../plots/cartesian":292,"./arrays_to_calcdata":446,"./attributes":447,"./calc":448,"./cross_trace_calc":452,"./cross_trace_defaults":453,"./defaults":454,"./format_labels":456,"./hover":458,"./marker_colorbar":465,"./plot":468,"./select":469,"./style":471,"./subtypes":472}],460:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian":344,"./arrays_to_calcdata":493,"./attributes":494,"./calc":495,"./cross_trace_calc":499,"./cross_trace_defaults":500,"./defaults":501,"./format_labels":503,"./hover":505,"./marker_colorbar":512,"./plot":515,"./select":516,"./style":518,"./subtypes":519}],507:[function(_dereq_,module,exports){ 'use strict'; var isArrayOrTypedArray = _dereq_('../../lib').isArrayOrTypedArray; @@ -94947,16 +99922,7 @@ module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout, if(!(opts || {}).noDash) coerce('line.dash'); }; -},{"../../components/colorscale/defaults":115,"../../components/colorscale/helpers":116,"../../lib":233}],461:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/colorscale/defaults":165,"../../components/colorscale/helpers":166,"../../lib":285}],508:[function(_dereq_,module,exports){ 'use strict'; var numConstants = _dereq_('../../constants/numerical'); @@ -95408,16 +100374,7 @@ module.exports = function linePoints(d, opts) { return segments; }; -},{"../../constants/numerical":212,"../../lib":233,"./constants":451}],462:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../constants/numerical":265,"../../lib":285,"./constants":498}],509:[function(_dereq_,module,exports){ 'use strict'; @@ -95427,15 +100384,7 @@ module.exports = function handleLineShapeDefaults(traceIn, traceOut, coerce) { if(shape === 'spline') coerce('line.smoothing'); }; -},{}],463:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],510:[function(_dereq_,module,exports){ 'use strict'; var LINKEDFILLS = {tonextx: 1, tonexty: 1, tonext: 1}; @@ -95517,16 +100466,7 @@ module.exports = function linkTraces(gd, plotinfo, cdscatter) { return cdscatterSorted; }; -},{}],464:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],511:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -95559,16 +100499,7 @@ module.exports = function makeBubbleSizeFn(trace) { }; }; -},{"fast-isnumeric":23}],465:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"fast-isnumeric":31}],512:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -95577,15 +100508,7 @@ module.exports = { max: 'cmax' }; -},{}],466:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],513:[function(_dereq_,module,exports){ 'use strict'; var Color = _dereq_('../../components/color'); @@ -95658,15 +100581,7 @@ module.exports = function markerDefaults(traceIn, traceOut, defaultColor, layout } }; -},{"../../components/color":105,"../../components/colorscale/defaults":115,"../../components/colorscale/helpers":116,"./subtypes":472}],467:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../components/colorscale/defaults":165,"../../components/colorscale/helpers":166,"./subtypes":519}],514:[function(_dereq_,module,exports){ 'use strict'; var dateTick0 = _dereq_('../../lib').dateTick0; @@ -95705,19 +100620,10 @@ module.exports = function handlePeriodDefaults(traceIn, traceOut, layout, coerce } }; -},{"../../constants/numerical":212,"../../lib":233}],468:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../constants/numerical":265,"../../lib":285}],515:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Registry = _dereq_('../../registry'); var Lib = _dereq_('../../lib'); @@ -96266,16 +101172,7 @@ function selectMarkers(gd, idx, plotinfo, cdscatter, cdscatterAll) { }); } -},{"../../components/drawing":127,"../../lib":233,"../../lib/polygon":245,"../../registry":326,"./line_points":461,"./link_traces":463,"./subtypes":472,"d3":21}],469:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/drawing":177,"../../lib":285,"../../lib/polygon":297,"../../registry":373,"./line_points":508,"./link_traces":510,"./subtypes":519,"@plotly/d3":20}],516:[function(_dereq_,module,exports){ 'use strict'; var subtypes = _dereq_('./subtypes'); @@ -96320,15 +101217,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{"./subtypes":472}],470:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"./subtypes":519}],517:[function(_dereq_,module,exports){ 'use strict'; var perStackAttrs = ['orientation', 'groupnorm', 'stackgaps']; @@ -96425,19 +101314,10 @@ module.exports = function handleStackDefaults(traceIn, traceOut, layout, coerce) } }; -},{}],471:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],518:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Drawing = _dereq_('../../components/drawing'); var Registry = _dereq_('../../registry'); @@ -96496,16 +101376,7 @@ module.exports = { styleOnSelect: styleOnSelect }; -},{"../../components/drawing":127,"../../registry":326,"d3":21}],472:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/drawing":177,"../../registry":373,"@plotly/d3":20}],519:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -96535,16 +101406,7 @@ module.exports = { } }; -},{"../../lib":233}],473:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285}],520:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -96565,15 +101427,7 @@ module.exports = function(traceIn, traceOut, layout, coerce, opts) { } }; -},{"../../lib":233}],474:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],521:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -96609,15 +101463,7 @@ module.exports = function handleXYDefaults(traceIn, traceOut, layout, coerce) { return len; }; -},{"../../lib":233,"../../registry":326}],475:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../registry":373}],522:[function(_dereq_,module,exports){ 'use strict'; var hovertemplateAttrs = _dereq_('../../plots/template_attributes').hovertemplateAttrs; @@ -96637,35 +101483,28 @@ module.exports = { a: { valType: 'data_array', editType: 'calc', - }, b: { valType: 'data_array', editType: 'calc', - }, c: { valType: 'data_array', editType: 'calc', - }, sum: { valType: 'number', - dflt: 0, min: 0, editType: 'calc', - }, mode: extendFlat({}, scatterAttrs.mode, {dflt: 'markers'}), text: extendFlat({}, scatterAttrs.text, { - }), texttemplate: texttemplateAttrs({editType: 'plot'}, { keys: ['a', 'b', 'c', 'text'] }), hovertext: extendFlat({}, scatterAttrs.hovertext, { - }), line: { color: scatterLineAttrs.color, @@ -96681,7 +101520,6 @@ module.exports = { fill: extendFlat({}, scatterAttrs.fill, { values: ['none', 'toself', 'tonext'], dflt: 'none', - }), fillcolor: scatterAttrs.fillcolor, marker: extendFlat({ @@ -96717,16 +101555,7 @@ module.exports = { hovertemplate: hovertemplateAttrs(), }; -},{"../../components/colorscale/attributes":112,"../../components/drawing/attributes":126,"../../lib/extend":227,"../../plots/attributes":275,"../../plots/template_attributes":321,"../scatter/attributes":447}],476:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/colorscale/attributes":162,"../../components/drawing/attributes":176,"../../lib/extend":279,"../../plots/attributes":327,"../../plots/template_attributes":368,"../scatter/attributes":494}],523:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -96798,16 +101627,7 @@ module.exports = function calc(gd, trace) { return cd; }; -},{"../scatter/arrays_to_calcdata":446,"../scatter/calc":448,"../scatter/calc_selection":449,"../scatter/colorscale_calc":450,"fast-isnumeric":23}],477:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../scatter/arrays_to_calcdata":493,"../scatter/calc":495,"../scatter/calc_selection":496,"../scatter/colorscale_calc":497,"fast-isnumeric":31}],524:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -96902,15 +101722,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":233,"../scatter/constants":451,"../scatter/fillcolor_defaults":455,"../scatter/line_defaults":460,"../scatter/line_shape_defaults":462,"../scatter/marker_defaults":466,"../scatter/subtypes":472,"../scatter/text_defaults":473,"./attributes":475}],478:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../scatter/constants":498,"../scatter/fillcolor_defaults":502,"../scatter/line_defaults":507,"../scatter/line_shape_defaults":509,"../scatter/marker_defaults":513,"../scatter/subtypes":519,"../scatter/text_defaults":520,"./attributes":522}],525:[function(_dereq_,module,exports){ 'use strict'; module.exports = function eventData(out, pt, trace, cd, pointNumber) { @@ -96934,15 +101746,7 @@ module.exports = function eventData(out, pt, trace, cd, pointNumber) { return out; }; -},{}],479:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],526:[function(_dereq_,module,exports){ 'use strict'; var Axes = _dereq_('../../plots/cartesian/axes'); @@ -96958,15 +101762,7 @@ module.exports = function formatLabels(cdi, trace, fullLayout) { return labels; }; -},{"../../plots/cartesian/axes":279}],480:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian/axes":331}],527:[function(_dereq_,module,exports){ 'use strict'; var scatterHover = _dereq_('../scatter/hover'); @@ -97032,15 +101828,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { return scatterPointData; }; -},{"../scatter/hover":458}],481:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../scatter/hover":505}],528:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -97061,21 +101849,10 @@ module.exports = { basePlotModule: _dereq_('../../plots/ternary'), categories: ['ternary', 'symbols', 'showLegend', 'scatter-like'], meta: { - - } }; -},{"../../plots/ternary":322,"../scatter/marker_colorbar":465,"../scatter/select":469,"../scatter/style":471,"./attributes":475,"./calc":476,"./defaults":477,"./event_data":478,"./format_labels":479,"./hover":480,"./plot":482}],482:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../plots/ternary":369,"../scatter/marker_colorbar":512,"../scatter/select":516,"../scatter/style":518,"./attributes":522,"./calc":523,"./defaults":524,"./event_data":525,"./format_labels":526,"./hover":527,"./plot":529}],529:[function(_dereq_,module,exports){ 'use strict'; var scatterPlot = _dereq_('../scatter/plot'); @@ -97099,19 +101876,12 @@ module.exports = function plot(gd, ternary, moduleCalcData) { scatterPlot(gd, plotinfo, moduleCalcData, scatterLayer); }; -},{"../scatter/plot":468}],483:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../scatter/plot":515}],530:[function(_dereq_,module,exports){ 'use strict'; var boxAttrs = _dereq_('../box/attributes'); var extendFlat = _dereq_('../../lib/extend').extendFlat; +var axisHoverFormat = _dereq_('../../plots/hoverformat_attributes'); module.exports = { y: boxAttrs.y, @@ -97119,44 +101889,37 @@ module.exports = { x0: boxAttrs.x0, y0: boxAttrs.y0, + xhoverformat: axisHoverFormat('x'), + yhoverformat: axisHoverFormat('y'), + name: extendFlat({}, boxAttrs.name, { - }), orientation: extendFlat({}, boxAttrs.orientation, { - }), bandwidth: { valType: 'number', min: 0, - editType: 'calc', - }, scalegroup: { valType: 'string', - dflt: '', editType: 'calc', - }, scalemode: { valType: 'enumerated', values: ['width', 'count'], dflt: 'width', - editType: 'calc', - }, spanmode: { valType: 'enumerated', values: ['soft', 'hard', 'manual'], dflt: 'soft', - editType: 'calc', - }, span: { valType: 'info_array', @@ -97164,42 +101927,32 @@ module.exports = { {valType: 'any', editType: 'calc'}, {valType: 'any', editType: 'calc'} ], - editType: 'calc', - }, line: { color: { valType: 'color', - editType: 'style', - }, width: { valType: 'number', - min: 0, dflt: 2, editType: 'style', - }, editType: 'plot' }, fillcolor: boxAttrs.fillcolor, points: extendFlat({}, boxAttrs.boxpoints, { - }), jitter: extendFlat({}, boxAttrs.jitter, { - }), pointpos: extendFlat({}, boxAttrs.pointpos, { - }), width: extendFlat({}, boxAttrs.width, { - }), marker: boxAttrs.marker, @@ -97211,38 +101964,28 @@ module.exports = { visible: { valType: 'boolean', dflt: false, - editType: 'plot', - }, width: { valType: 'number', min: 0, max: 1, dflt: 0.25, - editType: 'plot', - }, fillcolor: { valType: 'color', - editType: 'style', - }, line: { color: { valType: 'color', - editType: 'style', - }, width: { valType: 'number', min: 0, - editType: 'style', - }, editType: 'style' }, @@ -97253,22 +101996,16 @@ module.exports = { visible: { valType: 'boolean', dflt: false, - editType: 'plot', - }, color: { valType: 'color', - editType: 'style', - }, width: { valType: 'number', min: 0, - editType: 'style', - }, editType: 'plot' }, @@ -97277,9 +102014,7 @@ module.exports = { valType: 'enumerated', values: ['both', 'positive', 'negative'], dflt: 'both', - editType: 'calc', - }, offsetgroup: boxAttrs.offsetgroup, @@ -97293,21 +102028,11 @@ module.exports = { flags: ['violins', 'points', 'kde'], dflt: 'violins+points+kde', extras: ['all'], - editType: 'style', - } }; -},{"../../lib/extend":227,"../box/attributes":353}],484:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib/extend":279,"../../plots/hoverformat_attributes":363,"../box/attributes":400}],531:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -97475,15 +102200,7 @@ function calcSpan(trace, cdi, valAxis, bandwidth) { return spanOut; } -},{"../../constants/numerical":212,"../../lib":233,"../../plots/cartesian/axes":279,"../box/calc":354,"./helpers":487}],485:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/numerical":265,"../../lib":285,"../../plots/cartesian/axes":331,"../box/calc":401,"./helpers":534}],532:[function(_dereq_,module,exports){ 'use strict'; var setPositionOffset = _dereq_('../box/cross_trace_calc').setPositionOffset; @@ -97518,15 +102235,7 @@ module.exports = function crossTraceCalc(gd, plotinfo) { } }; -},{"../box/cross_trace_calc":355}],486:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../box/cross_trace_calc":402}],533:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -97579,15 +102288,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout if(!meanLineVisible) traceOut.meanline = {visible: false}; }; -},{"../../components/color":105,"../../lib":233,"../box/defaults":356,"./attributes":483}],487:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../lib":285,"../box/defaults":403,"./attributes":530}],534:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -97652,15 +102353,7 @@ exports.getKdeValue = function(calcItem, trace, valueDist) { exports.extractVal = function(o) { return o.v; }; -},{"../../lib":233}],488:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],535:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -97668,7 +102361,10 @@ var Axes = _dereq_('../../plots/cartesian/axes'); var boxHoverPoints = _dereq_('../box/hover'); var helpers = _dereq_('./helpers'); -module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLayer) { +module.exports = function hoverPoints(pointData, xval, yval, hovermode, opts) { + if(!opts) opts = {}; + var hoverLayer = opts.hoverLayer; + var cd = pointData.cd; var trace = cd[0].trace; var hoveron = trace.hoveron; @@ -97713,7 +102409,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay kdePointData[pLetter + '0'] = pOnPath[0]; kdePointData[pLetter + '1'] = pOnPath[1]; kdePointData[vLetter + '0'] = kdePointData[vLetter + '1'] = vValPx; - kdePointData[vLetter + 'Label'] = vLetter + ': ' + Axes.hoverLabelText(vAxis, vVal) + ', ' + cd[0].t.labels.kde + ' ' + kdeVal.toFixed(3); + kdePointData[vLetter + 'Label'] = vLetter + ': ' + Axes.hoverLabelText(vAxis, vVal, trace[vLetter + 'hoverformat']) + ', ' + cd[0].t.labels.kde + ' ' + kdeVal.toFixed(3); // move the spike to the KDE point kdePointData.spikeDistance = closeBoxData[0].spikeDistance; @@ -97764,15 +102460,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay return closeData; }; -},{"../../lib":233,"../../plots/cartesian/axes":279,"../box/hover":358,"./helpers":487}],489:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/cartesian/axes":331,"../box/hover":405,"./helpers":534}],536:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -97794,19 +102482,10 @@ module.exports = { basePlotModule: _dereq_('../../plots/cartesian'), categories: ['cartesian', 'svg', 'symbols', 'oriented', 'box-violin', 'showLegend', 'violinLayout', 'zoomScale'], meta: { - } }; -},{"../../plots/cartesian":292,"../box/defaults":356,"../box/select":363,"../scatter/style":471,"./attributes":483,"./calc":484,"./cross_trace_calc":485,"./defaults":486,"./hover":488,"./layout_attributes":490,"./layout_defaults":491,"./plot":492,"./style":493}],490:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian":344,"../box/defaults":403,"../box/select":410,"../scatter/style":518,"./attributes":530,"./calc":531,"./cross_trace_calc":532,"./defaults":533,"./hover":535,"./layout_attributes":537,"./layout_defaults":538,"./plot":539,"./style":540}],537:[function(_dereq_,module,exports){ 'use strict'; var boxLayoutAttrs = _dereq_('../box/layout_attributes'); @@ -97814,25 +102493,14 @@ var extendFlat = _dereq_('../../lib').extendFlat; module.exports = { violinmode: extendFlat({}, boxLayoutAttrs.boxmode, { - }), violingap: extendFlat({}, boxLayoutAttrs.boxgap, { - }), violingroupgap: extendFlat({}, boxLayoutAttrs.boxgroupgap, { - }) }; -},{"../../lib":233,"../box/layout_attributes":360}],491:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../box/layout_attributes":407}],538:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -97846,18 +102514,10 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { boxLayoutDefaults._supply(layoutIn, layoutOut, fullData, coerce, 'violin'); }; -},{"../../lib":233,"../box/layout_defaults":361,"./layout_attributes":490}],492:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../box/layout_defaults":408,"./layout_attributes":537}],539:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Lib = _dereq_('../../lib'); var Drawing = _dereq_('../../components/drawing'); @@ -98036,18 +102696,10 @@ module.exports = function plot(gd, plotinfo, cdViolins, violinLayer) { }); }; -},{"../../components/drawing":127,"../../lib":233,"../box/plot":362,"../scatter/line_points":461,"./helpers":487,"d3":21}],493:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/drawing":177,"../../lib":285,"../box/plot":409,"../scatter/line_points":508,"./helpers":534,"@plotly/d3":20}],540:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Color = _dereq_('../../components/color'); var stylePoints = _dereq_('../scatter/style').stylePoints; @@ -98091,21 +102743,1077 @@ module.exports = function style(gd) { }); }; -},{"../../components/color":105,"../scatter/style":471,"d3":21}],494:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +},{"../../components/color":155,"../scatter/style":518,"@plotly/d3":20}],541:[function(_dereq_,module,exports){ +'use strict'; +var Axes = _dereq_('../plots/cartesian/axes'); +var Lib = _dereq_('../lib'); +var PlotSchema = _dereq_('../plot_api/plot_schema'); +var pointsAccessorFunction = _dereq_('./helpers').pointsAccessorFunction; +var BADNUM = _dereq_('../constants/numerical').BADNUM; + +exports.moduleType = 'transform'; + +exports.name = 'aggregate'; + +var attrs = exports.attributes = { + enabled: { + valType: 'boolean', + dflt: true, + editType: 'calc', + }, + groups: { + // TODO: groupby should support string or array grouping this way too + // currently groupby only allows a grouping array + valType: 'string', + strict: true, + noBlank: true, + arrayOk: true, + dflt: 'x', + editType: 'calc', + }, + aggregations: { + _isLinkedToArray: 'aggregation', + target: { + valType: 'string', + editType: 'calc', + }, + func: { + valType: 'enumerated', + values: ['count', 'sum', 'avg', 'median', 'mode', 'rms', 'stddev', 'min', 'max', 'first', 'last', 'change', 'range'], + dflt: 'first', + editType: 'calc', + }, + funcmode: { + valType: 'enumerated', + values: ['sample', 'population'], + dflt: 'sample', + editType: 'calc', + }, + enabled: { + valType: 'boolean', + dflt: true, + editType: 'calc', + }, + editType: 'calc' + }, + editType: 'calc' +}; + +var aggAttrs = attrs.aggregations; + +/** + * Supply transform attributes defaults + * + * @param {object} transformIn + * object linked to trace.transforms[i] with 'func' set to exports.name + * @param {object} traceOut + * the _fullData trace this transform applies to + * @param {object} layout + * the plot's (not-so-full) layout + * @param {object} traceIn + * the input data trace this transform applies to + * + * @return {object} transformOut + * copy of transformIn that contains attribute defaults + */ +exports.supplyDefaults = function(transformIn, traceOut) { + var transformOut = {}; + var i; + + function coerce(attr, dflt) { + return Lib.coerce(transformIn, transformOut, attrs, attr, dflt); + } + + var enabled = coerce('enabled'); + + if(!enabled) return transformOut; + + /* + * Normally _arrayAttrs is calculated during doCalc, but that comes later. + * Anyway this can change due to *count* aggregations (see below) so it's not + * necessarily the same set. + * + * For performance we turn it into an object of truthy values + * we'll use 1 for arrays we haven't aggregated yet, 0 for finished arrays, + * as distinct from undefined which means this array isn't present in the input + * missing arrays can still be aggregate outputs for *count* aggregations. + */ + var arrayAttrArray = PlotSchema.findArrayAttributes(traceOut); + var arrayAttrs = {}; + for(i = 0; i < arrayAttrArray.length; i++) arrayAttrs[arrayAttrArray[i]] = 1; + + var groups = coerce('groups'); + + if(!Array.isArray(groups)) { + if(!arrayAttrs[groups]) { + transformOut.enabled = false; + return transformOut; + } + arrayAttrs[groups] = 0; + } + + var aggregationsIn = transformIn.aggregations || []; + var aggregationsOut = transformOut.aggregations = new Array(aggregationsIn.length); + var aggregationOut; + + function coercei(attr, dflt) { + return Lib.coerce(aggregationsIn[i], aggregationOut, aggAttrs, attr, dflt); + } + + for(i = 0; i < aggregationsIn.length; i++) { + aggregationOut = {_index: i}; + var target = coercei('target'); + var func = coercei('func'); + var enabledi = coercei('enabled'); + + // add this aggregation to the output only if it's the first instance + // of a valid target attribute - or an unused target attribute with "count" + if(enabledi && target && (arrayAttrs[target] || (func === 'count' && arrayAttrs[target] === undefined))) { + if(func === 'stddev') coercei('funcmode'); + + arrayAttrs[target] = 0; + aggregationsOut[i] = aggregationOut; + } else aggregationsOut[i] = {enabled: false, _index: i}; + } + + // any array attributes we haven't yet covered, fill them with the default aggregation + for(i = 0; i < arrayAttrArray.length; i++) { + if(arrayAttrs[arrayAttrArray[i]]) { + aggregationsOut.push({ + target: arrayAttrArray[i], + func: aggAttrs.func.dflt, + enabled: true, + _index: -1 + }); + } + } + + return transformOut; +}; + + +exports.calcTransform = function(gd, trace, opts) { + if(!opts.enabled) return; + + var groups = opts.groups; + + var groupArray = Lib.getTargetArray(trace, {target: groups}); + if(!groupArray) return; + + var i, vi, groupIndex, newGrouping; + + var groupIndices = {}; + var indexToPoints = {}; + var groupings = []; + + var originalPointsAccessor = pointsAccessorFunction(trace.transforms, opts); + + var len = groupArray.length; + if(trace._length) len = Math.min(len, trace._length); + + for(i = 0; i < len; i++) { + vi = groupArray[i]; + groupIndex = groupIndices[vi]; + if(groupIndex === undefined) { + groupIndices[vi] = groupings.length; + newGrouping = [i]; + groupings.push(newGrouping); + indexToPoints[groupIndices[vi]] = originalPointsAccessor(i); + } else { + groupings[groupIndex].push(i); + indexToPoints[groupIndices[vi]] = (indexToPoints[groupIndices[vi]] || []).concat(originalPointsAccessor(i)); + } + } + + opts._indexToPoints = indexToPoints; + + var aggregations = opts.aggregations; + + for(i = 0; i < aggregations.length; i++) { + aggregateOneArray(gd, trace, groupings, aggregations[i]); + } + + if(typeof groups === 'string') { + aggregateOneArray(gd, trace, groupings, { + target: groups, + func: 'first', + enabled: true + }); + } + + trace._length = groupings.length; +}; + +function aggregateOneArray(gd, trace, groupings, aggregation) { + if(!aggregation.enabled) return; + + var attr = aggregation.target; + var targetNP = Lib.nestedProperty(trace, attr); + var arrayIn = targetNP.get(); + var conversions = Axes.getDataConversions(gd, trace, attr, arrayIn); + var func = getAggregateFunction(aggregation, conversions); + + var arrayOut = new Array(groupings.length); + for(var i = 0; i < groupings.length; i++) { + arrayOut[i] = func(arrayIn, groupings[i]); + } + targetNP.set(arrayOut); + + if(aggregation.func === 'count') { + // count does not depend on an input array, so it's likely not part of _arrayAttrs yet + // but after this transform it most definitely *is* an array attribute. + Lib.pushUnique(trace._arrayAttrs, attr); + } +} + +function getAggregateFunction(opts, conversions) { + var func = opts.func; + var d2c = conversions.d2c; + var c2d = conversions.c2d; + + switch(func) { + // count, first, and last don't depend on anything about the data + // point back to pure functions for performance + case 'count': + return count; + case 'first': + return first; + case 'last': + return last; + + case 'sum': + // This will produce output in all cases even though it's nonsensical + // for date or category data. + return function(array, indices) { + var total = 0; + for(var i = 0; i < indices.length; i++) { + var vi = d2c(array[indices[i]]); + if(vi !== BADNUM) total += vi; + } + return c2d(total); + }; + + case 'avg': + // Generally meaningless for category data but it still does something. + return function(array, indices) { + var total = 0; + var cnt = 0; + for(var i = 0; i < indices.length; i++) { + var vi = d2c(array[indices[i]]); + if(vi !== BADNUM) { + total += vi; + cnt++; + } + } + return cnt ? c2d(total / cnt) : BADNUM; + }; + + case 'min': + return function(array, indices) { + var out = Infinity; + for(var i = 0; i < indices.length; i++) { + var vi = d2c(array[indices[i]]); + if(vi !== BADNUM) out = Math.min(out, vi); + } + return (out === Infinity) ? BADNUM : c2d(out); + }; + + case 'max': + return function(array, indices) { + var out = -Infinity; + for(var i = 0; i < indices.length; i++) { + var vi = d2c(array[indices[i]]); + if(vi !== BADNUM) out = Math.max(out, vi); + } + return (out === -Infinity) ? BADNUM : c2d(out); + }; + + case 'range': + return function(array, indices) { + var min = Infinity; + var max = -Infinity; + for(var i = 0; i < indices.length; i++) { + var vi = d2c(array[indices[i]]); + if(vi !== BADNUM) { + min = Math.min(min, vi); + max = Math.max(max, vi); + } + } + return (max === -Infinity || min === Infinity) ? BADNUM : c2d(max - min); + }; + + case 'change': + return function(array, indices) { + var first = d2c(array[indices[0]]); + var last = d2c(array[indices[indices.length - 1]]); + return (first === BADNUM || last === BADNUM) ? BADNUM : c2d(last - first); + }; + + case 'median': + return function(array, indices) { + var sortCalc = []; + for(var i = 0; i < indices.length; i++) { + var vi = d2c(array[indices[i]]); + if(vi !== BADNUM) sortCalc.push(vi); + } + if(!sortCalc.length) return BADNUM; + sortCalc.sort(Lib.sorterAsc); + var mid = (sortCalc.length - 1) / 2; + return c2d((sortCalc[Math.floor(mid)] + sortCalc[Math.ceil(mid)]) / 2); + }; + + case 'mode': + return function(array, indices) { + var counts = {}; + var maxCnt = 0; + var out = BADNUM; + for(var i = 0; i < indices.length; i++) { + var vi = d2c(array[indices[i]]); + if(vi !== BADNUM) { + var counti = counts[vi] = (counts[vi] || 0) + 1; + if(counti > maxCnt) { + maxCnt = counti; + out = vi; + } + } + } + return maxCnt ? c2d(out) : BADNUM; + }; + + case 'rms': + return function(array, indices) { + var total = 0; + var cnt = 0; + for(var i = 0; i < indices.length; i++) { + var vi = d2c(array[indices[i]]); + if(vi !== BADNUM) { + total += vi * vi; + cnt++; + } + } + return cnt ? c2d(Math.sqrt(total / cnt)) : BADNUM; + }; + + case 'stddev': + return function(array, indices) { + // balance numerical stability with performance: + // so that we call d2c once per element but don't need to + // store them, reference all to the first element + var total = 0; + var total2 = 0; + var cnt = 1; + var v0 = BADNUM; + var i; + for(i = 0; i < indices.length && v0 === BADNUM; i++) { + v0 = d2c(array[indices[i]]); + } + if(v0 === BADNUM) return BADNUM; + + for(; i < indices.length; i++) { + var vi = d2c(array[indices[i]]); + if(vi !== BADNUM) { + var dv = vi - v0; + total += dv; + total2 += dv * dv; + cnt++; + } + } + + // This is population std dev, if we want sample std dev + // we would need (...) / (cnt - 1) + // Also note there's no c2d here - that means for dates the result + // is a number of milliseconds, and for categories it's a number + // of category differences, which is not generically meaningful but + // as in other cases we don't forbid it. + var norm = (opts.funcmode === 'sample') ? (cnt - 1) : cnt; + // this is debatable: should a count of 1 return sample stddev of + // 0 or undefined? + if(!norm) return 0; + return Math.sqrt((total2 - (total * total / cnt)) / norm); + }; + } +} + +function count(array, indices) { + return indices.length; +} + +function first(array, indices) { + return array[indices[0]]; +} + +function last(array, indices) { + return array[indices[indices.length - 1]]; +} + +},{"../constants/numerical":265,"../lib":285,"../plot_api/plot_schema":319,"../plots/cartesian/axes":331,"./helpers":544}],542:[function(_dereq_,module,exports){ +'use strict'; + +var Lib = _dereq_('../lib'); +var Registry = _dereq_('../registry'); +var Axes = _dereq_('../plots/cartesian/axes'); +var pointsAccessorFunction = _dereq_('./helpers').pointsAccessorFunction; + +var filterOps = _dereq_('../constants/filter_ops'); +var COMPARISON_OPS = filterOps.COMPARISON_OPS; +var INTERVAL_OPS = filterOps.INTERVAL_OPS; +var SET_OPS = filterOps.SET_OPS; + +exports.moduleType = 'transform'; + +exports.name = 'filter'; + +exports.attributes = { + enabled: { + valType: 'boolean', + dflt: true, + editType: 'calc', + }, + target: { + valType: 'string', + strict: true, + noBlank: true, + arrayOk: true, + dflt: 'x', + editType: 'calc', + }, + operation: { + valType: 'enumerated', + values: [] + .concat(COMPARISON_OPS) + .concat(INTERVAL_OPS) + .concat(SET_OPS), + dflt: '=', + editType: 'calc', + }, + value: { + valType: 'any', + dflt: 0, + editType: 'calc', + }, + preservegaps: { + valType: 'boolean', + dflt: false, + editType: 'calc', + }, + editType: 'calc' +}; + +exports.supplyDefaults = function(transformIn) { + var transformOut = {}; + + function coerce(attr, dflt) { + return Lib.coerce(transformIn, transformOut, exports.attributes, attr, dflt); + } + + var enabled = coerce('enabled'); + + if(enabled) { + var target = coerce('target'); + + if(Lib.isArrayOrTypedArray(target) && target.length === 0) { + transformOut.enabled = false; + return transformOut; + } + + coerce('preservegaps'); + coerce('operation'); + coerce('value'); + + var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleDefaults'); + handleCalendarDefaults(transformIn, transformOut, 'valuecalendar', null); + handleCalendarDefaults(transformIn, transformOut, 'targetcalendar', null); + } + + return transformOut; +}; + +exports.calcTransform = function(gd, trace, opts) { + if(!opts.enabled) return; + + var targetArray = Lib.getTargetArray(trace, opts); + if(!targetArray) return; + + var target = opts.target; + + var len = targetArray.length; + if(trace._length) len = Math.min(len, trace._length); + + var targetCalendar = opts.targetcalendar; + var arrayAttrs = trace._arrayAttrs; + var preservegaps = opts.preservegaps; + + // even if you provide targetcalendar, if target is a string and there + // is a calendar attribute matching target it will get used instead. + if(typeof target === 'string') { + var attrTargetCalendar = Lib.nestedProperty(trace, target + 'calendar').get(); + if(attrTargetCalendar) targetCalendar = attrTargetCalendar; + } + + var d2c = Axes.getDataToCoordFunc(gd, trace, target, targetArray); + var filterFunc = getFilterFunc(opts, d2c, targetCalendar); + var originalArrays = {}; + var indexToPoints = {}; + var index = 0; + + function forAllAttrs(fn, index) { + for(var j = 0; j < arrayAttrs.length; j++) { + var np = Lib.nestedProperty(trace, arrayAttrs[j]); + fn(np, index); + } + } + + var initFn; + var fillFn; + if(preservegaps) { + initFn = function(np) { + originalArrays[np.astr] = Lib.extendDeep([], np.get()); + np.set(new Array(len)); + }; + fillFn = function(np, index) { + var val = originalArrays[np.astr][index]; + np.get()[index] = val; + }; + } else { + initFn = function(np) { + originalArrays[np.astr] = Lib.extendDeep([], np.get()); + np.set([]); + }; + fillFn = function(np, index) { + var val = originalArrays[np.astr][index]; + np.get().push(val); + }; + } + + // copy all original array attribute values, and clear arrays in trace + forAllAttrs(initFn); + + var originalPointsAccessor = pointsAccessorFunction(trace.transforms, opts); + + // loop through filter array, fill trace arrays if passed + for(var i = 0; i < len; i++) { + var passed = filterFunc(targetArray[i]); + if(passed) { + forAllAttrs(fillFn, i); + indexToPoints[index++] = originalPointsAccessor(i); + } else if(preservegaps) index++; + } + + opts._indexToPoints = indexToPoints; + trace._length = index; +}; + +function getFilterFunc(opts, d2c, targetCalendar) { + var operation = opts.operation; + var value = opts.value; + var hasArrayValue = Array.isArray(value); + + function isOperationIn(array) { + return array.indexOf(operation) !== -1; + } + + var d2cValue = function(v) { return d2c(v, 0, opts.valuecalendar); }; + var d2cTarget = function(v) { return d2c(v, 0, targetCalendar); }; + + var coercedValue; + + if(isOperationIn(COMPARISON_OPS)) { + coercedValue = hasArrayValue ? d2cValue(value[0]) : d2cValue(value); + } else if(isOperationIn(INTERVAL_OPS)) { + coercedValue = hasArrayValue ? + [d2cValue(value[0]), d2cValue(value[1])] : + [d2cValue(value), d2cValue(value)]; + } else if(isOperationIn(SET_OPS)) { + coercedValue = hasArrayValue ? value.map(d2cValue) : [d2cValue(value)]; + } + + switch(operation) { + case '=': + return function(v) { return d2cTarget(v) === coercedValue; }; + + case '!=': + return function(v) { return d2cTarget(v) !== coercedValue; }; + + case '<': + return function(v) { return d2cTarget(v) < coercedValue; }; + + case '<=': + return function(v) { return d2cTarget(v) <= coercedValue; }; + + case '>': + return function(v) { return d2cTarget(v) > coercedValue; }; + + case '>=': + return function(v) { return d2cTarget(v) >= coercedValue; }; + + case '[]': + return function(v) { + var cv = d2cTarget(v); + return cv >= coercedValue[0] && cv <= coercedValue[1]; + }; + + case '()': + return function(v) { + var cv = d2cTarget(v); + return cv > coercedValue[0] && cv < coercedValue[1]; + }; + + case '[)': + return function(v) { + var cv = d2cTarget(v); + return cv >= coercedValue[0] && cv < coercedValue[1]; + }; + + case '(]': + return function(v) { + var cv = d2cTarget(v); + return cv > coercedValue[0] && cv <= coercedValue[1]; + }; + + case '][': + return function(v) { + var cv = d2cTarget(v); + return cv <= coercedValue[0] || cv >= coercedValue[1]; + }; + + case ')(': + return function(v) { + var cv = d2cTarget(v); + return cv < coercedValue[0] || cv > coercedValue[1]; + }; + + case '](': + return function(v) { + var cv = d2cTarget(v); + return cv <= coercedValue[0] || cv > coercedValue[1]; + }; + + case ')[': + return function(v) { + var cv = d2cTarget(v); + return cv < coercedValue[0] || cv >= coercedValue[1]; + }; + + case '{}': + return function(v) { + return coercedValue.indexOf(d2cTarget(v)) !== -1; + }; + + case '}{': + return function(v) { + return coercedValue.indexOf(d2cTarget(v)) === -1; + }; + } +} + +},{"../constants/filter_ops":263,"../lib":285,"../plots/cartesian/axes":331,"../registry":373,"./helpers":544}],543:[function(_dereq_,module,exports){ +'use strict'; + +var Lib = _dereq_('../lib'); +var PlotSchema = _dereq_('../plot_api/plot_schema'); +var Plots = _dereq_('../plots/plots'); +var pointsAccessorFunction = _dereq_('./helpers').pointsAccessorFunction; + +exports.moduleType = 'transform'; + +exports.name = 'groupby'; + +exports.attributes = { + enabled: { + valType: 'boolean', + dflt: true, + editType: 'calc', + }, + groups: { + valType: 'data_array', + dflt: [], + editType: 'calc', + }, + nameformat: { + valType: 'string', + editType: 'calc', + }, + styles: { + _isLinkedToArray: 'style', + target: { + valType: 'string', + editType: 'calc', + }, + value: { + valType: 'any', + dflt: {}, + editType: 'calc', + _compareAsJSON: true + }, + editType: 'calc' + }, + editType: 'calc' +}; + +/** + * Supply transform attributes defaults + * + * @param {object} transformIn + * object linked to trace.transforms[i] with 'type' set to exports.name + * @param {object} traceOut + * the _fullData trace this transform applies to + * @param {object} layout + * the plot's (not-so-full) layout + * @param {object} traceIn + * the input data trace this transform applies to + * + * @return {object} transformOut + * copy of transformIn that contains attribute defaults + */ +exports.supplyDefaults = function(transformIn, traceOut, layout) { + var i; + var transformOut = {}; + + function coerce(attr, dflt) { + return Lib.coerce(transformIn, transformOut, exports.attributes, attr, dflt); + } + + var enabled = coerce('enabled'); + + if(!enabled) return transformOut; + + coerce('groups'); + coerce('nameformat', layout._dataLength > 1 ? '%{group} (%{trace})' : '%{group}'); + + var styleIn = transformIn.styles; + var styleOut = transformOut.styles = []; + + if(styleIn) { + for(i = 0; i < styleIn.length; i++) { + var thisStyle = styleOut[i] = {}; + Lib.coerce(styleIn[i], styleOut[i], exports.attributes.styles, 'target'); + var value = Lib.coerce(styleIn[i], styleOut[i], exports.attributes.styles, 'value'); + + // so that you can edit value in place and have Plotly.react notice it, or + // rebuild it every time and have Plotly.react NOT think it changed: + // use _compareAsJSON to say we should diff the _JSON_value + if(Lib.isPlainObject(value)) thisStyle.value = Lib.extendDeep({}, value); + else if(value) delete thisStyle.value; + } + } + + return transformOut; +}; + + +/** + * Apply transform !!! + * + * @param {array} data + * array of transformed traces (is [fullTrace] upon first transform) + * + * @param {object} state + * state object which includes: + * - transform {object} full transform attributes + * - fullTrace {object} full trace object which is being transformed + * - fullData {array} full pre-transform(s) data array + * - layout {object} the plot's (not-so-full) layout + * + * @return {object} newData + * array of transformed traces + */ +exports.transform = function(data, state) { + var newTraces, i, j; + var newData = []; + + for(i = 0; i < data.length; i++) { + newTraces = transformOne(data[i], state); + + for(j = 0; j < newTraces.length; j++) { + newData.push(newTraces[j]); + } + } + + return newData; +}; + +function transformOne(trace, state) { + var i, j, k, attr, srcArray, groupName, newTrace, transforms, arrayLookup; + var groupNameObj; + + var opts = state.transform; + var transformIndex = state.transformIndex; + var groups = trace.transforms[transformIndex].groups; + var originalPointsAccessor = pointsAccessorFunction(trace.transforms, opts); + + if(!(Lib.isArrayOrTypedArray(groups)) || groups.length === 0) { + return [trace]; + } + + var groupNames = Lib.filterUnique(groups); + var newData = new Array(groupNames.length); + var len = groups.length; + + var arrayAttrs = PlotSchema.findArrayAttributes(trace); + + var styles = opts.styles || []; + var styleLookup = {}; + for(i = 0; i < styles.length; i++) { + styleLookup[styles[i].target] = styles[i].value; + } + + if(opts.styles) { + groupNameObj = Lib.keyedContainer(opts, 'styles', 'target', 'value.name'); + } + + // An index to map group name --> expanded trace index + var indexLookup = {}; + var indexCnts = {}; + + for(i = 0; i < groupNames.length; i++) { + groupName = groupNames[i]; + indexLookup[groupName] = i; + indexCnts[groupName] = 0; + + // Start with a deep extend that just copies array references. + newTrace = newData[i] = Lib.extendDeepNoArrays({}, trace); + newTrace._group = groupName; + newTrace.transforms[transformIndex]._indexToPoints = {}; + + var suppliedName = null; + if(groupNameObj) { + suppliedName = groupNameObj.get(groupName); + } + + if(suppliedName || suppliedName === '') { + newTrace.name = suppliedName; + } else { + newTrace.name = Lib.templateString(opts.nameformat, { + trace: trace.name, + group: groupName + }); + } + + // In order for groups to apply correctly to other transform data (e.g. + // a filter transform), we have to break the connection and clone the + // transforms so that each group writes grouped values into a different + // destination. This function does not break the array reference + // connection between the split transforms it creates. That's handled in + // initialize, which creates a new empty array for each arrayAttr. + transforms = newTrace.transforms; + newTrace.transforms = []; + for(j = 0; j < transforms.length; j++) { + newTrace.transforms[j] = Lib.extendDeepNoArrays({}, transforms[j]); + } + + // Initialize empty arrays for the arrayAttrs, to be split in the next step + for(j = 0; j < arrayAttrs.length; j++) { + Lib.nestedProperty(newTrace, arrayAttrs[j]).set([]); + } + } + + // For each array attribute including those nested inside this and other + // transforms (small note that we technically only need to do this for + // transforms that have not yet been applied): + for(k = 0; k < arrayAttrs.length; k++) { + attr = arrayAttrs[k]; + + // Cache all the arrays to which we'll push: + for(j = 0, arrayLookup = []; j < groupNames.length; j++) { + arrayLookup[j] = Lib.nestedProperty(newData[j], attr).get(); + } + + // Get the input data: + srcArray = Lib.nestedProperty(trace, attr).get(); + + // Send each data point to the appropriate expanded trace: + for(j = 0; j < len; j++) { + // Map group data --> trace index --> array and push data onto it + arrayLookup[indexLookup[groups[j]]].push(srcArray[j]); + } + } + + for(j = 0; j < len; j++) { + newTrace = newData[indexLookup[groups[j]]]; + + var indexToPoints = newTrace.transforms[transformIndex]._indexToPoints; + indexToPoints[indexCnts[groups[j]]] = originalPointsAccessor(j); + indexCnts[groups[j]]++; + } + + for(i = 0; i < groupNames.length; i++) { + groupName = groupNames[i]; + newTrace = newData[i]; + + Plots.clearExpandedTraceDefaultColors(newTrace); + + // there's no need to coerce styleLookup[groupName] here + // as another round of supplyDefaults is done on the transformed traces + newTrace = Lib.extendDeepNoArrays(newTrace, styleLookup[groupName] || {}); + } + + return newData; +} + +},{"../lib":285,"../plot_api/plot_schema":319,"../plots/plots":366,"./helpers":544}],544:[function(_dereq_,module,exports){ +'use strict'; + +exports.pointsAccessorFunction = function(transforms, opts) { + var tr; + var prevIndexToPoints; + for(var i = 0; i < transforms.length; i++) { + tr = transforms[i]; + if(tr === opts) break; + if(!tr._indexToPoints || tr.enabled === false) continue; + prevIndexToPoints = tr._indexToPoints; + } + var originalPointsAccessor = prevIndexToPoints ? + function(i) {return prevIndexToPoints[i];} : + function(i) {return [i];}; + return originalPointsAccessor; +}; + +},{}],545:[function(_dereq_,module,exports){ +'use strict'; + +var Lib = _dereq_('../lib'); +var Axes = _dereq_('../plots/cartesian/axes'); +var pointsAccessorFunction = _dereq_('./helpers').pointsAccessorFunction; + +var BADNUM = _dereq_('../constants/numerical').BADNUM; + +exports.moduleType = 'transform'; + +exports.name = 'sort'; + +exports.attributes = { + enabled: { + valType: 'boolean', + dflt: true, + editType: 'calc', + }, + target: { + valType: 'string', + strict: true, + noBlank: true, + arrayOk: true, + dflt: 'x', + editType: 'calc', + }, + order: { + valType: 'enumerated', + values: ['ascending', 'descending'], + dflt: 'ascending', + editType: 'calc', + }, + editType: 'calc' +}; + +exports.supplyDefaults = function(transformIn) { + var transformOut = {}; + + function coerce(attr, dflt) { + return Lib.coerce(transformIn, transformOut, exports.attributes, attr, dflt); + } + + var enabled = coerce('enabled'); + + if(enabled) { + coerce('target'); + coerce('order'); + } + + return transformOut; +}; + +exports.calcTransform = function(gd, trace, opts) { + if(!opts.enabled) return; + + var targetArray = Lib.getTargetArray(trace, opts); + if(!targetArray) return; + + var target = opts.target; + + var len = targetArray.length; + if(trace._length) len = Math.min(len, trace._length); + + var arrayAttrs = trace._arrayAttrs; + var d2c = Axes.getDataToCoordFunc(gd, trace, target, targetArray); + var indices = getIndices(opts, targetArray, d2c, len); + var originalPointsAccessor = pointsAccessorFunction(trace.transforms, opts); + var indexToPoints = {}; + var i, j; + + for(i = 0; i < arrayAttrs.length; i++) { + var np = Lib.nestedProperty(trace, arrayAttrs[i]); + var arrayOld = np.get(); + var arrayNew = new Array(len); + + for(j = 0; j < len; j++) { + arrayNew[j] = arrayOld[indices[j]]; + } + + np.set(arrayNew); + } + + for(j = 0; j < len; j++) { + indexToPoints[j] = originalPointsAccessor(indices[j]); + } + + opts._indexToPoints = indexToPoints; + trace._length = len; +}; + +function getIndices(opts, targetArray, d2c, len) { + var sortedArray = new Array(len); + var indices = new Array(len); + var i; + + for(i = 0; i < len; i++) { + sortedArray[i] = {v: targetArray[i], i: i}; + } + + sortedArray.sort(getSortFunc(opts, d2c)); + + for(i = 0; i < len; i++) { + indices[i] = sortedArray[i].i; + } + + return indices; +} + +function getSortFunc(opts, d2c) { + switch(opts.order) { + case 'ascending': + return function(a, b) { + var ac = d2c(a.v); + var bc = d2c(b.v); + if(ac === BADNUM) { + return 1; + } + if(bc === BADNUM) { + return -1; + } + return ac - bc; + }; + case 'descending': + return function(a, b) { + var ac = d2c(a.v); + var bc = d2c(b.v); + if(ac === BADNUM) { + return 1; + } + if(bc === BADNUM) { + return -1; + } + return bc - ac; + }; + } +} + +},{"../constants/numerical":265,"../lib":285,"../plots/cartesian/axes":331,"./helpers":544}],546:[function(_dereq_,module,exports){ 'use strict'; // package version injected by `npm run preprocess` -exports.version = '1.58.4'; +exports.version = '2.0.0'; -},{}]},{},[11])(11) +},{}]},{},[15])(15) }); var locale={moduleType:"locale",name:"de",dictionary:{Autoscale:"Automatische Skalierung","Box Select":"Rechteckauswahl","Click to enter Colorscale title":"Klicken, um den Farbskalatitel einzugeben","Click to enter Component A title":"Klicken, um den Titel der Komponente A einzugeben","Click to enter Component B title":"Klicken, um den Titel der Komponente B einzugeben","Click to enter Component C title":"Klicken, um den Titel der Komponente C einzugeben","Click to enter Plot title":"Klicken, um den Titel des Graphen einzugeben","Click to enter X axis title":"Klicken, um den Titel der X-Achse einzugeben","Click to enter Y axis title":"Klicken, um den Titel der Y-Achse einzugeben","Compare data on hover":"\xdcber die Daten fahren, um sie zu vergleichen","Double-click on legend to isolate one trace":"Daten isolieren durch Doppelklick in der Legende","Double-click to zoom back out":"Herauszoomen durch Doppelklick","Download plot as a png":"Graphen als PNG herunterladen","Download plot":"Graphen herunterladen","Edit in Chart Studio":"Im Chart Studio bearbeiten","IE only supports svg. Changing format to svg.":"IE unterst\xfctzt nur SVG-Dateien. Format wird zu SVG gewechselt.","Lasso Select":"Lassoauswahl","Orbital rotation":"Orbitalrotation",Pan:"Verschieben","Produced with Plotly":"Erstellt mit Plotly",Reset:"Zur\xfccksetzen","Reset axes":"Achsen zur\xfccksetzen","Reset camera to default":"Kamera auf Standard zur\xfccksetzen","Reset camera to last save":"Kamera auf letzte Speicherung zur\xfccksetzen","Reset view":"Ansicht zur\xfccksetzen","Reset views":"Ansichten zur\xfccksetzen","Show closest data on hover":"Zeige n\xe4heste Daten beim \xdcberfahren","Snapshot succeeded":"Snapshot erfolgreich","Sorry, there was a problem downloading your snapshot!":"Es gab ein Problem beim Herunterladen des Snapshots","Taking snapshot - this may take a few seconds":"Erstelle einen Snapshot - dies kann einige Sekunden dauern",Zoom:"Zoom","Zoom in":"Hineinzoomen","Zoom out":"Herauszoomen","close:":"Schluss:",trace:"Datenspur","lat:":"Lat.:","lon:":"Lon.:","q1:":"q1:","q3:":"q3:","source:":"Quelle:","target:":"Ziel:","lower fence:":"Untere Schranke:","upper fence:":"Obere Schranke:","max:":"Max.:","mean \xb1 \u03c3:":"Mittelwert \xb1 \u03c3:","mean:":"Mittelwert:","median:":"Median:","min:":"Min.:","Turntable rotation":"Drehscheibenorbit","Toggle Spike Lines":"Bezugslinien an-/abschalten","open:":"Er\xf6ffnung:","high:":"H\xf6chstkurs:","low:":"Tiefstkurs:","Toggle show closest data on hover":"Anzeige der n\xe4hesten Daten an-/abschalten","incoming flow count:":"Anzahl eingehender Verbindungen:","outgoing flow count:":"Anzahl ausgehender Verbindungen:","kde:":"Dichte:"},format:{days:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"],shortDays:["So","Mo","Di","Mi","Do","Fr","Sa"],months:["Januar","Februar","M\xe4rz","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],shortMonths:["Jan","Feb","M\xe4r","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"],date:"%d.%m.%Y",decimal:",",thousands:"."}};"undefined"==typeof Plotly?(window.PlotlyLocales=window.PlotlyLocales||[],window.PlotlyLocales.push(locale)):Plotly.register(locale); diff --git a/static/babybuddy/js/graph.09e32032c8ef.js.gz b/static/babybuddy/js/graph.09e32032c8ef.js.gz new file mode 100644 index 00000000..62dd672b Binary files /dev/null and b/static/babybuddy/js/graph.09e32032c8ef.js.gz differ diff --git a/static/babybuddy/js/graph.455350929c2f.js.gz b/static/babybuddy/js/graph.455350929c2f.js.gz deleted file mode 100644 index 3c37ceaa..00000000 Binary files a/static/babybuddy/js/graph.455350929c2f.js.gz and /dev/null differ diff --git a/static/babybuddy/js/graph.js b/static/babybuddy/js/graph.js index 07da5dcb..4a156db9 100644 --- a/static/babybuddy/js/graph.js +++ b/static/babybuddy/js/graph.js @@ -1,6 +1,6 @@ /** -* plotly.js (cartesian) v1.58.4 -* Copyright 2012-2020, Plotly, Inc. +* plotly.js (cartesian) v2.0.0 +* Copyright 2012-2021, Plotly, Inc. * All rights reserved. * Licensed under the MIT license */ @@ -72,3694 +72,126 @@ for(var selector in rules) { Lib.addStyleRule(fullSelector, rules[selector]); } -},{"../src/lib":233}],2:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +},{"../src/lib":285}],2:[function(_dereq_,module,exports){ +'use strict'; +module.exports = _dereq_('../src/transforms/aggregate'); + +},{"../src/transforms/aggregate":541}],3:[function(_dereq_,module,exports){ 'use strict'; module.exports = _dereq_('../src/traces/bar'); -},{"../src/traces/bar":344}],3:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../src/traces/bar":391}],4:[function(_dereq_,module,exports){ 'use strict'; module.exports = _dereq_('../src/traces/box'); -},{"../src/traces/box":359}],4:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +},{"../src/traces/box":406}],5:[function(_dereq_,module,exports){ +'use strict'; +module.exports = _dereq_('../src/components/calendars'); + +},{"../src/components/calendars":153}],6:[function(_dereq_,module,exports){ 'use strict'; module.exports = _dereq_('../src/traces/contour'); -},{"../src/traces/contour":379}],5:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../src/traces/contour":426}],7:[function(_dereq_,module,exports){ 'use strict'; module.exports = _dereq_('../src/core'); -},{"../src/core":214}],6:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +},{"../src/core":267}],8:[function(_dereq_,module,exports){ +'use strict'; +module.exports = _dereq_('../src/transforms/filter'); + +},{"../src/transforms/filter":542}],9:[function(_dereq_,module,exports){ +'use strict'; + +module.exports = _dereq_('../src/transforms/groupby'); + +},{"../src/transforms/groupby":543}],10:[function(_dereq_,module,exports){ 'use strict'; module.exports = _dereq_('../src/traces/heatmap'); -},{"../src/traces/heatmap":395}],7:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../src/traces/heatmap":442}],11:[function(_dereq_,module,exports){ 'use strict'; module.exports = _dereq_('../src/traces/histogram'); -},{"../src/traces/histogram":413}],8:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../src/traces/histogram":460}],12:[function(_dereq_,module,exports){ 'use strict'; module.exports = _dereq_('../src/traces/histogram2d'); -},{"../src/traces/histogram2d":419}],9:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../src/traces/histogram2d":466}],13:[function(_dereq_,module,exports){ 'use strict'; module.exports = _dereq_('../src/traces/histogram2dcontour'); -},{"../src/traces/histogram2dcontour":423}],10:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../src/traces/histogram2dcontour":470}],14:[function(_dereq_,module,exports){ 'use strict'; module.exports = _dereq_('../src/traces/image'); -},{"../src/traces/image":431}],11:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../src/traces/image":478}],15:[function(_dereq_,module,exports){ 'use strict'; var Plotly = _dereq_('./core'); Plotly.register([ + // traces _dereq_('./bar'), _dereq_('./box'), _dereq_('./heatmap'), _dereq_('./histogram'), _dereq_('./histogram2d'), _dereq_('./histogram2dcontour'), - _dereq_('./image'), - _dereq_('./pie'), _dereq_('./contour'), _dereq_('./scatterternary'), - _dereq_('./violin') + _dereq_('./violin'), + _dereq_('./image'), + _dereq_('./pie'), + + // transforms + _dereq_('./aggregate'), + _dereq_('./filter'), + _dereq_('./groupby'), + _dereq_('./sort'), + + // components + _dereq_('./calendars'), ]); module.exports = Plotly; -},{"./bar":2,"./box":3,"./contour":4,"./core":5,"./heatmap":6,"./histogram":7,"./histogram2d":8,"./histogram2dcontour":9,"./image":10,"./pie":12,"./scatterternary":13,"./violin":14}],12:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"./aggregate":2,"./bar":3,"./box":4,"./calendars":5,"./contour":6,"./core":7,"./filter":8,"./groupby":9,"./heatmap":10,"./histogram":11,"./histogram2d":12,"./histogram2dcontour":13,"./image":14,"./pie":16,"./scatterternary":17,"./sort":18,"./violin":19}],16:[function(_dereq_,module,exports){ 'use strict'; module.exports = _dereq_('../src/traces/pie'); -},{"../src/traces/pie":440}],13:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../src/traces/pie":487}],17:[function(_dereq_,module,exports){ 'use strict'; module.exports = _dereq_('../src/traces/scatterternary'); -},{"../src/traces/scatterternary":481}],14:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +},{"../src/traces/scatterternary":528}],18:[function(_dereq_,module,exports){ +'use strict'; +module.exports = _dereq_('../src/transforms/sort'); + +},{"../src/transforms/sort":545}],19:[function(_dereq_,module,exports){ 'use strict'; module.exports = _dereq_('../src/traces/violin'); -},{"../src/traces/violin":489}],15:[function(_dereq_,module,exports){ -'use strict' - -exports.byteLength = byteLength -exports.toByteArray = toByteArray -exports.fromByteArray = fromByteArray - -var lookup = [] -var revLookup = [] -var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array - -var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' -for (var i = 0, len = code.length; i < len; ++i) { - lookup[i] = code[i] - revLookup[code.charCodeAt(i)] = i -} - -// Support decoding URL-safe base64 strings, as Node.js does. -// See: https://en.wikipedia.org/wiki/Base64#URL_applications -revLookup['-'.charCodeAt(0)] = 62 -revLookup['_'.charCodeAt(0)] = 63 - -function getLens (b64) { - var len = b64.length - - if (len % 4 > 0) { - throw new Error('Invalid string. Length must be a multiple of 4') - } - - // Trim off extra bytes after placeholder bytes are found - // See: https://github.com/beatgammit/base64-js/issues/42 - var validLen = b64.indexOf('=') - if (validLen === -1) validLen = len - - var placeHoldersLen = validLen === len - ? 0 - : 4 - (validLen % 4) - - return [validLen, placeHoldersLen] -} - -// base64 is 4/3 + up to two characters of the original data -function byteLength (b64) { - var lens = getLens(b64) - var validLen = lens[0] - var placeHoldersLen = lens[1] - return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen -} - -function _byteLength (b64, validLen, placeHoldersLen) { - return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen -} - -function toByteArray (b64) { - var tmp - var lens = getLens(b64) - var validLen = lens[0] - var placeHoldersLen = lens[1] - - var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) - - var curByte = 0 - - // if there are placeholders, only get up to the last complete 4 chars - var len = placeHoldersLen > 0 - ? validLen - 4 - : validLen - - var i - for (i = 0; i < len; i += 4) { - tmp = - (revLookup[b64.charCodeAt(i)] << 18) | - (revLookup[b64.charCodeAt(i + 1)] << 12) | - (revLookup[b64.charCodeAt(i + 2)] << 6) | - revLookup[b64.charCodeAt(i + 3)] - arr[curByte++] = (tmp >> 16) & 0xFF - arr[curByte++] = (tmp >> 8) & 0xFF - arr[curByte++] = tmp & 0xFF - } - - if (placeHoldersLen === 2) { - tmp = - (revLookup[b64.charCodeAt(i)] << 2) | - (revLookup[b64.charCodeAt(i + 1)] >> 4) - arr[curByte++] = tmp & 0xFF - } - - if (placeHoldersLen === 1) { - tmp = - (revLookup[b64.charCodeAt(i)] << 10) | - (revLookup[b64.charCodeAt(i + 1)] << 4) | - (revLookup[b64.charCodeAt(i + 2)] >> 2) - arr[curByte++] = (tmp >> 8) & 0xFF - arr[curByte++] = tmp & 0xFF - } - - return arr -} - -function tripletToBase64 (num) { - return lookup[num >> 18 & 0x3F] + - lookup[num >> 12 & 0x3F] + - lookup[num >> 6 & 0x3F] + - lookup[num & 0x3F] -} - -function encodeChunk (uint8, start, end) { - var tmp - var output = [] - for (var i = start; i < end; i += 3) { - tmp = - ((uint8[i] << 16) & 0xFF0000) + - ((uint8[i + 1] << 8) & 0xFF00) + - (uint8[i + 2] & 0xFF) - output.push(tripletToBase64(tmp)) - } - return output.join('') -} - -function fromByteArray (uint8) { - var tmp - var len = uint8.length - var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes - var parts = [] - var maxChunkLength = 16383 // must be multiple of 3 - - // go through the array every three bytes, we'll deal with trailing stuff later - for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { - parts.push(encodeChunk( - uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) - )) - } - - // pad the end with zeros, but make sure to not forget the extra bytes - if (extraBytes === 1) { - tmp = uint8[len - 1] - parts.push( - lookup[tmp >> 2] + - lookup[(tmp << 4) & 0x3F] + - '==' - ) - } else if (extraBytes === 2) { - tmp = (uint8[len - 2] << 8) + uint8[len - 1] - parts.push( - lookup[tmp >> 10] + - lookup[(tmp >> 4) & 0x3F] + - lookup[(tmp << 2) & 0x3F] + - '=' - ) - } - - return parts.join('') -} - -},{}],16:[function(_dereq_,module,exports){ - -},{}],17:[function(_dereq_,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; - -var R = typeof Reflect === 'object' ? Reflect : null -var ReflectApply = R && typeof R.apply === 'function' - ? R.apply - : function ReflectApply(target, receiver, args) { - return Function.prototype.apply.call(target, receiver, args); - } - -var ReflectOwnKeys -if (R && typeof R.ownKeys === 'function') { - ReflectOwnKeys = R.ownKeys -} else if (Object.getOwnPropertySymbols) { - ReflectOwnKeys = function ReflectOwnKeys(target) { - return Object.getOwnPropertyNames(target) - .concat(Object.getOwnPropertySymbols(target)); - }; -} else { - ReflectOwnKeys = function ReflectOwnKeys(target) { - return Object.getOwnPropertyNames(target); - }; -} - -function ProcessEmitWarning(warning) { - if (console && console.warn) console.warn(warning); -} - -var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) { - return value !== value; -} - -function EventEmitter() { - EventEmitter.init.call(this); -} -module.exports = EventEmitter; -module.exports.once = once; - -// Backwards-compat with node 0.10.x -EventEmitter.EventEmitter = EventEmitter; - -EventEmitter.prototype._events = undefined; -EventEmitter.prototype._eventsCount = 0; -EventEmitter.prototype._maxListeners = undefined; - -// By default EventEmitters will print a warning if more than 10 listeners are -// added to it. This is a useful default which helps finding memory leaks. -var defaultMaxListeners = 10; - -function checkListener(listener) { - if (typeof listener !== 'function') { - throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); - } -} - -Object.defineProperty(EventEmitter, 'defaultMaxListeners', { - enumerable: true, - get: function() { - return defaultMaxListeners; - }, - set: function(arg) { - if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) { - throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.'); - } - defaultMaxListeners = arg; - } -}); - -EventEmitter.init = function() { - - if (this._events === undefined || - this._events === Object.getPrototypeOf(this)._events) { - this._events = Object.create(null); - this._eventsCount = 0; - } - - this._maxListeners = this._maxListeners || undefined; -}; - -// Obviously not all Emitters should be limited to 10. This function allows -// that to be increased. Set to zero for unlimited. -EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { - if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) { - throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.'); - } - this._maxListeners = n; - return this; -}; - -function _getMaxListeners(that) { - if (that._maxListeners === undefined) - return EventEmitter.defaultMaxListeners; - return that._maxListeners; -} - -EventEmitter.prototype.getMaxListeners = function getMaxListeners() { - return _getMaxListeners(this); -}; - -EventEmitter.prototype.emit = function emit(type) { - var args = []; - for (var i = 1; i < arguments.length; i++) args.push(arguments[i]); - var doError = (type === 'error'); - - var events = this._events; - if (events !== undefined) - doError = (doError && events.error === undefined); - else if (!doError) - return false; - - // If there is no 'error' event listener then throw. - if (doError) { - var er; - if (args.length > 0) - er = args[0]; - if (er instanceof Error) { - // Note: The comments on the `throw` lines are intentional, they show - // up in Node's output if this results in an unhandled exception. - throw er; // Unhandled 'error' event - } - // At least give some kind of context to the user - var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : '')); - err.context = er; - throw err; // Unhandled 'error' event - } - - var handler = events[type]; - - if (handler === undefined) - return false; - - if (typeof handler === 'function') { - ReflectApply(handler, this, args); - } else { - var len = handler.length; - var listeners = arrayClone(handler, len); - for (var i = 0; i < len; ++i) - ReflectApply(listeners[i], this, args); - } - - return true; -}; - -function _addListener(target, type, listener, prepend) { - var m; - var events; - var existing; - - checkListener(listener); - - events = target._events; - if (events === undefined) { - events = target._events = Object.create(null); - target._eventsCount = 0; - } else { - // To avoid recursion in the case that type === "newListener"! Before - // adding it to the listeners, first emit "newListener". - if (events.newListener !== undefined) { - target.emit('newListener', type, - listener.listener ? listener.listener : listener); - - // Re-assign `events` because a newListener handler could have caused the - // this._events to be assigned to a new object - events = target._events; - } - existing = events[type]; - } - - if (existing === undefined) { - // Optimize the case of one listener. Don't need the extra array object. - existing = events[type] = listener; - ++target._eventsCount; - } else { - if (typeof existing === 'function') { - // Adding the second element, need to change to array. - existing = events[type] = - prepend ? [listener, existing] : [existing, listener]; - // If we've already got an array, just append. - } else if (prepend) { - existing.unshift(listener); - } else { - existing.push(listener); - } - - // Check for listener leak - m = _getMaxListeners(target); - if (m > 0 && existing.length > m && !existing.warned) { - existing.warned = true; - // No error code for this since it is a Warning - // eslint-disable-next-line no-restricted-syntax - var w = new Error('Possible EventEmitter memory leak detected. ' + - existing.length + ' ' + String(type) + ' listeners ' + - 'added. Use emitter.setMaxListeners() to ' + - 'increase limit'); - w.name = 'MaxListenersExceededWarning'; - w.emitter = target; - w.type = type; - w.count = existing.length; - ProcessEmitWarning(w); - } - } - - return target; -} - -EventEmitter.prototype.addListener = function addListener(type, listener) { - return _addListener(this, type, listener, false); -}; - -EventEmitter.prototype.on = EventEmitter.prototype.addListener; - -EventEmitter.prototype.prependListener = - function prependListener(type, listener) { - return _addListener(this, type, listener, true); - }; - -function onceWrapper() { - if (!this.fired) { - this.target.removeListener(this.type, this.wrapFn); - this.fired = true; - if (arguments.length === 0) - return this.listener.call(this.target); - return this.listener.apply(this.target, arguments); - } -} - -function _onceWrap(target, type, listener) { - var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener }; - var wrapped = onceWrapper.bind(state); - wrapped.listener = listener; - state.wrapFn = wrapped; - return wrapped; -} - -EventEmitter.prototype.once = function once(type, listener) { - checkListener(listener); - this.on(type, _onceWrap(this, type, listener)); - return this; -}; - -EventEmitter.prototype.prependOnceListener = - function prependOnceListener(type, listener) { - checkListener(listener); - this.prependListener(type, _onceWrap(this, type, listener)); - return this; - }; - -// Emits a 'removeListener' event if and only if the listener was removed. -EventEmitter.prototype.removeListener = - function removeListener(type, listener) { - var list, events, position, i, originalListener; - - checkListener(listener); - - events = this._events; - if (events === undefined) - return this; - - list = events[type]; - if (list === undefined) - return this; - - if (list === listener || list.listener === listener) { - if (--this._eventsCount === 0) - this._events = Object.create(null); - else { - delete events[type]; - if (events.removeListener) - this.emit('removeListener', type, list.listener || listener); - } - } else if (typeof list !== 'function') { - position = -1; - - for (i = list.length - 1; i >= 0; i--) { - if (list[i] === listener || list[i].listener === listener) { - originalListener = list[i].listener; - position = i; - break; - } - } - - if (position < 0) - return this; - - if (position === 0) - list.shift(); - else { - spliceOne(list, position); - } - - if (list.length === 1) - events[type] = list[0]; - - if (events.removeListener !== undefined) - this.emit('removeListener', type, originalListener || listener); - } - - return this; - }; - -EventEmitter.prototype.off = EventEmitter.prototype.removeListener; - -EventEmitter.prototype.removeAllListeners = - function removeAllListeners(type) { - var listeners, events, i; - - events = this._events; - if (events === undefined) - return this; - - // not listening for removeListener, no need to emit - if (events.removeListener === undefined) { - if (arguments.length === 0) { - this._events = Object.create(null); - this._eventsCount = 0; - } else if (events[type] !== undefined) { - if (--this._eventsCount === 0) - this._events = Object.create(null); - else - delete events[type]; - } - return this; - } - - // emit removeListener for all listeners on all events - if (arguments.length === 0) { - var keys = Object.keys(events); - var key; - for (i = 0; i < keys.length; ++i) { - key = keys[i]; - if (key === 'removeListener') continue; - this.removeAllListeners(key); - } - this.removeAllListeners('removeListener'); - this._events = Object.create(null); - this._eventsCount = 0; - return this; - } - - listeners = events[type]; - - if (typeof listeners === 'function') { - this.removeListener(type, listeners); - } else if (listeners !== undefined) { - // LIFO order - for (i = listeners.length - 1; i >= 0; i--) { - this.removeListener(type, listeners[i]); - } - } - - return this; - }; - -function _listeners(target, type, unwrap) { - var events = target._events; - - if (events === undefined) - return []; - - var evlistener = events[type]; - if (evlistener === undefined) - return []; - - if (typeof evlistener === 'function') - return unwrap ? [evlistener.listener || evlistener] : [evlistener]; - - return unwrap ? - unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length); -} - -EventEmitter.prototype.listeners = function listeners(type) { - return _listeners(this, type, true); -}; - -EventEmitter.prototype.rawListeners = function rawListeners(type) { - return _listeners(this, type, false); -}; - -EventEmitter.listenerCount = function(emitter, type) { - if (typeof emitter.listenerCount === 'function') { - return emitter.listenerCount(type); - } else { - return listenerCount.call(emitter, type); - } -}; - -EventEmitter.prototype.listenerCount = listenerCount; -function listenerCount(type) { - var events = this._events; - - if (events !== undefined) { - var evlistener = events[type]; - - if (typeof evlistener === 'function') { - return 1; - } else if (evlistener !== undefined) { - return evlistener.length; - } - } - - return 0; -} - -EventEmitter.prototype.eventNames = function eventNames() { - return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []; -}; - -function arrayClone(arr, n) { - var copy = new Array(n); - for (var i = 0; i < n; ++i) - copy[i] = arr[i]; - return copy; -} - -function spliceOne(list, index) { - for (; index + 1 < list.length; index++) - list[index] = list[index + 1]; - list.pop(); -} - -function unwrapListeners(arr) { - var ret = new Array(arr.length); - for (var i = 0; i < ret.length; ++i) { - ret[i] = arr[i].listener || arr[i]; - } - return ret; -} - -function once(emitter, name) { - return new Promise(function (resolve, reject) { - function eventListener() { - if (errorListener !== undefined) { - emitter.removeListener('error', errorListener); - } - resolve([].slice.call(arguments)); - }; - var errorListener; - - // Adding an error listener is not optional because - // if an error is thrown on an event emitter we cannot - // guarantee that the actual event we are waiting will - // be fired. The result could be a silent way to create - // memory or file descriptor leaks, which is something - // we should avoid. - if (name !== 'error') { - errorListener = function errorListener(err) { - emitter.removeListener(name, eventListener); - reject(err); - }; - - emitter.once('error', errorListener); - } - - emitter.once(name, eventListener); - }); -} - -},{}],18:[function(_dereq_,module,exports){ -(function (Buffer){(function (){ -/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ -/* eslint-disable no-proto */ - -'use strict' - -var base64 = _dereq_('base64-js') -var ieee754 = _dereq_('ieee754') - -exports.Buffer = Buffer -exports.SlowBuffer = SlowBuffer -exports.INSPECT_MAX_BYTES = 50 - -var K_MAX_LENGTH = 0x7fffffff -exports.kMaxLength = K_MAX_LENGTH - -/** - * If `Buffer.TYPED_ARRAY_SUPPORT`: - * === true Use Uint8Array implementation (fastest) - * === false Print warning and recommend using `buffer` v4.x which has an Object - * implementation (most compatible, even IE6) - * - * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, - * Opera 11.6+, iOS 4.2+. - * - * We report that the browser does not support typed arrays if the are not subclassable - * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` - * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support - * for __proto__ and has a buggy typed array implementation. - */ -Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() - -if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && - typeof console.error === 'function') { - console.error( - 'This browser lacks typed array (Uint8Array) support which is required by ' + - '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' - ) -} - -function typedArraySupport () { - // Can typed array instances can be augmented? - try { - var arr = new Uint8Array(1) - arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } } - return arr.foo() === 42 - } catch (e) { - return false - } -} - -Object.defineProperty(Buffer.prototype, 'parent', { - enumerable: true, - get: function () { - if (!Buffer.isBuffer(this)) return undefined - return this.buffer - } -}) - -Object.defineProperty(Buffer.prototype, 'offset', { - enumerable: true, - get: function () { - if (!Buffer.isBuffer(this)) return undefined - return this.byteOffset - } -}) - -function createBuffer (length) { - if (length > K_MAX_LENGTH) { - throw new RangeError('The value "' + length + '" is invalid for option "size"') - } - // Return an augmented `Uint8Array` instance - var buf = new Uint8Array(length) - buf.__proto__ = Buffer.prototype - return buf -} - -/** - * The Buffer constructor returns instances of `Uint8Array` that have their - * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of - * `Uint8Array`, so the returned instances will have all the node `Buffer` methods - * and the `Uint8Array` methods. Square bracket notation works as expected -- it - * returns a single octet. - * - * The `Uint8Array` prototype remains unmodified. - */ - -function Buffer (arg, encodingOrOffset, length) { - // Common case. - if (typeof arg === 'number') { - if (typeof encodingOrOffset === 'string') { - throw new TypeError( - 'The "string" argument must be of type string. Received type number' - ) - } - return allocUnsafe(arg) - } - return from(arg, encodingOrOffset, length) -} - -// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 -if (typeof Symbol !== 'undefined' && Symbol.species != null && - Buffer[Symbol.species] === Buffer) { - Object.defineProperty(Buffer, Symbol.species, { - value: null, - configurable: true, - enumerable: false, - writable: false - }) -} - -Buffer.poolSize = 8192 // not used by this implementation - -function from (value, encodingOrOffset, length) { - if (typeof value === 'string') { - return fromString(value, encodingOrOffset) - } - - if (ArrayBuffer.isView(value)) { - return fromArrayLike(value) - } - - if (value == null) { - throw TypeError( - 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + - 'or Array-like Object. Received type ' + (typeof value) - ) - } - - if (isInstance(value, ArrayBuffer) || - (value && isInstance(value.buffer, ArrayBuffer))) { - return fromArrayBuffer(value, encodingOrOffset, length) - } - - if (typeof value === 'number') { - throw new TypeError( - 'The "value" argument must not be of type number. Received type number' - ) - } - - var valueOf = value.valueOf && value.valueOf() - if (valueOf != null && valueOf !== value) { - return Buffer.from(valueOf, encodingOrOffset, length) - } - - var b = fromObject(value) - if (b) return b - - if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && - typeof value[Symbol.toPrimitive] === 'function') { - return Buffer.from( - value[Symbol.toPrimitive]('string'), encodingOrOffset, length - ) - } - - throw new TypeError( - 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + - 'or Array-like Object. Received type ' + (typeof value) - ) -} - -/** - * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError - * if value is a number. - * Buffer.from(str[, encoding]) - * Buffer.from(array) - * Buffer.from(buffer) - * Buffer.from(arrayBuffer[, byteOffset[, length]]) - **/ -Buffer.from = function (value, encodingOrOffset, length) { - return from(value, encodingOrOffset, length) -} - -// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: -// https://github.com/feross/buffer/pull/148 -Buffer.prototype.__proto__ = Uint8Array.prototype -Buffer.__proto__ = Uint8Array - -function assertSize (size) { - if (typeof size !== 'number') { - throw new TypeError('"size" argument must be of type number') - } else if (size < 0) { - throw new RangeError('The value "' + size + '" is invalid for option "size"') - } -} - -function alloc (size, fill, encoding) { - assertSize(size) - if (size <= 0) { - return createBuffer(size) - } - if (fill !== undefined) { - // Only pay attention to encoding if it's a string. This - // prevents accidentally sending in a number that would - // be interpretted as a start offset. - return typeof encoding === 'string' - ? createBuffer(size).fill(fill, encoding) - : createBuffer(size).fill(fill) - } - return createBuffer(size) -} - -/** - * Creates a new filled Buffer instance. - * alloc(size[, fill[, encoding]]) - **/ -Buffer.alloc = function (size, fill, encoding) { - return alloc(size, fill, encoding) -} - -function allocUnsafe (size) { - assertSize(size) - return createBuffer(size < 0 ? 0 : checked(size) | 0) -} - -/** - * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. - * */ -Buffer.allocUnsafe = function (size) { - return allocUnsafe(size) -} -/** - * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. - */ -Buffer.allocUnsafeSlow = function (size) { - return allocUnsafe(size) -} - -function fromString (string, encoding) { - if (typeof encoding !== 'string' || encoding === '') { - encoding = 'utf8' - } - - if (!Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) - } - - var length = byteLength(string, encoding) | 0 - var buf = createBuffer(length) - - var actual = buf.write(string, encoding) - - if (actual !== length) { - // Writing a hex string, for example, that contains invalid characters will - // cause everything after the first invalid character to be ignored. (e.g. - // 'abxxcd' will be treated as 'ab') - buf = buf.slice(0, actual) - } - - return buf -} - -function fromArrayLike (array) { - var length = array.length < 0 ? 0 : checked(array.length) | 0 - var buf = createBuffer(length) - for (var i = 0; i < length; i += 1) { - buf[i] = array[i] & 255 - } - return buf -} - -function fromArrayBuffer (array, byteOffset, length) { - if (byteOffset < 0 || array.byteLength < byteOffset) { - throw new RangeError('"offset" is outside of buffer bounds') - } - - if (array.byteLength < byteOffset + (length || 0)) { - throw new RangeError('"length" is outside of buffer bounds') - } - - var buf - if (byteOffset === undefined && length === undefined) { - buf = new Uint8Array(array) - } else if (length === undefined) { - buf = new Uint8Array(array, byteOffset) - } else { - buf = new Uint8Array(array, byteOffset, length) - } - - // Return an augmented `Uint8Array` instance - buf.__proto__ = Buffer.prototype - return buf -} - -function fromObject (obj) { - if (Buffer.isBuffer(obj)) { - var len = checked(obj.length) | 0 - var buf = createBuffer(len) - - if (buf.length === 0) { - return buf - } - - obj.copy(buf, 0, 0, len) - return buf - } - - if (obj.length !== undefined) { - if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { - return createBuffer(0) - } - return fromArrayLike(obj) - } - - if (obj.type === 'Buffer' && Array.isArray(obj.data)) { - return fromArrayLike(obj.data) - } -} - -function checked (length) { - // Note: cannot use `length < K_MAX_LENGTH` here because that fails when - // length is NaN (which is otherwise coerced to zero.) - if (length >= K_MAX_LENGTH) { - throw new RangeError('Attempt to allocate Buffer larger than maximum ' + - 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') - } - return length | 0 -} - -function SlowBuffer (length) { - if (+length != length) { // eslint-disable-line eqeqeq - length = 0 - } - return Buffer.alloc(+length) -} - -Buffer.isBuffer = function isBuffer (b) { - return b != null && b._isBuffer === true && - b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false -} - -Buffer.compare = function compare (a, b) { - if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength) - if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength) - if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { - throw new TypeError( - 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array' - ) - } - - if (a === b) return 0 - - var x = a.length - var y = b.length - - for (var i = 0, len = Math.min(x, y); i < len; ++i) { - if (a[i] !== b[i]) { - x = a[i] - y = b[i] - break - } - } - - if (x < y) return -1 - if (y < x) return 1 - return 0 -} - -Buffer.isEncoding = function isEncoding (encoding) { - switch (String(encoding).toLowerCase()) { - case 'hex': - case 'utf8': - case 'utf-8': - case 'ascii': - case 'latin1': - case 'binary': - case 'base64': - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return true - default: - return false - } -} - -Buffer.concat = function concat (list, length) { - if (!Array.isArray(list)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } - - if (list.length === 0) { - return Buffer.alloc(0) - } - - var i - if (length === undefined) { - length = 0 - for (i = 0; i < list.length; ++i) { - length += list[i].length - } - } - - var buffer = Buffer.allocUnsafe(length) - var pos = 0 - for (i = 0; i < list.length; ++i) { - var buf = list[i] - if (isInstance(buf, Uint8Array)) { - buf = Buffer.from(buf) - } - if (!Buffer.isBuffer(buf)) { - throw new TypeError('"list" argument must be an Array of Buffers') - } - buf.copy(buffer, pos) - pos += buf.length - } - return buffer -} - -function byteLength (string, encoding) { - if (Buffer.isBuffer(string)) { - return string.length - } - if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { - return string.byteLength - } - if (typeof string !== 'string') { - throw new TypeError( - 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + - 'Received type ' + typeof string - ) - } - - var len = string.length - var mustMatch = (arguments.length > 2 && arguments[2] === true) - if (!mustMatch && len === 0) return 0 - - // Use a for loop to avoid recursion - var loweredCase = false - for (;;) { - switch (encoding) { - case 'ascii': - case 'latin1': - case 'binary': - return len - case 'utf8': - case 'utf-8': - return utf8ToBytes(string).length - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return len * 2 - case 'hex': - return len >>> 1 - case 'base64': - return base64ToBytes(string).length - default: - if (loweredCase) { - return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8 - } - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } -} -Buffer.byteLength = byteLength - -function slowToString (encoding, start, end) { - var loweredCase = false - - // No need to verify that "this.length <= MAX_UINT32" since it's a read-only - // property of a typed array. - - // This behaves neither like String nor Uint8Array in that we set start/end - // to their upper/lower bounds if the value passed is out of range. - // undefined is handled specially as per ECMA-262 6th Edition, - // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. - if (start === undefined || start < 0) { - start = 0 - } - // Return early if start > this.length. Done here to prevent potential uint32 - // coercion fail below. - if (start > this.length) { - return '' - } - - if (end === undefined || end > this.length) { - end = this.length - } - - if (end <= 0) { - return '' - } - - // Force coersion to uint32. This will also coerce falsey/NaN values to 0. - end >>>= 0 - start >>>= 0 - - if (end <= start) { - return '' - } - - if (!encoding) encoding = 'utf8' - - while (true) { - switch (encoding) { - case 'hex': - return hexSlice(this, start, end) - - case 'utf8': - case 'utf-8': - return utf8Slice(this, start, end) - - case 'ascii': - return asciiSlice(this, start, end) - - case 'latin1': - case 'binary': - return latin1Slice(this, start, end) - - case 'base64': - return base64Slice(this, start, end) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return utf16leSlice(this, start, end) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = (encoding + '').toLowerCase() - loweredCase = true - } - } -} - -// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) -// to detect a Buffer instance. It's not possible to use `instanceof Buffer` -// reliably in a browserify context because there could be multiple different -// copies of the 'buffer' package in use. This method works even for Buffer -// instances that were created from another copy of the `buffer` package. -// See: https://github.com/feross/buffer/issues/154 -Buffer.prototype._isBuffer = true - -function swap (b, n, m) { - var i = b[n] - b[n] = b[m] - b[m] = i -} - -Buffer.prototype.swap16 = function swap16 () { - var len = this.length - if (len % 2 !== 0) { - throw new RangeError('Buffer size must be a multiple of 16-bits') - } - for (var i = 0; i < len; i += 2) { - swap(this, i, i + 1) - } - return this -} - -Buffer.prototype.swap32 = function swap32 () { - var len = this.length - if (len % 4 !== 0) { - throw new RangeError('Buffer size must be a multiple of 32-bits') - } - for (var i = 0; i < len; i += 4) { - swap(this, i, i + 3) - swap(this, i + 1, i + 2) - } - return this -} - -Buffer.prototype.swap64 = function swap64 () { - var len = this.length - if (len % 8 !== 0) { - throw new RangeError('Buffer size must be a multiple of 64-bits') - } - for (var i = 0; i < len; i += 8) { - swap(this, i, i + 7) - swap(this, i + 1, i + 6) - swap(this, i + 2, i + 5) - swap(this, i + 3, i + 4) - } - return this -} - -Buffer.prototype.toString = function toString () { - var length = this.length - if (length === 0) return '' - if (arguments.length === 0) return utf8Slice(this, 0, length) - return slowToString.apply(this, arguments) -} - -Buffer.prototype.toLocaleString = Buffer.prototype.toString - -Buffer.prototype.equals = function equals (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - if (this === b) return true - return Buffer.compare(this, b) === 0 -} - -Buffer.prototype.inspect = function inspect () { - var str = '' - var max = exports.INSPECT_MAX_BYTES - str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim() - if (this.length > max) str += ' ... ' - return '' -} - -Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { - if (isInstance(target, Uint8Array)) { - target = Buffer.from(target, target.offset, target.byteLength) - } - if (!Buffer.isBuffer(target)) { - throw new TypeError( - 'The "target" argument must be one of type Buffer or Uint8Array. ' + - 'Received type ' + (typeof target) - ) - } - - if (start === undefined) { - start = 0 - } - if (end === undefined) { - end = target ? target.length : 0 - } - if (thisStart === undefined) { - thisStart = 0 - } - if (thisEnd === undefined) { - thisEnd = this.length - } - - if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { - throw new RangeError('out of range index') - } - - if (thisStart >= thisEnd && start >= end) { - return 0 - } - if (thisStart >= thisEnd) { - return -1 - } - if (start >= end) { - return 1 - } - - start >>>= 0 - end >>>= 0 - thisStart >>>= 0 - thisEnd >>>= 0 - - if (this === target) return 0 - - var x = thisEnd - thisStart - var y = end - start - var len = Math.min(x, y) - - var thisCopy = this.slice(thisStart, thisEnd) - var targetCopy = target.slice(start, end) - - for (var i = 0; i < len; ++i) { - if (thisCopy[i] !== targetCopy[i]) { - x = thisCopy[i] - y = targetCopy[i] - break - } - } - - if (x < y) return -1 - if (y < x) return 1 - return 0 -} - -// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, -// OR the last index of `val` in `buffer` at offset <= `byteOffset`. -// -// Arguments: -// - buffer - a Buffer to search -// - val - a string, Buffer, or number -// - byteOffset - an index into `buffer`; will be clamped to an int32 -// - encoding - an optional encoding, relevant is val is a string -// - dir - true for indexOf, false for lastIndexOf -function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { - // Empty buffer means no match - if (buffer.length === 0) return -1 - - // Normalize byteOffset - if (typeof byteOffset === 'string') { - encoding = byteOffset - byteOffset = 0 - } else if (byteOffset > 0x7fffffff) { - byteOffset = 0x7fffffff - } else if (byteOffset < -0x80000000) { - byteOffset = -0x80000000 - } - byteOffset = +byteOffset // Coerce to Number. - if (numberIsNaN(byteOffset)) { - // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer - byteOffset = dir ? 0 : (buffer.length - 1) - } - - // Normalize byteOffset: negative offsets start from the end of the buffer - if (byteOffset < 0) byteOffset = buffer.length + byteOffset - if (byteOffset >= buffer.length) { - if (dir) return -1 - else byteOffset = buffer.length - 1 - } else if (byteOffset < 0) { - if (dir) byteOffset = 0 - else return -1 - } - - // Normalize val - if (typeof val === 'string') { - val = Buffer.from(val, encoding) - } - - // Finally, search either indexOf (if dir is true) or lastIndexOf - if (Buffer.isBuffer(val)) { - // Special case: looking for empty string/buffer always fails - if (val.length === 0) { - return -1 - } - return arrayIndexOf(buffer, val, byteOffset, encoding, dir) - } else if (typeof val === 'number') { - val = val & 0xFF // Search for a byte value [0-255] - if (typeof Uint8Array.prototype.indexOf === 'function') { - if (dir) { - return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) - } else { - return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) - } - } - return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) - } - - throw new TypeError('val must be string, number or Buffer') -} - -function arrayIndexOf (arr, val, byteOffset, encoding, dir) { - var indexSize = 1 - var arrLength = arr.length - var valLength = val.length - - if (encoding !== undefined) { - encoding = String(encoding).toLowerCase() - if (encoding === 'ucs2' || encoding === 'ucs-2' || - encoding === 'utf16le' || encoding === 'utf-16le') { - if (arr.length < 2 || val.length < 2) { - return -1 - } - indexSize = 2 - arrLength /= 2 - valLength /= 2 - byteOffset /= 2 - } - } - - function read (buf, i) { - if (indexSize === 1) { - return buf[i] - } else { - return buf.readUInt16BE(i * indexSize) - } - } - - var i - if (dir) { - var foundIndex = -1 - for (i = byteOffset; i < arrLength; i++) { - if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { - if (foundIndex === -1) foundIndex = i - if (i - foundIndex + 1 === valLength) return foundIndex * indexSize - } else { - if (foundIndex !== -1) i -= i - foundIndex - foundIndex = -1 - } - } - } else { - if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength - for (i = byteOffset; i >= 0; i--) { - var found = true - for (var j = 0; j < valLength; j++) { - if (read(arr, i + j) !== read(val, j)) { - found = false - break - } - } - if (found) return i - } - } - - return -1 -} - -Buffer.prototype.includes = function includes (val, byteOffset, encoding) { - return this.indexOf(val, byteOffset, encoding) !== -1 -} - -Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, true) -} - -Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { - return bidirectionalIndexOf(this, val, byteOffset, encoding, false) -} - -function hexWrite (buf, string, offset, length) { - offset = Number(offset) || 0 - var remaining = buf.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining - } - } - - var strLen = string.length - - if (length > strLen / 2) { - length = strLen / 2 - } - for (var i = 0; i < length; ++i) { - var parsed = parseInt(string.substr(i * 2, 2), 16) - if (numberIsNaN(parsed)) return i - buf[offset + i] = parsed - } - return i -} - -function utf8Write (buf, string, offset, length) { - return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) -} - -function asciiWrite (buf, string, offset, length) { - return blitBuffer(asciiToBytes(string), buf, offset, length) -} - -function latin1Write (buf, string, offset, length) { - return asciiWrite(buf, string, offset, length) -} - -function base64Write (buf, string, offset, length) { - return blitBuffer(base64ToBytes(string), buf, offset, length) -} - -function ucs2Write (buf, string, offset, length) { - return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) -} - -Buffer.prototype.write = function write (string, offset, length, encoding) { - // Buffer#write(string) - if (offset === undefined) { - encoding = 'utf8' - length = this.length - offset = 0 - // Buffer#write(string, encoding) - } else if (length === undefined && typeof offset === 'string') { - encoding = offset - length = this.length - offset = 0 - // Buffer#write(string, offset[, length][, encoding]) - } else if (isFinite(offset)) { - offset = offset >>> 0 - if (isFinite(length)) { - length = length >>> 0 - if (encoding === undefined) encoding = 'utf8' - } else { - encoding = length - length = undefined - } - } else { - throw new Error( - 'Buffer.write(string, encoding, offset[, length]) is no longer supported' - ) - } - - var remaining = this.length - offset - if (length === undefined || length > remaining) length = remaining - - if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { - throw new RangeError('Attempt to write outside buffer bounds') - } - - if (!encoding) encoding = 'utf8' - - var loweredCase = false - for (;;) { - switch (encoding) { - case 'hex': - return hexWrite(this, string, offset, length) - - case 'utf8': - case 'utf-8': - return utf8Write(this, string, offset, length) - - case 'ascii': - return asciiWrite(this, string, offset, length) - - case 'latin1': - case 'binary': - return latin1Write(this, string, offset, length) - - case 'base64': - // Warning: maxLength not taken into account in base64Write - return base64Write(this, string, offset, length) - - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return ucs2Write(this, string, offset, length) - - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) - encoding = ('' + encoding).toLowerCase() - loweredCase = true - } - } -} - -Buffer.prototype.toJSON = function toJSON () { - return { - type: 'Buffer', - data: Array.prototype.slice.call(this._arr || this, 0) - } -} - -function base64Slice (buf, start, end) { - if (start === 0 && end === buf.length) { - return base64.fromByteArray(buf) - } else { - return base64.fromByteArray(buf.slice(start, end)) - } -} - -function utf8Slice (buf, start, end) { - end = Math.min(buf.length, end) - var res = [] - - var i = start - while (i < end) { - var firstByte = buf[i] - var codePoint = null - var bytesPerSequence = (firstByte > 0xEF) ? 4 - : (firstByte > 0xDF) ? 3 - : (firstByte > 0xBF) ? 2 - : 1 - - if (i + bytesPerSequence <= end) { - var secondByte, thirdByte, fourthByte, tempCodePoint - - switch (bytesPerSequence) { - case 1: - if (firstByte < 0x80) { - codePoint = firstByte - } - break - case 2: - secondByte = buf[i + 1] - if ((secondByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) - if (tempCodePoint > 0x7F) { - codePoint = tempCodePoint - } - } - break - case 3: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) - if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { - codePoint = tempCodePoint - } - } - break - case 4: - secondByte = buf[i + 1] - thirdByte = buf[i + 2] - fourthByte = buf[i + 3] - if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { - tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) - if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { - codePoint = tempCodePoint - } - } - } - } - - if (codePoint === null) { - // we did not generate a valid codePoint so insert a - // replacement char (U+FFFD) and advance only 1 byte - codePoint = 0xFFFD - bytesPerSequence = 1 - } else if (codePoint > 0xFFFF) { - // encode to utf16 (surrogate pair dance) - codePoint -= 0x10000 - res.push(codePoint >>> 10 & 0x3FF | 0xD800) - codePoint = 0xDC00 | codePoint & 0x3FF - } - - res.push(codePoint) - i += bytesPerSequence - } - - return decodeCodePointsArray(res) -} - -// Based on http://stackoverflow.com/a/22747272/680742, the browser with -// the lowest limit is Chrome, with 0x10000 args. -// We go 1 magnitude less, for safety -var MAX_ARGUMENTS_LENGTH = 0x1000 - -function decodeCodePointsArray (codePoints) { - var len = codePoints.length - if (len <= MAX_ARGUMENTS_LENGTH) { - return String.fromCharCode.apply(String, codePoints) // avoid extra slice() - } - - // Decode in chunks to avoid "call stack size exceeded". - var res = '' - var i = 0 - while (i < len) { - res += String.fromCharCode.apply( - String, - codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) - ) - } - return res -} - -function asciiSlice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i] & 0x7F) - } - return ret -} - -function latin1Slice (buf, start, end) { - var ret = '' - end = Math.min(buf.length, end) - - for (var i = start; i < end; ++i) { - ret += String.fromCharCode(buf[i]) - } - return ret -} - -function hexSlice (buf, start, end) { - var len = buf.length - - if (!start || start < 0) start = 0 - if (!end || end < 0 || end > len) end = len - - var out = '' - for (var i = start; i < end; ++i) { - out += toHex(buf[i]) - } - return out -} - -function utf16leSlice (buf, start, end) { - var bytes = buf.slice(start, end) - var res = '' - for (var i = 0; i < bytes.length; i += 2) { - res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) - } - return res -} - -Buffer.prototype.slice = function slice (start, end) { - var len = this.length - start = ~~start - end = end === undefined ? len : ~~end - - if (start < 0) { - start += len - if (start < 0) start = 0 - } else if (start > len) { - start = len - } - - if (end < 0) { - end += len - if (end < 0) end = 0 - } else if (end > len) { - end = len - } - - if (end < start) end = start - - var newBuf = this.subarray(start, end) - // Return an augmented `Uint8Array` instance - newBuf.__proto__ = Buffer.prototype - return newBuf -} - -/* - * Need to make sure that buffer isn't trying to write out of bounds. - */ -function checkOffset (offset, ext, length) { - if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') - if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') -} - -Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - - return val -} - -Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - checkOffset(offset, byteLength, this.length) - } - - var val = this[offset + --byteLength] - var mul = 1 - while (byteLength > 0 && (mul *= 0x100)) { - val += this[offset + --byteLength] * mul - } - - return val -} - -Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 1, this.length) - return this[offset] -} - -Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - return this[offset] | (this[offset + 1] << 8) -} - -Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - return (this[offset] << 8) | this[offset + 1] -} - -Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return ((this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16)) + - (this[offset + 3] * 0x1000000) -} - -Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] * 0x1000000) + - ((this[offset + 1] << 16) | - (this[offset + 2] << 8) | - this[offset + 3]) -} - -Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var val = this[offset] - var mul = 1 - var i = 0 - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val -} - -Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) checkOffset(offset, byteLength, this.length) - - var i = byteLength - var mul = 1 - var val = this[offset + --i] - while (i > 0 && (mul *= 0x100)) { - val += this[offset + --i] * mul - } - mul *= 0x80 - - if (val >= mul) val -= Math.pow(2, 8 * byteLength) - - return val -} - -Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 1, this.length) - if (!(this[offset] & 0x80)) return (this[offset]) - return ((0xff - this[offset] + 1) * -1) -} - -Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset] | (this[offset + 1] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} - -Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 2, this.length) - var val = this[offset + 1] | (this[offset] << 8) - return (val & 0x8000) ? val | 0xFFFF0000 : val -} - -Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16) | - (this[offset + 3] << 24) -} - -Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - - return (this[offset] << 24) | - (this[offset + 1] << 16) | - (this[offset + 2] << 8) | - (this[offset + 3]) -} - -Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, true, 23, 4) -} - -Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 4, this.length) - return ieee754.read(this, offset, false, 23, 4) -} - -Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, true, 52, 8) -} - -Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { - offset = offset >>> 0 - if (!noAssert) checkOffset(offset, 8, this.length) - return ieee754.read(this, offset, false, 52, 8) -} - -function checkInt (buf, value, offset, ext, max, min) { - if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') - if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') - if (offset + ext > buf.length) throw new RangeError('Index out of range') -} - -Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } - - var mul = 1 - var i = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) { - var maxBytes = Math.pow(2, 8 * byteLength) - 1 - checkInt(this, value, offset, byteLength, maxBytes, 0) - } - - var i = byteLength - 1 - var mul = 1 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - this[offset + i] = (value / mul) & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) - this[offset] = (value & 0xff) - return offset + 1 -} - -Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - return offset + 2 -} - -Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - return offset + 2 -} - -Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - this[offset + 3] = (value >>> 24) - this[offset + 2] = (value >>> 16) - this[offset + 1] = (value >>> 8) - this[offset] = (value & 0xff) - return offset + 4 -} - -Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - return offset + 4 -} - -Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - var limit = Math.pow(2, (8 * byteLength) - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - var i = 0 - var mul = 1 - var sub = 0 - this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { - sub = 1 - } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - var limit = Math.pow(2, (8 * byteLength) - 1) - - checkInt(this, value, offset, byteLength, limit - 1, -limit) - } - - var i = byteLength - 1 - var mul = 1 - var sub = 0 - this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) { - if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { - sub = 1 - } - this[offset + i] = ((value / mul) >> 0) - sub & 0xFF - } - - return offset + byteLength -} - -Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) - if (value < 0) value = 0xff + value + 1 - this[offset] = (value & 0xff) - return offset + 1 -} - -Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - return offset + 2 -} - -Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) - this[offset] = (value >>> 8) - this[offset + 1] = (value & 0xff) - return offset + 2 -} - -Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - this[offset] = (value & 0xff) - this[offset + 1] = (value >>> 8) - this[offset + 2] = (value >>> 16) - this[offset + 3] = (value >>> 24) - return offset + 4 -} - -Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) - if (value < 0) value = 0xffffffff + value + 1 - this[offset] = (value >>> 24) - this[offset + 1] = (value >>> 16) - this[offset + 2] = (value >>> 8) - this[offset + 3] = (value & 0xff) - return offset + 4 -} - -function checkIEEE754 (buf, value, offset, ext, max, min) { - if (offset + ext > buf.length) throw new RangeError('Index out of range') - if (offset < 0) throw new RangeError('Index out of range') -} - -function writeFloat (buf, value, offset, littleEndian, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) - } - ieee754.write(buf, value, offset, littleEndian, 23, 4) - return offset + 4 -} - -Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { - return writeFloat(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { - return writeFloat(this, value, offset, false, noAssert) -} - -function writeDouble (buf, value, offset, littleEndian, noAssert) { - value = +value - offset = offset >>> 0 - if (!noAssert) { - checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) - } - ieee754.write(buf, value, offset, littleEndian, 52, 8) - return offset + 8 -} - -Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { - return writeDouble(this, value, offset, true, noAssert) -} - -Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { - return writeDouble(this, value, offset, false, noAssert) -} - -// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) -Buffer.prototype.copy = function copy (target, targetStart, start, end) { - if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') - if (!start) start = 0 - if (!end && end !== 0) end = this.length - if (targetStart >= target.length) targetStart = target.length - if (!targetStart) targetStart = 0 - if (end > 0 && end < start) end = start - - // Copy 0 bytes; we're done - if (end === start) return 0 - if (target.length === 0 || this.length === 0) return 0 - - // Fatal error conditions - if (targetStart < 0) { - throw new RangeError('targetStart out of bounds') - } - if (start < 0 || start >= this.length) throw new RangeError('Index out of range') - if (end < 0) throw new RangeError('sourceEnd out of bounds') - - // Are we oob? - if (end > this.length) end = this.length - if (target.length - targetStart < end - start) { - end = target.length - targetStart + start - } - - var len = end - start - - if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { - // Use built-in when available, missing from IE11 - this.copyWithin(targetStart, start, end) - } else if (this === target && start < targetStart && targetStart < end) { - // descending copy from end - for (var i = len - 1; i >= 0; --i) { - target[i + targetStart] = this[i + start] - } - } else { - Uint8Array.prototype.set.call( - target, - this.subarray(start, end), - targetStart - ) - } - - return len -} - -// Usage: -// buffer.fill(number[, offset[, end]]) -// buffer.fill(buffer[, offset[, end]]) -// buffer.fill(string[, offset[, end]][, encoding]) -Buffer.prototype.fill = function fill (val, start, end, encoding) { - // Handle string cases: - if (typeof val === 'string') { - if (typeof start === 'string') { - encoding = start - start = 0 - end = this.length - } else if (typeof end === 'string') { - encoding = end - end = this.length - } - if (encoding !== undefined && typeof encoding !== 'string') { - throw new TypeError('encoding must be a string') - } - if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { - throw new TypeError('Unknown encoding: ' + encoding) - } - if (val.length === 1) { - var code = val.charCodeAt(0) - if ((encoding === 'utf8' && code < 128) || - encoding === 'latin1') { - // Fast path: If `val` fits into a single byte, use that numeric value. - val = code - } - } - } else if (typeof val === 'number') { - val = val & 255 - } - - // Invalid ranges are not set to a default, so can range check early. - if (start < 0 || this.length < start || this.length < end) { - throw new RangeError('Out of range index') - } - - if (end <= start) { - return this - } - - start = start >>> 0 - end = end === undefined ? this.length : end >>> 0 - - if (!val) val = 0 - - var i - if (typeof val === 'number') { - for (i = start; i < end; ++i) { - this[i] = val - } - } else { - var bytes = Buffer.isBuffer(val) - ? val - : Buffer.from(val, encoding) - var len = bytes.length - if (len === 0) { - throw new TypeError('The value "' + val + - '" is invalid for argument "value"') - } - for (i = 0; i < end - start; ++i) { - this[i + start] = bytes[i % len] - } - } - - return this -} - -// HELPER FUNCTIONS -// ================ - -var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g - -function base64clean (str) { - // Node takes equal signs as end of the Base64 encoding - str = str.split('=')[0] - // Node strips out invalid characters like \n and \t from the string, base64-js does not - str = str.trim().replace(INVALID_BASE64_RE, '') - // Node converts strings with length < 2 to '' - if (str.length < 2) return '' - // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not - while (str.length % 4 !== 0) { - str = str + '=' - } - return str -} - -function toHex (n) { - if (n < 16) return '0' + n.toString(16) - return n.toString(16) -} - -function utf8ToBytes (string, units) { - units = units || Infinity - var codePoint - var length = string.length - var leadSurrogate = null - var bytes = [] - - for (var i = 0; i < length; ++i) { - codePoint = string.charCodeAt(i) - - // is surrogate component - if (codePoint > 0xD7FF && codePoint < 0xE000) { - // last char was a lead - if (!leadSurrogate) { - // no lead yet - if (codePoint > 0xDBFF) { - // unexpected trail - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } else if (i + 1 === length) { - // unpaired lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } - - // valid lead - leadSurrogate = codePoint - - continue - } - - // 2 leads in a row - if (codePoint < 0xDC00) { - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = codePoint - continue - } - - // valid surrogate pair - codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 - } else if (leadSurrogate) { - // valid bmp char, but last char was a lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - } - - leadSurrogate = null - - // encode utf8 - if (codePoint < 0x80) { - if ((units -= 1) < 0) break - bytes.push(codePoint) - } else if (codePoint < 0x800) { - if ((units -= 2) < 0) break - bytes.push( - codePoint >> 0x6 | 0xC0, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x10000) { - if ((units -= 3) < 0) break - bytes.push( - codePoint >> 0xC | 0xE0, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x110000) { - if ((units -= 4) < 0) break - bytes.push( - codePoint >> 0x12 | 0xF0, - codePoint >> 0xC & 0x3F | 0x80, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else { - throw new Error('Invalid code point') - } - } - - return bytes -} - -function asciiToBytes (str) { - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - // Node's code seems to be doing this and not & 0x7F.. - byteArray.push(str.charCodeAt(i) & 0xFF) - } - return byteArray -} - -function utf16leToBytes (str, units) { - var c, hi, lo - var byteArray = [] - for (var i = 0; i < str.length; ++i) { - if ((units -= 2) < 0) break - - c = str.charCodeAt(i) - hi = c >> 8 - lo = c % 256 - byteArray.push(lo) - byteArray.push(hi) - } - - return byteArray -} - -function base64ToBytes (str) { - return base64.toByteArray(base64clean(str)) -} - -function blitBuffer (src, dst, offset, length) { - for (var i = 0; i < length; ++i) { - if ((i + offset >= dst.length) || (i >= src.length)) break - dst[i + offset] = src[i] - } - return i -} - -// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass -// the `instanceof` check but they should be treated as of that type. -// See: https://github.com/feross/buffer/issues/166 -function isInstance (obj, type) { - return obj instanceof type || - (obj != null && obj.constructor != null && obj.constructor.name != null && - obj.constructor.name === type.name) -} -function numberIsNaN (obj) { - // For IE11 support - return obj !== obj // eslint-disable-line no-self-compare -} - -}).call(this)}).call(this,_dereq_("buffer").Buffer) -},{"base64-js":15,"buffer":18,"ieee754":56}],19:[function(_dereq_,module,exports){ -// https://d3js.org/d3-time-format/ v2.2.3 Copyright 2019 Mike Bostock -(function (global, factory) { -typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, _dereq_('d3-time')) : -typeof define === 'function' && define.amd ? define(['exports', 'd3-time'], factory) : -(global = global || self, factory(global.d3 = global.d3 || {}, global.d3)); -}(this, function (exports, d3Time) { 'use strict'; - -function localDate(d) { - if (0 <= d.y && d.y < 100) { - var date = new Date(-1, d.m, d.d, d.H, d.M, d.S, d.L); - date.setFullYear(d.y); - return date; - } - return new Date(d.y, d.m, d.d, d.H, d.M, d.S, d.L); -} - -function utcDate(d) { - if (0 <= d.y && d.y < 100) { - var date = new Date(Date.UTC(-1, d.m, d.d, d.H, d.M, d.S, d.L)); - date.setUTCFullYear(d.y); - return date; - } - return new Date(Date.UTC(d.y, d.m, d.d, d.H, d.M, d.S, d.L)); -} - -function newDate(y, m, d) { - return {y: y, m: m, d: d, H: 0, M: 0, S: 0, L: 0}; -} - -function formatLocale(locale) { - var locale_dateTime = locale.dateTime, - locale_date = locale.date, - locale_time = locale.time, - locale_periods = locale.periods, - locale_weekdays = locale.days, - locale_shortWeekdays = locale.shortDays, - locale_months = locale.months, - locale_shortMonths = locale.shortMonths; - - var periodRe = formatRe(locale_periods), - periodLookup = formatLookup(locale_periods), - weekdayRe = formatRe(locale_weekdays), - weekdayLookup = formatLookup(locale_weekdays), - shortWeekdayRe = formatRe(locale_shortWeekdays), - shortWeekdayLookup = formatLookup(locale_shortWeekdays), - monthRe = formatRe(locale_months), - monthLookup = formatLookup(locale_months), - shortMonthRe = formatRe(locale_shortMonths), - shortMonthLookup = formatLookup(locale_shortMonths); - - var formats = { - "a": formatShortWeekday, - "A": formatWeekday, - "b": formatShortMonth, - "B": formatMonth, - "c": null, - "d": formatDayOfMonth, - "e": formatDayOfMonth, - "f": formatMicroseconds, - "H": formatHour24, - "I": formatHour12, - "j": formatDayOfYear, - "L": formatMilliseconds, - "m": formatMonthNumber, - "M": formatMinutes, - "p": formatPeriod, - "q": formatQuarter, - "Q": formatUnixTimestamp, - "s": formatUnixTimestampSeconds, - "S": formatSeconds, - "u": formatWeekdayNumberMonday, - "U": formatWeekNumberSunday, - "V": formatWeekNumberISO, - "w": formatWeekdayNumberSunday, - "W": formatWeekNumberMonday, - "x": null, - "X": null, - "y": formatYear, - "Y": formatFullYear, - "Z": formatZone, - "%": formatLiteralPercent - }; - - var utcFormats = { - "a": formatUTCShortWeekday, - "A": formatUTCWeekday, - "b": formatUTCShortMonth, - "B": formatUTCMonth, - "c": null, - "d": formatUTCDayOfMonth, - "e": formatUTCDayOfMonth, - "f": formatUTCMicroseconds, - "H": formatUTCHour24, - "I": formatUTCHour12, - "j": formatUTCDayOfYear, - "L": formatUTCMilliseconds, - "m": formatUTCMonthNumber, - "M": formatUTCMinutes, - "p": formatUTCPeriod, - "q": formatUTCQuarter, - "Q": formatUnixTimestamp, - "s": formatUnixTimestampSeconds, - "S": formatUTCSeconds, - "u": formatUTCWeekdayNumberMonday, - "U": formatUTCWeekNumberSunday, - "V": formatUTCWeekNumberISO, - "w": formatUTCWeekdayNumberSunday, - "W": formatUTCWeekNumberMonday, - "x": null, - "X": null, - "y": formatUTCYear, - "Y": formatUTCFullYear, - "Z": formatUTCZone, - "%": formatLiteralPercent - }; - - var parses = { - "a": parseShortWeekday, - "A": parseWeekday, - "b": parseShortMonth, - "B": parseMonth, - "c": parseLocaleDateTime, - "d": parseDayOfMonth, - "e": parseDayOfMonth, - "f": parseMicroseconds, - "H": parseHour24, - "I": parseHour24, - "j": parseDayOfYear, - "L": parseMilliseconds, - "m": parseMonthNumber, - "M": parseMinutes, - "p": parsePeriod, - "q": parseQuarter, - "Q": parseUnixTimestamp, - "s": parseUnixTimestampSeconds, - "S": parseSeconds, - "u": parseWeekdayNumberMonday, - "U": parseWeekNumberSunday, - "V": parseWeekNumberISO, - "w": parseWeekdayNumberSunday, - "W": parseWeekNumberMonday, - "x": parseLocaleDate, - "X": parseLocaleTime, - "y": parseYear, - "Y": parseFullYear, - "Z": parseZone, - "%": parseLiteralPercent - }; - - // These recursive directive definitions must be deferred. - formats.x = newFormat(locale_date, formats); - formats.X = newFormat(locale_time, formats); - formats.c = newFormat(locale_dateTime, formats); - utcFormats.x = newFormat(locale_date, utcFormats); - utcFormats.X = newFormat(locale_time, utcFormats); - utcFormats.c = newFormat(locale_dateTime, utcFormats); - - function newFormat(specifier, formats) { - return function(date) { - var string = [], - i = -1, - j = 0, - n = specifier.length, - c, - pad, - format; - - if (!(date instanceof Date)) date = new Date(+date); - - while (++i < n) { - if (specifier.charCodeAt(i) === 37) { - string.push(specifier.slice(j, i)); - if ((pad = pads[c = specifier.charAt(++i)]) != null) c = specifier.charAt(++i); - else pad = c === "e" ? " " : "0"; - if (format = formats[c]) c = format(date, pad); - string.push(c); - j = i + 1; - } - } - - string.push(specifier.slice(j, i)); - return string.join(""); - }; - } - - function newParse(specifier, Z) { - return function(string) { - var d = newDate(1900, undefined, 1), - i = parseSpecifier(d, specifier, string += "", 0), - week, day; - if (i != string.length) return null; - - // If a UNIX timestamp is specified, return it. - if ("Q" in d) return new Date(d.Q); - if ("s" in d) return new Date(d.s * 1000 + ("L" in d ? d.L : 0)); - - // If this is utcParse, never use the local timezone. - if (Z && !("Z" in d)) d.Z = 0; - - // The am-pm flag is 0 for AM, and 1 for PM. - if ("p" in d) d.H = d.H % 12 + d.p * 12; - - // If the month was not specified, inherit from the quarter. - if (d.m === undefined) d.m = "q" in d ? d.q : 0; - - // Convert day-of-week and week-of-year to day-of-year. - if ("V" in d) { - if (d.V < 1 || d.V > 53) return null; - if (!("w" in d)) d.w = 1; - if ("Z" in d) { - week = utcDate(newDate(d.y, 0, 1)), day = week.getUTCDay(); - week = day > 4 || day === 0 ? d3Time.utcMonday.ceil(week) : d3Time.utcMonday(week); - week = d3Time.utcDay.offset(week, (d.V - 1) * 7); - d.y = week.getUTCFullYear(); - d.m = week.getUTCMonth(); - d.d = week.getUTCDate() + (d.w + 6) % 7; - } else { - week = localDate(newDate(d.y, 0, 1)), day = week.getDay(); - week = day > 4 || day === 0 ? d3Time.timeMonday.ceil(week) : d3Time.timeMonday(week); - week = d3Time.timeDay.offset(week, (d.V - 1) * 7); - d.y = week.getFullYear(); - d.m = week.getMonth(); - d.d = week.getDate() + (d.w + 6) % 7; - } - } else if ("W" in d || "U" in d) { - if (!("w" in d)) d.w = "u" in d ? d.u % 7 : "W" in d ? 1 : 0; - day = "Z" in d ? utcDate(newDate(d.y, 0, 1)).getUTCDay() : localDate(newDate(d.y, 0, 1)).getDay(); - d.m = 0; - d.d = "W" in d ? (d.w + 6) % 7 + d.W * 7 - (day + 5) % 7 : d.w + d.U * 7 - (day + 6) % 7; - } - - // If a time zone is specified, all fields are interpreted as UTC and then - // offset according to the specified time zone. - if ("Z" in d) { - d.H += d.Z / 100 | 0; - d.M += d.Z % 100; - return utcDate(d); - } - - // Otherwise, all fields are in local time. - return localDate(d); - }; - } - - function parseSpecifier(d, specifier, string, j) { - var i = 0, - n = specifier.length, - m = string.length, - c, - parse; - - while (i < n) { - if (j >= m) return -1; - c = specifier.charCodeAt(i++); - if (c === 37) { - c = specifier.charAt(i++); - parse = parses[c in pads ? specifier.charAt(i++) : c]; - if (!parse || ((j = parse(d, string, j)) < 0)) return -1; - } else if (c != string.charCodeAt(j++)) { - return -1; - } - } - - return j; - } - - function parsePeriod(d, string, i) { - var n = periodRe.exec(string.slice(i)); - return n ? (d.p = periodLookup[n[0].toLowerCase()], i + n[0].length) : -1; - } - - function parseShortWeekday(d, string, i) { - var n = shortWeekdayRe.exec(string.slice(i)); - return n ? (d.w = shortWeekdayLookup[n[0].toLowerCase()], i + n[0].length) : -1; - } - - function parseWeekday(d, string, i) { - var n = weekdayRe.exec(string.slice(i)); - return n ? (d.w = weekdayLookup[n[0].toLowerCase()], i + n[0].length) : -1; - } - - function parseShortMonth(d, string, i) { - var n = shortMonthRe.exec(string.slice(i)); - return n ? (d.m = shortMonthLookup[n[0].toLowerCase()], i + n[0].length) : -1; - } - - function parseMonth(d, string, i) { - var n = monthRe.exec(string.slice(i)); - return n ? (d.m = monthLookup[n[0].toLowerCase()], i + n[0].length) : -1; - } - - function parseLocaleDateTime(d, string, i) { - return parseSpecifier(d, locale_dateTime, string, i); - } - - function parseLocaleDate(d, string, i) { - return parseSpecifier(d, locale_date, string, i); - } - - function parseLocaleTime(d, string, i) { - return parseSpecifier(d, locale_time, string, i); - } - - function formatShortWeekday(d) { - return locale_shortWeekdays[d.getDay()]; - } - - function formatWeekday(d) { - return locale_weekdays[d.getDay()]; - } - - function formatShortMonth(d) { - return locale_shortMonths[d.getMonth()]; - } - - function formatMonth(d) { - return locale_months[d.getMonth()]; - } - - function formatPeriod(d) { - return locale_periods[+(d.getHours() >= 12)]; - } - - function formatQuarter(d) { - return 1 + ~~(d.getMonth() / 3); - } - - function formatUTCShortWeekday(d) { - return locale_shortWeekdays[d.getUTCDay()]; - } - - function formatUTCWeekday(d) { - return locale_weekdays[d.getUTCDay()]; - } - - function formatUTCShortMonth(d) { - return locale_shortMonths[d.getUTCMonth()]; - } - - function formatUTCMonth(d) { - return locale_months[d.getUTCMonth()]; - } - - function formatUTCPeriod(d) { - return locale_periods[+(d.getUTCHours() >= 12)]; - } - - function formatUTCQuarter(d) { - return 1 + ~~(d.getUTCMonth() / 3); - } - - return { - format: function(specifier) { - var f = newFormat(specifier += "", formats); - f.toString = function() { return specifier; }; - return f; - }, - parse: function(specifier) { - var p = newParse(specifier += "", false); - p.toString = function() { return specifier; }; - return p; - }, - utcFormat: function(specifier) { - var f = newFormat(specifier += "", utcFormats); - f.toString = function() { return specifier; }; - return f; - }, - utcParse: function(specifier) { - var p = newParse(specifier += "", true); - p.toString = function() { return specifier; }; - return p; - } - }; -} - -var pads = {"-": "", "_": " ", "0": "0"}, - numberRe = /^\s*\d+/, // note: ignores next directive - percentRe = /^%/, - requoteRe = /[\\^$*+?|[\]().{}]/g; - -function pad(value, fill, width) { - var sign = value < 0 ? "-" : "", - string = (sign ? -value : value) + "", - length = string.length; - return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string); -} - -function requote(s) { - return s.replace(requoteRe, "\\$&"); -} - -function formatRe(names) { - return new RegExp("^(?:" + names.map(requote).join("|") + ")", "i"); -} - -function formatLookup(names) { - var map = {}, i = -1, n = names.length; - while (++i < n) map[names[i].toLowerCase()] = i; - return map; -} - -function parseWeekdayNumberSunday(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 1)); - return n ? (d.w = +n[0], i + n[0].length) : -1; -} - -function parseWeekdayNumberMonday(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 1)); - return n ? (d.u = +n[0], i + n[0].length) : -1; -} - -function parseWeekNumberSunday(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.U = +n[0], i + n[0].length) : -1; -} - -function parseWeekNumberISO(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.V = +n[0], i + n[0].length) : -1; -} - -function parseWeekNumberMonday(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.W = +n[0], i + n[0].length) : -1; -} - -function parseFullYear(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 4)); - return n ? (d.y = +n[0], i + n[0].length) : -1; -} - -function parseYear(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.y = +n[0] + (+n[0] > 68 ? 1900 : 2000), i + n[0].length) : -1; -} - -function parseZone(d, string, i) { - var n = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(string.slice(i, i + 6)); - return n ? (d.Z = n[1] ? 0 : -(n[2] + (n[3] || "00")), i + n[0].length) : -1; -} - -function parseQuarter(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 1)); - return n ? (d.q = n[0] * 3 - 3, i + n[0].length) : -1; -} - -function parseMonthNumber(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.m = n[0] - 1, i + n[0].length) : -1; -} - -function parseDayOfMonth(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.d = +n[0], i + n[0].length) : -1; -} - -function parseDayOfYear(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 3)); - return n ? (d.m = 0, d.d = +n[0], i + n[0].length) : -1; -} - -function parseHour24(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.H = +n[0], i + n[0].length) : -1; -} - -function parseMinutes(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.M = +n[0], i + n[0].length) : -1; -} - -function parseSeconds(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 2)); - return n ? (d.S = +n[0], i + n[0].length) : -1; -} - -function parseMilliseconds(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 3)); - return n ? (d.L = +n[0], i + n[0].length) : -1; -} - -function parseMicroseconds(d, string, i) { - var n = numberRe.exec(string.slice(i, i + 6)); - return n ? (d.L = Math.floor(n[0] / 1000), i + n[0].length) : -1; -} - -function parseLiteralPercent(d, string, i) { - var n = percentRe.exec(string.slice(i, i + 1)); - return n ? i + n[0].length : -1; -} - -function parseUnixTimestamp(d, string, i) { - var n = numberRe.exec(string.slice(i)); - return n ? (d.Q = +n[0], i + n[0].length) : -1; -} - -function parseUnixTimestampSeconds(d, string, i) { - var n = numberRe.exec(string.slice(i)); - return n ? (d.s = +n[0], i + n[0].length) : -1; -} - -function formatDayOfMonth(d, p) { - return pad(d.getDate(), p, 2); -} - -function formatHour24(d, p) { - return pad(d.getHours(), p, 2); -} - -function formatHour12(d, p) { - return pad(d.getHours() % 12 || 12, p, 2); -} - -function formatDayOfYear(d, p) { - return pad(1 + d3Time.timeDay.count(d3Time.timeYear(d), d), p, 3); -} - -function formatMilliseconds(d, p) { - return pad(d.getMilliseconds(), p, 3); -} - -function formatMicroseconds(d, p) { - return formatMilliseconds(d, p) + "000"; -} - -function formatMonthNumber(d, p) { - return pad(d.getMonth() + 1, p, 2); -} - -function formatMinutes(d, p) { - return pad(d.getMinutes(), p, 2); -} - -function formatSeconds(d, p) { - return pad(d.getSeconds(), p, 2); -} - -function formatWeekdayNumberMonday(d) { - var day = d.getDay(); - return day === 0 ? 7 : day; -} - -function formatWeekNumberSunday(d, p) { - return pad(d3Time.timeSunday.count(d3Time.timeYear(d) - 1, d), p, 2); -} - -function formatWeekNumberISO(d, p) { - var day = d.getDay(); - d = (day >= 4 || day === 0) ? d3Time.timeThursday(d) : d3Time.timeThursday.ceil(d); - return pad(d3Time.timeThursday.count(d3Time.timeYear(d), d) + (d3Time.timeYear(d).getDay() === 4), p, 2); -} - -function formatWeekdayNumberSunday(d) { - return d.getDay(); -} - -function formatWeekNumberMonday(d, p) { - return pad(d3Time.timeMonday.count(d3Time.timeYear(d) - 1, d), p, 2); -} - -function formatYear(d, p) { - return pad(d.getFullYear() % 100, p, 2); -} - -function formatFullYear(d, p) { - return pad(d.getFullYear() % 10000, p, 4); -} - -function formatZone(d) { - var z = d.getTimezoneOffset(); - return (z > 0 ? "-" : (z *= -1, "+")) - + pad(z / 60 | 0, "0", 2) - + pad(z % 60, "0", 2); -} - -function formatUTCDayOfMonth(d, p) { - return pad(d.getUTCDate(), p, 2); -} - -function formatUTCHour24(d, p) { - return pad(d.getUTCHours(), p, 2); -} - -function formatUTCHour12(d, p) { - return pad(d.getUTCHours() % 12 || 12, p, 2); -} - -function formatUTCDayOfYear(d, p) { - return pad(1 + d3Time.utcDay.count(d3Time.utcYear(d), d), p, 3); -} - -function formatUTCMilliseconds(d, p) { - return pad(d.getUTCMilliseconds(), p, 3); -} - -function formatUTCMicroseconds(d, p) { - return formatUTCMilliseconds(d, p) + "000"; -} - -function formatUTCMonthNumber(d, p) { - return pad(d.getUTCMonth() + 1, p, 2); -} - -function formatUTCMinutes(d, p) { - return pad(d.getUTCMinutes(), p, 2); -} - -function formatUTCSeconds(d, p) { - return pad(d.getUTCSeconds(), p, 2); -} - -function formatUTCWeekdayNumberMonday(d) { - var dow = d.getUTCDay(); - return dow === 0 ? 7 : dow; -} - -function formatUTCWeekNumberSunday(d, p) { - return pad(d3Time.utcSunday.count(d3Time.utcYear(d) - 1, d), p, 2); -} - -function formatUTCWeekNumberISO(d, p) { - var day = d.getUTCDay(); - d = (day >= 4 || day === 0) ? d3Time.utcThursday(d) : d3Time.utcThursday.ceil(d); - return pad(d3Time.utcThursday.count(d3Time.utcYear(d), d) + (d3Time.utcYear(d).getUTCDay() === 4), p, 2); -} - -function formatUTCWeekdayNumberSunday(d) { - return d.getUTCDay(); -} - -function formatUTCWeekNumberMonday(d, p) { - return pad(d3Time.utcMonday.count(d3Time.utcYear(d) - 1, d), p, 2); -} - -function formatUTCYear(d, p) { - return pad(d.getUTCFullYear() % 100, p, 2); -} - -function formatUTCFullYear(d, p) { - return pad(d.getUTCFullYear() % 10000, p, 4); -} - -function formatUTCZone() { - return "+0000"; -} - -function formatLiteralPercent() { - return "%"; -} - -function formatUnixTimestamp(d) { - return +d; -} - -function formatUnixTimestampSeconds(d) { - return Math.floor(+d / 1000); -} - -var locale; - -defaultLocale({ - dateTime: "%x, %X", - date: "%-m/%-d/%Y", - time: "%-I:%M:%S %p", - periods: ["AM", "PM"], - days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], - shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], - months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], - shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] -}); - -function defaultLocale(definition) { - locale = formatLocale(definition); - exports.timeFormat = locale.format; - exports.timeParse = locale.parse; - exports.utcFormat = locale.utcFormat; - exports.utcParse = locale.utcParse; - return locale; -} - -var isoSpecifier = "%Y-%m-%dT%H:%M:%S.%LZ"; - -function formatIsoNative(date) { - return date.toISOString(); -} - -var formatIso = Date.prototype.toISOString - ? formatIsoNative - : exports.utcFormat(isoSpecifier); - -function parseIsoNative(string) { - var date = new Date(string); - return isNaN(date) ? null : date; -} - -var parseIso = +new Date("2000-01-01T00:00:00.000Z") - ? parseIsoNative - : exports.utcParse(isoSpecifier); - -exports.isoFormat = formatIso; -exports.isoParse = parseIso; -exports.timeFormatDefaultLocale = defaultLocale; -exports.timeFormatLocale = formatLocale; - -Object.defineProperty(exports, '__esModule', { value: true }); - -})); - -},{"d3-time":20}],20:[function(_dereq_,module,exports){ -// https://d3js.org/d3-time/ v1.1.0 Copyright 2019 Mike Bostock -(function (global, factory) { -typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : -typeof define === 'function' && define.amd ? define(['exports'], factory) : -(global = global || self, factory(global.d3 = global.d3 || {})); -}(this, function (exports) { 'use strict'; - -var t0 = new Date, - t1 = new Date; - -function newInterval(floori, offseti, count, field) { - - function interval(date) { - return floori(date = arguments.length === 0 ? new Date : new Date(+date)), date; - } - - interval.floor = function(date) { - return floori(date = new Date(+date)), date; - }; - - interval.ceil = function(date) { - return floori(date = new Date(date - 1)), offseti(date, 1), floori(date), date; - }; - - interval.round = function(date) { - var d0 = interval(date), - d1 = interval.ceil(date); - return date - d0 < d1 - date ? d0 : d1; - }; - - interval.offset = function(date, step) { - return offseti(date = new Date(+date), step == null ? 1 : Math.floor(step)), date; - }; - - interval.range = function(start, stop, step) { - var range = [], previous; - start = interval.ceil(start); - step = step == null ? 1 : Math.floor(step); - if (!(start < stop) || !(step > 0)) return range; // also handles Invalid Date - do range.push(previous = new Date(+start)), offseti(start, step), floori(start); - while (previous < start && start < stop); - return range; - }; - - interval.filter = function(test) { - return newInterval(function(date) { - if (date >= date) while (floori(date), !test(date)) date.setTime(date - 1); - }, function(date, step) { - if (date >= date) { - if (step < 0) while (++step <= 0) { - while (offseti(date, -1), !test(date)) {} // eslint-disable-line no-empty - } else while (--step >= 0) { - while (offseti(date, +1), !test(date)) {} // eslint-disable-line no-empty - } - } - }); - }; - - if (count) { - interval.count = function(start, end) { - t0.setTime(+start), t1.setTime(+end); - floori(t0), floori(t1); - return Math.floor(count(t0, t1)); - }; - - interval.every = function(step) { - step = Math.floor(step); - return !isFinite(step) || !(step > 0) ? null - : !(step > 1) ? interval - : interval.filter(field - ? function(d) { return field(d) % step === 0; } - : function(d) { return interval.count(0, d) % step === 0; }); - }; - } - - return interval; -} - -var millisecond = newInterval(function() { - // noop -}, function(date, step) { - date.setTime(+date + step); -}, function(start, end) { - return end - start; -}); - -// An optimized implementation for this simple case. -millisecond.every = function(k) { - k = Math.floor(k); - if (!isFinite(k) || !(k > 0)) return null; - if (!(k > 1)) return millisecond; - return newInterval(function(date) { - date.setTime(Math.floor(date / k) * k); - }, function(date, step) { - date.setTime(+date + step * k); - }, function(start, end) { - return (end - start) / k; - }); -}; -var milliseconds = millisecond.range; - -var durationSecond = 1e3; -var durationMinute = 6e4; -var durationHour = 36e5; -var durationDay = 864e5; -var durationWeek = 6048e5; - -var second = newInterval(function(date) { - date.setTime(date - date.getMilliseconds()); -}, function(date, step) { - date.setTime(+date + step * durationSecond); -}, function(start, end) { - return (end - start) / durationSecond; -}, function(date) { - return date.getUTCSeconds(); -}); -var seconds = second.range; - -var minute = newInterval(function(date) { - date.setTime(date - date.getMilliseconds() - date.getSeconds() * durationSecond); -}, function(date, step) { - date.setTime(+date + step * durationMinute); -}, function(start, end) { - return (end - start) / durationMinute; -}, function(date) { - return date.getMinutes(); -}); -var minutes = minute.range; - -var hour = newInterval(function(date) { - date.setTime(date - date.getMilliseconds() - date.getSeconds() * durationSecond - date.getMinutes() * durationMinute); -}, function(date, step) { - date.setTime(+date + step * durationHour); -}, function(start, end) { - return (end - start) / durationHour; -}, function(date) { - return date.getHours(); -}); -var hours = hour.range; - -var day = newInterval(function(date) { - date.setHours(0, 0, 0, 0); -}, function(date, step) { - date.setDate(date.getDate() + step); -}, function(start, end) { - return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationDay; -}, function(date) { - return date.getDate() - 1; -}); -var days = day.range; - -function weekday(i) { - return newInterval(function(date) { - date.setDate(date.getDate() - (date.getDay() + 7 - i) % 7); - date.setHours(0, 0, 0, 0); - }, function(date, step) { - date.setDate(date.getDate() + step * 7); - }, function(start, end) { - return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationWeek; - }); -} - -var sunday = weekday(0); -var monday = weekday(1); -var tuesday = weekday(2); -var wednesday = weekday(3); -var thursday = weekday(4); -var friday = weekday(5); -var saturday = weekday(6); - -var sundays = sunday.range; -var mondays = monday.range; -var tuesdays = tuesday.range; -var wednesdays = wednesday.range; -var thursdays = thursday.range; -var fridays = friday.range; -var saturdays = saturday.range; - -var month = newInterval(function(date) { - date.setDate(1); - date.setHours(0, 0, 0, 0); -}, function(date, step) { - date.setMonth(date.getMonth() + step); -}, function(start, end) { - return end.getMonth() - start.getMonth() + (end.getFullYear() - start.getFullYear()) * 12; -}, function(date) { - return date.getMonth(); -}); -var months = month.range; - -var year = newInterval(function(date) { - date.setMonth(0, 1); - date.setHours(0, 0, 0, 0); -}, function(date, step) { - date.setFullYear(date.getFullYear() + step); -}, function(start, end) { - return end.getFullYear() - start.getFullYear(); -}, function(date) { - return date.getFullYear(); -}); - -// An optimized implementation for this simple case. -year.every = function(k) { - return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : newInterval(function(date) { - date.setFullYear(Math.floor(date.getFullYear() / k) * k); - date.setMonth(0, 1); - date.setHours(0, 0, 0, 0); - }, function(date, step) { - date.setFullYear(date.getFullYear() + step * k); - }); -}; -var years = year.range; - -var utcMinute = newInterval(function(date) { - date.setUTCSeconds(0, 0); -}, function(date, step) { - date.setTime(+date + step * durationMinute); -}, function(start, end) { - return (end - start) / durationMinute; -}, function(date) { - return date.getUTCMinutes(); -}); -var utcMinutes = utcMinute.range; - -var utcHour = newInterval(function(date) { - date.setUTCMinutes(0, 0, 0); -}, function(date, step) { - date.setTime(+date + step * durationHour); -}, function(start, end) { - return (end - start) / durationHour; -}, function(date) { - return date.getUTCHours(); -}); -var utcHours = utcHour.range; - -var utcDay = newInterval(function(date) { - date.setUTCHours(0, 0, 0, 0); -}, function(date, step) { - date.setUTCDate(date.getUTCDate() + step); -}, function(start, end) { - return (end - start) / durationDay; -}, function(date) { - return date.getUTCDate() - 1; -}); -var utcDays = utcDay.range; - -function utcWeekday(i) { - return newInterval(function(date) { - date.setUTCDate(date.getUTCDate() - (date.getUTCDay() + 7 - i) % 7); - date.setUTCHours(0, 0, 0, 0); - }, function(date, step) { - date.setUTCDate(date.getUTCDate() + step * 7); - }, function(start, end) { - return (end - start) / durationWeek; - }); -} - -var utcSunday = utcWeekday(0); -var utcMonday = utcWeekday(1); -var utcTuesday = utcWeekday(2); -var utcWednesday = utcWeekday(3); -var utcThursday = utcWeekday(4); -var utcFriday = utcWeekday(5); -var utcSaturday = utcWeekday(6); - -var utcSundays = utcSunday.range; -var utcMondays = utcMonday.range; -var utcTuesdays = utcTuesday.range; -var utcWednesdays = utcWednesday.range; -var utcThursdays = utcThursday.range; -var utcFridays = utcFriday.range; -var utcSaturdays = utcSaturday.range; - -var utcMonth = newInterval(function(date) { - date.setUTCDate(1); - date.setUTCHours(0, 0, 0, 0); -}, function(date, step) { - date.setUTCMonth(date.getUTCMonth() + step); -}, function(start, end) { - return end.getUTCMonth() - start.getUTCMonth() + (end.getUTCFullYear() - start.getUTCFullYear()) * 12; -}, function(date) { - return date.getUTCMonth(); -}); -var utcMonths = utcMonth.range; - -var utcYear = newInterval(function(date) { - date.setUTCMonth(0, 1); - date.setUTCHours(0, 0, 0, 0); -}, function(date, step) { - date.setUTCFullYear(date.getUTCFullYear() + step); -}, function(start, end) { - return end.getUTCFullYear() - start.getUTCFullYear(); -}, function(date) { - return date.getUTCFullYear(); -}); - -// An optimized implementation for this simple case. -utcYear.every = function(k) { - return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : newInterval(function(date) { - date.setUTCFullYear(Math.floor(date.getUTCFullYear() / k) * k); - date.setUTCMonth(0, 1); - date.setUTCHours(0, 0, 0, 0); - }, function(date, step) { - date.setUTCFullYear(date.getUTCFullYear() + step * k); - }); -}; -var utcYears = utcYear.range; - -exports.timeDay = day; -exports.timeDays = days; -exports.timeFriday = friday; -exports.timeFridays = fridays; -exports.timeHour = hour; -exports.timeHours = hours; -exports.timeInterval = newInterval; -exports.timeMillisecond = millisecond; -exports.timeMilliseconds = milliseconds; -exports.timeMinute = minute; -exports.timeMinutes = minutes; -exports.timeMonday = monday; -exports.timeMondays = mondays; -exports.timeMonth = month; -exports.timeMonths = months; -exports.timeSaturday = saturday; -exports.timeSaturdays = saturdays; -exports.timeSecond = second; -exports.timeSeconds = seconds; -exports.timeSunday = sunday; -exports.timeSundays = sundays; -exports.timeThursday = thursday; -exports.timeThursdays = thursdays; -exports.timeTuesday = tuesday; -exports.timeTuesdays = tuesdays; -exports.timeWednesday = wednesday; -exports.timeWednesdays = wednesdays; -exports.timeWeek = sunday; -exports.timeWeeks = sundays; -exports.timeYear = year; -exports.timeYears = years; -exports.utcDay = utcDay; -exports.utcDays = utcDays; -exports.utcFriday = utcFriday; -exports.utcFridays = utcFridays; -exports.utcHour = utcHour; -exports.utcHours = utcHours; -exports.utcMillisecond = millisecond; -exports.utcMilliseconds = milliseconds; -exports.utcMinute = utcMinute; -exports.utcMinutes = utcMinutes; -exports.utcMonday = utcMonday; -exports.utcMondays = utcMondays; -exports.utcMonth = utcMonth; -exports.utcMonths = utcMonths; -exports.utcSaturday = utcSaturday; -exports.utcSaturdays = utcSaturdays; -exports.utcSecond = second; -exports.utcSeconds = seconds; -exports.utcSunday = utcSunday; -exports.utcSundays = utcSundays; -exports.utcThursday = utcThursday; -exports.utcThursdays = utcThursdays; -exports.utcTuesday = utcTuesday; -exports.utcTuesdays = utcTuesdays; -exports.utcWednesday = utcWednesday; -exports.utcWednesdays = utcWednesdays; -exports.utcWeek = utcSunday; -exports.utcWeeks = utcSundays; -exports.utcYear = utcYear; -exports.utcYears = utcYears; - -Object.defineProperty(exports, '__esModule', { value: true }); - -})); - -},{}],21:[function(_dereq_,module,exports){ +},{"../src/traces/violin":536}],20:[function(_dereq_,module,exports){ !function() { var d3 = { - version: "3.5.17" + version: "3.6.0" }; var d3_arraySlice = [].slice, d3_array = function(list) { return d3_arraySlice.call(list); @@ -5796,9 +2228,14 @@ Object.defineProperty(exports, '__esModule', { value: true }); var o; return dsv.parseRows(text, function(row, i) { if (o) return o(row, i - 1); - var a = new Function("d", "return {" + row.map(function(name, i) { - return JSON.stringify(name) + ": d[" + i + "]"; - }).join(",") + "}"); + var a = function(d) { + var obj = {}; + var len = row.length; + for (var k = 0; k < len; ++k) { + obj[row[k]] = d[k]; + } + return obj; + }; o = f ? function(row, i) { return f(a(row), i); } : a; @@ -13310,1186 +9747,4639 @@ Object.defineProperty(exports, '__esModule', { value: true }); return request.responseXML; }); if (typeof define === "function" && define.amd) this.d3 = d3, define(d3); else if (typeof module === "object" && module.exports) module.exports = d3; else this.d3 = d3; -}(); -},{}],22:[function(_dereq_,module,exports){ -(function (process,global){(function (){ +}.apply(self); +},{}],21:[function(_dereq_,module,exports){ +(function (global){(function (){ +'use strict'; + +var objectAssign = _dereq_('object-assign'); + +// compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js +// original notice: + /*! - * @overview es6-promise - a tiny implementation of Promises/A+. - * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) - * @license Licensed under MIT license - * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE - * @version v4.2.8+1e68dce6 + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT */ +function compare(a, b) { + if (a === b) { + return 0; + } -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global.ES6Promise = factory()); -}(this, (function () { 'use strict'; + var x = a.length; + var y = b.length; -function objectOrFunction(x) { - var type = typeof x; - return x !== null && (type === 'object' || type === 'function'); + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i]; + y = b[i]; + break; + } + } + + if (x < y) { + return -1; + } + if (y < x) { + return 1; + } + return 0; +} +function isBuffer(b) { + if (global.Buffer && typeof global.Buffer.isBuffer === 'function') { + return global.Buffer.isBuffer(b); + } + return !!(b != null && b._isBuffer); } -function isFunction(x) { - return typeof x === 'function'; +// based on node assert, original notice: +// NB: The URL to the CommonJS spec is kept just for tradition. +// node-assert has evolved a lot since then, both in API and behavior. + +// http://wiki.commonjs.org/wiki/Unit_Testing/1.0 +// +// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8! +// +// Originally from narwhal.js (http://narwhaljs.org) +// Copyright (c) 2009 Thomas Robinson <280north.com> +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the 'Software'), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +var util = _dereq_('util/'); +var hasOwn = Object.prototype.hasOwnProperty; +var pSlice = Array.prototype.slice; +var functionsHaveNames = (function () { + return function foo() {}.name === 'foo'; +}()); +function pToString (obj) { + return Object.prototype.toString.call(obj); } - - - -var _isArray = void 0; -if (Array.isArray) { - _isArray = Array.isArray; -} else { - _isArray = function (x) { - return Object.prototype.toString.call(x) === '[object Array]'; - }; +function isView(arrbuf) { + if (isBuffer(arrbuf)) { + return false; + } + if (typeof global.ArrayBuffer !== 'function') { + return false; + } + if (typeof ArrayBuffer.isView === 'function') { + return ArrayBuffer.isView(arrbuf); + } + if (!arrbuf) { + return false; + } + if (arrbuf instanceof DataView) { + return true; + } + if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) { + return true; + } + return false; } +// 1. The assert module provides functions that throw +// AssertionError's when particular conditions are not met. The +// assert module must conform to the following interface. -var isArray = _isArray; +var assert = module.exports = ok; -var len = 0; -var vertxNext = void 0; -var customSchedulerFn = void 0; +// 2. The AssertionError is defined in assert. +// new assert.AssertionError({ message: message, +// actual: actual, +// expected: expected }) -var asap = function asap(callback, arg) { - queue[len] = callback; - queue[len + 1] = arg; - len += 2; - if (len === 2) { - // If len is 2, that means that we need to schedule an async flush. - // If additional callbacks are queued before the queue is flushed, they - // will be processed by this flush that we are scheduling. - if (customSchedulerFn) { - customSchedulerFn(flush); - } else { - scheduleFlush(); +var regex = /\s*function\s+([^\(\s]*)\s*/; +// based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js +function getName(func) { + if (!util.isFunction(func)) { + return; + } + if (functionsHaveNames) { + return func.name; + } + var str = func.toString(); + var match = str.match(regex); + return match && match[1]; +} +assert.AssertionError = function AssertionError(options) { + this.name = 'AssertionError'; + this.actual = options.actual; + this.expected = options.expected; + this.operator = options.operator; + if (options.message) { + this.message = options.message; + this.generatedMessage = false; + } else { + this.message = getMessage(this); + this.generatedMessage = true; + } + var stackStartFunction = options.stackStartFunction || fail; + if (Error.captureStackTrace) { + Error.captureStackTrace(this, stackStartFunction); + } else { + // non v8 browsers so we can have a stacktrace + var err = new Error(); + if (err.stack) { + var out = err.stack; + + // try to strip useless frames + var fn_name = getName(stackStartFunction); + var idx = out.indexOf('\n' + fn_name); + if (idx >= 0) { + // once we have located the function frame + // we need to strip out everything before it (and its line) + var next_line = out.indexOf('\n', idx + 1); + out = out.substring(next_line + 1); + } + + this.stack = out; } } }; -function setScheduler(scheduleFn) { - customSchedulerFn = scheduleFn; +// assert.AssertionError instanceof Error +util.inherits(assert.AssertionError, Error); + +function truncate(s, n) { + if (typeof s === 'string') { + return s.length < n ? s : s.slice(0, n); + } else { + return s; + } +} +function inspect(something) { + if (functionsHaveNames || !util.isFunction(something)) { + return util.inspect(something); + } + var rawname = getName(something); + var name = rawname ? ': ' + rawname : ''; + return '[Function' + name + ']'; +} +function getMessage(self) { + return truncate(inspect(self.actual), 128) + ' ' + + self.operator + ' ' + + truncate(inspect(self.expected), 128); } -function setAsap(asapFn) { - asap = asapFn; +// At present only the three keys mentioned above are used and +// understood by the spec. Implementations or sub modules can pass +// other keys to the AssertionError's constructor - they will be +// ignored. + +// 3. All of the following functions must throw an AssertionError +// when a corresponding condition is not met, with a message that +// may be undefined if not provided. All assertion methods provide +// both the actual and expected values to the assertion error for +// display purposes. + +function fail(actual, expected, message, operator, stackStartFunction) { + throw new assert.AssertionError({ + message: message, + actual: actual, + expected: expected, + operator: operator, + stackStartFunction: stackStartFunction + }); } -var browserWindow = typeof window !== 'undefined' ? window : undefined; -var browserGlobal = browserWindow || {}; -var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; -var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'; +// EXTENSION! allows for well behaved errors defined elsewhere. +assert.fail = fail; -// test for web worker but not in IE10 -var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined'; +// 4. Pure assertion tests whether a value is truthy, as determined +// by !!guard. +// assert.ok(guard, message_opt); +// This statement is equivalent to assert.equal(true, !!guard, +// message_opt);. To test strictly for the value true, use +// assert.strictEqual(true, guard, message_opt);. -// node -function useNextTick() { - // node version 0.10.x displays a deprecation warning when nextTick is used recursively - // see https://github.com/cujojs/when/issues/410 for details - return function () { - return process.nextTick(flush); +function ok(value, message) { + if (!value) fail(value, true, message, '==', assert.ok); +} +assert.ok = ok; + +// 5. The equality assertion tests shallow, coercive equality with +// ==. +// assert.equal(actual, expected, message_opt); + +assert.equal = function equal(actual, expected, message) { + if (actual != expected) fail(actual, expected, message, '==', assert.equal); +}; + +// 6. The non-equality assertion tests for whether two objects are not equal +// with != assert.notEqual(actual, expected, message_opt); + +assert.notEqual = function notEqual(actual, expected, message) { + if (actual == expected) { + fail(actual, expected, message, '!=', assert.notEqual); + } +}; + +// 7. The equivalence assertion tests a deep equality relation. +// assert.deepEqual(actual, expected, message_opt); + +assert.deepEqual = function deepEqual(actual, expected, message) { + if (!_deepEqual(actual, expected, false)) { + fail(actual, expected, message, 'deepEqual', assert.deepEqual); + } +}; + +assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) { + if (!_deepEqual(actual, expected, true)) { + fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual); + } +}; + +function _deepEqual(actual, expected, strict, memos) { + // 7.1. All identical values are equivalent, as determined by ===. + if (actual === expected) { + return true; + } else if (isBuffer(actual) && isBuffer(expected)) { + return compare(actual, expected) === 0; + + // 7.2. If the expected value is a Date object, the actual value is + // equivalent if it is also a Date object that refers to the same time. + } else if (util.isDate(actual) && util.isDate(expected)) { + return actual.getTime() === expected.getTime(); + + // 7.3 If the expected value is a RegExp object, the actual value is + // equivalent if it is also a RegExp object with the same source and + // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`). + } else if (util.isRegExp(actual) && util.isRegExp(expected)) { + return actual.source === expected.source && + actual.global === expected.global && + actual.multiline === expected.multiline && + actual.lastIndex === expected.lastIndex && + actual.ignoreCase === expected.ignoreCase; + + // 7.4. Other pairs that do not both pass typeof value == 'object', + // equivalence is determined by ==. + } else if ((actual === null || typeof actual !== 'object') && + (expected === null || typeof expected !== 'object')) { + return strict ? actual === expected : actual == expected; + + // If both values are instances of typed arrays, wrap their underlying + // ArrayBuffers in a Buffer each to increase performance + // This optimization requires the arrays to have the same type as checked by + // Object.prototype.toString (aka pToString). Never perform binary + // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their + // bit patterns are not identical. + } else if (isView(actual) && isView(expected) && + pToString(actual) === pToString(expected) && + !(actual instanceof Float32Array || + actual instanceof Float64Array)) { + return compare(new Uint8Array(actual.buffer), + new Uint8Array(expected.buffer)) === 0; + + // 7.5 For all other Object pairs, including Array objects, equivalence is + // determined by having the same number of owned properties (as verified + // with Object.prototype.hasOwnProperty.call), the same set of keys + // (although not necessarily the same order), equivalent values for every + // corresponding key, and an identical 'prototype' property. Note: this + // accounts for both named and indexed properties on Arrays. + } else if (isBuffer(actual) !== isBuffer(expected)) { + return false; + } else { + memos = memos || {actual: [], expected: []}; + + var actualIndex = memos.actual.indexOf(actual); + if (actualIndex !== -1) { + if (actualIndex === memos.expected.indexOf(expected)) { + return true; + } + } + + memos.actual.push(actual); + memos.expected.push(expected); + + return objEquiv(actual, expected, strict, memos); + } +} + +function isArguments(object) { + return Object.prototype.toString.call(object) == '[object Arguments]'; +} + +function objEquiv(a, b, strict, actualVisitedObjects) { + if (a === null || a === undefined || b === null || b === undefined) + return false; + // if one is a primitive, the other must be same + if (util.isPrimitive(a) || util.isPrimitive(b)) + return a === b; + if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) + return false; + var aIsArgs = isArguments(a); + var bIsArgs = isArguments(b); + if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs)) + return false; + if (aIsArgs) { + a = pSlice.call(a); + b = pSlice.call(b); + return _deepEqual(a, b, strict); + } + var ka = objectKeys(a); + var kb = objectKeys(b); + var key, i; + // having the same number of owned properties (keys incorporates + // hasOwnProperty) + if (ka.length !== kb.length) + return false; + //the same set of keys (although not necessarily the same order), + ka.sort(); + kb.sort(); + //~~~cheap key test + for (i = ka.length - 1; i >= 0; i--) { + if (ka[i] !== kb[i]) + return false; + } + //equivalent values for every corresponding key, and + //~~~possibly expensive deep test + for (i = ka.length - 1; i >= 0; i--) { + key = ka[i]; + if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects)) + return false; + } + return true; +} + +// 8. The non-equivalence assertion tests for any deep inequality. +// assert.notDeepEqual(actual, expected, message_opt); + +assert.notDeepEqual = function notDeepEqual(actual, expected, message) { + if (_deepEqual(actual, expected, false)) { + fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual); + } +}; + +assert.notDeepStrictEqual = notDeepStrictEqual; +function notDeepStrictEqual(actual, expected, message) { + if (_deepEqual(actual, expected, true)) { + fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual); + } +} + + +// 9. The strict equality assertion tests strict equality, as determined by ===. +// assert.strictEqual(actual, expected, message_opt); + +assert.strictEqual = function strictEqual(actual, expected, message) { + if (actual !== expected) { + fail(actual, expected, message, '===', assert.strictEqual); + } +}; + +// 10. The strict non-equality assertion tests for strict inequality, as +// determined by !==. assert.notStrictEqual(actual, expected, message_opt); + +assert.notStrictEqual = function notStrictEqual(actual, expected, message) { + if (actual === expected) { + fail(actual, expected, message, '!==', assert.notStrictEqual); + } +}; + +function expectedException(actual, expected) { + if (!actual || !expected) { + return false; + } + + if (Object.prototype.toString.call(expected) == '[object RegExp]') { + return expected.test(actual); + } + + try { + if (actual instanceof expected) { + return true; + } + } catch (e) { + // Ignore. The instanceof check doesn't work for arrow functions. + } + + if (Error.isPrototypeOf(expected)) { + return false; + } + + return expected.call({}, actual) === true; +} + +function _tryBlock(block) { + var error; + try { + block(); + } catch (e) { + error = e; + } + return error; +} + +function _throws(shouldThrow, block, expected, message) { + var actual; + + if (typeof block !== 'function') { + throw new TypeError('"block" argument must be a function'); + } + + if (typeof expected === 'string') { + message = expected; + expected = null; + } + + actual = _tryBlock(block); + + message = (expected && expected.name ? ' (' + expected.name + ').' : '.') + + (message ? ' ' + message : '.'); + + if (shouldThrow && !actual) { + fail(actual, expected, 'Missing expected exception' + message); + } + + var userProvidedMessage = typeof message === 'string'; + var isUnwantedException = !shouldThrow && util.isError(actual); + var isUnexpectedException = !shouldThrow && actual && !expected; + + if ((isUnwantedException && + userProvidedMessage && + expectedException(actual, expected)) || + isUnexpectedException) { + fail(actual, expected, 'Got unwanted exception' + message); + } + + if ((shouldThrow && actual && expected && + !expectedException(actual, expected)) || (!shouldThrow && actual)) { + throw actual; + } +} + +// 11. Expected to throw an error: +// assert.throws(block, Error_opt, message_opt); + +assert.throws = function(block, /*optional*/error, /*optional*/message) { + _throws(true, block, error, message); +}; + +// EXTENSION! This is annoying to write outside this module. +assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) { + _throws(false, block, error, message); +}; + +assert.ifError = function(err) { if (err) throw err; }; + +// Expose a strict only variant of assert +function strict(value, message) { + if (!value) fail(value, true, message, '==', strict); +} +assert.strict = objectAssign(strict, assert, { + equal: assert.strictEqual, + deepEqual: assert.deepStrictEqual, + notEqual: assert.notStrictEqual, + notDeepEqual: assert.notDeepStrictEqual +}); +assert.strict.strict = assert.strict; + +var objectKeys = Object.keys || function (obj) { + var keys = []; + for (var key in obj) { + if (hasOwn.call(obj, key)) keys.push(key); + } + return keys; +}; + +}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"object-assign":71,"util/":24}],22:[function(_dereq_,module,exports){ +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } } -// vertx -function useVertxTimer() { - if (typeof vertxNext !== 'undefined') { - return function () { - vertxNext(flush); +},{}],23:[function(_dereq_,module,exports){ +module.exports = function isBuffer(arg) { + return arg && typeof arg === 'object' + && typeof arg.copy === 'function' + && typeof arg.fill === 'function' + && typeof arg.readUInt8 === 'function'; +} +},{}],24:[function(_dereq_,module,exports){ +(function (process,global){(function (){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var formatRegExp = /%[sdj%]/g; +exports.format = function(f) { + if (!isString(f)) { + var objects = []; + for (var i = 0; i < arguments.length; i++) { + objects.push(inspect(arguments[i])); + } + return objects.join(' '); + } + + var i = 1; + var args = arguments; + var len = args.length; + var str = String(f).replace(formatRegExp, function(x) { + if (x === '%%') return '%'; + if (i >= len) return x; + switch (x) { + case '%s': return String(args[i++]); + case '%d': return Number(args[i++]); + case '%j': + try { + return JSON.stringify(args[i++]); + } catch (_) { + return '[Circular]'; + } + default: + return x; + } + }); + for (var x = args[i]; i < len; x = args[++i]) { + if (isNull(x) || !isObject(x)) { + str += ' ' + x; + } else { + str += ' ' + inspect(x); + } + } + return str; +}; + + +// Mark that a method should not be used. +// Returns a modified function which warns once by default. +// If --no-deprecation is set, then it is a no-op. +exports.deprecate = function(fn, msg) { + // Allow for deprecating things in the process of starting up. + if (isUndefined(global.process)) { + return function() { + return exports.deprecate(fn, msg).apply(this, arguments); }; } - return useSetTimeout(); -} - -function useMutationObserver() { - var iterations = 0; - var observer = new BrowserMutationObserver(flush); - var node = document.createTextNode(''); - observer.observe(node, { characterData: true }); - - return function () { - node.data = iterations = ++iterations % 2; - }; -} - -// web worker -function useMessageChannel() { - var channel = new MessageChannel(); - channel.port1.onmessage = flush; - return function () { - return channel.port2.postMessage(0); - }; -} - -function useSetTimeout() { - // Store setTimeout reference so es6-promise will be unaffected by - // other code modifying setTimeout (like sinon.useFakeTimers()) - var globalSetTimeout = setTimeout; - return function () { - return globalSetTimeout(flush, 1); - }; -} - -var queue = new Array(1000); -function flush() { - for (var i = 0; i < len; i += 2) { - var callback = queue[i]; - var arg = queue[i + 1]; - - callback(arg); - - queue[i] = undefined; - queue[i + 1] = undefined; + if (process.noDeprecation === true) { + return fn; } - len = 0; -} - -function attemptVertx() { - try { - var vertx = Function('return this')().require('vertx'); - vertxNext = vertx.runOnLoop || vertx.runOnContext; - return useVertxTimer(); - } catch (e) { - return useSetTimeout(); - } -} - -var scheduleFlush = void 0; -// Decide what async method to use to triggering processing of queued callbacks: -if (isNode) { - scheduleFlush = useNextTick(); -} else if (BrowserMutationObserver) { - scheduleFlush = useMutationObserver(); -} else if (isWorker) { - scheduleFlush = useMessageChannel(); -} else if (browserWindow === undefined && typeof _dereq_ === 'function') { - scheduleFlush = attemptVertx(); -} else { - scheduleFlush = useSetTimeout(); -} - -function then(onFulfillment, onRejection) { - var parent = this; - - var child = new this.constructor(noop); - - if (child[PROMISE_ID] === undefined) { - makePromise(child); - } - - var _state = parent._state; - - - if (_state) { - var callback = arguments[_state - 1]; - asap(function () { - return invokeCallback(_state, child, callback, parent._result); - }); - } else { - subscribe(parent, child, onFulfillment, onRejection); - } - - return child; -} - -/** - `Promise.resolve` returns a promise that will become resolved with the - passed `value`. It is shorthand for the following: - - ```javascript - let promise = new Promise(function(resolve, reject){ - resolve(1); - }); - - promise.then(function(value){ - // value === 1 - }); - ``` - - Instead of writing the above, your code now simply becomes the following: - - ```javascript - let promise = Promise.resolve(1); - - promise.then(function(value){ - // value === 1 - }); - ``` - - @method resolve - @static - @param {Any} value value that the returned promise will be resolved with - Useful for tooling. - @return {Promise} a promise that will become fulfilled with the given - `value` -*/ -function resolve$1(object) { - /*jshint validthis:true */ - var Constructor = this; - - if (object && typeof object === 'object' && object.constructor === Constructor) { - return object; - } - - var promise = new Constructor(noop); - resolve(promise, object); - return promise; -} - -var PROMISE_ID = Math.random().toString(36).substring(2); - -function noop() {} - -var PENDING = void 0; -var FULFILLED = 1; -var REJECTED = 2; - -function selfFulfillment() { - return new TypeError("You cannot resolve a promise with itself"); -} - -function cannotReturnOwn() { - return new TypeError('A promises callback cannot return that same promise.'); -} - -function tryThen(then$$1, value, fulfillmentHandler, rejectionHandler) { - try { - then$$1.call(value, fulfillmentHandler, rejectionHandler); - } catch (e) { - return e; - } -} - -function handleForeignThenable(promise, thenable, then$$1) { - asap(function (promise) { - var sealed = false; - var error = tryThen(then$$1, thenable, function (value) { - if (sealed) { - return; - } - sealed = true; - if (thenable !== value) { - resolve(promise, value); + var warned = false; + function deprecated() { + if (!warned) { + if (process.throwDeprecation) { + throw new Error(msg); + } else if (process.traceDeprecation) { + console.trace(msg); } else { - fulfill(promise, value); + console.error(msg); } - }, function (reason) { - if (sealed) { - return; - } - sealed = true; - - reject(promise, reason); - }, 'Settle: ' + (promise._label || ' unknown promise')); - - if (!sealed && error) { - sealed = true; - reject(promise, error); + warned = true; } - }, promise); -} - -function handleOwnThenable(promise, thenable) { - if (thenable._state === FULFILLED) { - fulfill(promise, thenable._result); - } else if (thenable._state === REJECTED) { - reject(promise, thenable._result); - } else { - subscribe(thenable, undefined, function (value) { - return resolve(promise, value); - }, function (reason) { - return reject(promise, reason); - }); - } -} - -function handleMaybeThenable(promise, maybeThenable, then$$1) { - if (maybeThenable.constructor === promise.constructor && then$$1 === then && maybeThenable.constructor.resolve === resolve$1) { - handleOwnThenable(promise, maybeThenable); - } else { - if (then$$1 === undefined) { - fulfill(promise, maybeThenable); - } else if (isFunction(then$$1)) { - handleForeignThenable(promise, maybeThenable, then$$1); - } else { - fulfill(promise, maybeThenable); - } - } -} - -function resolve(promise, value) { - if (promise === value) { - reject(promise, selfFulfillment()); - } else if (objectOrFunction(value)) { - var then$$1 = void 0; - try { - then$$1 = value.then; - } catch (error) { - reject(promise, error); - return; - } - handleMaybeThenable(promise, value, then$$1); - } else { - fulfill(promise, value); - } -} - -function publishRejection(promise) { - if (promise._onerror) { - promise._onerror(promise._result); + return fn.apply(this, arguments); } - publish(promise); -} - -function fulfill(promise, value) { - if (promise._state !== PENDING) { - return; - } - - promise._result = value; - promise._state = FULFILLED; - - if (promise._subscribers.length !== 0) { - asap(publish, promise); - } -} - -function reject(promise, reason) { - if (promise._state !== PENDING) { - return; - } - promise._state = REJECTED; - promise._result = reason; - - asap(publishRejection, promise); -} - -function subscribe(parent, child, onFulfillment, onRejection) { - var _subscribers = parent._subscribers; - var length = _subscribers.length; - - - parent._onerror = null; - - _subscribers[length] = child; - _subscribers[length + FULFILLED] = onFulfillment; - _subscribers[length + REJECTED] = onRejection; - - if (length === 0 && parent._state) { - asap(publish, parent); - } -} - -function publish(promise) { - var subscribers = promise._subscribers; - var settled = promise._state; - - if (subscribers.length === 0) { - return; - } - - var child = void 0, - callback = void 0, - detail = promise._result; - - for (var i = 0; i < subscribers.length; i += 3) { - child = subscribers[i]; - callback = subscribers[i + settled]; - - if (child) { - invokeCallback(settled, child, callback, detail); - } else { - callback(detail); - } - } - - promise._subscribers.length = 0; -} - -function invokeCallback(settled, promise, callback, detail) { - var hasCallback = isFunction(callback), - value = void 0, - error = void 0, - succeeded = true; - - if (hasCallback) { - try { - value = callback(detail); - } catch (e) { - succeeded = false; - error = e; - } - - if (promise === value) { - reject(promise, cannotReturnOwn()); - return; - } - } else { - value = detail; - } - - if (promise._state !== PENDING) { - // noop - } else if (hasCallback && succeeded) { - resolve(promise, value); - } else if (succeeded === false) { - reject(promise, error); - } else if (settled === FULFILLED) { - fulfill(promise, value); - } else if (settled === REJECTED) { - reject(promise, value); - } -} - -function initializePromise(promise, resolver) { - try { - resolver(function resolvePromise(value) { - resolve(promise, value); - }, function rejectPromise(reason) { - reject(promise, reason); - }); - } catch (e) { - reject(promise, e); - } -} - -var id = 0; -function nextId() { - return id++; -} - -function makePromise(promise) { - promise[PROMISE_ID] = id++; - promise._state = undefined; - promise._result = undefined; - promise._subscribers = []; -} - -function validationError() { - return new Error('Array Methods must be provided an Array'); -} - -var Enumerator = function () { - function Enumerator(Constructor, input) { - this._instanceConstructor = Constructor; - this.promise = new Constructor(noop); - - if (!this.promise[PROMISE_ID]) { - makePromise(this.promise); - } - - if (isArray(input)) { - this.length = input.length; - this._remaining = input.length; - - this._result = new Array(this.length); - - if (this.length === 0) { - fulfill(this.promise, this._result); - } else { - this.length = this.length || 0; - this._enumerate(input); - if (this._remaining === 0) { - fulfill(this.promise, this._result); - } - } - } else { - reject(this.promise, validationError()); - } - } - - Enumerator.prototype._enumerate = function _enumerate(input) { - for (var i = 0; this._state === PENDING && i < input.length; i++) { - this._eachEntry(input[i], i); - } - }; - - Enumerator.prototype._eachEntry = function _eachEntry(entry, i) { - var c = this._instanceConstructor; - var resolve$$1 = c.resolve; - - - if (resolve$$1 === resolve$1) { - var _then = void 0; - var error = void 0; - var didError = false; - try { - _then = entry.then; - } catch (e) { - didError = true; - error = e; - } - - if (_then === then && entry._state !== PENDING) { - this._settledAt(entry._state, i, entry._result); - } else if (typeof _then !== 'function') { - this._remaining--; - this._result[i] = entry; - } else if (c === Promise$1) { - var promise = new c(noop); - if (didError) { - reject(promise, error); - } else { - handleMaybeThenable(promise, entry, _then); - } - this._willSettleAt(promise, i); - } else { - this._willSettleAt(new c(function (resolve$$1) { - return resolve$$1(entry); - }), i); - } - } else { - this._willSettleAt(resolve$$1(entry), i); - } - }; - - Enumerator.prototype._settledAt = function _settledAt(state, i, value) { - var promise = this.promise; - - - if (promise._state === PENDING) { - this._remaining--; - - if (state === REJECTED) { - reject(promise, value); - } else { - this._result[i] = value; - } - } - - if (this._remaining === 0) { - fulfill(promise, this._result); - } - }; - - Enumerator.prototype._willSettleAt = function _willSettleAt(promise, i) { - var enumerator = this; - - subscribe(promise, undefined, function (value) { - return enumerator._settledAt(FULFILLED, i, value); - }, function (reason) { - return enumerator._settledAt(REJECTED, i, reason); - }); - }; - - return Enumerator; -}(); - -/** - `Promise.all` accepts an array of promises, and returns a new promise which - is fulfilled with an array of fulfillment values for the passed promises, or - rejected with the reason of the first passed promise to be rejected. It casts all - elements of the passed iterable to promises as it runs this algorithm. - - Example: - - ```javascript - let promise1 = resolve(1); - let promise2 = resolve(2); - let promise3 = resolve(3); - let promises = [ promise1, promise2, promise3 ]; - - Promise.all(promises).then(function(array){ - // The array here would be [ 1, 2, 3 ]; - }); - ``` - - If any of the `promises` given to `all` are rejected, the first promise - that is rejected will be given as an argument to the returned promises's - rejection handler. For example: - - Example: - - ```javascript - let promise1 = resolve(1); - let promise2 = reject(new Error("2")); - let promise3 = reject(new Error("3")); - let promises = [ promise1, promise2, promise3 ]; - - Promise.all(promises).then(function(array){ - // Code here never runs because there are rejected promises! - }, function(error) { - // error.message === "2" - }); - ``` - - @method all - @static - @param {Array} entries array of promises - @param {String} label optional string for labeling the promise. - Useful for tooling. - @return {Promise} promise that is fulfilled when all `promises` have been - fulfilled, or rejected if any of them become rejected. - @static -*/ -function all(entries) { - return new Enumerator(this, entries).promise; -} - -/** - `Promise.race` returns a new promise which is settled in the same way as the - first passed promise to settle. - - Example: - - ```javascript - let promise1 = new Promise(function(resolve, reject){ - setTimeout(function(){ - resolve('promise 1'); - }, 200); - }); - - let promise2 = new Promise(function(resolve, reject){ - setTimeout(function(){ - resolve('promise 2'); - }, 100); - }); - - Promise.race([promise1, promise2]).then(function(result){ - // result === 'promise 2' because it was resolved before promise1 - // was resolved. - }); - ``` - - `Promise.race` is deterministic in that only the state of the first - settled promise matters. For example, even if other promises given to the - `promises` array argument are resolved, but the first settled promise has - become rejected before the other promises became fulfilled, the returned - promise will become rejected: - - ```javascript - let promise1 = new Promise(function(resolve, reject){ - setTimeout(function(){ - resolve('promise 1'); - }, 200); - }); - - let promise2 = new Promise(function(resolve, reject){ - setTimeout(function(){ - reject(new Error('promise 2')); - }, 100); - }); - - Promise.race([promise1, promise2]).then(function(result){ - // Code here never runs - }, function(reason){ - // reason.message === 'promise 2' because promise 2 became rejected before - // promise 1 became fulfilled - }); - ``` - - An example real-world use case is implementing timeouts: - - ```javascript - Promise.race([ajax('foo.json'), timeout(5000)]) - ``` - - @method race - @static - @param {Array} promises array of promises to observe - Useful for tooling. - @return {Promise} a promise which settles in the same way as the first passed - promise to settle. -*/ -function race(entries) { - /*jshint validthis:true */ - var Constructor = this; - - if (!isArray(entries)) { - return new Constructor(function (_, reject) { - return reject(new TypeError('You must pass an array to race.')); - }); - } else { - return new Constructor(function (resolve, reject) { - var length = entries.length; - for (var i = 0; i < length; i++) { - Constructor.resolve(entries[i]).then(resolve, reject); - } - }); - } -} - -/** - `Promise.reject` returns a promise rejected with the passed `reason`. - It is shorthand for the following: - - ```javascript - let promise = new Promise(function(resolve, reject){ - reject(new Error('WHOOPS')); - }); - - promise.then(function(value){ - // Code here doesn't run because the promise is rejected! - }, function(reason){ - // reason.message === 'WHOOPS' - }); - ``` - - Instead of writing the above, your code now simply becomes the following: - - ```javascript - let promise = Promise.reject(new Error('WHOOPS')); - - promise.then(function(value){ - // Code here doesn't run because the promise is rejected! - }, function(reason){ - // reason.message === 'WHOOPS' - }); - ``` - - @method reject - @static - @param {Any} reason value that the returned promise will be rejected with. - Useful for tooling. - @return {Promise} a promise rejected with the given `reason`. -*/ -function reject$1(reason) { - /*jshint validthis:true */ - var Constructor = this; - var promise = new Constructor(noop); - reject(promise, reason); - return promise; -} - -function needsResolver() { - throw new TypeError('You must pass a resolver function as the first argument to the promise constructor'); -} - -function needsNew() { - throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function."); -} - -/** - Promise objects represent the eventual result of an asynchronous operation. The - primary way of interacting with a promise is through its `then` method, which - registers callbacks to receive either a promise's eventual value or the reason - why the promise cannot be fulfilled. - - Terminology - ----------- - - - `promise` is an object or function with a `then` method whose behavior conforms to this specification. - - `thenable` is an object or function that defines a `then` method. - - `value` is any legal JavaScript value (including undefined, a thenable, or a promise). - - `exception` is a value that is thrown using the throw statement. - - `reason` is a value that indicates why a promise was rejected. - - `settled` the final resting state of a promise, fulfilled or rejected. - - A promise can be in one of three states: pending, fulfilled, or rejected. - - Promises that are fulfilled have a fulfillment value and are in the fulfilled - state. Promises that are rejected have a rejection reason and are in the - rejected state. A fulfillment value is never a thenable. - - Promises can also be said to *resolve* a value. If this value is also a - promise, then the original promise's settled state will match the value's - settled state. So a promise that *resolves* a promise that rejects will - itself reject, and a promise that *resolves* a promise that fulfills will - itself fulfill. - - - Basic Usage: - ------------ - - ```js - let promise = new Promise(function(resolve, reject) { - // on success - resolve(value); - - // on failure - reject(reason); - }); - - promise.then(function(value) { - // on fulfillment - }, function(reason) { - // on rejection - }); - ``` - - Advanced Usage: - --------------- - - Promises shine when abstracting away asynchronous interactions such as - `XMLHttpRequest`s. - - ```js - function getJSON(url) { - return new Promise(function(resolve, reject){ - let xhr = new XMLHttpRequest(); - - xhr.open('GET', url); - xhr.onreadystatechange = handler; - xhr.responseType = 'json'; - xhr.setRequestHeader('Accept', 'application/json'); - xhr.send(); - - function handler() { - if (this.readyState === this.DONE) { - if (this.status === 200) { - resolve(this.response); - } else { - reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']')); - } - } + return deprecated; +}; + + +var debugs = {}; +var debugEnviron; +exports.debuglog = function(set) { + if (isUndefined(debugEnviron)) + debugEnviron = process.env.NODE_DEBUG || ''; + set = set.toUpperCase(); + if (!debugs[set]) { + if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { + var pid = process.pid; + debugs[set] = function() { + var msg = exports.format.apply(exports, arguments); + console.error('%s %d: %s', set, pid, msg); }; - }); - } - - getJSON('/posts.json').then(function(json) { - // on fulfillment - }, function(reason) { - // on rejection - }); - ``` - - Unlike callbacks, promises are great composable primitives. - - ```js - Promise.all([ - getJSON('/posts'), - getJSON('/comments') - ]).then(function(values){ - values[0] // => postsJSON - values[1] // => commentsJSON - - return values; - }); - ``` - - @class Promise - @param {Function} resolver - Useful for tooling. - @constructor -*/ - -var Promise$1 = function () { - function Promise(resolver) { - this[PROMISE_ID] = nextId(); - this._result = this._state = undefined; - this._subscribers = []; - - if (noop !== resolver) { - typeof resolver !== 'function' && needsResolver(); - this instanceof Promise ? initializePromise(this, resolver) : needsNew(); - } - } - - /** - The primary way of interacting with a promise is through its `then` method, - which registers callbacks to receive either a promise's eventual value or the - reason why the promise cannot be fulfilled. - ```js - findUser().then(function(user){ - // user is available - }, function(reason){ - // user is unavailable, and you are given the reason why - }); - ``` - Chaining - -------- - The return value of `then` is itself a promise. This second, 'downstream' - promise is resolved with the return value of the first promise's fulfillment - or rejection handler, or rejected if the handler throws an exception. - ```js - findUser().then(function (user) { - return user.name; - }, function (reason) { - return 'default name'; - }).then(function (userName) { - // If `findUser` fulfilled, `userName` will be the user's name, otherwise it - // will be `'default name'` - }); - findUser().then(function (user) { - throw new Error('Found user, but still unhappy'); - }, function (reason) { - throw new Error('`findUser` rejected and we're unhappy'); - }).then(function (value) { - // never reached - }, function (reason) { - // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. - // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. - }); - ``` - If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. - ```js - findUser().then(function (user) { - throw new PedagogicalException('Upstream error'); - }).then(function (value) { - // never reached - }).then(function (value) { - // never reached - }, function (reason) { - // The `PedgagocialException` is propagated all the way down to here - }); - ``` - Assimilation - ------------ - Sometimes the value you want to propagate to a downstream promise can only be - retrieved asynchronously. This can be achieved by returning a promise in the - fulfillment or rejection handler. The downstream promise will then be pending - until the returned promise is settled. This is called *assimilation*. - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // The user's comments are now available - }); - ``` - If the assimliated promise rejects, then the downstream promise will also reject. - ```js - findUser().then(function (user) { - return findCommentsByAuthor(user); - }).then(function (comments) { - // If `findCommentsByAuthor` fulfills, we'll have the value here - }, function (reason) { - // If `findCommentsByAuthor` rejects, we'll have the reason here - }); - ``` - Simple Example - -------------- - Synchronous Example - ```javascript - let result; - try { - result = findResult(); - // success - } catch(reason) { - // failure - } - ``` - Errback Example - ```js - findResult(function(result, err){ - if (err) { - // failure } else { - // success + debugs[set] = function() {}; } - }); - ``` - Promise Example; - ```javascript - findResult().then(function(result){ - // success - }, function(reason){ - // failure - }); - ``` - Advanced Example - -------------- - Synchronous Example - ```javascript - let author, books; - try { - author = findAuthor(); - books = findBooksByAuthor(author); - // success - } catch(reason) { - // failure } - ``` - Errback Example - ```js - function foundBooks(books) { - } - function failure(reason) { - } - findAuthor(function(author, err){ - if (err) { - failure(err); - // failure - } else { - try { - findBoooksByAuthor(author, function(books, err) { - if (err) { - failure(err); - } else { - try { - foundBooks(books); - } catch(reason) { - failure(reason); - } - } - }); - } catch(error) { - failure(err); - } - // success - } - }); - ``` - Promise Example; - ```javascript - findAuthor(). - then(findBooksByAuthor). - then(function(books){ - // found books - }).catch(function(reason){ - // something went wrong - }); - ``` - @method then - @param {Function} onFulfilled - @param {Function} onRejected - Useful for tooling. - @return {Promise} - */ - - /** - `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same - as the catch block of a try/catch statement. - ```js - function findAuthor(){ - throw new Error('couldn't find that author'); - } - // synchronous - try { - findAuthor(); - } catch(reason) { - // something went wrong - } - // async with promises - findAuthor().catch(function(reason){ - // something went wrong - }); - ``` - @method catch - @param {Function} onRejection - Useful for tooling. - @return {Promise} - */ + return debugs[set]; +}; - Promise.prototype.catch = function _catch(onRejection) { - return this.then(null, onRejection); +/** + * Echos the value of a value. Trys to print the value out + * in the best way possible given the different types. + * + * @param {Object} obj The object to print out. + * @param {Object} opts Optional options object that alters the output. + */ +/* legacy: obj, showHidden, depth, colors*/ +function inspect(obj, opts) { + // default options + var ctx = { + seen: [], + stylize: stylizeNoColor }; - - /** - `finally` will be invoked regardless of the promise's fate just as native - try/catch/finally behaves - - Synchronous example: - - ```js - findAuthor() { - if (Math.random() > 0.5) { - throw new Error(); - } - return new Author(); - } - - try { - return findAuthor(); // succeed or fail - } catch(error) { - return findOtherAuther(); - } finally { - // always runs - // doesn't affect the return value - } - ``` - - Asynchronous example: - - ```js - findAuthor().catch(function(reason){ - return findOtherAuther(); - }).finally(function(){ - // author was either found, or not - }); - ``` - - @method finally - @param {Function} callback - @return {Promise} - */ + // legacy... + if (arguments.length >= 3) ctx.depth = arguments[2]; + if (arguments.length >= 4) ctx.colors = arguments[3]; + if (isBoolean(opts)) { + // legacy... + ctx.showHidden = opts; + } else if (opts) { + // got an "options" object + exports._extend(ctx, opts); + } + // set default options + if (isUndefined(ctx.showHidden)) ctx.showHidden = false; + if (isUndefined(ctx.depth)) ctx.depth = 2; + if (isUndefined(ctx.colors)) ctx.colors = false; + if (isUndefined(ctx.customInspect)) ctx.customInspect = true; + if (ctx.colors) ctx.stylize = stylizeWithColor; + return formatValue(ctx, obj, ctx.depth); +} +exports.inspect = inspect; - Promise.prototype.finally = function _finally(callback) { - var promise = this; - var constructor = promise.constructor; +// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics +inspect.colors = { + 'bold' : [1, 22], + 'italic' : [3, 23], + 'underline' : [4, 24], + 'inverse' : [7, 27], + 'white' : [37, 39], + 'grey' : [90, 39], + 'black' : [30, 39], + 'blue' : [34, 39], + 'cyan' : [36, 39], + 'green' : [32, 39], + 'magenta' : [35, 39], + 'red' : [31, 39], + 'yellow' : [33, 39] +}; - if (isFunction(callback)) { - return promise.then(function (value) { - return constructor.resolve(callback()).then(function () { - return value; - }); - }, function (reason) { - return constructor.resolve(callback()).then(function () { - throw reason; - }); - }); - } +// Don't use 'blue' not visible on cmd.exe +inspect.styles = { + 'special': 'cyan', + 'number': 'yellow', + 'boolean': 'yellow', + 'undefined': 'grey', + 'null': 'bold', + 'string': 'green', + 'date': 'magenta', + // "name": intentionally not styling + 'regexp': 'red' +}; - return promise.then(callback, callback); - }; - return Promise; -}(); +function stylizeWithColor(str, styleType) { + var style = inspect.styles[styleType]; -Promise$1.prototype.then = then; -Promise$1.all = all; -Promise$1.race = race; -Promise$1.resolve = resolve$1; -Promise$1.reject = reject$1; -Promise$1._setScheduler = setScheduler; -Promise$1._setAsap = setAsap; -Promise$1._asap = asap; - -/*global self*/ -function polyfill() { - var local = void 0; - - if (typeof global !== 'undefined') { - local = global; - } else if (typeof self !== 'undefined') { - local = self; + if (style) { + return '\u001b[' + inspect.colors[style][0] + 'm' + str + + '\u001b[' + inspect.colors[style][1] + 'm'; } else { - try { - local = Function('return this')(); - } catch (e) { - throw new Error('polyfill failed because global object is unavailable in this environment'); - } + return str; } - - var P = local.Promise; - - if (P) { - var promiseToString = null; - try { - promiseToString = Object.prototype.toString.call(P.resolve()); - } catch (e) { - // silently ignored - } - - if (promiseToString === '[object Promise]' && !P.cast) { - return; - } - } - - local.Promise = Promise$1; } -// Strange compat.. -Promise$1.polyfill = polyfill; -Promise$1.Promise = Promise$1; -return Promise$1; - -}))); +function stylizeNoColor(str, styleType) { + return str; +} +function arrayToHash(array) { + var hash = {}; + + array.forEach(function(val, idx) { + hash[val] = true; + }); + + return hash; +} +function formatValue(ctx, value, recurseTimes) { + // Provide a hook for user-specified inspect functions. + // Check that value is an object with an inspect function on it + if (ctx.customInspect && + value && + isFunction(value.inspect) && + // Filter out the util module, it's inspect function is special + value.inspect !== exports.inspect && + // Also filter out any prototype objects using the circular check. + !(value.constructor && value.constructor.prototype === value)) { + var ret = value.inspect(recurseTimes, ctx); + if (!isString(ret)) { + ret = formatValue(ctx, ret, recurseTimes); + } + return ret; + } + + // Primitive types cannot have properties + var primitive = formatPrimitive(ctx, value); + if (primitive) { + return primitive; + } + + // Look up the keys of the object. + var keys = Object.keys(value); + var visibleKeys = arrayToHash(keys); + + if (ctx.showHidden) { + keys = Object.getOwnPropertyNames(value); + } + + // IE doesn't make error fields non-enumerable + // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx + if (isError(value) + && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { + return formatError(value); + } + + // Some type of object without properties can be shortcutted. + if (keys.length === 0) { + if (isFunction(value)) { + var name = value.name ? ': ' + value.name : ''; + return ctx.stylize('[Function' + name + ']', 'special'); + } + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } + if (isDate(value)) { + return ctx.stylize(Date.prototype.toString.call(value), 'date'); + } + if (isError(value)) { + return formatError(value); + } + } + + var base = '', array = false, braces = ['{', '}']; + + // Make Array say that they are Array + if (isArray(value)) { + array = true; + braces = ['[', ']']; + } + + // Make functions say that they are functions + if (isFunction(value)) { + var n = value.name ? ': ' + value.name : ''; + base = ' [Function' + n + ']'; + } + + // Make RegExps say that they are RegExps + if (isRegExp(value)) { + base = ' ' + RegExp.prototype.toString.call(value); + } + + // Make dates with properties first say the date + if (isDate(value)) { + base = ' ' + Date.prototype.toUTCString.call(value); + } + + // Make error with message first say the error + if (isError(value)) { + base = ' ' + formatError(value); + } + + if (keys.length === 0 && (!array || value.length == 0)) { + return braces[0] + base + braces[1]; + } + + if (recurseTimes < 0) { + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } else { + return ctx.stylize('[Object]', 'special'); + } + } + + ctx.seen.push(value); + + var output; + if (array) { + output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); + } else { + output = keys.map(function(key) { + return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); + }); + } + + ctx.seen.pop(); + + return reduceToSingleString(output, base, braces); +} + + +function formatPrimitive(ctx, value) { + if (isUndefined(value)) + return ctx.stylize('undefined', 'undefined'); + if (isString(value)) { + var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') + .replace(/'/g, "\\'") + .replace(/\\"/g, '"') + '\''; + return ctx.stylize(simple, 'string'); + } + if (isNumber(value)) + return ctx.stylize('' + value, 'number'); + if (isBoolean(value)) + return ctx.stylize('' + value, 'boolean'); + // For some reason typeof null is "object", so special case here. + if (isNull(value)) + return ctx.stylize('null', 'null'); +} + + +function formatError(value) { + return '[' + Error.prototype.toString.call(value) + ']'; +} + + +function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { + var output = []; + for (var i = 0, l = value.length; i < l; ++i) { + if (hasOwnProperty(value, String(i))) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + String(i), true)); + } else { + output.push(''); + } + } + keys.forEach(function(key) { + if (!key.match(/^\d+$/)) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + key, true)); + } + }); + return output; +} + + +function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { + var name, str, desc; + desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; + if (desc.get) { + if (desc.set) { + str = ctx.stylize('[Getter/Setter]', 'special'); + } else { + str = ctx.stylize('[Getter]', 'special'); + } + } else { + if (desc.set) { + str = ctx.stylize('[Setter]', 'special'); + } + } + if (!hasOwnProperty(visibleKeys, key)) { + name = '[' + key + ']'; + } + if (!str) { + if (ctx.seen.indexOf(desc.value) < 0) { + if (isNull(recurseTimes)) { + str = formatValue(ctx, desc.value, null); + } else { + str = formatValue(ctx, desc.value, recurseTimes - 1); + } + if (str.indexOf('\n') > -1) { + if (array) { + str = str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n').substr(2); + } else { + str = '\n' + str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n'); + } + } + } else { + str = ctx.stylize('[Circular]', 'special'); + } + } + if (isUndefined(name)) { + if (array && key.match(/^\d+$/)) { + return str; + } + name = JSON.stringify('' + key); + if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { + name = name.substr(1, name.length - 2); + name = ctx.stylize(name, 'name'); + } else { + name = name.replace(/'/g, "\\'") + .replace(/\\"/g, '"') + .replace(/(^"|"$)/g, "'"); + name = ctx.stylize(name, 'string'); + } + } + + return name + ': ' + str; +} + + +function reduceToSingleString(output, base, braces) { + var numLinesEst = 0; + var length = output.reduce(function(prev, cur) { + numLinesEst++; + if (cur.indexOf('\n') >= 0) numLinesEst++; + return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; + }, 0); + + if (length > 60) { + return braces[0] + + (base === '' ? '' : base + '\n ') + + ' ' + + output.join(',\n ') + + ' ' + + braces[1]; + } + + return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; +} + + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. +function isArray(ar) { + return Array.isArray(ar); +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return isObject(d) && objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return isObject(e) && + (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +exports.isBuffer = _dereq_('./support/isBuffer'); + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + + +function pad(n) { + return n < 10 ? '0' + n.toString(10) : n.toString(10); +} + + +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', + 'Oct', 'Nov', 'Dec']; + +// 26 Feb 16:19:34 +function timestamp() { + var d = new Date(); + var time = [pad(d.getHours()), + pad(d.getMinutes()), + pad(d.getSeconds())].join(':'); + return [d.getDate(), months[d.getMonth()], time].join(' '); +} + + +// log is just a thin wrapper to console.log that prepends a timestamp +exports.log = function() { + console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); +}; + + +/** + * Inherit the prototype methods from one constructor into another. + * + * The Function.prototype.inherits from lang.js rewritten as a standalone + * function (not on Function.prototype). NOTE: If this file is to be loaded + * during bootstrapping this function needs to be rewritten using some native + * functions as prototype setup using normal JavaScript does not work as + * expected during bootstrapping (see mirror.js in r114903). + * + * @param {function} ctor Constructor function which needs to inherit the + * prototype. + * @param {function} superCtor Constructor function to inherit prototype from. + */ +exports.inherits = _dereq_('inherits'); + +exports._extend = function(origin, add) { + // Don't do anything if add isn't an object + if (!add || !isObject(add)) return origin; + + var keys = Object.keys(add); + var i = keys.length; + while (i--) { + origin[keys[i]] = add[keys[i]]; + } + return origin; +}; + +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} }).call(this)}).call(this,_dereq_('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":87}],23:[function(_dereq_,module,exports){ +},{"./support/isBuffer":23,"_process":96,"inherits":22}],25:[function(_dereq_,module,exports){ +'use strict' + +exports.byteLength = byteLength +exports.toByteArray = toByteArray +exports.fromByteArray = fromByteArray + +var lookup = [] +var revLookup = [] +var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array + +var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' +for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i] + revLookup[code.charCodeAt(i)] = i +} + +// Support decoding URL-safe base64 strings, as Node.js does. +// See: https://en.wikipedia.org/wiki/Base64#URL_applications +revLookup['-'.charCodeAt(0)] = 62 +revLookup['_'.charCodeAt(0)] = 63 + +function getLens (b64) { + var len = b64.length + + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // Trim off extra bytes after placeholder bytes are found + // See: https://github.com/beatgammit/base64-js/issues/42 + var validLen = b64.indexOf('=') + if (validLen === -1) validLen = len + + var placeHoldersLen = validLen === len + ? 0 + : 4 - (validLen % 4) + + return [validLen, placeHoldersLen] +} + +// base64 is 4/3 + up to two characters of the original data +function byteLength (b64) { + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen +} + +function _byteLength (b64, validLen, placeHoldersLen) { + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen +} + +function toByteArray (b64) { + var tmp + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + + var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) + + var curByte = 0 + + // if there are placeholders, only get up to the last complete 4 chars + var len = placeHoldersLen > 0 + ? validLen - 4 + : validLen + + var i + for (i = 0; i < len; i += 4) { + tmp = + (revLookup[b64.charCodeAt(i)] << 18) | + (revLookup[b64.charCodeAt(i + 1)] << 12) | + (revLookup[b64.charCodeAt(i + 2)] << 6) | + revLookup[b64.charCodeAt(i + 3)] + arr[curByte++] = (tmp >> 16) & 0xFF + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } + + if (placeHoldersLen === 2) { + tmp = + (revLookup[b64.charCodeAt(i)] << 2) | + (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[curByte++] = tmp & 0xFF + } + + if (placeHoldersLen === 1) { + tmp = + (revLookup[b64.charCodeAt(i)] << 10) | + (revLookup[b64.charCodeAt(i + 1)] << 4) | + (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } + + return arr +} + +function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + + lookup[num >> 12 & 0x3F] + + lookup[num >> 6 & 0x3F] + + lookup[num & 0x3F] +} + +function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = + ((uint8[i] << 16) & 0xFF0000) + + ((uint8[i + 1] << 8) & 0xFF00) + + (uint8[i + 2] & 0xFF) + output.push(tripletToBase64(tmp)) + } + return output.join('') +} + +function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk( + uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) + )) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + parts.push( + lookup[tmp >> 2] + + lookup[(tmp << 4) & 0x3F] + + '==' + ) + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + uint8[len - 1] + parts.push( + lookup[tmp >> 10] + + lookup[(tmp >> 4) & 0x3F] + + lookup[(tmp << 2) & 0x3F] + + '=' + ) + } + + return parts.join('') +} + +},{}],26:[function(_dereq_,module,exports){ + +},{}],27:[function(_dereq_,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +'use strict'; + +var R = typeof Reflect === 'object' ? Reflect : null +var ReflectApply = R && typeof R.apply === 'function' + ? R.apply + : function ReflectApply(target, receiver, args) { + return Function.prototype.apply.call(target, receiver, args); + } + +var ReflectOwnKeys +if (R && typeof R.ownKeys === 'function') { + ReflectOwnKeys = R.ownKeys +} else if (Object.getOwnPropertySymbols) { + ReflectOwnKeys = function ReflectOwnKeys(target) { + return Object.getOwnPropertyNames(target) + .concat(Object.getOwnPropertySymbols(target)); + }; +} else { + ReflectOwnKeys = function ReflectOwnKeys(target) { + return Object.getOwnPropertyNames(target); + }; +} + +function ProcessEmitWarning(warning) { + if (console && console.warn) console.warn(warning); +} + +var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) { + return value !== value; +} + +function EventEmitter() { + EventEmitter.init.call(this); +} +module.exports = EventEmitter; +module.exports.once = once; + +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; + +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._eventsCount = 0; +EventEmitter.prototype._maxListeners = undefined; + +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +var defaultMaxListeners = 10; + +function checkListener(listener) { + if (typeof listener !== 'function') { + throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); + } +} + +Object.defineProperty(EventEmitter, 'defaultMaxListeners', { + enumerable: true, + get: function() { + return defaultMaxListeners; + }, + set: function(arg) { + if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) { + throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.'); + } + defaultMaxListeners = arg; + } +}); + +EventEmitter.init = function() { + + if (this._events === undefined || + this._events === Object.getPrototypeOf(this)._events) { + this._events = Object.create(null); + this._eventsCount = 0; + } + + this._maxListeners = this._maxListeners || undefined; +}; + +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { + if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) { + throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.'); + } + this._maxListeners = n; + return this; +}; + +function _getMaxListeners(that) { + if (that._maxListeners === undefined) + return EventEmitter.defaultMaxListeners; + return that._maxListeners; +} + +EventEmitter.prototype.getMaxListeners = function getMaxListeners() { + return _getMaxListeners(this); +}; + +EventEmitter.prototype.emit = function emit(type) { + var args = []; + for (var i = 1; i < arguments.length; i++) args.push(arguments[i]); + var doError = (type === 'error'); + + var events = this._events; + if (events !== undefined) + doError = (doError && events.error === undefined); + else if (!doError) + return false; + + // If there is no 'error' event listener then throw. + if (doError) { + var er; + if (args.length > 0) + er = args[0]; + if (er instanceof Error) { + // Note: The comments on the `throw` lines are intentional, they show + // up in Node's output if this results in an unhandled exception. + throw er; // Unhandled 'error' event + } + // At least give some kind of context to the user + var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : '')); + err.context = er; + throw err; // Unhandled 'error' event + } + + var handler = events[type]; + + if (handler === undefined) + return false; + + if (typeof handler === 'function') { + ReflectApply(handler, this, args); + } else { + var len = handler.length; + var listeners = arrayClone(handler, len); + for (var i = 0; i < len; ++i) + ReflectApply(listeners[i], this, args); + } + + return true; +}; + +function _addListener(target, type, listener, prepend) { + var m; + var events; + var existing; + + checkListener(listener); + + events = target._events; + if (events === undefined) { + events = target._events = Object.create(null); + target._eventsCount = 0; + } else { + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (events.newListener !== undefined) { + target.emit('newListener', type, + listener.listener ? listener.listener : listener); + + // Re-assign `events` because a newListener handler could have caused the + // this._events to be assigned to a new object + events = target._events; + } + existing = events[type]; + } + + if (existing === undefined) { + // Optimize the case of one listener. Don't need the extra array object. + existing = events[type] = listener; + ++target._eventsCount; + } else { + if (typeof existing === 'function') { + // Adding the second element, need to change to array. + existing = events[type] = + prepend ? [listener, existing] : [existing, listener]; + // If we've already got an array, just append. + } else if (prepend) { + existing.unshift(listener); + } else { + existing.push(listener); + } + + // Check for listener leak + m = _getMaxListeners(target); + if (m > 0 && existing.length > m && !existing.warned) { + existing.warned = true; + // No error code for this since it is a Warning + // eslint-disable-next-line no-restricted-syntax + var w = new Error('Possible EventEmitter memory leak detected. ' + + existing.length + ' ' + String(type) + ' listeners ' + + 'added. Use emitter.setMaxListeners() to ' + + 'increase limit'); + w.name = 'MaxListenersExceededWarning'; + w.emitter = target; + w.type = type; + w.count = existing.length; + ProcessEmitWarning(w); + } + } + + return target; +} + +EventEmitter.prototype.addListener = function addListener(type, listener) { + return _addListener(this, type, listener, false); +}; + +EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +EventEmitter.prototype.prependListener = + function prependListener(type, listener) { + return _addListener(this, type, listener, true); + }; + +function onceWrapper() { + if (!this.fired) { + this.target.removeListener(this.type, this.wrapFn); + this.fired = true; + if (arguments.length === 0) + return this.listener.call(this.target); + return this.listener.apply(this.target, arguments); + } +} + +function _onceWrap(target, type, listener) { + var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener }; + var wrapped = onceWrapper.bind(state); + wrapped.listener = listener; + state.wrapFn = wrapped; + return wrapped; +} + +EventEmitter.prototype.once = function once(type, listener) { + checkListener(listener); + this.on(type, _onceWrap(this, type, listener)); + return this; +}; + +EventEmitter.prototype.prependOnceListener = + function prependOnceListener(type, listener) { + checkListener(listener); + this.prependListener(type, _onceWrap(this, type, listener)); + return this; + }; + +// Emits a 'removeListener' event if and only if the listener was removed. +EventEmitter.prototype.removeListener = + function removeListener(type, listener) { + var list, events, position, i, originalListener; + + checkListener(listener); + + events = this._events; + if (events === undefined) + return this; + + list = events[type]; + if (list === undefined) + return this; + + if (list === listener || list.listener === listener) { + if (--this._eventsCount === 0) + this._events = Object.create(null); + else { + delete events[type]; + if (events.removeListener) + this.emit('removeListener', type, list.listener || listener); + } + } else if (typeof list !== 'function') { + position = -1; + + for (i = list.length - 1; i >= 0; i--) { + if (list[i] === listener || list[i].listener === listener) { + originalListener = list[i].listener; + position = i; + break; + } + } + + if (position < 0) + return this; + + if (position === 0) + list.shift(); + else { + spliceOne(list, position); + } + + if (list.length === 1) + events[type] = list[0]; + + if (events.removeListener !== undefined) + this.emit('removeListener', type, originalListener || listener); + } + + return this; + }; + +EventEmitter.prototype.off = EventEmitter.prototype.removeListener; + +EventEmitter.prototype.removeAllListeners = + function removeAllListeners(type) { + var listeners, events, i; + + events = this._events; + if (events === undefined) + return this; + + // not listening for removeListener, no need to emit + if (events.removeListener === undefined) { + if (arguments.length === 0) { + this._events = Object.create(null); + this._eventsCount = 0; + } else if (events[type] !== undefined) { + if (--this._eventsCount === 0) + this._events = Object.create(null); + else + delete events[type]; + } + return this; + } + + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + var keys = Object.keys(events); + var key; + for (i = 0; i < keys.length; ++i) { + key = keys[i]; + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = Object.create(null); + this._eventsCount = 0; + return this; + } + + listeners = events[type]; + + if (typeof listeners === 'function') { + this.removeListener(type, listeners); + } else if (listeners !== undefined) { + // LIFO order + for (i = listeners.length - 1; i >= 0; i--) { + this.removeListener(type, listeners[i]); + } + } + + return this; + }; + +function _listeners(target, type, unwrap) { + var events = target._events; + + if (events === undefined) + return []; + + var evlistener = events[type]; + if (evlistener === undefined) + return []; + + if (typeof evlistener === 'function') + return unwrap ? [evlistener.listener || evlistener] : [evlistener]; + + return unwrap ? + unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length); +} + +EventEmitter.prototype.listeners = function listeners(type) { + return _listeners(this, type, true); +}; + +EventEmitter.prototype.rawListeners = function rawListeners(type) { + return _listeners(this, type, false); +}; + +EventEmitter.listenerCount = function(emitter, type) { + if (typeof emitter.listenerCount === 'function') { + return emitter.listenerCount(type); + } else { + return listenerCount.call(emitter, type); + } +}; + +EventEmitter.prototype.listenerCount = listenerCount; +function listenerCount(type) { + var events = this._events; + + if (events !== undefined) { + var evlistener = events[type]; + + if (typeof evlistener === 'function') { + return 1; + } else if (evlistener !== undefined) { + return evlistener.length; + } + } + + return 0; +} + +EventEmitter.prototype.eventNames = function eventNames() { + return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []; +}; + +function arrayClone(arr, n) { + var copy = new Array(n); + for (var i = 0; i < n; ++i) + copy[i] = arr[i]; + return copy; +} + +function spliceOne(list, index) { + for (; index + 1 < list.length; index++) + list[index] = list[index + 1]; + list.pop(); +} + +function unwrapListeners(arr) { + var ret = new Array(arr.length); + for (var i = 0; i < ret.length; ++i) { + ret[i] = arr[i].listener || arr[i]; + } + return ret; +} + +function once(emitter, name) { + return new Promise(function (resolve, reject) { + function eventListener() { + if (errorListener !== undefined) { + emitter.removeListener('error', errorListener); + } + resolve([].slice.call(arguments)); + }; + var errorListener; + + // Adding an error listener is not optional because + // if an error is thrown on an event emitter we cannot + // guarantee that the actual event we are waiting will + // be fired. The result could be a silent way to create + // memory or file descriptor leaks, which is something + // we should avoid. + if (name !== 'error') { + errorListener = function errorListener(err) { + emitter.removeListener(name, eventListener); + reject(err); + }; + + emitter.once('error', errorListener); + } + + emitter.once(name, eventListener); + }); +} + +},{}],28:[function(_dereq_,module,exports){ +(function (Buffer){(function (){ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +/* eslint-disable no-proto */ + +'use strict' + +var base64 = _dereq_('base64-js') +var ieee754 = _dereq_('ieee754') + +exports.Buffer = Buffer +exports.SlowBuffer = SlowBuffer +exports.INSPECT_MAX_BYTES = 50 + +var K_MAX_LENGTH = 0x7fffffff +exports.kMaxLength = K_MAX_LENGTH + +/** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Print warning and recommend using `buffer` v4.x which has an Object + * implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * We report that the browser does not support typed arrays if the are not subclassable + * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` + * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support + * for __proto__ and has a buggy typed array implementation. + */ +Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport() + +if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' && + typeof console.error === 'function') { + console.error( + 'This browser lacks typed array (Uint8Array) support which is required by ' + + '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.' + ) +} + +function typedArraySupport () { + // Can typed array instances can be augmented? + try { + var arr = new Uint8Array(1) + arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } } + return arr.foo() === 42 + } catch (e) { + return false + } +} + +Object.defineProperty(Buffer.prototype, 'parent', { + enumerable: true, + get: function () { + if (!Buffer.isBuffer(this)) return undefined + return this.buffer + } +}) + +Object.defineProperty(Buffer.prototype, 'offset', { + enumerable: true, + get: function () { + if (!Buffer.isBuffer(this)) return undefined + return this.byteOffset + } +}) + +function createBuffer (length) { + if (length > K_MAX_LENGTH) { + throw new RangeError('The value "' + length + '" is invalid for option "size"') + } + // Return an augmented `Uint8Array` instance + var buf = new Uint8Array(length) + buf.__proto__ = Buffer.prototype + return buf +} + +/** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ + +function Buffer (arg, encodingOrOffset, length) { + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new TypeError( + 'The "string" argument must be of type string. Received type number' + ) + } + return allocUnsafe(arg) + } + return from(arg, encodingOrOffset, length) +} + +// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 +if (typeof Symbol !== 'undefined' && Symbol.species != null && + Buffer[Symbol.species] === Buffer) { + Object.defineProperty(Buffer, Symbol.species, { + value: null, + configurable: true, + enumerable: false, + writable: false + }) +} + +Buffer.poolSize = 8192 // not used by this implementation + +function from (value, encodingOrOffset, length) { + if (typeof value === 'string') { + return fromString(value, encodingOrOffset) + } + + if (ArrayBuffer.isView(value)) { + return fromArrayLike(value) + } + + if (value == null) { + throw TypeError( + 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + + 'or Array-like Object. Received type ' + (typeof value) + ) + } + + if (isInstance(value, ArrayBuffer) || + (value && isInstance(value.buffer, ArrayBuffer))) { + return fromArrayBuffer(value, encodingOrOffset, length) + } + + if (typeof value === 'number') { + throw new TypeError( + 'The "value" argument must not be of type number. Received type number' + ) + } + + var valueOf = value.valueOf && value.valueOf() + if (valueOf != null && valueOf !== value) { + return Buffer.from(valueOf, encodingOrOffset, length) + } + + var b = fromObject(value) + if (b) return b + + if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && + typeof value[Symbol.toPrimitive] === 'function') { + return Buffer.from( + value[Symbol.toPrimitive]('string'), encodingOrOffset, length + ) + } + + throw new TypeError( + 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + + 'or Array-like Object. Received type ' + (typeof value) + ) +} + +/** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ +Buffer.from = function (value, encodingOrOffset, length) { + return from(value, encodingOrOffset, length) +} + +// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug: +// https://github.com/feross/buffer/pull/148 +Buffer.prototype.__proto__ = Uint8Array.prototype +Buffer.__proto__ = Uint8Array + +function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be of type number') + } else if (size < 0) { + throw new RangeError('The value "' + size + '" is invalid for option "size"') + } +} + +function alloc (size, fill, encoding) { + assertSize(size) + if (size <= 0) { + return createBuffer(size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + return typeof encoding === 'string' + ? createBuffer(size).fill(fill, encoding) + : createBuffer(size).fill(fill) + } + return createBuffer(size) +} + +/** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ +Buffer.alloc = function (size, fill, encoding) { + return alloc(size, fill, encoding) +} + +function allocUnsafe (size) { + assertSize(size) + return createBuffer(size < 0 ? 0 : checked(size) | 0) +} + +/** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ +Buffer.allocUnsafe = function (size) { + return allocUnsafe(size) +} +/** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ +Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(size) +} + +function fromString (string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8' + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + + var length = byteLength(string, encoding) | 0 + var buf = createBuffer(length) + + var actual = buf.write(string, encoding) + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + buf = buf.slice(0, actual) + } + + return buf +} + +function fromArrayLike (array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0 + var buf = createBuffer(length) + for (var i = 0; i < length; i += 1) { + buf[i] = array[i] & 255 + } + return buf +} + +function fromArrayBuffer (array, byteOffset, length) { + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('"offset" is outside of buffer bounds') + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('"length" is outside of buffer bounds') + } + + var buf + if (byteOffset === undefined && length === undefined) { + buf = new Uint8Array(array) + } else if (length === undefined) { + buf = new Uint8Array(array, byteOffset) + } else { + buf = new Uint8Array(array, byteOffset, length) + } + + // Return an augmented `Uint8Array` instance + buf.__proto__ = Buffer.prototype + return buf +} + +function fromObject (obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0 + var buf = createBuffer(len) + + if (buf.length === 0) { + return buf + } + + obj.copy(buf, 0, 0, len) + return buf + } + + if (obj.length !== undefined) { + if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) { + return createBuffer(0) + } + return fromArrayLike(obj) + } + + if (obj.type === 'Buffer' && Array.isArray(obj.data)) { + return fromArrayLike(obj.data) + } +} + +function checked (length) { + // Note: cannot use `length < K_MAX_LENGTH` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= K_MAX_LENGTH) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes') + } + return length | 0 +} + +function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0 + } + return Buffer.alloc(+length) +} + +Buffer.isBuffer = function isBuffer (b) { + return b != null && b._isBuffer === true && + b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false +} + +Buffer.compare = function compare (a, b) { + if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength) + if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength) + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError( + 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array' + ) + } + + if (a === b) return 0 + + var x = a.length + var y = b.length + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i] + y = b[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } +} + +Buffer.concat = function concat (list, length) { + if (!Array.isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + + if (list.length === 0) { + return Buffer.alloc(0) + } + + var i + if (length === undefined) { + length = 0 + for (i = 0; i < list.length; ++i) { + length += list[i].length + } + } + + var buffer = Buffer.allocUnsafe(length) + var pos = 0 + for (i = 0; i < list.length; ++i) { + var buf = list[i] + if (isInstance(buf, Uint8Array)) { + buf = Buffer.from(buf) + } + if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + buf.copy(buffer, pos) + pos += buf.length + } + return buffer +} + +function byteLength (string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length + } + if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { + return string.byteLength + } + if (typeof string !== 'string') { + throw new TypeError( + 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + + 'Received type ' + typeof string + ) + } + + var len = string.length + var mustMatch = (arguments.length > 2 && arguments[2] === true) + if (!mustMatch && len === 0) return 0 + + // Use a for loop to avoid recursion + var loweredCase = false + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len + case 'utf8': + case 'utf-8': + return utf8ToBytes(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) { + return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8 + } + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} +Buffer.byteLength = byteLength + +function slowToString (encoding, start, end) { + var loweredCase = false + + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0 + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } + + if (end === undefined || end > this.length) { + end = this.length + } + + if (end <= 0) { + return '' + } + + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0 + start >>>= 0 + + if (end <= start) { + return '' + } + + if (!encoding) encoding = 'utf8' + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) + + case 'ascii': + return asciiSlice(this, start, end) + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true + } + } +} + +// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package) +// to detect a Buffer instance. It's not possible to use `instanceof Buffer` +// reliably in a browserify context because there could be multiple different +// copies of the 'buffer' package in use. This method works even for Buffer +// instances that were created from another copy of the `buffer` package. +// See: https://github.com/feross/buffer/issues/154 +Buffer.prototype._isBuffer = true + +function swap (b, n, m) { + var i = b[n] + b[n] = b[m] + b[m] = i +} + +Buffer.prototype.swap16 = function swap16 () { + var len = this.length + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1) + } + return this +} + +Buffer.prototype.swap32 = function swap32 () { + var len = this.length + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3) + swap(this, i + 1, i + 2) + } + return this +} + +Buffer.prototype.swap64 = function swap64 () { + var len = this.length + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7) + swap(this, i + 1, i + 6) + swap(this, i + 2, i + 5) + swap(this, i + 3, i + 4) + } + return this +} + +Buffer.prototype.toString = function toString () { + var length = this.length + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) +} + +Buffer.prototype.toLocaleString = Buffer.prototype.toString + +Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 +} + +Buffer.prototype.inspect = function inspect () { + var str = '' + var max = exports.INSPECT_MAX_BYTES + str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim() + if (this.length > max) str += ' ... ' + return '' +} + +Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (isInstance(target, Uint8Array)) { + target = Buffer.from(target, target.offset, target.byteLength) + } + if (!Buffer.isBuffer(target)) { + throw new TypeError( + 'The "target" argument must be one of type Buffer or Uint8Array. ' + + 'Received type ' + (typeof target) + ) + } + + if (start === undefined) { + start = 0 + } + if (end === undefined) { + end = target ? target.length : 0 + } + if (thisStart === undefined) { + thisStart = 0 + } + if (thisEnd === undefined) { + thisEnd = this.length + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } + + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } + + start >>>= 0 + end >>>= 0 + thisStart >>>= 0 + thisEnd >>>= 0 + + if (this === target) return 0 + + var x = thisEnd - thisStart + var y = end - start + var len = Math.min(x, y) + + var thisCopy = this.slice(thisStart, thisEnd) + var targetCopy = target.slice(start, end) + + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i] + y = targetCopy[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, +// OR the last index of `val` in `buffer` at offset <= `byteOffset`. +// +// Arguments: +// - buffer - a Buffer to search +// - val - a string, Buffer, or number +// - byteOffset - an index into `buffer`; will be clamped to an int32 +// - encoding - an optional encoding, relevant is val is a string +// - dir - true for indexOf, false for lastIndexOf +function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset + byteOffset = 0 + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000 + } + byteOffset = +byteOffset // Coerce to Number. + if (numberIsNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1) + } + + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1 + } else if (byteOffset < 0) { + if (dir) byteOffset = 0 + else return -1 + } + + // Normalize val + if (typeof val === 'string') { + val = Buffer.from(val, encoding) + } + + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF // Search for a byte value [0-255] + if (typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } + } + return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) + } + + throw new TypeError('val must be string, number or Buffer') +} + +function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + var indexSize = 1 + var arrLength = arr.length + var valLength = val.length + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase() + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2 + arrLength /= 2 + valLength /= 2 + byteOffset /= 2 + } + } + + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } + + var i + if (dir) { + var foundIndex = -1 + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex + foundIndex = -1 + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength + for (i = byteOffset; i >= 0; i--) { + var found = true + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false + break + } + } + if (found) return i + } + } + + return -1 +} + +Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 +} + +Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) +} + +Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) +} + +function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + var remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } + } + + var strLen = string.length + + if (length > strLen / 2) { + length = strLen / 2 + } + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (numberIsNaN(parsed)) return i + buf[offset + i] = parsed + } + return i +} + +function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) +} + +function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) +} + +function latin1Write (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) +} + +function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) +} + +function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) +} + +Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8' + length = this.length + offset = 0 + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset + length = this.length + offset = 0 + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset >>> 0 + if (isFinite(length)) { + length = length >>> 0 + if (encoding === undefined) encoding = 'utf8' + } else { + encoding = length + length = undefined + } + } else { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) + } + + var remaining = this.length - offset + if (length === undefined || length > remaining) length = remaining + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds') + } + + if (!encoding) encoding = 'utf8' + + var loweredCase = false + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + return asciiWrite(this, string, offset, length) + + case 'latin1': + case 'binary': + return latin1Write(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} + +Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } +} + +function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) + } +} + +function utf8Slice (buf, start, end) { + end = Math.min(buf.length, end) + var res = [] + + var i = start + while (i < end) { + var firstByte = buf[i] + var codePoint = null + var bytesPerSequence = (firstByte > 0xEF) ? 4 + : (firstByte > 0xDF) ? 3 + : (firstByte > 0xBF) ? 2 + : 1 + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte + } + break + case 2: + secondByte = buf[i + 1] + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint + } + } + break + case 3: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint + } + } + break + case 4: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + fourthByte = buf[i + 3] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint + } + } + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD + bytesPerSequence = 1 + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000 + res.push(codePoint >>> 10 & 0x3FF | 0xD800) + codePoint = 0xDC00 | codePoint & 0x3FF + } + + res.push(codePoint) + i += bytesPerSequence + } + + return decodeCodePointsArray(res) +} + +// Based on http://stackoverflow.com/a/22747272/680742, the browser with +// the lowest limit is Chrome, with 0x10000 args. +// We go 1 magnitude less, for safety +var MAX_ARGUMENTS_LENGTH = 0x1000 + +function decodeCodePointsArray (codePoints) { + var len = codePoints.length + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + } + + // Decode in chunks to avoid "call stack size exceeded". + var res = '' + var i = 0 + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ) + } + return res +} + +function asciiSlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F) + } + return ret +} + +function latin1Slice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]) + } + return ret +} + +function hexSlice (buf, start, end) { + var len = buf.length + + if (!start || start < 0) start = 0 + if (!end || end < 0 || end > len) end = len + + var out = '' + for (var i = start; i < end; ++i) { + out += toHex(buf[i]) + } + return out +} + +function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end) + var res = '' + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256)) + } + return res +} + +Buffer.prototype.slice = function slice (start, end) { + var len = this.length + start = ~~start + end = end === undefined ? len : ~~end + + if (start < 0) { + start += len + if (start < 0) start = 0 + } else if (start > len) { + start = len + } + + if (end < 0) { + end += len + if (end < 0) end = 0 + } else if (end > len) { + end = len + } + + if (end < start) end = start + + var newBuf = this.subarray(start, end) + // Return an augmented `Uint8Array` instance + newBuf.__proto__ = Buffer.prototype + return newBuf +} + +/* + * Need to make sure that buffer isn't trying to write out of bounds. + */ +function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') +} + +Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + + return val +} + +Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + checkOffset(offset, byteLength, this.length) + } + + var val = this[offset + --byteLength] + var mul = 1 + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul + } + + return val +} + +Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + return this[offset] +} + +Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return this[offset] | (this[offset + 1] << 8) +} + +Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + return (this[offset] << 8) | this[offset + 1] +} + +Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) +} + +Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) +} + +Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var i = byteLength + var mul = 1 + var val = this[offset + --i] + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) +} + +Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset] | (this[offset + 1] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset + 1] | (this[offset] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) +} + +Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) +} + +Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, true, 23, 4) +} + +Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, false, 23, 4) +} + +Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, true, 52, 8) +} + +Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + offset = offset >>> 0 + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, false, 52, 8) +} + +function checkInt (buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') +} + +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var mul = 1 + var i = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + byteLength = byteLength >>> 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) + this[offset] = (value & 0xff) + return offset + 1 +} + +Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 +} + +Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 +} + +Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = (value & 0xff) + return offset + 4 +} + +Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 +} + +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + var limit = Math.pow(2, (8 * byteLength) - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = 0 + var mul = 1 + var sub = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + var limit = Math.pow(2, (8 * byteLength) - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = byteLength - 1 + var mul = 1 + var sub = 0 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) + if (value < 0) value = 0xff + value + 1 + this[offset] = (value & 0xff) + return offset + 1 +} + +Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + return offset + 2 +} + +Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + return offset + 2 +} + +Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) + return offset + 4 +} + +Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (value < 0) value = 0xffffffff + value + 1 + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + return offset + 4 +} + +function checkIEEE754 (buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') +} + +function writeFloat (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } + ieee754.write(buf, value, offset, littleEndian, 23, 4) + return offset + 4 +} + +Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) +} + +function writeDouble (buf, value, offset, littleEndian, noAssert) { + value = +value + offset = offset >>> 0 + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } + ieee754.write(buf, value, offset, littleEndian, 52, 8) + return offset + 8 +} + +Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) +} + +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer.prototype.copy = function copy (target, targetStart, start, end) { + if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer') + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (targetStart >= target.length) targetStart = target.length + if (!targetStart) targetStart = 0 + if (end > 0 && end < start) end = start + + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 + + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('Index out of range') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start + } + + var len = end - start + + if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') { + // Use built-in when available, missing from IE11 + this.copyWithin(targetStart, start, end) + } else if (this === target && start < targetStart && targetStart < end) { + // descending copy from end + for (var i = len - 1; i >= 0; --i) { + target[i + targetStart] = this[i + start] + } + } else { + Uint8Array.prototype.set.call( + target, + this.subarray(start, end), + targetStart + ) + } + + return len +} + +// Usage: +// buffer.fill(number[, offset[, end]]) +// buffer.fill(buffer[, offset[, end]]) +// buffer.fill(string[, offset[, end]][, encoding]) +Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start + start = 0 + end = this.length + } else if (typeof end === 'string') { + encoding = end + end = this.length + } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') + } + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + if (val.length === 1) { + var code = val.charCodeAt(0) + if ((encoding === 'utf8' && code < 128) || + encoding === 'latin1') { + // Fast path: If `val` fits into a single byte, use that numeric value. + val = code + } + } + } else if (typeof val === 'number') { + val = val & 255 + } + + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } + + if (end <= start) { + return this + } + + start = start >>> 0 + end = end === undefined ? this.length : end >>> 0 + + if (!val) val = 0 + + var i + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val + } + } else { + var bytes = Buffer.isBuffer(val) + ? val + : Buffer.from(val, encoding) + var len = bytes.length + if (len === 0) { + throw new TypeError('The value "' + val + + '" is invalid for argument "value"') + } + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len] + } + } + + return this +} + +// HELPER FUNCTIONS +// ================ + +var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g + +function base64clean (str) { + // Node takes equal signs as end of the Base64 encoding + str = str.split('=')[0] + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = str.trim().replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '=' + } + return str +} + +function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) +} + +function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] + + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } + + // valid lead + leadSurrogate = codePoint + + continue + } + + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } + + // valid surrogate pair + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + } + + leadSurrogate = null + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') + } + } + + return bytes +} + +function asciiToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) + } + return byteArray +} + +function utf16leToBytes (str, units) { + var c, hi, lo + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break + + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) + } + + return byteArray +} + +function base64ToBytes (str) { + return base64.toByteArray(base64clean(str)) +} + +function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i] + } + return i +} + +// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass +// the `instanceof` check but they should be treated as of that type. +// See: https://github.com/feross/buffer/issues/166 +function isInstance (obj, type) { + return obj instanceof type || + (obj != null && obj.constructor != null && obj.constructor.name != null && + obj.constructor.name === type.name) +} +function numberIsNaN (obj) { + // For IE11 support + return obj !== obj // eslint-disable-line no-self-compare +} + +}).call(this)}).call(this,_dereq_("buffer").Buffer) +},{"base64-js":25,"buffer":28,"ieee754":64}],29:[function(_dereq_,module,exports){ +// https://d3js.org/d3-time-format/ v2.2.3 Copyright 2019 Mike Bostock +(function (global, factory) { +typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, _dereq_('d3-time')) : +typeof define === 'function' && define.amd ? define(['exports', 'd3-time'], factory) : +(global = global || self, factory(global.d3 = global.d3 || {}, global.d3)); +}(this, function (exports, d3Time) { 'use strict'; + +function localDate(d) { + if (0 <= d.y && d.y < 100) { + var date = new Date(-1, d.m, d.d, d.H, d.M, d.S, d.L); + date.setFullYear(d.y); + return date; + } + return new Date(d.y, d.m, d.d, d.H, d.M, d.S, d.L); +} + +function utcDate(d) { + if (0 <= d.y && d.y < 100) { + var date = new Date(Date.UTC(-1, d.m, d.d, d.H, d.M, d.S, d.L)); + date.setUTCFullYear(d.y); + return date; + } + return new Date(Date.UTC(d.y, d.m, d.d, d.H, d.M, d.S, d.L)); +} + +function newDate(y, m, d) { + return {y: y, m: m, d: d, H: 0, M: 0, S: 0, L: 0}; +} + +function formatLocale(locale) { + var locale_dateTime = locale.dateTime, + locale_date = locale.date, + locale_time = locale.time, + locale_periods = locale.periods, + locale_weekdays = locale.days, + locale_shortWeekdays = locale.shortDays, + locale_months = locale.months, + locale_shortMonths = locale.shortMonths; + + var periodRe = formatRe(locale_periods), + periodLookup = formatLookup(locale_periods), + weekdayRe = formatRe(locale_weekdays), + weekdayLookup = formatLookup(locale_weekdays), + shortWeekdayRe = formatRe(locale_shortWeekdays), + shortWeekdayLookup = formatLookup(locale_shortWeekdays), + monthRe = formatRe(locale_months), + monthLookup = formatLookup(locale_months), + shortMonthRe = formatRe(locale_shortMonths), + shortMonthLookup = formatLookup(locale_shortMonths); + + var formats = { + "a": formatShortWeekday, + "A": formatWeekday, + "b": formatShortMonth, + "B": formatMonth, + "c": null, + "d": formatDayOfMonth, + "e": formatDayOfMonth, + "f": formatMicroseconds, + "H": formatHour24, + "I": formatHour12, + "j": formatDayOfYear, + "L": formatMilliseconds, + "m": formatMonthNumber, + "M": formatMinutes, + "p": formatPeriod, + "q": formatQuarter, + "Q": formatUnixTimestamp, + "s": formatUnixTimestampSeconds, + "S": formatSeconds, + "u": formatWeekdayNumberMonday, + "U": formatWeekNumberSunday, + "V": formatWeekNumberISO, + "w": formatWeekdayNumberSunday, + "W": formatWeekNumberMonday, + "x": null, + "X": null, + "y": formatYear, + "Y": formatFullYear, + "Z": formatZone, + "%": formatLiteralPercent + }; + + var utcFormats = { + "a": formatUTCShortWeekday, + "A": formatUTCWeekday, + "b": formatUTCShortMonth, + "B": formatUTCMonth, + "c": null, + "d": formatUTCDayOfMonth, + "e": formatUTCDayOfMonth, + "f": formatUTCMicroseconds, + "H": formatUTCHour24, + "I": formatUTCHour12, + "j": formatUTCDayOfYear, + "L": formatUTCMilliseconds, + "m": formatUTCMonthNumber, + "M": formatUTCMinutes, + "p": formatUTCPeriod, + "q": formatUTCQuarter, + "Q": formatUnixTimestamp, + "s": formatUnixTimestampSeconds, + "S": formatUTCSeconds, + "u": formatUTCWeekdayNumberMonday, + "U": formatUTCWeekNumberSunday, + "V": formatUTCWeekNumberISO, + "w": formatUTCWeekdayNumberSunday, + "W": formatUTCWeekNumberMonday, + "x": null, + "X": null, + "y": formatUTCYear, + "Y": formatUTCFullYear, + "Z": formatUTCZone, + "%": formatLiteralPercent + }; + + var parses = { + "a": parseShortWeekday, + "A": parseWeekday, + "b": parseShortMonth, + "B": parseMonth, + "c": parseLocaleDateTime, + "d": parseDayOfMonth, + "e": parseDayOfMonth, + "f": parseMicroseconds, + "H": parseHour24, + "I": parseHour24, + "j": parseDayOfYear, + "L": parseMilliseconds, + "m": parseMonthNumber, + "M": parseMinutes, + "p": parsePeriod, + "q": parseQuarter, + "Q": parseUnixTimestamp, + "s": parseUnixTimestampSeconds, + "S": parseSeconds, + "u": parseWeekdayNumberMonday, + "U": parseWeekNumberSunday, + "V": parseWeekNumberISO, + "w": parseWeekdayNumberSunday, + "W": parseWeekNumberMonday, + "x": parseLocaleDate, + "X": parseLocaleTime, + "y": parseYear, + "Y": parseFullYear, + "Z": parseZone, + "%": parseLiteralPercent + }; + + // These recursive directive definitions must be deferred. + formats.x = newFormat(locale_date, formats); + formats.X = newFormat(locale_time, formats); + formats.c = newFormat(locale_dateTime, formats); + utcFormats.x = newFormat(locale_date, utcFormats); + utcFormats.X = newFormat(locale_time, utcFormats); + utcFormats.c = newFormat(locale_dateTime, utcFormats); + + function newFormat(specifier, formats) { + return function(date) { + var string = [], + i = -1, + j = 0, + n = specifier.length, + c, + pad, + format; + + if (!(date instanceof Date)) date = new Date(+date); + + while (++i < n) { + if (specifier.charCodeAt(i) === 37) { + string.push(specifier.slice(j, i)); + if ((pad = pads[c = specifier.charAt(++i)]) != null) c = specifier.charAt(++i); + else pad = c === "e" ? " " : "0"; + if (format = formats[c]) c = format(date, pad); + string.push(c); + j = i + 1; + } + } + + string.push(specifier.slice(j, i)); + return string.join(""); + }; + } + + function newParse(specifier, Z) { + return function(string) { + var d = newDate(1900, undefined, 1), + i = parseSpecifier(d, specifier, string += "", 0), + week, day; + if (i != string.length) return null; + + // If a UNIX timestamp is specified, return it. + if ("Q" in d) return new Date(d.Q); + if ("s" in d) return new Date(d.s * 1000 + ("L" in d ? d.L : 0)); + + // If this is utcParse, never use the local timezone. + if (Z && !("Z" in d)) d.Z = 0; + + // The am-pm flag is 0 for AM, and 1 for PM. + if ("p" in d) d.H = d.H % 12 + d.p * 12; + + // If the month was not specified, inherit from the quarter. + if (d.m === undefined) d.m = "q" in d ? d.q : 0; + + // Convert day-of-week and week-of-year to day-of-year. + if ("V" in d) { + if (d.V < 1 || d.V > 53) return null; + if (!("w" in d)) d.w = 1; + if ("Z" in d) { + week = utcDate(newDate(d.y, 0, 1)), day = week.getUTCDay(); + week = day > 4 || day === 0 ? d3Time.utcMonday.ceil(week) : d3Time.utcMonday(week); + week = d3Time.utcDay.offset(week, (d.V - 1) * 7); + d.y = week.getUTCFullYear(); + d.m = week.getUTCMonth(); + d.d = week.getUTCDate() + (d.w + 6) % 7; + } else { + week = localDate(newDate(d.y, 0, 1)), day = week.getDay(); + week = day > 4 || day === 0 ? d3Time.timeMonday.ceil(week) : d3Time.timeMonday(week); + week = d3Time.timeDay.offset(week, (d.V - 1) * 7); + d.y = week.getFullYear(); + d.m = week.getMonth(); + d.d = week.getDate() + (d.w + 6) % 7; + } + } else if ("W" in d || "U" in d) { + if (!("w" in d)) d.w = "u" in d ? d.u % 7 : "W" in d ? 1 : 0; + day = "Z" in d ? utcDate(newDate(d.y, 0, 1)).getUTCDay() : localDate(newDate(d.y, 0, 1)).getDay(); + d.m = 0; + d.d = "W" in d ? (d.w + 6) % 7 + d.W * 7 - (day + 5) % 7 : d.w + d.U * 7 - (day + 6) % 7; + } + + // If a time zone is specified, all fields are interpreted as UTC and then + // offset according to the specified time zone. + if ("Z" in d) { + d.H += d.Z / 100 | 0; + d.M += d.Z % 100; + return utcDate(d); + } + + // Otherwise, all fields are in local time. + return localDate(d); + }; + } + + function parseSpecifier(d, specifier, string, j) { + var i = 0, + n = specifier.length, + m = string.length, + c, + parse; + + while (i < n) { + if (j >= m) return -1; + c = specifier.charCodeAt(i++); + if (c === 37) { + c = specifier.charAt(i++); + parse = parses[c in pads ? specifier.charAt(i++) : c]; + if (!parse || ((j = parse(d, string, j)) < 0)) return -1; + } else if (c != string.charCodeAt(j++)) { + return -1; + } + } + + return j; + } + + function parsePeriod(d, string, i) { + var n = periodRe.exec(string.slice(i)); + return n ? (d.p = periodLookup[n[0].toLowerCase()], i + n[0].length) : -1; + } + + function parseShortWeekday(d, string, i) { + var n = shortWeekdayRe.exec(string.slice(i)); + return n ? (d.w = shortWeekdayLookup[n[0].toLowerCase()], i + n[0].length) : -1; + } + + function parseWeekday(d, string, i) { + var n = weekdayRe.exec(string.slice(i)); + return n ? (d.w = weekdayLookup[n[0].toLowerCase()], i + n[0].length) : -1; + } + + function parseShortMonth(d, string, i) { + var n = shortMonthRe.exec(string.slice(i)); + return n ? (d.m = shortMonthLookup[n[0].toLowerCase()], i + n[0].length) : -1; + } + + function parseMonth(d, string, i) { + var n = monthRe.exec(string.slice(i)); + return n ? (d.m = monthLookup[n[0].toLowerCase()], i + n[0].length) : -1; + } + + function parseLocaleDateTime(d, string, i) { + return parseSpecifier(d, locale_dateTime, string, i); + } + + function parseLocaleDate(d, string, i) { + return parseSpecifier(d, locale_date, string, i); + } + + function parseLocaleTime(d, string, i) { + return parseSpecifier(d, locale_time, string, i); + } + + function formatShortWeekday(d) { + return locale_shortWeekdays[d.getDay()]; + } + + function formatWeekday(d) { + return locale_weekdays[d.getDay()]; + } + + function formatShortMonth(d) { + return locale_shortMonths[d.getMonth()]; + } + + function formatMonth(d) { + return locale_months[d.getMonth()]; + } + + function formatPeriod(d) { + return locale_periods[+(d.getHours() >= 12)]; + } + + function formatQuarter(d) { + return 1 + ~~(d.getMonth() / 3); + } + + function formatUTCShortWeekday(d) { + return locale_shortWeekdays[d.getUTCDay()]; + } + + function formatUTCWeekday(d) { + return locale_weekdays[d.getUTCDay()]; + } + + function formatUTCShortMonth(d) { + return locale_shortMonths[d.getUTCMonth()]; + } + + function formatUTCMonth(d) { + return locale_months[d.getUTCMonth()]; + } + + function formatUTCPeriod(d) { + return locale_periods[+(d.getUTCHours() >= 12)]; + } + + function formatUTCQuarter(d) { + return 1 + ~~(d.getUTCMonth() / 3); + } + + return { + format: function(specifier) { + var f = newFormat(specifier += "", formats); + f.toString = function() { return specifier; }; + return f; + }, + parse: function(specifier) { + var p = newParse(specifier += "", false); + p.toString = function() { return specifier; }; + return p; + }, + utcFormat: function(specifier) { + var f = newFormat(specifier += "", utcFormats); + f.toString = function() { return specifier; }; + return f; + }, + utcParse: function(specifier) { + var p = newParse(specifier += "", true); + p.toString = function() { return specifier; }; + return p; + } + }; +} + +var pads = {"-": "", "_": " ", "0": "0"}, + numberRe = /^\s*\d+/, // note: ignores next directive + percentRe = /^%/, + requoteRe = /[\\^$*+?|[\]().{}]/g; + +function pad(value, fill, width) { + var sign = value < 0 ? "-" : "", + string = (sign ? -value : value) + "", + length = string.length; + return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string); +} + +function requote(s) { + return s.replace(requoteRe, "\\$&"); +} + +function formatRe(names) { + return new RegExp("^(?:" + names.map(requote).join("|") + ")", "i"); +} + +function formatLookup(names) { + var map = {}, i = -1, n = names.length; + while (++i < n) map[names[i].toLowerCase()] = i; + return map; +} + +function parseWeekdayNumberSunday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 1)); + return n ? (d.w = +n[0], i + n[0].length) : -1; +} + +function parseWeekdayNumberMonday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 1)); + return n ? (d.u = +n[0], i + n[0].length) : -1; +} + +function parseWeekNumberSunday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.U = +n[0], i + n[0].length) : -1; +} + +function parseWeekNumberISO(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.V = +n[0], i + n[0].length) : -1; +} + +function parseWeekNumberMonday(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.W = +n[0], i + n[0].length) : -1; +} + +function parseFullYear(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 4)); + return n ? (d.y = +n[0], i + n[0].length) : -1; +} + +function parseYear(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.y = +n[0] + (+n[0] > 68 ? 1900 : 2000), i + n[0].length) : -1; +} + +function parseZone(d, string, i) { + var n = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(string.slice(i, i + 6)); + return n ? (d.Z = n[1] ? 0 : -(n[2] + (n[3] || "00")), i + n[0].length) : -1; +} + +function parseQuarter(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 1)); + return n ? (d.q = n[0] * 3 - 3, i + n[0].length) : -1; +} + +function parseMonthNumber(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.m = n[0] - 1, i + n[0].length) : -1; +} + +function parseDayOfMonth(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.d = +n[0], i + n[0].length) : -1; +} + +function parseDayOfYear(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 3)); + return n ? (d.m = 0, d.d = +n[0], i + n[0].length) : -1; +} + +function parseHour24(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.H = +n[0], i + n[0].length) : -1; +} + +function parseMinutes(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.M = +n[0], i + n[0].length) : -1; +} + +function parseSeconds(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 2)); + return n ? (d.S = +n[0], i + n[0].length) : -1; +} + +function parseMilliseconds(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 3)); + return n ? (d.L = +n[0], i + n[0].length) : -1; +} + +function parseMicroseconds(d, string, i) { + var n = numberRe.exec(string.slice(i, i + 6)); + return n ? (d.L = Math.floor(n[0] / 1000), i + n[0].length) : -1; +} + +function parseLiteralPercent(d, string, i) { + var n = percentRe.exec(string.slice(i, i + 1)); + return n ? i + n[0].length : -1; +} + +function parseUnixTimestamp(d, string, i) { + var n = numberRe.exec(string.slice(i)); + return n ? (d.Q = +n[0], i + n[0].length) : -1; +} + +function parseUnixTimestampSeconds(d, string, i) { + var n = numberRe.exec(string.slice(i)); + return n ? (d.s = +n[0], i + n[0].length) : -1; +} + +function formatDayOfMonth(d, p) { + return pad(d.getDate(), p, 2); +} + +function formatHour24(d, p) { + return pad(d.getHours(), p, 2); +} + +function formatHour12(d, p) { + return pad(d.getHours() % 12 || 12, p, 2); +} + +function formatDayOfYear(d, p) { + return pad(1 + d3Time.timeDay.count(d3Time.timeYear(d), d), p, 3); +} + +function formatMilliseconds(d, p) { + return pad(d.getMilliseconds(), p, 3); +} + +function formatMicroseconds(d, p) { + return formatMilliseconds(d, p) + "000"; +} + +function formatMonthNumber(d, p) { + return pad(d.getMonth() + 1, p, 2); +} + +function formatMinutes(d, p) { + return pad(d.getMinutes(), p, 2); +} + +function formatSeconds(d, p) { + return pad(d.getSeconds(), p, 2); +} + +function formatWeekdayNumberMonday(d) { + var day = d.getDay(); + return day === 0 ? 7 : day; +} + +function formatWeekNumberSunday(d, p) { + return pad(d3Time.timeSunday.count(d3Time.timeYear(d) - 1, d), p, 2); +} + +function formatWeekNumberISO(d, p) { + var day = d.getDay(); + d = (day >= 4 || day === 0) ? d3Time.timeThursday(d) : d3Time.timeThursday.ceil(d); + return pad(d3Time.timeThursday.count(d3Time.timeYear(d), d) + (d3Time.timeYear(d).getDay() === 4), p, 2); +} + +function formatWeekdayNumberSunday(d) { + return d.getDay(); +} + +function formatWeekNumberMonday(d, p) { + return pad(d3Time.timeMonday.count(d3Time.timeYear(d) - 1, d), p, 2); +} + +function formatYear(d, p) { + return pad(d.getFullYear() % 100, p, 2); +} + +function formatFullYear(d, p) { + return pad(d.getFullYear() % 10000, p, 4); +} + +function formatZone(d) { + var z = d.getTimezoneOffset(); + return (z > 0 ? "-" : (z *= -1, "+")) + + pad(z / 60 | 0, "0", 2) + + pad(z % 60, "0", 2); +} + +function formatUTCDayOfMonth(d, p) { + return pad(d.getUTCDate(), p, 2); +} + +function formatUTCHour24(d, p) { + return pad(d.getUTCHours(), p, 2); +} + +function formatUTCHour12(d, p) { + return pad(d.getUTCHours() % 12 || 12, p, 2); +} + +function formatUTCDayOfYear(d, p) { + return pad(1 + d3Time.utcDay.count(d3Time.utcYear(d), d), p, 3); +} + +function formatUTCMilliseconds(d, p) { + return pad(d.getUTCMilliseconds(), p, 3); +} + +function formatUTCMicroseconds(d, p) { + return formatUTCMilliseconds(d, p) + "000"; +} + +function formatUTCMonthNumber(d, p) { + return pad(d.getUTCMonth() + 1, p, 2); +} + +function formatUTCMinutes(d, p) { + return pad(d.getUTCMinutes(), p, 2); +} + +function formatUTCSeconds(d, p) { + return pad(d.getUTCSeconds(), p, 2); +} + +function formatUTCWeekdayNumberMonday(d) { + var dow = d.getUTCDay(); + return dow === 0 ? 7 : dow; +} + +function formatUTCWeekNumberSunday(d, p) { + return pad(d3Time.utcSunday.count(d3Time.utcYear(d) - 1, d), p, 2); +} + +function formatUTCWeekNumberISO(d, p) { + var day = d.getUTCDay(); + d = (day >= 4 || day === 0) ? d3Time.utcThursday(d) : d3Time.utcThursday.ceil(d); + return pad(d3Time.utcThursday.count(d3Time.utcYear(d), d) + (d3Time.utcYear(d).getUTCDay() === 4), p, 2); +} + +function formatUTCWeekdayNumberSunday(d) { + return d.getUTCDay(); +} + +function formatUTCWeekNumberMonday(d, p) { + return pad(d3Time.utcMonday.count(d3Time.utcYear(d) - 1, d), p, 2); +} + +function formatUTCYear(d, p) { + return pad(d.getUTCFullYear() % 100, p, 2); +} + +function formatUTCFullYear(d, p) { + return pad(d.getUTCFullYear() % 10000, p, 4); +} + +function formatUTCZone() { + return "+0000"; +} + +function formatLiteralPercent() { + return "%"; +} + +function formatUnixTimestamp(d) { + return +d; +} + +function formatUnixTimestampSeconds(d) { + return Math.floor(+d / 1000); +} + +var locale; + +defaultLocale({ + dateTime: "%x, %X", + date: "%-m/%-d/%Y", + time: "%-I:%M:%S %p", + periods: ["AM", "PM"], + days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], + shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], + months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], + shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] +}); + +function defaultLocale(definition) { + locale = formatLocale(definition); + exports.timeFormat = locale.format; + exports.timeParse = locale.parse; + exports.utcFormat = locale.utcFormat; + exports.utcParse = locale.utcParse; + return locale; +} + +var isoSpecifier = "%Y-%m-%dT%H:%M:%S.%LZ"; + +function formatIsoNative(date) { + return date.toISOString(); +} + +var formatIso = Date.prototype.toISOString + ? formatIsoNative + : exports.utcFormat(isoSpecifier); + +function parseIsoNative(string) { + var date = new Date(string); + return isNaN(date) ? null : date; +} + +var parseIso = +new Date("2000-01-01T00:00:00.000Z") + ? parseIsoNative + : exports.utcParse(isoSpecifier); + +exports.isoFormat = formatIso; +exports.isoParse = parseIso; +exports.timeFormatDefaultLocale = defaultLocale; +exports.timeFormatLocale = formatLocale; + +Object.defineProperty(exports, '__esModule', { value: true }); + +})); + +},{"d3-time":30}],30:[function(_dereq_,module,exports){ +// https://d3js.org/d3-time/ v1.1.0 Copyright 2019 Mike Bostock +(function (global, factory) { +typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : +typeof define === 'function' && define.amd ? define(['exports'], factory) : +(global = global || self, factory(global.d3 = global.d3 || {})); +}(this, function (exports) { 'use strict'; + +var t0 = new Date, + t1 = new Date; + +function newInterval(floori, offseti, count, field) { + + function interval(date) { + return floori(date = arguments.length === 0 ? new Date : new Date(+date)), date; + } + + interval.floor = function(date) { + return floori(date = new Date(+date)), date; + }; + + interval.ceil = function(date) { + return floori(date = new Date(date - 1)), offseti(date, 1), floori(date), date; + }; + + interval.round = function(date) { + var d0 = interval(date), + d1 = interval.ceil(date); + return date - d0 < d1 - date ? d0 : d1; + }; + + interval.offset = function(date, step) { + return offseti(date = new Date(+date), step == null ? 1 : Math.floor(step)), date; + }; + + interval.range = function(start, stop, step) { + var range = [], previous; + start = interval.ceil(start); + step = step == null ? 1 : Math.floor(step); + if (!(start < stop) || !(step > 0)) return range; // also handles Invalid Date + do range.push(previous = new Date(+start)), offseti(start, step), floori(start); + while (previous < start && start < stop); + return range; + }; + + interval.filter = function(test) { + return newInterval(function(date) { + if (date >= date) while (floori(date), !test(date)) date.setTime(date - 1); + }, function(date, step) { + if (date >= date) { + if (step < 0) while (++step <= 0) { + while (offseti(date, -1), !test(date)) {} // eslint-disable-line no-empty + } else while (--step >= 0) { + while (offseti(date, +1), !test(date)) {} // eslint-disable-line no-empty + } + } + }); + }; + + if (count) { + interval.count = function(start, end) { + t0.setTime(+start), t1.setTime(+end); + floori(t0), floori(t1); + return Math.floor(count(t0, t1)); + }; + + interval.every = function(step) { + step = Math.floor(step); + return !isFinite(step) || !(step > 0) ? null + : !(step > 1) ? interval + : interval.filter(field + ? function(d) { return field(d) % step === 0; } + : function(d) { return interval.count(0, d) % step === 0; }); + }; + } + + return interval; +} + +var millisecond = newInterval(function() { + // noop +}, function(date, step) { + date.setTime(+date + step); +}, function(start, end) { + return end - start; +}); + +// An optimized implementation for this simple case. +millisecond.every = function(k) { + k = Math.floor(k); + if (!isFinite(k) || !(k > 0)) return null; + if (!(k > 1)) return millisecond; + return newInterval(function(date) { + date.setTime(Math.floor(date / k) * k); + }, function(date, step) { + date.setTime(+date + step * k); + }, function(start, end) { + return (end - start) / k; + }); +}; +var milliseconds = millisecond.range; + +var durationSecond = 1e3; +var durationMinute = 6e4; +var durationHour = 36e5; +var durationDay = 864e5; +var durationWeek = 6048e5; + +var second = newInterval(function(date) { + date.setTime(date - date.getMilliseconds()); +}, function(date, step) { + date.setTime(+date + step * durationSecond); +}, function(start, end) { + return (end - start) / durationSecond; +}, function(date) { + return date.getUTCSeconds(); +}); +var seconds = second.range; + +var minute = newInterval(function(date) { + date.setTime(date - date.getMilliseconds() - date.getSeconds() * durationSecond); +}, function(date, step) { + date.setTime(+date + step * durationMinute); +}, function(start, end) { + return (end - start) / durationMinute; +}, function(date) { + return date.getMinutes(); +}); +var minutes = minute.range; + +var hour = newInterval(function(date) { + date.setTime(date - date.getMilliseconds() - date.getSeconds() * durationSecond - date.getMinutes() * durationMinute); +}, function(date, step) { + date.setTime(+date + step * durationHour); +}, function(start, end) { + return (end - start) / durationHour; +}, function(date) { + return date.getHours(); +}); +var hours = hour.range; + +var day = newInterval(function(date) { + date.setHours(0, 0, 0, 0); +}, function(date, step) { + date.setDate(date.getDate() + step); +}, function(start, end) { + return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationDay; +}, function(date) { + return date.getDate() - 1; +}); +var days = day.range; + +function weekday(i) { + return newInterval(function(date) { + date.setDate(date.getDate() - (date.getDay() + 7 - i) % 7); + date.setHours(0, 0, 0, 0); + }, function(date, step) { + date.setDate(date.getDate() + step * 7); + }, function(start, end) { + return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationWeek; + }); +} + +var sunday = weekday(0); +var monday = weekday(1); +var tuesday = weekday(2); +var wednesday = weekday(3); +var thursday = weekday(4); +var friday = weekday(5); +var saturday = weekday(6); + +var sundays = sunday.range; +var mondays = monday.range; +var tuesdays = tuesday.range; +var wednesdays = wednesday.range; +var thursdays = thursday.range; +var fridays = friday.range; +var saturdays = saturday.range; + +var month = newInterval(function(date) { + date.setDate(1); + date.setHours(0, 0, 0, 0); +}, function(date, step) { + date.setMonth(date.getMonth() + step); +}, function(start, end) { + return end.getMonth() - start.getMonth() + (end.getFullYear() - start.getFullYear()) * 12; +}, function(date) { + return date.getMonth(); +}); +var months = month.range; + +var year = newInterval(function(date) { + date.setMonth(0, 1); + date.setHours(0, 0, 0, 0); +}, function(date, step) { + date.setFullYear(date.getFullYear() + step); +}, function(start, end) { + return end.getFullYear() - start.getFullYear(); +}, function(date) { + return date.getFullYear(); +}); + +// An optimized implementation for this simple case. +year.every = function(k) { + return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : newInterval(function(date) { + date.setFullYear(Math.floor(date.getFullYear() / k) * k); + date.setMonth(0, 1); + date.setHours(0, 0, 0, 0); + }, function(date, step) { + date.setFullYear(date.getFullYear() + step * k); + }); +}; +var years = year.range; + +var utcMinute = newInterval(function(date) { + date.setUTCSeconds(0, 0); +}, function(date, step) { + date.setTime(+date + step * durationMinute); +}, function(start, end) { + return (end - start) / durationMinute; +}, function(date) { + return date.getUTCMinutes(); +}); +var utcMinutes = utcMinute.range; + +var utcHour = newInterval(function(date) { + date.setUTCMinutes(0, 0, 0); +}, function(date, step) { + date.setTime(+date + step * durationHour); +}, function(start, end) { + return (end - start) / durationHour; +}, function(date) { + return date.getUTCHours(); +}); +var utcHours = utcHour.range; + +var utcDay = newInterval(function(date) { + date.setUTCHours(0, 0, 0, 0); +}, function(date, step) { + date.setUTCDate(date.getUTCDate() + step); +}, function(start, end) { + return (end - start) / durationDay; +}, function(date) { + return date.getUTCDate() - 1; +}); +var utcDays = utcDay.range; + +function utcWeekday(i) { + return newInterval(function(date) { + date.setUTCDate(date.getUTCDate() - (date.getUTCDay() + 7 - i) % 7); + date.setUTCHours(0, 0, 0, 0); + }, function(date, step) { + date.setUTCDate(date.getUTCDate() + step * 7); + }, function(start, end) { + return (end - start) / durationWeek; + }); +} + +var utcSunday = utcWeekday(0); +var utcMonday = utcWeekday(1); +var utcTuesday = utcWeekday(2); +var utcWednesday = utcWeekday(3); +var utcThursday = utcWeekday(4); +var utcFriday = utcWeekday(5); +var utcSaturday = utcWeekday(6); + +var utcSundays = utcSunday.range; +var utcMondays = utcMonday.range; +var utcTuesdays = utcTuesday.range; +var utcWednesdays = utcWednesday.range; +var utcThursdays = utcThursday.range; +var utcFridays = utcFriday.range; +var utcSaturdays = utcSaturday.range; + +var utcMonth = newInterval(function(date) { + date.setUTCDate(1); + date.setUTCHours(0, 0, 0, 0); +}, function(date, step) { + date.setUTCMonth(date.getUTCMonth() + step); +}, function(start, end) { + return end.getUTCMonth() - start.getUTCMonth() + (end.getUTCFullYear() - start.getUTCFullYear()) * 12; +}, function(date) { + return date.getUTCMonth(); +}); +var utcMonths = utcMonth.range; + +var utcYear = newInterval(function(date) { + date.setUTCMonth(0, 1); + date.setUTCHours(0, 0, 0, 0); +}, function(date, step) { + date.setUTCFullYear(date.getUTCFullYear() + step); +}, function(start, end) { + return end.getUTCFullYear() - start.getUTCFullYear(); +}, function(date) { + return date.getUTCFullYear(); +}); + +// An optimized implementation for this simple case. +utcYear.every = function(k) { + return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : newInterval(function(date) { + date.setUTCFullYear(Math.floor(date.getUTCFullYear() / k) * k); + date.setUTCMonth(0, 1); + date.setUTCHours(0, 0, 0, 0); + }, function(date, step) { + date.setUTCFullYear(date.getUTCFullYear() + step * k); + }); +}; +var utcYears = utcYear.range; + +exports.timeDay = day; +exports.timeDays = days; +exports.timeFriday = friday; +exports.timeFridays = fridays; +exports.timeHour = hour; +exports.timeHours = hours; +exports.timeInterval = newInterval; +exports.timeMillisecond = millisecond; +exports.timeMilliseconds = milliseconds; +exports.timeMinute = minute; +exports.timeMinutes = minutes; +exports.timeMonday = monday; +exports.timeMondays = mondays; +exports.timeMonth = month; +exports.timeMonths = months; +exports.timeSaturday = saturday; +exports.timeSaturdays = saturdays; +exports.timeSecond = second; +exports.timeSeconds = seconds; +exports.timeSunday = sunday; +exports.timeSundays = sundays; +exports.timeThursday = thursday; +exports.timeThursdays = thursdays; +exports.timeTuesday = tuesday; +exports.timeTuesdays = tuesdays; +exports.timeWednesday = wednesday; +exports.timeWednesdays = wednesdays; +exports.timeWeek = sunday; +exports.timeWeeks = sundays; +exports.timeYear = year; +exports.timeYears = years; +exports.utcDay = utcDay; +exports.utcDays = utcDays; +exports.utcFriday = utcFriday; +exports.utcFridays = utcFridays; +exports.utcHour = utcHour; +exports.utcHours = utcHours; +exports.utcMillisecond = millisecond; +exports.utcMilliseconds = milliseconds; +exports.utcMinute = utcMinute; +exports.utcMinutes = utcMinutes; +exports.utcMonday = utcMonday; +exports.utcMondays = utcMondays; +exports.utcMonth = utcMonth; +exports.utcMonths = utcMonths; +exports.utcSaturday = utcSaturday; +exports.utcSaturdays = utcSaturdays; +exports.utcSecond = second; +exports.utcSeconds = seconds; +exports.utcSunday = utcSunday; +exports.utcSundays = utcSundays; +exports.utcThursday = utcThursday; +exports.utcThursdays = utcThursdays; +exports.utcTuesday = utcTuesday; +exports.utcTuesdays = utcTuesdays; +exports.utcWednesday = utcWednesday; +exports.utcWednesdays = utcWednesdays; +exports.utcWeek = utcSunday; +exports.utcWeeks = utcSundays; +exports.utcYear = utcYear; +exports.utcYears = utcYears; + +Object.defineProperty(exports, '__esModule', { value: true }); + +})); + +},{}],31:[function(_dereq_,module,exports){ /** * inspired by is-number * but significantly simplified and sped up by ignoring number and string constructors @@ -14515,7 +14405,7 @@ module.exports = function(n) { return n - n < 1; }; -},{"is-string-blank":75}],24:[function(_dereq_,module,exports){ +},{"is-string-blank":68}],32:[function(_dereq_,module,exports){ module.exports = adjoint; /** @@ -14549,7 +14439,7 @@ function adjoint(out, a) { out[15] = (a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11)); return out; }; -},{}],25:[function(_dereq_,module,exports){ +},{}],33:[function(_dereq_,module,exports){ module.exports = clone; /** @@ -14578,7 +14468,7 @@ function clone(a) { out[15] = a[15]; return out; }; -},{}],26:[function(_dereq_,module,exports){ +},{}],34:[function(_dereq_,module,exports){ module.exports = copy; /** @@ -14607,7 +14497,7 @@ function copy(out, a) { out[15] = a[15]; return out; }; -},{}],27:[function(_dereq_,module,exports){ +},{}],35:[function(_dereq_,module,exports){ module.exports = create; /** @@ -14635,7 +14525,7 @@ function create() { out[15] = 1; return out; }; -},{}],28:[function(_dereq_,module,exports){ +},{}],36:[function(_dereq_,module,exports){ module.exports = determinant; /** @@ -14666,7 +14556,7 @@ function determinant(a) { // Calculate the determinant return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; }; -},{}],29:[function(_dereq_,module,exports){ +},{}],37:[function(_dereq_,module,exports){ module.exports = fromQuat; /** @@ -14714,7 +14604,7 @@ function fromQuat(out, q) { return out; }; -},{}],30:[function(_dereq_,module,exports){ +},{}],38:[function(_dereq_,module,exports){ module.exports = fromRotation /** @@ -14769,7 +14659,7 @@ function fromRotation(out, rad, axis) { return out } -},{}],31:[function(_dereq_,module,exports){ +},{}],39:[function(_dereq_,module,exports){ module.exports = fromRotationTranslation; /** @@ -14823,7 +14713,7 @@ function fromRotationTranslation(out, q, v) { return out; }; -},{}],32:[function(_dereq_,module,exports){ +},{}],40:[function(_dereq_,module,exports){ module.exports = fromScaling /** @@ -14857,7 +14747,7 @@ function fromScaling(out, v) { return out } -},{}],33:[function(_dereq_,module,exports){ +},{}],41:[function(_dereq_,module,exports){ module.exports = fromTranslation /** @@ -14891,7 +14781,7 @@ function fromTranslation(out, v) { return out } -},{}],34:[function(_dereq_,module,exports){ +},{}],42:[function(_dereq_,module,exports){ module.exports = fromXRotation /** @@ -14928,7 +14818,7 @@ function fromXRotation(out, rad) { out[15] = 1 return out } -},{}],35:[function(_dereq_,module,exports){ +},{}],43:[function(_dereq_,module,exports){ module.exports = fromYRotation /** @@ -14965,7 +14855,7 @@ function fromYRotation(out, rad) { out[15] = 1 return out } -},{}],36:[function(_dereq_,module,exports){ +},{}],44:[function(_dereq_,module,exports){ module.exports = fromZRotation /** @@ -15002,7 +14892,7 @@ function fromZRotation(out, rad) { out[15] = 1 return out } -},{}],37:[function(_dereq_,module,exports){ +},{}],45:[function(_dereq_,module,exports){ module.exports = frustum; /** @@ -15039,7 +14929,7 @@ function frustum(out, left, right, bottom, top, near, far) { out[15] = 0; return out; }; -},{}],38:[function(_dereq_,module,exports){ +},{}],46:[function(_dereq_,module,exports){ module.exports = identity; /** @@ -15067,7 +14957,7 @@ function identity(out) { out[15] = 1; return out; }; -},{}],39:[function(_dereq_,module,exports){ +},{}],47:[function(_dereq_,module,exports){ module.exports = { create: _dereq_('./create') , clone: _dereq_('./clone') @@ -15100,7 +14990,7 @@ module.exports = { , str: _dereq_('./str') } -},{"./adjoint":24,"./clone":25,"./copy":26,"./create":27,"./determinant":28,"./fromQuat":29,"./fromRotation":30,"./fromRotationTranslation":31,"./fromScaling":32,"./fromTranslation":33,"./fromXRotation":34,"./fromYRotation":35,"./fromZRotation":36,"./frustum":37,"./identity":38,"./invert":40,"./lookAt":41,"./multiply":42,"./ortho":43,"./perspective":44,"./perspectiveFromFieldOfView":45,"./rotate":46,"./rotateX":47,"./rotateY":48,"./rotateZ":49,"./scale":50,"./str":51,"./translate":52,"./transpose":53}],40:[function(_dereq_,module,exports){ +},{"./adjoint":32,"./clone":33,"./copy":34,"./create":35,"./determinant":36,"./fromQuat":37,"./fromRotation":38,"./fromRotationTranslation":39,"./fromScaling":40,"./fromTranslation":41,"./fromXRotation":42,"./fromYRotation":43,"./fromZRotation":44,"./frustum":45,"./identity":46,"./invert":48,"./lookAt":49,"./multiply":50,"./ortho":51,"./perspective":52,"./perspectiveFromFieldOfView":53,"./rotate":54,"./rotateX":55,"./rotateY":56,"./rotateZ":57,"./scale":58,"./str":59,"./translate":60,"./transpose":61}],48:[function(_dereq_,module,exports){ module.exports = invert; /** @@ -15156,7 +15046,7 @@ function invert(out, a) { return out; }; -},{}],41:[function(_dereq_,module,exports){ +},{}],49:[function(_dereq_,module,exports){ var identity = _dereq_('./identity'); module.exports = lookAt; @@ -15247,7 +15137,7 @@ function lookAt(out, eye, center, up) { return out; }; -},{"./identity":38}],42:[function(_dereq_,module,exports){ +},{"./identity":46}],50:[function(_dereq_,module,exports){ module.exports = multiply; /** @@ -15290,7 +15180,7 @@ function multiply(out, a, b) { out[15] = b0*a03 + b1*a13 + b2*a23 + b3*a33; return out; }; -},{}],43:[function(_dereq_,module,exports){ +},{}],51:[function(_dereq_,module,exports){ module.exports = ortho; /** @@ -15327,7 +15217,7 @@ function ortho(out, left, right, bottom, top, near, far) { out[15] = 1; return out; }; -},{}],44:[function(_dereq_,module,exports){ +},{}],52:[function(_dereq_,module,exports){ module.exports = perspective; /** @@ -15361,7 +15251,7 @@ function perspective(out, fovy, aspect, near, far) { out[15] = 0; return out; }; -},{}],45:[function(_dereq_,module,exports){ +},{}],53:[function(_dereq_,module,exports){ module.exports = perspectiveFromFieldOfView; /** @@ -15403,7 +15293,7 @@ function perspectiveFromFieldOfView(out, fov, near, far) { } -},{}],46:[function(_dereq_,module,exports){ +},{}],54:[function(_dereq_,module,exports){ module.exports = rotate; /** @@ -15468,7 +15358,7 @@ function rotate(out, a, rad, axis) { } return out; }; -},{}],47:[function(_dereq_,module,exports){ +},{}],55:[function(_dereq_,module,exports){ module.exports = rotateX; /** @@ -15513,7 +15403,7 @@ function rotateX(out, a, rad) { out[11] = a23 * c - a13 * s; return out; }; -},{}],48:[function(_dereq_,module,exports){ +},{}],56:[function(_dereq_,module,exports){ module.exports = rotateY; /** @@ -15558,7 +15448,7 @@ function rotateY(out, a, rad) { out[11] = a03 * s + a23 * c; return out; }; -},{}],49:[function(_dereq_,module,exports){ +},{}],57:[function(_dereq_,module,exports){ module.exports = rotateZ; /** @@ -15603,7 +15493,7 @@ function rotateZ(out, a, rad) { out[7] = a13 * c - a03 * s; return out; }; -},{}],50:[function(_dereq_,module,exports){ +},{}],58:[function(_dereq_,module,exports){ module.exports = scale; /** @@ -15635,7 +15525,7 @@ function scale(out, a, v) { out[15] = a[15]; return out; }; -},{}],51:[function(_dereq_,module,exports){ +},{}],59:[function(_dereq_,module,exports){ module.exports = str; /** @@ -15650,7 +15540,7 @@ function str(a) { a[8] + ', ' + a[9] + ', ' + a[10] + ', ' + a[11] + ', ' + a[12] + ', ' + a[13] + ', ' + a[14] + ', ' + a[15] + ')'; }; -},{}],52:[function(_dereq_,module,exports){ +},{}],60:[function(_dereq_,module,exports){ module.exports = translate; /** @@ -15689,7 +15579,7 @@ function translate(out, a, v) { return out; }; -},{}],53:[function(_dereq_,module,exports){ +},{}],61:[function(_dereq_,module,exports){ module.exports = transpose; /** @@ -15739,7 +15629,7 @@ function transpose(out, a) { return out; }; -},{}],54:[function(_dereq_,module,exports){ +},{}],62:[function(_dereq_,module,exports){ (function (global){(function (){ 'use strict' @@ -15756,7 +15646,7 @@ else { module.exports = hasHover }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"is-browser":73}],55:[function(_dereq_,module,exports){ +},{"is-browser":66}],63:[function(_dereq_,module,exports){ 'use strict' var isBrowser = _dereq_('is-browser') @@ -15782,7 +15672,7 @@ function detect() { module.exports = isBrowser && detect() -},{"is-browser":73}],56:[function(_dereq_,module,exports){ +},{"is-browser":66}],64:[function(_dereq_,module,exports){ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m var eLen = (nBytes * 8) - mLen - 1 @@ -15868,987 +15758,38 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -},{}],57:[function(_dereq_,module,exports){ -'use strict'; - -var typeHandlers = _dereq_('./types'); - -module.exports = function (buffer, filepath) { - var type, result; - for (type in typeHandlers) { - result = typeHandlers[type].detect(buffer, filepath); - if (result) { - return type; - } - } -}; - -},{"./types":60}],58:[function(_dereq_,module,exports){ -(function (Buffer){(function (){ -'use strict'; - -var fs = _dereq_('fs'); -var path = _dereq_('path'); - -var typeHandlers = _dereq_('./types'); -var detector = _dereq_('./detector'); - -// Maximum buffer size, with a default of 512 kilobytes. -// TO-DO: make this adaptive based on the initial signature of the image -var MaxBufferSize = 512*1024; - -/** - * Return size information based on a buffer - * - * @param {Buffer} buffer - * @param {String} filepath - * @returns {Object} - */ -function lookup (buffer, filepath) { - // detect the file type.. don't rely on the extension - var type = detector(buffer, filepath); - - // find an appropriate handler for this file type - if (type in typeHandlers) { - var size = typeHandlers[type].calculate(buffer, filepath); - if (size !== false) { - size.type = type; - return size; - } - } - - // throw up, if we don't understand the file - throw new TypeError('unsupported file type: ' + type + ' (file: ' + filepath + ')'); -} - -/** - * Reads a file into a buffer. - * - * The callback will be called after the process has completed. The - * callback's first argument will be an error (or null). The second argument - * will be the Buffer, if the operation was successful. - * - * @param {String} filepath - * @param {Function} callback - */ -function asyncFileToBuffer (filepath, callback) { - // open the file in read only mode - fs.open(filepath, 'r', function (err, descriptor) { - if (err) { return callback(err); } - fs.fstat(descriptor, function (err, stats) { - if (err) { return callback(err); } - var size = stats.size; - if (size <= 0) { - return callback(new Error('File size is not greater than 0 —— ' + filepath)); - } - var bufferSize = Math.min(size, MaxBufferSize); - var buffer = Buffer.alloc(bufferSize); - // read first buffer block from the file, asynchronously - fs.read(descriptor, buffer, 0, bufferSize, 0, function (err) { - if (err) { return callback(err); } - // close the file, we are done - fs.close(descriptor, function (err) { - callback(err, buffer); - }); - }); - }); - }); -} - -/** - * Synchronously reads a file into a buffer, blocking the nodejs process. - * - * @param {String} filepath - * @returns {Buffer} - */ -function syncFileToBuffer (filepath) { - // read from the file, synchronously - var descriptor = fs.openSync(filepath, 'r'); - var size = fs.fstatSync(descriptor).size; - var bufferSize = Math.min(size, MaxBufferSize); - var buffer = Buffer.alloc(bufferSize); - fs.readSync(descriptor, buffer, 0, bufferSize, 0); - fs.closeSync(descriptor); - return buffer; -} - -/** - * @param {Buffer|string} input - buffer or relative/absolute path of the image file - * @param {Function=} callback - optional function for async detection - */ -module.exports = function (input, callback) { - - // Handle buffer input - if (Buffer.isBuffer(input)) { - return lookup(input); - } - - // input should be a string at this point - if (typeof input !== 'string') { - throw new TypeError('invalid invocation'); - } - - // resolve the file path - var filepath = path.resolve(input); - - if (typeof callback === 'function') { - asyncFileToBuffer(filepath, function (err, buffer) { - if (err) { return callback(err); } - - // return the dimensions - var dimensions; - try { - dimensions = lookup(buffer, filepath); - } catch (e) { - err = e; - } - callback(err, dimensions); - }); - } else { - var buffer = syncFileToBuffer(filepath); - return lookup(buffer, filepath); - } -}; - -module.exports.types = Object.keys(typeHandlers); - -}).call(this)}).call(this,_dereq_("buffer").Buffer) -},{"./detector":57,"./types":60,"buffer":18,"fs":16,"path":78}],59:[function(_dereq_,module,exports){ -'use strict'; - -// Abstract reading multi-byte unsigned integers -function readUInt (buffer, bits, offset, isBigEndian) { - offset = offset || 0; - var endian = isBigEndian ? 'BE' : 'LE'; - var method = buffer['readUInt' + bits + endian]; - return method.call(buffer, offset); -} - -module.exports = readUInt; - -},{}],60:[function(_dereq_,module,exports){ -'use strict'; - -// load all available handlers for browserify support -var typeHandlers = { - bmp: _dereq_('./types/bmp'), - cur: _dereq_('./types/cur'), - dds: _dereq_('./types/dds'), - gif: _dereq_('./types/gif'), - icns: _dereq_('./types/icns'), - ico: _dereq_('./types/ico'), - jpg: _dereq_('./types/jpg'), - png: _dereq_('./types/png'), - psd: _dereq_('./types/psd'), - svg: _dereq_('./types/svg'), - tiff: _dereq_('./types/tiff'), - webp: _dereq_('./types/webp'), -}; - -module.exports = typeHandlers; - -},{"./types/bmp":61,"./types/cur":62,"./types/dds":63,"./types/gif":64,"./types/icns":65,"./types/ico":66,"./types/jpg":67,"./types/png":68,"./types/psd":69,"./types/svg":70,"./types/tiff":71,"./types/webp":72}],61:[function(_dereq_,module,exports){ -'use strict'; - -function isBMP (buffer) { - return ('BM' === buffer.toString('ascii', 0, 2)); -} - -function calculate (buffer) { - return { - 'width': buffer.readUInt32LE(18), - 'height': Math.abs(buffer.readInt32LE(22)) - }; -} - -module.exports = { - 'detect': isBMP, - 'calculate': calculate -}; - -},{}],62:[function(_dereq_,module,exports){ -'use strict'; - -var TYPE_CURSOR = 2; - -function isCUR (buffer) { - var type; - if (buffer.readUInt16LE(0) !== 0) { - return false; - } - type = buffer.readUInt16LE(2); - return type === TYPE_CURSOR; -} - -module.exports = { - 'detect': isCUR, - 'calculate': _dereq_('./ico').calculate -}; - -},{"./ico":66}],63:[function(_dereq_,module,exports){ -'use strict'; - -function isDDS(buffer){ - return buffer.readUInt32LE(0) === 0x20534444; -} - -function calculate(buffer){ - // read file resolution metadata - return { - 'height': buffer.readUInt32LE(12), - 'width': buffer.readUInt32LE(16) - }; -} - -module.exports = { - 'detect': isDDS, - 'calculate': calculate -}; - -},{}],64:[function(_dereq_,module,exports){ -'use strict'; - -var gifRegexp = /^GIF8[79]a/; -function isGIF (buffer) { - var signature = buffer.toString('ascii', 0, 6); - return (gifRegexp.test(signature)); -} - -function calculate(buffer) { - return { - 'width': buffer.readUInt16LE(6), - 'height': buffer.readUInt16LE(8) - }; -} - -module.exports = { - 'detect': isGIF, - 'calculate': calculate -}; - },{}],65:[function(_dereq_,module,exports){ -'use strict'; - -/** - * ICNS Header - * - * | Offset | Size | Purpose | - * | 0 | 4 | Magic literal, must be "icns" (0x69, 0x63, 0x6e, 0x73) | - * | 4 | 4 | Length of file, in bytes, msb first. | - * - **/ -var SIZE_HEADER = 4 + 4; // 8 -var FILE_LENGTH_OFFSET = 4; // MSB => BIG ENDIAN - -/** - * Image Entry - * - * | Offset | Size | Purpose | - * | 0 | 4 | Icon type, see OSType below. | - * | 4 | 4 | Length of data, in bytes (including type and length), msb first. | - * | 8 | n | Icon data | - * - **/ -var ENTRY_LENGTH_OFFSET = 4; // MSB => BIG ENDIAN - -function isICNS (buffer) { - return ('icns' === buffer.toString('ascii', 0, 4)); -} - -var ICON_TYPE_SIZE = { - ICON: 32, - 'ICN#': 32, - // m => 16 x 16 - 'icm#': 16, - icm4: 16, - icm8: 16, - // s => 16 x 16 - 'ics#': 16, - ics4: 16, - ics8: 16, - is32: 16, - s8mk: 16, - icp4: 16, - // l => 32 x 32 - icl4: 32, - icl8: 32, - il32: 32, - l8mk: 32, - icp5: 32, - ic11: 32, - // h => 48 x 48 - ich4: 48, - ich8: 48, - ih32: 48, - h8mk: 48, - // . => 64 x 64 - icp6: 64, - ic12: 32, - // t => 128 x 128 - it32: 128, - t8mk: 128, - ic07: 128, - // . => 256 x 256 - ic08: 256, - ic13: 256, - // . => 512 x 512 - ic09: 512, - ic14: 512, - // . => 1024 x 1024 - ic10: 1024, -}; - -function readImageHeader(buffer, imageOffset) { - var imageLengthOffset = imageOffset + ENTRY_LENGTH_OFFSET; - // returns [type, length] - return [ - buffer.toString('ascii', imageOffset, imageLengthOffset), - buffer.readUInt32BE(imageLengthOffset) - ]; -} - -function getImageSize(type) { - var size = ICON_TYPE_SIZE[type]; - return { width: size, height: size, type: type }; -} - -function calculate (buffer) { - var - bufferLength = buffer.length, - imageOffset = SIZE_HEADER, - fileLength = buffer.readUInt32BE(FILE_LENGTH_OFFSET), - imageHeader, - imageSize, - result; - - imageHeader = readImageHeader(buffer, imageOffset); - imageSize = getImageSize(imageHeader[0]); - imageOffset += imageHeader[1]; - - if (imageOffset === fileLength) { - return imageSize; - } - - result = { - width: imageSize.width, - height: imageSize.height, - images: [imageSize] +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }) + } }; - - while (imageOffset < fileLength && imageOffset < bufferLength) { - imageHeader = readImageHeader(buffer, imageOffset); - imageSize = getImageSize(imageHeader[0]); - imageOffset += imageHeader[1]; - result.images.push(imageSize); +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } } - - return result; } -module.exports = { - 'detect': isICNS, - 'calculate': calculate -}; - },{}],66:[function(_dereq_,module,exports){ -'use strict'; - -var TYPE_ICON = 1; - -/** - * ICON Header - * - * | Offset | Size | Purpose | - * | 0 | 2 | Reserved. Must always be 0. | - * | 2 | 2 | Image type: 1 for icon (.ICO) image, 2 for cursor (.CUR) image. Other values are invalid. | - * | 4 | 2 | Number of images in the file. | - * - **/ -var SIZE_HEADER = 2 + 2 + 2; // 6 - -/** - * Image Entry - * - * | Offset | Size | Purpose | - * | 0 | 1 | Image width in pixels. Can be any number between 0 and 255. Value 0 means width is 256 pixels. | - * | 1 | 1 | Image height in pixels. Can be any number between 0 and 255. Value 0 means height is 256 pixels. | - * | 2 | 1 | Number of colors in the color palette. Should be 0 if the image does not use a color palette. | - * | 3 | 1 | Reserved. Should be 0. | - * | 4 | 2 | ICO format: Color planes. Should be 0 or 1. | - * | | | CUR format: The horizontal coordinates of the hotspot in number of pixels from the left. | - * | 6 | 2 | ICO format: Bits per pixel. | - * | | | CUR format: The vertical coordinates of the hotspot in number of pixels from the top. | - * | 8 | 4 | The size of the image's data in bytes | - * | 12 | 4 | The offset of BMP or PNG data from the beginning of the ICO/CUR file | - * - **/ -var SIZE_IMAGE_ENTRY = 1 + 1 + 1 + 1 + 2 + 2 + 4 + 4; // 16 - -function isICO (buffer) { - var type; - if (buffer.readUInt16LE(0) !== 0) { - return false; - } - type = buffer.readUInt16LE(2); - return type === TYPE_ICON; -} - -function getSizeFromOffset(buffer, offset) { - var value = buffer.readUInt8(offset); - return value === 0 ? 256 : value; -} - -function getImageSize(buffer, imageIndex) { - var offset = SIZE_HEADER + (imageIndex * SIZE_IMAGE_ENTRY); - return { - 'width': getSizeFromOffset(buffer, offset), - 'height': getSizeFromOffset(buffer, offset + 1) - }; -} - -function calculate (buffer) { - var - nbImages = buffer.readUInt16LE(4), - result = getImageSize(buffer, 0), - imageIndex; - - if (nbImages === 1) { - return result; - } - - result.images = [{ - width: result.width, - height: result.height - }]; - - for (imageIndex = 1; imageIndex < nbImages; imageIndex += 1) { - result.images.push(getImageSize(buffer, imageIndex)); - } - - return result; -} - -module.exports = { - 'detect': isICO, - 'calculate': calculate -}; - -},{}],67:[function(_dereq_,module,exports){ -'use strict'; - -var readUInt = _dereq_('../readUInt'); - -// NOTE: we only support baseline and progressive JPGs here -// due to the structure of the loader class, we only get a buffer -// with a maximum size of 4096 bytes. so if the SOF marker is outside -// if this range we can't detect the file size correctly. - -function isJPG (buffer) { //, filepath - var SOIMarker = buffer.toString('hex', 0, 2); - return ('ffd8' === SOIMarker); -} - -function isEXIF (buffer) { //, filepath - var exifMarker = buffer.toString('hex', 2, 6); - return (exifMarker === '45786966'); // 'Exif' -} - -function extractSize (buffer, i) { - return { - 'height' : buffer.readUInt16BE(i), - 'width' : buffer.readUInt16BE(i + 2) - }; -} - -var APP1_DATA_SIZE_BYTES = 2; -var EXIF_HEADER_BYTES = 6; -var TIFF_BYTE_ALIGN_BYTES = 2; -var BIG_ENDIAN_BYTE_ALIGN = '4d4d'; -var LITTLE_ENDIAN_BYTE_ALIGN = '4949'; - -// Each entry is exactly 12 bytes -var IDF_ENTRY_BYTES = 12; -var NUM_DIRECTORY_ENTRIES_BYTES = 2; - -function validateExifBlock (buffer, i) { - // Skip APP1 Data Size - var exifBlock = buffer.slice(APP1_DATA_SIZE_BYTES, i); - - // Consider byte alignment - var byteAlign = exifBlock.toString('hex', EXIF_HEADER_BYTES, EXIF_HEADER_BYTES + TIFF_BYTE_ALIGN_BYTES); - - // Ignore Empty EXIF. Validate byte alignment - var isBigEndian = byteAlign === BIG_ENDIAN_BYTE_ALIGN; - var isLittleEndian = byteAlign === LITTLE_ENDIAN_BYTE_ALIGN; - - if (isBigEndian || isLittleEndian) { - return extractOrientation(exifBlock, isBigEndian); - } -} - -function extractOrientation (exifBlock, isBigEndian) { - // TODO: assert that this contains 0x002A - // var STATIC_MOTOROLA_TIFF_HEADER_BYTES = 2; - // var TIFF_IMAGE_FILE_DIRECTORY_BYTES = 4; - - // TODO: derive from TIFF_IMAGE_FILE_DIRECTORY_BYTES - var idfOffset = 8; - - // IDF osset works from right after the header bytes - // (so the offset includes the tiff byte align) - var offset = EXIF_HEADER_BYTES + idfOffset; - - var idfDirectoryEntries = readUInt(exifBlock, 16, offset, isBigEndian); - - var start; - var end; - for (var directoryEntryNumber = 0; directoryEntryNumber < idfDirectoryEntries; directoryEntryNumber++) { - start = offset + NUM_DIRECTORY_ENTRIES_BYTES + (directoryEntryNumber * IDF_ENTRY_BYTES); - end = start + IDF_ENTRY_BYTES; - - // Skip on corrupt EXIF blocks - if (start > exifBlock.length) { - return; - } - - var block = exifBlock.slice(start, end); - var tagNumber = readUInt(block, 16, 0, isBigEndian); - - // 0x0112 (decimal: 274) is the `orientation` tag ID - if (tagNumber === 274) { - var dataFormat = readUInt(block, 16, 2, isBigEndian); - if (dataFormat !== 3) { - return; - } - - // unsinged int has 2 bytes per component - // if there would more than 4 bytes in total it's a pointer - var numberOfComponents = readUInt(block, 32, 4, isBigEndian); - if (numberOfComponents !== 1) { - return; - } - - return readUInt(block, 16, 8, isBigEndian); - } - } -} - -function validateBuffer (buffer, i) { - // index should be within buffer limits - if (i > buffer.length) { - throw new TypeError('Corrupt JPG, exceeded buffer limits'); - } - // Every JPEG block must begin with a 0xFF - if (buffer[i] !== 0xFF) { - throw new TypeError('Invalid JPG, marker table corrupted'); - } -} - -function calculate (buffer) { - // Skip 4 chars, they are for signature - buffer = buffer.slice(4); - - var orientation; - - var i, next; - while (buffer.length) { - // read length of the next block - i = buffer.readUInt16BE(0); - - if (isEXIF(buffer)) { - orientation = validateExifBlock(buffer, i); - } - - // ensure correct format - validateBuffer(buffer, i); - - // 0xFFC0 is baseline standard(SOF) - // 0xFFC1 is baseline optimized(SOF) - // 0xFFC2 is progressive(SOF2) - next = buffer[i + 1]; - if (next === 0xC0 || next === 0xC1 || next === 0xC2) { - var size = extractSize(buffer, i + 5); - - if (!orientation) { - return size; - } - - return { - width: size.width, - height: size.height, - orientation: orientation - }; - } - - // move to the next block - buffer = buffer.slice(i + 2); - } - - throw new TypeError('Invalid JPG, no size found'); -} - -module.exports = { - 'detect': isJPG, - 'calculate': calculate -}; - -},{"../readUInt":59}],68:[function(_dereq_,module,exports){ -'use strict'; - -var pngSignature = 'PNG\r\n\x1a\n'; -var pngImageHeaderChunkName = 'IHDR'; - -// Used to detect "fried" png's: http://www.jongware.com/pngdefry.html -var pngFriedChunkName = 'CgBI'; - -function isPNG (buffer) { - if (pngSignature === buffer.toString('ascii', 1, 8)) { - var chunkName = buffer.toString('ascii', 12, 16); - if (chunkName === pngFriedChunkName) { - chunkName = buffer.toString('ascii', 28, 32); - } - if (chunkName !== pngImageHeaderChunkName) { - throw new TypeError('invalid png'); - } - return true; - } -} - -function calculate (buffer) { - if (buffer.toString('ascii', 12, 16) === pngFriedChunkName) { - return { - 'width': buffer.readUInt32BE(32), - 'height': buffer.readUInt32BE(36) - }; - } - return { - 'width': buffer.readUInt32BE(16), - 'height': buffer.readUInt32BE(20) - }; -} - -module.exports = { - 'detect': isPNG, - 'calculate': calculate -}; - -},{}],69:[function(_dereq_,module,exports){ -'use strict'; - -function isPSD (buffer) { - return ('8BPS' === buffer.toString('ascii', 0, 4)); -} - -function calculate (buffer) { - return { - 'width': buffer.readUInt32BE(18), - 'height': buffer.readUInt32BE(14) - }; -} - -module.exports = { - 'detect': isPSD, - 'calculate': calculate -}; - -},{}],70:[function(_dereq_,module,exports){ -'use strict'; - -var svgReg = /"']|"[^"]*"|'[^']*')*>/; -function isSVG (buffer) { - return svgReg.test(buffer); -} - -var extractorRegExps = { - 'root': svgReg, - 'width': /\swidth=(['"])([^%]+?)\1/, - 'height': /\sheight=(['"])([^%]+?)\1/, - 'viewbox': /\sviewBox=(['"])(.+?)\1/ -}; - -var units = { - 'cm': 96/2.54, - 'mm': 96/2.54/10, - 'm': 96/2.54*100, - 'pt': 96/72, - 'pc': 96/72/12, - 'em': 16, - 'ex': 8, -}; - -function parseLength (len) { - var m = /([0-9.]+)([a-z]*)/.exec(len); - if (!m) { - return undefined; - } - return Math.round(parseFloat(m[1]) * (units[m[2]] || 1)); -} - -function parseViewbox (viewbox) { - var bounds = viewbox.split(' '); - return { - 'width': parseLength(bounds[2]), - 'height': parseLength(bounds[3]) - }; -} - -function parseAttributes (root) { - var width = root.match(extractorRegExps.width); - var height = root.match(extractorRegExps.height); - var viewbox = root.match(extractorRegExps.viewbox); - return { - 'width': width && parseLength(width[2]), - 'height': height && parseLength(height[2]), - 'viewbox': viewbox && parseViewbox(viewbox[2]) - }; -} - -function calculateByDimensions (attrs) { - return { - 'width': attrs.width, - 'height': attrs.height - }; -} - -function calculateByViewbox (attrs) { - var ratio = attrs.viewbox.width / attrs.viewbox.height; - if (attrs.width) { - return { - 'width': attrs.width, - 'height': Math.floor(attrs.width / ratio) - }; - } - if (attrs.height) { - return { - 'width': Math.floor(attrs.height * ratio), - 'height': attrs.height - }; - } - return { - 'width': attrs.viewbox.width, - 'height': attrs.viewbox.height - }; -} - -function calculate (buffer) { - var root = buffer.toString('utf8').match(extractorRegExps.root); - if (root) { - var attrs = parseAttributes(root[0]); - if (attrs.width && attrs.height) { - return calculateByDimensions(attrs); - } - if (attrs.viewbox) { - return calculateByViewbox(attrs); - } - } - throw new TypeError('invalid svg'); -} - -module.exports = { - 'detect': isSVG, - 'calculate': calculate -}; - -},{}],71:[function(_dereq_,module,exports){ -(function (Buffer){(function (){ -'use strict'; - -// based on http://www.compix.com/fileformattif.htm -// TO-DO: support big-endian as well - -var fs = _dereq_('fs'); -var readUInt = _dereq_('../readUInt'); - -function isTIFF (buffer) { - var hex4 = buffer.toString('hex', 0, 4); - return ('49492a00' === hex4 || '4d4d002a' === hex4); -} - -// Read IFD (image-file-directory) into a buffer -function readIFD (buffer, filepath, isBigEndian) { - - var ifdOffset = readUInt(buffer, 32, 4, isBigEndian); - - // read only till the end of the file - var bufferSize = 1024; - var fileSize = fs.statSync(filepath).size; - if (ifdOffset + bufferSize > fileSize) { - bufferSize = fileSize - ifdOffset - 10; - } - - // populate the buffer - var endBuffer = Buffer.alloc(bufferSize); - var descriptor = fs.openSync(filepath, 'r'); - fs.readSync(descriptor, endBuffer, 0, bufferSize, ifdOffset); - - // var ifdLength = readUInt(endBuffer, 16, 0, isBigEndian); - var ifdBuffer = endBuffer.slice(2); //, 2 + 12 * ifdLength); - return ifdBuffer; -} - -// TIFF values seem to be messed up on Big-Endian, this helps -function readValue (buffer, isBigEndian) { - var low = readUInt(buffer, 16, 8, isBigEndian); - var high = readUInt(buffer, 16, 10, isBigEndian); - return (high << 16) + low; -} - -// move to the next tag -function nextTag (buffer) { - if (buffer.length > 24) { - return buffer.slice(12); - } -} - -// Extract IFD tags from TIFF metadata -/* eslint-disable complexity */ -function extractTags (buffer, isBigEndian) { - var tags = {}; - var code, type, length; - - while (buffer && buffer.length) { - code = readUInt(buffer, 16, 0, isBigEndian); - type = readUInt(buffer, 16, 2, isBigEndian); - length = readUInt(buffer, 32, 4, isBigEndian); - - // 0 means end of IFD - if (code === 0) { - break; - } else { - // 256 is width, 257 is height - // if (code === 256 || code === 257) { - if (length === 1 && (type === 3 || type === 4)) { - tags[code] = readValue(buffer, isBigEndian); - } - - // move to the next tag - buffer = nextTag(buffer); - } - } - return tags; -} -/* eslint-enable complexity */ - -// Test if the TIFF is Big Endian or Little Endian -function determineEndianness (buffer) { - var signature = buffer.toString('ascii', 0, 2); - if ('II' === signature) { - return 'LE'; - } else if ('MM' === signature) { - return 'BE'; - } -} - -function calculate (buffer, filepath) { - - if (!filepath) { - throw new TypeError('Tiff doesn\'t support buffer'); - } - - // Determine BE/LE - var isBigEndian = determineEndianness(buffer) === 'BE'; - - // read the IFD - var ifdBuffer = readIFD(buffer, filepath, isBigEndian); - - // extract the tags from the IFD - var tags = extractTags(ifdBuffer, isBigEndian); - - var width = tags[256]; - var height = tags[257]; - - if (!width || !height) { - throw new TypeError('Invalid Tiff, missing tags'); - } - - return { - 'width': width, - 'height': height - }; -} - -module.exports = { - 'detect': isTIFF, - 'calculate': calculate -}; - -}).call(this)}).call(this,_dereq_("buffer").Buffer) -},{"../readUInt":59,"buffer":18,"fs":16}],72:[function(_dereq_,module,exports){ -'use strict'; - -// based on https://developers.google.com/speed/webp/docs/riff_container - -function isWebP (buffer) { - var riffHeader = 'RIFF' === buffer.toString('ascii', 0, 4); - var webpHeader = 'WEBP' === buffer.toString('ascii', 8, 12); - var vp8Header = 'VP8' === buffer.toString('ascii', 12, 15); - return (riffHeader && webpHeader && vp8Header); -} - -/* eslint-disable complexity */ -function calculate (buffer) { - var chunkHeader = buffer.toString('ascii', 12, 16); - buffer = buffer.slice(20, 30); - - // Extended webp stream signature - if (chunkHeader === 'VP8X') { - var extendedHeader = buffer[0]; - var validStart = (extendedHeader & 0xc0) === 0; - var validEnd = (extendedHeader & 0x01) === 0; - if (validStart && validEnd) { - return calculateExtended(buffer); - } else { - return false; - } - } - - // Lossless webp stream signature - if (chunkHeader === 'VP8 ' && buffer[0] !== 0x2f) { - return calculateLossy(buffer); - } - - // Lossy webp stream signature - var signature = buffer.toString('hex', 3, 6); - if (chunkHeader === 'VP8L' && signature !== '9d012a') { - return calculateLossless(buffer); - } - - return false; -} -/* eslint-enable complexity */ - -function calculateExtended (buffer) { - return { - 'width': 1 + buffer.readUIntLE(4, 3), - 'height': 1 + buffer.readUIntLE(7, 3) - }; -} - -function calculateLossless (buffer) { - return { - 'width': 1 + (((buffer[2] & 0x3F) << 8) | buffer[1]), - 'height': 1 + (((buffer[4] & 0xF) << 10) | (buffer[3] << 2) | - ((buffer[2] & 0xC0) >> 6)) - }; -} - -function calculateLossy (buffer) { - // `& 0x3fff` returns the last 14 bits - // TO-DO: include webp scaling in the calculations - return { - 'width': buffer.readInt16LE(6) & 0x3fff, - 'height': buffer.readInt16LE(8) & 0x3fff - }; -} - -module.exports = { - 'detect': isWebP, - 'calculate': calculate -}; - -},{}],73:[function(_dereq_,module,exports){ module.exports = true; -},{}],74:[function(_dereq_,module,exports){ +},{}],67:[function(_dereq_,module,exports){ 'use strict' module.exports = isMobile @@ -16885,7 +15826,7 @@ function isMobile (opts) { return result } -},{}],75:[function(_dereq_,module,exports){ +},{}],68:[function(_dereq_,module,exports){ 'use strict'; /** @@ -16922,7 +15863,7 @@ module.exports = function(str){ return true; } -},{}],76:[function(_dereq_,module,exports){ +},{}],69:[function(_dereq_,module,exports){ var rootPosition = { left: 0, top: 0 } module.exports = mouseEventOffset @@ -16949,7 +15890,476 @@ function getBoundingClientOffset (element) { } } -},{}],77:[function(_dereq_,module,exports){ +},{}],70:[function(_dereq_,module,exports){ +(function (global,setImmediate){(function (){ +/*! Native Promise Only + v0.8.1 (c) Kyle Simpson + MIT License: http://getify.mit-license.org +*/ + +(function UMD(name,context,definition){ + // special form of UMD for polyfilling across evironments + context[name] = context[name] || definition(); + if (typeof module != "undefined" && module.exports) { module.exports = context[name]; } + else if (typeof define == "function" && define.amd) { define(function $AMD$(){ return context[name]; }); } +})("Promise",typeof global != "undefined" ? global : this,function DEF(){ + /*jshint validthis:true */ + "use strict"; + + var builtInProp, cycle, scheduling_queue, + ToString = Object.prototype.toString, + timer = (typeof setImmediate != "undefined") ? + function timer(fn) { return setImmediate(fn); } : + setTimeout + ; + + // dammit, IE8. + try { + Object.defineProperty({},"x",{}); + builtInProp = function builtInProp(obj,name,val,config) { + return Object.defineProperty(obj,name,{ + value: val, + writable: true, + configurable: config !== false + }); + }; + } + catch (err) { + builtInProp = function builtInProp(obj,name,val) { + obj[name] = val; + return obj; + }; + } + + // Note: using a queue instead of array for efficiency + scheduling_queue = (function Queue() { + var first, last, item; + + function Item(fn,self) { + this.fn = fn; + this.self = self; + this.next = void 0; + } + + return { + add: function add(fn,self) { + item = new Item(fn,self); + if (last) { + last.next = item; + } + else { + first = item; + } + last = item; + item = void 0; + }, + drain: function drain() { + var f = first; + first = last = cycle = void 0; + + while (f) { + f.fn.call(f.self); + f = f.next; + } + } + }; + })(); + + function schedule(fn,self) { + scheduling_queue.add(fn,self); + if (!cycle) { + cycle = timer(scheduling_queue.drain); + } + } + + // promise duck typing + function isThenable(o) { + var _then, o_type = typeof o; + + if (o != null && + ( + o_type == "object" || o_type == "function" + ) + ) { + _then = o.then; + } + return typeof _then == "function" ? _then : false; + } + + function notify() { + for (var i=0; i 0) { + schedule(notify,self); + } + } + } + catch (err) { + reject.call(new MakeDefWrapper(self),err); + } + } + + function reject(msg) { + var self = this; + + // already triggered? + if (self.triggered) { return; } + + self.triggered = true; + + // unwrap + if (self.def) { + self = self.def; + } + + self.msg = msg; + self.state = 2; + if (self.chain.length > 0) { + schedule(notify,self); + } + } + + function iteratePromises(Constructor,arr,resolver,rejecter) { + for (var idx=0; idx 2) { - var lastSlashIndex = res.lastIndexOf('/'); - if (lastSlashIndex !== res.length - 1) { - if (lastSlashIndex === -1) { - res = ''; - lastSegmentLength = 0; - } else { - res = res.slice(0, lastSlashIndex); - lastSegmentLength = res.length - 1 - res.lastIndexOf('/'); - } - lastSlash = i; - dots = 0; - continue; - } - } else if (res.length === 2 || res.length === 1) { - res = ''; - lastSegmentLength = 0; - lastSlash = i; - dots = 0; - continue; - } - } - if (allowAboveRoot) { - if (res.length > 0) - res += '/..'; - else - res = '..'; - lastSegmentLength = 2; - } - } else { - if (res.length > 0) - res += '/' + path.slice(lastSlash + 1, i); - else - res = path.slice(lastSlash + 1, i); - lastSegmentLength = i - lastSlash - 1; - } - lastSlash = i; - dots = 0; - } else if (code === 46 /*.*/ && dots !== -1) { - ++dots; - } else { - dots = -1; - } - } - return res; -} - -function _format(sep, pathObject) { - var dir = pathObject.dir || pathObject.root; - var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || ''); - if (!dir) { - return base; - } - if (dir === pathObject.root) { - return dir + base; - } - return dir + sep + base; -} - -var posix = { - // path.resolve([from ...], to) - resolve: function resolve() { - var resolvedPath = ''; - var resolvedAbsolute = false; - var cwd; - - for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { - var path; - if (i >= 0) - path = arguments[i]; - else { - if (cwd === undefined) - cwd = process.cwd(); - path = cwd; - } - - assertPath(path); - - // Skip empty entries - if (path.length === 0) { - continue; - } - - resolvedPath = path + '/' + resolvedPath; - resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/; - } - - // At this point the path should be resolved to a full absolute path, but - // handle relative paths to be safe (might happen when process.cwd() fails) - - // Normalize the path - resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute); - - if (resolvedAbsolute) { - if (resolvedPath.length > 0) - return '/' + resolvedPath; - else - return '/'; - } else if (resolvedPath.length > 0) { - return resolvedPath; - } else { - return '.'; - } - }, - - normalize: function normalize(path) { - assertPath(path); - - if (path.length === 0) return '.'; - - var isAbsolute = path.charCodeAt(0) === 47 /*/*/; - var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/; - - // Normalize the path - path = normalizeStringPosix(path, !isAbsolute); - - if (path.length === 0 && !isAbsolute) path = '.'; - if (path.length > 0 && trailingSeparator) path += '/'; - - if (isAbsolute) return '/' + path; - return path; - }, - - isAbsolute: function isAbsolute(path) { - assertPath(path); - return path.length > 0 && path.charCodeAt(0) === 47 /*/*/; - }, - - join: function join() { - if (arguments.length === 0) - return '.'; - var joined; - for (var i = 0; i < arguments.length; ++i) { - var arg = arguments[i]; - assertPath(arg); - if (arg.length > 0) { - if (joined === undefined) - joined = arg; - else - joined += '/' + arg; - } - } - if (joined === undefined) - return '.'; - return posix.normalize(joined); - }, - - relative: function relative(from, to) { - assertPath(from); - assertPath(to); - - if (from === to) return ''; - - from = posix.resolve(from); - to = posix.resolve(to); - - if (from === to) return ''; - - // Trim any leading backslashes - var fromStart = 1; - for (; fromStart < from.length; ++fromStart) { - if (from.charCodeAt(fromStart) !== 47 /*/*/) - break; - } - var fromEnd = from.length; - var fromLen = fromEnd - fromStart; - - // Trim any leading backslashes - var toStart = 1; - for (; toStart < to.length; ++toStart) { - if (to.charCodeAt(toStart) !== 47 /*/*/) - break; - } - var toEnd = to.length; - var toLen = toEnd - toStart; - - // Compare paths to find the longest common path from root - var length = fromLen < toLen ? fromLen : toLen; - var lastCommonSep = -1; - var i = 0; - for (; i <= length; ++i) { - if (i === length) { - if (toLen > length) { - if (to.charCodeAt(toStart + i) === 47 /*/*/) { - // We get here if `from` is the exact base path for `to`. - // For example: from='/foo/bar'; to='/foo/bar/baz' - return to.slice(toStart + i + 1); - } else if (i === 0) { - // We get here if `from` is the root - // For example: from='/'; to='/foo' - return to.slice(toStart + i); - } - } else if (fromLen > length) { - if (from.charCodeAt(fromStart + i) === 47 /*/*/) { - // We get here if `to` is the exact base path for `from`. - // For example: from='/foo/bar/baz'; to='/foo/bar' - lastCommonSep = i; - } else if (i === 0) { - // We get here if `to` is the root. - // For example: from='/foo'; to='/' - lastCommonSep = 0; - } - } - break; - } - var fromCode = from.charCodeAt(fromStart + i); - var toCode = to.charCodeAt(toStart + i); - if (fromCode !== toCode) - break; - else if (fromCode === 47 /*/*/) - lastCommonSep = i; - } - - var out = ''; - // Generate the relative path based on the path difference between `to` - // and `from` - for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) { - if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) { - if (out.length === 0) - out += '..'; - else - out += '/..'; - } - } - - // Lastly, append the rest of the destination (`to`) path that comes after - // the common path parts - if (out.length > 0) - return out + to.slice(toStart + lastCommonSep); - else { - toStart += lastCommonSep; - if (to.charCodeAt(toStart) === 47 /*/*/) - ++toStart; - return to.slice(toStart); - } - }, - - _makeLong: function _makeLong(path) { - return path; - }, - - dirname: function dirname(path) { - assertPath(path); - if (path.length === 0) return '.'; - var code = path.charCodeAt(0); - var hasRoot = code === 47 /*/*/; - var end = -1; - var matchedSlash = true; - for (var i = path.length - 1; i >= 1; --i) { - code = path.charCodeAt(i); - if (code === 47 /*/*/) { - if (!matchedSlash) { - end = i; - break; - } - } else { - // We saw the first non-path separator - matchedSlash = false; - } - } - - if (end === -1) return hasRoot ? '/' : '.'; - if (hasRoot && end === 1) return '//'; - return path.slice(0, end); - }, - - basename: function basename(path, ext) { - if (ext !== undefined && typeof ext !== 'string') throw new TypeError('"ext" argument must be a string'); - assertPath(path); - - var start = 0; - var end = -1; - var matchedSlash = true; - var i; - - if (ext !== undefined && ext.length > 0 && ext.length <= path.length) { - if (ext.length === path.length && ext === path) return ''; - var extIdx = ext.length - 1; - var firstNonSlashEnd = -1; - for (i = path.length - 1; i >= 0; --i) { - var code = path.charCodeAt(i); - if (code === 47 /*/*/) { - // If we reached a path separator that was not part of a set of path - // separators at the end of the string, stop now - if (!matchedSlash) { - start = i + 1; - break; - } - } else { - if (firstNonSlashEnd === -1) { - // We saw the first non-path separator, remember this index in case - // we need it if the extension ends up not matching - matchedSlash = false; - firstNonSlashEnd = i + 1; - } - if (extIdx >= 0) { - // Try to match the explicit extension - if (code === ext.charCodeAt(extIdx)) { - if (--extIdx === -1) { - // We matched the extension, so mark this as the end of our path - // component - end = i; - } - } else { - // Extension does not match, so our result is the entire path - // component - extIdx = -1; - end = firstNonSlashEnd; - } - } - } - } - - if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length; - return path.slice(start, end); - } else { - for (i = path.length - 1; i >= 0; --i) { - if (path.charCodeAt(i) === 47 /*/*/) { - // If we reached a path separator that was not part of a set of path - // separators at the end of the string, stop now - if (!matchedSlash) { - start = i + 1; - break; - } - } else if (end === -1) { - // We saw the first non-path separator, mark this as the end of our - // path component - matchedSlash = false; - end = i + 1; - } - } - - if (end === -1) return ''; - return path.slice(start, end); - } - }, - - extname: function extname(path) { - assertPath(path); - var startDot = -1; - var startPart = 0; - var end = -1; - var matchedSlash = true; - // Track the state of characters (if any) we see before our first dot and - // after any path separator we find - var preDotState = 0; - for (var i = path.length - 1; i >= 0; --i) { - var code = path.charCodeAt(i); - if (code === 47 /*/*/) { - // If we reached a path separator that was not part of a set of path - // separators at the end of the string, stop now - if (!matchedSlash) { - startPart = i + 1; - break; - } - continue; - } - if (end === -1) { - // We saw the first non-path separator, mark this as the end of our - // extension - matchedSlash = false; - end = i + 1; - } - if (code === 46 /*.*/) { - // If this is our first dot, mark it as the start of our extension - if (startDot === -1) - startDot = i; - else if (preDotState !== 1) - preDotState = 1; - } else if (startDot !== -1) { - // We saw a non-dot and non-path separator before our dot, so we should - // have a good chance at having a non-empty extension - preDotState = -1; - } - } - - if (startDot === -1 || end === -1 || - // We saw a non-dot character immediately before the dot - preDotState === 0 || - // The (right-most) trimmed path component is exactly '..' - preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { - return ''; - } - return path.slice(startDot, end); - }, - - format: function format(pathObject) { - if (pathObject === null || typeof pathObject !== 'object') { - throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject); - } - return _format('/', pathObject); - }, - - parse: function parse(path) { - assertPath(path); - - var ret = { root: '', dir: '', base: '', ext: '', name: '' }; - if (path.length === 0) return ret; - var code = path.charCodeAt(0); - var isAbsolute = code === 47 /*/*/; - var start; - if (isAbsolute) { - ret.root = '/'; - start = 1; - } else { - start = 0; - } - var startDot = -1; - var startPart = 0; - var end = -1; - var matchedSlash = true; - var i = path.length - 1; - - // Track the state of characters (if any) we see before our first dot and - // after any path separator we find - var preDotState = 0; - - // Get non-dir info - for (; i >= start; --i) { - code = path.charCodeAt(i); - if (code === 47 /*/*/) { - // If we reached a path separator that was not part of a set of path - // separators at the end of the string, stop now - if (!matchedSlash) { - startPart = i + 1; - break; - } - continue; - } - if (end === -1) { - // We saw the first non-path separator, mark this as the end of our - // extension - matchedSlash = false; - end = i + 1; - } - if (code === 46 /*.*/) { - // If this is our first dot, mark it as the start of our extension - if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1; - } else if (startDot !== -1) { - // We saw a non-dot and non-path separator before our dot, so we should - // have a good chance at having a non-empty extension - preDotState = -1; - } - } - - if (startDot === -1 || end === -1 || - // We saw a non-dot character immediately before the dot - preDotState === 0 || - // The (right-most) trimmed path component is exactly '..' - preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { - if (end !== -1) { - if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end); - } - } else { - if (startPart === 0 && isAbsolute) { - ret.name = path.slice(1, startDot); - ret.base = path.slice(1, end); - } else { - ret.name = path.slice(startPart, startDot); - ret.base = path.slice(startPart, end); - } - ret.ext = path.slice(startDot, end); - } - - if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/'; - - return ret; - }, - - sep: '/', - delimiter: ':', - win32: null, - posix: null -}; - -posix.posix = posix; - -module.exports = posix; - -}).call(this)}).call(this,_dereq_('_process')) -},{"_process":87}],79:[function(_dereq_,module,exports){ +},{}],73:[function(_dereq_,module,exports){ /* * @copyright 2016 Sean Connelly (@voidqk), http://syntheti.cc * @license MIT @@ -17669,7 +16546,7 @@ if (typeof window === 'object') module.exports = PolyBool; -},{"./lib/build-log":80,"./lib/epsilon":81,"./lib/geojson":82,"./lib/intersecter":83,"./lib/segment-chainer":85,"./lib/segment-selector":86}],80:[function(_dereq_,module,exports){ +},{"./lib/build-log":74,"./lib/epsilon":75,"./lib/geojson":76,"./lib/intersecter":77,"./lib/segment-chainer":79,"./lib/segment-selector":80}],74:[function(_dereq_,module,exports){ // (c) Copyright 2016, Sean Connelly (@voidqk), http://syntheti.cc // MIT License // Project Home: https://github.com/voidqk/polybooljs @@ -17784,7 +16661,7 @@ function BuildLog(){ module.exports = BuildLog; -},{}],81:[function(_dereq_,module,exports){ +},{}],75:[function(_dereq_,module,exports){ // (c) Copyright 2016, Sean Connelly (@voidqk), http://syntheti.cc // MIT License // Project Home: https://github.com/voidqk/polybooljs @@ -17956,7 +16833,7 @@ function Epsilon(eps){ module.exports = Epsilon; -},{}],82:[function(_dereq_,module,exports){ +},{}],76:[function(_dereq_,module,exports){ // (c) Copyright 2017, Sean Connelly (@voidqk), http://syntheti.cc // MIT License // Project Home: https://github.com/voidqk/polybooljs @@ -18146,7 +17023,7 @@ var GeoJSON = { module.exports = GeoJSON; -},{}],83:[function(_dereq_,module,exports){ +},{}],77:[function(_dereq_,module,exports){ // (c) Copyright 2016, Sean Connelly (@voidqk), http://syntheti.cc // MIT License // Project Home: https://github.com/voidqk/polybooljs @@ -18653,7 +17530,7 @@ function Intersecter(selfIntersection, eps, buildLog){ module.exports = Intersecter; -},{"./linked-list":84}],84:[function(_dereq_,module,exports){ +},{"./linked-list":78}],78:[function(_dereq_,module,exports){ // (c) Copyright 2016, Sean Connelly (@voidqk), http://syntheti.cc // MIT License // Project Home: https://github.com/voidqk/polybooljs @@ -18736,7 +17613,7 @@ var LinkedList = { module.exports = LinkedList; -},{}],85:[function(_dereq_,module,exports){ +},{}],79:[function(_dereq_,module,exports){ // (c) Copyright 2016, Sean Connelly (@voidqk), http://syntheti.cc // MIT License // Project Home: https://github.com/voidqk/polybooljs @@ -18990,7 +17867,7 @@ function SegmentChainer(segments, eps, buildLog){ module.exports = SegmentChainer; -},{}],86:[function(_dereq_,module,exports){ +},{}],80:[function(_dereq_,module,exports){ // (c) Copyright 2016, Sean Connelly (@voidqk), http://syntheti.cc // MIT License // Project Home: https://github.com/voidqk/polybooljs @@ -19158,7 +18035,1391 @@ var SegmentSelector = { module.exports = SegmentSelector; -},{}],87:[function(_dereq_,module,exports){ +},{}],81:[function(_dereq_,module,exports){ +'use strict'; + + +var Transform = _dereq_('stream').Transform; +var streamParser = _dereq_('stream-parser'); + + +function ParserStream() { + Transform.call(this, { readableObjectMode: true }); +} + +// Inherit from Transform +ParserStream.prototype = Object.create(Transform.prototype); +ParserStream.prototype.constructor = ParserStream; + +streamParser(ParserStream.prototype); + + +exports.ParserStream = ParserStream; + + +exports.sliceEq = function (src, start, dest) { + for (var i = start, j = 0; j < dest.length;) { + if (src[i++] !== dest[j++]) return false; + } + return true; +}; + +exports.str2arr = function (str, format) { + var arr = [], i = 0; + + if (format && format === 'hex') { + while (i < str.length) { + arr.push(parseInt(str.slice(i, i + 2), 16)); + i += 2; + } + } else { + for (; i < str.length; i++) { + /* eslint-disable no-bitwise */ + arr.push(str.charCodeAt(i) & 0xFF); + } + } + + return arr; +}; + +exports.readUInt16LE = function (data, offset) { + return data[offset] | (data[offset + 1] << 8); +}; + +exports.readUInt16BE = function (data, offset) { + return data[offset + 1] | (data[offset] << 8); +}; + +exports.readUInt32LE = function (data, offset) { + return data[offset] | + (data[offset + 1] << 8) | + (data[offset + 2] << 16) | + (data[offset + 3] * 0x1000000); +}; + +exports.readUInt32BE = function (data, offset) { + return data[offset + 3] | + (data[offset + 2] << 8) | + (data[offset + 1] << 16) | + (data[offset] * 0x1000000); +}; + + +function ProbeError(message, code, statusCode) { + Error.call(this); + Error.captureStackTrace(this, this.constructor); + + this.name = this.constructor.name; + + this.message = message; + if (code) this.code = code; + if (statusCode) this.statusCode = statusCode; +} + +// Inherit from Error +ProbeError.prototype = Object.create(Error.prototype); +ProbeError.prototype.constructor = ProbeError; + + +exports.ProbeError = ProbeError; + +},{"stream":98,"stream-parser":114}],82:[function(_dereq_,module,exports){ + +/* eslint-disable no-bitwise */ +/* eslint-disable consistent-return */ + +'use strict'; + +////////////////////////////////////////////////////////////////////////// +// Helpers +// +function error(message, code) { + var err = new Error(message); + err.code = code; + return err; +} + + +function utf8_decode(str) { + try { + return decodeURIComponent(escape(str)); + } catch (_) { + return str; + } +} + + +////////////////////////////////////////////////////////////////////////// +// Exif parser +// +// Input: +// - jpeg_bin: Uint8Array - jpeg file +// - exif_start: Number - start of TIFF header (after Exif\0\0) +// - exif_end: Number - end of Exif segment +// - on_entry: Number - callback +// +function ExifParser(jpeg_bin, exif_start, exif_end) { + // Uint8Array, exif without signature (which isn't included in offsets) + this.input = jpeg_bin.subarray(exif_start, exif_end); + + // offset correction for `on_entry` callback + this.start = exif_start; + + // Check TIFF header (includes byte alignment and first IFD offset) + var sig = String.fromCharCode.apply(null, this.input.subarray(0, 4)); + + if (sig !== 'II\x2A\0' && sig !== 'MM\0\x2A') { + throw error('invalid TIFF signature', 'EBADDATA'); + } + + // true if motorola (big endian) byte alignment, false if intel + this.big_endian = sig[0] === 'M'; +} + + +ExifParser.prototype.each = function (on_entry) { + // allow premature exit + this.aborted = false; + + var offset = this.read_uint32(4); + + this.ifds_to_read = [ { + id: 0, + offset: offset + } ]; + + while (this.ifds_to_read.length > 0 && !this.aborted) { + var i = this.ifds_to_read.shift(); + if (!i.offset) continue; + this.scan_ifd(i.id, i.offset, on_entry); + } +}; + + +ExifParser.prototype.read_uint16 = function (offset) { + var d = this.input; + if (offset + 2 > d.length) throw error('unexpected EOF', 'EBADDATA'); + + return this.big_endian ? + d[offset] * 0x100 + d[offset + 1] : + d[offset] + d[offset + 1] * 0x100; +}; + + +ExifParser.prototype.read_uint32 = function (offset) { + var d = this.input; + if (offset + 4 > d.length) throw error('unexpected EOF', 'EBADDATA'); + + return this.big_endian ? + d[offset] * 0x1000000 + d[offset + 1] * 0x10000 + d[offset + 2] * 0x100 + d[offset + 3] : + d[offset] + d[offset + 1] * 0x100 + d[offset + 2] * 0x10000 + d[offset + 3] * 0x1000000; +}; + + +ExifParser.prototype.is_subifd_link = function (ifd, tag) { + return (ifd === 0 && tag === 0x8769) || // SubIFD + (ifd === 0 && tag === 0x8825) || // GPS Info + (ifd === 0x8769 && tag === 0xA005); // Interop IFD +}; + + +// Returns byte length of a single component of a given format +// +ExifParser.prototype.exif_format_length = function (format) { + switch (format) { + case 1: // byte + case 2: // ascii + case 6: // sbyte + case 7: // undefined + return 1; + + case 3: // short + case 8: // sshort + return 2; + + case 4: // long + case 9: // slong + case 11: // float + return 4; + + case 5: // rational + case 10: // srational + case 12: // double + return 8; + + default: + // unknown type + return 0; + } +}; + + +// Reads Exif data +// +ExifParser.prototype.exif_format_read = function (format, offset) { + var v; + + switch (format) { + case 1: // byte + case 2: // ascii + v = this.input[offset]; + return v; + + case 6: // sbyte + v = this.input[offset]; + return v | (v & 0x80) * 0x1fffffe; + + case 3: // short + v = this.read_uint16(offset); + return v; + + case 8: // sshort + v = this.read_uint16(offset); + return v | (v & 0x8000) * 0x1fffe; + + case 4: // long + v = this.read_uint32(offset); + return v; + + case 9: // slong + v = this.read_uint32(offset); + return v | 0; + + case 5: // rational + case 10: // srational + case 11: // float + case 12: // double + return null; // not implemented + + case 7: // undefined + return null; // blob + + default: + // unknown type + return null; + } +}; + + +ExifParser.prototype.scan_ifd = function (ifd_no, offset, on_entry) { + var entry_count = this.read_uint16(offset); + + offset += 2; + + for (var i = 0; i < entry_count; i++) { + var tag = this.read_uint16(offset); + var format = this.read_uint16(offset + 2); + var count = this.read_uint32(offset + 4); + + var comp_length = this.exif_format_length(format); + var data_length = count * comp_length; + var data_offset = data_length <= 4 ? offset + 8 : this.read_uint32(offset + 8); + var is_subifd_link = false; + + if (data_offset + data_length > this.input.length) { + throw error('unexpected EOF', 'EBADDATA'); + } + + var value = []; + var comp_offset = data_offset; + + for (var j = 0; j < count; j++, comp_offset += comp_length) { + var item = this.exif_format_read(format, comp_offset); + if (item === null) { + value = null; + break; + } + value.push(item); + } + + if (Array.isArray(value) && format === 2) { + value = utf8_decode(String.fromCharCode.apply(null, value)); + if (value && value[value.length - 1] === '\0') value = value.slice(0, -1); + } + + if (this.is_subifd_link(ifd_no, tag)) { + if (Array.isArray(value) && Number.isInteger(value[0]) && value[0] > 0) { + this.ifds_to_read.push({ + id: tag, + offset: value[0] + }); + is_subifd_link = true; + } + } + + var entry = { + is_big_endian: this.big_endian, + ifd: ifd_no, + tag: tag, + format: format, + count: count, + entry_offset: offset + this.start, + data_length: data_length, + data_offset: data_offset + this.start, + value: value, + is_subifd_link: is_subifd_link + }; + + if (on_entry(entry) === false) { + this.aborted = true; + return; + } + + offset += 12; + } + + if (ifd_no === 0) { + this.ifds_to_read.push({ + id: 1, + offset: this.read_uint32(offset) + }); + } +}; + + +module.exports.ExifParser = ExifParser; + +// returns orientation stored in Exif (1-8), 0 if none was found, -1 if error +module.exports.get_orientation = function (data) { + var orientation = 0; + try { + new ExifParser(data, 0, data.length).each(function (entry) { + if (entry.ifd === 0 && entry.tag === 0x112 && Array.isArray(entry.value)) { + orientation = entry.value[0]; + return false; + } + }); + return orientation; + } catch (err) { + return -1; + } +}; + +},{}],83:[function(_dereq_,module,exports){ +// Utils used to parse miaf-based files (avif/heic/heif) +// +// ISO media file spec: +// https://web.archive.org/web/20180219054429/http://l.web.umkc.edu/lizhu/teaching/2016sp.video-communication/ref/mp4.pdf +// +// ISO image file format spec: +// https://standards.iso.org/ittf/PubliclyAvailableStandards/c066067_ISO_IEC_23008-12_2017.zip +// + +'use strict'; + +/* eslint-disable consistent-return */ +/* eslint-disable no-bitwise */ + +var readUInt16BE = _dereq_('./common').readUInt16BE; +var readUInt32BE = _dereq_('./common').readUInt32BE; + +/* + * interface Box { + * size: uint32; // if size == 0, box lasts until EOF + * boxtype: char[4]; + * largesize?: uint64; // only if size == 1 + * usertype?: char[16]; // only if boxtype == 'uuid' + * } + */ +function unbox(data, offset) { + if (data.length < 4 + offset) return null; + + var size = readUInt32BE(data, offset); + + // size includes first 4 bytes (length) + if (data.length < size + offset || size < 8) return null; + + // if size === 1, real size is following uint64 (only for big boxes, not needed) + // if size === 0, real size is until the end of the file (only for big boxes, not needed) + + return { + boxtype: String.fromCharCode.apply(null, data.slice(offset + 4, offset + 8)), + data: data.slice(offset + 8, offset + size), + end: offset + size + }; +} + + +module.exports.unbox = unbox; + + +// parses `meta` -> `iprp` -> `ipco` box, returns: +// { +// sizes: [ { width, height } ], +// transforms: [ { type, value } ] +// } +function scan_ipco(data, sandbox) { + var offset = 0; + + for (;;) { + var box = unbox(data, offset); + if (!box) break; + + switch (box.boxtype) { + case 'ispe': + sandbox.sizes.push({ + width: readUInt32BE(box.data, 4), + height: readUInt32BE(box.data, 8) + }); + break; + + case 'irot': + sandbox.transforms.push({ + type: 'irot', + value: box.data[0] & 3 + }); + break; + + case 'imir': + sandbox.transforms.push({ + type: 'imir', + value: box.data[0] & 1 + }); + break; + } + + offset = box.end; + } +} + + +function readUIntBE(data, offset, size) { + var result = 0; + + for (var i = 0; i < size; i++) { + result = result * 256 + (data[offset + i] || 0); + } + + return result; +} + + +// parses `meta` -> `iloc` box +function scan_iloc(data, sandbox) { + var offset_size = (data[4] >> 4) & 0xF; + var length_size = data[4] & 0xF; + var base_offset_size = (data[5] >> 4) & 0xF; + var item_count = readUInt16BE(data, 6); + var offset = 8; + + for (var i = 0; i < item_count; i++) { + var item_ID = readUInt16BE(data, offset); + offset += 2; + + var data_reference_index = readUInt16BE(data, offset); + offset += 2; + + var base_offset = readUIntBE(data, offset, base_offset_size); + offset += base_offset_size; + + var extent_count = readUInt16BE(data, offset); + offset += 2; + + if (data_reference_index === 0 && extent_count === 1) { + var first_extent_offset = readUIntBE(data, offset, offset_size); + var first_extent_length = readUIntBE(data, offset + offset_size, length_size); + sandbox.item_loc[item_ID] = { length: first_extent_length, offset: first_extent_offset + base_offset }; + } + + offset += extent_count * (offset_size + length_size); + } +} + + +// parses `meta` -> `iinf` box +function scan_iinf(data, sandbox) { + var item_count = readUInt16BE(data, 4); + var offset = 6; + + for (var i = 0; i < item_count; i++) { + var box = unbox(data, offset); + if (!box) break; + if (box.boxtype === 'infe') { + var item_id = readUInt16BE(box.data, 4); + var item_name = ''; + + for (var pos = 8; pos < box.data.length && box.data[pos]; pos++) { + item_name += String.fromCharCode(box.data[pos]); + } + + sandbox.item_inf[item_name] = item_id; + } + offset = box.end; + } +} + + +// parses `meta` -> `iprp` box +function scan_iprp(data, sandbox) { + var offset = 0; + + for (;;) { + var box = unbox(data, offset); + if (!box) break; + if (box.boxtype === 'ipco') scan_ipco(box.data, sandbox); + offset = box.end; + } +} + + +// parses `meta` box +function scan_meta(data, sandbox) { + var offset = 4; // version + flags + + for (;;) { + var box = unbox(data, offset); + if (!box) break; + if (box.boxtype === 'iprp') scan_iprp(box.data, sandbox); + if (box.boxtype === 'iloc') scan_iloc(box.data, sandbox); + if (box.boxtype === 'iinf') scan_iinf(box.data, sandbox); + offset = box.end; + } +} + + +// get image with largest single dimension as base +function getMaxSize(sizes) { + var maxWidthSize = sizes.reduce(function (a, b) { + return a.width > b.width || (a.width === b.width && a.height > b.height) ? a : b; + }); + + var maxHeightSize = sizes.reduce(function (a, b) { + return a.height > b.height || (a.height === b.height && a.width > b.width) ? a : b; + }); + + var maxSize; + + if (maxWidthSize.width > maxHeightSize.height || + (maxWidthSize.width === maxHeightSize.height && maxWidthSize.height > maxHeightSize.width)) { + maxSize = maxWidthSize; + } else { + maxSize = maxHeightSize; + } + + return maxSize; +} + + +module.exports.readSizeFromMeta = function (data) { + var sandbox = { + sizes: [], + transforms: [], + item_inf: {}, + item_loc: {} + }; + + scan_meta(data, sandbox); + + if (!sandbox.sizes.length) return; + + var maxSize = getMaxSize(sandbox.sizes); + + var orientation = 1; + + // convert imir/irot to exif orientation + sandbox.transforms.forEach(function (transform) { + var rotate_ccw = { 1: 6, 2: 5, 3: 8, 4: 7, 5: 4, 6: 3, 7: 2, 8: 1 }; + var mirror_vert = { 1: 4, 2: 3, 3: 2, 4: 1, 5: 6, 6: 5, 7: 8, 8: 7 }; + + if (transform.type === 'imir') { + if (transform.value === 0) { + // vertical flip + orientation = mirror_vert[orientation]; + } else { + // horizontal flip = vertical flip + 180 deg rotation + orientation = mirror_vert[orientation]; + orientation = rotate_ccw[orientation]; + orientation = rotate_ccw[orientation]; + } + } + + if (transform.type === 'irot') { + // counter-clockwise rotation 90 deg 0-3 times + for (var i = 0; i < transform.value; i++) { + orientation = rotate_ccw[orientation]; + } + } + }); + + var exif_location = null; + + if (sandbox.item_inf.Exif) { + exif_location = sandbox.item_loc[sandbox.item_inf.Exif]; + } + + return { + width: maxSize.width, + height: maxSize.height, + orientation: sandbox.transforms.length ? orientation : null, + variants: sandbox.sizes, + exif_location: exif_location + }; +}; + + +module.exports.getMimeType = function (data) { + var brand = String.fromCharCode.apply(null, data.slice(0, 4)); + var compat = {}; + + compat[brand] = true; + + for (var i = 8; i < data.length; i += 4) { + compat[String.fromCharCode.apply(null, data.slice(i, i + 4))] = true; + } + + // heic and avif are superset of miaf, so they should all list mif1 as compatible + if (!compat.mif1 && !compat.msf1 && !compat.miaf) return; + + if (brand === 'avif' || brand === 'avis' || brand === 'avio') { + // `.avifs` and `image/avif-sequence` are removed from spec, all files have single type + return { type: 'avif', mime: 'image/avif' }; + } + + // https://nokiatech.github.io/heif/technical.html + if (brand === 'heic' || brand === 'heix') { + return { type: 'heic', mime: 'image/heic' }; + } + + if (brand === 'hevc' || brand === 'hevx') { + return { type: 'heic', mime: 'image/heic-sequence' }; + } + + if (compat.avif || compat.avis) { + return { type: 'avif', mime: 'image/avif' }; + } + + if (compat.heic || compat.heix || compat.hevc || compat.hevx || compat.heis) { + if (compat.msf1) { + return { type: 'heif', mime: 'image/heif-sequence' }; + } + return { type: 'heif', mime: 'image/heif' }; + } + + return { type: 'avif', mime: 'image/avif' }; +}; + +},{"./common":81}],84:[function(_dereq_,module,exports){ +// Utils used to parse miaf-based files (avif/heic/heif) +// +// - image collections are not supported (only last size is reported) +// - images with metadata encoded after image data are not supported +// - images without any `ispe` box are not supported +// + +/* eslint-disable consistent-return */ + +'use strict'; + + +var str2arr = _dereq_('../common').str2arr; +var sliceEq = _dereq_('../common').sliceEq; +var readUInt32BE = _dereq_('../common').readUInt32BE; +var miaf = _dereq_('../miaf_utils'); +var exif = _dereq_('../exif_utils'); + +var SIG_FTYP = str2arr('ftyp'); + + +module.exports = function (data) { + // ISO media file (avif format) starts with ftyp box: + // 0000 0020 6674 7970 6176 6966 + // (length) f t y p a v i f + // + if (!sliceEq(data, 4, SIG_FTYP)) return; + + var firstBox = miaf.unbox(data, 0); + if (!firstBox) return; + + var fileType = miaf.getMimeType(firstBox.data); + if (!fileType) return; + + var meta, offset = firstBox.end; + + for (;;) { + var box = miaf.unbox(data, offset); + if (!box) break; + offset = box.end; + + // mdat block SHOULD be last (but not strictly required), + // so it's unlikely that metadata is after it + if (box.boxtype === 'mdat') return; + if (box.boxtype === 'meta') { + meta = box.data; + break; + } + } + + if (!meta) return; + + var imgSize = miaf.readSizeFromMeta(meta); + + if (!imgSize) return; + + var result = { + width: imgSize.width, + height: imgSize.height, + type: fileType.type, + mime: fileType.mime, + wUnits: 'px', + hUnits: 'px' + }; + + if (imgSize.variants.length > 1) { + result.variants = imgSize.variants; + } + + if (imgSize.orientation) { + result.orientation = imgSize.orientation; + } + + if (imgSize.exif_location && + imgSize.exif_location.offset + imgSize.exif_location.length <= data.length) { + + var sig_offset = readUInt32BE(data, imgSize.exif_location.offset); + var exif_data = data.slice( + imgSize.exif_location.offset + sig_offset + 4, + imgSize.exif_location.offset + imgSize.exif_location.length); + + var orientation = exif.get_orientation(exif_data); + + if (orientation > 0) result.orientation = orientation; + } + + return result; +}; + +},{"../common":81,"../exif_utils":82,"../miaf_utils":83}],85:[function(_dereq_,module,exports){ +'use strict'; + +/* eslint-disable consistent-return */ + +var str2arr = _dereq_('../common').str2arr; +var sliceEq = _dereq_('../common').sliceEq; +var readUInt16LE = _dereq_('../common').readUInt16LE; + +var SIG_BM = str2arr('BM'); + + +module.exports = function (data) { + if (data.length < 26) return; + + if (!sliceEq(data, 0, SIG_BM)) return; + + return { + width: readUInt16LE(data, 18), + height: readUInt16LE(data, 22), + type: 'bmp', + mime: 'image/bmp', + wUnits: 'px', + hUnits: 'px' + }; +}; + +},{"../common":81}],86:[function(_dereq_,module,exports){ +'use strict'; + +/* eslint-disable consistent-return */ + +var str2arr = _dereq_('../common').str2arr; +var sliceEq = _dereq_('../common').sliceEq; +var readUInt16LE = _dereq_('../common').readUInt16LE; + + +var SIG_GIF87a = str2arr('GIF87a'); +var SIG_GIF89a = str2arr('GIF89a'); + + +module.exports = function (data) { + if (data.length < 10) return; + + if (!sliceEq(data, 0, SIG_GIF87a) && !sliceEq(data, 0, SIG_GIF89a)) return; + + return { + width: readUInt16LE(data, 6), + height: readUInt16LE(data, 8), + type: 'gif', + mime: 'image/gif', + wUnits: 'px', + hUnits: 'px' + }; +}; + +},{"../common":81}],87:[function(_dereq_,module,exports){ +'use strict'; + +/* eslint-disable consistent-return */ + +var readUInt16LE = _dereq_('../common').readUInt16LE; + +var HEADER = 0; +var TYPE_ICO = 1; +var INDEX_SIZE = 16; + +// Format specification: +// https://en.wikipedia.org/wiki/ICO_(file_format)#Icon_resource_structure +module.exports = function (data) { + var header = readUInt16LE(data, 0); + var type = readUInt16LE(data, 2); + var numImages = readUInt16LE(data, 4); + + if (header !== HEADER || type !== TYPE_ICO || !numImages) { + return; + } + + var variants = []; + var maxSize = { width: 0, height: 0 }; + + for (var i = 0; i < numImages; i++) { + var width = data[6 + INDEX_SIZE * i] || 256; + var height = data[6 + INDEX_SIZE * i + 1] || 256; + var size = { width: width, height: height }; + variants.push(size); + + if (width > maxSize.width || height > maxSize.height) { + maxSize = size; + } + } + + return { + width: maxSize.width, + height: maxSize.height, + variants: variants, + type: 'ico', + mime: 'image/x-icon', + wUnits: 'px', + hUnits: 'px' + }; +}; + +},{"../common":81}],88:[function(_dereq_,module,exports){ +'use strict'; + +/* eslint-disable consistent-return */ + +var readUInt16BE = _dereq_('../common').readUInt16BE; +var str2arr = _dereq_('../common').str2arr; +var sliceEq = _dereq_('../common').sliceEq; +var exif = _dereq_('../exif_utils'); + + +var SIG_EXIF = str2arr('Exif\0\0'); + + +module.exports = function (data) { + if (data.length < 2) return; + + // first marker of the file MUST be 0xFFD8 + if (data[0] !== 0xFF || data[1] !== 0xD8) return; + + var offset = 2; + + for (;;) { + if (data.length - offset < 2) return; + // not a JPEG marker + if (data[offset++] !== 0xFF) return; + + var code = data[offset++]; + var length; + + // skip padding bytes + while (code === 0xFF) code = data[offset++]; + + // standalone markers, according to JPEG 1992, + // http://www.w3.org/Graphics/JPEG/itu-t81.pdf, see Table B.1 + if ((0xD0 <= code && code <= 0xD9) || code === 0x01) { + length = 0; + } else if (0xC0 <= code && code <= 0xFE) { + // the rest of the unreserved markers + if (data.length - offset < 2) return; + + length = readUInt16BE(data, offset) - 2; + offset += 2; + } else { + // unknown markers + return; + } + + if (code === 0xD9 /* EOI */ || code === 0xDA /* SOS */) { + // end of the datastream + return; + } + + var orientation; + + // try to get orientation from Exif segment + if (code === 0xE1 && length >= 10 && sliceEq(data, offset, SIG_EXIF)) { + orientation = exif.get_orientation(data.slice(offset + 6, offset + length)); + } + + if (length >= 5 && + (0xC0 <= code && code <= 0xCF) && + code !== 0xC4 && code !== 0xC8 && code !== 0xCC) { + + if (data.length - offset < length) return; + + var result = { + width: readUInt16BE(data, offset + 3), + height: readUInt16BE(data, offset + 1), + type: 'jpg', + mime: 'image/jpeg', + wUnits: 'px', + hUnits: 'px' + }; + + if (orientation > 0) { + result.orientation = orientation; + } + + return result; + } + + offset += length; + } +}; + +},{"../common":81,"../exif_utils":82}],89:[function(_dereq_,module,exports){ +'use strict'; + +/* eslint-disable consistent-return */ + +var str2arr = _dereq_('../common').str2arr; +var sliceEq = _dereq_('../common').sliceEq; +var readUInt32BE = _dereq_('../common').readUInt32BE; + + +var SIG_PNG = str2arr('\x89PNG\r\n\x1a\n'); +var SIG_IHDR = str2arr('IHDR'); + + +module.exports = function (data) { + if (data.length < 24) return; + + // check PNG signature + if (!sliceEq(data, 0, SIG_PNG)) return; + + // check that first chunk is IHDR + if (!sliceEq(data, 12, SIG_IHDR)) return; + + return { + width: readUInt32BE(data, 16), + height: readUInt32BE(data, 20), + type: 'png', + mime: 'image/png', + wUnits: 'px', + hUnits: 'px' + }; +}; + +},{"../common":81}],90:[function(_dereq_,module,exports){ +'use strict'; + +/* eslint-disable consistent-return */ + +var str2arr = _dereq_('../common').str2arr; +var sliceEq = _dereq_('../common').sliceEq; +var readUInt32BE = _dereq_('../common').readUInt32BE; + + +var SIG_8BPS = str2arr('8BPS\x00\x01'); + + +module.exports = function (data) { + if (data.length < 6 + 16) return; + + // signature + version + if (!sliceEq(data, 0, SIG_8BPS)) return; + + return { + width: readUInt32BE(data, 6 + 12), + height: readUInt32BE(data, 6 + 8), + type: 'psd', + mime: 'image/vnd.adobe.photoshop', + wUnits: 'px', + hUnits: 'px' + }; +}; + +},{"../common":81}],91:[function(_dereq_,module,exports){ +'use strict'; + +/* eslint-disable consistent-return */ + +function isWhiteSpace(chr) { + return chr === 0x20 || chr === 0x09 || chr === 0x0D || chr === 0x0A; +} + +// Filter NaN, Infinity, < 0 +function isFinitePositive(val) { + return typeof val === 'number' && isFinite(val) && val > 0; +} + +function canBeSvg(buf) { + var i = 0, max = buf.length; + + while (i < max && isWhiteSpace(buf[i])) i++; + + if (i === max) return false; + return buf[i] === 0x3c; /* < */ +} + + +var SVG_HEADER_RE = /]+>/; +var SVG_WIDTH_RE = /[^-]\bwidth="([^%]+?)"|[^-]\bwidth='([^%]+?)'/; +var SVG_HEIGHT_RE = /\bheight="([^%]+?)"|\bheight='([^%]+?)'/; +var SVG_VIEWBOX_RE = /\bview[bB]ox="(.+?)"|\bview[bB]ox='(.+?)'/; +var SVG_UNITS_RE = /in$|mm$|cm$|pt$|pc$|px$|em$|ex$/; + +function svgAttrs(str) { + var width = str.match(SVG_WIDTH_RE); + var height = str.match(SVG_HEIGHT_RE); + var viewbox = str.match(SVG_VIEWBOX_RE); + + return { + width: width && (width[1] || width[2]), + height: height && (height[1] || height[2]), + viewbox: viewbox && (viewbox[1] || viewbox[2]) + }; +} + + +function units(str) { + if (!SVG_UNITS_RE.test(str)) return 'px'; + + return str.match(SVG_UNITS_RE)[0]; +} + + +module.exports = function (data) { + if (!canBeSvg(data)) return; + + var str = ''; + + for (var i = 0; i < data.length; i++) { + // 1. We can't rely on buffer features + // 2. Don't care about UTF16 because ascii is enougth for our goals + str += String.fromCharCode(data[i]); + } + + if (!SVG_HEADER_RE.test(str)) return; + + var attrs = svgAttrs(str.match(SVG_HEADER_RE)[0]); + var width = parseFloat(attrs.width); + var height = parseFloat(attrs.height); + + // Extract from direct values + + if (attrs.width && attrs.height) { + if (!isFinitePositive(width) || !isFinitePositive(height)) return; + + return { + width: width, + height: height, + type: 'svg', + mime: 'image/svg+xml', + wUnits: units(attrs.width), + hUnits: units(attrs.height) + }; + } + + // Extract from viewbox + + var parts = (attrs.viewbox || '').split(' '); + var viewbox = { + width: parts[2], + height: parts[3] + }; + var vbWidth = parseFloat(viewbox.width); + var vbHeight = parseFloat(viewbox.height); + + if (!isFinitePositive(vbWidth) || !isFinitePositive(vbHeight)) return; + if (units(viewbox.width) !== units(viewbox.height)) return; + + var ratio = vbWidth / vbHeight; + + if (attrs.width) { + if (!isFinitePositive(width)) return; + + return { + width: width, + height: width / ratio, + type: 'svg', + mime: 'image/svg+xml', + wUnits: units(attrs.width), + hUnits: units(attrs.width) + }; + } + + if (attrs.height) { + if (!isFinitePositive(height)) return; + + return { + width: height * ratio, + height: height, + type: 'svg', + mime: 'image/svg+xml', + wUnits: units(attrs.height), + hUnits: units(attrs.height) + }; + } + + return { + width: vbWidth, + height: vbHeight, + type: 'svg', + mime: 'image/svg+xml', + wUnits: units(viewbox.width), + hUnits: units(viewbox.height) + }; +}; + +},{}],92:[function(_dereq_,module,exports){ +'use strict'; + +/* eslint-disable consistent-return */ + +var str2arr = _dereq_('../common').str2arr; +var sliceEq = _dereq_('../common').sliceEq; +var readUInt16LE = _dereq_('../common').readUInt16LE; +var readUInt16BE = _dereq_('../common').readUInt16BE; +var readUInt32LE = _dereq_('../common').readUInt32LE; +var readUInt32BE = _dereq_('../common').readUInt32BE; + + +var SIG_1 = str2arr('II\x2A\0'); +var SIG_2 = str2arr('MM\0\x2A'); + + +function readUInt16(buffer, offset, is_big_endian) { + return is_big_endian ? readUInt16BE(buffer, offset) : readUInt16LE(buffer, offset); +} + +function readUInt32(buffer, offset, is_big_endian) { + return is_big_endian ? readUInt32BE(buffer, offset) : readUInt32LE(buffer, offset); +} + +function readIFDValue(data, data_offset, is_big_endian) { + var type = readUInt16(data, data_offset + 2, is_big_endian); + var values = readUInt32(data, data_offset + 4, is_big_endian); + + if (values !== 1 || (type !== 3 && type !== 4)) return null; + + if (type === 3) { + return readUInt16(data, data_offset + 8, is_big_endian); + } + + return readUInt32(data, data_offset + 8, is_big_endian); +} + +module.exports = function (data) { + if (data.length < 8) return; + + // check TIFF signature + if (!sliceEq(data, 0, SIG_1) && !sliceEq(data, 0, SIG_2)) return; + + var is_big_endian = (data[0] === 77 /* 'MM' */); + var count = readUInt32(data, 4, is_big_endian) - 8; + + if (count < 0) return; + + // skip until IFD + var offset = count + 8; + + if (data.length - offset < 2) return; + + // read number of IFD entries + var ifd_size = readUInt16(data, offset + 0, is_big_endian) * 12; + + if (ifd_size <= 0) return; + + offset += 2; + + // read all IFD entries + if (data.length - offset < ifd_size) return; + + var i, width, height, tag; + + for (i = 0; i < ifd_size; i += 12) { + tag = readUInt16(data, offset + i, is_big_endian); + + if (tag === 256) { + width = readIFDValue(data, offset + i, is_big_endian); + } else if (tag === 257) { + height = readIFDValue(data, offset + i, is_big_endian); + } + } + + if (width && height) { + return { + width: width, + height: height, + type: 'tiff', + mime: 'image/tiff', + wUnits: 'px', + hUnits: 'px' + }; + } +}; + +},{"../common":81}],93:[function(_dereq_,module,exports){ +'use strict'; + +/* eslint-disable no-bitwise */ +/* eslint-disable consistent-return */ + +var str2arr = _dereq_('../common').str2arr; +var sliceEq = _dereq_('../common').sliceEq; +var readUInt16LE = _dereq_('../common').readUInt16LE; +var readUInt32LE = _dereq_('../common').readUInt32LE; +var exif = _dereq_('../exif_utils'); + + +var SIG_RIFF = str2arr('RIFF'); +var SIG_WEBP = str2arr('WEBP'); + + +function parseVP8(data, offset) { + if (data[offset + 3] !== 0x9D || data[offset + 4] !== 0x01 || data[offset + 5] !== 0x2A) { + // bad code block signature + return; + } + + return { + width: readUInt16LE(data, offset + 6) & 0x3FFF, + height: readUInt16LE(data, offset + 8) & 0x3FFF, + type: 'webp', + mime: 'image/webp', + wUnits: 'px', + hUnits: 'px' + }; +} + + +function parseVP8L(data, offset) { + if (data[offset] !== 0x2F) return; + + var bits = readUInt32LE(data, offset + 1); + + return { + width: (bits & 0x3FFF) + 1, + height: ((bits >> 14) & 0x3FFF) + 1, + type: 'webp', + mime: 'image/webp', + wUnits: 'px', + hUnits: 'px' + }; +} + + +function parseVP8X(data, offset) { + return { + // TODO: replace with `data.readUIntLE(8, 3) + 1` + // when 0.10 support is dropped + width: ((data[offset + 6] << 16) | (data[offset + 5] << 8) | data[offset + 4]) + 1, + height: ((data[offset + 9] << offset) | (data[offset + 8] << 8) | data[offset + 7]) + 1, + type: 'webp', + mime: 'image/webp', + wUnits: 'px', + hUnits: 'px' + }; +} + + +module.exports = function (data) { + if (data.length < 16) return; + + // check /^RIFF....WEBPVP8([ LX])$/ signature + if (!sliceEq(data, 0, SIG_RIFF) && !sliceEq(data, 8, SIG_WEBP)) return; + + var offset = 12; + var result = null; + var exif_orientation = 0; + var fileLength = readUInt32LE(data, 4) + 8; + + if (fileLength > data.length) return; + + while (offset + 8 < fileLength) { + if (data[offset] === 0) { + // after each chunk of odd size there should be 0 byte of padding, skip those + offset++; + continue; + } + + var header = String.fromCharCode.apply(null, data.slice(offset, offset + 4)); + var length = readUInt32LE(data, offset + 4); + + if (header === 'VP8 ' && length >= 10) { + result = result || parseVP8(data, offset + 8); + } else if (header === 'VP8L' && length >= 9) { + result = result || parseVP8L(data, offset + 8); + } else if (header === 'VP8X' && length >= 10) { + result = result || parseVP8X(data, offset + 8); + } else if (header === 'EXIF') { + exif_orientation = exif.get_orientation(data.slice(offset + 8, offset + 8 + length)); + + // exif is the last chunk we care about, stop after it + offset = Infinity; + } + + offset += 8 + length; + } + + if (!result) return; + + if (exif_orientation > 0) { + result.orientation = exif_orientation; + } + + return result; +}; + +},{"../common":81,"../exif_utils":82}],94:[function(_dereq_,module,exports){ +'use strict'; + + +module.exports = { + avif: _dereq_('./parse_sync/avif'), + bmp: _dereq_('./parse_sync/bmp'), + gif: _dereq_('./parse_sync/gif'), + ico: _dereq_('./parse_sync/ico'), + jpeg: _dereq_('./parse_sync/jpeg'), + png: _dereq_('./parse_sync/png'), + psd: _dereq_('./parse_sync/psd'), + svg: _dereq_('./parse_sync/svg'), + tiff: _dereq_('./parse_sync/tiff'), + webp: _dereq_('./parse_sync/webp') +}; + +},{"./parse_sync/avif":84,"./parse_sync/bmp":85,"./parse_sync/gif":86,"./parse_sync/ico":87,"./parse_sync/jpeg":88,"./parse_sync/png":89,"./parse_sync/psd":90,"./parse_sync/svg":91,"./parse_sync/tiff":92,"./parse_sync/webp":93}],95:[function(_dereq_,module,exports){ +'use strict'; + + +var parsers = _dereq_('./lib/parsers_sync'); + + +function probeBuffer(buffer) { + var parser_names = Object.keys(parsers); + + for (var i = 0; i < parser_names.length; i++) { + var result = parsers[parser_names[i]](buffer); + + if (result) return result; + } + + return null; +} + + +/////////////////////////////////////////////////////////////////////// +// Exports +// + +module.exports = function get_image_size(src) { + return probeBuffer(src); +}; + +module.exports.parsers = parsers; + +},{"./lib/parsers_sync":94}],96:[function(_dereq_,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -19344,7 +19605,4538 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],88:[function(_dereq_,module,exports){ +},{}],97:[function(_dereq_,module,exports){ +/* eslint-disable node/no-deprecated-api */ +var buffer = _dereq_('buffer') +var Buffer = buffer.Buffer + +// alternative to using Object.keys for old browsers +function copyProps (src, dst) { + for (var key in src) { + dst[key] = src[key] + } +} +if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { + module.exports = buffer +} else { + // Copy properties from require('buffer') + copyProps(buffer, exports) + exports.Buffer = SafeBuffer +} + +function SafeBuffer (arg, encodingOrOffset, length) { + return Buffer(arg, encodingOrOffset, length) +} + +SafeBuffer.prototype = Object.create(Buffer.prototype) + +// Copy static methods from Buffer +copyProps(Buffer, SafeBuffer) + +SafeBuffer.from = function (arg, encodingOrOffset, length) { + if (typeof arg === 'number') { + throw new TypeError('Argument must not be a number') + } + return Buffer(arg, encodingOrOffset, length) +} + +SafeBuffer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + var buf = Buffer(size) + if (fill !== undefined) { + if (typeof encoding === 'string') { + buf.fill(fill, encoding) + } else { + buf.fill(fill) + } + } else { + buf.fill(0) + } + return buf +} + +SafeBuffer.allocUnsafe = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return Buffer(size) +} + +SafeBuffer.allocUnsafeSlow = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return buffer.SlowBuffer(size) +} + +},{"buffer":28}],98:[function(_dereq_,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +module.exports = Stream; + +var EE = _dereq_('events').EventEmitter; +var inherits = _dereq_('inherits'); + +inherits(Stream, EE); +Stream.Readable = _dereq_('readable-stream/lib/_stream_readable.js'); +Stream.Writable = _dereq_('readable-stream/lib/_stream_writable.js'); +Stream.Duplex = _dereq_('readable-stream/lib/_stream_duplex.js'); +Stream.Transform = _dereq_('readable-stream/lib/_stream_transform.js'); +Stream.PassThrough = _dereq_('readable-stream/lib/_stream_passthrough.js'); +Stream.finished = _dereq_('readable-stream/lib/internal/streams/end-of-stream.js') +Stream.pipeline = _dereq_('readable-stream/lib/internal/streams/pipeline.js') + +// Backwards-compat with node 0.4.x +Stream.Stream = Stream; + + + +// old-style streams. Note that the pipe method (the only relevant +// part of this class) is overridden in the Readable class. + +function Stream() { + EE.call(this); +} + +Stream.prototype.pipe = function(dest, options) { + var source = this; + + function ondata(chunk) { + if (dest.writable) { + if (false === dest.write(chunk) && source.pause) { + source.pause(); + } + } + } + + source.on('data', ondata); + + function ondrain() { + if (source.readable && source.resume) { + source.resume(); + } + } + + dest.on('drain', ondrain); + + // If the 'end' option is not supplied, dest.end() will be called when + // source gets the 'end' or 'close' events. Only dest.end() once. + if (!dest._isStdio && (!options || options.end !== false)) { + source.on('end', onend); + source.on('close', onclose); + } + + var didOnEnd = false; + function onend() { + if (didOnEnd) return; + didOnEnd = true; + + dest.end(); + } + + + function onclose() { + if (didOnEnd) return; + didOnEnd = true; + + if (typeof dest.destroy === 'function') dest.destroy(); + } + + // don't leave dangling pipes when there are errors. + function onerror(er) { + cleanup(); + if (EE.listenerCount(this, 'error') === 0) { + throw er; // Unhandled stream error in pipe. + } + } + + source.on('error', onerror); + dest.on('error', onerror); + + // remove all the event listeners that were added. + function cleanup() { + source.removeListener('data', ondata); + dest.removeListener('drain', ondrain); + + source.removeListener('end', onend); + source.removeListener('close', onclose); + + source.removeListener('error', onerror); + dest.removeListener('error', onerror); + + source.removeListener('end', cleanup); + source.removeListener('close', cleanup); + + dest.removeListener('close', cleanup); + } + + source.on('end', cleanup); + source.on('close', cleanup); + + dest.on('close', cleanup); + + dest.emit('pipe', source); + + // Allow for unix-like usage: A.pipe(B).pipe(C) + return dest; +}; + +},{"events":27,"inherits":65,"readable-stream/lib/_stream_duplex.js":100,"readable-stream/lib/_stream_passthrough.js":101,"readable-stream/lib/_stream_readable.js":102,"readable-stream/lib/_stream_transform.js":103,"readable-stream/lib/_stream_writable.js":104,"readable-stream/lib/internal/streams/end-of-stream.js":108,"readable-stream/lib/internal/streams/pipeline.js":110}],99:[function(_dereq_,module,exports){ +'use strict'; + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } + +var codes = {}; + +function createErrorType(code, message, Base) { + if (!Base) { + Base = Error; + } + + function getMessage(arg1, arg2, arg3) { + if (typeof message === 'string') { + return message; + } else { + return message(arg1, arg2, arg3); + } + } + + var NodeError = + /*#__PURE__*/ + function (_Base) { + _inheritsLoose(NodeError, _Base); + + function NodeError(arg1, arg2, arg3) { + return _Base.call(this, getMessage(arg1, arg2, arg3)) || this; + } + + return NodeError; + }(Base); + + NodeError.prototype.name = Base.name; + NodeError.prototype.code = code; + codes[code] = NodeError; +} // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js + + +function oneOf(expected, thing) { + if (Array.isArray(expected)) { + var len = expected.length; + expected = expected.map(function (i) { + return String(i); + }); + + if (len > 2) { + return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1]; + } else if (len === 2) { + return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]); + } else { + return "of ".concat(thing, " ").concat(expected[0]); + } + } else { + return "of ".concat(thing, " ").concat(String(expected)); + } +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith + + +function startsWith(str, search, pos) { + return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search; +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith + + +function endsWith(str, search, this_len) { + if (this_len === undefined || this_len > str.length) { + this_len = str.length; + } + + return str.substring(this_len - search.length, this_len) === search; +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes + + +function includes(str, search, start) { + if (typeof start !== 'number') { + start = 0; + } + + if (start + search.length > str.length) { + return false; + } else { + return str.indexOf(search, start) !== -1; + } +} + +createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) { + return 'The value "' + value + '" is invalid for option "' + name + '"'; +}, TypeError); +createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) { + // determiner: 'must be' or 'must not be' + var determiner; + + if (typeof expected === 'string' && startsWith(expected, 'not ')) { + determiner = 'must not be'; + expected = expected.replace(/^not /, ''); + } else { + determiner = 'must be'; + } + + var msg; + + if (endsWith(name, ' argument')) { + // For cases like 'first argument' + msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type')); + } else { + var type = includes(name, '.') ? 'property' : 'argument'; + msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type')); + } + + msg += ". Received type ".concat(typeof actual); + return msg; +}, TypeError); +createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF'); +createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) { + return 'The ' + name + ' method is not implemented'; +}); +createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close'); +createErrorType('ERR_STREAM_DESTROYED', function (name) { + return 'Cannot call ' + name + ' after a stream was destroyed'; +}); +createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times'); +createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable'); +createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end'); +createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError); +createErrorType('ERR_UNKNOWN_ENCODING', function (arg) { + return 'Unknown encoding: ' + arg; +}, TypeError); +createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event'); +module.exports.codes = codes; + +},{}],100:[function(_dereq_,module,exports){ +(function (process){(function (){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. +// a duplex stream is just a stream that is both readable and writable. +// Since JS doesn't have multiple prototypal inheritance, this class +// prototypally inherits from Readable, and then parasitically from +// Writable. +'use strict'; +/**/ + +var objectKeys = Object.keys || function (obj) { + var keys = []; + + for (var key in obj) { + keys.push(key); + } + + return keys; +}; +/**/ + + +module.exports = Duplex; + +var Readable = _dereq_('./_stream_readable'); + +var Writable = _dereq_('./_stream_writable'); + +_dereq_('inherits')(Duplex, Readable); + +{ + // Allow the keys array to be GC'ed. + var keys = objectKeys(Writable.prototype); + + for (var v = 0; v < keys.length; v++) { + var method = keys[v]; + if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; + } +} + +function Duplex(options) { + if (!(this instanceof Duplex)) return new Duplex(options); + Readable.call(this, options); + Writable.call(this, options); + this.allowHalfOpen = true; + + if (options) { + if (options.readable === false) this.readable = false; + if (options.writable === false) this.writable = false; + + if (options.allowHalfOpen === false) { + this.allowHalfOpen = false; + this.once('end', onend); + } + } +} + +Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.highWaterMark; + } +}); +Object.defineProperty(Duplex.prototype, 'writableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState && this._writableState.getBuffer(); + } +}); +Object.defineProperty(Duplex.prototype, 'writableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.length; + } +}); // the no-half-open enforcer + +function onend() { + // If the writable side ended, then we're ok. + if (this._writableState.ended) return; // no more data can be written. + // But allow more writes to happen in this tick. + + process.nextTick(onEndNT, this); +} + +function onEndNT(self) { + self.end(); +} + +Object.defineProperty(Duplex.prototype, 'destroyed', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + if (this._readableState === undefined || this._writableState === undefined) { + return false; + } + + return this._readableState.destroyed && this._writableState.destroyed; + }, + set: function set(value) { + // we ignore the value if the stream + // has not been initialized yet + if (this._readableState === undefined || this._writableState === undefined) { + return; + } // backward compatibility, the user is explicitly + // managing destroyed + + + this._readableState.destroyed = value; + this._writableState.destroyed = value; + } +}); +}).call(this)}).call(this,_dereq_('_process')) +},{"./_stream_readable":102,"./_stream_writable":104,"_process":96,"inherits":65}],101:[function(_dereq_,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. +// a passthrough stream. +// basically just the most minimal sort of Transform stream. +// Every written chunk gets output as-is. +'use strict'; + +module.exports = PassThrough; + +var Transform = _dereq_('./_stream_transform'); + +_dereq_('inherits')(PassThrough, Transform); + +function PassThrough(options) { + if (!(this instanceof PassThrough)) return new PassThrough(options); + Transform.call(this, options); +} + +PassThrough.prototype._transform = function (chunk, encoding, cb) { + cb(null, chunk); +}; +},{"./_stream_transform":103,"inherits":65}],102:[function(_dereq_,module,exports){ +(function (process,global){(function (){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. +'use strict'; + +module.exports = Readable; +/**/ + +var Duplex; +/**/ + +Readable.ReadableState = ReadableState; +/**/ + +var EE = _dereq_('events').EventEmitter; + +var EElistenerCount = function EElistenerCount(emitter, type) { + return emitter.listeners(type).length; +}; +/**/ + +/**/ + + +var Stream = _dereq_('./internal/streams/stream'); +/**/ + + +var Buffer = _dereq_('buffer').Buffer; + +var OurUint8Array = global.Uint8Array || function () {}; + +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} + +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} +/**/ + + +var debugUtil = _dereq_('util'); + +var debug; + +if (debugUtil && debugUtil.debuglog) { + debug = debugUtil.debuglog('stream'); +} else { + debug = function debug() {}; +} +/**/ + + +var BufferList = _dereq_('./internal/streams/buffer_list'); + +var destroyImpl = _dereq_('./internal/streams/destroy'); + +var _require = _dereq_('./internal/streams/state'), + getHighWaterMark = _require.getHighWaterMark; + +var _require$codes = _dereq_('../errors').codes, + ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, + ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF, + ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, + ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; // Lazy loaded to improve the startup performance. + + +var StringDecoder; +var createReadableStreamAsyncIterator; +var from; + +_dereq_('inherits')(Readable, Stream); + +var errorOrDestroy = destroyImpl.errorOrDestroy; +var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; + +function prependListener(emitter, event, fn) { + // Sadly this is not cacheable as some libraries bundle their own + // event emitter implementation with them. + if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); // This is a hack to make sure that our error handler is attached before any + // userland ones. NEVER DO THIS. This is here only because this code needs + // to continue to work with older versions of Node.js that do not include + // the prependListener() method. The goal is to eventually remove this hack. + + if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; +} + +function ReadableState(options, stream, isDuplex) { + Duplex = Duplex || _dereq_('./_stream_duplex'); + options = options || {}; // Duplex streams are both readable and writable, but share + // the same options object. + // However, some cases require setting options to different + // values for the readable and the writable sides of the duplex stream. + // These options can be provided separately as readableXXX and writableXXX. + + if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag. Used to make read(n) ignore n and to + // make all the buffer merging and length checks go away + + this.objectMode = !!options.objectMode; + if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer + // Note: 0 is a valid value, means "don't call _read preemptively ever" + + this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex); // A linked list is used to store data chunks instead of an array because the + // linked list can remove elements from the beginning faster than + // array.shift() + + this.buffer = new BufferList(); + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = null; + this.ended = false; + this.endEmitted = false; + this.reading = false; // a flag to be able to tell if the event 'readable'/'data' is emitted + // immediately, or on a later tick. We set this to true at first, because + // any actions that shouldn't happen until "later" should generally also + // not happen before the first read call. + + this.sync = true; // whenever we return null, then we set a flag to say + // that we're awaiting a 'readable' event emission. + + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + this.resumeScheduled = false; + this.paused = true; // Should close be emitted on destroy. Defaults to true. + + this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'end' (and potentially 'finish') + + this.autoDestroy = !!options.autoDestroy; // has it been destroyed + + this.destroyed = false; // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + + this.defaultEncoding = options.defaultEncoding || 'utf8'; // the number of writers that are awaiting a drain event in .pipe()s + + this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled + + this.readingMore = false; + this.decoder = null; + this.encoding = null; + + if (options.encoding) { + if (!StringDecoder) StringDecoder = _dereq_('string_decoder/').StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } +} + +function Readable(options) { + Duplex = Duplex || _dereq_('./_stream_duplex'); + if (!(this instanceof Readable)) return new Readable(options); // Checking for a Stream.Duplex instance is faster here instead of inside + // the ReadableState constructor, at least with V8 6.5 + + var isDuplex = this instanceof Duplex; + this._readableState = new ReadableState(options, this, isDuplex); // legacy + + this.readable = true; + + if (options) { + if (typeof options.read === 'function') this._read = options.read; + if (typeof options.destroy === 'function') this._destroy = options.destroy; + } + + Stream.call(this); +} + +Object.defineProperty(Readable.prototype, 'destroyed', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + if (this._readableState === undefined) { + return false; + } + + return this._readableState.destroyed; + }, + set: function set(value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._readableState) { + return; + } // backward compatibility, the user is explicitly + // managing destroyed + + + this._readableState.destroyed = value; + } +}); +Readable.prototype.destroy = destroyImpl.destroy; +Readable.prototype._undestroy = destroyImpl.undestroy; + +Readable.prototype._destroy = function (err, cb) { + cb(err); +}; // Manually shove something into the read() buffer. +// This returns true if the highWaterMark has not been hit yet, +// similar to how Writable.write() returns true if you should +// write() some more. + + +Readable.prototype.push = function (chunk, encoding) { + var state = this._readableState; + var skipChunkCheck; + + if (!state.objectMode) { + if (typeof chunk === 'string') { + encoding = encoding || state.defaultEncoding; + + if (encoding !== state.encoding) { + chunk = Buffer.from(chunk, encoding); + encoding = ''; + } + + skipChunkCheck = true; + } + } else { + skipChunkCheck = true; + } + + return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); +}; // Unshift should *always* be something directly out of read() + + +Readable.prototype.unshift = function (chunk) { + return readableAddChunk(this, chunk, null, true, false); +}; + +function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { + debug('readableAddChunk', chunk); + var state = stream._readableState; + + if (chunk === null) { + state.reading = false; + onEofChunk(stream, state); + } else { + var er; + if (!skipChunkCheck) er = chunkInvalid(state, chunk); + + if (er) { + errorOrDestroy(stream, er); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { + chunk = _uint8ArrayToBuffer(chunk); + } + + if (addToFront) { + if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true); + } else if (state.ended) { + errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF()); + } else if (state.destroyed) { + return false; + } else { + state.reading = false; + + if (state.decoder && !encoding) { + chunk = state.decoder.write(chunk); + if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state); + } else { + addChunk(stream, state, chunk, false); + } + } + } else if (!addToFront) { + state.reading = false; + maybeReadMore(stream, state); + } + } // We can push more data if we are below the highWaterMark. + // Also, if we have no data yet, we can stand some more bytes. + // This is to work around cases where hwm=0, such as the repl. + + + return !state.ended && (state.length < state.highWaterMark || state.length === 0); +} + +function addChunk(stream, state, chunk, addToFront) { + if (state.flowing && state.length === 0 && !state.sync) { + state.awaitDrain = 0; + stream.emit('data', chunk); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); + if (state.needReadable) emitReadable(stream); + } + + maybeReadMore(stream, state); +} + +function chunkInvalid(state, chunk) { + var er; + + if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk); + } + + return er; +} + +Readable.prototype.isPaused = function () { + return this._readableState.flowing === false; +}; // backwards compatibility. + + +Readable.prototype.setEncoding = function (enc) { + if (!StringDecoder) StringDecoder = _dereq_('string_decoder/').StringDecoder; + var decoder = new StringDecoder(enc); + this._readableState.decoder = decoder; // If setEncoding(null), decoder.encoding equals utf8 + + this._readableState.encoding = this._readableState.decoder.encoding; // Iterate over current buffer to convert already stored Buffers: + + var p = this._readableState.buffer.head; + var content = ''; + + while (p !== null) { + content += decoder.write(p.data); + p = p.next; + } + + this._readableState.buffer.clear(); + + if (content !== '') this._readableState.buffer.push(content); + this._readableState.length = content.length; + return this; +}; // Don't raise the hwm > 1GB + + +var MAX_HWM = 0x40000000; + +function computeNewHighWaterMark(n) { + if (n >= MAX_HWM) { + // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE. + n = MAX_HWM; + } else { + // Get the next highest power of 2 to prevent increasing hwm excessively in + // tiny amounts + n--; + n |= n >>> 1; + n |= n >>> 2; + n |= n >>> 4; + n |= n >>> 8; + n |= n >>> 16; + n++; + } + + return n; +} // This function is designed to be inlinable, so please take care when making +// changes to the function body. + + +function howMuchToRead(n, state) { + if (n <= 0 || state.length === 0 && state.ended) return 0; + if (state.objectMode) return 1; + + if (n !== n) { + // Only flow one buffer at a time + if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; + } // If we're asking for more than the current hwm, then raise the hwm. + + + if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); + if (n <= state.length) return n; // Don't have enough + + if (!state.ended) { + state.needReadable = true; + return 0; + } + + return state.length; +} // you can override either this method, or the async _read(n) below. + + +Readable.prototype.read = function (n) { + debug('read', n); + n = parseInt(n, 10); + var state = this._readableState; + var nOrig = n; + if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we + // already have a bunch of data in the buffer, then just trigger + // the 'readable' event and move on. + + if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) { + debug('read: emitReadable', state.length, state.ended); + if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); + return null; + } + + n = howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up. + + if (n === 0 && state.ended) { + if (state.length === 0) endReadable(this); + return null; + } // All the actual chunk generation logic needs to be + // *below* the call to _read. The reason is that in certain + // synthetic stream cases, such as passthrough streams, _read + // may be a completely synchronous operation which may change + // the state of the read buffer, providing enough data when + // before there was *not* enough. + // + // So, the steps are: + // 1. Figure out what the state of things will be after we do + // a read from the buffer. + // + // 2. If that resulting state will trigger a _read, then call _read. + // Note that this may be asynchronous, or synchronous. Yes, it is + // deeply ugly to write APIs this way, but that still doesn't mean + // that the Readable class should behave improperly, as streams are + // designed to be sync/async agnostic. + // Take note if the _read call is sync or async (ie, if the read call + // has returned yet), so that we know whether or not it's safe to emit + // 'readable' etc. + // + // 3. Actually pull the requested chunks out of the buffer and return. + // if we need a readable event, then we need to do some reading. + + + var doRead = state.needReadable; + debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read some + + if (state.length === 0 || state.length - n < state.highWaterMark) { + doRead = true; + debug('length less than watermark', doRead); + } // however, if we've ended, then there's no point, and if we're already + // reading, then it's unnecessary. + + + if (state.ended || state.reading) { + doRead = false; + debug('reading or ended', doRead); + } else if (doRead) { + debug('do read'); + state.reading = true; + state.sync = true; // if the length is currently zero, then we *need* a readable event. + + if (state.length === 0) state.needReadable = true; // call internal read method + + this._read(state.highWaterMark); + + state.sync = false; // If _read pushed data synchronously, then `reading` will be false, + // and we need to re-evaluate how much data we can return to the user. + + if (!state.reading) n = howMuchToRead(nOrig, state); + } + + var ret; + if (n > 0) ret = fromList(n, state);else ret = null; + + if (ret === null) { + state.needReadable = state.length <= state.highWaterMark; + n = 0; + } else { + state.length -= n; + state.awaitDrain = 0; + } + + if (state.length === 0) { + // If we have nothing in the buffer, then we want to know + // as soon as we *do* get something into the buffer. + if (!state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick. + + if (nOrig !== n && state.ended) endReadable(this); + } + + if (ret !== null) this.emit('data', ret); + return ret; +}; + +function onEofChunk(stream, state) { + debug('onEofChunk'); + if (state.ended) return; + + if (state.decoder) { + var chunk = state.decoder.end(); + + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; + } + } + + state.ended = true; + + if (state.sync) { + // if we are sync, wait until next tick to emit the data. + // Otherwise we risk emitting data in the flow() + // the readable code triggers during a read() call + emitReadable(stream); + } else { + // emit 'readable' now to make sure it gets picked up. + state.needReadable = false; + + if (!state.emittedReadable) { + state.emittedReadable = true; + emitReadable_(stream); + } + } +} // Don't emit readable right away in sync mode, because this can trigger +// another read() call => stack overflow. This way, it might trigger +// a nextTick recursion warning, but that's not so bad. + + +function emitReadable(stream) { + var state = stream._readableState; + debug('emitReadable', state.needReadable, state.emittedReadable); + state.needReadable = false; + + if (!state.emittedReadable) { + debug('emitReadable', state.flowing); + state.emittedReadable = true; + process.nextTick(emitReadable_, stream); + } +} + +function emitReadable_(stream) { + var state = stream._readableState; + debug('emitReadable_', state.destroyed, state.length, state.ended); + + if (!state.destroyed && (state.length || state.ended)) { + stream.emit('readable'); + state.emittedReadable = false; + } // The stream needs another readable event if + // 1. It is not flowing, as the flow mechanism will take + // care of it. + // 2. It is not ended. + // 3. It is below the highWaterMark, so we can schedule + // another readable later. + + + state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark; + flow(stream); +} // at this point, the user has presumably seen the 'readable' event, +// and called read() to consume some data. that may have triggered +// in turn another _read(n) call, in which case reading = true if +// it's in progress. +// However, if we're not ended, or reading, and the length < hwm, +// then go ahead and try to read some more preemptively. + + +function maybeReadMore(stream, state) { + if (!state.readingMore) { + state.readingMore = true; + process.nextTick(maybeReadMore_, stream, state); + } +} + +function maybeReadMore_(stream, state) { + // Attempt to read more data if we should. + // + // The conditions for reading more data are (one of): + // - Not enough data buffered (state.length < state.highWaterMark). The loop + // is responsible for filling the buffer with enough data if such data + // is available. If highWaterMark is 0 and we are not in the flowing mode + // we should _not_ attempt to buffer any extra data. We'll get more data + // when the stream consumer calls read() instead. + // - No data in the buffer, and the stream is in flowing mode. In this mode + // the loop below is responsible for ensuring read() is called. Failing to + // call read here would abort the flow and there's no other mechanism for + // continuing the flow if the stream consumer has just subscribed to the + // 'data' event. + // + // In addition to the above conditions to keep reading data, the following + // conditions prevent the data from being read: + // - The stream has ended (state.ended). + // - There is already a pending 'read' operation (state.reading). This is a + // case where the the stream has called the implementation defined _read() + // method, but they are processing the call asynchronously and have _not_ + // called push() with new data. In this case we skip performing more + // read()s. The execution ends in this method again after the _read() ends + // up calling push() with more data. + while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) { + var len = state.length; + debug('maybeReadMore read 0'); + stream.read(0); + if (len === state.length) // didn't get any data, stop spinning. + break; + } + + state.readingMore = false; +} // abstract method. to be overridden in specific implementation classes. +// call cb(er, data) where data is <= n in length. +// for virtual (non-string, non-buffer) streams, "length" is somewhat +// arbitrary, and perhaps not very meaningful. + + +Readable.prototype._read = function (n) { + errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()')); +}; + +Readable.prototype.pipe = function (dest, pipeOpts) { + var src = this; + var state = this._readableState; + + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + + case 1: + state.pipes = [state.pipes, dest]; + break; + + default: + state.pipes.push(dest); + break; + } + + state.pipesCount += 1; + debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); + var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; + var endFn = doEnd ? onend : unpipe; + if (state.endEmitted) process.nextTick(endFn);else src.once('end', endFn); + dest.on('unpipe', onunpipe); + + function onunpipe(readable, unpipeInfo) { + debug('onunpipe'); + + if (readable === src) { + if (unpipeInfo && unpipeInfo.hasUnpiped === false) { + unpipeInfo.hasUnpiped = true; + cleanup(); + } + } + } + + function onend() { + debug('onend'); + dest.end(); + } // when the dest drains, it reduces the awaitDrain counter + // on the source. This would be more elegant with a .once() + // handler in flow(), but adding and removing repeatedly is + // too slow. + + + var ondrain = pipeOnDrain(src); + dest.on('drain', ondrain); + var cleanedUp = false; + + function cleanup() { + debug('cleanup'); // cleanup event handlers once the pipe is broken + + dest.removeListener('close', onclose); + dest.removeListener('finish', onfinish); + dest.removeListener('drain', ondrain); + dest.removeListener('error', onerror); + dest.removeListener('unpipe', onunpipe); + src.removeListener('end', onend); + src.removeListener('end', unpipe); + src.removeListener('data', ondata); + cleanedUp = true; // if the reader is waiting for a drain event from this + // specific writer, then it would cause it to never start + // flowing again. + // So, if this is awaiting a drain, then we just call it now. + // If we don't know, then assume that we are waiting for one. + + if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); + } + + src.on('data', ondata); + + function ondata(chunk) { + debug('ondata'); + var ret = dest.write(chunk); + debug('dest.write', ret); + + if (ret === false) { + // If the user unpiped during `dest.write()`, it is possible + // to get stuck in a permanently paused state if that write + // also returned false. + // => Check whether `dest` is still a piping destination. + if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { + debug('false write response, pause', state.awaitDrain); + state.awaitDrain++; + } + + src.pause(); + } + } // if the dest has an error, then stop piping into it. + // however, don't suppress the throwing behavior for this. + + + function onerror(er) { + debug('onerror', er); + unpipe(); + dest.removeListener('error', onerror); + if (EElistenerCount(dest, 'error') === 0) errorOrDestroy(dest, er); + } // Make sure our error handler is attached before userland ones. + + + prependListener(dest, 'error', onerror); // Both close and finish should trigger unpipe, but only once. + + function onclose() { + dest.removeListener('finish', onfinish); + unpipe(); + } + + dest.once('close', onclose); + + function onfinish() { + debug('onfinish'); + dest.removeListener('close', onclose); + unpipe(); + } + + dest.once('finish', onfinish); + + function unpipe() { + debug('unpipe'); + src.unpipe(dest); + } // tell the dest that it's being piped to + + + dest.emit('pipe', src); // start the flow if it hasn't been started already. + + if (!state.flowing) { + debug('pipe resume'); + src.resume(); + } + + return dest; +}; + +function pipeOnDrain(src) { + return function pipeOnDrainFunctionResult() { + var state = src._readableState; + debug('pipeOnDrain', state.awaitDrain); + if (state.awaitDrain) state.awaitDrain--; + + if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { + state.flowing = true; + flow(src); + } + }; +} + +Readable.prototype.unpipe = function (dest) { + var state = this._readableState; + var unpipeInfo = { + hasUnpiped: false + }; // if we're not piping anywhere, then do nothing. + + if (state.pipesCount === 0) return this; // just one destination. most common case. + + if (state.pipesCount === 1) { + // passed in one, but it's not the right one. + if (dest && dest !== state.pipes) return this; + if (!dest) dest = state.pipes; // got a match. + + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + if (dest) dest.emit('unpipe', this, unpipeInfo); + return this; + } // slow case. multiple pipe destinations. + + + if (!dest) { + // remove all. + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + + for (var i = 0; i < len; i++) { + dests[i].emit('unpipe', this, { + hasUnpiped: false + }); + } + + return this; + } // try to find the right one. + + + var index = indexOf(state.pipes, dest); + if (index === -1) return this; + state.pipes.splice(index, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) state.pipes = state.pipes[0]; + dest.emit('unpipe', this, unpipeInfo); + return this; +}; // set up data events if they are asked for +// Ensure readable listeners eventually get something + + +Readable.prototype.on = function (ev, fn) { + var res = Stream.prototype.on.call(this, ev, fn); + var state = this._readableState; + + if (ev === 'data') { + // update readableListening so that resume() may be a no-op + // a few lines down. This is needed to support once('readable'). + state.readableListening = this.listenerCount('readable') > 0; // Try start flowing on next tick if stream isn't explicitly paused + + if (state.flowing !== false) this.resume(); + } else if (ev === 'readable') { + if (!state.endEmitted && !state.readableListening) { + state.readableListening = state.needReadable = true; + state.flowing = false; + state.emittedReadable = false; + debug('on readable', state.length, state.reading); + + if (state.length) { + emitReadable(this); + } else if (!state.reading) { + process.nextTick(nReadingNextTick, this); + } + } + } + + return res; +}; + +Readable.prototype.addListener = Readable.prototype.on; + +Readable.prototype.removeListener = function (ev, fn) { + var res = Stream.prototype.removeListener.call(this, ev, fn); + + if (ev === 'readable') { + // We need to check if there is someone still listening to + // readable and reset the state. However this needs to happen + // after readable has been emitted but before I/O (nextTick) to + // support once('readable', fn) cycles. This means that calling + // resume within the same tick will have no + // effect. + process.nextTick(updateReadableListening, this); + } + + return res; +}; + +Readable.prototype.removeAllListeners = function (ev) { + var res = Stream.prototype.removeAllListeners.apply(this, arguments); + + if (ev === 'readable' || ev === undefined) { + // We need to check if there is someone still listening to + // readable and reset the state. However this needs to happen + // after readable has been emitted but before I/O (nextTick) to + // support once('readable', fn) cycles. This means that calling + // resume within the same tick will have no + // effect. + process.nextTick(updateReadableListening, this); + } + + return res; +}; + +function updateReadableListening(self) { + var state = self._readableState; + state.readableListening = self.listenerCount('readable') > 0; + + if (state.resumeScheduled && !state.paused) { + // flowing needs to be set to true now, otherwise + // the upcoming resume will not flow. + state.flowing = true; // crude way to check if we should resume + } else if (self.listenerCount('data') > 0) { + self.resume(); + } +} + +function nReadingNextTick(self) { + debug('readable nexttick read 0'); + self.read(0); +} // pause() and resume() are remnants of the legacy readable stream API +// If the user uses them, then switch into old mode. + + +Readable.prototype.resume = function () { + var state = this._readableState; + + if (!state.flowing) { + debug('resume'); // we flow only if there is no one listening + // for readable, but we still have to call + // resume() + + state.flowing = !state.readableListening; + resume(this, state); + } + + state.paused = false; + return this; +}; + +function resume(stream, state) { + if (!state.resumeScheduled) { + state.resumeScheduled = true; + process.nextTick(resume_, stream, state); + } +} + +function resume_(stream, state) { + debug('resume', state.reading); + + if (!state.reading) { + stream.read(0); + } + + state.resumeScheduled = false; + stream.emit('resume'); + flow(stream); + if (state.flowing && !state.reading) stream.read(0); +} + +Readable.prototype.pause = function () { + debug('call pause flowing=%j', this._readableState.flowing); + + if (this._readableState.flowing !== false) { + debug('pause'); + this._readableState.flowing = false; + this.emit('pause'); + } + + this._readableState.paused = true; + return this; +}; + +function flow(stream) { + var state = stream._readableState; + debug('flow', state.flowing); + + while (state.flowing && stream.read() !== null) { + ; + } +} // wrap an old-style stream as the async data source. +// This is *not* part of the readable stream interface. +// It is an ugly unfortunate mess of history. + + +Readable.prototype.wrap = function (stream) { + var _this = this; + + var state = this._readableState; + var paused = false; + stream.on('end', function () { + debug('wrapped end'); + + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) _this.push(chunk); + } + + _this.push(null); + }); + stream.on('data', function (chunk) { + debug('wrapped data'); + if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode + + if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; + + var ret = _this.push(chunk); + + if (!ret) { + paused = true; + stream.pause(); + } + }); // proxy all the other methods. + // important when wrapping filters and duplexes. + + for (var i in stream) { + if (this[i] === undefined && typeof stream[i] === 'function') { + this[i] = function methodWrap(method) { + return function methodWrapReturnFunction() { + return stream[method].apply(stream, arguments); + }; + }(i); + } + } // proxy certain important events. + + + for (var n = 0; n < kProxyEvents.length; n++) { + stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); + } // when we try to consume some more bytes, simply unpause the + // underlying stream. + + + this._read = function (n) { + debug('wrapped _read', n); + + if (paused) { + paused = false; + stream.resume(); + } + }; + + return this; +}; + +if (typeof Symbol === 'function') { + Readable.prototype[Symbol.asyncIterator] = function () { + if (createReadableStreamAsyncIterator === undefined) { + createReadableStreamAsyncIterator = _dereq_('./internal/streams/async_iterator'); + } + + return createReadableStreamAsyncIterator(this); + }; +} + +Object.defineProperty(Readable.prototype, 'readableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState.highWaterMark; + } +}); +Object.defineProperty(Readable.prototype, 'readableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState && this._readableState.buffer; + } +}); +Object.defineProperty(Readable.prototype, 'readableFlowing', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState.flowing; + }, + set: function set(state) { + if (this._readableState) { + this._readableState.flowing = state; + } + } +}); // exposed for testing purposes only. + +Readable._fromList = fromList; +Object.defineProperty(Readable.prototype, 'readableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState.length; + } +}); // Pluck off n bytes from an array of buffers. +// Length is the combined lengths of all the buffers in the list. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. + +function fromList(n, state) { + // nothing buffered + if (state.length === 0) return null; + var ret; + if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { + // read it all, truncate the list + if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.first();else ret = state.buffer.concat(state.length); + state.buffer.clear(); + } else { + // read part of list + ret = state.buffer.consume(n, state.decoder); + } + return ret; +} + +function endReadable(stream) { + var state = stream._readableState; + debug('endReadable', state.endEmitted); + + if (!state.endEmitted) { + state.ended = true; + process.nextTick(endReadableNT, state, stream); + } +} + +function endReadableNT(state, stream) { + debug('endReadableNT', state.endEmitted, state.length); // Check that we didn't get one last unshift. + + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream.readable = false; + stream.emit('end'); + + if (state.autoDestroy) { + // In case of duplex streams we need a way to detect + // if the writable side is ready for autoDestroy as well + var wState = stream._writableState; + + if (!wState || wState.autoDestroy && wState.finished) { + stream.destroy(); + } + } + } +} + +if (typeof Symbol === 'function') { + Readable.from = function (iterable, opts) { + if (from === undefined) { + from = _dereq_('./internal/streams/from'); + } + + return from(Readable, iterable, opts); + }; +} + +function indexOf(xs, x) { + for (var i = 0, l = xs.length; i < l; i++) { + if (xs[i] === x) return i; + } + + return -1; +} +}).call(this)}).call(this,_dereq_('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"../errors":99,"./_stream_duplex":100,"./internal/streams/async_iterator":105,"./internal/streams/buffer_list":106,"./internal/streams/destroy":107,"./internal/streams/from":109,"./internal/streams/state":111,"./internal/streams/stream":112,"_process":96,"buffer":28,"events":27,"inherits":65,"string_decoder/":113,"util":26}],103:[function(_dereq_,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. +// a transform stream is a readable/writable stream where you do +// something with the data. Sometimes it's called a "filter", +// but that's not a great name for it, since that implies a thing where +// some bits pass through, and others are simply ignored. (That would +// be a valid example of a transform, of course.) +// +// While the output is causally related to the input, it's not a +// necessarily symmetric or synchronous transformation. For example, +// a zlib stream might take multiple plain-text writes(), and then +// emit a single compressed chunk some time in the future. +// +// Here's how this works: +// +// The Transform stream has all the aspects of the readable and writable +// stream classes. When you write(chunk), that calls _write(chunk,cb) +// internally, and returns false if there's a lot of pending writes +// buffered up. When you call read(), that calls _read(n) until +// there's enough pending readable data buffered up. +// +// In a transform stream, the written data is placed in a buffer. When +// _read(n) is called, it transforms the queued up data, calling the +// buffered _write cb's as it consumes chunks. If consuming a single +// written chunk would result in multiple output chunks, then the first +// outputted bit calls the readcb, and subsequent chunks just go into +// the read buffer, and will cause it to emit 'readable' if necessary. +// +// This way, back-pressure is actually determined by the reading side, +// since _read has to be called to start processing a new chunk. However, +// a pathological inflate type of transform can cause excessive buffering +// here. For example, imagine a stream where every byte of input is +// interpreted as an integer from 0-255, and then results in that many +// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in +// 1kb of data being output. In this case, you could write a very small +// amount of input, and end up with a very large amount of output. In +// such a pathological inflating mechanism, there'd be no way to tell +// the system to stop doing the transform. A single 4MB write could +// cause the system to run out of memory. +// +// However, even in such a pathological case, only a single written chunk +// would be consumed, and then the rest would wait (un-transformed) until +// the results of the previous transformed chunk were consumed. +'use strict'; + +module.exports = Transform; + +var _require$codes = _dereq_('../errors').codes, + ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, + ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, + ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING, + ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0; + +var Duplex = _dereq_('./_stream_duplex'); + +_dereq_('inherits')(Transform, Duplex); + +function afterTransform(er, data) { + var ts = this._transformState; + ts.transforming = false; + var cb = ts.writecb; + + if (cb === null) { + return this.emit('error', new ERR_MULTIPLE_CALLBACK()); + } + + ts.writechunk = null; + ts.writecb = null; + if (data != null) // single equals check for both `null` and `undefined` + this.push(data); + cb(er); + var rs = this._readableState; + rs.reading = false; + + if (rs.needReadable || rs.length < rs.highWaterMark) { + this._read(rs.highWaterMark); + } +} + +function Transform(options) { + if (!(this instanceof Transform)) return new Transform(options); + Duplex.call(this, options); + this._transformState = { + afterTransform: afterTransform.bind(this), + needTransform: false, + transforming: false, + writecb: null, + writechunk: null, + writeencoding: null + }; // start out asking for a readable event once data is transformed. + + this._readableState.needReadable = true; // we have implemented the _read method, and done the other things + // that Readable wants before the first _read call, so unset the + // sync guard flag. + + this._readableState.sync = false; + + if (options) { + if (typeof options.transform === 'function') this._transform = options.transform; + if (typeof options.flush === 'function') this._flush = options.flush; + } // When the writable side finishes, then flush out anything remaining. + + + this.on('prefinish', prefinish); +} + +function prefinish() { + var _this = this; + + if (typeof this._flush === 'function' && !this._readableState.destroyed) { + this._flush(function (er, data) { + done(_this, er, data); + }); + } else { + done(this, null, null); + } +} + +Transform.prototype.push = function (chunk, encoding) { + this._transformState.needTransform = false; + return Duplex.prototype.push.call(this, chunk, encoding); +}; // This is the part where you do stuff! +// override this function in implementation classes. +// 'chunk' is an input chunk. +// +// Call `push(newChunk)` to pass along transformed output +// to the readable side. You may call 'push' zero or more times. +// +// Call `cb(err)` when you are done with this chunk. If you pass +// an error, then that'll put the hurt on the whole operation. If you +// never call cb(), then you'll never get another chunk. + + +Transform.prototype._transform = function (chunk, encoding, cb) { + cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()')); +}; + +Transform.prototype._write = function (chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); + } +}; // Doesn't matter what the args are here. +// _transform does all the work. +// That we got here means that the readable side wants more data. + + +Transform.prototype._read = function (n) { + var ts = this._transformState; + + if (ts.writechunk !== null && !ts.transforming) { + ts.transforming = true; + + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + // mark that we need a transform, so that any data that comes in + // will get processed, now that we've asked for it. + ts.needTransform = true; + } +}; + +Transform.prototype._destroy = function (err, cb) { + Duplex.prototype._destroy.call(this, err, function (err2) { + cb(err2); + }); +}; + +function done(stream, er, data) { + if (er) return stream.emit('error', er); + if (data != null) // single equals check for both `null` and `undefined` + stream.push(data); // TODO(BridgeAR): Write a test for these two error cases + // if there's nothing in the write buffer, then that means + // that nothing more will ever be provided + + if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0(); + if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING(); + return stream.push(null); +} +},{"../errors":99,"./_stream_duplex":100,"inherits":65}],104:[function(_dereq_,module,exports){ +(function (process,global){(function (){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. +// A bit simpler than readable streams. +// Implement an async ._write(chunk, encoding, cb), and it'll handle all +// the drain event emission and buffering. +'use strict'; + +module.exports = Writable; +/* */ + +function WriteReq(chunk, encoding, cb) { + this.chunk = chunk; + this.encoding = encoding; + this.callback = cb; + this.next = null; +} // It seems a linked list but it is not +// there will be only 2 of these for each stream + + +function CorkedRequest(state) { + var _this = this; + + this.next = null; + this.entry = null; + + this.finish = function () { + onCorkedFinish(_this, state); + }; +} +/* */ + +/**/ + + +var Duplex; +/**/ + +Writable.WritableState = WritableState; +/**/ + +var internalUtil = { + deprecate: _dereq_('util-deprecate') +}; +/**/ + +/**/ + +var Stream = _dereq_('./internal/streams/stream'); +/**/ + + +var Buffer = _dereq_('buffer').Buffer; + +var OurUint8Array = global.Uint8Array || function () {}; + +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} + +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} + +var destroyImpl = _dereq_('./internal/streams/destroy'); + +var _require = _dereq_('./internal/streams/state'), + getHighWaterMark = _require.getHighWaterMark; + +var _require$codes = _dereq_('../errors').codes, + ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, + ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, + ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, + ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE, + ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED, + ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES, + ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END, + ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING; + +var errorOrDestroy = destroyImpl.errorOrDestroy; + +_dereq_('inherits')(Writable, Stream); + +function nop() {} + +function WritableState(options, stream, isDuplex) { + Duplex = Duplex || _dereq_('./_stream_duplex'); + options = options || {}; // Duplex streams are both readable and writable, but share + // the same options object. + // However, some cases require setting options to different + // values for the readable and the writable sides of the duplex stream, + // e.g. options.readableObjectMode vs. options.writableObjectMode, etc. + + if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag to indicate whether or not this stream + // contains buffers or objects. + + this.objectMode = !!options.objectMode; + if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false + // Note: 0 is a valid value, means that we always return false if + // the entire buffer is not flushed immediately on write() + + this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex); // if _final has been called + + this.finalCalled = false; // drain event flag. + + this.needDrain = false; // at the start of calling end() + + this.ending = false; // when end() has been called, and returned + + this.ended = false; // when 'finish' is emitted + + this.finished = false; // has it been destroyed + + this.destroyed = false; // should we decode strings into buffers before passing to _write? + // this is here so that some node-core streams can optimize string + // handling at a lower level. + + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + + this.defaultEncoding = options.defaultEncoding || 'utf8'; // not an actual buffer we keep track of, but a measurement + // of how much we're waiting to get pushed to some underlying + // socket or file. + + this.length = 0; // a flag to see when we're in the middle of a write. + + this.writing = false; // when true all writes will be buffered until .uncork() call + + this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + + this.sync = true; // a flag to know if we're processing previously buffered items, which + // may call the _write() callback in the same tick, so that we don't + // end up in an overlapped onwrite situation. + + this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb) + + this.onwrite = function (er) { + onwrite(stream, er); + }; // the callback that the user supplies to write(chunk,encoding,cb) + + + this.writecb = null; // the amount that is being written when _write is called. + + this.writelen = 0; + this.bufferedRequest = null; + this.lastBufferedRequest = null; // number of pending user-supplied write callbacks + // this must be 0 before 'finish' can be emitted + + this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs + // This is relevant for synchronous Transform streams + + this.prefinished = false; // True if the error was already emitted and should not be thrown again + + this.errorEmitted = false; // Should close be emitted on destroy. Defaults to true. + + this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'finish' (and potentially 'end') + + this.autoDestroy = !!options.autoDestroy; // count buffered requests + + this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always + // one allocated and free to use, and we maintain at most two + + this.corkedRequestsFree = new CorkedRequest(this); +} + +WritableState.prototype.getBuffer = function getBuffer() { + var current = this.bufferedRequest; + var out = []; + + while (current) { + out.push(current); + current = current.next; + } + + return out; +}; + +(function () { + try { + Object.defineProperty(WritableState.prototype, 'buffer', { + get: internalUtil.deprecate(function writableStateBufferGetter() { + return this.getBuffer(); + }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') + }); + } catch (_) {} +})(); // Test _writableState for inheritance to account for Duplex streams, +// whose prototype chain only points to Readable. + + +var realHasInstance; + +if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { + realHasInstance = Function.prototype[Symbol.hasInstance]; + Object.defineProperty(Writable, Symbol.hasInstance, { + value: function value(object) { + if (realHasInstance.call(this, object)) return true; + if (this !== Writable) return false; + return object && object._writableState instanceof WritableState; + } + }); +} else { + realHasInstance = function realHasInstance(object) { + return object instanceof this; + }; +} + +function Writable(options) { + Duplex = Duplex || _dereq_('./_stream_duplex'); // Writable ctor is applied to Duplexes, too. + // `realHasInstance` is necessary because using plain `instanceof` + // would return false, as no `_writableState` property is attached. + // Trying to use the custom `instanceof` for Writable here will also break the + // Node.js LazyTransform implementation, which has a non-trivial getter for + // `_writableState` that would lead to infinite recursion. + // Checking for a Stream.Duplex instance is faster here instead of inside + // the WritableState constructor, at least with V8 6.5 + + var isDuplex = this instanceof Duplex; + if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options); + this._writableState = new WritableState(options, this, isDuplex); // legacy. + + this.writable = true; + + if (options) { + if (typeof options.write === 'function') this._write = options.write; + if (typeof options.writev === 'function') this._writev = options.writev; + if (typeof options.destroy === 'function') this._destroy = options.destroy; + if (typeof options.final === 'function') this._final = options.final; + } + + Stream.call(this); +} // Otherwise people can pipe Writable streams, which is just wrong. + + +Writable.prototype.pipe = function () { + errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE()); +}; + +function writeAfterEnd(stream, cb) { + var er = new ERR_STREAM_WRITE_AFTER_END(); // TODO: defer error events consistently everywhere, not just the cb + + errorOrDestroy(stream, er); + process.nextTick(cb, er); +} // Checks that a user-supplied chunk is valid, especially for the particular +// mode the stream is in. Currently this means that `null` is never accepted +// and undefined/non-string values are only allowed in object mode. + + +function validChunk(stream, state, chunk, cb) { + var er; + + if (chunk === null) { + er = new ERR_STREAM_NULL_VALUES(); + } else if (typeof chunk !== 'string' && !state.objectMode) { + er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk); + } + + if (er) { + errorOrDestroy(stream, er); + process.nextTick(cb, er); + return false; + } + + return true; +} + +Writable.prototype.write = function (chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + + var isBuf = !state.objectMode && _isUint8Array(chunk); + + if (isBuf && !Buffer.isBuffer(chunk)) { + chunk = _uint8ArrayToBuffer(chunk); + } + + if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; + if (typeof cb !== 'function') cb = nop; + if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { + state.pendingcb++; + ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); + } + return ret; +}; + +Writable.prototype.cork = function () { + this._writableState.corked++; +}; + +Writable.prototype.uncork = function () { + var state = this._writableState; + + if (state.corked) { + state.corked--; + if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); + } +}; + +Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { + // node::ParseEncoding() requires lower case. + if (typeof encoding === 'string') encoding = encoding.toLowerCase(); + if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding); + this._writableState.defaultEncoding = encoding; + return this; +}; + +Object.defineProperty(Writable.prototype, 'writableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState && this._writableState.getBuffer(); + } +}); + +function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { + chunk = Buffer.from(chunk, encoding); + } + + return chunk; +} + +Object.defineProperty(Writable.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.highWaterMark; + } +}); // if we're already writing something, then just put this +// in the queue, and wait our turn. Otherwise, call _write +// If we return false, then we need a drain event, so set that flag. + +function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { + if (!isBuf) { + var newChunk = decodeChunk(state, chunk, encoding); + + if (chunk !== newChunk) { + isBuf = true; + encoding = 'buffer'; + chunk = newChunk; + } + } + + var len = state.objectMode ? 1 : chunk.length; + state.length += len; + var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false. + + if (!ret) state.needDrain = true; + + if (state.writing || state.corked) { + var last = state.lastBufferedRequest; + state.lastBufferedRequest = { + chunk: chunk, + encoding: encoding, + isBuf: isBuf, + callback: cb, + next: null + }; + + if (last) { + last.next = state.lastBufferedRequest; + } else { + state.bufferedRequest = state.lastBufferedRequest; + } + + state.bufferedRequestCount += 1; + } else { + doWrite(stream, state, false, len, chunk, encoding, cb); + } + + return ret; +} + +function doWrite(stream, state, writev, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); + state.sync = false; +} + +function onwriteError(stream, state, sync, er, cb) { + --state.pendingcb; + + if (sync) { + // defer the callback if we are being called synchronously + // to avoid piling up things on the stack + process.nextTick(cb, er); // this can emit finish, and it will always happen + // after error + + process.nextTick(finishMaybe, stream, state); + stream._writableState.errorEmitted = true; + errorOrDestroy(stream, er); + } else { + // the caller expect this to happen before if + // it is async + cb(er); + stream._writableState.errorEmitted = true; + errorOrDestroy(stream, er); // this can emit finish, but finish must + // always follow error + + finishMaybe(stream, state); + } +} + +function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; +} + +function onwrite(stream, er) { + var state = stream._writableState; + var sync = state.sync; + var cb = state.writecb; + if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK(); + onwriteStateUpdate(state); + if (er) onwriteError(stream, state, sync, er, cb);else { + // Check if we're actually ready to finish, but don't emit yet + var finished = needFinish(state) || stream.destroyed; + + if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { + clearBuffer(stream, state); + } + + if (sync) { + process.nextTick(afterWrite, stream, state, finished, cb); + } else { + afterWrite(stream, state, finished, cb); + } + } +} + +function afterWrite(stream, state, finished, cb) { + if (!finished) onwriteDrain(stream, state); + state.pendingcb--; + cb(); + finishMaybe(stream, state); +} // Must force callback to be called on nextTick, so that we don't +// emit 'drain' before the write() consumer gets the 'false' return +// value, and has a chance to attach a 'drain' listener. + + +function onwriteDrain(stream, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream.emit('drain'); + } +} // if there's something in the buffer waiting, then process it + + +function clearBuffer(stream, state) { + state.bufferProcessing = true; + var entry = state.bufferedRequest; + + if (stream._writev && entry && entry.next) { + // Fast case, write everything using _writev() + var l = state.bufferedRequestCount; + var buffer = new Array(l); + var holder = state.corkedRequestsFree; + holder.entry = entry; + var count = 0; + var allBuffers = true; + + while (entry) { + buffer[count] = entry; + if (!entry.isBuf) allBuffers = false; + entry = entry.next; + count += 1; + } + + buffer.allBuffers = allBuffers; + doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time + // as the hot path ends with doWrite + + state.pendingcb++; + state.lastBufferedRequest = null; + + if (holder.next) { + state.corkedRequestsFree = holder.next; + holder.next = null; + } else { + state.corkedRequestsFree = new CorkedRequest(state); + } + + state.bufferedRequestCount = 0; + } else { + // Slow case, write chunks one-by-one + while (entry) { + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; + doWrite(stream, state, false, len, chunk, encoding, cb); + entry = entry.next; + state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then + // it means that we need to wait until it does. + // also, that means that the chunk and cb are currently + // being processed, so move the buffer counter past them. + + if (state.writing) { + break; + } + } + + if (entry === null) state.lastBufferedRequest = null; + } + + state.bufferedRequest = entry; + state.bufferProcessing = false; +} + +Writable.prototype._write = function (chunk, encoding, cb) { + cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()')); +}; + +Writable.prototype._writev = null; + +Writable.prototype.end = function (chunk, encoding, cb) { + var state = this._writableState; + + if (typeof chunk === 'function') { + cb = chunk; + chunk = null; + encoding = null; + } else if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks + + if (state.corked) { + state.corked = 1; + this.uncork(); + } // ignore unnecessary end() calls. + + + if (!state.ending) endWritable(this, state, cb); + return this; +}; + +Object.defineProperty(Writable.prototype, 'writableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.length; + } +}); + +function needFinish(state) { + return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; +} + +function callFinal(stream, state) { + stream._final(function (err) { + state.pendingcb--; + + if (err) { + errorOrDestroy(stream, err); + } + + state.prefinished = true; + stream.emit('prefinish'); + finishMaybe(stream, state); + }); +} + +function prefinish(stream, state) { + if (!state.prefinished && !state.finalCalled) { + if (typeof stream._final === 'function' && !state.destroyed) { + state.pendingcb++; + state.finalCalled = true; + process.nextTick(callFinal, stream, state); + } else { + state.prefinished = true; + stream.emit('prefinish'); + } + } +} + +function finishMaybe(stream, state) { + var need = needFinish(state); + + if (need) { + prefinish(stream, state); + + if (state.pendingcb === 0) { + state.finished = true; + stream.emit('finish'); + + if (state.autoDestroy) { + // In case of duplex streams we need a way to detect + // if the readable side is ready for autoDestroy as well + var rState = stream._readableState; + + if (!rState || rState.autoDestroy && rState.endEmitted) { + stream.destroy(); + } + } + } + } + + return need; +} + +function endWritable(stream, state, cb) { + state.ending = true; + finishMaybe(stream, state); + + if (cb) { + if (state.finished) process.nextTick(cb);else stream.once('finish', cb); + } + + state.ended = true; + stream.writable = false; +} + +function onCorkedFinish(corkReq, state, err) { + var entry = corkReq.entry; + corkReq.entry = null; + + while (entry) { + var cb = entry.callback; + state.pendingcb--; + cb(err); + entry = entry.next; + } // reuse the free corkReq. + + + state.corkedRequestsFree.next = corkReq; +} + +Object.defineProperty(Writable.prototype, 'destroyed', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + if (this._writableState === undefined) { + return false; + } + + return this._writableState.destroyed; + }, + set: function set(value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._writableState) { + return; + } // backward compatibility, the user is explicitly + // managing destroyed + + + this._writableState.destroyed = value; + } +}); +Writable.prototype.destroy = destroyImpl.destroy; +Writable.prototype._undestroy = destroyImpl.undestroy; + +Writable.prototype._destroy = function (err, cb) { + cb(err); +}; +}).call(this)}).call(this,_dereq_('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"../errors":99,"./_stream_duplex":100,"./internal/streams/destroy":107,"./internal/streams/state":111,"./internal/streams/stream":112,"_process":96,"buffer":28,"inherits":65,"util-deprecate":120}],105:[function(_dereq_,module,exports){ +(function (process){(function (){ +'use strict'; + +var _Object$setPrototypeO; + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var finished = _dereq_('./end-of-stream'); + +var kLastResolve = Symbol('lastResolve'); +var kLastReject = Symbol('lastReject'); +var kError = Symbol('error'); +var kEnded = Symbol('ended'); +var kLastPromise = Symbol('lastPromise'); +var kHandlePromise = Symbol('handlePromise'); +var kStream = Symbol('stream'); + +function createIterResult(value, done) { + return { + value: value, + done: done + }; +} + +function readAndResolve(iter) { + var resolve = iter[kLastResolve]; + + if (resolve !== null) { + var data = iter[kStream].read(); // we defer if data is null + // we can be expecting either 'end' or + // 'error' + + if (data !== null) { + iter[kLastPromise] = null; + iter[kLastResolve] = null; + iter[kLastReject] = null; + resolve(createIterResult(data, false)); + } + } +} + +function onReadable(iter) { + // we wait for the next tick, because it might + // emit an error with process.nextTick + process.nextTick(readAndResolve, iter); +} + +function wrapForNext(lastPromise, iter) { + return function (resolve, reject) { + lastPromise.then(function () { + if (iter[kEnded]) { + resolve(createIterResult(undefined, true)); + return; + } + + iter[kHandlePromise](resolve, reject); + }, reject); + }; +} + +var AsyncIteratorPrototype = Object.getPrototypeOf(function () {}); +var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = { + get stream() { + return this[kStream]; + }, + + next: function next() { + var _this = this; + + // if we have detected an error in the meanwhile + // reject straight away + var error = this[kError]; + + if (error !== null) { + return Promise.reject(error); + } + + if (this[kEnded]) { + return Promise.resolve(createIterResult(undefined, true)); + } + + if (this[kStream].destroyed) { + // We need to defer via nextTick because if .destroy(err) is + // called, the error will be emitted via nextTick, and + // we cannot guarantee that there is no error lingering around + // waiting to be emitted. + return new Promise(function (resolve, reject) { + process.nextTick(function () { + if (_this[kError]) { + reject(_this[kError]); + } else { + resolve(createIterResult(undefined, true)); + } + }); + }); + } // if we have multiple next() calls + // we will wait for the previous Promise to finish + // this logic is optimized to support for await loops, + // where next() is only called once at a time + + + var lastPromise = this[kLastPromise]; + var promise; + + if (lastPromise) { + promise = new Promise(wrapForNext(lastPromise, this)); + } else { + // fast path needed to support multiple this.push() + // without triggering the next() queue + var data = this[kStream].read(); + + if (data !== null) { + return Promise.resolve(createIterResult(data, false)); + } + + promise = new Promise(this[kHandlePromise]); + } + + this[kLastPromise] = promise; + return promise; + } +}, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () { + return this; +}), _defineProperty(_Object$setPrototypeO, "return", function _return() { + var _this2 = this; + + // destroy(err, cb) is a private API + // we can guarantee we have that here, because we control the + // Readable class this is attached to + return new Promise(function (resolve, reject) { + _this2[kStream].destroy(null, function (err) { + if (err) { + reject(err); + return; + } + + resolve(createIterResult(undefined, true)); + }); + }); +}), _Object$setPrototypeO), AsyncIteratorPrototype); + +var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) { + var _Object$create; + + var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, { + value: stream, + writable: true + }), _defineProperty(_Object$create, kLastResolve, { + value: null, + writable: true + }), _defineProperty(_Object$create, kLastReject, { + value: null, + writable: true + }), _defineProperty(_Object$create, kError, { + value: null, + writable: true + }), _defineProperty(_Object$create, kEnded, { + value: stream._readableState.endEmitted, + writable: true + }), _defineProperty(_Object$create, kHandlePromise, { + value: function value(resolve, reject) { + var data = iterator[kStream].read(); + + if (data) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + resolve(createIterResult(data, false)); + } else { + iterator[kLastResolve] = resolve; + iterator[kLastReject] = reject; + } + }, + writable: true + }), _Object$create)); + iterator[kLastPromise] = null; + finished(stream, function (err) { + if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') { + var reject = iterator[kLastReject]; // reject if we are waiting for data in the Promise + // returned by next() and store the error + + if (reject !== null) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + reject(err); + } + + iterator[kError] = err; + return; + } + + var resolve = iterator[kLastResolve]; + + if (resolve !== null) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + resolve(createIterResult(undefined, true)); + } + + iterator[kEnded] = true; + }); + stream.on('readable', onReadable.bind(null, iterator)); + return iterator; +}; + +module.exports = createReadableStreamAsyncIterator; +}).call(this)}).call(this,_dereq_('_process')) +},{"./end-of-stream":108,"_process":96}],106:[function(_dereq_,module,exports){ +'use strict'; + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +var _require = _dereq_('buffer'), + Buffer = _require.Buffer; + +var _require2 = _dereq_('util'), + inspect = _require2.inspect; + +var custom = inspect && inspect.custom || 'inspect'; + +function copyBuffer(src, target, offset) { + Buffer.prototype.copy.call(src, target, offset); +} + +module.exports = +/*#__PURE__*/ +function () { + function BufferList() { + _classCallCheck(this, BufferList); + + this.head = null; + this.tail = null; + this.length = 0; + } + + _createClass(BufferList, [{ + key: "push", + value: function push(v) { + var entry = { + data: v, + next: null + }; + if (this.length > 0) this.tail.next = entry;else this.head = entry; + this.tail = entry; + ++this.length; + } + }, { + key: "unshift", + value: function unshift(v) { + var entry = { + data: v, + next: this.head + }; + if (this.length === 0) this.tail = entry; + this.head = entry; + ++this.length; + } + }, { + key: "shift", + value: function shift() { + if (this.length === 0) return; + var ret = this.head.data; + if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; + --this.length; + return ret; + } + }, { + key: "clear", + value: function clear() { + this.head = this.tail = null; + this.length = 0; + } + }, { + key: "join", + value: function join(s) { + if (this.length === 0) return ''; + var p = this.head; + var ret = '' + p.data; + + while (p = p.next) { + ret += s + p.data; + } + + return ret; + } + }, { + key: "concat", + value: function concat(n) { + if (this.length === 0) return Buffer.alloc(0); + var ret = Buffer.allocUnsafe(n >>> 0); + var p = this.head; + var i = 0; + + while (p) { + copyBuffer(p.data, ret, i); + i += p.data.length; + p = p.next; + } + + return ret; + } // Consumes a specified amount of bytes or characters from the buffered data. + + }, { + key: "consume", + value: function consume(n, hasStrings) { + var ret; + + if (n < this.head.data.length) { + // `slice` is the same for buffers and strings. + ret = this.head.data.slice(0, n); + this.head.data = this.head.data.slice(n); + } else if (n === this.head.data.length) { + // First chunk is a perfect match. + ret = this.shift(); + } else { + // Result spans more than one buffer. + ret = hasStrings ? this._getString(n) : this._getBuffer(n); + } + + return ret; + } + }, { + key: "first", + value: function first() { + return this.head.data; + } // Consumes a specified amount of characters from the buffered data. + + }, { + key: "_getString", + value: function _getString(n) { + var p = this.head; + var c = 1; + var ret = p.data; + n -= ret.length; + + while (p = p.next) { + var str = p.data; + var nb = n > str.length ? str.length : n; + if (nb === str.length) ret += str;else ret += str.slice(0, n); + n -= nb; + + if (n === 0) { + if (nb === str.length) { + ++c; + if (p.next) this.head = p.next;else this.head = this.tail = null; + } else { + this.head = p; + p.data = str.slice(nb); + } + + break; + } + + ++c; + } + + this.length -= c; + return ret; + } // Consumes a specified amount of bytes from the buffered data. + + }, { + key: "_getBuffer", + value: function _getBuffer(n) { + var ret = Buffer.allocUnsafe(n); + var p = this.head; + var c = 1; + p.data.copy(ret); + n -= p.data.length; + + while (p = p.next) { + var buf = p.data; + var nb = n > buf.length ? buf.length : n; + buf.copy(ret, ret.length - n, 0, nb); + n -= nb; + + if (n === 0) { + if (nb === buf.length) { + ++c; + if (p.next) this.head = p.next;else this.head = this.tail = null; + } else { + this.head = p; + p.data = buf.slice(nb); + } + + break; + } + + ++c; + } + + this.length -= c; + return ret; + } // Make sure the linked list only shows the minimal necessary information. + + }, { + key: custom, + value: function value(_, options) { + return inspect(this, _objectSpread({}, options, { + // Only inspect one level. + depth: 0, + // It should not recurse. + customInspect: false + })); + } + }]); + + return BufferList; +}(); +},{"buffer":28,"util":26}],107:[function(_dereq_,module,exports){ +(function (process){(function (){ +'use strict'; // undocumented cb() API, needed for core, not for public API + +function destroy(err, cb) { + var _this = this; + + var readableDestroyed = this._readableState && this._readableState.destroyed; + var writableDestroyed = this._writableState && this._writableState.destroyed; + + if (readableDestroyed || writableDestroyed) { + if (cb) { + cb(err); + } else if (err) { + if (!this._writableState) { + process.nextTick(emitErrorNT, this, err); + } else if (!this._writableState.errorEmitted) { + this._writableState.errorEmitted = true; + process.nextTick(emitErrorNT, this, err); + } + } + + return this; + } // we set destroyed to true before firing error callbacks in order + // to make it re-entrance safe in case destroy() is called within callbacks + + + if (this._readableState) { + this._readableState.destroyed = true; + } // if this is a duplex stream mark the writable part as destroyed as well + + + if (this._writableState) { + this._writableState.destroyed = true; + } + + this._destroy(err || null, function (err) { + if (!cb && err) { + if (!_this._writableState) { + process.nextTick(emitErrorAndCloseNT, _this, err); + } else if (!_this._writableState.errorEmitted) { + _this._writableState.errorEmitted = true; + process.nextTick(emitErrorAndCloseNT, _this, err); + } else { + process.nextTick(emitCloseNT, _this); + } + } else if (cb) { + process.nextTick(emitCloseNT, _this); + cb(err); + } else { + process.nextTick(emitCloseNT, _this); + } + }); + + return this; +} + +function emitErrorAndCloseNT(self, err) { + emitErrorNT(self, err); + emitCloseNT(self); +} + +function emitCloseNT(self) { + if (self._writableState && !self._writableState.emitClose) return; + if (self._readableState && !self._readableState.emitClose) return; + self.emit('close'); +} + +function undestroy() { + if (this._readableState) { + this._readableState.destroyed = false; + this._readableState.reading = false; + this._readableState.ended = false; + this._readableState.endEmitted = false; + } + + if (this._writableState) { + this._writableState.destroyed = false; + this._writableState.ended = false; + this._writableState.ending = false; + this._writableState.finalCalled = false; + this._writableState.prefinished = false; + this._writableState.finished = false; + this._writableState.errorEmitted = false; + } +} + +function emitErrorNT(self, err) { + self.emit('error', err); +} + +function errorOrDestroy(stream, err) { + // We have tests that rely on errors being emitted + // in the same tick, so changing this is semver major. + // For now when you opt-in to autoDestroy we allow + // the error to be emitted nextTick. In a future + // semver major update we should change the default to this. + var rState = stream._readableState; + var wState = stream._writableState; + if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err); +} + +module.exports = { + destroy: destroy, + undestroy: undestroy, + errorOrDestroy: errorOrDestroy +}; +}).call(this)}).call(this,_dereq_('_process')) +},{"_process":96}],108:[function(_dereq_,module,exports){ +// Ported from https://github.com/mafintosh/end-of-stream with +// permission from the author, Mathias Buus (@mafintosh). +'use strict'; + +var ERR_STREAM_PREMATURE_CLOSE = _dereq_('../../../errors').codes.ERR_STREAM_PREMATURE_CLOSE; + +function once(callback) { + var called = false; + return function () { + if (called) return; + called = true; + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + callback.apply(this, args); + }; +} + +function noop() {} + +function isRequest(stream) { + return stream.setHeader && typeof stream.abort === 'function'; +} + +function eos(stream, opts, callback) { + if (typeof opts === 'function') return eos(stream, null, opts); + if (!opts) opts = {}; + callback = once(callback || noop); + var readable = opts.readable || opts.readable !== false && stream.readable; + var writable = opts.writable || opts.writable !== false && stream.writable; + + var onlegacyfinish = function onlegacyfinish() { + if (!stream.writable) onfinish(); + }; + + var writableEnded = stream._writableState && stream._writableState.finished; + + var onfinish = function onfinish() { + writable = false; + writableEnded = true; + if (!readable) callback.call(stream); + }; + + var readableEnded = stream._readableState && stream._readableState.endEmitted; + + var onend = function onend() { + readable = false; + readableEnded = true; + if (!writable) callback.call(stream); + }; + + var onerror = function onerror(err) { + callback.call(stream, err); + }; + + var onclose = function onclose() { + var err; + + if (readable && !readableEnded) { + if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE(); + return callback.call(stream, err); + } + + if (writable && !writableEnded) { + if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE(); + return callback.call(stream, err); + } + }; + + var onrequest = function onrequest() { + stream.req.on('finish', onfinish); + }; + + if (isRequest(stream)) { + stream.on('complete', onfinish); + stream.on('abort', onclose); + if (stream.req) onrequest();else stream.on('request', onrequest); + } else if (writable && !stream._writableState) { + // legacy streams + stream.on('end', onlegacyfinish); + stream.on('close', onlegacyfinish); + } + + stream.on('end', onend); + stream.on('finish', onfinish); + if (opts.error !== false) stream.on('error', onerror); + stream.on('close', onclose); + return function () { + stream.removeListener('complete', onfinish); + stream.removeListener('abort', onclose); + stream.removeListener('request', onrequest); + if (stream.req) stream.req.removeListener('finish', onfinish); + stream.removeListener('end', onlegacyfinish); + stream.removeListener('close', onlegacyfinish); + stream.removeListener('finish', onfinish); + stream.removeListener('end', onend); + stream.removeListener('error', onerror); + stream.removeListener('close', onclose); + }; +} + +module.exports = eos; +},{"../../../errors":99}],109:[function(_dereq_,module,exports){ +module.exports = function () { + throw new Error('Readable.from is not available in the browser') +}; + +},{}],110:[function(_dereq_,module,exports){ +// Ported from https://github.com/mafintosh/pump with +// permission from the author, Mathias Buus (@mafintosh). +'use strict'; + +var eos; + +function once(callback) { + var called = false; + return function () { + if (called) return; + called = true; + callback.apply(void 0, arguments); + }; +} + +var _require$codes = _dereq_('../../../errors').codes, + ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS, + ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED; + +function noop(err) { + // Rethrow the error if it exists to avoid swallowing it + if (err) throw err; +} + +function isRequest(stream) { + return stream.setHeader && typeof stream.abort === 'function'; +} + +function destroyer(stream, reading, writing, callback) { + callback = once(callback); + var closed = false; + stream.on('close', function () { + closed = true; + }); + if (eos === undefined) eos = _dereq_('./end-of-stream'); + eos(stream, { + readable: reading, + writable: writing + }, function (err) { + if (err) return callback(err); + closed = true; + callback(); + }); + var destroyed = false; + return function (err) { + if (closed) return; + if (destroyed) return; + destroyed = true; // request.destroy just do .end - .abort is what we want + + if (isRequest(stream)) return stream.abort(); + if (typeof stream.destroy === 'function') return stream.destroy(); + callback(err || new ERR_STREAM_DESTROYED('pipe')); + }; +} + +function call(fn) { + fn(); +} + +function pipe(from, to) { + return from.pipe(to); +} + +function popCallback(streams) { + if (!streams.length) return noop; + if (typeof streams[streams.length - 1] !== 'function') return noop; + return streams.pop(); +} + +function pipeline() { + for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) { + streams[_key] = arguments[_key]; + } + + var callback = popCallback(streams); + if (Array.isArray(streams[0])) streams = streams[0]; + + if (streams.length < 2) { + throw new ERR_MISSING_ARGS('streams'); + } + + var error; + var destroys = streams.map(function (stream, i) { + var reading = i < streams.length - 1; + var writing = i > 0; + return destroyer(stream, reading, writing, function (err) { + if (!error) error = err; + if (err) destroys.forEach(call); + if (reading) return; + destroys.forEach(call); + callback(error); + }); + }); + return streams.reduce(pipe); +} + +module.exports = pipeline; +},{"../../../errors":99,"./end-of-stream":108}],111:[function(_dereq_,module,exports){ +'use strict'; + +var ERR_INVALID_OPT_VALUE = _dereq_('../../../errors').codes.ERR_INVALID_OPT_VALUE; + +function highWaterMarkFrom(options, isDuplex, duplexKey) { + return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null; +} + +function getHighWaterMark(state, options, duplexKey, isDuplex) { + var hwm = highWaterMarkFrom(options, isDuplex, duplexKey); + + if (hwm != null) { + if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) { + var name = isDuplex ? duplexKey : 'highWaterMark'; + throw new ERR_INVALID_OPT_VALUE(name, hwm); + } + + return Math.floor(hwm); + } // Default value + + + return state.objectMode ? 16 : 16 * 1024; +} + +module.exports = { + getHighWaterMark: getHighWaterMark +}; +},{"../../../errors":99}],112:[function(_dereq_,module,exports){ +module.exports = _dereq_('events').EventEmitter; + +},{"events":27}],113:[function(_dereq_,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +'use strict'; + +/**/ + +var Buffer = _dereq_('safe-buffer').Buffer; +/**/ + +var isEncoding = Buffer.isEncoding || function (encoding) { + encoding = '' + encoding; + switch (encoding && encoding.toLowerCase()) { + case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw': + return true; + default: + return false; + } +}; + +function _normalizeEncoding(enc) { + if (!enc) return 'utf8'; + var retried; + while (true) { + switch (enc) { + case 'utf8': + case 'utf-8': + return 'utf8'; + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return 'utf16le'; + case 'latin1': + case 'binary': + return 'latin1'; + case 'base64': + case 'ascii': + case 'hex': + return enc; + default: + if (retried) return; // undefined + enc = ('' + enc).toLowerCase(); + retried = true; + } + } +}; + +// Do not cache `Buffer.isEncoding` when checking encoding names as some +// modules monkey-patch it to support additional encodings +function normalizeEncoding(enc) { + var nenc = _normalizeEncoding(enc); + if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); + return nenc || enc; +} + +// StringDecoder provides an interface for efficiently splitting a series of +// buffers into a series of JS strings without breaking apart multi-byte +// characters. +exports.StringDecoder = StringDecoder; +function StringDecoder(encoding) { + this.encoding = normalizeEncoding(encoding); + var nb; + switch (this.encoding) { + case 'utf16le': + this.text = utf16Text; + this.end = utf16End; + nb = 4; + break; + case 'utf8': + this.fillLast = utf8FillLast; + nb = 4; + break; + case 'base64': + this.text = base64Text; + this.end = base64End; + nb = 3; + break; + default: + this.write = simpleWrite; + this.end = simpleEnd; + return; + } + this.lastNeed = 0; + this.lastTotal = 0; + this.lastChar = Buffer.allocUnsafe(nb); +} + +StringDecoder.prototype.write = function (buf) { + if (buf.length === 0) return ''; + var r; + var i; + if (this.lastNeed) { + r = this.fillLast(buf); + if (r === undefined) return ''; + i = this.lastNeed; + this.lastNeed = 0; + } else { + i = 0; + } + if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i); + return r || ''; +}; + +StringDecoder.prototype.end = utf8End; + +// Returns only complete characters in a Buffer +StringDecoder.prototype.text = utf8Text; + +// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer +StringDecoder.prototype.fillLast = function (buf) { + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); + } + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length); + this.lastNeed -= buf.length; +}; + +// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a +// continuation byte. If an invalid byte is detected, -2 is returned. +function utf8CheckByte(byte) { + if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; + return byte >> 6 === 0x02 ? -1 : -2; +} + +// Checks at most 3 bytes at the end of a Buffer in order to detect an +// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4) +// needed to complete the UTF-8 character (if applicable) are returned. +function utf8CheckIncomplete(self, buf, i) { + var j = buf.length - 1; + if (j < i) return 0; + var nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 1; + return nb; + } + if (--j < i || nb === -2) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 2; + return nb; + } + if (--j < i || nb === -2) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) { + if (nb === 2) nb = 0;else self.lastNeed = nb - 3; + } + return nb; + } + return 0; +} + +// Validates as many continuation bytes for a multi-byte UTF-8 character as +// needed or are available. If we see a non-continuation byte where we expect +// one, we "replace" the validated continuation bytes we've seen so far with +// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding +// behavior. The continuation byte check is included three times in the case +// where all of the continuation bytes for a character exist in the same buffer. +// It is also done this way as a slight performance increase instead of using a +// loop. +function utf8CheckExtraBytes(self, buf, p) { + if ((buf[0] & 0xC0) !== 0x80) { + self.lastNeed = 0; + return '\ufffd'; + } + if (self.lastNeed > 1 && buf.length > 1) { + if ((buf[1] & 0xC0) !== 0x80) { + self.lastNeed = 1; + return '\ufffd'; + } + if (self.lastNeed > 2 && buf.length > 2) { + if ((buf[2] & 0xC0) !== 0x80) { + self.lastNeed = 2; + return '\ufffd'; + } + } + } +} + +// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer. +function utf8FillLast(buf) { + var p = this.lastTotal - this.lastNeed; + var r = utf8CheckExtraBytes(this, buf, p); + if (r !== undefined) return r; + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, p, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); + } + buf.copy(this.lastChar, p, 0, buf.length); + this.lastNeed -= buf.length; +} + +// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a +// partial character, the character's bytes are buffered until the required +// number of bytes are available. +function utf8Text(buf, i) { + var total = utf8CheckIncomplete(this, buf, i); + if (!this.lastNeed) return buf.toString('utf8', i); + this.lastTotal = total; + var end = buf.length - (total - this.lastNeed); + buf.copy(this.lastChar, 0, end); + return buf.toString('utf8', i, end); +} + +// For UTF-8, a replacement character is added when ending on a partial +// character. +function utf8End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + '\ufffd'; + return r; +} + +// UTF-16LE typically needs two bytes per character, but even if we have an even +// number of bytes available, we need to check if we end on a leading/high +// surrogate. In that case, we need to wait for the next two bytes in order to +// decode the last character properly. +function utf16Text(buf, i) { + if ((buf.length - i) % 2 === 0) { + var r = buf.toString('utf16le', i); + if (r) { + var c = r.charCodeAt(r.length - 1); + if (c >= 0xD800 && c <= 0xDBFF) { + this.lastNeed = 2; + this.lastTotal = 4; + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + return r.slice(0, -1); + } + } + return r; + } + this.lastNeed = 1; + this.lastTotal = 2; + this.lastChar[0] = buf[buf.length - 1]; + return buf.toString('utf16le', i, buf.length - 1); +} + +// For UTF-16LE we do not explicitly append special replacement characters if we +// end on a partial character, we simply let v8 handle that. +function utf16End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) { + var end = this.lastTotal - this.lastNeed; + return r + this.lastChar.toString('utf16le', 0, end); + } + return r; +} + +function base64Text(buf, i) { + var n = (buf.length - i) % 3; + if (n === 0) return buf.toString('base64', i); + this.lastNeed = 3 - n; + this.lastTotal = 3; + if (n === 1) { + this.lastChar[0] = buf[buf.length - 1]; + } else { + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + } + return buf.toString('base64', i, buf.length - n); +} + +function base64End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed); + return r; +} + +// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex) +function simpleWrite(buf) { + return buf.toString(this.encoding); +} + +function simpleEnd(buf) { + return buf && buf.length ? this.write(buf) : ''; +} +},{"safe-buffer":97}],114:[function(_dereq_,module,exports){ +(function (process,Buffer){(function (){ + +/** + * Module dependencies. + */ + +var assert = _dereq_('assert'); +var debug = _dereq_('debug')('stream-parser'); + +/** + * Module exports. + */ + +module.exports = Parser; + +/** + * Parser states. + */ + +var INIT = -1; +var BUFFERING = 0; +var SKIPPING = 1; +var PASSTHROUGH = 2; + +/** + * The `Parser` stream mixin works with either `Writable` or `Transform` stream + * instances/subclasses. Provides a convenient generic "parsing" API: + * + * _bytes(n, cb) - buffers "n" bytes and then calls "cb" with the "chunk" + * _skipBytes(n, cb) - skips "n" bytes and then calls "cb" when done + * + * If you extend a `Transform` stream, then the `_passthrough()` function is also + * added: + * + * _passthrough(n, cb) - passes through "n" bytes untouched and then calls "cb" + * + * @param {Stream} stream Transform or Writable stream instance to extend + * @api public + */ + +function Parser (stream) { + var isTransform = stream && 'function' == typeof stream._transform; + var isWritable = stream && 'function' == typeof stream._write; + + if (!isTransform && !isWritable) throw new Error('must pass a Writable or Transform stream in'); + debug('extending Parser into stream'); + + // Transform streams and Writable streams get `_bytes()` and `_skipBytes()` + stream._bytes = _bytes; + stream._skipBytes = _skipBytes; + + // only Transform streams get the `_passthrough()` function + if (isTransform) stream._passthrough = _passthrough; + + // take control of the streams2 callback functions for this stream + if (isTransform) { + stream._transform = transform; + } else { + stream._write = write; + } +} + +function init (stream) { + debug('initializing parser stream'); + + // number of bytes left to parser for the next "chunk" + stream._parserBytesLeft = 0; + + // array of Buffer instances that make up the next "chunk" + stream._parserBuffers = []; + + // number of bytes parsed so far for the next "chunk" + stream._parserBuffered = 0; + + // flag that keeps track of if what the parser should do with bytes received + stream._parserState = INIT; + + // the callback for the next "chunk" + stream._parserCallback = null; + + // XXX: backwards compat with the old Transform API... remove at some point.. + if ('function' == typeof stream.push) { + stream._parserOutput = stream.push.bind(stream); + } + + stream._parserInit = true; +} + +/** + * Buffers `n` bytes and then invokes `fn` once that amount has been collected. + * + * @param {Number} n the number of bytes to buffer + * @param {Function} fn callback function to invoke when `n` bytes are buffered + * @api public + */ + +function _bytes (n, fn) { + assert(!this._parserCallback, 'there is already a "callback" set!'); + assert(isFinite(n) && n > 0, 'can only buffer a finite number of bytes > 0, got "' + n + '"'); + if (!this._parserInit) init(this); + debug('buffering %o bytes', n); + this._parserBytesLeft = n; + this._parserCallback = fn; + this._parserState = BUFFERING; +} + +/** + * Skips over the next `n` bytes, then invokes `fn` once that amount has + * been discarded. + * + * @param {Number} n the number of bytes to discard + * @param {Function} fn callback function to invoke when `n` bytes have been skipped + * @api public + */ + +function _skipBytes (n, fn) { + assert(!this._parserCallback, 'there is already a "callback" set!'); + assert(n > 0, 'can only skip > 0 bytes, got "' + n + '"'); + if (!this._parserInit) init(this); + debug('skipping %o bytes', n); + this._parserBytesLeft = n; + this._parserCallback = fn; + this._parserState = SKIPPING; +} + +/** + * Passes through `n` bytes to the readable side of this stream untouched, + * then invokes `fn` once that amount has been passed through. + * + * @param {Number} n the number of bytes to pass through + * @param {Function} fn callback function to invoke when `n` bytes have passed through + * @api public + */ + +function _passthrough (n, fn) { + assert(!this._parserCallback, 'There is already a "callback" set!'); + assert(n > 0, 'can only pass through > 0 bytes, got "' + n + '"'); + if (!this._parserInit) init(this); + debug('passing through %o bytes', n); + this._parserBytesLeft = n; + this._parserCallback = fn; + this._parserState = PASSTHROUGH; +} + +/** + * The `_write()` callback function implementation. + * + * @api private + */ + +function write (chunk, encoding, fn) { + if (!this._parserInit) init(this); + debug('write(%o bytes)', chunk.length); + + // XXX: old Writable stream API compat... remove at some point... + if ('function' == typeof encoding) fn = encoding; + + data(this, chunk, null, fn); +} + +/** + * The `_transform()` callback function implementation. + * + * @api private + */ + + +function transform (chunk, output, fn) { + if (!this._parserInit) init(this); + debug('transform(%o bytes)', chunk.length); + + // XXX: old Transform stream API compat... remove at some point... + if ('function' != typeof output) { + output = this._parserOutput; + } + + data(this, chunk, output, fn); +} + +/** + * The internal buffering/passthrough logic... + * + * This `_data` function get's "trampolined" to prevent stack overflows for tight + * loops. This technique requires us to return a "thunk" function for any + * synchronous action. Async stuff breaks the trampoline, but that's ok since it's + * working with a new stack at that point anyway. + * + * @api private + */ + +function _data (stream, chunk, output, fn) { + if (stream._parserBytesLeft <= 0) { + return fn(new Error('got data but not currently parsing anything')); + } + + if (chunk.length <= stream._parserBytesLeft) { + // small buffer fits within the "_parserBytesLeft" window + return function () { + return process(stream, chunk, output, fn); + }; + } else { + // large buffer needs to be sliced on "_parserBytesLeft" and processed + return function () { + var b = chunk.slice(0, stream._parserBytesLeft); + return process(stream, b, output, function (err) { + if (err) return fn(err); + if (chunk.length > b.length) { + return function () { + return _data(stream, chunk.slice(b.length), output, fn); + }; + } + }); + }; + } +} + +/** + * The internal `process` function gets called by the `data` function when + * something "interesting" happens. This function takes care of buffering the + * bytes when buffering, passing through the bytes when doing that, and invoking + * the user callback when the number of bytes has been reached. + * + * @api private + */ + +function process (stream, chunk, output, fn) { + stream._parserBytesLeft -= chunk.length; + debug('%o bytes left for stream piece', stream._parserBytesLeft); + + if (stream._parserState === BUFFERING) { + // buffer + stream._parserBuffers.push(chunk); + stream._parserBuffered += chunk.length; + } else if (stream._parserState === PASSTHROUGH) { + // passthrough + output(chunk); + } + // don't need to do anything for the SKIPPING case + + if (0 === stream._parserBytesLeft) { + // done with stream "piece", invoke the callback + var cb = stream._parserCallback; + if (cb && stream._parserState === BUFFERING && stream._parserBuffers.length > 1) { + chunk = Buffer.concat(stream._parserBuffers, stream._parserBuffered); + } + if (stream._parserState !== BUFFERING) { + chunk = null; + } + stream._parserCallback = null; + stream._parserBuffered = 0; + stream._parserState = INIT; + stream._parserBuffers.splice(0); // empty + + if (cb) { + var args = []; + if (chunk) { + // buffered + args.push(chunk); + } else { + // passthrough + } + if (output) { + // on a Transform stream, has "output" function + args.push(output); + } + var async = cb.length > args.length; + if (async) { + args.push(trampoline(fn)); + } + // invoke cb + var rtn = cb.apply(stream, args); + if (!async || fn === rtn) return fn; + } + } else { + // need more bytes + return fn; + } +} + +var data = trampoline(_data); + +/** + * Generic thunk-based "trampoline" helper function. + * + * @param {Function} input function + * @return {Function} "trampolined" function + * @api private + */ + +function trampoline (fn) { + return function () { + var result = fn.apply(this, arguments); + + while ('function' == typeof result) { + result = result(); + } + + return result; + }; +} + +}).call(this)}).call(this,_dereq_('_process'),_dereq_("buffer").Buffer) +},{"_process":96,"assert":21,"buffer":28,"debug":115}],115:[function(_dereq_,module,exports){ +(function (process){(function (){ +/** + * This is the web browser implementation of `debug()`. + * + * Expose `debug()` as the module. + */ + +exports = module.exports = _dereq_('./debug'); +exports.log = log; +exports.formatArgs = formatArgs; +exports.save = save; +exports.load = load; +exports.useColors = useColors; +exports.storage = 'undefined' != typeof chrome + && 'undefined' != typeof chrome.storage + ? chrome.storage.local + : localstorage(); + +/** + * Colors. + */ + +exports.colors = [ + 'lightseagreen', + 'forestgreen', + 'goldenrod', + 'dodgerblue', + 'darkorchid', + 'crimson' +]; + +/** + * Currently only WebKit-based Web Inspectors, Firefox >= v31, + * and the Firebug extension (any Firefox version) are known + * to support "%c" CSS customizations. + * + * TODO: add a `localStorage` variable to explicitly enable/disable colors + */ + +function useColors() { + // NB: In an Electron preload script, document will be defined but not fully + // initialized. Since we know we're in Chrome, we'll just detect this case + // explicitly + if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') { + return true; + } + + // is webkit? http://stackoverflow.com/a/16459606/376773 + // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 + return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || + // is firebug? http://stackoverflow.com/a/398120/376773 + (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || + // is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + // double check webkit in userAgent just in case we are in a worker + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); +} + +/** + * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. + */ + +exports.formatters.j = function(v) { + try { + return JSON.stringify(v); + } catch (err) { + return '[UnexpectedJSONParseError]: ' + err.message; + } +}; + + +/** + * Colorize log arguments if enabled. + * + * @api public + */ + +function formatArgs(args) { + var useColors = this.useColors; + + args[0] = (useColors ? '%c' : '') + + this.namespace + + (useColors ? ' %c' : ' ') + + args[0] + + (useColors ? '%c ' : ' ') + + '+' + exports.humanize(this.diff); + + if (!useColors) return; + + var c = 'color: ' + this.color; + args.splice(1, 0, c, 'color: inherit') + + // the final "%c" is somewhat tricky, because there could be other + // arguments passed either before or after the %c, so we need to + // figure out the correct index to insert the CSS into + var index = 0; + var lastC = 0; + args[0].replace(/%[a-zA-Z%]/g, function(match) { + if ('%%' === match) return; + index++; + if ('%c' === match) { + // we only are interested in the *last* %c + // (the user may have provided their own) + lastC = index; + } + }); + + args.splice(lastC, 0, c); +} + +/** + * Invokes `console.log()` when available. + * No-op when `console.log` is not a "function". + * + * @api public + */ + +function log() { + // this hackery is required for IE8/9, where + // the `console.log` function doesn't have 'apply' + return 'object' === typeof console + && console.log + && Function.prototype.apply.call(console.log, console, arguments); +} + +/** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ + +function save(namespaces) { + try { + if (null == namespaces) { + exports.storage.removeItem('debug'); + } else { + exports.storage.debug = namespaces; + } + } catch(e) {} +} + +/** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ + +function load() { + var r; + try { + r = exports.storage.debug; + } catch(e) {} + + // If debug isn't set in LS, and we're in Electron, try to load $DEBUG + if (!r && typeof process !== 'undefined' && 'env' in process) { + r = process.env.DEBUG; + } + + return r; +} + +/** + * Enable namespaces listed in `localStorage.debug` initially. + */ + +exports.enable(load()); + +/** + * Localstorage attempts to return the localstorage. + * + * This is necessary because safari throws + * when a user disables cookies/localstorage + * and you attempt to access it. + * + * @return {LocalStorage} + * @api private + */ + +function localstorage() { + try { + return window.localStorage; + } catch (e) {} +} + +}).call(this)}).call(this,_dereq_('_process')) +},{"./debug":116,"_process":96}],116:[function(_dereq_,module,exports){ + +/** + * This is the common logic for both the Node.js and web browser + * implementations of `debug()`. + * + * Expose `debug()` as the module. + */ + +exports = module.exports = createDebug.debug = createDebug['default'] = createDebug; +exports.coerce = coerce; +exports.disable = disable; +exports.enable = enable; +exports.enabled = enabled; +exports.humanize = _dereq_('ms'); + +/** + * The currently active debug mode names, and names to skip. + */ + +exports.names = []; +exports.skips = []; + +/** + * Map of special "%n" handling functions, for the debug "format" argument. + * + * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". + */ + +exports.formatters = {}; + +/** + * Previous log timestamp. + */ + +var prevTime; + +/** + * Select a color. + * @param {String} namespace + * @return {Number} + * @api private + */ + +function selectColor(namespace) { + var hash = 0, i; + + for (i in namespace) { + hash = ((hash << 5) - hash) + namespace.charCodeAt(i); + hash |= 0; // Convert to 32bit integer + } + + return exports.colors[Math.abs(hash) % exports.colors.length]; +} + +/** + * Create a debugger with the given `namespace`. + * + * @param {String} namespace + * @return {Function} + * @api public + */ + +function createDebug(namespace) { + + function debug() { + // disabled? + if (!debug.enabled) return; + + var self = debug; + + // set `diff` timestamp + var curr = +new Date(); + var ms = curr - (prevTime || curr); + self.diff = ms; + self.prev = prevTime; + self.curr = curr; + prevTime = curr; + + // turn the `arguments` into a proper Array + var args = new Array(arguments.length); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i]; + } + + args[0] = exports.coerce(args[0]); + + if ('string' !== typeof args[0]) { + // anything else let's inspect with %O + args.unshift('%O'); + } + + // apply any `formatters` transformations + var index = 0; + args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { + // if we encounter an escaped % then don't increase the array index + if (match === '%%') return match; + index++; + var formatter = exports.formatters[format]; + if ('function' === typeof formatter) { + var val = args[index]; + match = formatter.call(self, val); + + // now we need to remove `args[index]` since it's inlined in the `format` + args.splice(index, 1); + index--; + } + return match; + }); + + // apply env-specific formatting (colors, etc.) + exports.formatArgs.call(self, args); + + var logFn = debug.log || exports.log || console.log.bind(console); + logFn.apply(self, args); + } + + debug.namespace = namespace; + debug.enabled = exports.enabled(namespace); + debug.useColors = exports.useColors(); + debug.color = selectColor(namespace); + + // env-specific initialization logic for debug instances + if ('function' === typeof exports.init) { + exports.init(debug); + } + + return debug; +} + +/** + * Enables a debug mode by namespaces. This can include modes + * separated by a colon and wildcards. + * + * @param {String} namespaces + * @api public + */ + +function enable(namespaces) { + exports.save(namespaces); + + exports.names = []; + exports.skips = []; + + var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); + var len = split.length; + + for (var i = 0; i < len; i++) { + if (!split[i]) continue; // ignore empty strings + namespaces = split[i].replace(/\*/g, '.*?'); + if (namespaces[0] === '-') { + exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); + } else { + exports.names.push(new RegExp('^' + namespaces + '$')); + } + } +} + +/** + * Disable debug output. + * + * @api public + */ + +function disable() { + exports.enable(''); +} + +/** + * Returns true if the given mode name is enabled, false otherwise. + * + * @param {String} name + * @return {Boolean} + * @api public + */ + +function enabled(name) { + var i, len; + for (i = 0, len = exports.skips.length; i < len; i++) { + if (exports.skips[i].test(name)) { + return false; + } + } + for (i = 0, len = exports.names.length; i < len; i++) { + if (exports.names[i].test(name)) { + return true; + } + } + return false; +} + +/** + * Coerce `val`. + * + * @param {Mixed} val + * @return {Mixed} + * @api private + */ + +function coerce(val) { + if (val instanceof Error) return val.stack || val.message; + return val; +} + +},{"ms":117}],117:[function(_dereq_,module,exports){ +/** + * Helpers. + */ + +var s = 1000; +var m = s * 60; +var h = m * 60; +var d = h * 24; +var y = d * 365.25; + +/** + * Parse or format the given `val`. + * + * Options: + * + * - `long` verbose formatting [false] + * + * @param {String|Number} val + * @param {Object} [options] + * @throws {Error} throw an error if val is not a non-empty string or a number + * @return {String|Number} + * @api public + */ + +module.exports = function(val, options) { + options = options || {}; + var type = typeof val; + if (type === 'string' && val.length > 0) { + return parse(val); + } else if (type === 'number' && isNaN(val) === false) { + return options.long ? fmtLong(val) : fmtShort(val); + } + throw new Error( + 'val is not a non-empty string or a valid number. val=' + + JSON.stringify(val) + ); +}; + +/** + * Parse the given `str` and return milliseconds. + * + * @param {String} str + * @return {Number} + * @api private + */ + +function parse(str) { + str = String(str); + if (str.length > 100) { + return; + } + var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec( + str + ); + if (!match) { + return; + } + var n = parseFloat(match[1]); + var type = (match[2] || 'ms').toLowerCase(); + switch (type) { + case 'years': + case 'year': + case 'yrs': + case 'yr': + case 'y': + return n * y; + case 'days': + case 'day': + case 'd': + return n * d; + case 'hours': + case 'hour': + case 'hrs': + case 'hr': + case 'h': + return n * h; + case 'minutes': + case 'minute': + case 'mins': + case 'min': + case 'm': + return n * m; + case 'seconds': + case 'second': + case 'secs': + case 'sec': + case 's': + return n * s; + case 'milliseconds': + case 'millisecond': + case 'msecs': + case 'msec': + case 'ms': + return n; + default: + return undefined; + } +} + +/** + * Short format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + +function fmtShort(ms) { + if (ms >= d) { + return Math.round(ms / d) + 'd'; + } + if (ms >= h) { + return Math.round(ms / h) + 'h'; + } + if (ms >= m) { + return Math.round(ms / m) + 'm'; + } + if (ms >= s) { + return Math.round(ms / s) + 's'; + } + return ms + 'ms'; +} + +/** + * Long format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + +function fmtLong(ms) { + return plural(ms, d, 'day') || + plural(ms, h, 'hour') || + plural(ms, m, 'minute') || + plural(ms, s, 'second') || + ms + ' ms'; +} + +/** + * Pluralization helper. + */ + +function plural(ms, n, name) { + if (ms < n) { + return; + } + if (ms < n * 1.5) { + return Math.floor(ms / n) + ' ' + name; + } + return Math.ceil(ms / n) + ' ' + name + 's'; +} + +},{}],118:[function(_dereq_,module,exports){ +(function (setImmediate,clearImmediate){(function (){ +var nextTick = _dereq_('process/browser.js').nextTick; +var apply = Function.prototype.apply; +var slice = Array.prototype.slice; +var immediateIds = {}; +var nextImmediateId = 0; + +// DOM APIs, for completeness + +exports.setTimeout = function() { + return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout); +}; +exports.setInterval = function() { + return new Timeout(apply.call(setInterval, window, arguments), clearInterval); +}; +exports.clearTimeout = +exports.clearInterval = function(timeout) { timeout.close(); }; + +function Timeout(id, clearFn) { + this._id = id; + this._clearFn = clearFn; +} +Timeout.prototype.unref = Timeout.prototype.ref = function() {}; +Timeout.prototype.close = function() { + this._clearFn.call(window, this._id); +}; + +// Does not start the time, just sets up the members needed. +exports.enroll = function(item, msecs) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = msecs; +}; + +exports.unenroll = function(item) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = -1; +}; + +exports._unrefActive = exports.active = function(item) { + clearTimeout(item._idleTimeoutId); + + var msecs = item._idleTimeout; + if (msecs >= 0) { + item._idleTimeoutId = setTimeout(function onTimeout() { + if (item._onTimeout) + item._onTimeout(); + }, msecs); + } +}; + +// That's not how node.js implements it but the exposed api is the same. +exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) { + var id = nextImmediateId++; + var args = arguments.length < 2 ? false : slice.call(arguments, 1); + + immediateIds[id] = true; + + nextTick(function onNextTick() { + if (immediateIds[id]) { + // fn.call() is faster so we optimize for the common use-case + // @see http://jsperf.com/call-apply-segu + if (args) { + fn.apply(null, args); + } else { + fn.call(null); + } + // Prevent ids from leaking + exports.clearImmediate(id); + } + }); + + return id; +}; + +exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) { + delete immediateIds[id]; +}; +}).call(this)}).call(this,_dereq_("timers").setImmediate,_dereq_("timers").clearImmediate) +},{"process/browser.js":96,"timers":118}],119:[function(_dereq_,module,exports){ // TinyColor v1.4.2 // https://github.com/bgrins/TinyColor // Brian Grinstead, MIT License @@ -20541,15 +25333,5277 @@ else { })(Math); -},{}],89:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +},{}],120:[function(_dereq_,module,exports){ +(function (global){(function (){ +/** + * Module exports. + */ + +module.exports = deprecate; + +/** + * Mark that a method should not be used. + * Returns a modified function which warns once by default. + * + * If `localStorage.noDeprecation = true` is set, then it is a no-op. + * + * If `localStorage.throwDeprecation = true` is set, then deprecated functions + * will throw an Error when invoked. + * + * If `localStorage.traceDeprecation = true` is set, then deprecated functions + * will invoke `console.trace()` instead of `console.error()`. + * + * @param {Function} fn - the function to deprecate + * @param {String} msg - the string to print to the console when `fn` is invoked + * @returns {Function} a new "deprecated" version of `fn` + * @api public + */ + +function deprecate (fn, msg) { + if (config('noDeprecation')) { + return fn; + } + + var warned = false; + function deprecated() { + if (!warned) { + if (config('throwDeprecation')) { + throw new Error(msg); + } else if (config('traceDeprecation')) { + console.trace(msg); + } else { + console.warn(msg); + } + warned = true; + } + return fn.apply(this, arguments); + } + + return deprecated; +} + +/** + * Checks `localStorage` for boolean values for the given `name`. + * + * @param {String} name + * @returns {Boolean} + * @api private + */ + +function config (name) { + // accessing global.localStorage can trigger a DOMException in sandboxed iframes + try { + if (!global.localStorage) return false; + } catch (_) { + return false; + } + var val = global.localStorage[name]; + if (null == val) return false; + return String(val).toLowerCase() === 'true'; +} + +}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],121:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Traditional Chinese calendar for jQuery v2.0.2. + Written by Nicolas Riesco (enquiries@nicolasriesco.net) December 2016. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +var gregorianCalendar = main.instance(); + +/** Implementation of the traditional Chinese calendar. + Source of calendar tables https://github.com/isee15/Lunar-Solar-Calendar-Converter . + @class ChineseCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function ChineseCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +ChineseCalendar.prototype = new main.baseCalendar; + +assign(ChineseCalendar.prototype, { + /** The calendar name. + @memberof ChineseCalendar */ + name: 'Chinese', + /** Julian date of start of Gregorian epoch: 1 January 0001 CE. + @memberof GregorianCalendar */ + jdEpoch: 1721425.5, + /** true if has a year zero, false if not. + @memberof ChineseCalendar */ + hasYearZero: false, + /** The minimum month number. + This calendar uses month indices to account for intercalary months. + @memberof ChineseCalendar */ + minMonth: 0, + /** The first month in the year. + This calendar uses month indices to account for intercalary months. + @memberof ChineseCalendar */ + firstMonth: 0, + /** The minimum day number. + @memberof ChineseCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof ChineseCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Chinese', + epochs: ['BEC', 'EC'], + monthNumbers: function(date, padded) { + if (typeof date === 'string') { + var match = date.match(MONTH_NUMBER_REGEXP); + return (match) ? match[0] : ''; + } + + var year = this._validateYear(date); + var monthIndex = date.month(); + + var month = '' + this.toChineseMonth(year, monthIndex); + + if (padded && month.length < 2) { + month = "0" + month; + } + + if (this.isIntercalaryMonth(year, monthIndex)) { + month += 'i'; + } + + return month; + }, + monthNames: function(date) { + if (typeof date === 'string') { + var match = date.match(MONTH_NAME_REGEXP); + return (match) ? match[0] : ''; + } + + var year = this._validateYear(date); + var monthIndex = date.month(); + + var month = this.toChineseMonth(year, monthIndex); + + var monthName = ['一月','二月','三月','四月','五月','六月', + '七月','八月','九月','十月','十一月','十二月'][month - 1]; + + if (this.isIntercalaryMonth(year, monthIndex)) { + monthName = '闰' + monthName; + } + + return monthName; + }, + monthNamesShort: function(date) { + if (typeof date === 'string') { + var match = date.match(MONTH_SHORT_NAME_REGEXP); + return (match) ? match[0] : ''; + } + + var year = this._validateYear(date); + var monthIndex = date.month(); + + var month = this.toChineseMonth(year, monthIndex); + + var monthName = ['一','二','三','四','五','六', + '七','八','九','十','十一','十二'][month - 1]; + + if (this.isIntercalaryMonth(year, monthIndex)) { + monthName = '闰' + monthName; + } + + return monthName; + }, + parseMonth: function(year, monthString) { + year = this._validateYear(year); + var month = parseInt(monthString); + var isIntercalary; + + if (!isNaN(month)) { + var i = monthString[monthString.length - 1]; + isIntercalary = (i === 'i' || i === 'I'); + } else { + if (monthString[0] === '闰') { + isIntercalary = true; + monthString = monthString.substring(1); + } + if (monthString[monthString.length - 1] === '月') { + monthString = monthString.substring(0, monthString.length - 1); + } + month = 1 + + ['一','二','三','四','五','六', + '七','八','九','十','十一','十二'].indexOf(monthString); + } + + var monthIndex = this.toMonthIndex(year, month, isIntercalary); + return monthIndex; + }, + dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], + dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], + dayNamesMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], + digits: null, + dateFormat: 'yyyy/mm/dd', + firstDay: 1, + isRTL: false + } + }, + + /** Check that a candidate date is from the same calendar and is valid. + @memberof BaseCalendar + @private + @param year {CDate|number} The date or the year to validate. + @param error {string} Error message if invalid. + @return {number} The year. + @throws Error if year out of range. */ + _validateYear: function(year, error) { + if (year.year) { + year = year.year(); + } + + if (typeof year !== 'number' || year < 1888 || year > 2111) { + throw error.replace(/\{0\}/, this.local.name); + } + + return year; + }, + + /** Retrieve the month index (i.e. accounting for intercalary months). + @memberof ChineseCalendar + @param year {number} The year. + @param month {number} The month (1 for first month). + @param [isIntercalary=false] {boolean} If month is intercalary. + @return {number} The month index (0 for first month). + @throws Error if an invalid month/year or a different calendar used. */ + toMonthIndex: function(year, month, isIntercalary) { + // compute intercalary month in the year (0 if none) + var intercalaryMonth = this.intercalaryMonth(year); + + // validate month + var invalidIntercalaryMonth = + (isIntercalary && month !== intercalaryMonth); + if (invalidIntercalaryMonth || month < 1 || month > 12) { + throw main.local.invalidMonth + .replace(/\{0\}/, this.local.name); + } + + // compute month index + var monthIndex; + + if (!intercalaryMonth) { + monthIndex = month - 1; + } else if(!isIntercalary && month <= intercalaryMonth) { + monthIndex = month - 1; + } else { + monthIndex = month; + } + + return monthIndex; + }, + + /** Retrieve the month (i.e. accounting for intercalary months). + @memberof ChineseCalendar + @param year {CDate|number} The date or the year to examine. + @param monthIndex {number} The month index (0 for first month). + @return {number} The month (1 for first month). + @throws Error if an invalid month/year or a different calendar used. */ + toChineseMonth: function(year, monthIndex) { + if (year.year) { + year = year.year(); + monthIndex = year.month(); + } + + // compute intercalary month in the year (0 if none) + var intercalaryMonth = this.intercalaryMonth(year); + + // validate month + var maxMonthIndex = (intercalaryMonth) ? 12 : 11; + if (monthIndex < 0 || monthIndex > maxMonthIndex) { + throw main.local.invalidMonth + .replace(/\{0\}/, this.local.name); + } + + // compute Chinese month + var month; + + if (!intercalaryMonth) { + month = monthIndex + 1; + } else if(monthIndex < intercalaryMonth) { + month = monthIndex + 1; + } else { + month = monthIndex; + } + + return month; + }, + + /** Determine the intercalary month of a year (if any). + @memberof ChineseCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The intercalary month number, or 0 if none. + @throws Error if an invalid year or a different calendar used. */ + intercalaryMonth: function(year) { + year = this._validateYear(year); + + var monthDaysTable = LUNAR_MONTH_DAYS[year - LUNAR_MONTH_DAYS[0]]; + var intercalaryMonth = monthDaysTable >> 13; + + return intercalaryMonth; + }, + + /** Determine whether this date is an intercalary month. + @memberof ChineseCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [monthIndex] {number} The month index to examine. + @return {boolean} true if this is an intercalary month, false if not. + @throws Error if an invalid year or a different calendar used. */ + isIntercalaryMonth: function(year, monthIndex) { + if (year.year) { + year = year.year(); + monthIndex = year.month(); + } + + var intercalaryMonth = this.intercalaryMonth(year); + + return !!intercalaryMonth && intercalaryMonth === monthIndex; + }, + + /** Determine whether this date is in a leap year. + @memberof ChineseCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + return (this.intercalaryMonth(year) !== 0); + }, + + /** Determine the week of the year for a date - ISO 8601. + @memberof ChineseCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [monthIndex] {number} The month index to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, monthIndex, day) { + // compute Chinese new year + var validatedYear = + this._validateYear(year, main.local.invalidyear); + var packedDate = + CHINESE_NEW_YEAR[validatedYear - CHINESE_NEW_YEAR[0]]; + + var y = (packedDate >> 9) & 0xFFF; + var m = (packedDate >> 5) & 0x0F; + var d = packedDate & 0x1F; + + // find first Thrusday of the year + var firstThursday; + firstThursday = gregorianCalendar.newDate(y, m, d); + firstThursday.add(4 - (firstThursday.dayOfWeek() || 7), 'd'); + + // compute days from first Thursday + var offset = + this.toJD(year, monthIndex, day) - firstThursday.toJD(); + return 1 + Math.floor(offset / 7); + }, + + /** Retrieve the number of months in a year. + @memberof ChineseCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of months. + @throws Error if an invalid year or a different calendar used. */ + monthsInYear: function(year) { + return (this.leapYear(year)) ? 13 : 12; + }, + + /** Retrieve the number of days in a month. + @memberof ChineseCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [monthIndex] {number} The month index. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, monthIndex) { + if (year.year) { + monthIndex = year.month(); + year = year.year(); + } + + year = this._validateYear(year); + + var monthDaysTable = LUNAR_MONTH_DAYS[year - LUNAR_MONTH_DAYS[0]]; + + var intercalaryMonth = monthDaysTable >> 13; + var maxMonthIndex = (intercalaryMonth) ? 12 : 11; + if (monthIndex > maxMonthIndex) { + throw main.local.invalidMonth + .replace(/\{0\}/, this.local.name); + } + + var daysInMonth = (monthDaysTable & (1 << (12 - monthIndex))) ? + 30 : 29; + + return daysInMonth; + }, + + /** Determine whether this date is a week day. + @memberof ChineseCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [monthIndex] {number} The month index to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, monthIndex, day) { + return (this.dayOfWeek(year, monthIndex, day) || 7) < 6; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof ChineseCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [monthIndex] {number} The month index to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, monthIndex, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + year = this._validateYear(date.year()); + monthIndex = date.month(); + day = date.day(); + + var isIntercalary = this.isIntercalaryMonth(year, monthIndex); + var month = this.toChineseMonth(year, monthIndex); + + var solar = toSolar(year, month, day, isIntercalary); + + return gregorianCalendar.toJD(solar.year, solar.month, solar.day); + }, + + /** Create a new date from a Julian date. + @memberof ChineseCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + var date = gregorianCalendar.fromJD(jd); + var lunar = toLunar(date.year(), date.month(), date.day()); + var monthIndex = this.toMonthIndex( + lunar.year, lunar.month, lunar.isIntercalary); + return this.newDate(lunar.year, monthIndex, lunar.day); + }, + + /** Create a new date from a string. + @memberof ChineseCalendar + @param dateString {string} String representing a Chinese date + @return {CDate} The new date. + @throws Error if an invalid date. */ + fromString: function(dateString) { + var match = dateString.match(DATE_REGEXP); + + var year = this._validateYear(+match[1]); + + var month = +match[2]; + var isIntercalary = !!match[3]; + var monthIndex = this.toMonthIndex(year, month, isIntercalary); + + var day = +match[4]; + + return this.newDate(year, monthIndex, day); + }, + + /** Add period(s) to a date. + Cater for no year zero. + @memberof ChineseCalendar + @param date {CDate} The starting date. + @param offset {number} The number of periods to adjust by. + @param period {string} One of 'y' for year, 'm' for month, 'w' for week, 'd' for day. + @return {CDate} The updated date. + @throws Error if a different calendar used. */ + add: function(date, offset, period) { + var year = date.year(); + var monthIndex = date.month(); + var isIntercalary = this.isIntercalaryMonth(year, monthIndex); + var month = this.toChineseMonth(year, monthIndex); + + var cdate = Object.getPrototypeOf(ChineseCalendar.prototype) + .add.call(this, date, offset, period); + + if (period === 'y') { + // Resync month + var resultYear = cdate.year(); + var resultMonthIndex = cdate.month(); + + // Using the fact the month index of an intercalary month + // equals its month number: + var resultCanBeIntercalaryMonth = + this.isIntercalaryMonth(resultYear, month); + + var correctedMonthIndex = + (isIntercalary && resultCanBeIntercalaryMonth) ? + this.toMonthIndex(resultYear, month, true) : + this.toMonthIndex(resultYear, month, false); + + if (correctedMonthIndex !== resultMonthIndex) { + cdate.month(correctedMonthIndex); + } + } + + return cdate; + }, +}); + +// Used by ChineseCalendar.prototype.fromString +var DATE_REGEXP = /^\s*(-?\d\d\d\d|\d\d)[-/](\d?\d)([iI]?)[-/](\d?\d)/m; +var MONTH_NUMBER_REGEXP = /^\d?\d[iI]?/m; +var MONTH_NAME_REGEXP = /^闰?十?[一二三四五六七八九]?月/m; +var MONTH_SHORT_NAME_REGEXP = /^闰?十?[一二三四五六七八九]?/m; + +// Chinese calendar implementation +main.calendars.chinese = ChineseCalendar; + +// Chinese calendar tables from year 1888 to 2111 +// +// Source: +// https://github.com/isee15/Lunar-Solar-Calendar-Converter.git + +// Table of intercalary months and days per month from year 1888 to 2111 +// +// bit (12 - i): days in the i^th month +// (= 0 if i^th lunar month has 29 days) +// (= 1 if i^th lunar month has 30 days) +// (first month in lunar year is i = 0) +// bits (13,14,15,16): intercalary month +// (= 0 if lunar year has no intercalary month) +var LUNAR_MONTH_DAYS = [1887, 0x1694, 0x16aa, 0x4ad5, + 0xab6, 0xc4b7, 0x4ae, 0xa56, 0xb52a, 0x1d2a, 0xd54, 0x75aa, 0x156a, + 0x1096d, 0x95c, 0x14ae, 0xaa4d, 0x1a4c, 0x1b2a, 0x8d55, 0xad4, + 0x135a, 0x495d, 0x95c, 0xd49b, 0x149a, 0x1a4a, 0xbaa5, 0x16a8, + 0x1ad4, 0x52da, 0x12b6, 0xe937, 0x92e, 0x1496, 0xb64b, 0xd4a, + 0xda8, 0x95b5, 0x56c, 0x12ae, 0x492f, 0x92e, 0xcc96, 0x1a94, + 0x1d4a, 0xada9, 0xb5a, 0x56c, 0x726e, 0x125c, 0xf92d, 0x192a, + 0x1a94, 0xdb4a, 0x16aa, 0xad4, 0x955b, 0x4ba, 0x125a, 0x592b, + 0x152a, 0xf695, 0xd94, 0x16aa, 0xaab5, 0x9b4, 0x14b6, 0x6a57, + 0xa56, 0x1152a, 0x1d2a, 0xd54, 0xd5aa, 0x156a, 0x96c, 0x94ae, + 0x14ae, 0xa4c, 0x7d26, 0x1b2a, 0xeb55, 0xad4, 0x12da, 0xa95d, + 0x95a, 0x149a, 0x9a4d, 0x1a4a, 0x11aa5, 0x16a8, 0x16d4, 0xd2da, + 0x12b6, 0x936, 0x9497, 0x1496, 0x1564b, 0xd4a, 0xda8, 0xd5b4, + 0x156c, 0x12ae, 0xa92f, 0x92e, 0xc96, 0x6d4a, 0x1d4a, 0x10d65, + 0xb58, 0x156c, 0xb26d, 0x125c, 0x192c, 0x9a95, 0x1a94, 0x1b4a, + 0x4b55, 0xad4, 0xf55b, 0x4ba, 0x125a, 0xb92b, 0x152a, 0x1694, + 0x96aa, 0x15aa, 0x12ab5, 0x974, 0x14b6, 0xca57, 0xa56, 0x1526, + 0x8e95, 0xd54, 0x15aa, 0x49b5, 0x96c, 0xd4ae, 0x149c, 0x1a4c, + 0xbd26, 0x1aa6, 0xb54, 0x6d6a, 0x12da, 0x1695d, 0x95a, 0x149a, + 0xda4b, 0x1a4a, 0x1aa4, 0xbb54, 0x16b4, 0xada, 0x495b, 0x936, + 0xf497, 0x1496, 0x154a, 0xb6a5, 0xda4, 0x15b4, 0x6ab6, 0x126e, + 0x1092f, 0x92e, 0xc96, 0xcd4a, 0x1d4a, 0xd64, 0x956c, 0x155c, + 0x125c, 0x792e, 0x192c, 0xfa95, 0x1a94, 0x1b4a, 0xab55, 0xad4, + 0x14da, 0x8a5d, 0xa5a, 0x1152b, 0x152a, 0x1694, 0xd6aa, 0x15aa, + 0xab4, 0x94ba, 0x14b6, 0xa56, 0x7527, 0xd26, 0xee53, 0xd54, 0x15aa, + 0xa9b5, 0x96c, 0x14ae, 0x8a4e, 0x1a4c, 0x11d26, 0x1aa4, 0x1b54, + 0xcd6a, 0xada, 0x95c, 0x949d, 0x149a, 0x1a2a, 0x5b25, 0x1aa4, + 0xfb52, 0x16b4, 0xaba, 0xa95b, 0x936, 0x1496, 0x9a4b, 0x154a, + 0x136a5, 0xda4, 0x15ac]; + +// Table of Chinese New Years from year 1888 to 2111 +// +// bits (0 to 4): solar day +// bits (5 to 8): solar month +// bits (9 to 20): solar year +var CHINESE_NEW_YEAR = [1887, 0xec04c, 0xec23f, 0xec435, 0xec649, + 0xec83e, 0xeca51, 0xecc46, 0xece3a, 0xed04d, 0xed242, 0xed436, + 0xed64a, 0xed83f, 0xeda53, 0xedc48, 0xede3d, 0xee050, 0xee244, + 0xee439, 0xee64d, 0xee842, 0xeea36, 0xeec4a, 0xeee3e, 0xef052, + 0xef246, 0xef43a, 0xef64e, 0xef843, 0xefa37, 0xefc4b, 0xefe41, + 0xf0054, 0xf0248, 0xf043c, 0xf0650, 0xf0845, 0xf0a38, 0xf0c4d, + 0xf0e42, 0xf1037, 0xf124a, 0xf143e, 0xf1651, 0xf1846, 0xf1a3a, + 0xf1c4e, 0xf1e44, 0xf2038, 0xf224b, 0xf243f, 0xf2653, 0xf2848, + 0xf2a3b, 0xf2c4f, 0xf2e45, 0xf3039, 0xf324d, 0xf3442, 0xf3636, + 0xf384a, 0xf3a3d, 0xf3c51, 0xf3e46, 0xf403b, 0xf424e, 0xf4443, + 0xf4638, 0xf484c, 0xf4a3f, 0xf4c52, 0xf4e48, 0xf503c, 0xf524f, + 0xf5445, 0xf5639, 0xf584d, 0xf5a42, 0xf5c35, 0xf5e49, 0xf603e, + 0xf6251, 0xf6446, 0xf663b, 0xf684f, 0xf6a43, 0xf6c37, 0xf6e4b, + 0xf703f, 0xf7252, 0xf7447, 0xf763c, 0xf7850, 0xf7a45, 0xf7c39, + 0xf7e4d, 0xf8042, 0xf8254, 0xf8449, 0xf863d, 0xf8851, 0xf8a46, + 0xf8c3b, 0xf8e4f, 0xf9044, 0xf9237, 0xf944a, 0xf963f, 0xf9853, + 0xf9a47, 0xf9c3c, 0xf9e50, 0xfa045, 0xfa238, 0xfa44c, 0xfa641, + 0xfa836, 0xfaa49, 0xfac3d, 0xfae52, 0xfb047, 0xfb23a, 0xfb44e, + 0xfb643, 0xfb837, 0xfba4a, 0xfbc3f, 0xfbe53, 0xfc048, 0xfc23c, + 0xfc450, 0xfc645, 0xfc839, 0xfca4c, 0xfcc41, 0xfce36, 0xfd04a, + 0xfd23d, 0xfd451, 0xfd646, 0xfd83a, 0xfda4d, 0xfdc43, 0xfde37, + 0xfe04b, 0xfe23f, 0xfe453, 0xfe648, 0xfe83c, 0xfea4f, 0xfec44, + 0xfee38, 0xff04c, 0xff241, 0xff436, 0xff64a, 0xff83e, 0xffa51, + 0xffc46, 0xffe3a, 0x10004e, 0x100242, 0x100437, 0x10064b, 0x100841, + 0x100a53, 0x100c48, 0x100e3c, 0x10104f, 0x101244, 0x101438, + 0x10164c, 0x101842, 0x101a35, 0x101c49, 0x101e3d, 0x102051, + 0x102245, 0x10243a, 0x10264e, 0x102843, 0x102a37, 0x102c4b, + 0x102e3f, 0x103053, 0x103247, 0x10343b, 0x10364f, 0x103845, + 0x103a38, 0x103c4c, 0x103e42, 0x104036, 0x104249, 0x10443d, + 0x104651, 0x104846, 0x104a3a, 0x104c4e, 0x104e43, 0x105038, + 0x10524a, 0x10543e, 0x105652, 0x105847, 0x105a3b, 0x105c4f, + 0x105e45, 0x106039, 0x10624c, 0x106441, 0x106635, 0x106849, + 0x106a3d, 0x106c51, 0x106e47, 0x10703c, 0x10724f, 0x107444, + 0x107638, 0x10784c, 0x107a3f, 0x107c53, 0x107e48]; + +function toLunar(yearOrDate, monthOrResult, day, result) { + var solarDate; + var lunarDate; + + if(typeof yearOrDate === 'object') { + solarDate = yearOrDate; + lunarDate = monthOrResult || {}; + + } else { + var isValidYear = (typeof yearOrDate === 'number') && + (yearOrDate >= 1888) && (yearOrDate <= 2111); + if(!isValidYear) + throw new Error("Solar year outside range 1888-2111"); + + var isValidMonth = (typeof monthOrResult === 'number') && + (monthOrResult >= 1) && (monthOrResult <= 12); + if(!isValidMonth) + throw new Error("Solar month outside range 1 - 12"); + + var isValidDay = (typeof day === 'number') && (day >= 1) && (day <= 31); + if(!isValidDay) + throw new Error("Solar day outside range 1 - 31"); + + solarDate = { + year: yearOrDate, + month: monthOrResult, + day: day, + }; + lunarDate = result || {}; + } + + // Compute Chinese new year and lunar year + var chineseNewYearPackedDate = + CHINESE_NEW_YEAR[solarDate.year - CHINESE_NEW_YEAR[0]]; + + var packedDate = (solarDate.year << 9) | (solarDate.month << 5) + | solarDate.day; + + lunarDate.year = (packedDate >= chineseNewYearPackedDate) ? + solarDate.year : + solarDate.year - 1; + + chineseNewYearPackedDate = + CHINESE_NEW_YEAR[lunarDate.year - CHINESE_NEW_YEAR[0]]; + + var y = (chineseNewYearPackedDate >> 9) & 0xFFF; + var m = (chineseNewYearPackedDate >> 5) & 0x0F; + var d = chineseNewYearPackedDate & 0x1F; + + // Compute days from new year + var daysFromNewYear; + + var chineseNewYearJSDate = new Date(y, m -1, d); + var jsDate = new Date(solarDate.year, solarDate.month - 1, solarDate.day); + + daysFromNewYear = Math.round( + (jsDate - chineseNewYearJSDate) / (24 * 3600 * 1000)); + + // Compute lunar month and day + var monthDaysTable = LUNAR_MONTH_DAYS[lunarDate.year - LUNAR_MONTH_DAYS[0]]; + + var i; + for(i = 0; i < 13; i++) { + var daysInMonth = (monthDaysTable & (1 << (12 - i))) ? 30 : 29; + + if (daysFromNewYear < daysInMonth) { + break; + } + + daysFromNewYear -= daysInMonth; + } + + var intercalaryMonth = monthDaysTable >> 13; + if (!intercalaryMonth || i < intercalaryMonth) { + lunarDate.isIntercalary = false; + lunarDate.month = 1 + i; + } else if (i === intercalaryMonth) { + lunarDate.isIntercalary = true; + lunarDate.month = i; + } else { + lunarDate.isIntercalary = false; + lunarDate.month = i; + } + + lunarDate.day = 1 + daysFromNewYear; + + return lunarDate; +} + +function toSolar(yearOrDate, monthOrResult, day, isIntercalaryOrResult, result) { + var solarDate; + var lunarDate; + + if(typeof yearOrDate === 'object') { + lunarDate = yearOrDate; + solarDate = monthOrResult || {}; + + } else { + var isValidYear = (typeof yearOrDate === 'number') && + (yearOrDate >= 1888) && (yearOrDate <= 2111); + if(!isValidYear) + throw new Error("Lunar year outside range 1888-2111"); + + var isValidMonth = (typeof monthOrResult === 'number') && + (monthOrResult >= 1) && (monthOrResult <= 12); + if(!isValidMonth) + throw new Error("Lunar month outside range 1 - 12"); + + var isValidDay = (typeof day === 'number') && (day >= 1) && (day <= 30); + if(!isValidDay) + throw new Error("Lunar day outside range 1 - 30"); + + var isIntercalary; + if(typeof isIntercalaryOrResult === 'object') { + isIntercalary = false; + solarDate = isIntercalaryOrResult; + } else { + isIntercalary = !!isIntercalaryOrResult; + solarDate = result || {}; + } + + lunarDate = { + year: yearOrDate, + month: monthOrResult, + day: day, + isIntercalary: isIntercalary, + }; + } + + // Compute days from new year + var daysFromNewYear; + + daysFromNewYear = lunarDate.day - 1; + + var monthDaysTable = LUNAR_MONTH_DAYS[lunarDate.year - LUNAR_MONTH_DAYS[0]]; + var intercalaryMonth = monthDaysTable >> 13; + + var monthsFromNewYear; + if (!intercalaryMonth) { + monthsFromNewYear = lunarDate.month - 1; + } else if (lunarDate.month > intercalaryMonth) { + monthsFromNewYear = lunarDate.month; + } else if (lunarDate.isIntercalary) { + monthsFromNewYear = lunarDate.month; + } else { + monthsFromNewYear = lunarDate.month - 1; + } + + for(var i = 0; i < monthsFromNewYear; i++) { + var daysInMonth = (monthDaysTable & (1 << (12 - i))) ? 30 : 29; + daysFromNewYear += daysInMonth; + } + + // Compute Chinese new year + var packedDate = CHINESE_NEW_YEAR[lunarDate.year - CHINESE_NEW_YEAR[0]]; + + var y = (packedDate >> 9) & 0xFFF; + var m = (packedDate >> 5) & 0x0F; + var d = packedDate & 0x1F; + + // Compute solar date + var jsDate = new Date(y, m - 1, d + daysFromNewYear); + + solarDate.year = jsDate.getFullYear(); + solarDate.month = 1 + jsDate.getMonth(); + solarDate.day = jsDate.getDate(); + + return solarDate; +} + + +},{"../main":135,"object-assign":71}],122:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Coptic calendar for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) February 2010. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +/** Implementation of the Coptic calendar. + See http://en.wikipedia.org/wiki/Coptic_calendar. + See also Calendrical Calculations: The Millennium Edition + (http://emr.cs.iit.edu/home/reingold/calendar-book/index.shtml). + @class CopticCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function CopticCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +CopticCalendar.prototype = new main.baseCalendar; + +assign(CopticCalendar.prototype, { + /** The calendar name. + @memberof CopticCalendar */ + name: 'Coptic', + /** Julian date of start of Coptic epoch: 29 August 284 CE (Gregorian). + @memberof CopticCalendar */ + jdEpoch: 1825029.5, + /** Days per month in a common year. + @memberof CopticCalendar */ + daysPerMonth: [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 5], + /** true if has a year zero, false if not. + @memberof CopticCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof CopticCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof CopticCalendar */ + firstMonth: 1, + /** The minimum day number. + @memberof CopticCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof CopticCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Coptic', + epochs: ['BAM', 'AM'], + monthNames: ['Thout', 'Paopi', 'Hathor', 'Koiak', 'Tobi', 'Meshir', + 'Paremhat', 'Paremoude', 'Pashons', 'Paoni', 'Epip', 'Mesori', 'Pi Kogi Enavot'], + monthNamesShort: ['Tho', 'Pao', 'Hath', 'Koi', 'Tob', 'Mesh', + 'Pat', 'Pad', 'Pash', 'Pao', 'Epi', 'Meso', 'PiK'], + dayNames: ['Tkyriaka', 'Pesnau', 'Pshoment', 'Peftoou', 'Ptiou', 'Psoou', 'Psabbaton'], + dayNamesShort: ['Tky', 'Pes', 'Psh', 'Pef', 'Pti', 'Pso', 'Psa'], + dayNamesMin: ['Tk', 'Pes', 'Psh', 'Pef', 'Pt', 'Pso', 'Psa'], + digits: null, + dateFormat: 'dd/mm/yyyy', + firstDay: 0, + isRTL: false + } + }, + + /** Determine whether this date is in a leap year. + @memberof CopticCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + var year = date.year() + (date.year() < 0 ? 1 : 0); // No year zero + return year % 4 === 3 || year % 4 === -1; + }, + + /** Retrieve the number of months in a year. + @memberof CopticCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of months. + @throws Error if an invalid year or a different calendar used. */ + monthsInYear: function(year) { + this._validate(year, this.minMonth, this.minDay, + main.local.invalidYear || main.regionalOptions[''].invalidYear); + return 13; + }, + + /** Determine the week of the year for a date. + @memberof CopticCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number) the month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + // Find Sunday of this week starting on Sunday + var checkDate = this.newDate(year, month, day); + checkDate.add(-checkDate.dayOfWeek(), 'd'); + return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1; + }, + + /** Retrieve the number of days in a month. + @memberof CopticCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + var date = this._validate(year, month, this.minDay, main.local.invalidMonth); + return this.daysPerMonth[date.month() - 1] + + (date.month() === 13 && this.leapYear(date.year()) ? 1 : 0); + }, + + /** Determine whether this date is a week day. + @memberof CopticCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param month {number} The month to examine. + @param day {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + return (this.dayOfWeek(year, month, day) || 7) < 6; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof CopticCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number) the month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + year = date.year(); + if (year < 0) { year++; } // No year zero + return date.day() + (date.month() - 1) * 30 + + (year - 1) * 365 + Math.floor(year / 4) + this.jdEpoch - 1; + }, + + /** Create a new date from a Julian date. + @memberof CopticCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + var c = Math.floor(jd) + 0.5 - this.jdEpoch; + var year = Math.floor((c - Math.floor((c + 366) / 1461)) / 365) + 1; + if (year <= 0) { year--; } // No year zero + c = Math.floor(jd) + 0.5 - this.newDate(year, 1, 1).toJD(); + var month = Math.floor(c / 30) + 1; + var day = c - (month - 1) * 30 + 1; + return this.newDate(year, month, day); + } +}); + +// Coptic calendar implementation +main.calendars.coptic = CopticCalendar; + + +},{"../main":135,"object-assign":71}],123:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Discworld calendar for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) January 2016. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +/** Implementation of the Discworld calendar - Unseen University version. + See also http://wiki.lspace.org/mediawiki/Discworld_calendar + and http://discworld.wikia.com/wiki/Discworld_calendar. + @class DiscworldCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function DiscworldCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +DiscworldCalendar.prototype = new main.baseCalendar; + +assign(DiscworldCalendar.prototype, { + /** The calendar name. + @memberof DiscworldCalendar */ + name: 'Discworld', + /** Julian date of start of Discworld epoch: 1 January 0001 CE. + @memberof DiscworldCalendar */ + jdEpoch: 1721425.5, + /** Days per month in a common year. + @memberof DiscworldCalendar */ + daysPerMonth: [16, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32], + /** true if has a year zero, false if not. + @memberof DiscworldCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof DiscworldCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof DiscworldCalendar */ + firstMonth: 1, + /** The minimum day number. + @memberof DiscworldCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof DiscworldCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Discworld', + epochs: ['BUC', 'UC'], + monthNames: ['Ick', 'Offle', 'February', 'March', 'April', 'May', 'June', + 'Grune', 'August', 'Spune', 'Sektober', 'Ember', 'December'], + monthNamesShort: ['Ick', 'Off', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Gru', 'Aug', 'Spu', 'Sek', 'Emb', 'Dec'], + dayNames: ['Sunday', 'Octeday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], + dayNamesShort: ['Sun', 'Oct', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], + dayNamesMin: ['Su', 'Oc', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], + digits: null, + dateFormat: 'yyyy/mm/dd', + firstDay: 2, + isRTL: false + } + }, + + /** Determine whether this date is in a leap year. + @memberof DiscworldCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + return false; + }, + + /** Retrieve the number of months in a year. + @memberof DiscworldCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of months. + @throws Error if an invalid year or a different calendar used. */ + monthsInYear: function(year) { + this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + return 13; + }, + + /** Retrieve the number of days in a year. + @memberof DiscworldCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of days. + @throws Error if an invalid year or a different calendar used. */ + daysInYear: function(year) { + this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + return 400; + }, + + /** Determine the week of the year for a date. + @memberof DiscworldCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + // Find Sunday of this week starting on Sunday + var checkDate = this.newDate(year, month, day); + checkDate.add(-checkDate.dayOfWeek(), 'd'); + return Math.floor((checkDate.dayOfYear() - 1) / 8) + 1; + }, + + /** Retrieve the number of days in a month. + @memberof DiscworldCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + var date = this._validate(year, month, this.minDay, main.local.invalidMonth); + return this.daysPerMonth[date.month() - 1]; + }, + + /** Retrieve the number of days in a week. + @memberof DiscworldCalendar + @return {number} The number of days. */ + daysInWeek: function() { + return 8; + }, + + /** Retrieve the day of the week for a date. + @memberof DiscworldCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The day of the week: 0 to number of days - 1. + @throws Error if an invalid date or a different calendar used. */ + dayOfWeek: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + return (date.day() + 1) % 8; + }, + + /** Determine whether this date is a week day. + @memberof DiscworldCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + var dow = this.dayOfWeek(year, month, day); + return (dow >= 2 && dow <= 6); + }, + + /** Retrieve additional information about a date. + @memberof DiscworldCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {object} Additional information - contents depends on calendar. + @throws Error if an invalid date or a different calendar used. */ + extraInfo: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + return {century: centuries[Math.floor((date.year() - 1) / 100) + 1] || ''}; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof DiscworldCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + year = date.year() + (date.year() < 0 ? 1 : 0); + month = date.month(); + day = date.day(); + return day + (month > 1 ? 16 : 0) + (month > 2 ? (month - 2) * 32 : 0) + + (year - 1) * 400 + this.jdEpoch - 1; + }, + + /** Create a new date from a Julian date. + @memberof DiscworldCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + jd = Math.floor(jd + 0.5) - Math.floor(this.jdEpoch) - 1; + var year = Math.floor(jd / 400) + 1; + jd -= (year - 1) * 400; + jd += (jd > 15 ? 16 : 0); + var month = Math.floor(jd / 32) + 1; + var day = jd - (month - 1) * 32 + 1; + return this.newDate(year <= 0 ? year - 1 : year, month, day); + } +}); + +// Names of the centuries +var centuries = { + 20: 'Fruitbat', + 21: 'Anchovy' +}; + +// Discworld calendar implementation +main.calendars.discworld = DiscworldCalendar; + + +},{"../main":135,"object-assign":71}],124:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Ethiopian calendar for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) February 2010. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +/** Implementation of the Ethiopian calendar. + See http://en.wikipedia.org/wiki/Ethiopian_calendar. + See also Calendrical Calculations: The Millennium Edition + (http://emr.cs.iit.edu/home/reingold/calendar-book/index.shtml). + @class EthiopianCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function EthiopianCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +EthiopianCalendar.prototype = new main.baseCalendar; + +assign(EthiopianCalendar.prototype, { + /** The calendar name. + @memberof EthiopianCalendar */ + name: 'Ethiopian', + /** Julian date of start of Ethiopian epoch: 27 August 8 CE (Gregorian). + @memberof EthiopianCalendar */ + jdEpoch: 1724220.5, + /** Days per month in a common year. + @memberof EthiopianCalendar */ + daysPerMonth: [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 5], + /** true if has a year zero, false if not. + @memberof EthiopianCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof EthiopianCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof EthiopianCalendar */ + firstMonth: 1, + /** The minimum day number. + @memberof EthiopianCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof EthiopianCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Ethiopian', + epochs: ['BEE', 'EE'], + monthNames: ['Meskerem', 'Tikemet', 'Hidar', 'Tahesas', 'Tir', 'Yekatit', + 'Megabit', 'Miazia', 'Genbot', 'Sene', 'Hamle', 'Nehase', 'Pagume'], + monthNamesShort: ['Mes', 'Tik', 'Hid', 'Tah', 'Tir', 'Yek', + 'Meg', 'Mia', 'Gen', 'Sen', 'Ham', 'Neh', 'Pag'], + dayNames: ['Ehud', 'Segno', 'Maksegno', 'Irob', 'Hamus', 'Arb', 'Kidame'], + dayNamesShort: ['Ehu', 'Seg', 'Mak', 'Iro', 'Ham', 'Arb', 'Kid'], + dayNamesMin: ['Eh', 'Se', 'Ma', 'Ir', 'Ha', 'Ar', 'Ki'], + digits: null, + dateFormat: 'dd/mm/yyyy', + firstDay: 0, + isRTL: false + } + }, + + /** Determine whether this date is in a leap year. + @memberof EthiopianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + var year = date.year() + (date.year() < 0 ? 1 : 0); // No year zero + return year % 4 === 3 || year % 4 === -1; + }, + + /** Retrieve the number of months in a year. + @memberof EthiopianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of months. + @throws Error if an invalid year or a different calendar used. */ + monthsInYear: function(year) { + this._validate(year, this.minMonth, this.minDay, + main.local.invalidYear || main.regionalOptions[''].invalidYear); + return 13; + }, + + /** Determine the week of the year for a date. + @memberof EthiopianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + // Find Sunday of this week starting on Sunday + var checkDate = this.newDate(year, month, day); + checkDate.add(-checkDate.dayOfWeek(), 'd'); + return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1; + }, + + /** Retrieve the number of days in a month. + @memberof EthiopianCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + var date = this._validate(year, month, this.minDay, main.local.invalidMonth); + return this.daysPerMonth[date.month() - 1] + + (date.month() === 13 && this.leapYear(date.year()) ? 1 : 0); + }, + + /** Determine whether this date is a week day. + @memberof EthiopianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + return (this.dayOfWeek(year, month, day) || 7) < 6; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof EthiopianCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + year = date.year(); + if (year < 0) { year++; } // No year zero + return date.day() + (date.month() - 1) * 30 + + (year - 1) * 365 + Math.floor(year / 4) + this.jdEpoch - 1; + }, + + /** Create a new date from a Julian date. + @memberof EthiopianCalendar + @param jd {number} the Julian date to convert. + @return {CDate} the equivalent date. */ + fromJD: function(jd) { + var c = Math.floor(jd) + 0.5 - this.jdEpoch; + var year = Math.floor((c - Math.floor((c + 366) / 1461)) / 365) + 1; + if (year <= 0) { year--; } // No year zero + c = Math.floor(jd) + 0.5 - this.newDate(year, 1, 1).toJD(); + var month = Math.floor(c / 30) + 1; + var day = c - (month - 1) * 30 + 1; + return this.newDate(year, month, day); + } +}); + +// Ethiopian calendar implementation +main.calendars.ethiopian = EthiopianCalendar; + + +},{"../main":135,"object-assign":71}],125:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Hebrew calendar for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) August 2009. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +/** Implementation of the Hebrew civil calendar. + Based on code from http://www.fourmilab.ch/documents/calendar/. + See also http://en.wikipedia.org/wiki/Hebrew_calendar. + @class HebrewCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function HebrewCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +HebrewCalendar.prototype = new main.baseCalendar; + +assign(HebrewCalendar.prototype, { + /** The calendar name. + @memberof HebrewCalendar */ + name: 'Hebrew', + /** Julian date of start of Hebrew epoch: 7 October 3761 BCE. + @memberof HebrewCalendar */ + jdEpoch: 347995.5, + /** Days per month in a common year. + @memberof HebrewCalendar */ + daysPerMonth: [30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 29], + /** true if has a year zero, false if not. + @memberof HebrewCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof HebrewCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof HebrewCalendar */ + firstMonth: 7, + /** The minimum day number. + @memberof HebrewCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof HebrewCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Hebrew', + epochs: ['BAM', 'AM'], + monthNames: ['Nisan', 'Iyar', 'Sivan', 'Tammuz', 'Av', 'Elul', + 'Tishrei', 'Cheshvan', 'Kislev', 'Tevet', 'Shevat', 'Adar', 'Adar II'], + monthNamesShort: ['Nis', 'Iya', 'Siv', 'Tam', 'Av', 'Elu', 'Tis', 'Che', 'Kis', 'Tev', 'She', 'Ada', 'Ad2'], + dayNames: ['Yom Rishon', 'Yom Sheni', 'Yom Shlishi', 'Yom Revi\'i', 'Yom Chamishi', 'Yom Shishi', 'Yom Shabbat'], + dayNamesShort: ['Ris', 'She', 'Shl', 'Rev', 'Cha', 'Shi', 'Sha'], + dayNamesMin: ['Ri','She','Shl','Re','Ch','Shi','Sha'], + digits: null, + dateFormat: 'dd/mm/yyyy', + firstDay: 0, + isRTL: false + } + }, + + /** Determine whether this date is in a leap year. + @memberof HebrewCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + return this._leapYear(date.year()); + }, + + /** Determine whether this date is in a leap year. + @memberof HebrewCalendar + @private + @param year {number} The year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + _leapYear: function(year) { + year = (year < 0 ? year + 1 : year); + return mod(year * 7 + 1, 19) < 7; + }, + + /** Retrieve the number of months in a year. + @memberof HebrewCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of months. + @throws Error if an invalid year or a different calendar used. */ + monthsInYear: function(year) { + this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + return this._leapYear(year.year ? year.year() : year) ? 13 : 12; + }, + + /** Determine the week of the year for a date. + @memberof HebrewCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + // Find Sunday of this week starting on Sunday + var checkDate = this.newDate(year, month, day); + checkDate.add(-checkDate.dayOfWeek(), 'd'); + return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1; + }, + + /** Retrieve the number of days in a year. + @memberof HebrewCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of days. + @throws Error if an invalid year or a different calendar used. */ + daysInYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + year = date.year(); + return this.toJD((year === -1 ? +1 : year + 1), 7, 1) - this.toJD(year, 7, 1); + }, + + /** Retrieve the number of days in a month. + @memberof HebrewCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + if (year.year) { + month = year.month(); + year = year.year(); + } + this._validate(year, month, this.minDay, main.local.invalidMonth); + return (month === 12 && this.leapYear(year) ? 30 : // Adar I + (month === 8 && mod(this.daysInYear(year), 10) === 5 ? 30 : // Cheshvan in shlemah year + (month === 9 && mod(this.daysInYear(year), 10) === 3 ? 29 : // Kislev in chaserah year + this.daysPerMonth[month - 1]))); + }, + + /** Determine whether this date is a week day. + @memberof HebrewCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + return this.dayOfWeek(year, month, day) !== 6; + }, + + /** Retrieve additional information about a date - year type. + @memberof HebrewCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {object} Additional information - contents depends on calendar. + @throws Error if an invalid date or a different calendar used. */ + extraInfo: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + return {yearType: (this.leapYear(date) ? 'embolismic' : 'common') + ' ' + + ['deficient', 'regular', 'complete'][this.daysInYear(date) % 10 - 3]}; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof HebrewCalendar + @param year {CDate)|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + year = date.year(); + month = date.month(); + day = date.day(); + var adjYear = (year <= 0 ? year + 1 : year); + var jd = this.jdEpoch + this._delay1(adjYear) + + this._delay2(adjYear) + day + 1; + if (month < 7) { + for (var m = 7; m <= this.monthsInYear(year); m++) { + jd += this.daysInMonth(year, m); + } + for (var m = 1; m < month; m++) { + jd += this.daysInMonth(year, m); + } + } + else { + for (var m = 7; m < month; m++) { + jd += this.daysInMonth(year, m); + } + } + return jd; + }, + + /** Test for delay of start of new year and to avoid + Sunday, Wednesday, or Friday as start of the new year. + @memberof HebrewCalendar + @private + @param year {number} The year to examine. + @return {number} The days to offset by. */ + _delay1: function(year) { + var months = Math.floor((235 * year - 234) / 19); + var parts = 12084 + 13753 * months; + var day = months * 29 + Math.floor(parts / 25920); + if (mod(3 * (day + 1), 7) < 3) { + day++; + } + return day; + }, + + /** Check for delay in start of new year due to length of adjacent years. + @memberof HebrewCalendar + @private + @param year {number} The year to examine. + @return {number} The days to offset by. */ + _delay2: function(year) { + var last = this._delay1(year - 1); + var present = this._delay1(year); + var next = this._delay1(year + 1); + return ((next - present) === 356 ? 2 : ((present - last) === 382 ? 1 : 0)); + }, + + /** Create a new date from a Julian date. + @memberof HebrewCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + jd = Math.floor(jd) + 0.5; + var year = Math.floor(((jd - this.jdEpoch) * 98496.0) / 35975351.0) - 1; + while (jd >= this.toJD((year === -1 ? +1 : year + 1), 7, 1)) { + year++; + } + var month = (jd < this.toJD(year, 1, 1)) ? 7 : 1; + while (jd > this.toJD(year, month, this.daysInMonth(year, month))) { + month++; + } + var day = jd - this.toJD(year, month, 1) + 1; + return this.newDate(year, month, day); + } +}); + +// Modulus function which works for non-integers. +function mod(a, b) { + return a - (b * Math.floor(a / b)); +} + +// Hebrew calendar implementation +main.calendars.hebrew = HebrewCalendar; + + +},{"../main":135,"object-assign":71}],126:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Islamic calendar for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) August 2009. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +/** Implementation of the Islamic or '16 civil' calendar. + Based on code from http://www.iranchamber.com/calendar/converter/iranian_calendar_converter.php. + See also http://en.wikipedia.org/wiki/Islamic_calendar. + @class IslamicCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function IslamicCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +IslamicCalendar.prototype = new main.baseCalendar; + +assign(IslamicCalendar.prototype, { + /** The calendar name. + @memberof IslamicCalendar */ + name: 'Islamic', + /** Julian date of start of Islamic epoch: 16 July 622 CE. + @memberof IslamicCalendar */ + jdEpoch: 1948439.5, + /** Days per month in a common year. + @memberof IslamicCalendar */ + daysPerMonth: [30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29], + /** true if has a year zero, false if not. + @memberof IslamicCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof IslamicCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof IslamicCalendar */ + firstMonth: 1, + /** The minimum day number. + @memberof IslamicCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof IslamicCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Islamic', + epochs: ['BH', 'AH'], + monthNames: ['Muharram', 'Safar', 'Rabi\' al-awwal', 'Rabi\' al-thani', 'Jumada al-awwal', 'Jumada al-thani', + 'Rajab', 'Sha\'aban', 'Ramadan', 'Shawwal', 'Dhu al-Qi\'dah', 'Dhu al-Hijjah'], + monthNamesShort: ['Muh', 'Saf', 'Rab1', 'Rab2', 'Jum1', 'Jum2', 'Raj', 'Sha\'', 'Ram', 'Shaw', 'DhuQ', 'DhuH'], + dayNames: ['Yawm al-ahad', 'Yawm al-ithnayn', 'Yawm ath-thulaathaa\'', + 'Yawm al-arbi\'aa\'', 'Yawm al-khamīs', 'Yawm al-jum\'a', 'Yawm as-sabt'], + dayNamesShort: ['Aha', 'Ith', 'Thu', 'Arb', 'Kha', 'Jum', 'Sab'], + dayNamesMin: ['Ah','It','Th','Ar','Kh','Ju','Sa'], + digits: null, + dateFormat: 'yyyy/mm/dd', + firstDay: 6, + isRTL: false + } + }, + + /** Determine whether this date is in a leap year. + @memberof IslamicCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + return (date.year() * 11 + 14) % 30 < 11; + }, + + /** Determine the week of the year for a date. + @memberof IslamicCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + // Find Sunday of this week starting on Sunday + var checkDate = this.newDate(year, month, day); + checkDate.add(-checkDate.dayOfWeek(), 'd'); + return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1; + }, + + /** Retrieve the number of days in a year. + @memberof IslamicCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of days. + @throws Error if an invalid year or a different calendar used. */ + daysInYear: function(year) { + return (this.leapYear(year) ? 355 : 354); + }, + + /** Retrieve the number of days in a month. + @memberof IslamicCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + var date = this._validate(year, month, this.minDay, main.local.invalidMonth); + return this.daysPerMonth[date.month() - 1] + + (date.month() === 12 && this.leapYear(date.year()) ? 1 : 0); + }, + + /** Determine whether this date is a week day. + @memberof IslamicCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + return this.dayOfWeek(year, month, day) !== 5; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof IslamicCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + year = date.year(); + month = date.month(); + day = date.day(); + year = (year <= 0 ? year + 1 : year); + return day + Math.ceil(29.5 * (month - 1)) + (year - 1) * 354 + + Math.floor((3 + (11 * year)) / 30) + this.jdEpoch - 1; + }, + + /** Create a new date from a Julian date. + @memberof IslamicCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + jd = Math.floor(jd) + 0.5; + var year = Math.floor((30 * (jd - this.jdEpoch) + 10646) / 10631); + year = (year <= 0 ? year - 1 : year); + var month = Math.min(12, Math.ceil((jd - 29 - this.toJD(year, 1, 1)) / 29.5) + 1); + var day = jd - this.toJD(year, month, 1) + 1; + return this.newDate(year, month, day); + } +}); + +// Islamic (16 civil) calendar implementation +main.calendars.islamic = IslamicCalendar; + + +},{"../main":135,"object-assign":71}],127:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Julian calendar for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) August 2009. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +/** Implementation of the Julian calendar. + Based on code from http://www.fourmilab.ch/documents/calendar/. + See also http://en.wikipedia.org/wiki/Julian_calendar. + @class JulianCalendar + @augments BaseCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function JulianCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +JulianCalendar.prototype = new main.baseCalendar; + +assign(JulianCalendar.prototype, { + /** The calendar name. + @memberof JulianCalendar */ + name: 'Julian', + /** Julian date of start of Julian epoch: 1 January 0001 AD = 30 December 0001 BCE. + @memberof JulianCalendar */ + jdEpoch: 1721423.5, + /** Days per month in a common year. + @memberof JulianCalendar */ + daysPerMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], + /** true if has a year zero, false if not. + @memberof JulianCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof JulianCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof JulianCalendar */ + firstMonth: 1, + /** The minimum day number. + @memberof JulianCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof JulianCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Julian', + epochs: ['BC', 'AD'], + monthNames: ['January', 'February', 'March', 'April', 'May', 'June', + 'July', 'August', 'September', 'October', 'November', 'December'], + monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], + dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], + dayNamesMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], + digits: null, + dateFormat: 'mm/dd/yyyy', + firstDay: 0, + isRTL: false + } + }, + + /** Determine whether this date is in a leap year. + @memberof JulianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + var year = (date.year() < 0 ? date.year() + 1 : date.year()); // No year zero + return (year % 4) === 0; + }, + + /** Determine the week of the year for a date - ISO 8601. + @memberof JulianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + // Find Thursday of this week starting on Monday + var checkDate = this.newDate(year, month, day); + checkDate.add(4 - (checkDate.dayOfWeek() || 7), 'd'); + return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1; + }, + + /** Retrieve the number of days in a month. + @memberof JulianCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + var date = this._validate(year, month, this.minDay, main.local.invalidMonth); + return this.daysPerMonth[date.month() - 1] + + (date.month() === 2 && this.leapYear(date.year()) ? 1 : 0); + }, + + /** Determine whether this date is a week day. + @memberof JulianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} True if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + return (this.dayOfWeek(year, month, day) || 7) < 6; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof JulianCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + year = date.year(); + month = date.month(); + day = date.day(); + if (year < 0) { year++; } // No year zero + // Jean Meeus algorithm, "Astronomical Algorithms", 1991 + if (month <= 2) { + year--; + month += 12; + } + return Math.floor(365.25 * (year + 4716)) + + Math.floor(30.6001 * (month + 1)) + day - 1524.5; + }, + + /** Create a new date from a Julian date. + @memberof JulianCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + // Jean Meeus algorithm, "Astronomical Algorithms", 1991 + var a = Math.floor(jd + 0.5); + var b = a + 1524; + var c = Math.floor((b - 122.1) / 365.25); + var d = Math.floor(365.25 * c); + var e = Math.floor((b - d) / 30.6001); + var month = e - Math.floor(e < 14 ? 1 : 13); + var year = c - Math.floor(month > 2 ? 4716 : 4715); + var day = b - d - Math.floor(30.6001 * e); + if (year <= 0) { year--; } // No year zero + return this.newDate(year, month, day); + } +}); + +// Julian calendar implementation +main.calendars.julian = JulianCalendar; + + +},{"../main":135,"object-assign":71}],128:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Mayan calendar for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) August 2009. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +/** Implementation of the Mayan Long Count calendar. + See also http://en.wikipedia.org/wiki/Mayan_calendar. + @class MayanCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function MayanCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +MayanCalendar.prototype = new main.baseCalendar; + +assign(MayanCalendar.prototype, { + /** The calendar name. + @memberof MayanCalendar */ + name: 'Mayan', + /** Julian date of start of Mayan epoch: 11 August 3114 BCE. + @memberof MayanCalendar */ + jdEpoch: 584282.5, + /** true if has a year zero, false if not. + @memberof MayanCalendar */ + hasYearZero: true, + /** The minimum month number. + @memberof MayanCalendar */ + minMonth: 0, + /** The first month in the year. + @memberof MayanCalendar */ + firstMonth: 0, + /** The minimum day number. + @memberof MayanCalendar */ + minDay: 0, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof MayanCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. + @property haabMonths {string[]} The names of the Haab months. + @property tzolkinMonths {string[]} The names of the Tzolkin months. */ + regionalOptions: { // Localisations + '': { + name: 'Mayan', + epochs: ['', ''], + monthNames: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '10', '11', '12', '13', '14', '15', '16', '17'], + monthNamesShort: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '10', '11', '12', '13', '14', '15', '16', '17'], + dayNames: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '10', '11', '12', '13', '14', '15', '16', '17', '18', '19'], + dayNamesShort: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '10', '11', '12', '13', '14', '15', '16', '17', '18', '19'], + dayNamesMin: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + '10', '11', '12', '13', '14', '15', '16', '17', '18', '19'], + digits: null, + dateFormat: 'YYYY.m.d', + firstDay: 0, + isRTL: false, + haabMonths: ['Pop', 'Uo', 'Zip', 'Zotz', 'Tzec', 'Xul', 'Yaxkin', 'Mol', 'Chen', 'Yax', + 'Zac', 'Ceh', 'Mac', 'Kankin', 'Muan', 'Pax', 'Kayab', 'Cumku', 'Uayeb'], + tzolkinMonths: ['Imix', 'Ik', 'Akbal', 'Kan', 'Chicchan', 'Cimi', 'Manik', 'Lamat', 'Muluc', 'Oc', + 'Chuen', 'Eb', 'Ben', 'Ix', 'Men', 'Cib', 'Caban', 'Etznab', 'Cauac', 'Ahau'] + } + }, + + /** Determine whether this date is in a leap year. + @memberof MayanCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + return false; + }, + + /** Format the year, if not a simple sequential number. + @memberof MayanCalendar + @param year {CDate|number} The date to format or the year to format. + @return {string} The formatted year. + @throws Error if an invalid year or a different calendar used. */ + formatYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + year = date.year(); + var baktun = Math.floor(year / 400); + year = year % 400; + year += (year < 0 ? 400 : 0); + var katun = Math.floor(year / 20); + return baktun + '.' + katun + '.' + (year % 20); + }, + + /** Convert from the formatted year back to a single number. + @memberof MayanCalendar + @param years {string} The year as n.n.n. + @return {number} The sequential year. + @throws Error if an invalid value is supplied. */ + forYear: function(years) { + years = years.split('.'); + if (years.length < 3) { + throw 'Invalid Mayan year'; + } + var year = 0; + for (var i = 0; i < years.length; i++) { + var y = parseInt(years[i], 10); + if (Math.abs(y) > 19 || (i > 0 && y < 0)) { + throw 'Invalid Mayan year'; + } + year = year * 20 + y; + } + return year; + }, + + /** Retrieve the number of months in a year. + @memberof MayanCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of months. + @throws Error if an invalid year or a different calendar used. */ + monthsInYear: function(year) { + this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + return 18; + }, + + /** Determine the week of the year for a date. + @memberof MayanCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + this._validate(year, month, day, main.local.invalidDate); + return 0; + }, + + /** Retrieve the number of days in a year. + @memberof MayanCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of days. + @throws Error if an invalid year or a different calendar used. */ + daysInYear: function(year) { + this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + return 360; + }, + + /** Retrieve the number of days in a month. + @memberof MayanCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + this._validate(year, month, this.minDay, main.local.invalidMonth); + return 20; + }, + + /** Retrieve the number of days in a week. + @memberof MayanCalendar + @return {number} The number of days. */ + daysInWeek: function() { + return 5; // Just for formatting + }, + + /** Retrieve the day of the week for a date. + @memberof MayanCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The day of the week: 0 to number of days - 1. + @throws Error if an invalid date or a different calendar used. */ + dayOfWeek: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + return date.day(); + }, + + /** Determine whether this date is a week day. + @memberof MayanCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + this._validate(year, month, day, main.local.invalidDate); + return true; + }, + + /** Retrieve additional information about a date - Haab and Tzolkin equivalents. + @memberof MayanCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {object} Additional information - contents depends on calendar. + @throws Error if an invalid date or a different calendar used. */ + extraInfo: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + var jd = date.toJD(); + var haab = this._toHaab(jd); + var tzolkin = this._toTzolkin(jd); + return {haabMonthName: this.local.haabMonths[haab[0] - 1], + haabMonth: haab[0], haabDay: haab[1], + tzolkinDayName: this.local.tzolkinMonths[tzolkin[0] - 1], + tzolkinDay: tzolkin[0], tzolkinTrecena: tzolkin[1]}; + }, + + /** Retrieve Haab date from a Julian date. + @memberof MayanCalendar + @private + @param jd {number} The Julian date. + @return {number[]} Corresponding Haab month and day. */ + _toHaab: function(jd) { + jd -= this.jdEpoch; + var day = mod(jd + 8 + ((18 - 1) * 20), 365); + return [Math.floor(day / 20) + 1, mod(day, 20)]; + }, + + /** Retrieve Tzolkin date from a Julian date. + @memberof MayanCalendar + @private + @param jd {number} The Julian date. + @return {number[]} Corresponding Tzolkin day and trecena. */ + _toTzolkin: function(jd) { + jd -= this.jdEpoch; + return [amod(jd + 20, 20), amod(jd + 4, 13)]; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof MayanCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + return date.day() + (date.month() * 20) + (date.year() * 360) + this.jdEpoch; + }, + + /** Create a new date from a Julian date. + @memberof MayanCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + jd = Math.floor(jd) + 0.5 - this.jdEpoch; + var year = Math.floor(jd / 360); + jd = jd % 360; + jd += (jd < 0 ? 360 : 0); + var month = Math.floor(jd / 20); + var day = jd % 20; + return this.newDate(year, month, day); + } +}); + +// Modulus function which works for non-integers. +function mod(a, b) { + return a - (b * Math.floor(a / b)); +} + +// Modulus function which returns numerator if modulus is zero. +function amod(a, b) { + return mod(a - 1, b) + 1; +} + +// Mayan calendar implementation +main.calendars.mayan = MayanCalendar; + + +},{"../main":135,"object-assign":71}],129:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Nanakshahi calendar for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) January 2016. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +/** Implementation of the Nanakshahi calendar. + See also https://en.wikipedia.org/wiki/Nanakshahi_calendar. + @class NanakshahiCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function NanakshahiCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +NanakshahiCalendar.prototype = new main.baseCalendar; + +var gregorian = main.instance('gregorian'); + +assign(NanakshahiCalendar.prototype, { + /** The calendar name. + @memberof NanakshahiCalendar */ + name: 'Nanakshahi', + /** Julian date of start of Nanakshahi epoch: 14 March 1469 CE. + @memberof NanakshahiCalendar */ + jdEpoch: 2257673.5, + /** Days per month in a common year. + @memberof NanakshahiCalendar */ + daysPerMonth: [31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 30], + /** true if has a year zero, false if not. + @memberof NanakshahiCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof NanakshahiCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof NanakshahiCalendar */ + firstMonth: 1, + /** The minimum day number. + @memberof NanakshahiCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof NanakshahiCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Nanakshahi', + epochs: ['BN', 'AN'], + monthNames: ['Chet', 'Vaisakh', 'Jeth', 'Harh', 'Sawan', 'Bhadon', + 'Assu', 'Katak', 'Maghar', 'Poh', 'Magh', 'Phagun'], + monthNamesShort: ['Che', 'Vai', 'Jet', 'Har', 'Saw', 'Bha', 'Ass', 'Kat', 'Mgr', 'Poh', 'Mgh', 'Pha'], + dayNames: ['Somvaar', 'Mangalvar', 'Budhvaar', 'Veervaar', 'Shukarvaar', 'Sanicharvaar', 'Etvaar'], + dayNamesShort: ['Som', 'Mangal', 'Budh', 'Veer', 'Shukar', 'Sanichar', 'Et'], + dayNamesMin: ['So', 'Ma', 'Bu', 'Ve', 'Sh', 'Sa', 'Et'], + digits: null, + dateFormat: 'dd-mm-yyyy', + firstDay: 0, + isRTL: false + } + }, + + /** Determine whether this date is in a leap year. + @memberof NanakshahiCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, + main.local.invalidYear || main.regionalOptions[''].invalidYear); + return gregorian.leapYear(date.year() + (date.year() < 1 ? 1 : 0) + 1469); + }, + + /** Determine the week of the year for a date. + @memberof NanakshahiCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + // Find Monday of this week starting on Monday + var checkDate = this.newDate(year, month, day); + checkDate.add(1 - (checkDate.dayOfWeek() || 7), 'd'); + return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1; + }, + + /** Retrieve the number of days in a month. + @memberof NanakshahiCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + var date = this._validate(year, month, this.minDay, main.local.invalidMonth); + return this.daysPerMonth[date.month() - 1] + + (date.month() === 12 && this.leapYear(date.year()) ? 1 : 0); + }, + + /** Determine whether this date is a week day. + @memberof NanakshahiCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + return (this.dayOfWeek(year, month, day) || 7) < 6; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof NanakshahiCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidMonth); + var year = date.year(); + if (year < 0) { year++; } // No year zero + var doy = date.day(); + for (var m = 1; m < date.month(); m++) { + doy += this.daysPerMonth[m - 1]; + } + return doy + gregorian.toJD(year + 1468, 3, 13); + }, + + /** Create a new date from a Julian date. + @memberof NanakshahiCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + jd = Math.floor(jd + 0.5); + var year = Math.floor((jd - (this.jdEpoch - 1)) / 366); + while (jd >= this.toJD(year + 1, 1, 1)) { + year++; + } + var day = jd - Math.floor(this.toJD(year, 1, 1) + 0.5) + 1; + var month = 1; + while (day > this.daysInMonth(year, month)) { + day -= this.daysInMonth(year, month); + month++; + } + return this.newDate(year, month, day); + } +}); + +// Nanakshahi calendar implementation +main.calendars.nanakshahi = NanakshahiCalendar; + + +},{"../main":135,"object-assign":71}],130:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Nepali calendar for jQuery v2.0.2. + Written by Artur Neumann (ict.projects{at}nepal.inf.org) April 2013. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +/** Implementation of the Nepali civil calendar. + Based on the ideas from + http://codeissue.com/articles/a04e050dea7468f/algorithm-to-convert-english-date-to-nepali-date-using-c-net + and http://birenj2ee.blogspot.com/2011/04/nepali-calendar-in-java.html + See also http://en.wikipedia.org/wiki/Nepali_calendar + and https://en.wikipedia.org/wiki/Bikram_Samwat. + @class NepaliCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function NepaliCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +NepaliCalendar.prototype = new main.baseCalendar; + +assign(NepaliCalendar.prototype, { + /** The calendar name. + @memberof NepaliCalendar */ + name: 'Nepali', + /** Julian date of start of Nepali epoch: 14 April 57 BCE. + @memberof NepaliCalendar */ + jdEpoch: 1700709.5, + /** Days per month in a common year. + @memberof NepaliCalendar */ + daysPerMonth: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + /** true if has a year zero, false if not. + @memberof NepaliCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof NepaliCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof NepaliCalendar */ + firstMonth: 1, + /** The minimum day number. + @memberof NepaliCalendar */ + minDay: 1, + /** The number of days in the year. + @memberof NepaliCalendar */ + daysPerYear: 365, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof NepaliCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Nepali', + epochs: ['BBS', 'ABS'], + monthNames: ['Baisakh', 'Jestha', 'Ashadh', 'Shrawan', 'Bhadra', 'Ashwin', + 'Kartik', 'Mangsir', 'Paush', 'Mangh', 'Falgun', 'Chaitra'], + monthNamesShort: ['Bai', 'Je', 'As', 'Shra', 'Bha', 'Ash', 'Kar', 'Mang', 'Pau', 'Ma', 'Fal', 'Chai'], + dayNames: ['Aaitabaar', 'Sombaar', 'Manglbaar', 'Budhabaar', 'Bihibaar', 'Shukrabaar', 'Shanibaar'], + dayNamesShort: ['Aaita', 'Som', 'Mangl', 'Budha', 'Bihi', 'Shukra', 'Shani'], + dayNamesMin: ['Aai', 'So', 'Man', 'Bu', 'Bi', 'Shu', 'Sha'], + digits: null, + dateFormat: 'dd/mm/yyyy', + firstDay: 1, + isRTL: false + } + }, + + /** Determine whether this date is in a leap year. + @memberof NepaliCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + return this.daysInYear(year) !== this.daysPerYear; + }, + + /** Determine the week of the year for a date. + @memberof NepaliCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + // Find Sunday of this week starting on Sunday + var checkDate = this.newDate(year, month, day); + checkDate.add(-checkDate.dayOfWeek(), 'd'); + return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1; + }, + + /** Retrieve the number of days in a year. + @memberof NepaliCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of days. + @throws Error if an invalid year or a different calendar used. */ + daysInYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + year = date.year(); + if (typeof this.NEPALI_CALENDAR_DATA[year] === 'undefined') { + return this.daysPerYear; + } + var daysPerYear = 0; + for (var month_number = this.minMonth; month_number <= 12; month_number++) { + daysPerYear += this.NEPALI_CALENDAR_DATA[year][month_number]; + } + return daysPerYear; + }, + + /** Retrieve the number of days in a month. + @memberof NepaliCalendar + @param year {CDate|number| The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + if (year.year) { + month = year.month(); + year = year.year(); + } + this._validate(year, month, this.minDay, main.local.invalidMonth); + return (typeof this.NEPALI_CALENDAR_DATA[year] === 'undefined' ? + this.daysPerMonth[month - 1] : this.NEPALI_CALENDAR_DATA[year][month]); + }, + + /** Determine whether this date is a week day. + @memberof NepaliCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + return this.dayOfWeek(year, month, day) !== 6; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof NepaliCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(nepaliYear, nepaliMonth, nepaliDay) { + var date = this._validate(nepaliYear, nepaliMonth, nepaliDay, main.local.invalidDate); + nepaliYear = date.year(); + nepaliMonth = date.month(); + nepaliDay = date.day(); + var gregorianCalendar = main.instance(); + var gregorianDayOfYear = 0; // We will add all the days that went by since + // the 1st. January and then we can get the Gregorian Date + var nepaliMonthToCheck = nepaliMonth; + var nepaliYearToCheck = nepaliYear; + this._createMissingCalendarData(nepaliYear); + // Get the correct year + var gregorianYear = nepaliYear - (nepaliMonthToCheck > 9 || (nepaliMonthToCheck === 9 && + nepaliDay >= this.NEPALI_CALENDAR_DATA[nepaliYearToCheck][0]) ? 56 : 57); + // First we add the amount of days in the actual Nepali month as the day of year in the + // Gregorian one because at least this days are gone since the 1st. Jan. + if (nepaliMonth !== 9) { + gregorianDayOfYear = nepaliDay; + nepaliMonthToCheck--; + } + // Now we loop throw all Nepali month and add the amount of days to gregorianDayOfYear + // we do this till we reach Paush (9th month). 1st. January always falls in this month + while (nepaliMonthToCheck !== 9) { + if (nepaliMonthToCheck <= 0) { + nepaliMonthToCheck = 12; + nepaliYearToCheck--; + } + gregorianDayOfYear += this.NEPALI_CALENDAR_DATA[nepaliYearToCheck][nepaliMonthToCheck]; + nepaliMonthToCheck--; + } + // If the date that has to be converted is in Paush (month no. 9) we have to do some other calculation + if (nepaliMonth === 9) { + // Add the days that are passed since the first day of Paush and substract the + // amount of days that lie between 1st. Jan and 1st Paush + gregorianDayOfYear += nepaliDay - this.NEPALI_CALENDAR_DATA[nepaliYearToCheck][0]; + // For the first days of Paush we are now in negative values, + // because in the end of the gregorian year we substract + // 365 / 366 days (P.S. remember math in school + - gives -) + if (gregorianDayOfYear < 0) { + gregorianDayOfYear += gregorianCalendar.daysInYear(gregorianYear); + } + } + else { + gregorianDayOfYear += this.NEPALI_CALENDAR_DATA[nepaliYearToCheck][9] - + this.NEPALI_CALENDAR_DATA[nepaliYearToCheck][0]; + } + return gregorianCalendar.newDate(gregorianYear, 1 ,1).add(gregorianDayOfYear, 'd').toJD(); + }, + + /** Create a new date from a Julian date. + @memberof NepaliCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + var gregorianCalendar = main.instance(); + var gregorianDate = gregorianCalendar.fromJD(jd); + var gregorianYear = gregorianDate.year(); + var gregorianDayOfYear = gregorianDate.dayOfYear(); + var nepaliYear = gregorianYear + 56; //this is not final, it could be also +57 but +56 is always true for 1st Jan. + this._createMissingCalendarData(nepaliYear); + var nepaliMonth = 9; // Jan 1 always fall in Nepali month Paush which is the 9th month of Nepali calendar. + // Get the Nepali day in Paush (month 9) of 1st January + var dayOfFirstJanInPaush = this.NEPALI_CALENDAR_DATA[nepaliYear][0]; + // Check how many days are left of Paush . + // Days calculated from 1st Jan till the end of the actual Nepali month, + // we use this value to check if the gregorian Date is in the actual Nepali month. + var daysSinceJanFirstToEndOfNepaliMonth = + this.NEPALI_CALENDAR_DATA[nepaliYear][nepaliMonth] - dayOfFirstJanInPaush + 1; + // If the gregorian day-of-year is smaller o equal than the sum of days between the 1st January and + // the end of the actual nepali month we found the correct nepali month. + // Example: + // The 4th February 2011 is the gregorianDayOfYear 35 (31 days of January + 4) + // 1st January 2011 is in the nepali year 2067, where 1st. January is in the 17th day of Paush (9th month) + // In 2067 Paush has 30days, This means (30-17+1=14) there are 14days between 1st January and end of Paush + // (including 17th January) + // The gregorianDayOfYear (35) is bigger than 14, so we check the next month + // The next nepali month (Mangh) has 29 days + // 29+14=43, this is bigger than gregorianDayOfYear(35) so, we found the correct nepali month + while (gregorianDayOfYear > daysSinceJanFirstToEndOfNepaliMonth) { + nepaliMonth++; + if (nepaliMonth > 12) { + nepaliMonth = 1; + nepaliYear++; + } + daysSinceJanFirstToEndOfNepaliMonth += this.NEPALI_CALENDAR_DATA[nepaliYear][nepaliMonth]; + } + // The last step is to calculate the nepali day-of-month + // to continue our example from before: + // we calculated there are 43 days from 1st. January (17 Paush) till end of Mangh (29 days) + // when we subtract from this 43 days the day-of-year of the the Gregorian date (35), + // we know how far the searched day is away from the end of the Nepali month. + // So we simply subtract this number from the amount of days in this month (30) + var nepaliDayOfMonth = this.NEPALI_CALENDAR_DATA[nepaliYear][nepaliMonth] - + (daysSinceJanFirstToEndOfNepaliMonth - gregorianDayOfYear); + return this.newDate(nepaliYear, nepaliMonth, nepaliDayOfMonth); + }, + + /** Creates missing data in the NEPALI_CALENDAR_DATA table. + This data will not be correct but just give an estimated result. Mostly -/+ 1 day + @private + @param nepaliYear {number} The missing year number. */ + _createMissingCalendarData: function(nepaliYear) { + var tmp_calendar_data = this.daysPerMonth.slice(0); + tmp_calendar_data.unshift(17); + for (var nepaliYearToCreate = (nepaliYear - 1); nepaliYearToCreate < (nepaliYear + 2); nepaliYearToCreate++) { + if (typeof this.NEPALI_CALENDAR_DATA[nepaliYearToCreate] === 'undefined') { + this.NEPALI_CALENDAR_DATA[nepaliYearToCreate] = tmp_calendar_data; + } + } + }, + + NEPALI_CALENDAR_DATA: { + // These data are from http://www.ashesh.com.np + 1970: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 1971: [18, 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30], + 1972: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], + 1973: [19, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + 1974: [19, 31, 31, 32, 30, 31, 31, 30, 29, 30, 29, 30, 30], + 1975: [18, 31, 31, 32, 32, 30, 31, 30, 29, 30, 29, 30, 30], + 1976: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 1977: [18, 31, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31], + 1978: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 1979: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 1980: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 1981: [18, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], + 1982: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 1983: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 1984: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 1985: [18, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], + 1986: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 1987: [18, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 1988: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 1989: [18, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], + 1990: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 1991: [18, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30], + // These data are from http://nepalicalendar.rat32.com/index.php + 1992: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + 1993: [18, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], + 1994: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 1995: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], + 1996: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + 1997: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 1998: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 1999: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2000: [17, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + 2001: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2002: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2003: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2004: [17, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + 2005: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2006: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2007: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2008: [17, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31], + 2009: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2010: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2011: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2012: [17, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], + 2013: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2014: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2015: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2016: [17, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], + 2017: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2018: [18, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2019: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + 2020: [17, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], + 2021: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2022: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], + 2023: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + 2024: [17, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], + 2025: [18, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2026: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2027: [17, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + 2028: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2029: [18, 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30], + 2030: [17, 31, 32, 31, 32, 31, 30, 30, 30, 30, 30, 30, 31], + 2031: [17, 31, 32, 31, 32, 31, 31, 31, 31, 31, 31, 31, 31], + 2032: [17, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32], + 2033: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2034: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2035: [17, 30, 32, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31], + 2036: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2037: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2038: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2039: [17, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], + 2040: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2041: [18, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2042: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2043: [17, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], + 2044: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2045: [18, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2046: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2047: [17, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], + 2048: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2049: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], + 2050: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + 2051: [17, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], + 2052: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2053: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], + 2054: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + 2055: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 30, 29, 30], + 2056: [17, 31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30], + 2057: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2058: [17, 30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + 2059: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2060: [17, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2061: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2062: [17, 30, 32, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31], + 2063: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2064: [17, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2065: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2066: [17, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31], + 2067: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2068: [17, 31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2069: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2070: [17, 31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30], + 2071: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2072: [17, 31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2073: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31], + 2074: [17, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], + 2075: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2076: [16, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], + 2077: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31], + 2078: [17, 31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30], + 2079: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30], + 2080: [16, 31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30], + // These data are from http://www.ashesh.com.np/nepali-calendar/ + 2081: [17, 31, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30], + 2082: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30], + 2083: [17, 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30], + 2084: [17, 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30], + 2085: [17, 31, 32, 31, 32, 31, 31, 30, 30, 29, 30, 30, 30], + 2086: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30], + 2087: [16, 31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30], + 2088: [16, 30, 31, 32, 32, 30, 31, 30, 30, 29, 30, 30, 30], + 2089: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30], + 2090: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30], + 2091: [16, 31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30], + 2092: [16, 31, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30], + 2093: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30], + 2094: [17, 31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30], + 2095: [17, 31, 31, 32, 31, 31, 31, 30, 29, 30, 30, 30, 30], + 2096: [17, 30, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30], + 2097: [17, 31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30], + 2098: [17, 31, 31, 32, 31, 31, 31, 29, 30, 29, 30, 30, 31], + 2099: [17, 31, 31, 32, 31, 31, 31, 30, 29, 29, 30, 30, 30], + 2100: [17, 31, 32, 31, 32, 30, 31, 30, 29, 30, 29, 30, 30] + } +}); + +// Nepali calendar implementation +main.calendars.nepali = NepaliCalendar; + + +},{"../main":135,"object-assign":71}],131:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Persian calendar for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) August 2009. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +/** Implementation of the Persian or Jalali calendar. + Based on code from http://www.iranchamber.com/calendar/converter/iranian_calendar_converter.php. + See also http://en.wikipedia.org/wiki/Iranian_calendar. + @class PersianCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function PersianCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +PersianCalendar.prototype = new main.baseCalendar; + +assign(PersianCalendar.prototype, { + /** The calendar name. + @memberof PersianCalendar */ + name: 'Persian', + /** Julian date of start of Persian epoch: 19 March 622 CE. + @memberof PersianCalendar */ + jdEpoch: 1948320.5, + /** Days per month in a common year. + @memberof PersianCalendar */ + daysPerMonth: [31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29], + /** true if has a year zero, false if not. + @memberof PersianCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof PersianCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof PersianCalendar */ + firstMonth: 1, + /** The minimum day number. + @memberof PersianCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof PersianCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Persian', + epochs: ['BP', 'AP'], + monthNames: ['Farvardin', 'Ordibehesht', 'Khordad', 'Tir', 'Mordad', 'Shahrivar', + 'Mehr', 'Aban', 'Azar', 'Day', 'Bahman', 'Esfand'], + monthNamesShort: ['Far', 'Ord', 'Kho', 'Tir', 'Mor', 'Sha', 'Meh', 'Aba', 'Aza', 'Day', 'Bah', 'Esf'], + dayNames: ['Yekshambe', 'Doshambe', 'Seshambe', 'Chæharshambe', 'Panjshambe', 'Jom\'e', 'Shambe'], + dayNamesShort: ['Yek', 'Do', 'Se', 'Chæ', 'Panj', 'Jom', 'Sha'], + dayNamesMin: ['Ye','Do','Se','Ch','Pa','Jo','Sh'], + digits: null, + dateFormat: 'yyyy/mm/dd', + firstDay: 6, + isRTL: false + } + }, + + /** Determine whether this date is in a leap year. + @memberof PersianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + return (((((date.year() - (date.year() > 0 ? 474 : 473)) % 2820) + + 474 + 38) * 682) % 2816) < 682; + }, + + /** Determine the week of the year for a date. + @memberof PersianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + // Find Saturday of this week starting on Saturday + var checkDate = this.newDate(year, month, day); + checkDate.add(-((checkDate.dayOfWeek() + 1) % 7), 'd'); + return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1; + }, + + /** Retrieve the number of days in a month. + @memberof PersianCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + var date = this._validate(year, month, this.minDay, main.local.invalidMonth); + return this.daysPerMonth[date.month() - 1] + + (date.month() === 12 && this.leapYear(date.year()) ? 1 : 0); + }, + + /** Determine whether this date is a week day. + @memberof PersianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + return this.dayOfWeek(year, month, day) !== 5; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof PersianCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + year = date.year(); + month = date.month(); + day = date.day(); + var epBase = year - (year >= 0 ? 474 : 473); + var epYear = 474 + mod(epBase, 2820); + return day + (month <= 7 ? (month - 1) * 31 : (month - 1) * 30 + 6) + + Math.floor((epYear * 682 - 110) / 2816) + (epYear - 1) * 365 + + Math.floor(epBase / 2820) * 1029983 + this.jdEpoch - 1; + }, + + /** Create a new date from a Julian date. + @memberof PersianCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + jd = Math.floor(jd) + 0.5; + var depoch = jd - this.toJD(475, 1, 1); + var cycle = Math.floor(depoch / 1029983); + var cyear = mod(depoch, 1029983); + var ycycle = 2820; + if (cyear !== 1029982) { + var aux1 = Math.floor(cyear / 366); + var aux2 = mod(cyear, 366); + ycycle = Math.floor(((2134 * aux1) + (2816 * aux2) + 2815) / 1028522) + aux1 + 1; + } + var year = ycycle + (2820 * cycle) + 474; + year = (year <= 0 ? year - 1 : year); + var yday = jd - this.toJD(year, 1, 1) + 1; + var month = (yday <= 186 ? Math.ceil(yday / 31) : Math.ceil((yday - 6) / 30)); + var day = jd - this.toJD(year, month, 1) + 1; + return this.newDate(year, month, day); + } +}); + +// Modulus function which works for non-integers. +function mod(a, b) { + return a - (b * Math.floor(a / b)); +} + +// Persian (Jalali) calendar implementation +main.calendars.persian = PersianCalendar; +main.calendars.jalali = PersianCalendar; + + +},{"../main":135,"object-assign":71}],132:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Taiwanese (Minguo) calendar for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) February 2010. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +var gregorianCalendar = main.instance(); + +/** Implementation of the Taiwanese calendar. + See http://en.wikipedia.org/wiki/Minguo_calendar. + @class TaiwanCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function TaiwanCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +TaiwanCalendar.prototype = new main.baseCalendar; + +assign(TaiwanCalendar.prototype, { + /** The calendar name. + @memberof TaiwanCalendar */ + name: 'Taiwan', + /** Julian date of start of Taiwan epoch: 1 January 1912 CE (Gregorian). + @memberof TaiwanCalendar */ + jdEpoch: 2419402.5, + /** Difference in years between Taiwan and Gregorian calendars. + @memberof TaiwanCalendar */ + yearsOffset: 1911, + /** Days per month in a common year. + @memberof TaiwanCalendar */ + daysPerMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], + /** true if has a year zero, false if not. + @memberof TaiwanCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof TaiwanCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof TaiwanCalendar */ + firstMonth: 1, + /** The minimum day number. + @memberof TaiwanCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof TaiwanCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Taiwan', + epochs: ['BROC', 'ROC'], + monthNames: ['January', 'February', 'March', 'April', 'May', 'June', + 'July', 'August', 'September', 'October', 'November', 'December'], + monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], + dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], + dayNamesMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], + digits: null, + dateFormat: 'yyyy/mm/dd', + firstDay: 1, + isRTL: false + } + }, + + /** Determine whether this date is in a leap year. + @memberof TaiwanCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + var year = this._t2gYear(date.year()); + return gregorianCalendar.leapYear(year); + }, + + /** Determine the week of the year for a date - ISO 8601. + @memberof TaiwanCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + var year = this._t2gYear(date.year()); + return gregorianCalendar.weekOfYear(year, date.month(), date.day()); + }, + + /** Retrieve the number of days in a month. + @memberof TaiwanCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + var date = this._validate(year, month, this.minDay, main.local.invalidMonth); + return this.daysPerMonth[date.month() - 1] + + (date.month() === 2 && this.leapYear(date.year()) ? 1 : 0); + }, + + /** Determine whether this date is a week day. + @memberof TaiwanCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + return (this.dayOfWeek(year, month, day) || 7) < 6; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof TaiwanCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + var year = this._t2gYear(date.year()); + return gregorianCalendar.toJD(year, date.month(), date.day()); + }, + + /** Create a new date from a Julian date. + @memberof TaiwanCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + var date = gregorianCalendar.fromJD(jd); + var year = this._g2tYear(date.year()); + return this.newDate(year, date.month(), date.day()); + }, + + /** Convert Taiwanese to Gregorian year. + @memberof TaiwanCalendar + @private + @param year {number} The Taiwanese year. + @return {number} The corresponding Gregorian year. */ + _t2gYear: function(year) { + return year + this.yearsOffset + (year >= -this.yearsOffset && year <= -1 ? 1 : 0); + }, + + /** Convert Gregorian to Taiwanese year. + @memberof TaiwanCalendar + @private + @param year {number} The Gregorian year. + @return {number} The corresponding Taiwanese year. */ + _g2tYear: function(year) { + return year - this.yearsOffset - (year >= 1 && year <= this.yearsOffset ? 1 : 0); + } +}); + +// Taiwan calendar implementation +main.calendars.taiwan = TaiwanCalendar; + + +},{"../main":135,"object-assign":71}],133:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Thai calendar for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) February 2010. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +var gregorianCalendar = main.instance(); + +/** Implementation of the Thai calendar. + See http://en.wikipedia.org/wiki/Thai_calendar. + @class ThaiCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function ThaiCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +ThaiCalendar.prototype = new main.baseCalendar; + +assign(ThaiCalendar.prototype, { + /** The calendar name. + @memberof ThaiCalendar */ + name: 'Thai', + /** Julian date of start of Thai epoch: 1 January 543 BCE (Gregorian). + @memberof ThaiCalendar */ + jdEpoch: 1523098.5, + /** Difference in years between Thai and Gregorian calendars. + @memberof ThaiCalendar */ + yearsOffset: 543, + /** Days per month in a common year. + @memberof ThaiCalendar */ + daysPerMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], + /** true if has a year zero, false if not. + @memberof ThaiCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof ThaiCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof ThaiCalendar */ + firstMonth: 1, + /** The minimum day number. + @memberof ThaiCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof ThaiCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Thai', + epochs: ['BBE', 'BE'], + monthNames: ['January', 'February', 'March', 'April', 'May', 'June', + 'July', 'August', 'September', 'October', 'November', 'December'], + monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], + dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], + dayNamesMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], + digits: null, + dateFormat: 'dd/mm/yyyy', + firstDay: 0, + isRTL: false + } + }, + + /** Determine whether this date is in a leap year. + @memberof ThaiCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + var year = this._t2gYear(date.year()); + return gregorianCalendar.leapYear(year); + }, + + /** Determine the week of the year for a date - ISO 8601. + @memberof ThaiCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + var year = this._t2gYear(date.year()); + return gregorianCalendar.weekOfYear(year, date.month(), date.day()); + }, + + /** Retrieve the number of days in a month. + @memberof ThaiCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + var date = this._validate(year, month, this.minDay, main.local.invalidMonth); + return this.daysPerMonth[date.month() - 1] + + (date.month() === 2 && this.leapYear(date.year()) ? 1 : 0); + }, + + /** Determine whether this date is a week day. + @memberof ThaiCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + return (this.dayOfWeek(year, month, day) || 7) < 6; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof ThaiCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + var year = this._t2gYear(date.year()); + return gregorianCalendar.toJD(year, date.month(), date.day()); + }, + + /** Create a new date from a Julian date. + @memberof ThaiCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + var date = gregorianCalendar.fromJD(jd); + var year = this._g2tYear(date.year()); + return this.newDate(year, date.month(), date.day()); + }, + + /** Convert Thai to Gregorian year. + @memberof ThaiCalendar + @private + @param year {number} The Thai year. + @return {number} The corresponding Gregorian year. */ + _t2gYear: function(year) { + return year - this.yearsOffset - (year >= 1 && year <= this.yearsOffset ? 1 : 0); + }, + + /** Convert Gregorian to Thai year. + @memberof ThaiCalendar + @private + @param year {number} The Gregorian year. + @return {number} The corresponding Thai year. */ + _g2tYear: function(year) { + return year + this.yearsOffset + (year >= -this.yearsOffset && year <= -1 ? 1 : 0); + } +}); + +// Thai calendar implementation +main.calendars.thai = ThaiCalendar; + + +},{"../main":135,"object-assign":71}],134:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + UmmAlQura calendar for jQuery v2.0.2. + Written by Amro Osama March 2013. + Modified by Binnooh.com & www.elm.sa - 2014 - Added dates back to 1276 Hijri year. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var main = _dereq_('../main'); +var assign = _dereq_('object-assign'); + + +/** Implementation of the UmmAlQura or 'saudi' calendar. + See also http://en.wikipedia.org/wiki/Islamic_calendar#Saudi_Arabia.27s_Umm_al-Qura_calendar. + http://www.ummulqura.org.sa/About.aspx + http://www.staff.science.uu.nl/~gent0113/islam/ummalqura.htm + @class UmmAlQuraCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function UmmAlQuraCalendar(language) { + this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; +} + +UmmAlQuraCalendar.prototype = new main.baseCalendar; + +assign(UmmAlQuraCalendar.prototype, { + /** The calendar name. + @memberof UmmAlQuraCalendar */ + name: 'UmmAlQura', + //jdEpoch: 1948440, // Julian date of start of UmmAlQura epoch: 14 March 1937 CE + //daysPerMonth: // Days per month in a common year, replaced by a method. + /** true if has a year zero, false if not. + @memberof UmmAlQuraCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof UmmAlQuraCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof UmmAlQuraCalendar */ + firstMonth: 1, + /** The minimum day number. + @memberof UmmAlQuraCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof UmmAlQuraCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Umm al-Qura', + epochs: ['BH', 'AH'], + monthNames: ['Al-Muharram', 'Safar', 'Rabi\' al-awwal', 'Rabi\' Al-Thani', 'Jumada Al-Awwal', 'Jumada Al-Thani', + 'Rajab', 'Sha\'aban', 'Ramadan', 'Shawwal', 'Dhu al-Qi\'dah', 'Dhu al-Hijjah'], + monthNamesShort: ['Muh', 'Saf', 'Rab1', 'Rab2', 'Jum1', 'Jum2', 'Raj', 'Sha\'', 'Ram', 'Shaw', 'DhuQ', 'DhuH'], + dayNames: ['Yawm al-Ahad', 'Yawm al-Ithnain', 'Yawm al-Thalāthā’', 'Yawm al-Arba‘ā’', 'Yawm al-Khamīs', 'Yawm al-Jum‘a', 'Yawm al-Sabt'], + dayNamesMin: ['Ah', 'Ith', 'Th', 'Ar', 'Kh', 'Ju', 'Sa'], + digits: null, + dateFormat: 'yyyy/mm/dd', + firstDay: 6, + isRTL: true + } + }, + + /** Determine whether this date is in a leap year. + @memberof UmmAlQuraCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function (year) { + var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); + return (this.daysInYear(date.year()) === 355); + }, + + /** Determine the week of the year for a date. + @memberof UmmAlQuraCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function (year, month, day) { + // Find Sunday of this week starting on Sunday + var checkDate = this.newDate(year, month, day); + checkDate.add(-checkDate.dayOfWeek(), 'd'); + return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1; + }, + + /** Retrieve the number of days in a year. + @memberof UmmAlQuraCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of days. + @throws Error if an invalid year or a different calendar used. */ + daysInYear: function (year) { + var daysCount = 0; + for (var i = 1; i <= 12; i++) { + daysCount += this.daysInMonth(year, i); + } + return daysCount; + }, + + /** Retrieve the number of days in a month. + @memberof UmmAlQuraCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function (year, month) { + var date = this._validate(year, month, this.minDay, main.local.invalidMonth); + var mcjdn = date.toJD() - 2400000 + 0.5; // Modified Chronological Julian Day Number (MCJDN) + // the MCJDN's of the start of the lunations in the Umm al-Qura calendar are stored in the 'ummalqura_dat' array + var index = 0; + for (var i = 0; i < ummalqura_dat.length; i++) { + if (ummalqura_dat[i] > mcjdn) { + return (ummalqura_dat[index] - ummalqura_dat[index - 1]); + } + index++; + } + return 30; // Unknown outside + }, + + /** Determine whether this date is a week day. + @memberof UmmAlQuraCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function (year, month, day) { + return this.dayOfWeek(year, month, day) !== 5; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof UmmAlQuraCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function (year, month, day) { + var date = this._validate(year, month, day, main.local.invalidDate); + var index = (12 * (date.year() - 1)) + date.month() - 15292; + var mcjdn = date.day() + ummalqura_dat[index - 1] - 1; + return mcjdn + 2400000 - 0.5; // Modified Chronological Julian Day Number (MCJDN) + }, + + /** Create a new date from a Julian date. + @memberof UmmAlQuraCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function (jd) { + var mcjdn = jd - 2400000 + 0.5; // Modified Chronological Julian Day Number (MCJDN) + // the MCJDN's of the start of the lunations in the Umm al-Qura calendar + // are stored in the 'ummalqura_dat' array + var index = 0; + for (var i = 0; i < ummalqura_dat.length; i++) { + if (ummalqura_dat[i] > mcjdn) break; + index++; + } + var lunation = index + 15292; //UmmAlQura Lunation Number + var ii = Math.floor((lunation - 1) / 12); + var year = ii + 1; + var month = lunation - 12 * ii; + var day = mcjdn - ummalqura_dat[index - 1] + 1; + return this.newDate(year, month, day); + }, + + /** Determine whether a date is valid for this calendar. + @memberof UmmAlQuraCalendar + @param year {number} The year to examine. + @param month {number} The month to examine. + @param day {number} The day to examine. + @return {boolean} true if a valid date, false if not. */ + isValid: function(year, month, day) { + var valid = main.baseCalendar.prototype.isValid.apply(this, arguments); + if (valid) { + year = (year.year != null ? year.year : year); + valid = (year >= 1276 && year <= 1500); + } + return valid; + }, + + /** Check that a candidate date is from the same calendar and is valid. + @memberof UmmAlQuraCalendar + @private + @param year {CDate|number} The date to validate or the year to validate. + @param month {number} The month to validate. + @param day {number} The day to validate. + @param error {string} Error message if invalid. + @throws Error if different calendars used or invalid date. */ + _validate: function(year, month, day, error) { + var date = main.baseCalendar.prototype._validate.apply(this, arguments); + if (date.year < 1276 || date.year > 1500) { + throw error.replace(/\{0\}/, this.local.name); + } + return date; + } +}); + +// UmmAlQura calendar implementation +main.calendars.ummalqura = UmmAlQuraCalendar; + +var ummalqura_dat = [ + 20, 50, 79, 109, 138, 168, 197, 227, 256, 286, 315, 345, 374, 404, 433, 463, 492, 522, 551, 581, + 611, 641, 670, 700, 729, 759, 788, 818, 847, 877, 906, 936, 965, 995, 1024, 1054, 1083, 1113, 1142, 1172, + 1201, 1231, 1260, 1290, 1320, 1350, 1379, 1409, 1438, 1468, 1497, 1527, 1556, 1586, 1615, 1645, 1674, 1704, 1733, 1763, + 1792, 1822, 1851, 1881, 1910, 1940, 1969, 1999, 2028, 2058, 2087, 2117, 2146, 2176, 2205, 2235, 2264, 2294, 2323, 2353, + 2383, 2413, 2442, 2472, 2501, 2531, 2560, 2590, 2619, 2649, 2678, 2708, 2737, 2767, 2796, 2826, 2855, 2885, 2914, 2944, + 2973, 3003, 3032, 3062, 3091, 3121, 3150, 3180, 3209, 3239, 3268, 3298, 3327, 3357, 3386, 3416, 3446, 3476, 3505, 3535, + 3564, 3594, 3623, 3653, 3682, 3712, 3741, 3771, 3800, 3830, 3859, 3889, 3918, 3948, 3977, 4007, 4036, 4066, 4095, 4125, + 4155, 4185, 4214, 4244, 4273, 4303, 4332, 4362, 4391, 4421, 4450, 4480, 4509, 4539, 4568, 4598, 4627, 4657, 4686, 4716, + 4745, 4775, 4804, 4834, 4863, 4893, 4922, 4952, 4981, 5011, 5040, 5070, 5099, 5129, 5158, 5188, 5218, 5248, 5277, 5307, + 5336, 5366, 5395, 5425, 5454, 5484, 5513, 5543, 5572, 5602, 5631, 5661, 5690, 5720, 5749, 5779, 5808, 5838, 5867, 5897, + 5926, 5956, 5985, 6015, 6044, 6074, 6103, 6133, 6162, 6192, 6221, 6251, 6281, 6311, 6340, 6370, 6399, 6429, 6458, 6488, + 6517, 6547, 6576, 6606, 6635, 6665, 6694, 6724, 6753, 6783, 6812, 6842, 6871, 6901, 6930, 6960, 6989, 7019, 7048, 7078, + 7107, 7137, 7166, 7196, 7225, 7255, 7284, 7314, 7344, 7374, 7403, 7433, 7462, 7492, 7521, 7551, 7580, 7610, 7639, 7669, + 7698, 7728, 7757, 7787, 7816, 7846, 7875, 7905, 7934, 7964, 7993, 8023, 8053, 8083, 8112, 8142, 8171, 8201, 8230, 8260, + 8289, 8319, 8348, 8378, 8407, 8437, 8466, 8496, 8525, 8555, 8584, 8614, 8643, 8673, 8702, 8732, 8761, 8791, 8821, 8850, + 8880, 8909, 8938, 8968, 8997, 9027, 9056, 9086, 9115, 9145, 9175, 9205, 9234, 9264, 9293, 9322, 9352, 9381, 9410, 9440, + 9470, 9499, 9529, 9559, 9589, 9618, 9648, 9677, 9706, 9736, 9765, 9794, 9824, 9853, 9883, 9913, 9943, 9972, 10002, 10032, + 10061, 10090, 10120, 10149, 10178, 10208, 10237, 10267, 10297, 10326, 10356, 10386, 10415, 10445, 10474, 10504, 10533, 10562, 10592, 10621, + 10651, 10680, 10710, 10740, 10770, 10799, 10829, 10858, 10888, 10917, 10947, 10976, 11005, 11035, 11064, 11094, 11124, 11153, 11183, 11213, + 11242, 11272, 11301, 11331, 11360, 11389, 11419, 11448, 11478, 11507, 11537, 11567, 11596, 11626, 11655, 11685, 11715, 11744, 11774, 11803, + 11832, 11862, 11891, 11921, 11950, 11980, 12010, 12039, 12069, 12099, 12128, 12158, 12187, 12216, 12246, 12275, 12304, 12334, 12364, 12393, + 12423, 12453, 12483, 12512, 12542, 12571, 12600, 12630, 12659, 12688, 12718, 12747, 12777, 12807, 12837, 12866, 12896, 12926, 12955, 12984, + 13014, 13043, 13072, 13102, 13131, 13161, 13191, 13220, 13250, 13280, 13310, 13339, 13368, 13398, 13427, 13456, 13486, 13515, 13545, 13574, + 13604, 13634, 13664, 13693, 13723, 13752, 13782, 13811, 13840, 13870, 13899, 13929, 13958, 13988, 14018, 14047, 14077, 14107, 14136, 14166, + 14195, 14224, 14254, 14283, 14313, 14342, 14372, 14401, 14431, 14461, 14490, 14520, 14550, 14579, 14609, 14638, 14667, 14697, 14726, 14756, + 14785, 14815, 14844, 14874, 14904, 14933, 14963, 14993, 15021, 15051, 15081, 15110, 15140, 15169, 15199, 15228, 15258, 15287, 15317, 15347, + 15377, 15406, 15436, 15465, 15494, 15524, 15553, 15582, 15612, 15641, 15671, 15701, 15731, 15760, 15790, 15820, 15849, 15878, 15908, 15937, + 15966, 15996, 16025, 16055, 16085, 16114, 16144, 16174, 16204, 16233, 16262, 16292, 16321, 16350, 16380, 16409, 16439, 16468, 16498, 16528, + 16558, 16587, 16617, 16646, 16676, 16705, 16734, 16764, 16793, 16823, 16852, 16882, 16912, 16941, 16971, 17001, 17030, 17060, 17089, 17118, + 17148, 17177, 17207, 17236, 17266, 17295, 17325, 17355, 17384, 17414, 17444, 17473, 17502, 17532, 17561, 17591, 17620, 17650, 17679, 17709, + 17738, 17768, 17798, 17827, 17857, 17886, 17916, 17945, 17975, 18004, 18034, 18063, 18093, 18122, 18152, 18181, 18211, 18241, 18270, 18300, + 18330, 18359, 18388, 18418, 18447, 18476, 18506, 18535, 18565, 18595, 18625, 18654, 18684, 18714, 18743, 18772, 18802, 18831, 18860, 18890, + 18919, 18949, 18979, 19008, 19038, 19068, 19098, 19127, 19156, 19186, 19215, 19244, 19274, 19303, 19333, 19362, 19392, 19422, 19452, 19481, + 19511, 19540, 19570, 19599, 19628, 19658, 19687, 19717, 19746, 19776, 19806, 19836, 19865, 19895, 19924, 19954, 19983, 20012, 20042, 20071, + 20101, 20130, 20160, 20190, 20219, 20249, 20279, 20308, 20338, 20367, 20396, 20426, 20455, 20485, 20514, 20544, 20573, 20603, 20633, 20662, + 20692, 20721, 20751, 20780, 20810, 20839, 20869, 20898, 20928, 20957, 20987, 21016, 21046, 21076, 21105, 21135, 21164, 21194, 21223, 21253, + 21282, 21312, 21341, 21371, 21400, 21430, 21459, 21489, 21519, 21548, 21578, 21607, 21637, 21666, 21696, 21725, 21754, 21784, 21813, 21843, + 21873, 21902, 21932, 21962, 21991, 22021, 22050, 22080, 22109, 22138, 22168, 22197, 22227, 22256, 22286, 22316, 22346, 22375, 22405, 22434, + 22464, 22493, 22522, 22552, 22581, 22611, 22640, 22670, 22700, 22730, 22759, 22789, 22818, 22848, 22877, 22906, 22936, 22965, 22994, 23024, + 23054, 23083, 23113, 23143, 23173, 23202, 23232, 23261, 23290, 23320, 23349, 23379, 23408, 23438, 23467, 23497, 23527, 23556, 23586, 23616, + 23645, 23674, 23704, 23733, 23763, 23792, 23822, 23851, 23881, 23910, 23940, 23970, 23999, 24029, 24058, 24088, 24117, 24147, 24176, 24206, + 24235, 24265, 24294, 24324, 24353, 24383, 24413, 24442, 24472, 24501, 24531, 24560, 24590, 24619, 24648, 24678, 24707, 24737, 24767, 24796, + 24826, 24856, 24885, 24915, 24944, 24974, 25003, 25032, 25062, 25091, 25121, 25150, 25180, 25210, 25240, 25269, 25299, 25328, 25358, 25387, + 25416, 25446, 25475, 25505, 25534, 25564, 25594, 25624, 25653, 25683, 25712, 25742, 25771, 25800, 25830, 25859, 25888, 25918, 25948, 25977, + 26007, 26037, 26067, 26096, 26126, 26155, 26184, 26214, 26243, 26272, 26302, 26332, 26361, 26391, 26421, 26451, 26480, 26510, 26539, 26568, + 26598, 26627, 26656, 26686, 26715, 26745, 26775, 26805, 26834, 26864, 26893, 26923, 26952, 26982, 27011, 27041, 27070, 27099, 27129, 27159, + 27188, 27218, 27248, 27277, 27307, 27336, 27366, 27395, 27425, 27454, 27484, 27513, 27542, 27572, 27602, 27631, 27661, 27691, 27720, 27750, + 27779, 27809, 27838, 27868, 27897, 27926, 27956, 27985, 28015, 28045, 28074, 28104, 28134, 28163, 28193, 28222, 28252, 28281, 28310, 28340, + 28369, 28399, 28428, 28458, 28488, 28517, 28547, 28577, + // From 1356 + 28607, 28636, 28665, 28695, 28724, 28754, 28783, 28813, 28843, 28872, 28901, 28931, 28960, 28990, 29019, 29049, 29078, 29108, 29137, 29167, + 29196, 29226, 29255, 29285, 29315, 29345, 29375, 29404, 29434, 29463, 29492, 29522, 29551, 29580, 29610, 29640, 29669, 29699, 29729, 29759, + 29788, 29818, 29847, 29876, 29906, 29935, 29964, 29994, 30023, 30053, 30082, 30112, 30141, 30171, 30200, 30230, 30259, 30289, 30318, 30348, + 30378, 30408, 30437, 30467, 30496, 30526, 30555, 30585, 30614, 30644, 30673, 30703, 30732, 30762, 30791, 30821, 30850, 30880, 30909, 30939, + 30968, 30998, 31027, 31057, 31086, 31116, 31145, 31175, 31204, 31234, 31263, 31293, 31322, 31352, 31381, 31411, 31441, 31471, 31500, 31530, + 31559, 31589, 31618, 31648, 31676, 31706, 31736, 31766, 31795, 31825, 31854, 31884, 31913, 31943, 31972, 32002, 32031, 32061, 32090, 32120, + 32150, 32180, 32209, 32239, 32268, 32298, 32327, 32357, 32386, 32416, 32445, 32475, 32504, 32534, 32563, 32593, 32622, 32652, 32681, 32711, + 32740, 32770, 32799, 32829, 32858, 32888, 32917, 32947, 32976, 33006, 33035, 33065, 33094, 33124, 33153, 33183, 33213, 33243, 33272, 33302, + 33331, 33361, 33390, 33420, 33450, 33479, 33509, 33539, 33568, 33598, 33627, 33657, 33686, 33716, 33745, 33775, 33804, 33834, 33863, 33893, + 33922, 33952, 33981, 34011, 34040, 34069, 34099, 34128, 34158, 34187, 34217, 34247, 34277, 34306, 34336, 34365, 34395, 34424, 34454, 34483, + 34512, 34542, 34571, 34601, 34631, 34660, 34690, 34719, 34749, 34778, 34808, 34837, 34867, 34896, 34926, 34955, 34985, 35015, 35044, 35074, + 35103, 35133, 35162, 35192, 35222, 35251, 35280, 35310, 35340, 35370, 35399, 35429, 35458, 35488, 35517, 35547, 35576, 35605, 35635, 35665, + 35694, 35723, 35753, 35782, 35811, 35841, 35871, 35901, 35930, 35960, 35989, 36019, 36048, 36078, 36107, 36136, 36166, 36195, 36225, 36254, + 36284, 36314, 36343, 36373, 36403, 36433, 36462, 36492, 36521, 36551, 36580, 36610, 36639, 36669, 36698, 36728, 36757, 36786, 36816, 36845, + 36875, 36904, 36934, 36963, 36993, 37022, 37052, 37081, 37111, 37141, 37170, 37200, 37229, 37259, 37288, 37318, 37347, 37377, 37406, 37436, + 37465, 37495, 37524, 37554, 37584, 37613, 37643, 37672, 37701, 37731, 37760, 37790, 37819, 37849, 37878, 37908, 37938, 37967, 37997, 38027, + 38056, 38085, 38115, 38144, 38174, 38203, 38233, 38262, 38292, 38322, 38351, 38381, 38410, 38440, 38469, 38499, 38528, 38558, 38587, 38617, + 38646, 38676, 38705, 38735, 38764, 38794, 38823, 38853, 38882, 38912, 38941, 38971, 39001, 39030, 39059, 39089, 39118, 39148, 39178, 39208, + 39237, 39267, 39297, 39326, 39355, 39385, 39414, 39444, 39473, 39503, 39532, 39562, 39592, 39621, 39650, 39680, 39709, 39739, 39768, 39798, + 39827, 39857, 39886, 39916, 39946, 39975, 40005, 40035, 40064, 40094, 40123, 40153, 40182, 40212, 40241, 40271, 40300, 40330, 40359, 40389, + 40418, 40448, 40477, 40507, 40536, 40566, 40595, 40625, 40655, 40685, 40714, 40744, 40773, 40803, 40832, 40862, 40892, 40921, 40951, 40980, + 41009, 41039, 41068, 41098, 41127, 41157, 41186, 41216, 41245, 41275, 41304, 41334, 41364, 41393, 41422, 41452, 41481, 41511, 41540, 41570, + 41599, 41629, 41658, 41688, 41718, 41748, 41777, 41807, 41836, 41865, 41894, 41924, 41953, 41983, 42012, 42042, 42072, 42102, 42131, 42161, + 42190, 42220, 42249, 42279, 42308, 42337, 42367, 42397, 42426, 42456, 42485, 42515, 42545, 42574, 42604, 42633, 42662, 42692, 42721, 42751, + 42780, 42810, 42839, 42869, 42899, 42929, 42958, 42988, 43017, 43046, 43076, 43105, 43135, 43164, 43194, 43223, 43253, 43283, 43312, 43342, + 43371, 43401, 43430, 43460, 43489, 43519, 43548, 43578, 43607, 43637, 43666, 43696, 43726, 43755, 43785, 43814, 43844, 43873, 43903, 43932, + 43962, 43991, 44021, 44050, 44080, 44109, 44139, 44169, 44198, 44228, 44258, 44287, 44317, 44346, 44375, 44405, 44434, 44464, 44493, 44523, + 44553, 44582, 44612, 44641, 44671, 44700, 44730, 44759, 44788, 44818, 44847, 44877, 44906, 44936, 44966, 44996, 45025, 45055, 45084, 45114, + 45143, 45172, 45202, 45231, 45261, 45290, 45320, 45350, 45380, 45409, 45439, 45468, 45498, 45527, 45556, 45586, 45615, 45644, 45674, 45704, + 45733, 45763, 45793, 45823, 45852, 45882, 45911, 45940, 45970, 45999, 46028, 46058, 46088, 46117, 46147, 46177, 46206, 46236, 46265, 46295, + 46324, 46354, 46383, 46413, 46442, 46472, 46501, 46531, 46560, 46590, 46620, 46649, 46679, 46708, 46738, 46767, 46797, 46826, 46856, 46885, + 46915, 46944, 46974, 47003, 47033, 47063, 47092, 47122, 47151, 47181, 47210, 47240, 47269, 47298, 47328, 47357, 47387, 47417, 47446, 47476, + 47506, 47535, 47565, 47594, 47624, 47653, 47682, 47712, 47741, 47771, 47800, 47830, 47860, 47890, 47919, 47949, 47978, 48008, 48037, 48066, + 48096, 48125, 48155, 48184, 48214, 48244, 48273, 48303, 48333, 48362, 48392, 48421, 48450, 48480, 48509, 48538, 48568, 48598, 48627, 48657, + 48687, 48717, 48746, 48776, 48805, 48834, 48864, 48893, 48922, 48952, 48982, 49011, 49041, 49071, 49100, 49130, 49160, 49189, 49218, 49248, + 49277, 49306, 49336, 49365, 49395, 49425, 49455, 49484, 49514, 49543, 49573, 49602, 49632, 49661, 49690, 49720, 49749, 49779, 49809, 49838, + 49868, 49898, 49927, 49957, 49986, 50016, 50045, 50075, 50104, 50133, 50163, 50192, 50222, 50252, 50281, 50311, 50340, 50370, 50400, 50429, + 50459, 50488, 50518, 50547, 50576, 50606, 50635, 50665, 50694, 50724, 50754, 50784, 50813, 50843, 50872, 50902, 50931, 50960, 50990, 51019, + 51049, 51078, 51108, 51138, 51167, 51197, 51227, 51256, 51286, 51315, 51345, 51374, 51403, 51433, 51462, 51492, 51522, 51552, 51582, 51611, + 51641, 51670, 51699, 51729, 51758, 51787, 51816, 51846, 51876, 51906, 51936, 51965, 51995, 52025, 52054, 52083, 52113, 52142, 52171, 52200, + 52230, 52260, 52290, 52319, 52349, 52379, 52408, 52438, 52467, 52497, 52526, 52555, 52585, 52614, 52644, 52673, 52703, 52733, 52762, 52792, + 52822, 52851, 52881, 52910, 52939, 52969, 52998, 53028, 53057, 53087, 53116, 53146, 53176, 53205, 53235, 53264, 53294, 53324, 53353, 53383, + 53412, 53441, 53471, 53500, 53530, 53559, 53589, 53619, 53648, 53678, 53708, 53737, 53767, 53796, 53825, 53855, 53884, 53913, 53943, 53973, + 54003, 54032, 54062, 54092, 54121, 54151, 54180, 54209, 54239, 54268, 54297, 54327, 54357, 54387, 54416, 54446, 54476, 54505, 54535, 54564, + 54593, 54623, 54652, 54681, 54711, 54741, 54770, 54800, 54830, 54859, 54889, 54919, 54948, 54977, 55007, 55036, 55066, 55095, 55125, 55154, + 55184, 55213, 55243, 55273, 55302, 55332, 55361, 55391, 55420, 55450, 55479, 55508, 55538, 55567, 55597, 55627, 55657, 55686, 55716, 55745, + 55775, 55804, 55834, 55863, 55892, 55922, 55951, 55981, 56011, 56040, 56070, 56100, 56129, 56159, 56188, 56218, 56247, 56276, 56306, 56335, + 56365, 56394, 56424, 56454, 56483, 56513, 56543, 56572, 56601, 56631, 56660, 56690, 56719, 56749, 56778, 56808, 56837, 56867, 56897, 56926, + 56956, 56985, 57015, 57044, 57074, 57103, 57133, 57162, 57192, 57221, 57251, 57280, 57310, 57340, 57369, 57399, 57429, 57458, 57487, 57517, + 57546, 57576, 57605, 57634, 57664, 57694, 57723, 57753, 57783, 57813, 57842, 57871, 57901, 57930, 57959, 57989, 58018, 58048, 58077, 58107, + 58137, 58167, 58196, 58226, 58255, 58285, 58314, 58343, 58373, 58402, 58432, 58461, 58491, 58521, 58551, 58580, 58610, 58639, 58669, 58698, + 58727, 58757, 58786, 58816, 58845, 58875, 58905, 58934, 58964, 58994, 59023, 59053, 59082, 59111, 59141, 59170, 59200, 59229, 59259, 59288, + 59318, 59348, 59377, 59407, 59436, 59466, 59495, 59525, 59554, 59584, 59613, 59643, 59672, 59702, 59731, 59761, 59791, 59820, 59850, 59879, + 59909, 59939, 59968, 59997, 60027, 60056, 60086, 60115, 60145, 60174, 60204, 60234, 60264, 60293, 60323, 60352, 60381, 60411, 60440, 60469, + 60499, 60528, 60558, 60588, 60618, 60648, 60677, 60707, 60736, 60765, 60795, 60824, 60853, 60883, 60912, 60942, 60972, 61002, 61031, 61061, + 61090, 61120, 61149, 61179, 61208, 61237, 61267, 61296, 61326, 61356, 61385, 61415, 61445, 61474, 61504, 61533, 61563, 61592, 61621, 61651, + 61680, 61710, 61739, 61769, 61799, 61828, 61858, 61888, 61917, 61947, 61976, 62006, 62035, 62064, 62094, 62123, 62153, 62182, 62212, 62242, + 62271, 62301, 62331, 62360, 62390, 62419, 62448, 62478, 62507, 62537, 62566, 62596, 62625, 62655, 62685, 62715, 62744, 62774, 62803, 62832, + 62862, 62891, 62921, 62950, 62980, 63009, 63039, 63069, 63099, 63128, 63157, 63187, 63216, 63246, 63275, 63305, 63334, 63363, 63393, 63423, + 63453, 63482, 63512, 63541, 63571, 63600, 63630, 63659, 63689, 63718, 63747, 63777, 63807, 63836, 63866, 63895, 63925, 63955, 63984, 64014, + 64043, 64073, 64102, 64131, 64161, 64190, 64220, 64249, 64279, 64309, 64339, 64368, 64398, 64427, 64457, 64486, 64515, 64545, 64574, 64603, + 64633, 64663, 64692, 64722, 64752, 64782, 64811, 64841, 64870, 64899, 64929, 64958, 64987, 65017, 65047, 65076, 65106, 65136, 65166, 65195, + 65225, 65254, 65283, 65313, 65342, 65371, 65401, 65431, 65460, 65490, 65520, 65549, 65579, 65608, 65638, 65667, 65697, 65726, 65755, 65785, + 65815, 65844, 65874, 65903, 65933, 65963, 65992, 66022, 66051, 66081, 66110, 66140, 66169, 66199, 66228, 66258, 66287, 66317, 66346, 66376, + 66405, 66435, 66465, 66494, 66524, 66553, 66583, 66612, 66641, 66671, 66700, 66730, 66760, 66789, 66819, 66849, 66878, 66908, 66937, 66967, + 66996, 67025, 67055, 67084, 67114, 67143, 67173, 67203, 67233, 67262, 67292, 67321, 67351, 67380, 67409, 67439, 67468, 67497, 67527, 67557, + 67587, 67617, 67646, 67676, 67705, 67735, 67764, 67793, 67823, 67852, 67882, 67911, 67941, 67971, 68000, 68030, 68060, 68089, 68119, 68148, + 68177, 68207, 68236, 68266, 68295, 68325, 68354, 68384, 68414, 68443, 68473, 68502, 68532, 68561, 68591, 68620, 68650, 68679, 68708, 68738, + 68768, 68797, 68827, 68857, 68886, 68916, 68946, 68975, 69004, 69034, 69063, 69092, 69122, 69152, 69181, 69211, 69240, 69270, 69300, 69330, + 69359, 69388, 69418, 69447, 69476, 69506, 69535, 69565, 69595, 69624, 69654, 69684, 69713, 69743, 69772, 69802, 69831, 69861, 69890, 69919, + 69949, 69978, 70008, 70038, 70067, 70097, 70126, 70156, 70186, 70215, 70245, 70274, 70303, 70333, 70362, 70392, 70421, 70451, 70481, 70510, + 70540, 70570, 70599, 70629, 70658, 70687, 70717, 70746, 70776, 70805, 70835, 70864, 70894, 70924, 70954, 70983, 71013, 71042, 71071, 71101, + 71130, 71159, 71189, 71218, 71248, 71278, 71308, 71337, 71367, 71397, 71426, 71455, 71485, 71514, 71543, 71573, 71602, 71632, 71662, 71691, + 71721, 71751, 71781, 71810, 71839, 71869, 71898, 71927, 71957, 71986, 72016, 72046, 72075, 72105, 72135, 72164, 72194, 72223, 72253, 72282, + 72311, 72341, 72370, 72400, 72429, 72459, 72489, 72518, 72548, 72577, 72607, 72637, 72666, 72695, 72725, 72754, 72784, 72813, 72843, 72872, + 72902, 72931, 72961, 72991, 73020, 73050, 73080, 73109, 73139, 73168, 73197, 73227, 73256, 73286, 73315, 73345, 73375, 73404, 73434, 73464, + 73493, 73523, 73552, 73581, 73611, 73640, 73669, 73699, 73729, 73758, 73788, 73818, 73848, 73877, 73907, 73936, 73965, 73995, 74024, 74053, + 74083, 74113, 74142, 74172, 74202, 74231, 74261, 74291, 74320, 74349, 74379, 74408, 74437, 74467, 74497, 74526, 74556, 74586, 74615, 74645, + 74675, 74704, 74733, 74763, 74792, 74822, 74851, 74881, 74910, 74940, 74969, 74999, 75029, 75058, 75088, 75117, 75147, 75176, 75206, 75235, + 75264, 75294, 75323, 75353, 75383, 75412, 75442, 75472, 75501, 75531, 75560, 75590, 75619, 75648, 75678, 75707, 75737, 75766, 75796, 75826, + 75856, 75885, 75915, 75944, 75974, 76003, 76032, 76062, 76091, 76121, 76150, 76180, 76210, 76239, 76269, 76299, 76328, 76358, 76387, 76416, + 76446, 76475, 76505, 76534, 76564, 76593, 76623, 76653, 76682, 76712, 76741, 76771, 76801, 76830, 76859, 76889, 76918, 76948, 76977, 77007, + 77036, 77066, 77096, 77125, 77155, 77185, 77214, 77243, 77273, 77302, 77332, 77361, 77390, 77420, 77450, 77479, 77509, 77539, 77569, 77598, + 77627, 77657, 77686, 77715, 77745, 77774, 77804, 77833, 77863, 77893, 77923, 77952, 77982, 78011, 78041, 78070, 78099, 78129, 78158, 78188, + 78217, 78247, 78277, 78307, 78336, 78366, 78395, 78425, 78454, 78483, 78513, 78542, 78572, 78601, 78631, 78661, 78690, 78720, 78750, 78779, + 78808, 78838, 78867, 78897, 78926, 78956, 78985, 79015, 79044, 79074, 79104, 79133, 79163, 79192, 79222, 79251, 79281, 79310, 79340, 79369, + 79399, 79428, 79458, 79487, 79517, 79546, 79576, 79606, 79635, 79665, 79695, 79724, 79753, 79783, 79812, 79841, 79871, 79900, 79930, 79960, + 79990]; + + +},{"../main":135,"object-assign":71}],135:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Calendars for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) August 2009. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var assign = _dereq_('object-assign'); + + +function Calendars() { + this.regionalOptions = []; + this.regionalOptions[''] = { + invalidCalendar: 'Calendar {0} not found', + invalidDate: 'Invalid {0} date', + invalidMonth: 'Invalid {0} month', + invalidYear: 'Invalid {0} year', + differentCalendars: 'Cannot mix {0} and {1} dates' + }; + this.local = this.regionalOptions['']; + this.calendars = {}; + this._localCals = {}; +} + +/** Create the calendars plugin. +

Provides support for various world calendars in a consistent manner.

+ @class Calendars + @example _exports.instance('julian').newDate(2014, 12, 25) */ +assign(Calendars.prototype, { + + /** Obtain a calendar implementation and localisation. + @memberof Calendars + @param [name='gregorian'] {string} The name of the calendar, e.g. 'gregorian', 'persian', 'islamic'. + @param [language=''] {string} The language code to use for localisation (default is English). + @return {Calendar} The calendar and localisation. + @throws Error if calendar not found. */ + instance: function(name, language) { + name = (name || 'gregorian').toLowerCase(); + language = language || ''; + var cal = this._localCals[name + '-' + language]; + if (!cal && this.calendars[name]) { + cal = new this.calendars[name](language); + this._localCals[name + '-' + language] = cal; + } + if (!cal) { + throw (this.local.invalidCalendar || this.regionalOptions[''].invalidCalendar). + replace(/\{0\}/, name); + } + return cal; + }, + + /** Create a new date - for today if no other parameters given. + @memberof Calendars + @param year {CDate|number} The date to copy or the year for the date. + @param [month] {number} The month for the date. + @param [day] {number} The day for the date. + @param [calendar='gregorian'] {BaseCalendar|string} The underlying calendar or the name of the calendar. + @param [language=''] {string} The language to use for localisation (default English). + @return {CDate} The new date. + @throws Error if an invalid date. */ + newDate: function(year, month, day, calendar, language) { + calendar = (year != null && year.year ? year.calendar() : (typeof calendar === 'string' ? + this.instance(calendar, language) : calendar)) || this.instance(); + return calendar.newDate(year, month, day); + }, + + /** A simple digit substitution function for localising numbers via the Calendar digits option. + @member Calendars + @param digits {string[]} The substitute digits, for 0 through 9. + @return {function} The substitution function. */ + substituteDigits: function(digits) { + return function(value) { + return (value + '').replace(/[0-9]/g, function(digit) { + return digits[digit]; + }); + } + }, + + /** Digit substitution function for localising Chinese style numbers via the Calendar digits option. + @member Calendars + @param digits {string[]} The substitute digits, for 0 through 9. + @param powers {string[]} The characters denoting powers of 10, i.e. 1, 10, 100, 1000. + @return {function} The substitution function. */ + substituteChineseDigits: function(digits, powers) { + return function(value) { + var localNumber = ''; + var power = 0; + while (value > 0) { + var units = value % 10; + localNumber = (units === 0 ? '' : digits[units] + powers[power]) + localNumber; + power++; + value = Math.floor(value / 10); + } + if (localNumber.indexOf(digits[1] + powers[1]) === 0) { + localNumber = localNumber.substr(1); + } + return localNumber || digits[0]; + } + } +}); + +/** Generic date, based on a particular calendar. + @class CDate + @param calendar {BaseCalendar} The underlying calendar implementation. + @param year {number} The year for this date. + @param month {number} The month for this date. + @param day {number} The day for this date. + @return {CDate} The date object. + @throws Error if an invalid date. */ +function CDate(calendar, year, month, day) { + this._calendar = calendar; + this._year = year; + this._month = month; + this._day = day; + if (this._calendar._validateLevel === 0 && + !this._calendar.isValid(this._year, this._month, this._day)) { + throw (_exports.local.invalidDate || _exports.regionalOptions[''].invalidDate). + replace(/\{0\}/, this._calendar.local.name); + } +} + +/** Pad a numeric value with leading zeroes. + @private + @param value {number} The number to format. + @param length {number} The minimum length. + @return {string} The formatted number. */ +function pad(value, length) { + value = '' + value; + return '000000'.substring(0, length - value.length) + value; +} + +assign(CDate.prototype, { + + /** Create a new date. + @memberof CDate + @param [year] {CDate|number} The date to copy or the year for the date (default this date). + @param [month] {number} The month for the date. + @param [day] {number} The day for the date. + @return {CDate} The new date. + @throws Error if an invalid date. */ + newDate: function(year, month, day) { + return this._calendar.newDate((year == null ? this : year), month, day); + }, + + /** Set or retrieve the year for this date. + @memberof CDate + @param [year] {number} The year for the date. + @return {number|CDate} The date's year (if no parameter) or the updated date. + @throws Error if an invalid date. */ + year: function(year) { + return (arguments.length === 0 ? this._year : this.set(year, 'y')); + }, + + /** Set or retrieve the month for this date. + @memberof CDate + @param [month] {number} The month for the date. + @return {number|CDate} The date's month (if no parameter) or the updated date. + @throws Error if an invalid date. */ + month: function(month) { + return (arguments.length === 0 ? this._month : this.set(month, 'm')); + }, + + /** Set or retrieve the day for this date. + @memberof CDate + @param [day] {number} The day for the date. + @return {number|CData} The date's day (if no parameter) or the updated date. + @throws Error if an invalid date. */ + day: function(day) { + return (arguments.length === 0 ? this._day : this.set(day, 'd')); + }, + + /** Set new values for this date. + @memberof CDate + @param year {number} The year for the date. + @param month {number} The month for the date. + @param day {number} The day for the date. + @return {CDate} The updated date. + @throws Error if an invalid date. */ + date: function(year, month, day) { + if (!this._calendar.isValid(year, month, day)) { + throw (_exports.local.invalidDate || _exports.regionalOptions[''].invalidDate). + replace(/\{0\}/, this._calendar.local.name); + } + this._year = year; + this._month = month; + this._day = day; + return this; + }, + + /** Determine whether this date is in a leap year. + @memberof CDate + @return {boolean} true if this is a leap year, false if not. */ + leapYear: function() { + return this._calendar.leapYear(this); + }, + + /** Retrieve the epoch designator for this date, e.g. BCE or CE. + @memberof CDate + @return {string} The current epoch. */ + epoch: function() { + return this._calendar.epoch(this); + }, + + /** Format the year, if not a simple sequential number. + @memberof CDate + @return {string} The formatted year. */ + formatYear: function() { + return this._calendar.formatYear(this); + }, + + /** Retrieve the month of the year for this date, + i.e. the month's position within a numbered year. + @memberof CDate + @return {number} The month of the year: minMonth to months per year. */ + monthOfYear: function() { + return this._calendar.monthOfYear(this); + }, + + /** Retrieve the week of the year for this date. + @memberof CDate + @return {number} The week of the year: 1 to weeks per year. */ + weekOfYear: function() { + return this._calendar.weekOfYear(this); + }, + + /** Retrieve the number of days in the year for this date. + @memberof CDate + @return {number} The number of days in this year. */ + daysInYear: function() { + return this._calendar.daysInYear(this); + }, + + /** Retrieve the day of the year for this date. + @memberof CDate + @return {number} The day of the year: 1 to days per year. */ + dayOfYear: function() { + return this._calendar.dayOfYear(this); + }, + + /** Retrieve the number of days in the month for this date. + @memberof CDate + @return {number} The number of days. */ + daysInMonth: function() { + return this._calendar.daysInMonth(this); + }, + + /** Retrieve the day of the week for this date. + @memberof CDate + @return {number} The day of the week: 0 to number of days - 1. */ + dayOfWeek: function() { + return this._calendar.dayOfWeek(this); + }, + + /** Determine whether this date is a week day. + @memberof CDate + @return {boolean} true if a week day, false if not. */ + weekDay: function() { + return this._calendar.weekDay(this); + }, + + /** Retrieve additional information about this date. + @memberof CDate + @return {object} Additional information - contents depends on calendar. */ + extraInfo: function() { + return this._calendar.extraInfo(this); + }, + + /** Add period(s) to a date. + @memberof CDate + @param offset {number} The number of periods to adjust by. + @param period {string} One of 'y' for year, 'm' for month, 'w' for week, 'd' for day. + @return {CDate} The updated date. */ + add: function(offset, period) { + return this._calendar.add(this, offset, period); + }, + + /** Set a portion of the date. + @memberof CDate + @param value {number} The new value for the period. + @param period {string} One of 'y' for year, 'm' for month, 'd' for day. + @return {CDate} The updated date. + @throws Error if not a valid date. */ + set: function(value, period) { + return this._calendar.set(this, value, period); + }, + + /** Compare this date to another date. + @memberof CDate + @param date {CDate} The other date. + @return {number} -1 if this date is before the other date, + 0 if they are equal, or +1 if this date is after the other date. */ + compareTo: function(date) { + if (this._calendar.name !== date._calendar.name) { + throw (_exports.local.differentCalendars || _exports.regionalOptions[''].differentCalendars). + replace(/\{0\}/, this._calendar.local.name).replace(/\{1\}/, date._calendar.local.name); + } + var c = (this._year !== date._year ? this._year - date._year : + this._month !== date._month ? this.monthOfYear() - date.monthOfYear() : + this._day - date._day); + return (c === 0 ? 0 : (c < 0 ? -1 : +1)); + }, + + /** Retrieve the calendar backing this date. + @memberof CDate + @return {BaseCalendar} The calendar implementation. */ + calendar: function() { + return this._calendar; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof CDate + @return {number} The equivalent Julian date. */ + toJD: function() { + return this._calendar.toJD(this); + }, + + /** Create a new date from a Julian date. + @memberof CDate + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + return this._calendar.fromJD(jd); + }, + + /** Convert this date to a standard (Gregorian) JavaScript Date. + @memberof CDate + @return {Date} The equivalent JavaScript date. */ + toJSDate: function() { + return this._calendar.toJSDate(this); + }, + + /** Create a new date from a standard (Gregorian) JavaScript Date. + @memberof CDate + @param jsd {Date} The JavaScript date to convert. + @return {CDate} The equivalent date. */ + fromJSDate: function(jsd) { + return this._calendar.fromJSDate(jsd); + }, + + /** Convert to a string for display. + @memberof CDate + @return {string} This date as a string. */ + toString: function() { + return (this.year() < 0 ? '-' : '') + pad(Math.abs(this.year()), 4) + + '-' + pad(this.month(), 2) + '-' + pad(this.day(), 2); + } +}); + +/** Basic functionality for all calendars. + Other calendars should extend this: +
OtherCalendar.prototype = new BaseCalendar;
+ @class BaseCalendar */ +function BaseCalendar() { + this.shortYearCutoff = '+10'; +} + +assign(BaseCalendar.prototype, { + _validateLevel: 0, // "Stack" to turn validation on/off + + /** Create a new date within this calendar - today if no parameters given. + @memberof BaseCalendar + @param year {CDate|number} The date to duplicate or the year for the date. + @param [month] {number} The month for the date. + @param [day] {number} The day for the date. + @return {CDate} The new date. + @throws Error if not a valid date or a different calendar used. */ + newDate: function(year, month, day) { + if (year == null) { + return this.today(); + } + if (year.year) { + this._validate(year, month, day, + _exports.local.invalidDate || _exports.regionalOptions[''].invalidDate); + day = year.day(); + month = year.month(); + year = year.year(); + } + return new CDate(this, year, month, day); + }, + + /** Create a new date for today. + @memberof BaseCalendar + @return {CDate} Today's date. */ + today: function() { + return this.fromJSDate(new Date()); + }, + + /** Retrieve the epoch designator for this date. + @memberof BaseCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {string} The current epoch. + @throws Error if an invalid year or a different calendar used. */ + epoch: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, + _exports.local.invalidYear || _exports.regionalOptions[''].invalidYear); + return (date.year() < 0 ? this.local.epochs[0] : this.local.epochs[1]); + }, + + /** Format the year, if not a simple sequential number + @memberof BaseCalendar + @param year {CDate|number} The date to format or the year to format. + @return {string} The formatted year. + @throws Error if an invalid year or a different calendar used. */ + formatYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, + _exports.local.invalidYear || _exports.regionalOptions[''].invalidYear); + return (date.year() < 0 ? '-' : '') + pad(Math.abs(date.year()), 4) + }, + + /** Retrieve the number of months in a year. + @memberof BaseCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of months. + @throws Error if an invalid year or a different calendar used. */ + monthsInYear: function(year) { + this._validate(year, this.minMonth, this.minDay, + _exports.local.invalidYear || _exports.regionalOptions[''].invalidYear); + return 12; + }, + + /** Calculate the month's ordinal position within the year - + for those calendars that don't start at month 1! + @memberof BaseCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param month {number} The month to examine. + @return {number} The ordinal position, starting from minMonth. + @throws Error if an invalid year/month or a different calendar used. */ + monthOfYear: function(year, month) { + var date = this._validate(year, month, this.minDay, + _exports.local.invalidMonth || _exports.regionalOptions[''].invalidMonth); + return (date.month() + this.monthsInYear(date) - this.firstMonth) % + this.monthsInYear(date) + this.minMonth; + }, + + /** Calculate actual month from ordinal position, starting from minMonth. + @memberof BaseCalendar + @param year {number} The year to examine. + @param ord {number} The month's ordinal position. + @return {number} The month's number. + @throws Error if an invalid year/month. */ + fromMonthOfYear: function(year, ord) { + var m = (ord + this.firstMonth - 2 * this.minMonth) % + this.monthsInYear(year) + this.minMonth; + this._validate(year, m, this.minDay, + _exports.local.invalidMonth || _exports.regionalOptions[''].invalidMonth); + return m; + }, + + /** Retrieve the number of days in a year. + @memberof BaseCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {number} The number of days. + @throws Error if an invalid year or a different calendar used. */ + daysInYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, + _exports.local.invalidYear || _exports.regionalOptions[''].invalidYear); + return (this.leapYear(date) ? 366 : 365); + }, + + /** Retrieve the day of the year for a date. + @memberof BaseCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The day of the year. + @throws Error if an invalid date or a different calendar used. */ + dayOfYear: function(year, month, day) { + var date = this._validate(year, month, day, + _exports.local.invalidDate || _exports.regionalOptions[''].invalidDate); + return date.toJD() - this.newDate(date.year(), + this.fromMonthOfYear(date.year(), this.minMonth), this.minDay).toJD() + 1; + }, + + /** Retrieve the number of days in a week. + @memberof BaseCalendar + @return {number} The number of days. */ + daysInWeek: function() { + return 7; + }, + + /** Retrieve the day of the week for a date. + @memberof BaseCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The day of the week: 0 to number of days - 1. + @throws Error if an invalid date or a different calendar used. */ + dayOfWeek: function(year, month, day) { + var date = this._validate(year, month, day, + _exports.local.invalidDate || _exports.regionalOptions[''].invalidDate); + return (Math.floor(this.toJD(date)) + 2) % this.daysInWeek(); + }, + + /** Retrieve additional information about a date. + @memberof BaseCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {object} Additional information - contents depends on calendar. + @throws Error if an invalid date or a different calendar used. */ + extraInfo: function(year, month, day) { + this._validate(year, month, day, + _exports.local.invalidDate || _exports.regionalOptions[''].invalidDate); + return {}; + }, + + /** Add period(s) to a date. + Cater for no year zero. + @memberof BaseCalendar + @param date {CDate} The starting date. + @param offset {number} The number of periods to adjust by. + @param period {string} One of 'y' for year, 'm' for month, 'w' for week, 'd' for day. + @return {CDate} The updated date. + @throws Error if a different calendar used. */ + add: function(date, offset, period) { + this._validate(date, this.minMonth, this.minDay, + _exports.local.invalidDate || _exports.regionalOptions[''].invalidDate); + return this._correctAdd(date, this._add(date, offset, period), offset, period); + }, + + /** Add period(s) to a date. + @memberof BaseCalendar + @private + @param date {CDate} The starting date. + @param offset {number} The number of periods to adjust by. + @param period {string} One of 'y' for year, 'm' for month, 'w' for week, 'd' for day. + @return {CDate} The updated date. */ + _add: function(date, offset, period) { + this._validateLevel++; + if (period === 'd' || period === 'w') { + var jd = date.toJD() + offset * (period === 'w' ? this.daysInWeek() : 1); + var d = date.calendar().fromJD(jd); + this._validateLevel--; + return [d.year(), d.month(), d.day()]; + } + try { + var y = date.year() + (period === 'y' ? offset : 0); + var m = date.monthOfYear() + (period === 'm' ? offset : 0); + var d = date.day();// + (period === 'd' ? offset : 0) + + //(period === 'w' ? offset * this.daysInWeek() : 0); + var resyncYearMonth = function(calendar) { + while (m < calendar.minMonth) { + y--; + m += calendar.monthsInYear(y); + } + var yearMonths = calendar.monthsInYear(y); + while (m > yearMonths - 1 + calendar.minMonth) { + y++; + m -= yearMonths; + yearMonths = calendar.monthsInYear(y); + } + }; + if (period === 'y') { + if (date.month() !== this.fromMonthOfYear(y, m)) { // Hebrew + m = this.newDate(y, date.month(), this.minDay).monthOfYear(); + } + m = Math.min(m, this.monthsInYear(y)); + d = Math.min(d, this.daysInMonth(y, this.fromMonthOfYear(y, m))); + } + else if (period === 'm') { + resyncYearMonth(this); + d = Math.min(d, this.daysInMonth(y, this.fromMonthOfYear(y, m))); + } + var ymd = [y, this.fromMonthOfYear(y, m), d]; + this._validateLevel--; + return ymd; + } + catch (e) { + this._validateLevel--; + throw e; + } + }, + + /** Correct a candidate date after adding period(s) to a date. + Handle no year zero if necessary. + @memberof BaseCalendar + @private + @param date {CDate} The starting date. + @param ymd {number[]} The added date. + @param offset {number} The number of periods to adjust by. + @param period {string} One of 'y' for year, 'm' for month, 'w' for week, 'd' for day. + @return {CDate} The updated date. */ + _correctAdd: function(date, ymd, offset, period) { + if (!this.hasYearZero && (period === 'y' || period === 'm')) { + if (ymd[0] === 0 || // In year zero + (date.year() > 0) !== (ymd[0] > 0)) { // Crossed year zero + var adj = {y: [1, 1, 'y'], m: [1, this.monthsInYear(-1), 'm'], + w: [this.daysInWeek(), this.daysInYear(-1), 'd'], + d: [1, this.daysInYear(-1), 'd']}[period]; + var dir = (offset < 0 ? -1 : +1); + ymd = this._add(date, offset * adj[0] + dir * adj[1], adj[2]); + } + } + return date.date(ymd[0], ymd[1], ymd[2]); + }, + + /** Set a portion of the date. + @memberof BaseCalendar + @param date {CDate} The starting date. + @param value {number} The new value for the period. + @param period {string} One of 'y' for year, 'm' for month, 'd' for day. + @return {CDate} The updated date. + @throws Error if an invalid date or a different calendar used. */ + set: function(date, value, period) { + this._validate(date, this.minMonth, this.minDay, + _exports.local.invalidDate || _exports.regionalOptions[''].invalidDate); + var y = (period === 'y' ? value : date.year()); + var m = (period === 'm' ? value : date.month()); + var d = (period === 'd' ? value : date.day()); + if (period === 'y' || period === 'm') { + d = Math.min(d, this.daysInMonth(y, m)); + } + return date.date(y, m, d); + }, + + /** Determine whether a date is valid for this calendar. + @memberof BaseCalendar + @param year {number} The year to examine. + @param month {number} The month to examine. + @param day {number} The day to examine. + @return {boolean} true if a valid date, false if not. */ + isValid: function(year, month, day) { + this._validateLevel++; + var valid = (this.hasYearZero || year !== 0); + if (valid) { + var date = this.newDate(year, month, this.minDay); + valid = (month >= this.minMonth && month - this.minMonth < this.monthsInYear(date)) && + (day >= this.minDay && day - this.minDay < this.daysInMonth(date)); + } + this._validateLevel--; + return valid; + }, + + /** Convert the date to a standard (Gregorian) JavaScript Date. + @memberof BaseCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {Date} The equivalent JavaScript date. + @throws Error if an invalid date or a different calendar used. */ + toJSDate: function(year, month, day) { + var date = this._validate(year, month, day, + _exports.local.invalidDate || _exports.regionalOptions[''].invalidDate); + return _exports.instance().fromJD(this.toJD(date)).toJSDate(); + }, + + /** Convert the date from a standard (Gregorian) JavaScript Date. + @memberof BaseCalendar + @param jsd {Date} The JavaScript date. + @return {CDate} The equivalent calendar date. */ + fromJSDate: function(jsd) { + return this.fromJD(_exports.instance().fromJSDate(jsd).toJD()); + }, + + /** Check that a candidate date is from the same calendar and is valid. + @memberof BaseCalendar + @private + @param year {CDate|number} The date to validate or the year to validate. + @param [month] {number} The month to validate. + @param [day] {number} The day to validate. + @param error {string} Rrror message if invalid. + @throws Error if different calendars used or invalid date. */ + _validate: function(year, month, day, error) { + if (year.year) { + if (this._validateLevel === 0 && this.name !== year.calendar().name) { + throw (_exports.local.differentCalendars || _exports.regionalOptions[''].differentCalendars). + replace(/\{0\}/, this.local.name).replace(/\{1\}/, year.calendar().local.name); + } + return year; + } + try { + this._validateLevel++; + if (this._validateLevel === 1 && !this.isValid(year, month, day)) { + throw error.replace(/\{0\}/, this.local.name); + } + var date = this.newDate(year, month, day); + this._validateLevel--; + return date; + } + catch (e) { + this._validateLevel--; + throw e; + } + } +}); + +/** Implementation of the Proleptic Gregorian Calendar. + See http://en.wikipedia.org/wiki/Gregorian_calendar + and http://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar. + @class GregorianCalendar + @augments BaseCalendar + @param [language=''] {string} The language code (default English) for localisation. */ +function GregorianCalendar(language) { + this.local = this.regionalOptions[language] || this.regionalOptions['']; +} + +GregorianCalendar.prototype = new BaseCalendar; + +assign(GregorianCalendar.prototype, { + /** The calendar name. + @memberof GregorianCalendar */ + name: 'Gregorian', + /** Julian date of start of Gregorian epoch: 1 January 0001 CE. + @memberof GregorianCalendar */ + jdEpoch: 1721425.5, + /** Days per month in a common year. + @memberof GregorianCalendar */ + daysPerMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], + /** true if has a year zero, false if not. + @memberof GregorianCalendar */ + hasYearZero: false, + /** The minimum month number. + @memberof GregorianCalendar */ + minMonth: 1, + /** The first month in the year. + @memberof GregorianCalendar */ + firstMonth: 1, + /** The minimum day number. + @memberof GregorianCalendar */ + minDay: 1, + + /** Localisations for the plugin. + Entries are objects indexed by the language code ('' being the default US/English). + Each object has the following attributes. + @memberof GregorianCalendar + @property name {string} The calendar name. + @property epochs {string[]} The epoch names. + @property monthNames {string[]} The long names of the months of the year. + @property monthNamesShort {string[]} The short names of the months of the year. + @property dayNames {string[]} The long names of the days of the week. + @property dayNamesShort {string[]} The short names of the days of the week. + @property dayNamesMin {string[]} The minimal names of the days of the week. + @property dateFormat {string} The date format for this calendar. + See the options on formatDate for details. + @property firstDay {number} The number of the first day of the week, starting at 0. + @property isRTL {number} true if this localisation reads right-to-left. */ + regionalOptions: { // Localisations + '': { + name: 'Gregorian', + epochs: ['BCE', 'CE'], + monthNames: ['January', 'February', 'March', 'April', 'May', 'June', + 'July', 'August', 'September', 'October', 'November', 'December'], + monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], + dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], + dayNamesMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], + digits: null, + dateFormat: 'mm/dd/yyyy', + firstDay: 0, + isRTL: false + } + }, + + /** Determine whether this date is in a leap year. + @memberof GregorianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @return {boolean} true if this is a leap year, false if not. + @throws Error if an invalid year or a different calendar used. */ + leapYear: function(year) { + var date = this._validate(year, this.minMonth, this.minDay, + _exports.local.invalidYear || _exports.regionalOptions[''].invalidYear); + var year = date.year() + (date.year() < 0 ? 1 : 0); // No year zero + return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0); + }, + + /** Determine the week of the year for a date - ISO 8601. + @memberof GregorianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {number} The week of the year, starting from 1. + @throws Error if an invalid date or a different calendar used. */ + weekOfYear: function(year, month, day) { + // Find Thursday of this week starting on Monday + var checkDate = this.newDate(year, month, day); + checkDate.add(4 - (checkDate.dayOfWeek() || 7), 'd'); + return Math.floor((checkDate.dayOfYear() - 1) / 7) + 1; + }, + + /** Retrieve the number of days in a month. + @memberof GregorianCalendar + @param year {CDate|number} The date to examine or the year of the month. + @param [month] {number} The month. + @return {number} The number of days in this month. + @throws Error if an invalid month/year or a different calendar used. */ + daysInMonth: function(year, month) { + var date = this._validate(year, month, this.minDay, + _exports.local.invalidMonth || _exports.regionalOptions[''].invalidMonth); + return this.daysPerMonth[date.month() - 1] + + (date.month() === 2 && this.leapYear(date.year()) ? 1 : 0); + }, + + /** Determine whether this date is a week day. + @memberof GregorianCalendar + @param year {CDate|number} The date to examine or the year to examine. + @param [month] {number} The month to examine. + @param [day] {number} The day to examine. + @return {boolean} true if a week day, false if not. + @throws Error if an invalid date or a different calendar used. */ + weekDay: function(year, month, day) { + return (this.dayOfWeek(year, month, day) || 7) < 6; + }, + + /** Retrieve the Julian date equivalent for this date, + i.e. days since January 1, 4713 BCE Greenwich noon. + @memberof GregorianCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {number} The equivalent Julian date. + @throws Error if an invalid date or a different calendar used. */ + toJD: function(year, month, day) { + var date = this._validate(year, month, day, + _exports.local.invalidDate || _exports.regionalOptions[''].invalidDate); + year = date.year(); + month = date.month(); + day = date.day(); + if (year < 0) { year++; } // No year zero + // Jean Meeus algorithm, "Astronomical Algorithms", 1991 + if (month < 3) { + month += 12; + year--; + } + var a = Math.floor(year / 100); + var b = 2 - a + Math.floor(a / 4); + return Math.floor(365.25 * (year + 4716)) + + Math.floor(30.6001 * (month + 1)) + day + b - 1524.5; + }, + + /** Create a new date from a Julian date. + @memberof GregorianCalendar + @param jd {number} The Julian date to convert. + @return {CDate} The equivalent date. */ + fromJD: function(jd) { + // Jean Meeus algorithm, "Astronomical Algorithms", 1991 + var z = Math.floor(jd + 0.5); + var a = Math.floor((z - 1867216.25) / 36524.25); + a = z + 1 + a - Math.floor(a / 4); + var b = a + 1524; + var c = Math.floor((b - 122.1) / 365.25); + var d = Math.floor(365.25 * c); + var e = Math.floor((b - d) / 30.6001); + var day = b - d - Math.floor(e * 30.6001); + var month = e - (e > 13.5 ? 13 : 1); + var year = c - (month > 2.5 ? 4716 : 4715); + if (year <= 0) { year--; } // No year zero + return this.newDate(year, month, day); + }, + + /** Convert this date to a standard (Gregorian) JavaScript Date. + @memberof GregorianCalendar + @param year {CDate|number} The date to convert or the year to convert. + @param [month] {number} The month to convert. + @param [day] {number} The day to convert. + @return {Date} The equivalent JavaScript date. + @throws Error if an invalid date or a different calendar used. */ + toJSDate: function(year, month, day) { + var date = this._validate(year, month, day, + _exports.local.invalidDate || _exports.regionalOptions[''].invalidDate); + var jsd = new Date(date.year(), date.month() - 1, date.day()); + jsd.setHours(0); + jsd.setMinutes(0); + jsd.setSeconds(0); + jsd.setMilliseconds(0); + // Hours may be non-zero on daylight saving cut-over: + // > 12 when midnight changeover, but then cannot generate + // midnight datetime, so jump to 1AM, otherwise reset. + jsd.setHours(jsd.getHours() > 12 ? jsd.getHours() + 2 : 0); + return jsd; + }, + + /** Create a new date from a standard (Gregorian) JavaScript Date. + @memberof GregorianCalendar + @param jsd {Date} The JavaScript date to convert. + @return {CDate} The equivalent date. */ + fromJSDate: function(jsd) { + return this.newDate(jsd.getFullYear(), jsd.getMonth() + 1, jsd.getDate()); + } +}); + +// Singleton manager +var _exports = module.exports = new Calendars(); + +// Date template +_exports.cdate = CDate; + +// Base calendar template +_exports.baseCalendar = BaseCalendar; + +// Gregorian calendar implementation +_exports.calendars.gregorian = GregorianCalendar; + + +},{"object-assign":71}],136:[function(_dereq_,module,exports){ +/* + * World Calendars + * https://github.com/alexcjohnson/world-calendars + * + * Batch-converted from kbwood/calendars + * Many thanks to Keith Wood and all of the contributors to the original project! + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* http://keith-wood.name/calendars.html + Calendars extras for jQuery v2.0.2. + Written by Keith Wood (wood.keith{at}optusnet.com.au) August 2009. + Available under the MIT (http://keith-wood.name/licence.html) license. + Please attribute the author if you use it. */ + +var assign = _dereq_('object-assign'); +var main = _dereq_('./main'); + + +assign(main.regionalOptions[''], { + invalidArguments: 'Invalid arguments', + invalidFormat: 'Cannot format a date from another calendar', + missingNumberAt: 'Missing number at position {0}', + unknownNameAt: 'Unknown name at position {0}', + unexpectedLiteralAt: 'Unexpected literal at position {0}', + unexpectedText: 'Additional text found at end' +}); +main.local = main.regionalOptions['']; + +assign(main.cdate.prototype, { + + /** Format this date. + Found in the jquery.calendars.plus.js module. + @memberof CDate + @param [format] {string} The date format to use (see formatDate). + @param [settings] {object} Options for the formatDate function. + @return {string} The formatted date. */ + formatDate: function(format, settings) { + if (typeof format !== 'string') { + settings = format; + format = ''; + } + return this._calendar.formatDate(format || '', this, settings); + } +}); + +assign(main.baseCalendar.prototype, { + + UNIX_EPOCH: main.instance().newDate(1970, 1, 1).toJD(), + SECS_PER_DAY: 24 * 60 * 60, + TICKS_EPOCH: main.instance().jdEpoch, // 1 January 0001 CE + TICKS_PER_DAY: 24 * 60 * 60 * 10000000, + + /** Date form for ATOM (RFC 3339/ISO 8601). + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + ATOM: 'yyyy-mm-dd', + /** Date form for cookies. + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + COOKIE: 'D, dd M yyyy', + /** Date form for full date. + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + FULL: 'DD, MM d, yyyy', + /** Date form for ISO 8601. + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + ISO_8601: 'yyyy-mm-dd', + /** Date form for Julian date. + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + JULIAN: 'J', + /** Date form for RFC 822. + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + RFC_822: 'D, d M yy', + /** Date form for RFC 850. + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + RFC_850: 'DD, dd-M-yy', + /** Date form for RFC 1036. + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + RFC_1036: 'D, d M yy', + /** Date form for RFC 1123. + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + RFC_1123: 'D, d M yyyy', + /** Date form for RFC 2822. + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + RFC_2822: 'D, d M yyyy', + /** Date form for RSS (RFC 822). + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + RSS: 'D, d M yy', + /** Date form for Windows ticks. + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + TICKS: '!', + /** Date form for Unix timestamp. + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + TIMESTAMP: '@', + /** Date form for W3c (ISO 8601). + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar */ + W3C: 'yyyy-mm-dd', + + /** Format a date object into a string value. + The format can be combinations of the following: +
    +
  • d - day of month (no leading zero)
  • +
  • dd - day of month (two digit)
  • +
  • o - day of year (no leading zeros)
  • +
  • oo - day of year (three digit)
  • +
  • D - day name short
  • +
  • DD - day name long
  • +
  • w - week of year (no leading zero)
  • +
  • ww - week of year (two digit)
  • +
  • m - month of year (no leading zero)
  • +
  • mm - month of year (two digit)
  • +
  • M - month name short
  • +
  • MM - month name long
  • +
  • yy - year (two digit)
  • +
  • yyyy - year (four digit)
  • +
  • YYYY - formatted year
  • +
  • J - Julian date (days since January 1, 4713 BCE Greenwich noon)
  • +
  • @ - Unix timestamp (s since 01/01/1970)
  • +
  • ! - Windows ticks (100ns since 01/01/0001)
  • +
  • '...' - literal text
  • +
  • '' - single quote
  • +
+ Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar + @param [format] {string} The desired format of the date (defaults to calendar format). + @param date {CDate} The date value to format. + @param [settings] {object} Addition options, whose attributes include: + @property [dayNamesShort] {string[]} Abbreviated names of the days from Sunday. + @property [dayNames] {string[]} Names of the days from Sunday. + @property [monthNamesShort] {string[]} Abbreviated names of the months. + @property [monthNames] {string[]} Names of the months. + @property [calculateWeek] {CalendarsPickerCalculateWeek} Function that determines week of the year. + @property [localNumbers=false] {boolean} true to localise numbers (if available), + false to use normal Arabic numerals. + @return {string} The date in the above format. + @throws Errors if the date is from a different calendar. */ + formatDate: function(format, date, settings) { + if (typeof format !== 'string') { + settings = date; + date = format; + format = ''; + } + if (!date) { + return ''; + } + if (date.calendar() !== this) { + throw main.local.invalidFormat || main.regionalOptions[''].invalidFormat; + } + format = format || this.local.dateFormat; + settings = settings || {}; + var dayNamesShort = settings.dayNamesShort || this.local.dayNamesShort; + var dayNames = settings.dayNames || this.local.dayNames; + var monthNumbers = settings.monthNumbers || this.local.monthNumbers; + var monthNamesShort = settings.monthNamesShort || this.local.monthNamesShort; + var monthNames = settings.monthNames || this.local.monthNames; + var calculateWeek = settings.calculateWeek || this.local.calculateWeek; + // Check whether a format character is doubled + var doubled = function(match, step) { + var matches = 1; + while (iFormat + matches < format.length && format.charAt(iFormat + matches) === match) { + matches++; + } + iFormat += matches - 1; + return Math.floor(matches / (step || 1)) > 1; + }; + // Format a number, with leading zeroes if necessary + var formatNumber = function(match, value, len, step) { + var num = '' + value; + if (doubled(match, step)) { + while (num.length < len) { + num = '0' + num; + } + } + return num; + }; + // Format a name, short or long as requested + var formatName = function(match, value, shortNames, longNames) { + return (doubled(match) ? longNames[value] : shortNames[value]); + }; + // Format month number + // (e.g. Chinese calendar needs to account for intercalary months) + var calendar = this; + var formatMonth = function(date) { + return (typeof monthNumbers === 'function') ? + monthNumbers.call(calendar, date, doubled('m')) : + localiseNumbers(formatNumber('m', date.month(), 2)); + }; + // Format a month name, short or long as requested + var formatMonthName = function(date, useLongName) { + if (useLongName) { + return (typeof monthNames === 'function') ? + monthNames.call(calendar, date) : + monthNames[date.month() - calendar.minMonth]; + } else { + return (typeof monthNamesShort === 'function') ? + monthNamesShort.call(calendar, date) : + monthNamesShort[date.month() - calendar.minMonth]; + } + }; + // Localise numbers if requested and available + var digits = this.local.digits; + var localiseNumbers = function(value) { + return (settings.localNumbers && digits ? digits(value) : value); + }; + var output = ''; + var literal = false; + for (var iFormat = 0; iFormat < format.length; iFormat++) { + if (literal) { + if (format.charAt(iFormat) === "'" && !doubled("'")) { + literal = false; + } + else { + output += format.charAt(iFormat); + } + } + else { + switch (format.charAt(iFormat)) { + case 'd': output += localiseNumbers(formatNumber('d', date.day(), 2)); break; + case 'D': output += formatName('D', date.dayOfWeek(), + dayNamesShort, dayNames); break; + case 'o': output += formatNumber('o', date.dayOfYear(), 3); break; + case 'w': output += formatNumber('w', date.weekOfYear(), 2); break; + case 'm': output += formatMonth(date); break; + case 'M': output += formatMonthName(date, doubled('M')); break; + case 'y': + output += (doubled('y', 2) ? date.year() : + (date.year() % 100 < 10 ? '0' : '') + date.year() % 100); + break; + case 'Y': + doubled('Y', 2); + output += date.formatYear(); + break; + case 'J': output += date.toJD(); break; + case '@': output += (date.toJD() - this.UNIX_EPOCH) * this.SECS_PER_DAY; break; + case '!': output += (date.toJD() - this.TICKS_EPOCH) * this.TICKS_PER_DAY; break; + case "'": + if (doubled("'")) { + output += "'"; + } + else { + literal = true; + } + break; + default: + output += format.charAt(iFormat); + } + } + } + return output; + }, + + /** Parse a string value into a date object. + See formatDate for the possible formats, plus: +
    +
  • * - ignore rest of string
  • +
+ Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar + @param format {string} The expected format of the date ('' for default calendar format). + @param value {string} The date in the above format. + @param [settings] {object} Additional options whose attributes include: + @property [shortYearCutoff] {number} The cutoff year for determining the century. + @property [dayNamesShort] {string[]} Abbreviated names of the days from Sunday. + @property [dayNames] {string[]} Names of the days from Sunday. + @property [monthNamesShort] {string[]} Abbreviated names of the months. + @property [monthNames] {string[]} Names of the months. + @return {CDate} The extracted date value or null if value is blank. + @throws Errors if the format and/or value are missing, + if the value doesn't match the format, or if the date is invalid. */ + parseDate: function(format, value, settings) { + if (value == null) { + throw main.local.invalidArguments || main.regionalOptions[''].invalidArguments; + } + value = (typeof value === 'object' ? value.toString() : value + ''); + if (value === '') { + return null; + } + format = format || this.local.dateFormat; + settings = settings || {}; + var shortYearCutoff = settings.shortYearCutoff || this.shortYearCutoff; + shortYearCutoff = (typeof shortYearCutoff !== 'string' ? shortYearCutoff : + this.today().year() % 100 + parseInt(shortYearCutoff, 10)); + var dayNamesShort = settings.dayNamesShort || this.local.dayNamesShort; + var dayNames = settings.dayNames || this.local.dayNames; + var parseMonth = settings.parseMonth || this.local.parseMonth; + var monthNumbers = settings.monthNumbers || this.local.monthNumbers; + var monthNamesShort = settings.monthNamesShort || this.local.monthNamesShort; + var monthNames = settings.monthNames || this.local.monthNames; + var jd = -1; + var year = -1; + var month = -1; + var day = -1; + var doy = -1; + var shortYear = false; + var literal = false; + // Check whether a format character is doubled + var doubled = function(match, step) { + var matches = 1; + while (iFormat + matches < format.length && format.charAt(iFormat + matches) === match) { + matches++; + } + iFormat += matches - 1; + return Math.floor(matches / (step || 1)) > 1; + }; + // Extract a number from the string value + var getNumber = function(match, step) { + var isDoubled = doubled(match, step); + var size = [2, 3, isDoubled ? 4 : 2, isDoubled ? 4 : 2, 10, 11, 20]['oyYJ@!'.indexOf(match) + 1]; + var digits = new RegExp('^-?\\d{1,' + size + '}'); + var num = value.substring(iValue).match(digits); + if (!num) { + throw (main.local.missingNumberAt || main.regionalOptions[''].missingNumberAt). + replace(/\{0\}/, iValue); + } + iValue += num[0].length; + return parseInt(num[0], 10); + }; + // Extract a month number from the string value + var calendar = this; + var getMonthNumber = function() { + if (typeof monthNumbers === 'function') { + doubled('m'); // update iFormat + var month = monthNumbers.call(calendar, value.substring(iValue)); + iValue += month.length; + return month; + } + + return getNumber('m'); + }; + // Extract a name from the string value and convert to an index + var getName = function(match, shortNames, longNames, step) { + var names = (doubled(match, step) ? longNames : shortNames); + for (var i = 0; i < names.length; i++) { + if (value.substr(iValue, names[i].length).toLowerCase() === names[i].toLowerCase()) { + iValue += names[i].length; + return i + calendar.minMonth; + } + } + throw (main.local.unknownNameAt || main.regionalOptions[''].unknownNameAt). + replace(/\{0\}/, iValue); + }; + // Extract a month number from the string value + var getMonthName = function() { + if (typeof monthNames === 'function') { + var month = doubled('M') ? + monthNames.call(calendar, value.substring(iValue)) : + monthNamesShort.call(calendar, value.substring(iValue)); + iValue += month.length; + return month; + } + + return getName('M', monthNamesShort, monthNames); + }; + // Confirm that a literal character matches the string value + var checkLiteral = function() { + if (value.charAt(iValue) !== format.charAt(iFormat)) { + throw (main.local.unexpectedLiteralAt || + main.regionalOptions[''].unexpectedLiteralAt).replace(/\{0\}/, iValue); + } + iValue++; + }; + var iValue = 0; + for (var iFormat = 0; iFormat < format.length; iFormat++) { + if (literal) { + if (format.charAt(iFormat) === "'" && !doubled("'")) { + literal = false; + } + else { + checkLiteral(); + } + } + else { + switch (format.charAt(iFormat)) { + case 'd': day = getNumber('d'); break; + case 'D': getName('D', dayNamesShort, dayNames); break; + case 'o': doy = getNumber('o'); break; + case 'w': getNumber('w'); break; + case 'm': month = getMonthNumber(); break; + case 'M': month = getMonthName(); break; + case 'y': + var iSave = iFormat; + shortYear = !doubled('y', 2); + iFormat = iSave; + year = getNumber('y', 2); + break; + case 'Y': year = getNumber('Y', 2); break; + case 'J': + jd = getNumber('J') + 0.5; + if (value.charAt(iValue) === '.') { + iValue++; + getNumber('J'); + } + break; + case '@': jd = getNumber('@') / this.SECS_PER_DAY + this.UNIX_EPOCH; break; + case '!': jd = getNumber('!') / this.TICKS_PER_DAY + this.TICKS_EPOCH; break; + case '*': iValue = value.length; break; + case "'": + if (doubled("'")) { + checkLiteral(); + } + else { + literal = true; + } + break; + default: checkLiteral(); + } + } + } + if (iValue < value.length) { + throw main.local.unexpectedText || main.regionalOptions[''].unexpectedText; + } + if (year === -1) { + year = this.today().year(); + } + else if (year < 100 && shortYear) { + year += (shortYearCutoff === -1 ? 1900 : this.today().year() - + this.today().year() % 100 - (year <= shortYearCutoff ? 0 : 100)); + } + if (typeof month === 'string') { + month = parseMonth.call(this, year, month); + } + if (doy > -1) { + month = 1; + day = doy; + for (var dim = this.daysInMonth(year, month); day > dim; dim = this.daysInMonth(year, month)) { + month++; + day -= dim; + } + } + return (jd > -1 ? this.fromJD(jd) : this.newDate(year, month, day)); + }, + + /** A date may be specified as an exact value or a relative one. + Found in the jquery.calendars.plus.js module. + @memberof BaseCalendar + @param dateSpec {CDate|number|string} The date as an object or string in the given format or + an offset - numeric days from today, or string amounts and periods, e.g. '+1m +2w'. + @param defaultDate {CDate} The date to use if no other supplied, may be null. + @param currentDate {CDate} The current date as a possible basis for relative dates, + if null today is used (optional) + @param [dateFormat] {string} The expected date format - see formatDate. + @param [settings] {object} Additional options whose attributes include: + @property [shortYearCutoff] {number} The cutoff year for determining the century. + @property [dayNamesShort] {string[]} Abbreviated names of the days from Sunday. + @property [dayNames] {string[]} Names of the days from Sunday. + @property [monthNamesShort] {string[]} Abbreviated names of the months. + @property [monthNames] {string[]} Names of the months. + @return {CDate} The decoded date. */ + determineDate: function(dateSpec, defaultDate, currentDate, dateFormat, settings) { + if (currentDate && typeof currentDate !== 'object') { + settings = dateFormat; + dateFormat = currentDate; + currentDate = null; + } + if (typeof dateFormat !== 'string') { + settings = dateFormat; + dateFormat = ''; + } + var calendar = this; + var offsetString = function(offset) { + try { + return calendar.parseDate(dateFormat, offset, settings); + } + catch (e) { + // Ignore + } + offset = offset.toLowerCase(); + var date = (offset.match(/^c/) && currentDate ? + currentDate.newDate() : null) || calendar.today(); + var pattern = /([+-]?[0-9]+)\s*(d|w|m|y)?/g; + var matches = pattern.exec(offset); + while (matches) { + date.add(parseInt(matches[1], 10), matches[2] || 'd'); + matches = pattern.exec(offset); + } + return date; + }; + defaultDate = (defaultDate ? defaultDate.newDate() : null); + dateSpec = (dateSpec == null ? defaultDate : + (typeof dateSpec === 'string' ? offsetString(dateSpec) : (typeof dateSpec === 'number' ? + (isNaN(dateSpec) || dateSpec === Infinity || dateSpec === -Infinity ? defaultDate : + calendar.today().add(dateSpec, 'd')) : calendar.newDate(dateSpec)))); + return dateSpec; + } +}); + + +},{"./main":135,"object-assign":71}],137:[function(_dereq_,module,exports){ 'use strict'; /** @@ -20612,15 +30666,7 @@ module.exports = [ } ]; -},{}],90:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],138:[function(_dereq_,module,exports){ 'use strict'; var ARROWPATHS = _dereq_('./arrow_paths'); @@ -20659,192 +30705,143 @@ function arrowCoordinateDescription(axis, lower, upper) { module.exports = templatedArray('annotation', { visible: { valType: 'boolean', - dflt: true, editType: 'calc+arraydraw', - }, text: { valType: 'string', - editType: 'calc+arraydraw', - }, textangle: { valType: 'angle', dflt: 0, - editType: 'calc+arraydraw', - }, font: fontAttrs({ editType: 'calc+arraydraw', colorEditType: 'arraydraw', - }), width: { valType: 'number', min: 1, dflt: null, - editType: 'calc+arraydraw', - }, height: { valType: 'number', min: 1, dflt: null, - editType: 'calc+arraydraw', - }, opacity: { valType: 'number', min: 0, max: 1, dflt: 1, - editType: 'arraydraw', - }, align: { valType: 'enumerated', values: ['left', 'center', 'right'], dflt: 'center', - editType: 'arraydraw', - }, valign: { valType: 'enumerated', values: ['top', 'middle', 'bottom'], dflt: 'middle', - editType: 'arraydraw', - }, bgcolor: { valType: 'color', dflt: 'rgba(0,0,0,0)', - editType: 'arraydraw', - }, bordercolor: { valType: 'color', dflt: 'rgba(0,0,0,0)', - editType: 'arraydraw', - }, borderpad: { valType: 'number', min: 0, dflt: 1, - editType: 'calc+arraydraw', - }, borderwidth: { valType: 'number', min: 0, dflt: 1, - editType: 'calc+arraydraw', - }, // arrow showarrow: { valType: 'boolean', dflt: true, - editType: 'calc+arraydraw', - }, arrowcolor: { valType: 'color', - editType: 'arraydraw', - }, arrowhead: { valType: 'integer', min: 0, max: ARROWPATHS.length, dflt: 1, - editType: 'arraydraw', - }, startarrowhead: { valType: 'integer', min: 0, max: ARROWPATHS.length, dflt: 1, - editType: 'arraydraw', - }, arrowside: { valType: 'flaglist', flags: ['end', 'start'], extras: ['none'], dflt: 'end', - editType: 'arraydraw', - }, arrowsize: { valType: 'number', min: 0.3, dflt: 1, - editType: 'calc+arraydraw', - }, startarrowsize: { valType: 'number', min: 0.3, dflt: 1, - editType: 'calc+arraydraw', - }, arrowwidth: { valType: 'number', min: 0.1, - editType: 'calc+arraydraw', - }, standoff: { valType: 'number', min: 0, dflt: 0, - editType: 'calc+arraydraw', - }, startstandoff: { valType: 'number', min: 0, dflt: 0, - editType: 'calc+arraydraw', - }, ax: { valType: 'any', - editType: 'calc+arraydraw', - }, ay: { valType: 'any', - editType: 'calc+arraydraw', - }, axref: { valType: 'enumerated', @@ -20853,9 +30850,7 @@ module.exports = templatedArray('annotation', { 'pixel', cartesianConstants.idRegex.x.toString() ], - editType: 'calc', - }, ayref: { valType: 'enumerated', @@ -20864,9 +30859,7 @@ module.exports = templatedArray('annotation', { 'pixel', cartesianConstants.idRegex.y.toString() ], - editType: 'calc', - }, // positioning xref: { @@ -20875,30 +30868,22 @@ module.exports = templatedArray('annotation', { 'paper', cartesianConstants.idRegex.x.toString() ], - editType: 'calc', - }, x: { valType: 'any', - editType: 'calc+arraydraw', - }, xanchor: { valType: 'enumerated', values: ['auto', 'left', 'center', 'right'], dflt: 'auto', - editType: 'calc+arraydraw', - }, xshift: { valType: 'number', dflt: 0, - editType: 'calc+arraydraw', - }, yref: { valType: 'enumerated', @@ -20906,104 +30891,70 @@ module.exports = templatedArray('annotation', { 'paper', cartesianConstants.idRegex.y.toString() ], - editType: 'calc', - }, y: { valType: 'any', - editType: 'calc+arraydraw', - }, yanchor: { valType: 'enumerated', values: ['auto', 'top', 'middle', 'bottom'], dflt: 'auto', - editType: 'calc+arraydraw', - }, yshift: { valType: 'number', dflt: 0, - editType: 'calc+arraydraw', - }, clicktoshow: { valType: 'enumerated', values: [false, 'onoff', 'onout'], dflt: false, - editType: 'arraydraw', - }, xclick: { valType: 'any', - editType: 'arraydraw', - }, yclick: { valType: 'any', - editType: 'arraydraw', - }, hovertext: { valType: 'string', - editType: 'arraydraw', - }, hoverlabel: { bgcolor: { valType: 'color', - editType: 'arraydraw', - }, bordercolor: { valType: 'color', - editType: 'arraydraw', - }, font: fontAttrs({ editType: 'arraydraw', - }), editType: 'arraydraw' }, captureevents: { valType: 'boolean', - editType: 'arraydraw', - }, editType: 'calc', _deprecated: { ref: { valType: 'string', - editType: 'calc', - } } }); -},{"../../constants/axis_placeable_objects":208,"../../plot_api/plot_template":268,"../../plots/cartesian/constants":285,"../../plots/font_attributes":307,"./arrow_paths":89}],91:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../constants/axis_placeable_objects":261,"../../plot_api/plot_template":320,"../../plots/cartesian/constants":337,"../../plots/font_attributes":359,"./arrow_paths":137}],139:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -21085,15 +31036,7 @@ function calcAxisExpansion(ann, ax) { ann._extremes[axId] = extremes; } -},{"../../lib":233,"../../plots/cartesian/axes":279,"./draw":96}],92:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/cartesian/axes":331,"./draw":144}],140:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -21218,20 +31161,12 @@ function getToggleSets(gd, hoverData) { return {on: onSet, off: offSet, explicitOff: explicitOffSet}; } -// to handle log axes until v2 +// to handle log axes until v3 function clickData2r(d, ax) { return ax.type === 'log' ? ax.l2r(d) : ax.d2r(d); } -},{"../../lib":233,"../../plot_api/plot_template":268,"../../registry":326}],93:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plot_api/plot_template":320,"../../registry":373}],141:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -21302,16 +31237,7 @@ module.exports = function handleAnnotationCommonDefaults(annIn, annOut, fullLayo coerce('captureevents', !!hoverText); }; -},{"../../lib":233,"../color":105}],94:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../color":155}],142:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -21321,7 +31247,7 @@ var toLogRange = _dereq_('../../lib/to_log_range'); * convertCoords: when converting an axis between log and linear * you need to alter any annotations on that axis to keep them * pointing at the same data point. - * In v2.0 this will become obsolete + * In v3.0 this will become obsolete * * gd: the plot div * ax: the axis being changed @@ -21365,16 +31291,7 @@ module.exports = function convertCoords(gd, ax, newType, doExtra) { } }; -},{"../../lib/to_log_range":257,"fast-isnumeric":23}],95:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib/to_log_range":309,"fast-isnumeric":31}],143:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -21473,18 +31390,10 @@ function handleAnnotationDefaults(annIn, annOut, fullLayout) { } } -},{"../../lib":233,"../../plots/array_container_defaults":274,"../../plots/cartesian/axes":279,"./attributes":90,"./common_defaults":93}],96:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/array_container_defaults":326,"../../plots/cartesian/axes":331,"./attributes":138,"./common_defaults":141}],144:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Registry = _dereq_('../../registry'); var Plots = _dereq_('../../plots/plots'); @@ -22234,19 +32143,10 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { } else annText.call(textLayout); } -},{"../../lib":233,"../../lib/setcursor":253,"../../lib/svg_text_utils":255,"../../plot_api/plot_template":268,"../../plots/cartesian/axes":279,"../../plots/plots":313,"../../registry":326,"../color":105,"../dragelement":124,"../drawing":127,"../fx":145,"./draw_arrow_head":97,"d3":21}],97:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../lib/setcursor":305,"../../lib/svg_text_utils":307,"../../plot_api/plot_template":320,"../../plots/cartesian/axes":331,"../../plots/plots":366,"../../registry":373,"../color":155,"../dragelement":174,"../drawing":177,"../fx":195,"./draw_arrow_head":145,"@plotly/d3":20}],145:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Color = _dereq_('../color'); @@ -22390,16 +32290,7 @@ module.exports = function drawArrowHead(el3, ends, options) { if(doEnd) drawhead(headStyle, end, endRot, scale); }; -},{"../../lib":233,"../color":105,"./arrow_paths":89,"d3":21}],98:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../color":155,"./arrow_paths":137,"@plotly/d3":20}],146:[function(_dereq_,module,exports){ 'use strict'; var drawModule = _dereq_('./draw'); @@ -22424,16 +32315,7 @@ module.exports = { convertCoords: _dereq_('./convert_coords') }; -},{"../../plots/cartesian/include_components":291,"./attributes":90,"./calc_autorange":91,"./click":92,"./convert_coords":94,"./defaults":95,"./draw":96}],99:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../plots/cartesian/include_components":343,"./attributes":138,"./calc_autorange":139,"./click":140,"./convert_coords":142,"./defaults":143,"./draw":144}],147:[function(_dereq_,module,exports){ 'use strict'; var annAttrs = _dereq_('../annotations/attributes'); @@ -22444,28 +32326,18 @@ module.exports = overrideAll(templatedArray('annotation', { visible: annAttrs.visible, x: { valType: 'any', - - }, y: { valType: 'any', - - }, z: { valType: 'any', - - }, ax: { valType: 'number', - - }, ay: { valType: 'number', - - }, xanchor: annAttrs.xanchor, @@ -22512,15 +32384,7 @@ module.exports = overrideAll(templatedArray('annotation', { // zref: 'z' }), 'calc', 'from-root'); -},{"../../plot_api/edit_types":261,"../../plot_api/plot_template":268,"../annotations/attributes":90}],100:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plot_api/edit_types":313,"../../plot_api/plot_template":320,"../annotations/attributes":138}],148:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -22577,15 +32441,7 @@ function mockAnnAxes(ann, scene) { }; } -},{"../../lib":233,"../../plots/cartesian/axes":279}],101:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/cartesian/axes":331}],149:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -22653,15 +32509,7 @@ function handleAnnotationDefaults(annIn, annOut, sceneLayout, opts) { } } -},{"../../lib":233,"../../plots/array_container_defaults":274,"../../plots/cartesian/axes":279,"../annotations/common_defaults":93,"./attributes":99}],102:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/array_container_defaults":326,"../../plots/cartesian/axes":331,"../annotations/common_defaults":141,"./attributes":147}],150:[function(_dereq_,module,exports){ 'use strict'; var drawRaw = _dereq_('../annotations/draw').drawRaw; @@ -22705,15 +32553,7 @@ module.exports = function draw(scene) { } }; -},{"../../plots/gl3d/project":310,"../annotations/draw":96}],103:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/gl3d/project":362,"../annotations/draw":144}],151:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -22753,15 +32593,298 @@ function includeGL3D(layoutIn, layoutOut) { } } -},{"../../lib":233,"../../registry":326,"./attributes":99,"./convert":100,"./defaults":101,"./draw":102}],104:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +},{"../../lib":285,"../../registry":373,"./attributes":147,"./convert":148,"./defaults":149,"./draw":150}],152:[function(_dereq_,module,exports){ +'use strict'; +// a trimmed down version of: +// https://github.com/alexcjohnson/world-calendars/blob/master/dist/index.js + +module.exports = _dereq_('world-calendars/dist/main'); + +_dereq_('world-calendars/dist/plus'); + +_dereq_('world-calendars/dist/calendars/chinese'); +_dereq_('world-calendars/dist/calendars/coptic'); +_dereq_('world-calendars/dist/calendars/discworld'); +_dereq_('world-calendars/dist/calendars/ethiopian'); +_dereq_('world-calendars/dist/calendars/hebrew'); +_dereq_('world-calendars/dist/calendars/islamic'); +_dereq_('world-calendars/dist/calendars/julian'); +_dereq_('world-calendars/dist/calendars/mayan'); +_dereq_('world-calendars/dist/calendars/nanakshahi'); +_dereq_('world-calendars/dist/calendars/nepali'); +_dereq_('world-calendars/dist/calendars/persian'); +_dereq_('world-calendars/dist/calendars/taiwan'); +_dereq_('world-calendars/dist/calendars/thai'); +_dereq_('world-calendars/dist/calendars/ummalqura'); + +},{"world-calendars/dist/calendars/chinese":121,"world-calendars/dist/calendars/coptic":122,"world-calendars/dist/calendars/discworld":123,"world-calendars/dist/calendars/ethiopian":124,"world-calendars/dist/calendars/hebrew":125,"world-calendars/dist/calendars/islamic":126,"world-calendars/dist/calendars/julian":127,"world-calendars/dist/calendars/mayan":128,"world-calendars/dist/calendars/nanakshahi":129,"world-calendars/dist/calendars/nepali":130,"world-calendars/dist/calendars/persian":131,"world-calendars/dist/calendars/taiwan":132,"world-calendars/dist/calendars/thai":133,"world-calendars/dist/calendars/ummalqura":134,"world-calendars/dist/main":135,"world-calendars/dist/plus":136}],153:[function(_dereq_,module,exports){ +'use strict'; + +var calendars = _dereq_('./calendars'); + +var Lib = _dereq_('../../lib'); +var constants = _dereq_('../../constants/numerical'); + +var EPOCHJD = constants.EPOCHJD; +var ONEDAY = constants.ONEDAY; + +var attributes = { + valType: 'enumerated', + values: Object.keys(calendars.calendars), + editType: 'calc', + dflt: 'gregorian' +}; + +var handleDefaults = function(contIn, contOut, attr, dflt) { + var attrs = {}; + attrs[attr] = attributes; + + return Lib.coerce(contIn, contOut, attrs, attr, dflt); +}; + +var handleTraceDefaults = function(traceIn, traceOut, coords, layout) { + for(var i = 0; i < coords.length; i++) { + handleDefaults(traceIn, traceOut, coords[i] + 'calendar', layout.calendar); + } +}; + +// each calendar needs its own default canonical tick. I would love to use +// 2000-01-01 (or even 0000-01-01) for them all but they don't necessarily +// all support either of those dates. Instead I'll use the most significant +// number they *do* support, biased toward the present day. +var CANONICAL_TICK = { + chinese: '2000-01-01', + coptic: '2000-01-01', + discworld: '2000-01-01', + ethiopian: '2000-01-01', + hebrew: '5000-01-01', + islamic: '1000-01-01', + julian: '2000-01-01', + mayan: '5000-01-01', + nanakshahi: '1000-01-01', + nepali: '2000-01-01', + persian: '1000-01-01', + jalali: '1000-01-01', + taiwan: '1000-01-01', + thai: '2000-01-01', + ummalqura: '1400-01-01' +}; + +// Start on a Sunday - for week ticks +// Discworld and Mayan calendars don't have 7-day weeks but we're going to give them +// 7-day week ticks so start on our Sundays. +// If anyone really cares we can customize the auto tick spacings for these calendars. +var CANONICAL_SUNDAY = { + chinese: '2000-01-02', + coptic: '2000-01-03', + discworld: '2000-01-03', + ethiopian: '2000-01-05', + hebrew: '5000-01-01', + islamic: '1000-01-02', + julian: '2000-01-03', + mayan: '5000-01-01', + nanakshahi: '1000-01-05', + nepali: '2000-01-05', + persian: '1000-01-01', + jalali: '1000-01-01', + taiwan: '1000-01-04', + thai: '2000-01-04', + ummalqura: '1400-01-06' +}; + +var DFLTRANGE = { + chinese: ['2000-01-01', '2001-01-01'], + coptic: ['1700-01-01', '1701-01-01'], + discworld: ['1800-01-01', '1801-01-01'], + ethiopian: ['2000-01-01', '2001-01-01'], + hebrew: ['5700-01-01', '5701-01-01'], + islamic: ['1400-01-01', '1401-01-01'], + julian: ['2000-01-01', '2001-01-01'], + mayan: ['5200-01-01', '5201-01-01'], + nanakshahi: ['0500-01-01', '0501-01-01'], + nepali: ['2000-01-01', '2001-01-01'], + persian: ['1400-01-01', '1401-01-01'], + jalali: ['1400-01-01', '1401-01-01'], + taiwan: ['0100-01-01', '0101-01-01'], + thai: ['2500-01-01', '2501-01-01'], + ummalqura: ['1400-01-01', '1401-01-01'] +}; + +/* + * convert d3 templates to world-calendars templates, so our users only need + * to know d3's specifiers. Map space padding to no padding, and unknown fields + * to an ugly placeholder + */ +var UNKNOWN = '##'; +var d3ToWorldCalendars = { + 'd': {'0': 'dd', '-': 'd'}, // 2-digit or unpadded day of month + 'e': {'0': 'd', '-': 'd'}, // alternate, always unpadded day of month + 'a': {'0': 'D', '-': 'D'}, // short weekday name + 'A': {'0': 'DD', '-': 'DD'}, // full weekday name + 'j': {'0': 'oo', '-': 'o'}, // 3-digit or unpadded day of the year + 'W': {'0': 'ww', '-': 'w'}, // 2-digit or unpadded week of the year (Monday first) + 'm': {'0': 'mm', '-': 'm'}, // 2-digit or unpadded month number + 'b': {'0': 'M', '-': 'M'}, // short month name + 'B': {'0': 'MM', '-': 'MM'}, // full month name + 'y': {'0': 'yy', '-': 'yy'}, // 2-digit year (map unpadded to zero-padded) + 'Y': {'0': 'yyyy', '-': 'yyyy'}, // 4-digit year (map unpadded to zero-padded) + 'U': UNKNOWN, // Sunday-first week of the year + 'w': UNKNOWN, // day of the week [0(sunday),6] + // combined format, we replace the date part with the world-calendar version + // and the %X stays there for d3 to handle with time parts + 'c': {'0': 'D M d %X yyyy', '-': 'D M d %X yyyy'}, + 'x': {'0': 'mm/dd/yyyy', '-': 'mm/dd/yyyy'} +}; + +function worldCalFmt(fmt, x, calendar) { + var dateJD = Math.floor((x + 0.05) / ONEDAY) + EPOCHJD; + var cDate = getCal(calendar).fromJD(dateJD); + var i = 0; + var modifier, directive, directiveLen, directiveObj, replacementPart; + + while((i = fmt.indexOf('%', i)) !== -1) { + modifier = fmt.charAt(i + 1); + if(modifier === '0' || modifier === '-' || modifier === '_') { + directiveLen = 3; + directive = fmt.charAt(i + 2); + if(modifier === '_') modifier = '-'; + } else { + directive = modifier; + modifier = '0'; + directiveLen = 2; + } + directiveObj = d3ToWorldCalendars[directive]; + if(!directiveObj) { + i += directiveLen; + } else { + // code is recognized as a date part but world-calendars doesn't support it + if(directiveObj === UNKNOWN) replacementPart = UNKNOWN; + + // format the cDate according to the translated directive + else replacementPart = cDate.formatDate(directiveObj[modifier]); + + fmt = fmt.substr(0, i) + replacementPart + fmt.substr(i + directiveLen); + i += replacementPart.length; + } + } + return fmt; +} + +// cache world calendars, so we don't have to reinstantiate +// during each date-time conversion +var allCals = {}; +function getCal(calendar) { + var calendarObj = allCals[calendar]; + if(calendarObj) return calendarObj; + + calendarObj = allCals[calendar] = calendars.instance(calendar); + return calendarObj; +} + +function makeAttrs(description) { + return Lib.extendFlat({}, attributes, { description: description }); +} + +function makeTraceAttrsDescription(coord) { + return 'Sets the calendar system to use with `' + coord + '` date data.'; +} + +var xAttrs = { + xcalendar: makeAttrs(makeTraceAttrsDescription('x')) +}; + +var xyAttrs = Lib.extendFlat({}, xAttrs, { + ycalendar: makeAttrs(makeTraceAttrsDescription('y')) +}); + +var xyzAttrs = Lib.extendFlat({}, xyAttrs, { + zcalendar: makeAttrs(makeTraceAttrsDescription('z')) +}); + +var axisAttrs = makeAttrs([ + 'Sets the calendar system to use for `range` and `tick0`', + 'if this is a date axis. This does not set the calendar for', + 'interpreting data on this axis, that\'s specified in the trace', + 'or via the global `layout.calendar`' +].join(' ')); + +module.exports = { + moduleType: 'component', + name: 'calendars', + + schema: { + traces: { + scatter: xyAttrs, + bar: xyAttrs, + box: xyAttrs, + heatmap: xyAttrs, + contour: xyAttrs, + histogram: xyAttrs, + histogram2d: xyAttrs, + histogram2dcontour: xyAttrs, + scatter3d: xyzAttrs, + surface: xyzAttrs, + mesh3d: xyzAttrs, + scattergl: xyAttrs, + ohlc: xAttrs, + candlestick: xAttrs + }, + layout: { + calendar: makeAttrs([ + 'Sets the default calendar system to use for interpreting and', + 'displaying dates throughout the plot.' + ].join(' ')) + }, + subplots: { + xaxis: {calendar: axisAttrs}, + yaxis: {calendar: axisAttrs}, + scene: { + xaxis: {calendar: axisAttrs}, + // TODO: it's actually redundant to include yaxis and zaxis here + // because in the scene attributes these are the same object so merging + // into one merges into them all. However, I left them in for parity with + // cartesian, where yaxis is unused until we Plotschema.get() when we + // use its presence or absence to determine whether to delete attributes + // from yaxis if they only apply to x (rangeselector/rangeslider) + yaxis: {calendar: axisAttrs}, + zaxis: {calendar: axisAttrs} + }, + polar: { + radialaxis: {calendar: axisAttrs} + } + }, + transforms: { + filter: { + valuecalendar: makeAttrs([ + 'WARNING: All transforms are deprecated and may be removed from the API in next major version.', + 'Sets the calendar system to use for `value`, if it is a date.' + ].join(' ')), + targetcalendar: makeAttrs([ + 'WARNING: All transforms are deprecated and may be removed from the API in next major version.', + 'Sets the calendar system to use for `target`, if it is an', + 'array of dates. If `target` is a string (eg *x*) we use the', + 'corresponding trace attribute (eg `xcalendar`) if it exists,', + 'even if `targetcalendar` is provided.' + ].join(' ')) + } + } + }, + + layoutAttributes: attributes, + + handleDefaults: handleDefaults, + handleTraceDefaults: handleTraceDefaults, + + CANONICAL_SUNDAY: CANONICAL_SUNDAY, + CANONICAL_TICK: CANONICAL_TICK, + DFLTRANGE: DFLTRANGE, + + getCal: getCal, + worldCalFmt: worldCalFmt +}; + +},{"../../constants/numerical":265,"../../lib":285,"./calendars":152}],154:[function(_dereq_,module,exports){ 'use strict'; @@ -22793,20 +32916,12 @@ exports.borderLine = '#BEC8D9'; // gives back exactly lightLine if the other colors are defaults. exports.lightFraction = 100 * (0xe - 0x4) / (0xf - 0x4); -},{}],105:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],155:[function(_dereq_,module,exports){ 'use strict'; var tinycolor = _dereq_('tinycolor2'); var isNumeric = _dereq_('fast-isnumeric'); +var isTypedArray = _dereq_('../../lib/array').isTypedArray; var color = module.exports = {}; @@ -22921,7 +33036,7 @@ color.clean = function(container) { if(!Array.isArray(el0) && el0 && typeof el0 === 'object') { for(j = 0; j < val.length; j++) color.clean(val[j]); } - } else if(val && typeof val === 'object') color.clean(val); + } else if(val && typeof val === 'object' && !isTypedArray(val)) color.clean(val); } }; @@ -22967,15 +33082,7 @@ function cleanOne(val) { return 'rgb(' + rgbStr + ')'; } -},{"./attributes":104,"fast-isnumeric":23,"tinycolor2":88}],106:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib/array":271,"./attributes":154,"fast-isnumeric":31,"tinycolor2":119}],156:[function(_dereq_,module,exports){ 'use strict'; var axesAttrs = _dereq_('../../plots/cartesian/layout_attributes'); @@ -22988,82 +33095,61 @@ module.exports = overrideAll({ // TODO: only right is supported currently // orient: { // valType: 'enumerated', -// // values: ['left', 'right', 'top', 'bottom'], // dflt: 'right', -// +// // }, thicknessmode: { valType: 'enumerated', values: ['fraction', 'pixels'], - dflt: 'pixels', - }, thickness: { valType: 'number', - min: 0, dflt: 30, - }, lenmode: { valType: 'enumerated', values: ['fraction', 'pixels'], - dflt: 'fraction', - }, len: { valType: 'number', min: 0, dflt: 1, - - }, x: { valType: 'number', dflt: 1.02, min: -2, max: 3, - - }, xanchor: { valType: 'enumerated', values: ['left', 'center', 'right'], dflt: 'left', - - }, xpad: { valType: 'number', - min: 0, dflt: 10, - }, y: { valType: 'number', - dflt: 0.5, min: -2, max: 3, - }, yanchor: { valType: 'enumerated', values: ['top', 'middle', 'bottom'], - dflt: 'middle', - }, ypad: { valType: 'number', - min: 0, dflt: 10, - }, // a possible line around the bar itself outlinecolor: axesAttrs.linecolor, @@ -23073,16 +33159,12 @@ module.exports = overrideAll({ bordercolor: axesAttrs.linecolor, borderwidth: { valType: 'number', - min: 0, dflt: 0, - }, bgcolor: { valType: 'color', - dflt: 'rgba(0,0,0,0)', - }, // tick and title properties named and function exactly as in axes tickmode: axesAttrs.tickmode, @@ -23092,6 +33174,8 @@ module.exports = overrideAll({ tickvals: axesAttrs.tickvals, ticktext: axesAttrs.ticktext, ticks: extendFlat({}, axesAttrs.ticks, {dflt: ''}), + ticklabeloverflow: extendFlat({}, axesAttrs.ticklabeloverflow, { + }), ticklabelposition: { valType: 'enumerated', values: [ @@ -23100,15 +33184,12 @@ module.exports = overrideAll({ 'outside bottom', 'inside bottom' ], dflt: 'outside', - - }, ticklen: axesAttrs.ticklen, tickwidth: axesAttrs.tickwidth, tickcolor: axesAttrs.tickcolor, showticklabels: axesAttrs.showticklabels, tickfont: fontAttrs({ - }), tickangle: axesAttrs.tickangle, tickformat: axesAttrs.tickformat, @@ -23124,49 +33205,31 @@ module.exports = overrideAll({ title: { text: { valType: 'string', - - }, font: fontAttrs({ - }), side: { valType: 'enumerated', values: ['right', 'top', 'bottom'], - dflt: 'top', - } }, _deprecated: { title: { valType: 'string', - - }, titlefont: fontAttrs({ - }), titleside: { valType: 'enumerated', values: ['right', 'top', 'bottom'], - dflt: 'top', - } } }, 'colorbars', 'from-root'); -},{"../../lib/extend":227,"../../plot_api/edit_types":261,"../../plots/cartesian/layout_attributes":293,"../../plots/font_attributes":307}],107:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib/extend":279,"../../plot_api/edit_types":313,"../../plots/cartesian/layout_attributes":345,"../../plots/font_attributes":359}],157:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -23186,16 +33249,7 @@ module.exports = { } }; -},{}],108:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],158:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -23240,11 +33294,14 @@ module.exports = function colorbarDefaults(containerIn, containerOut, layout) { coerce('bordercolor'); coerce('borderwidth'); coerce('bgcolor'); + var ticklabelposition = coerce('ticklabelposition'); + coerce('ticklabeloverflow', ticklabelposition.indexOf('inside') !== -1 ? 'hide past domain' : 'hide past div'); handleTickValueDefaults(colorbarIn, colorbarOut, coerce, 'linear'); - var opts = {outerTicks: false, font: layout.font}; + var font = layout.font; + var opts = {outerTicks: false, font: font}; if(ticklabelposition.indexOf('inside') !== -1) { opts.bgColor = 'black'; // could we instead use the average of colors in the scale? } @@ -23252,22 +33309,20 @@ module.exports = function colorbarDefaults(containerIn, containerOut, layout) { handleTickMarkDefaults(colorbarIn, colorbarOut, coerce, 'linear', opts); coerce('title.text', layout._dfltTitle.colorbar); - Lib.coerceFont(coerce, 'title.font', layout.font); + + var tickFont = colorbarOut.tickfont; + var dfltTitleFont = Lib.extendFlat({}, tickFont, { + color: font.color, + size: Lib.bigFont(tickFont.size) + }); + Lib.coerceFont(coerce, 'title.font', dfltTitleFont); coerce('title.side'); }; -},{"../../lib":233,"../../plot_api/plot_template":268,"../../plots/cartesian/tick_label_defaults":300,"../../plots/cartesian/tick_mark_defaults":301,"../../plots/cartesian/tick_value_defaults":302,"./attributes":106}],109:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plot_api/plot_template":320,"../../plots/cartesian/tick_label_defaults":352,"../../plots/cartesian/tick_mark_defaults":353,"../../plots/cartesian/tick_value_defaults":354,"./attributes":156}],159:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var tinycolor = _dereq_('tinycolor2'); var Plots = _dereq_('../../plots/plots'); @@ -23944,6 +33999,7 @@ function mockColorBarAxis(gd, opts, zrange) { tickcolor: opts.tickcolor, showticklabels: opts.showticklabels, ticklabelposition: opts.ticklabelposition, + ticklabeloverflow: opts.ticklabeloverflow, tickfont: opts.tickfont, tickangle: opts.tickangle, tickformat: opts.tickformat, @@ -23990,16 +34046,7 @@ module.exports = { draw: draw }; -},{"../../constants/alignment":207,"../../lib":233,"../../lib/extend":227,"../../lib/setcursor":253,"../../lib/svg_text_utils":255,"../../plots/cartesian/axes":279,"../../plots/cartesian/axis_defaults":281,"../../plots/cartesian/layout_attributes":293,"../../plots/cartesian/position_defaults":296,"../../plots/plots":313,"../../registry":326,"../color":105,"../colorscale/helpers":116,"../dragelement":124,"../drawing":127,"../titles":200,"./constants":107,"d3":21,"tinycolor2":88}],110:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../constants/alignment":260,"../../lib":285,"../../lib/extend":279,"../../lib/setcursor":305,"../../lib/svg_text_utils":307,"../../plots/cartesian/axes":331,"../../plots/cartesian/axis_defaults":333,"../../plots/cartesian/layout_attributes":345,"../../plots/cartesian/position_defaults":348,"../../plots/plots":366,"../../registry":373,"../color":155,"../colorscale/helpers":166,"../dragelement":174,"../drawing":177,"../titles":253,"./constants":157,"@plotly/d3":20,"tinycolor2":119}],160:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -24009,15 +34056,7 @@ module.exports = function hasColorbar(container) { return Lib.isPlainObject(container.colorbar); }; -},{"../../lib":233}],111:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],161:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -24031,15 +34070,7 @@ module.exports = { hasColorbar: _dereq_('./has_colorbar') }; -},{"./attributes":106,"./defaults":108,"./draw":109,"./has_colorbar":110}],112:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"./attributes":156,"./defaults":158,"./draw":159,"./has_colorbar":160}],162:[function(_dereq_,module,exports){ 'use strict'; var colorbarAttrs = _dereq_('../colorbar/attributes'); @@ -24140,9 +34171,7 @@ module.exports = function colorScaleAttrs(context, opts) { attrs.color = { valType: 'color', arrayOk: true, - editType: editTypeOverride || 'style', - }; if(opts.anim) { @@ -24152,74 +34181,58 @@ module.exports = function colorScaleAttrs(context, opts) { attrs[auto] = { valType: 'boolean', - dflt: true, editType: 'calc', impliedEdits: autoImpliedEdits, - }; attrs[min] = { valType: 'number', - dflt: null, editType: editTypeOverride || 'plot', impliedEdits: minmaxImpliedEdits, - }; attrs[max] = { valType: 'number', - dflt: null, editType: editTypeOverride || 'plot', impliedEdits: minmaxImpliedEdits, - }; attrs[mid] = { valType: 'number', - dflt: null, editType: 'calc', impliedEdits: autoImpliedEdits, - }; attrs.colorscale = { valType: 'colorscale', - editType: 'calc', dflt: colorscaleDflt, impliedEdits: {autocolorscale: false}, - }; attrs.autocolorscale = { valType: 'boolean', - // gets overrode in 'heatmap' & 'surface' for backwards comp. dflt: opts.autoColorDflt === false ? false : true, editType: 'calc', impliedEdits: {colorscale: undefined}, - }; attrs.reversescale = { valType: 'boolean', - dflt: false, editType: 'plot', - }; if(!noScale) { attrs.showscale = { valType: 'boolean', - dflt: showScaleDflt, editType: 'calc', - }; attrs.colorbar = colorbarAttrs; @@ -24228,26 +34241,16 @@ module.exports = function colorScaleAttrs(context, opts) { if(!opts.noColorAxis) { attrs.coloraxis = { valType: 'subplotid', - regex: counterRegex('coloraxis'), dflt: null, editType: 'calc', - }; } return attrs; }; -},{"../../lib/regex":249,"../colorbar/attributes":106,"./scales.js":120}],113:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib/regex":301,"../colorbar/attributes":156,"./scales.js":170}],163:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -24318,15 +34321,7 @@ module.exports = function calc(gd, trace, opts) { } }; -},{"../../lib":233,"./helpers":116,"fast-isnumeric":23}],114:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"./helpers":166,"fast-isnumeric":31}],164:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -24395,15 +34390,7 @@ module.exports = function crossTraceDefaults(fullData, fullLayout) { } }; -},{"../../lib":233,"./helpers":116}],115:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"./helpers":166}],165:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -24520,18 +34507,10 @@ module.exports = function colorScaleDefaults(parentContIn, parentContOut, layout } }; -},{"../../lib":233,"../../registry":326,"../colorbar/defaults":108,"../colorbar/has_colorbar":110,"./scales":120,"fast-isnumeric":23}],116:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../registry":373,"../colorbar/defaults":158,"../colorbar/has_colorbar":160,"./scales":170,"fast-isnumeric":31}],166:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var tinycolor = _dereq_('tinycolor2'); var isNumeric = _dereq_('fast-isnumeric'); @@ -24573,7 +34552,7 @@ var letterAttrs = ['min', 'max', 'mid', 'auto']; /** * Extract 'c' / 'z', trace / color axis colorscale options * - * Note that it would be nice to replace all z* with c* equivalents in v2 + * Note that it would be nice to replace all z* with c* equivalents in v3 * * @param {object} cont : attribute container * @return {object}: @@ -24760,15 +34739,7 @@ module.exports = { makeColorScaleFuncFromTrace: makeColorScaleFuncFromTrace }; -},{"../../lib":233,"../color":105,"./scales":120,"d3":21,"fast-isnumeric":23,"tinycolor2":88}],117:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../color":155,"./scales":170,"@plotly/d3":20,"fast-isnumeric":31,"tinycolor2":119}],167:[function(_dereq_,module,exports){ 'use strict'; var scales = _dereq_('./scales'); @@ -24802,15 +34773,7 @@ module.exports = { makeColorScaleFuncFromTrace: helpers.makeColorScaleFuncFromTrace }; -},{"./attributes":112,"./calc":113,"./cross_trace_defaults":114,"./defaults":115,"./helpers":116,"./layout_attributes":118,"./layout_defaults":119,"./scales":120}],118:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"./attributes":162,"./calc":163,"./cross_trace_defaults":164,"./defaults":165,"./helpers":166,"./layout_attributes":168,"./layout_defaults":169,"./scales":170}],168:[function(_dereq_,module,exports){ 'use strict'; var extendFlat = _dereq_('../../lib/extend').extendFlat; @@ -24829,23 +34792,17 @@ module.exports = { sequential: { valType: 'colorscale', dflt: scales.Reds, - editType: 'calc', - }, sequentialminus: { valType: 'colorscale', dflt: scales.Blues, - editType: 'calc', - }, diverging: { valType: 'colorscale', dflt: scales.RdBu, - editType: 'calc', - } }, @@ -24855,7 +34812,6 @@ module.exports = { // support yaxis, yaxis2, yaxis3, ... counters _isSubplotObj: true, editType: 'calc', - }, colorScaleAttrs('', { colorAttr: 'corresponding trace color array(s)', noColorAxis: true, @@ -24863,15 +34819,7 @@ module.exports = { })) }; -},{"../../lib/extend":227,"./attributes":112,"./scales":120}],119:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib/extend":279,"./attributes":162,"./scales":170}],169:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -24914,15 +34862,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) { } }; -},{"../../lib":233,"../../plot_api/plot_template":268,"./defaults":115,"./layout_attributes":118}],120:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plot_api/plot_template":320,"./defaults":165,"./layout_attributes":168}],170:[function(_dereq_,module,exports){ 'use strict'; var tinycolor = _dereq_('tinycolor2'); @@ -25118,16 +35058,7 @@ module.exports = { isValid: isValidScale }; -},{"tinycolor2":88}],121:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"tinycolor2":119}],171:[function(_dereq_,module,exports){ 'use strict'; @@ -25151,16 +35082,7 @@ module.exports = function align(v, dv, v0, v1, anchor) { return vc; }; -},{}],122:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],172:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -25189,15 +35111,7 @@ module.exports = function getCursor(x, y, xanchor, yanchor) { return cursorset[y][x]; }; -},{"../../lib":233}],123:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],173:[function(_dereq_,module,exports){ 'use strict'; exports.selectMode = function(dragmode) { @@ -25248,15 +35162,7 @@ exports.selectingOrDrawing = function(dragmode) { ); }; -},{}],124:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],174:[function(_dereq_,module,exports){ 'use strict'; var mouseOffset = _dereq_('mouse-event-offset'); @@ -25431,7 +35337,7 @@ dragElement.init = function init(options) { if(dx || dy) { gd._dragged = true; - dragElement.unhover(gd); + dragElement.unhover(gd, e); } if(gd._dragged && options.moveFn && !rightClick) { @@ -25540,15 +35446,7 @@ function pointerOffset(e) { ); } -},{"../../lib":233,"../../plots/cartesian/constants":285,"./align":121,"./cursor":122,"./unhover":125,"has-hover":54,"has-passive-events":55,"mouse-event-offset":76}],125:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/cartesian/constants":337,"./align":171,"./cursor":172,"./unhover":175,"has-hover":62,"has-passive-events":63,"mouse-event-offset":69}],175:[function(_dereq_,module,exports){ 'use strict'; var Events = _dereq_('../../lib/events'); @@ -25577,7 +35475,7 @@ unhover.raw = function raw(gd, evt) { var oldhoverdata = gd._hoverdata; if(!evt) evt = {}; - if(evt.target && + if(evt.target && !gd._dragged && Events.triggerHandler(gd, 'plotly_beforehover', evt) === false) { return; } @@ -25595,16 +35493,7 @@ unhover.raw = function raw(gd, evt) { } }; -},{"../../lib/dom":225,"../../lib/events":226,"../../lib/throttle":256,"../fx/constants":139}],126:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib/dom":277,"../../lib/events":278,"../../lib/throttle":308,"../fx/constants":189}],176:[function(_dereq_,module,exports){ 'use strict'; exports.dash = { @@ -25615,24 +35504,44 @@ exports.dash = { // dash lengths in px, and it will be honored values: ['solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'], dflt: 'solid', - editType: 'style', - }; -},{}],127:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +exports.pattern = { + shape: { + valType: 'enumerated', + values: ['', '/', '\\', 'x', '-', '|', '+', '.'], + dflt: '', + arrayOk: true, + editType: 'style', + }, + bgcolor: { + valType: 'color', + arrayOk: true, + editType: 'style', + }, + size: { + valType: 'number', + min: 0, + dflt: 8, + arrayOk: true, + editType: 'style', + }, + solidity: { + valType: 'number', + min: 0, + max: 1, + dflt: 0.3, + arrayOk: true, + editType: 'style', + }, + editType: 'style' +}; +},{}],177:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var isNumeric = _dereq_('fast-isnumeric'); var tinycolor = _dereq_('tinycolor2'); @@ -25986,6 +35895,185 @@ drawing.gradient = function(sel, gd, gradientID, type, colorscale, prop) { fullLayout._gradientUrlQueryParts[k] = 1; }; +/** + * pattern: create and apply a pattern fill + * + * @param {object} sel: d3 selection to apply this pattern to + * You can use `selection.call(Drawing.pattern, ...)` + * @param {DOM element} gd: the graph div `sel` is part of + * @param {string} patternID: a unique (within this plot) identifier + * for this pattern, so that we don't create unnecessary definitions + * @param {string} bgcolor: background color for this pattern + * @param {string} fgcolor: foreground color for this pattern + * @param {number} size: size of unit squares for repetition of this pattern + * @param {number} solidity: how solid lines of this pattern are + * @param {string} prop: the property to apply to, 'fill' or 'stroke' + */ +drawing.pattern = function(sel, gd, patternID, shape, bgcolor, fgcolor, size, solidity, prop) { + var fullLayout = gd._fullLayout; + var fullID = 'p' + fullLayout._uid + '-' + patternID; + var width, height; + + // linear interpolation + var linearFn = function(x, x0, x1, y0, y1) { + return y0 + (y1 - y0) * (x - x0) / (x1 - x0); + }; + + var path, linewidth, radius; + var patternTag; + var patternAttrs = {}; + switch(shape) { + case '/': + width = size * Math.sqrt(2); + height = size * Math.sqrt(2); + path = 'M-' + (width / 4) + ',' + (height / 4) + 'l' + (width / 2) + ',-' + (height / 2) + + 'M0,' + height + 'L' + width + ',0' + + 'M' + (width / 4 * 3) + ',' + (height / 4 * 5) + 'l' + (width / 2) + ',-' + (height / 2); + linewidth = solidity * size; + patternTag = 'path'; + patternAttrs = { + 'd': path, + 'stroke': fgcolor, + 'stroke-width': linewidth + 'px' + }; + break; + case '\\': + width = size * Math.sqrt(2); + height = size * Math.sqrt(2); + path = 'M' + (width / 4 * 3) + ',-' + (height / 4) + 'l' + (width / 2) + ',' + (height / 2) + + 'M0,0L' + width + ',' + height + + 'M-' + (width / 4) + ',' + (height / 4 * 3) + 'l' + (width / 2) + ',' + (height / 2); + linewidth = solidity * size; + patternTag = 'path'; + patternAttrs = { + 'd': path, + 'stroke': fgcolor, + 'stroke-width': linewidth + 'px' + }; + break; + case 'x': + width = size * Math.sqrt(2); + height = size * Math.sqrt(2); + path = 'M-' + (width / 4) + ',' + (height / 4) + 'l' + (width / 2) + ',-' + (height / 2) + + 'M0,' + height + 'L' + width + ',0' + + 'M' + (width / 4 * 3) + ',' + (height / 4 * 5) + 'l' + (width / 2) + ',-' + (height / 2) + + 'M' + (width / 4 * 3) + ',-' + (height / 4) + 'l' + (width / 2) + ',' + (height / 2) + + 'M0,0L' + width + ',' + height + + 'M-' + (width / 4) + ',' + (height / 4 * 3) + 'l' + (width / 2) + ',' + (height / 2); + linewidth = size - size * Math.sqrt(1.0 - solidity); + patternTag = 'path'; + patternAttrs = { + 'd': path, + 'stroke': fgcolor, + 'stroke-width': linewidth + 'px' + }; + break; + case '|': + width = size; + height = size; + patternTag = 'path'; + path = 'M' + (width / 2) + ',0L' + (width / 2) + ',' + height; + linewidth = solidity * size; + patternTag = 'path'; + patternAttrs = { + 'd': path, + 'stroke': fgcolor, + 'stroke-width': linewidth + 'px' + }; + break; + case '-': + width = size; + height = size; + patternTag = 'path'; + path = 'M0,' + (height / 2) + 'L' + width + ',' + (height / 2); + linewidth = solidity * size; + patternTag = 'path'; + patternAttrs = { + 'd': path, + 'stroke': fgcolor, + 'stroke-width': linewidth + 'px' + }; + break; + case '+': + width = size; + height = size; + patternTag = 'path'; + path = 'M' + (width / 2) + ',0L' + (width / 2) + ',' + height + + 'M0,' + (height / 2) + 'L' + width + ',' + (height / 2); + linewidth = size - size * Math.sqrt(1.0 - solidity); + patternTag = 'path'; + patternAttrs = { + 'd': path, + 'stroke': fgcolor, + 'stroke-width': linewidth + 'px' + }; + break; + case '.': + width = size; + height = size; + if(solidity < Math.PI / 4) { + radius = Math.sqrt(solidity * size * size / Math.PI); + } else { + radius = linearFn(solidity, Math.PI / 4, 1.0, size / 2, size / Math.sqrt(2)); + } + patternTag = 'circle'; + patternAttrs = { + 'cx': width / 2, + 'cy': height / 2, + 'r': radius, + 'fill': fgcolor + }; + break; + } + + var pattern = fullLayout._defs.select('.patterns') + .selectAll('#' + fullID) + .data([shape + ';' + bgcolor + ';' + fgcolor + ';' + size + ';' + solidity], Lib.identity); + + pattern.exit().remove(); + + pattern.enter() + .append('pattern') + .each(function() { + var el = d3.select(this); + + el.attr({ + 'id': fullID, + 'width': width + 'px', + 'height': height + 'px', + 'patternUnits': 'userSpaceOnUse' + }); + + if(bgcolor) { + var rects = el.selectAll('rect').data([0]); + rects.exit().remove(); + rects.enter() + .append('rect') + .attr({ + 'width': width + 'px', + 'height': height + 'px', + 'fill': bgcolor + }); + } + + var patterns = el.selectAll(patternTag).data([0]); + patterns.exit().remove(); + patterns.enter() + .append(patternTag) + .attr(patternAttrs); + }); + + sel.style(prop, getFullUrl(fullID, gd)) + .style(prop + '-opacity', null); + + sel.classed('pattern_filled', true); + var className2query = function(s) { + return '.' + s.attr('class').replace(/\s/g, '.'); + }; + var k = className2query(d3.select(sel.node().parentNode)) + '>.pattern_filled'; + fullLayout._patternUrlQueryParts[k] = 1; +}; + /* * Make the gradients container and clear out any previous gradients. * We never collect all the gradients we need in one place, @@ -26004,6 +36092,23 @@ drawing.initGradients = function(gd) { fullLayout._gradientUrlQueryParts = {}; }; +drawing.initPatterns = function(gd) { + var fullLayout = gd._fullLayout; + + var patternsGroup = Lib.ensureSingle(fullLayout._defs, 'g', 'patterns'); + patternsGroup.selectAll('pattern').remove(); + + // initialize stash of query parts filled in Drawing.pattern, + // used to fix URL strings during image exports + fullLayout._patternUrlQueryParts = {}; +}; + +drawing.getPatternAttr = function(mp, i, dflt) { + if(mp && Lib.isArrayOrTypedArray(mp)) { + return i < mp.length ? mp[i] : dflt; + } + return mp; +}; drawing.pointStyle = function(s, trace, gd) { if(!s.size()) return; @@ -26109,11 +36214,14 @@ drawing.singlePointStyle = function(d, sel, trace, fns, gd) { // for legend - arrays will propagate through here, but we don't need // to treat it as per-point. - if(Array.isArray(gradientType)) { + if(Lib.isArrayOrTypedArray(gradientType)) { gradientType = gradientType[0]; if(!gradientInfo[gradientType]) gradientType = 0; } + var markerPattern = marker.pattern; + var patternShape = markerPattern && drawing.getPatternAttr(markerPattern.shape, d.i, ''); + if(gradientType && gradientType !== 'none') { var gradientColor = d.mgc; if(gradientColor) perPointGradient = true; @@ -26124,6 +36232,20 @@ drawing.singlePointStyle = function(d, sel, trace, fns, gd) { drawing.gradient(sel, gd, gradientID, gradientType, [[0, gradientColor], [1, fillColor]], 'fill'); + } else if(patternShape) { + var patternBGColor = drawing.getPatternAttr(markerPattern.bgcolor, d.i, null); + var patternSize = drawing.getPatternAttr(markerPattern.size, d.i, 8); + var patternSolidity = drawing.getPatternAttr(markerPattern.solidity, d.i, 0.3); + var perPointPattern = Lib.isArrayOrTypedArray(markerPattern.shape) || + Lib.isArrayOrTypedArray(markerPattern.bgcolor) || + Lib.isArrayOrTypedArray(markerPattern.size) || + Lib.isArrayOrTypedArray(markerPattern.solidity); + + var patternID = trace.uid; + if(perPointPattern) patternID += '-' + d.i; + + drawing.pattern(sel, gd, patternID, patternShape, patternBGColor, fillColor, + patternSize, patternSolidity, 'fill'); } else { Color.fill(sel, fillColor); } @@ -26362,7 +36484,8 @@ drawing.textPointStyle = function(s, trace, gd) { } if(texttemplate) { - var labels = trace._module.formatLabels ? trace._module.formatLabels(d, trace, fullLayout) : {}; + var fn = trace._module.formatLabels; + var labels = fn ? fn(d, trace, fullLayout) : {}; var pointValues = {}; appendArrayPointValue(pointValues, trace, d.i); var meta = trace._meta || {}; @@ -26688,7 +36811,9 @@ function getFullUrl(localId, gd) { var context = gd._context; var baseUrl = context._exportedPlot ? '' : (context._baseUrl || ''); - return 'url(\'' + baseUrl + '#' + localId + '\')'; + return baseUrl ? + 'url(\'' + baseUrl + '#' + localId + '\')' : + 'url(#' + localId + ')'; } drawing.getTranslate = function(element) { @@ -26817,19 +36942,10 @@ drawing.setTextPointsScale = function(selection, xScale, yScale) { }); }; -},{"../../components/fx/helpers":141,"../../constants/alignment":207,"../../constants/interactions":211,"../../constants/xmlns_namespaces":213,"../../lib":233,"../../lib/svg_text_utils":255,"../../registry":326,"../../traces/scatter/make_bubble_size_func":464,"../../traces/scatter/subtypes":472,"../color":105,"../colorscale":117,"./symbol_defs":128,"d3":21,"fast-isnumeric":23,"tinycolor2":88}],128:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/fx/helpers":191,"../../constants/alignment":260,"../../constants/interactions":264,"../../constants/xmlns_namespaces":266,"../../lib":285,"../../lib/svg_text_utils":307,"../../registry":373,"../../traces/scatter/make_bubble_size_func":511,"../../traces/scatter/subtypes":519,"../color":155,"../colorscale":167,"./symbol_defs":178,"@plotly/d3":20,"fast-isnumeric":31,"tinycolor2":119}],178:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); /** Marker symbol definitions * users can specify markers either by number or name @@ -27381,130 +37497,90 @@ module.exports = { } }; -},{"d3":21}],129:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"@plotly/d3":20}],179:[function(_dereq_,module,exports){ 'use strict'; module.exports = { visible: { valType: 'boolean', - editType: 'calc', - }, type: { valType: 'enumerated', values: ['percent', 'constant', 'sqrt', 'data'], - editType: 'calc', - }, symmetric: { valType: 'boolean', - editType: 'calc', - }, array: { valType: 'data_array', editType: 'calc', - }, arrayminus: { valType: 'data_array', editType: 'calc', - }, value: { valType: 'number', min: 0, dflt: 10, - editType: 'calc', - }, valueminus: { valType: 'number', min: 0, dflt: 10, - editType: 'calc', - }, traceref: { valType: 'integer', min: 0, dflt: 0, - editType: 'style' }, tracerefminus: { valType: 'integer', min: 0, dflt: 0, - editType: 'style' }, copy_ystyle: { valType: 'boolean', - editType: 'plot' }, copy_zstyle: { valType: 'boolean', - editType: 'style' }, color: { valType: 'color', - editType: 'style', - }, thickness: { valType: 'number', min: 0, dflt: 2, - editType: 'style', - }, width: { valType: 'number', min: 0, - editType: 'plot', - }, editType: 'calc', _deprecated: { opacity: { valType: 'number', - editType: 'style', - } } }; -},{}],130:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],180:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -27582,16 +37658,7 @@ function calcOneAxis(calcTrace, trace, axis, coord) { baseExtremes.max = baseExtremes.max.concat(extremes.max); } -},{"../../lib":233,"../../plots/cartesian/axes":279,"../../registry":326,"./compute_error":131,"fast-isnumeric":23}],131:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../plots/cartesian/axes":331,"../../registry":373,"./compute_error":181,"fast-isnumeric":31}],181:[function(_dereq_,module,exports){ 'use strict'; @@ -27683,15 +37750,7 @@ function makeComputeErrorValue(type, value) { } } -},{}],132:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],182:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -27758,15 +37817,7 @@ module.exports = function(traceIn, traceOut, defaultColor, opts) { } }; -},{"../../lib":233,"../../plot_api/plot_template":268,"../../registry":326,"./attributes":129,"fast-isnumeric":23}],133:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plot_api/plot_template":320,"../../registry":373,"./attributes":179,"fast-isnumeric":31}],183:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -27827,19 +37878,10 @@ function hoverInfo(calcPoint, trace, hoverPoint) { } } -},{"../../lib":233,"../../plot_api/edit_types":261,"./attributes":129,"./calc":130,"./compute_error":131,"./defaults":132,"./plot":134,"./style":135}],134:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../plot_api/edit_types":313,"./attributes":179,"./calc":180,"./compute_error":181,"./defaults":182,"./plot":184,"./style":185}],184:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var isNumeric = _dereq_('fast-isnumeric'); var Drawing = _dereq_('../drawing'); @@ -27999,19 +38041,10 @@ function errorCoords(d, xa, ya) { return out; } -},{"../../traces/scatter/subtypes":472,"../drawing":127,"d3":21,"fast-isnumeric":23}],135:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../traces/scatter/subtypes":519,"../drawing":177,"@plotly/d3":20,"fast-isnumeric":31}],185:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Color = _dereq_('../color'); @@ -28036,15 +38069,7 @@ module.exports = function style(traces) { }); }; -},{"../color":105,"d3":21}],136:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../color":155,"@plotly/d3":20}],186:[function(_dereq_,module,exports){ 'use strict'; var fontAttrs = _dereq_('../../plots/font_attributes'); @@ -28055,16 +38080,13 @@ module.exports = { hoverlabel: { bgcolor: extendFlat({}, hoverLabelAttrs.bgcolor, { arrayOk: true, - }), bordercolor: extendFlat({}, hoverLabelAttrs.bordercolor, { arrayOk: true, - }), font: fontAttrs({ arrayOk: true, editType: 'none', - }), align: extendFlat({}, hoverLabelAttrs.align, {arrayOk: true}), namelength: extendFlat({}, hoverLabelAttrs.namelength, {arrayOk: true}), @@ -28072,15 +38094,7 @@ module.exports = { } }; -},{"../../lib/extend":227,"../../plots/font_attributes":307,"./layout_attributes":146}],137:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib/extend":279,"../../plots/font_attributes":359,"./layout_attributes":196}],187:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -28131,15 +38145,7 @@ function paste(traceAttr, cd, cdAttr, fn) { } } -},{"../../lib":233,"../../registry":326}],138:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../registry":373}],188:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -28168,15 +38174,7 @@ module.exports = function click(gd, evt, subplot) { } }; -},{"../../registry":326,"./hover":142}],139:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../registry":373,"./hover":192}],189:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -28200,15 +38198,7 @@ module.exports = { HOVERID: '-hover' }; -},{}],140:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],190:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -28226,15 +38216,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleHoverLabelDefaults(traceIn, traceOut, coerce, opts); }; -},{"../../lib":233,"./attributes":136,"./hoverlabel_defaults":143}],141:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"./attributes":186,"./hoverlabel_defaults":193}],191:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -28488,18 +38470,10 @@ exports.isXYhover = function(hovermode) { return !!xyHoverMode[hovermode]; }; -},{"../../lib":233}],142:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],192:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var isNumeric = _dereq_('fast-isnumeric'); var tinycolor = _dereq_('tinycolor2'); @@ -28538,6 +38512,13 @@ var YSHIFTY = Math.sin(YA_RADIANS); var HOVERARROWSIZE = constants.HOVERARROWSIZE; var HOVERTEXTPAD = constants.HOVERTEXTPAD; +var multipleHoverPoints = { + box: true, + ohlc: true, + violin: true, + candlestick: true +}; + // fx.hover: highlight data on hover // evt can be a mousemove event, or an object with data about what points // to hover on @@ -28747,8 +38728,11 @@ function _hover(gd, evt, subplot, noHoverEvent) { return dragElement.unhoverRaw(gd, evt); } - var hoverdistance = fullLayout.hoverdistance === -1 ? Infinity : fullLayout.hoverdistance; - var spikedistance = fullLayout.spikedistance === -1 ? Infinity : fullLayout.spikedistance; + var hoverdistance = fullLayout.hoverdistance; + if(hoverdistance === -1) hoverdistance = Infinity; + + var spikedistance = fullLayout.spikedistance; + if(spikedistance === -1) spikedistance = Infinity; // hoverData: the set of candidate points we've found to highlight var hoverData = []; @@ -28763,7 +38747,7 @@ function _hover(gd, evt, subplot, noHoverEvent) { // mapped onto each of the currently selected overlaid subplots var xvalArray, yvalArray; - var itemnum, curvenum, cd, trace, subplotId, subploti, mode, + var itemnum, curvenum, cd, trace, subplotId, subploti, _mode, xval, yval, pointData, closedataPreviousLength; // spikePoints: the set of candidate points we've found to draw spikes to @@ -28826,7 +38810,13 @@ function _hover(gd, evt, subplot, noHoverEvent) { return; } - var dbb = evt.target.getBoundingClientRect(); + // Discover event target, traversing open shadow roots. + var target = evt.composedPath && evt.composedPath()[0]; + if(!target) { + // Fallback for browsers not supporting composedPath + target = evt.target; + } + var dbb = target.getBoundingClientRect(); xpx = evt.clientX - dbb.left; ypx = evt.clientY - dbb.top; @@ -28892,9 +38882,9 @@ function _hover(gd, evt, subplot, noHoverEvent) { } // within one trace mode can sometimes be overridden - mode = hovermode; - if(helpers.isUnifiedHover(mode)) { - mode = mode.charAt(0); + _mode = hovermode; + if(helpers.isUnifiedHover(_mode)) { + _mode = _mode.charAt(0); } // container for new point, also used to pass info into module.hoverPoints @@ -28952,20 +38942,20 @@ function _hover(gd, evt, subplot, noHoverEvent) { // for a highlighting array, figure out what // we're searching for with this element - if(mode === 'array') { + if(_mode === 'array') { var selection = evt[curvenum]; if('pointNumber' in selection) { pointData.index = selection.pointNumber; - mode = 'closest'; + _mode = 'closest'; } else { - mode = ''; + _mode = ''; if('xval' in selection) { xval = selection.xval; - mode = 'x'; + _mode = 'x'; } if('yval' in selection) { yval = selection.yval; - mode = mode ? 'closest' : 'y'; + _mode = _mode ? 'closest' : 'y'; } } } else if(customXVal !== undefined && customYVal !== undefined) { @@ -28979,7 +38969,11 @@ function _hover(gd, evt, subplot, noHoverEvent) { // Now if there is range to look in, find the points to hover. if(hoverdistance !== 0) { if(trace._module && trace._module.hoverPoints) { - var newPoints = trace._module.hoverPoints(pointData, xval, yval, mode, fullLayout._hoverlayer); + var newPoints = trace._module.hoverPoints(pointData, xval, yval, _mode, { + finiteRange: true, + hoverLayer: fullLayout._hoverlayer + }); + if(newPoints) { var newPoint; for(var newPointNum = 0; newPointNum < newPoints.length; newPointNum++) { @@ -29008,7 +39002,9 @@ function _hover(gd, evt, subplot, noHoverEvent) { if(hoverData.length === 0) { pointData.distance = spikedistance; pointData.index = false; - var closestPoints = trace._module.hoverPoints(pointData, xval, yval, 'closest', fullLayout._hoverlayer); + var closestPoints = trace._module.hoverPoints(pointData, xval, yval, 'closest', { + hoverLayer: fullLayout._hoverlayer + }); if(closestPoints) { closestPoints = closestPoints.filter(function(point) { // some hover points, like scatter fills, do not allow spikes, @@ -29127,46 +39123,70 @@ function _hover(gd, evt, subplot, noHoverEvent) { } } - hoverData.sort(function(d1, d2) { return d1.distance - d2.distance; }); + var sortHoverData = function() { + hoverData.sort(function(d1, d2) { return d1.distance - d2.distance; }); + + // move period positioned points and box/bar-like traces to the end of the list + hoverData = orderRangePoints(hoverData, hovermode); + }; + sortHoverData(); - // If in compare mode, select every point at position if( - helpers.isXYhover(mode) && + helpers.isXYhover(_mode) && hoverData[0].length !== 0 && hoverData[0].trace.type !== 'splom' // TODO: add support for splom ) { - var hd = hoverData[0]; - var cd0 = hd.cd[hd.index]; - var isGrouped = (fullLayout.boxmode === 'group' || fullLayout.violinmode === 'group'); - - var xVal = hd.xVal; - var ax = hd.xa; - if(ax.type === 'category') xVal = ax._categoriesMap[xVal]; - if(ax.type === 'date') xVal = ax.d2c(xVal); - if(cd0 && cd0.t && cd0.t.posLetter === ax._id && isGrouped) { - xVal += cd0.t.dPos; + // pick winning point + var winningPoint = hoverData[0]; + // discard other points + if(multipleHoverPoints[winningPoint.trace.type]) { + hoverData = hoverData.filter(function(d) { + return d.trace.index === winningPoint.trace.index; + }); + } else { + hoverData = [winningPoint]; } + var initLen = hoverData.length; - var yVal = hd.yVal; - ax = hd.ya; - if(ax.type === 'category') yVal = ax._categoriesMap[yVal]; - if(ax.type === 'date') yVal = ax.d2c(yVal); - if(cd0 && cd0.t && cd0.t.posLetter === ax._id && isGrouped) { - yVal += cd0.t.dPos; - } + var winX = getCoord('x', winningPoint, fullLayout); + var winY = getCoord('y', winningPoint, fullLayout); - findHoverPoints(xVal, yVal); + // in compare mode, select every point at position + findHoverPoints(winX, winY); - // Remove duplicated hoverData points - // note that d3 also filters identical points in the rendering steps - var repeated = {}; - hoverData = hoverData.filter(function(hd) { - var key = hoverDataKey(hd); - if(!repeated[key]) { - repeated[key] = true; - return repeated[key]; + var finalPoints = []; + var seen = {}; + var id = 0; + var insert = function(newHd) { + var key = multipleHoverPoints[newHd.trace.type] ? hoverDataKey(newHd) : newHd.trace.index; + if(!seen[key]) { + id++; + seen[key] = id; + finalPoints.push(newHd); + } else { + var oldId = seen[key] - 1; + var oldHd = finalPoints[oldId]; + if(oldId > 0 && + Math.abs(newHd.distance) < + Math.abs(oldHd.distance) + ) { + // replace with closest + finalPoints[oldId] = newHd; + } } - }); + }; + + var k; + // insert the winnig point(s) first + for(k = 0; k < initLen; k++) { + insert(hoverData[k]); + } + // override from the end + for(k = hoverData.length - 1; k > initLen - 1; k--) { + insert(hoverData[k]); + } + hoverData = finalPoints; + sortHoverData(); } // lastly, emit custom hover/unhover events @@ -29269,9 +39289,8 @@ function createHoverText(hoverData, opts, gd) { var c0 = hoverData[0]; var xa = c0.xa; var ya = c0.ya; - var commonAttr = hovermode.charAt(0) === 'y' ? 'yLabel' : 'xLabel'; - var t0 = c0[commonAttr]; - var t00 = (String(t0) || '').split(' ')[0]; + var axLetter = hovermode.charAt(0); + var t0 = c0[axLetter + 'Label']; var outerContainerBB = outerContainer.node().getBoundingClientRect(); var outerTop = outerContainerBB.top; var outerWidth = outerContainerBB.width; @@ -29460,27 +39479,13 @@ function createHoverText(hoverData, opts, gd) { } label.attr('transform', strTranslate(lx, ly)); - - // remove the "close but not quite" points - // because of error bars, only take up to a space - hoverData = filterClosePoints(hoverData); }); - function filterClosePoints(hoverData) { - return hoverData.filter(function(d) { - return (d.zLabelVal !== undefined) || - (d[commonAttr] || '').split(' ')[0] === t00; - }); - } - // Show a single hover label if(helpers.isUnifiedHover(hovermode)) { // Delete leftover hover labels from other hovermodes container.selectAll('g.hovertext').remove(); - // similarly to compare mode, we remove the "close but not quite together" points - if((t0 !== undefined) && (c0.distance <= opts.hoverdistance)) hoverData = filterClosePoints(hoverData); - // Return early if nothing is hovered on if(hoverData.length === 0) return; @@ -29500,10 +39505,10 @@ function createHoverText(hoverData, opts, gd) { }; var mockLayoutOut = {}; legendSupplyDefaults(mockLayoutIn, mockLayoutOut, gd._fullData); - var legendOpts = mockLayoutOut.legend; + var mockLegend = mockLayoutOut.legend; // prepare items for the legend - legendOpts.entries = []; + mockLegend.entries = []; for(var j = 0; j < hoverData.length; j++) { var texts = getHoverLabelText(hoverData[j], true, hovermode, fullLayout, t0); var text = texts[0]; @@ -29529,17 +39534,19 @@ function createHoverText(hoverData, opts, gd) { } pt._distinct = true; - legendOpts.entries.push([pt]); + mockLegend.entries.push([pt]); } - legendOpts.entries.sort(function(a, b) { return a[0].trace.index - b[0].trace.index;}); - legendOpts.layer = container; + mockLegend.entries.sort(function(a, b) { return a[0].trace.index - b[0].trace.index;}); + mockLegend.layer = container; // Draw unified hover label - legendDraw(gd, legendOpts); + mockLegend._inHover = true; + legendDraw(gd, mockLegend); // Position the hover - var ly = Lib.mean(hoverData.map(function(c) {return (c.y0 + c.y1) / 2;})); - var lx = Lib.mean(hoverData.map(function(c) {return (c.x0 + c.x1) / 2;})); + var winningPoint = hoverData[0]; + var ly = (winningPoint.y0 + winningPoint.y1) / 2; + var lx = (winningPoint.x0 + winningPoint.x1) / 2; var legendContainer = container.select('g.legend'); var tbb = legendContainer.node().getBoundingClientRect(); lx += xa._offset; @@ -29736,14 +39743,17 @@ function getHoverLabelText(d, showCommonLabel, hovermode, fullLayout, t0, g) { name = plainText(d.name, d.nameLength); } + var h0 = hovermode.charAt(0); + var h1 = h0 === 'x' ? 'y' : 'x'; + if(d.zLabel !== undefined) { if(d.xLabel !== undefined) text += 'x: ' + d.xLabel + '
'; if(d.yLabel !== undefined) text += 'y: ' + d.yLabel + '
'; if(d.trace.type !== 'choropleth' && d.trace.type !== 'choroplethmapbox') { text += (text ? 'z: ' : '') + d.zLabel; } - } else if(showCommonLabel && d[hovermode.charAt(0) + 'Label'] === t0) { - text = d[(hovermode.charAt(0) === 'x' ? 'y' : 'x') + 'Label'] || ''; + } else if(showCommonLabel && d[h0 + 'Label'] === t0) { + text = d[h1 + 'Label'] || ''; } else if(d.xLabel === undefined) { if(d.yLabel !== undefined && d.trace.type !== 'scattercarpet') { text = d.yLabel; @@ -29772,16 +39782,20 @@ function getHoverLabelText(d, showCommonLabel, hovermode, fullLayout, t0, g) { } // hovertemplate - var d3locale = fullLayout._d3locale; var hovertemplate = d.hovertemplate || false; - var hovertemplateLabels = d.hovertemplateLabels || d; - var eventData = d.eventData[0] || {}; if(hovertemplate) { + var labels = d.hovertemplateLabels || d; + + if(d[h0 + 'Label'] !== t0) { + labels[h0 + 'other'] = labels[h0 + 'Val']; + labels[h0 + 'otherLabel'] = labels[h0 + 'Label']; + } + text = Lib.hovertemplateString( hovertemplate, - hovertemplateLabels, - d3locale, - eventData, + labels, + fullLayout._d3locale, + d.eventData[0] || {}, d.trace._meta ); @@ -30098,11 +40112,11 @@ function cleanPoint(d, hovermode) { // and convert the x and y label values into formatted text if(d.xLabelVal !== undefined) { - d.xLabel = ('xLabel' in d) ? d.xLabel : Axes.hoverLabelText(d.xa, d.xLabelVal); + d.xLabel = ('xLabel' in d) ? d.xLabel : Axes.hoverLabelText(d.xa, d.xLabelVal, trace.xhoverformat); d.xVal = d.xa.c2d(d.xLabelVal); } if(d.yLabelVal !== undefined) { - d.yLabel = ('yLabel' in d) ? d.yLabel : Axes.hoverLabelText(d.ya, d.yLabelVal); + d.yLabel = ('yLabel' in d) ? d.yLabel : Axes.hoverLabelText(d.ya, d.yLabelVal, trace.yhoverformat); d.yVal = d.ya.c2d(d.yLabelVal); } @@ -30360,15 +40374,52 @@ function plainText(s, len) { }); } -},{"../../lib":233,"../../lib/events":226,"../../lib/override_cursor":244,"../../lib/svg_text_utils":255,"../../plots/cartesian/axes":279,"../../registry":326,"../color":105,"../dragelement":124,"../drawing":127,"../legend/defaults":157,"../legend/draw":158,"./constants":139,"./helpers":141,"d3":21,"fast-isnumeric":23,"tinycolor2":88}],143:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +function orderRangePoints(hoverData, hovermode) { + var axLetter = hovermode.charAt(0); + var first = []; + var second = []; + var last = []; + + for(var i = 0; i < hoverData.length; i++) { + var d = hoverData[i]; + + if( + Registry.traceIs(d.trace, 'bar-like') || + Registry.traceIs(d.trace, 'box-violin') + ) { + last.push(d); + } else if(d.trace[axLetter + 'period']) { + second.push(d); + } else { + first.push(d); + } + } + + return first.concat(second).concat(last); +} + +function getCoord(axLetter, winningPoint, fullLayout) { + var ax = winningPoint[axLetter + 'a']; + var val = winningPoint[axLetter + 'Val']; + + if(ax.type === 'category') val = ax._categoriesMap[val]; + else if(ax.type === 'date') val = ax.d2c(val); + + var cd0 = winningPoint.cd[winningPoint.index]; + if(cd0 && cd0.t && cd0.t.posLetter === ax._id) { + if( + fullLayout.boxmode === 'group' || + fullLayout.violinmode === 'group' + ) { + val += cd0.t.dPos; + } + } + + return val; +} + +},{"../../lib":285,"../../lib/events":278,"../../lib/override_cursor":296,"../../lib/svg_text_utils":307,"../../plots/cartesian/axes":331,"../../registry":373,"../color":155,"../dragelement":174,"../drawing":177,"../legend/defaults":207,"../legend/draw":208,"./constants":189,"./helpers":191,"@plotly/d3":20,"fast-isnumeric":31,"tinycolor2":119}],193:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -30406,21 +40457,13 @@ module.exports = function handleHoverLabelDefaults(contIn, contOut, coerce, opts coerce('hoverlabel.align', opts.align); }; -},{"../../lib":233,"../color":105,"./helpers":141}],144:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../color":155,"./helpers":191}],194:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); var layoutAttributes = _dereq_('./layout_attributes'); -module.exports = function handleHoverModeDefaults(layoutIn, layoutOut, fullData) { +module.exports = function handleHoverModeDefaults(layoutIn, layoutOut) { function coerce(attr, dflt) { // don't coerce if it is already coerced in other place e.g. in cartesian defaults if(layoutOut[attr] !== undefined) return layoutOut[attr]; @@ -30428,52 +40471,14 @@ module.exports = function handleHoverModeDefaults(layoutIn, layoutOut, fullData) return Lib.coerce(layoutIn, layoutOut, layoutAttributes, attr, dflt); } - var clickmode = coerce('clickmode'); - - var hovermodeDflt; - if(layoutOut._has('cartesian')) { - if(clickmode.indexOf('select') > -1) { - hovermodeDflt = 'closest'; - } else { - // flag for 'horizontal' plots: - // determines the state of the mode bar 'compare' hovermode button - layoutOut._isHoriz = isHoriz(fullData, layoutOut); - hovermodeDflt = layoutOut._isHoriz ? 'y' : 'x'; - } - } else hovermodeDflt = 'closest'; - - return coerce('hovermode', hovermodeDflt); + coerce('clickmode'); + return coerce('hovermode'); }; -function isHoriz(fullData, fullLayout) { - var stackOpts = fullLayout._scatterStackOpts || {}; - - for(var i = 0; i < fullData.length; i++) { - var trace = fullData[i]; - var subplot = trace.xaxis + trace.yaxis; - var subplotStackOpts = stackOpts[subplot] || {}; - var groupOpts = subplotStackOpts[trace.stackgroup] || {}; - - if(trace.orientation !== 'h' && groupOpts.orientation !== 'h') { - return false; - } - } - - return true; -} - -},{"../../lib":233,"./layout_attributes":146}],145:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"./layout_attributes":196}],195:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Lib = _dereq_('../../lib'); var dragElement = _dereq_('../dragelement'); var helpers = _dereq_('./helpers'); @@ -30541,22 +40546,13 @@ function castHoverinfo(trace, fullLayout, ptNumber) { return Lib.castOption(trace, ptNumber, 'hoverinfo', _coerce); } -},{"../../lib":233,"../dragelement":124,"./attributes":136,"./calc":137,"./click":138,"./constants":139,"./defaults":140,"./helpers":141,"./hover":142,"./layout_attributes":146,"./layout_defaults":147,"./layout_global_defaults":148,"d3":21}],146:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../dragelement":174,"./attributes":186,"./calc":187,"./click":188,"./constants":189,"./defaults":190,"./helpers":191,"./hover":192,"./layout_attributes":196,"./layout_defaults":197,"./layout_global_defaults":198,"@plotly/d3":20}],196:[function(_dereq_,module,exports){ 'use strict'; var constants = _dereq_('./constants'); var fontAttrs = _dereq_('../../plots/font_attributes')({ editType: 'none', - }); fontAttrs.family.dflt = constants.HOVERFONT; fontAttrs.size.dflt = constants.HOVERFONTSIZE; @@ -30564,16 +40560,13 @@ fontAttrs.size.dflt = constants.HOVERFONTSIZE; module.exports = { clickmode: { valType: 'flaglist', - flags: ['event', 'select'], dflt: 'event', editType: 'plot', extras: ['none'], - }, dragmode: { valType: 'enumerated', - values: [ 'zoom', 'pan', @@ -30590,99 +40583,74 @@ module.exports = { ], dflt: 'zoom', editType: 'modebar', - }, hovermode: { valType: 'enumerated', - values: ['x', 'y', 'closest', false, 'x unified', 'y unified'], + dflt: 'closest', editType: 'modebar', - }, hoverdistance: { valType: 'integer', min: -1, dflt: 20, - editType: 'none', - }, spikedistance: { valType: 'integer', min: -1, - dflt: 20, - + dflt: -1, editType: 'none', - }, hoverlabel: { bgcolor: { valType: 'color', - editType: 'none', - }, bordercolor: { valType: 'color', - editType: 'none', - }, font: fontAttrs, align: { valType: 'enumerated', values: ['left', 'right', 'auto'], dflt: 'auto', - editType: 'none', - }, namelength: { valType: 'integer', min: -1, dflt: 15, - editType: 'none', - }, editType: 'none' }, selectdirection: { valType: 'enumerated', - values: ['h', 'v', 'd', 'any'], dflt: 'any', - editType: 'none' } }; -},{"../../plots/font_attributes":307,"./constants":139}],147:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/font_attributes":359,"./constants":189}],197:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); -var isUnifiedHover = _dereq_('./helpers').isUnifiedHover; var layoutAttributes = _dereq_('./layout_attributes'); var handleHoverModeDefaults = _dereq_('./hovermode_defaults'); var handleHoverLabelDefaults = _dereq_('./hoverlabel_defaults'); -module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { +module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) { function coerce(attr, dflt) { return Lib.coerce(layoutIn, layoutOut, layoutAttributes, attr, dflt); } - var hoverMode = handleHoverModeDefaults(layoutIn, layoutOut, fullData); + var hoverMode = handleHoverModeDefaults(layoutIn, layoutOut); if(hoverMode) { coerce('hoverdistance'); - coerce('spikedistance', isUnifiedHover(hoverMode) ? -1 : undefined); + coerce('spikedistance'); } var dragMode = coerce('dragmode'); @@ -30705,15 +40673,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { handleHoverLabelDefaults(layoutIn, layoutOut, coerce); }; -},{"../../lib":233,"./helpers":141,"./hoverlabel_defaults":143,"./hovermode_defaults":144,"./layout_attributes":146}],148:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"./hoverlabel_defaults":193,"./hovermode_defaults":194,"./layout_attributes":196}],198:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -30728,15 +40688,7 @@ module.exports = function supplyLayoutGlobalDefaults(layoutIn, layoutOut) { handleHoverLabelDefaults(layoutIn, layoutOut, coerce); }; -},{"../../lib":233,"./hoverlabel_defaults":143,"./layout_attributes":146}],149:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"./hoverlabel_defaults":193,"./layout_attributes":196}],199:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -30749,92 +40701,69 @@ var gridAttrs = { rows: { valType: 'integer', min: 1, - editType: 'plot', - }, roworder: { valType: 'enumerated', values: ['top to bottom', 'bottom to top'], dflt: 'top to bottom', - editType: 'plot', - }, columns: { valType: 'integer', min: 1, - editType: 'plot', - }, subplots: { valType: 'info_array', freeLength: true, dimensions: 2, items: {valType: 'enumerated', values: [counterRegex('xy').toString(), ''], editType: 'plot'}, - editType: 'plot', - }, xaxes: { valType: 'info_array', freeLength: true, items: {valType: 'enumerated', values: [cartesianIdRegex.x.toString(), ''], editType: 'plot'}, - editType: 'plot', - }, yaxes: { valType: 'info_array', freeLength: true, items: {valType: 'enumerated', values: [cartesianIdRegex.y.toString(), ''], editType: 'plot'}, - editType: 'plot', - }, pattern: { valType: 'enumerated', values: ['independent', 'coupled'], dflt: 'coupled', - editType: 'plot', - }, xgap: { valType: 'number', min: 0, max: 1, - editType: 'plot', - }, ygap: { valType: 'number', min: 0, max: 1, - editType: 'plot', - }, domain: domainAttrs({name: 'grid', editType: 'plot', noGridCell: true}, { - }), xside: { valType: 'enumerated', values: ['bottom', 'bottom plot', 'top plot', 'top'], dflt: 'bottom plot', - editType: 'plot', - }, yside: { valType: 'enumerated', values: ['left', 'left plot', 'right plot', 'right'], dflt: 'left plot', - editType: 'plot', - }, editType: 'plot' }; @@ -31102,15 +41031,7 @@ module.exports = { contentDefaults: contentDefaults }; -},{"../../lib":233,"../../lib/regex":249,"../../plot_api/plot_template":268,"../../plots/cartesian/constants":285,"../../plots/domain":306}],150:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../lib/regex":301,"../../plot_api/plot_template":320,"../../plots/cartesian/constants":337,"../../plots/domain":358}],200:[function(_dereq_,module,exports){ 'use strict'; var cartesianConstants = _dereq_('../../plots/cartesian/constants'); @@ -31121,95 +41042,73 @@ var axisPlaceableObjs = _dereq_('../../constants/axis_placeable_objects'); module.exports = templatedArray('image', { visible: { valType: 'boolean', - dflt: true, editType: 'arraydraw', - }, source: { valType: 'string', - editType: 'arraydraw', - }, layer: { valType: 'enumerated', values: ['below', 'above'], dflt: 'above', - editType: 'arraydraw', - }, sizex: { valType: 'number', - dflt: 0, editType: 'arraydraw', - }, sizey: { valType: 'number', - dflt: 0, editType: 'arraydraw', - }, sizing: { valType: 'enumerated', values: ['fill', 'contain', 'stretch'], dflt: 'contain', - editType: 'arraydraw', - }, opacity: { valType: 'number', - min: 0, max: 1, dflt: 1, editType: 'arraydraw', - }, x: { valType: 'any', - dflt: 0, editType: 'arraydraw', - }, y: { valType: 'any', - dflt: 0, editType: 'arraydraw', - }, xanchor: { valType: 'enumerated', values: ['left', 'center', 'right'], dflt: 'left', - editType: 'arraydraw', - }, yanchor: { valType: 'enumerated', values: ['top', 'middle', 'bottom'], dflt: 'top', - editType: 'arraydraw', - }, xref: { @@ -31219,9 +41118,7 @@ module.exports = templatedArray('image', { cartesianConstants.idRegex.x.toString() ], dflt: 'paper', - editType: 'arraydraw', - }, yref: { @@ -31231,23 +41128,12 @@ module.exports = templatedArray('image', { cartesianConstants.idRegex.y.toString() ], dflt: 'paper', - editType: 'arraydraw', - }, editType: 'arraydraw' }); -},{"../../constants/axis_placeable_objects":208,"../../plot_api/plot_template":268,"../../plots/cartesian/constants":285}],151:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../constants/axis_placeable_objects":261,"../../plot_api/plot_template":320,"../../plots/cartesian/constants":337}],201:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -31257,7 +41143,7 @@ var toLogRange = _dereq_('../../lib/to_log_range'); * convertCoords: when converting an axis between log and linear * you need to alter any images on that axis to keep them * pointing at the same data point. - * In v2.0 this will become obsolete (or perhaps size will still need conversion?) + * In v3.0 this will become obsolete (or perhaps size will still need conversion?) * we convert size by declaring that the maximum extent *in data units* should be * the same, assuming the image is anchored by its center (could remove that restriction * if we think it's important) even though the actual left and right values will not be @@ -31319,15 +41205,7 @@ module.exports = function convertCoords(gd, ax, newType, doExtra) { } }; -},{"../../lib/to_log_range":257,"fast-isnumeric":23}],152:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib/to_log_range":309,"fast-isnumeric":31}],202:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -31384,18 +41262,10 @@ function imageDefaults(imageIn, imageOut, fullLayout) { return imageOut; } -},{"../../lib":233,"../../plots/array_container_defaults":274,"../../plots/cartesian/axes":279,"./attributes":150}],153:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/array_container_defaults":326,"../../plots/cartesian/axes":331,"./attributes":200}],203:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Drawing = _dereq_('../drawing'); var Axes = _dereq_('../../plots/cartesian/axes'); var axisIds = _dereq_('../../plots/cartesian/axis_ids'); @@ -31623,7 +41493,7 @@ module.exports = function draw(gd) { subplot = allSubplots[i]; var subplotObj = fullLayout._plots[subplot]; - // filter out overlaid plots (which havd their images on the main plot) + // filter out overlaid plots (which have their images on the main plot) // and gl2d plots (which don't support below images, at least not yet) if(!subplotObj.imagelayer) continue; @@ -31642,15 +41512,7 @@ module.exports = function draw(gd) { } }; -},{"../../constants/xmlns_namespaces":213,"../../plots/cartesian/axes":279,"../../plots/cartesian/axis_ids":282,"../drawing":127,"d3":21}],154:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/xmlns_namespaces":266,"../../plots/cartesian/axes":331,"../../plots/cartesian/axis_ids":334,"../drawing":177,"@plotly/d3":20}],204:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -31666,15 +41528,7 @@ module.exports = { convertCoords: _dereq_('./convert_coords') }; -},{"../../plots/cartesian/include_components":291,"./attributes":150,"./convert_coords":151,"./defaults":152,"./draw":153}],155:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian/include_components":343,"./attributes":200,"./convert_coords":201,"./defaults":202,"./draw":203}],205:[function(_dereq_,module,exports){ 'use strict'; var fontAttrs = _dereq_('../../plots/font_attributes'); @@ -31684,150 +41538,112 @@ var colorAttrs = _dereq_('../color/attributes'); module.exports = { bgcolor: { valType: 'color', - editType: 'legend', - }, bordercolor: { valType: 'color', dflt: colorAttrs.defaultLine, - editType: 'legend', - }, borderwidth: { valType: 'number', min: 0, dflt: 0, - editType: 'legend', - }, font: fontAttrs({ editType: 'legend', - }), orientation: { valType: 'enumerated', values: ['v', 'h'], dflt: 'v', - editType: 'legend', - }, traceorder: { valType: 'flaglist', flags: ['reversed', 'grouped'], extras: ['normal'], - editType: 'legend', - }, tracegroupgap: { valType: 'number', min: 0, dflt: 10, - editType: 'legend', - }, itemsizing: { valType: 'enumerated', values: ['trace', 'constant'], dflt: 'trace', - editType: 'legend', - }, itemwidth: { valType: 'number', min: 30, dflt: 30, - editType: 'legend', - }, itemclick: { valType: 'enumerated', values: ['toggle', 'toggleothers', false], dflt: 'toggle', - editType: 'legend', - }, itemdoubleclick: { valType: 'enumerated', values: ['toggle', 'toggleothers', false], dflt: 'toggleothers', - editType: 'legend', - }, x: { valType: 'number', min: -2, max: 3, - editType: 'legend', - }, xanchor: { valType: 'enumerated', values: ['auto', 'left', 'center', 'right'], dflt: 'left', - editType: 'legend', - }, y: { valType: 'number', min: -2, max: 3, - editType: 'legend', - }, yanchor: { valType: 'enumerated', values: ['auto', 'top', 'middle', 'bottom'], - editType: 'legend', - }, uirevision: { valType: 'any', - editType: 'none', - }, valign: { valType: 'enumerated', values: ['top', 'middle', 'bottom'], dflt: 'middle', - editType: 'legend', - }, title: { text: { valType: 'string', dflt: '', - editType: 'legend', - }, font: fontAttrs({ editType: 'legend', - }), side: { valType: 'enumerated', values: ['top', 'left', 'top left'], - editType: 'legend', - }, editType: 'legend', }, @@ -31835,15 +41651,7 @@ module.exports = { editType: 'legend' }; -},{"../../plots/font_attributes":307,"../color/attributes":104}],156:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/font_attributes":359,"../color/attributes":154}],206:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -31859,15 +41667,7 @@ module.exports = { itemGap: 5 }; -},{}],157:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],207:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -31947,12 +41747,13 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { coerce('bgcolor', layoutOut.paper_bgcolor); coerce('bordercolor'); coerce('borderwidth'); - Lib.coerceFont(coerce, 'font', layoutOut.font); + var itemFont = Lib.coerceFont(coerce, 'font', layoutOut.font); var orientation = coerce('orientation'); + var isHorizontal = orientation === 'h'; var defaultX, defaultY, defaultYAnchor; - if(orientation === 'h') { + if(isHorizontal) { defaultX = 0; if(Registry.getComponentMethod('rangeslider', 'isVisible')(layoutIn.xaxis)) { @@ -31961,7 +41762,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { } else { // maybe use y=1.1 / yanchor=bottom as above // to avoid https://github.com/plotly/plotly.js/issues/1199 - // in v2 + // in v3 defaultY = -0.1; defaultYAnchor = 'top'; } @@ -31989,23 +41790,19 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { var titleText = coerce('title.text'); if(titleText) { - coerce('title.side', orientation === 'h' ? 'left' : 'top'); - Lib.coerceFont(coerce, 'title.font', layoutOut.font); + coerce('title.side', isHorizontal ? 'left' : 'top'); + var dfltTitleFont = Lib.extendFlat({}, itemFont, { + size: Lib.bigFont(itemFont.size) + }); + + Lib.coerceFont(coerce, 'title.font', dfltTitleFont); } }; -},{"../../lib":233,"../../plot_api/plot_template":268,"../../plots/layout_attributes":311,"../../registry":326,"./attributes":155,"./helpers":161}],158:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plot_api/plot_template":320,"../../plots/layout_attributes":364,"../../registry":373,"./attributes":205,"./helpers":211}],208:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Lib = _dereq_('../../lib'); var Plots = _dereq_('../../plots/plots'); @@ -32027,19 +41824,24 @@ var getLegendData = _dereq_('./get_legend_data'); var style = _dereq_('./style'); var helpers = _dereq_('./helpers'); +var MAIN_TITLE = 1; + module.exports = function draw(gd, opts) { + if(!opts) opts = gd._fullLayout.legend || {}; + return _draw(gd, opts); +}; + +function _draw(gd, legendObj) { var fullLayout = gd._fullLayout; var clipId = 'legend' + fullLayout._uid; var layer; - // Check whether this is the main legend (ie. called without any opts) - if(!opts) { - opts = fullLayout.legend || {}; - opts._main = true; - layer = fullLayout._infolayer; - } else { - layer = opts.layer; + var inHover = legendObj._inHover; + if(inHover) { + layer = legendObj.layer; clipId += '-hover'; + } else { + layer = fullLayout._infolayer; } if(!layer) return; @@ -32047,24 +41849,24 @@ module.exports = function draw(gd, opts) { if(!gd._legendMouseDownTime) gd._legendMouseDownTime = 0; var legendData; - if(opts._main) { + if(!inHover) { if(!gd.calcdata) return; - legendData = fullLayout.showlegend && getLegendData(gd.calcdata, opts); + legendData = fullLayout.showlegend && getLegendData(gd.calcdata, legendObj); } else { - if(!opts.entries) return; - legendData = getLegendData(opts.entries, opts); + if(!legendObj.entries) return; + legendData = getLegendData(legendObj.entries, legendObj); } var hiddenSlices = fullLayout.hiddenlabels || []; - if(opts._main && (!fullLayout.showlegend || !legendData.length)) { + if(!inHover && (!fullLayout.showlegend || !legendData.length)) { layer.selectAll('.legend').remove(); fullLayout._topdefs.select('#' + clipId).remove(); return Plots.autoMargin(gd, 'legend'); } var legend = Lib.ensureSingle(layer, 'g', 'legend', function(s) { - if(opts._main) s.attr('pointer-events', 'all'); + if(!inHover) s.attr('pointer-events', 'all'); }); var clipPath = Lib.ensureSingleById(fullLayout._topdefs, 'clipPath', clipId, function(s) { @@ -32074,22 +41876,22 @@ module.exports = function draw(gd, opts) { var bg = Lib.ensureSingle(legend, 'rect', 'bg', function(s) { s.attr('shape-rendering', 'crispEdges'); }); - bg.call(Color.stroke, opts.bordercolor) - .call(Color.fill, opts.bgcolor) - .style('stroke-width', opts.borderwidth + 'px'); + bg.call(Color.stroke, legendObj.bordercolor) + .call(Color.fill, legendObj.bgcolor) + .style('stroke-width', legendObj.borderwidth + 'px'); var scrollBox = Lib.ensureSingle(legend, 'g', 'scrollbox'); - var title = opts.title; - opts._titleWidth = 0; - opts._titleHeight = 0; + var title = legendObj.title; + legendObj._titleWidth = 0; + legendObj._titleHeight = 0; if(title.text) { var titleEl = Lib.ensureSingle(scrollBox, 'text', 'legendtitletext'); titleEl.attr('text-anchor', 'start') .call(Drawing.font, title.font) .text(title.text); - textLayout(titleEl, scrollBox, gd, opts); // handle mathjax or multi-line text and compute title height + textLayout(titleEl, scrollBox, gd, legendObj, MAIN_TITLE); // handle mathjax or multi-line text and compute title height } else { scrollBox.selectAll('.legendtitletext').remove(); } @@ -32115,31 +41917,31 @@ module.exports = function draw(gd, opts) { return trace.visible === 'legendonly' ? 0.5 : 1; } }) - .each(function() { d3.select(this).call(drawTexts, gd, opts); }) - .call(style, gd, opts) - .each(function() { if(opts._main) d3.select(this).call(setupTraceToggle, gd); }); + .each(function() { d3.select(this).call(drawTexts, gd, legendObj); }) + .call(style, gd, legendObj) + .each(function() { if(!inHover) d3.select(this).call(setupTraceToggle, gd); }); Lib.syncOrAsync([ Plots.previousPromises, - function() { return computeLegendDimensions(gd, groups, traces, opts); }, + function() { return computeLegendDimensions(gd, groups, traces, legendObj); }, function() { // IF expandMargin return a Promise (which is truthy), // we're under a doAutoMargin redraw, so we don't have to // draw the remaining pieces below - if(opts._main && expandMargin(gd)) return; + if(!inHover && expandMargin(gd)) return; var gs = fullLayout._size; - var bw = opts.borderwidth; + var bw = legendObj.borderwidth; - var lx = gs.l + gs.w * opts.x - FROM_TL[getXanchor(opts)] * opts._width; - var ly = gs.t + gs.h * (1 - opts.y) - FROM_TL[getYanchor(opts)] * opts._effHeight; + var lx = gs.l + gs.w * legendObj.x - FROM_TL[getXanchor(legendObj)] * legendObj._width; + var ly = gs.t + gs.h * (1 - legendObj.y) - FROM_TL[getYanchor(legendObj)] * legendObj._effHeight; - if(opts._main && fullLayout.margin.autoexpand) { + if(!inHover && fullLayout.margin.autoexpand) { var lx0 = lx; var ly0 = ly; - lx = Lib.constrain(lx, 0, fullLayout.width - opts._width); - ly = Lib.constrain(ly, 0, fullLayout.height - opts._effHeight); + lx = Lib.constrain(lx, 0, fullLayout.width - legendObj._width); + ly = Lib.constrain(ly, 0, fullLayout.height - legendObj._effHeight); if(lx !== lx0) { Lib.log('Constrain legend.x to make legend fit inside graph'); @@ -32151,21 +41953,21 @@ module.exports = function draw(gd, opts) { // Set size and position of all the elements that make up a legend: // legend, background and border, scroll box and scroll bar as well as title - if(opts._main) Drawing.setTranslate(legend, lx, ly); + if(!inHover) Drawing.setTranslate(legend, lx, ly); // to be safe, remove previous listeners scrollBar.on('.drag', null); legend.on('wheel', null); - if(!opts._main || opts._height <= opts._maxHeight || gd._context.staticPlot) { + if(inHover || legendObj._height <= legendObj._maxHeight || gd._context.staticPlot) { // if scrollbar should not be shown. - var height = opts._effHeight; + var height = legendObj._effHeight; - // if not the main legend, let it be its full size - if(!opts._main) height = opts._height; + // if unified hover, let it be its full size + if(inHover) height = legendObj._height; bg.attr({ - width: opts._width - bw, + width: legendObj._width - bw, height: height - bw, x: bw / 2, y: bw / 2 @@ -32174,7 +41976,7 @@ module.exports = function draw(gd, opts) { Drawing.setTranslate(scrollBox, 0, 0); clipPath.select('rect').attr({ - width: opts._width - 2 * bw, + width: legendObj._width - 2 * bw, height: height - 2 * bw, x: bw, y: bw @@ -32183,36 +41985,36 @@ module.exports = function draw(gd, opts) { Drawing.setClipUrl(scrollBox, clipId, gd); Drawing.setRect(scrollBar, 0, 0, 0, 0); - delete opts._scrollY; + delete legendObj._scrollY; } else { var scrollBarHeight = Math.max(constants.scrollBarMinHeight, - opts._effHeight * opts._effHeight / opts._height); - var scrollBarYMax = opts._effHeight - + legendObj._effHeight * legendObj._effHeight / legendObj._height); + var scrollBarYMax = legendObj._effHeight - scrollBarHeight - 2 * constants.scrollBarMargin; - var scrollBoxYMax = opts._height - opts._effHeight; + var scrollBoxYMax = legendObj._height - legendObj._effHeight; var scrollRatio = scrollBarYMax / scrollBoxYMax; - var scrollBoxY = Math.min(opts._scrollY || 0, scrollBoxYMax); + var scrollBoxY = Math.min(legendObj._scrollY || 0, scrollBoxYMax); // increase the background and clip-path width // by the scrollbar width and margin bg.attr({ - width: opts._width - + width: legendObj._width - 2 * bw + constants.scrollBarWidth + constants.scrollBarMargin, - height: opts._effHeight - bw, + height: legendObj._effHeight - bw, x: bw / 2, y: bw / 2 }); clipPath.select('rect').attr({ - width: opts._width - + width: legendObj._width - 2 * bw + constants.scrollBarWidth + constants.scrollBarMargin, - height: opts._effHeight - 2 * bw, + height: legendObj._effHeight - 2 * bw, x: bw, y: bw + scrollBoxY }); @@ -32224,7 +42026,7 @@ module.exports = function draw(gd, opts) { // scroll legend by mousewheel or touchpad swipe up/down legend.on('wheel', function() { scrollBoxY = Lib.constrain( - opts._scrollY + + legendObj._scrollY + ((d3.event.deltaY / scrollBarYMax) * scrollBoxYMax), 0, scrollBoxYMax); scrollHandler(scrollBoxY, scrollBarHeight, scrollRatio); @@ -32290,12 +42092,12 @@ module.exports = function draw(gd, opts) { } function scrollHandler(scrollBoxY, scrollBarHeight, scrollRatio) { - opts._scrollY = gd._fullLayout.legend._scrollY = scrollBoxY; + legendObj._scrollY = gd._fullLayout.legend._scrollY = scrollBoxY; Drawing.setTranslate(scrollBox, 0, -scrollBoxY); Drawing.setRect( scrollBar, - opts._width, + legendObj._width, constants.scrollBarMargin + scrollBoxY * scrollRatio, constants.scrollBarWidth, scrollBarHeight @@ -32322,8 +42124,8 @@ module.exports = function draw(gd, opts) { Drawing.setTranslate(legend, newX, newY); - xf = dragElement.align(newX, 0, gs.l, gs.l + gs.w, opts.xanchor); - yf = dragElement.align(newY, 0, gs.t + gs.h, gs.t, opts.yanchor); + xf = dragElement.align(newX, 0, gs.l, gs.l + gs.w, legendObj.xanchor); + yf = dragElement.align(newY, 0, gs.t + gs.h, gs.t, legendObj.yanchor); }, doneFn: function() { if(xf !== undefined && yf !== undefined) { @@ -32345,7 +42147,7 @@ module.exports = function draw(gd, opts) { }); } }], gd); -}; +} function clickOrDoubleClick(gd, legend, legendItem, numClicks, evt) { var trace = legendItem.data()[0][0].trace; @@ -32374,6 +42176,7 @@ function clickOrDoubleClick(gd, legend, legendItem, numClicks, evt) { if(numClicks === 1) { legend._clickTimeout = setTimeout(function() { + if(!gd._fullLayout) return; handleClick(legendItem, gd, numClicks); }, gd._context.doubleClickDelay); } else if(numClicks === 2) { @@ -32385,16 +42188,15 @@ function clickOrDoubleClick(gd, legend, legendItem, numClicks, evt) { } } -function drawTexts(g, gd, opts) { +function drawTexts(g, gd, legendObj) { var legendItem = g.data()[0][0]; var trace = legendItem.trace; var isPieLike = Registry.traceIs(trace, 'pie-like'); - var traceIndex = trace.index; - var isEditable = opts._main && gd._context.edits.legendText && !isPieLike; - var maxNameLength = opts._maxNameLength; + var isEditable = !legendObj._inHover && gd._context.edits.legendText && !isPieLike; + var maxNameLength = legendObj._maxNameLength; var name; - if(!opts.entries) { + if(!legendObj.entries) { name = isPieLike ? legendItem.label : trace.name; if(trace._meta) { name = Lib.templateString(name, trace._meta); @@ -32406,18 +42208,18 @@ function drawTexts(g, gd, opts) { var textEl = Lib.ensureSingle(g, 'text', 'legendtext'); textEl.attr('text-anchor', 'start') - .call(Drawing.font, opts.font) + .call(Drawing.font, legendObj.font) .text(isEditable ? ensureLength(name, maxNameLength) : name); - var textGap = opts.itemwidth + constants.itemGap * 2; + var textGap = legendObj.itemwidth + constants.itemGap * 2; svgTextUtils.positionText(textEl, textGap, 0); if(isEditable) { textEl.call(svgTextUtils.makeEditable, {gd: gd, text: name}) - .call(textLayout, g, gd, opts) + .call(textLayout, g, gd, legendObj) .on('edit', function(newName) { this.text(ensureLength(newName, maxNameLength)) - .call(textLayout, g, gd, opts); + .call(textLayout, g, gd, legendObj); var fullInput = legendItem.trace._fullInput || {}; var update = {}; @@ -32435,10 +42237,10 @@ function drawTexts(g, gd, opts) { update.name = newName; } - return Registry.call('_guiRestyle', gd, update, traceIndex); + return Registry.call('_guiRestyle', gd, update, trace.index); }); } else { - textLayout(textEl, g, gd, opts); + textLayout(textEl, g, gd, legendObj); } } @@ -32494,25 +42296,25 @@ function setupTraceToggle(g, gd) { }); } -function textLayout(s, g, gd, opts) { - if(!opts._main) s.attr('data-notex', true); // do not process MathJax if not main +function textLayout(s, g, gd, legendObj, aTitle) { + if(legendObj._inHover) s.attr('data-notex', true); // do not process MathJax for unified hover svgTextUtils.convertToTspans(s, gd, function() { - computeTextDimensions(g, gd, opts); + computeTextDimensions(g, gd, legendObj, aTitle); }); } -function computeTextDimensions(g, gd, opts) { +function computeTextDimensions(g, gd, legendObj, aTitle) { var legendItem = g.data()[0][0]; - if(opts._main && legendItem && !legendItem.trace.showlegend) { + if(!legendObj._inHover && legendItem && !legendItem.trace.showlegend) { g.remove(); return; } var mathjaxGroup = g.select('g[class*=math-group]'); var mathjaxNode = mathjaxGroup.node(); - if(!opts) opts = gd._fullLayout.legend; - var bw = opts.borderwidth; - var lineHeight = (legendItem ? opts : opts.title).font.size * LINE_SPACING; + if(!legendObj) legendObj = gd._fullLayout.legend; + var bw = legendObj.borderwidth; + var lineHeight = (aTitle === MAIN_TITLE ? legendObj.title : legendObj).font.size * LINE_SPACING; var height, width; if(mathjaxNode) { @@ -32521,14 +42323,14 @@ function computeTextDimensions(g, gd, opts) { height = mathjaxBB.height; width = mathjaxBB.width; - if(legendItem) { + if(aTitle === MAIN_TITLE) { + Drawing.setTranslate(mathjaxGroup, bw, bw + height * 0.75); + } else { // legend item Drawing.setTranslate(mathjaxGroup, 0, height * 0.25); - } else { // case of title - Drawing.setTranslate(mathjaxGroup, bw, height * 0.75 + bw); } } else { - var textEl = g.select(legendItem ? - '.legendtext' : '.legendtitletext' + var textEl = g.select(aTitle === MAIN_TITLE ? + '.legendtitletext' : '.legendtext' ); var textLines = svgTextUtils.lineCount(textEl); var textNode = textEl.node(); @@ -32538,36 +42340,45 @@ function computeTextDimensions(g, gd, opts) { // approximation to height offset to center the font // to avoid getBoundingClientRect - var textY = lineHeight * ((textLines - 1) / 2 - 0.3); - if(legendItem) { - var textGap = opts.itemwidth + constants.itemGap * 2; - svgTextUtils.positionText(textEl, textGap, -textY); - } else { // case of title - svgTextUtils.positionText(textEl, constants.titlePad + bw, lineHeight + bw); + if(aTitle === MAIN_TITLE) { + if(legendObj.title.side === 'left') { + // add extra space between legend title and itmes + width += constants.itemGap * 2; + } + + svgTextUtils.positionText(textEl, + bw + constants.titlePad, + bw + lineHeight + ); + } else { // legend item + svgTextUtils.positionText(textEl, + legendObj.itemwidth + constants.itemGap * 2, + -lineHeight * ((textLines - 1) / 2 - 0.3) + ); } } - if(legendItem) { + if(aTitle === MAIN_TITLE) { + legendObj._titleWidth = width; + legendObj._titleHeight = height; + } else { // legend item legendItem.lineHeight = lineHeight; legendItem.height = Math.max(height, 16) + 3; legendItem.width = width; - } else { // case of title - opts._titleWidth = width; - opts._titleHeight = height; } } -function getTitleSize(opts) { +function getTitleSize(legendObj) { var w = 0; var h = 0; - var side = opts.title.side; + var side = legendObj.title.side; if(side) { if(side.indexOf('left') !== -1) { - w = opts._titleWidth; + w = legendObj._titleWidth; } if(side.indexOf('top') !== -1) { - h = opts._titleHeight; + h = legendObj._titleHeight; } } @@ -32584,68 +42395,70 @@ function getTitleSize(opts) { * - _width: legend width * - _maxWidth (for orientation:h only): maximum width before starting new row */ -function computeLegendDimensions(gd, groups, traces, opts) { +function computeLegendDimensions(gd, groups, traces, legendObj) { var fullLayout = gd._fullLayout; - if(!opts) opts = fullLayout.legend; + if(!legendObj) legendObj = fullLayout.legend; var gs = fullLayout._size; - var isVertical = helpers.isVertical(opts); - var isGrouped = helpers.isGrouped(opts); + var isVertical = helpers.isVertical(legendObj); + var isGrouped = helpers.isGrouped(legendObj); - var bw = opts.borderwidth; + var bw = legendObj.borderwidth; var bw2 = 2 * bw; var itemGap = constants.itemGap; - var textGap = opts.itemwidth + itemGap * 2; + var textGap = legendObj.itemwidth + itemGap * 2; var endPad = 2 * (bw + itemGap); - var yanchor = getYanchor(opts); - var isBelowPlotArea = opts.y < 0 || (opts.y === 0 && yanchor === 'top'); - var isAbovePlotArea = opts.y > 1 || (opts.y === 1 && yanchor === 'bottom'); + var yanchor = getYanchor(legendObj); + var isBelowPlotArea = legendObj.y < 0 || (legendObj.y === 0 && yanchor === 'top'); + var isAbovePlotArea = legendObj.y > 1 || (legendObj.y === 1 && yanchor === 'bottom'); + + var traceGroupGap = legendObj.tracegroupgap; // - if below/above plot area, give it the maximum potential margin-push value // - otherwise, extend the height of the plot area - opts._maxHeight = Math.max( + legendObj._maxHeight = Math.max( (isBelowPlotArea || isAbovePlotArea) ? fullLayout.height / 2 : gs.h, 30 ); var toggleRectWidth = 0; - opts._width = 0; - opts._height = 0; - var titleSize = getTitleSize(opts); + legendObj._width = 0; + legendObj._height = 0; + var titleSize = getTitleSize(legendObj); if(isVertical) { traces.each(function(d) { var h = d[0].height; Drawing.setTranslate(this, bw + titleSize[0], - bw + titleSize[1] + opts._height + h / 2 + itemGap + bw + titleSize[1] + legendObj._height + h / 2 + itemGap ); - opts._height += h; - opts._width = Math.max(opts._width, d[0].width); + legendObj._height += h; + legendObj._width = Math.max(legendObj._width, d[0].width); }); - toggleRectWidth = textGap + opts._width; - opts._width += itemGap + textGap + bw2; - opts._height += endPad; + toggleRectWidth = textGap + legendObj._width; + legendObj._width += itemGap + textGap + bw2; + legendObj._height += endPad; if(isGrouped) { groups.each(function(d, i) { - Drawing.setTranslate(this, 0, i * opts.tracegroupgap); + Drawing.setTranslate(this, 0, i * legendObj.tracegroupgap); }); - opts._height += (opts._lgroupsLength - 1) * opts.tracegroupgap; + legendObj._height += (legendObj._lgroupsLength - 1) * legendObj.tracegroupgap; } } else { - var xanchor = getXanchor(opts); - var isLeftOfPlotArea = opts.x < 0 || (opts.x === 0 && xanchor === 'right'); - var isRightOfPlotArea = opts.x > 1 || (opts.x === 1 && xanchor === 'left'); + var xanchor = getXanchor(legendObj); + var isLeftOfPlotArea = legendObj.x < 0 || (legendObj.x === 0 && xanchor === 'right'); + var isRightOfPlotArea = legendObj.x > 1 || (legendObj.x === 1 && xanchor === 'left'); var isBeyondPlotAreaY = isAbovePlotArea || isBelowPlotArea; var hw = fullLayout.width / 2; // - if placed within x-margins, extend the width of the plot area // - else if below/above plot area and anchored in the margin, extend to opposite margin, // - otherwise give it the maximum potential margin-push value - opts._maxWidth = Math.max( + legendObj._maxWidth = Math.max( isLeftOfPlotArea ? ((isBeyondPlotAreaY && xanchor === 'left') ? gs.l + gs.w : hw) : isRightOfPlotArea ? ((isBeyondPlotAreaY && xanchor === 'right') ? gs.r + gs.w : hw) : gs.w, @@ -32681,10 +42494,10 @@ function computeLegendDimensions(gd, groups, traces, opts) { var next = maxWidthInGroup + itemGap; - if((next + bw + groupOffsetX) > opts._maxWidth) { + if((next + bw + groupOffsetX) > legendObj._maxWidth) { maxRowWidth = Math.max(maxRowWidth, groupOffsetX); groupOffsetX = 0; - groupOffsetY += maxGroupHeightInRow + opts.tracegroupgap; + groupOffsetY += maxGroupHeightInRow + traceGroupGap; maxGroupHeightInRow = offsetY; } @@ -32693,11 +42506,11 @@ function computeLegendDimensions(gd, groups, traces, opts) { groupOffsetX += next; }); - opts._width = Math.max(maxRowWidth, groupOffsetX) + bw; - opts._height = groupOffsetY + maxGroupHeightInRow + endPad; + legendObj._width = Math.max(maxRowWidth, groupOffsetX) + bw; + legendObj._height = groupOffsetY + maxGroupHeightInRow + endPad; } else { var nTraces = traces.size(); - var oneRowLegend = (combinedItemWidth + bw2 + (nTraces - 1) * itemGap) < opts._maxWidth; + var oneRowLegend = (combinedItemWidth + bw2 + (nTraces - 1) * itemGap) < legendObj._maxWidth; var maxItemHeightInRow = 0; var offsetX = 0; @@ -32708,11 +42521,11 @@ function computeLegendDimensions(gd, groups, traces, opts) { var w = textGap + d[0].width; var next = (oneRowLegend ? w : maxItemWidth) + itemGap; - if((next + bw + offsetX - itemGap) >= opts._maxWidth) { + if((next + bw + offsetX - itemGap) >= legendObj._maxWidth) { maxRowWidth = Math.max(maxRowWidth, rowWidth); offsetX = 0; offsetY += maxItemHeightInRow; - opts._height += maxItemHeightInRow; + legendObj._height += maxItemHeightInRow; maxItemHeightInRow = 0; } @@ -32727,30 +42540,30 @@ function computeLegendDimensions(gd, groups, traces, opts) { }); if(oneRowLegend) { - opts._width = offsetX + bw2; - opts._height = maxItemHeightInRow + endPad; + legendObj._width = offsetX + bw2; + legendObj._height = maxItemHeightInRow + endPad; } else { - opts._width = Math.max(maxRowWidth, rowWidth) + bw2; - opts._height += maxItemHeightInRow + endPad; + legendObj._width = Math.max(maxRowWidth, rowWidth) + bw2; + legendObj._height += maxItemHeightInRow + endPad; } } } - opts._width = Math.ceil( + legendObj._width = Math.ceil( Math.max( - opts._width + titleSize[0], - opts._titleWidth + 2 * (bw + constants.titlePad) + legendObj._width + titleSize[0], + legendObj._titleWidth + 2 * (bw + constants.titlePad) ) ); - opts._height = Math.ceil( + legendObj._height = Math.ceil( Math.max( - opts._height + titleSize[1], - opts._titleHeight + 2 * (bw + constants.itemGap) + legendObj._height + titleSize[1], + legendObj._titleHeight + 2 * (bw + constants.itemGap) ) ); - opts._effHeight = Math.min(opts._height, opts._maxHeight); + legendObj._effHeight = Math.min(legendObj._height, legendObj._maxHeight); var edits = gd._context.edits; var isEditable = edits.legendText || edits.legendPosition; @@ -32765,41 +42578,33 @@ function computeLegendDimensions(gd, groups, traces, opts) { function expandMargin(gd) { var fullLayout = gd._fullLayout; - var opts = fullLayout.legend; - var xanchor = getXanchor(opts); - var yanchor = getYanchor(opts); + var legendObj = fullLayout.legend; + var xanchor = getXanchor(legendObj); + var yanchor = getYanchor(legendObj); return Plots.autoMargin(gd, 'legend', { - x: opts.x, - y: opts.y, - l: opts._width * (FROM_TL[xanchor]), - r: opts._width * (FROM_BR[xanchor]), - b: opts._effHeight * (FROM_BR[yanchor]), - t: opts._effHeight * (FROM_TL[yanchor]) + x: legendObj.x, + y: legendObj.y, + l: legendObj._width * (FROM_TL[xanchor]), + r: legendObj._width * (FROM_BR[xanchor]), + b: legendObj._effHeight * (FROM_BR[yanchor]), + t: legendObj._effHeight * (FROM_TL[yanchor]) }); } -function getXanchor(opts) { - return Lib.isRightAnchor(opts) ? 'right' : - Lib.isCenterAnchor(opts) ? 'center' : +function getXanchor(legendObj) { + return Lib.isRightAnchor(legendObj) ? 'right' : + Lib.isCenterAnchor(legendObj) ? 'center' : 'left'; } -function getYanchor(opts) { - return Lib.isBottomAnchor(opts) ? 'bottom' : - Lib.isMiddleAnchor(opts) ? 'middle' : +function getYanchor(legendObj) { + return Lib.isBottomAnchor(legendObj) ? 'bottom' : + Lib.isMiddleAnchor(legendObj) ? 'middle' : 'top'; } -},{"../../constants/alignment":207,"../../lib":233,"../../lib/events":226,"../../lib/svg_text_utils":255,"../../plots/plots":313,"../../registry":326,"../color":105,"../dragelement":124,"../drawing":127,"./constants":156,"./get_legend_data":159,"./handle_click":160,"./helpers":161,"./style":163,"d3":21}],159:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/alignment":260,"../../lib":285,"../../lib/events":278,"../../lib/svg_text_utils":307,"../../plots/plots":366,"../../registry":373,"../color":155,"../dragelement":174,"../drawing":177,"./constants":206,"./get_legend_data":209,"./handle_click":210,"./helpers":211,"./style":213,"@plotly/d3":20}],209:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -32813,7 +42618,6 @@ module.exports = function getLegendData(calcdata, opts) { var lgroupi = 0; var maxNameLength = 0; var i, j; - var main = opts._main; function addOneItem(legendGroup, legendItem) { // each '' legend group is treated as a separate group @@ -32839,7 +42643,7 @@ module.exports = function getLegendData(calcdata, opts) { var trace = cd0.trace; var lgroup = trace.legendgroup; - if(main && (!trace.visible || !trace.showlegend)) continue; + if(!opts._inHover && (!trace.visible || !trace.showlegend)) continue; if(Registry.traceIs(trace, 'pie-like')) { if(!slicesShown[lgroup]) slicesShown[lgroup] = {}; @@ -32900,15 +42704,7 @@ module.exports = function getLegendData(calcdata, opts) { return legendData; }; -},{"../../registry":326,"./helpers":161}],160:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../registry":373,"./helpers":211}],210:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -33139,16 +42935,7 @@ module.exports = function handleClick(g, gd, numClicks) { } }; -},{"../../lib":233,"../../registry":326}],161:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../registry":373}],211:[function(_dereq_,module,exports){ 'use strict'; exports.isGrouped = function isGrouped(legendLayout) { @@ -33163,16 +42950,7 @@ exports.isReversed = function isReversed(legendLayout) { return (legendLayout.traceorder || '').indexOf('reversed') !== -1; }; -},{}],162:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],212:[function(_dereq_,module,exports){ 'use strict'; @@ -33187,18 +42965,10 @@ module.exports = { style: _dereq_('./style') }; -},{"./attributes":155,"./defaults":157,"./draw":158,"./style":163}],163:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"./attributes":205,"./defaults":207,"./draw":208,"./style":213}],213:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Registry = _dereq_('../../registry'); var Lib = _dereq_('../../lib'); @@ -33293,13 +43063,16 @@ module.exports = function style(s, gd, legend) { .each(styleOHLC); function styleLines(d) { + var styleGuide = getStyleGuide(d); + var showFill = styleGuide.showFill; + var showLine = styleGuide.showLine; + var showGradientLine = styleGuide.showGradientLine; + var showGradientFill = styleGuide.showGradientFill; + var anyFill = styleGuide.anyFill; + var anyLine = styleGuide.anyLine; + var d0 = d[0]; var trace = d0.trace; - var showFill = trace.visible && trace.fill && trace.fill !== 'none'; - var showLine = subTypes.hasLines(trace); - var contours = trace.contours; - var showGradientLine = false; - var showGradientFill = false; var dMod, tMod; var cOpts = extractOpts(trace); @@ -33325,28 +43098,10 @@ module.exports = function style(s, gd, legend) { } }; - if(contours) { - var coloring = contours.coloring; - - if(coloring === 'lines') { - showGradientLine = true; - } else { - showLine = coloring === 'none' || coloring === 'heatmap' || contours.showlines; - } - - if(contours.type === 'constraint') { - showFill = contours._operation !== '='; - } else if(coloring === 'fill' || coloring === 'heatmap') { - showGradientFill = true; - } - } - // with fill and no markers or text, move the line and fill up a bit // so it's more centered - var markersOrText = subTypes.hasMarkers(trace) || subTypes.hasText(trace); - var anyFill = showFill || showGradientFill; - var anyLine = showLine || showGradientLine; - var pathStart = (markersOrText || !anyFill) ? 'M5,0' : + + var pathStart = (subTypes.hasMarkers(trace) || !anyFill) ? 'M5,0' : // with a line leave it slightly below center, to leave room for the // line thickness and because the line is usually more prominent anyLine ? 'M5,-2' : 'M5,-3'; @@ -33382,11 +43137,15 @@ module.exports = function style(s, gd, legend) { } function stylePoints(d) { + var styleGuide = getStyleGuide(d); + var anyFill = styleGuide.anyFill; + var anyLine = styleGuide.anyLine; + var showLine = styleGuide.showLine; + var showMarker = styleGuide.showMarker; + var d0 = d[0]; var trace = d0.trace; - var showMarkers = subTypes.hasMarkers(trace); - var showText = subTypes.hasText(trace); - var showLines = subTypes.hasLines(trace); + var showText = !showMarker && !anyLine && !anyFill && subTypes.hasText(trace); var dMod, tMod; // 'scatter3d' don't use gd.calcdata, @@ -33415,11 +43174,11 @@ module.exports = function style(s, gd, legend) { } // constrain text, markers, etc so they'll fit on the legend - if(showMarkers || showText || showLines) { + if(showMarker || showText || showLine) { var dEdit = {}; var tEdit = {}; - if(showMarkers) { + if(showMarker) { dEdit.mc = boundVal('marker.color', pickFirst); dEdit.mx = boundVal('marker.symbol', pickFirst); dEdit.mo = boundVal('marker.opacity', Lib.mean, [0.2, 1]); @@ -33436,7 +43195,7 @@ module.exports = function style(s, gd, legend) { tEdit.marker.size = ms; } - if(showLines) { + if(showLine) { tEdit.line = { width: boundVal('line.width', pickFirst, [0, 10], CST_LINE_WIDTH) }; @@ -33463,7 +43222,7 @@ module.exports = function style(s, gd, legend) { var ptgroup = d3.select(this).select('g.legendpoints'); var pts = ptgroup.selectAll('path.scatterpts') - .data(showMarkers ? dMod : []); + .data(showMarker ? dMod : []); // make sure marker is on the bottom, in case it enters after text pts.enter().insert('path', ':first-child') .classed('scatterpts', true) @@ -33473,7 +43232,7 @@ module.exports = function style(s, gd, legend) { // 'mrc' is set in pointStyle and used in textPointStyle: // constrain it here - if(showMarkers) dMod[0].mrc = 3; + if(showMarker) dMod[0].mrc = 3; var txt = ptgroup.selectAll('g.pointtext') .data(showText ? dMod : []); @@ -33555,8 +43314,23 @@ module.exports = function style(s, gd, legend) { var d0 = d[0]; var w = boundLineWidth(d0.mlw, marker.line, MAX_MARKER_LINE_WIDTH, CST_MARKER_LINE_WIDTH); - p.style('stroke-width', w + 'px') - .call(Color.fill, d0.mc || marker.color); + p.style('stroke-width', w + 'px'); + + var fillColor = d0.mc || marker.color; + + var markerPattern = marker.pattern; + var patternShape = markerPattern && Drawing.getPatternAttr(markerPattern.shape, 0, ''); + + if(patternShape) { + var patternBGColor = Drawing.getPatternAttr(markerPattern.bgcolor, 0, null); + var patternSize = Math.min(12, Drawing.getPatternAttr(markerPattern.size, 0, 8)); + var patternSolidity = Drawing.getPatternAttr(markerPattern.solidity, 0, 0.3); + var patternID = 'legend-' + trace.uid; + p.call(Drawing.pattern, gd, patternID, patternShape, patternBGColor, + fillColor, patternSize, patternSolidity, 'fill'); + } else { + p.call(Color.fill, fillColor); + } if(w) Color.stroke(p, d0.mlc || markerLine.color); }); @@ -33820,15 +43594,88 @@ function getGradientDirection(reversescale, isRadial) { return str + (reversescale ? '' : 'reversed'); } -},{"../../lib":233,"../../registry":326,"../../traces/pie/helpers":439,"../../traces/pie/style_one":445,"../../traces/scatter/subtypes":472,"../color":105,"../colorscale/helpers":116,"../drawing":127,"./constants":156,"d3":21}],164:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +function getStyleGuide(d) { + var trace = d[0].trace; + var contours = trace.contours; + var showLine = subTypes.hasLines(trace); + var showMarker = subTypes.hasMarkers(trace); + var showFill = trace.visible && trace.fill && trace.fill !== 'none'; + var showGradientLine = false; + var showGradientFill = false; + + if(contours) { + var coloring = contours.coloring; + + if(coloring === 'lines') { + showGradientLine = true; + } else { + showLine = coloring === 'none' || coloring === 'heatmap' || contours.showlines; + } + + if(contours.type === 'constraint') { + showFill = contours._operation !== '='; + } else if(coloring === 'fill' || coloring === 'heatmap') { + showGradientFill = true; + } + } + + return { + showMarker: showMarker, + showLine: showLine, + showFill: showFill, + showGradientLine: showGradientLine, + showGradientFill: showGradientFill, + anyLine: showLine || showGradientLine, + anyFill: showFill || showGradientFill, + }; +} + +},{"../../lib":285,"../../registry":373,"../../traces/pie/helpers":486,"../../traces/pie/style_one":492,"../../traces/scatter/subtypes":519,"../color":155,"../colorscale/helpers":166,"../drawing":177,"./constants":206,"@plotly/d3":20}],214:[function(_dereq_,module,exports){ +'use strict'; + +var constants = _dereq_('./constants'); + +module.exports = { + editType: 'modebar', + + orientation: { + valType: 'enumerated', + values: ['v', 'h'], + dflt: 'h', + editType: 'modebar', + }, + bgcolor: { + valType: 'color', + editType: 'modebar', + }, + color: { + valType: 'color', + editType: 'modebar', + }, + activecolor: { + valType: 'color', + editType: 'modebar', + }, + uirevision: { + valType: 'any', + editType: 'none', + }, + add: { + valType: 'string', + arrayOk: true, + dflt: '', + editType: 'modebar', + }, + remove: { + valType: 'string', + arrayOk: true, + dflt: '', + editType: 'modebar', + } +}; + +},{"./constants":216}],215:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -33923,6 +43770,7 @@ modeBarButtons.editInChartStudio = { modeBarButtons.zoom2d = { name: 'zoom2d', + _cat: 'zoom', title: function(gd) { return _(gd, 'Zoom'); }, attr: 'dragmode', val: 'zoom', @@ -33932,6 +43780,7 @@ modeBarButtons.zoom2d = { modeBarButtons.pan2d = { name: 'pan2d', + _cat: 'pan', title: function(gd) { return _(gd, 'Pan'); }, attr: 'dragmode', val: 'pan', @@ -33941,6 +43790,7 @@ modeBarButtons.pan2d = { modeBarButtons.select2d = { name: 'select2d', + _cat: 'select', title: function(gd) { return _(gd, 'Box Select'); }, attr: 'dragmode', val: 'select', @@ -33950,6 +43800,7 @@ modeBarButtons.select2d = { modeBarButtons.lasso2d = { name: 'lasso2d', + _cat: 'lasso', title: function(gd) { return _(gd, 'Lasso Select'); }, attr: 'dragmode', val: 'lasso', @@ -34011,6 +43862,7 @@ modeBarButtons.eraseshape = { modeBarButtons.zoomIn2d = { name: 'zoomIn2d', + _cat: 'zoomin', title: function(gd) { return _(gd, 'Zoom in'); }, attr: 'zoom', val: 'in', @@ -34020,6 +43872,7 @@ modeBarButtons.zoomIn2d = { modeBarButtons.zoomOut2d = { name: 'zoomOut2d', + _cat: 'zoomout', title: function(gd) { return _(gd, 'Zoom out'); }, attr: 'zoom', val: 'out', @@ -34029,6 +43882,7 @@ modeBarButtons.zoomOut2d = { modeBarButtons.autoScale2d = { name: 'autoScale2d', + _cat: 'autoscale', title: function(gd) { return _(gd, 'Autoscale'); }, attr: 'zoom', val: 'auto', @@ -34038,6 +43892,7 @@ modeBarButtons.autoScale2d = { modeBarButtons.resetScale2d = { name: 'resetScale2d', + _cat: 'resetscale', title: function(gd) { return _(gd, 'Reset axes'); }, attr: 'zoom', val: 'reset', @@ -34047,6 +43902,7 @@ modeBarButtons.resetScale2d = { modeBarButtons.hoverClosestCartesian = { name: 'hoverClosestCartesian', + _cat: 'hoverclosest', title: function(gd) { return _(gd, 'Show closest data on hover'); }, attr: 'hovermode', val: 'closest', @@ -34057,6 +43913,7 @@ modeBarButtons.hoverClosestCartesian = { modeBarButtons.hoverCompareCartesian = { name: 'hoverCompareCartesian', + _cat: 'hoverCompare', title: function(gd) { return _(gd, 'Compare data on hover'); }, attr: 'hovermode', val: function(gd) { @@ -34140,6 +43997,7 @@ function handleCartesian(gd, ev) { modeBarButtons.zoom3d = { name: 'zoom3d', + _cat: 'zoom', title: function(gd) { return _(gd, 'Zoom'); }, attr: 'scene.dragmode', val: 'zoom', @@ -34149,6 +44007,7 @@ modeBarButtons.zoom3d = { modeBarButtons.pan3d = { name: 'pan3d', + _cat: 'pan', title: function(gd) { return _(gd, 'Pan'); }, attr: 'scene.dragmode', val: 'pan', @@ -34196,6 +44055,7 @@ function handleDrag3d(gd, ev) { modeBarButtons.resetCameraDefault3d = { name: 'resetCameraDefault3d', + _cat: 'resetCameraDefault', title: function(gd) { return _(gd, 'Reset camera to default'); }, attr: 'resetDefault', icon: Icons.home, @@ -34204,6 +44064,7 @@ modeBarButtons.resetCameraDefault3d = { modeBarButtons.resetCameraLastSave3d = { name: 'resetCameraLastSave3d', + _cat: 'resetCameraLastSave', title: function(gd) { return _(gd, 'Reset camera to last save'); }, attr: 'resetLastSave', icon: Icons.movie, @@ -34253,6 +44114,7 @@ function handleCamera3d(gd, ev) { modeBarButtons.hoverClosest3d = { name: 'hoverClosest3d', + _cat: 'hoverclosest', title: function(gd) { return _(gd, 'Toggle show closest data on hover'); }, attr: 'hovermode', val: null, @@ -34307,6 +44169,7 @@ function handleHover3d(gd, ev) { modeBarButtons.zoomInGeo = { name: 'zoomInGeo', + _cat: 'zoomin', title: function(gd) { return _(gd, 'Zoom in'); }, attr: 'zoom', val: 'in', @@ -34316,6 +44179,7 @@ modeBarButtons.zoomInGeo = { modeBarButtons.zoomOutGeo = { name: 'zoomOutGeo', + _cat: 'zoomout', title: function(gd) { return _(gd, 'Zoom out'); }, attr: 'zoom', val: 'out', @@ -34325,6 +44189,7 @@ modeBarButtons.zoomOutGeo = { modeBarButtons.resetGeo = { name: 'resetGeo', + _cat: 'reset', title: function(gd) { return _(gd, 'Reset'); }, attr: 'reset', val: null, @@ -34334,6 +44199,7 @@ modeBarButtons.resetGeo = { modeBarButtons.hoverClosestGeo = { name: 'hoverClosestGeo', + _cat: 'hoverclosest', title: function(gd) { return _(gd, 'Toggle show closest data on hover'); }, attr: 'hovermode', val: null, @@ -34369,6 +44235,7 @@ function handleGeo(gd, ev) { modeBarButtons.hoverClosestGl2d = { name: 'hoverClosestGl2d', + _cat: 'hoverclosest', title: function(gd) { return _(gd, 'Toggle show closest data on hover'); }, attr: 'hovermode', val: null, @@ -34380,6 +44247,7 @@ modeBarButtons.hoverClosestGl2d = { modeBarButtons.hoverClosestPie = { name: 'hoverClosestPie', + _cat: 'hoverclosest', title: function(gd) { return _(gd, 'Toggle show closest data on hover'); }, attr: 'hovermode', val: 'closest', @@ -34492,6 +44360,7 @@ function setSpikelineVisibility(gd) { modeBarButtons.resetViewMapbox = { name: 'resetViewMapbox', + _cat: 'resetView', title: function(gd) { return _(gd, 'Reset view'); }, attr: 'reset', icon: Icons.home, @@ -34502,6 +44371,7 @@ modeBarButtons.resetViewMapbox = { modeBarButtons.zoomInMapbox = { name: 'zoomInMapbox', + _cat: 'zoomin', title: function(gd) { return _(gd, 'Zoom in'); }, attr: 'zoom', val: 'in', @@ -34511,6 +44381,7 @@ modeBarButtons.zoomInMapbox = { modeBarButtons.zoomOutMapbox = { name: 'zoomOutMapbox', + _cat: 'zoomout', title: function(gd) { return _(gd, 'Zoom out'); }, attr: 'zoom', val: 'out', @@ -34556,30 +44427,89 @@ function resetView(gd, subplotType) { Registry.call('_guiRelayout', gd, aObj); } -},{"../../fonts/ploticon":216,"../../lib":233,"../../plots/cartesian/axis_ids":282,"../../plots/plots":313,"../../registry":326,"../shapes/draw":186}],165:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../fonts/ploticon":268,"../../lib":285,"../../plots/cartesian/axis_ids":334,"../../plots/plots":366,"../../registry":373,"../shapes/draw":239}],216:[function(_dereq_,module,exports){ 'use strict'; -exports.manage = _dereq_('./manage'); +var modeBarButtons = _dereq_('./buttons'); +var buttonList = Object.keys(modeBarButtons); -},{"./manage":166}],166:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +var DRAW_MODES = [ + 'drawline', + 'drawopenpath', + 'drawclosedpath', + 'drawcircle', + 'drawrect', + 'eraseshape' +]; +var backButtons = [ + 'v1hovermode', + 'hoverclosest', + 'hovercompare', + 'togglehover', + 'togglespikelines' +].concat(DRAW_MODES); +var foreButtons = []; +var addToForeButtons = function(b) { + if(backButtons.indexOf(b._cat || b.name) !== -1) return; + // for convenience add lowercase shotname e.g. zoomin as well fullname zoomInGeo + var name = b.name; + var _cat = (b._cat || b.name).toLowerCase(); + if(foreButtons.indexOf(name) === -1) foreButtons.push(name); + if(foreButtons.indexOf(_cat) === -1) foreButtons.push(_cat); +}; +buttonList.forEach(function(k) { + addToForeButtons(modeBarButtons[k]); +}); +foreButtons.sort(); + +module.exports = { + DRAW_MODES: DRAW_MODES, + backButtons: backButtons, + foreButtons: foreButtons +}; + +},{"./buttons":215}],217:[function(_dereq_,module,exports){ +'use strict'; + +var Lib = _dereq_('../../lib'); +var Color = _dereq_('../color'); +var Template = _dereq_('../../plot_api/plot_template'); +var attributes = _dereq_('./attributes'); + +module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) { + var containerIn = layoutIn.modebar || {}; + var containerOut = Template.newContainer(layoutOut, 'modebar'); + + function coerce(attr, dflt) { + return Lib.coerce(containerIn, containerOut, attributes, attr, dflt); + } + + coerce('orientation'); + coerce('bgcolor', Color.addOpacity(layoutOut.paper_bgcolor, 0.5)); + var defaultColor = Color.contrast(Color.rgb(layoutOut.modebar.bgcolor)); + coerce('color', Color.addOpacity(defaultColor, 0.3)); + coerce('activecolor', Color.addOpacity(defaultColor, 0.7)); + coerce('uirevision', layoutOut.uirevision); + coerce('add'); + coerce('remove'); +}; + +},{"../../lib":285,"../../plot_api/plot_template":320,"../color":155,"./attributes":214}],218:[function(_dereq_,module,exports){ +'use strict'; + +module.exports = { + moduleType: 'component', + name: 'modebar', + + layoutAttributes: _dereq_('./attributes'), + supplyLayoutDefaults: _dereq_('./defaults'), + + manage: _dereq_('./manage') +}; + +},{"./attributes":214,"./defaults":217,"./manage":219}],219:[function(_dereq_,module,exports){ 'use strict'; var axisIds = _dereq_('../../plots/cartesian/axis_ids'); @@ -34589,6 +44519,7 @@ var isUnifiedHover = _dereq_('../fx/helpers').isUnifiedHover; var createModeBar = _dereq_('./modebar'); var modeBarButtons = _dereq_('./buttons'); +var DRAW_MODES = _dereq_('./constants').DRAW_MODES; /** * ModeBar wrapper around 'create' and 'update', @@ -34640,22 +44571,47 @@ module.exports = function manageModeBar(gd) { else fullLayout._modeBar = createModeBar(gd, buttonGroups); }; -var DRAW_MODES = [ - 'drawline', - 'drawopenpath', - 'drawclosedpath', - 'drawcircle', - 'drawrect', - 'eraseshape' -]; - // logic behind which buttons are displayed by default function getButtonGroups(gd) { var fullLayout = gd._fullLayout; var fullData = gd._fullData; var context = gd._context; - var buttonsToRemove = context.modeBarButtonsToRemove; - var buttonsToAdd = context.modeBarButtonsToAdd; + + function match(name, B) { + if(typeof B === 'string') { + if(B.toLowerCase() === name.toLowerCase()) return true; + } else { + var v0 = B.name; + var v1 = (B._cat || B.name); + + if(v0 === name || v1 === name.toLowerCase()) return true; + } + return false; + } + + var layoutAdd = fullLayout.modebar.add; + if(typeof layoutAdd === 'string') layoutAdd = [layoutAdd]; + + var layoutRemove = fullLayout.modebar.remove; + if(typeof layoutRemove === 'string') layoutRemove = [layoutRemove]; + + var buttonsToAdd = context.modeBarButtonsToAdd.concat( + layoutAdd.filter(function(e) { + for(var i = 0; i < context.modeBarButtonsToRemove.length; i++) { + if(match(e, context.modeBarButtonsToRemove[i])) return false; + } + return true; + }) + ); + + var buttonsToRemove = context.modeBarButtonsToRemove.concat( + layoutRemove.filter(function(e) { + for(var i = 0; i < context.modeBarButtonsToAdd.length; i++) { + if(match(e, context.modeBarButtonsToAdd[i])) return false; + } + return true; + }) + ); var hasCartesian = fullLayout._has('cartesian'); var hasGL3D = fullLayout._has('gl3d'); @@ -34678,9 +44634,20 @@ function getButtonGroups(gd) { var out = []; for(var i = 0; i < newGroup.length; i++) { - var button = newGroup[i]; - if(buttonsToRemove.indexOf(button) !== -1) continue; - out.push(modeBarButtons[button]); + var name = newGroup[i]; + var B = modeBarButtons[name]; + var v0 = B.name.toLowerCase(); + var v1 = (B._cat || B.name).toLowerCase(); + var found = false; + for(var q = 0; q < buttonsToRemove.length; q++) { + var t = buttonsToRemove[q].toLowerCase(); + if(t === v0 || t === v1) { + found = true; + break; + } + } + if(found) continue; + out.push(modeBarButtons[name]); } groups.push(out); @@ -34752,19 +44719,50 @@ function getButtonGroups(gd) { dragModeGroup.push('select2d', 'lasso2d'); } - // accept pre-defined buttons as string + var enabledHoverGroup = []; + var enableHover = function(a) { + // return if already added + if(enabledHoverGroup.indexOf(a) !== -1) return; + // should be in hoverGroup + if(hoverGroup.indexOf(a) !== -1) { + enabledHoverGroup.push(a); + } + }; if(Array.isArray(buttonsToAdd)) { var newList = []; for(var i = 0; i < buttonsToAdd.length; i++) { var b = buttonsToAdd[i]; if(typeof b === 'string') { + b = b.toLowerCase(); + if(DRAW_MODES.indexOf(b) !== -1) { + // accept pre-defined drag modes i.e. shape drawing features as string if( fullLayout._has('mapbox') || // draw shapes in paper coordinate (could be improved in future to support data coordinate, when there is no pitch) fullLayout._has('cartesian') // draw shapes in data coordinate ) { dragModeGroup.push(b); } + } else if(b === 'togglespikelines') { + enableHover('toggleSpikelines'); + } else if(b === 'togglehover') { + enableHover('toggleHover'); + } else if(b === 'hovercompare') { + enableHover('hoverCompareCartesian'); + } else if(b === 'hoverclosest') { + enableHover('hoverClosestCartesian'); + enableHover('hoverClosestGeo'); + enableHover('hoverClosest3d'); + enableHover('hoverClosestGl2d'); + enableHover('hoverClosestPie'); + } else if(b === 'v1hovermode') { + enableHover('toggleHover'); + enableHover('hoverClosestCartesian'); + enableHover('hoverCompareCartesian'); + enableHover('hoverClosestGeo'); + enableHover('hoverClosest3d'); + enableHover('hoverClosestGl2d'); + enableHover('hoverClosestPie'); } } else newList.push(b); } @@ -34773,7 +44771,7 @@ function getButtonGroups(gd) { addGroup(dragModeGroup); addGroup(zoomGroup.concat(resetGroup)); - addGroup(hoverGroup); + addGroup(enabledHoverGroup); return appendButtonsToGroups(groups, buttonsToAdd); } @@ -34866,19 +44864,10 @@ function fillCustomButton(customButtons) { return customButtons; } -},{"../../plots/cartesian/axis_ids":282,"../../registry":326,"../../traces/scatter/subtypes":472,"../fx/helpers":141,"./buttons":164,"./modebar":167}],167:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../plots/cartesian/axis_ids":334,"../../registry":373,"../../traces/scatter/subtypes":519,"../fx/helpers":191,"./buttons":215,"./constants":216,"./modebar":220}],220:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); @@ -35212,15 +45201,7 @@ function createModeBar(gd, buttons) { module.exports = createModeBar; -},{"../../fonts/ploticon":216,"../../lib":233,"d3":21,"fast-isnumeric":23}],168:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../fonts/ploticon":268,"../../lib":285,"@plotly/d3":20,"fast-isnumeric":31}],221:[function(_dereq_,module,exports){ 'use strict'; var fontAttrs = _dereq_('../../plots/font_attributes'); @@ -35230,51 +45211,38 @@ var templatedArray = _dereq_('../../plot_api/plot_template').templatedArray; var buttonAttrs = templatedArray('button', { visible: { valType: 'boolean', - dflt: true, editType: 'plot', - }, step: { valType: 'enumerated', - values: ['month', 'year', 'day', 'hour', 'minute', 'second', 'all'], dflt: 'month', editType: 'plot', - }, stepmode: { valType: 'enumerated', - values: ['backward', 'todate'], dflt: 'backward', editType: 'plot', - }, count: { valType: 'number', - min: 0, dflt: 1, editType: 'plot', - }, label: { valType: 'string', - editType: 'plot', - }, editType: 'plot', - }); module.exports = { visible: { valType: 'boolean', - editType: 'plot', - }, buttons: buttonAttrs, @@ -35283,80 +45251,55 @@ module.exports = { valType: 'number', min: -2, max: 3, - editType: 'plot', - }, xanchor: { valType: 'enumerated', values: ['auto', 'left', 'center', 'right'], dflt: 'left', - editType: 'plot', - }, y: { valType: 'number', min: -2, max: 3, - editType: 'plot', - }, yanchor: { valType: 'enumerated', values: ['auto', 'top', 'middle', 'bottom'], dflt: 'bottom', - editType: 'plot', - }, font: fontAttrs({ editType: 'plot', - }), bgcolor: { valType: 'color', dflt: colorAttrs.lightLine, - editType: 'plot', - }, activecolor: { valType: 'color', - editType: 'plot', - }, bordercolor: { valType: 'color', dflt: colorAttrs.defaultLine, - editType: 'plot', - }, borderwidth: { valType: 'number', min: 0, dflt: 0, - editType: 'plot', - }, editType: 'plot' }; -},{"../../plot_api/plot_template":268,"../../plots/font_attributes":307,"../color/attributes":104}],169:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plot_api/plot_template":320,"../../plots/font_attributes":359,"../color/attributes":154}],222:[function(_dereq_,module,exports){ 'use strict'; @@ -35377,15 +45320,7 @@ module.exports = { darkAmount: 10 }; -},{}],170:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],223:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -35469,18 +45404,10 @@ function getPosDflt(containerOut, layout, counterAxes) { return [containerOut.domain[0], posY + constants.yPad]; } -},{"../../lib":233,"../../plot_api/plot_template":268,"../../plots/array_container_defaults":274,"../color":105,"./attributes":168,"./constants":169}],171:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plot_api/plot_template":320,"../../plots/array_container_defaults":326,"../color":155,"./attributes":221,"./constants":222}],224:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Registry = _dereq_('../../registry'); var Plots = _dereq_('../../plots/plots'); @@ -35724,19 +45651,10 @@ function reposition(gd, buttons, opts, axName, selector) { selector.attr('transform', strTranslate(lx, ly)); } -},{"../../constants/alignment":207,"../../lib":233,"../../lib/svg_text_utils":255,"../../plots/cartesian/axis_ids":282,"../../plots/plots":313,"../../registry":326,"../color":105,"../drawing":127,"./constants":169,"./get_update_object":172,"d3":21}],172:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../constants/alignment":260,"../../lib":285,"../../lib/svg_text_utils":307,"../../plots/cartesian/axis_ids":334,"../../plots/plots":366,"../../registry":373,"../color":155,"../drawing":177,"./constants":222,"./get_update_object":225,"@plotly/d3":20}],225:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); module.exports = function getUpdateObject(axisLayout, buttonLayout) { var axName = axisLayout._name; @@ -35778,15 +45696,7 @@ function getXRange(axisLayout, buttonLayout) { return [range0, range1]; } -},{"d3":21}],173:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"@plotly/d3":20}],226:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -35805,15 +45715,7 @@ module.exports = { draw: _dereq_('./draw') }; -},{"./attributes":168,"./defaults":170,"./draw":171}],174:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"./attributes":221,"./defaults":223,"./draw":224}],227:[function(_dereq_,module,exports){ 'use strict'; var colorAttributes = _dereq_('../color/attributes'); @@ -35822,72 +45724,50 @@ module.exports = { bgcolor: { valType: 'color', dflt: colorAttributes.background, - editType: 'plot', - }, bordercolor: { valType: 'color', dflt: colorAttributes.defaultLine, - editType: 'plot', - }, borderwidth: { valType: 'integer', dflt: 0, min: 0, - editType: 'plot', - }, autorange: { valType: 'boolean', dflt: true, - editType: 'calc', impliedEdits: {'range[0]': undefined, 'range[1]': undefined}, - }, range: { valType: 'info_array', - items: [ {valType: 'any', editType: 'calc', impliedEdits: {'^autorange': false}}, {valType: 'any', editType: 'calc', impliedEdits: {'^autorange': false}} ], editType: 'calc', impliedEdits: {'autorange': false}, - }, thickness: { valType: 'number', dflt: 0.15, min: 0, max: 1, - editType: 'plot', - }, visible: { valType: 'boolean', dflt: true, - editType: 'calc', - }, editType: 'calc' }; -},{"../color/attributes":104}],175:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../color/attributes":154}],228:[function(_dereq_,module,exports){ 'use strict'; var listAxes = _dereq_('../../plots/cartesian/axis_ids').list; @@ -35913,15 +45793,7 @@ module.exports = function calcAutorange(gd) { } }; -},{"../../plots/cartesian/autorange":278,"../../plots/cartesian/axis_ids":282,"./constants":176}],176:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian/autorange":330,"../../plots/cartesian/axis_ids":334,"./constants":229}],229:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -35969,15 +45841,7 @@ module.exports = { extraPad: 15 }; -},{}],177:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],230:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -36055,18 +45919,10 @@ module.exports = function handleDefaults(layoutIn, layoutOut, axName) { containerOut._input = containerIn; }; -},{"../../lib":233,"../../plot_api/plot_template":268,"../../plots/cartesian/axis_ids":282,"./attributes":174,"./oppaxis_attributes":181}],178:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plot_api/plot_template":320,"../../plots/cartesian/axis_ids":334,"./attributes":227,"./oppaxis_attributes":234}],231:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Registry = _dereq_('../../registry'); var Plots = _dereq_('../../plots/plots'); @@ -36699,15 +46555,7 @@ function drawGrabbers(rangeSlider, gd, axisOpts, opts) { grabAreaMax.attr('height', opts._height); } -},{"../../lib":233,"../../lib/setcursor":253,"../../plots/cartesian":292,"../../plots/cartesian/axis_ids":282,"../../plots/plots":313,"../../registry":326,"../color":105,"../dragelement":124,"../drawing":127,"../titles":200,"./constants":176,"d3":21}],179:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../lib/setcursor":305,"../../plots/cartesian":344,"../../plots/cartesian/axis_ids":334,"../../plots/plots":366,"../../registry":373,"../color":155,"../dragelement":174,"../drawing":177,"../titles":253,"./constants":229,"@plotly/d3":20}],232:[function(_dereq_,module,exports){ 'use strict'; var axisIDs = _dereq_('../../plots/cartesian/axis_ids'); @@ -36774,15 +46622,7 @@ exports.autoMarginOpts = function(gd, ax) { }; }; -},{"../../constants/alignment":207,"../../lib/svg_text_utils":255,"../../plots/cartesian/axis_ids":282,"./constants":176}],180:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/alignment":260,"../../lib/svg_text_utils":307,"../../plots/cartesian/axis_ids":334,"./constants":229}],233:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -36813,15 +46653,7 @@ module.exports = { autoMarginOpts: helpers.autoMarginOpts }; -},{"../../lib":233,"./attributes":174,"./calc_autorange":175,"./defaults":177,"./draw":178,"./helpers":179,"./oppaxis_attributes":181}],181:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"./attributes":227,"./calc_autorange":228,"./defaults":230,"./draw":231,"./helpers":232,"./oppaxis_attributes":234}],234:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -36834,32 +46666,20 @@ module.exports = { valType: 'enumerated', values: ['auto', 'fixed', 'match'], dflt: 'match', - editType: 'calc', - }, range: { valType: 'info_array', - items: [ {valType: 'any', editType: 'plot'}, {valType: 'any', editType: 'plot'} ], editType: 'plot', - }, editType: 'calc' }; -},{}],182:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],235:[function(_dereq_,module,exports){ 'use strict'; var annAttrs = _dereq_('../annotations/attributes'); @@ -36872,94 +46692,68 @@ var axisPlaceableObjs = _dereq_('../../constants/axis_placeable_objects'); module.exports = templatedArray('shape', { visible: { valType: 'boolean', - dflt: true, editType: 'calc+arraydraw', - }, type: { valType: 'enumerated', values: ['circle', 'rect', 'path', 'line'], - editType: 'calc+arraydraw', - }, layer: { valType: 'enumerated', values: ['below', 'above'], dflt: 'above', - editType: 'arraydraw', - }, xref: extendFlat({}, annAttrs.xref, { - }), xsizemode: { valType: 'enumerated', values: ['scaled', 'pixel'], dflt: 'scaled', - editType: 'calc+arraydraw', - }, xanchor: { valType: 'any', - editType: 'calc+arraydraw', - }, x0: { valType: 'any', - editType: 'calc+arraydraw', - }, x1: { valType: 'any', - editType: 'calc+arraydraw', - }, yref: extendFlat({}, annAttrs.yref, { - }), ysizemode: { valType: 'enumerated', values: ['scaled', 'pixel'], dflt: 'scaled', - editType: 'calc+arraydraw', - }, yanchor: { valType: 'any', - editType: 'calc+arraydraw', - }, y0: { valType: 'any', - editType: 'calc+arraydraw', - }, y1: { valType: 'any', - editType: 'calc+arraydraw', - }, path: { valType: 'string', - editType: 'calc+arraydraw', - }, opacity: { @@ -36967,52 +46761,35 @@ module.exports = templatedArray('shape', { min: 0, max: 1, dflt: 1, - editType: 'arraydraw', - }, line: { color: extendFlat({}, scatterLineAttrs.color, {editType: 'arraydraw'}), width: extendFlat({}, scatterLineAttrs.width, {editType: 'calc+arraydraw'}), dash: extendFlat({}, dash, {editType: 'arraydraw'}), - editType: 'calc+arraydraw' }, fillcolor: { valType: 'color', dflt: 'rgba(0,0,0,0)', - editType: 'arraydraw', - }, fillrule: { valType: 'enumerated', values: ['evenodd', 'nonzero'], dflt: 'evenodd', - editType: 'arraydraw', - }, editable: { valType: 'boolean', - dflt: false, editType: 'calc+arraydraw', - }, editType: 'arraydraw' }); -},{"../../constants/axis_placeable_objects":208,"../../lib/extend":227,"../../plot_api/plot_template":268,"../../traces/scatter/attributes":447,"../annotations/attributes":90,"../drawing/attributes":126}],183:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/axis_placeable_objects":261,"../../lib/extend":279,"../../plot_api/plot_template":320,"../../traces/scatter/attributes":494,"../annotations/attributes":138,"../drawing/attributes":176}],236:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -37124,16 +46901,7 @@ function shapeBounds(ax, v0, v1, path, paramsToUse) { if(max >= min) return [min, max]; } -},{"../../lib":233,"../../plots/cartesian/axes":279,"./constants":184,"./helpers":193}],184:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../plots/cartesian/axes":331,"./constants":237,"./helpers":246}],237:[function(_dereq_,module,exports){ 'use strict'; @@ -37188,16 +46956,7 @@ module.exports = { } }; -},{}],185:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],238:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -37272,7 +47031,7 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) { var dflt0 = 0.25; var dflt1 = 0.75; - // hack until V2.0 when log has regular range behavior - make it look like other + // hack until V3.0 when log has regular range behavior - make it look like other // ranges to send to coerce, then put it back after // this is all to give reasonable default position behavior on log axes, which is // a pretty unimportant edge case so we could just ignore this. @@ -37319,16 +47078,7 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) { } } -},{"../../lib":233,"../../plots/array_container_defaults":274,"../../plots/cartesian/axes":279,"./attributes":182,"./helpers":193}],186:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../plots/array_container_defaults":326,"../../plots/cartesian/axes":331,"./attributes":235,"./helpers":246}],239:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -38093,15 +47843,7 @@ function eraseActiveShape(gd) { } } -},{"../../lib":233,"../../lib/setcursor":253,"../../plot_api/plot_template":268,"../../plots/cartesian/axes":279,"../../plots/cartesian/handle_outline":289,"../../registry":326,"../color":105,"../dragelement":124,"../drawing":127,"./constants":184,"./draw_newshape/display_outlines":190,"./draw_newshape/helpers":191,"./helpers":193}],187:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../lib/setcursor":305,"../../plot_api/plot_template":320,"../../plots/cartesian/axes":331,"../../plots/cartesian/handle_outline":341,"../../registry":373,"../color":155,"../dragelement":174,"../drawing":177,"./constants":237,"./draw_newshape/display_outlines":243,"./draw_newshape/helpers":244,"./helpers":246}],240:[function(_dereq_,module,exports){ 'use strict'; var dash = _dereq_('../../drawing/attributes').dash; @@ -38113,63 +47855,48 @@ module.exports = { color: { valType: 'color', editType: 'none', - - }, width: { valType: 'number', min: 0, dflt: 4, - editType: 'none', - }, dash: extendFlat({}, dash, { dflt: 'solid', editType: 'none' }), - editType: 'none' }, fillcolor: { valType: 'color', dflt: 'rgba(0,0,0,0)', - editType: 'none', - }, fillrule: { valType: 'enumerated', values: ['evenodd', 'nonzero'], dflt: 'evenodd', - editType: 'none', - }, opacity: { valType: 'number', min: 0, max: 1, dflt: 1, - editType: 'none', - }, layer: { valType: 'enumerated', values: ['below', 'above'], dflt: 'above', - editType: 'none', - }, drawdirection: { valType: 'enumerated', - values: ['ortho', 'horizontal', 'vertical', 'diagonal'], dflt: 'diagonal', editType: 'none', - }, editType: 'none' @@ -38179,32 +47906,20 @@ module.exports = { fillcolor: { valType: 'color', dflt: 'rgb(255,0,255)', - editType: 'none', - }, opacity: { valType: 'number', min: 0, max: 1, dflt: 0.5, - editType: 'none', - }, editType: 'none' } }; -},{"../../../lib/extend":227,"../../drawing/attributes":126}],188:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../../lib/extend":279,"../../drawing/attributes":176}],241:[function(_dereq_,module,exports){ 'use strict'; var CIRCLE_SIDES = 32; // should be divisible by 4 @@ -38220,16 +47935,7 @@ module.exports = { SQRT2: Math.sqrt(2) }; -},{}],189:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],242:[function(_dereq_,module,exports){ 'use strict'; var Color = _dereq_('../../color'); @@ -38252,16 +47958,7 @@ module.exports = function supplyDrawNewShapeDefaults(layoutIn, layoutOut, coerce coerce('activeshape.opacity'); }; -},{"../../color":105}],190:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../color":155}],243:[function(_dereq_,module,exports){ 'use strict'; var dragElement = _dereq_('../../dragelement'); @@ -38547,16 +48244,7 @@ function recordPositions(polygonsOut, polygonsIn) { return polygonsOut; } -},{"../../../plots/cartesian/handle_outline":289,"../../../registry":326,"../../dragelement":124,"../../dragelement/helpers":123,"./constants":188,"./helpers":191,"./newshapes":192}],191:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../../plots/cartesian/handle_outline":341,"../../../registry":373,"../../dragelement":174,"../../dragelement/helpers":173,"./constants":241,"./helpers":244,"./newshapes":245}],244:[function(_dereq_,module,exports){ 'use strict'; var parseSvgPath = _dereq_('parse-svg-path'); @@ -38885,16 +48573,7 @@ exports.ellipseOver = function(pos) { }; }; -},{"../../../plots/cartesian/helpers":290,"./constants":188,"parse-svg-path":77}],192:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../../plots/cartesian/helpers":342,"./constants":241,"parse-svg-path":72}],245:[function(_dereq_,module,exports){ 'use strict'; var dragHelpers = _dereq_('../../dragelement/helpers'); @@ -39144,16 +48823,7 @@ function fixDatesForPaths(polygons, xaxis, yaxis) { return polygons; } -},{"../../../plots/cartesian/handle_outline":289,"../../../plots/cartesian/helpers":290,"../../dragelement/helpers":123,"./constants":188,"./helpers":191}],193:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../../plots/cartesian/handle_outline":341,"../../../plots/cartesian/helpers":342,"../../dragelement/helpers":173,"./constants":241,"./helpers":244}],246:[function(_dereq_,module,exports){ 'use strict'; var constants = _dereq_('./constants'); @@ -39165,7 +48835,7 @@ var Lib = _dereq_('../../lib'); // so these have to be specified in terms of the category serial numbers, // but can take fractional values. Other axis types we specify position based on // the actual data values. -// TODO: in V2.0 (when log axis ranges are in data units) range and shape position +// TODO: in V3.0 (when log axis ranges are in data units) range and shape position // will be identical, so rangeToShapePosition and shapePositionToRange can be // removed entirely. @@ -39302,16 +48972,7 @@ exports.makeOptionsAndPlotinfo = function(gd, index) { }; }; -},{"../../lib":233,"./constants":184}],194:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"./constants":237}],247:[function(_dereq_,module,exports){ 'use strict'; var drawModule = _dereq_('./draw'); @@ -39330,15 +48991,7 @@ module.exports = { drawOne: drawModule.drawOne }; -},{"../../plots/cartesian/include_components":291,"./attributes":182,"./calc_autorange":183,"./defaults":185,"./draw":186,"./draw_newshape/defaults":189}],195:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian/include_components":343,"./attributes":235,"./calc_autorange":236,"./defaults":238,"./draw":239,"./draw_newshape/defaults":242}],248:[function(_dereq_,module,exports){ 'use strict'; var fontAttrs = _dereq_('../../plots/font_attributes'); @@ -39352,60 +49005,44 @@ var constants = _dereq_('./constants'); var stepsAttrs = templatedArray('step', { visible: { valType: 'boolean', - dflt: true, - }, method: { valType: 'enumerated', values: ['restyle', 'relayout', 'animate', 'update', 'skip'], dflt: 'restyle', - - }, args: { valType: 'info_array', - freeLength: true, items: [ { valType: 'any' }, { valType: 'any' }, { valType: 'any' } ], - }, label: { valType: 'string', - - }, value: { valType: 'string', - - }, execute: { valType: 'boolean', - dflt: true, - } }); module.exports = overrideAll(templatedArray('slider', { visible: { valType: 'boolean', - dflt: true, - }, active: { valType: 'number', - min: 0, dflt: 0, - }, steps: stepsAttrs, @@ -39413,176 +49050,122 @@ module.exports = overrideAll(templatedArray('slider', { lenmode: { valType: 'enumerated', values: ['fraction', 'pixels'], - dflt: 'fraction', - }, len: { valType: 'number', min: 0, dflt: 1, - - }, x: { valType: 'number', min: -2, max: 3, dflt: 0, - - }, pad: extendDeepAll(padAttrs({editType: 'arraydraw'}), { - }, {t: {dflt: 20}}), xanchor: { valType: 'enumerated', values: ['auto', 'left', 'center', 'right'], dflt: 'left', - - }, y: { valType: 'number', min: -2, max: 3, dflt: 0, - - }, yanchor: { valType: 'enumerated', values: ['auto', 'top', 'middle', 'bottom'], dflt: 'top', - - }, transition: { duration: { valType: 'number', - min: 0, dflt: 150, - }, easing: { valType: 'enumerated', values: animationAttrs.transition.easing.values, - dflt: 'cubic-in-out', - } }, currentvalue: { visible: { valType: 'boolean', - dflt: true, - }, xanchor: { valType: 'enumerated', values: ['left', 'center', 'right'], dflt: 'left', - - }, offset: { valType: 'number', dflt: 10, - - }, prefix: { valType: 'string', - - }, suffix: { valType: 'string', - - }, font: fontAttrs({ - }) }, font: fontAttrs({ - }), activebgcolor: { valType: 'color', - dflt: constants.gripBgActiveColor, - }, bgcolor: { valType: 'color', - dflt: constants.railBgColor, - }, bordercolor: { valType: 'color', dflt: constants.railBorderColor, - - }, borderwidth: { valType: 'number', min: 0, dflt: constants.railBorderWidth, - - }, ticklen: { valType: 'number', min: 0, dflt: constants.tickLength, - - }, tickcolor: { valType: 'color', dflt: constants.tickColor, - - }, tickwidth: { valType: 'number', min: 0, dflt: 1, - - }, minorticklen: { valType: 'number', min: 0, dflt: constants.minorTickLength, - - } }), 'arraydraw', 'from-root'); -},{"../../lib/extend":227,"../../plot_api/edit_types":261,"../../plot_api/plot_template":268,"../../plots/animation_attributes":273,"../../plots/font_attributes":307,"../../plots/pad_attributes":312,"./constants":196}],196:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib/extend":279,"../../plot_api/edit_types":313,"../../plot_api/plot_template":320,"../../plots/animation_attributes":325,"../../plots/font_attributes":359,"../../plots/pad_attributes":365,"./constants":249}],249:[function(_dereq_,module,exports){ 'use strict'; @@ -39667,15 +49250,7 @@ module.exports = { currentValueInset: 0, }; -},{}],197:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],250:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -39782,18 +49357,10 @@ function stepDefaults(valueIn, valueOut) { } } -},{"../../lib":233,"../../plots/array_container_defaults":274,"./attributes":195,"./constants":196}],198:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/array_container_defaults":326,"./attributes":248,"./constants":249}],251:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Plots = _dereq_('../../plots/plots'); var Color = _dereq_('../color'); @@ -40413,15 +49980,7 @@ function drawRail(sliderGroup, sliderOpts) { ); } -},{"../../constants/alignment":207,"../../lib":233,"../../lib/svg_text_utils":255,"../../plot_api/plot_template":268,"../../plots/plots":313,"../color":105,"../drawing":127,"./constants":196,"d3":21}],199:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/alignment":260,"../../lib":285,"../../lib/svg_text_utils":307,"../../plot_api/plot_template":320,"../../plots/plots":366,"../color":155,"../drawing":177,"./constants":249,"@plotly/d3":20}],252:[function(_dereq_,module,exports){ 'use strict'; var constants = _dereq_('./constants'); @@ -40436,19 +49995,10 @@ module.exports = { draw: _dereq_('./draw') }; -},{"./attributes":195,"./constants":196,"./defaults":197,"./draw":198}],200:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"./attributes":248,"./constants":249,"./defaults":250,"./draw":251}],253:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var isNumeric = _dereq_('fast-isnumeric'); var Plots = _dereq_('../../plots/plots'); @@ -40704,15 +50254,7 @@ module.exports = { draw: draw }; -},{"../../constants/alignment":207,"../../constants/interactions":211,"../../lib":233,"../../lib/svg_text_utils":255,"../../plots/plots":313,"../../registry":326,"../color":105,"../drawing":127,"d3":21,"fast-isnumeric":23}],201:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/alignment":260,"../../constants/interactions":264,"../../lib":285,"../../lib/svg_text_utils":307,"../../plots/plots":366,"../../registry":373,"../color":155,"../drawing":177,"@plotly/d3":20,"fast-isnumeric":31}],254:[function(_dereq_,module,exports){ 'use strict'; var fontAttrs = _dereq_('../../plots/font_attributes'); @@ -40725,49 +50267,37 @@ var templatedArray = _dereq_('../../plot_api/plot_template').templatedArray; var buttonsAttrs = templatedArray('button', { visible: { valType: 'boolean', - - }, method: { valType: 'enumerated', values: ['restyle', 'relayout', 'animate', 'update', 'skip'], dflt: 'restyle', - - }, args: { valType: 'info_array', - freeLength: true, items: [ {valType: 'any'}, {valType: 'any'}, {valType: 'any'} ], - }, args2: { valType: 'info_array', - freeLength: true, items: [ {valType: 'any'}, {valType: 'any'}, {valType: 'any'} ], - }, label: { valType: 'string', - dflt: '', - }, execute: { valType: 'boolean', - dflt: true, - } }); @@ -40776,39 +50306,29 @@ module.exports = overrideAll(templatedArray('updatemenu', { visible: { valType: 'boolean', - - }, type: { valType: 'enumerated', values: ['dropdown', 'buttons'], dflt: 'dropdown', - - }, direction: { valType: 'enumerated', values: ['left', 'right', 'up', 'down'], dflt: 'down', - - }, active: { valType: 'integer', - min: -1, dflt: 0, - }, showactive: { valType: 'boolean', - dflt: true, - }, buttons: buttonsAttrs, @@ -40818,71 +50338,46 @@ module.exports = overrideAll(templatedArray('updatemenu', { min: -2, max: 3, dflt: -0.05, - - }, xanchor: { valType: 'enumerated', values: ['auto', 'left', 'center', 'right'], dflt: 'right', - - }, y: { valType: 'number', min: -2, max: 3, dflt: 1, - - }, yanchor: { valType: 'enumerated', values: ['auto', 'top', 'middle', 'bottom'], dflt: 'top', - - }, pad: extendFlat(padAttrs({editType: 'arraydraw'}), { - }), font: fontAttrs({ - }), bgcolor: { valType: 'color', - - }, bordercolor: { valType: 'color', dflt: colorAttrs.borderLine, - - }, borderwidth: { valType: 'number', min: 0, dflt: 1, - editType: 'arraydraw', - } }), 'arraydraw', 'from-root'); -},{"../../lib/extend":227,"../../plot_api/edit_types":261,"../../plot_api/plot_template":268,"../../plots/font_attributes":307,"../../plots/pad_attributes":312,"../color/attributes":104}],202:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib/extend":279,"../../plot_api/edit_types":313,"../../plot_api/plot_template":320,"../../plots/font_attributes":359,"../../plots/pad_attributes":365,"../color/attributes":154}],255:[function(_dereq_,module,exports){ 'use strict'; @@ -40954,15 +50449,7 @@ module.exports = { } }; -},{}],203:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],256:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -41037,19 +50524,10 @@ function buttonDefaults(buttonIn, buttonOut) { } } -},{"../../lib":233,"../../plots/array_container_defaults":274,"./attributes":201,"./constants":202}],204:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../plots/array_container_defaults":326,"./attributes":254,"./constants":255}],257:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Plots = _dereq_('../../plots/plots'); var Color = _dereq_('../color'); @@ -41688,22 +51166,14 @@ function removeAllButtons(gButton, newMenuIndexAttr) { .selectAll('g.' + constants.dropdownButtonClassName).remove(); } -},{"../../constants/alignment":207,"../../lib":233,"../../lib/svg_text_utils":255,"../../plot_api/plot_template":268,"../../plots/plots":313,"../color":105,"../drawing":127,"./constants":202,"./scrollbox":206,"d3":21}],205:[function(_dereq_,module,exports){ -arguments[4][199][0].apply(exports,arguments) -},{"./attributes":201,"./constants":202,"./defaults":203,"./draw":204,"dup":199}],206:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/alignment":260,"../../lib":285,"../../lib/svg_text_utils":307,"../../plot_api/plot_template":320,"../../plots/plots":366,"../color":155,"../drawing":177,"./constants":255,"./scrollbox":259,"@plotly/d3":20}],258:[function(_dereq_,module,exports){ +arguments[4][252][0].apply(exports,arguments) +},{"./attributes":254,"./constants":255,"./defaults":256,"./draw":257,"dup":252}],259:[function(_dereq_,module,exports){ 'use strict'; module.exports = ScrollBox; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Color = _dereq_('../color'); var Drawing = _dereq_('../drawing'); @@ -42155,15 +51625,7 @@ ScrollBox.prototype.setTranslate = function setTranslate(translateX, translateY) } }; -},{"../../lib":233,"../color":105,"../drawing":127,"d3":21}],207:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../color":155,"../drawing":177,"@plotly/d3":20}],260:[function(_dereq_,module,exports){ 'use strict'; // fraction of some size to get to a named position @@ -42220,16 +51682,7 @@ module.exports = { } }; -},{}],208:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],261:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -42252,15 +51705,7 @@ module.exports = { } }; -},{}],209:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],262:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -42268,15 +51713,7 @@ module.exports = { DATE_FORMAT_LINK: 'https://github.com/d3/d3-time-format#locale_format' }; -},{}],210:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],263:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -42306,15 +51743,7 @@ module.exports = { } }; -},{}],211:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],264:[function(_dereq_,module,exports){ 'use strict'; @@ -42329,15 +51758,7 @@ module.exports = { DESELECTDIM: 0.2 }; -},{}],212:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],265:[function(_dereq_,module,exports){ 'use strict'; @@ -42355,7 +51776,7 @@ module.exports = { * to avoid glitches: Make sure that even when you multiply it by the * number of pixels on a giant screen it still works */ - FP_SAFE: Number.MAX_VALUE / 10000, + FP_SAFE: Number.MAX_VALUE * 1e-4, /* * conversion of date units to milliseconds @@ -42402,16 +51823,7 @@ module.exports = { MINUS_SIGN: '\u2212' }; -},{}],213:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],266:[function(_dereq_,module,exports){ 'use strict'; @@ -42426,28 +51838,17 @@ exports.svgAttrs = { 'xmlns:xlink': exports.xlink }; -},{}],214:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],267:[function(_dereq_,module,exports){ 'use strict'; exports.version = _dereq_('./version').version; // inject promise polyfill -_dereq_('es6-promise').polyfill(); +_dereq_('native-promise-only'); // inject plot css _dereq_('../build/plotcss'); -// inject default MathJax config -_dereq_('./fonts/mathjax_config')(); - // include registry module and expose register method var Registry = _dereq_('./registry'); var register = exports.register = Registry.register; @@ -42484,7 +51885,8 @@ register([ _dereq_('./components/grid'), _dereq_('./components/errorbars'), _dereq_('./components/colorscale'), - _dereq_('./components/colorbar') + _dereq_('./components/colorbar'), + _dereq_('./components/modebar') ]); // locales en and en-US are required for default behavior @@ -42503,55 +51905,24 @@ if(window.PlotlyLocales && Array.isArray(window.PlotlyLocales)) { exports.Icons = _dereq_('./fonts/ploticon'); // unofficial 'beta' plot methods, use at your own risk -exports.Plots = _dereq_('./plots/plots'); -exports.Fx = _dereq_('./components/fx'); +var Fx = _dereq_('./components/fx'); +var Plots = _dereq_('./plots/plots'); + +exports.Plots = { + resize: Plots.resize, + graphJson: Plots.graphJson, + sendDataToCloud: Plots.sendDataToCloud +}; +exports.Fx = { + hover: Fx.hover, + unhover: Fx.unhover, + loneHover: Fx.loneHover, + loneUnhover: Fx.loneUnhover +}; exports.Snapshot = _dereq_('./snapshot'); exports.PlotSchema = _dereq_('./plot_api/plot_schema'); -exports.Queue = _dereq_('./lib/queue'); - -// export d3 used in the bundle -exports.d3 = _dereq_('d3'); - -},{"../build/plotcss":1,"./components/annotations":98,"./components/annotations3d":103,"./components/colorbar":111,"./components/colorscale":117,"./components/errorbars":133,"./components/fx":145,"./components/grid":149,"./components/images":154,"./components/legend":162,"./components/rangeselector":173,"./components/rangeslider":180,"./components/shapes":194,"./components/sliders":199,"./components/updatemenus":205,"./fonts/mathjax_config":215,"./fonts/ploticon":216,"./lib/queue":248,"./locale-en":259,"./locale-en-us":258,"./plot_api":263,"./plot_api/plot_schema":267,"./plots/plots":313,"./registry":326,"./snapshot":331,"./traces/scatter":459,"./version":494,"d3":21,"es6-promise":22}],215:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - -'use strict'; - -/* global MathJax:false */ - -module.exports = function() { - if(typeof MathJax !== 'undefined') { - var globalConfig = (window.PlotlyConfig || {}).MathJaxConfig !== 'local'; - - if(globalConfig) { - MathJax.Hub.Config({ - messageStyle: 'none', - skipStartupTypeset: true, - displayAlign: 'left', - tex2jax: { - inlineMath: [['$', '$'], ['\\(', '\\)']] - } - }); - MathJax.Hub.Configured(); - } - } -}; - -},{}],216:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +},{"../build/plotcss":1,"./components/annotations":146,"./components/annotations3d":151,"./components/colorbar":161,"./components/colorscale":167,"./components/errorbars":183,"./components/fx":195,"./components/grid":199,"./components/images":204,"./components/legend":212,"./components/modebar":218,"./components/rangeselector":226,"./components/rangeslider":233,"./components/shapes":247,"./components/sliders":252,"./components/updatemenus":258,"./fonts/ploticon":268,"./locale-en":311,"./locale-en-us":310,"./plot_api":315,"./plot_api/plot_schema":319,"./plots/plots":366,"./registry":373,"./snapshot":378,"./traces/scatter":506,"./version":546,"native-promise-only":70}],268:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -42723,16 +52094,7 @@ module.exports = { } }; -},{}],217:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],269:[function(_dereq_,module,exports){ 'use strict'; @@ -42787,15 +52149,7 @@ exports.isBottomAnchor = function isBottomAnchor(opts) { ); }; -},{}],218:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],270:[function(_dereq_,module,exports){ 'use strict'; var modModule = _dereq_('./mod'); @@ -43028,28 +52382,13 @@ module.exports = { pathAnnulus: pathAnnulus }; -},{"./mod":240}],219:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"./mod":292}],271:[function(_dereq_,module,exports){ 'use strict'; var isArray = Array.isArray; -// IE9 fallbacks - -var ab = (typeof ArrayBuffer === 'undefined' || !ArrayBuffer.isView) ? - {isView: function() { return false; }} : - ArrayBuffer; - -var dv = (typeof DataView === 'undefined') ? - function() {} : - DataView; +var ab = ArrayBuffer; +var dv = DataView; function isTypedArray(a) { return ab.isView(a) && !(a instanceof dv); @@ -43185,16 +52524,7 @@ function _rowLength(z, fn, len0) { return 0; } -},{}],220:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],272:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -43218,15 +52548,7 @@ module.exports = function cleanNumber(v) { return BADNUM; }; -},{"../constants/numerical":212,"fast-isnumeric":23}],221:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../constants/numerical":265,"fast-isnumeric":31}],273:[function(_dereq_,module,exports){ 'use strict'; /** @@ -43246,15 +52568,7 @@ module.exports = function clearGlCanvases(gd) { } }; -},{}],222:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],274:[function(_dereq_,module,exports){ 'use strict'; /** @@ -43269,15 +52583,7 @@ module.exports = function clearResponsive(gd) { } }; -},{}],223:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],275:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -43295,9 +52601,6 @@ var isArrayOrTypedArray = _dereq_('./array').isArrayOrTypedArray; exports.valObjectMeta = { data_array: { // You can use *dflt=[] to force said array to exist though. - - - coerceFunction: function(v, propOut, dflt) { // TODO maybe `v: {type: 'float32', vals: [/* ... */]}` also if(isArrayOrTypedArray(v)) propOut.set(v); @@ -43305,9 +52608,6 @@ exports.valObjectMeta = { } }, enumerated: { - - - coerceFunction: function(v, propOut, dflt, opts) { if(opts.coerceNumber) v = +v; if(opts.values.indexOf(v) === -1) propOut.set(dflt); @@ -43329,18 +52629,12 @@ exports.valObjectMeta = { } }, 'boolean': { - - - coerceFunction: function(v, propOut, dflt) { if(v === true || v === false) propOut.set(v); else propOut.set(dflt); } }, number: { - - - coerceFunction: function(v, propOut, dflt, opts) { if(!isNumeric(v) || (opts.min !== undefined && v < opts.min) || @@ -43350,9 +52644,6 @@ exports.valObjectMeta = { } }, integer: { - - - coerceFunction: function(v, propOut, dflt, opts) { if(v % 1 || !isNumeric(v) || (opts.min !== undefined && v < opts.min) || @@ -43362,10 +52653,7 @@ exports.valObjectMeta = { } }, string: { - - // TODO 'values shouldn't be in there (edge case: 'dash' in Scatter) - coerceFunction: function(v, propOut, dflt, opts) { if(typeof v !== 'string') { var okToCoerce = (typeof v === 'number'); @@ -43377,18 +52665,12 @@ exports.valObjectMeta = { } }, color: { - - - coerceFunction: function(v, propOut, dflt) { if(tinycolor(v).isValid()) propOut.set(v); else propOut.set(dflt); } }, colorlist: { - - - coerceFunction: function(v, propOut, dflt) { function isColor(color) { return tinycolor(color).isValid(); @@ -43399,17 +52681,11 @@ exports.valObjectMeta = { } }, colorscale: { - - - coerceFunction: function(v, propOut, dflt) { propOut.set(colorscales.get(v, dflt)); } }, angle: { - - - coerceFunction: function(v, propOut, dflt) { if(v === 'auto') propOut.set('auto'); else if(!isNumeric(v)) propOut.set(dflt); @@ -43417,9 +52693,6 @@ exports.valObjectMeta = { } }, subplotid: { - - - coerceFunction: function(v, propOut, dflt, opts) { var regex = opts.regex || counterRegex(dflt); if(typeof v === 'string' && regex.test(v)) { @@ -43439,9 +52712,6 @@ exports.valObjectMeta = { } }, flaglist: { - - - coerceFunction: function(v, propOut, dflt, opts) { if(typeof v !== 'string') { propOut.set(dflt); @@ -43464,23 +52734,17 @@ exports.valObjectMeta = { } }, any: { - - - coerceFunction: function(v, propOut, dflt) { if(v === undefined) propOut.set(dflt); else propOut.set(v); } }, info_array: { - - // set `dimensions=2` for a 2D array or '1-2' for either // `items` may be a single object instead of an array, in which case // `freeLength` must be true. // if `dimensions='1-2'` and items is a 1D array, then the value can // either be a matching 1D array or an array of such matching 1D arrays - coerceFunction: function(v, propOut, dflt, opts) { // simplified coerce function just for array items function coercePart(v, opts, dflt) { @@ -43651,6 +52915,18 @@ exports.coerceFont = function(coerce, attr, dfltObj) { return out; }; +/* + * Shortcut to coerce the pattern attributes + */ +exports.coercePattern = function(coerce, attr) { + var shape = coerce(attr + '.shape'); + if(shape) { + coerce(attr + '.size'); + coerce(attr + '.bgcolor'); + coerce(attr + '.solidity'); + } +}; + /** Coerce shortcut for 'hoverinfo' * handling 1-vs-multi-trace dflt logic * @@ -43733,16 +53009,7 @@ function validate(value, opts) { } exports.validate = validate; -},{"../components/colorscale/scales":120,"../constants/interactions":211,"../plots/attributes":275,"./array":219,"./mod":240,"./nested_property":241,"./regex":249,"fast-isnumeric":23,"tinycolor2":88}],224:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../components/colorscale/scales":170,"../constants/interactions":264,"../plots/attributes":327,"./array":271,"./mod":292,"./nested_property":293,"./regex":301,"fast-isnumeric":31,"tinycolor2":119}],276:[function(_dereq_,module,exports){ 'use strict'; var timeFormat = _dereq_('d3-time-format').timeFormat; @@ -44334,18 +53601,10 @@ exports.findExactDates = function(data, calendar) { }; }; -},{"../constants/numerical":212,"../registry":326,"./loggers":237,"./mod":240,"d3-time-format":19,"fast-isnumeric":23}],225:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../constants/numerical":265,"../registry":373,"./loggers":289,"./mod":292,"d3-time-format":29,"fast-isnumeric":31}],277:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var loggers = _dereq_('./loggers'); var matrix = _dereq_('./matrix'); var mat4X4 = _dereq_('gl-mat4'); @@ -44512,16 +53771,7 @@ module.exports = { equalDomRects: equalDomRects }; -},{"./loggers":237,"./matrix":239,"d3":21,"gl-mat4":39}],226:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"./loggers":289,"./matrix":291,"@plotly/d3":20,"gl-mat4":47}],278:[function(_dereq_,module,exports){ 'use strict'; /* global jQuery:false */ @@ -44685,16 +53935,7 @@ var Events = { module.exports = Events; -},{"events":17}],227:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"events":27}],279:[function(_dereq_,module,exports){ 'use strict'; var isPlainObject = _dereq_('./is_plain_object.js'); @@ -44799,16 +54040,7 @@ function _extend(inputs, isDeep, keepAllKeys, noArrayCopies) { return target; } -},{"./is_plain_object.js":234}],228:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"./is_plain_object.js":286}],280:[function(_dereq_,module,exports){ 'use strict'; @@ -44850,15 +54082,7 @@ module.exports = function filterUnique(array) { return out; }; -},{}],229:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],281:[function(_dereq_,module,exports){ 'use strict'; /** Filter out object items with visible !== true @@ -44898,15 +54122,7 @@ function isCalcData(cont) { ); } -},{}],230:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],282:[function(_dereq_,module,exports){ 'use strict'; var mod = _dereq_('./mod').mod; @@ -45142,15 +54358,7 @@ exports.findPointOnPath = function findPointOnPath(path, val, coord, opts) { return pt; }; -},{"./mod":240}],231:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"./mod":292}],283:[function(_dereq_,module,exports){ 'use strict'; // Simple helper functions @@ -45158,16 +54366,7 @@ exports.findPointOnPath = function findPointOnPath(path, val, coord, opts) { module.exports = function identity(d) { return d; }; -},{}],232:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],284:[function(_dereq_,module,exports){ 'use strict'; module.exports = function incrementNumeric(x, delta) { @@ -45200,23 +54399,16 @@ module.exports = function incrementNumeric(x, delta) { return newX; }; -},{}],233:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],285:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var utcFormat = _dereq_('d3-time-format').utcFormat; var isNumeric = _dereq_('fast-isnumeric'); var numConstants = _dereq_('../constants/numerical'); -var FP_SAFE = numConstants.FP_SAFE; +var MAX_SAFE = numConstants.FP_SAFE; +var MIN_SAFE = -MAX_SAFE; var BADNUM = numConstants.BADNUM; var lib = module.exports = {}; @@ -45246,6 +54438,7 @@ lib.valObjectMeta = coerceModule.valObjectMeta; lib.coerce = coerceModule.coerce; lib.coerce2 = coerceModule.coerce2; lib.coerceFont = coerceModule.coerceFont; +lib.coercePattern = coerceModule.coercePattern; lib.coerceHoverinfo = coerceModule.coerceHoverinfo; lib.coerceSelectionMarkerOpacity = coerceModule.coerceSelectionMarkerOpacity; lib.validate = coerceModule.validate; @@ -45376,8 +54569,7 @@ lib.cleanNumber = _dereq_('./clean_number'); lib.ensureNumber = function ensureNumber(v) { if(!isNumeric(v)) return BADNUM; v = Number(v); - if(v < -FP_SAFE || v > FP_SAFE) return BADNUM; - return isNumeric(v) ? Number(v) : BADNUM; + return (v > MAX_SAFE || v < MIN_SAFE) ? BADNUM : v; }; /** @@ -45915,11 +55107,6 @@ lib.isIE = function() { return typeof window.navigator.msSaveBlob !== 'undefined'; }; -var IS_IE9_OR_BELOW_REGEX = /MSIE [1-9]\./; -lib.isIE9orBelow = function() { - return lib.isIE() && IS_IE9_OR_BELOW_REGEX.test(window.navigator.userAgent); -}; - var IS_SAFARI_REGEX = /Version\/[\d\.]+.*Safari/; lib.isSafari = function() { return IS_SAFARI_REGEX.test(window.navigator.userAgent); @@ -45930,12 +55117,20 @@ lib.isIOS = function() { return IS_IOS_REGEX.test(window.navigator.userAgent); }; -/** - * Duck typing to recognize a d3 selection, mostly for IE9's benefit - * because it doesn't handle instanceof like modern browsers - */ +var FIREFOX_VERSION_REGEX = /Firefox\/(\d+)\.\d+/; +lib.getFirefoxVersion = function() { + var match = FIREFOX_VERSION_REGEX.exec(window.navigator.userAgent); + if(match && match.length === 2) { + var versionInt = parseInt(match[1]); + if(!isNaN(versionInt)) { + return versionInt; + } + } + return null; +}; + lib.isD3Selection = function(obj) { - return obj && (typeof obj.classed === 'function'); + return obj instanceof d3.selection; }; /** @@ -46262,21 +55457,50 @@ function templateFormatString(string, labels, d3locale) { // just in case it speeds things up *slightly*: var getterCache = {}; - return string.replace(lib.TEMPLATE_STRING_REGEX, function(match, key, format) { - var obj, value, i; - for(i = 3; i < args.length; i++) { - obj = args[i]; - if(!obj) continue; - if(obj.hasOwnProperty(key)) { - value = obj[key]; - break; - } + return string.replace(lib.TEMPLATE_STRING_REGEX, function(match, rawKey, format) { + var isOther = + rawKey === 'xother' || + rawKey === 'yother'; - if(!SIMPLE_PROPERTY_REGEX.test(key)) { - value = getterCache[key] || lib.nestedProperty(obj, key).get(); - if(value) getterCache[key] = value; + var isSpaceOther = + rawKey === '_xother' || + rawKey === '_yother'; + + var isSpaceOtherSpace = + rawKey === '_xother_' || + rawKey === '_yother_'; + + var isOtherSpace = + rawKey === 'xother_' || + rawKey === 'yother_'; + + var hasOther = isOther || isSpaceOther || isOtherSpace || isSpaceOtherSpace; + + var key = rawKey; + if(isSpaceOther || isSpaceOtherSpace) key = key.substring(1); + if(isOtherSpace || isSpaceOtherSpace) key = key.substring(0, key.length - 1); + + var value; + if(hasOther) { + value = labels[key]; + if(value === undefined) return ''; + } else { + var obj, i; + for(i = 3; i < args.length; i++) { + obj = args[i]; + if(!obj) continue; + if(obj.hasOwnProperty(key)) { + value = obj[key]; + break; + } + + if(!SIMPLE_PROPERTY_REGEX.test(key)) { + value = lib.nestedProperty(obj, key).get(); + value = getterCache[key] || lib.nestedProperty(obj, key).get(); + if(value) getterCache[key] = value; + } + if(value !== undefined) break; } - if(value !== undefined) break; } if(value === undefined && opts) { @@ -46306,8 +55530,16 @@ function templateFormatString(string, labels, d3locale) { value = lib.formatDate(ms, format.replace(TEMPLATE_STRING_FORMAT_SEPARATOR, ''), false, fmt); } } else { - if(labels.hasOwnProperty(key + 'Label')) value = labels[key + 'Label']; + var keyLabel = key + 'Label'; + if(labels.hasOwnProperty(keyLabel)) value = labels[keyLabel]; } + + if(hasOther) { + value = '(' + value + ')'; + if(isSpaceOther || isSpaceOtherSpace) value = ' ' + value; + if(isOtherSpace || isSpaceOtherSpace) value = value + ' '; + } + return value; }); } @@ -46483,16 +55715,35 @@ lib.join2 = function(arr, mainSeparator, lastSeparator) { return arr.join(mainSeparator); }; -},{"../constants/numerical":212,"./anchor_utils":217,"./angles":218,"./array":219,"./clean_number":220,"./clear_responsive":222,"./coerce":223,"./dates":224,"./dom":225,"./extend":227,"./filter_unique":228,"./filter_visible":229,"./geometry2d":230,"./identity":231,"./increment":232,"./is_plain_object":234,"./keyed_container":235,"./localize":236,"./loggers":237,"./make_trace_groups":238,"./matrix":239,"./mod":240,"./nested_property":241,"./noop":242,"./notifier":243,"./preserve_drawing_buffer":246,"./push_unique":247,"./regex":249,"./relative_attr":250,"./relink_private":251,"./search":252,"./stats":254,"./throttle":256,"./to_log_range":257,"d3":21,"d3-time-format":19,"fast-isnumeric":23}],234:[function(_dereq_,module,exports){ +lib.bigFont = function(size) { + return Math.round(1.2 * size); +}; + +var firefoxVersion = lib.getFirefoxVersion(); +// see https://bugzilla.mozilla.org/show_bug.cgi?id=1684973 +var isProblematicFirefox = firefoxVersion !== null && firefoxVersion < 86; + /** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - + * Return the mouse position from the last event registered by D3. + * @returns An array with two numbers, representing the x and y coordinates of the mouse pointer + * at the event relative to the targeted node. + */ +lib.getPositionFromD3Event = function() { + if(isProblematicFirefox) { + // layerX and layerY are non-standard, so we only fallback to them when we have to: + return [ + d3.event.layerX, + d3.event.layerY + ]; + } else { + return [ + d3.event.offsetX, + d3.event.offsetY + ]; + } +}; +},{"../constants/numerical":265,"./anchor_utils":269,"./angles":270,"./array":271,"./clean_number":272,"./clear_responsive":274,"./coerce":275,"./dates":276,"./dom":277,"./extend":279,"./filter_unique":280,"./filter_visible":281,"./geometry2d":282,"./identity":283,"./increment":284,"./is_plain_object":286,"./keyed_container":287,"./localize":288,"./loggers":289,"./make_trace_groups":290,"./matrix":291,"./mod":292,"./nested_property":293,"./noop":294,"./notifier":295,"./preserve_drawing_buffer":298,"./push_unique":299,"./regex":301,"./relative_attr":302,"./relink_private":303,"./search":304,"./stats":306,"./throttle":308,"./to_log_range":309,"@plotly/d3":20,"d3-time-format":29,"fast-isnumeric":31}],286:[function(_dereq_,module,exports){ 'use strict'; // more info: http://stackoverflow.com/questions/18531624/isplainobject-thing @@ -46507,19 +55758,11 @@ module.exports = function isPlainObject(obj) { return ( Object.prototype.toString.call(obj) === '[object Object]' && - Object.getPrototypeOf(obj) === Object.prototype + Object.getPrototypeOf(obj).hasOwnProperty('hasOwnProperty') ); }; -},{}],235:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],287:[function(_dereq_,module,exports){ 'use strict'; var nestedProperty = _dereq_('./nested_property'); @@ -46704,16 +55947,7 @@ module.exports = function keyedContainer(baseObj, path, keyName, valueName) { return obj; }; -},{"./nested_property":241}],236:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"./nested_property":293}],288:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../registry'); @@ -46760,15 +55994,7 @@ module.exports = function localize(gd, s) { return s; }; -},{"../registry":326}],237:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../registry":373}],289:[function(_dereq_,module,exports){ 'use strict'; /* eslint-disable no-console */ @@ -46793,7 +56019,7 @@ loggers.log = function() { for(i = 0; i < arguments.length; i++) { messages.push(arguments[i]); } - apply(console.trace || console.log, messages); + console.trace.apply(console, messages); } if(dfltConfig.notifyOnLogging > 1) { @@ -46813,7 +56039,7 @@ loggers.warn = function() { for(i = 0; i < arguments.length; i++) { messages.push(arguments[i]); } - apply(console.trace || console.log, messages); + console.trace.apply(console, messages); } if(dfltConfig.notifyOnLogging > 0) { @@ -46833,7 +56059,7 @@ loggers.error = function() { for(i = 0; i < arguments.length; i++) { messages.push(arguments[i]); } - apply(console.error, messages); + console.error.apply(console, messages); } if(dfltConfig.notifyOnLogging > 0) { @@ -46845,43 +56071,10 @@ loggers.error = function() { } }; -/* - * Robust apply, for IE9 where console.log doesn't support - * apply like other functions do - */ -function apply(f, args) { - if(f && f.apply) { - try { - // `this` should always be console, since here we're always - // applying a method of the console object. - f.apply(console, args); - return; - } catch(e) { /* in case apply failed, fall back on the code below */ } - } - - // no apply - just try calling the function on each arg independently - for(var i = 0; i < args.length; i++) { - try { - f(args[i]); - } catch(e) { - // still fails - last resort simple console.log - console.log(args[i]); - } - } -} - -},{"../plot_api/plot_config":266,"./notifier":243}],238:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../plot_api/plot_config":318,"./notifier":295}],290:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); /** * General helper to manage trace groups based on calcdata @@ -46913,16 +56106,7 @@ module.exports = function makeTraceGroups(traceLayer, cdModule, cls) { return traces; }; -},{"d3":21}],239:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"@plotly/d3":20}],291:[function(_dereq_,module,exports){ 'use strict'; var mat4X4 = _dereq_('gl-mat4'); @@ -47065,15 +56249,7 @@ exports.inverseTransformMatrix = function(m) { ]; }; -},{"gl-mat4":39}],240:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"gl-mat4":47}],292:[function(_dereq_,module,exports){ 'use strict'; /** @@ -47100,16 +56276,7 @@ module.exports = { modHalf: modHalf }; -},{}],241:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],293:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -47346,15 +56513,7 @@ function badContainer(container, propStr, propParts) { }; } -},{"./array":219,"fast-isnumeric":23}],242:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"./array":271,"fast-isnumeric":31}],294:[function(_dereq_,module,exports){ 'use strict'; // Simple helper functions @@ -47362,19 +56521,10 @@ function badContainer(container, propStr, propParts) { module.exports = function noop() {}; -},{}],243:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],295:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var isNumeric = _dereq_('fast-isnumeric'); var NOTEDATA = []; @@ -47450,16 +56600,7 @@ module.exports = function(text, displayLength) { }); }; -},{"d3":21,"fast-isnumeric":23}],244:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"@plotly/d3":20,"fast-isnumeric":31}],296:[function(_dereq_,module,exports){ 'use strict'; var setCursor = _dereq_('./setcursor'); @@ -47498,16 +56639,7 @@ module.exports = function overrideCursor(el3, csr) { } }; -},{"./setcursor":253}],245:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"./setcursor":305}],297:[function(_dereq_,module,exports){ 'use strict'; var dot = _dereq_('./matrix').dot; @@ -47750,15 +56882,7 @@ polygon.filter = function filter(pts, tolerance) { }; }; -},{"../constants/numerical":212,"./matrix":239}],246:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../constants/numerical":265,"./matrix":291}],298:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -47820,15 +56944,7 @@ function getUserAgent() { return ua; } -},{"fast-isnumeric":23,"is-mobile":74}],247:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"fast-isnumeric":31,"is-mobile":67}],299:[function(_dereq_,module,exports){ 'use strict'; /** @@ -47858,15 +56974,7 @@ module.exports = function pushUnique(array, item) { return array; }; -},{}],248:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],300:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../lib'); @@ -47987,10 +57095,6 @@ queue.stopSequence = function(gd) { queue.undo = function undo(gd) { var queueObj, i; - if(gd.framework && gd.framework.isPolar) { - gd.framework.undo(); - return; - } if(gd.undoQueue === undefined || isNaN(gd.undoQueue.index) || gd.undoQueue.index <= 0) { @@ -48020,10 +57124,6 @@ queue.undo = function undo(gd) { queue.redo = function redo(gd) { var queueObj, i; - if(gd.framework && gd.framework.isPolar) { - gd.framework.redo(); - return; - } if(gd.undoQueue === undefined || isNaN(gd.undoQueue.index) || gd.undoQueue.index >= gd.undoQueue.queue.length) { @@ -48066,15 +57166,7 @@ queue.plotDo = function(gd, func, args) { module.exports = queue; -},{"../lib":233,"../plot_api/plot_config":266}],249:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285,"../plot_api/plot_config":318}],301:[function(_dereq_,module,exports){ 'use strict'; /* @@ -48096,16 +57188,7 @@ exports.counter = function(head, tail, openEnded, matchBeginning) { return new RegExp(startWithPrefix + head + '([2-9]|[1-9][0-9]+)?' + fullTail); }; -},{}],250:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],302:[function(_dereq_,module,exports){ 'use strict'; // ASCEND: chop off the last nesting level - either [] or . - to ascend @@ -48149,16 +57232,7 @@ module.exports = function(baseAttr, relativeAttr) { return baseAttr + relativeAttr; }; -},{}],251:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],303:[function(_dereq_,module,exports){ 'use strict'; var isArrayOrTypedArray = _dereq_('./array').isArrayOrTypedArray; @@ -48206,16 +57280,7 @@ module.exports = function relinkPrivateKeys(toContainer, fromContainer) { } }; -},{"./array":219,"./is_plain_object":234}],252:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"./array":271,"./is_plain_object":286}],304:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -48411,16 +57476,7 @@ exports.findIndexOfMin = function(arr, fn) { return ind; }; -},{"../constants/numerical":212,"./identity":231,"./loggers":237,"fast-isnumeric":23}],253:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../constants/numerical":265,"./identity":283,"./loggers":289,"fast-isnumeric":31}],305:[function(_dereq_,module,exports){ 'use strict'; // works with our CSS cursor classes (see css/_cursor.scss) @@ -48434,16 +57490,7 @@ module.exports = function setCursor(el3, csr) { if(csr) el3.classed('cursor-' + csr, true); }; -},{}],254:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],306:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -48544,21 +57591,12 @@ exports.interp = function(arr, n) { return frac * arr[Math.ceil(n)] + (1 - frac) * arr[Math.floor(n)]; }; -},{"./array":219,"fast-isnumeric":23}],255:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"./array":271,"fast-isnumeric":31}],307:[function(_dereq_,module,exports){ 'use strict'; /* global MathJax:false */ -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Lib = _dereq_('../lib'); var strTranslate = Lib.strTranslate; @@ -49311,6 +58349,18 @@ function alignHTMLWith(_base, container, options) { }; } +var onePx = '1px '; + +exports.makeTextShadow = function(color) { + var x = onePx; + var y = onePx; + var b = onePx; + return x + y + b + color + ', ' + + '-' + x + '-' + y + b + color + ', ' + + x + '-' + y + b + color + ', ' + + '-' + x + y + b + color; +}; + /* * Editable title * @param {d3.selection} context: the element being edited. Normally text, @@ -49435,15 +58485,7 @@ exports.makeEditable = function(context, options) { return d3.rebind(context, dispatch, 'on'); }; -},{"../constants/alignment":207,"../constants/xmlns_namespaces":213,"../lib":233,"d3":21}],256:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../constants/alignment":260,"../constants/xmlns_namespaces":266,"../lib":285,"@plotly/d3":20}],308:[function(_dereq_,module,exports){ 'use strict'; var timerCache = {}; @@ -49538,15 +58580,7 @@ function _clearTimeout(cache) { } } -},{}],257:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],309:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -49566,15 +58600,7 @@ module.exports = function toLogRange(val, range) { return newVal; }; -},{"fast-isnumeric":23}],258:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"fast-isnumeric":31}],310:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -49588,15 +58614,7 @@ module.exports = { } }; -},{}],259:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],311:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -49631,16 +58649,7 @@ module.exports = { } }; -},{}],260:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],312:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../registry'); @@ -49689,15 +58698,7 @@ module.exports = function containerArrayMatch(astr) { return {array: arrayStr, index: Number(match[1]), property: match[3] || ''}; }; -},{"../registry":326}],261:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../registry":373}],313:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../lib'); @@ -49708,7 +58709,6 @@ var traceOpts = { valType: 'flaglist', extras: ['none'], flags: ['calc', 'clearAxisTypes', 'plot', 'style', 'markerSize', 'colorbars'], - }; var layoutOpts = { @@ -49718,7 +58718,6 @@ var layoutOpts = { 'calc', 'plot', 'legend', 'ticks', 'axrange', 'layoutstyle', 'modebar', 'camera', 'arraydraw', 'colorbars' ], - }; // flags for inside restyle/relayout include a few extras @@ -49814,15 +58813,7 @@ function overrideOne(attr, editTypeOverride, overrideContainers, key) { } } -},{"../lib":233}],262:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285}],314:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -50516,20 +59507,12 @@ exports.clearAxisTypes = function(gd, traces, layoutUpdate) { } }; -},{"../components/color":105,"../lib":233,"../plots/cartesian/axis_ids":282,"../plots/plots":313,"../registry":326,"fast-isnumeric":23,"gl-mat4/fromQuat":29}],263:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../components/color":155,"../lib":285,"../plots/cartesian/axis_ids":334,"../plots/plots":366,"../registry":373,"fast-isnumeric":31,"gl-mat4/fromQuat":37}],315:[function(_dereq_,module,exports){ 'use strict'; var main = _dereq_('./plot_api'); -exports.plot = main.plot; +exports._doPlot = main._doPlot; exports.newPlot = main.newPlot; exports.restyle = main.restyle; exports.relayout = main.relayout; @@ -50559,16 +59542,7 @@ var templateApi = _dereq_('./template_api'); exports.makeTemplate = templateApi.makeTemplate; exports.validateTemplate = templateApi.validateTemplate; -},{"../snapshot/download":328,"./plot_api":265,"./template_api":270,"./to_image":271,"./validate":272}],264:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../snapshot/download":375,"./plot_api":317,"./template_api":322,"./to_image":323,"./validate":324}],316:[function(_dereq_,module,exports){ 'use strict'; var isPlainObject = _dereq_('../lib/is_plain_object'); @@ -50772,18 +59746,10 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, return true; }; -},{"../lib/is_plain_object":234,"../lib/loggers":237,"../lib/noop":242,"../lib/search":252,"../registry":326,"./container_array_match":260}],265:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib/is_plain_object":286,"../lib/loggers":289,"../lib/noop":294,"../lib/search":304,"../registry":373,"./container_array_match":312}],317:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var isNumeric = _dereq_('fast-isnumeric'); var hasHover = _dereq_('has-hover'); @@ -50796,14 +59762,12 @@ var Queue = _dereq_('../lib/queue'); var Registry = _dereq_('../registry'); var PlotSchema = _dereq_('./plot_schema'); var Plots = _dereq_('../plots/plots'); -var Polar = _dereq_('../plots/polar/legacy'); var Axes = _dereq_('../plots/cartesian/axes'); var Drawing = _dereq_('../components/drawing'); var Color = _dereq_('../components/color'); var initInteractions = _dereq_('../plots/cartesian/graph_interact').initInteractions; var xmlnsNamespaces = _dereq_('../constants/xmlns_namespaces'); -var svgTextUtils = _dereq_('../lib/svg_text_utils'); var clearSelect = _dereq_('../plots/cartesian/select').clearSelect; var dfltConfig = _dereq_('./plot_config').dfltConfig; @@ -50818,7 +59782,7 @@ var numericNameWarningCount = 0; var numericNameWarningCountLimit = 5; /** - * Main plot-creation function + * Internal plot-creation function * * @param {string id or DOM element} gd * the id or DOM element of the graph container div @@ -50838,7 +59802,7 @@ var numericNameWarningCountLimit = 5; * object containing `data`, `layout`, `config`, and `frames` members * */ -function plot(gd, data, layout, config) { +function _doPlot(gd, data, layout, config) { var frames; gd = Lib.getGraphDiv(gd); @@ -50860,7 +59824,7 @@ function plot(gd, data, layout, config) { // if there's no data or layout, and this isn't yet a plotly plot // container, log a warning to help plotly.js users debug if(!data && !layout && !Lib.isPlotDiv(gd)) { - Lib.warn('Calling Plotly.plot as if redrawing ' + + Lib.warn('Calling _doPlot as if redrawing ' + 'but this container doesn\'t yet have a plot.', gd); } @@ -50916,13 +59880,7 @@ function plot(gd, data, layout, config) { var fullLayout = gd._fullLayout; var hasCartesian = fullLayout._has('cartesian'); - // Legacy polar plots - if(!fullLayout._has('polar') && data && data[0] && data[0].r) { - Lib.log('Legacy polar charts are deprecated!'); - return plotLegacyPolar(gd, data, layout); - } - - // so we don't try to re-call Plotly.plot from inside + // so we don't try to re-call _doPlot from inside // legend and colorbar, if margins changed fullLayout._replotting = true; @@ -50935,14 +59893,9 @@ function plot(gd, data, layout, config) { } } - // polar need a different framework - if(gd.framework !== makePlotFramework) { - gd.framework = makePlotFramework; - makePlotFramework(gd); - } - - // clear gradient defs on each .plot call, because we know we'll loop through all traces + // clear gradient and pattern defs on each .plot call, because we know we'll loop through all traces Drawing.initGradients(gd); + Drawing.initPatterns(gd); // save initial show spikes once per graph if(graphWasEmpty) Axes.saveShowSpikeInitial(gd); @@ -50950,7 +59903,7 @@ function plot(gd, data, layout, config) { // prepare the data and find the autorange // generate calcdata, if we need to - // to force redoing calcdata, just delete it before calling Plotly.plot + // to force redoing calcdata, just delete it before calling _doPlot var recalc = !gd.calcdata || gd.calcdata.length !== (gd._fullData || []).length; if(recalc) Plots.doCalcdata(gd); @@ -51322,99 +60275,6 @@ function setPlotContext(gd, config) { } } -function plotLegacyPolar(gd, data, layout) { - // build or reuse the container skeleton - var plotContainer = d3.select(gd).selectAll('.plot-container') - .data([0]); - plotContainer.enter() - .insert('div', ':first-child') - .classed('plot-container plotly', true); - var paperDiv = plotContainer.selectAll('.svg-container') - .data([0]); - paperDiv.enter().append('div') - .classed('svg-container', true) - .style('position', 'relative'); - - // empty it everytime for now - paperDiv.html(''); - - // fulfill gd requirements - if(data) gd.data = data; - if(layout) gd.layout = layout; - Polar.manager.fillLayout(gd); - - // resize canvas - paperDiv.style({ - width: gd._fullLayout.width + 'px', - height: gd._fullLayout.height + 'px' - }); - - // instantiate framework - gd.framework = Polar.manager.framework(gd); - - // plot - gd.framework({data: gd.data, layout: gd.layout}, paperDiv.node()); - - // set undo point - gd.framework.setUndoPoint(); - - // get the resulting svg for extending it - var polarPlotSVG = gd.framework.svg(); - - // editable title - var opacity = 1; - var txt = gd._fullLayout.title ? gd._fullLayout.title.text : ''; - if(txt === '' || !txt) opacity = 0; - - var titleLayout = function() { - this.call(svgTextUtils.convertToTspans, gd); - // TODO: html/mathjax - // TODO: center title - }; - - var title = polarPlotSVG.select('.title-group text') - .call(titleLayout); - - if(gd._context.edits.titleText) { - var placeholderText = Lib._(gd, 'Click to enter Plot title'); - if(!txt || txt === placeholderText) { - opacity = 0.2; - // placeholder is not going through convertToTspans - // so needs explicit data-unformatted - title.attr({'data-unformatted': placeholderText}) - .text(placeholderText) - .style({opacity: opacity}) - .on('mouseover.opacity', function() { - d3.select(this).transition().duration(100) - .style('opacity', 1); - }) - .on('mouseout.opacity', function() { - d3.select(this).transition().duration(1000) - .style('opacity', 0); - }); - } - - var setContenteditable = function() { - this.call(svgTextUtils.makeEditable, {gd: gd}) - .on('edit', function(text) { - gd.framework({layout: {title: {text: text}}}); - this.text(text) - .call(titleLayout); - this.call(setContenteditable); - }) - .on('cancel', function() { - var txt = this.attr('data-unformatted'); - this.text(txt).call(titleLayout); - }); - }; - title.call(setContenteditable); - } - - gd._context.setBackground(gd, gd._fullLayout.paper_bgcolor); - Plots.addLinks(gd); - - return Promise.resolve(); -} // convenience function to force a full redraw, mostly for use by plotly.js function redraw(gd) { @@ -51428,7 +60288,7 @@ function redraw(gd) { helpers.cleanLayout(gd.layout); gd.calcdata = undefined; - return exports.plot(gd).then(function() { + return exports._doPlot(gd).then(function() { gd.emit('plotly_redraw'); return gd; }); @@ -51449,7 +60309,7 @@ function newPlot(gd, data, layout, config) { Plots.cleanPlot([], {}, gd._fullData || [], gd._fullLayout || {}); Plots.purge(gd); - return exports.plot(gd, data, layout, config); + return exports._doPlot(gd, data, layout, config); } /** @@ -52160,7 +61020,7 @@ function restyle(gd, astr, val, _traces) { var seq = []; if(flags.fullReplot) { - seq.push(exports.plot); + seq.push(exports._doPlot); } else { seq.push(Plots.previousPromises); @@ -52646,10 +61506,6 @@ function relayout(gd, astr, val) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); - if(gd.framework && gd.framework.isPolar) { - return Promise.resolve(gd); - } - var aobj = {}; if(typeof astr === 'string') { aobj[astr] = val; @@ -53159,10 +62015,6 @@ function update(gd, traceUpdate, layoutUpdate, _traces) { gd = Lib.getGraphDiv(gd); helpers.clearPromiseQueue(gd); - if(gd.framework && gd.framework.isPolar) { - return Promise.resolve(gd); - } - if(!Lib.isPlainObject(traceUpdate)) traceUpdate = {}; if(!Lib.isPlainObject(layoutUpdate)) layoutUpdate = {}; @@ -53189,7 +62041,7 @@ function update(gd, traceUpdate, layoutUpdate, _traces) { // relayoutFlags.layoutReplot and restyleFlags.fullReplot are true seq.push(subroutines.layoutReplot); } else if(restyleFlags.fullReplot) { - seq.push(exports.plot); + seq.push(exports._doPlot); } else { seq.push(Plots.previousPromises); axRangeSupplyDefaultsByPass(gd, relayoutFlags, relayoutSpecs) || Plots.supplyDefaults(gd); @@ -53581,7 +62433,7 @@ function react(gd, data, layout, config) { }); } else if(restyleFlags.fullReplot || relayoutFlags.layoutReplot || configChanged) { gd._fullLayout._skipDefaults = true; - seq.push(exports.plot); + seq.push(exports._doPlot); } else { for(var componentType in relayoutFlags.arrays) { var indices = relayoutFlags.arrays[componentType]; @@ -54480,7 +63332,7 @@ function deleteFrames(gd, frameList) { } /** - * Purge a graph container div back to its initial pre-Plotly.plot state + * Purge a graph container div back to its initial pre-_doPlot state * * @param {string id or DOM element} gd * the id or DOM element of the graph container div @@ -54503,7 +63355,7 @@ function purge(gd) { // remove plot container if(fullLayout._container) fullLayout._container.remove(); - // in contrast to Plotly.Plots.purge which does NOT clear _context! + // in contrast to _doPlots.purge which does NOT clear _context! delete gd._context; return gd; @@ -54684,7 +63536,7 @@ exports.moveTraces = moveTraces; exports.prependTraces = prependTraces; exports.newPlot = newPlot; -exports.plot = plot; +exports._doPlot = _doPlot; exports.purge = purge; exports.react = react; @@ -54702,20 +63554,12 @@ exports._guiUpdate = guiEdit(update); exports._storeDirectGUIEdit = _storeDirectGUIEdit; -},{"../components/color":105,"../components/drawing":127,"../constants/xmlns_namespaces":213,"../lib":233,"../lib/events":226,"../lib/queue":248,"../lib/svg_text_utils":255,"../plots/cartesian/axes":279,"../plots/cartesian/constants":285,"../plots/cartesian/graph_interact":288,"../plots/cartesian/select":298,"../plots/plots":313,"../plots/polar/legacy":316,"../registry":326,"./edit_types":261,"./helpers":262,"./manage_arrays":264,"./plot_config":266,"./plot_schema":267,"./subroutines":269,"d3":21,"fast-isnumeric":23,"has-hover":54}],266:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../components/color":155,"../components/drawing":177,"../constants/xmlns_namespaces":266,"../lib":285,"../lib/events":278,"../lib/queue":300,"../plots/cartesian/axes":331,"../plots/cartesian/constants":337,"../plots/cartesian/graph_interact":340,"../plots/cartesian/select":350,"../plots/plots":366,"../registry":373,"./edit_types":313,"./helpers":314,"./manage_arrays":316,"./plot_config":318,"./plot_schema":319,"./subroutines":321,"@plotly/d3":20,"fast-isnumeric":31,"has-hover":62}],318:[function(_dereq_,module,exports){ 'use strict'; /** * This will be transferred over to gd and overridden by - * config args to Plotly.plot. + * config args to Plotly.newPlot. * * The defaults are the appropriate settings for plotly.js, * so we get the right experience without any config argument. @@ -54729,94 +63573,77 @@ var configAttributes = { staticPlot: { valType: 'boolean', dflt: false, - }, plotlyServerURL: { valType: 'string', dflt: '', - }, editable: { valType: 'boolean', dflt: false, - }, edits: { annotationPosition: { valType: 'boolean', dflt: false, - }, annotationTail: { valType: 'boolean', dflt: false, - }, annotationText: { valType: 'boolean', dflt: false, - }, axisTitleText: { valType: 'boolean', dflt: false, - }, colorbarPosition: { valType: 'boolean', dflt: false, - }, colorbarTitleText: { valType: 'boolean', dflt: false, - }, legendPosition: { valType: 'boolean', dflt: false, - }, legendText: { valType: 'boolean', dflt: false, - }, shapePosition: { valType: 'boolean', dflt: false, - }, titleText: { valType: 'boolean', dflt: false, - } }, autosizable: { valType: 'boolean', dflt: false, - }, responsive: { valType: 'boolean', dflt: false, - }, fillFrame: { valType: 'boolean', dflt: false, - }, frameMargins: { valType: 'number', dflt: 0, min: 0, max: 0.5, - }, scrollZoom: { @@ -54824,105 +63651,86 @@ var configAttributes = { flags: ['cartesian', 'gl3d', 'geo', 'mapbox'], extras: [true, false], dflt: 'gl3d+geo+mapbox', - }, doubleClick: { valType: 'enumerated', values: [false, 'reset', 'autosize', 'reset+autosize'], dflt: 'reset+autosize', - }, doubleClickDelay: { valType: 'number', dflt: 300, min: 0, - }, showAxisDragHandles: { valType: 'boolean', dflt: true, - }, showAxisRangeEntryBoxes: { valType: 'boolean', dflt: true, - }, showTips: { valType: 'boolean', dflt: true, - }, showLink: { valType: 'boolean', dflt: false, - }, linkText: { valType: 'string', dflt: 'Edit chart', noBlank: true, - }, sendData: { valType: 'boolean', dflt: true, - }, showSources: { valType: 'any', dflt: false, - }, displayModeBar: { valType: 'enumerated', values: ['hover', true, false], dflt: 'hover', - }, showSendToCloud: { valType: 'boolean', dflt: false, - }, showEditInChartStudio: { valType: 'boolean', dflt: false, - }, modeBarButtonsToRemove: { valType: 'any', dflt: [], - }, modeBarButtonsToAdd: { valType: 'any', dflt: [], - }, modeBarButtons: { valType: 'any', dflt: false, - }, toImageButtonOptions: { valType: 'any', dflt: {}, - }, displaylogo: { valType: 'boolean', dflt: true, - }, watermark: { valType: 'boolean', dflt: false, - }, plotGlPixelRatio: { @@ -54930,26 +63738,22 @@ var configAttributes = { dflt: 2, min: 1, max: 4, - }, setBackground: { valType: 'any', dflt: 'transparent', - }, topojsonURL: { valType: 'string', noBlank: true, dflt: 'https://cdn.plot.ly/', - }, mapboxAccessToken: { valType: 'string', dflt: null, - }, logging: { @@ -54957,7 +63761,6 @@ var configAttributes = { min: 0, max: 2, dflt: 1, - }, notifyOnLogging: { @@ -54965,32 +63768,27 @@ var configAttributes = { min: 0, max: 2, dflt: 0, - }, queueLength: { valType: 'integer', min: 0, dflt: 0, - }, globalTransforms: { valType: 'any', dflt: [], - }, locale: { valType: 'string', dflt: 'en-US', - }, locales: { valType: 'any', dflt: {}, - } }; @@ -55017,15 +63815,7 @@ module.exports = { dfltConfig: dfltConfig }; -},{}],267:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],319:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../registry'); @@ -55037,13 +63827,8 @@ var frameAttributes = _dereq_('../plots/frame_attributes'); var animationAttributes = _dereq_('../plots/animation_attributes'); var configAttributes = _dereq_('./plot_config').configAttributes; -// polar attributes are not part of the Registry yet -var polarAreaAttrs = _dereq_('../plots/polar/legacy/area_attributes'); -var polarAxisAttrs = _dereq_('../plots/polar/legacy/axis_attributes'); - var editTypes = _dereq_('./edit_types'); -var extendFlat = Lib.extendFlat; var extendDeepAll = Lib.extendDeepAll; var isPlainObject = Lib.isPlainObject; var isArrayOrTypedArray = Lib.isArrayOrTypedArray; @@ -55075,7 +63860,7 @@ exports.UNDERSCORE_ATTRS = UNDERSCORE_ATTRS; exports.get = function() { var traces = {}; - Registry.allTypes.concat('area').forEach(function(type) { + Registry.allTypes.forEach(function(type) { traces[type] = getTraceAttributes(type); }); @@ -55094,7 +63879,6 @@ exports.get = function() { layout: editTypes.layout }, impliedEdits: { - } }, @@ -55287,8 +64071,6 @@ exports.getTraceValObject = function(trace, parts) { moduleAttrs = (Registry.transformsRegistry[transforms[tNum].type] || {}).attributes; valObject = moduleAttrs && moduleAttrs[parts[2]]; i = 3; // start recursing only inside the transform - } else if(trace.type === 'area') { - valObject = polarAreaAttrs[head]; } else { // first look in the module for this trace // components have already merged their trace attributes in here @@ -55389,12 +64171,7 @@ function layoutHeadAttr(fullLayout, head) { if(head in baseLayoutAttributes) return baseLayoutAttributes[head]; - // Polar doesn't populate _modules or _basePlotModules - // just fall back on these when the others fail - if(head === 'radialaxis' || head === 'angularaxis') { - return polarAxisAttrs[head]; - } - return polarAxisAttrs.layout[head] || false; + return false; } function recurseIntoValObject(valObject, parts, i) { @@ -55452,13 +64229,8 @@ function isIndex(val) { function getTraceAttributes(type) { var _module, basePlotModule; - if(type === 'area') { - _module = { attributes: polarAreaAttrs }; - basePlotModule = {}; - } else { - _module = Registry.modules[type]._module, - basePlotModule = _module.basePlotModule; - } + _module = Registry.modules[type]._module, + basePlotModule = _module.basePlotModule; var attributes = {}; @@ -55556,9 +64328,6 @@ function getLayoutAttributes() { } } - // polar layout attributes - layoutAttributes = assignPolarLayoutAttrs(layoutAttributes); - // add registered components layout attributes for(key in Registry.componentsRegistry) { _module = Registry.componentsRegistry[key]; @@ -55636,21 +64405,14 @@ function mergeValTypeAndRole(attrs) { function makeSrcAttr(attrName) { return { valType: 'string', - - editType: 'none' }; } function callback(attr, attrName, attrs) { if(exports.isValObject(attr)) { - if(attr.valType === 'data_array') { - // all 'data_array' attrs have role 'data' - attr.role = 'data'; - // all 'data_array' attrs have a corresponding 'src' attr - attrs[attrName + 'src'] = makeSrcAttr(attrName); - } else if(attr.arrayOk === true) { - // all 'arrayOk' attrs have a corresponding 'src' attr + if(attr.arrayOk === true || attr.valType === 'data_array') { + // all 'arrayOk' and 'data_array' attrs have a corresponding 'src' attr attrs[attrName + 'src'] = makeSrcAttr(attrName); } } else if(isPlainObject(attr)) { @@ -55703,16 +64465,6 @@ function stringify(attrs) { walk(attrs); } -function assignPolarLayoutAttrs(layoutAttributes) { - extendFlat(layoutAttributes, { - radialaxis: polarAxisAttrs.radialaxis, - angularaxis: polarAxisAttrs.angularaxis - }); - - extendFlat(layoutAttributes, polarAxisAttrs.layout); - - return layoutAttributes; -} function handleBasePlotModule(layoutAttributes, _module, astr) { var np = nestedProperty(layoutAttributes, astr); @@ -55728,16 +64480,7 @@ function insertAttrs(baseAttrs, newAttrs, astr) { np.set(extendDeepAll(np.get() || {}, newAttrs)); } -},{"../lib":233,"../plots/animation_attributes":273,"../plots/attributes":275,"../plots/frame_attributes":308,"../plots/layout_attributes":311,"../plots/polar/legacy/area_attributes":314,"../plots/polar/legacy/axis_attributes":315,"../registry":326,"./edit_types":261,"./plot_config":266}],268:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../lib":285,"../plots/animation_attributes":325,"../plots/attributes":327,"../plots/frame_attributes":360,"../plots/layout_attributes":364,"../registry":373,"./edit_types":313,"./plot_config":318}],320:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../lib'); @@ -55748,16 +64491,12 @@ var TEMPLATEITEMNAME = 'templateitemname'; var templateAttrs = { name: { valType: 'string', - editType: 'none', - } }; templateAttrs[TEMPLATEITEMNAME] = { valType: 'string', - editType: 'calc', - }; /** @@ -56040,18 +64779,10 @@ exports.arrayEditor = function(parentIn, containerStr, itemOut) { }; }; -},{"../lib":233,"../plots/attributes":275}],269:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285,"../plots/attributes":327}],321:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Registry = _dereq_('../registry'); var Plots = _dereq_('../plots/plots'); @@ -56579,7 +65310,7 @@ exports.doColorBars = function(gd) { exports.layoutReplot = function(gd) { var layout = gd.layout; gd.layout = undefined; - return Registry.call('plot', gd, '', layout); + return Registry.call('_doPlot', gd, '', layout); }; exports.doLegend = function(gd) { @@ -56764,16 +65495,7 @@ exports.drawMarginPushers = function(gd) { Registry.getComponentMethod('colorbar', 'draw')(gd); }; -},{"../components/color":105,"../components/drawing":127,"../components/modebar":165,"../components/titles":200,"../constants/alignment":207,"../lib":233,"../lib/clear_gl_canvases":221,"../plots/cartesian/autorange":278,"../plots/cartesian/axes":279,"../plots/cartesian/constraints":286,"../plots/plots":313,"../registry":326,"d3":21}],270:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../components/color":155,"../components/drawing":177,"../components/modebar":218,"../components/titles":253,"../constants/alignment":260,"../lib":285,"../lib/clear_gl_canvases":273,"../plots/cartesian/autorange":330,"../plots/cartesian/axes":331,"../plots/cartesian/constraints":338,"../plots/plots":366,"../registry":373,"@plotly/d3":20}],322:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../lib'); @@ -57226,15 +65948,7 @@ function format(opts) { return opts; } -},{"../lib":233,"../plots/attributes":275,"../plots/plots":313,"./plot_config":266,"./plot_schema":267,"./plot_template":268}],271:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285,"../plots/attributes":327,"../plots/plots":366,"./plot_config":318,"./plot_schema":319,"./plot_template":320}],323:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -57253,33 +65967,27 @@ var attrs = { valType: 'enumerated', values: ['png', 'jpeg', 'webp', 'svg', 'full-json'], dflt: 'png', - }, width: { valType: 'number', min: 1, - }, height: { valType: 'number', min: 1, - }, scale: { valType: 'number', min: 0, dflt: 1, - }, setBackground: { valType: 'any', dflt: false, - }, imageDataOnly: { valType: 'boolean', dflt: false, - } }; @@ -57436,7 +66144,7 @@ function toImage(gd, opts) { } return new Promise(function(resolve, reject) { - plotApi.plot(clonedGd, data, layoutImage, configImage) + plotApi.newPlot(clonedGd, data, layoutImage, configImage) .then(redrawFunc) .then(wait) .then(convert) @@ -57447,15 +66155,7 @@ function toImage(gd, opts) { module.exports = toImage; -},{"../lib":233,"../plots/plots":313,"../snapshot/helpers":330,"../snapshot/svgtoimg":332,"../snapshot/tosvg":334,"../version":494,"./plot_api":265,"fast-isnumeric":23}],272:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285,"../plots/plots":366,"../snapshot/helpers":377,"../snapshot/svgtoimg":379,"../snapshot/tosvg":381,"../version":546,"./plot_api":317,"fast-isnumeric":31}],324:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../lib'); @@ -57878,61 +66578,41 @@ function convertPathToAttributeString(path) { return astr; } -},{"../lib":233,"../plots/plots":313,"./plot_config":266,"./plot_schema":267}],273:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285,"../plots/plots":366,"./plot_config":318,"./plot_schema":319}],325:[function(_dereq_,module,exports){ 'use strict'; module.exports = { mode: { valType: 'enumerated', dflt: 'afterall', - values: ['immediate', 'next', 'afterall'], - }, direction: { valType: 'enumerated', - values: ['forward', 'reverse'], dflt: 'forward', - }, fromcurrent: { valType: 'boolean', dflt: false, - - }, frame: { duration: { valType: 'number', - min: 0, dflt: 500, - }, redraw: { valType: 'boolean', - dflt: true, - }, }, transition: { duration: { valType: 'number', - min: 0, dflt: 500, editType: 'none', - }, easing: { valType: 'enumerated', @@ -57975,30 +66655,18 @@ module.exports = { 'back-in-out', 'bounce-in-out' ], - editType: 'none', - }, ordering: { valType: 'enumerated', values: ['layout first', 'traces first'], dflt: 'layout first', - editType: 'none', - } } }; -},{}],274:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],326:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../lib'); @@ -58085,15 +66753,7 @@ module.exports = function handleArrayContainerDefaults(parentObjIn, parentObjOut return contOut; }; -},{"../lib":233,"../plot_api/plot_template":268}],275:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285,"../plot_api/plot_template":320}],327:[function(_dereq_,module,exports){ 'use strict'; var fxAttrs = _dereq_('../components/fx/attributes'); @@ -58101,7 +66761,6 @@ var fxAttrs = _dereq_('../components/fx/attributes'); module.exports = { type: { valType: 'enumerated', - values: [], // listed dynamically dflt: 'scatter', editType: 'calc+clearAxisTypes', @@ -58110,64 +66769,48 @@ module.exports = { visible: { valType: 'enumerated', values: [true, false, 'legendonly'], - dflt: true, editType: 'calc', - }, showlegend: { valType: 'boolean', - dflt: true, editType: 'style', - }, legendgroup: { valType: 'string', - dflt: '', editType: 'style', - }, opacity: { valType: 'number', - min: 0, max: 1, dflt: 1, editType: 'style', - }, name: { valType: 'string', - editType: 'style', - }, uid: { valType: 'string', - editType: 'plot', anim: true, - }, ids: { valType: 'data_array', editType: 'calc', anim: true, - }, customdata: { valType: 'data_array', editType: 'calc', - }, meta: { valType: 'any', arrayOk: true, - editType: 'plot', - }, // N.B. these cannot be 'data_array' as they do not have the same length as @@ -58177,20 +66820,16 @@ module.exports = { // https://github.com/plotly/plotly.js/issues/1894 selectedpoints: { valType: 'any', - editType: 'calc', - }, hoverinfo: { valType: 'flaglist', - flags: ['x', 'y', 'z', 'text', 'name'], extras: ['all', 'none', 'skip'], arrayOk: true, dflt: 'all', editType: 'none', - }, hoverlabel: fxAttrs.hoverlabel, stream: { @@ -58198,43 +66837,28 @@ module.exports = { valType: 'string', noBlank: true, strict: true, - editType: 'calc', - }, maxpoints: { valType: 'number', min: 0, max: 10000, dflt: 500, - editType: 'calc', - }, editType: 'calc' }, transforms: { _isLinkedToArray: 'transform', editType: 'calc', - }, uirevision: { valType: 'any', - editType: 'none', - } }; -},{"../components/fx/attributes":136}],276:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../components/fx/attributes":186}],328:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -58318,51 +66942,33 @@ module.exports = function alignPeriod(trace, ax, axLetter, vals) { return newVals; }; -},{"../../constants/numerical":212,"../../lib":233,"fast-isnumeric":23}],277:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/numerical":265,"../../lib":285,"fast-isnumeric":31}],329:[function(_dereq_,module,exports){ 'use strict'; module.exports = { xaxis: { valType: 'subplotid', - dflt: 'x', editType: 'calc+clearAxisTypes', - }, yaxis: { valType: 'subplotid', - dflt: 'y', editType: 'calc+clearAxisTypes', - } }; -},{}],278:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],330:[function(_dereq_,module,exports){ 'use strict'; +var d3 = _dereq_('@plotly/d3'); var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); var FP_SAFE = _dereq_('../../constants/numerical').FP_SAFE; var Registry = _dereq_('../../registry'); +var Drawing = _dereq_('../../components/drawing'); var axIds = _dereq_('./axis_ids'); var getFromId = axIds.getFromId; @@ -58575,7 +67181,7 @@ function makePadFn(fullLayout, ax, max) { var zero = 0; if(!isLinked(fullLayout, ax._id)) { - zero = padInsideLabelsOnAnchorAxis(ax, max); + zero = padInsideLabelsOnAnchorAxis(fullLayout, ax, max); } extrappad = Math.max(zero, extrappad); @@ -58594,45 +67200,69 @@ function makePadFn(fullLayout, ax, max) { var TEXTPAD = 3; -function padInsideLabelsOnAnchorAxis(ax, max) { +function padInsideLabelsOnAnchorAxis(fullLayout, ax, max) { var pad = 0; - var anchorAxis = ax._anchorAxis || {}; - if((anchorAxis.ticklabelposition || '').indexOf('inside') !== -1) { - // increase padding to make more room for inside tick labels of the counter axis - if(( - !max && ( - anchorAxis.side === 'left' || - anchorAxis.side === 'bottom' - ) - ) || ( - max && ( - anchorAxis.side === 'top' || - anchorAxis.side === 'right' - ) - )) { - var isX = ax._id.charAt(0) === 'x'; - if(anchorAxis._vals) { - var rad = Lib.deg2rad(anchorAxis._tickAngles[anchorAxis._id + 'tick'] || 0); - var cosA = Math.abs(Math.cos(rad)); - var sinA = Math.abs(Math.sin(rad)); + var isX = ax._id.charAt(0) === 'x'; - // use bounding boxes - anchorAxis._vals.forEach(function(t) { - if(t.bb) { - var w = 2 * TEXTPAD + t.bb.width; - var h = 2 * TEXTPAD + t.bb.height; + for(var subplot in fullLayout._plots) { + var plotinfo = fullLayout._plots[subplot]; - pad = Math.max(pad, isX ? - Math.max(w * cosA, h * sinA) : - Math.max(h * cosA, w * sinA) - ); + if(ax._id !== plotinfo.xaxis._id && ax._id !== plotinfo.yaxis._id) continue; + + var anchorAxis = (isX ? plotinfo.yaxis : plotinfo.xaxis) || {}; + + if((anchorAxis.ticklabelposition || '').indexOf('inside') !== -1) { + // increase padding to make more room for inside tick labels of the counter axis + if(( + !max && ( + anchorAxis.side === 'left' || + anchorAxis.side === 'bottom' + ) + ) || ( + max && ( + anchorAxis.side === 'top' || + anchorAxis.side === 'right' + ) + )) { + if(anchorAxis._vals) { + var rad = Lib.deg2rad(anchorAxis._tickAngles[anchorAxis._id + 'tick'] || 0); + var cosA = Math.abs(Math.cos(rad)); + var sinA = Math.abs(Math.sin(rad)); + + // no stashed bounding boxes - stash bounding boxes + if(!anchorAxis._vals[0].bb) { + var cls = anchorAxis._id + 'tick'; + var tickLabels = anchorAxis._selections[cls]; + tickLabels.each(function(d) { + var thisLabel = d3.select(this); + var mathjaxGroup = thisLabel.select('.text-math-group'); + if(mathjaxGroup.empty()) { + d.bb = Drawing.bBox(thisLabel.node()); + } + }); } - }); - } - if(anchorAxis.ticks === 'inside' && anchorAxis.ticklabelposition === 'inside') { - pad += anchorAxis.ticklen || 0; + // use bounding boxes + for(var i = 0; i < anchorAxis._vals.length; i++) { + var t = anchorAxis._vals[i]; + var bb = t.bb; + + if(bb) { + var w = 2 * TEXTPAD + bb.width; + var h = 2 * TEXTPAD + bb.height; + + pad = Math.max(pad, isX ? + Math.max(w * cosA, h * sinA) : + Math.max(h * cosA, w * sinA) + ); + } + } + } + + if(anchorAxis.ticks === 'inside' && anchorAxis.ticklabelposition === 'inside') { + pad += anchorAxis.ticklen || 0; + } } } } @@ -58956,18 +67586,10 @@ function goodNumber(v) { function lessOrEqual(v0, v1) { return v0 <= v1; } function greaterOrEqual(v0, v1) { return v0 >= v1; } -},{"../../constants/numerical":212,"../../lib":233,"../../registry":326,"./axis_ids":282,"fast-isnumeric":23}],279:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/drawing":177,"../../constants/numerical":265,"../../lib":285,"../../registry":373,"./axis_ids":334,"@plotly/d3":20,"fast-isnumeric":31}],331:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var isNumeric = _dereq_('fast-isnumeric'); var Plots = _dereq_('../../plots/plots'); @@ -59001,6 +67623,11 @@ var ONESEC = constants.ONESEC; var MINUS_SIGN = constants.MINUS_SIGN; var BADNUM = constants.BADNUM; +var ZERO_PATH = { K: 'zeroline' }; +var GRID_PATH = { K: 'gridline', L: 'path' }; +var TICK_PATH = { K: 'tick', L: 'path' }; +var TICK_TEXT = { K: 'tick', L: 'text' }; + var alignmentConstants = _dereq_('../../constants/alignment'); var MID_SHIFT = alignmentConstants.MID_SHIFT; var CAP_SHIFT = alignmentConstants.CAP_SHIFT; @@ -59516,7 +68143,7 @@ axes.prepTicks = function(ax, opts) { if(!nt) { if(ax.type === 'category' || ax.type === 'multicategory') { - minPx = ax.tickfont ? (ax.tickfont.size || 12) * 1.2 : 15; + minPx = ax.tickfont ? Lib.bigFont(ax.tickfont.size || 12) : 15; nt = ax._length / minPx; } else { minPx = ax._id.charAt(0) === 'y' ? 40 : 80; @@ -60323,16 +68950,23 @@ axes.tickText = function(ax, x, hover, noSuffixPrefix) { * log axes (where negative values can't be displayed but can appear in hover text) * * @param {object} ax: the axis to format text for - * @param {number} val: calcdata value to format - * @param {Optional(number)} val2: a second value to display + * @param {number or array of numbers} values: calcdata value(s) to format + * @param {Optional(string)} hoverformat: trace (x|y)hoverformat to override axis.hoverformat * * @returns {string} `val` formatted as a string appropriate to this axis, or - * `val` and `val2` as a range (ie ' - ') if `val2` is provided and - * it's different from `val`. + * first value and second value as a range (ie ' - ') if the second value is provided and + * it's different from the first value. */ -axes.hoverLabelText = function(ax, val, val2) { - if(val2 !== BADNUM && val2 !== val) { - return axes.hoverLabelText(ax, val) + ' - ' + axes.hoverLabelText(ax, val2); +axes.hoverLabelText = function(ax, values, hoverformat) { + if(hoverformat) ax = Lib.extendFlat({}, ax, {hoverformat: hoverformat}); + + var val = Array.isArray(values) ? values[0] : values; + var val2 = Array.isArray(values) ? values[1] : undefined; + if(val2 !== undefined && val2 !== val) { + return ( + axes.hoverLabelText(ax, val, hoverformat) + ' - ' + + axes.hoverLabelText(ax, val2, hoverformat) + ); } var logOffScale = (ax.type === 'log' && val <= 0); @@ -60416,7 +69050,7 @@ function formatDate(ax, out, hover, extraPrecision) { ax._prevDateHead = headStr; dateStr += '
' + headStr; } else { - var isInside = (ax.ticklabelposition || '').indexOf('inside') !== -1; + var isInside = insideTicklabelposition(ax); var side = ax._realSide || ax.side; // polar mocks the side of the radial axis if( (!isInside && side === 'top') || @@ -61147,6 +69781,7 @@ axes.drawOne = function(gd, ax, opts) { return axes.drawLabels(gd, ax, { vals: vals, layer: mainAxLayer, + plotinfo: plotinfo, transFn: transTickLabelFn, labelFns: axes.makeLabelFns(ax, mainLinePosition) }); @@ -61765,7 +70400,10 @@ axes.drawTicks = function(gd, ax, opts) { .classed('crisp', opts.crisp !== false) .call(Color.stroke, ax.tickcolor) .style('stroke-width', Drawing.crispRound(gd, ax.tickwidth, 1) + 'px') - .attr('d', opts.path); + .attr('d', opts.path) + .style('display', null); // visible + + hideCounterAxisInsideTickLabels(ax, [TICK_PATH]); ticks.attr('transform', opts.transFn); }; @@ -61828,7 +70466,10 @@ axes.drawGrid = function(gd, ax, opts) { grid.attr('transform', opts.transFn) .attr('d', opts.path) .call(Color.stroke, ax.gridcolor || '#ddd') - .style('stroke-width', ax._gw + 'px'); + .style('stroke-width', ax._gw + 'px') + .style('display', null); // visible + + hideCounterAxisInsideTickLabels(ax, [GRID_PATH]); if(typeof opts.path === 'function') grid.attr('d', opts.path); }; @@ -61877,7 +70518,10 @@ axes.drawZeroLine = function(gd, ax, opts) { zl.attr('transform', opts.transFn) .attr('d', opts.path) .call(Color.stroke, ax.zerolinecolor || Color.defaultLine) - .style('stroke-width', Drawing.crispRound(gd, ax.zerolinewidth, ax._gw || 1) + 'px'); + .style('stroke-width', Drawing.crispRound(gd, ax.zerolinewidth, ax._gw || 1) + 'px') + .style('display', null); // visible + + hideCounterAxisInsideTickLabels(ax, [ZERO_PATH]); }; /** @@ -61952,6 +70596,8 @@ axes.drawLabels = function(gd, ax, opts) { } }); + hideCounterAxisInsideTickLabels(ax, [TICK_TEXT]); + tickLabels.exit().remove(); if(opts.repositionOnUpdate) { @@ -61962,8 +70608,6 @@ axes.drawLabels = function(gd, ax, opts) { } function positionLabels(s, angle) { - var isInside = (ax.ticklabelposition || '').indexOf('inside') !== -1; - s.each(function(d) { var thisLabel = d3.select(this); var mathjaxGroup = thisLabel.select('.text-math-group'); @@ -61991,13 +70635,10 @@ axes.drawLabels = function(gd, ax, opts) { 'text-anchor': anchor }); - if(isInside) { - // ensure visible - thisText.style({ opacity: 100 }); + thisText.style('opacity', 1); // visible - if(ax._hideOutOfRangeInsideTickLabels) { - ax._hideOutOfRangeInsideTickLabels(); - } + if(ax._adjustTickLabelsOverflow) { + ax._adjustTickLabelsOverflow(); } } else { var mjWidth = Drawing.bBox(mathjaxGroup.node()).width; @@ -62007,39 +70648,135 @@ axes.drawLabels = function(gd, ax, opts) { }); } - ax._hideOutOfRangeInsideTickLabels = undefined; - if((ax.ticklabelposition || '').indexOf('inside') !== -1) { - ax._hideOutOfRangeInsideTickLabels = function() { + ax._adjustTickLabelsOverflow = function() { + var ticklabeloverflow = ax.ticklabeloverflow; + if(!ticklabeloverflow || ticklabeloverflow === 'allow') return; + + var hideOverflow = ticklabeloverflow.indexOf('hide') !== -1; + + var isX = ax._id.charAt(0) === 'x'; + // div positions + var p0 = 0; + var p1 = isX ? + gd._fullLayout.width : + gd._fullLayout.height; + + if(ticklabeloverflow.indexOf('domain') !== -1) { + // domain positions var rl = Lib.simpleMap(ax.range, ax.r2l); + p0 = ax.l2p(rl[0]) + ax._offset; + p1 = ax.l2p(rl[1]) + ax._offset; + } - // hide inside tick labels that go outside axis end points - var p0 = ax.l2p(rl[0]); - var p1 = ax.l2p(rl[1]); + var min = Math.min(p0, p1); + var max = Math.max(p0, p1); - var min = Math.min(p0, p1) + ax._offset; - var max = Math.max(p0, p1) + ax._offset; + var side = ax.side; - var isX = ax._id.charAt(0) === 'x'; + var visibleLabelMin = Infinity; + var visibleLabelMax = -Infinity; - tickLabels.each(function(d) { - var thisLabel = d3.select(this); - var mathjaxGroup = thisLabel.select('.text-math-group'); + tickLabels.each(function(d) { + var thisLabel = d3.select(this); + var mathjaxGroup = thisLabel.select('.text-math-group'); - if(mathjaxGroup.empty()) { - var bb = Drawing.bBox(thisLabel.node()); - var hide = false; - if(isX) { - if(bb.right > max) hide = true; - else if(bb.left < min) hide = true; + if(mathjaxGroup.empty()) { + var bb = Drawing.bBox(thisLabel.node()); + var adjust = 0; + if(isX) { + if(bb.right > max) adjust = 1; + else if(bb.left < min) adjust = 1; + } else { + if(bb.bottom > max) adjust = 1; + else if(bb.top + (ax.tickangle ? 0 : d.fontSize / 4) < min) adjust = 1; + } + + var t = thisLabel.select('text'); + if(adjust) { + if(hideOverflow) t.style('opacity', 0); // hidden + } else { + t.style('opacity', 1); // visible + + if(side === 'bottom' || side === 'right') { + visibleLabelMin = Math.min(visibleLabelMin, isX ? bb.top : bb.left); } else { - if(bb.bottom > max) hide = true; - else if(bb.top + (ax.tickangle ? 0 : d.fontSize / 4) < min) hide = true; + visibleLabelMin = -Infinity; } - if(hide) thisLabel.select('text').style({ opacity: 0 }); - } // TODO: hide mathjax? - }); - }; - } + + if(side === 'top' || side === 'left') { + visibleLabelMax = Math.max(visibleLabelMax, isX ? bb.bottom : bb.right); + } else { + visibleLabelMax = Infinity; + } + } + } // TODO: hide mathjax? + }); + + for(var subplot in fullLayout._plots) { + var plotinfo = fullLayout._plots[subplot]; + if(ax._id !== plotinfo.xaxis._id && ax._id !== plotinfo.yaxis._id) continue; + var anchorAx = isX ? plotinfo.yaxis : plotinfo.xaxis; + if(anchorAx) { + anchorAx['_visibleLabelMin_' + ax._id] = visibleLabelMin; + anchorAx['_visibleLabelMax_' + ax._id] = visibleLabelMax; + } + } + }; + + ax._hideCounterAxisInsideTickLabels = function(partialOpts) { + var isX = ax._id.charAt(0) === 'x'; + + var anchoredAxes = []; + for(var subplot in fullLayout._plots) { + var plotinfo = fullLayout._plots[subplot]; + if(ax._id !== plotinfo.xaxis._id && ax._id !== plotinfo.yaxis._id) continue; + anchoredAxes.push(isX ? plotinfo.yaxis : plotinfo.xaxis); + } + + anchoredAxes.forEach(function(anchorAx, idx) { + if(anchorAx && insideTicklabelposition(anchorAx)) { + (partialOpts || [ + ZERO_PATH, + GRID_PATH, + TICK_PATH, + TICK_TEXT + ]).forEach(function(e) { + var isPeriodLabel = + e.K === 'tick' && + e.L === 'text' && + ax.ticklabelmode === 'period'; + + var mainPlotinfo = fullLayout._plots[ax._mainSubplot]; + + var sel; + if(e.K === ZERO_PATH.K) sel = mainPlotinfo.zerolinelayer.selectAll('.' + ax._id + 'zl'); + else if(e.K === GRID_PATH.K) sel = mainPlotinfo.gridlayer.selectAll('.' + ax._id); + else sel = mainPlotinfo[ax._id.charAt(0) + 'axislayer']; + + sel.each(function() { + var w = d3.select(this); + if(e.L) w = w.selectAll(e.L); + + w.each(function(d) { + var q = ax.l2p( + isPeriodLabel ? getPosX(d) : d.x + ) + ax._offset; + + var t = d3.select(this); + if( + q < ax['_visibleLabelMax_' + anchorAx._id] && + q > ax['_visibleLabelMin_' + anchorAx._id] + ) { + t.style('display', 'none'); // hidden + } else if(e.K === 'tick' && !idx) { + t.style('display', null); // visible + } + }); + }); + }); + } + }); + }; // make sure all labels are correctly positioned at their base angle // the positionLabels call above is only for newly drawn labels. @@ -62168,7 +70905,7 @@ axes.drawLabels = function(gd, ax, opts) { var anchorAx = ax._anchorAxis; if( anchorAx && anchorAx.autorange && - (ax.ticklabelposition || '').indexOf('inside') !== -1 && + insideTicklabelposition(ax) && !isLinked(fullLayout, ax._id) ) { if(!fullLayout._insideTickLabelsAutorange) { @@ -62180,7 +70917,10 @@ axes.drawLabels = function(gd, ax, opts) { function computeFinalTickLabelBoundingBoxes() { tickLabels.each(function(d, i) { var thisLabel = selectTickLabel(this); - ax._vals[i].bb = Drawing.bBox(thisLabel.node()); + var mathjaxGroup = thisLabel.select('.text-math-group'); + if(mathjaxGroup.empty()) { + ax._vals[i].bb = Drawing.bBox(thisLabel.node()); + } }); } ); @@ -62317,7 +71057,7 @@ function drawTitle(gd, ax) { if(ax.title.hasOwnProperty('standoff')) { titleStandoff = ax._depth + ax.title.standoff + approxTitleDepth(ax); } else { - var isInside = (ax.ticklabelposition || '').indexOf('inside') !== -1; + var isInside = insideTicklabelposition(ax); if(ax.type === 'multicategory') { titleStandoff = ax._depth; @@ -62676,16 +71416,19 @@ function moveOutsideBreak(v, ax) { return v; } -},{"../../components/color":105,"../../components/drawing":127,"../../components/titles":200,"../../constants/alignment":207,"../../constants/numerical":212,"../../lib":233,"../../lib/svg_text_utils":255,"../../plots/plots":313,"../../registry":326,"./autorange":278,"./axis_autotype":280,"./axis_ids":282,"./clean_ticks":284,"./layout_attributes":293,"./set_convert":299,"d3":21,"fast-isnumeric":23}],280:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +function insideTicklabelposition(ax) { + return ((ax.ticklabelposition || '').indexOf('inside') !== -1); +} +function hideCounterAxisInsideTickLabels(ax, opts) { + if(insideTicklabelposition(ax._anchorAxis || {})) { + if(ax._hideCounterAxisInsideTickLabels) { + ax._hideCounterAxisInsideTickLabels(opts); + } + } +} +},{"../../components/color":155,"../../components/drawing":177,"../../components/titles":253,"../../constants/alignment":260,"../../constants/numerical":265,"../../lib":285,"../../lib/svg_text_utils":307,"../../plots/plots":366,"../../registry":373,"./autorange":330,"./axis_autotype":332,"./axis_ids":334,"./clean_ticks":336,"./layout_attributes":345,"./set_convert":351,"@plotly/d3":20,"fast-isnumeric":31}],332:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -62807,15 +71550,7 @@ function multiCategory(a) { return isArrayOrTypedArray(a[0]) && isArrayOrTypedArray(a[1]); } -},{"../../constants/numerical":212,"../../lib":233,"fast-isnumeric":23}],281:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/numerical":265,"../../lib":285,"fast-isnumeric":31}],333:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -62874,8 +71609,9 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, } } + var ticklabelposition = ''; if(!options.noTicklabelposition || axType === 'multicategory') { - Lib.coerce(containerIn, containerOut, { + ticklabelposition = Lib.coerce(containerIn, containerOut, { ticklabelposition: { valType: 'enumerated', dflt: 'outside', @@ -62893,6 +71629,17 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, }, 'ticklabelposition'); } + if(!options.noTicklabeloverflow) { + coerce('ticklabeloverflow', + ticklabelposition.indexOf('inside') !== -1 ? + 'hide past domain' : + axType === 'category' || + axType === 'multicategory' ? + 'allow' : + 'hide past div' + ); + } + setConvert(containerOut, layoutOut); var autorangeDflt = !containerOut.isValidRange(containerIn.range); @@ -62922,7 +71669,7 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, coerce('title.text', dfltTitle); Lib.coerceFont(coerce, 'title.font', { family: font.family, - size: Math.round(font.size * 1.2), + size: Lib.bigFont(font.size), color: dfltFontColor }); @@ -63115,15 +71862,7 @@ function indexOfDay(v) { ]; } -},{"../../lib":233,"../../registry":326,"../array_container_defaults":274,"./category_order_defaults":283,"./constants":285,"./layout_attributes":293,"./line_grid_defaults":295,"./set_convert":299,"./tick_label_defaults":300,"./tick_mark_defaults":301,"./tick_value_defaults":302,"fast-isnumeric":23}],282:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../registry":373,"../array_container_defaults":326,"./category_order_defaults":335,"./constants":337,"./layout_attributes":345,"./line_grid_defaults":347,"./set_convert":351,"./tick_label_defaults":352,"./tick_mark_defaults":353,"./tick_value_defaults":354,"fast-isnumeric":31}],334:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -63271,15 +72010,7 @@ exports.isLinked = function(fullLayout, axId) { ); }; -},{"../../registry":326,"./constants":285}],283:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../registry":373,"./constants":337}],335:[function(_dereq_,module,exports){ 'use strict'; function findCategories(ax, opts) { @@ -63365,15 +72096,7 @@ module.exports = function handleCategoryOrderDefaults(containerIn, containerOut, } }; -},{}],284:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],336:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -63457,15 +72180,7 @@ exports.tick0 = function(tick0, axType, calendar, dtick) { return isNumeric(tick0) ? Number(tick0) : 0; }; -},{"../../constants/numerical":212,"../../lib":233,"fast-isnumeric":23}],285:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/numerical":265,"../../lib":285,"fast-isnumeric":31}],337:[function(_dereq_,module,exports){ 'use strict'; var counterRegex = _dereq_('../../lib/regex').counter; @@ -63549,15 +72264,7 @@ module.exports = { } }; -},{"../../lib/regex":249}],286:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib/regex":301}],338:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -64200,18 +72907,10 @@ function updateDomain(ax, factor) { ax.setScale(); } -},{"../../constants/alignment":207,"../../constants/numerical":212,"../../lib":233,"./autorange":278,"./axis_ids":282,"./layout_attributes":293,"./scale_zoom":297,"./set_convert":299}],287:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/alignment":260,"../../constants/numerical":265,"../../lib":285,"./autorange":330,"./axis_ids":334,"./layout_attributes":345,"./scale_zoom":349,"./set_convert":351}],339:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var tinycolor = _dereq_('tinycolor2'); var supportsPassive = _dereq_('has-passive-events'); @@ -64746,6 +73445,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { // then replot after a delay to make sure // no more scrolling is coming redrawTimer = setTimeout(function() { + if(!gd._fullLayout) return; scrollViewBox = [0, 0, pw, ph]; dragTail(); }, REDRAWDELAY); @@ -65538,19 +74238,10 @@ module.exports = { attachWheelEventHandler: attachWheelEventHandler }; -},{"../../components/color":105,"../../components/dragelement":124,"../../components/dragelement/helpers":123,"../../components/drawing":127,"../../components/fx":145,"../../constants/alignment":207,"../../lib":233,"../../lib/clear_gl_canvases":221,"../../lib/setcursor":253,"../../lib/svg_text_utils":255,"../../plot_api/subroutines":269,"../../registry":326,"../plots":313,"./axes":279,"./axis_ids":282,"./constants":285,"./scale_zoom":297,"./select":298,"d3":21,"has-passive-events":55,"tinycolor2":88}],288:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/color":155,"../../components/dragelement":174,"../../components/dragelement/helpers":173,"../../components/drawing":177,"../../components/fx":195,"../../constants/alignment":260,"../../lib":285,"../../lib/clear_gl_canvases":273,"../../lib/setcursor":305,"../../lib/svg_text_utils":307,"../../plot_api/subroutines":321,"../../registry":373,"../plots":366,"./axes":331,"./axis_ids":334,"./constants":337,"./scale_zoom":349,"./select":350,"@plotly/d3":20,"has-passive-events":63,"tinycolor2":119}],340:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Fx = _dereq_('../../components/fx'); var dragElement = _dereq_('../../components/dragelement'); @@ -65706,16 +74397,7 @@ exports.updateFx = function(gd) { setCursor(fullLayout._draggers, cursor); }; -},{"../../components/dragelement":124,"../../components/fx":145,"../../lib/setcursor":253,"./constants":285,"./dragbox":287,"d3":21}],289:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/dragelement":174,"../../components/fx":195,"../../lib/setcursor":305,"./constants":337,"./dragbox":339,"@plotly/d3":20}],341:[function(_dereq_,module,exports){ 'use strict'; function clearOutlineControllers(gd) { @@ -65742,21 +74424,12 @@ module.exports = { clearSelect: clearSelect }; -},{}],290:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],342:[function(_dereq_,module,exports){ 'use strict'; var strTranslate = _dereq_('../../lib').strTranslate; -// in v2 (once log ranges are fixed), +// in v3 (once log ranges are fixed), // we'll be able to p2r here for all axis types function p2r(ax, v) { switch(ax.type) { @@ -65799,16 +74472,7 @@ module.exports = { getTransform: getTransform }; -},{"../../lib":233}],291:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285}],343:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -65877,19 +74541,10 @@ module.exports = function makeIncludeComponents(containerArrayName) { }; }; -},{"../../lib":233,"../../registry":326,"./axis_ids":282}],292:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../registry":373,"./axis_ids":334}],344:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Registry = _dereq_('../../registry'); var Lib = _dereq_('../../lib'); @@ -66495,15 +75150,7 @@ exports.toSVG = function(gd) { exports.updateFx = _dereq_('./graph_interact').updateFx; -},{"../../components/drawing":127,"../../constants/xmlns_namespaces":213,"../../lib":233,"../../registry":326,"../get_data":309,"../plots":313,"./attributes":277,"./axis_ids":282,"./constants":285,"./graph_interact":288,"./layout_attributes":293,"./layout_defaults":294,"./transition_axes":303,"d3":21}],293:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/drawing":177,"../../constants/xmlns_namespaces":266,"../../lib":285,"../../registry":373,"../get_data":361,"../plots":366,"./attributes":329,"./axis_ids":334,"./constants":337,"./graph_interact":340,"./layout_attributes":345,"./layout_defaults":346,"./transition_axes":355,"@plotly/d3":20}],345:[function(_dereq_,module,exports){ 'use strict'; var fontAttrs = _dereq_('../font_attributes'); @@ -66512,8 +75159,10 @@ var dash = _dereq_('../../components/drawing/attributes').dash; var extendFlat = _dereq_('../../lib/extend').extendFlat; var templatedArray = _dereq_('../../plot_api/plot_template').templatedArray; -var FORMAT_LINK = _dereq_('../../constants/docs').FORMAT_LINK; -var DATE_FORMAT_LINK = _dereq_('../../constants/docs').DATE_FORMAT_LINK; +var docs = _dereq_('../../constants/docs'); +var FORMAT_LINK = docs.FORMAT_LINK; +var DATE_FORMAT_LINK = docs.DATE_FORMAT_LINK; + var ONEDAY = _dereq_('../../constants/numerical').ONEDAY; var constants = _dereq_('./constants'); var HOUR = constants.HOUR_PATTERN; @@ -66522,34 +75171,25 @@ var DAY_OF_WEEK = constants.WEEKDAY_PATTERN; module.exports = { visible: { valType: 'boolean', - editType: 'plot', - }, color: { valType: 'color', dflt: colorAttrs.defaultLine, - editType: 'ticks', - }, title: { text: { valType: 'string', - editType: 'ticks', - }, font: fontAttrs({ editType: 'ticks', - }), standoff: { valType: 'number', - min: 0, editType: 'ticks', - }, editType: 'ticks' }, @@ -66560,43 +75200,34 @@ module.exports = { // to gd.data like the others are. values: ['-', 'linear', 'log', 'date', 'category', 'multicategory'], dflt: '-', - editType: 'calc', // we forget when an axis has been autotyped, just writing the auto // value back to the input - so it doesn't make sense to template this. // Note: we do NOT prohibit this in `coerce`, so if someone enters a // type in the template explicitly it will be honored as the default. _noTemplating: true, - }, autotypenumbers: { valType: 'enumerated', values: ['convert types', 'strict'], dflt: 'convert types', - editType: 'calc', - }, autorange: { valType: 'enumerated', values: [true, false, 'reversed'], dflt: true, - editType: 'axrange', impliedEdits: {'range[0]': undefined, 'range[1]': undefined}, - }, rangemode: { valType: 'enumerated', values: ['normal', 'tozero', 'nonnegative'], dflt: 'normal', - editType: 'plot', - }, range: { valType: 'info_array', - items: [ {valType: 'any', editType: 'axrange', impliedEdits: {'^autorange': false}, anim: true}, {valType: 'any', editType: 'axrange', impliedEdits: {'^autorange': false}, anim: true} @@ -66604,14 +75235,11 @@ module.exports = { editType: 'axrange', impliedEdits: {'autorange': false}, anim: true, - }, fixedrange: { valType: 'boolean', dflt: false, - editType: 'calc', - }, // scaleanchor: not used directly, just put here for reference // values are any opposite-letter axis id @@ -66621,32 +75249,24 @@ module.exports = { constants.idRegex.x.toString(), constants.idRegex.y.toString() ], - editType: 'plot', - }, scaleratio: { valType: 'number', min: 0, dflt: 1, - editType: 'plot', - }, constrain: { valType: 'enumerated', values: ['range', 'domain'], - editType: 'plot', - }, // constraintoward: not used directly, just put here for reference constraintoward: { valType: 'enumerated', values: ['left', 'center', 'right', 'top', 'middle', 'bottom'], - editType: 'plot', - }, matches: { valType: 'enumerated', @@ -66654,58 +75274,46 @@ module.exports = { constants.idRegex.x.toString(), constants.idRegex.y.toString() ], - editType: 'calc', - }, rangebreaks: templatedArray('rangebreak', { enabled: { valType: 'boolean', - dflt: true, editType: 'calc', - }, bounds: { valType: 'info_array', - items: [ {valType: 'any', editType: 'calc'}, {valType: 'any', editType: 'calc'} ], editType: 'calc', - }, pattern: { valType: 'enumerated', values: [DAY_OF_WEEK, HOUR, ''], - editType: 'calc', - }, values: { valType: 'info_array', freeLength: true, - editType: 'calc', items: { valType: 'any', editType: 'calc' }, - }, dvalue: { // TODO could become 'any' to add support for 'months', 'years' valType: 'number', - editType: 'calc', min: 0, dflt: ONEDAY, - }, /* @@ -66714,16 +75322,12 @@ module.exports = { min: 0, dflt: 0, // for *date* axes, maybe something else for *linear* editType: 'calc', - - }, gapmode: { valType: 'enumerated', values: ['pixels', 'fraction'], dflt: 'pixels', editType: 'calc', - - }, */ @@ -66740,65 +75344,49 @@ module.exports = { tickmode: { valType: 'enumerated', values: ['auto', 'linear', 'array'], - editType: 'ticks', impliedEdits: {tick0: undefined, dtick: undefined}, - }, nticks: { valType: 'integer', min: 0, dflt: 0, - editType: 'ticks', - }, tick0: { valType: 'any', - editType: 'ticks', impliedEdits: {tickmode: 'linear'}, - }, dtick: { valType: 'any', - editType: 'ticks', impliedEdits: {tickmode: 'linear'}, - }, tickvals: { valType: 'data_array', editType: 'ticks', - }, ticktext: { valType: 'data_array', editType: 'ticks', - }, ticks: { valType: 'enumerated', values: ['outside', 'inside', ''], - editType: 'ticks', - }, tickson: { valType: 'enumerated', values: ['labels', 'boundaries'], - dflt: 'labels', editType: 'ticks', - }, ticklabelmode: { valType: 'enumerated', values: ['instant', 'period'], dflt: 'instant', - editType: 'ticks', - }, // ticklabelposition: not used directly, as values depend on direction (similar to side) // left/right options are for x axes, and top/bottom options are for y axes @@ -66812,291 +75400,223 @@ module.exports = { 'outside bottom', 'inside bottom' ], dflt: 'outside', - editType: 'calc', - + }, + ticklabeloverflow: { + valType: 'enumerated', + values: [ + 'allow', + 'hide past div', + 'hide past domain' + ], + editType: 'calc', }, mirror: { valType: 'enumerated', values: [true, 'ticks', false, 'all', 'allticks'], dflt: false, - editType: 'ticks+layoutstyle', - }, ticklen: { valType: 'number', min: 0, dflt: 5, - editType: 'ticks', - }, tickwidth: { valType: 'number', min: 0, dflt: 1, - editType: 'ticks', - }, tickcolor: { valType: 'color', dflt: colorAttrs.defaultLine, - editType: 'ticks', - }, showticklabels: { valType: 'boolean', dflt: true, - editType: 'ticks', - }, automargin: { valType: 'boolean', dflt: false, - editType: 'ticks', - }, showspikes: { valType: 'boolean', dflt: false, - editType: 'modebar', - }, spikecolor: { valType: 'color', dflt: null, - editType: 'none', - }, spikethickness: { valType: 'number', dflt: 3, - editType: 'none', - }, spikedash: extendFlat({}, dash, {dflt: 'dash', editType: 'none'}), spikemode: { valType: 'flaglist', flags: ['toaxis', 'across', 'marker'], - dflt: 'toaxis', editType: 'none', - }, spikesnap: { valType: 'enumerated', values: ['data', 'cursor', 'hovered data'], - dflt: 'data', - + dflt: 'hovered data', editType: 'none', - }, tickfont: fontAttrs({ editType: 'ticks', - }), tickangle: { valType: 'angle', dflt: 'auto', - editType: 'ticks', - }, tickprefix: { valType: 'string', dflt: '', - editType: 'ticks', - }, showtickprefix: { valType: 'enumerated', values: ['all', 'first', 'last', 'none'], dflt: 'all', - editType: 'ticks', - }, ticksuffix: { valType: 'string', dflt: '', - editType: 'ticks', - }, showticksuffix: { valType: 'enumerated', values: ['all', 'first', 'last', 'none'], dflt: 'all', - editType: 'ticks', - }, showexponent: { valType: 'enumerated', values: ['all', 'first', 'last', 'none'], dflt: 'all', - editType: 'ticks', - }, exponentformat: { valType: 'enumerated', values: ['none', 'e', 'E', 'power', 'SI', 'B'], dflt: 'B', - editType: 'ticks', - }, minexponent: { valType: 'number', dflt: 3, min: 0, - editType: 'ticks', - }, separatethousands: { valType: 'boolean', dflt: false, - editType: 'ticks', - }, tickformat: { valType: 'string', dflt: '', - editType: 'ticks', - }, tickformatstops: templatedArray('tickformatstop', { enabled: { valType: 'boolean', - dflt: true, editType: 'ticks', - }, dtickrange: { valType: 'info_array', - items: [ {valType: 'any', editType: 'ticks'}, {valType: 'any', editType: 'ticks'} ], editType: 'ticks', - }, value: { valType: 'string', dflt: '', - editType: 'ticks', - }, editType: 'ticks' }), hoverformat: { valType: 'string', dflt: '', - editType: 'none', - }, // lines and grids showline: { valType: 'boolean', dflt: false, - editType: 'ticks+layoutstyle', - }, linecolor: { valType: 'color', dflt: colorAttrs.defaultLine, - editType: 'layoutstyle', - }, linewidth: { valType: 'number', min: 0, dflt: 1, - editType: 'ticks+layoutstyle', - }, showgrid: { valType: 'boolean', - editType: 'ticks', - }, gridcolor: { valType: 'color', dflt: colorAttrs.lightLine, - editType: 'ticks', - }, gridwidth: { valType: 'number', min: 0, dflt: 1, - editType: 'ticks', - }, zeroline: { valType: 'boolean', - editType: 'ticks', - }, zerolinecolor: { valType: 'color', dflt: colorAttrs.defaultLine, - editType: 'ticks', - }, zerolinewidth: { valType: 'number', dflt: 1, - editType: 'ticks', - }, showdividers: { valType: 'boolean', dflt: true, - editType: 'ticks', - }, dividercolor: { valType: 'color', dflt: colorAttrs.defaultLine, - editType: 'ticks', - }, dividerwidth: { valType: 'number', dflt: 1, - editType: 'ticks', - }, // TODO dividerlen: that would override "to label base" length? @@ -67110,18 +75630,14 @@ module.exports = { constants.idRegex.x.toString(), constants.idRegex.y.toString() ], - editType: 'plot', - }, // side: not used directly, as values depend on direction // values are top, bottom for x axes, and left, right for y side: { valType: 'enumerated', values: ['top', 'bottom', 'left', 'right'], - editType: 'plot', - }, // overlaying: not used directly, just put here for reference // values are false and any other same-letter axis id that's not @@ -67133,37 +75649,29 @@ module.exports = { constants.idRegex.x.toString(), constants.idRegex.y.toString() ], - editType: 'plot', - }, layer: { valType: 'enumerated', values: ['above traces', 'below traces'], dflt: 'above traces', - editType: 'plot', - }, domain: { valType: 'info_array', - items: [ {valType: 'number', min: 0, max: 1, editType: 'plot'}, {valType: 'number', min: 0, max: 1, editType: 'plot'} ], dflt: [0, 1], editType: 'plot', - }, position: { valType: 'number', min: 0, max: 1, dflt: 0, - editType: 'plot', - }, categoryorder: { valType: 'enumerated', @@ -67177,54 +75685,34 @@ module.exports = { 'median ascending', 'median descending' ], dflt: 'trace', - editType: 'calc', - }, categoryarray: { valType: 'data_array', - editType: 'calc', - }, uirevision: { valType: 'any', - editType: 'none', - }, editType: 'calc', _deprecated: { autotick: { valType: 'boolean', - editType: 'ticks', - }, title: { valType: 'string', - editType: 'ticks', - }, titlefont: fontAttrs({ editType: 'ticks', - }) } }; -},{"../../components/color/attributes":104,"../../components/drawing/attributes":126,"../../constants/docs":209,"../../constants/numerical":212,"../../lib/extend":227,"../../plot_api/plot_template":268,"../font_attributes":307,"./constants":285}],294:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/color/attributes":154,"../../components/drawing/attributes":176,"../../constants/docs":262,"../../constants/numerical":265,"../../lib/extend":279,"../../plot_api/plot_template":320,"../font_attributes":359,"./constants":337}],346:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -67427,7 +75915,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { } } - var hovermode = handleHoverModeDefaults(layoutIn, layoutOut, fullData); + var hovermode = handleHoverModeDefaults(layoutIn, layoutOut); var unifiedHover = isUnifiedHover(hovermode); // first pass creates the containers, determines types, and handles most of the settings @@ -67480,7 +75968,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { var spikethickness = coerce2('spikethickness', unifiedHover ? 1.5 : undefined); var spikedash = coerce2('spikedash', unifiedHover ? 'dot' : undefined); var spikemode = coerce2('spikemode', unifiedHover ? 'across' : undefined); - var spikesnap = coerce2('spikesnap', unifiedHover ? 'hovered data' : undefined); + var spikesnap = coerce2('spikesnap'); var showSpikes = coerce('showspikes', !!unifiedSpike || !!spikecolor || !!spikethickness || !!spikedash || !!spikemode || !!spikesnap); if(!showSpikes) { @@ -67602,15 +76090,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { }); }; -},{"../../components/color":105,"../../components/fx/helpers":141,"../../components/fx/hovermode_defaults":144,"../../lib":233,"../../plot_api/plot_template":268,"../../registry":326,"../layout_attributes":311,"./axis_defaults":281,"./axis_ids":282,"./constants":285,"./constraints":286,"./layout_attributes":293,"./position_defaults":296,"./type_defaults":304}],295:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../components/fx/helpers":191,"../../components/fx/hovermode_defaults":194,"../../lib":285,"../../plot_api/plot_template":320,"../../registry":373,"../layout_attributes":364,"./axis_defaults":333,"./axis_ids":334,"./constants":337,"./constraints":338,"./layout_attributes":345,"./position_defaults":348,"./type_defaults":356}],347:[function(_dereq_,module,exports){ 'use strict'; var colorMix = _dereq_('tinycolor2').mix; @@ -67667,16 +76147,7 @@ module.exports = function handleLineGridDefaults(containerIn, containerOut, coer } }; -},{"../../components/color/attributes":104,"../../lib":233,"tinycolor2":88}],296:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/color/attributes":154,"../../lib":285,"tinycolor2":119}],348:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -67755,16 +76226,7 @@ module.exports = function handlePositionDefaults(containerIn, containerOut, coer return containerOut; }; -},{"../../lib":233,"fast-isnumeric":23}],297:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"fast-isnumeric":31}],349:[function(_dereq_,module,exports){ 'use strict'; var FROM_BL = _dereq_('../../constants/alignment').FROM_BL; @@ -67784,16 +76246,7 @@ module.exports = function scaleZoom(ax, factor, centerFraction) { ax.setScale(); }; -},{"../../constants/alignment":207}],298:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../constants/alignment":260}],350:[function(_dereq_,module,exports){ 'use strict'; var polybool = _dereq_('polybooljs'); @@ -68142,9 +76595,9 @@ function prepSelect(e, startX, startY, dragOptions, mode) { } if(clickmode === 'event') { - // TODO: remove in v2 - this was probably never intended to work as it does, + // TODO: remove in v3 - this was probably never intended to work as it does, // but in case anyone depends on it we don't want to break it now. - // Note that click-to-select introduced pre v2 also emitts proper + // Note that click-to-select introduced pre v3 also emitts proper // event data when clickmode is having 'select' in its flag list. gd.emit('plotly_selected', undefined); } @@ -68727,18 +77180,10 @@ module.exports = { selectOnClick: selectOnClick }; -},{"../../components/color":105,"../../components/dragelement/helpers":123,"../../components/drawing":127,"../../components/fx":145,"../../components/fx/helpers":141,"../../components/shapes/draw_newshape/display_outlines":190,"../../components/shapes/draw_newshape/helpers":191,"../../components/shapes/draw_newshape/newshapes":192,"../../lib":233,"../../lib/clear_gl_canvases":221,"../../lib/polygon":245,"../../lib/throttle":256,"../../plot_api/subroutines":269,"../../registry":326,"./axis_ids":282,"./constants":285,"./handle_outline":289,"./helpers":290,"polybooljs":79}],299:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../components/dragelement/helpers":173,"../../components/drawing":177,"../../components/fx":195,"../../components/fx/helpers":191,"../../components/shapes/draw_newshape/display_outlines":243,"../../components/shapes/draw_newshape/helpers":244,"../../components/shapes/draw_newshape/newshapes":245,"../../lib":285,"../../lib/clear_gl_canvases":273,"../../lib/polygon":297,"../../lib/throttle":308,"../../plot_api/subroutines":321,"../../registry":373,"./axis_ids":334,"./constants":337,"./handle_outline":341,"./helpers":342,"polybooljs":73}],351:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var utcFormat = _dereq_('d3-time-format').utcFormat; var isNumeric = _dereq_('fast-isnumeric'); @@ -68788,7 +77233,7 @@ function isValidCategory(v) { * - category: calcdata format (c), and will stay that way because * the data format has no continuous mapping * - log: linearized (l) format - * TODO: in v2.0 we plan to change it to data format. At that point + * TODO: in v3.0 we plan to change it to data format. At that point * shapes will work the same way as ranges, tick0, and annotations * so they can use this conversion too. * @@ -68825,7 +77270,7 @@ module.exports = function setConvert(ax, fullLayout) { if((opts || {}).msUTC && isNumeric(v)) { // For now it is only used // to fix bar length in milliseconds & gl3d ticks - // It could be applied in other places in v2 + // It could be applied in other places in v3 return +v; } @@ -69685,16 +78130,7 @@ module.exports = function setConvert(ax, fullLayout) { delete ax._forceTick0; }; -},{"../../constants/numerical":212,"../../lib":233,"./axis_ids":282,"./constants":285,"d3":21,"d3-time-format":19,"fast-isnumeric":23}],300:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../constants/numerical":265,"../../lib":285,"./axis_ids":334,"./constants":337,"@plotly/d3":20,"d3-time-format":29,"fast-isnumeric":31}],352:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -69812,16 +78248,7 @@ function tickformatstopDefaults(valueIn, valueOut) { } } -},{"../../components/color":105,"../../lib":233,"../array_container_defaults":274,"./layout_attributes":293}],301:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/color":155,"../../lib":285,"../array_container_defaults":326,"./layout_attributes":345}],353:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -69845,15 +78272,7 @@ module.exports = function handleTickDefaults(containerIn, containerOut, coerce, } }; -},{"../../lib":233,"./layout_attributes":293}],302:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"./layout_attributes":345}],354:[function(_dereq_,module,exports){ 'use strict'; var cleanTicks = _dereq_('./clean_ticks'); @@ -69892,18 +78311,10 @@ module.exports = function handleTickValueDefaults(containerIn, containerOut, coe } }; -},{"../../lib":233,"./clean_ticks":284}],303:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"./clean_ticks":336}],355:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Registry = _dereq_('../../registry'); var Lib = _dereq_('../../lib'); @@ -70105,15 +78516,7 @@ module.exports = function transitionAxes(gd, edits, transitionOpts, makeOnComple return Promise.resolve(); }; -},{"../../components/drawing":127,"../../lib":233,"../../registry":326,"./axes":279,"d3":21}],304:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/drawing":177,"../../lib":285,"../../registry":373,"./axes":331,"@plotly/d3":20}],356:[function(_dereq_,module,exports){ 'use strict'; var traceIs = _dereq_('../../registry').traceIs; @@ -70245,15 +78648,7 @@ function isBoxWithoutPositionCoords(trace, axLetter) { ); } -},{"../../registry":326,"./axis_autotype":280}],305:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../registry":373,"./axis_autotype":332}],357:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../registry'); @@ -70672,15 +79067,7 @@ function crawl(attrs, callback, path, depth) { }); } -},{"../lib":233,"../registry":326}],306:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285,"../registry":373}],358:[function(_dereq_,module,exports){ 'use strict'; var extendFlat = _dereq_('../lib/extend').extendFlat; @@ -70712,7 +79099,6 @@ exports.attributes = function(opts, extra) { var base = { valType: 'info_array', - editType: opts.editType, items: [ {valType: 'number', min: 0, max: 1, editType: opts.editType}, @@ -70727,10 +79113,8 @@ exports.attributes = function(opts, extra) { var out = { x: extendFlat({}, base, { - }), y: extendFlat({}, base, { - }), editType: opts.editType }; @@ -70740,17 +79124,13 @@ exports.attributes = function(opts, extra) { valType: 'integer', min: 0, dflt: 0, - editType: opts.editType, - }; out.column = { valType: 'integer', min: 0, dflt: 0, - editType: opts.editType, - }; } @@ -70784,15 +79164,7 @@ exports.defaults = function(containerOut, layout, coerce, dfltDomains) { if(!(y[0] < y[1])) containerOut.domain.y = dfltY.slice(); }; -},{"../lib/extend":227}],307:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib/extend":279}],359:[function(_dereq_,module,exports){ 'use strict'; /* @@ -70817,27 +79189,22 @@ module.exports = function(opts) { var attrs = { family: { valType: 'string', - noBlank: true, strict: true, editType: editType, - }, size: { valType: 'number', - min: 1, editType: editType }, color: { valType: 'color', - editType: colorEditType }, editType: editType, // blank strings so compress_attributes can remove // TODO - that's uber hacky... better solution? - }; if(opts.arrayOk) { @@ -70849,15 +79216,7 @@ module.exports = function(opts) { return attrs; }; -},{}],308:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],360:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -70865,45 +79224,25 @@ module.exports = { group: { valType: 'string', - - }, name: { valType: 'string', - - }, traces: { valType: 'any', - - }, baseframe: { valType: 'string', - - }, data: { valType: 'any', - - }, layout: { valType: 'any', - - } }; -},{}],309:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],361:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../registry'); @@ -71024,16 +79363,7 @@ exports.getSubplotData = function getSubplotData(data, type, subplotId) { return subplotData; }; -},{"../registry":326,"./cartesian/constants":285}],310:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../registry":373,"./cartesian/constants":337}],362:[function(_dereq_,module,exports){ 'use strict'; function xformMatrix(m, v) { @@ -71058,15 +79388,22 @@ function project(camera, v) { module.exports = project; -},{}],311:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +},{}],363:[function(_dereq_,module,exports){ +'use strict'; +var docs = _dereq_('../constants/docs'); +var FORMAT_LINK = docs.FORMAT_LINK; +var DATE_FORMAT_LINK = docs.DATE_FORMAT_LINK; + +module.exports = function axisHoverFormat(x, noDates) { + return { + valType: 'string', + dflt: '', + editType: 'none', + }; +}; + +},{"../constants/docs":262}],364:[function(_dereq_,module,exports){ 'use strict'; var fontAttrs = _dereq_('./font_attributes'); @@ -71078,7 +79415,6 @@ var extendFlat = _dereq_('../lib/extend').extendFlat; var globalFont = fontAttrs({ editType: 'calc', - }); globalFont.family.dflt = '"Open Sans", verdana, arial, sans-serif'; globalFont.size.dflt = 12; @@ -71089,66 +79425,50 @@ module.exports = { title: { text: { valType: 'string', - editType: 'layoutstyle', - }, font: fontAttrs({ editType: 'layoutstyle', - }), xref: { valType: 'enumerated', dflt: 'container', values: ['container', 'paper'], - editType: 'layoutstyle', - }, yref: { valType: 'enumerated', dflt: 'container', values: ['container', 'paper'], - editType: 'layoutstyle', - }, x: { valType: 'number', min: 0, max: 1, dflt: 0.5, - editType: 'layoutstyle', - }, y: { valType: 'number', min: 0, max: 1, dflt: 'auto', - editType: 'layoutstyle', - }, xanchor: { valType: 'enumerated', dflt: 'auto', values: ['auto', 'left', 'center', 'right'], - editType: 'layoutstyle', - }, yanchor: { valType: 'enumerated', dflt: 'auto', values: ['auto', 'top', 'middle', 'bottom'], - editType: 'layoutstyle', - }, pad: extendFlat(padAttrs({editType: 'layoutstyle'}), { - }), editType: 'layoutstyle' }, @@ -71157,217 +79477,134 @@ module.exports = { valType: 'enumerated', values: [false, 'hide', 'show'], dflt: false, - editType: 'plot', - }, minsize: { valType: 'number', min: 0, dflt: 0, - editType: 'plot', - }, editType: 'plot' }, autosize: { valType: 'boolean', - dflt: false, // autosize, width, and height get special editType treatment in _relayout // so we can handle noop resizes more efficiently editType: 'none', - }, width: { valType: 'number', - min: 10, dflt: 700, editType: 'plot', - }, height: { valType: 'number', - min: 10, dflt: 450, editType: 'plot', - }, margin: { l: { valType: 'number', - min: 0, dflt: 80, editType: 'plot', - }, r: { valType: 'number', - min: 0, dflt: 80, editType: 'plot', - }, t: { valType: 'number', - min: 0, dflt: 100, editType: 'plot', - }, b: { valType: 'number', - min: 0, dflt: 80, editType: 'plot', - }, pad: { valType: 'number', - min: 0, dflt: 0, editType: 'plot', - }, autoexpand: { valType: 'boolean', - dflt: true, editType: 'plot', - }, editType: 'plot' }, computed: { valType: 'any', - editType: 'none', - }, paper_bgcolor: { valType: 'color', - dflt: colorAttrs.background, editType: 'plot', - }, plot_bgcolor: { // defined here, but set in cartesian.supplyLayoutDefaults // because it needs to know if there are (2D) axes or not valType: 'color', - dflt: colorAttrs.background, editType: 'layoutstyle', - }, autotypenumbers: { valType: 'enumerated', values: ['convert types', 'strict'], dflt: 'convert types', - editType: 'calc', - }, separators: { valType: 'string', - editType: 'plot', - }, hidesources: { valType: 'boolean', - dflt: false, editType: 'plot', - }, showlegend: { // handled in legend.supplyLayoutDefaults // but included here because it's not in the legend object valType: 'boolean', - editType: 'legend', - }, colorway: { valType: 'colorlist', dflt: colorAttrs.defaults, - editType: 'calc', - }, datarevision: { valType: 'any', - editType: 'calc', - }, uirevision: { valType: 'any', - editType: 'none', - }, editrevision: { valType: 'any', - editType: 'none', - }, selectionrevision: { valType: 'any', - editType: 'none', - }, template: { valType: 'any', - editType: 'calc', - - }, - modebar: { - orientation: { - valType: 'enumerated', - values: ['v', 'h'], - dflt: 'h', - - editType: 'modebar', - - }, - bgcolor: { - valType: 'color', - - editType: 'modebar', - - }, - color: { - valType: 'color', - - editType: 'modebar', - - }, - activecolor: { - valType: 'color', - - editType: 'modebar', - - }, - uirevision: { - valType: 'any', - - editType: 'none', - - }, - editType: 'modebar' }, newshape: drawNewShapeAttrs.newshape, @@ -71376,38 +79613,24 @@ module.exports = { meta: { valType: 'any', arrayOk: true, - editType: 'plot', - }, transition: extendFlat({}, animationAttrs.transition, { - editType: 'none' }), _deprecated: { title: { valType: 'string', - editType: 'layoutstyle', - }, titlefont: fontAttrs({ editType: 'layoutstyle', - }) } }; -},{"../components/color/attributes":104,"../components/shapes/draw_newshape/attributes":187,"../lib/extend":227,"./animation_attributes":273,"./font_attributes":307,"./pad_attributes":312}],312:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../components/color/attributes":154,"../components/shapes/draw_newshape/attributes":240,"../lib/extend":279,"./animation_attributes":325,"./font_attributes":359,"./pad_attributes":365}],365:[function(_dereq_,module,exports){ 'use strict'; /** @@ -71425,47 +79648,31 @@ module.exports = function(opts) { t: { valType: 'number', dflt: 0, - editType: editType, - }, r: { valType: 'number', dflt: 0, - editType: editType, - }, b: { valType: 'number', dflt: 0, - editType: editType, - }, l: { valType: 'number', dflt: 0, - editType: editType, - }, editType: editType }; }; -},{}],313:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],366:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var timeFormatLocale = _dereq_('d3-time-format').timeFormatLocale; var isNumeric = _dereq_('fast-isnumeric'); @@ -71514,15 +79721,9 @@ plots.hasSimpleAPICommandBindings = commandModule.hasSimpleAPICommandBindings; plots.redrawText = function(gd) { gd = Lib.getGraphDiv(gd); - var fullLayout = gd._fullLayout || {}; - var hasPolar = fullLayout._has && fullLayout._has('polar'); - var hasLegacyPolar = !hasPolar && gd.data && gd.data[0] && gd.data[0].r; - - // do not work if polar is present - if(hasLegacyPolar) return; - return new Promise(function(resolve) { setTimeout(function() { + if(!gd._fullLayout) return; Registry.getComponentMethod('annotations', 'draw')(gd); Registry.getComponentMethod('legend', 'draw')(gd); Registry.getComponentMethod('colorbar', 'draw')(gd); @@ -71588,7 +79789,7 @@ plots.previousPromises = function(gd) { /** * Adds the 'Edit chart' link. - * Note that now Plotly.plot() calls this so it can regenerate whenever it replots + * Note that now _doPlot calls this so it can regenerate whenever it replots * * Add source links to your graph inside the 'showSources' config argument. */ @@ -71925,15 +80126,6 @@ plots.supplyDefaults = function(gd, opts) { newFullLayout.images.length === 0 ); - // TODO remove in v2.0.0 - // add has-plot-type refs to fullLayout for backward compatibility - newFullLayout._hasCartesian = newFullLayout._has('cartesian'); - newFullLayout._hasGeo = newFullLayout._has('geo'); - newFullLayout._hasGL3D = newFullLayout._has('gl3d'); - newFullLayout._hasGL2D = newFullLayout._has('gl2d'); - newFullLayout._hasTernary = newFullLayout._has('ternary'); - newFullLayout._hasPie = newFullLayout._has('pie'); - // relink / initialize subplot axis objects plots.linkSubplots(newFullData, newFullLayout, oldFullData, oldFullLayout); @@ -72168,7 +80360,7 @@ function getFormatObj(gd, formatKeys) { /** * getFormatter: combine the final separators with the locale formatting object * we pulled earlier to generate number and time formatters - * TODO: remove separators in v2, only use locale, so we don't need this step? + * TODO: remove separators in v3, only use locale, so we don't need this step? * * @param {object} formatObj: d3.locale format object * @param {string} separators: length-2 string to override decimal and thousands @@ -72969,7 +81161,7 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) { // layouts with no set width and height were set temporary set to 'initial' // to pass through the autosize routine // - // This behavior is subject to change in v2. + // This behavior is subject to change in v3. coerce('autosize', !(layoutIn.width && layoutIn.height)); coerce('width'); @@ -72997,12 +81189,10 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) { coerce('editrevision', uirevision); coerce('selectionrevision', uirevision); - coerce('modebar.orientation'); - coerce('modebar.bgcolor', Color.addOpacity(layoutOut.paper_bgcolor, 0.5)); - var modebarDefaultColor = Color.contrast(Color.rgb(layoutOut.modebar.bgcolor)); - coerce('modebar.color', Color.addOpacity(modebarDefaultColor, 0.3)); - coerce('modebar.activecolor', Color.addOpacity(modebarDefaultColor, 0.7)); - coerce('modebar.uirevision', uirevision); + Registry.getComponentMethod( + 'modebar', + 'supplyLayoutDefaults' + )(layoutIn, layoutOut); Registry.getComponentMethod( 'shapes', @@ -73213,7 +81403,6 @@ plots.purge = function(gd) { delete gd._fullData; delete gd._fullLayout; delete gd.calcdata; - delete gd.framework; delete gd.empty; delete gd.fid; @@ -73223,7 +81412,7 @@ plots.purge = function(gd) { delete gd.autoplay; // are we doing an action that doesn't go in undo queue? delete gd.changed; - // these get recreated on Plotly.plot anyway, but just to be safe + // these get recreated on _doPlot anyway, but just to be safe // (and to have a record of them...) delete gd._promises; delete gd._redrawTimer; @@ -73550,24 +81739,28 @@ plots.doAutoMargin = function(gd) { var maxNumberOfRedraws = 3 * (1 + Object.keys(pushMarginIds).length); if(fullLayout._redrawFromAutoMarginCount < maxNumberOfRedraws) { - return Registry.call('plot', gd); + return Registry.call('_doPlot', gd); } else { fullLayout._size = oldMargins; Lib.warn('Too many auto-margin redraws.'); } } - hideOutOfRangeInsideTickLabels(gd); + refineTicks(gd); }; -function hideOutOfRangeInsideTickLabels(gd) { +function refineTicks(gd) { var axList = axisIDs.list(gd, '', true); - for(var i = 0; i < axList.length; i++) { - var ax = axList[i]; - var hideFn = ax._hideOutOfRangeInsideTickLabels; - if(hideFn) hideFn(); - } + [ + '_adjustTickLabelsOverflow', + '_hideCounterAxisInsideTickLabels' + ].forEach(function(k) { + for(var i = 0; i < axList.length; i++) { + var hideFn = axList[i][k]; + if(hideFn) hideFn(); + } + }); } var marginKeys = ['l', 'r', 't', 'b', 'p', 'w', 'h']; @@ -73708,8 +81901,6 @@ plots.graphJson = function(gd, dataonly, mode, output, useDefaults, includeConfi } } - if(gd.framework && gd.framework.isPolar) obj = gd.framework.getConfig(); - if(frames) obj.frames = stripObj(frames); if(includeConfig) obj.config = stripObj(gd._context, true); @@ -74204,6 +82395,7 @@ plots.transitionFromReact = function(gd, restyleFlags, relayoutFlags, oldFullLay } function transitionAxes() { + if(!gd._fullLayout) return; for(var j = 0; j < basePlotModules.length; j++) { if(basePlotModules[j].transitionAxes) { basePlotModules[j].transitionAxes(gd, axEdits, axisTransitionOpts, makeCallback); @@ -74212,6 +82404,7 @@ plots.transitionFromReact = function(gd, restyleFlags, relayoutFlags, oldFullLay } function transitionTraces() { + if(!gd._fullLayout) return; for(var j = 0; j < basePlotModules.length; j++) { basePlotModules[j].plot(gd, transitionedTraces, traceTransitionOpts, makeCallback); } @@ -74881,1769 +83074,7 @@ plots.cleanBasePlot = function(desiredType, newFullData, newFullLayout, oldFullD } }; -},{"../components/color":105,"../constants/numerical":212,"../lib":233,"../plot_api/plot_schema":267,"../plot_api/plot_template":268,"../plots/get_data":309,"../registry":326,"./animation_attributes":273,"./attributes":275,"./cartesian/axis_ids":282,"./cartesian/handle_outline":289,"./command":305,"./font_attributes":307,"./frame_attributes":308,"./layout_attributes":311,"d3":21,"d3-time-format":19,"fast-isnumeric":23}],314:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - -'use strict'; - -var scatterAttrs = _dereq_('../../../traces/scatter/attributes'); -var scatterMarkerAttrs = scatterAttrs.marker; -var extendFlat = _dereq_('../../../lib/extend').extendFlat; - -var deprecationWarning = [ - 'Area traces are deprecated!', - 'Please switch to the *barpolar* trace type.' -].join(' '); - -module.exports = { - r: extendFlat({}, scatterAttrs.r, { - - }), - t: extendFlat({}, scatterAttrs.t, { - - }), - marker: { - color: extendFlat({}, scatterMarkerAttrs.color, { - - }), - size: extendFlat({}, scatterMarkerAttrs.size, { - - }), - symbol: extendFlat({}, scatterMarkerAttrs.symbol, { - - }), - opacity: extendFlat({}, scatterMarkerAttrs.opacity, { - - }), - editType: 'calc' - } -}; - -},{"../../../lib/extend":227,"../../../traces/scatter/attributes":447}],315:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - -'use strict'; - -var axesAttrs = _dereq_('../../cartesian/layout_attributes'); -var extendFlat = _dereq_('../../../lib/extend').extendFlat; -var overrideAll = _dereq_('../../../plot_api/edit_types').overrideAll; - -var deprecationWarning = [ - 'Legacy polar charts are deprecated!', - 'Please switch to *polar* subplots.' -].join(' '); - -var domainAttr = extendFlat({}, axesAttrs.domain, { - -}); - -function mergeAttrs(axisName, nonCommonAttrs) { - var commonAttrs = { - showline: { - valType: 'boolean', - - - }, - showticklabels: { - valType: 'boolean', - - - }, - tickorientation: { - valType: 'enumerated', - values: ['horizontal', 'vertical'], - - - }, - ticklen: { - valType: 'number', - min: 0, - - - }, - tickcolor: { - valType: 'color', - - - }, - ticksuffix: { - valType: 'string', - - - }, - endpadding: { - valType: 'number', - - description: deprecationWarning, - }, - visible: { - valType: 'boolean', - - - } - }; - - return extendFlat({}, nonCommonAttrs, commonAttrs); -} - -module.exports = overrideAll({ - radialaxis: mergeAttrs('radial', { - range: { - valType: 'info_array', - - items: [ - { valType: 'number' }, - { valType: 'number' } - ], - - }, - domain: domainAttr, - orientation: { - valType: 'number', - - - } - }), - - angularaxis: mergeAttrs('angular', { - range: { - valType: 'info_array', - - items: [ - { valType: 'number', dflt: 0 }, - { valType: 'number', dflt: 360 } - ], - - }, - domain: domainAttr - }), - - // attributes that appear at layout root - layout: { - direction: { - valType: 'enumerated', - values: ['clockwise', 'counterclockwise'], - - - }, - orientation: { - valType: 'angle', - - - } - } -}, 'plot', 'nested'); - -},{"../../../lib/extend":227,"../../../plot_api/edit_types":261,"../../cartesian/layout_attributes":293}],316:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - -'use strict'; - -var Polar = module.exports = _dereq_('./micropolar'); - -Polar.manager = _dereq_('./micropolar_manager'); - -},{"./micropolar":317,"./micropolar_manager":318}],317:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - -var d3 = _dereq_('d3'); -var Lib = _dereq_('../../../lib'); -var extendDeepAll = Lib.extendDeepAll; -var MID_SHIFT = _dereq_('../../../constants/alignment').MID_SHIFT; - -var µ = module.exports = { version: '0.2.2' }; - -µ.Axis = function module() { - var config = { - data: [], - layout: {} - }, inputConfig = {}, liveConfig = {}; - var svg, container, dispatch = d3.dispatch('hover'), radialScale, angularScale; - var exports = {}; - function render(_container) { - container = _container || container; - var data = config.data; - var axisConfig = config.layout; - if (typeof container == 'string' || container.nodeName) container = d3.select(container); - container.datum(data).each(function(_data, _index) { - var dataOriginal = _data.slice(); - liveConfig = { - data: µ.util.cloneJson(dataOriginal), - layout: µ.util.cloneJson(axisConfig) - }; - var colorIndex = 0; - dataOriginal.forEach(function(d, i) { - if (!d.color) { - d.color = axisConfig.defaultColorRange[colorIndex]; - colorIndex = (colorIndex + 1) % axisConfig.defaultColorRange.length; - } - if (!d.strokeColor) { - d.strokeColor = d.geometry === 'LinePlot' ? d.color : d3.rgb(d.color).darker().toString(); - } - liveConfig.data[i].color = d.color; - liveConfig.data[i].strokeColor = d.strokeColor; - liveConfig.data[i].strokeDash = d.strokeDash; - liveConfig.data[i].strokeSize = d.strokeSize; - }); - var data = dataOriginal.filter(function(d, i) { - var visible = d.visible; - return typeof visible === 'undefined' || visible === true; - }); - var isStacked = false; - var dataWithGroupId = data.map(function(d, i) { - isStacked = isStacked || typeof d.groupId !== 'undefined'; - return d; - }); - if (isStacked) { - var grouped = d3.nest().key(function(d, i) { - return typeof d.groupId != 'undefined' ? d.groupId : 'unstacked'; - }).entries(dataWithGroupId); - var dataYStack = []; - var stacked = grouped.map(function(d, i) { - if (d.key === 'unstacked') return d.values; else { - var prevArray = d.values[0].r.map(function(d, i) { - return 0; - }); - d.values.forEach(function(d, i, a) { - d.yStack = [ prevArray ]; - dataYStack.push(prevArray); - prevArray = µ.util.sumArrays(d.r, prevArray); - }); - return d.values; - } - }); - data = d3.merge(stacked); - } - data.forEach(function(d, i) { - d.t = Array.isArray(d.t[0]) ? d.t : [ d.t ]; - d.r = Array.isArray(d.r[0]) ? d.r : [ d.r ]; - }); - var radius = Math.min(axisConfig.width - axisConfig.margin.left - axisConfig.margin.right, axisConfig.height - axisConfig.margin.top - axisConfig.margin.bottom) / 2; - radius = Math.max(10, radius); - var chartCenter = [ axisConfig.margin.left + radius, axisConfig.margin.top + radius ]; - var extent; - if (isStacked) { - var highestStackedValue = d3.max(µ.util.sumArrays(µ.util.arrayLast(data).r[0], µ.util.arrayLast(dataYStack))); - extent = [ 0, highestStackedValue ]; - } else extent = d3.extent(µ.util.flattenArray(data.map(function(d, i) { - return d.r; - }))); - if (axisConfig.radialAxis.domain != µ.DATAEXTENT) extent[0] = 0; - radialScale = d3.scale.linear().domain(axisConfig.radialAxis.domain != µ.DATAEXTENT && axisConfig.radialAxis.domain ? axisConfig.radialAxis.domain : extent).range([ 0, radius ]); - liveConfig.layout.radialAxis.domain = radialScale.domain(); - var angularDataMerged = µ.util.flattenArray(data.map(function(d, i) { - return d.t; - })); - var isOrdinal = typeof angularDataMerged[0] === 'string'; - var ticks; - if (isOrdinal) { - angularDataMerged = µ.util.deduplicate(angularDataMerged); - ticks = angularDataMerged.slice(); - angularDataMerged = d3.range(angularDataMerged.length); - data = data.map(function(d, i) { - var result = d; - d.t = [ angularDataMerged ]; - if (isStacked) result.yStack = d.yStack; - return result; - }); - } - var hasOnlyLineOrDotPlot = data.filter(function(d, i) { - return d.geometry === 'LinePlot' || d.geometry === 'DotPlot'; - }).length === data.length; - var needsEndSpacing = axisConfig.needsEndSpacing === null ? isOrdinal || !hasOnlyLineOrDotPlot : axisConfig.needsEndSpacing; - var useProvidedDomain = axisConfig.angularAxis.domain && axisConfig.angularAxis.domain != µ.DATAEXTENT && !isOrdinal && axisConfig.angularAxis.domain[0] >= 0; - var angularDomain = useProvidedDomain ? axisConfig.angularAxis.domain : d3.extent(angularDataMerged); - var angularDomainStep = Math.abs(angularDataMerged[1] - angularDataMerged[0]); - if (hasOnlyLineOrDotPlot && !isOrdinal) angularDomainStep = 0; - var angularDomainWithPadding = angularDomain.slice(); - if (needsEndSpacing && isOrdinal) angularDomainWithPadding[1] += angularDomainStep; - var tickCount = axisConfig.angularAxis.ticksCount || 4; - if (tickCount > 8) tickCount = tickCount / (tickCount / 8) + tickCount % 8; - if (axisConfig.angularAxis.ticksStep) { - tickCount = (angularDomainWithPadding[1] - angularDomainWithPadding[0]) / tickCount; - } - var angularTicksStep = axisConfig.angularAxis.ticksStep || (angularDomainWithPadding[1] - angularDomainWithPadding[0]) / (tickCount * (axisConfig.minorTicks + 1)); - if (ticks) angularTicksStep = Math.max(Math.round(angularTicksStep), 1); - if (!angularDomainWithPadding[2]) angularDomainWithPadding[2] = angularTicksStep; - var angularAxisRange = d3.range.apply(this, angularDomainWithPadding); - angularAxisRange = angularAxisRange.map(function(d, i) { - return parseFloat(d.toPrecision(12)); - }); - angularScale = d3.scale.linear().domain(angularDomainWithPadding.slice(0, 2)).range(axisConfig.direction === 'clockwise' ? [ 0, 360 ] : [ 360, 0 ]); - liveConfig.layout.angularAxis.domain = angularScale.domain(); - liveConfig.layout.angularAxis.endPadding = needsEndSpacing ? angularDomainStep : 0; - svg = d3.select(this).select('svg.chart-root'); - if (typeof svg === 'undefined' || svg.empty()) { - var skeleton = "' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '"; - var doc = new DOMParser().parseFromString(skeleton, 'application/xml'); - var newSvg = this.appendChild(this.ownerDocument.importNode(doc.documentElement, true)); - svg = d3.select(newSvg); - } - svg.select('.guides-group').style({ - 'pointer-events': 'none' - }); - svg.select('.angular.axis-group').style({ - 'pointer-events': 'none' - }); - svg.select('.radial.axis-group').style({ - 'pointer-events': 'none' - }); - var chartGroup = svg.select('.chart-group'); - var lineStyle = { - fill: 'none', - stroke: axisConfig.tickColor - }; - var fontStyle = { - 'font-size': axisConfig.font.size, - 'font-family': axisConfig.font.family, - fill: axisConfig.font.color, - 'text-shadow': [ '-1px 0px', '1px -1px', '-1px 1px', '1px 1px' ].map(function(d, i) { - return ' ' + d + ' 0 ' + axisConfig.font.outlineColor; - }).join(',') - }; - var legendContainer; - if (axisConfig.showLegend) { - legendContainer = svg.select('.legend-group').attr({ - transform: 'translate(' + [ radius, axisConfig.margin.top ] + ')' - }).style({ - display: 'block' - }); - var elements = data.map(function(d, i) { - var datumClone = µ.util.cloneJson(d); - datumClone.symbol = d.geometry === 'DotPlot' ? d.dotType || 'circle' : d.geometry != 'LinePlot' ? 'square' : 'line'; - datumClone.visibleInLegend = typeof d.visibleInLegend === 'undefined' || d.visibleInLegend; - datumClone.color = d.geometry === 'LinePlot' ? d.strokeColor : d.color; - return datumClone; - }); - - µ.Legend().config({ - data: data.map(function(d, i) { - return d.name || 'Element' + i; - }), - legendConfig: extendDeepAll({}, - µ.Legend.defaultConfig().legendConfig, - { - container: legendContainer, - elements: elements, - reverseOrder: axisConfig.legend.reverseOrder - } - ) - })(); - - var legendBBox = legendContainer.node().getBBox(); - radius = Math.min(axisConfig.width - legendBBox.width - axisConfig.margin.left - axisConfig.margin.right, axisConfig.height - axisConfig.margin.top - axisConfig.margin.bottom) / 2; - radius = Math.max(10, radius); - chartCenter = [ axisConfig.margin.left + radius, axisConfig.margin.top + radius ]; - radialScale.range([ 0, radius ]); - liveConfig.layout.radialAxis.domain = radialScale.domain(); - legendContainer.attr('transform', 'translate(' + [ chartCenter[0] + radius, chartCenter[1] - radius ] + ')'); - } else { - legendContainer = svg.select('.legend-group').style({ - display: 'none' - }); - } - svg.attr({ - width: axisConfig.width, - height: axisConfig.height - }).style({ - opacity: axisConfig.opacity - }); - chartGroup.attr('transform', 'translate(' + chartCenter + ')').style({ - cursor: 'crosshair' - }); - var centeringOffset = [ (axisConfig.width - (axisConfig.margin.left + axisConfig.margin.right + radius * 2 + (legendBBox ? legendBBox.width : 0))) / 2, (axisConfig.height - (axisConfig.margin.top + axisConfig.margin.bottom + radius * 2)) / 2 ]; - centeringOffset[0] = Math.max(0, centeringOffset[0]); - centeringOffset[1] = Math.max(0, centeringOffset[1]); - svg.select('.outer-group').attr('transform', 'translate(' + centeringOffset + ')'); - if (axisConfig.title && axisConfig.title.text) { - var title = svg.select('g.title-group text').style(fontStyle).text(axisConfig.title.text); - var titleBBox = title.node().getBBox(); - title.attr({ - x: chartCenter[0] - titleBBox.width / 2, - y: chartCenter[1] - radius - 20 - }); - } - var radialAxis = svg.select('.radial.axis-group'); - if (axisConfig.radialAxis.gridLinesVisible) { - var gridCircles = radialAxis.selectAll('circle.grid-circle').data(radialScale.ticks(5)); - gridCircles.enter().append('circle').attr({ - 'class': 'grid-circle' - }).style(lineStyle); - gridCircles.attr('r', radialScale); - gridCircles.exit().remove(); - } - radialAxis.select('circle.outside-circle').attr({ - r: radius - }).style(lineStyle); - var backgroundCircle = svg.select('circle.background-circle').attr({ - r: radius - }).style({ - fill: axisConfig.backgroundColor, - stroke: axisConfig.stroke - }); - function currentAngle(d, i) { - return angularScale(d) % 360 + axisConfig.orientation; - } - if (axisConfig.radialAxis.visible) { - var axis = d3.svg.axis().scale(radialScale).ticks(5).tickSize(5); - radialAxis.call(axis).attr({ - transform: 'rotate(' + axisConfig.radialAxis.orientation + ')' - }); - radialAxis.selectAll('.domain').style(lineStyle); - radialAxis.selectAll('g>text').text(function(d, i) { - return this.textContent + axisConfig.radialAxis.ticksSuffix; - }).style(fontStyle).style({ - 'text-anchor': 'start' - }).attr({ - x: 0, - y: 0, - dx: 0, - dy: 0, - transform: function(d, i) { - if (axisConfig.radialAxis.tickOrientation === 'horizontal') { - return 'rotate(' + -axisConfig.radialAxis.orientation + ') translate(' + [ 0, fontStyle['font-size'] ] + ')'; - } else return 'translate(' + [ 0, fontStyle['font-size'] ] + ')'; - } - }); - radialAxis.selectAll('g>line').style({ - stroke: 'black' - }); - } - var angularAxis = svg.select('.angular.axis-group').selectAll('g.angular-tick').data(angularAxisRange); - var angularAxisEnter = angularAxis.enter().append('g').classed('angular-tick', true); - angularAxis.attr({ - transform: function(d, i) { - return 'rotate(' + currentAngle(d, i) + ')'; - } - }).style({ - display: axisConfig.angularAxis.visible ? 'block' : 'none' - }); - angularAxis.exit().remove(); - angularAxisEnter.append('line').classed('grid-line', true).classed('major', function(d, i) { - return i % (axisConfig.minorTicks + 1) == 0; - }).classed('minor', function(d, i) { - return !(i % (axisConfig.minorTicks + 1) == 0); - }).style(lineStyle); - angularAxisEnter.selectAll('.minor').style({ - stroke: axisConfig.minorTickColor - }); - angularAxis.select('line.grid-line').attr({ - x1: axisConfig.tickLength ? radius - axisConfig.tickLength : 0, - x2: radius - }).style({ - display: axisConfig.angularAxis.gridLinesVisible ? 'block' : 'none' - }); - angularAxisEnter.append('text').classed('axis-text', true).style(fontStyle); - var ticksText = angularAxis.select('text.axis-text').attr({ - x: radius + axisConfig.labelOffset, - dy: MID_SHIFT + 'em', - transform: function(d, i) { - var angle = currentAngle(d, i); - var rad = radius + axisConfig.labelOffset; - var orient = axisConfig.angularAxis.tickOrientation; - if (orient == 'horizontal') return 'rotate(' + -angle + ' ' + rad + ' 0)'; else if (orient == 'radial') return angle < 270 && angle > 90 ? 'rotate(180 ' + rad + ' 0)' : null; else return 'rotate(' + (angle <= 180 && angle > 0 ? -90 : 90) + ' ' + rad + ' 0)'; - } - }).style({ - 'text-anchor': 'middle', - display: axisConfig.angularAxis.labelsVisible ? 'block' : 'none' - }).text(function(d, i) { - if (i % (axisConfig.minorTicks + 1) != 0) return ''; - if (ticks) { - return ticks[d] + axisConfig.angularAxis.ticksSuffix; - } else return d + axisConfig.angularAxis.ticksSuffix; - }).style(fontStyle); - if (axisConfig.angularAxis.rewriteTicks) ticksText.text(function(d, i) { - if (i % (axisConfig.minorTicks + 1) != 0) return ''; - return axisConfig.angularAxis.rewriteTicks(this.textContent, i); - }); - var rightmostTickEndX = d3.max(chartGroup.selectAll('.angular-tick text')[0].map(function(d, i) { - return d.getCTM().e + d.getBBox().width; - })); - legendContainer.attr({ - transform: 'translate(' + [ radius + rightmostTickEndX, axisConfig.margin.top ] + ')' - }); - var hasGeometry = svg.select('g.geometry-group').selectAll('g').size() > 0; - var geometryContainer = svg.select('g.geometry-group').selectAll('g.geometry').data(data); - geometryContainer.enter().append('g').attr({ - 'class': function(d, i) { - return 'geometry geometry' + i; - } - }); - geometryContainer.exit().remove(); - if (data[0] || hasGeometry) { - var geometryConfigs = []; - data.forEach(function(d, i) { - var geometryConfig = {}; - geometryConfig.radialScale = radialScale; - geometryConfig.angularScale = angularScale; - geometryConfig.container = geometryContainer.filter(function(dB, iB) { - return iB == i; - }); - geometryConfig.geometry = d.geometry; - geometryConfig.orientation = axisConfig.orientation; - geometryConfig.direction = axisConfig.direction; - geometryConfig.index = i; - geometryConfigs.push({ - data: d, - geometryConfig: geometryConfig - }); - }); - var geometryConfigsGrouped = d3.nest().key(function(d, i) { - return typeof d.data.groupId != 'undefined' || 'unstacked'; - }).entries(geometryConfigs); - var geometryConfigsGrouped2 = []; - geometryConfigsGrouped.forEach(function(d, i) { - if (d.key === 'unstacked') geometryConfigsGrouped2 = geometryConfigsGrouped2.concat(d.values.map(function(d, i) { - return [ d ]; - })); else geometryConfigsGrouped2.push(d.values); - }); - geometryConfigsGrouped2.forEach(function(d, i) { - var geometry; - if (Array.isArray(d)) geometry = d[0].geometryConfig.geometry; else geometry = d.geometryConfig.geometry; - var finalGeometryConfig = d.map(function(dB, iB) { - return extendDeepAll(µ[geometry].defaultConfig(), dB); - }); - µ[geometry]().config(finalGeometryConfig)(); - }); - } - var guides = svg.select('.guides-group'); - var tooltipContainer = svg.select('.tooltips-group'); - var angularTooltip = µ.tooltipPanel().config({ - container: tooltipContainer, - fontSize: 8 - })(); - var radialTooltip = µ.tooltipPanel().config({ - container: tooltipContainer, - fontSize: 8 - })(); - var geometryTooltip = µ.tooltipPanel().config({ - container: tooltipContainer, - hasTick: true - })(); - var angularValue, radialValue; - if (!isOrdinal) { - var angularGuideLine = guides.select('line').attr({ - x1: 0, - y1: 0, - y2: 0 - }).style({ - stroke: 'grey', - 'pointer-events': 'none' - }); - chartGroup.on('mousemove.angular-guide', function(d, i) { - var mouseAngle = µ.util.getMousePos(backgroundCircle).angle; - angularGuideLine.attr({ - x2: -radius, - transform: 'rotate(' + mouseAngle + ')' - }).style({ - opacity: .5 - }); - var angleWithOriginOffset = (mouseAngle + 180 + 360 - axisConfig.orientation) % 360; - angularValue = angularScale.invert(angleWithOriginOffset); - var pos = µ.util.convertToCartesian(radius + 12, mouseAngle + 180); - angularTooltip.text(µ.util.round(angularValue)).move([ pos[0] + chartCenter[0], pos[1] + chartCenter[1] ]); - }).on('mouseout.angular-guide', function(d, i) { - guides.select('line').style({ - opacity: 0 - }); - }); - } - var angularGuideCircle = guides.select('circle').style({ - stroke: 'grey', - fill: 'none' - }); - chartGroup.on('mousemove.radial-guide', function(d, i) { - var r = µ.util.getMousePos(backgroundCircle).radius; - angularGuideCircle.attr({ - r: r - }).style({ - opacity: .5 - }); - radialValue = radialScale.invert(µ.util.getMousePos(backgroundCircle).radius); - var pos = µ.util.convertToCartesian(r, axisConfig.radialAxis.orientation); - radialTooltip.text(µ.util.round(radialValue)).move([ pos[0] + chartCenter[0], pos[1] + chartCenter[1] ]); - }).on('mouseout.radial-guide', function(d, i) { - angularGuideCircle.style({ - opacity: 0 - }); - geometryTooltip.hide(); - angularTooltip.hide(); - radialTooltip.hide(); - }); - svg.selectAll('.geometry-group .mark').on('mouseover.tooltip', function(d, i) { - var el = d3.select(this); - var color = this.style.fill; - var newColor = 'black'; - var opacity = this.style.opacity || 1; - el.attr({ - 'data-opacity': opacity - }); - if (color && color !== 'none') { - el.attr({ - 'data-fill': color - }); - newColor = d3.hsl(color).darker().toString(); - el.style({ - fill: newColor, - opacity: 1 - }); - var textData = { - t: µ.util.round(d[0]), - r: µ.util.round(d[1]) - }; - if (isOrdinal) textData.t = ticks[d[0]]; - var text = 't: ' + textData.t + ', r: ' + textData.r; - var bbox = this.getBoundingClientRect(); - var svgBBox = svg.node().getBoundingClientRect(); - var pos = [ bbox.left + bbox.width / 2 - centeringOffset[0] - svgBBox.left, bbox.top + bbox.height / 2 - centeringOffset[1] - svgBBox.top ]; - geometryTooltip.config({ - color: newColor - }).text(text); - geometryTooltip.move(pos); - } else { - color = this.style.stroke || 'black'; - el.attr({ - 'data-stroke': color - }); - newColor = d3.hsl(color).darker().toString(); - el.style({ - stroke: newColor, - opacity: 1 - }); - } - }).on('mousemove.tooltip', function(d, i) { - if (d3.event.which != 0) return false; - if (d3.select(this).attr('data-fill')) geometryTooltip.show(); - }).on('mouseout.tooltip', function(d, i) { - geometryTooltip.hide(); - var el = d3.select(this); - var fillColor = el.attr('data-fill'); - if (fillColor) el.style({ - fill: fillColor, - opacity: el.attr('data-opacity') - }); else el.style({ - stroke: el.attr('data-stroke'), - opacity: el.attr('data-opacity') - }); - }); - }); - return exports; - } - exports.render = function(_container) { - render(_container); - return this; - }; - exports.config = function(_x) { - if (!arguments.length) return config; - var xClone = µ.util.cloneJson(_x); - xClone.data.forEach(function(d, i) { - if (!config.data[i]) config.data[i] = {}; - extendDeepAll(config.data[i], µ.Axis.defaultConfig().data[0]); - extendDeepAll(config.data[i], d); - }); - extendDeepAll(config.layout, µ.Axis.defaultConfig().layout); - extendDeepAll(config.layout, xClone.layout); - return this; - }; - exports.getLiveConfig = function() { - return liveConfig; - }; - exports.getinputConfig = function() { - return inputConfig; - }; - exports.radialScale = function(_x) { - return radialScale; - }; - exports.angularScale = function(_x) { - return angularScale; - }; - exports.svg = function() { - return svg; - }; - d3.rebind(exports, dispatch, 'on'); - return exports; -}; - -µ.Axis.defaultConfig = function(d, i) { - var config = { - data: [ { - t: [ 1, 2, 3, 4 ], - r: [ 10, 11, 12, 13 ], - name: 'Line1', - geometry: 'LinePlot', - color: null, - strokeDash: 'solid', - strokeColor: null, - strokeSize: '1', - visibleInLegend: true, - opacity: 1 - } ], - layout: { - defaultColorRange: d3.scale.category10().range(), - title: null, - height: 450, - width: 500, - margin: { - top: 40, - right: 40, - bottom: 40, - left: 40 - }, - font: { - size: 12, - color: 'gray', - outlineColor: 'white', - family: 'Tahoma, sans-serif' - }, - direction: 'clockwise', - orientation: 0, - labelOffset: 10, - radialAxis: { - domain: null, - orientation: -45, - ticksSuffix: '', - visible: true, - gridLinesVisible: true, - tickOrientation: 'horizontal', - rewriteTicks: null - }, - angularAxis: { - domain: [ 0, 360 ], - ticksSuffix: '', - visible: true, - gridLinesVisible: true, - labelsVisible: true, - tickOrientation: 'horizontal', - rewriteTicks: null, - ticksCount: null, - ticksStep: null - }, - minorTicks: 0, - tickLength: null, - tickColor: 'silver', - minorTickColor: '#eee', - backgroundColor: 'none', - needsEndSpacing: null, - showLegend: true, - legend: { - reverseOrder: false - }, - opacity: 1 - } - }; - return config; -}; - -µ.util = {}; - -µ.DATAEXTENT = 'dataExtent'; - -µ.AREA = 'AreaChart'; - -µ.LINE = 'LinePlot'; - -µ.DOT = 'DotPlot'; - -µ.BAR = 'BarChart'; - -µ.util._override = function(_objA, _objB) { - for (var x in _objA) if (x in _objB) _objB[x] = _objA[x]; -}; - -µ.util._extend = function(_objA, _objB) { - for (var x in _objA) _objB[x] = _objA[x]; -}; - -µ.util._rndSnd = function() { - return Math.random() * 2 - 1 + (Math.random() * 2 - 1) + (Math.random() * 2 - 1); -}; - -µ.util.dataFromEquation2 = function(_equation, _step) { - var step = _step || 6; - var data = d3.range(0, 360 + step, step).map(function(deg, index) { - var theta = deg * Math.PI / 180; - var radius = _equation(theta); - return [ deg, radius ]; - }); - return data; -}; - -µ.util.dataFromEquation = function(_equation, _step, _name) { - var step = _step || 6; - var t = [], r = []; - d3.range(0, 360 + step, step).forEach(function(deg, index) { - var theta = deg * Math.PI / 180; - var radius = _equation(theta); - t.push(deg); - r.push(radius); - }); - var result = { - t: t, - r: r - }; - if (_name) result.name = _name; - return result; -}; - -µ.util.ensureArray = function(_val, _count) { - if (typeof _val === 'undefined') return null; - var arr = [].concat(_val); - return d3.range(_count).map(function(d, i) { - return arr[i] || arr[0]; - }); -}; - -µ.util.fillArrays = function(_obj, _valueNames, _count) { - _valueNames.forEach(function(d, i) { - _obj[d] = µ.util.ensureArray(_obj[d], _count); - }); - return _obj; -}; - -µ.util.cloneJson = function(json) { - return JSON.parse(JSON.stringify(json)); -}; - -µ.util.validateKeys = function(obj, keys) { - if (typeof keys === 'string') keys = keys.split('.'); - var next = keys.shift(); - return obj[next] && (!keys.length || objHasKeys(obj[next], keys)); -}; - -µ.util.sumArrays = function(a, b) { - return d3.zip(a, b).map(function(d, i) { - return d3.sum(d); - }); -}; - -µ.util.arrayLast = function(a) { - return a[a.length - 1]; -}; - -µ.util.arrayEqual = function(a, b) { - var i = Math.max(a.length, b.length, 1); - while (i-- >= 0 && a[i] === b[i]) ; - return i === -2; -}; - -µ.util.flattenArray = function(arr) { - var r = []; - while (!µ.util.arrayEqual(r, arr)) { - r = arr; - arr = [].concat.apply([], arr); - } - return arr; -}; - -µ.util.deduplicate = function(arr) { - return arr.filter(function(v, i, a) { - return a.indexOf(v) == i; - }); -}; - -µ.util.convertToCartesian = function(radius, theta) { - var thetaRadians = theta * Math.PI / 180; - var x = radius * Math.cos(thetaRadians); - var y = radius * Math.sin(thetaRadians); - return [ x, y ]; -}; - -µ.util.round = function(_value, _digits) { - var digits = _digits || 2; - var mult = Math.pow(10, digits); - return Math.round(_value * mult) / mult; -}; - -µ.util.getMousePos = function(_referenceElement) { - var mousePos = d3.mouse(_referenceElement.node()); - var mouseX = mousePos[0]; - var mouseY = mousePos[1]; - var mouse = {}; - mouse.x = mouseX; - mouse.y = mouseY; - mouse.pos = mousePos; - mouse.angle = (Math.atan2(mouseY, mouseX) + Math.PI) * 180 / Math.PI; - mouse.radius = Math.sqrt(mouseX * mouseX + mouseY * mouseY); - return mouse; -}; - -µ.util.duplicatesCount = function(arr) { - var uniques = {}, val; - var dups = {}; - for (var i = 0, len = arr.length; i < len; i++) { - val = arr[i]; - if (val in uniques) { - uniques[val]++; - dups[val] = uniques[val]; - } else { - uniques[val] = 1; - } - } - return dups; -}; - -µ.util.duplicates = function(arr) { - return Object.keys(µ.util.duplicatesCount(arr)); -}; - -µ.util.translator = function(obj, sourceBranch, targetBranch, reverse) { - if (reverse) { - var targetBranchCopy = targetBranch.slice(); - targetBranch = sourceBranch; - sourceBranch = targetBranchCopy; - } - var value = sourceBranch.reduce(function(previousValue, currentValue) { - if (typeof previousValue != 'undefined') return previousValue[currentValue]; - }, obj); - if (typeof value === 'undefined') return; - sourceBranch.reduce(function(previousValue, currentValue, index) { - if (typeof previousValue == 'undefined') return; - if (index === sourceBranch.length - 1) delete previousValue[currentValue]; - return previousValue[currentValue]; - }, obj); - targetBranch.reduce(function(previousValue, currentValue, index) { - if (typeof previousValue[currentValue] === 'undefined') previousValue[currentValue] = {}; - if (index === targetBranch.length - 1) previousValue[currentValue] = value; - return previousValue[currentValue]; - }, obj); -}; - -µ.PolyChart = function module() { - var config = [ µ.PolyChart.defaultConfig() ]; - var dispatch = d3.dispatch('hover'); - var dashArray = { - solid: 'none', - dash: [ 5, 2 ], - dot: [ 2, 5 ] - }; - var colorScale; - function exports() { - var geometryConfig = config[0].geometryConfig; - var container = geometryConfig.container; - if (typeof container == 'string') container = d3.select(container); - container.datum(config).each(function(_config, _index) { - var isStack = !!_config[0].data.yStack; - var data = _config.map(function(d, i) { - if (isStack) return d3.zip(d.data.t[0], d.data.r[0], d.data.yStack[0]); else return d3.zip(d.data.t[0], d.data.r[0]); - }); - var angularScale = geometryConfig.angularScale; - var domainMin = geometryConfig.radialScale.domain()[0]; - var generator = {}; - generator.bar = function(d, i, pI) { - var dataConfig = _config[pI].data; - var h = geometryConfig.radialScale(d[1]) - geometryConfig.radialScale(0); - var stackTop = geometryConfig.radialScale(d[2] || 0); - var w = dataConfig.barWidth; - d3.select(this).attr({ - 'class': 'mark bar', - d: 'M' + [ [ h + stackTop, -w / 2 ], [ h + stackTop, w / 2 ], [ stackTop, w / 2 ], [ stackTop, -w / 2 ] ].join('L') + 'Z', - transform: function(d, i) { - return 'rotate(' + (geometryConfig.orientation + angularScale(d[0])) + ')'; - } - }); - }; - generator.dot = function(d, i, pI) { - var stackedData = d[2] ? [ d[0], d[1] + d[2] ] : d; - var symbol = d3.svg.symbol().size(_config[pI].data.dotSize).type(_config[pI].data.dotType)(d, i); - d3.select(this).attr({ - 'class': 'mark dot', - d: symbol, - transform: function(d, i) { - var coord = convertToCartesian(getPolarCoordinates(stackedData)); - return 'translate(' + [ coord.x, coord.y ] + ')'; - } - }); - }; - var line = d3.svg.line.radial().interpolate(_config[0].data.lineInterpolation).radius(function(d) { - return geometryConfig.radialScale(d[1]); - }).angle(function(d) { - return geometryConfig.angularScale(d[0]) * Math.PI / 180; - }); - generator.line = function(d, i, pI) { - var lineData = d[2] ? data[pI].map(function(d, i) { - return [ d[0], d[1] + d[2] ]; - }) : data[pI]; - d3.select(this).each(generator['dot']).style({ - opacity: function(dB, iB) { - return +_config[pI].data.dotVisible; - }, - fill: markStyle.stroke(d, i, pI) - }).attr({ - 'class': 'mark dot' - }); - if (i > 0) return; - var lineSelection = d3.select(this.parentNode).selectAll('path.line').data([ 0 ]); - lineSelection.enter().insert('path'); - lineSelection.attr({ - 'class': 'line', - d: line(lineData), - transform: function(dB, iB) { - return 'rotate(' + (geometryConfig.orientation + 90) + ')'; - }, - 'pointer-events': 'none' - }).style({ - fill: function(dB, iB) { - return markStyle.fill(d, i, pI); - }, - 'fill-opacity': 0, - stroke: function(dB, iB) { - return markStyle.stroke(d, i, pI); - }, - 'stroke-width': function(dB, iB) { - return markStyle['stroke-width'](d, i, pI); - }, - 'stroke-dasharray': function(dB, iB) { - return markStyle['stroke-dasharray'](d, i, pI); - }, - opacity: function(dB, iB) { - return markStyle.opacity(d, i, pI); - }, - display: function(dB, iB) { - return markStyle.display(d, i, pI); - } - }); - }; - var angularRange = geometryConfig.angularScale.range(); - var triangleAngle = Math.abs(angularRange[1] - angularRange[0]) / data[0].length * Math.PI / 180; - var arc = d3.svg.arc().startAngle(function(d) { - return -triangleAngle / 2; - }).endAngle(function(d) { - return triangleAngle / 2; - }).innerRadius(function(d) { - return geometryConfig.radialScale(domainMin + (d[2] || 0)); - }).outerRadius(function(d) { - return geometryConfig.radialScale(domainMin + (d[2] || 0)) + geometryConfig.radialScale(d[1]); - }); - generator.arc = function(d, i, pI) { - d3.select(this).attr({ - 'class': 'mark arc', - d: arc, - transform: function(d, i) { - return 'rotate(' + (geometryConfig.orientation + angularScale(d[0]) + 90) + ')'; - } - }); - }; - var markStyle = { - fill: function(d, i, pI) { - return _config[pI].data.color; - }, - stroke: function(d, i, pI) { - return _config[pI].data.strokeColor; - }, - 'stroke-width': function(d, i, pI) { - return _config[pI].data.strokeSize + 'px'; - }, - 'stroke-dasharray': function(d, i, pI) { - return dashArray[_config[pI].data.strokeDash]; - }, - opacity: function(d, i, pI) { - return _config[pI].data.opacity; - }, - display: function(d, i, pI) { - return typeof _config[pI].data.visible === 'undefined' || _config[pI].data.visible ? 'block' : 'none'; - } - }; - var geometryLayer = d3.select(this).selectAll('g.layer').data(data); - geometryLayer.enter().append('g').attr({ - 'class': 'layer' - }); - var geometry = geometryLayer.selectAll('path.mark').data(function(d, i) { - return d; - }); - geometry.enter().append('path').attr({ - 'class': 'mark' - }); - geometry.style(markStyle).each(generator[geometryConfig.geometryType]); - geometry.exit().remove(); - geometryLayer.exit().remove(); - function getPolarCoordinates(d, i) { - var r = geometryConfig.radialScale(d[1]); - var t = (geometryConfig.angularScale(d[0]) + geometryConfig.orientation) * Math.PI / 180; - return { - r: r, - t: t - }; - } - function convertToCartesian(polarCoordinates) { - var x = polarCoordinates.r * Math.cos(polarCoordinates.t); - var y = polarCoordinates.r * Math.sin(polarCoordinates.t); - return { - x: x, - y: y - }; - } - }); - } - exports.config = function(_x) { - if (!arguments.length) return config; - _x.forEach(function(d, i) { - if (!config[i]) config[i] = {}; - extendDeepAll(config[i], µ.PolyChart.defaultConfig()); - extendDeepAll(config[i], d); - }); - return this; - }; - exports.getColorScale = function() { - return colorScale; - }; - d3.rebind(exports, dispatch, 'on'); - return exports; -}; - -µ.PolyChart.defaultConfig = function() { - var config = { - data: { - name: 'geom1', - t: [ [ 1, 2, 3, 4 ] ], - r: [ [ 1, 2, 3, 4 ] ], - dotType: 'circle', - dotSize: 64, - dotVisible: false, - barWidth: 20, - color: '#ffa500', - strokeSize: 1, - strokeColor: 'silver', - strokeDash: 'solid', - opacity: 1, - index: 0, - visible: true, - visibleInLegend: true - }, - geometryConfig: { - geometry: 'LinePlot', - geometryType: 'arc', - direction: 'clockwise', - orientation: 0, - container: 'body', - radialScale: null, - angularScale: null, - colorScale: d3.scale.category20() - } - }; - return config; -}; - -µ.BarChart = function module() { - return µ.PolyChart(); -}; - -µ.BarChart.defaultConfig = function() { - var config = { - geometryConfig: { - geometryType: 'bar' - } - }; - return config; -}; - -µ.AreaChart = function module() { - return µ.PolyChart(); -}; - -µ.AreaChart.defaultConfig = function() { - var config = { - geometryConfig: { - geometryType: 'arc' - } - }; - return config; -}; - -µ.DotPlot = function module() { - return µ.PolyChart(); -}; - -µ.DotPlot.defaultConfig = function() { - var config = { - geometryConfig: { - geometryType: 'dot', - dotType: 'circle' - } - }; - return config; -}; - -µ.LinePlot = function module() { - return µ.PolyChart(); -}; - -µ.LinePlot.defaultConfig = function() { - var config = { - geometryConfig: { - geometryType: 'line' - } - }; - return config; -}; - -µ.Legend = function module() { - var config = µ.Legend.defaultConfig(); - var dispatch = d3.dispatch('hover'); - function exports() { - var legendConfig = config.legendConfig; - var flattenData = config.data.map(function(d, i) { - return [].concat(d).map(function(dB, iB) { - var element = extendDeepAll({}, legendConfig.elements[i]); - element.name = dB; - element.color = [].concat(legendConfig.elements[i].color)[iB]; - return element; - }); - }); - var data = d3.merge(flattenData); - data = data.filter(function(d, i) { - return legendConfig.elements[i] && (legendConfig.elements[i].visibleInLegend || typeof legendConfig.elements[i].visibleInLegend === 'undefined'); - }); - if (legendConfig.reverseOrder) data = data.reverse(); - var container = legendConfig.container; - if (typeof container == 'string' || container.nodeName) container = d3.select(container); - var colors = data.map(function(d, i) { - return d.color; - }); - var lineHeight = legendConfig.fontSize; - var isContinuous = legendConfig.isContinuous == null ? typeof data[0] === 'number' : legendConfig.isContinuous; - var height = isContinuous ? legendConfig.height : lineHeight * data.length; - var legendContainerGroup = container.classed('legend-group', true); - var svg = legendContainerGroup.selectAll('svg').data([ 0 ]); - var svgEnter = svg.enter().append('svg').attr({ - width: 300, - height: height + lineHeight, - xmlns: 'http://www.w3.org/2000/svg', - 'xmlns:xlink': 'http://www.w3.org/1999/xlink', - version: '1.1' - }); - svgEnter.append('g').classed('legend-axis', true); - svgEnter.append('g').classed('legend-marks', true); - var dataNumbered = d3.range(data.length); - var colorScale = d3.scale[isContinuous ? 'linear' : 'ordinal']().domain(dataNumbered).range(colors); - var dataScale = d3.scale[isContinuous ? 'linear' : 'ordinal']().domain(dataNumbered)[isContinuous ? 'range' : 'rangePoints']([ 0, height ]); - var shapeGenerator = function(_type, _size) { - var squareSize = _size * 3; - if (_type === 'line') { - return 'M' + [ [ -_size / 2, -_size / 12 ], [ _size / 2, -_size / 12 ], [ _size / 2, _size / 12 ], [ -_size / 2, _size / 12 ] ] + 'Z'; - } else if (d3.svg.symbolTypes.indexOf(_type) != -1) return d3.svg.symbol().type(_type).size(squareSize)(); else return d3.svg.symbol().type('square').size(squareSize)(); - }; - if (isContinuous) { - var gradient = svg.select('.legend-marks').append('defs').append('linearGradient').attr({ - id: 'grad1', - x1: '0%', - y1: '0%', - x2: '0%', - y2: '100%' - }).selectAll('stop').data(colors); - gradient.enter().append('stop'); - gradient.attr({ - offset: function(d, i) { - return i / (colors.length - 1) * 100 + '%'; - } - }).style({ - 'stop-color': function(d, i) { - return d; - } - }); - svg.append('rect').classed('legend-mark', true).attr({ - height: legendConfig.height, - width: legendConfig.colorBandWidth, - fill: 'url(#grad1)' - }); - } else { - var legendElement = svg.select('.legend-marks').selectAll('path.legend-mark').data(data); - legendElement.enter().append('path').classed('legend-mark', true); - legendElement.attr({ - transform: function(d, i) { - return 'translate(' + [ lineHeight / 2, dataScale(i) + lineHeight / 2 ] + ')'; - }, - d: function(d, i) { - var symbolType = d.symbol; - return shapeGenerator(symbolType, lineHeight); - }, - fill: function(d, i) { - return colorScale(i); - } - }); - legendElement.exit().remove(); - } - var legendAxis = d3.svg.axis().scale(dataScale).orient('right'); - var axis = svg.select('g.legend-axis').attr({ - transform: 'translate(' + [ isContinuous ? legendConfig.colorBandWidth : lineHeight, lineHeight / 2 ] + ')' - }).call(legendAxis); - axis.selectAll('.domain').style({ - fill: 'none', - stroke: 'none' - }); - axis.selectAll('line').style({ - fill: 'none', - stroke: isContinuous ? legendConfig.textColor : 'none' - }); - axis.selectAll('text').style({ - fill: legendConfig.textColor, - 'font-size': legendConfig.fontSize - }).text(function(d, i) { - return data[i].name; - }); - return exports; - } - exports.config = function(_x) { - if (!arguments.length) return config; - extendDeepAll(config, _x); - return this; - }; - d3.rebind(exports, dispatch, 'on'); - return exports; -}; - -µ.Legend.defaultConfig = function(d, i) { - var config = { - data: [ 'a', 'b', 'c' ], - legendConfig: { - elements: [ { - symbol: 'line', - color: 'red' - }, { - symbol: 'square', - color: 'yellow' - }, { - symbol: 'diamond', - color: 'limegreen' - } ], - height: 150, - colorBandWidth: 30, - fontSize: 12, - container: 'body', - isContinuous: null, - textColor: 'grey', - reverseOrder: false - } - }; - return config; -}; - -µ.tooltipPanel = function() { - var tooltipEl, tooltipTextEl, backgroundEl; - var config = { - container: null, - hasTick: false, - fontSize: 12, - color: 'white', - padding: 5 - }; - var id = 'tooltip-' + µ.tooltipPanel.uid++; - var tickSize = 10; - var exports = function() { - tooltipEl = config.container.selectAll('g.' + id).data([ 0 ]); - var tooltipEnter = tooltipEl.enter().append('g').classed(id, true).style({ - 'pointer-events': 'none', - display: 'none' - }); - backgroundEl = tooltipEnter.append('path').style({ - fill: 'white', - 'fill-opacity': .9 - }).attr({ - d: 'M0 0' - }); - tooltipTextEl = tooltipEnter.append('text').attr({ - dx: config.padding + tickSize, - dy: +config.fontSize * .3 - }); - return exports; - }; - exports.text = function(_text) { - var l = d3.hsl(config.color).l; - var strokeColor = l >= .5 ? '#aaa' : 'white'; - var fillColor = l >= .5 ? 'black' : 'white'; - var text = _text || ''; - tooltipTextEl.style({ - fill: fillColor, - 'font-size': config.fontSize + 'px' - }).text(text); - var padding = config.padding; - var bbox = tooltipTextEl.node().getBBox(); - var boxStyle = { - fill: config.color, - stroke: strokeColor, - 'stroke-width': '2px' - }; - var backGroundW = bbox.width + padding * 2 + tickSize; - var backGroundH = bbox.height + padding * 2; - backgroundEl.attr({ - d: 'M' + [ [ tickSize, -backGroundH / 2 ], [ tickSize, -backGroundH / 4 ], [ config.hasTick ? 0 : tickSize, 0 ], [ tickSize, backGroundH / 4 ], [ tickSize, backGroundH / 2 ], [ backGroundW, backGroundH / 2 ], [ backGroundW, -backGroundH / 2 ] ].join('L') + 'Z' - }).style(boxStyle); - tooltipEl.attr({ - transform: 'translate(' + [ tickSize, -backGroundH / 2 + padding * 2 ] + ')' - }); - tooltipEl.style({ - display: 'block' - }); - return exports; - }; - exports.move = function(_pos) { - if (!tooltipEl) return; - tooltipEl.attr({ - transform: 'translate(' + [ _pos[0], _pos[1] ] + ')' - }).style({ - display: 'block' - }); - return exports; - }; - exports.hide = function() { - if (!tooltipEl) return; - tooltipEl.style({ - display: 'none' - }); - return exports; - }; - exports.show = function() { - if (!tooltipEl) return; - tooltipEl.style({ - display: 'block' - }); - return exports; - }; - exports.config = function(_x) { - extendDeepAll(config, _x); - return exports; - }; - return exports; -}; - -µ.tooltipPanel.uid = 1; - -µ.adapter = {}; - -µ.adapter.plotly = function module() { - var exports = {}; - exports.convert = function(_inputConfig, reverse) { - var outputConfig = {}; - if (_inputConfig.data) { - outputConfig.data = _inputConfig.data.map(function(d, i) { - var r = extendDeepAll({}, d); - var toTranslate = [ - [ r, [ 'marker', 'color' ], [ 'color' ] ], - [ r, [ 'marker', 'opacity' ], [ 'opacity' ] ], - [ r, [ 'marker', 'line', 'color' ], [ 'strokeColor' ] ], - [ r, [ 'marker', 'line', 'dash' ], [ 'strokeDash' ] ], - [ r, [ 'marker', 'line', 'width' ], [ 'strokeSize' ] ], - [ r, [ 'marker', 'symbol' ], [ 'dotType' ] ], - [ r, [ 'marker', 'size' ], [ 'dotSize' ] ], - [ r, [ 'marker', 'barWidth' ], [ 'barWidth' ] ], - [ r, [ 'line', 'interpolation' ], [ 'lineInterpolation' ] ], - [ r, [ 'showlegend' ], [ 'visibleInLegend' ] ] - ]; - toTranslate.forEach(function(d, i) { - µ.util.translator.apply(null, d.concat(reverse)); - }); - - if (!reverse) delete r.marker; - if (reverse) delete r.groupId; - if (!reverse) { - if (r.type === 'scatter') { - if (r.mode === 'lines') r.geometry = 'LinePlot'; else if (r.mode === 'markers') r.geometry = 'DotPlot'; else if (r.mode === 'lines+markers') { - r.geometry = 'LinePlot'; - r.dotVisible = true; - } - } else if (r.type === 'area') r.geometry = 'AreaChart'; else if (r.type === 'bar') r.geometry = 'BarChart'; - delete r.mode; - delete r.type; - } else { - if (r.geometry === 'LinePlot') { - r.type = 'scatter'; - if (r.dotVisible === true) { - delete r.dotVisible; - r.mode = 'lines+markers'; - } else r.mode = 'lines'; - } else if (r.geometry === 'DotPlot') { - r.type = 'scatter'; - r.mode = 'markers'; - } else if (r.geometry === 'AreaChart') r.type = 'area'; else if (r.geometry === 'BarChart') r.type = 'bar'; - delete r.geometry; - } - return r; - }); - if (!reverse && _inputConfig.layout && _inputConfig.layout.barmode === 'stack') { - var duplicates = µ.util.duplicates(outputConfig.data.map(function(d, i) { - return d.geometry; - })); - outputConfig.data.forEach(function(d, i) { - var idx = duplicates.indexOf(d.geometry); - if (idx != -1) outputConfig.data[i].groupId = idx; - }); - } - } - if (_inputConfig.layout) { - var r = extendDeepAll({}, _inputConfig.layout); - var toTranslate = [ - [ r, [ 'plot_bgcolor' ], [ 'backgroundColor' ] ], - [ r, [ 'showlegend' ], [ 'showLegend' ] ], - [ r, [ 'radialaxis' ], [ 'radialAxis' ] ], - [ r, [ 'angularaxis' ], [ 'angularAxis' ] ], - [ r.angularaxis, [ 'showline' ], [ 'gridLinesVisible' ] ], - [ r.angularaxis, [ 'showticklabels' ], [ 'labelsVisible' ] ], - [ r.angularaxis, [ 'nticks' ], [ 'ticksCount' ] ], - [ r.angularaxis, [ 'tickorientation' ], [ 'tickOrientation' ] ], - [ r.angularaxis, [ 'ticksuffix' ], [ 'ticksSuffix' ] ], - [ r.angularaxis, [ 'range' ], [ 'domain' ] ], - [ r.angularaxis, [ 'endpadding' ], [ 'endPadding' ] ], - [ r.radialaxis, [ 'showline' ], [ 'gridLinesVisible' ] ], - [ r.radialaxis, [ 'tickorientation' ], [ 'tickOrientation' ] ], - [ r.radialaxis, [ 'ticksuffix' ], [ 'ticksSuffix' ] ], - [ r.radialaxis, [ 'range' ], [ 'domain' ] ], - [ r.angularAxis, [ 'showline' ], [ 'gridLinesVisible' ] ], - [ r.angularAxis, [ 'showticklabels' ], [ 'labelsVisible' ] ], - [ r.angularAxis, [ 'nticks' ], [ 'ticksCount' ] ], - [ r.angularAxis, [ 'tickorientation' ], [ 'tickOrientation' ] ], - [ r.angularAxis, [ 'ticksuffix' ], [ 'ticksSuffix' ] ], - [ r.angularAxis, [ 'range' ], [ 'domain' ] ], - [ r.angularAxis, [ 'endpadding' ], [ 'endPadding' ] ], - [ r.radialAxis, [ 'showline' ], [ 'gridLinesVisible' ] ], - [ r.radialAxis, [ 'tickorientation' ], [ 'tickOrientation' ] ], - [ r.radialAxis, [ 'ticksuffix' ], [ 'ticksSuffix' ] ], - [ r.radialAxis, [ 'range' ], [ 'domain' ] ], - [ r.font, [ 'outlinecolor' ], [ 'outlineColor' ] ], - [ r.legend, [ 'traceorder' ], [ 'reverseOrder' ] ], - [ r, [ 'labeloffset' ], [ 'labelOffset' ] ], - [ r, [ 'defaultcolorrange' ], [ 'defaultColorRange' ] ] - ]; - toTranslate.forEach(function(d, i) { - µ.util.translator.apply(null, d.concat(reverse)); - }); - - if (!reverse) { - if (r.angularAxis && typeof r.angularAxis.ticklen !== 'undefined') r.tickLength = r.angularAxis.ticklen; - if (r.angularAxis && typeof r.angularAxis.tickcolor !== 'undefined') r.tickColor = r.angularAxis.tickcolor; - } else { - if (typeof r.tickLength !== 'undefined') { - r.angularaxis.ticklen = r.tickLength; - delete r.tickLength; - } - if (r.tickColor) { - r.angularaxis.tickcolor = r.tickColor; - delete r.tickColor; - } - } - if (r.legend && typeof r.legend.reverseOrder != 'boolean') { - r.legend.reverseOrder = r.legend.reverseOrder != 'normal'; - } - if (r.legend && typeof r.legend.traceorder == 'boolean') { - r.legend.traceorder = r.legend.traceorder ? 'reversed' : 'normal'; - delete r.legend.reverseOrder; - } - if (r.margin && typeof r.margin.t != 'undefined') { - var source = [ 't', 'r', 'b', 'l', 'pad' ]; - var target = [ 'top', 'right', 'bottom', 'left', 'pad' ]; - var margin = {}; - d3.entries(r.margin).forEach(function(dB, iB) { - margin[target[source.indexOf(dB.key)]] = dB.value; - }); - r.margin = margin; - } - if (reverse) { - delete r.needsEndSpacing; - delete r.minorTickColor; - delete r.minorTicks; - delete r.angularaxis.ticksCount; - delete r.angularaxis.ticksCount; - delete r.angularaxis.ticksStep; - delete r.angularaxis.rewriteTicks; - delete r.angularaxis.nticks; - delete r.radialaxis.ticksCount; - delete r.radialaxis.ticksCount; - delete r.radialaxis.ticksStep; - delete r.radialaxis.rewriteTicks; - delete r.radialaxis.nticks; - } - outputConfig.layout = r; - } - return outputConfig; - }; - return exports; -}; - -},{"../../../constants/alignment":207,"../../../lib":233,"d3":21}],318:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - -/* eslint-disable new-cap */ - -'use strict'; - -var d3 = _dereq_('d3'); -var Lib = _dereq_('../../../lib'); -var Color = _dereq_('../../../components/color'); - -var micropolar = _dereq_('./micropolar'); -var UndoManager = _dereq_('./undo_manager'); -var extendDeepAll = Lib.extendDeepAll; - -var manager = module.exports = {}; - -manager.framework = function(_gd) { - var config, previousConfigClone, plot, convertedInput, container; - var undoManager = new UndoManager(); - - function exports(_inputConfig, _container) { - if(_container) container = _container; - d3.select(d3.select(container).node().parentNode).selectAll('.svg-container>*:not(.chart-root)').remove(); - - config = (!config) ? - _inputConfig : - extendDeepAll(config, _inputConfig); - - if(!plot) plot = micropolar.Axis(); - convertedInput = micropolar.adapter.plotly().convert(config); - plot.config(convertedInput).render(container); - _gd.data = config.data; - _gd.layout = config.layout; - manager.fillLayout(_gd); - return config; - } - exports.isPolar = true; - exports.svg = function() { return plot.svg(); }; - exports.getConfig = function() { return config; }; - exports.getLiveConfig = function() { - return micropolar.adapter.plotly().convert(plot.getLiveConfig(), true); - }; - exports.getLiveScales = function() { return {t: plot.angularScale(), r: plot.radialScale()}; }; - exports.setUndoPoint = function() { - var that = this; - var configClone = micropolar.util.cloneJson(config); - (function(_configClone, _previousConfigClone) { - undoManager.add({ - undo: function() { - if(_previousConfigClone) that(_previousConfigClone); - }, - redo: function() { - that(_configClone); - } - }); - })(configClone, previousConfigClone); - previousConfigClone = micropolar.util.cloneJson(configClone); - }; - exports.undo = function() { undoManager.undo(); }; - exports.redo = function() { undoManager.redo(); }; - return exports; -}; - -manager.fillLayout = function(_gd) { - var container = d3.select(_gd).selectAll('.plot-container'); - var paperDiv = container.selectAll('.svg-container'); - var paper = _gd.framework && _gd.framework.svg && _gd.framework.svg(); - var dflts = { - width: 800, - height: 600, - paper_bgcolor: Color.background, - _container: container, - _paperdiv: paperDiv, - _paper: paper - }; - - _gd._fullLayout = extendDeepAll(dflts, _gd.layout); -}; - -},{"../../../components/color":105,"../../../lib":233,"./micropolar":317,"./undo_manager":319,"d3":21}],319:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - -'use strict'; - -// Modified from https://github.com/ArthurClemens/Javascript-Undo-Manager -// Copyright (c) 2010-2013 Arthur Clemens, arthur@visiblearea.com -module.exports = function UndoManager() { - var undoCommands = []; - var index = -1; - var isExecuting = false; - var callback; - - function execute(command, action) { - if(!command) return this; - - isExecuting = true; - command[action](); - isExecuting = false; - - return this; - } - - return { - add: function(command) { - if(isExecuting) return this; - undoCommands.splice(index + 1, undoCommands.length - index); - undoCommands.push(command); - index = undoCommands.length - 1; - return this; - }, - setCallback: function(callbackFunc) { callback = callbackFunc; }, - undo: function() { - var command = undoCommands[index]; - if(!command) return this; - execute(command, 'undo'); - index -= 1; - if(callback) callback(command.undo); - return this; - }, - redo: function() { - var command = undoCommands[index + 1]; - if(!command) return this; - execute(command, 'redo'); - index += 1; - if(callback) callback(command.redo); - return this; - }, - clear: function() { - undoCommands = []; - index = -1; - }, - hasUndo: function() { return index !== -1; }, - hasRedo: function() { return index < (undoCommands.length - 1); }, - getCommands: function() { return undoCommands; }, - getPreviousCommand: function() { return undoCommands[index - 1]; }, - getIndex: function() { return index; } - }; -}; - -},{}],320:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../components/color":155,"../constants/numerical":265,"../lib":285,"../plot_api/plot_schema":319,"../plot_api/plot_template":320,"../plots/get_data":361,"../registry":373,"./animation_attributes":325,"./attributes":327,"./cartesian/axis_ids":334,"./cartesian/handle_outline":341,"./command":357,"./font_attributes":359,"./frame_attributes":360,"./layout_attributes":364,"@plotly/d3":20,"d3-time-format":29,"fast-isnumeric":31}],367:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../lib'); @@ -76719,29 +83150,31 @@ module.exports = function handleSubplotDefaults(layoutIn, layoutOut, fullData, o } }; -},{"../lib":233,"../plot_api/plot_template":268,"./domain":306}],321:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285,"../plot_api/plot_template":320,"./domain":358}],368:[function(_dereq_,module,exports){ 'use strict'; -var FORMAT_LINK = _dereq_('../constants/docs').FORMAT_LINK; -var DATE_FORMAT_LINK = _dereq_('../constants/docs').DATE_FORMAT_LINK; +var docs = _dereq_('../constants/docs'); +var FORMAT_LINK = docs.FORMAT_LINK; +var DATE_FORMAT_LINK = docs.DATE_FORMAT_LINK; -var templateFormatStringDescription = [ - 'Variables are inserted using %{variable}, for example "y: %{y}".', - 'Numbers are formatted using d3-format\'s syntax %{variable:d3-format}, for example "Price: %{y:$.2f}".', - FORMAT_LINK, - 'for details on the formatting syntax.', - 'Dates are formatted using d3-time-format\'s syntax %{variable|d3-time-format}, for example "Day: %{2019-01-01|%A}".', - DATE_FORMAT_LINK, - 'for details on the date formatting syntax.' -].join(' '); +function templateFormatStringDescription(opts) { + var supportOther = opts && opts.supportOther; + + return [ + 'Variables are inserted using %{variable},', + 'for example "y: %{y}"' + ( + supportOther ? + ' as well as %{xother}, {%_xother}, {%_xother_}, {%xother_}. When showing info for several points, *xother* will be added to those with different x positions from the first point. An underscore before or after *(x|y)other* will add a space on that side, only when this field is shown.' : + '.' + ), + 'Numbers are formatted using d3-format\'s syntax %{variable:d3-format}, for example "Price: %{y:$.2f}".', + FORMAT_LINK, + 'for details on the formatting syntax.', + 'Dates are formatted using d3-time-format\'s syntax %{variable|d3-time-format}, for example "Day: %{2019-01-01|%A}".', + DATE_FORMAT_LINK, + 'for details on the date formatting syntax.' + ].join(' '); +} function describeVariables(extra) { var descPart = extra.description ? ' ' + extra.description : ''; @@ -76769,10 +83202,8 @@ exports.hovertemplateAttrs = function(opts, extra) { var hovertemplate = { valType: 'string', - dflt: '', editType: opts.editType || 'none', - }; if(opts.arrayOk !== false) { @@ -76790,10 +83221,8 @@ exports.texttemplateAttrs = function(opts, extra) { var texttemplate = { valType: 'string', - dflt: '', editType: opts.editType || 'calc', - }; if(opts.arrayOk !== false) { @@ -76802,16 +83231,7 @@ exports.texttemplateAttrs = function(opts, extra) { return texttemplate; }; -},{"../constants/docs":209}],322:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../constants/docs":262}],369:[function(_dereq_,module,exports){ 'use strict'; var Ternary = _dereq_('./ternary'); @@ -76831,10 +83251,8 @@ exports.idRegex = exports.attrRegex = counterRegex(TERNARY); var attributes = exports.attributes = {}; attributes[attr] = { valType: 'subplotid', - dflt: 'ternary', editType: 'calc', - }; exports.layoutAttributes = _dereq_('./layout_attributes'); @@ -76886,15 +83304,7 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) } }; -},{"../../lib":233,"../../plots/get_data":309,"./layout_attributes":323,"./layout_defaults":324,"./ternary":325}],323:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/get_data":361,"./layout_attributes":370,"./layout_defaults":371,"./ternary":372}],370:[function(_dereq_,module,exports){ 'use strict'; var colorAttrs = _dereq_('../../components/color/attributes'); @@ -76948,9 +83358,7 @@ var ternaryAxesAttrs = { min: { valType: 'number', dflt: 0, - min: 0, - }, _deprecated: { title: axesAttrs._deprecated.title, @@ -76963,16 +83371,12 @@ var attrs = module.exports = overrideAll({ bgcolor: { valType: 'color', - dflt: colorAttrs.background, - }, sum: { valType: 'number', - dflt: 1, min: 0, - }, aaxis: ternaryAxesAttrs, baxis: ternaryAxesAttrs, @@ -76982,27 +83386,15 @@ var attrs = module.exports = overrideAll({ // set uirevisions outside of `overrideAll` so we can get `editType: none` attrs.uirevision = { valType: 'any', - editType: 'none', - }; attrs.aaxis.uirevision = attrs.baxis.uirevision = attrs.caxis.uirevision = { valType: 'any', - editType: 'none', - }; -},{"../../components/color/attributes":104,"../../lib/extend":227,"../../plot_api/edit_types":261,"../cartesian/layout_attributes":293,"../domain":306}],324:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color/attributes":154,"../../lib/extend":279,"../../plot_api/edit_types":313,"../cartesian/layout_attributes":345,"../domain":358}],371:[function(_dereq_,module,exports){ 'use strict'; var Color = _dereq_('../../components/color'); @@ -77087,7 +83479,7 @@ function handleAxisDefaults(containerIn, containerOut, options, ternaryLayoutOut Lib.coerceFont(coerce, 'title.font', { family: options.font.family, - size: Math.round(options.font.size * 1.2), + size: Lib.bigFont(options.font.size), color: dfltFontColor }); @@ -77126,19 +83518,10 @@ function handleAxisDefaults(containerIn, containerOut, options, ternaryLayoutOut coerce('layer'); } -},{"../../components/color":105,"../../lib":233,"../../plot_api/plot_template":268,"../cartesian/line_grid_defaults":295,"../cartesian/tick_label_defaults":300,"../cartesian/tick_mark_defaults":301,"../cartesian/tick_value_defaults":302,"../subplot_defaults":320,"./layout_attributes":323}],325:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/color":155,"../../lib":285,"../../plot_api/plot_template":320,"../cartesian/line_grid_defaults":347,"../cartesian/tick_label_defaults":352,"../cartesian/tick_mark_defaults":353,"../cartesian/tick_value_defaults":354,"../subplot_defaults":367,"./layout_attributes":370}],372:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var tinycolor = _dereq_('tinycolor2'); var Registry = _dereq_('../../registry'); @@ -77907,15 +84290,7 @@ function removeZoombox(gd) { .remove(); } -},{"../../components/color":105,"../../components/dragelement":124,"../../components/dragelement/helpers":123,"../../components/drawing":127,"../../components/fx":145,"../../components/titles":200,"../../lib":233,"../../lib/extend":227,"../../registry":326,"../cartesian/axes":279,"../cartesian/constants":285,"../cartesian/select":298,"../cartesian/set_convert":299,"../plots":313,"d3":21,"tinycolor2":88}],326:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../components/dragelement":174,"../../components/dragelement/helpers":173,"../../components/drawing":177,"../../components/fx":195,"../../components/titles":253,"../../lib":285,"../../lib/extend":279,"../../registry":373,"../cartesian/axes":331,"../cartesian/constants":337,"../cartesian/select":350,"../cartesian/set_convert":351,"../plots":366,"@plotly/d3":20,"tinycolor2":119}],373:[function(_dereq_,module,exports){ 'use strict'; var Loggers = _dereq_('./lib/loggers'); @@ -78054,7 +84429,7 @@ exports.traceIs = function(traceType, category) { var _module = exports.modules[traceType]; if(!_module) { - if(traceType && traceType !== 'area') { + if(traceType) { Loggers.log('Unrecognized trace type ' + traceType + '.'); } @@ -78373,15 +84748,7 @@ function getTraceType(traceType) { return traceType; } -},{"./lib/dom":225,"./lib/extend":227,"./lib/is_plain_object":234,"./lib/loggers":237,"./lib/noop":242,"./lib/push_unique":247,"./plots/attributes":275,"./plots/layout_attributes":311}],327:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"./lib/dom":277,"./lib/extend":279,"./lib/is_plain_object":286,"./lib/loggers":289,"./lib/noop":294,"./lib/push_unique":299,"./plots/attributes":327,"./plots/layout_attributes":364}],374:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../registry'); @@ -78434,11 +84801,6 @@ function keyIsAxis(keyName) { module.exports = function clonePlot(graphObj, options) { - // Polar plot compatibility - if(graphObj.framework && graphObj.framework.isPolar) { - graphObj = graphObj.framework.getConfig(); - } - var i; var oldData = graphObj.data; var oldLayout = graphObj.layout; @@ -78546,15 +84908,7 @@ module.exports = function clonePlot(graphObj, options) { return plotTile; }; -},{"../lib":233,"../registry":326}],328:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285,"../registry":373}],375:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../lib'); @@ -78618,15 +84972,7 @@ function downloadImage(gd, opts) { module.exports = downloadImage; -},{"../lib":233,"../plot_api/to_image":271,"./filesaver":329,"./helpers":330}],329:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285,"../plot_api/to_image":323,"./filesaver":376,"./helpers":377}],376:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../lib'); @@ -78652,10 +84998,6 @@ function fileSaver(url, name, format) { var blob; var objectUrl; - if(Lib.isIE9orBelow()) { - reject(new Error('IE < 10 unsupported')); - } - // Safari doesn't allow downloading of blob urls if(Lib.isSafari()) { var prefix = format === 'svg' ? ',' : ';base64,'; @@ -78698,15 +85040,7 @@ function fileSaver(url, name, format) { module.exports = fileSaver; -},{"../lib":233,"./helpers":330}],330:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285,"./helpers":377}],377:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../registry'); @@ -78723,13 +85057,7 @@ exports.getDelay = function(fullLayout) { exports.getRedrawFunc = function(gd) { return function() { - var fullLayout = gd._fullLayout || {}; - var hasPolar = fullLayout._has && fullLayout._has('polar'); - var hasLegacyPolar = !hasPolar && gd.data && gd.data[0] && gd.data[0].r; - - if(!hasLegacyPolar) { - Registry.getComponentMethod('colorbar', 'draw')(gd); - } + Registry.getComponentMethod('colorbar', 'draw')(gd); }; }; @@ -78781,16 +85109,7 @@ exports.IMAGE_URL_PREFIX = /^data:image\/\w+;base64,/; exports.MSG_IE_BAD_FORMAT = 'Sorry IE does not support downloading from canvas. Try {format:\'svg\'} instead.'; -},{"../registry":326}],331:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../registry":373}],378:[function(_dereq_,module,exports){ 'use strict'; var helpers = _dereq_('./helpers'); @@ -78807,15 +85126,7 @@ var Snapshot = { module.exports = Snapshot; -},{"./cloneplot":327,"./download":328,"./helpers":330,"./svgtoimg":332,"./toimage":333,"./tosvg":334}],332:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"./cloneplot":374,"./download":375,"./helpers":377,"./svgtoimg":379,"./toimage":380,"./tosvg":381}],379:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../lib'); @@ -78855,7 +85166,7 @@ function svgToImg(opts) { var img = new Image(); var svgBlob, url; - if(format === 'svg' || Lib.isIE9orBelow() || Lib.isSafari()) { + if(format === 'svg' || Lib.isSafari()) { url = helpers.encodeSVG(svg); } else { svgBlob = helpers.createBlob(svg, 'svg'); @@ -78934,15 +85245,7 @@ function svgToImg(opts) { module.exports = svgToImg; -},{"../lib":233,"./helpers":330,"events":17}],333:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../lib":285,"./helpers":377,"events":27}],380:[function(_dereq_,module,exports){ 'use strict'; var EventEmitter = _dereq_('events').EventEmitter; @@ -78998,7 +85301,7 @@ function toImage(gd, opts) { var redrawFunc = helpers.getRedrawFunc(clonedGd); - Registry.call('plot', clonedGd, clone.data, clone.layout, clone.config) + Registry.call('_doPlot', clonedGd, clone.data, clone.layout, clone.config) .then(redrawFunc) .then(wait) .catch(function(err) { @@ -79011,19 +85314,10 @@ function toImage(gd, opts) { module.exports = toImage; -},{"../lib":233,"../registry":326,"./cloneplot":327,"./helpers":330,"./svgtoimg":332,"./tosvg":334,"events":17}],334:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../lib":285,"../registry":373,"./cloneplot":374,"./helpers":377,"./svgtoimg":379,"./tosvg":381,"events":27}],381:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Lib = _dereq_('../lib'); var Drawing = _dereq_('../components/drawing'); @@ -79056,7 +85350,7 @@ module.exports = function toSVG(gd, format, scale) { var toppaper = fullLayout._toppaper; var width = fullLayout.width; var height = fullLayout.height; - var i; + var i, k; // make background color a rect in the svg, then revert after scraping // all other alterations have been dealt with by properly preparing the svg @@ -79129,28 +85423,31 @@ module.exports = function toSVG(gd, format, scale) { } }); - + var queryParts = []; if(fullLayout._gradientUrlQueryParts) { - var queryParts = []; - for(var k in fullLayout._gradientUrlQueryParts) queryParts.push(k); + for(k in fullLayout._gradientUrlQueryParts) queryParts.push(k); + } - if(queryParts.length) { - svg.selectAll(queryParts.join(',')).each(function() { - var pt = d3.select(this); + if(fullLayout._patternUrlQueryParts) { + for(k in fullLayout._patternUrlQueryParts) queryParts.push(k); + } - // similar to font family styles above, - // we must remove " after the SVG DOM has been serialized - var fill = this.style.fill; - if(fill && fill.indexOf('url(') !== -1) { - pt.style('fill', fill.replace(DOUBLEQUOTE_REGEX, DUMMY_SUB)); - } + if(queryParts.length) { + svg.selectAll(queryParts.join(',')).each(function() { + var pt = d3.select(this); - var stroke = this.style.stroke; - if(stroke && stroke.indexOf('url(') !== -1) { - pt.style('stroke', stroke.replace(DOUBLEQUOTE_REGEX, DUMMY_SUB)); - } - }); - } + // similar to font family styles above, + // we must remove " after the SVG DOM has been serialized + var fill = this.style.fill; + if(fill && fill.indexOf('url(') !== -1) { + pt.style('fill', fill.replace(DOUBLEQUOTE_REGEX, DUMMY_SUB)); + } + + var stroke = this.style.stroke; + if(stroke && stroke.indexOf('url(') !== -1) { + pt.style('stroke', stroke.replace(DOUBLEQUOTE_REGEX, DUMMY_SUB)); + } + }); } if(format === 'pdf' || format === 'eps') { @@ -79178,6 +85475,8 @@ module.exports = function toSVG(gd, format, scale) { // Fix quotations around font strings and gradient URLs s = s.replace(DUMMY_REGEX, '\''); + // Do we need this process now that IE9 and IE10 are not supported? + // IE is very strict, so we will need to clean // svg with the following regex // yes this is messy, but do not know a better way @@ -79200,15 +85499,7 @@ module.exports = function toSVG(gd, format, scale) { return s; }; -},{"../components/color":105,"../components/drawing":127,"../constants/xmlns_namespaces":213,"../lib":233,"d3":21}],335:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../components/color":155,"../components/drawing":177,"../constants/xmlns_namespaces":266,"../lib":285,"@plotly/d3":20}],382:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -79233,23 +85524,17 @@ module.exports = function arraysToCalcdata(cd, trace) { } }; -},{"../../lib":233}],336:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],383:[function(_dereq_,module,exports){ 'use strict'; var scatterAttrs = _dereq_('../scatter/attributes'); +var axisHoverFormat = _dereq_('../../plots/hoverformat_attributes'); var hovertemplateAttrs = _dereq_('../../plots/template_attributes').hovertemplateAttrs; var texttemplateAttrs = _dereq_('../../plots/template_attributes').texttemplateAttrs; var colorScaleAttrs = _dereq_('../../components/colorscale/attributes'); var fontAttrs = _dereq_('../../plots/font_attributes'); var constants = _dereq_('./constants'); +var pattern = _dereq_('../../components/drawing/attributes').pattern; var extendFlat = _dereq_('../../lib/extend').extendFlat; @@ -79257,7 +85542,6 @@ var textFontAttrs = fontAttrs({ editType: 'calc', arrayOk: true, colorEditType: 'style', - }); var scatterMarkerAttrs = scatterAttrs.marker; @@ -79281,10 +85565,9 @@ var marker = extendFlat({ dflt: 1, min: 0, max: 1, - editType: 'style', - - } + }, + pattern: pattern }); module.exports = { @@ -79301,6 +85584,8 @@ module.exports = { yperiod0: scatterAttrs.yperiod0, xperiodalignment: scatterAttrs.xperiodalignment, yperiodalignment: scatterAttrs.yperiodalignment, + xhoverformat: axisHoverFormat('x'), + yhoverformat: axisHoverFormat('y'), text: scatterAttrs.text, texttemplate: texttemplateAttrs({editType: 'plot'}, { @@ -79313,80 +85598,62 @@ module.exports = { textposition: { valType: 'enumerated', - values: ['inside', 'outside', 'auto', 'none'], - dflt: 'none', + dflt: 'auto', arrayOk: true, editType: 'calc', - }, insidetextanchor: { valType: 'enumerated', values: ['end', 'middle', 'start'], dflt: 'end', - editType: 'plot', - }, textangle: { valType: 'angle', dflt: 'auto', - editType: 'plot', - }, textfont: extendFlat({}, textFontAttrs, { - }), insidetextfont: extendFlat({}, textFontAttrs, { - }), outsidetextfont: extendFlat({}, textFontAttrs, { - }), constraintext: { valType: 'enumerated', values: ['inside', 'outside', 'both', 'none'], - dflt: 'both', editType: 'calc', - }, cliponaxis: extendFlat({}, scatterAttrs.cliponaxis, { - }), orientation: { valType: 'enumerated', - values: ['v', 'h'], editType: 'calc+clearAxisTypes', - }, base: { valType: 'any', dflt: null, arrayOk: true, - editType: 'calc', - }, offset: { valType: 'number', dflt: null, arrayOk: true, - editType: 'calc', - }, width: { @@ -79394,26 +85661,20 @@ module.exports = { dflt: null, min: 0, arrayOk: true, - editType: 'calc', - }, marker: marker, offsetgroup: { valType: 'string', - dflt: '', editType: 'calc', - }, alignmentgroup: { valType: 'string', - dflt: '', editType: 'calc', - }, selected: { @@ -79435,29 +85696,16 @@ module.exports = { editType: 'style' }, - r: scatterAttrs.r, - t: scatterAttrs.t, - _deprecated: { bardir: { valType: 'enumerated', - editType: 'calc', values: ['v', 'h'], - } } }; -},{"../../components/colorscale/attributes":112,"../../lib/extend":227,"../../plots/font_attributes":307,"../../plots/template_attributes":321,"../scatter/attributes":447,"./constants":338}],337:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale/attributes":162,"../../components/drawing/attributes":176,"../../lib/extend":279,"../../plots/font_attributes":359,"../../plots/hoverformat_attributes":363,"../../plots/template_attributes":368,"../scatter/attributes":494,"./constants":385}],384:[function(_dereq_,module,exports){ 'use strict'; var Axes = _dereq_('../../plots/cartesian/axes'); @@ -79528,16 +85776,7 @@ module.exports = function calc(gd, trace) { return cd; }; -},{"../../components/colorscale/calc":113,"../../components/colorscale/helpers":116,"../../plots/cartesian/align_period":276,"../../plots/cartesian/axes":279,"../scatter/calc_selection":449,"./arrays_to_calcdata":335}],338:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/colorscale/calc":163,"../../components/colorscale/helpers":166,"../../plots/cartesian/align_period":328,"../../plots/cartesian/axes":331,"../scatter/calc_selection":496,"./arrays_to_calcdata":382}],385:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -79550,15 +85789,7 @@ module.exports = { eventDataKeys: ['value', 'label'] }; -},{}],339:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],386:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -80330,15 +86561,7 @@ module.exports = { setGroupPositions: setGroupPositions }; -},{"../../constants/numerical":212,"../../lib":233,"../../plots/cartesian/axes":279,"../../plots/cartesian/constraints":286,"../../registry":326,"./sieve.js":349,"fast-isnumeric":23}],340:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/numerical":265,"../../lib":285,"../../plots/cartesian/axes":331,"../../plots/cartesian/constraints":338,"../../registry":373,"./sieve.js":396,"fast-isnumeric":31}],387:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -80365,6 +86588,8 @@ function supplyDefaults(traceIn, traceOut, defaultColor, layout) { } handlePeriodDefaults(traceIn, traceOut, layout, coerce); + coerce('xhoverformat'); + coerce('yhoverformat'); coerce('orientation', (traceOut.x && !traceOut.y) ? 'h' : 'v'); coerce('base'); @@ -80515,15 +86740,7 @@ module.exports = { handleText: handleText }; -},{"../../components/color":105,"../../lib":233,"../../plots/cartesian/constraints":286,"../../registry":326,"../scatter/period_defaults":467,"../scatter/xy_defaults":474,"./attributes":336,"./style_defaults":351}],341:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../lib":285,"../../plots/cartesian/constraints":338,"../../registry":373,"../scatter/period_defaults":514,"../scatter/xy_defaults":521,"./attributes":383,"./style_defaults":398}],388:[function(_dereq_,module,exports){ 'use strict'; module.exports = function eventData(out, pt, trace) { @@ -80544,15 +86761,7 @@ module.exports = function eventData(out, pt, trace) { return out; }; -},{}],342:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],389:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -80622,16 +86831,7 @@ exports.getLineWidth = function(trace, di) { return w; }; -},{"../../lib":233,"fast-isnumeric":23,"tinycolor2":88}],343:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"fast-isnumeric":31,"tinycolor2":119}],390:[function(_dereq_,module,exports){ 'use strict'; var Fx = _dereq_('../../components/fx'); @@ -80643,8 +86843,8 @@ var getLineWidth = _dereq_('./helpers').getLineWidth; var hoverLabelText = _dereq_('../../plots/cartesian/axes').hoverLabelText; var BADNUM = _dereq_('../../constants/numerical').BADNUM; -function hoverPoints(pointData, xval, yval, hovermode) { - var barPointData = hoverOnBars(pointData, xval, yval, hovermode); +function hoverPoints(pointData, xval, yval, hovermode, opts) { + var barPointData = hoverOnBars(pointData, xval, yval, hovermode, opts); if(barPointData) { var cd = barPointData.cd; @@ -80658,20 +86858,46 @@ function hoverPoints(pointData, xval, yval, hovermode) { } } -function hoverOnBars(pointData, xval, yval, hovermode) { +function hoverOnBars(pointData, xval, yval, hovermode, opts) { var cd = pointData.cd; var trace = cd[0].trace; var t = cd[0].t; var isClosest = (hovermode === 'closest'); var isWaterfall = (trace.type === 'waterfall'); var maxHoverDistance = pointData.maxHoverDistance; + var maxSpikeDistance = pointData.maxSpikeDistance; var posVal, sizeVal, posLetter, sizeLetter, dx, dy, pRangeCalc; - function thisBarMinPos(di) { return di[posLetter] - di.w / 2; } - function thisBarMaxPos(di) { return di[posLetter] + di.w / 2; } + if(trace.orientation === 'h') { + posVal = yval; + sizeVal = xval; + posLetter = 'y'; + sizeLetter = 'x'; + dx = sizeFn; + dy = positionFn; + } else { + posVal = xval; + sizeVal = yval; + posLetter = 'x'; + sizeLetter = 'y'; + dy = sizeFn; + dx = positionFn; + } - var minPos = isClosest ? + var period = trace[posLetter + 'period']; + + function thisBarMinPos(di) { return thisBarExtPos(di, -1); } + function thisBarMaxPos(di) { return thisBarExtPos(di, 1); } + + function thisBarExtPos(di, sgn) { + if(period) { + return di.p + sgn * Math.abs(di.p - di.orig_p); + } + return di[posLetter] + sgn * di.w / 2; + } + + var minPos = isClosest || period ? thisBarMinPos : function(di) { /* @@ -80689,60 +86915,62 @@ function hoverOnBars(pointData, xval, yval, hovermode) { return Math.min(thisBarMinPos(di), di.p - t.bardelta / 2); }; - var maxPos = isClosest ? + var maxPos = isClosest || period ? thisBarMaxPos : function(di) { return Math.max(thisBarMaxPos(di), di.p + t.bardelta / 2); }; - function _positionFn(_minPos, _maxPos) { + function inbox(_minPos, _maxPos, maxDistance) { + if(opts.finiteRange) maxDistance = 0; + // add a little to the pseudo-distance for wider bars, so that like scatter, // if you are over two overlapping bars, the narrower one wins. return Fx.inbox(_minPos - posVal, _maxPos - posVal, - maxHoverDistance + Math.min(1, Math.abs(_maxPos - _minPos) / pRangeCalc) - 1); + maxDistance + Math.min(1, Math.abs(_maxPos - _minPos) / pRangeCalc) - 1); } function positionFn(di) { - return _positionFn(minPos(di), maxPos(di)); + return inbox(minPos(di), maxPos(di), maxHoverDistance); } function thisBarPositionFn(di) { - return _positionFn(thisBarMinPos(di), thisBarMaxPos(di)); + return inbox(thisBarMinPos(di), thisBarMaxPos(di), maxSpikeDistance); + } + + function getSize(di) { + var s = di[sizeLetter]; + + if(isWaterfall) { + var rawS = Math.abs(di.rawS) || 0; + if(sizeVal > 0) { + s += rawS; + } else if(sizeVal < 0) { + s -= rawS; + } + } + + return s; } function sizeFn(di) { var v = sizeVal; var b = di.b; - var s = di[sizeLetter]; - - if(isWaterfall) { - var rawS = Math.abs(di.rawS) || 0; - if(v > 0) { - s += rawS; - } else if(v < 0) { - s -= rawS; - } - } + var s = getSize(di); // add a gradient so hovering near the end of a // bar makes it a little closer match return Fx.inbox(b - v, s - v, maxHoverDistance + (s - v) / (s - b) - 1); } - if(trace.orientation === 'h') { - posVal = yval; - sizeVal = xval; - posLetter = 'y'; - sizeLetter = 'x'; - dx = sizeFn; - dy = positionFn; - } else { - posVal = xval; - sizeVal = yval; - posLetter = 'x'; - sizeLetter = 'y'; - dy = sizeFn; - dx = positionFn; + function thisBarSizeFn(di) { + var v = sizeVal; + var b = di.b; + var s = getSize(di); + + // add a gradient so hovering near the end of a + // bar makes it a little closer match + return Fx.inbox(b - v, s - v, maxSpikeDistance + (s - v) / (s - b) - 1); } var pa = pointData[posLetter + 'a']; @@ -80787,12 +87015,12 @@ function hoverOnBars(pointData, xval, yval, hovermode) { var hasPeriod = di.orig_p !== undefined; pointData[posLetter + 'LabelVal'] = hasPeriod ? di.orig_p : di.p; - pointData.labelLabel = hoverLabelText(pa, pointData[posLetter + 'LabelVal']); - pointData.valueLabel = hoverLabelText(sa, pointData[sizeLetter + 'LabelVal']); - pointData.baseLabel = hoverLabelText(sa, di.b); + pointData.labelLabel = hoverLabelText(pa, pointData[posLetter + 'LabelVal'], trace[posLetter + 'hoverformat']); + pointData.valueLabel = hoverLabelText(sa, pointData[sizeLetter + 'LabelVal'], trace[sizeLetter + 'hoverformat']); + pointData.baseLabel = hoverLabelText(sa, di.b, trace[sizeLetter + 'hoverformat']); // spikelines always want "closest" distance regardless of hovermode - pointData.spikeDistance = (sizeFn(di) + thisBarPositionFn(di)) / 2 - maxHoverDistance; + pointData.spikeDistance = (thisBarSizeFn(di) + thisBarPositionFn(di)) / 2; // they also want to point to the data value, regardless of where the label goes // in case of bars shifted within groups pointData[posLetter + 'Spike'] = pa.c2p(di.p, true); @@ -80818,15 +87046,7 @@ module.exports = { getTraceColor: getTraceColor }; -},{"../../components/color":105,"../../components/fx":145,"../../constants/numerical":212,"../../lib":233,"../../plots/cartesian/axes":279,"../../registry":326,"./helpers":342}],344:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../components/fx":195,"../../constants/numerical":265,"../../lib":285,"../../plots/cartesian/axes":331,"../../registry":373,"./helpers":389}],391:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -80852,19 +87072,10 @@ module.exports = { categories: ['bar-like', 'cartesian', 'svg', 'bar', 'oriented', 'errorBarsOK', 'showLegend', 'zoomScale'], animatable: true, meta: { - } }; -},{"../../plots/cartesian":292,"../scatter/marker_colorbar":465,"./arrays_to_calcdata":335,"./attributes":336,"./calc":337,"./cross_trace_calc":339,"./defaults":340,"./event_data":341,"./hover":343,"./layout_attributes":345,"./layout_defaults":346,"./plot":347,"./select":348,"./style":350}],345:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian":344,"../scatter/marker_colorbar":512,"./arrays_to_calcdata":382,"./attributes":383,"./calc":384,"./cross_trace_calc":386,"./defaults":387,"./event_data":388,"./hover":390,"./layout_attributes":392,"./layout_defaults":393,"./plot":394,"./select":395,"./style":397}],392:[function(_dereq_,module,exports){ 'use strict'; @@ -80873,46 +87084,30 @@ module.exports = { valType: 'enumerated', values: ['stack', 'group', 'overlay', 'relative'], dflt: 'group', - editType: 'calc', - }, barnorm: { valType: 'enumerated', values: ['', 'fraction', 'percent'], dflt: '', - editType: 'calc', - }, bargap: { valType: 'number', min: 0, max: 1, - editType: 'calc', - }, bargroupgap: { valType: 'number', min: 0, max: 1, dflt: 0, - editType: 'calc', - } }; -},{}],346:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],393:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -80964,18 +87159,10 @@ module.exports = function(layoutIn, layoutOut, fullData) { coerce('bargroupgap'); }; -},{"../../lib":233,"../../plots/cartesian/axes":279,"../../registry":326,"./layout_attributes":345}],347:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/cartesian/axes":331,"../../registry":373,"./layout_attributes":392}],394:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var isNumeric = _dereq_('fast-isnumeric'); var Lib = _dereq_('../../lib'); @@ -81622,11 +87809,11 @@ function calcTexttemplate(fullLayout, cd, index, xa, ya) { } function formatLabel(u) { - return tickText(pAxis, u, true).text; + return tickText(pAxis, pAxis.c2l(u), true).text; } function formatNumber(v) { - return tickText(vAxis, +v, true).text; + return tickText(vAxis, vAxis.c2l(v), true).text; } var cdi = cd[index]; @@ -81749,15 +87936,7 @@ module.exports = { toMoveInsideBar: toMoveInsideBar }; -},{"../../components/color":105,"../../components/drawing":127,"../../components/fx/helpers":141,"../../lib":233,"../../lib/svg_text_utils":255,"../../plots/cartesian/axes":279,"../../registry":326,"./attributes":336,"./constants":338,"./helpers":342,"./style":350,"./uniform_text":352,"d3":21,"fast-isnumeric":23}],348:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../components/drawing":177,"../../components/fx/helpers":191,"../../lib":285,"../../lib/svg_text_utils":307,"../../plots/cartesian/axes":331,"../../registry":373,"./attributes":383,"./constants":385,"./helpers":389,"./style":397,"./uniform_text":399,"@plotly/d3":20,"fast-isnumeric":31}],395:[function(_dereq_,module,exports){ 'use strict'; module.exports = function selectPoints(searchInfo, selectionTester) { @@ -81813,15 +87992,7 @@ function getCentroid(d, xa, ya, isHorizontal, isFunnel) { } } -},{}],349:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],396:[function(_dereq_,module,exports){ 'use strict'; module.exports = Sieve; @@ -81927,18 +88098,10 @@ Sieve.prototype.getLabel = function getLabel(position, value) { return prefix + label; }; -},{"../../constants/numerical":212,"../../lib":233}],350:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/numerical":265,"../../lib":285}],397:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Color = _dereq_('../../components/color'); var Drawing = _dereq_('../../components/drawing'); var Lib = _dereq_('../../lib'); @@ -82096,7 +88259,7 @@ function getBarColor(cd, trace) { if(trace.type === 'waterfall') { return trace[cd.dir].marker.color; } - return cd.mc || trace.marker.color; + return cd.mcc || cd.mc || trace.marker.color; } module.exports = { @@ -82109,20 +88272,13 @@ module.exports = { resizeText: resizeText }; -},{"../../components/color":105,"../../components/drawing":127,"../../lib":233,"../../registry":326,"./attributes":336,"./helpers":342,"./uniform_text":352,"d3":21}],351:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../components/drawing":177,"../../lib":285,"../../registry":373,"./attributes":383,"./helpers":389,"./uniform_text":399,"@plotly/d3":20}],398:[function(_dereq_,module,exports){ 'use strict'; var Color = _dereq_('../../components/color'); var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); +var coercePattern = _dereq_('../../lib').coercePattern; module.exports = function handleStyleDefaults(traceIn, traceOut, coerce, defaultColor, layout) { coerce('marker.color', defaultColor); @@ -82143,22 +88299,16 @@ module.exports = function handleStyleDefaults(traceIn, traceOut, coerce, default coerce('marker.line.width'); coerce('marker.opacity'); + coercePattern(coerce, 'marker.pattern'); + coerce('selected.marker.color'); coerce('unselected.marker.color'); }; -},{"../../components/color":105,"../../components/colorscale/defaults":115,"../../components/colorscale/helpers":116}],352:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../components/colorscale/defaults":165,"../../components/colorscale/helpers":166,"../../lib":285}],399:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Lib = _dereq_('../../lib'); function resizeText(gd, gTrace, traceType) { @@ -82233,20 +88383,13 @@ module.exports = { resizeText: resizeText }; -},{"../../lib":233,"d3":21}],353:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"@plotly/d3":20}],400:[function(_dereq_,module,exports){ 'use strict'; var scatterAttrs = _dereq_('../scatter/attributes'); var barAttrs = _dereq_('../bar/attributes'); var colorAttrs = _dereq_('../../components/color/attributes'); +var axisHoverFormat = _dereq_('../../plots/hoverformat_attributes'); var hovertemplateAttrs = _dereq_('../../plots/template_attributes').hovertemplateAttrs; var extendFlat = _dereq_('../../lib/extend').extendFlat; @@ -82257,37 +88400,27 @@ module.exports = { y: { valType: 'data_array', editType: 'calc+clearAxisTypes', - }, x: { valType: 'data_array', editType: 'calc+clearAxisTypes', - }, x0: { valType: 'any', - editType: 'calc+clearAxisTypes', - }, y0: { valType: 'any', - editType: 'calc+clearAxisTypes', - }, dx: { valType: 'number', - editType: 'calc', - }, dy: { valType: 'number', - editType: 'calc', - }, xperiod: scatterAttrs.xperiod, @@ -82296,65 +88429,49 @@ module.exports = { yperiod0: scatterAttrs.yperiod0, xperiodalignment: scatterAttrs.xperiodalignment, yperiodalignment: scatterAttrs.yperiodalignment, + xhoverformat: axisHoverFormat('x'), + yhoverformat: axisHoverFormat('y'), name: { valType: 'string', - editType: 'calc+clearAxisTypes', - }, q1: { valType: 'data_array', - editType: 'calc+clearAxisTypes', - }, median: { valType: 'data_array', - editType: 'calc+clearAxisTypes', - }, q3: { valType: 'data_array', - editType: 'calc+clearAxisTypes', - }, lowerfence: { valType: 'data_array', - editType: 'calc', - }, upperfence: { valType: 'data_array', - editType: 'calc', - }, notched: { valType: 'boolean', - editType: 'calc', - }, notchwidth: { valType: 'number', min: 0, max: 0.5, dflt: 0.25, - editType: 'calc', - }, notchspan: { valType: 'data_array', - editType: 'calc', - }, // TODO @@ -82365,80 +88482,60 @@ module.exports = { boxpoints: { valType: 'enumerated', values: ['all', 'outliers', 'suspectedoutliers', false], - editType: 'calc', - }, jitter: { valType: 'number', min: 0, max: 1, - editType: 'calc', - }, pointpos: { valType: 'number', min: -2, max: 2, - editType: 'calc', - }, boxmean: { valType: 'enumerated', values: [true, 'sd', false], - editType: 'calc', - }, mean: { valType: 'data_array', - editType: 'calc', - }, sd: { valType: 'data_array', - editType: 'calc', - }, orientation: { valType: 'enumerated', values: ['v', 'h'], - editType: 'calc+clearAxisTypes', - }, quartilemethod: { valType: 'enumerated', values: ['linear', 'exclusive', 'inclusive'], dflt: 'linear', - editType: 'calc', - }, width: { valType: 'number', min: 0, - dflt: 0, editType: 'calc', - }, marker: { outliercolor: { valType: 'color', dflt: 'rgba(0, 0, 0, 0)', - editType: 'style', - }, symbol: extendFlat({}, scatterMarkerAttrs.symbol, {arrayOk: false, editType: 'plot'}), @@ -82457,17 +88554,13 @@ module.exports = { ), outliercolor: { valType: 'color', - editType: 'style', - }, outlierwidth: { valType: 'number', min: 0, dflt: 1, - editType: 'style', - }, editType: 'style' }, @@ -82477,17 +88570,13 @@ module.exports = { line: { color: { valType: 'color', - editType: 'style', - }, width: { valType: 'number', - min: 0, dflt: 2, editType: 'style', - }, editType: 'plot' }, @@ -82499,9 +88588,7 @@ module.exports = { min: 0, max: 1, dflt: 0.5, - editType: 'calc', - }, offsetgroup: barAttrs.offsetgroup, @@ -82517,34 +88604,21 @@ module.exports = { }, text: extendFlat({}, scatterAttrs.text, { - }), hovertext: extendFlat({}, scatterAttrs.hovertext, { - }), hovertemplate: hovertemplateAttrs({ - }), hoveron: { valType: 'flaglist', flags: ['boxes', 'points'], dflt: 'boxes+points', - editType: 'style', - } }; -},{"../../components/color/attributes":104,"../../lib/extend":227,"../../plots/template_attributes":321,"../bar/attributes":336,"../scatter/attributes":447}],354:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color/attributes":154,"../../lib/extend":279,"../../plots/hoverformat_attributes":363,"../../plots/template_attributes":368,"../bar/attributes":383,"../scatter/attributes":494}],401:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -82990,15 +89064,7 @@ function computeNotchSpan(cdi, N) { return 1.57 * (cdi.q3 - cdi.q1) / Math.sqrt(N); } -},{"../../constants/numerical":212,"../../lib":233,"../../plots/cartesian/align_period":276,"../../plots/cartesian/axes":279,"fast-isnumeric":23}],355:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/numerical":265,"../../lib":285,"../../plots/cartesian/align_period":328,"../../plots/cartesian/axes":331,"fast-isnumeric":31}],402:[function(_dereq_,module,exports){ 'use strict'; var Axes = _dereq_('../../plots/cartesian/axes'); @@ -83222,15 +89288,7 @@ module.exports = { setPositionOffset: setPositionOffset }; -},{"../../lib":233,"../../plots/cartesian/axes":279,"../../plots/cartesian/constraints":286}],356:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/cartesian/axes":331,"../../plots/cartesian/constraints":338}],403:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -83250,6 +89308,8 @@ function supplyDefaults(traceIn, traceOut, defaultColor, layout) { if(traceOut.visible === false) return; handlePeriodDefaults(traceIn, traceOut, layout, coerce); + coerce('xhoverformat'); + coerce('yhoverformat'); var hasPreCompStats = traceOut._hasPreCompStats; @@ -83538,15 +89598,7 @@ module.exports = { handlePointsDefaults: handlePointsDefaults }; -},{"../../components/color":105,"../../lib":233,"../../plots/cartesian/axis_autotype":280,"../../registry":326,"../bar/defaults":340,"../scatter/period_defaults":467,"./attributes":353}],357:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../lib":285,"../../plots/cartesian/axis_autotype":332,"../../registry":373,"../bar/defaults":387,"../scatter/period_defaults":514,"./attributes":400}],404:[function(_dereq_,module,exports){ 'use strict'; module.exports = function eventData(out, pt) { @@ -83563,15 +89615,7 @@ module.exports = function eventData(out, pt) { return out; }; -},{}],358:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],405:[function(_dereq_,module,exports){ 'use strict'; var Axes = _dereq_('../../plots/cartesian/axes'); @@ -83740,7 +89784,7 @@ function hoverOnBoxes(pointData, xval, yval, hovermode) { pointData2.attr = attr; pointData2[vLetter + '0'] = pointData2[vLetter + '1'] = valPx; pointData2[vLetter + 'LabelVal'] = val; - pointData2[vLetter + 'Label'] = (t.labels ? t.labels[attr] + ' ' : '') + Axes.hoverLabelText(vAxis, val); + pointData2[vLetter + 'Label'] = (t.labels ? t.labels[attr] + ' ' : '') + Axes.hoverLabelText(vAxis, val, trace[vLetter + 'hoverformat']); // Note: introduced to be able to distinguish a // clicked point from a box during click-to-select @@ -83850,15 +89894,7 @@ module.exports = { hoverOnPoints: hoverOnPoints }; -},{"../../components/color":105,"../../components/fx":145,"../../lib":233,"../../plots/cartesian/axes":279}],359:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../components/fx":195,"../../lib":285,"../../plots/cartesian/axes":331}],406:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -83881,19 +89917,10 @@ module.exports = { basePlotModule: _dereq_('../../plots/cartesian'), categories: ['cartesian', 'svg', 'symbols', 'oriented', 'box-violin', 'showLegend', 'boxLayout', 'zoomScale'], meta: { - } }; -},{"../../plots/cartesian":292,"./attributes":353,"./calc":354,"./cross_trace_calc":355,"./defaults":356,"./event_data":357,"./hover":358,"./layout_attributes":360,"./layout_defaults":361,"./plot":362,"./select":363,"./style":364}],360:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian":344,"./attributes":400,"./calc":401,"./cross_trace_calc":402,"./defaults":403,"./event_data":404,"./hover":405,"./layout_attributes":407,"./layout_defaults":408,"./plot":409,"./select":410,"./style":411}],407:[function(_dereq_,module,exports){ 'use strict'; @@ -83902,39 +89929,25 @@ module.exports = { valType: 'enumerated', values: ['group', 'overlay'], dflt: 'overlay', - editType: 'calc', - }, boxgap: { valType: 'number', min: 0, max: 1, dflt: 0.3, - editType: 'calc', - }, boxgroupgap: { valType: 'number', min: 0, max: 1, dflt: 0.3, - editType: 'calc', - } }; -},{}],361:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],408:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -83972,18 +89985,10 @@ module.exports = { _supply: _supply }; -},{"../../lib":233,"../../registry":326,"./layout_attributes":360}],362:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../registry":373,"./layout_attributes":407}],409:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Lib = _dereq_('../../lib'); var Drawing = _dereq_('../../components/drawing'); @@ -84322,15 +90327,7 @@ module.exports = { plotBoxMean: plotBoxMean }; -},{"../../components/drawing":127,"../../lib":233,"d3":21}],363:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/drawing":177,"../../lib":285,"@plotly/d3":20}],410:[function(_dereq_,module,exports){ 'use strict'; module.exports = function selectPoints(searchInfo, selectionTester) { @@ -84371,18 +90368,10 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{}],364:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],411:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Color = _dereq_('../../components/color'); var Drawing = _dereq_('../../components/drawing'); @@ -84445,19 +90434,12 @@ module.exports = { styleOnSelect: styleOnSelect }; -},{"../../components/color":105,"../../components/drawing":127,"d3":21}],365:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../components/drawing":177,"@plotly/d3":20}],412:[function(_dereq_,module,exports){ 'use strict'; var heatmapAttrs = _dereq_('../heatmap/attributes'); var scatterAttrs = _dereq_('../scatter/attributes'); +var axisHoverFormat = _dereq_('../../plots/hoverformat_attributes'); var colorScaleAttrs = _dereq_('../../components/colorscale/attributes'); var dash = _dereq_('../../components/drawing/attributes').dash; var fontAttrs = _dereq_('../../plots/font_attributes'); @@ -84492,39 +90474,34 @@ module.exports = extendFlat({ transpose: heatmapAttrs.transpose, xtype: heatmapAttrs.xtype, ytype: heatmapAttrs.ytype, - zhoverformat: heatmapAttrs.zhoverformat, + xhoverformat: axisHoverFormat('x'), + yhoverformat: axisHoverFormat('y'), + zhoverformat: axisHoverFormat('z', 1), hovertemplate: heatmapAttrs.hovertemplate, hoverongaps: heatmapAttrs.hoverongaps, connectgaps: extendFlat({}, heatmapAttrs.connectgaps, { - }), fillcolor: { valType: 'color', - editType: 'calc', - }, autocontour: { valType: 'boolean', dflt: true, - editType: 'calc', impliedEdits: { 'contours.start': undefined, 'contours.end': undefined, 'contours.size': undefined }, - }, ncontours: { valType: 'integer', dflt: 15, min: 1, - editType: 'calc', - }, contours: { @@ -84532,83 +90509,62 @@ module.exports = extendFlat({ valType: 'enumerated', values: ['levels', 'constraint'], dflt: 'levels', - editType: 'calc', - }, start: { valType: 'number', dflt: null, - editType: 'plot', impliedEdits: {'^autocontour': false}, - }, end: { valType: 'number', dflt: null, - editType: 'plot', impliedEdits: {'^autocontour': false}, - }, size: { valType: 'number', dflt: null, min: 0, - editType: 'plot', impliedEdits: {'^autocontour': false}, - }, coloring: { valType: 'enumerated', values: ['fill', 'heatmap', 'lines', 'none'], dflt: 'fill', - editType: 'calc', - }, showlines: { valType: 'boolean', dflt: true, - editType: 'plot', - }, showlabels: { valType: 'boolean', dflt: false, - editType: 'plot', - }, labelfont: fontAttrs({ editType: 'plot', colorEditType: 'style', - }), labelformat: { valType: 'string', dflt: '', - editType: 'plot', - }, operation: { valType: 'enumerated', values: [].concat(COMPARISON_OPS2).concat(INTERVAL_OPS), - dflt: '=', editType: 'calc', - }, value: { valType: 'any', dflt: 0, - editType: 'calc', - }, editType: 'calc', impliedEdits: {'autocontour': false} @@ -84617,18 +90573,14 @@ module.exports = extendFlat({ line: { color: extendFlat({}, scatterLineAttrs.color, { editType: 'style+colorbars', - }), width: { valType: 'number', min: 0, - editType: 'style+colorbars', - }, dash: dash, smoothing: extendFlat({}, scatterLineAttrs.smoothing, { - }), editType: 'plot' } @@ -84640,15 +90592,7 @@ module.exports = extendFlat({ }) ); -},{"../../components/colorscale/attributes":112,"../../components/drawing/attributes":126,"../../constants/docs":209,"../../constants/filter_ops":210,"../../lib/extend":227,"../../plots/font_attributes":307,"../heatmap/attributes":387,"../scatter/attributes":447}],366:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale/attributes":162,"../../components/drawing/attributes":176,"../../constants/docs":262,"../../constants/filter_ops":263,"../../lib/extend":279,"../../plots/font_attributes":359,"../../plots/hoverformat_attributes":363,"../heatmap/attributes":434,"../scatter/attributes":494}],413:[function(_dereq_,module,exports){ 'use strict'; var Colorscale = _dereq_('../../components/colorscale'); @@ -84693,15 +90637,7 @@ module.exports = function calc(gd, trace) { return cd; }; -},{"../../components/colorscale":117,"../heatmap/calc":388,"./end_plus":376,"./set_contours":384}],367:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale":167,"../heatmap/calc":435,"./end_plus":423,"./set_contours":431}],414:[function(_dereq_,module,exports){ 'use strict'; module.exports = function(pathinfo, contours) { @@ -84783,15 +90719,7 @@ module.exports = function(pathinfo, contours) { } }; -},{}],368:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],415:[function(_dereq_,module,exports){ 'use strict'; var Colorscale = _dereq_('../../components/colorscale'); @@ -84834,15 +90762,7 @@ module.exports = { calc: calc }; -},{"../../components/colorscale":117,"./end_plus":376,"./make_color_map":381}],369:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale":167,"./end_plus":423,"./make_color_map":428}],416:[function(_dereq_,module,exports){ 'use strict'; module.exports = { // some constants to help with marching squares algorithm @@ -84912,16 +90832,7 @@ module.exports = { } }; -},{}],370:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],417:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -85006,15 +90917,7 @@ function handleConstraintValueDefaults(coerce, contours) { } } -},{"../../components/color":105,"../../constants/filter_ops":210,"./label_defaults":380,"fast-isnumeric":23}],371:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../constants/filter_ops":263,"./label_defaults":427,"fast-isnumeric":31}],418:[function(_dereq_,module,exports){ 'use strict'; var filterOps = _dereq_('../../constants/filter_ops'); @@ -85085,15 +90988,7 @@ function makeInequalitySettings(operation) { }; } -},{"../../constants/filter_ops":210,"fast-isnumeric":23}],372:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/filter_ops":263,"fast-isnumeric":31}],419:[function(_dereq_,module,exports){ 'use strict'; module.exports = function handleContourDefaults(traceIn, traceOut, coerce, coerce2) { @@ -85114,15 +91009,7 @@ module.exports = function handleContourDefaults(traceIn, traceOut, coerce, coerc if(autoContour || !contourSize) coerce('ncontours'); }; -},{}],373:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],420:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -85214,15 +91101,7 @@ function copyPathinfo(pi) { }); } -},{"../../lib":233}],374:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],421:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -85251,6 +91130,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout } handlePeriodDefaults(traceIn, traceOut, layout, coerce); + coerce('xhoverformat'); + coerce('yhoverformat'); coerce('text'); coerce('hovertext'); @@ -85268,15 +91149,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout } }; -},{"../../lib":233,"../heatmap/xyz_defaults":401,"../scatter/period_defaults":467,"./attributes":365,"./constraint_defaults":370,"./contours_defaults":372,"./style_defaults":386}],375:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../heatmap/xyz_defaults":448,"../scatter/period_defaults":514,"./attributes":412,"./constraint_defaults":417,"./contours_defaults":419,"./style_defaults":433}],422:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -85332,16 +91205,7 @@ module.exports = function emptyPathinfo(contours, plotinfo, cd0) { return pathinfo; }; -},{"../../lib":233,"./constraint_mapping":371,"./end_plus":376}],376:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"./constraint_mapping":418,"./end_plus":423}],423:[function(_dereq_,module,exports){ 'use strict'; /* @@ -85352,15 +91216,7 @@ module.exports = function endPlus(contours) { return contours.end + contours.size / 1e6; }; -},{}],377:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],424:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -85646,24 +91502,18 @@ function getInterpPx(pi, loc, step) { } } -},{"../../lib":233,"./constants":369}],378:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"./constants":416}],425:[function(_dereq_,module,exports){ 'use strict'; var Color = _dereq_('../../components/color'); var heatmapHoverPoints = _dereq_('../heatmap/hover'); -module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLayer) { - var hoverData = heatmapHoverPoints(pointData, xval, yval, hovermode, hoverLayer, true); +module.exports = function hoverPoints(pointData, xval, yval, hovermode, opts) { + if(!opts) opts = {}; + opts.isContour = true; + + var hoverData = heatmapHoverPoints(pointData, xval, yval, hovermode, opts); if(hoverData) { hoverData.forEach(function(hoverPt) { @@ -85681,15 +91531,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay return hoverData; }; -},{"../../components/color":105,"../heatmap/hover":394}],379:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../heatmap/hover":441}],426:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -85706,20 +91548,10 @@ module.exports = { basePlotModule: _dereq_('../../plots/cartesian'), categories: ['cartesian', 'svg', '2dMap', 'contour', 'showLegend'], meta: { - } }; -},{"../../plots/cartesian":292,"./attributes":365,"./calc":366,"./colorbar":368,"./defaults":374,"./hover":378,"./plot":383,"./style":385}],380:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../plots/cartesian":344,"./attributes":412,"./calc":413,"./colorbar":415,"./defaults":421,"./hover":425,"./plot":430,"./style":432}],427:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -85740,18 +91572,10 @@ module.exports = function handleLabelDefaults(coerce, layout, lineColor, opts) { if(opts.hasHover !== false) coerce('zhoverformat'); }; -},{"../../lib":233}],381:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],428:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Colorscale = _dereq_('../../components/colorscale'); var endPlus = _dereq_('./end_plus'); @@ -85824,15 +91648,7 @@ module.exports = function makeColorMap(trace) { ); }; -},{"../../components/colorscale":117,"./end_plus":376,"d3":21}],382:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale":167,"./end_plus":423,"@plotly/d3":20}],429:[function(_dereq_,module,exports){ 'use strict'; var constants = _dereq_('./constants'); @@ -85916,19 +91732,10 @@ function getMarchingIndex(val, corners) { return (mi === 15) ? 0 : mi; } -},{"./constants":369}],383:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"./constants":416}],430:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Lib = _dereq_('../../lib'); var Drawing = _dereq_('../../components/drawing'); @@ -86607,15 +92414,7 @@ function makeClipMask(cd0) { return z; } -},{"../../components/colorscale":117,"../../components/drawing":127,"../../lib":233,"../../lib/svg_text_utils":255,"../../plots/cartesian/axes":279,"../../plots/cartesian/set_convert":299,"../heatmap/plot":398,"./close_boundaries":367,"./constants":369,"./convert_to_constraints":373,"./empty_pathinfo":375,"./find_all_paths":377,"./make_crossings":382,"d3":21}],384:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale":167,"../../components/drawing":177,"../../lib":285,"../../lib/svg_text_utils":307,"../../plots/cartesian/axes":331,"../../plots/cartesian/set_convert":351,"../heatmap/plot":445,"./close_boundaries":414,"./constants":416,"./convert_to_constraints":420,"./empty_pathinfo":422,"./find_all_paths":424,"./make_crossings":429,"@plotly/d3":20}],431:[function(_dereq_,module,exports){ 'use strict'; var Axes = _dereq_('../../plots/cartesian/axes'); @@ -86711,19 +92510,10 @@ function autoContours(start, end, ncontours) { return dummyAx; } -},{"../../lib":233,"../../plots/cartesian/axes":279}],385:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../plots/cartesian/axes":331}],432:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Drawing = _dereq_('../../components/drawing'); var heatmapStyle = _dereq_('../heatmap/style'); @@ -86792,16 +92582,7 @@ module.exports = function style(gd) { heatmapStyle(gd); }; -},{"../../components/drawing":127,"../heatmap/style":399,"./make_color_map":381,"d3":21}],386:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/drawing":177,"../heatmap/style":446,"./make_color_map":428,"@plotly/d3":20}],433:[function(_dereq_,module,exports){ 'use strict'; var colorscaleDefaults = _dereq_('../../components/colorscale/defaults'); @@ -86837,22 +92618,14 @@ module.exports = function handleStyleDefaults(traceIn, traceOut, coerce, layout, handleLabelDefaults(coerce, layout, lineColor, opts); }; -},{"../../components/colorscale/defaults":115,"./label_defaults":380}],387:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale/defaults":165,"./label_defaults":427}],434:[function(_dereq_,module,exports){ 'use strict'; var scatterAttrs = _dereq_('../scatter/attributes'); var baseAttrs = _dereq_('../../plots/attributes'); +var axisHoverFormat = _dereq_('../../plots/hoverformat_attributes'); var hovertemplateAttrs = _dereq_('../../plots/template_attributes').hovertemplateAttrs; var colorScaleAttrs = _dereq_('../../components/colorscale/attributes'); -var FORMAT_LINK = _dereq_('../../constants/docs').FORMAT_LINK; var extendFlat = _dereq_('../../lib/extend').extendFlat; @@ -86860,7 +92633,6 @@ module.exports = extendFlat({ z: { valType: 'data_array', editType: 'calc', - }, x: extendFlat({}, scatterAttrs.x, {impliedEdits: {xtype: 'array'}}), x0: extendFlat({}, scatterAttrs.x0, {impliedEdits: {xtype: 'scaled'}}), @@ -86879,78 +92651,57 @@ module.exports = extendFlat({ text: { valType: 'data_array', editType: 'calc', - }, hovertext: { valType: 'data_array', editType: 'calc', - }, transpose: { valType: 'boolean', dflt: false, - editType: 'calc', - }, xtype: { valType: 'enumerated', values: ['array', 'scaled'], - editType: 'calc+clearAxisTypes', - }, ytype: { valType: 'enumerated', values: ['array', 'scaled'], - editType: 'calc+clearAxisTypes', - }, zsmooth: { valType: 'enumerated', values: ['fast', 'best', false], dflt: false, - editType: 'calc', - }, hoverongaps: { valType: 'boolean', dflt: true, - editType: 'none', - }, connectgaps: { valType: 'boolean', - editType: 'calc', - }, xgap: { valType: 'number', dflt: 0, min: 0, - editType: 'plot', - }, ygap: { valType: 'number', dflt: 0, min: 0, - editType: 'plot', - - }, - zhoverformat: { - valType: 'string', - dflt: '', - - editType: 'none', - }, + xhoverformat: axisHoverFormat('x'), + yhoverformat: axisHoverFormat('y'), + zhoverformat: axisHoverFormat('z', 1), + hovertemplate: hovertemplateAttrs(), showlegend: extendFlat({}, baseAttrs.showlegend, {dflt: false}) }, { @@ -86959,15 +92710,7 @@ module.exports = extendFlat({ colorScaleAttrs('', {cLetter: 'z', autoColorDflt: false}) ); -},{"../../components/colorscale/attributes":112,"../../constants/docs":209,"../../lib/extend":227,"../../plots/attributes":275,"../../plots/template_attributes":321,"../scatter/attributes":447}],388:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale/attributes":162,"../../lib/extend":279,"../../plots/attributes":327,"../../plots/hoverformat_attributes":363,"../../plots/template_attributes":368,"../scatter/attributes":494}],435:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -87168,15 +92911,7 @@ function dropZonBreaks(x, y, z) { return newZ; } -},{"../../components/colorscale/calc":113,"../../constants/numerical":212,"../../lib":233,"../../plots/cartesian/align_period":276,"../../plots/cartesian/axes":279,"../../registry":326,"../histogram2d/calc":416,"./clean_2d_array":389,"./convert_column_xyz":391,"./find_empties":393,"./interp2d":396,"./make_bound_array":397}],389:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale/calc":163,"../../constants/numerical":265,"../../lib":285,"../../plots/cartesian/align_period":328,"../../plots/cartesian/axes":331,"../../registry":373,"../histogram2d/calc":463,"./clean_2d_array":436,"./convert_column_xyz":438,"./find_empties":440,"./interp2d":443,"./make_bound_array":444}],436:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -87245,15 +92980,7 @@ module.exports = function clean2dArray(zOld, trace, xa, ya) { return zNew; }; -},{"../../constants/numerical":212,"../../lib":233,"fast-isnumeric":23}],390:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/numerical":265,"../../lib":285,"fast-isnumeric":31}],437:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -87261,16 +92988,7 @@ module.exports = { max: 'zmax' }; -},{}],391:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],438:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -87351,16 +93069,7 @@ module.exports = function convertColumnData(trace, ax1, ax2, var1Name, var2Name, trace._after2before = after2before; }; -},{"../../constants/numerical":212,"../../lib":233,"../../plots/cartesian/align_period":276}],392:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../constants/numerical":265,"../../lib":285,"../../plots/cartesian/align_period":328}],439:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -87384,6 +93093,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout } handlePeriodDefaults(traceIn, traceOut, layout, coerce); + coerce('xhoverformat'); + coerce('yhoverformat'); coerce('text'); coerce('hovertext'); @@ -87397,15 +93108,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: '', cLetter: 'z'}); }; -},{"../../components/colorscale/defaults":115,"../../lib":233,"../scatter/period_defaults":467,"./attributes":387,"./style_defaults":400,"./xyz_defaults":401}],393:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale/defaults":165,"../../lib":285,"../scatter/period_defaults":514,"./attributes":434,"./style_defaults":447,"./xyz_defaults":448}],440:[function(_dereq_,module,exports){ 'use strict'; var maxRowLength = _dereq_('../../lib').maxRowLength; @@ -87502,15 +93205,7 @@ module.exports = function findEmpties(z) { return empties.sort(function(a, b) { return b[2] - a[2]; }); }; -},{"../../lib":233}],394:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],441:[function(_dereq_,module,exports){ 'use strict'; var Fx = _dereq_('../../components/fx'); @@ -87518,7 +93213,10 @@ var Lib = _dereq_('../../lib'); var Axes = _dereq_('../../plots/cartesian/axes'); var extractOpts = _dereq_('../../components/colorscale').extractOpts; -module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLayer, contour) { +module.exports = function hoverPoints(pointData, xval, yval, hovermode, opts) { + if(!opts) opts = {}; + var isContour = opts.isContour; + var cd0 = pointData.cd[0]; var trace = cd0.trace; var xa = pointData.xa; @@ -87551,7 +93249,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay Fx.inbox(yval - y[0], yval - y[y.length - 1], 0) > 0) { return; } else { - if(contour) { + if(isContour) { var i2; x2 = [2 * x[0] - x[1]]; @@ -87576,7 +93274,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay var y1 = ya.c2p(y[ny + 1]); var _x, _y; - if(contour) { + if(isContour) { _x = cd0.orig_x || x; _y = cd0.orig_y || y; @@ -87640,15 +93338,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay })]; }; -},{"../../components/colorscale":117,"../../components/fx":145,"../../lib":233,"../../plots/cartesian/axes":279}],395:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale":167,"../../components/fx":195,"../../lib":285,"../../plots/cartesian/axes":331}],442:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -87665,19 +93355,10 @@ module.exports = { basePlotModule: _dereq_('../../plots/cartesian'), categories: ['cartesian', 'svg', '2dMap', 'showLegend'], meta: { - } }; -},{"../../plots/cartesian":292,"./attributes":387,"./calc":388,"./colorbar":390,"./defaults":392,"./hover":394,"./plot":398,"./style":399}],396:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian":344,"./attributes":434,"./calc":435,"./colorbar":437,"./defaults":439,"./hover":441,"./plot":445,"./style":446}],443:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -87802,15 +93483,7 @@ function iterateInterp2d(z, emptyPoints, overshoot) { return maxFractionalChange; } -},{"../../lib":233}],397:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],444:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -87890,19 +93563,10 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks, return arrayOut; }; -},{"../../lib":233,"../../registry":326}],398:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../registry":373}],445:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var tinycolor = _dereq_('tinycolor2'); var Registry = _dereq_('../../registry'); @@ -88295,19 +93959,10 @@ function putColor(pixels, pxIndex, c) { pixels[pxIndex + 3] = Math.round(c[3] * 255); } -},{"../../components/colorscale":117,"../../constants/xmlns_namespaces":213,"../../lib":233,"../../registry":326,"d3":21,"tinycolor2":88}],399:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/colorscale":167,"../../constants/xmlns_namespaces":266,"../../lib":285,"../../registry":373,"@plotly/d3":20,"tinycolor2":119}],446:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); module.exports = function style(gd) { d3.select(gd).selectAll('.hm image') @@ -88316,16 +93971,7 @@ module.exports = function style(gd) { }); }; -},{"d3":21}],400:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"@plotly/d3":20}],447:[function(_dereq_,module,exports){ 'use strict'; module.exports = function handleStyleDefaults(traceIn, traceOut, coerce) { @@ -88339,15 +93985,7 @@ module.exports = function handleStyleDefaults(traceIn, traceOut, coerce) { coerce('zhoverformat'); }; -},{}],401:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],448:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -88386,10 +94024,7 @@ module.exports = function handleXYZDefaults(traceIn, traceOut, coerce, layout, x traceOut._length = null; } - if( - traceIn.type === 'heatmapgl' || - traceIn.type === 'contourgl' - ) return true; // skip calendars until we handle them in those traces + if(traceIn.type === 'heatmapgl') return true; // skip calendars until we handle them in those traces var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults'); handleCalendarDefaults(traceIn, traceOut, [xName, yName], layout); @@ -88441,18 +94076,11 @@ function isValidZ(z) { return (allRowsAreArrays && oneRowIsFilled && hasOneNumber); } -},{"../../lib":233,"../../registry":326,"fast-isnumeric":23}],402:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../registry":373,"fast-isnumeric":31}],449:[function(_dereq_,module,exports){ 'use strict'; var barAttrs = _dereq_('../bar/attributes'); +var axisHoverFormat = _dereq_('../../plots/hoverformat_attributes'); var hovertemplateAttrs = _dereq_('../../plots/template_attributes').hovertemplateAttrs; var makeBinAttrs = _dereq_('./bin_attributes'); var constants = _dereq_('./constants'); @@ -88462,64 +94090,53 @@ module.exports = { x: { valType: 'data_array', editType: 'calc+clearAxisTypes', - }, y: { valType: 'data_array', editType: 'calc+clearAxisTypes', - }, + xhoverformat: axisHoverFormat('x'), + yhoverformat: axisHoverFormat('y'), + text: extendFlat({}, barAttrs.text, { - }), hovertext: extendFlat({}, barAttrs.hovertext, { - }), orientation: barAttrs.orientation, histfunc: { valType: 'enumerated', values: ['count', 'sum', 'avg', 'min', 'max'], - dflt: 'count', editType: 'calc', - }, histnorm: { valType: 'enumerated', values: ['', 'percent', 'probability', 'density', 'probability density'], dflt: '', - editType: 'calc', - }, cumulative: { enabled: { valType: 'boolean', dflt: false, - editType: 'calc', - }, direction: { valType: 'enumerated', values: ['increasing', 'decreasing'], dflt: 'increasing', - editType: 'calc', - }, currentbin: { valType: 'enumerated', values: ['include', 'exclude', 'half'], dflt: 'include', - editType: 'calc', - }, editType: 'calc' }, @@ -88527,9 +94144,7 @@ module.exports = { valType: 'integer', min: 0, dflt: 0, - editType: 'calc', - }, xbins: makeBinAttrs('x', true), @@ -88537,32 +94152,24 @@ module.exports = { valType: 'integer', min: 0, dflt: 0, - editType: 'calc', - }, ybins: makeBinAttrs('y', true), autobinx: { valType: 'boolean', dflt: null, - editType: 'calc', - }, autobiny: { valType: 'boolean', dflt: null, - editType: 'calc', - }, bingroup: { valType: 'string', - dflt: '', editType: 'calc', - }, hovertemplate: hovertemplateAttrs({}, { @@ -88582,16 +94189,7 @@ module.exports = { } }; -},{"../../lib/extend":227,"../../plots/template_attributes":321,"../bar/attributes":336,"./bin_attributes":404,"./constants":408}],403:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib/extend":279,"../../plots/hoverformat_attributes":363,"../../plots/template_attributes":368,"../bar/attributes":383,"./bin_attributes":451,"./constants":455}],450:[function(_dereq_,module,exports){ 'use strict'; @@ -88607,51 +94205,28 @@ module.exports = function doAvg(size, counts) { return total; }; -},{}],404:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],451:[function(_dereq_,module,exports){ 'use strict'; module.exports = function makeBinAttrs(axLetter, match) { return { start: { valType: 'any', // for date axes - editType: 'calc', - }, end: { valType: 'any', // for date axes - editType: 'calc', - }, size: { valType: 'any', // for date axes - editType: 'calc', - }, editType: 'calc' }; }; -},{}],405:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],452:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -88716,16 +94291,7 @@ module.exports = { } }; -},{"fast-isnumeric":23}],406:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"fast-isnumeric":31}],453:[function(_dereq_,module,exports){ 'use strict'; var numConstants = _dereq_('../../constants/numerical'); @@ -88892,15 +94458,7 @@ function dateParts(v, pa, calendar) { return parts; } -},{"../../constants/numerical":212,"../../plots/cartesian/axes":279}],407:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/numerical":265,"../../plots/cartesian/axes":331}],454:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -89471,31 +95029,14 @@ module.exports = { calcAllAutoBins: calcAllAutoBins }; -},{"../../lib":233,"../../plots/cartesian/axes":279,"../../registry":326,"../bar/arrays_to_calcdata":335,"./average":403,"./bin_functions":405,"./bin_label_vals":406,"./norm_functions":414,"fast-isnumeric":23}],408:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../plots/cartesian/axes":331,"../../registry":373,"../bar/arrays_to_calcdata":382,"./average":450,"./bin_functions":452,"./bin_label_vals":453,"./norm_functions":461,"fast-isnumeric":31}],455:[function(_dereq_,module,exports){ 'use strict'; module.exports = { eventDataKeys: ['binNumber'] }; -},{}],409:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],456:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -89764,15 +95305,7 @@ module.exports = function crossTraceDefaults(fullData, fullLayout) { } }; -},{"../../lib":233,"../../plots/cartesian/axis_ids":282,"../../plots/cartesian/constraints":286,"../../registry":326,"../bar/defaults":340}],410:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/cartesian/axis_ids":334,"../../plots/cartesian/constraints":338,"../../registry":373,"../bar/defaults":387}],457:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -89799,6 +95332,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout coerce('text'); coerce('hovertext'); coerce('hovertemplate'); + coerce('xhoverformat'); + coerce('yhoverformat'); var orientation = coerce('orientation', (y && !x) ? 'h' : 'v'); var sampleLetter = orientation === 'v' ? 'x' : 'y'; @@ -89838,15 +95373,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout errorBarsSupplyDefaults(traceIn, traceOut, lineColor || Color.defaultLine, {axis: 'x', inherit: 'y'}); }; -},{"../../components/color":105,"../../lib":233,"../../registry":326,"../bar/style_defaults":351,"./attributes":402}],411:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../lib":285,"../../registry":373,"../bar/style_defaults":398,"./attributes":449}],458:[function(_dereq_,module,exports){ 'use strict'; module.exports = function eventData(out, pt, trace, cd, pointNumber) { @@ -89887,23 +95414,14 @@ module.exports = function eventData(out, pt, trace, cd, pointNumber) { return out; }; -},{}],412:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],459:[function(_dereq_,module,exports){ 'use strict'; var barHover = _dereq_('../bar/hover').hoverPoints; var hoverLabelText = _dereq_('../../plots/cartesian/axes').hoverLabelText; -module.exports = function hoverPoints(pointData, xval, yval, hovermode) { - var pts = barHover(pointData, xval, yval, hovermode); +module.exports = function hoverPoints(pointData, xval, yval, hovermode, opts) { + var pts = barHover(pointData, xval, yval, hovermode, opts); if(!pts) return; @@ -89914,21 +95432,13 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { if(!trace.cumulative.enabled) { var posLetter = trace.orientation === 'h' ? 'y' : 'x'; - pointData[posLetter + 'Label'] = hoverLabelText(pointData[posLetter + 'a'], di.ph0, di.ph1); + pointData[posLetter + 'Label'] = hoverLabelText(pointData[posLetter + 'a'], [di.ph0, di.ph1], trace[posLetter + 'hoverformat']); } return pts; }; -},{"../../plots/cartesian/axes":279,"../bar/hover":343}],413:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian/axes":331,"../bar/hover":390}],460:[function(_dereq_,module,exports){ 'use strict'; /** @@ -89966,20 +95476,10 @@ module.exports = { basePlotModule: _dereq_('../../plots/cartesian'), categories: ['bar-like', 'cartesian', 'svg', 'bar', 'histogram', 'oriented', 'errorBarsOK', 'showLegend'], meta: { - } }; -},{"../../plots/cartesian":292,"../bar/cross_trace_calc":339,"../bar/layout_attributes":345,"../bar/layout_defaults":346,"../bar/plot":347,"../bar/select":348,"../bar/style":350,"../scatter/marker_colorbar":465,"./attributes":402,"./calc":407,"./cross_trace_defaults":409,"./defaults":410,"./event_data":411,"./hover":412}],414:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../plots/cartesian":344,"../bar/cross_trace_calc":386,"../bar/layout_attributes":392,"../bar/layout_defaults":393,"../bar/plot":394,"../bar/select":395,"../bar/style":397,"../scatter/marker_colorbar":512,"./attributes":449,"./calc":454,"./cross_trace_defaults":456,"./defaults":457,"./event_data":458,"./hover":459}],461:[function(_dereq_,module,exports){ 'use strict'; @@ -90005,21 +95505,14 @@ module.exports = { } }; -},{}],415:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],462:[function(_dereq_,module,exports){ 'use strict'; var histogramAttrs = _dereq_('../histogram/attributes'); var makeBinAttrs = _dereq_('../histogram/bin_attributes'); var heatmapAttrs = _dereq_('../heatmap/attributes'); var baseAttrs = _dereq_('../../plots/attributes'); +var axisHoverFormat = _dereq_('../../plots/hoverformat_attributes'); var hovertemplateAttrs = _dereq_('../../plots/template_attributes').hovertemplateAttrs; var colorScaleAttrs = _dereq_('../../components/colorscale/attributes'); @@ -90033,13 +95526,11 @@ module.exports = extendFlat( z: { valType: 'data_array', editType: 'calc', - }, marker: { color: { valType: 'data_array', editType: 'calc', - }, editType: 'calc' }, @@ -90054,34 +95545,25 @@ module.exports = extendFlat( autobiny: histogramAttrs.autobiny, bingroup: extendFlat({}, histogramAttrs.bingroup, { - }), xbingroup: extendFlat({}, histogramAttrs.bingroup, { - }), ybingroup: extendFlat({}, histogramAttrs.bingroup, { - }), xgap: heatmapAttrs.xgap, ygap: heatmapAttrs.ygap, zsmooth: heatmapAttrs.zsmooth, - zhoverformat: heatmapAttrs.zhoverformat, + xhoverformat: axisHoverFormat('x'), + yhoverformat: axisHoverFormat('y'), + zhoverformat: axisHoverFormat('z', 1), hovertemplate: hovertemplateAttrs({}, {keys: 'z'}), showlegend: extendFlat({}, baseAttrs.showlegend, {dflt: false}) }, colorScaleAttrs('', {cLetter: 'z', autoColorDflt: false}) ); -},{"../../components/colorscale/attributes":112,"../../lib/extend":227,"../../plots/attributes":275,"../../plots/template_attributes":321,"../heatmap/attributes":387,"../histogram/attributes":402,"../histogram/bin_attributes":404}],416:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale/attributes":162,"../../lib/extend":279,"../../plots/attributes":327,"../../plots/hoverformat_attributes":363,"../../plots/template_attributes":368,"../heatmap/attributes":434,"../histogram/attributes":449,"../histogram/bin_attributes":451}],463:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -90292,16 +95774,7 @@ function getRanges(edges, uniqueVals, gapLow, gapHigh, ax, calendar) { return out; } -},{"../../lib":233,"../../plots/cartesian/axes":279,"../histogram/average":403,"../histogram/bin_functions":405,"../histogram/bin_label_vals":406,"../histogram/calc":407,"../histogram/norm_functions":414}],417:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../plots/cartesian/axes":331,"../histogram/average":450,"../histogram/bin_functions":452,"../histogram/bin_label_vals":453,"../histogram/calc":454,"../histogram/norm_functions":461}],464:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -90323,25 +95796,18 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleStyleDefaults(traceIn, traceOut, coerce, layout); colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: '', cLetter: 'z'}); coerce('hovertemplate'); + coerce('xhoverformat'); + coerce('yhoverformat'); }; -},{"../../components/colorscale/defaults":115,"../../lib":233,"../heatmap/style_defaults":400,"./attributes":415,"./sample_defaults":420}],418:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/colorscale/defaults":165,"../../lib":285,"../heatmap/style_defaults":447,"./attributes":462,"./sample_defaults":467}],465:[function(_dereq_,module,exports){ 'use strict'; var heatmapHover = _dereq_('../heatmap/hover'); var hoverLabelText = _dereq_('../../plots/cartesian/axes').hoverLabelText; -module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLayer, contour) { - var pts = heatmapHover(pointData, xval, yval, hovermode, hoverLayer, contour); +module.exports = function hoverPoints(pointData, xval, yval, hovermode, opts) { + var pts = heatmapHover(pointData, xval, yval, hovermode, opts); if(!pts) return; @@ -90350,24 +95816,17 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay var ny = indices[0]; var nx = indices[1]; var cd0 = pointData.cd[0]; + var trace = cd0.trace; var xRange = cd0.xRanges[nx]; var yRange = cd0.yRanges[ny]; - pointData.xLabel = hoverLabelText(pointData.xa, xRange[0], xRange[1]); - pointData.yLabel = hoverLabelText(pointData.ya, yRange[0], yRange[1]); + pointData.xLabel = hoverLabelText(pointData.xa, [xRange[0], xRange[1]], trace.xhoverformat); + pointData.yLabel = hoverLabelText(pointData.ya, [yRange[0], yRange[1]], trace.yhoverformat); return pts; }; -},{"../../plots/cartesian/axes":279,"../heatmap/hover":394}],419:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian/axes":331,"../heatmap/hover":441}],466:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -90387,20 +95846,10 @@ module.exports = { basePlotModule: _dereq_('../../plots/cartesian'), categories: ['cartesian', 'svg', '2dMap', 'histogram', 'showLegend'], meta: { - - } }; -},{"../../plots/cartesian":292,"../heatmap/calc":388,"../heatmap/colorbar":390,"../heatmap/plot":398,"../heatmap/style":399,"../histogram/cross_trace_defaults":409,"../histogram/event_data":411,"./attributes":415,"./defaults":417,"./hover":418}],420:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian":344,"../heatmap/calc":435,"../heatmap/colorbar":437,"../heatmap/plot":445,"../heatmap/style":446,"../histogram/cross_trace_defaults":456,"../histogram/event_data":458,"./attributes":462,"./defaults":464,"./hover":465}],467:[function(_dereq_,module,exports){ 'use strict'; var Registry = _dereq_('../../registry'); @@ -90437,20 +95886,13 @@ module.exports = function handleSampleDefaults(traceIn, traceOut, coerce, layout coerce('autobiny'); }; -},{"../../lib":233,"../../registry":326}],421:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../registry":373}],468:[function(_dereq_,module,exports){ 'use strict'; var histogram2dAttrs = _dereq_('../histogram2d/attributes'); var contourAttrs = _dereq_('../contour/attributes'); var colorScaleAttrs = _dereq_('../../components/colorscale/attributes'); +var axisHoverFormat = _dereq_('../../plots/hoverformat_attributes'); var extendFlat = _dereq_('../../lib/extend').extendFlat; @@ -90480,13 +95922,14 @@ module.exports = extendFlat({ color: contourAttrs.line.color, width: extendFlat({}, contourAttrs.line.width, { dflt: 0.5, - }), dash: contourAttrs.line.dash, smoothing: contourAttrs.line.smoothing, editType: 'plot' }, - zhoverformat: histogram2dAttrs.zhoverformat, + xhoverformat: axisHoverFormat('x'), + yhoverformat: axisHoverFormat('y'), + zhoverformat: axisHoverFormat('z', 1), hovertemplate: histogram2dAttrs.hovertemplate }, colorScaleAttrs('', { @@ -90495,16 +95938,7 @@ module.exports = extendFlat({ }) ); -},{"../../components/colorscale/attributes":112,"../../lib/extend":227,"../contour/attributes":365,"../histogram2d/attributes":415}],422:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/colorscale/attributes":162,"../../lib/extend":279,"../../plots/hoverformat_attributes":363,"../contour/attributes":412,"../histogram2d/attributes":462}],469:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -90530,17 +95964,11 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout handleContoursDefaults(traceIn, traceOut, coerce, coerce2); handleStyleDefaults(traceIn, traceOut, coerce, layout); coerce('hovertemplate'); + coerce('xhoverformat'); + coerce('yhoverformat'); }; -},{"../../lib":233,"../contour/contours_defaults":372,"../contour/style_defaults":386,"../histogram2d/sample_defaults":420,"./attributes":421}],423:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../contour/contours_defaults":419,"../contour/style_defaults":433,"../histogram2d/sample_defaults":467,"./attributes":468}],470:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -90559,20 +95987,10 @@ module.exports = { basePlotModule: _dereq_('../../plots/cartesian'), categories: ['cartesian', 'svg', '2dMap', 'contour', 'histogram', 'showLegend'], meta: { - - } }; -},{"../../plots/cartesian":292,"../contour/calc":366,"../contour/colorbar":368,"../contour/hover":378,"../contour/plot":383,"../contour/style":385,"../histogram/cross_trace_defaults":409,"./attributes":421,"./defaults":422}],424:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian":344,"../contour/calc":413,"../contour/colorbar":415,"../contour/hover":425,"../contour/plot":430,"../contour/style":432,"../histogram/cross_trace_defaults":456,"./attributes":468,"./defaults":469}],471:[function(_dereq_,module,exports){ 'use strict'; var baseAttrs = _dereq_('../../plots/attributes'); @@ -90592,22 +96010,22 @@ for(var i = 0; i < cm.length; i++) { module.exports = extendFlat({ source: { valType: 'string', - editType: 'calc', - }, z: { valType: 'data_array', - editType: 'calc', - }, colormodel: { valType: 'enumerated', values: cm, - editType: 'calc', - + }, + zsmooth: { + valType: 'enumerated', + values: ['fast', false], + dflt: false, + editType: 'plot', }, zmin: { valType: 'info_array', @@ -90617,9 +96035,7 @@ module.exports = extendFlat({ {valType: 'number', editType: 'calc'}, {valType: 'number', editType: 'calc'} ], - editType: 'calc', - }, zmax: { valType: 'info_array', @@ -90629,47 +96045,35 @@ module.exports = extendFlat({ {valType: 'number', editType: 'calc'}, {valType: 'number', editType: 'calc'} ], - editType: 'calc', - }, x0: { valType: 'any', dflt: 0, - editType: 'calc+clearAxisTypes', - }, y0: { valType: 'any', dflt: 0, - editType: 'calc+clearAxisTypes', - }, dx: { valType: 'number', dflt: 1, - editType: 'calc', - }, dy: { valType: 'number', dflt: 1, - editType: 'calc', - }, text: { valType: 'data_array', editType: 'plot', - }, hovertext: { valType: 'data_array', editType: 'plot', - }, hoverinfo: extendFlat({}, baseAttrs.hoverinfo, { flags: ['x', 'y', 'z', 'color', 'name', 'text'], @@ -90682,15 +96086,7 @@ module.exports = extendFlat({ transforms: undefined }); -},{"../../lib/extend":227,"../../plots/attributes":275,"../../plots/template_attributes":321,"./constants":426}],425:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib/extend":279,"../../plots/attributes":327,"../../plots/template_attributes":368,"./constants":473}],472:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -90780,15 +96176,7 @@ function makeScaler(trace) { }; } -},{"../../lib":233,"../../plots/cartesian/axes":279,"./constants":426,"./helpers":429,"fast-isnumeric":23}],426:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/cartesian/axes":331,"./constants":473,"./helpers":476,"fast-isnumeric":31}],473:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -90838,18 +96226,23 @@ module.exports = { }, suffix: ['°', '%', '%', ''] } - } + }, + // For pixelated image rendering + // http://phrogz.net/tmp/canvas_image_zoom.html + // https://developer.mozilla.org/en-US/docs/Web/CSS/image-rendering + pixelatedStyle: [ + 'image-rendering: optimizeSpeed', + 'image-rendering: -moz-crisp-edges', + 'image-rendering: -o-crisp-edges', + 'image-rendering: -webkit-optimize-contrast', + 'image-rendering: optimize-contrast', + 'image-rendering: crisp-edges', + 'image-rendering: pixelated', + '' + ].join('; ') }; -},{}],427:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],474:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -90891,6 +96284,7 @@ module.exports = function supplyDefaults(traceIn, traceOut) { traceOut.zmax = cm.zmaxDflt; } + coerce('zsmooth'); coerce('text'); coerce('hovertext'); coerce('hovertemplate'); @@ -90898,15 +96292,7 @@ module.exports = function supplyDefaults(traceIn, traceOut) { traceOut._length = null; }; -},{"../../lib":233,"../../snapshot/helpers":330,"./attributes":424,"./constants":426}],428:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../snapshot/helpers":377,"./attributes":471,"./constants":473}],475:[function(_dereq_,module,exports){ 'use strict'; module.exports = function eventData(out, pt) { @@ -90920,36 +96306,20 @@ module.exports = function eventData(out, pt) { return out; }; -},{}],429:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],476:[function(_dereq_,module,exports){ 'use strict'; -var sizeOf = _dereq_('image-size'); +var probeSync = _dereq_('probe-image-size/sync'); var dataUri = _dereq_('../../snapshot/helpers').IMAGE_URL_PREFIX; var Buffer = _dereq_('buffer/').Buffer; // note: the trailing slash is important! exports.getImageSize = function(src) { var data = src.replace(dataUri, ''); var buff = new Buffer(data, 'base64'); - return sizeOf(buff); + return probeSync(buff); }; -},{"../../snapshot/helpers":330,"buffer/":18,"image-size":58}],430:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../snapshot/helpers":377,"buffer/":28,"probe-image-size/sync":95}],477:[function(_dereq_,module,exports){ 'use strict'; var Fx = _dereq_('../../components/fx'); @@ -91041,15 +96411,7 @@ module.exports = function hoverPoints(pointData, xval, yval) { })]; }; -},{"../../components/fx":145,"../../lib":233,"./constants":426}],431:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/fx":195,"../../lib":285,"./constants":473}],478:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -91067,22 +96429,13 @@ module.exports = { categories: ['cartesian', 'svg', '2dMap', 'noSortingByValue'], animatable: false, meta: { - } }; -},{"../../plots/cartesian":292,"./attributes":424,"./calc":425,"./defaults":427,"./event_data":428,"./hover":430,"./plot":432,"./style":433}],432:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian":344,"./attributes":471,"./calc":472,"./defaults":474,"./event_data":475,"./hover":477,"./plot":479,"./style":480}],479:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Lib = _dereq_('../../lib'); var strTranslate = Lib.strTranslate; var xmlnsNamespaces = _dereq_('../../constants/xmlns_namespaces'); @@ -91100,8 +96453,11 @@ module.exports = function plot(gd, plotinfo, cdimage, imageLayer) { var plotGroup = d3.select(this); var cd0 = cd[0]; var trace = cd0.trace; - var fastImage = supportsPixelatedImage && !trace._hasZ && trace._hasSource && xa.type === 'linear' && ya.type === 'linear'; - trace._fastImage = fastImage; + var realImage = ( + ((trace.zsmooth === 'fast') || (trace.zsmooth === false && supportsPixelatedImage)) && + !trace._hasZ && trace._hasSource && xa.type === 'linear' && ya.type === 'linear' + ); + trace._realImage = realImage; var z = cd0.z; var x0 = cd0.x0; @@ -91147,7 +96503,7 @@ module.exports = function plot(gd, plotinfo, cdimage, imageLayer) { } // Reduce image size when zoomed in to save memory - if(!fastImage) { + if(!realImage) { var extra = 0.5; // half the axis size left = Math.max(-extra * xa._length, left); right = Math.min((1 + extra) * xa._length, right); @@ -91210,11 +96566,9 @@ module.exports = function plot(gd, plotinfo, cdimage, imageLayer) { image3.exit().remove(); - // Pixelated image rendering - // http://phrogz.net/tmp/canvas_image_zoom.html - // https://developer.mozilla.org/en-US/docs/Web/CSS/image-rendering - var style = 'image-rendering: optimizeSpeed; image-rendering: -moz-crisp-edges; image-rendering: -o-crisp-edges; image-rendering: -webkit-optimize-contrast; image-rendering: optimize-contrast; image-rendering: crisp-edges; image-rendering: pixelated;'; - if(fastImage) { + var style = (trace.zsmooth === false) ? constants.pixelatedStyle : ''; + + if(realImage) { var xRange = Lib.simpleMap(xa.range, xa.r2l); var yRange = Lib.simpleMap(ya.range, ya.r2l); @@ -91270,7 +96624,7 @@ module.exports = function plot(gd, plotinfo, cdimage, imageLayer) { canvas = drawMagnifiedPixelsOnCanvas(function(i, j) {return z[j][i];}); href = canvas.toDataURL('image/png'); } else if(trace._hasSource) { - if(fastImage) { + if(realImage) { href = trace.source; } else { var context = trace._canvas.el.getContext('2d'); @@ -91301,18 +96655,10 @@ module.exports = function plot(gd, plotinfo, cdimage, imageLayer) { }); }; -},{"../../constants/xmlns_namespaces":213,"../../lib":233,"./constants":426,"d3":21}],433:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/xmlns_namespaces":266,"../../lib":285,"./constants":473,"@plotly/d3":20}],480:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); module.exports = function style(gd) { d3.select(gd).selectAll('.im image') @@ -91321,15 +96667,7 @@ module.exports = function style(gd) { }); }; -},{"d3":21}],434:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"@plotly/d3":20}],481:[function(_dereq_,module,exports){ 'use strict'; var baseAttrs = _dereq_('../../plots/attributes'); @@ -91345,61 +96683,49 @@ var textFontAttrs = fontAttrs({ editType: 'plot', arrayOk: true, colorEditType: 'plot', - }); module.exports = { labels: { valType: 'data_array', editType: 'calc', - }, // equivalent of x0 and dx, if label is missing label0: { valType: 'number', - dflt: 0, editType: 'calc', - }, dlabel: { valType: 'number', - dflt: 1, editType: 'calc', - }, values: { valType: 'data_array', editType: 'calc', - }, marker: { colors: { valType: 'data_array', // TODO 'color_array' ? editType: 'calc', - }, line: { color: { valType: 'color', - dflt: colorAttrs.defaultLine, arrayOk: true, editType: 'style', - }, width: { valType: 'number', - min: 0, dflt: 0, arrayOk: true, editType: 'style', - }, editType: 'calc' }, @@ -91409,15 +96735,12 @@ module.exports = { text: { valType: 'data_array', editType: 'plot', - }, hovertext: { valType: 'string', - dflt: '', arrayOk: true, editType: 'style', - }, // 'see eg:' @@ -91426,20 +96749,16 @@ module.exports = { // 'of its own. but the point is the size of the whole pie is important.)' scalegroup: { valType: 'string', - dflt: '', editType: 'calc', - }, // labels (legend is handled by plots.attributes.showlegend and layout.hiddenlabels) textinfo: { valType: 'flaglist', - flags: ['label', 'text', 'value', 'percent'], extras: ['none'], editType: 'calc', - }, hoverinfo: extendFlat({}, baseAttrs.hoverinfo, { flags: ['label', 'text', 'value', 'percent', 'name'] @@ -91452,48 +96771,36 @@ module.exports = { }), textposition: { valType: 'enumerated', - values: ['inside', 'outside', 'auto', 'none'], dflt: 'auto', arrayOk: true, editType: 'plot', - }, textfont: extendFlat({}, textFontAttrs, { - }), insidetextorientation: { valType: 'enumerated', - values: ['horizontal', 'radial', 'tangential', 'auto'], dflt: 'auto', editType: 'plot', - }, insidetextfont: extendFlat({}, textFontAttrs, { - }), outsidetextfont: extendFlat({}, textFontAttrs, { - }), automargin: { valType: 'boolean', dflt: false, - editType: 'plot', - }, title: { text: { valType: 'string', dflt: '', - editType: 'plot', - }, font: extendFlat({}, textFontAttrs, { - }), position: { valType: 'enumerated', @@ -91502,9 +96809,7 @@ module.exports = { 'middle center', 'bottom left', 'bottom center', 'bottom right' ], - editType: 'plot', - }, editType: 'plot' @@ -91515,21 +96820,17 @@ module.exports = { hole: { valType: 'number', - min: 0, max: 1, dflt: 0, editType: 'calc', - }, // ordering and direction sort: { valType: 'boolean', - dflt: true, editType: 'calc', - }, direction: { /** @@ -91541,42 +96842,33 @@ module.exports = { */ valType: 'enumerated', values: ['clockwise', 'counterclockwise'], - dflt: 'counterclockwise', editType: 'calc', - }, rotation: { valType: 'number', - min: -360, max: 360, dflt: 0, editType: 'calc', - }, pull: { valType: 'number', - min: 0, max: 1, dflt: 0, arrayOk: true, editType: 'calc', - }, _deprecated: { title: { valType: 'string', dflt: '', - editType: 'calc', - }, titlefont: extendFlat({}, textFontAttrs, { - }), titleposition: { valType: 'enumerated', @@ -91585,22 +96877,12 @@ module.exports = { 'middle center', 'bottom left', 'bottom center', 'bottom right' ], - editType: 'calc', - } } }; -},{"../../components/color/attributes":104,"../../lib/extend":227,"../../plots/attributes":275,"../../plots/domain":306,"../../plots/font_attributes":307,"../../plots/template_attributes":321}],435:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color/attributes":154,"../../lib/extend":279,"../../plots/attributes":327,"../../plots/domain":358,"../../plots/font_attributes":359,"../../plots/template_attributes":368}],482:[function(_dereq_,module,exports){ 'use strict'; var plots = _dereq_('../../plots/plots'); @@ -91615,15 +96897,7 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) plots.cleanBasePlot(exports.name, newFullData, newFullLayout, oldFullData, oldFullLayout); }; -},{"../../plots/plots":313}],436:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/plots":366}],483:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -91798,15 +97072,7 @@ module.exports = { generateExtendedColors: generateExtendedColors }; -},{"../../components/color":105,"fast-isnumeric":23,"tinycolor2":88}],437:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"fast-isnumeric":31,"tinycolor2":119}],484:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -91929,15 +97195,7 @@ module.exports = { supplyDefaults: supplyDefaults }; -},{"../../lib":233,"../../plots/domain":306,"../bar/defaults":340,"./attributes":434,"fast-isnumeric":23}],438:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/domain":358,"../bar/defaults":387,"./attributes":481,"fast-isnumeric":31}],485:[function(_dereq_,module,exports){ 'use strict'; var appendArrayMultiPointValues = _dereq_('../../components/fx/helpers').appendArrayMultiPointValues; @@ -91978,15 +97236,7 @@ module.exports = function eventData(pt, trace) { return out; }; -},{"../../components/fx/helpers":141}],439:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/fx/helpers":191}],486:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -92026,15 +97276,7 @@ exports.getRotationAngle = function(rotation) { return (rotation === 'auto' ? 0 : rotation) * Math.PI / 180; }; -},{"../../lib":233}],440:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],487:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -92055,52 +97297,29 @@ module.exports = { basePlotModule: _dereq_('./base_plot'), categories: ['pie-like', 'pie', 'showLegend'], meta: { - } }; -},{"./attributes":434,"./base_plot":435,"./calc":436,"./defaults":437,"./layout_attributes":441,"./layout_defaults":442,"./plot":443,"./style":444,"./style_one":445}],441:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"./attributes":481,"./base_plot":482,"./calc":483,"./defaults":484,"./layout_attributes":488,"./layout_defaults":489,"./plot":490,"./style":491,"./style_one":492}],488:[function(_dereq_,module,exports){ 'use strict'; module.exports = { hiddenlabels: { valType: 'data_array', - editType: 'calc', - }, piecolorway: { valType: 'colorlist', - editType: 'calc', - }, extendpiecolors: { valType: 'boolean', dflt: true, - editType: 'calc', - } }; -},{}],442:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],489:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -92117,18 +97336,10 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) { coerce('extendpiecolors'); }; -},{"../../lib":233,"./layout_attributes":441}],443:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"./layout_attributes":488}],490:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Plots = _dereq_('../../plots/plots'); var Fx = _dereq_('../../components/fx'); @@ -93297,18 +98508,10 @@ module.exports = { computeTransform: computeTransform }; -},{"../../components/color":105,"../../components/drawing":127,"../../components/fx":145,"../../lib":233,"../../lib/svg_text_utils":255,"../../plots/plots":313,"../bar/constants":338,"../bar/uniform_text":352,"./event_data":438,"./helpers":439,"d3":21}],444:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../components/drawing":177,"../../components/fx":195,"../../lib":285,"../../lib/svg_text_utils":307,"../../plots/plots":366,"../bar/constants":385,"../bar/uniform_text":399,"./event_data":485,"./helpers":486,"@plotly/d3":20}],491:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var styleOne = _dereq_('./style_one'); var resizeText = _dereq_('../bar/uniform_text').resizeText; @@ -93330,15 +98533,7 @@ module.exports = function style(gd) { }); }; -},{"../bar/uniform_text":352,"./style_one":445,"d3":21}],445:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../bar/uniform_text":399,"./style_one":492,"@plotly/d3":20}],492:[function(_dereq_,module,exports){ 'use strict'; var Color = _dereq_('../../components/color'); @@ -93354,16 +98549,7 @@ module.exports = function styleOne(s, pt, trace) { .call(Color.stroke, lineColor); }; -},{"../../components/color":105,"./helpers":439}],446:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/color":155,"./helpers":486}],493:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -93406,17 +98592,10 @@ module.exports = function arraysToCalcdata(cd, trace) { } }; -},{"../../lib":233}],447:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],494:[function(_dereq_,module,exports){ 'use strict'; +var axisHoverFormat = _dereq_('../../plots/hoverformat_attributes'); var texttemplateAttrs = _dereq_('../../plots/template_attributes').texttemplateAttrs; var hovertemplateAttrs = _dereq_('../../plots/template_attributes').hovertemplateAttrs; var colorScaleAttrs = _dereq_('../../components/colorscale/attributes'); @@ -93432,18 +98611,14 @@ function axisPeriod(axis) { return { valType: 'any', dflt: 0, - editType: 'calc', - }; } function axisPeriod0(axis) { return { valType: 'any', - editType: 'calc', - }; } @@ -93454,9 +98629,7 @@ function axisPeriodAlignment(axis) { 'start', 'middle', 'end' ], dflt: 'middle', - editType: 'calc', - }; } @@ -93465,45 +98638,35 @@ module.exports = { valType: 'data_array', editType: 'calc+clearAxisTypes', anim: true, - }, x0: { valType: 'any', dflt: 0, - editType: 'calc+clearAxisTypes', anim: true, - }, dx: { valType: 'number', dflt: 1, - editType: 'calc', anim: true, - }, y: { valType: 'data_array', editType: 'calc+clearAxisTypes', anim: true, - }, y0: { valType: 'any', dflt: 0, - editType: 'calc+clearAxisTypes', anim: true, - }, dy: { valType: 'number', dflt: 1, - editType: 'calc', anim: true, - }, xperiod: axisPeriod('x'), @@ -93512,45 +98675,37 @@ module.exports = { yperiod0: axisPeriod0('y0'), xperiodalignment: axisPeriodAlignment('x'), yperiodalignment: axisPeriodAlignment('y'), + xhoverformat: axisHoverFormat('x'), + yhoverformat: axisHoverFormat('y'), stackgroup: { valType: 'string', - dflt: '', editType: 'calc', - }, orientation: { valType: 'enumerated', - values: ['v', 'h'], editType: 'calc', - }, groupnorm: { valType: 'enumerated', values: ['', 'fraction', 'percent'], dflt: '', - editType: 'calc', - }, stackgaps: { valType: 'enumerated', values: ['infer zero', 'interpolate'], dflt: 'infer zero', - editType: 'calc', - }, text: { valType: 'string', - dflt: '', arrayOk: true, editType: 'calc', - }, texttemplate: texttemplateAttrs({}, { @@ -93558,71 +98713,56 @@ module.exports = { }), hovertext: { valType: 'string', - dflt: '', arrayOk: true, editType: 'style', - }, mode: { valType: 'flaglist', flags: ['lines', 'markers', 'text'], extras: ['none'], - editType: 'calc', - }, hoveron: { valType: 'flaglist', flags: ['points', 'fills'], - editType: 'style', - }, hovertemplate: hovertemplateAttrs({}, { keys: constants.eventDataKeys }), + line: { color: { valType: 'color', - editType: 'style', anim: true, - }, width: { valType: 'number', min: 0, dflt: 2, - editType: 'style', anim: true, - }, shape: { valType: 'enumerated', values: ['linear', 'spline', 'hv', 'vh', 'hvh', 'vhv'], dflt: 'linear', - editType: 'plot', - }, smoothing: { valType: 'number', min: 0, max: 1.3, dflt: 1, - editType: 'plot', - }, dash: extendFlat({}, dash, {editType: 'style'}), simplify: { valType: 'boolean', dflt: true, - editType: 'plot', - }, editType: 'plot' }, @@ -93630,31 +98770,23 @@ module.exports = { connectgaps: { valType: 'boolean', dflt: false, - editType: 'calc', - }, cliponaxis: { valType: 'boolean', dflt: true, - editType: 'plot', - }, fill: { valType: 'enumerated', values: ['none', 'tozeroy', 'tozerox', 'tonexty', 'tonextx', 'toself', 'tonext'], - editType: 'calc', - }, fillcolor: { valType: 'color', - editType: 'style', anim: true, - }, marker: extendFlat({ symbol: { @@ -93662,60 +98794,46 @@ module.exports = { values: Drawing.symbolList, dflt: 'circle', arrayOk: true, - editType: 'style', - }, opacity: { valType: 'number', min: 0, max: 1, arrayOk: true, - editType: 'style', anim: true, - }, size: { valType: 'number', min: 0, dflt: 6, arrayOk: true, - editType: 'calc', anim: true, - }, maxdisplayed: { valType: 'number', min: 0, dflt: 0, - editType: 'plot', - }, sizeref: { valType: 'number', dflt: 1, - editType: 'calc', - }, sizemin: { valType: 'number', min: 0, dflt: 0, - editType: 'calc', - }, sizemode: { valType: 'enumerated', values: ['diameter', 'area'], dflt: 'diameter', - editType: 'calc', - }, line: extendFlat({ @@ -93723,10 +98841,8 @@ module.exports = { valType: 'number', min: 0, arrayOk: true, - editType: 'style', anim: true, - }, editType: 'calc' }, @@ -93738,16 +98854,12 @@ module.exports = { values: ['radial', 'horizontal', 'vertical', 'none'], arrayOk: true, dflt: 'none', - editType: 'calc', - }, color: { valType: 'color', arrayOk: true, - editType: 'calc', - }, editType: 'calc' }, @@ -93761,31 +98873,23 @@ module.exports = { valType: 'number', min: 0, max: 1, - editType: 'style', - }, color: { valType: 'color', - editType: 'style', - }, size: { valType: 'number', min: 0, - editType: 'style', - }, editType: 'style' }, textfont: { color: { valType: 'color', - editType: 'style', - }, editType: 'style' }, @@ -93797,31 +98901,23 @@ module.exports = { valType: 'number', min: 0, max: 1, - editType: 'style', - }, color: { valType: 'color', - editType: 'style', - }, size: { valType: 'number', min: 0, - editType: 'style', - }, editType: 'style' }, textfont: { color: { valType: 'color', - editType: 'style', - }, editType: 'style' }, @@ -93837,38 +98933,16 @@ module.exports = { ], dflt: 'middle center', arrayOk: true, - editType: 'calc', - }, textfont: fontAttrs({ editType: 'calc', colorEditType: 'style', arrayOk: true, - }), - - r: { - valType: 'data_array', - editType: 'calc', - - }, - t: { - valType: 'data_array', - editType: 'calc', - - } }; -},{"../../components/colorscale/attributes":112,"../../components/drawing":127,"../../components/drawing/attributes":126,"../../lib/extend":227,"../../plots/font_attributes":307,"../../plots/template_attributes":321,"./constants":451}],448:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/colorscale/attributes":162,"../../components/drawing":177,"../../components/drawing/attributes":176,"../../lib/extend":279,"../../plots/font_attributes":359,"../../plots/hoverformat_attributes":363,"../../plots/template_attributes":368,"./constants":498}],495:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -94159,15 +99233,7 @@ module.exports = { getStackOpts: getStackOpts }; -},{"../../constants/numerical":212,"../../lib":233,"../../plots/cartesian/align_period":276,"../../plots/cartesian/axes":279,"./arrays_to_calcdata":446,"./calc_selection":449,"./colorscale_calc":450,"./subtypes":472,"fast-isnumeric":23}],449:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/numerical":265,"../../lib":285,"../../plots/cartesian/align_period":328,"../../plots/cartesian/axes":331,"./arrays_to_calcdata":493,"./calc_selection":496,"./colorscale_calc":497,"./subtypes":519,"fast-isnumeric":31}],496:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -94178,15 +99244,7 @@ module.exports = function calcSelection(cd, trace) { } }; -},{"../../lib":233}],450:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],497:[function(_dereq_,module,exports){ 'use strict'; var hasColorscale = _dereq_('../../components/colorscale/helpers').hasColorscale; @@ -94221,16 +99279,7 @@ module.exports = function calcMarkerColorscale(gd, trace) { } }; -},{"../../components/colorscale/calc":113,"../../components/colorscale/helpers":116,"./subtypes":472}],451:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/colorscale/calc":163,"../../components/colorscale/helpers":166,"./subtypes":519}],498:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -94250,16 +99299,7 @@ module.exports = { eventDataKeys: [] }; -},{}],452:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],499:[function(_dereq_,module,exports){ 'use strict'; var calc = _dereq_('./calc'); @@ -94431,16 +99471,7 @@ function getInterp(calcTrace, index, position, posAttr) { return pt0.s + (pt1.s - pt0.s) * (position - pt0[posAttr]) / (pt1[posAttr] - pt0[posAttr]); } -},{"./calc":448}],453:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"./calc":495}],500:[function(_dereq_,module,exports){ 'use strict'; @@ -94470,15 +99501,7 @@ module.exports = function crossTraceDefaults(fullData) { } }; -},{}],454:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],501:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -94507,6 +99530,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout if(!traceOut.visible) return; handlePeriodDefaults(traceIn, traceOut, layout, coerce); + coerce('xhoverformat'); + coerce('yhoverformat'); var stackGroupOpts = handleStackDefaults(traceIn, traceOut, layout, coerce); @@ -94563,16 +99588,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":233,"../../registry":326,"./attributes":447,"./constants":451,"./fillcolor_defaults":455,"./line_defaults":460,"./line_shape_defaults":462,"./marker_defaults":466,"./period_defaults":467,"./stack_defaults":470,"./subtypes":472,"./text_defaults":473,"./xy_defaults":474}],455:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285,"../../registry":373,"./attributes":494,"./constants":498,"./fillcolor_defaults":502,"./line_defaults":507,"./line_shape_defaults":509,"./marker_defaults":513,"./period_defaults":514,"./stack_defaults":517,"./subtypes":519,"./text_defaults":520,"./xy_defaults":521}],502:[function(_dereq_,module,exports){ 'use strict'; var Color = _dereq_('../../components/color'); @@ -94600,15 +99616,7 @@ module.exports = function fillColorDefaults(traceIn, traceOut, defaultColor, coe )); }; -},{"../../components/color":105,"../../lib":233}],456:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../lib":285}],503:[function(_dereq_,module,exports){ 'use strict'; var Axes = _dereq_('../../plots/cartesian/axes'); @@ -94620,22 +99628,13 @@ module.exports = function formatLabels(cdi, trace, fullLayout) { var xa = Axes.getFromTrace(mockGd, trace, 'x'); var ya = Axes.getFromTrace(mockGd, trace, 'y'); - labels.xLabel = Axes.tickText(xa, cdi.x, true).text; - labels.yLabel = Axes.tickText(ya, cdi.y, true).text; + labels.xLabel = Axes.tickText(xa, xa.c2l(cdi.x), true).text; + labels.yLabel = Axes.tickText(ya, ya.c2l(cdi.y), true).text; return labels; }; -},{"../../plots/cartesian/axes":279}],457:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../plots/cartesian/axes":331}],504:[function(_dereq_,module,exports){ 'use strict'; var Color = _dereq_('../../components/color'); @@ -94675,15 +99674,7 @@ module.exports = function getTraceColor(trace, di) { } }; -},{"../../components/color":105,"./subtypes":472}],458:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"./subtypes":519}],505:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -94714,13 +99705,14 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { var rad = Math.max(3, di.mrc || 0); var kink = 1 - 1 / rad; var dxRaw = Math.abs(xa.c2p(di.x) - xpx); - var d = (dxRaw < rad) ? (kink * dxRaw / rad) : (dxRaw - rad + kink); - return d; + if(di.orig_x !== undefined) dxRaw += xa.c2p(di.orig_x) - xa.c2p(di.x); + return (dxRaw < rad) ? (kink * dxRaw / rad) : (dxRaw - rad + kink); }; var dy = function(di) { var rad = Math.max(3, di.mrc || 0); var kink = 1 - 1 / rad; var dyRaw = Math.abs(ya.c2p(di.y) - ypx); + if(di.orig_y !== undefined) dyRaw += ya.c2p(di.orig_y) - ya.c2p(di.y); return (dyRaw < rad) ? (kink * dyRaw / rad) : (dyRaw - rad + kink); }; var dxy = function(di) { @@ -94870,15 +99862,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { } }; -},{"../../components/color":105,"../../components/fx":145,"../../lib":233,"../../registry":326,"./get_trace_color":457}],459:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../components/fx":195,"../../lib":285,"../../registry":373,"./get_trace_color":504}],506:[function(_dereq_,module,exports){ 'use strict'; var subtypes = _dereq_('./subtypes'); @@ -94912,19 +99896,10 @@ module.exports = { 'zoomScale' ], meta: { - } }; -},{"../../plots/cartesian":292,"./arrays_to_calcdata":446,"./attributes":447,"./calc":448,"./cross_trace_calc":452,"./cross_trace_defaults":453,"./defaults":454,"./format_labels":456,"./hover":458,"./marker_colorbar":465,"./plot":468,"./select":469,"./style":471,"./subtypes":472}],460:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian":344,"./arrays_to_calcdata":493,"./attributes":494,"./calc":495,"./cross_trace_calc":499,"./cross_trace_defaults":500,"./defaults":501,"./format_labels":503,"./hover":505,"./marker_colorbar":512,"./plot":515,"./select":516,"./style":518,"./subtypes":519}],507:[function(_dereq_,module,exports){ 'use strict'; var isArrayOrTypedArray = _dereq_('../../lib').isArrayOrTypedArray; @@ -94947,16 +99922,7 @@ module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout, if(!(opts || {}).noDash) coerce('line.dash'); }; -},{"../../components/colorscale/defaults":115,"../../components/colorscale/helpers":116,"../../lib":233}],461:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/colorscale/defaults":165,"../../components/colorscale/helpers":166,"../../lib":285}],508:[function(_dereq_,module,exports){ 'use strict'; var numConstants = _dereq_('../../constants/numerical'); @@ -95408,16 +100374,7 @@ module.exports = function linePoints(d, opts) { return segments; }; -},{"../../constants/numerical":212,"../../lib":233,"./constants":451}],462:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../constants/numerical":265,"../../lib":285,"./constants":498}],509:[function(_dereq_,module,exports){ 'use strict'; @@ -95427,15 +100384,7 @@ module.exports = function handleLineShapeDefaults(traceIn, traceOut, coerce) { if(shape === 'spline') coerce('line.smoothing'); }; -},{}],463:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],510:[function(_dereq_,module,exports){ 'use strict'; var LINKEDFILLS = {tonextx: 1, tonexty: 1, tonext: 1}; @@ -95517,16 +100466,7 @@ module.exports = function linkTraces(gd, plotinfo, cdscatter) { return cdscatterSorted; }; -},{}],464:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],511:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -95559,16 +100499,7 @@ module.exports = function makeBubbleSizeFn(trace) { }; }; -},{"fast-isnumeric":23}],465:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"fast-isnumeric":31}],512:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -95577,15 +100508,7 @@ module.exports = { max: 'cmax' }; -},{}],466:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],513:[function(_dereq_,module,exports){ 'use strict'; var Color = _dereq_('../../components/color'); @@ -95658,15 +100581,7 @@ module.exports = function markerDefaults(traceIn, traceOut, defaultColor, layout } }; -},{"../../components/color":105,"../../components/colorscale/defaults":115,"../../components/colorscale/helpers":116,"./subtypes":472}],467:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../components/colorscale/defaults":165,"../../components/colorscale/helpers":166,"./subtypes":519}],514:[function(_dereq_,module,exports){ 'use strict'; var dateTick0 = _dereq_('../../lib').dateTick0; @@ -95705,19 +100620,10 @@ module.exports = function handlePeriodDefaults(traceIn, traceOut, layout, coerce } }; -},{"../../constants/numerical":212,"../../lib":233}],468:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../constants/numerical":265,"../../lib":285}],515:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Registry = _dereq_('../../registry'); var Lib = _dereq_('../../lib'); @@ -96266,16 +101172,7 @@ function selectMarkers(gd, idx, plotinfo, cdscatter, cdscatterAll) { }); } -},{"../../components/drawing":127,"../../lib":233,"../../lib/polygon":245,"../../registry":326,"./line_points":461,"./link_traces":463,"./subtypes":472,"d3":21}],469:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/drawing":177,"../../lib":285,"../../lib/polygon":297,"../../registry":373,"./line_points":508,"./link_traces":510,"./subtypes":519,"@plotly/d3":20}],516:[function(_dereq_,module,exports){ 'use strict'; var subtypes = _dereq_('./subtypes'); @@ -96320,15 +101217,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { return selection; }; -},{"./subtypes":472}],470:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"./subtypes":519}],517:[function(_dereq_,module,exports){ 'use strict'; var perStackAttrs = ['orientation', 'groupnorm', 'stackgaps']; @@ -96425,19 +101314,10 @@ module.exports = function handleStackDefaults(traceIn, traceOut, layout, coerce) } }; -},{}],471:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{}],518:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Drawing = _dereq_('../../components/drawing'); var Registry = _dereq_('../../registry'); @@ -96496,16 +101376,7 @@ module.exports = { styleOnSelect: styleOnSelect }; -},{"../../components/drawing":127,"../../registry":326,"d3":21}],472:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/drawing":177,"../../registry":373,"@plotly/d3":20}],519:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -96535,16 +101406,7 @@ module.exports = { } }; -},{"../../lib":233}],473:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../lib":285}],520:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -96565,15 +101427,7 @@ module.exports = function(traceIn, traceOut, layout, coerce, opts) { } }; -},{"../../lib":233}],474:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],521:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -96609,15 +101463,7 @@ module.exports = function handleXYDefaults(traceIn, traceOut, layout, coerce) { return len; }; -},{"../../lib":233,"../../registry":326}],475:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../registry":373}],522:[function(_dereq_,module,exports){ 'use strict'; var hovertemplateAttrs = _dereq_('../../plots/template_attributes').hovertemplateAttrs; @@ -96637,35 +101483,28 @@ module.exports = { a: { valType: 'data_array', editType: 'calc', - }, b: { valType: 'data_array', editType: 'calc', - }, c: { valType: 'data_array', editType: 'calc', - }, sum: { valType: 'number', - dflt: 0, min: 0, editType: 'calc', - }, mode: extendFlat({}, scatterAttrs.mode, {dflt: 'markers'}), text: extendFlat({}, scatterAttrs.text, { - }), texttemplate: texttemplateAttrs({editType: 'plot'}, { keys: ['a', 'b', 'c', 'text'] }), hovertext: extendFlat({}, scatterAttrs.hovertext, { - }), line: { color: scatterLineAttrs.color, @@ -96681,7 +101520,6 @@ module.exports = { fill: extendFlat({}, scatterAttrs.fill, { values: ['none', 'toself', 'tonext'], dflt: 'none', - }), fillcolor: scatterAttrs.fillcolor, marker: extendFlat({ @@ -96717,16 +101555,7 @@ module.exports = { hovertemplate: hovertemplateAttrs(), }; -},{"../../components/colorscale/attributes":112,"../../components/drawing/attributes":126,"../../lib/extend":227,"../../plots/attributes":275,"../../plots/template_attributes":321,"../scatter/attributes":447}],476:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../components/colorscale/attributes":162,"../../components/drawing/attributes":176,"../../lib/extend":279,"../../plots/attributes":327,"../../plots/template_attributes":368,"../scatter/attributes":494}],523:[function(_dereq_,module,exports){ 'use strict'; var isNumeric = _dereq_('fast-isnumeric'); @@ -96798,16 +101627,7 @@ module.exports = function calc(gd, trace) { return cd; }; -},{"../scatter/arrays_to_calcdata":446,"../scatter/calc":448,"../scatter/calc_selection":449,"../scatter/colorscale_calc":450,"fast-isnumeric":23}],477:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../scatter/arrays_to_calcdata":493,"../scatter/calc":495,"../scatter/calc_selection":496,"../scatter/colorscale_calc":497,"fast-isnumeric":31}],524:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -96902,15 +101722,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout Lib.coerceSelectionMarkerOpacity(traceOut, coerce); }; -},{"../../lib":233,"../scatter/constants":451,"../scatter/fillcolor_defaults":455,"../scatter/line_defaults":460,"../scatter/line_shape_defaults":462,"../scatter/marker_defaults":466,"../scatter/subtypes":472,"../scatter/text_defaults":473,"./attributes":475}],478:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../scatter/constants":498,"../scatter/fillcolor_defaults":502,"../scatter/line_defaults":507,"../scatter/line_shape_defaults":509,"../scatter/marker_defaults":513,"../scatter/subtypes":519,"../scatter/text_defaults":520,"./attributes":522}],525:[function(_dereq_,module,exports){ 'use strict'; module.exports = function eventData(out, pt, trace, cd, pointNumber) { @@ -96934,15 +101746,7 @@ module.exports = function eventData(out, pt, trace, cd, pointNumber) { return out; }; -},{}],479:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{}],526:[function(_dereq_,module,exports){ 'use strict'; var Axes = _dereq_('../../plots/cartesian/axes'); @@ -96958,15 +101762,7 @@ module.exports = function formatLabels(cdi, trace, fullLayout) { return labels; }; -},{"../../plots/cartesian/axes":279}],480:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian/axes":331}],527:[function(_dereq_,module,exports){ 'use strict'; var scatterHover = _dereq_('../scatter/hover'); @@ -97032,15 +101828,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { return scatterPointData; }; -},{"../scatter/hover":458}],481:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../scatter/hover":505}],528:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -97061,21 +101849,10 @@ module.exports = { basePlotModule: _dereq_('../../plots/ternary'), categories: ['ternary', 'symbols', 'showLegend', 'scatter-like'], meta: { - - } }; -},{"../../plots/ternary":322,"../scatter/marker_colorbar":465,"../scatter/select":469,"../scatter/style":471,"./attributes":475,"./calc":476,"./defaults":477,"./event_data":478,"./format_labels":479,"./hover":480,"./plot":482}],482:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - - +},{"../../plots/ternary":369,"../scatter/marker_colorbar":512,"../scatter/select":516,"../scatter/style":518,"./attributes":522,"./calc":523,"./defaults":524,"./event_data":525,"./format_labels":526,"./hover":527,"./plot":529}],529:[function(_dereq_,module,exports){ 'use strict'; var scatterPlot = _dereq_('../scatter/plot'); @@ -97099,19 +101876,12 @@ module.exports = function plot(gd, ternary, moduleCalcData) { scatterPlot(gd, plotinfo, moduleCalcData, scatterLayer); }; -},{"../scatter/plot":468}],483:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../scatter/plot":515}],530:[function(_dereq_,module,exports){ 'use strict'; var boxAttrs = _dereq_('../box/attributes'); var extendFlat = _dereq_('../../lib/extend').extendFlat; +var axisHoverFormat = _dereq_('../../plots/hoverformat_attributes'); module.exports = { y: boxAttrs.y, @@ -97119,44 +101889,37 @@ module.exports = { x0: boxAttrs.x0, y0: boxAttrs.y0, + xhoverformat: axisHoverFormat('x'), + yhoverformat: axisHoverFormat('y'), + name: extendFlat({}, boxAttrs.name, { - }), orientation: extendFlat({}, boxAttrs.orientation, { - }), bandwidth: { valType: 'number', min: 0, - editType: 'calc', - }, scalegroup: { valType: 'string', - dflt: '', editType: 'calc', - }, scalemode: { valType: 'enumerated', values: ['width', 'count'], dflt: 'width', - editType: 'calc', - }, spanmode: { valType: 'enumerated', values: ['soft', 'hard', 'manual'], dflt: 'soft', - editType: 'calc', - }, span: { valType: 'info_array', @@ -97164,42 +101927,32 @@ module.exports = { {valType: 'any', editType: 'calc'}, {valType: 'any', editType: 'calc'} ], - editType: 'calc', - }, line: { color: { valType: 'color', - editType: 'style', - }, width: { valType: 'number', - min: 0, dflt: 2, editType: 'style', - }, editType: 'plot' }, fillcolor: boxAttrs.fillcolor, points: extendFlat({}, boxAttrs.boxpoints, { - }), jitter: extendFlat({}, boxAttrs.jitter, { - }), pointpos: extendFlat({}, boxAttrs.pointpos, { - }), width: extendFlat({}, boxAttrs.width, { - }), marker: boxAttrs.marker, @@ -97211,38 +101964,28 @@ module.exports = { visible: { valType: 'boolean', dflt: false, - editType: 'plot', - }, width: { valType: 'number', min: 0, max: 1, dflt: 0.25, - editType: 'plot', - }, fillcolor: { valType: 'color', - editType: 'style', - }, line: { color: { valType: 'color', - editType: 'style', - }, width: { valType: 'number', min: 0, - editType: 'style', - }, editType: 'style' }, @@ -97253,22 +101996,16 @@ module.exports = { visible: { valType: 'boolean', dflt: false, - editType: 'plot', - }, color: { valType: 'color', - editType: 'style', - }, width: { valType: 'number', min: 0, - editType: 'style', - }, editType: 'plot' }, @@ -97277,9 +102014,7 @@ module.exports = { valType: 'enumerated', values: ['both', 'positive', 'negative'], dflt: 'both', - editType: 'calc', - }, offsetgroup: boxAttrs.offsetgroup, @@ -97293,21 +102028,11 @@ module.exports = { flags: ['violins', 'points', 'kde'], dflt: 'violins+points+kde', extras: ['all'], - editType: 'style', - } }; -},{"../../lib/extend":227,"../box/attributes":353}],484:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib/extend":279,"../../plots/hoverformat_attributes":363,"../box/attributes":400}],531:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -97475,15 +102200,7 @@ function calcSpan(trace, cdi, valAxis, bandwidth) { return spanOut; } -},{"../../constants/numerical":212,"../../lib":233,"../../plots/cartesian/axes":279,"../box/calc":354,"./helpers":487}],485:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../constants/numerical":265,"../../lib":285,"../../plots/cartesian/axes":331,"../box/calc":401,"./helpers":534}],532:[function(_dereq_,module,exports){ 'use strict'; var setPositionOffset = _dereq_('../box/cross_trace_calc').setPositionOffset; @@ -97518,15 +102235,7 @@ module.exports = function crossTraceCalc(gd, plotinfo) { } }; -},{"../box/cross_trace_calc":355}],486:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../box/cross_trace_calc":402}],533:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -97579,15 +102288,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout if(!meanLineVisible) traceOut.meanline = {visible: false}; }; -},{"../../components/color":105,"../../lib":233,"../box/defaults":356,"./attributes":483}],487:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/color":155,"../../lib":285,"../box/defaults":403,"./attributes":530}],534:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -97652,15 +102353,7 @@ exports.getKdeValue = function(calcItem, trace, valueDist) { exports.extractVal = function(o) { return o.v; }; -},{"../../lib":233}],488:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285}],535:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -97668,7 +102361,10 @@ var Axes = _dereq_('../../plots/cartesian/axes'); var boxHoverPoints = _dereq_('../box/hover'); var helpers = _dereq_('./helpers'); -module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLayer) { +module.exports = function hoverPoints(pointData, xval, yval, hovermode, opts) { + if(!opts) opts = {}; + var hoverLayer = opts.hoverLayer; + var cd = pointData.cd; var trace = cd[0].trace; var hoveron = trace.hoveron; @@ -97713,7 +102409,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay kdePointData[pLetter + '0'] = pOnPath[0]; kdePointData[pLetter + '1'] = pOnPath[1]; kdePointData[vLetter + '0'] = kdePointData[vLetter + '1'] = vValPx; - kdePointData[vLetter + 'Label'] = vLetter + ': ' + Axes.hoverLabelText(vAxis, vVal) + ', ' + cd[0].t.labels.kde + ' ' + kdeVal.toFixed(3); + kdePointData[vLetter + 'Label'] = vLetter + ': ' + Axes.hoverLabelText(vAxis, vVal, trace[vLetter + 'hoverformat']) + ', ' + cd[0].t.labels.kde + ' ' + kdeVal.toFixed(3); // move the spike to the KDE point kdePointData.spikeDistance = closeBoxData[0].spikeDistance; @@ -97764,15 +102460,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay return closeData; }; -},{"../../lib":233,"../../plots/cartesian/axes":279,"../box/hover":358,"./helpers":487}],489:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../../plots/cartesian/axes":331,"../box/hover":405,"./helpers":534}],536:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -97794,19 +102482,10 @@ module.exports = { basePlotModule: _dereq_('../../plots/cartesian'), categories: ['cartesian', 'svg', 'symbols', 'oriented', 'box-violin', 'showLegend', 'violinLayout', 'zoomScale'], meta: { - } }; -},{"../../plots/cartesian":292,"../box/defaults":356,"../box/select":363,"../scatter/style":471,"./attributes":483,"./calc":484,"./cross_trace_calc":485,"./defaults":486,"./hover":488,"./layout_attributes":490,"./layout_defaults":491,"./plot":492,"./style":493}],490:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../plots/cartesian":344,"../box/defaults":403,"../box/select":410,"../scatter/style":518,"./attributes":530,"./calc":531,"./cross_trace_calc":532,"./defaults":533,"./hover":535,"./layout_attributes":537,"./layout_defaults":538,"./plot":539,"./style":540}],537:[function(_dereq_,module,exports){ 'use strict'; var boxLayoutAttrs = _dereq_('../box/layout_attributes'); @@ -97814,25 +102493,14 @@ var extendFlat = _dereq_('../../lib').extendFlat; module.exports = { violinmode: extendFlat({}, boxLayoutAttrs.boxmode, { - }), violingap: extendFlat({}, boxLayoutAttrs.boxgap, { - }), violingroupgap: extendFlat({}, boxLayoutAttrs.boxgroupgap, { - }) }; -},{"../../lib":233,"../box/layout_attributes":360}],491:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../box/layout_attributes":407}],538:[function(_dereq_,module,exports){ 'use strict'; var Lib = _dereq_('../../lib'); @@ -97846,18 +102514,10 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { boxLayoutDefaults._supply(layoutIn, layoutOut, fullData, coerce, 'violin'); }; -},{"../../lib":233,"../box/layout_defaults":361,"./layout_attributes":490}],492:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../lib":285,"../box/layout_defaults":408,"./layout_attributes":537}],539:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Lib = _dereq_('../../lib'); var Drawing = _dereq_('../../components/drawing'); @@ -98036,18 +102696,10 @@ module.exports = function plot(gd, plotinfo, cdViolins, violinLayer) { }); }; -},{"../../components/drawing":127,"../../lib":233,"../box/plot":362,"../scatter/line_points":461,"./helpers":487,"d3":21}],493:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ - +},{"../../components/drawing":177,"../../lib":285,"../box/plot":409,"../scatter/line_points":508,"./helpers":534,"@plotly/d3":20}],540:[function(_dereq_,module,exports){ 'use strict'; -var d3 = _dereq_('d3'); +var d3 = _dereq_('@plotly/d3'); var Color = _dereq_('../../components/color'); var stylePoints = _dereq_('../scatter/style').stylePoints; @@ -98091,21 +102743,1077 @@ module.exports = function style(gd) { }); }; -},{"../../components/color":105,"../scatter/style":471,"d3":21}],494:[function(_dereq_,module,exports){ -/** -* Copyright 2012-2020, Plotly, Inc. -* All rights reserved. -* -* This source code is licensed under the MIT license found in the -* LICENSE file in the root directory of this source tree. -*/ +},{"../../components/color":155,"../scatter/style":518,"@plotly/d3":20}],541:[function(_dereq_,module,exports){ +'use strict'; +var Axes = _dereq_('../plots/cartesian/axes'); +var Lib = _dereq_('../lib'); +var PlotSchema = _dereq_('../plot_api/plot_schema'); +var pointsAccessorFunction = _dereq_('./helpers').pointsAccessorFunction; +var BADNUM = _dereq_('../constants/numerical').BADNUM; + +exports.moduleType = 'transform'; + +exports.name = 'aggregate'; + +var attrs = exports.attributes = { + enabled: { + valType: 'boolean', + dflt: true, + editType: 'calc', + }, + groups: { + // TODO: groupby should support string or array grouping this way too + // currently groupby only allows a grouping array + valType: 'string', + strict: true, + noBlank: true, + arrayOk: true, + dflt: 'x', + editType: 'calc', + }, + aggregations: { + _isLinkedToArray: 'aggregation', + target: { + valType: 'string', + editType: 'calc', + }, + func: { + valType: 'enumerated', + values: ['count', 'sum', 'avg', 'median', 'mode', 'rms', 'stddev', 'min', 'max', 'first', 'last', 'change', 'range'], + dflt: 'first', + editType: 'calc', + }, + funcmode: { + valType: 'enumerated', + values: ['sample', 'population'], + dflt: 'sample', + editType: 'calc', + }, + enabled: { + valType: 'boolean', + dflt: true, + editType: 'calc', + }, + editType: 'calc' + }, + editType: 'calc' +}; + +var aggAttrs = attrs.aggregations; + +/** + * Supply transform attributes defaults + * + * @param {object} transformIn + * object linked to trace.transforms[i] with 'func' set to exports.name + * @param {object} traceOut + * the _fullData trace this transform applies to + * @param {object} layout + * the plot's (not-so-full) layout + * @param {object} traceIn + * the input data trace this transform applies to + * + * @return {object} transformOut + * copy of transformIn that contains attribute defaults + */ +exports.supplyDefaults = function(transformIn, traceOut) { + var transformOut = {}; + var i; + + function coerce(attr, dflt) { + return Lib.coerce(transformIn, transformOut, attrs, attr, dflt); + } + + var enabled = coerce('enabled'); + + if(!enabled) return transformOut; + + /* + * Normally _arrayAttrs is calculated during doCalc, but that comes later. + * Anyway this can change due to *count* aggregations (see below) so it's not + * necessarily the same set. + * + * For performance we turn it into an object of truthy values + * we'll use 1 for arrays we haven't aggregated yet, 0 for finished arrays, + * as distinct from undefined which means this array isn't present in the input + * missing arrays can still be aggregate outputs for *count* aggregations. + */ + var arrayAttrArray = PlotSchema.findArrayAttributes(traceOut); + var arrayAttrs = {}; + for(i = 0; i < arrayAttrArray.length; i++) arrayAttrs[arrayAttrArray[i]] = 1; + + var groups = coerce('groups'); + + if(!Array.isArray(groups)) { + if(!arrayAttrs[groups]) { + transformOut.enabled = false; + return transformOut; + } + arrayAttrs[groups] = 0; + } + + var aggregationsIn = transformIn.aggregations || []; + var aggregationsOut = transformOut.aggregations = new Array(aggregationsIn.length); + var aggregationOut; + + function coercei(attr, dflt) { + return Lib.coerce(aggregationsIn[i], aggregationOut, aggAttrs, attr, dflt); + } + + for(i = 0; i < aggregationsIn.length; i++) { + aggregationOut = {_index: i}; + var target = coercei('target'); + var func = coercei('func'); + var enabledi = coercei('enabled'); + + // add this aggregation to the output only if it's the first instance + // of a valid target attribute - or an unused target attribute with "count" + if(enabledi && target && (arrayAttrs[target] || (func === 'count' && arrayAttrs[target] === undefined))) { + if(func === 'stddev') coercei('funcmode'); + + arrayAttrs[target] = 0; + aggregationsOut[i] = aggregationOut; + } else aggregationsOut[i] = {enabled: false, _index: i}; + } + + // any array attributes we haven't yet covered, fill them with the default aggregation + for(i = 0; i < arrayAttrArray.length; i++) { + if(arrayAttrs[arrayAttrArray[i]]) { + aggregationsOut.push({ + target: arrayAttrArray[i], + func: aggAttrs.func.dflt, + enabled: true, + _index: -1 + }); + } + } + + return transformOut; +}; + + +exports.calcTransform = function(gd, trace, opts) { + if(!opts.enabled) return; + + var groups = opts.groups; + + var groupArray = Lib.getTargetArray(trace, {target: groups}); + if(!groupArray) return; + + var i, vi, groupIndex, newGrouping; + + var groupIndices = {}; + var indexToPoints = {}; + var groupings = []; + + var originalPointsAccessor = pointsAccessorFunction(trace.transforms, opts); + + var len = groupArray.length; + if(trace._length) len = Math.min(len, trace._length); + + for(i = 0; i < len; i++) { + vi = groupArray[i]; + groupIndex = groupIndices[vi]; + if(groupIndex === undefined) { + groupIndices[vi] = groupings.length; + newGrouping = [i]; + groupings.push(newGrouping); + indexToPoints[groupIndices[vi]] = originalPointsAccessor(i); + } else { + groupings[groupIndex].push(i); + indexToPoints[groupIndices[vi]] = (indexToPoints[groupIndices[vi]] || []).concat(originalPointsAccessor(i)); + } + } + + opts._indexToPoints = indexToPoints; + + var aggregations = opts.aggregations; + + for(i = 0; i < aggregations.length; i++) { + aggregateOneArray(gd, trace, groupings, aggregations[i]); + } + + if(typeof groups === 'string') { + aggregateOneArray(gd, trace, groupings, { + target: groups, + func: 'first', + enabled: true + }); + } + + trace._length = groupings.length; +}; + +function aggregateOneArray(gd, trace, groupings, aggregation) { + if(!aggregation.enabled) return; + + var attr = aggregation.target; + var targetNP = Lib.nestedProperty(trace, attr); + var arrayIn = targetNP.get(); + var conversions = Axes.getDataConversions(gd, trace, attr, arrayIn); + var func = getAggregateFunction(aggregation, conversions); + + var arrayOut = new Array(groupings.length); + for(var i = 0; i < groupings.length; i++) { + arrayOut[i] = func(arrayIn, groupings[i]); + } + targetNP.set(arrayOut); + + if(aggregation.func === 'count') { + // count does not depend on an input array, so it's likely not part of _arrayAttrs yet + // but after this transform it most definitely *is* an array attribute. + Lib.pushUnique(trace._arrayAttrs, attr); + } +} + +function getAggregateFunction(opts, conversions) { + var func = opts.func; + var d2c = conversions.d2c; + var c2d = conversions.c2d; + + switch(func) { + // count, first, and last don't depend on anything about the data + // point back to pure functions for performance + case 'count': + return count; + case 'first': + return first; + case 'last': + return last; + + case 'sum': + // This will produce output in all cases even though it's nonsensical + // for date or category data. + return function(array, indices) { + var total = 0; + for(var i = 0; i < indices.length; i++) { + var vi = d2c(array[indices[i]]); + if(vi !== BADNUM) total += vi; + } + return c2d(total); + }; + + case 'avg': + // Generally meaningless for category data but it still does something. + return function(array, indices) { + var total = 0; + var cnt = 0; + for(var i = 0; i < indices.length; i++) { + var vi = d2c(array[indices[i]]); + if(vi !== BADNUM) { + total += vi; + cnt++; + } + } + return cnt ? c2d(total / cnt) : BADNUM; + }; + + case 'min': + return function(array, indices) { + var out = Infinity; + for(var i = 0; i < indices.length; i++) { + var vi = d2c(array[indices[i]]); + if(vi !== BADNUM) out = Math.min(out, vi); + } + return (out === Infinity) ? BADNUM : c2d(out); + }; + + case 'max': + return function(array, indices) { + var out = -Infinity; + for(var i = 0; i < indices.length; i++) { + var vi = d2c(array[indices[i]]); + if(vi !== BADNUM) out = Math.max(out, vi); + } + return (out === -Infinity) ? BADNUM : c2d(out); + }; + + case 'range': + return function(array, indices) { + var min = Infinity; + var max = -Infinity; + for(var i = 0; i < indices.length; i++) { + var vi = d2c(array[indices[i]]); + if(vi !== BADNUM) { + min = Math.min(min, vi); + max = Math.max(max, vi); + } + } + return (max === -Infinity || min === Infinity) ? BADNUM : c2d(max - min); + }; + + case 'change': + return function(array, indices) { + var first = d2c(array[indices[0]]); + var last = d2c(array[indices[indices.length - 1]]); + return (first === BADNUM || last === BADNUM) ? BADNUM : c2d(last - first); + }; + + case 'median': + return function(array, indices) { + var sortCalc = []; + for(var i = 0; i < indices.length; i++) { + var vi = d2c(array[indices[i]]); + if(vi !== BADNUM) sortCalc.push(vi); + } + if(!sortCalc.length) return BADNUM; + sortCalc.sort(Lib.sorterAsc); + var mid = (sortCalc.length - 1) / 2; + return c2d((sortCalc[Math.floor(mid)] + sortCalc[Math.ceil(mid)]) / 2); + }; + + case 'mode': + return function(array, indices) { + var counts = {}; + var maxCnt = 0; + var out = BADNUM; + for(var i = 0; i < indices.length; i++) { + var vi = d2c(array[indices[i]]); + if(vi !== BADNUM) { + var counti = counts[vi] = (counts[vi] || 0) + 1; + if(counti > maxCnt) { + maxCnt = counti; + out = vi; + } + } + } + return maxCnt ? c2d(out) : BADNUM; + }; + + case 'rms': + return function(array, indices) { + var total = 0; + var cnt = 0; + for(var i = 0; i < indices.length; i++) { + var vi = d2c(array[indices[i]]); + if(vi !== BADNUM) { + total += vi * vi; + cnt++; + } + } + return cnt ? c2d(Math.sqrt(total / cnt)) : BADNUM; + }; + + case 'stddev': + return function(array, indices) { + // balance numerical stability with performance: + // so that we call d2c once per element but don't need to + // store them, reference all to the first element + var total = 0; + var total2 = 0; + var cnt = 1; + var v0 = BADNUM; + var i; + for(i = 0; i < indices.length && v0 === BADNUM; i++) { + v0 = d2c(array[indices[i]]); + } + if(v0 === BADNUM) return BADNUM; + + for(; i < indices.length; i++) { + var vi = d2c(array[indices[i]]); + if(vi !== BADNUM) { + var dv = vi - v0; + total += dv; + total2 += dv * dv; + cnt++; + } + } + + // This is population std dev, if we want sample std dev + // we would need (...) / (cnt - 1) + // Also note there's no c2d here - that means for dates the result + // is a number of milliseconds, and for categories it's a number + // of category differences, which is not generically meaningful but + // as in other cases we don't forbid it. + var norm = (opts.funcmode === 'sample') ? (cnt - 1) : cnt; + // this is debatable: should a count of 1 return sample stddev of + // 0 or undefined? + if(!norm) return 0; + return Math.sqrt((total2 - (total * total / cnt)) / norm); + }; + } +} + +function count(array, indices) { + return indices.length; +} + +function first(array, indices) { + return array[indices[0]]; +} + +function last(array, indices) { + return array[indices[indices.length - 1]]; +} + +},{"../constants/numerical":265,"../lib":285,"../plot_api/plot_schema":319,"../plots/cartesian/axes":331,"./helpers":544}],542:[function(_dereq_,module,exports){ +'use strict'; + +var Lib = _dereq_('../lib'); +var Registry = _dereq_('../registry'); +var Axes = _dereq_('../plots/cartesian/axes'); +var pointsAccessorFunction = _dereq_('./helpers').pointsAccessorFunction; + +var filterOps = _dereq_('../constants/filter_ops'); +var COMPARISON_OPS = filterOps.COMPARISON_OPS; +var INTERVAL_OPS = filterOps.INTERVAL_OPS; +var SET_OPS = filterOps.SET_OPS; + +exports.moduleType = 'transform'; + +exports.name = 'filter'; + +exports.attributes = { + enabled: { + valType: 'boolean', + dflt: true, + editType: 'calc', + }, + target: { + valType: 'string', + strict: true, + noBlank: true, + arrayOk: true, + dflt: 'x', + editType: 'calc', + }, + operation: { + valType: 'enumerated', + values: [] + .concat(COMPARISON_OPS) + .concat(INTERVAL_OPS) + .concat(SET_OPS), + dflt: '=', + editType: 'calc', + }, + value: { + valType: 'any', + dflt: 0, + editType: 'calc', + }, + preservegaps: { + valType: 'boolean', + dflt: false, + editType: 'calc', + }, + editType: 'calc' +}; + +exports.supplyDefaults = function(transformIn) { + var transformOut = {}; + + function coerce(attr, dflt) { + return Lib.coerce(transformIn, transformOut, exports.attributes, attr, dflt); + } + + var enabled = coerce('enabled'); + + if(enabled) { + var target = coerce('target'); + + if(Lib.isArrayOrTypedArray(target) && target.length === 0) { + transformOut.enabled = false; + return transformOut; + } + + coerce('preservegaps'); + coerce('operation'); + coerce('value'); + + var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleDefaults'); + handleCalendarDefaults(transformIn, transformOut, 'valuecalendar', null); + handleCalendarDefaults(transformIn, transformOut, 'targetcalendar', null); + } + + return transformOut; +}; + +exports.calcTransform = function(gd, trace, opts) { + if(!opts.enabled) return; + + var targetArray = Lib.getTargetArray(trace, opts); + if(!targetArray) return; + + var target = opts.target; + + var len = targetArray.length; + if(trace._length) len = Math.min(len, trace._length); + + var targetCalendar = opts.targetcalendar; + var arrayAttrs = trace._arrayAttrs; + var preservegaps = opts.preservegaps; + + // even if you provide targetcalendar, if target is a string and there + // is a calendar attribute matching target it will get used instead. + if(typeof target === 'string') { + var attrTargetCalendar = Lib.nestedProperty(trace, target + 'calendar').get(); + if(attrTargetCalendar) targetCalendar = attrTargetCalendar; + } + + var d2c = Axes.getDataToCoordFunc(gd, trace, target, targetArray); + var filterFunc = getFilterFunc(opts, d2c, targetCalendar); + var originalArrays = {}; + var indexToPoints = {}; + var index = 0; + + function forAllAttrs(fn, index) { + for(var j = 0; j < arrayAttrs.length; j++) { + var np = Lib.nestedProperty(trace, arrayAttrs[j]); + fn(np, index); + } + } + + var initFn; + var fillFn; + if(preservegaps) { + initFn = function(np) { + originalArrays[np.astr] = Lib.extendDeep([], np.get()); + np.set(new Array(len)); + }; + fillFn = function(np, index) { + var val = originalArrays[np.astr][index]; + np.get()[index] = val; + }; + } else { + initFn = function(np) { + originalArrays[np.astr] = Lib.extendDeep([], np.get()); + np.set([]); + }; + fillFn = function(np, index) { + var val = originalArrays[np.astr][index]; + np.get().push(val); + }; + } + + // copy all original array attribute values, and clear arrays in trace + forAllAttrs(initFn); + + var originalPointsAccessor = pointsAccessorFunction(trace.transforms, opts); + + // loop through filter array, fill trace arrays if passed + for(var i = 0; i < len; i++) { + var passed = filterFunc(targetArray[i]); + if(passed) { + forAllAttrs(fillFn, i); + indexToPoints[index++] = originalPointsAccessor(i); + } else if(preservegaps) index++; + } + + opts._indexToPoints = indexToPoints; + trace._length = index; +}; + +function getFilterFunc(opts, d2c, targetCalendar) { + var operation = opts.operation; + var value = opts.value; + var hasArrayValue = Array.isArray(value); + + function isOperationIn(array) { + return array.indexOf(operation) !== -1; + } + + var d2cValue = function(v) { return d2c(v, 0, opts.valuecalendar); }; + var d2cTarget = function(v) { return d2c(v, 0, targetCalendar); }; + + var coercedValue; + + if(isOperationIn(COMPARISON_OPS)) { + coercedValue = hasArrayValue ? d2cValue(value[0]) : d2cValue(value); + } else if(isOperationIn(INTERVAL_OPS)) { + coercedValue = hasArrayValue ? + [d2cValue(value[0]), d2cValue(value[1])] : + [d2cValue(value), d2cValue(value)]; + } else if(isOperationIn(SET_OPS)) { + coercedValue = hasArrayValue ? value.map(d2cValue) : [d2cValue(value)]; + } + + switch(operation) { + case '=': + return function(v) { return d2cTarget(v) === coercedValue; }; + + case '!=': + return function(v) { return d2cTarget(v) !== coercedValue; }; + + case '<': + return function(v) { return d2cTarget(v) < coercedValue; }; + + case '<=': + return function(v) { return d2cTarget(v) <= coercedValue; }; + + case '>': + return function(v) { return d2cTarget(v) > coercedValue; }; + + case '>=': + return function(v) { return d2cTarget(v) >= coercedValue; }; + + case '[]': + return function(v) { + var cv = d2cTarget(v); + return cv >= coercedValue[0] && cv <= coercedValue[1]; + }; + + case '()': + return function(v) { + var cv = d2cTarget(v); + return cv > coercedValue[0] && cv < coercedValue[1]; + }; + + case '[)': + return function(v) { + var cv = d2cTarget(v); + return cv >= coercedValue[0] && cv < coercedValue[1]; + }; + + case '(]': + return function(v) { + var cv = d2cTarget(v); + return cv > coercedValue[0] && cv <= coercedValue[1]; + }; + + case '][': + return function(v) { + var cv = d2cTarget(v); + return cv <= coercedValue[0] || cv >= coercedValue[1]; + }; + + case ')(': + return function(v) { + var cv = d2cTarget(v); + return cv < coercedValue[0] || cv > coercedValue[1]; + }; + + case '](': + return function(v) { + var cv = d2cTarget(v); + return cv <= coercedValue[0] || cv > coercedValue[1]; + }; + + case ')[': + return function(v) { + var cv = d2cTarget(v); + return cv < coercedValue[0] || cv >= coercedValue[1]; + }; + + case '{}': + return function(v) { + return coercedValue.indexOf(d2cTarget(v)) !== -1; + }; + + case '}{': + return function(v) { + return coercedValue.indexOf(d2cTarget(v)) === -1; + }; + } +} + +},{"../constants/filter_ops":263,"../lib":285,"../plots/cartesian/axes":331,"../registry":373,"./helpers":544}],543:[function(_dereq_,module,exports){ +'use strict'; + +var Lib = _dereq_('../lib'); +var PlotSchema = _dereq_('../plot_api/plot_schema'); +var Plots = _dereq_('../plots/plots'); +var pointsAccessorFunction = _dereq_('./helpers').pointsAccessorFunction; + +exports.moduleType = 'transform'; + +exports.name = 'groupby'; + +exports.attributes = { + enabled: { + valType: 'boolean', + dflt: true, + editType: 'calc', + }, + groups: { + valType: 'data_array', + dflt: [], + editType: 'calc', + }, + nameformat: { + valType: 'string', + editType: 'calc', + }, + styles: { + _isLinkedToArray: 'style', + target: { + valType: 'string', + editType: 'calc', + }, + value: { + valType: 'any', + dflt: {}, + editType: 'calc', + _compareAsJSON: true + }, + editType: 'calc' + }, + editType: 'calc' +}; + +/** + * Supply transform attributes defaults + * + * @param {object} transformIn + * object linked to trace.transforms[i] with 'type' set to exports.name + * @param {object} traceOut + * the _fullData trace this transform applies to + * @param {object} layout + * the plot's (not-so-full) layout + * @param {object} traceIn + * the input data trace this transform applies to + * + * @return {object} transformOut + * copy of transformIn that contains attribute defaults + */ +exports.supplyDefaults = function(transformIn, traceOut, layout) { + var i; + var transformOut = {}; + + function coerce(attr, dflt) { + return Lib.coerce(transformIn, transformOut, exports.attributes, attr, dflt); + } + + var enabled = coerce('enabled'); + + if(!enabled) return transformOut; + + coerce('groups'); + coerce('nameformat', layout._dataLength > 1 ? '%{group} (%{trace})' : '%{group}'); + + var styleIn = transformIn.styles; + var styleOut = transformOut.styles = []; + + if(styleIn) { + for(i = 0; i < styleIn.length; i++) { + var thisStyle = styleOut[i] = {}; + Lib.coerce(styleIn[i], styleOut[i], exports.attributes.styles, 'target'); + var value = Lib.coerce(styleIn[i], styleOut[i], exports.attributes.styles, 'value'); + + // so that you can edit value in place and have Plotly.react notice it, or + // rebuild it every time and have Plotly.react NOT think it changed: + // use _compareAsJSON to say we should diff the _JSON_value + if(Lib.isPlainObject(value)) thisStyle.value = Lib.extendDeep({}, value); + else if(value) delete thisStyle.value; + } + } + + return transformOut; +}; + + +/** + * Apply transform !!! + * + * @param {array} data + * array of transformed traces (is [fullTrace] upon first transform) + * + * @param {object} state + * state object which includes: + * - transform {object} full transform attributes + * - fullTrace {object} full trace object which is being transformed + * - fullData {array} full pre-transform(s) data array + * - layout {object} the plot's (not-so-full) layout + * + * @return {object} newData + * array of transformed traces + */ +exports.transform = function(data, state) { + var newTraces, i, j; + var newData = []; + + for(i = 0; i < data.length; i++) { + newTraces = transformOne(data[i], state); + + for(j = 0; j < newTraces.length; j++) { + newData.push(newTraces[j]); + } + } + + return newData; +}; + +function transformOne(trace, state) { + var i, j, k, attr, srcArray, groupName, newTrace, transforms, arrayLookup; + var groupNameObj; + + var opts = state.transform; + var transformIndex = state.transformIndex; + var groups = trace.transforms[transformIndex].groups; + var originalPointsAccessor = pointsAccessorFunction(trace.transforms, opts); + + if(!(Lib.isArrayOrTypedArray(groups)) || groups.length === 0) { + return [trace]; + } + + var groupNames = Lib.filterUnique(groups); + var newData = new Array(groupNames.length); + var len = groups.length; + + var arrayAttrs = PlotSchema.findArrayAttributes(trace); + + var styles = opts.styles || []; + var styleLookup = {}; + for(i = 0; i < styles.length; i++) { + styleLookup[styles[i].target] = styles[i].value; + } + + if(opts.styles) { + groupNameObj = Lib.keyedContainer(opts, 'styles', 'target', 'value.name'); + } + + // An index to map group name --> expanded trace index + var indexLookup = {}; + var indexCnts = {}; + + for(i = 0; i < groupNames.length; i++) { + groupName = groupNames[i]; + indexLookup[groupName] = i; + indexCnts[groupName] = 0; + + // Start with a deep extend that just copies array references. + newTrace = newData[i] = Lib.extendDeepNoArrays({}, trace); + newTrace._group = groupName; + newTrace.transforms[transformIndex]._indexToPoints = {}; + + var suppliedName = null; + if(groupNameObj) { + suppliedName = groupNameObj.get(groupName); + } + + if(suppliedName || suppliedName === '') { + newTrace.name = suppliedName; + } else { + newTrace.name = Lib.templateString(opts.nameformat, { + trace: trace.name, + group: groupName + }); + } + + // In order for groups to apply correctly to other transform data (e.g. + // a filter transform), we have to break the connection and clone the + // transforms so that each group writes grouped values into a different + // destination. This function does not break the array reference + // connection between the split transforms it creates. That's handled in + // initialize, which creates a new empty array for each arrayAttr. + transforms = newTrace.transforms; + newTrace.transforms = []; + for(j = 0; j < transforms.length; j++) { + newTrace.transforms[j] = Lib.extendDeepNoArrays({}, transforms[j]); + } + + // Initialize empty arrays for the arrayAttrs, to be split in the next step + for(j = 0; j < arrayAttrs.length; j++) { + Lib.nestedProperty(newTrace, arrayAttrs[j]).set([]); + } + } + + // For each array attribute including those nested inside this and other + // transforms (small note that we technically only need to do this for + // transforms that have not yet been applied): + for(k = 0; k < arrayAttrs.length; k++) { + attr = arrayAttrs[k]; + + // Cache all the arrays to which we'll push: + for(j = 0, arrayLookup = []; j < groupNames.length; j++) { + arrayLookup[j] = Lib.nestedProperty(newData[j], attr).get(); + } + + // Get the input data: + srcArray = Lib.nestedProperty(trace, attr).get(); + + // Send each data point to the appropriate expanded trace: + for(j = 0; j < len; j++) { + // Map group data --> trace index --> array and push data onto it + arrayLookup[indexLookup[groups[j]]].push(srcArray[j]); + } + } + + for(j = 0; j < len; j++) { + newTrace = newData[indexLookup[groups[j]]]; + + var indexToPoints = newTrace.transforms[transformIndex]._indexToPoints; + indexToPoints[indexCnts[groups[j]]] = originalPointsAccessor(j); + indexCnts[groups[j]]++; + } + + for(i = 0; i < groupNames.length; i++) { + groupName = groupNames[i]; + newTrace = newData[i]; + + Plots.clearExpandedTraceDefaultColors(newTrace); + + // there's no need to coerce styleLookup[groupName] here + // as another round of supplyDefaults is done on the transformed traces + newTrace = Lib.extendDeepNoArrays(newTrace, styleLookup[groupName] || {}); + } + + return newData; +} + +},{"../lib":285,"../plot_api/plot_schema":319,"../plots/plots":366,"./helpers":544}],544:[function(_dereq_,module,exports){ +'use strict'; + +exports.pointsAccessorFunction = function(transforms, opts) { + var tr; + var prevIndexToPoints; + for(var i = 0; i < transforms.length; i++) { + tr = transforms[i]; + if(tr === opts) break; + if(!tr._indexToPoints || tr.enabled === false) continue; + prevIndexToPoints = tr._indexToPoints; + } + var originalPointsAccessor = prevIndexToPoints ? + function(i) {return prevIndexToPoints[i];} : + function(i) {return [i];}; + return originalPointsAccessor; +}; + +},{}],545:[function(_dereq_,module,exports){ +'use strict'; + +var Lib = _dereq_('../lib'); +var Axes = _dereq_('../plots/cartesian/axes'); +var pointsAccessorFunction = _dereq_('./helpers').pointsAccessorFunction; + +var BADNUM = _dereq_('../constants/numerical').BADNUM; + +exports.moduleType = 'transform'; + +exports.name = 'sort'; + +exports.attributes = { + enabled: { + valType: 'boolean', + dflt: true, + editType: 'calc', + }, + target: { + valType: 'string', + strict: true, + noBlank: true, + arrayOk: true, + dflt: 'x', + editType: 'calc', + }, + order: { + valType: 'enumerated', + values: ['ascending', 'descending'], + dflt: 'ascending', + editType: 'calc', + }, + editType: 'calc' +}; + +exports.supplyDefaults = function(transformIn) { + var transformOut = {}; + + function coerce(attr, dflt) { + return Lib.coerce(transformIn, transformOut, exports.attributes, attr, dflt); + } + + var enabled = coerce('enabled'); + + if(enabled) { + coerce('target'); + coerce('order'); + } + + return transformOut; +}; + +exports.calcTransform = function(gd, trace, opts) { + if(!opts.enabled) return; + + var targetArray = Lib.getTargetArray(trace, opts); + if(!targetArray) return; + + var target = opts.target; + + var len = targetArray.length; + if(trace._length) len = Math.min(len, trace._length); + + var arrayAttrs = trace._arrayAttrs; + var d2c = Axes.getDataToCoordFunc(gd, trace, target, targetArray); + var indices = getIndices(opts, targetArray, d2c, len); + var originalPointsAccessor = pointsAccessorFunction(trace.transforms, opts); + var indexToPoints = {}; + var i, j; + + for(i = 0; i < arrayAttrs.length; i++) { + var np = Lib.nestedProperty(trace, arrayAttrs[i]); + var arrayOld = np.get(); + var arrayNew = new Array(len); + + for(j = 0; j < len; j++) { + arrayNew[j] = arrayOld[indices[j]]; + } + + np.set(arrayNew); + } + + for(j = 0; j < len; j++) { + indexToPoints[j] = originalPointsAccessor(indices[j]); + } + + opts._indexToPoints = indexToPoints; + trace._length = len; +}; + +function getIndices(opts, targetArray, d2c, len) { + var sortedArray = new Array(len); + var indices = new Array(len); + var i; + + for(i = 0; i < len; i++) { + sortedArray[i] = {v: targetArray[i], i: i}; + } + + sortedArray.sort(getSortFunc(opts, d2c)); + + for(i = 0; i < len; i++) { + indices[i] = sortedArray[i].i; + } + + return indices; +} + +function getSortFunc(opts, d2c) { + switch(opts.order) { + case 'ascending': + return function(a, b) { + var ac = d2c(a.v); + var bc = d2c(b.v); + if(ac === BADNUM) { + return 1; + } + if(bc === BADNUM) { + return -1; + } + return ac - bc; + }; + case 'descending': + return function(a, b) { + var ac = d2c(a.v); + var bc = d2c(b.v); + if(ac === BADNUM) { + return 1; + } + if(bc === BADNUM) { + return -1; + } + return bc - ac; + }; + } +} + +},{"../constants/numerical":265,"../lib":285,"../plots/cartesian/axes":331,"./helpers":544}],546:[function(_dereq_,module,exports){ 'use strict'; // package version injected by `npm run preprocess` -exports.version = '1.58.4'; +exports.version = '2.0.0'; -},{}]},{},[11])(11) +},{}]},{},[15])(15) }); var locale={moduleType:"locale",name:"de",dictionary:{Autoscale:"Automatische Skalierung","Box Select":"Rechteckauswahl","Click to enter Colorscale title":"Klicken, um den Farbskalatitel einzugeben","Click to enter Component A title":"Klicken, um den Titel der Komponente A einzugeben","Click to enter Component B title":"Klicken, um den Titel der Komponente B einzugeben","Click to enter Component C title":"Klicken, um den Titel der Komponente C einzugeben","Click to enter Plot title":"Klicken, um den Titel des Graphen einzugeben","Click to enter X axis title":"Klicken, um den Titel der X-Achse einzugeben","Click to enter Y axis title":"Klicken, um den Titel der Y-Achse einzugeben","Compare data on hover":"\xdcber die Daten fahren, um sie zu vergleichen","Double-click on legend to isolate one trace":"Daten isolieren durch Doppelklick in der Legende","Double-click to zoom back out":"Herauszoomen durch Doppelklick","Download plot as a png":"Graphen als PNG herunterladen","Download plot":"Graphen herunterladen","Edit in Chart Studio":"Im Chart Studio bearbeiten","IE only supports svg. Changing format to svg.":"IE unterst\xfctzt nur SVG-Dateien. Format wird zu SVG gewechselt.","Lasso Select":"Lassoauswahl","Orbital rotation":"Orbitalrotation",Pan:"Verschieben","Produced with Plotly":"Erstellt mit Plotly",Reset:"Zur\xfccksetzen","Reset axes":"Achsen zur\xfccksetzen","Reset camera to default":"Kamera auf Standard zur\xfccksetzen","Reset camera to last save":"Kamera auf letzte Speicherung zur\xfccksetzen","Reset view":"Ansicht zur\xfccksetzen","Reset views":"Ansichten zur\xfccksetzen","Show closest data on hover":"Zeige n\xe4heste Daten beim \xdcberfahren","Snapshot succeeded":"Snapshot erfolgreich","Sorry, there was a problem downloading your snapshot!":"Es gab ein Problem beim Herunterladen des Snapshots","Taking snapshot - this may take a few seconds":"Erstelle einen Snapshot - dies kann einige Sekunden dauern",Zoom:"Zoom","Zoom in":"Hineinzoomen","Zoom out":"Herauszoomen","close:":"Schluss:",trace:"Datenspur","lat:":"Lat.:","lon:":"Lon.:","q1:":"q1:","q3:":"q3:","source:":"Quelle:","target:":"Ziel:","lower fence:":"Untere Schranke:","upper fence:":"Obere Schranke:","max:":"Max.:","mean \xb1 \u03c3:":"Mittelwert \xb1 \u03c3:","mean:":"Mittelwert:","median:":"Median:","min:":"Min.:","Turntable rotation":"Drehscheibenorbit","Toggle Spike Lines":"Bezugslinien an-/abschalten","open:":"Er\xf6ffnung:","high:":"H\xf6chstkurs:","low:":"Tiefstkurs:","Toggle show closest data on hover":"Anzeige der n\xe4hesten Daten an-/abschalten","incoming flow count:":"Anzahl eingehender Verbindungen:","outgoing flow count:":"Anzahl ausgehender Verbindungen:","kde:":"Dichte:"},format:{days:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"],shortDays:["So","Mo","Di","Mi","Do","Fr","Sa"],months:["Januar","Februar","M\xe4rz","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],shortMonths:["Jan","Feb","M\xe4r","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"],date:"%d.%m.%Y",decimal:",",thousands:"."}};"undefined"==typeof Plotly?(window.PlotlyLocales=window.PlotlyLocales||[],window.PlotlyLocales.push(locale)):Plotly.register(locale); diff --git a/static/babybuddy/js/graph.js.gz b/static/babybuddy/js/graph.js.gz index 3c37ceaa..62dd672b 100644 Binary files a/static/babybuddy/js/graph.js.gz and b/static/babybuddy/js/graph.js.gz differ diff --git a/static/staticfiles.json b/static/staticfiles.json index 6c5fbee7..aa1b04b2 100644 --- a/static/staticfiles.json +++ b/static/staticfiles.json @@ -1 +1 @@ -{"paths": {"admin/js/vendor/select2/i18n/bg.js": "admin/js/vendor/select2/i18n/bg.39b8be30d4f0.js", "admin/js/vendor/select2/i18n/en.js": "admin/js/vendor/select2/i18n/en.cf932ba09a98.js", "admin/js/vendor/select2/i18n/lt.js": "admin/js/vendor/select2/i18n/lt.23c7ce903300.js", "admin/js/vendor/select2/i18n/zh-TW.js": "admin/js/vendor/select2/i18n/zh-TW.04554a227c2b.js", "admin/js/vendor/select2/i18n/is.js": "admin/js/vendor/select2/i18n/is.3ddd9a6a97e9.js", "admin/js/vendor/select2/i18n/vi.js": "admin/js/vendor/select2/i18n/vi.097a5b75b3e1.js", "admin/js/vendor/select2/i18n/sk.js": "admin/js/vendor/select2/i18n/sk.33d02cef8d11.js", "admin/js/vendor/select2/i18n/cs.js": "admin/js/vendor/select2/i18n/cs.4f43e8e7d33a.js", "admin/js/vendor/select2/i18n/ps.js": "admin/js/vendor/select2/i18n/ps.38dfa47af9e0.js", "admin/js/vendor/select2/i18n/hy.js": "admin/js/vendor/select2/i18n/hy.c7babaeef5a6.js", "admin/js/vendor/select2/i18n/eu.js": "admin/js/vendor/select2/i18n/eu.adfe5c97b72c.js", "admin/js/vendor/select2/i18n/nl.js": "admin/js/vendor/select2/i18n/nl.997868a37ed8.js", "admin/js/vendor/select2/i18n/tk.js": "admin/js/vendor/select2/i18n/tk.7c572a68c78f.js", "admin/js/vendor/select2/i18n/sr-Cyrl.js": "admin/js/vendor/select2/i18n/sr-Cyrl.f254bb8c4c7c.js", "admin/js/vendor/select2/i18n/az.js": "admin/js/vendor/select2/i18n/az.270c257daf81.js", "admin/js/vendor/select2/i18n/he.js": "admin/js/vendor/select2/i18n/he.e420ff6cd3ed.js", "admin/js/vendor/select2/i18n/af.js": "admin/js/vendor/select2/i18n/af.4f6fcd73488c.js", "admin/js/vendor/select2/i18n/ms.js": "admin/js/vendor/select2/i18n/ms.4ba82c9a51ce.js", "admin/js/vendor/select2/i18n/uk.js": "admin/js/vendor/select2/i18n/uk.8cede7f4803c.js", "admin/js/vendor/select2/i18n/sr.js": "admin/js/vendor/select2/i18n/sr.5ed85a48f483.js", "admin/js/vendor/select2/i18n/sv.js": "admin/js/vendor/select2/i18n/sv.7a9c2f71e777.js", "admin/js/vendor/select2/i18n/es.js": "admin/js/vendor/select2/i18n/es.66dbc2652fb1.js", "admin/js/vendor/select2/i18n/ka.js": "admin/js/vendor/select2/i18n/ka.2083264a54f0.js", "admin/js/vendor/select2/i18n/dsb.js": "admin/js/vendor/select2/i18n/dsb.56372c92d2f1.js", "admin/js/vendor/select2/i18n/hi.js": "admin/js/vendor/select2/i18n/hi.70640d41628f.js", "admin/js/vendor/select2/i18n/tr.js": "admin/js/vendor/select2/i18n/tr.b5a0643d1545.js", "admin/js/vendor/select2/i18n/ne.js": "admin/js/vendor/select2/i18n/ne.3d79fd3f08db.js", "admin/js/vendor/select2/i18n/ru.js": "admin/js/vendor/select2/i18n/ru.934aa95f5b5f.js", "admin/js/vendor/select2/i18n/sl.js": "admin/js/vendor/select2/i18n/sl.131a78bc0752.js", "admin/js/vendor/select2/i18n/hsb.js": "admin/js/vendor/select2/i18n/hsb.fa3b55265efe.js", "admin/js/vendor/select2/i18n/id.js": "admin/js/vendor/select2/i18n/id.04debded514d.js", "admin/js/vendor/select2/i18n/de.js": "admin/js/vendor/select2/i18n/de.8a1c222b0204.js", "admin/js/vendor/select2/i18n/bs.js": "admin/js/vendor/select2/i18n/bs.91624382358e.js", "admin/js/vendor/select2/i18n/th.js": "admin/js/vendor/select2/i18n/th.f38c20b0221b.js", "admin/js/vendor/select2/i18n/mk.js": "admin/js/vendor/select2/i18n/mk.dabbb9087130.js", "admin/js/vendor/select2/i18n/zh-CN.js": "admin/js/vendor/select2/i18n/zh-CN.2cff662ec5f9.js", "admin/js/vendor/select2/i18n/km.js": "admin/js/vendor/select2/i18n/km.c23089cb06ca.js", "admin/js/vendor/select2/i18n/ca.js": "admin/js/vendor/select2/i18n/ca.a166b745933a.js", "admin/js/vendor/select2/i18n/hr.js": "admin/js/vendor/select2/i18n/hr.a2b092cc1147.js", "admin/js/vendor/select2/i18n/ar.js": "admin/js/vendor/select2/i18n/ar.65aa8e36bf5d.js", "admin/js/vendor/select2/i18n/pl.js": "admin/js/vendor/select2/i18n/pl.6031b4f16452.js", "admin/js/vendor/select2/i18n/pt.js": "admin/js/vendor/select2/i18n/pt.33b4a3b44d43.js", "admin/js/vendor/select2/i18n/hu.js": "admin/js/vendor/select2/i18n/hu.6ec6039cb8a3.js", "admin/js/vendor/select2/i18n/ja.js": "admin/js/vendor/select2/i18n/ja.170ae885d74f.js", "admin/js/vendor/select2/i18n/fr.js": "admin/js/vendor/select2/i18n/fr.05e0542fcfe6.js", "admin/js/vendor/select2/i18n/ko.js": "admin/js/vendor/select2/i18n/ko.e7be6c20e673.js", "admin/js/vendor/select2/i18n/el.js": "admin/js/vendor/select2/i18n/el.27097f071856.js", "admin/js/vendor/select2/i18n/fi.js": "admin/js/vendor/select2/i18n/fi.614ec42aa9ba.js", "admin/js/vendor/select2/i18n/da.js": "admin/js/vendor/select2/i18n/da.766346afe4dd.js", "admin/js/vendor/select2/i18n/gl.js": "admin/js/vendor/select2/i18n/gl.d99b1fedaa86.js", "admin/js/vendor/select2/i18n/lv.js": "admin/js/vendor/select2/i18n/lv.08e62128eac1.js", "admin/js/vendor/select2/i18n/ro.js": "admin/js/vendor/select2/i18n/ro.f75cb460ec3b.js", "admin/js/vendor/select2/i18n/it.js": "admin/js/vendor/select2/i18n/it.be4fe8d365b5.js", "admin/js/vendor/select2/i18n/fa.js": "admin/js/vendor/select2/i18n/fa.3b5bd1961cfd.js", "admin/js/vendor/select2/i18n/nb.js": "admin/js/vendor/select2/i18n/nb.da2fce143f27.js", "admin/js/vendor/select2/i18n/pt-BR.js": "admin/js/vendor/select2/i18n/pt-BR.e1b294433e7f.js", "admin/js/vendor/select2/i18n/bn.js": "admin/js/vendor/select2/i18n/bn.6d42b4dd5665.js", "admin/js/vendor/select2/i18n/sq.js": "admin/js/vendor/select2/i18n/sq.5636b60d29c9.js", "admin/js/vendor/select2/i18n/et.js": "admin/js/vendor/select2/i18n/et.2b96fd98289d.js", "admin/js/vendor/xregexp/xregexp.min.js": "admin/js/vendor/xregexp/xregexp.min.b0439563a5d3.js", "admin/js/vendor/xregexp/xregexp.js": "admin/js/vendor/xregexp/xregexp.efda034b9537.js", "admin/js/vendor/xregexp/LICENSE.txt": "admin/js/vendor/xregexp/LICENSE.bf79e414957a.txt", "admin/js/vendor/select2/LICENSE.md": "admin/js/vendor/select2/LICENSE.f94142512c91.md", "admin/js/vendor/select2/select2.full.js": "admin/js/vendor/select2/select2.full.c2afdeda3058.js", "admin/js/vendor/select2/select2.full.min.js": "admin/js/vendor/select2/select2.full.min.fcd7500d8e13.js", "admin/js/vendor/jquery/jquery.min.js": "admin/js/vendor/jquery/jquery.min.dc5e7f18c8d3.js", "admin/js/vendor/jquery/jquery.js": "admin/js/vendor/jquery/jquery.23c7c5d2d131.js", "admin/js/vendor/jquery/LICENSE.txt": "admin/js/vendor/jquery/LICENSE.75308107741f.txt", "admin/css/vendor/select2/select2.css": "admin/css/vendor/select2/select2.a2194c262648.css", "admin/css/vendor/select2/LICENSE-SELECT2.md": "admin/css/vendor/select2/LICENSE-SELECT2.f94142512c91.md", "admin/css/vendor/select2/select2.min.css": "admin/css/vendor/select2/select2.min.9f54e6414f87.css", "babybuddy/img/core/child-placeholder.png": "babybuddy/img/core/child-placeholder.7c0a81f0d7f0.png", "rest_framework/docs/js/api.js": "rest_framework/docs/js/api.c9743eab7a4f.js", "rest_framework/docs/js/jquery.json-view.min.js": "rest_framework/docs/js/jquery.json-view.min.b7c2d6981377.js", "rest_framework/docs/js/highlight.pack.js": "rest_framework/docs/js/highlight.pack.479b5f21dcba.js", "rest_framework/docs/img/favicon.ico": "rest_framework/docs/img/favicon.5195b4d0f3eb.ico", "rest_framework/docs/img/grid.png": "rest_framework/docs/img/grid.a4b938cf382b.png", "rest_framework/docs/css/highlight.css": "rest_framework/docs/css/highlight.e0e4d973c6d7.css", "rest_framework/docs/css/jquery.json-view.min.css": "rest_framework/docs/css/jquery.json-view.min.a2e6beeb6710.css", "rest_framework/docs/css/base.css": "rest_framework/docs/css/base.3208b6cc4466.css", "admin/js/admin/RelatedObjectLookups.js": "admin/js/admin/RelatedObjectLookups.b4d76b6aaf0b.js", "admin/js/admin/DateTimeShortcuts.js": "admin/js/admin/DateTimeShortcuts.5548f99471bf.js", "admin/img/gis/move_vertex_off.svg": "admin/img/gis/move_vertex_off.7a23bf31ef8a.svg", "admin/img/gis/move_vertex_on.svg": "admin/img/gis/move_vertex_on.0047eba25b67.svg", "babybuddy/logo/icon2.png": "babybuddy/logo/icon2.be48fd16c53f.png", "babybuddy/logo/icon-brand.png": "babybuddy/logo/icon-brand.96e4491f2209.png", "babybuddy/logo/icon.png": "babybuddy/logo/icon.6377611bf399.png", "babybuddy/logo/logo.png": "babybuddy/logo/logo.62870041cc83.png", "babybuddy/js/graph.js": "babybuddy/js/graph.455350929c2f.js", "babybuddy/js/app.js": "babybuddy/js/app.e50e8057bfa2.js", "babybuddy/js/vendor.js": "babybuddy/js/vendor.5c045131725f.js", "babybuddy/fonts/fontawesome-webfont.woff": "babybuddy/fonts/fontawesome-webfont.fee66e712a8a.woff", "babybuddy/fonts/fontawesome-webfont.ttf": "babybuddy/fonts/fontawesome-webfont.b06871f281fe.ttf", "babybuddy/fonts/fontawesome-webfont.woff2": "babybuddy/fonts/fontawesome-webfont.af7ae505a9ee.woff2", "babybuddy/fonts/fontawesome-webfont.svg": "babybuddy/fonts/fontawesome-webfont.912ec66d7572.svg", "babybuddy/fonts/fontawesome-webfont.eot": "babybuddy/fonts/fontawesome-webfont.674f50d287a8.eot", "babybuddy/fonts/FontAwesome.otf": "babybuddy/fonts/FontAwesome.0d2717cd5d85.otf", "babybuddy/root/apple-touch-icon.png": "babybuddy/root/apple-touch-icon.33416748f239.png", "babybuddy/root/android-chrome-512x512.png": "babybuddy/root/android-chrome-512x512.89ee40b783cd.png", "babybuddy/root/favicon.ico": "babybuddy/root/favicon.1b19cfd81791.ico", "babybuddy/root/android-chrome-384x384.png": "babybuddy/root/android-chrome-384x384.7849615a1e26.png", "babybuddy/root/mstile-150x150.png": "babybuddy/root/mstile-150x150.f231c8ff6157.png", "babybuddy/root/android-chrome-192x192.png": "babybuddy/root/android-chrome-192x192.484bd0e8cb66.png", "babybuddy/root/site.webmanifest.json": "babybuddy/root/site.webmanifest.61dac00bb04b.json", "babybuddy/root/favicon-32x32.png": "babybuddy/root/favicon-32x32.076f1340f1cf.png", "babybuddy/root/favicon-16x16.png": "babybuddy/root/favicon-16x16.12c501486484.png", "babybuddy/root/browserconfig.xml": "babybuddy/root/browserconfig.5858221e0a38.xml", "babybuddy/root/safari-pinned-tab.svg": "babybuddy/root/safari-pinned-tab.3de51db2baf2.svg", "babybuddy/css/app.css": "babybuddy/css/app.61b50a7dc061.css", "rest_framework/js/jquery-3.5.1.min.js": "rest_framework/js/jquery-3.5.1.min.dc5e7f18c8d3.js", "rest_framework/js/csrf.js": "rest_framework/js/csrf.969930007329.js", "rest_framework/js/default.js": "rest_framework/js/default.5b08897dbdc3.js", "rest_framework/js/bootstrap.min.js": "rest_framework/js/bootstrap.min.2f34b630ffe3.js", "rest_framework/js/prettify-min.js": "rest_framework/js/prettify-min.709bfcc456c6.js", "rest_framework/js/coreapi-0.1.1.js": "rest_framework/js/coreapi-0.1.1.8851fb9336c9.js", "rest_framework/js/ajax-form.js": "rest_framework/js/ajax-form.0ea6e6052ab5.js", "rest_framework/fonts/fontawesome-webfont.woff": "rest_framework/fonts/fontawesome-webfont.3293616ec0c6.woff", "rest_framework/fonts/glyphicons-halflings-regular.eot": "rest_framework/fonts/glyphicons-halflings-regular.f4769f9bdb74.eot", "rest_framework/fonts/fontawesome-webfont.ttf": "rest_framework/fonts/fontawesome-webfont.dcb26c7239d8.ttf", "rest_framework/fonts/glyphicons-halflings-regular.woff2": "rest_framework/fonts/glyphicons-halflings-regular.448c34a56d69.woff2", "rest_framework/fonts/glyphicons-halflings-regular.svg": "rest_framework/fonts/glyphicons-halflings-regular.08eda92397ae.svg", "rest_framework/fonts/fontawesome-webfont.svg": "rest_framework/fonts/fontawesome-webfont.83e37a11f9d7.svg", "rest_framework/fonts/glyphicons-halflings-regular.ttf": "rest_framework/fonts/glyphicons-halflings-regular.e18bbf611f2a.ttf", "rest_framework/fonts/fontawesome-webfont.eot": "rest_framework/fonts/fontawesome-webfont.8b27bc96115c.eot", "rest_framework/fonts/glyphicons-halflings-regular.woff": "rest_framework/fonts/glyphicons-halflings-regular.fa2772327f55.woff", "rest_framework/img/glyphicons-halflings-white.png": "rest_framework/img/glyphicons-halflings-white.9bbc6e960299.png", "rest_framework/img/glyphicons-halflings.png": "rest_framework/img/glyphicons-halflings.90233c9067e9.png", "rest_framework/img/grid.png": "rest_framework/img/grid.a4b938cf382b.png", "rest_framework/css/prettify.css": "rest_framework/css/prettify.a987f72342ee.css", "rest_framework/css/bootstrap-tweaks.css": "rest_framework/css/bootstrap-tweaks.46ed116b0edd.css", "rest_framework/css/bootstrap-theme.min.css": "rest_framework/css/bootstrap-theme.min.66b84a04375e.css", "rest_framework/css/font-awesome-4.0.3.css": "rest_framework/css/font-awesome-4.0.3.c1e1ea213abf.css", "rest_framework/css/default.css": "rest_framework/css/default.789dfb5732d7.css", "rest_framework/css/bootstrap.min.css": "rest_framework/css/bootstrap.min.77017a69879a.css", "admin/js/SelectFilter2.js": "admin/js/SelectFilter2.d250dcb52a9a.js", "admin/js/popup_response.js": "admin/js/popup_response.c6cc78ea5551.js", "admin/js/prepopulate_init.js": "admin/js/prepopulate_init.e056047b7a7e.js", "admin/js/jquery.init.js": "admin/js/jquery.init.b7781a0897fc.js", "admin/js/nav_sidebar.js": "admin/js/nav_sidebar.7605597ddf52.js", "admin/js/prepopulate.js": "admin/js/prepopulate.bd2361dfd64d.js", "admin/js/SelectBox.js": "admin/js/SelectBox.8161741c7647.js", "admin/js/core.js": "admin/js/core.ccd84108ec57.js", "admin/js/cancel.js": "admin/js/cancel.ecc4c5ca7b32.js", "admin/js/change_form.js": "admin/js/change_form.9d8ca4f96b75.js", "admin/js/collapse.js": "admin/js/collapse.f84e7410290f.js", "admin/js/autocomplete.js": "admin/js/autocomplete.b6b77d0e5906.js", "admin/js/urlify.js": "admin/js/urlify.25cc3eac8123.js", "admin/js/actions.js": "admin/js/actions.a6d23e8853fd.js", "admin/js/calendar.js": "admin/js/calendar.f8a5d055eb33.js", "admin/js/inlines.js": "admin/js/inlines.7596b7fd289e.js", "admin/fonts/README.txt": "admin/fonts/README.ab99e6b541ea.txt", "admin/fonts/Roboto-Light-webfont.woff": "admin/fonts/Roboto-Light-webfont.c73eb1ceba33.woff", "admin/fonts/Roboto-Regular-webfont.woff": "admin/fonts/Roboto-Regular-webfont.35b07eb2f871.woff", "admin/fonts/Roboto-Bold-webfont.woff": "admin/fonts/Roboto-Bold-webfont.50d75e48e0a3.woff", "admin/fonts/LICENSE.txt": "admin/fonts/LICENSE.d273d63619c9.txt", "admin/img/README.txt": "admin/img/README.a70711a38d87.txt", "admin/img/icon-alert.svg": "admin/img/icon-alert.034cc7d8a67f.svg", "admin/img/tooltag-add.svg": "admin/img/tooltag-add.e59d620a9742.svg", "admin/img/icon-calendar.svg": "admin/img/icon-calendar.ac7aea671bea.svg", "admin/img/calendar-icons.svg": "admin/img/calendar-icons.39b290681a8b.svg", "admin/img/icon-addlink.svg": "admin/img/icon-addlink.d519b3bab011.svg", "admin/img/icon-deletelink.svg": "admin/img/icon-deletelink.564ef9dc3854.svg", "admin/img/icon-clock.svg": "admin/img/icon-clock.e1d4dfac3f2b.svg", "admin/img/tooltag-arrowright.svg": "admin/img/tooltag-arrowright.bbfb788a849e.svg", "admin/img/icon-unknown-alt.svg": "admin/img/icon-unknown-alt.81536e128bb6.svg", "admin/img/selector-icons.svg": "admin/img/selector-icons.b4555096cea2.svg", "admin/img/LICENSE": "admin/img/LICENSE.2c54f4e1ca1c", "admin/img/icon-unknown.svg": "admin/img/icon-unknown.a18cb4398978.svg", "admin/img/icon-changelink.svg": "admin/img/icon-changelink.18d2fd706348.svg", "admin/img/search.svg": "admin/img/search.7cf54ff789c6.svg", "admin/img/sorting-icons.svg": "admin/img/sorting-icons.3a097b59f104.svg", "admin/img/icon-no.svg": "admin/img/icon-no.439e821418cd.svg", "admin/img/inline-delete.svg": "admin/img/inline-delete.fec1b761f254.svg", "admin/img/icon-yes.svg": "admin/img/icon-yes.d2f9f035226a.svg", "admin/img/icon-viewlink.svg": "admin/img/icon-viewlink.41eb31f7826e.svg", "admin/css/dashboard.css": "admin/css/dashboard.be83f13e4369.css", "admin/css/base.css": "admin/css/base.1f418065fc2c.css", "admin/css/widgets.css": "admin/css/widgets.694d845b2cb1.css", "admin/css/responsive.css": "admin/css/responsive.b128bdf0edef.css", "admin/css/autocomplete.css": "admin/css/autocomplete.4a81fc4242d0.css", "admin/css/fonts.css": "admin/css/fonts.168bab448fee.css", "admin/css/nav_sidebar.css": "admin/css/nav_sidebar.0fd434145f4d.css", "admin/css/changelists.css": "admin/css/changelists.c70d77c47e69.css", "admin/css/forms.css": "admin/css/forms.1d89ec6432f5.css", "admin/css/responsive_rtl.css": "admin/css/responsive_rtl.e13ae754cceb.css", "admin/css/rtl.css": "admin/css/rtl.4bc23eb90919.css", "admin/css/login.css": "admin/css/login.c35adf41bb6e.css", "import_export/action_formats.js": "import_export/action_formats.11c3e817b80a.js", "import_export/import.css": "import_export/import.358144dd8713.css"}, "version": "1.0"} \ No newline at end of file +{"paths": {"admin/js/vendor/select2/i18n/bg.js": "admin/js/vendor/select2/i18n/bg.39b8be30d4f0.js", "admin/js/vendor/select2/i18n/en.js": "admin/js/vendor/select2/i18n/en.cf932ba09a98.js", "admin/js/vendor/select2/i18n/lt.js": "admin/js/vendor/select2/i18n/lt.23c7ce903300.js", "admin/js/vendor/select2/i18n/zh-TW.js": "admin/js/vendor/select2/i18n/zh-TW.04554a227c2b.js", "admin/js/vendor/select2/i18n/is.js": "admin/js/vendor/select2/i18n/is.3ddd9a6a97e9.js", "admin/js/vendor/select2/i18n/vi.js": "admin/js/vendor/select2/i18n/vi.097a5b75b3e1.js", "admin/js/vendor/select2/i18n/sk.js": "admin/js/vendor/select2/i18n/sk.33d02cef8d11.js", "admin/js/vendor/select2/i18n/cs.js": "admin/js/vendor/select2/i18n/cs.4f43e8e7d33a.js", "admin/js/vendor/select2/i18n/ps.js": "admin/js/vendor/select2/i18n/ps.38dfa47af9e0.js", "admin/js/vendor/select2/i18n/hy.js": "admin/js/vendor/select2/i18n/hy.c7babaeef5a6.js", "admin/js/vendor/select2/i18n/eu.js": "admin/js/vendor/select2/i18n/eu.adfe5c97b72c.js", "admin/js/vendor/select2/i18n/nl.js": "admin/js/vendor/select2/i18n/nl.997868a37ed8.js", "admin/js/vendor/select2/i18n/tk.js": "admin/js/vendor/select2/i18n/tk.7c572a68c78f.js", "admin/js/vendor/select2/i18n/sr-Cyrl.js": "admin/js/vendor/select2/i18n/sr-Cyrl.f254bb8c4c7c.js", "admin/js/vendor/select2/i18n/az.js": "admin/js/vendor/select2/i18n/az.270c257daf81.js", "admin/js/vendor/select2/i18n/he.js": "admin/js/vendor/select2/i18n/he.e420ff6cd3ed.js", "admin/js/vendor/select2/i18n/af.js": "admin/js/vendor/select2/i18n/af.4f6fcd73488c.js", "admin/js/vendor/select2/i18n/ms.js": "admin/js/vendor/select2/i18n/ms.4ba82c9a51ce.js", "admin/js/vendor/select2/i18n/uk.js": "admin/js/vendor/select2/i18n/uk.8cede7f4803c.js", "admin/js/vendor/select2/i18n/sr.js": "admin/js/vendor/select2/i18n/sr.5ed85a48f483.js", "admin/js/vendor/select2/i18n/sv.js": "admin/js/vendor/select2/i18n/sv.7a9c2f71e777.js", "admin/js/vendor/select2/i18n/es.js": "admin/js/vendor/select2/i18n/es.66dbc2652fb1.js", "admin/js/vendor/select2/i18n/ka.js": "admin/js/vendor/select2/i18n/ka.2083264a54f0.js", "admin/js/vendor/select2/i18n/dsb.js": "admin/js/vendor/select2/i18n/dsb.56372c92d2f1.js", "admin/js/vendor/select2/i18n/hi.js": "admin/js/vendor/select2/i18n/hi.70640d41628f.js", "admin/js/vendor/select2/i18n/tr.js": "admin/js/vendor/select2/i18n/tr.b5a0643d1545.js", "admin/js/vendor/select2/i18n/ne.js": "admin/js/vendor/select2/i18n/ne.3d79fd3f08db.js", "admin/js/vendor/select2/i18n/ru.js": "admin/js/vendor/select2/i18n/ru.934aa95f5b5f.js", "admin/js/vendor/select2/i18n/sl.js": "admin/js/vendor/select2/i18n/sl.131a78bc0752.js", "admin/js/vendor/select2/i18n/hsb.js": "admin/js/vendor/select2/i18n/hsb.fa3b55265efe.js", "admin/js/vendor/select2/i18n/id.js": "admin/js/vendor/select2/i18n/id.04debded514d.js", "admin/js/vendor/select2/i18n/de.js": "admin/js/vendor/select2/i18n/de.8a1c222b0204.js", "admin/js/vendor/select2/i18n/bs.js": "admin/js/vendor/select2/i18n/bs.91624382358e.js", "admin/js/vendor/select2/i18n/th.js": "admin/js/vendor/select2/i18n/th.f38c20b0221b.js", "admin/js/vendor/select2/i18n/mk.js": "admin/js/vendor/select2/i18n/mk.dabbb9087130.js", "admin/js/vendor/select2/i18n/zh-CN.js": "admin/js/vendor/select2/i18n/zh-CN.2cff662ec5f9.js", "admin/js/vendor/select2/i18n/km.js": "admin/js/vendor/select2/i18n/km.c23089cb06ca.js", "admin/js/vendor/select2/i18n/ca.js": "admin/js/vendor/select2/i18n/ca.a166b745933a.js", "admin/js/vendor/select2/i18n/hr.js": "admin/js/vendor/select2/i18n/hr.a2b092cc1147.js", "admin/js/vendor/select2/i18n/ar.js": "admin/js/vendor/select2/i18n/ar.65aa8e36bf5d.js", "admin/js/vendor/select2/i18n/pl.js": "admin/js/vendor/select2/i18n/pl.6031b4f16452.js", "admin/js/vendor/select2/i18n/pt.js": "admin/js/vendor/select2/i18n/pt.33b4a3b44d43.js", "admin/js/vendor/select2/i18n/hu.js": "admin/js/vendor/select2/i18n/hu.6ec6039cb8a3.js", "admin/js/vendor/select2/i18n/ja.js": "admin/js/vendor/select2/i18n/ja.170ae885d74f.js", "admin/js/vendor/select2/i18n/fr.js": "admin/js/vendor/select2/i18n/fr.05e0542fcfe6.js", "admin/js/vendor/select2/i18n/ko.js": "admin/js/vendor/select2/i18n/ko.e7be6c20e673.js", "admin/js/vendor/select2/i18n/el.js": "admin/js/vendor/select2/i18n/el.27097f071856.js", "admin/js/vendor/select2/i18n/fi.js": "admin/js/vendor/select2/i18n/fi.614ec42aa9ba.js", "admin/js/vendor/select2/i18n/da.js": "admin/js/vendor/select2/i18n/da.766346afe4dd.js", "admin/js/vendor/select2/i18n/gl.js": "admin/js/vendor/select2/i18n/gl.d99b1fedaa86.js", "admin/js/vendor/select2/i18n/lv.js": "admin/js/vendor/select2/i18n/lv.08e62128eac1.js", "admin/js/vendor/select2/i18n/ro.js": "admin/js/vendor/select2/i18n/ro.f75cb460ec3b.js", "admin/js/vendor/select2/i18n/it.js": "admin/js/vendor/select2/i18n/it.be4fe8d365b5.js", "admin/js/vendor/select2/i18n/fa.js": "admin/js/vendor/select2/i18n/fa.3b5bd1961cfd.js", "admin/js/vendor/select2/i18n/nb.js": "admin/js/vendor/select2/i18n/nb.da2fce143f27.js", "admin/js/vendor/select2/i18n/pt-BR.js": "admin/js/vendor/select2/i18n/pt-BR.e1b294433e7f.js", "admin/js/vendor/select2/i18n/bn.js": "admin/js/vendor/select2/i18n/bn.6d42b4dd5665.js", "admin/js/vendor/select2/i18n/sq.js": "admin/js/vendor/select2/i18n/sq.5636b60d29c9.js", "admin/js/vendor/select2/i18n/et.js": "admin/js/vendor/select2/i18n/et.2b96fd98289d.js", "admin/js/vendor/xregexp/xregexp.min.js": "admin/js/vendor/xregexp/xregexp.min.b0439563a5d3.js", "admin/js/vendor/xregexp/xregexp.js": "admin/js/vendor/xregexp/xregexp.efda034b9537.js", "admin/js/vendor/xregexp/LICENSE.txt": "admin/js/vendor/xregexp/LICENSE.bf79e414957a.txt", "admin/js/vendor/select2/LICENSE.md": "admin/js/vendor/select2/LICENSE.f94142512c91.md", "admin/js/vendor/select2/select2.full.js": "admin/js/vendor/select2/select2.full.c2afdeda3058.js", "admin/js/vendor/select2/select2.full.min.js": "admin/js/vendor/select2/select2.full.min.fcd7500d8e13.js", "admin/js/vendor/jquery/jquery.min.js": "admin/js/vendor/jquery/jquery.min.dc5e7f18c8d3.js", "admin/js/vendor/jquery/jquery.js": "admin/js/vendor/jquery/jquery.23c7c5d2d131.js", "admin/js/vendor/jquery/LICENSE.txt": "admin/js/vendor/jquery/LICENSE.75308107741f.txt", "admin/css/vendor/select2/select2.css": "admin/css/vendor/select2/select2.a2194c262648.css", "admin/css/vendor/select2/LICENSE-SELECT2.md": "admin/css/vendor/select2/LICENSE-SELECT2.f94142512c91.md", "admin/css/vendor/select2/select2.min.css": "admin/css/vendor/select2/select2.min.9f54e6414f87.css", "babybuddy/img/core/child-placeholder.png": "babybuddy/img/core/child-placeholder.7c0a81f0d7f0.png", "rest_framework/docs/js/api.js": "rest_framework/docs/js/api.c9743eab7a4f.js", "rest_framework/docs/js/jquery.json-view.min.js": "rest_framework/docs/js/jquery.json-view.min.b7c2d6981377.js", "rest_framework/docs/js/highlight.pack.js": "rest_framework/docs/js/highlight.pack.479b5f21dcba.js", "rest_framework/docs/img/favicon.ico": "rest_framework/docs/img/favicon.5195b4d0f3eb.ico", "rest_framework/docs/img/grid.png": "rest_framework/docs/img/grid.a4b938cf382b.png", "rest_framework/docs/css/highlight.css": "rest_framework/docs/css/highlight.e0e4d973c6d7.css", "rest_framework/docs/css/jquery.json-view.min.css": "rest_framework/docs/css/jquery.json-view.min.a2e6beeb6710.css", "rest_framework/docs/css/base.css": "rest_framework/docs/css/base.3208b6cc4466.css", "admin/js/admin/RelatedObjectLookups.js": "admin/js/admin/RelatedObjectLookups.b4d76b6aaf0b.js", "admin/js/admin/DateTimeShortcuts.js": "admin/js/admin/DateTimeShortcuts.5548f99471bf.js", "admin/img/gis/move_vertex_off.svg": "admin/img/gis/move_vertex_off.7a23bf31ef8a.svg", "admin/img/gis/move_vertex_on.svg": "admin/img/gis/move_vertex_on.0047eba25b67.svg", "babybuddy/logo/icon2.png": "babybuddy/logo/icon2.be48fd16c53f.png", "babybuddy/logo/icon-brand.png": "babybuddy/logo/icon-brand.96e4491f2209.png", "babybuddy/logo/icon.png": "babybuddy/logo/icon.6377611bf399.png", "babybuddy/logo/logo.png": "babybuddy/logo/logo.62870041cc83.png", "babybuddy/js/graph.js": "babybuddy/js/graph.09e32032c8ef.js", "babybuddy/js/app.js": "babybuddy/js/app.e50e8057bfa2.js", "babybuddy/js/vendor.js": "babybuddy/js/vendor.5c045131725f.js", "babybuddy/fonts/fontawesome-webfont.woff": "babybuddy/fonts/fontawesome-webfont.fee66e712a8a.woff", "babybuddy/fonts/fontawesome-webfont.ttf": "babybuddy/fonts/fontawesome-webfont.b06871f281fe.ttf", "babybuddy/fonts/fontawesome-webfont.woff2": "babybuddy/fonts/fontawesome-webfont.af7ae505a9ee.woff2", "babybuddy/fonts/fontawesome-webfont.svg": "babybuddy/fonts/fontawesome-webfont.912ec66d7572.svg", "babybuddy/fonts/fontawesome-webfont.eot": "babybuddy/fonts/fontawesome-webfont.674f50d287a8.eot", "babybuddy/fonts/FontAwesome.otf": "babybuddy/fonts/FontAwesome.0d2717cd5d85.otf", "babybuddy/root/apple-touch-icon.png": "babybuddy/root/apple-touch-icon.33416748f239.png", "babybuddy/root/android-chrome-512x512.png": "babybuddy/root/android-chrome-512x512.89ee40b783cd.png", "babybuddy/root/favicon.ico": "babybuddy/root/favicon.1b19cfd81791.ico", "babybuddy/root/android-chrome-384x384.png": "babybuddy/root/android-chrome-384x384.7849615a1e26.png", "babybuddy/root/mstile-150x150.png": "babybuddy/root/mstile-150x150.f231c8ff6157.png", "babybuddy/root/android-chrome-192x192.png": "babybuddy/root/android-chrome-192x192.484bd0e8cb66.png", "babybuddy/root/site.webmanifest.json": "babybuddy/root/site.webmanifest.61dac00bb04b.json", "babybuddy/root/favicon-32x32.png": "babybuddy/root/favicon-32x32.076f1340f1cf.png", "babybuddy/root/favicon-16x16.png": "babybuddy/root/favicon-16x16.12c501486484.png", "babybuddy/root/browserconfig.xml": "babybuddy/root/browserconfig.5858221e0a38.xml", "babybuddy/root/safari-pinned-tab.svg": "babybuddy/root/safari-pinned-tab.3de51db2baf2.svg", "babybuddy/css/app.css": "babybuddy/css/app.61b50a7dc061.css", "rest_framework/js/jquery-3.5.1.min.js": "rest_framework/js/jquery-3.5.1.min.dc5e7f18c8d3.js", "rest_framework/js/csrf.js": "rest_framework/js/csrf.969930007329.js", "rest_framework/js/default.js": "rest_framework/js/default.5b08897dbdc3.js", "rest_framework/js/bootstrap.min.js": "rest_framework/js/bootstrap.min.2f34b630ffe3.js", "rest_framework/js/prettify-min.js": "rest_framework/js/prettify-min.709bfcc456c6.js", "rest_framework/js/coreapi-0.1.1.js": "rest_framework/js/coreapi-0.1.1.8851fb9336c9.js", "rest_framework/js/ajax-form.js": "rest_framework/js/ajax-form.0ea6e6052ab5.js", "rest_framework/fonts/fontawesome-webfont.woff": "rest_framework/fonts/fontawesome-webfont.3293616ec0c6.woff", "rest_framework/fonts/glyphicons-halflings-regular.eot": "rest_framework/fonts/glyphicons-halflings-regular.f4769f9bdb74.eot", "rest_framework/fonts/fontawesome-webfont.ttf": "rest_framework/fonts/fontawesome-webfont.dcb26c7239d8.ttf", "rest_framework/fonts/glyphicons-halflings-regular.woff2": "rest_framework/fonts/glyphicons-halflings-regular.448c34a56d69.woff2", "rest_framework/fonts/glyphicons-halflings-regular.svg": "rest_framework/fonts/glyphicons-halflings-regular.08eda92397ae.svg", "rest_framework/fonts/fontawesome-webfont.svg": "rest_framework/fonts/fontawesome-webfont.83e37a11f9d7.svg", "rest_framework/fonts/glyphicons-halflings-regular.ttf": "rest_framework/fonts/glyphicons-halflings-regular.e18bbf611f2a.ttf", "rest_framework/fonts/fontawesome-webfont.eot": "rest_framework/fonts/fontawesome-webfont.8b27bc96115c.eot", "rest_framework/fonts/glyphicons-halflings-regular.woff": "rest_framework/fonts/glyphicons-halflings-regular.fa2772327f55.woff", "rest_framework/img/glyphicons-halflings-white.png": "rest_framework/img/glyphicons-halflings-white.9bbc6e960299.png", "rest_framework/img/glyphicons-halflings.png": "rest_framework/img/glyphicons-halflings.90233c9067e9.png", "rest_framework/img/grid.png": "rest_framework/img/grid.a4b938cf382b.png", "rest_framework/css/prettify.css": "rest_framework/css/prettify.a987f72342ee.css", "rest_framework/css/bootstrap-tweaks.css": "rest_framework/css/bootstrap-tweaks.46ed116b0edd.css", "rest_framework/css/bootstrap-theme.min.css": "rest_framework/css/bootstrap-theme.min.66b84a04375e.css", "rest_framework/css/font-awesome-4.0.3.css": "rest_framework/css/font-awesome-4.0.3.c1e1ea213abf.css", "rest_framework/css/default.css": "rest_framework/css/default.789dfb5732d7.css", "rest_framework/css/bootstrap.min.css": "rest_framework/css/bootstrap.min.77017a69879a.css", "admin/js/SelectFilter2.js": "admin/js/SelectFilter2.d250dcb52a9a.js", "admin/js/popup_response.js": "admin/js/popup_response.c6cc78ea5551.js", "admin/js/prepopulate_init.js": "admin/js/prepopulate_init.e056047b7a7e.js", "admin/js/jquery.init.js": "admin/js/jquery.init.b7781a0897fc.js", "admin/js/nav_sidebar.js": "admin/js/nav_sidebar.7605597ddf52.js", "admin/js/prepopulate.js": "admin/js/prepopulate.bd2361dfd64d.js", "admin/js/SelectBox.js": "admin/js/SelectBox.8161741c7647.js", "admin/js/core.js": "admin/js/core.ccd84108ec57.js", "admin/js/cancel.js": "admin/js/cancel.ecc4c5ca7b32.js", "admin/js/change_form.js": "admin/js/change_form.9d8ca4f96b75.js", "admin/js/collapse.js": "admin/js/collapse.f84e7410290f.js", "admin/js/autocomplete.js": "admin/js/autocomplete.b6b77d0e5906.js", "admin/js/urlify.js": "admin/js/urlify.25cc3eac8123.js", "admin/js/actions.js": "admin/js/actions.a6d23e8853fd.js", "admin/js/calendar.js": "admin/js/calendar.f8a5d055eb33.js", "admin/js/inlines.js": "admin/js/inlines.7596b7fd289e.js", "admin/fonts/README.txt": "admin/fonts/README.ab99e6b541ea.txt", "admin/fonts/Roboto-Light-webfont.woff": "admin/fonts/Roboto-Light-webfont.c73eb1ceba33.woff", "admin/fonts/Roboto-Regular-webfont.woff": "admin/fonts/Roboto-Regular-webfont.35b07eb2f871.woff", "admin/fonts/Roboto-Bold-webfont.woff": "admin/fonts/Roboto-Bold-webfont.50d75e48e0a3.woff", "admin/fonts/LICENSE.txt": "admin/fonts/LICENSE.d273d63619c9.txt", "admin/img/README.txt": "admin/img/README.a70711a38d87.txt", "admin/img/icon-alert.svg": "admin/img/icon-alert.034cc7d8a67f.svg", "admin/img/tooltag-add.svg": "admin/img/tooltag-add.e59d620a9742.svg", "admin/img/icon-calendar.svg": "admin/img/icon-calendar.ac7aea671bea.svg", "admin/img/calendar-icons.svg": "admin/img/calendar-icons.39b290681a8b.svg", "admin/img/icon-addlink.svg": "admin/img/icon-addlink.d519b3bab011.svg", "admin/img/icon-deletelink.svg": "admin/img/icon-deletelink.564ef9dc3854.svg", "admin/img/icon-clock.svg": "admin/img/icon-clock.e1d4dfac3f2b.svg", "admin/img/tooltag-arrowright.svg": "admin/img/tooltag-arrowright.bbfb788a849e.svg", "admin/img/icon-unknown-alt.svg": "admin/img/icon-unknown-alt.81536e128bb6.svg", "admin/img/selector-icons.svg": "admin/img/selector-icons.b4555096cea2.svg", "admin/img/LICENSE": "admin/img/LICENSE.2c54f4e1ca1c", "admin/img/icon-unknown.svg": "admin/img/icon-unknown.a18cb4398978.svg", "admin/img/icon-changelink.svg": "admin/img/icon-changelink.18d2fd706348.svg", "admin/img/search.svg": "admin/img/search.7cf54ff789c6.svg", "admin/img/sorting-icons.svg": "admin/img/sorting-icons.3a097b59f104.svg", "admin/img/icon-no.svg": "admin/img/icon-no.439e821418cd.svg", "admin/img/inline-delete.svg": "admin/img/inline-delete.fec1b761f254.svg", "admin/img/icon-yes.svg": "admin/img/icon-yes.d2f9f035226a.svg", "admin/img/icon-viewlink.svg": "admin/img/icon-viewlink.41eb31f7826e.svg", "admin/css/dashboard.css": "admin/css/dashboard.be83f13e4369.css", "admin/css/base.css": "admin/css/base.1f418065fc2c.css", "admin/css/widgets.css": "admin/css/widgets.694d845b2cb1.css", "admin/css/responsive.css": "admin/css/responsive.b128bdf0edef.css", "admin/css/autocomplete.css": "admin/css/autocomplete.4a81fc4242d0.css", "admin/css/fonts.css": "admin/css/fonts.168bab448fee.css", "admin/css/nav_sidebar.css": "admin/css/nav_sidebar.0fd434145f4d.css", "admin/css/changelists.css": "admin/css/changelists.c70d77c47e69.css", "admin/css/forms.css": "admin/css/forms.1d89ec6432f5.css", "admin/css/responsive_rtl.css": "admin/css/responsive_rtl.e13ae754cceb.css", "admin/css/rtl.css": "admin/css/rtl.4bc23eb90919.css", "admin/css/login.css": "admin/css/login.c35adf41bb6e.css", "import_export/action_formats.js": "import_export/action_formats.11c3e817b80a.js", "import_export/import.css": "import_export/import.358144dd8713.css"}, "version": "1.0"} \ No newline at end of file