Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tensorflow/tfjs-data

Package Overview
Dependencies
Maintainers
11
Versions
126
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tensorflow/tfjs-data - npm Package Compare versions

Comparing version 4.2.0 to 4.3.0

2

dist/dataset.d.ts

@@ -26,3 +26,3 @@ /**

*/
export declare type DatasetContainer = Container<Dataset<TensorContainer>>;
export type DatasetContainer = Container<Dataset<TensorContainer>>;
/**

@@ -29,0 +29,0 @@ * Represents a potentially large list of independent data elements (typically

@@ -42,61 +42,2 @@ /**

/**
* Create a `CSVDataset`.
*
* @param input A `DataSource` providing a chunked, UTF8-encoded byte stream.
* @param csvConfig (Optional) A CSVConfig object that contains configurations
* of reading and decoding from CSV file(s).
*
* hasHeader: (Optional) A boolean value that indicates whether the first
* row of provided CSV file is a header line with column names, and should
* not be included in the data. Defaults to `true`.
*
* columnNames: (Optional) A list of strings that corresponds to
* the CSV column names, in order. If provided, it ignores the column
* names inferred from the header row. If not provided, infers the column
* names from the first row of the records. If hasHeader is false and
* columnNames is not provided, this method throws an error.
*
* columnConfigs: (Optional) A dictionary whose key is column names, value
* is an object stating if this column is required, column's data type,
* default value, and if this column is label. If provided, keys must
* correspond to names provided in columnNames or inferred from the file
* header lines. If isLabel is true any column, returns an array of two
* items: the first item is a dict of features key/value pairs, the second
* item is a dict of labels key/value pairs. If no feature is marked as
* label, returns a dict of features only.
*
* configuredColumnsOnly (Optional) If true, only columns provided in
* columnConfigs will be parsed and provided during iteration.
*
* delimiter (Optional) The string used to parse each line of the input
* file. Defaults to `,`.
*/
constructor(input, csvConfig) {
super();
this.input = input;
this.hasHeader = true;
this.fullColumnNames = null;
this.columnNamesValidated = false;
this.columnConfigs = null;
this.configuredColumnsOnly = false;
this.delimiter = ',';
this.delimWhitespace = false;
this.base = new TextLineDataset(input);
if (!csvConfig) {
csvConfig = {};
}
this.hasHeader = csvConfig.hasHeader === false ? false : true;
this.fullColumnNames = csvConfig.columnNames;
this.columnConfigs = csvConfig.columnConfigs;
this.configuredColumnsOnly = csvConfig.configuredColumnsOnly;
if (csvConfig.delimWhitespace) {
util.assert(csvConfig.delimiter == null, () => 'Delimiter should not be provided when delimWhitespace is true.');
this.delimWhitespace = true;
this.delimiter = ' ';
}
else {
this.delimiter = csvConfig.delimiter ? csvConfig.delimiter : ',';
}
}
/**
* Returns column names of the csv dataset. If `configuredColumnsOnly` is

@@ -177,2 +118,61 @@ * true, return column names in `columnConfigs`. If `configuredColumnsOnly` is

}
/**
* Create a `CSVDataset`.
*
* @param input A `DataSource` providing a chunked, UTF8-encoded byte stream.
* @param csvConfig (Optional) A CSVConfig object that contains configurations
* of reading and decoding from CSV file(s).
*
* hasHeader: (Optional) A boolean value that indicates whether the first
* row of provided CSV file is a header line with column names, and should
* not be included in the data. Defaults to `true`.
*
* columnNames: (Optional) A list of strings that corresponds to
* the CSV column names, in order. If provided, it ignores the column
* names inferred from the header row. If not provided, infers the column
* names from the first row of the records. If hasHeader is false and
* columnNames is not provided, this method throws an error.
*
* columnConfigs: (Optional) A dictionary whose key is column names, value
* is an object stating if this column is required, column's data type,
* default value, and if this column is label. If provided, keys must
* correspond to names provided in columnNames or inferred from the file
* header lines. If isLabel is true any column, returns an array of two
* items: the first item is a dict of features key/value pairs, the second
* item is a dict of labels key/value pairs. If no feature is marked as
* label, returns a dict of features only.
*
* configuredColumnsOnly (Optional) If true, only columns provided in
* columnConfigs will be parsed and provided during iteration.
*
* delimiter (Optional) The string used to parse each line of the input
* file. Defaults to `,`.
*/
constructor(input, csvConfig) {
super();
this.input = input;
this.hasHeader = true;
this.fullColumnNames = null;
this.columnNamesValidated = false;
this.columnConfigs = null;
this.configuredColumnsOnly = false;
this.delimiter = ',';
this.delimWhitespace = false;
this.base = new TextLineDataset(input);
if (!csvConfig) {
csvConfig = {};
}
this.hasHeader = csvConfig.hasHeader === false ? false : true;
this.fullColumnNames = csvConfig.columnNames;
this.columnConfigs = csvConfig.columnConfigs;
this.configuredColumnsOnly = csvConfig.configuredColumnsOnly;
if (csvConfig.delimWhitespace) {
util.assert(csvConfig.delimiter == null, () => 'Delimiter should not be provided when delimWhitespace is true.');
this.delimWhitespace = true;
this.delimiter = ' ';
}
else {
this.delimiter = csvConfig.delimiter ? csvConfig.delimiter : ',';
}
}
async iterator() {

@@ -381,2 +381,2 @@ if (!this.columnNamesValidated) {

// tf.data.TFRecordDataset()
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3N2X2RhdGFzZXQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi90ZmpzLWRhdGEvc3JjL2RhdGFzZXRzL2Nzdl9kYXRhc2V0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7Ozs7Ozs7Ozs7O0dBZ0JHO0FBRUgsT0FBTyxFQUFrQixJQUFJLEVBQUMsTUFBTSx1QkFBdUIsQ0FBQztBQUM1RCxPQUFPLEVBQUMsT0FBTyxFQUFDLE1BQU0sWUFBWSxDQUFDO0FBSW5DLE9BQU8sRUFBQyxlQUFlLEVBQUMsTUFBTSxxQkFBcUIsQ0FBQztBQUVwRCxNQUFNLFVBQVUsR0FBRyxHQUFHLENBQUM7QUFDdkIsTUFBTSxTQUFTLEdBQUcsTUFBTSxDQUFDLEtBQUssQ0FBQyxDQUFDO0FBQ2hDLE1BQU0sV0FBVyxHQUFHLE1BQU0sQ0FBQyxPQUFPLENBQUMsQ0FBQztBQUNwQyxNQUFNLFdBQVcsR0FBRyxNQUFNLENBQUMsT0FBTyxDQUFDLENBQUM7QUFDcEMsTUFBTSx1QkFBdUIsR0FBRyxNQUFNLENBQUMsaUJBQWlCLENBQUMsQ0FBQztBQUMxRCxNQUFNLDJCQUEyQixHQUFHLE1BQU0sQ0FBQyxjQUFjLENBQUMsQ0FBQztBQUUz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gICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICByZXN1bHQucHVzaCgnJyk7XG4gICAgICAgICAgICAgIGN1cnJlbnRTdGF0ZSA9IFNUQVRFX09VVDtcbiAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAvLyBFbnRlciBhbiB1bnF1b3RlZCBmaWVsZFxuICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgY3VycmVudFN0YXRlID0gU1RBVEVfRklFTEQ7XG4gICAgICAgICAgICAgIHJlYWRPZmZzZXQgPSBpO1xuICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICB9XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIC8vIEluIGFuIHVucXVvdGVkIGZpZWxkXG4gICAgICAgIGNhc2UgU1RBVEVfRklFTEQ6XG4gICAgICAgICAgc3dpdGNoIChsaW5lLmNoYXJBdChpKSkge1xuICAgICAgICAgICAgLy8gRXhpdCBhbiB1bnF1b3RlZCBmaWVsZCwgYWRkIGl0IHRvIHJlc3VsdFxuICAgICAgICAgICAgY2FzZSB0aGlzLmRlbGltaXRlcjpcbiAgICAgICAgICAgICAgcmVzdWx0LnB1c2gobGluZS5zdWJzdHJpbmcocmVhZE9mZnNldCwgaSkpO1xuICAgICAgICAgICAgICBjdXJyZW50U3RhdGUgPSBTVEFURV9PVVQ7XG4gICAgICAgICAgICAgIHJlYWRPZmZzZXQgPSBpICsgMTtcbiAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgIH1cbiAgICAgICAgICBicmVhaztcbiAgICAgICAgLy8gSW4gYSBxdW90ZWQgZmllbGRcbiAgICAgICAgY2FzZSBTVEFURV9RVU9URTpcbiAgICAgICAgICBzd2l0Y2ggKGxpbmUuY2hhckF0KGkpKSB7XG4gICAgICAgICAgICAvLyBSZWFkIGEgcXVvdGUgYWZ0ZXIgYSBxdW90ZVxuICAgICAgICAgICAgY2FzZSBDT0RFX1FVT1RFOlxuICAgICAgICAgICAgICBjdXJyZW50U3RhdGUgPSBTVEFURV9RVU9URV9BRlRFUl9RVU9URTtcbiAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgIH1cbiAgICAgICAgICBicmVhaztcbiAgICAgICAgLy8gVGhpcyBzdGF0ZSBtZWFucyBpdCdzIHJpZ2h0IGFmdGVyIGEgc2Vjb25kIHF1b3RlIGluIGEgZmllbGRcbiAgICAgICAgY2FzZSBTVEFURV9RVU9URV9BRlRFUl9RVU9URTpcbiAgICAgICAgICBzd2l0Y2ggKGxpbmUuY2hhckF0KGkpKSB7XG4gICAgICAgICAgICAvLyBGaW5pc2hlZCBhIHF1b3RlZCBmaWVsZFxuICAgICAgICAgICAgY2FzZSB0aGlzLmRlbGltaXRlcjpcbiAgICAgICAgICAgICAgcmVzdWx0LnB1c2gobGluZS5zdWJzdHJpbmcocmVhZE9mZnNldCwgaSAtIDEpKTtcbiAgICAgICAgICAgICAgY3VycmVudFN0YXRlID0gU1RBVEVfT1VUO1xuICAgICAgICAgICAgICByZWFkT2Zmc2V0ID0gaSArIDE7XG4gICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgLy8gRmluaXNoZWQgYSBxdW90ZWQgcGFydCBpbiBhIHF1b3RlZCBmaWVsZFxuICAgICAgICAgICAgY2FzZSBDT0RFX1FVT1RFOlxuICAgICAgICAgICAgICBjdXJyZW50U3RhdGUgPSBTVEFURV9RVU9URTtcbiAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAvLyBJbiBhIHF1b3RlZCBwYXJ0IGluIGEgcXVvdGVkIGZpZWxkXG4gICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICBjdXJyZW50U3RhdGUgPSBTVEFURV9XSVRISU5fUVVPVEVfSU5fUVVPVEU7XG4gICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgIH1cbiAg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ICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIC8vIFNldCB2YWx1ZSBhcyBzdHJpbmdcbiAgICAgICAgICAgICAgcGFyc2VkVmFsdWUgPSB2YWx1ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGVsc2UgaWYgKCFjb25maWcgfHwgIWNvbmZpZy5kdHlwZSkge1xuICAgICAgICAgICAgLy8gSWYgdGhpcyB2YWx1ZSBpcyBhIG51bWJlciBhbmQgbm8gdHlwZSBjb25maWcgaXMgcHJvdmlkZWQsIHJldHVyblxuICAgICAgICAgICAgLy8gaXQgYXMgbnVtYmVyLlxuICAgICAgICAgICAgcGFyc2VkVmFsdWUgPSB2YWx1ZUFzTnVtO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAvLyBJZiB0aGlzIHZhbHVlIGlzIGEgbnVtYmVyIGFuZCBkYXRhIHR5cGUgaXMgcHJvdmlkZWQsIHBhcnNlIGl0XG4gICAgICAgICAgICAvLyBhY2NvcmRpbmcgdG8gcHJvdmlkZWQgZGF0YSB0eXBlLlxuICAgICAgICAgICAgc3dpdGNoIChjb25maWcuZHR5cGUpIHtcbiAgICAgICAgICAgICAgY2FzZSAnZmxvYXQzMic6XG4gICAgICAgICAgICAgICAgcGFyc2VkVmFsdWUgPSB2YWx1ZUFzTnVtO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICBjYXNlICdpbnQzMic6XG4gICAgICAgICAgICAgICAgcGFyc2VkVmFsdWUgPSBNYXRoLmZsb29yKHZhbHVlQXNOdW0pO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICBjYXNlICdib29sJzpcbiAgICAgICAgICAgICAgICBwYXJzZWRWYWx1ZSA9IHRoaXMuZ2V0Qm9vbGVhbih2YWx1ZSk7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICAgICAgcGFyc2V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bVdoaXRlc3BhY2UpIHtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICByZXN1bHQucHVzaCgnJyk7XG4gICAgICAgICAgICAgIGN1cnJlbnRTdGF0ZSA9IFNUQVRFX09VVDtcbiAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAvLyBFbnRlciBhbiB1bnF1b3RlZCBmaWVsZFxuICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgY3VycmVudFN0YXRlID0gU1RBVEVfRklFTEQ7XG4gICAgICAgICAgICAgIHJlYWRPZmZzZXQgPSBpO1xuICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICB9XG4gICAgICAgICAgYnJlYWs7XG4gICAgICAgIC8vIEluIGFuIHVucXVvdGVkIGZpZWxkXG4gICAgICAgIGNhc2UgU1RBVEVfRklFTEQ6XG4gICAgICAgICAgc3dpdGNoIChsaW5lLmNoYXJBdChpKSkge1xuICAgICAgICAgICAgLy8gRXhpdCBhbiB1bnF1b3RlZCBmaWVsZCwgYWRkIGl0IHRvIHJlc3VsdFxuICAgICAgICAgICAgY2FzZSB0aGlzLmRlbGltaXRlcjpcbiAgICAgICAgICAgICAgcmVzdWx0LnB1c2gobGluZS5zdWJzdHJpbmcocmVhZE9mZnNldCwgaSkpO1xuICAgICAgICAgICAgICBjdXJyZW50U3RhdGUgPSBTVEFURV9PVVQ7XG4gICAgICAgICAgICAgIHJlYWRPZmZzZXQgPSBpICsgMTtcbiAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgIH1cbiAgICAgICAgICBicmVhaztcbiAgICAgICAgLy8gSW4gYSBxdW90ZWQgZmllbGRcbiAgICAgICAgY2FzZSBTVEFURV9RVU9URTpcbiAgICAgICAgICBzd2l0Y2ggKGxpbmUuY2hhckF0KGkpKSB7XG4gICAgICAgICAgICAvLyBSZWFkIGEgcXVvdGUgYWZ0ZXIgYSBxdW90ZVxuICAgICAgICAgICAgY2FzZSBDT0RFX1FVT1RFOlxuICAgICAgICAgICAgICBjdXJyZW50U3RhdGUgPSBTVEFURV9RVU9URV9BRlRFUl9RVU9URTtcbiAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgIH1cbiAgICAgICAgICBicmVhaztcbiAgICAgICAgLy8gVGhpcyBzdGF0ZSBtZWFucyBpdCdzIHJpZ2h0IGFmdGVyIGEgc2Vjb25kIHF1b3RlIGluIGEgZmllbGRcbiAgICAgICAgY2FzZSBTVEFURV9RVU9URV9BRlRFUl9RVU9URTpcbiAgICAgICAgICBzd2l0Y2ggKGxpbmUuY2hhckF0KGkpKSB7XG4gICAgICAgICAgICAvLyBGaW5pc2hlZCBhIHF1b3RlZCBmaWVsZFxuICAgICAgICAgICAgY2FzZSB0aGlzLmRlbGltaXRlcjpcbiAgICAgICAgICAgICAgcmVzdWx0LnB1c2gobGluZS5zdWJzdHJpbmcocmVhZE9mZnNldCwgaSAtIDEpKTtcbiAgICAgICAgICAgICAgY3VycmVudFN0YXRlID0gU1RBVEVfT1VUO1xuICAgICAgICAgICAgICByZWFkT2Zmc2V0ID0gaSArIDE7XG4gICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgLy8gRmluaXNoZWQgYSBxdW90ZWQgcGFydCBpbiBhIHF1b3RlZCBmaWVsZFxuICAgICAgICAgICAgY2FzZSBDT0RFX1FVT1RFOlxuICAgICAgICAgICAgICBjdXJyZW50U3RhdGUgPSBTVEFURV9RVU9URTtcbiAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAvLyBJbiBhIHF1b3RlZCBwYXJ0IGluIGEgcXVvdGVkIGZpZWxkXG4gICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICBjdXJyZW50U3RhdGUgPSBTVEFURV9XSVRISU5fUVVPVEVfSU5fUVVPVEU7XG4gICAgICAgICAgICAgIGJ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1bGxDb2x1bW5OYW1lcy5sZW5ndGh9IGVsZW1lbnRzIGluIGEgcm93LCBidXQgZ290ICR7cmVzdWx0fWApO1xuICAgIH1cbiAgICByZXR1cm4gcmVzdWx0O1xuICB9XG59XG5cbi8vIFRPRE8oc29lcmdlbCk6IGFkZCBtb3JlIGJhc2ljIGRhdGFzZXRzIGZvciBwYXJpdHkgd2l0aCB0Zi5kYXRhXG4vLyB0Zi5kYXRhLkZpeGVkTGVuZ3RoUmVjb3JkRGF0YXNldCgpXG4vLyB0Zi5kYXRhLlRGUmVjb3JkRGF0YXNldCgpXG4iXX0=

@@ -26,3 +26,3 @@ /**

*/
export declare type IteratorContainer = Container<LazyIterator<tf.TensorContainer>>;
export type IteratorContainer = Container<LazyIterator<tf.TensorContainer>>;
/**

@@ -29,0 +29,0 @@ * Create a `LazyIterator` from an array of items.

@@ -17,3 +17,3 @@ /**

*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@tensorflow/tfjs-core")):"function"==typeof define&&define.amd?define(["exports","@tensorflow/tfjs-core"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).tf=t.tf||{},t.tf)}(this,(function(t,e){"use strict";function n(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,e}var r=n(e),i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},i(t,e)};function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function u(t,e,n,r){return new(n||(n=Promise))((function(i,o){function u(t){try{a(r.next(t))}catch(t){o(t)}}function s(t){try{a(r.throw(t))}catch(t){o(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,s)}a((r=r.apply(t,e||[])).next())}))}function s(t,e){var n,r,i,o,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,r=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(!(i=u.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){u=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){u.label=o[1];break}if(6===o[0]&&u.label<i[1]){u.label=i[1],i=o;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(o);break}i[2]&&u.ops.pop(),u.trys.pop();continue}o=e.call(t,u)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function a(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)u.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return u}function l(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function h(t){if(t.__esModule)return t;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach((function(n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})})),e}function d(t){var e={exports:{}};return t(e,e.exports),e.exports}var p=d((function(t){!function(t,e,n){function r(t){var e,n=this,r=(e=4022871197,function(t){t=String(t);for(var n=0;n<t.length;n++){var r=.02519603282416938*(e+=t.charCodeAt(n));r-=e=r>>>0,e=(r*=e)>>>0,e+=4294967296*(r-=e)}return 2.3283064365386963e-10*(e>>>0)});n.next=function(){var t=2091639*n.s0+2.3283064365386963e-10*n.c;return n.s0=n.s1,n.s1=n.s2,n.s2=t-(n.c=0|t)},n.c=1,n.s0=r(" "),n.s1=r(" "),n.s2=r(" "),n.s0-=r(t),n.s0<0&&(n.s0+=1),n.s1-=r(t),n.s1<0&&(n.s1+=1),n.s2-=r(t),n.s2<0&&(n.s2+=1),r=null}function i(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e}function o(t,e){var n=new r(t),o=e&&e.state,u=n.next;return u.int32=function(){return 4294967296*n.next()|0},u.double=function(){return u()+11102230246251565e-32*(2097152*u()|0)},u.quick=u,o&&("object"==typeof o&&i(o,n),u.state=function(){return i(n,{})}),u}e&&e.exports?e.exports=o:n&&n.amd?n((function(){return o})):this.alea=o}(0,t,!1)})),v=d((function(t){!function(t,e,n){function r(t){var e=this,n="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8},t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++)e.x^=0|n.charCodeAt(r),e.next()}function i(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e}function o(t,e){var n=new r(t),o=e&&e.state,u=function(){return(n.next()>>>0)/4294967296};return u.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},u.int32=n.next,u.quick=u,o&&("object"==typeof o&&i(o,n),u.state=function(){return i(n,{})}),u}e&&e.exports?e.exports=o:n&&n.amd?n((function(){return o})):this.xor128=o}(0,t,!1)})),m=d((function(t){!function(t,e,n){function r(t){var e=this,n="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++)e.x^=0|n.charCodeAt(r),r==n.length&&(e.d=e.x<<10^e.x>>>4),e.next()}function i(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e}function o(t,e){var n=new r(t),o=e&&e.state,u=function(){return(n.next()>>>0)/4294967296};return u.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},u.int32=n.next,u.quick=u,o&&("object"==typeof o&&i(o,n),u.state=function(){return i(n,{})}),u}e&&e.exports?e.exports=o:n&&n.amd?n((function(){return o})):this.xorwow=o}(0,t,!1)})),y=d((function(t){!function(t,e,n){function r(t){var e=this;e.next=function(){var t,n,r=e.x,i=e.i;return t=r[i],n=(t^=t>>>7)^t<<24,n^=(t=r[i+1&7])^t>>>10,n^=(t=r[i+3&7])^t>>>3,n^=(t=r[i+4&7])^t<<7,t=r[i+7&7],n^=(t^=t<<13)^t<<9,r[i]=n,e.i=i+1&7,n},function(t,e){var n,r=[];if(e===(0|e))r[0]=e;else for(e=""+e,n=0;n<e.length;++n)r[7&n]=r[7&n]<<15^e.charCodeAt(n)+r[n+1&7]<<13;for(;r.length<8;)r.push(0);for(n=0;n<8&&0===r[n];++n);for(8==n&&(r[7]=-1),t.x=r,t.i=0,n=256;n>0;--n)t.next()}(e,t)}function i(t,e){return e.x=t.x.slice(),e.i=t.i,e}function o(t,e){null==t&&(t=+new Date);var n=new r(t),o=e&&e.state,u=function(){return(n.next()>>>0)/4294967296};return u.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},u.int32=n.next,u.quick=u,o&&(o.x&&i(o,n),u.state=function(){return i(n,{})}),u}e&&e.exports?e.exports=o:n&&n.amd?n((function(){return o})):this.xorshift7=o}(0,t,!1)})),w=d((function(t){!function(t,e,n){function r(t){var e=this;e.next=function(){var t,n,r=e.w,i=e.X,o=e.i;return e.w=r=r+1640531527|0,n=i[o+34&127],t=i[o=o+1&127],n^=n<<13,t^=t<<17,n^=n>>>15,t^=t>>>12,n=i[o]=n^t,e.i=o,n+(r^r>>>16)|0},function(t,e){var n,r,i,o,u,s=[],a=128;for(e===(0|e)?(r=e,e=null):(e+="\0",r=0,a=Math.max(a,e.length)),i=0,o=-32;o<a;++o)e&&(r^=e.charCodeAt((o+32)%e.length)),0===o&&(u=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,o>=0&&(u=u+1640531527|0,i=0==(n=s[127&o]^=r+u)?i+1:0);for(i>=128&&(s[127&(e&&e.length||0)]=-1),i=127,o=512;o>0;--o)r=s[i+34&127],n=s[i=i+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,s[i]=r^n;t.w=u,t.X=s,t.i=i}(e,t)}function i(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e}function o(t,e){null==t&&(t=+new Date);var n=new r(t),o=e&&e.state,u=function(){return(n.next()>>>0)/4294967296};return u.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},u.int32=n.next,u.quick=u,o&&(o.X&&i(o,n),u.state=function(){return i(n,{})}),u}e&&e.exports?e.exports=o:n&&n.amd?n((function(){return o})):this.xor4096=o}(0,t,!1)})),b=d((function(t){!function(t,e,n){function r(t){var e=this,n="";e.next=function(){var t=e.b,n=e.c,r=e.d,i=e.a;return t=t<<25^t>>>7^n,n=n-r|0,r=r<<24^r>>>8^i,i=i-t|0,e.b=t=t<<20^t>>>12^n,e.c=n=n-r|0,e.d=r<<16^n>>>16^i,e.a=i-t|0},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):n+=t;for(var r=0;r<n.length+20;r++)e.b^=0|n.charCodeAt(r),e.next()}function i(t,e){return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e}function o(t,e){var n=new r(t),o=e&&e.state,u=function(){return(n.next()>>>0)/4294967296};return u.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},u.int32=n.next,u.quick=u,o&&("object"==typeof o&&i(o,n),u.state=function(){return i(n,{})}),u}e&&e.exports?e.exports=o:n&&n.amd?n((function(){return o})):this.tychei=o}(0,t,!1)})),g=h({__proto__:null,default:{}}),x=d((function(t){!function(e,n,r){var i,o=256,u=r.pow(o,6),s=r.pow(2,52),a=2*s,c=255;function l(t,c,l){var m=[],y=p(d((c=1==c?{entropy:!0}:c||{}).entropy?[t,v(n)]:null==t?function(){try{var t;return i&&(t=i.randomBytes)?t=t(o):(t=new Uint8Array(o),(e.crypto||e.msCrypto).getRandomValues(t)),v(t)}catch(t){var r=e.navigator,u=r&&r.plugins;return[+new Date,e,u,e.screen,v(n)]}}():t,3),m),w=new f(m),b=function(){for(var t=w.g(6),e=u,n=0;t<s;)t=(t+n)*o,e*=o,n=w.g(1);for(;t>=a;)t/=2,e/=2,n>>>=1;return(t+n)/e};return b.int32=function(){return 0|w.g(4)},b.quick=function(){return w.g(4)/4294967296},b.double=b,p(v(w.S),n),(c.pass||l||function(t,e,n,i){return i&&(i.S&&h(i,w),t.state=function(){return h(w,{})}),n?(r.random=t,e):t})(b,y,"global"in c?c.global:this==r,c.state)}function f(t){var e,n=t.length,r=this,i=0,u=r.i=r.j=0,s=r.S=[];for(n||(t=[n++]);i<o;)s[i]=i++;for(i=0;i<o;i++)s[i]=s[u=c&u+t[i%n]+(e=s[i])],s[u]=e;(r.g=function(t){for(var e,n=0,i=r.i,u=r.j,s=r.S;t--;)e=s[i=c&i+1],n=n*o+s[c&(s[i]=s[u=c&u+e])+(s[u]=e)];return r.i=i,r.j=u,n})(o)}function h(t,e){return e.i=t.i,e.j=t.j,e.S=t.S.slice(),e}function d(t,e){var n,r=[],i=typeof t;if(e&&"object"==i)for(n in t)try{r.push(d(t[n],e-1))}catch(t){}return r.length?r:"string"==i?t:t+"\0"}function p(t,e){for(var n,r=t+"",i=0;i<r.length;)e[c&i]=c&(n^=19*e[c&i])+r.charCodeAt(i++);return v(e)}function v(t){return String.fromCharCode.apply(0,t)}if(p(r.random(),n),t.exports){t.exports=l;try{i=g}catch(t){}}else r.seedrandom=l}("undefined"!=typeof self?self:f,[],Math)}));x.alea=p,x.xor128=v,x.xorwow=m,x.xorshift7=y,x.xor4096=w,x.tychei=b;var C=x;function z(t,e,n,r){if(void 0===n&&(n=new Map),void 0===r&&(r=new Set),null==t)return null;if("function"==typeof Blob&&t instanceof Blob)return t.slice();if(r.has(t))throw new Error("Circular references are not supported.");if(n.has(t))return n.get(t);var i=e(t);if(i.recurse&&null!==i.value)throw new Error("A deep map function may not return both a value and recurse=true.");if(i.recurse){if(T(t)){var o=Array.isArray(t)?[]:{};for(var u in r.add(t),t){var s=z(t[u],e,n,r);o[u]=s}return r.delete(t),t.__proto__&&(o.__proto__=t.__proto__),o}throw new Error("Can't recurse into non-iterable type: ".concat(t))}return n.set(t,i.value),i.value}function E(t,e){return void 0===e&&(e=A),S(t,e)}function S(t,e,n){void 0===n&&(n=new Set);var r=t[0];if(n.has(r))throw new Error("Circular references are not supported.");var i=e(t);if(i.recurse&&null!==i.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(i.recurse){if(T(r)){var o=Array.isArray(r)?[]:{};n.add(r);var u=function(r){var i=S(t.map((function(t){return t[r]})),e,n);o[r]=i};for(var s in r)u(s);return n.delete(r),o}throw new Error("Can't recurse into non-iterable type: ".concat(r))}return i.value}function A(t){return null===t?null:T(t[0])?{value:null,recurse:!0}:{value:t,recurse:!1}}function R(t,e){return u(this,void 0,void 0,(function(){var n,i,o,u,c,l,f,h,d;return s(this,(function(s){switch(s.label){case 0:n=new Map,z(t,e,n),s.label=1;case 1:s.trys.push([1,6,7,8]),i=a(Array.from(n.keys())),o=i.next(),s.label=2;case 2:return o.done?[3,5]:(u=o.value,c=n.get(u),r.util.isPromise(c)?[4,c]:[3,4]);case 3:l=s.sent(),n.set(u,l),s.label=4;case 4:return o=i.next(),[3,2];case 5:return[3,8];case 6:return f=s.sent(),h={error:f},[3,8];case 7:try{o&&!o.done&&(d=i.return)&&d.call(i)}finally{if(h)throw h.error}return[7];case 8:return[2,z(t,e,n)]}}))}))}function T(t){var e=!1;r.env().get("IS_BROWSER")?e=t instanceof TextDecoder:e=t instanceof require("string_decoder").StringDecoder;return null!=t&&!ArrayBuffer.isView(t)&&(Array.isArray(t)||"object"==typeof t&&!(t instanceof r.Tensor)&&!(t instanceof Promise)&&!e)}function k(t){return z(t,F)}function F(t){return t instanceof r.Tensor?{value:t.clone(),recurse:!1}:T(t)?{value:null,recurse:!0}:{value:t,recurse:!1}}var _=function(){function t(t){if(this.capacity=t,this.begin=0,this.end=0,null==t)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(t<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(t),this.doubledCapacity=2*t}return t.prototype.wrap=function(t){for(;t<0;)t+=this.doubledCapacity;return t%this.doubledCapacity},t.prototype.get=function(t){if(t<0)throw new RangeError("Can't get item at a negative index.");return this.data[t%this.capacity]},t.prototype.set=function(t,e){if(t<0)throw new RangeError("Can't set item at a negative index.");this.data[t%this.capacity]=e},t.prototype.length=function(){var t=this.end-this.begin;return t<0&&(t=this.doubledCapacity+t),t},t.prototype.isFull=function(){return this.length()===this.capacity},t.prototype.isEmpty=function(){return 0===this.length()},t.prototype.push=function(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,t),this.end=this.wrap(this.end+1)},t.prototype.pushAll=function(t){var e,n;try{for(var r=a(t),i=r.next();!i.done;i=r.next()){var o=i.value;this.push(o)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}},t.prototype.pop=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);var t=this.get(this.end);return this.set(this.end,void 0),t},t.prototype.unshift=function(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,t)},t.prototype.shift=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var t=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),t},t.prototype.shuffleExcise=function(t){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var e=this.wrap(this.begin+t),n=this.get(e);return this.set(e,this.pop()),n},t}(),O=function(t){function e(){return t.call(this,e.INITIAL_CAPACITY)||this}return o(e,t),e.prototype.isFull=function(){return!1},e.prototype.push=function(e){t.prototype.isFull.call(this)&&this.expand(),t.prototype.push.call(this,e)},e.prototype.unshift=function(e){t.prototype.isFull.call(this)&&this.expand(),t.prototype.unshift.call(this,e)},e.prototype.expand=function(){for(var t=2*this.capacity,e=new Array(t),n=this.length(),r=0;r<n;r++)e[r]=this.get(this.wrap(this.begin+r));this.data=e,this.capacity=t,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=n},e}(_);function N(t){return new M(t)}function D(t){return new P(t)}O.INITIAL_CAPACITY=32;var I,j=function(){function t(){}return t.prototype.toArray=function(){return u(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t=[],[4,this.next()];case 1:e=n.sent(),n.label=2;case 2:return e.done?[3,4]:(t.push(e.value),[4,this.next()]);case 3:return e=n.sent(),[3,2];case 4:return[2,t]}}))}))},t.prototype.toArrayForTest=function(){return u(this,void 0,void 0,(function(){var t,e,n;return s(this,(function(r){switch(r.label){case 0:return t=this.prefetch(100),e=[],[4,t.next()];case 1:n=r.sent(),r.label=2;case 2:return n.done?[3,4]:(e.push(n.value),[4,t.next()]);case 3:return n=r.sent(),[3,2];case 4:return[2,e]}}))}))},t.prototype.resolveFully=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return[4,this.next()];case 1:t=e.sent(),e.label=2;case 2:return t.done?[3,4]:[4,this.next()];case 3:return t=e.sent(),[3,2];case 4:return[2]}}))}))},t.prototype.resolveWhile=function(t){return u(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){switch(r.label){case 0:return[4,this.next()];case 1:e=r.sent(),n=t(e.value),r.label=2;case 2:return e.done||!n?[3,4]:[4,this.next()];case 3:return e=r.sent(),n=t(e.value),[3,2];case 4:return[2]}}))}))},t.prototype.handleErrors=function(t){return new U(this,t)},t.prototype.filter=function(t){return new W(this,t)},t.prototype.map=function(t){return new V(this,t)},t.prototype.mapAsync=function(t){return new Q(this,t)},t.prototype.serialMapAsync=function(t){return new Q(this,t).serial()},t.prototype.flatmap=function(t){return new G(this,t)},t.prototype.forEachAsync=function(t){return u(this,void 0,void 0,(function(){return s(this,(function(e){return[2,this.map(t).resolveFully()]}))}))},t.prototype.serialForEach=function(t){return u(this,void 0,void 0,(function(){return s(this,(function(e){return[2,this.serialMapAsync(t).resolveWhile((function(t){return!0===t}))]}))}))},t.prototype.rowMajorBatch=function(t,e){return void 0===e&&(e=!0),new H(this,t,e)},t.prototype.columnMajorBatch=function(t,e,n){return void 0===e&&(e=!0),void 0===n&&(n=A),this.rowMajorBatch(t,e).map((function(t){return E(t,n)}))},t.prototype.concatenate=function(t,e){return new Z(N([this,t]),e)},t.prototype.take=function(t){return t<0||null==t?this:new q(this,t)},t.prototype.skip=function(t){return t<0||null==t?this:new L(this,t)},t.prototype.prefetch=function(t){return new Y(this,t)},t.prototype.shuffle=function(t,e){return new K(this,t,e)},t.prototype.serial=function(){return new B(this)},t}(),M=function(t){function e(e){var n=t.call(this)||this;return n.items=e,n.trav=0,n}return o(e,t),e.prototype.summary=function(){return"Array of ".concat(this.items.length," items")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(e){return this.trav>=this.items.length?[2,{value:null,done:!0}]:(t=this.items[this.trav],this.trav++,[2,{value:k(t),done:!1}])}))}))},e}(j),P=function(t){function e(e){var n=t.call(this)||this;return n.nextFn=e,n}return o(e,t),e.prototype.summary=function(){return"Function call"},e.prototype.next=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){try{return[2,this.nextFn()]}catch(t){throw t.message="Error thrown while iterating through a dataset: ".concat(t.message),t}return[2]}))}))},e}(j),B=function(t){function e(e){var n=t.call(this)||this;return n.upstream=e,n.lastRead=Promise.resolve({value:null,done:!1}),n}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Serial")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.upstream.next()]}))}))},e}(j),L=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.maxCount=n,r.count=0,r.lastRead=Promise.resolve({value:null,done:!1}),r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Skip")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return this.count++<this.maxCount?[4,this.upstream.next()]:[3,2];case 1:return(t=e.sent()).done?[2,t]:(r.dispose(t.value),[3,0]);case 2:return[2,this.upstream.next()]}}))}))},e}(j),q=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.maxCount=n,r.count=0,r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Take")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return this.count++>=this.maxCount?[2,{value:null,done:!0}]:[2,this.upstream.next()]}))}))},e}(j),H=function(t){function e(e,n,r){void 0===r&&(r=!0);var i=t.call(this)||this;return i.upstream=e,i.batchSize=n,i.enableSmallLastBatch=r,i.lastRead=Promise.resolve({value:null,done:!1}),i}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> RowMajorBatch")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:t=[],n.label=1;case 1:return t.length<this.batchSize?[4,this.upstream.next()]:[3,3];case 2:return(e=n.sent()).done?this.enableSmallLastBatch&&t.length>0?[2,{value:t,done:!1}]:[2,{value:null,done:!0}]:(t.push(e.value),[3,1]);case 3:return[2,{value:t,done:!1}]}}))}))},e}(j),W=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.predicate=n,r.lastRead=Promise.resolve({value:null,done:!1}),r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Filter")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return[4,this.upstream.next()];case 1:return(t=e.sent()).done||this.predicate(t.value)?[2,t]:(r.dispose(t.value),[3,0]);case 2:return[2]}}))}))},e}(j),V=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Map")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t,e,n,i,o,u,c,l,f;return s(this,(function(s){switch(s.label){case 0:return[4,this.upstream.next()];case 1:if((t=s.sent()).done)return[2,{value:null,done:!0}];e=r.tensor_util.getTensorsInContainer(t.value),n=this.transform(t.value),i=r.tensor_util.getTensorsInContainer(n);try{for(o=a(e),u=o.next();!u.done;u=o.next())c=u.value,r.tensor_util.isTensorInList(c,i)||c.dispose()}catch(t){l={error:t}}finally{try{u&&!u.done&&(f=o.return)&&f.call(o)}finally{if(l)throw l.error}}return[2,{value:n,done:!1}]}}))}))},e}(j),U=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.handler=n,r.count=0,r.lastRead=Promise.resolve({value:null,done:!1}),r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> handleErrors")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.upstream.next()];case 2:return[2,e.sent()];case 3:return t=e.sent(),this.handler(t)?[3,4]:[2,{value:null,done:!0}];case 4:return[3,0];case 5:return[2]}}))}))},e}(j),Q=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> AsyncMap")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t,e,n,i,o,u,c,l,f;return s(this,(function(s){switch(s.label){case 0:return[4,this.upstream.next()];case 1:return(t=s.sent()).done?[2,{value:null,done:!0}]:(e=r.tensor_util.getTensorsInContainer(t.value),[4,this.transform(t.value)]);case 2:n=s.sent(),i=r.tensor_util.getTensorsInContainer(n);try{for(o=a(e),u=o.next();!u.done;u=o.next())c=u.value,r.tensor_util.isTensorInList(c,i)||c.dispose()}catch(t){l={error:t}}finally{try{u&&!u.done&&(f=o.return)&&f.call(o)}finally{if(l)throw l.error}}return[2,{value:n,done:!1}]}}))}))},e}(j),X=function(t){function e(){var e=t.call(this)||this;return e.outputQueue=new O,e.lastRead=Promise.resolve({value:null,done:!1}),e}return o(e,t),e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return 0!==this.outputQueue.length()?[3,2]:[4,this.pump()];case 1:return t.sent()?[3,0]:[2,{value:null,done:!0}];case 2:return[2,{value:this.outputQueue.shift(),done:!1}]}}))}))},e}(j),G=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Flatmap")},e.prototype.pump=function(){return u(this,void 0,void 0,(function(){var t,e,n,i,o,u,c,l,f;return s(this,(function(s){switch(s.label){case 0:return[4,this.upstream.next()];case 1:if((t=s.sent()).done)return[2,!1];e=r.tensor_util.getTensorsInContainer(t.value),n=this.transform(t.value),i=r.tensor_util.getTensorsInContainer(n),this.outputQueue.pushAll(n);try{for(o=a(e),u=o.next();!u.done;u=o.next())c=u.value,r.tensor_util.isTensorInList(c,i)||c.dispose()}catch(t){l={error:t}}finally{try{u&&!u.done&&(f=o.return)&&f.call(o)}finally{if(l)throw l.error}}return[2,!0]}}))}))},e}(X),Z=function(t){function e(e,n){var r=t.call(this)||this;return r.baseErrorHandler=n,r.lastRead=null,r.iterator=null,r.moreIterators=e,r}return o(e,t),e.prototype.summary=function(){return"".concat("TODO: fill in upstream of chained summaries"," -> Chained")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return this.lastRead=this.readFromChain(this.lastRead),[2,this.lastRead]}))}))},e.prototype.readFromChain=function(t){return u(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){switch(r.label){case 0:return[4,t];case 1:return r.sent(),null!=this.iterator?[3,3]:[4,this.moreIterators.next()];case 2:if((e=r.sent()).done)return[2,{value:null,done:!0}];this.iterator=e.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler)),r.label=3;case 3:return[4,this.iterator.next()];case 4:return(n=r.sent()).done?(this.iterator=null,[2,this.readFromChain(t)]):[2,n]}}))}))},e}(j);!function(t){t[t.FAIL=0]="FAIL",t[t.SHORTEST=1]="SHORTEST",t[t.LONGEST=2]="LONGEST"}(I||(I={}));var J=function(t){function e(e,n){void 0===n&&(n=I.FAIL);var r=t.call(this)||this;return r.iterators=e,r.mismatchMode=n,r.count=0,r.currentPromise=null,r}return o(e,t),e.prototype.summary=function(){return"{".concat("TODO: fill in upstream of zip summaries","} -> Zip")},e.prototype.nextState=function(t){return u(this,void 0,void 0,(function(){function e(t){return t instanceof j?{value:t.next().then((function(t){return n++,t.done&&r++,t.value})),recurse:!1}:{value:null,recurse:!0}}var n,r,i;return s(this,(function(o){switch(o.label){case 0:return[4,t];case 1:return o.sent(),n=0,r=0,[4,R(this.iterators,e)];case 2:if(i=o.sent(),n===r)return[2,{value:null,done:!0}];if(r>0)switch(this.mismatchMode){case I.FAIL:throw new Error("Zipped streams should have the same length. "+"Mismatched at element ".concat(this.count,"."));case I.SHORTEST:return[2,{value:null,done:!0}];case I.LONGEST:}return this.count++,[2,{value:i,done:!1}]}}))}))},e.prototype.next=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return this.currentPromise=this.nextState(this.currentPromise),[2,this.currentPromise]}))}))},e}(j),Y=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.bufferSize=n,r.buffer=new _(n),r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Prefetch")},e.prototype.refill=function(){for(;!this.buffer.isFull();){var t=this.upstream.next();this.buffer.push(t)}},e.prototype.next=function(){return this.refill(),this.buffer.shift()},e}(j),K=function(t){function e(e,n,i){var o=t.call(this,e,n)||this;return o.upstream=e,o.windowSize=n,o.upstreamExhausted=!1,o.random=C.alea(i||r.util.now().toString()),o.lastRead=Promise.resolve({value:null,done:!1}),o}return o(e,t),e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.randomInt=function(t){return Math.floor(this.random()*t)},e.prototype.chooseIndex=function(){return this.randomInt(this.buffer.length())},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:this.upstreamExhausted||this.refill(),n.label=1;case 1:return this.buffer.isEmpty()?[3,3]:(t=this.chooseIndex(),[4,this.buffer.shuffleExcise(t)]);case 2:return(e=n.sent()).done?(this.upstreamExhausted=!0,[3,1]):(this.refill(),[2,e]);case 3:return[2,{value:null,done:!0}]}}))}))},e}(Y),$=function(){function t(){this.size=null}return t.prototype.batch=function(t,e){var n=this;void 0===e&&(e=!0);var i=this;return r.util.assert(t>0,(function(){return"batchSize needs to be positive, but it is\n ".concat(t)})),tt((function(){return u(n,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,i.iterator()];case 1:return[2,n.sent().columnMajorBatch(t,e,et)]}}))}))}),this.size===1/0||null==this.size?this.size:e?Math.ceil(this.size/t):Math.floor(this.size/t))},t.prototype.concatenate=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){var e,r;return s(this,(function(i){switch(i.label){case 0:return[4,n.iterator()];case 1:return r=(e=i.sent()).concatenate,[4,t.iterator()];case 2:return[2,r.apply(e,[i.sent()])]}}))}))}),this.size===1/0||t.size===1/0?1/0:null!=this.size&&null!=t.size?this.size+t.size:null)},t.prototype.filter=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().filter((function(e){return r.tidy((function(){return t(e)}))}))]}}))}))}),this.size===1/0?1/0:null)},t.prototype.forEachAsync=function(t){return u(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.iterator()];case 1:return[2,e.sent().forEachAsync(t)]}}))}))},t.prototype.map=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().map((function(e){return r.tidy((function(){return t(e)}))}))]}}))}))}),this.size)},t.prototype.mapAsync=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().mapAsync(t)]}}))}))}),this.size)},t.prototype.prefetch=function(t){var e=this;if(null==t)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");var n=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().prefetch(t)]}}))}))}),this.size)},t.prototype.repeat=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){var e,r=this;return s(this,(function(i){return e=D((function(){return u(r,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t={},[4,n.iterator()];case 1:return[2,(t.value=e.sent(),t.done=!1,t)]}}))}))})),[2,(o=e.take(t),new Z(o,a))];var o,a}))}))}),null!=this.size&&t>0?this.size*t:0===t?0:null!=this.size&&(void 0===t||t<0)?1/0:null)},t.prototype.skip=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().skip(t)]}}))}))}),null!=this.size&&t>=0&&this.size>=t?this.size-t:null!=this.size&&(this.size<t||void 0===t||t<0)?0:null)},t.prototype.shuffle=function(t,e,n){var i=this;if(void 0===n&&(n=!0),null==t||t<0)throw null==this.size?new RangeError("`Dataset.shuffle()` requires bufferSize to be specified."):new RangeError("`Dataset.shuffle()` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for `tf.Tensor`s), consider setting "+"bufferSize to the dataset size (".concat(this.size," elements)"));var o=this,a=C.alea(e||r.util.now().toString());return tt((function(){return u(i,void 0,void 0,(function(){var e;return s(this,(function(r){switch(r.label){case 0:return e=a.int32(),n&&(e+=a.int32()),[4,o.iterator()];case 1:return[2,r.sent().shuffle(t,e.toString())]}}))}))}),this.size)},t.prototype.take=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().take(t)]}}))}))}),null!=this.size&&this.size>t?t:null!=this.size&&this.size<=t?this.size:null)},t.prototype.toArray=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return[4,this.iterator()];case 1:return[2,t.sent().toArray()]}}))}))},t.prototype.toArrayForTest=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return[4,this.iterator()];case 1:return[2,t.sent().toArrayForTest()]}}))}))},t}();function tt(t,e){return void 0===e&&(e=null),new(function(n){function r(){var t=n.apply(this,l([],c(arguments),!1))||this;return t.size=e,t}return o(r,n),r.prototype.iterator=function(){return u(this,void 0,void 0,(function(){return s(this,(function(e){return[2,t()]}))}))},r}($))}function et(t){return null===t?null:function(t){return null==t||null===(e=t)||"object"!=typeof e&&"function"!=typeof e||Array.isArray(t)||"object"==typeof t&&t instanceof r.Tensor||r.util.isTypedArray(t);var e}(t[0])?{value:function(t){if(0===t.length)throw new Error("Can't make a batch of zero elements.");return t[0]instanceof r.Tensor?r.stack(t):r.tensor(t)}(t),recurse:!1}:{value:null,recurse:!0}}$.MAX_BUFFER_SIZE=1e4;var nt=function(t){function e(e){var n=t.call(this)||this;return n.input=e,n}return o(e,t),e.prototype.iterator=function(){return u(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return[4,this.input.iterator()];case 1:return t=n.sent(),e=t.decodeUTF8(),[2,e.split("\n").map((function(t){return t.endsWith("\r")&&(t=t.slice(0,-1)),t}))]}}))}))},e}($),rt='"',it=Symbol("out"),ot=Symbol("field"),ut=Symbol("quote"),st=Symbol("quoteafterquote"),at=Symbol("quoteinquote"),ct=function(t){function n(n,r){var i=t.call(this)||this;return i.input=n,i.hasHeader=!0,i.fullColumnNames=null,i.columnNamesValidated=!1,i.columnConfigs=null,i.configuredColumnsOnly=!1,i.delimiter=",",i.delimWhitespace=!1,i.base=new nt(n),r||(r={}),i.hasHeader=!1!==r.hasHeader,i.fullColumnNames=r.columnNames,i.columnConfigs=r.columnConfigs,i.configuredColumnsOnly=r.configuredColumnsOnly,r.delimWhitespace?(e.util.assert(null==r.delimiter,(function(){return"Delimiter should not be provided when delimWhitespace is true."})),i.delimWhitespace=!0,i.delimiter=" "):i.delimiter=r.delimiter?r.delimiter:",",i}return o(n,t),n.prototype.columnNames=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:t.sent(),t.label=2;case 2:return[2,this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames]}}))}))},n.prototype.setColumnNames=function(){return u(this,void 0,void 0,(function(){var t,n,r,i,o,u,c,l,f=this;return s(this,(function(s){switch(s.label){case 0:return[4,this.maybeReadHeaderLine()];case 1:if(t=s.sent(),!this.fullColumnNames&&!t)throw new Error("Column names must be provided if there is no header line.");if(this.fullColumnNames&&t&&e.util.assert(t.length===this.fullColumnNames.length,(function(){return"The length of provided columnNames ("+f.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+t.length.toString()+")."})),this.fullColumnNames||(this.fullColumnNames=t),n=this.fullColumnNames.reduce((function(t,e){return t[e]=t[e]+1||1,t}),{}),r=Object.keys(n).filter((function(t){return n[t]>1})),e.util.assert(0===r.length,(function(){return"Duplicate column names found: "+r.toString()})),this.columnConfigs)try{for(i=a(Object.keys(this.columnConfigs)),o=i.next();!o.done;o=i.next())if(u=o.value,-1===this.fullColumnNames.indexOf(u))throw new Error('The key "'+u+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").")}catch(t){c={error:t}}finally{try{o&&!o.done&&(l=i.return)&&l.call(i)}finally{if(c)throw c.error}}return this.columnNamesValidated=!0,[2]}}))}))},n.prototype.maybeReadHeaderLine=function(){return u(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return this.hasHeader?[4,this.base.iterator()]:[3,3];case 1:return[4,n.sent().next()];case 2:if((t=n.sent()).done)throw new Error("No data was found for CSV parsing.");return e=t.value,[2,this.parseRow(e,!1)];case 3:return[2,null]}}))}))},n.prototype.iterator=function(){return u(this,void 0,void 0,(function(){var t,e=this;return s(this,(function(n){switch(n.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:n.sent(),n.label=2;case 2:return[4,this.base.iterator()];case 3:return t=n.sent(),this.hasHeader&&(t=t.skip(1)),[2,t.map((function(t){return e.makeDataElement(t)}))]}}))}))},n.prototype.makeDataElement=function(t){for(var e=this.parseRow(t),n={},r={},i=0;i<this.fullColumnNames.length;i++){var o=this.fullColumnNames[i],u=this.columnConfigs?this.columnConfigs[o]:null;if(!this.configuredColumnsOnly||u){var s=e[i],a=null;if(""===s)if(u&&void 0!==u.default)a=u.default;else{if(u&&(u.required||u.isLabel))throw new Error("Required column ".concat(o," is empty in this line: ").concat(t));a=void 0}else{var c=Number(s);if(isNaN(c))a=u&&"bool"===u.dtype?this.getBoolean(s):s;else if(u&&u.dtype)switch(u.dtype){case"float32":default:a=c;break;case"int32":a=Math.floor(c);break;case"bool":a=this.getBoolean(s)}else a=c}u&&u.isLabel?r[o]=a:n[o]=a}}return 0===Object.keys(r).length?n:{xs:n,ys:r}},n.prototype.getBoolean=function(t){return"1"===t||"true"===t.toLowerCase()?1:0},n.prototype.parseRow=function(t,e){void 0===e&&(e=!0);for(var n=[],r=0,i=t.length,o=it,u=0;u<i;u++)switch(o){case it:switch(t.charAt(u)){case rt:r=u+1,o=ut;break;case this.delimiter:if(r=u+1," "===this.delimiter&&this.delimWhitespace)break;n.push(""),o=it;break;default:o=ot,r=u}break;case ot:if(t.charAt(u)===this.delimiter)n.push(t.substring(r,u)),o=it,r=u+1;break;case ut:if(t.charAt(u)===rt)o=st;break;case st:switch(t.charAt(u)){case this.delimiter:n.push(t.substring(r,u-1)),o=it,r=u+1;break;case rt:o=ut;break;default:o=at}break;case at:if(t.charAt(u)===rt)o=ut}if(o===st?n.push(t.substring(r,i-1)):n.push(t.substring(r)),e&&n.length!==this.fullColumnNames.length)throw new Error("Invalid row in csv file. Should have ".concat(this.fullColumnNames.length," elements in a row, but got ").concat(n));return n},n}($),lt=function(t){function n(e){var n=t.call(this)||this;n.microphoneConfig=e,n.isClosed=!1,n.fftSize=e.fftSize||1024;var r=Math.log2(n.fftSize);if(n.fftSize<0||r<4||r>14||!Number.isInteger(r))throw new Error("Invalid fftSize: it must be a power of 2 between "+"2 to 4 and 2 to 14, but got ".concat(n.fftSize));if(n.numFrames=e.numFramesPerSpectrogram||43,n.sampleRateHz=e.sampleRateHz,n.columnTruncateLength=e.columnTruncateLength||n.fftSize,n.audioTrackConstraints=e.audioTrackConstraints,n.smoothingTimeConstant=e.smoothingTimeConstant||0,n.includeSpectrogram=!1!==e.includeSpectrogram,n.includeWaveform=!0===e.includeWaveform,!n.includeSpectrogram&&!n.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.");return n}return o(n,t),n.prototype.summary=function(){return"microphone"},n.create=function(t){return void 0===t&&(t={}),u(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:if(!e.env().get("IS_BROWSER"))throw new Error("microphone API is only supported in browser environment.");return[4,(r=new n(t)).start()];case 1:return i.sent(),[2,r]}}))}))},n.prototype.start=function(){return u(this,void 0,void 0,(function(){var t,e,n,r;return s(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=this,[4,navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1})];case 1:return t.stream=i.sent(),[3,3];case 2:throw e=i.sent(),new Error("Error thrown while initializing video stream: ".concat(e.message));case 3:if(!this.stream)throw new Error("Could not obtain audio from microphone.");if(n=window.AudioContext||window.webkitAudioContext,this.audioContext=new n,this.sampleRateHz){if(this.audioContext.sampleRate!==this.sampleRateHz)throw new Error("Mismatch in sampling rate: "+"Expected: ".concat(this.sampleRateHz,"; ")+"Actual: ".concat(this.audioContext.sampleRate))}else this.sampleRateHz=this.audioContext.sampleRate;return r=this.audioContext.createMediaStreamSource(this.stream),this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,r.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize),[2]}}))}))},n.prototype.next=function(){return u(this,void 0,void 0,(function(){var t,e,n,r,i;return s(this,(function(o){switch(o.label){case 0:return this.isClosed?[2,{value:null,done:!0}]:[4,this.getAudioData()];case 1:return n=o.sent(),this.includeSpectrogram&&(r=this.flattenQueue(n.freqDataQueue),t=this.getTensorFromAudioDataArray(r,[this.numFrames,this.columnTruncateLength,1])),this.includeWaveform&&(i=this.flattenQueue(n.timeDataQueue),e=this.getTensorFromAudioDataArray(i,[this.numFrames*this.fftSize,1])),[2,{value:{spectrogram:t,waveform:e},done:!1}]}}))}))},n.prototype.capture=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.next()];case 1:return[2,t.sent().value]}}))}))},n.prototype.getAudioData=function(){return u(this,void 0,void 0,(function(){var t,e,n,r=this;return s(this,(function(i){return t=[],e=[],n=0,[2,new Promise((function(i){var o=setInterval((function(){r.includeSpectrogram&&(r.analyser.getFloatFrequencyData(r.freqData),r.freqData[0]===-1/0&&i({freqDataQueue:t,timeDataQueue:e}),t.push(r.freqData.slice(0,r.columnTruncateLength))),r.includeWaveform&&(r.analyser.getFloatTimeDomainData(r.timeData),e.push(r.timeData.slice())),++n===r.numFrames&&(clearInterval(o),i({freqDataQueue:t,timeDataQueue:e}))}),r.fftSize/r.sampleRateHz*1e3)}))]}))}))},n.prototype.stop=function(){this.isClosed||(this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop())},n.prototype.toArray=function(){throw new Error("Can not convert infinite audio stream to array.")},n.prototype.getSampleRate=function(){return this.sampleRateHz},n.prototype.flattenQueue=function(t){var e=t[0].length,n=new Float32Array(t.length*e);return t.forEach((function(t,r){return n.set(t,r*e)})),n},n.prototype.getTensorFromAudioDataArray=function(t,n){var r=new Float32Array(e.util.sizeFromShape(n));return r.set(t,r.length-t.length),e.tensor(r,n)},n}(j),ft=function(t){function n(n,r){var i=t.call(this)||this;if(i.webcamVideoElement=n,i.webcamConfig=r,i.isClosed=!0,i.resize=!1,i.needToResize())if(i.resize=!0,i.cropSize=[i.webcamConfig.resizeHeight,i.webcamConfig.resizeWidth],i.cropBoxInd=e.tensor1d([0],"int32"),i.webcamConfig.centerCrop){var o=1*i.webcamConfig.resizeWidth/i.webcamVideoElement.width,u=1*i.webcamConfig.resizeHeight/i.webcamVideoElement.height,s=(1-o)/2,a=(1-u)/2,c=s+o,l=u+a;i.cropBox=e.tensor2d([a,s,l,c],[1,4])}else i.cropBox=e.tensor2d([0,0,1,1],[1,4]);return i}return o(n,t),n.prototype.summary=function(){return"webcam"},n.create=function(t,r){return void 0===r&&(r={}),u(this,void 0,void 0,(function(){var i;return s(this,(function(o){switch(o.label){case 0:if(!e.env().get("IS_BROWSER"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!t){if(t=document.createElement("video"),!r.resizeWidth||!r.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");t.width=r.resizeWidth,t.height=r.resizeHeight}return[4,(i=new n(t,r)).start()];case 1:return o.sent(),[2,i]}}))}))},n.prototype.start=function(){return u(this,void 0,void 0,(function(){var t,n,r=this;return s(this,(function(i){switch(i.label){case 0:this.webcamConfig.facingMode&&e.util.assert("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,(function(){return"Invalid webcam facing mode: ".concat(r.webcamConfig.facingMode,". ")+"Please provide 'user' or 'environment'"})),i.label=1;case 1:return i.trys.push([1,3,,4]),t=this,[4,navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})];case 2:return t.stream=i.sent(),[3,4];case 3:throw(n=i.sent()).message="Error thrown while initializing video stream: ".concat(n.message),n;case 4:if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(t){console.log(t),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,[2,new Promise((function(t){r.webcamVideoElement.onloadedmetadata=function(){t()}}))]}}))}))},n.prototype.next=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(n){if(this.isClosed)return[2,{value:null,done:!0}];try{t=e.browser.fromPixels(this.webcamVideoElement)}catch(t){throw new Error("Error thrown converting video to pixels: ".concat(JSON.stringify(t)))}if(!this.resize)return[2,{value:t,done:!1}];try{return[2,{value:this.cropAndResizeFrame(t),done:!1}]}catch(t){throw new Error("Error thrown cropping the video: ".concat(t.message))}finally{t.dispose()}return[2]}))}))},n.prototype.needToResize=function(){return!(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight)},n.prototype.cropAndResizeFrame=function(t){var n=this;return e.tidy((function(){var r,i=e.expandDims(e.cast(t,"float32"),0),o=(r=e.image.cropAndResize(i,n.cropBox,n.cropBoxInd,n.cropSize,"bilinear")).shape;return e.reshape(r,o.slice(1))}))},n.prototype.capture=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.next()];case 1:return[2,t.sent().value]}}))}))},n.prototype.stop=function(){this.stream.getTracks().forEach((function(t){return t.stop()}));try{this.webcamVideoElement.srcObject=null}catch(t){console.log(t),this.webcamVideoElement.src=null}this.isClosed=!0},n.prototype.toArray=function(){throw new Error("Can not convert infinite video stream to array.")},n}(j),ht=function(){},dt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.split=function(t){return new pt(this,t)},e}(j),pt=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.impl=new vt(e,n),r}return o(e,t),e.prototype.summary=function(){return this.impl.summary()},e.prototype.next=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.impl.next()]}))}))},e}(dt),vt=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.separator=n,r.carryover="",r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Split('").concat(this.separator,"')")},e.prototype.pump=function(){return u(this,void 0,void 0,(function(){var t,e,n,r,i,o,u;return s(this,(function(s){switch(s.label){case 0:return[4,this.upstream.next()];case 1:if((t=s.sent()).done)return""===this.carryover?[2,!1]:(this.outputQueue.push(this.carryover),this.carryover="",[2,!0]);(e=t.value.split(this.separator))[0]=this.carryover+e[0];try{for(n=a(e.slice(0,-1)),r=n.next();!r.done;r=n.next())i=r.value,this.outputQueue.push(i)}catch(t){o={error:t}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}}return this.carryover=e[e.length-1],[2,!0]}}))}))},e}(X),mt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.decodeUTF8=function(){return new yt(this)},e}(j),yt=function(t){function e(e){var n=t.call(this)||this;return n.upstream=e,n.impl=new wt(e),n}return o(e,t),e.prototype.summary=function(){return this.impl.summary()},e.prototype.next=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.impl.next()]}))}))},e}(dt),wt=function(t){function n(n){var r=t.call(this)||this;if(r.upstream=n,e.env().get("IS_BROWSER"))r.decoder=new TextDecoder("utf-8");else{var i=require("string_decoder").StringDecoder;r.decoder=new i("utf8")}return r}return o(n,t),n.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Utf8")},n.prototype.pump=function(){return u(this,void 0,void 0,(function(){var t,n,r;return s(this,(function(i){switch(i.label){case 0:return[4,this.upstream.next()];case 1:return(t=i.sent()).done?[2,!1]:(n=t.value,r=e.env().get("IS_BROWSER")?this.decoder.decode(n,{stream:!0}):this.decoder.write(Buffer.from(n.buffer)),this.outputQueue.push(r),[2,!0])}}))}))},n}(X),bt=function(t){function n(n,r){void 0===r&&(r={});var i=t.call(this)||this;return i.file=n,i.options=r,e.util.assert(n instanceof Uint8Array||!!e.env().get("IS_BROWSER")&&(n instanceof File||n instanceof Blob),(function(){return"FileChunkIterator only supports File, Blob and Uint8Array right now."})),i.offset=r.offset||0,i.chunkSize=r.chunkSize||1048576,i}return o(n,t),n.prototype.summary=function(){return"FileChunks ".concat(this.file)},n.prototype.next=function(){return u(this,void 0,void 0,(function(){var t,e,n=this;return s(this,(function(r){switch(r.label){case 0:return this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size)?[2,{value:null,done:!0}]:(t=new Promise((function(t,e){var r=n.offset+n.chunkSize;if(n.file instanceof Uint8Array)t(new Uint8Array(n.file.slice(n.offset,r)));else{var i=new FileReader;i.onload=function(n){var r=i.result;if(r instanceof ArrayBuffer&&(r=new Uint8Array(r)),!(r instanceof Uint8Array))return e(new TypeError("FileReader returned unknown type."));t(r)},i.onabort=function(t){return e(new Error("Aborted"))},i.onerror=function(t){return e(new Error(t.type))};var o=n.file.slice(n.offset,r);i.readAsArrayBuffer(o)}n.offset=r})),e={},[4,t]);case 1:return[2,(e.value=r.sent(),e.done=!1,e)]}}))}))},n}(mt);function gt(t,n,r){return void 0===n&&(n={}),u(this,void 0,void 0,(function(){var i,o,u,a,c;return s(this,(function(s){switch(s.label){case 0:return"string"==typeof t?i=t:(i=t.url,o=xt(t)),[4,(r||e.util.fetch)(i,o)];case 1:return(u=s.sent()).ok?(c=Uint8Array.bind,[4,u.arrayBuffer()]):[3,3];case 2:return a=new(c.apply(Uint8Array,[void 0,s.sent()])),[2,new bt(a,n)];case 3:throw new Error(u.statusText)}}))}))}var xt=function(t){return{method:t.method,headers:t.headers,body:t.body,mode:t.mode,credentials:t.credentials,cache:t.cache,redirect:t.redirect,referrer:t.referrer,integrity:t.integrity}};function Ct(t){return"string"==typeof t&&"file://"===t.slice(0,7)}var zt=function(t){function n(e,n){void 0===n&&(n={});var r=t.call(this)||this;return r.input=e,r.options=n,r}return o(n,t),n.prototype.iterator=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(n){return Ct(this.input)&&e.env().get("IS_NODE")&&(t=require("fs"),this.input=t.readFileSync(this.input.slice(7))),[2,new bt(this.input,this.options)]}))}))},n}(ht),Et=function(t){function e(e,n){void 0===n&&(n={});var r=t.call(this)||this;return r.url=e,r.fileOptions=n,r}return o(e,t),e.prototype.iterator=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return Ct(this.url)?[2,new zt(this.url,this.fileOptions).iterator()]:[2,gt(this.url,this.fileOptions)]}))}))},e}(ht);t.CSVDataset=ct,t.Dataset=$,t.FileDataSource=zt,t.TextLineDataset=nt,t.URLDataSource=Et,t.array=function(t){var e=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){return[2,N(t)]}))}))}),t.length)},t.csv=function(t,e){return void 0===e&&(e={}),new ct(new Et(t),e)},t.func=function(t){var e=this,n=D(t);return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(t){return[2,n]}))}))}))},t.generator=function(t){var e=this;return tt((function(){return u(e,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return[4,t()];case 1:return e=n.sent(),[2,D((function(){return e.next()}))]}}))}))}))},t.microphone=function(t){return u(this,void 0,void 0,(function(){return s(this,(function(e){return[2,lt.create(t)]}))}))},t.version_data="4.2.0",t.webcam=function(t,e){return u(this,void 0,void 0,(function(){return s(this,(function(n){return[2,ft.create(t,e)]}))}))},t.zip=function(t){var e,n=this;if(!T(t))throw new Error("The argument to zip() must be an object or array.");if(Array.isArray(t))for(var r=0;r<t.length;r++)e=null==e?t[r].size:Math.min(e,t[r].size);else if(t instanceof Object)for(var i in t)e=null==e?t[i].size:Math.min(e,t[i].size);return tt((function(){return u(n,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return[4,R(t,(function(t){if(t instanceof $)return{value:t.iterator(),recurse:!1};if(T(t))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")}))];case 1:return e=n.sent(),[2,(r=e,i=I.SHORTEST,void 0===i&&(i=I.FAIL),new J(r,i))]}var r,i}))}))}),e)},Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@tensorflow/tfjs-core")):"function"==typeof define&&define.amd?define(["exports","@tensorflow/tfjs-core"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).tf=t.tf||{},t.tf)}(this,(function(t,e){"use strict";function n(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,e}var r=n(e),i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},i(t,e)};function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function u(t,e,n,r){return new(n||(n=Promise))((function(i,o){function u(t){try{a(r.next(t))}catch(t){o(t)}}function s(t){try{a(r.throw(t))}catch(t){o(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,s)}a((r=r.apply(t,e||[])).next())}))}function s(t,e){var n,r,i,o,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,r=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(!(i=u.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){u=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){u.label=o[1];break}if(6===o[0]&&u.label<i[1]){u.label=i[1],i=o;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(o);break}i[2]&&u.ops.pop(),u.trys.pop();continue}o=e.call(t,u)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function a(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)u.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return u}function l(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function h(t){if(t.__esModule)return t;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach((function(n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})})),e}function d(t){var e={exports:{}};return t(e,e.exports),e.exports}var p=d((function(t){!function(t,e,n){function r(t){var e,n=this,r=(e=4022871197,function(t){t=String(t);for(var n=0;n<t.length;n++){var r=.02519603282416938*(e+=t.charCodeAt(n));r-=e=r>>>0,e=(r*=e)>>>0,e+=4294967296*(r-=e)}return 2.3283064365386963e-10*(e>>>0)});n.next=function(){var t=2091639*n.s0+2.3283064365386963e-10*n.c;return n.s0=n.s1,n.s1=n.s2,n.s2=t-(n.c=0|t)},n.c=1,n.s0=r(" "),n.s1=r(" "),n.s2=r(" "),n.s0-=r(t),n.s0<0&&(n.s0+=1),n.s1-=r(t),n.s1<0&&(n.s1+=1),n.s2-=r(t),n.s2<0&&(n.s2+=1),r=null}function i(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e}function o(t,e){var n=new r(t),o=e&&e.state,u=n.next;return u.int32=function(){return 4294967296*n.next()|0},u.double=function(){return u()+11102230246251565e-32*(2097152*u()|0)},u.quick=u,o&&("object"==typeof o&&i(o,n),u.state=function(){return i(n,{})}),u}e&&e.exports?e.exports=o:n&&n.amd?n((function(){return o})):this.alea=o}(0,t,!1)})),v=d((function(t){!function(t,e,n){function r(t){var e=this,n="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8},t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++)e.x^=0|n.charCodeAt(r),e.next()}function i(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e}function o(t,e){var n=new r(t),o=e&&e.state,u=function(){return(n.next()>>>0)/4294967296};return u.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},u.int32=n.next,u.quick=u,o&&("object"==typeof o&&i(o,n),u.state=function(){return i(n,{})}),u}e&&e.exports?e.exports=o:n&&n.amd?n((function(){return o})):this.xor128=o}(0,t,!1)})),m=d((function(t){!function(t,e,n){function r(t){var e=this,n="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++)e.x^=0|n.charCodeAt(r),r==n.length&&(e.d=e.x<<10^e.x>>>4),e.next()}function i(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e}function o(t,e){var n=new r(t),o=e&&e.state,u=function(){return(n.next()>>>0)/4294967296};return u.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},u.int32=n.next,u.quick=u,o&&("object"==typeof o&&i(o,n),u.state=function(){return i(n,{})}),u}e&&e.exports?e.exports=o:n&&n.amd?n((function(){return o})):this.xorwow=o}(0,t,!1)})),y=d((function(t){!function(t,e,n){function r(t){var e=this;e.next=function(){var t,n,r=e.x,i=e.i;return t=r[i],n=(t^=t>>>7)^t<<24,n^=(t=r[i+1&7])^t>>>10,n^=(t=r[i+3&7])^t>>>3,n^=(t=r[i+4&7])^t<<7,t=r[i+7&7],n^=(t^=t<<13)^t<<9,r[i]=n,e.i=i+1&7,n},function(t,e){var n,r=[];if(e===(0|e))r[0]=e;else for(e=""+e,n=0;n<e.length;++n)r[7&n]=r[7&n]<<15^e.charCodeAt(n)+r[n+1&7]<<13;for(;r.length<8;)r.push(0);for(n=0;n<8&&0===r[n];++n);for(8==n&&(r[7]=-1),t.x=r,t.i=0,n=256;n>0;--n)t.next()}(e,t)}function i(t,e){return e.x=t.x.slice(),e.i=t.i,e}function o(t,e){null==t&&(t=+new Date);var n=new r(t),o=e&&e.state,u=function(){return(n.next()>>>0)/4294967296};return u.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},u.int32=n.next,u.quick=u,o&&(o.x&&i(o,n),u.state=function(){return i(n,{})}),u}e&&e.exports?e.exports=o:n&&n.amd?n((function(){return o})):this.xorshift7=o}(0,t,!1)})),w=d((function(t){!function(t,e,n){function r(t){var e=this;e.next=function(){var t,n,r=e.w,i=e.X,o=e.i;return e.w=r=r+1640531527|0,n=i[o+34&127],t=i[o=o+1&127],n^=n<<13,t^=t<<17,n^=n>>>15,t^=t>>>12,n=i[o]=n^t,e.i=o,n+(r^r>>>16)|0},function(t,e){var n,r,i,o,u,s=[],a=128;for(e===(0|e)?(r=e,e=null):(e+="\0",r=0,a=Math.max(a,e.length)),i=0,o=-32;o<a;++o)e&&(r^=e.charCodeAt((o+32)%e.length)),0===o&&(u=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,o>=0&&(u=u+1640531527|0,i=0==(n=s[127&o]^=r+u)?i+1:0);for(i>=128&&(s[127&(e&&e.length||0)]=-1),i=127,o=512;o>0;--o)r=s[i+34&127],n=s[i=i+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,s[i]=r^n;t.w=u,t.X=s,t.i=i}(e,t)}function i(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e}function o(t,e){null==t&&(t=+new Date);var n=new r(t),o=e&&e.state,u=function(){return(n.next()>>>0)/4294967296};return u.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},u.int32=n.next,u.quick=u,o&&(o.X&&i(o,n),u.state=function(){return i(n,{})}),u}e&&e.exports?e.exports=o:n&&n.amd?n((function(){return o})):this.xor4096=o}(0,t,!1)})),b=d((function(t){!function(t,e,n){function r(t){var e=this,n="";e.next=function(){var t=e.b,n=e.c,r=e.d,i=e.a;return t=t<<25^t>>>7^n,n=n-r|0,r=r<<24^r>>>8^i,i=i-t|0,e.b=t=t<<20^t>>>12^n,e.c=n=n-r|0,e.d=r<<16^n>>>16^i,e.a=i-t|0},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):n+=t;for(var r=0;r<n.length+20;r++)e.b^=0|n.charCodeAt(r),e.next()}function i(t,e){return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e}function o(t,e){var n=new r(t),o=e&&e.state,u=function(){return(n.next()>>>0)/4294967296};return u.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},u.int32=n.next,u.quick=u,o&&("object"==typeof o&&i(o,n),u.state=function(){return i(n,{})}),u}e&&e.exports?e.exports=o:n&&n.amd?n((function(){return o})):this.tychei=o}(0,t,!1)})),g=h({__proto__:null,default:{}}),x=d((function(t){!function(e,n,r){var i,o=256,u=r.pow(o,6),s=r.pow(2,52),a=2*s,c=255;function l(t,c,l){var m=[],y=p(d((c=1==c?{entropy:!0}:c||{}).entropy?[t,v(n)]:null==t?function(){try{var t;return i&&(t=i.randomBytes)?t=t(o):(t=new Uint8Array(o),(e.crypto||e.msCrypto).getRandomValues(t)),v(t)}catch(t){var r=e.navigator,u=r&&r.plugins;return[+new Date,e,u,e.screen,v(n)]}}():t,3),m),w=new f(m),b=function(){for(var t=w.g(6),e=u,n=0;t<s;)t=(t+n)*o,e*=o,n=w.g(1);for(;t>=a;)t/=2,e/=2,n>>>=1;return(t+n)/e};return b.int32=function(){return 0|w.g(4)},b.quick=function(){return w.g(4)/4294967296},b.double=b,p(v(w.S),n),(c.pass||l||function(t,e,n,i){return i&&(i.S&&h(i,w),t.state=function(){return h(w,{})}),n?(r.random=t,e):t})(b,y,"global"in c?c.global:this==r,c.state)}function f(t){var e,n=t.length,r=this,i=0,u=r.i=r.j=0,s=r.S=[];for(n||(t=[n++]);i<o;)s[i]=i++;for(i=0;i<o;i++)s[i]=s[u=c&u+t[i%n]+(e=s[i])],s[u]=e;(r.g=function(t){for(var e,n=0,i=r.i,u=r.j,s=r.S;t--;)e=s[i=c&i+1],n=n*o+s[c&(s[i]=s[u=c&u+e])+(s[u]=e)];return r.i=i,r.j=u,n})(o)}function h(t,e){return e.i=t.i,e.j=t.j,e.S=t.S.slice(),e}function d(t,e){var n,r=[],i=typeof t;if(e&&"object"==i)for(n in t)try{r.push(d(t[n],e-1))}catch(t){}return r.length?r:"string"==i?t:t+"\0"}function p(t,e){for(var n,r=t+"",i=0;i<r.length;)e[c&i]=c&(n^=19*e[c&i])+r.charCodeAt(i++);return v(e)}function v(t){return String.fromCharCode.apply(0,t)}if(p(r.random(),n),t.exports){t.exports=l;try{i=g}catch(t){}}else r.seedrandom=l}("undefined"!=typeof self?self:f,[],Math)}));x.alea=p,x.xor128=v,x.xorwow=m,x.xorshift7=y,x.xor4096=w,x.tychei=b;var C=x;function z(t,e,n,r){if(void 0===n&&(n=new Map),void 0===r&&(r=new Set),null==t)return null;if("function"==typeof Blob&&t instanceof Blob)return t.slice();if(r.has(t))throw new Error("Circular references are not supported.");if(n.has(t))return n.get(t);var i=e(t);if(i.recurse&&null!==i.value)throw new Error("A deep map function may not return both a value and recurse=true.");if(i.recurse){if(T(t)){var o=Array.isArray(t)?[]:{};for(var u in r.add(t),t){var s=z(t[u],e,n,r);o[u]=s}return r.delete(t),t.__proto__&&(o.__proto__=t.__proto__),o}throw new Error("Can't recurse into non-iterable type: ".concat(t))}return n.set(t,i.value),i.value}function E(t,e){return void 0===e&&(e=A),S(t,e)}function S(t,e,n){void 0===n&&(n=new Set);var r=t[0];if(n.has(r))throw new Error("Circular references are not supported.");var i=e(t);if(i.recurse&&null!==i.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(i.recurse){if(T(r)){var o=Array.isArray(r)?[]:{};n.add(r);var u=function(r){var i=S(t.map((function(t){return t[r]})),e,n);o[r]=i};for(var s in r)u(s);return n.delete(r),o}throw new Error("Can't recurse into non-iterable type: ".concat(r))}return i.value}function A(t){return null===t?null:T(t[0])?{value:null,recurse:!0}:{value:t,recurse:!1}}function R(t,e){return u(this,void 0,void 0,(function(){var n,i,o,u,c,l,f,h,d;return s(this,(function(s){switch(s.label){case 0:n=new Map,z(t,e,n),s.label=1;case 1:s.trys.push([1,6,7,8]),i=a(Array.from(n.keys())),o=i.next(),s.label=2;case 2:return o.done?[3,5]:(u=o.value,c=n.get(u),r.util.isPromise(c)?[4,c]:[3,4]);case 3:l=s.sent(),n.set(u,l),s.label=4;case 4:return o=i.next(),[3,2];case 5:return[3,8];case 6:return f=s.sent(),h={error:f},[3,8];case 7:try{o&&!o.done&&(d=i.return)&&d.call(i)}finally{if(h)throw h.error}return[7];case 8:return[2,z(t,e,n)]}}))}))}function T(t){var e=!1;r.env().get("IS_BROWSER")?e=t instanceof TextDecoder:e=t instanceof require("string_decoder").StringDecoder;return null!=t&&!ArrayBuffer.isView(t)&&(Array.isArray(t)||"object"==typeof t&&!(t instanceof r.Tensor)&&!(t instanceof Promise)&&!e)}function k(t){return z(t,F)}function F(t){return t instanceof r.Tensor?{value:t.clone(),recurse:!1}:T(t)?{value:null,recurse:!0}:{value:t,recurse:!1}}var _=function(){function t(t){if(this.capacity=t,this.begin=0,this.end=0,null==t)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(t<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(t),this.doubledCapacity=2*t}return t.prototype.wrap=function(t){for(;t<0;)t+=this.doubledCapacity;return t%this.doubledCapacity},t.prototype.get=function(t){if(t<0)throw new RangeError("Can't get item at a negative index.");return this.data[t%this.capacity]},t.prototype.set=function(t,e){if(t<0)throw new RangeError("Can't set item at a negative index.");this.data[t%this.capacity]=e},t.prototype.length=function(){var t=this.end-this.begin;return t<0&&(t=this.doubledCapacity+t),t},t.prototype.isFull=function(){return this.length()===this.capacity},t.prototype.isEmpty=function(){return 0===this.length()},t.prototype.push=function(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,t),this.end=this.wrap(this.end+1)},t.prototype.pushAll=function(t){var e,n;try{for(var r=a(t),i=r.next();!i.done;i=r.next()){var o=i.value;this.push(o)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}},t.prototype.pop=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);var t=this.get(this.end);return this.set(this.end,void 0),t},t.prototype.unshift=function(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,t)},t.prototype.shift=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var t=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),t},t.prototype.shuffleExcise=function(t){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var e=this.wrap(this.begin+t),n=this.get(e);return this.set(e,this.pop()),n},t}(),O=function(t){function e(){return t.call(this,e.INITIAL_CAPACITY)||this}return o(e,t),e.prototype.isFull=function(){return!1},e.prototype.push=function(e){t.prototype.isFull.call(this)&&this.expand(),t.prototype.push.call(this,e)},e.prototype.unshift=function(e){t.prototype.isFull.call(this)&&this.expand(),t.prototype.unshift.call(this,e)},e.prototype.expand=function(){for(var t=2*this.capacity,e=new Array(t),n=this.length(),r=0;r<n;r++)e[r]=this.get(this.wrap(this.begin+r));this.data=e,this.capacity=t,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=n},e}(_);function N(t){return new M(t)}function D(t){return new P(t)}O.INITIAL_CAPACITY=32;var I,j=function(){function t(){}return t.prototype.toArray=function(){return u(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t=[],[4,this.next()];case 1:e=n.sent(),n.label=2;case 2:return e.done?[3,4]:(t.push(e.value),[4,this.next()]);case 3:return e=n.sent(),[3,2];case 4:return[2,t]}}))}))},t.prototype.toArrayForTest=function(){return u(this,void 0,void 0,(function(){var t,e,n;return s(this,(function(r){switch(r.label){case 0:return t=this.prefetch(100),e=[],[4,t.next()];case 1:n=r.sent(),r.label=2;case 2:return n.done?[3,4]:(e.push(n.value),[4,t.next()]);case 3:return n=r.sent(),[3,2];case 4:return[2,e]}}))}))},t.prototype.resolveFully=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return[4,this.next()];case 1:t=e.sent(),e.label=2;case 2:return t.done?[3,4]:[4,this.next()];case 3:return t=e.sent(),[3,2];case 4:return[2]}}))}))},t.prototype.resolveWhile=function(t){return u(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){switch(r.label){case 0:return[4,this.next()];case 1:e=r.sent(),n=t(e.value),r.label=2;case 2:return e.done||!n?[3,4]:[4,this.next()];case 3:return e=r.sent(),n=t(e.value),[3,2];case 4:return[2]}}))}))},t.prototype.handleErrors=function(t){return new U(this,t)},t.prototype.filter=function(t){return new W(this,t)},t.prototype.map=function(t){return new V(this,t)},t.prototype.mapAsync=function(t){return new Q(this,t)},t.prototype.serialMapAsync=function(t){return new Q(this,t).serial()},t.prototype.flatmap=function(t){return new G(this,t)},t.prototype.forEachAsync=function(t){return u(this,void 0,void 0,(function(){return s(this,(function(e){return[2,this.map(t).resolveFully()]}))}))},t.prototype.serialForEach=function(t){return u(this,void 0,void 0,(function(){return s(this,(function(e){return[2,this.serialMapAsync(t).resolveWhile((function(t){return!0===t}))]}))}))},t.prototype.rowMajorBatch=function(t,e){return void 0===e&&(e=!0),new H(this,t,e)},t.prototype.columnMajorBatch=function(t,e,n){return void 0===e&&(e=!0),void 0===n&&(n=A),this.rowMajorBatch(t,e).map((function(t){return E(t,n)}))},t.prototype.concatenate=function(t,e){return new Z(N([this,t]),e)},t.prototype.take=function(t){return t<0||null==t?this:new q(this,t)},t.prototype.skip=function(t){return t<0||null==t?this:new L(this,t)},t.prototype.prefetch=function(t){return new Y(this,t)},t.prototype.shuffle=function(t,e){return new K(this,t,e)},t.prototype.serial=function(){return new B(this)},t}(),M=function(t){function e(e){var n=t.call(this)||this;return n.items=e,n.trav=0,n}return o(e,t),e.prototype.summary=function(){return"Array of ".concat(this.items.length," items")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(e){return this.trav>=this.items.length?[2,{value:null,done:!0}]:(t=this.items[this.trav],this.trav++,[2,{value:k(t),done:!1}])}))}))},e}(j),P=function(t){function e(e){var n=t.call(this)||this;return n.nextFn=e,n}return o(e,t),e.prototype.summary=function(){return"Function call"},e.prototype.next=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){try{return[2,this.nextFn()]}catch(t){throw t.message="Error thrown while iterating through a dataset: ".concat(t.message),t}return[2]}))}))},e}(j),B=function(t){function e(e){var n=t.call(this)||this;return n.upstream=e,n.lastRead=Promise.resolve({value:null,done:!1}),n}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Serial")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.upstream.next()]}))}))},e}(j),L=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.maxCount=n,r.count=0,r.lastRead=Promise.resolve({value:null,done:!1}),r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Skip")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return this.count++<this.maxCount?[4,this.upstream.next()]:[3,2];case 1:return(t=e.sent()).done?[2,t]:(r.dispose(t.value),[3,0]);case 2:return[2,this.upstream.next()]}}))}))},e}(j),q=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.maxCount=n,r.count=0,r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Take")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return this.count++>=this.maxCount?[2,{value:null,done:!0}]:[2,this.upstream.next()]}))}))},e}(j),H=function(t){function e(e,n,r){void 0===r&&(r=!0);var i=t.call(this)||this;return i.upstream=e,i.batchSize=n,i.enableSmallLastBatch=r,i.lastRead=Promise.resolve({value:null,done:!1}),i}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> RowMajorBatch")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:t=[],n.label=1;case 1:return t.length<this.batchSize?[4,this.upstream.next()]:[3,3];case 2:return(e=n.sent()).done?this.enableSmallLastBatch&&t.length>0?[2,{value:t,done:!1}]:[2,{value:null,done:!0}]:(t.push(e.value),[3,1]);case 3:return[2,{value:t,done:!1}]}}))}))},e}(j),W=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.predicate=n,r.lastRead=Promise.resolve({value:null,done:!1}),r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Filter")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return[4,this.upstream.next()];case 1:return(t=e.sent()).done||this.predicate(t.value)?[2,t]:(r.dispose(t.value),[3,0]);case 2:return[2]}}))}))},e}(j),V=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Map")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t,e,n,i,o,u,c,l,f;return s(this,(function(s){switch(s.label){case 0:return[4,this.upstream.next()];case 1:if((t=s.sent()).done)return[2,{value:null,done:!0}];e=r.tensor_util.getTensorsInContainer(t.value),n=this.transform(t.value),i=r.tensor_util.getTensorsInContainer(n);try{for(o=a(e),u=o.next();!u.done;u=o.next())c=u.value,r.tensor_util.isTensorInList(c,i)||c.dispose()}catch(t){l={error:t}}finally{try{u&&!u.done&&(f=o.return)&&f.call(o)}finally{if(l)throw l.error}}return[2,{value:n,done:!1}]}}))}))},e}(j),U=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.handler=n,r.count=0,r.lastRead=Promise.resolve({value:null,done:!1}),r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> handleErrors")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.upstream.next()];case 2:return[2,e.sent()];case 3:return t=e.sent(),this.handler(t)?[3,4]:[2,{value:null,done:!0}];case 4:return[3,0];case 5:return[2]}}))}))},e}(j),Q=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> AsyncMap")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t,e,n,i,o,u,c,l,f;return s(this,(function(s){switch(s.label){case 0:return[4,this.upstream.next()];case 1:return(t=s.sent()).done?[2,{value:null,done:!0}]:(e=r.tensor_util.getTensorsInContainer(t.value),[4,this.transform(t.value)]);case 2:n=s.sent(),i=r.tensor_util.getTensorsInContainer(n);try{for(o=a(e),u=o.next();!u.done;u=o.next())c=u.value,r.tensor_util.isTensorInList(c,i)||c.dispose()}catch(t){l={error:t}}finally{try{u&&!u.done&&(f=o.return)&&f.call(o)}finally{if(l)throw l.error}}return[2,{value:n,done:!1}]}}))}))},e}(j),X=function(t){function e(){var e=t.call(this)||this;return e.outputQueue=new O,e.lastRead=Promise.resolve({value:null,done:!1}),e}return o(e,t),e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return 0!==this.outputQueue.length()?[3,2]:[4,this.pump()];case 1:return t.sent()?[3,0]:[2,{value:null,done:!0}];case 2:return[2,{value:this.outputQueue.shift(),done:!1}]}}))}))},e}(j),G=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Flatmap")},e.prototype.pump=function(){return u(this,void 0,void 0,(function(){var t,e,n,i,o,u,c,l,f;return s(this,(function(s){switch(s.label){case 0:return[4,this.upstream.next()];case 1:if((t=s.sent()).done)return[2,!1];e=r.tensor_util.getTensorsInContainer(t.value),n=this.transform(t.value),i=r.tensor_util.getTensorsInContainer(n),this.outputQueue.pushAll(n);try{for(o=a(e),u=o.next();!u.done;u=o.next())c=u.value,r.tensor_util.isTensorInList(c,i)||c.dispose()}catch(t){l={error:t}}finally{try{u&&!u.done&&(f=o.return)&&f.call(o)}finally{if(l)throw l.error}}return[2,!0]}}))}))},e}(X),Z=function(t){function e(e,n){var r=t.call(this)||this;return r.baseErrorHandler=n,r.lastRead=null,r.iterator=null,r.moreIterators=e,r}return o(e,t),e.prototype.summary=function(){return"".concat("TODO: fill in upstream of chained summaries"," -> Chained")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return this.lastRead=this.readFromChain(this.lastRead),[2,this.lastRead]}))}))},e.prototype.readFromChain=function(t){return u(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){switch(r.label){case 0:return[4,t];case 1:return r.sent(),null!=this.iterator?[3,3]:[4,this.moreIterators.next()];case 2:if((e=r.sent()).done)return[2,{value:null,done:!0}];this.iterator=e.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler)),r.label=3;case 3:return[4,this.iterator.next()];case 4:return(n=r.sent()).done?(this.iterator=null,[2,this.readFromChain(t)]):[2,n]}}))}))},e}(j);!function(t){t[t.FAIL=0]="FAIL",t[t.SHORTEST=1]="SHORTEST",t[t.LONGEST=2]="LONGEST"}(I||(I={}));var J=function(t){function e(e,n){void 0===n&&(n=I.FAIL);var r=t.call(this)||this;return r.iterators=e,r.mismatchMode=n,r.count=0,r.currentPromise=null,r}return o(e,t),e.prototype.summary=function(){return"{".concat("TODO: fill in upstream of zip summaries","} -> Zip")},e.prototype.nextState=function(t){return u(this,void 0,void 0,(function(){function e(t){return t instanceof j?{value:t.next().then((function(t){return n++,t.done&&r++,t.value})),recurse:!1}:{value:null,recurse:!0}}var n,r,i;return s(this,(function(o){switch(o.label){case 0:return[4,t];case 1:return o.sent(),n=0,r=0,[4,R(this.iterators,e)];case 2:if(i=o.sent(),n===r)return[2,{value:null,done:!0}];if(r>0)switch(this.mismatchMode){case I.FAIL:throw new Error("Zipped streams should have the same length. "+"Mismatched at element ".concat(this.count,"."));case I.SHORTEST:return[2,{value:null,done:!0}];case I.LONGEST:}return this.count++,[2,{value:i,done:!1}]}}))}))},e.prototype.next=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return this.currentPromise=this.nextState(this.currentPromise),[2,this.currentPromise]}))}))},e}(j),Y=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.bufferSize=n,r.buffer=new _(n),r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Prefetch")},e.prototype.refill=function(){for(;!this.buffer.isFull();){var t=this.upstream.next();this.buffer.push(t)}},e.prototype.next=function(){return this.refill(),this.buffer.shift()},e}(j),K=function(t){function e(e,n,i){var o=t.call(this,e,n)||this;return o.upstream=e,o.windowSize=n,o.upstreamExhausted=!1,o.random=C.alea(i||r.util.now().toString()),o.lastRead=Promise.resolve({value:null,done:!1}),o}return o(e,t),e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.randomInt=function(t){return Math.floor(this.random()*t)},e.prototype.chooseIndex=function(){return this.randomInt(this.buffer.length())},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:this.upstreamExhausted||this.refill(),n.label=1;case 1:return this.buffer.isEmpty()?[3,3]:(t=this.chooseIndex(),[4,this.buffer.shuffleExcise(t)]);case 2:return(e=n.sent()).done?(this.upstreamExhausted=!0,[3,1]):(this.refill(),[2,e]);case 3:return[2,{value:null,done:!0}]}}))}))},e}(Y),$=function(){function t(){this.size=null}return t.prototype.batch=function(t,e){var n=this;void 0===e&&(e=!0);var i=this;return r.util.assert(t>0,(function(){return"batchSize needs to be positive, but it is\n ".concat(t)})),tt((function(){return u(n,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,i.iterator()];case 1:return[2,n.sent().columnMajorBatch(t,e,et)]}}))}))}),this.size===1/0||null==this.size?this.size:e?Math.ceil(this.size/t):Math.floor(this.size/t))},t.prototype.concatenate=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){var e,r;return s(this,(function(i){switch(i.label){case 0:return[4,n.iterator()];case 1:return r=(e=i.sent()).concatenate,[4,t.iterator()];case 2:return[2,r.apply(e,[i.sent()])]}}))}))}),this.size===1/0||t.size===1/0?1/0:null!=this.size&&null!=t.size?this.size+t.size:null)},t.prototype.filter=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().filter((function(e){return r.tidy((function(){return t(e)}))}))]}}))}))}),this.size===1/0?1/0:null)},t.prototype.forEachAsync=function(t){return u(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.iterator()];case 1:return[2,e.sent().forEachAsync(t)]}}))}))},t.prototype.map=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().map((function(e){return r.tidy((function(){return t(e)}))}))]}}))}))}),this.size)},t.prototype.mapAsync=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().mapAsync(t)]}}))}))}),this.size)},t.prototype.prefetch=function(t){var e=this;if(null==t)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");var n=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().prefetch(t)]}}))}))}),this.size)},t.prototype.repeat=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){var e,r=this;return s(this,(function(i){return e=D((function(){return u(r,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t={},[4,n.iterator()];case 1:return[2,(t.value=e.sent(),t.done=!1,t)]}}))}))})),[2,(o=e.take(t),new Z(o,a))];var o,a}))}))}),null!=this.size&&t>0?this.size*t:0===t?0:null!=this.size&&(void 0===t||t<0)?1/0:null)},t.prototype.skip=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().skip(t)]}}))}))}),null!=this.size&&t>=0&&this.size>=t?this.size-t:null!=this.size&&(this.size<t||void 0===t||t<0)?0:null)},t.prototype.shuffle=function(t,e,n){var i=this;if(void 0===n&&(n=!0),null==t||t<0)throw null==this.size?new RangeError("`Dataset.shuffle()` requires bufferSize to be specified."):new RangeError("`Dataset.shuffle()` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for `tf.Tensor`s), consider setting "+"bufferSize to the dataset size (".concat(this.size," elements)"));var o=this,a=C.alea(e||r.util.now().toString());return tt((function(){return u(i,void 0,void 0,(function(){var e;return s(this,(function(r){switch(r.label){case 0:return e=a.int32(),n&&(e+=a.int32()),[4,o.iterator()];case 1:return[2,r.sent().shuffle(t,e.toString())]}}))}))}),this.size)},t.prototype.take=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().take(t)]}}))}))}),null!=this.size&&this.size>t?t:null!=this.size&&this.size<=t?this.size:null)},t.prototype.toArray=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return[4,this.iterator()];case 1:return[2,t.sent().toArray()]}}))}))},t.prototype.toArrayForTest=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return[4,this.iterator()];case 1:return[2,t.sent().toArrayForTest()]}}))}))},t}();function tt(t,e){return void 0===e&&(e=null),new(function(n){function r(){var t=n.apply(this,l([],c(arguments),!1))||this;return t.size=e,t}return o(r,n),r.prototype.iterator=function(){return u(this,void 0,void 0,(function(){return s(this,(function(e){return[2,t()]}))}))},r}($))}function et(t){return null===t?null:function(t){return null==t||null===(e=t)||"object"!=typeof e&&"function"!=typeof e||Array.isArray(t)||"object"==typeof t&&t instanceof r.Tensor||r.util.isTypedArray(t);var e}(t[0])?{value:function(t){if(0===t.length)throw new Error("Can't make a batch of zero elements.");return t[0]instanceof r.Tensor?r.stack(t):r.tensor(t)}(t),recurse:!1}:{value:null,recurse:!0}}$.MAX_BUFFER_SIZE=1e4;var nt=function(t){function e(e){var n=t.call(this)||this;return n.input=e,n}return o(e,t),e.prototype.iterator=function(){return u(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return[4,this.input.iterator()];case 1:return t=n.sent(),e=t.decodeUTF8(),[2,e.split("\n").map((function(t){return t.endsWith("\r")&&(t=t.slice(0,-1)),t}))]}}))}))},e}($),rt='"',it=Symbol("out"),ot=Symbol("field"),ut=Symbol("quote"),st=Symbol("quoteafterquote"),at=Symbol("quoteinquote"),ct=function(t){function n(n,r){var i=t.call(this)||this;return i.input=n,i.hasHeader=!0,i.fullColumnNames=null,i.columnNamesValidated=!1,i.columnConfigs=null,i.configuredColumnsOnly=!1,i.delimiter=",",i.delimWhitespace=!1,i.base=new nt(n),r||(r={}),i.hasHeader=!1!==r.hasHeader,i.fullColumnNames=r.columnNames,i.columnConfigs=r.columnConfigs,i.configuredColumnsOnly=r.configuredColumnsOnly,r.delimWhitespace?(e.util.assert(null==r.delimiter,(function(){return"Delimiter should not be provided when delimWhitespace is true."})),i.delimWhitespace=!0,i.delimiter=" "):i.delimiter=r.delimiter?r.delimiter:",",i}return o(n,t),n.prototype.columnNames=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:t.sent(),t.label=2;case 2:return[2,this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames]}}))}))},n.prototype.setColumnNames=function(){return u(this,void 0,void 0,(function(){var t,n,r,i,o,u,c,l,f=this;return s(this,(function(s){switch(s.label){case 0:return[4,this.maybeReadHeaderLine()];case 1:if(t=s.sent(),!this.fullColumnNames&&!t)throw new Error("Column names must be provided if there is no header line.");if(this.fullColumnNames&&t&&e.util.assert(t.length===this.fullColumnNames.length,(function(){return"The length of provided columnNames ("+f.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+t.length.toString()+")."})),this.fullColumnNames||(this.fullColumnNames=t),n=this.fullColumnNames.reduce((function(t,e){return t[e]=t[e]+1||1,t}),{}),r=Object.keys(n).filter((function(t){return n[t]>1})),e.util.assert(0===r.length,(function(){return"Duplicate column names found: "+r.toString()})),this.columnConfigs)try{for(i=a(Object.keys(this.columnConfigs)),o=i.next();!o.done;o=i.next())if(u=o.value,-1===this.fullColumnNames.indexOf(u))throw new Error('The key "'+u+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").")}catch(t){c={error:t}}finally{try{o&&!o.done&&(l=i.return)&&l.call(i)}finally{if(c)throw c.error}}return this.columnNamesValidated=!0,[2]}}))}))},n.prototype.maybeReadHeaderLine=function(){return u(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return this.hasHeader?[4,this.base.iterator()]:[3,3];case 1:return[4,n.sent().next()];case 2:if((t=n.sent()).done)throw new Error("No data was found for CSV parsing.");return e=t.value,[2,this.parseRow(e,!1)];case 3:return[2,null]}}))}))},n.prototype.iterator=function(){return u(this,void 0,void 0,(function(){var t,e=this;return s(this,(function(n){switch(n.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:n.sent(),n.label=2;case 2:return[4,this.base.iterator()];case 3:return t=n.sent(),this.hasHeader&&(t=t.skip(1)),[2,t.map((function(t){return e.makeDataElement(t)}))]}}))}))},n.prototype.makeDataElement=function(t){for(var e=this.parseRow(t),n={},r={},i=0;i<this.fullColumnNames.length;i++){var o=this.fullColumnNames[i],u=this.columnConfigs?this.columnConfigs[o]:null;if(!this.configuredColumnsOnly||u){var s=e[i],a=null;if(""===s)if(u&&void 0!==u.default)a=u.default;else{if(u&&(u.required||u.isLabel))throw new Error("Required column ".concat(o," is empty in this line: ").concat(t));a=void 0}else{var c=Number(s);if(isNaN(c))a=u&&"bool"===u.dtype?this.getBoolean(s):s;else if(u&&u.dtype)switch(u.dtype){case"float32":default:a=c;break;case"int32":a=Math.floor(c);break;case"bool":a=this.getBoolean(s)}else a=c}u&&u.isLabel?r[o]=a:n[o]=a}}return 0===Object.keys(r).length?n:{xs:n,ys:r}},n.prototype.getBoolean=function(t){return"1"===t||"true"===t.toLowerCase()?1:0},n.prototype.parseRow=function(t,e){void 0===e&&(e=!0);for(var n=[],r=0,i=t.length,o=it,u=0;u<i;u++)switch(o){case it:switch(t.charAt(u)){case rt:r=u+1,o=ut;break;case this.delimiter:if(r=u+1," "===this.delimiter&&this.delimWhitespace)break;n.push(""),o=it;break;default:o=ot,r=u}break;case ot:if(t.charAt(u)===this.delimiter)n.push(t.substring(r,u)),o=it,r=u+1;break;case ut:if(t.charAt(u)===rt)o=st;break;case st:switch(t.charAt(u)){case this.delimiter:n.push(t.substring(r,u-1)),o=it,r=u+1;break;case rt:o=ut;break;default:o=at}break;case at:if(t.charAt(u)===rt)o=ut}if(o===st?n.push(t.substring(r,i-1)):n.push(t.substring(r)),e&&n.length!==this.fullColumnNames.length)throw new Error("Invalid row in csv file. Should have ".concat(this.fullColumnNames.length," elements in a row, but got ").concat(n));return n},n}($),lt=function(t){function n(e){var n=t.call(this)||this;n.microphoneConfig=e,n.isClosed=!1,n.fftSize=e.fftSize||1024;var r=Math.log2(n.fftSize);if(n.fftSize<0||r<4||r>14||!Number.isInteger(r))throw new Error("Invalid fftSize: it must be a power of 2 between "+"2 to 4 and 2 to 14, but got ".concat(n.fftSize));if(n.numFrames=e.numFramesPerSpectrogram||43,n.sampleRateHz=e.sampleRateHz,n.columnTruncateLength=e.columnTruncateLength||n.fftSize,n.audioTrackConstraints=e.audioTrackConstraints,n.smoothingTimeConstant=e.smoothingTimeConstant||0,n.includeSpectrogram=!1!==e.includeSpectrogram,n.includeWaveform=!0===e.includeWaveform,!n.includeSpectrogram&&!n.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.");return n}return o(n,t),n.prototype.summary=function(){return"microphone"},n.create=function(t){return void 0===t&&(t={}),u(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:if(!e.env().get("IS_BROWSER"))throw new Error("microphone API is only supported in browser environment.");return[4,(r=new n(t)).start()];case 1:return i.sent(),[2,r]}}))}))},n.prototype.start=function(){return u(this,void 0,void 0,(function(){var t,e,n,r;return s(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=this,[4,navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1})];case 1:return t.stream=i.sent(),[3,3];case 2:throw e=i.sent(),new Error("Error thrown while initializing video stream: ".concat(e.message));case 3:if(!this.stream)throw new Error("Could not obtain audio from microphone.");if(n=window.AudioContext||window.webkitAudioContext,this.audioContext=new n,this.sampleRateHz){if(this.audioContext.sampleRate!==this.sampleRateHz)throw new Error("Mismatch in sampling rate: "+"Expected: ".concat(this.sampleRateHz,"; ")+"Actual: ".concat(this.audioContext.sampleRate))}else this.sampleRateHz=this.audioContext.sampleRate;return r=this.audioContext.createMediaStreamSource(this.stream),this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,r.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize),[2]}}))}))},n.prototype.next=function(){return u(this,void 0,void 0,(function(){var t,e,n,r,i;return s(this,(function(o){switch(o.label){case 0:return this.isClosed?[2,{value:null,done:!0}]:[4,this.getAudioData()];case 1:return n=o.sent(),this.includeSpectrogram&&(r=this.flattenQueue(n.freqDataQueue),t=this.getTensorFromAudioDataArray(r,[this.numFrames,this.columnTruncateLength,1])),this.includeWaveform&&(i=this.flattenQueue(n.timeDataQueue),e=this.getTensorFromAudioDataArray(i,[this.numFrames*this.fftSize,1])),[2,{value:{spectrogram:t,waveform:e},done:!1}]}}))}))},n.prototype.capture=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.next()];case 1:return[2,t.sent().value]}}))}))},n.prototype.getAudioData=function(){return u(this,void 0,void 0,(function(){var t,e,n,r=this;return s(this,(function(i){return t=[],e=[],n=0,[2,new Promise((function(i){var o=setInterval((function(){r.includeSpectrogram&&(r.analyser.getFloatFrequencyData(r.freqData),r.freqData[0]===-1/0&&i({freqDataQueue:t,timeDataQueue:e}),t.push(r.freqData.slice(0,r.columnTruncateLength))),r.includeWaveform&&(r.analyser.getFloatTimeDomainData(r.timeData),e.push(r.timeData.slice())),++n===r.numFrames&&(clearInterval(o),i({freqDataQueue:t,timeDataQueue:e}))}),r.fftSize/r.sampleRateHz*1e3)}))]}))}))},n.prototype.stop=function(){this.isClosed||(this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop())},n.prototype.toArray=function(){throw new Error("Can not convert infinite audio stream to array.")},n.prototype.getSampleRate=function(){return this.sampleRateHz},n.prototype.flattenQueue=function(t){var e=t[0].length,n=new Float32Array(t.length*e);return t.forEach((function(t,r){return n.set(t,r*e)})),n},n.prototype.getTensorFromAudioDataArray=function(t,n){var r=new Float32Array(e.util.sizeFromShape(n));return r.set(t,r.length-t.length),e.tensor(r,n)},n}(j),ft=function(t){function n(n,r){var i=t.call(this)||this;if(i.webcamVideoElement=n,i.webcamConfig=r,i.isClosed=!0,i.resize=!1,i.needToResize())if(i.resize=!0,i.cropSize=[i.webcamConfig.resizeHeight,i.webcamConfig.resizeWidth],i.cropBoxInd=e.tensor1d([0],"int32"),i.webcamConfig.centerCrop){var o=1*i.webcamConfig.resizeWidth/i.webcamVideoElement.width,u=1*i.webcamConfig.resizeHeight/i.webcamVideoElement.height,s=(1-o)/2,a=(1-u)/2,c=s+o,l=u+a;i.cropBox=e.tensor2d([a,s,l,c],[1,4])}else i.cropBox=e.tensor2d([0,0,1,1],[1,4]);return i}return o(n,t),n.prototype.summary=function(){return"webcam"},n.create=function(t,r){return void 0===r&&(r={}),u(this,void 0,void 0,(function(){var i;return s(this,(function(o){switch(o.label){case 0:if(!e.env().get("IS_BROWSER"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!t){if(t=document.createElement("video"),!r.resizeWidth||!r.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");t.width=r.resizeWidth,t.height=r.resizeHeight}return[4,(i=new n(t,r)).start()];case 1:return o.sent(),[2,i]}}))}))},n.prototype.start=function(){return u(this,void 0,void 0,(function(){var t,n,r=this;return s(this,(function(i){switch(i.label){case 0:this.webcamConfig.facingMode&&e.util.assert("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,(function(){return"Invalid webcam facing mode: ".concat(r.webcamConfig.facingMode,". ")+"Please provide 'user' or 'environment'"})),i.label=1;case 1:return i.trys.push([1,3,,4]),t=this,[4,navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})];case 2:return t.stream=i.sent(),[3,4];case 3:throw(n=i.sent()).message="Error thrown while initializing video stream: ".concat(n.message),n;case 4:if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(t){console.log(t),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,[2,new Promise((function(t){r.webcamVideoElement.onloadedmetadata=function(){t()}}))]}}))}))},n.prototype.next=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(n){if(this.isClosed)return[2,{value:null,done:!0}];try{t=e.browser.fromPixels(this.webcamVideoElement)}catch(t){throw new Error("Error thrown converting video to pixels: ".concat(JSON.stringify(t)))}if(!this.resize)return[2,{value:t,done:!1}];try{return[2,{value:this.cropAndResizeFrame(t),done:!1}]}catch(t){throw new Error("Error thrown cropping the video: ".concat(t.message))}finally{t.dispose()}return[2]}))}))},n.prototype.needToResize=function(){return!(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight)},n.prototype.cropAndResizeFrame=function(t){var n=this;return e.tidy((function(){var r,i=e.expandDims(e.cast(t,"float32"),0),o=(r=e.image.cropAndResize(i,n.cropBox,n.cropBoxInd,n.cropSize,"bilinear")).shape;return e.reshape(r,o.slice(1))}))},n.prototype.capture=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.next()];case 1:return[2,t.sent().value]}}))}))},n.prototype.stop=function(){this.stream.getTracks().forEach((function(t){return t.stop()}));try{this.webcamVideoElement.srcObject=null}catch(t){console.log(t),this.webcamVideoElement.src=null}this.isClosed=!0},n.prototype.toArray=function(){throw new Error("Can not convert infinite video stream to array.")},n}(j),ht=function(){},dt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.split=function(t){return new pt(this,t)},e}(j),pt=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.impl=new vt(e,n),r}return o(e,t),e.prototype.summary=function(){return this.impl.summary()},e.prototype.next=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.impl.next()]}))}))},e}(dt),vt=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.separator=n,r.carryover="",r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Split('").concat(this.separator,"')")},e.prototype.pump=function(){return u(this,void 0,void 0,(function(){var t,e,n,r,i,o,u;return s(this,(function(s){switch(s.label){case 0:return[4,this.upstream.next()];case 1:if((t=s.sent()).done)return""===this.carryover?[2,!1]:(this.outputQueue.push(this.carryover),this.carryover="",[2,!0]);(e=t.value.split(this.separator))[0]=this.carryover+e[0];try{for(n=a(e.slice(0,-1)),r=n.next();!r.done;r=n.next())i=r.value,this.outputQueue.push(i)}catch(t){o={error:t}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}}return this.carryover=e[e.length-1],[2,!0]}}))}))},e}(X),mt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.decodeUTF8=function(){return new yt(this)},e}(j),yt=function(t){function e(e){var n=t.call(this)||this;return n.upstream=e,n.impl=new wt(e),n}return o(e,t),e.prototype.summary=function(){return this.impl.summary()},e.prototype.next=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.impl.next()]}))}))},e}(dt),wt=function(t){function n(n){var r=t.call(this)||this;if(r.upstream=n,e.env().get("IS_BROWSER"))r.decoder=new TextDecoder("utf-8");else{var i=require("string_decoder").StringDecoder;r.decoder=new i("utf8")}return r}return o(n,t),n.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Utf8")},n.prototype.pump=function(){return u(this,void 0,void 0,(function(){var t,n,r;return s(this,(function(i){switch(i.label){case 0:return[4,this.upstream.next()];case 1:return(t=i.sent()).done?[2,!1]:(n=t.value,r=e.env().get("IS_BROWSER")?this.decoder.decode(n,{stream:!0}):this.decoder.write(Buffer.from(n.buffer)),this.outputQueue.push(r),[2,!0])}}))}))},n}(X),bt=function(t){function n(n,r){void 0===r&&(r={});var i=t.call(this)||this;return i.file=n,i.options=r,e.util.assert(n instanceof Uint8Array||!!e.env().get("IS_BROWSER")&&(n instanceof File||n instanceof Blob),(function(){return"FileChunkIterator only supports File, Blob and Uint8Array right now."})),i.offset=r.offset||0,i.chunkSize=r.chunkSize||1048576,i}return o(n,t),n.prototype.summary=function(){return"FileChunks ".concat(this.file)},n.prototype.next=function(){return u(this,void 0,void 0,(function(){var t,e,n=this;return s(this,(function(r){switch(r.label){case 0:return this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size)?[2,{value:null,done:!0}]:(t=new Promise((function(t,e){var r=n.offset+n.chunkSize;if(n.file instanceof Uint8Array)t(new Uint8Array(n.file.slice(n.offset,r)));else{var i=new FileReader;i.onload=function(n){var r=i.result;if(r instanceof ArrayBuffer&&(r=new Uint8Array(r)),!(r instanceof Uint8Array))return e(new TypeError("FileReader returned unknown type."));t(r)},i.onabort=function(t){return e(new Error("Aborted"))},i.onerror=function(t){return e(new Error(t.type))};var o=n.file.slice(n.offset,r);i.readAsArrayBuffer(o)}n.offset=r})),e={},[4,t]);case 1:return[2,(e.value=r.sent(),e.done=!1,e)]}}))}))},n}(mt);function gt(t,n,r){return void 0===n&&(n={}),u(this,void 0,void 0,(function(){var i,o,u,a,c;return s(this,(function(s){switch(s.label){case 0:return"string"==typeof t?i=t:(i=t.url,o=xt(t)),[4,(r||e.util.fetch)(i,o)];case 1:return(u=s.sent()).ok?(c=Uint8Array.bind,[4,u.arrayBuffer()]):[3,3];case 2:return a=new(c.apply(Uint8Array,[void 0,s.sent()])),[2,new bt(a,n)];case 3:throw new Error(u.statusText)}}))}))}var xt=function(t){return{method:t.method,headers:t.headers,body:t.body,mode:t.mode,credentials:t.credentials,cache:t.cache,redirect:t.redirect,referrer:t.referrer,integrity:t.integrity}};function Ct(t){return"string"==typeof t&&"file://"===t.slice(0,7)}var zt=function(t){function n(e,n){void 0===n&&(n={});var r=t.call(this)||this;return r.input=e,r.options=n,r}return o(n,t),n.prototype.iterator=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(n){return Ct(this.input)&&e.env().get("IS_NODE")&&(t=require("fs"),this.input=t.readFileSync(this.input.slice(7))),[2,new bt(this.input,this.options)]}))}))},n}(ht),Et=function(t){function e(e,n){void 0===n&&(n={});var r=t.call(this)||this;return r.url=e,r.fileOptions=n,r}return o(e,t),e.prototype.iterator=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return Ct(this.url)?[2,new zt(this.url,this.fileOptions).iterator()]:[2,gt(this.url,this.fileOptions)]}))}))},e}(ht);t.CSVDataset=ct,t.Dataset=$,t.FileDataSource=zt,t.TextLineDataset=nt,t.URLDataSource=Et,t.array=function(t){var e=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){return[2,N(t)]}))}))}),t.length)},t.csv=function(t,e){return void 0===e&&(e={}),new ct(new Et(t),e)},t.func=function(t){var e=this,n=D(t);return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(t){return[2,n]}))}))}))},t.generator=function(t){var e=this;return tt((function(){return u(e,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return[4,t()];case 1:return e=n.sent(),[2,D((function(){return e.next()}))]}}))}))}))},t.microphone=function(t){return u(this,void 0,void 0,(function(){return s(this,(function(e){return[2,lt.create(t)]}))}))},t.version_data="4.3.0",t.webcam=function(t,e){return u(this,void 0,void 0,(function(){return s(this,(function(n){return[2,ft.create(t,e)]}))}))},t.zip=function(t){var e,n=this;if(!T(t))throw new Error("The argument to zip() must be an object or array.");if(Array.isArray(t))for(var r=0;r<t.length;r++)e=null==e?t[r].size:Math.min(e,t[r].size);else if(t instanceof Object)for(var i in t)e=null==e?t[i].size:Math.min(e,t[i].size);return tt((function(){return u(n,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return[4,R(t,(function(t){if(t instanceof $)return{value:t.iterator(),recurse:!1};if(T(t))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")}))];case 1:return e=n.sent(),[2,(r=e,i=I.SHORTEST,void 0===i&&(i=I.FAIL),new J(r,i))]}var r,i}))}))}),e)},Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=tf-data.min.js.map

@@ -27,7 +27,7 @@ /**

*/
export declare type ElementArray = number | number[] | tf.Tensor | string;
export type ElementArray = number | number[] | tf.Tensor | string;
/**
* A map from string keys (aka column names) to values for a single element.
*/
export declare type TabularRecord = {
export type TabularRecord = {
[key: string]: ElementArray;

@@ -34,0 +34,0 @@ };

@@ -17,3 +17,3 @@ /**

*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@tensorflow/tfjs-core")):"function"==typeof define&&define.amd?define(["exports","@tensorflow/tfjs-core"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).tf=t.tf||{},t.tf)}(this,(function(t,e){"use strict";function r(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(r){if("default"!==r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})}})),e.default=t,e}var s=r(e),n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(t){if(t.__esModule)return t;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach((function(r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})})),e}function a(t){var e={exports:{}};return t(e,e.exports),e.exports}var o=a((function(t){!function(t,e,r){function s(t){var e,r=this,s=(e=4022871197,function(t){t=String(t);for(var r=0;r<t.length;r++){var s=.02519603282416938*(e+=t.charCodeAt(r));s-=e=s>>>0,e=(s*=e)>>>0,e+=4294967296*(s-=e)}return 2.3283064365386963e-10*(e>>>0)});r.next=function(){var t=2091639*r.s0+2.3283064365386963e-10*r.c;return r.s0=r.s1,r.s1=r.s2,r.s2=t-(r.c=0|t)},r.c=1,r.s0=s(" "),r.s1=s(" "),r.s2=s(" "),r.s0-=s(t),r.s0<0&&(r.s0+=1),r.s1-=s(t),r.s1<0&&(r.s1+=1),r.s2-=s(t),r.s2<0&&(r.s2+=1),s=null}function n(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e}function i(t,e){var r=new s(t),i=e&&e.state,a=r.next;return a.int32=function(){return 4294967296*r.next()|0},a.double=function(){return a()+11102230246251565e-32*(2097152*a()|0)},a.quick=a,i&&("object"==typeof i&&n(i,r),a.state=function(){return n(r,{})}),a}e&&e.exports?e.exports=i:r&&r.amd?r((function(){return i})):this.alea=i}(0,t,!1)})),u=a((function(t){!function(t,e,r){function s(t){var e=this,r="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8},t===(0|t)?e.x=t:r+=t;for(var s=0;s<r.length+64;s++)e.x^=0|r.charCodeAt(s),e.next()}function n(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e}function i(t,e){var r=new s(t),i=e&&e.state,a=function(){return(r.next()>>>0)/4294967296};return a.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},a.int32=r.next,a.quick=a,i&&("object"==typeof i&&n(i,r),a.state=function(){return n(r,{})}),a}e&&e.exports?e.exports=i:r&&r.amd?r((function(){return i})):this.xor128=i}(0,t,!1)})),h=a((function(t){!function(t,e,r){function s(t){var e=this,r="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:r+=t;for(var s=0;s<r.length+64;s++)e.x^=0|r.charCodeAt(s),s==r.length&&(e.d=e.x<<10^e.x>>>4),e.next()}function n(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e}function i(t,e){var r=new s(t),i=e&&e.state,a=function(){return(r.next()>>>0)/4294967296};return a.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},a.int32=r.next,a.quick=a,i&&("object"==typeof i&&n(i,r),a.state=function(){return n(r,{})}),a}e&&e.exports?e.exports=i:r&&r.amd?r((function(){return i})):this.xorwow=i}(0,t,!1)})),l=a((function(t){!function(t,e,r){function s(t){var e=this;e.next=function(){var t,r,s=e.x,n=e.i;return t=s[n],r=(t^=t>>>7)^t<<24,r^=(t=s[n+1&7])^t>>>10,r^=(t=s[n+3&7])^t>>>3,r^=(t=s[n+4&7])^t<<7,t=s[n+7&7],r^=(t^=t<<13)^t<<9,s[n]=r,e.i=n+1&7,r},function(t,e){var r,s=[];if(e===(0|e))s[0]=e;else for(e=""+e,r=0;r<e.length;++r)s[7&r]=s[7&r]<<15^e.charCodeAt(r)+s[r+1&7]<<13;for(;s.length<8;)s.push(0);for(r=0;r<8&&0===s[r];++r);for(8==r&&(s[7]=-1),t.x=s,t.i=0,r=256;r>0;--r)t.next()}(e,t)}function n(t,e){return e.x=t.x.slice(),e.i=t.i,e}function i(t,e){null==t&&(t=+new Date);var r=new s(t),i=e&&e.state,a=function(){return(r.next()>>>0)/4294967296};return a.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},a.int32=r.next,a.quick=a,i&&(i.x&&n(i,r),a.state=function(){return n(r,{})}),a}e&&e.exports?e.exports=i:r&&r.amd?r((function(){return i})):this.xorshift7=i}(0,t,!1)})),c=a((function(t){!function(t,e,r){function s(t){var e=this;e.next=function(){var t,r,s=e.w,n=e.X,i=e.i;return e.w=s=s+1640531527|0,r=n[i+34&127],t=n[i=i+1&127],r^=r<<13,t^=t<<17,r^=r>>>15,t^=t>>>12,r=n[i]=r^t,e.i=i,r+(s^s>>>16)|0},function(t,e){var r,s,n,i,a,o=[],u=128;for(e===(0|e)?(s=e,e=null):(e+="\0",s=0,u=Math.max(u,e.length)),n=0,i=-32;i<u;++i)e&&(s^=e.charCodeAt((i+32)%e.length)),0===i&&(a=s),s^=s<<10,s^=s>>>15,s^=s<<4,s^=s>>>13,i>=0&&(a=a+1640531527|0,n=0==(r=o[127&i]^=s+a)?n+1:0);for(n>=128&&(o[127&(e&&e.length||0)]=-1),n=127,i=512;i>0;--i)s=o[n+34&127],r=o[n=n+1&127],s^=s<<13,r^=r<<17,s^=s>>>15,r^=r>>>12,o[n]=s^r;t.w=a,t.X=o,t.i=n}(e,t)}function n(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e}function i(t,e){null==t&&(t=+new Date);var r=new s(t),i=e&&e.state,a=function(){return(r.next()>>>0)/4294967296};return a.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},a.int32=r.next,a.quick=a,i&&(i.X&&n(i,r),a.state=function(){return n(r,{})}),a}e&&e.exports?e.exports=i:r&&r.amd?r((function(){return i})):this.xor4096=i}(0,t,!1)})),f=a((function(t){!function(t,e,r){function s(t){var e=this,r="";e.next=function(){var t=e.b,r=e.c,s=e.d,n=e.a;return t=t<<25^t>>>7^r,r=r-s|0,s=s<<24^s>>>8^n,n=n-t|0,e.b=t=t<<20^t>>>12^r,e.c=r=r-s|0,e.d=s<<16^r>>>16^n,e.a=n-t|0},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):r+=t;for(var s=0;s<r.length+20;s++)e.b^=0|r.charCodeAt(s),e.next()}function n(t,e){return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e}function i(t,e){var r=new s(t),i=e&&e.state,a=function(){return(r.next()>>>0)/4294967296};return a.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},a.int32=r.next,a.quick=a,i&&("object"==typeof i&&n(i,r),a.state=function(){return n(r,{})}),a}e&&e.exports?e.exports=i:r&&r.amd?r((function(){return i})):this.tychei=i}(0,t,!1)})),d=i({__proto__:null,default:{}}),m=a((function(t){!function(e,r,s){var n,i=256,a=s.pow(i,6),o=s.pow(2,52),u=2*o,h=255;function l(t,h,l){var d=[],y=p(m((h=1==h?{entropy:!0}:h||{}).entropy?[t,w(r)]:null==t?function(){try{var t;return n&&(t=n.randomBytes)?t=t(i):(t=new Uint8Array(i),(e.crypto||e.msCrypto).getRandomValues(t)),w(t)}catch(t){var s=e.navigator,a=s&&s.plugins;return[+new Date,e,a,e.screen,w(r)]}}():t,3),d),g=new c(d),x=function(){for(var t=g.g(6),e=a,r=0;t<o;)t=(t+r)*i,e*=i,r=g.g(1);for(;t>=u;)t/=2,e/=2,r>>>=1;return(t+r)/e};return x.int32=function(){return 0|g.g(4)},x.quick=function(){return g.g(4)/4294967296},x.double=x,p(w(g.S),r),(h.pass||l||function(t,e,r,n){return n&&(n.S&&f(n,g),t.state=function(){return f(g,{})}),r?(s.random=t,e):t})(x,y,"global"in h?h.global:this==s,h.state)}function c(t){var e,r=t.length,s=this,n=0,a=s.i=s.j=0,o=s.S=[];for(r||(t=[r++]);n<i;)o[n]=n++;for(n=0;n<i;n++)o[n]=o[a=h&a+t[n%r]+(e=o[n])],o[a]=e;(s.g=function(t){for(var e,r=0,n=s.i,a=s.j,o=s.S;t--;)e=o[n=h&n+1],r=r*i+o[h&(o[n]=o[a=h&a+e])+(o[a]=e)];return s.i=n,s.j=a,r})(i)}function f(t,e){return e.i=t.i,e.j=t.j,e.S=t.S.slice(),e}function m(t,e){var r,s=[],n=typeof t;if(e&&"object"==n)for(r in t)try{s.push(m(t[r],e-1))}catch(t){}return s.length?s:"string"==n?t:t+"\0"}function p(t,e){for(var r,s=t+"",n=0;n<s.length;)e[h&n]=h&(r^=19*e[h&n])+s.charCodeAt(n++);return w(e)}function w(t){return String.fromCharCode.apply(0,t)}if(p(s.random(),r),t.exports){t.exports=l;try{n=d}catch(t){}}else s.seedrandom=l}("undefined"!=typeof self?self:n,[],Math)}));m.alea=o,m.xor128=u,m.xorwow=h,m.xorshift7=l,m.xor4096=c,m.tychei=f;var p,w=m;function y(t,e,r=new Map,s=new Set){if(null==t)return null;if("function"==typeof Blob&&t instanceof Blob)return t.slice();if(s.has(t))throw new Error("Circular references are not supported.");if(r.has(t))return r.get(t);const n=e(t);if(n.recurse&&null!==n.value)throw new Error("A deep map function may not return both a value and recurse=true.");if(n.recurse){if(C(t)){const n=Array.isArray(t)?[]:{};s.add(t);for(const i in t){const a=y(t[i],e,r,s);n[i]=a}return s.delete(t),t.__proto__&&(n.__proto__=t.__proto__),n}throw new Error(`Can't recurse into non-iterable type: ${t}`)}return r.set(t,n.value),n.value}function g(t,e=v){return x(t,e)}function x(t,e,r=new Set){const s=t[0];if(r.has(s))throw new Error("Circular references are not supported.");const n=e(t);if(n.recurse&&null!==n.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(n.recurse){if(C(s)){const n=Array.isArray(s)?[]:{};r.add(s);for(const i in s){const s=x(t.map((t=>t[i])),e,r);n[i]=s}return r.delete(s),n}throw new Error(`Can't recurse into non-iterable type: ${s}`)}return n.value}function v(t){return null===t?null:C(t[0])?{value:null,recurse:!0}:{value:t,recurse:!1}}async function b(t,e){const r=new Map;y(t,e,r);for(const t of Array.from(r.keys())){const e=r.get(t);if(s.util.isPromise(e)){const s=await e;r.set(t,s)}}return y(t,e,r)}function C(t){let e=!1;if(s.env().get("IS_BROWSER"))e=t instanceof TextDecoder;else{const{StringDecoder:r}=require("string_decoder");e=t instanceof r}return null!=t&&!ArrayBuffer.isView(t)&&(Array.isArray(t)||"object"==typeof t&&!(t instanceof s.Tensor)&&!(t instanceof Promise)&&!e)}function z(t){return y(t,E)}function E(t){return t instanceof s.Tensor?{value:t.clone(),recurse:!1}:C(t)?{value:null,recurse:!0}:{value:t,recurse:!1}}class S{constructor(t){if(this.capacity=t,this.begin=0,this.end=0,null==t)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(t<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(t),this.doubledCapacity=2*t}wrap(t){for(;t<0;)t+=this.doubledCapacity;return t%this.doubledCapacity}get(t){if(t<0)throw new RangeError("Can't get item at a negative index.");return this.data[t%this.capacity]}set(t,e){if(t<0)throw new RangeError("Can't set item at a negative index.");this.data[t%this.capacity]=e}length(){let t=this.end-this.begin;return t<0&&(t=this.doubledCapacity+t),t}isFull(){return this.length()===this.capacity}isEmpty(){return 0===this.length()}push(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,t),this.end=this.wrap(this.end+1)}pushAll(t){for(const e of t)this.push(e)}pop(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);const t=this.get(this.end);return this.set(this.end,void 0),t}unshift(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,t)}shift(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");const t=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),t}shuffleExcise(t){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");const e=this.wrap(this.begin+t),r=this.get(e);return this.set(e,this.pop()),r}}class R extends S{constructor(){super(R.INITIAL_CAPACITY)}isFull(){return!1}push(t){super.isFull()&&this.expand(),super.push(t)}unshift(t){super.isFull()&&this.expand(),super.unshift(t)}expand(){const t=2*this.capacity,e=new Array(t),r=this.length();for(let t=0;t<r;t++)e[t]=this.get(this.wrap(this.begin+t));this.data=e,this.capacity=t,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=r}}function A(t){return new F(t)}function T(t){return new N(t)}R.INITIAL_CAPACITY=32;class k{async toArray(){const t=[];let e=await this.next();for(;!e.done;)t.push(e.value),e=await this.next();return t}async toArrayForTest(){const t=this.prefetch(100),e=[];let r=await t.next();for(;!r.done;)e.push(r.value),r=await t.next();return e}async resolveFully(){let t=await this.next();for(;!t.done;)t=await this.next()}async resolveWhile(t){let e=await this.next(),r=t(e.value);for(;!e.done&&r;)e=await this.next(),r=t(e.value)}handleErrors(t){return new B(this,t)}filter(t){return new j(this,t)}map(t){return new M(this,t)}mapAsync(t){return new $(this,t)}serialMapAsync(t){return new $(this,t).serial()}flatmap(t){return new L(this,t)}async forEachAsync(t){return this.map(t).resolveFully()}async serialForEach(t){return this.serialMapAsync(t).resolveWhile((t=>!0===t))}rowMajorBatch(t,e=!0){return new _(this,t,e)}columnMajorBatch(t,e=!0,r=v){return this.rowMajorBatch(t,e).map((t=>g(t,r)))}concatenate(t,e){return new q(A([this,t]),e)}take(t){return t<0||null==t?this:new O(this,t)}skip(t){return t<0||null==t?this:new I(this,t)}prefetch(t){return new W(this,t)}shuffle(t,e){return new V(this,t,e)}serial(){return new D(this)}}class F extends k{constructor(t){super(),this.items=t,this.trav=0}summary(){return`Array of ${this.items.length} items`}async next(){if(this.trav>=this.items.length)return{value:null,done:!0};const t=this.items[this.trav];return this.trav++,{value:z(t),done:!1}}}class N extends k{constructor(t){super(),this.nextFn=t}summary(){return"Function call"}async next(){try{return this.nextFn()}catch(t){throw t.message=`Error thrown while iterating through a dataset: ${t.message}`,t}}}class D extends k{constructor(t){super(),this.upstream=t,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Serial`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){return this.upstream.next()}}class I extends k{constructor(t,e){super(),this.upstream=t,this.maxCount=e,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Skip`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;this.count++<this.maxCount;){const t=await this.upstream.next();if(t.done)return t;s.dispose(t.value)}return this.upstream.next()}}class O extends k{constructor(t,e){super(),this.upstream=t,this.maxCount=e,this.count=0}summary(){return`${this.upstream.summary()} -> Take`}async next(){return this.count++>=this.maxCount?{value:null,done:!0}:this.upstream.next()}}class _ extends k{constructor(t,e,r=!0){super(),this.upstream=t,this.batchSize=e,this.enableSmallLastBatch=r,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> RowMajorBatch`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){const t=[];for(;t.length<this.batchSize;){const e=await this.upstream.next();if(e.done)return this.enableSmallLastBatch&&t.length>0?{value:t,done:!1}:{value:null,done:!0};t.push(e.value)}return{value:t,done:!1}}}class j extends k{constructor(t,e){super(),this.upstream=t,this.predicate=e,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Filter`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;;){const t=await this.upstream.next();if(t.done||this.predicate(t.value))return t;s.dispose(t.value)}}}class M extends k{constructor(t,e){super(),this.upstream=t,this.transform=e}summary(){return`${this.upstream.summary()} -> Map`}async next(){const t=await this.upstream.next();if(t.done)return{value:null,done:!0};const e=s.tensor_util.getTensorsInContainer(t.value),r=this.transform(t.value),n=s.tensor_util.getTensorsInContainer(r);for(const t of e)s.tensor_util.isTensorInList(t,n)||t.dispose();return{value:r,done:!1}}}class B extends k{constructor(t,e){super(),this.upstream=t,this.handler=e,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> handleErrors`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;;)try{return await this.upstream.next()}catch(t){if(!this.handler(t))return{value:null,done:!0}}}}class $ extends k{constructor(t,e){super(),this.upstream=t,this.transform=e}summary(){return`${this.upstream.summary()} -> AsyncMap`}async next(){const t=await this.upstream.next();if(t.done)return{value:null,done:!0};const e=s.tensor_util.getTensorsInContainer(t.value),r=await this.transform(t.value),n=s.tensor_util.getTensorsInContainer(r);for(const t of e)s.tensor_util.isTensorInList(t,n)||t.dispose();return{value:r,done:!1}}}class P extends k{constructor(){super(),this.outputQueue=new R,this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;0===this.outputQueue.length();)if(!await this.pump())return{value:null,done:!0};return{value:this.outputQueue.shift(),done:!1}}}class L extends P{constructor(t,e){super(),this.upstream=t,this.transform=e}summary(){return`${this.upstream.summary()} -> Flatmap`}async pump(){const t=await this.upstream.next();if(t.done)return!1;const e=s.tensor_util.getTensorsInContainer(t.value),r=this.transform(t.value),n=s.tensor_util.getTensorsInContainer(r);this.outputQueue.pushAll(r);for(const t of e)s.tensor_util.isTensorInList(t,n)||t.dispose();return!0}}class q extends k{constructor(t,e){super(),this.baseErrorHandler=e,this.lastRead=null,this.iterator=null,this.moreIterators=t}summary(){return"TODO: fill in upstream of chained summaries -> Chained"}async next(){return this.lastRead=this.readFromChain(this.lastRead),this.lastRead}async readFromChain(t){if(await t,null==this.iterator){const t=await this.moreIterators.next();if(t.done)return{value:null,done:!0};this.iterator=t.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler))}const e=await this.iterator.next();return e.done?(this.iterator=null,this.readFromChain(t)):e}}!function(t){t[t.FAIL=0]="FAIL",t[t.SHORTEST=1]="SHORTEST",t[t.LONGEST=2]="LONGEST"}(p||(p={}));class H extends k{constructor(t,e=p.FAIL){super(),this.iterators=t,this.mismatchMode=e,this.count=0,this.currentPromise=null}summary(){return"{TODO: fill in upstream of zip summaries} -> Zip"}async nextState(t){await t;let e=0,r=0;const s=await b(this.iterators,(function(t){if(t instanceof k){return{value:t.next().then((t=>(e++,t.done&&r++,t.value))),recurse:!1}}return{value:null,recurse:!0}}));if(e===r)return{value:null,done:!0};if(r>0)switch(this.mismatchMode){case p.FAIL:throw new Error(`Zipped streams should have the same length. Mismatched at element ${this.count}.`);case p.SHORTEST:return{value:null,done:!0};case p.LONGEST:}return this.count++,{value:s,done:!1}}async next(){return this.currentPromise=this.nextState(this.currentPromise),this.currentPromise}}class W extends k{constructor(t,e){super(),this.upstream=t,this.bufferSize=e,this.buffer=new S(e)}summary(){return`${this.upstream.summary()} -> Prefetch`}refill(){for(;!this.buffer.isFull();){const t=this.upstream.next();this.buffer.push(t)}}next(){return this.refill(),this.buffer.shift()}}class V extends W{constructor(t,e,r){super(t,e),this.upstream=t,this.windowSize=e,this.upstreamExhausted=!1,this.random=w.alea(r||s.util.now().toString()),this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}randomInt(t){return Math.floor(this.random()*t)}chooseIndex(){return this.randomInt(this.buffer.length())}async serialNext(){for(this.upstreamExhausted||this.refill();!this.buffer.isEmpty();){const t=this.chooseIndex(),e=await this.buffer.shuffleExcise(t);if(!e.done)return this.refill(),e;this.upstreamExhausted=!0}return{value:null,done:!0}}}class U{constructor(){this.size=null}batch(t,e=!0){const r=this;let n;return s.util.assert(t>0,(()=>`batchSize needs to be positive, but it is\n ${t}`)),n=this.size===1/0||null==this.size?this.size:e?Math.ceil(this.size/t):Math.floor(this.size/t),Q((async()=>(await r.iterator()).columnMajorBatch(t,e,X)),n)}concatenate(t){const e=this;let r;return r=this.size===1/0||t.size===1/0?1/0:null!=this.size&&null!=t.size?this.size+t.size:null,Q((async()=>(await e.iterator()).concatenate(await t.iterator())),r)}filter(t){const e=this;let r;return r=this.size===1/0?1/0:null,Q((async()=>(await e.iterator()).filter((e=>s.tidy((()=>t(e)))))),r)}async forEachAsync(t){return(await this.iterator()).forEachAsync(t)}map(t){const e=this;return Q((async()=>(await e.iterator()).map((e=>s.tidy((()=>t(e)))))),this.size)}mapAsync(t){const e=this;return Q((async()=>(await e.iterator()).mapAsync(t)),this.size)}prefetch(t){if(null==t)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");const e=this;return Q((async()=>(await e.iterator()).prefetch(t)),this.size)}repeat(t){const e=this;let r;return r=null!=this.size&&t>0?this.size*t:0===t?0:null!=this.size&&(void 0===t||t<0)?1/0:null,Q((async()=>{const r=T((async()=>({value:await e.iterator(),done:!1})));return s=r.take(t),new q(s,n);var s,n}),r)}skip(t){const e=this;let r;return r=null!=this.size&&t>=0&&this.size>=t?this.size-t:null!=this.size&&(this.size<t||void 0===t||t<0)?0:null,Q((async()=>(await e.iterator()).skip(t)),r)}shuffle(t,e,r=!0){if(null==t||t<0)throw null==this.size?new RangeError("`Dataset.shuffle()` requires bufferSize to be specified."):new RangeError(`\`Dataset.shuffle()\` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for \`tf.Tensor\`s), consider setting bufferSize to the dataset size (${this.size} elements)`);const n=this,i=w.alea(e||s.util.now().toString());return Q((async()=>{let e=i.int32();return r&&(e+=i.int32()),(await n.iterator()).shuffle(t,e.toString())}),this.size)}take(t){const e=this;let r;return r=null!=this.size&&this.size>t?t:null!=this.size&&this.size<=t?this.size:null,Q((async()=>(await e.iterator()).take(t)),r)}async toArray(){if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArray()}async toArrayForTest(){if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArrayForTest()}}function Q(t,e=null){return new class extends U{constructor(){super(...arguments),this.size=e}async iterator(){return t()}}}function X(t){if(null===t)return null;const e=t[0];if(null==(r=e)||null===(n=r)||"object"!=typeof n&&"function"!=typeof n||Array.isArray(r)||"object"==typeof r&&r instanceof s.Tensor||s.util.isTypedArray(r)){return{value:function(t){if(0===t.length)throw new Error("Can't make a batch of zero elements.");return t[0]instanceof s.Tensor?s.stack(t):s.tensor(t)}(t),recurse:!1}}var r,n;return{value:null,recurse:!0}}U.MAX_BUFFER_SIZE=1e4;class G extends U{constructor(t){super(),this.input=t}async iterator(){return(await this.input.iterator()).decodeUTF8().split("\n").map((t=>(t.endsWith("\r")&&(t=t.slice(0,-1)),t)))}}const Z='"',J=Symbol("out"),Y=Symbol("field"),K=Symbol("quote"),tt=Symbol("quoteafterquote"),et=Symbol("quoteinquote");class rt extends U{constructor(t,r){super(),this.input=t,this.hasHeader=!0,this.fullColumnNames=null,this.columnNamesValidated=!1,this.columnConfigs=null,this.configuredColumnsOnly=!1,this.delimiter=",",this.delimWhitespace=!1,this.base=new G(t),r||(r={}),this.hasHeader=!1!==r.hasHeader,this.fullColumnNames=r.columnNames,this.columnConfigs=r.columnConfigs,this.configuredColumnsOnly=r.configuredColumnsOnly,r.delimWhitespace?(e.util.assert(null==r.delimiter,(()=>"Delimiter should not be provided when delimWhitespace is true.")),this.delimWhitespace=!0,this.delimiter=" "):this.delimiter=r.delimiter?r.delimiter:","}async columnNames(){return this.columnNamesValidated||await this.setColumnNames(),this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames}async setColumnNames(){const t=await this.maybeReadHeaderLine();if(!this.fullColumnNames&&!t)throw new Error("Column names must be provided if there is no header line.");this.fullColumnNames&&t&&e.util.assert(t.length===this.fullColumnNames.length,(()=>"The length of provided columnNames ("+this.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+t.length.toString()+").")),this.fullColumnNames||(this.fullColumnNames=t);const r=this.fullColumnNames.reduce(((t,e)=>(t[e]=t[e]+1||1,t)),{}),s=Object.keys(r).filter((t=>r[t]>1));if(e.util.assert(0===s.length,(()=>"Duplicate column names found: "+s.toString())),this.columnConfigs)for(const t of Object.keys(this.columnConfigs)){if(-1===this.fullColumnNames.indexOf(t))throw new Error('The key "'+t+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").")}this.columnNamesValidated=!0}async maybeReadHeaderLine(){if(this.hasHeader){const t=await this.base.iterator(),e=await t.next();if(e.done)throw new Error("No data was found for CSV parsing.");const r=e.value;return this.parseRow(r,!1)}return null}async iterator(){this.columnNamesValidated||await this.setColumnNames();let t=await this.base.iterator();return this.hasHeader&&(t=t.skip(1)),t.map((t=>this.makeDataElement(t)))}makeDataElement(t){const e=this.parseRow(t),r={},s={};for(let n=0;n<this.fullColumnNames.length;n++){const i=this.fullColumnNames[n],a=this.columnConfigs?this.columnConfigs[i]:null;if(!this.configuredColumnsOnly||a){const o=e[n];let u=null;if(""===o)if(a&&void 0!==a.default)u=a.default;else{if(a&&(a.required||a.isLabel))throw new Error(`Required column ${i} is empty in this line: ${t}`);u=void 0}else{const t=Number(o);if(isNaN(t))u=a&&"bool"===a.dtype?this.getBoolean(o):o;else if(a&&a.dtype)switch(a.dtype){case"float32":default:u=t;break;case"int32":u=Math.floor(t);break;case"bool":u=this.getBoolean(o)}else u=t}a&&a.isLabel?s[i]=u:r[i]=u}}return 0===Object.keys(s).length?r:{xs:r,ys:s}}getBoolean(t){return"1"===t||"true"===t.toLowerCase()?1:0}parseRow(t,e=!0){const r=[];let s=0;const n=t.length;let i=J;for(let e=0;e<n;e++)switch(i){case J:switch(t.charAt(e)){case Z:s=e+1,i=K;break;case this.delimiter:if(s=e+1," "===this.delimiter&&this.delimWhitespace)break;r.push(""),i=J;break;default:i=Y,s=e}break;case Y:if(t.charAt(e)===this.delimiter)r.push(t.substring(s,e)),i=J,s=e+1;break;case K:if(t.charAt(e)===Z)i=tt;break;case tt:switch(t.charAt(e)){case this.delimiter:r.push(t.substring(s,e-1)),i=J,s=e+1;break;case Z:i=K;break;default:i=et}break;case et:if(t.charAt(e)===Z)i=K}if(i===tt?r.push(t.substring(s,n-1)):r.push(t.substring(s)),e&&r.length!==this.fullColumnNames.length)throw new Error(`Invalid row in csv file. Should have ${this.fullColumnNames.length} elements in a row, but got ${r}`);return r}}class st extends k{constructor(t){super(),this.microphoneConfig=t,this.isClosed=!1,this.fftSize=t.fftSize||1024;const e=Math.log2(this.fftSize);if(this.fftSize<0||e<4||e>14||!Number.isInteger(e))throw new Error(`Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got ${this.fftSize}`);if(this.numFrames=t.numFramesPerSpectrogram||43,this.sampleRateHz=t.sampleRateHz,this.columnTruncateLength=t.columnTruncateLength||this.fftSize,this.audioTrackConstraints=t.audioTrackConstraints,this.smoothingTimeConstant=t.smoothingTimeConstant||0,this.includeSpectrogram=!1!==t.includeSpectrogram,this.includeWaveform=!0===t.includeWaveform,!this.includeSpectrogram&&!this.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.")}summary(){return"microphone"}static async create(t={}){if(!e.env().get("IS_BROWSER"))throw new Error("microphone API is only supported in browser environment.");const r=new st(t);return await r.start(),r}async start(){try{this.stream=await navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1})}catch(t){throw new Error(`Error thrown while initializing video stream: ${t.message}`)}if(!this.stream)throw new Error("Could not obtain audio from microphone.");const t=window.AudioContext||window.webkitAudioContext;if(this.audioContext=new t,this.sampleRateHz){if(this.audioContext.sampleRate!==this.sampleRateHz)throw new Error(`Mismatch in sampling rate: Expected: ${this.sampleRateHz}; Actual: ${this.audioContext.sampleRate}`)}else this.sampleRateHz=this.audioContext.sampleRate;const e=this.audioContext.createMediaStreamSource(this.stream);this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,e.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize)}async next(){if(this.isClosed)return{value:null,done:!0};let t,e;const r=await this.getAudioData();if(this.includeSpectrogram){const e=this.flattenQueue(r.freqDataQueue);t=this.getTensorFromAudioDataArray(e,[this.numFrames,this.columnTruncateLength,1])}if(this.includeWaveform){const t=this.flattenQueue(r.timeDataQueue);e=this.getTensorFromAudioDataArray(t,[this.numFrames*this.fftSize,1])}return{value:{spectrogram:t,waveform:e},done:!1}}async capture(){return(await this.next()).value}async getAudioData(){const t=[],e=[];let r=0;return new Promise((s=>{const n=setInterval((()=>{this.includeSpectrogram&&(this.analyser.getFloatFrequencyData(this.freqData),this.freqData[0]===-1/0&&s({freqDataQueue:t,timeDataQueue:e}),t.push(this.freqData.slice(0,this.columnTruncateLength))),this.includeWaveform&&(this.analyser.getFloatTimeDomainData(this.timeData),e.push(this.timeData.slice())),++r===this.numFrames&&(clearInterval(n),s({freqDataQueue:t,timeDataQueue:e}))}),this.fftSize/this.sampleRateHz*1e3)}))}stop(){this.isClosed||(this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop())}toArray(){throw new Error("Can not convert infinite audio stream to array.")}getSampleRate(){return this.sampleRateHz}flattenQueue(t){const e=t[0].length,r=new Float32Array(t.length*e);return t.forEach(((t,s)=>r.set(t,s*e))),r}getTensorFromAudioDataArray(t,r){const s=new Float32Array(e.util.sizeFromShape(r));return s.set(t,s.length-t.length),e.tensor(s,r)}}class nt extends k{constructor(t,r){if(super(),this.webcamVideoElement=t,this.webcamConfig=r,this.isClosed=!0,this.resize=!1,this.needToResize())if(this.resize=!0,this.cropSize=[this.webcamConfig.resizeHeight,this.webcamConfig.resizeWidth],this.cropBoxInd=e.tensor1d([0],"int32"),this.webcamConfig.centerCrop){const t=1*this.webcamConfig.resizeWidth/this.webcamVideoElement.width,r=1*this.webcamConfig.resizeHeight/this.webcamVideoElement.height,s=(1-t)/2,n=(1-r)/2,i=s+t,a=r+n;this.cropBox=e.tensor2d([n,s,a,i],[1,4])}else this.cropBox=e.tensor2d([0,0,1,1],[1,4])}summary(){return"webcam"}static async create(t,r={}){if(!e.env().get("IS_BROWSER"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!t){if(t=document.createElement("video"),!r.resizeWidth||!r.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");t.width=r.resizeWidth,t.height=r.resizeHeight}const s=new nt(t,r);return await s.start(),s}async start(){this.webcamConfig.facingMode&&e.util.assert("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,(()=>`Invalid webcam facing mode: ${this.webcamConfig.facingMode}. Please provide 'user' or 'environment'`));try{this.stream=await navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})}catch(t){throw t.message=`Error thrown while initializing video stream: ${t.message}`,t}if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(t){console.log(t),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,new Promise((t=>{this.webcamVideoElement.onloadedmetadata=()=>{t()}}))}async next(){if(this.isClosed)return{value:null,done:!0};let t;try{t=e.browser.fromPixels(this.webcamVideoElement)}catch(t){throw new Error(`Error thrown converting video to pixels: ${JSON.stringify(t)}`)}if(!this.resize)return{value:t,done:!1};try{return{value:this.cropAndResizeFrame(t),done:!1}}catch(t){throw new Error(`Error thrown cropping the video: ${t.message}`)}finally{t.dispose()}}needToResize(){return!(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight)}cropAndResizeFrame(t){return e.tidy((()=>{const r=e.expandDims(e.cast(t,"float32"),0);let s;s=e.image.cropAndResize(r,this.cropBox,this.cropBoxInd,this.cropSize,"bilinear");const n=s.shape;return e.reshape(s,n.slice(1))}))}async capture(){return(await this.next()).value}stop(){this.stream.getTracks().forEach((t=>t.stop()));try{this.webcamVideoElement.srcObject=null}catch(t){console.log(t),this.webcamVideoElement.src=null}this.isClosed=!0}toArray(){throw new Error("Can not convert infinite video stream to array.")}}class it{}class at extends k{split(t){return new ot(this,t)}}class ot extends at{constructor(t,e){super(),this.upstream=t,this.impl=new ut(t,e)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class ut extends P{constructor(t,e){super(),this.upstream=t,this.separator=e,this.carryover=""}summary(){return`${this.upstream.summary()} -> Split('${this.separator}')`}async pump(){const t=await this.upstream.next();if(t.done)return""!==this.carryover&&(this.outputQueue.push(this.carryover),this.carryover="",!0);const e=t.value.split(this.separator);e[0]=this.carryover+e[0];for(const t of e.slice(0,-1))this.outputQueue.push(t);return this.carryover=e[e.length-1],!0}}class ht extends k{decodeUTF8(){return new lt(this)}}class lt extends at{constructor(t){super(),this.upstream=t,this.impl=new ct(t)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class ct extends P{constructor(t){if(super(),this.upstream=t,e.env().get("IS_BROWSER"))this.decoder=new TextDecoder("utf-8");else{const{StringDecoder:t}=require("string_decoder");this.decoder=new t("utf8")}}summary(){return`${this.upstream.summary()} -> Utf8`}async pump(){const t=await this.upstream.next();let r,s;return!t.done&&(r=t.value,s=e.env().get("IS_BROWSER")?this.decoder.decode(r,{stream:!0}):this.decoder.write(Buffer.from(r.buffer)),this.outputQueue.push(s),!0)}}class ft extends ht{constructor(t,r={}){super(),this.file=t,this.options=r,e.util.assert(t instanceof Uint8Array||!!e.env().get("IS_BROWSER")&&(t instanceof File||t instanceof Blob),(()=>"FileChunkIterator only supports File, Blob and Uint8Array right now.")),this.offset=r.offset||0,this.chunkSize=r.chunkSize||1048576}summary(){return`FileChunks ${this.file}`}async next(){if(this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size))return{value:null,done:!0};const t=new Promise(((t,e)=>{const r=this.offset+this.chunkSize;if(this.file instanceof Uint8Array)t(new Uint8Array(this.file.slice(this.offset,r)));else{const s=new FileReader;s.onload=r=>{let n=s.result;if(n instanceof ArrayBuffer&&(n=new Uint8Array(n)),!(n instanceof Uint8Array))return e(new TypeError("FileReader returned unknown type."));t(n)},s.onabort=t=>e(new Error("Aborted")),s.onerror=t=>e(new Error(t.type));const n=this.file.slice(this.offset,r);s.readAsArrayBuffer(n)}this.offset=r}));return{value:await t,done:!1}}}const dt=t=>({method:t.method,headers:t.headers,body:t.body,mode:t.mode,credentials:t.credentials,cache:t.cache,redirect:t.redirect,referrer:t.referrer,integrity:t.integrity});function mt(t){return"string"==typeof t&&"file://"===t.slice(0,7)}class pt extends it{constructor(t,e={}){super(),this.input=t,this.options=e}async iterator(){if(mt(this.input)&&e.env().get("IS_NODE")){const t=require("fs");this.input=t.readFileSync(this.input.slice(7))}return new ft(this.input,this.options)}}class wt extends it{constructor(t,e={}){super(),this.url=t,this.fileOptions=e}async iterator(){return mt(this.url)?new pt(this.url,this.fileOptions).iterator():async function(t,r={},s){let n,i;"string"==typeof t?n=t:(n=t.url,i=dt(t));const a=await(s||e.util.fetch)(n,i);if(a.ok){const t=new Uint8Array(await a.arrayBuffer());return new ft(t,r)}throw new Error(a.statusText)}(this.url,this.fileOptions)}}t.CSVDataset=rt,t.Dataset=U,t.FileDataSource=pt,t.TextLineDataset=G,t.URLDataSource=wt,t.array=function(t){return Q((async()=>A(t)),t.length)},t.csv=function(t,e={}){return new rt(new wt(t),e)},t.func=function(t){const e=T(t);return Q((async()=>e))},t.generator=function(t){return Q((async()=>{const e=await t();return T((()=>e.next()))}))},t.microphone=async function(t){return st.create(t)},t.version_data="4.2.0",t.webcam=async function(t,e){return nt.create(t,e)},t.zip=function(t){if(!C(t))throw new Error("The argument to zip() must be an object or array.");let e;if(Array.isArray(t))for(let r=0;r<t.length;r++)e=null==e?t[r].size:Math.min(e,t[r].size);else if(t instanceof Object)for(const r in t)e=null==e?t[r].size:Math.min(e,t[r].size);return Q((async()=>function(t,e=p.FAIL){return new H(t,e)}(await b(t,(t=>{if(t instanceof U)return{value:t.iterator(),recurse:!1};if(C(t))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")})),p.SHORTEST)),e)},Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@tensorflow/tfjs-core")):"function"==typeof define&&define.amd?define(["exports","@tensorflow/tfjs-core"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).tf=t.tf||{},t.tf)}(this,(function(t,e){"use strict";function r(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(r){if("default"!==r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})}})),e.default=t,e}var s=r(e),n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(t){if(t.__esModule)return t;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach((function(r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})})),e}function a(t){var e={exports:{}};return t(e,e.exports),e.exports}var o=a((function(t){!function(t,e,r){function s(t){var e,r=this,s=(e=4022871197,function(t){t=String(t);for(var r=0;r<t.length;r++){var s=.02519603282416938*(e+=t.charCodeAt(r));s-=e=s>>>0,e=(s*=e)>>>0,e+=4294967296*(s-=e)}return 2.3283064365386963e-10*(e>>>0)});r.next=function(){var t=2091639*r.s0+2.3283064365386963e-10*r.c;return r.s0=r.s1,r.s1=r.s2,r.s2=t-(r.c=0|t)},r.c=1,r.s0=s(" "),r.s1=s(" "),r.s2=s(" "),r.s0-=s(t),r.s0<0&&(r.s0+=1),r.s1-=s(t),r.s1<0&&(r.s1+=1),r.s2-=s(t),r.s2<0&&(r.s2+=1),s=null}function n(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e}function i(t,e){var r=new s(t),i=e&&e.state,a=r.next;return a.int32=function(){return 4294967296*r.next()|0},a.double=function(){return a()+11102230246251565e-32*(2097152*a()|0)},a.quick=a,i&&("object"==typeof i&&n(i,r),a.state=function(){return n(r,{})}),a}e&&e.exports?e.exports=i:r&&r.amd?r((function(){return i})):this.alea=i}(0,t,!1)})),u=a((function(t){!function(t,e,r){function s(t){var e=this,r="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8},t===(0|t)?e.x=t:r+=t;for(var s=0;s<r.length+64;s++)e.x^=0|r.charCodeAt(s),e.next()}function n(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e}function i(t,e){var r=new s(t),i=e&&e.state,a=function(){return(r.next()>>>0)/4294967296};return a.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},a.int32=r.next,a.quick=a,i&&("object"==typeof i&&n(i,r),a.state=function(){return n(r,{})}),a}e&&e.exports?e.exports=i:r&&r.amd?r((function(){return i})):this.xor128=i}(0,t,!1)})),h=a((function(t){!function(t,e,r){function s(t){var e=this,r="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:r+=t;for(var s=0;s<r.length+64;s++)e.x^=0|r.charCodeAt(s),s==r.length&&(e.d=e.x<<10^e.x>>>4),e.next()}function n(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e}function i(t,e){var r=new s(t),i=e&&e.state,a=function(){return(r.next()>>>0)/4294967296};return a.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},a.int32=r.next,a.quick=a,i&&("object"==typeof i&&n(i,r),a.state=function(){return n(r,{})}),a}e&&e.exports?e.exports=i:r&&r.amd?r((function(){return i})):this.xorwow=i}(0,t,!1)})),l=a((function(t){!function(t,e,r){function s(t){var e=this;e.next=function(){var t,r,s=e.x,n=e.i;return t=s[n],r=(t^=t>>>7)^t<<24,r^=(t=s[n+1&7])^t>>>10,r^=(t=s[n+3&7])^t>>>3,r^=(t=s[n+4&7])^t<<7,t=s[n+7&7],r^=(t^=t<<13)^t<<9,s[n]=r,e.i=n+1&7,r},function(t,e){var r,s=[];if(e===(0|e))s[0]=e;else for(e=""+e,r=0;r<e.length;++r)s[7&r]=s[7&r]<<15^e.charCodeAt(r)+s[r+1&7]<<13;for(;s.length<8;)s.push(0);for(r=0;r<8&&0===s[r];++r);for(8==r&&(s[7]=-1),t.x=s,t.i=0,r=256;r>0;--r)t.next()}(e,t)}function n(t,e){return e.x=t.x.slice(),e.i=t.i,e}function i(t,e){null==t&&(t=+new Date);var r=new s(t),i=e&&e.state,a=function(){return(r.next()>>>0)/4294967296};return a.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},a.int32=r.next,a.quick=a,i&&(i.x&&n(i,r),a.state=function(){return n(r,{})}),a}e&&e.exports?e.exports=i:r&&r.amd?r((function(){return i})):this.xorshift7=i}(0,t,!1)})),c=a((function(t){!function(t,e,r){function s(t){var e=this;e.next=function(){var t,r,s=e.w,n=e.X,i=e.i;return e.w=s=s+1640531527|0,r=n[i+34&127],t=n[i=i+1&127],r^=r<<13,t^=t<<17,r^=r>>>15,t^=t>>>12,r=n[i]=r^t,e.i=i,r+(s^s>>>16)|0},function(t,e){var r,s,n,i,a,o=[],u=128;for(e===(0|e)?(s=e,e=null):(e+="\0",s=0,u=Math.max(u,e.length)),n=0,i=-32;i<u;++i)e&&(s^=e.charCodeAt((i+32)%e.length)),0===i&&(a=s),s^=s<<10,s^=s>>>15,s^=s<<4,s^=s>>>13,i>=0&&(a=a+1640531527|0,n=0==(r=o[127&i]^=s+a)?n+1:0);for(n>=128&&(o[127&(e&&e.length||0)]=-1),n=127,i=512;i>0;--i)s=o[n+34&127],r=o[n=n+1&127],s^=s<<13,r^=r<<17,s^=s>>>15,r^=r>>>12,o[n]=s^r;t.w=a,t.X=o,t.i=n}(e,t)}function n(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e}function i(t,e){null==t&&(t=+new Date);var r=new s(t),i=e&&e.state,a=function(){return(r.next()>>>0)/4294967296};return a.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},a.int32=r.next,a.quick=a,i&&(i.X&&n(i,r),a.state=function(){return n(r,{})}),a}e&&e.exports?e.exports=i:r&&r.amd?r((function(){return i})):this.xor4096=i}(0,t,!1)})),f=a((function(t){!function(t,e,r){function s(t){var e=this,r="";e.next=function(){var t=e.b,r=e.c,s=e.d,n=e.a;return t=t<<25^t>>>7^r,r=r-s|0,s=s<<24^s>>>8^n,n=n-t|0,e.b=t=t<<20^t>>>12^r,e.c=r=r-s|0,e.d=s<<16^r>>>16^n,e.a=n-t|0},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):r+=t;for(var s=0;s<r.length+20;s++)e.b^=0|r.charCodeAt(s),e.next()}function n(t,e){return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e}function i(t,e){var r=new s(t),i=e&&e.state,a=function(){return(r.next()>>>0)/4294967296};return a.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},a.int32=r.next,a.quick=a,i&&("object"==typeof i&&n(i,r),a.state=function(){return n(r,{})}),a}e&&e.exports?e.exports=i:r&&r.amd?r((function(){return i})):this.tychei=i}(0,t,!1)})),d=i({__proto__:null,default:{}}),m=a((function(t){!function(e,r,s){var n,i=256,a=s.pow(i,6),o=s.pow(2,52),u=2*o,h=255;function l(t,h,l){var d=[],y=p(m((h=1==h?{entropy:!0}:h||{}).entropy?[t,w(r)]:null==t?function(){try{var t;return n&&(t=n.randomBytes)?t=t(i):(t=new Uint8Array(i),(e.crypto||e.msCrypto).getRandomValues(t)),w(t)}catch(t){var s=e.navigator,a=s&&s.plugins;return[+new Date,e,a,e.screen,w(r)]}}():t,3),d),g=new c(d),x=function(){for(var t=g.g(6),e=a,r=0;t<o;)t=(t+r)*i,e*=i,r=g.g(1);for(;t>=u;)t/=2,e/=2,r>>>=1;return(t+r)/e};return x.int32=function(){return 0|g.g(4)},x.quick=function(){return g.g(4)/4294967296},x.double=x,p(w(g.S),r),(h.pass||l||function(t,e,r,n){return n&&(n.S&&f(n,g),t.state=function(){return f(g,{})}),r?(s.random=t,e):t})(x,y,"global"in h?h.global:this==s,h.state)}function c(t){var e,r=t.length,s=this,n=0,a=s.i=s.j=0,o=s.S=[];for(r||(t=[r++]);n<i;)o[n]=n++;for(n=0;n<i;n++)o[n]=o[a=h&a+t[n%r]+(e=o[n])],o[a]=e;(s.g=function(t){for(var e,r=0,n=s.i,a=s.j,o=s.S;t--;)e=o[n=h&n+1],r=r*i+o[h&(o[n]=o[a=h&a+e])+(o[a]=e)];return s.i=n,s.j=a,r})(i)}function f(t,e){return e.i=t.i,e.j=t.j,e.S=t.S.slice(),e}function m(t,e){var r,s=[],n=typeof t;if(e&&"object"==n)for(r in t)try{s.push(m(t[r],e-1))}catch(t){}return s.length?s:"string"==n?t:t+"\0"}function p(t,e){for(var r,s=t+"",n=0;n<s.length;)e[h&n]=h&(r^=19*e[h&n])+s.charCodeAt(n++);return w(e)}function w(t){return String.fromCharCode.apply(0,t)}if(p(s.random(),r),t.exports){t.exports=l;try{n=d}catch(t){}}else s.seedrandom=l}("undefined"!=typeof self?self:n,[],Math)}));m.alea=o,m.xor128=u,m.xorwow=h,m.xorshift7=l,m.xor4096=c,m.tychei=f;var p,w=m;function y(t,e,r=new Map,s=new Set){if(null==t)return null;if("function"==typeof Blob&&t instanceof Blob)return t.slice();if(s.has(t))throw new Error("Circular references are not supported.");if(r.has(t))return r.get(t);const n=e(t);if(n.recurse&&null!==n.value)throw new Error("A deep map function may not return both a value and recurse=true.");if(n.recurse){if(C(t)){const n=Array.isArray(t)?[]:{};s.add(t);for(const i in t){const a=y(t[i],e,r,s);n[i]=a}return s.delete(t),t.__proto__&&(n.__proto__=t.__proto__),n}throw new Error(`Can't recurse into non-iterable type: ${t}`)}return r.set(t,n.value),n.value}function g(t,e=v){return x(t,e)}function x(t,e,r=new Set){const s=t[0];if(r.has(s))throw new Error("Circular references are not supported.");const n=e(t);if(n.recurse&&null!==n.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(n.recurse){if(C(s)){const n=Array.isArray(s)?[]:{};r.add(s);for(const i in s){const s=x(t.map((t=>t[i])),e,r);n[i]=s}return r.delete(s),n}throw new Error(`Can't recurse into non-iterable type: ${s}`)}return n.value}function v(t){return null===t?null:C(t[0])?{value:null,recurse:!0}:{value:t,recurse:!1}}async function b(t,e){const r=new Map;y(t,e,r);for(const t of Array.from(r.keys())){const e=r.get(t);if(s.util.isPromise(e)){const s=await e;r.set(t,s)}}return y(t,e,r)}function C(t){let e=!1;if(s.env().get("IS_BROWSER"))e=t instanceof TextDecoder;else{const{StringDecoder:r}=require("string_decoder");e=t instanceof r}return null!=t&&!ArrayBuffer.isView(t)&&(Array.isArray(t)||"object"==typeof t&&!(t instanceof s.Tensor)&&!(t instanceof Promise)&&!e)}function z(t){return y(t,E)}function E(t){return t instanceof s.Tensor?{value:t.clone(),recurse:!1}:C(t)?{value:null,recurse:!0}:{value:t,recurse:!1}}class S{constructor(t){if(this.capacity=t,this.begin=0,this.end=0,null==t)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(t<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(t),this.doubledCapacity=2*t}wrap(t){for(;t<0;)t+=this.doubledCapacity;return t%this.doubledCapacity}get(t){if(t<0)throw new RangeError("Can't get item at a negative index.");return this.data[t%this.capacity]}set(t,e){if(t<0)throw new RangeError("Can't set item at a negative index.");this.data[t%this.capacity]=e}length(){let t=this.end-this.begin;return t<0&&(t=this.doubledCapacity+t),t}isFull(){return this.length()===this.capacity}isEmpty(){return 0===this.length()}push(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,t),this.end=this.wrap(this.end+1)}pushAll(t){for(const e of t)this.push(e)}pop(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);const t=this.get(this.end);return this.set(this.end,void 0),t}unshift(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,t)}shift(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");const t=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),t}shuffleExcise(t){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");const e=this.wrap(this.begin+t),r=this.get(e);return this.set(e,this.pop()),r}}class R extends S{constructor(){super(R.INITIAL_CAPACITY)}isFull(){return!1}push(t){super.isFull()&&this.expand(),super.push(t)}unshift(t){super.isFull()&&this.expand(),super.unshift(t)}expand(){const t=2*this.capacity,e=new Array(t),r=this.length();for(let t=0;t<r;t++)e[t]=this.get(this.wrap(this.begin+t));this.data=e,this.capacity=t,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=r}}function A(t){return new F(t)}function T(t){return new N(t)}R.INITIAL_CAPACITY=32;class k{async toArray(){const t=[];let e=await this.next();for(;!e.done;)t.push(e.value),e=await this.next();return t}async toArrayForTest(){const t=this.prefetch(100),e=[];let r=await t.next();for(;!r.done;)e.push(r.value),r=await t.next();return e}async resolveFully(){let t=await this.next();for(;!t.done;)t=await this.next()}async resolveWhile(t){let e=await this.next(),r=t(e.value);for(;!e.done&&r;)e=await this.next(),r=t(e.value)}handleErrors(t){return new B(this,t)}filter(t){return new j(this,t)}map(t){return new M(this,t)}mapAsync(t){return new $(this,t)}serialMapAsync(t){return new $(this,t).serial()}flatmap(t){return new L(this,t)}async forEachAsync(t){return this.map(t).resolveFully()}async serialForEach(t){return this.serialMapAsync(t).resolveWhile((t=>!0===t))}rowMajorBatch(t,e=!0){return new _(this,t,e)}columnMajorBatch(t,e=!0,r=v){return this.rowMajorBatch(t,e).map((t=>g(t,r)))}concatenate(t,e){return new q(A([this,t]),e)}take(t){return t<0||null==t?this:new O(this,t)}skip(t){return t<0||null==t?this:new I(this,t)}prefetch(t){return new W(this,t)}shuffle(t,e){return new V(this,t,e)}serial(){return new D(this)}}class F extends k{constructor(t){super(),this.items=t,this.trav=0}summary(){return`Array of ${this.items.length} items`}async next(){if(this.trav>=this.items.length)return{value:null,done:!0};const t=this.items[this.trav];return this.trav++,{value:z(t),done:!1}}}class N extends k{constructor(t){super(),this.nextFn=t}summary(){return"Function call"}async next(){try{return this.nextFn()}catch(t){throw t.message=`Error thrown while iterating through a dataset: ${t.message}`,t}}}class D extends k{constructor(t){super(),this.upstream=t,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Serial`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){return this.upstream.next()}}class I extends k{constructor(t,e){super(),this.upstream=t,this.maxCount=e,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Skip`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;this.count++<this.maxCount;){const t=await this.upstream.next();if(t.done)return t;s.dispose(t.value)}return this.upstream.next()}}class O extends k{constructor(t,e){super(),this.upstream=t,this.maxCount=e,this.count=0}summary(){return`${this.upstream.summary()} -> Take`}async next(){return this.count++>=this.maxCount?{value:null,done:!0}:this.upstream.next()}}class _ extends k{constructor(t,e,r=!0){super(),this.upstream=t,this.batchSize=e,this.enableSmallLastBatch=r,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> RowMajorBatch`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){const t=[];for(;t.length<this.batchSize;){const e=await this.upstream.next();if(e.done)return this.enableSmallLastBatch&&t.length>0?{value:t,done:!1}:{value:null,done:!0};t.push(e.value)}return{value:t,done:!1}}}class j extends k{constructor(t,e){super(),this.upstream=t,this.predicate=e,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Filter`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;;){const t=await this.upstream.next();if(t.done||this.predicate(t.value))return t;s.dispose(t.value)}}}class M extends k{constructor(t,e){super(),this.upstream=t,this.transform=e}summary(){return`${this.upstream.summary()} -> Map`}async next(){const t=await this.upstream.next();if(t.done)return{value:null,done:!0};const e=s.tensor_util.getTensorsInContainer(t.value),r=this.transform(t.value),n=s.tensor_util.getTensorsInContainer(r);for(const t of e)s.tensor_util.isTensorInList(t,n)||t.dispose();return{value:r,done:!1}}}class B extends k{constructor(t,e){super(),this.upstream=t,this.handler=e,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> handleErrors`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;;)try{return await this.upstream.next()}catch(t){if(!this.handler(t))return{value:null,done:!0}}}}class $ extends k{constructor(t,e){super(),this.upstream=t,this.transform=e}summary(){return`${this.upstream.summary()} -> AsyncMap`}async next(){const t=await this.upstream.next();if(t.done)return{value:null,done:!0};const e=s.tensor_util.getTensorsInContainer(t.value),r=await this.transform(t.value),n=s.tensor_util.getTensorsInContainer(r);for(const t of e)s.tensor_util.isTensorInList(t,n)||t.dispose();return{value:r,done:!1}}}class P extends k{constructor(){super(),this.outputQueue=new R,this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;0===this.outputQueue.length();)if(!await this.pump())return{value:null,done:!0};return{value:this.outputQueue.shift(),done:!1}}}class L extends P{constructor(t,e){super(),this.upstream=t,this.transform=e}summary(){return`${this.upstream.summary()} -> Flatmap`}async pump(){const t=await this.upstream.next();if(t.done)return!1;const e=s.tensor_util.getTensorsInContainer(t.value),r=this.transform(t.value),n=s.tensor_util.getTensorsInContainer(r);this.outputQueue.pushAll(r);for(const t of e)s.tensor_util.isTensorInList(t,n)||t.dispose();return!0}}class q extends k{constructor(t,e){super(),this.baseErrorHandler=e,this.lastRead=null,this.iterator=null,this.moreIterators=t}summary(){return"TODO: fill in upstream of chained summaries -> Chained"}async next(){return this.lastRead=this.readFromChain(this.lastRead),this.lastRead}async readFromChain(t){if(await t,null==this.iterator){const t=await this.moreIterators.next();if(t.done)return{value:null,done:!0};this.iterator=t.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler))}const e=await this.iterator.next();return e.done?(this.iterator=null,this.readFromChain(t)):e}}!function(t){t[t.FAIL=0]="FAIL",t[t.SHORTEST=1]="SHORTEST",t[t.LONGEST=2]="LONGEST"}(p||(p={}));class H extends k{constructor(t,e=p.FAIL){super(),this.iterators=t,this.mismatchMode=e,this.count=0,this.currentPromise=null}summary(){return"{TODO: fill in upstream of zip summaries} -> Zip"}async nextState(t){await t;let e=0,r=0;const s=await b(this.iterators,(function(t){if(t instanceof k){return{value:t.next().then((t=>(e++,t.done&&r++,t.value))),recurse:!1}}return{value:null,recurse:!0}}));if(e===r)return{value:null,done:!0};if(r>0)switch(this.mismatchMode){case p.FAIL:throw new Error(`Zipped streams should have the same length. Mismatched at element ${this.count}.`);case p.SHORTEST:return{value:null,done:!0};case p.LONGEST:}return this.count++,{value:s,done:!1}}async next(){return this.currentPromise=this.nextState(this.currentPromise),this.currentPromise}}class W extends k{constructor(t,e){super(),this.upstream=t,this.bufferSize=e,this.buffer=new S(e)}summary(){return`${this.upstream.summary()} -> Prefetch`}refill(){for(;!this.buffer.isFull();){const t=this.upstream.next();this.buffer.push(t)}}next(){return this.refill(),this.buffer.shift()}}class V extends W{constructor(t,e,r){super(t,e),this.upstream=t,this.windowSize=e,this.upstreamExhausted=!1,this.random=w.alea(r||s.util.now().toString()),this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}randomInt(t){return Math.floor(this.random()*t)}chooseIndex(){return this.randomInt(this.buffer.length())}async serialNext(){for(this.upstreamExhausted||this.refill();!this.buffer.isEmpty();){const t=this.chooseIndex(),e=await this.buffer.shuffleExcise(t);if(!e.done)return this.refill(),e;this.upstreamExhausted=!0}return{value:null,done:!0}}}class U{constructor(){this.size=null}batch(t,e=!0){const r=this;let n;return s.util.assert(t>0,(()=>`batchSize needs to be positive, but it is\n ${t}`)),n=this.size===1/0||null==this.size?this.size:e?Math.ceil(this.size/t):Math.floor(this.size/t),Q((async()=>(await r.iterator()).columnMajorBatch(t,e,X)),n)}concatenate(t){const e=this;let r;return r=this.size===1/0||t.size===1/0?1/0:null!=this.size&&null!=t.size?this.size+t.size:null,Q((async()=>(await e.iterator()).concatenate(await t.iterator())),r)}filter(t){const e=this;let r;return r=this.size===1/0?1/0:null,Q((async()=>(await e.iterator()).filter((e=>s.tidy((()=>t(e)))))),r)}async forEachAsync(t){return(await this.iterator()).forEachAsync(t)}map(t){const e=this;return Q((async()=>(await e.iterator()).map((e=>s.tidy((()=>t(e)))))),this.size)}mapAsync(t){const e=this;return Q((async()=>(await e.iterator()).mapAsync(t)),this.size)}prefetch(t){if(null==t)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");const e=this;return Q((async()=>(await e.iterator()).prefetch(t)),this.size)}repeat(t){const e=this;let r;return r=null!=this.size&&t>0?this.size*t:0===t?0:null!=this.size&&(void 0===t||t<0)?1/0:null,Q((async()=>{const r=T((async()=>({value:await e.iterator(),done:!1})));return s=r.take(t),new q(s,n);var s,n}),r)}skip(t){const e=this;let r;return r=null!=this.size&&t>=0&&this.size>=t?this.size-t:null!=this.size&&(this.size<t||void 0===t||t<0)?0:null,Q((async()=>(await e.iterator()).skip(t)),r)}shuffle(t,e,r=!0){if(null==t||t<0)throw null==this.size?new RangeError("`Dataset.shuffle()` requires bufferSize to be specified."):new RangeError(`\`Dataset.shuffle()\` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for \`tf.Tensor\`s), consider setting bufferSize to the dataset size (${this.size} elements)`);const n=this,i=w.alea(e||s.util.now().toString());return Q((async()=>{let e=i.int32();return r&&(e+=i.int32()),(await n.iterator()).shuffle(t,e.toString())}),this.size)}take(t){const e=this;let r;return r=null!=this.size&&this.size>t?t:null!=this.size&&this.size<=t?this.size:null,Q((async()=>(await e.iterator()).take(t)),r)}async toArray(){if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArray()}async toArrayForTest(){if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArrayForTest()}}function Q(t,e=null){return new class extends U{constructor(){super(...arguments),this.size=e}async iterator(){return t()}}}function X(t){if(null===t)return null;const e=t[0];if(null==(r=e)||null===(n=r)||"object"!=typeof n&&"function"!=typeof n||Array.isArray(r)||"object"==typeof r&&r instanceof s.Tensor||s.util.isTypedArray(r)){return{value:function(t){if(0===t.length)throw new Error("Can't make a batch of zero elements.");return t[0]instanceof s.Tensor?s.stack(t):s.tensor(t)}(t),recurse:!1}}var r,n;return{value:null,recurse:!0}}U.MAX_BUFFER_SIZE=1e4;class G extends U{constructor(t){super(),this.input=t}async iterator(){return(await this.input.iterator()).decodeUTF8().split("\n").map((t=>(t.endsWith("\r")&&(t=t.slice(0,-1)),t)))}}const Z='"',J=Symbol("out"),Y=Symbol("field"),K=Symbol("quote"),tt=Symbol("quoteafterquote"),et=Symbol("quoteinquote");class rt extends U{async columnNames(){return this.columnNamesValidated||await this.setColumnNames(),this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames}async setColumnNames(){const t=await this.maybeReadHeaderLine();if(!this.fullColumnNames&&!t)throw new Error("Column names must be provided if there is no header line.");this.fullColumnNames&&t&&e.util.assert(t.length===this.fullColumnNames.length,(()=>"The length of provided columnNames ("+this.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+t.length.toString()+").")),this.fullColumnNames||(this.fullColumnNames=t);const r=this.fullColumnNames.reduce(((t,e)=>(t[e]=t[e]+1||1,t)),{}),s=Object.keys(r).filter((t=>r[t]>1));if(e.util.assert(0===s.length,(()=>"Duplicate column names found: "+s.toString())),this.columnConfigs)for(const t of Object.keys(this.columnConfigs)){if(-1===this.fullColumnNames.indexOf(t))throw new Error('The key "'+t+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").")}this.columnNamesValidated=!0}async maybeReadHeaderLine(){if(this.hasHeader){const t=await this.base.iterator(),e=await t.next();if(e.done)throw new Error("No data was found for CSV parsing.");const r=e.value;return this.parseRow(r,!1)}return null}constructor(t,r){super(),this.input=t,this.hasHeader=!0,this.fullColumnNames=null,this.columnNamesValidated=!1,this.columnConfigs=null,this.configuredColumnsOnly=!1,this.delimiter=",",this.delimWhitespace=!1,this.base=new G(t),r||(r={}),this.hasHeader=!1!==r.hasHeader,this.fullColumnNames=r.columnNames,this.columnConfigs=r.columnConfigs,this.configuredColumnsOnly=r.configuredColumnsOnly,r.delimWhitespace?(e.util.assert(null==r.delimiter,(()=>"Delimiter should not be provided when delimWhitespace is true.")),this.delimWhitespace=!0,this.delimiter=" "):this.delimiter=r.delimiter?r.delimiter:","}async iterator(){this.columnNamesValidated||await this.setColumnNames();let t=await this.base.iterator();return this.hasHeader&&(t=t.skip(1)),t.map((t=>this.makeDataElement(t)))}makeDataElement(t){const e=this.parseRow(t),r={},s={};for(let n=0;n<this.fullColumnNames.length;n++){const i=this.fullColumnNames[n],a=this.columnConfigs?this.columnConfigs[i]:null;if(!this.configuredColumnsOnly||a){const o=e[n];let u=null;if(""===o)if(a&&void 0!==a.default)u=a.default;else{if(a&&(a.required||a.isLabel))throw new Error(`Required column ${i} is empty in this line: ${t}`);u=void 0}else{const t=Number(o);if(isNaN(t))u=a&&"bool"===a.dtype?this.getBoolean(o):o;else if(a&&a.dtype)switch(a.dtype){case"float32":default:u=t;break;case"int32":u=Math.floor(t);break;case"bool":u=this.getBoolean(o)}else u=t}a&&a.isLabel?s[i]=u:r[i]=u}}return 0===Object.keys(s).length?r:{xs:r,ys:s}}getBoolean(t){return"1"===t||"true"===t.toLowerCase()?1:0}parseRow(t,e=!0){const r=[];let s=0;const n=t.length;let i=J;for(let e=0;e<n;e++)switch(i){case J:switch(t.charAt(e)){case Z:s=e+1,i=K;break;case this.delimiter:if(s=e+1," "===this.delimiter&&this.delimWhitespace)break;r.push(""),i=J;break;default:i=Y,s=e}break;case Y:if(t.charAt(e)===this.delimiter)r.push(t.substring(s,e)),i=J,s=e+1;break;case K:if(t.charAt(e)===Z)i=tt;break;case tt:switch(t.charAt(e)){case this.delimiter:r.push(t.substring(s,e-1)),i=J,s=e+1;break;case Z:i=K;break;default:i=et}break;case et:if(t.charAt(e)===Z)i=K}if(i===tt?r.push(t.substring(s,n-1)):r.push(t.substring(s)),e&&r.length!==this.fullColumnNames.length)throw new Error(`Invalid row in csv file. Should have ${this.fullColumnNames.length} elements in a row, but got ${r}`);return r}}class st extends k{constructor(t){super(),this.microphoneConfig=t,this.isClosed=!1,this.fftSize=t.fftSize||1024;const e=Math.log2(this.fftSize);if(this.fftSize<0||e<4||e>14||!Number.isInteger(e))throw new Error(`Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got ${this.fftSize}`);if(this.numFrames=t.numFramesPerSpectrogram||43,this.sampleRateHz=t.sampleRateHz,this.columnTruncateLength=t.columnTruncateLength||this.fftSize,this.audioTrackConstraints=t.audioTrackConstraints,this.smoothingTimeConstant=t.smoothingTimeConstant||0,this.includeSpectrogram=!1!==t.includeSpectrogram,this.includeWaveform=!0===t.includeWaveform,!this.includeSpectrogram&&!this.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.")}summary(){return"microphone"}static async create(t={}){if(!e.env().get("IS_BROWSER"))throw new Error("microphone API is only supported in browser environment.");const r=new st(t);return await r.start(),r}async start(){try{this.stream=await navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1})}catch(t){throw new Error(`Error thrown while initializing video stream: ${t.message}`)}if(!this.stream)throw new Error("Could not obtain audio from microphone.");const t=window.AudioContext||window.webkitAudioContext;if(this.audioContext=new t,this.sampleRateHz){if(this.audioContext.sampleRate!==this.sampleRateHz)throw new Error(`Mismatch in sampling rate: Expected: ${this.sampleRateHz}; Actual: ${this.audioContext.sampleRate}`)}else this.sampleRateHz=this.audioContext.sampleRate;const e=this.audioContext.createMediaStreamSource(this.stream);this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,e.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize)}async next(){if(this.isClosed)return{value:null,done:!0};let t,e;const r=await this.getAudioData();if(this.includeSpectrogram){const e=this.flattenQueue(r.freqDataQueue);t=this.getTensorFromAudioDataArray(e,[this.numFrames,this.columnTruncateLength,1])}if(this.includeWaveform){const t=this.flattenQueue(r.timeDataQueue);e=this.getTensorFromAudioDataArray(t,[this.numFrames*this.fftSize,1])}return{value:{spectrogram:t,waveform:e},done:!1}}async capture(){return(await this.next()).value}async getAudioData(){const t=[],e=[];let r=0;return new Promise((s=>{const n=setInterval((()=>{this.includeSpectrogram&&(this.analyser.getFloatFrequencyData(this.freqData),this.freqData[0]===-1/0&&s({freqDataQueue:t,timeDataQueue:e}),t.push(this.freqData.slice(0,this.columnTruncateLength))),this.includeWaveform&&(this.analyser.getFloatTimeDomainData(this.timeData),e.push(this.timeData.slice())),++r===this.numFrames&&(clearInterval(n),s({freqDataQueue:t,timeDataQueue:e}))}),this.fftSize/this.sampleRateHz*1e3)}))}stop(){this.isClosed||(this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop())}toArray(){throw new Error("Can not convert infinite audio stream to array.")}getSampleRate(){return this.sampleRateHz}flattenQueue(t){const e=t[0].length,r=new Float32Array(t.length*e);return t.forEach(((t,s)=>r.set(t,s*e))),r}getTensorFromAudioDataArray(t,r){const s=new Float32Array(e.util.sizeFromShape(r));return s.set(t,s.length-t.length),e.tensor(s,r)}}class nt extends k{constructor(t,r){if(super(),this.webcamVideoElement=t,this.webcamConfig=r,this.isClosed=!0,this.resize=!1,this.needToResize())if(this.resize=!0,this.cropSize=[this.webcamConfig.resizeHeight,this.webcamConfig.resizeWidth],this.cropBoxInd=e.tensor1d([0],"int32"),this.webcamConfig.centerCrop){const t=1*this.webcamConfig.resizeWidth/this.webcamVideoElement.width,r=1*this.webcamConfig.resizeHeight/this.webcamVideoElement.height,s=(1-t)/2,n=(1-r)/2,i=s+t,a=r+n;this.cropBox=e.tensor2d([n,s,a,i],[1,4])}else this.cropBox=e.tensor2d([0,0,1,1],[1,4])}summary(){return"webcam"}static async create(t,r={}){if(!e.env().get("IS_BROWSER"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!t){if(t=document.createElement("video"),!r.resizeWidth||!r.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");t.width=r.resizeWidth,t.height=r.resizeHeight}const s=new nt(t,r);return await s.start(),s}async start(){this.webcamConfig.facingMode&&e.util.assert("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,(()=>`Invalid webcam facing mode: ${this.webcamConfig.facingMode}. Please provide 'user' or 'environment'`));try{this.stream=await navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})}catch(t){throw t.message=`Error thrown while initializing video stream: ${t.message}`,t}if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(t){console.log(t),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,new Promise((t=>{this.webcamVideoElement.onloadedmetadata=()=>{t()}}))}async next(){if(this.isClosed)return{value:null,done:!0};let t;try{t=e.browser.fromPixels(this.webcamVideoElement)}catch(t){throw new Error(`Error thrown converting video to pixels: ${JSON.stringify(t)}`)}if(!this.resize)return{value:t,done:!1};try{return{value:this.cropAndResizeFrame(t),done:!1}}catch(t){throw new Error(`Error thrown cropping the video: ${t.message}`)}finally{t.dispose()}}needToResize(){return!(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight)}cropAndResizeFrame(t){return e.tidy((()=>{const r=e.expandDims(e.cast(t,"float32"),0);let s;s=e.image.cropAndResize(r,this.cropBox,this.cropBoxInd,this.cropSize,"bilinear");const n=s.shape;return e.reshape(s,n.slice(1))}))}async capture(){return(await this.next()).value}stop(){this.stream.getTracks().forEach((t=>t.stop()));try{this.webcamVideoElement.srcObject=null}catch(t){console.log(t),this.webcamVideoElement.src=null}this.isClosed=!0}toArray(){throw new Error("Can not convert infinite video stream to array.")}}class it{}class at extends k{split(t){return new ot(this,t)}}class ot extends at{constructor(t,e){super(),this.upstream=t,this.impl=new ut(t,e)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class ut extends P{constructor(t,e){super(),this.upstream=t,this.separator=e,this.carryover=""}summary(){return`${this.upstream.summary()} -> Split('${this.separator}')`}async pump(){const t=await this.upstream.next();if(t.done)return""!==this.carryover&&(this.outputQueue.push(this.carryover),this.carryover="",!0);const e=t.value.split(this.separator);e[0]=this.carryover+e[0];for(const t of e.slice(0,-1))this.outputQueue.push(t);return this.carryover=e[e.length-1],!0}}class ht extends k{decodeUTF8(){return new lt(this)}}class lt extends at{constructor(t){super(),this.upstream=t,this.impl=new ct(t)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class ct extends P{constructor(t){if(super(),this.upstream=t,e.env().get("IS_BROWSER"))this.decoder=new TextDecoder("utf-8");else{const{StringDecoder:t}=require("string_decoder");this.decoder=new t("utf8")}}summary(){return`${this.upstream.summary()} -> Utf8`}async pump(){const t=await this.upstream.next();let r,s;return!t.done&&(r=t.value,s=e.env().get("IS_BROWSER")?this.decoder.decode(r,{stream:!0}):this.decoder.write(Buffer.from(r.buffer)),this.outputQueue.push(s),!0)}}class ft extends ht{constructor(t,r={}){super(),this.file=t,this.options=r,e.util.assert(t instanceof Uint8Array||!!e.env().get("IS_BROWSER")&&(t instanceof File||t instanceof Blob),(()=>"FileChunkIterator only supports File, Blob and Uint8Array right now.")),this.offset=r.offset||0,this.chunkSize=r.chunkSize||1048576}summary(){return`FileChunks ${this.file}`}async next(){if(this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size))return{value:null,done:!0};const t=new Promise(((t,e)=>{const r=this.offset+this.chunkSize;if(this.file instanceof Uint8Array)t(new Uint8Array(this.file.slice(this.offset,r)));else{const s=new FileReader;s.onload=r=>{let n=s.result;if(n instanceof ArrayBuffer&&(n=new Uint8Array(n)),!(n instanceof Uint8Array))return e(new TypeError("FileReader returned unknown type."));t(n)},s.onabort=t=>e(new Error("Aborted")),s.onerror=t=>e(new Error(t.type));const n=this.file.slice(this.offset,r);s.readAsArrayBuffer(n)}this.offset=r}));return{value:await t,done:!1}}}const dt=t=>({method:t.method,headers:t.headers,body:t.body,mode:t.mode,credentials:t.credentials,cache:t.cache,redirect:t.redirect,referrer:t.referrer,integrity:t.integrity});function mt(t){return"string"==typeof t&&"file://"===t.slice(0,7)}class pt extends it{constructor(t,e={}){super(),this.input=t,this.options=e}async iterator(){if(mt(this.input)&&e.env().get("IS_NODE")){const t=require("fs");this.input=t.readFileSync(this.input.slice(7))}return new ft(this.input,this.options)}}class wt extends it{constructor(t,e={}){super(),this.url=t,this.fileOptions=e}async iterator(){return mt(this.url)?new pt(this.url,this.fileOptions).iterator():async function(t,r={},s){let n,i;"string"==typeof t?n=t:(n=t.url,i=dt(t));const a=await(s||e.util.fetch)(n,i);if(a.ok){const t=new Uint8Array(await a.arrayBuffer());return new ft(t,r)}throw new Error(a.statusText)}(this.url,this.fileOptions)}}t.CSVDataset=rt,t.Dataset=U,t.FileDataSource=pt,t.TextLineDataset=G,t.URLDataSource=wt,t.array=function(t){return Q((async()=>A(t)),t.length)},t.csv=function(t,e={}){return new rt(new wt(t),e)},t.func=function(t){const e=T(t);return Q((async()=>e))},t.generator=function(t){return Q((async()=>{const e=await t();return T((()=>e.next()))}))},t.microphone=async function(t){return st.create(t)},t.version_data="4.3.0",t.webcam=async function(t,e){return nt.create(t,e)},t.zip=function(t){if(!C(t))throw new Error("The argument to zip() must be an object or array.");let e;if(Array.isArray(t))for(let r=0;r<t.length;r++)e=null==e?t[r].size:Math.min(e,t[r].size);else if(t instanceof Object)for(const r in t)e=null==e?t[r].size:Math.min(e,t[r].size);return Q((async()=>function(t,e=p.FAIL){return new H(t,e)}(await b(t,(t=>{if(t instanceof U)return{value:t.iterator(),recurse:!1};if(C(t))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")})),p.SHORTEST)),e)},Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=tf-data.es2017.min.js.map

@@ -17,3 +17,3 @@ /**

*/
import*as t from"@tensorflow/tfjs-core";import{util as e,env as r,tensor as s,tensor1d as n,tensor2d as i,browser as a,tidy as o,expandDims as u,cast as h,image as l,reshape as c}from"@tensorflow/tfjs-core";var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function m(t){if(t.__esModule)return t;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach((function(r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})})),e}function d(t){var e={exports:{}};return t(e,e.exports),e.exports}var p=d((function(t){!function(t,e,r){function s(t){var e,r=this,s=(e=4022871197,function(t){t=String(t);for(var r=0;r<t.length;r++){var s=.02519603282416938*(e+=t.charCodeAt(r));s-=e=s>>>0,e=(s*=e)>>>0,e+=4294967296*(s-=e)}return 2.3283064365386963e-10*(e>>>0)});r.next=function(){var t=2091639*r.s0+2.3283064365386963e-10*r.c;return r.s0=r.s1,r.s1=r.s2,r.s2=t-(r.c=0|t)},r.c=1,r.s0=s(" "),r.s1=s(" "),r.s2=s(" "),r.s0-=s(t),r.s0<0&&(r.s0+=1),r.s1-=s(t),r.s1<0&&(r.s1+=1),r.s2-=s(t),r.s2<0&&(r.s2+=1),s=null}function n(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e}function i(t,e){var r=new s(t),i=e&&e.state,a=r.next;return a.int32=function(){return 4294967296*r.next()|0},a.double=function(){return a()+11102230246251565e-32*(2097152*a()|0)},a.quick=a,i&&("object"==typeof i&&n(i,r),a.state=function(){return n(r,{})}),a}e&&e.exports?e.exports=i:r&&r.amd?r((function(){return i})):this.alea=i}(0,t,!1)})),w=d((function(t){!function(t,e,r){function s(t){var e=this,r="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8},t===(0|t)?e.x=t:r+=t;for(var s=0;s<r.length+64;s++)e.x^=0|r.charCodeAt(s),e.next()}function n(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e}function i(t,e){var r=new s(t),i=e&&e.state,a=function(){return(r.next()>>>0)/4294967296};return a.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},a.int32=r.next,a.quick=a,i&&("object"==typeof i&&n(i,r),a.state=function(){return n(r,{})}),a}e&&e.exports?e.exports=i:r&&r.amd?r((function(){return i})):this.xor128=i}(0,t,!1)})),y=d((function(t){!function(t,e,r){function s(t){var e=this,r="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:r+=t;for(var s=0;s<r.length+64;s++)e.x^=0|r.charCodeAt(s),s==r.length&&(e.d=e.x<<10^e.x>>>4),e.next()}function n(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e}function i(t,e){var r=new s(t),i=e&&e.state,a=function(){return(r.next()>>>0)/4294967296};return a.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},a.int32=r.next,a.quick=a,i&&("object"==typeof i&&n(i,r),a.state=function(){return n(r,{})}),a}e&&e.exports?e.exports=i:r&&r.amd?r((function(){return i})):this.xorwow=i}(0,t,!1)})),g=d((function(t){!function(t,e,r){function s(t){var e=this;e.next=function(){var t,r,s=e.x,n=e.i;return t=s[n],r=(t^=t>>>7)^t<<24,r^=(t=s[n+1&7])^t>>>10,r^=(t=s[n+3&7])^t>>>3,r^=(t=s[n+4&7])^t<<7,t=s[n+7&7],r^=(t^=t<<13)^t<<9,s[n]=r,e.i=n+1&7,r},function(t,e){var r,s=[];if(e===(0|e))s[0]=e;else for(e=""+e,r=0;r<e.length;++r)s[7&r]=s[7&r]<<15^e.charCodeAt(r)+s[r+1&7]<<13;for(;s.length<8;)s.push(0);for(r=0;r<8&&0===s[r];++r);for(8==r&&(s[7]=-1),t.x=s,t.i=0,r=256;r>0;--r)t.next()}(e,t)}function n(t,e){return e.x=t.x.slice(),e.i=t.i,e}function i(t,e){null==t&&(t=+new Date);var r=new s(t),i=e&&e.state,a=function(){return(r.next()>>>0)/4294967296};return a.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},a.int32=r.next,a.quick=a,i&&(i.x&&n(i,r),a.state=function(){return n(r,{})}),a}e&&e.exports?e.exports=i:r&&r.amd?r((function(){return i})):this.xorshift7=i}(0,t,!1)})),x=d((function(t){!function(t,e,r){function s(t){var e=this;e.next=function(){var t,r,s=e.w,n=e.X,i=e.i;return e.w=s=s+1640531527|0,r=n[i+34&127],t=n[i=i+1&127],r^=r<<13,t^=t<<17,r^=r>>>15,t^=t>>>12,r=n[i]=r^t,e.i=i,r+(s^s>>>16)|0},function(t,e){var r,s,n,i,a,o=[],u=128;for(e===(0|e)?(s=e,e=null):(e+="\0",s=0,u=Math.max(u,e.length)),n=0,i=-32;i<u;++i)e&&(s^=e.charCodeAt((i+32)%e.length)),0===i&&(a=s),s^=s<<10,s^=s>>>15,s^=s<<4,s^=s>>>13,i>=0&&(a=a+1640531527|0,n=0==(r=o[127&i]^=s+a)?n+1:0);for(n>=128&&(o[127&(e&&e.length||0)]=-1),n=127,i=512;i>0;--i)s=o[n+34&127],r=o[n=n+1&127],s^=s<<13,r^=r<<17,s^=s>>>15,r^=r>>>12,o[n]=s^r;t.w=a,t.X=o,t.i=n}(e,t)}function n(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e}function i(t,e){null==t&&(t=+new Date);var r=new s(t),i=e&&e.state,a=function(){return(r.next()>>>0)/4294967296};return a.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},a.int32=r.next,a.quick=a,i&&(i.X&&n(i,r),a.state=function(){return n(r,{})}),a}e&&e.exports?e.exports=i:r&&r.amd?r((function(){return i})):this.xor4096=i}(0,t,!1)})),v=d((function(t){!function(t,e,r){function s(t){var e=this,r="";e.next=function(){var t=e.b,r=e.c,s=e.d,n=e.a;return t=t<<25^t>>>7^r,r=r-s|0,s=s<<24^s>>>8^n,n=n-t|0,e.b=t=t<<20^t>>>12^r,e.c=r=r-s|0,e.d=s<<16^r>>>16^n,e.a=n-t|0},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):r+=t;for(var s=0;s<r.length+20;s++)e.b^=0|r.charCodeAt(s),e.next()}function n(t,e){return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e}function i(t,e){var r=new s(t),i=e&&e.state,a=function(){return(r.next()>>>0)/4294967296};return a.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},a.int32=r.next,a.quick=a,i&&("object"==typeof i&&n(i,r),a.state=function(){return n(r,{})}),a}e&&e.exports?e.exports=i:r&&r.amd?r((function(){return i})):this.tychei=i}(0,t,!1)})),b=m({__proto__:null,default:{}}),C=d((function(t){!function(e,r,s){var n,i=256,a=s.pow(i,6),o=s.pow(2,52),u=2*o,h=255;function l(t,h,l){var w=[],y=d(m((h=1==h?{entropy:!0}:h||{}).entropy?[t,p(r)]:null==t?function(){try{var t;return n&&(t=n.randomBytes)?t=t(i):(t=new Uint8Array(i),(e.crypto||e.msCrypto).getRandomValues(t)),p(t)}catch(t){var s=e.navigator,a=s&&s.plugins;return[+new Date,e,a,e.screen,p(r)]}}():t,3),w),g=new c(w),x=function(){for(var t=g.g(6),e=a,r=0;t<o;)t=(t+r)*i,e*=i,r=g.g(1);for(;t>=u;)t/=2,e/=2,r>>>=1;return(t+r)/e};return x.int32=function(){return 0|g.g(4)},x.quick=function(){return g.g(4)/4294967296},x.double=x,d(p(g.S),r),(h.pass||l||function(t,e,r,n){return n&&(n.S&&f(n,g),t.state=function(){return f(g,{})}),r?(s.random=t,e):t})(x,y,"global"in h?h.global:this==s,h.state)}function c(t){var e,r=t.length,s=this,n=0,a=s.i=s.j=0,o=s.S=[];for(r||(t=[r++]);n<i;)o[n]=n++;for(n=0;n<i;n++)o[n]=o[a=h&a+t[n%r]+(e=o[n])],o[a]=e;(s.g=function(t){for(var e,r=0,n=s.i,a=s.j,o=s.S;t--;)e=o[n=h&n+1],r=r*i+o[h&(o[n]=o[a=h&a+e])+(o[a]=e)];return s.i=n,s.j=a,r})(i)}function f(t,e){return e.i=t.i,e.j=t.j,e.S=t.S.slice(),e}function m(t,e){var r,s=[],n=typeof t;if(e&&"object"==n)for(r in t)try{s.push(m(t[r],e-1))}catch(t){}return s.length?s:"string"==n?t:t+"\0"}function d(t,e){for(var r,s=t+"",n=0;n<s.length;)e[h&n]=h&(r^=19*e[h&n])+s.charCodeAt(n++);return p(e)}function p(t){return String.fromCharCode.apply(0,t)}if(d(s.random(),r),t.exports){t.exports=l;try{n=b}catch(t){}}else s.seedrandom=l}("undefined"!=typeof self?self:f,[],Math)}));C.alea=p,C.xor128=w,C.xorwow=y,C.xorshift7=g,C.xor4096=x,C.tychei=v;var z,E=C;function S(t,e,r=new Map,s=new Set){if(null==t)return null;if("function"==typeof Blob&&t instanceof Blob)return t.slice();if(s.has(t))throw new Error("Circular references are not supported.");if(r.has(t))return r.get(t);const n=e(t);if(n.recurse&&null!==n.value)throw new Error("A deep map function may not return both a value and recurse=true.");if(n.recurse){if(F(t)){const n=Array.isArray(t)?[]:{};s.add(t);for(const i in t){const a=S(t[i],e,r,s);n[i]=a}return s.delete(t),t.__proto__&&(n.__proto__=t.__proto__),n}throw new Error(`Can't recurse into non-iterable type: ${t}`)}return r.set(t,n.value),n.value}function A(t,e=T){return R(t,e)}function R(t,e,r=new Set){const s=t[0];if(r.has(s))throw new Error("Circular references are not supported.");const n=e(t);if(n.recurse&&null!==n.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(n.recurse){if(F(s)){const n=Array.isArray(s)?[]:{};r.add(s);for(const i in s){const s=R(t.map((t=>t[i])),e,r);n[i]=s}return r.delete(s),n}throw new Error(`Can't recurse into non-iterable type: ${s}`)}return n.value}function T(t){return null===t?null:F(t[0])?{value:null,recurse:!0}:{value:t,recurse:!1}}async function k(e,r){const s=new Map;S(e,r,s);for(const e of Array.from(s.keys())){const r=s.get(e);if(t.util.isPromise(r)){const t=await r;s.set(e,t)}}return S(e,r,s)}function F(e){let r=!1;if(t.env().get("IS_BROWSER"))r=e instanceof TextDecoder;else{const{StringDecoder:t}=require("string_decoder");r=e instanceof t}return null!=e&&!ArrayBuffer.isView(e)&&(Array.isArray(e)||"object"==typeof e&&!(e instanceof t.Tensor)&&!(e instanceof Promise)&&!r)}function N(t){return S(t,I)}function I(e){return e instanceof t.Tensor?{value:e.clone(),recurse:!1}:F(e)?{value:null,recurse:!0}:{value:e,recurse:!1}}class _{constructor(t){if(this.capacity=t,this.begin=0,this.end=0,null==t)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(t<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(t),this.doubledCapacity=2*t}wrap(t){for(;t<0;)t+=this.doubledCapacity;return t%this.doubledCapacity}get(t){if(t<0)throw new RangeError("Can't get item at a negative index.");return this.data[t%this.capacity]}set(t,e){if(t<0)throw new RangeError("Can't set item at a negative index.");this.data[t%this.capacity]=e}length(){let t=this.end-this.begin;return t<0&&(t=this.doubledCapacity+t),t}isFull(){return this.length()===this.capacity}isEmpty(){return 0===this.length()}push(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,t),this.end=this.wrap(this.end+1)}pushAll(t){for(const e of t)this.push(e)}pop(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);const t=this.get(this.end);return this.set(this.end,void 0),t}unshift(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,t)}shift(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");const t=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),t}shuffleExcise(t){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");const e=this.wrap(this.begin+t),r=this.get(e);return this.set(e,this.pop()),r}}class D extends _{constructor(){super(D.INITIAL_CAPACITY)}isFull(){return!1}push(t){super.isFull()&&this.expand(),super.push(t)}unshift(t){super.isFull()&&this.expand(),super.unshift(t)}expand(){const t=2*this.capacity,e=new Array(t),r=this.length();for(let t=0;t<r;t++)e[t]=this.get(this.wrap(this.begin+t));this.data=e,this.capacity=t,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=r}}function O(t){return new B(t)}function M(t){return new $(t)}D.INITIAL_CAPACITY=32;class j{async toArray(){const t=[];let e=await this.next();for(;!e.done;)t.push(e.value),e=await this.next();return t}async toArrayForTest(){const t=this.prefetch(100),e=[];let r=await t.next();for(;!r.done;)e.push(r.value),r=await t.next();return e}async resolveFully(){let t=await this.next();for(;!t.done;)t=await this.next()}async resolveWhile(t){let e=await this.next(),r=t(e.value);for(;!e.done&&r;)e=await this.next(),r=t(e.value)}handleErrors(t){return new U(this,t)}filter(t){return new W(this,t)}map(t){return new V(this,t)}mapAsync(t){return new Q(this,t)}serialMapAsync(t){return new Q(this,t).serial()}flatmap(t){return new G(this,t)}async forEachAsync(t){return this.map(t).resolveFully()}async serialForEach(t){return this.serialMapAsync(t).resolveWhile((t=>!0===t))}rowMajorBatch(t,e=!0){return new P(this,t,e)}columnMajorBatch(t,e=!0,r=T){return this.rowMajorBatch(t,e).map((t=>A(t,r)))}concatenate(t,e){return new Z(O([this,t]),e)}take(t){return t<0||null==t?this:new L(this,t)}skip(t){return t<0||null==t?this:new q(this,t)}prefetch(t){return new Y(this,t)}shuffle(t,e){return new K(this,t,e)}serial(){return new H(this)}}class B extends j{constructor(t){super(),this.items=t,this.trav=0}summary(){return`Array of ${this.items.length} items`}async next(){if(this.trav>=this.items.length)return{value:null,done:!0};const t=this.items[this.trav];return this.trav++,{value:N(t),done:!1}}}class $ extends j{constructor(t){super(),this.nextFn=t}summary(){return"Function call"}async next(){try{return this.nextFn()}catch(t){throw t.message=`Error thrown while iterating through a dataset: ${t.message}`,t}}}class H extends j{constructor(t){super(),this.upstream=t,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Serial`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){return this.upstream.next()}}class q extends j{constructor(t,e){super(),this.upstream=t,this.maxCount=e,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Skip`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;this.count++<this.maxCount;){const e=await this.upstream.next();if(e.done)return e;t.dispose(e.value)}return this.upstream.next()}}class L extends j{constructor(t,e){super(),this.upstream=t,this.maxCount=e,this.count=0}summary(){return`${this.upstream.summary()} -> Take`}async next(){return this.count++>=this.maxCount?{value:null,done:!0}:this.upstream.next()}}class P extends j{constructor(t,e,r=!0){super(),this.upstream=t,this.batchSize=e,this.enableSmallLastBatch=r,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> RowMajorBatch`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){const t=[];for(;t.length<this.batchSize;){const e=await this.upstream.next();if(e.done)return this.enableSmallLastBatch&&t.length>0?{value:t,done:!1}:{value:null,done:!0};t.push(e.value)}return{value:t,done:!1}}}class W extends j{constructor(t,e){super(),this.upstream=t,this.predicate=e,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Filter`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;;){const e=await this.upstream.next();if(e.done||this.predicate(e.value))return e;t.dispose(e.value)}}}class V extends j{constructor(t,e){super(),this.upstream=t,this.transform=e}summary(){return`${this.upstream.summary()} -> Map`}async next(){const e=await this.upstream.next();if(e.done)return{value:null,done:!0};const r=t.tensor_util.getTensorsInContainer(e.value),s=this.transform(e.value),n=t.tensor_util.getTensorsInContainer(s);for(const e of r)t.tensor_util.isTensorInList(e,n)||e.dispose();return{value:s,done:!1}}}class U extends j{constructor(t,e){super(),this.upstream=t,this.handler=e,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> handleErrors`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;;)try{return await this.upstream.next()}catch(t){if(!this.handler(t))return{value:null,done:!0}}}}class Q extends j{constructor(t,e){super(),this.upstream=t,this.transform=e}summary(){return`${this.upstream.summary()} -> AsyncMap`}async next(){const e=await this.upstream.next();if(e.done)return{value:null,done:!0};const r=t.tensor_util.getTensorsInContainer(e.value),s=await this.transform(e.value),n=t.tensor_util.getTensorsInContainer(s);for(const e of r)t.tensor_util.isTensorInList(e,n)||e.dispose();return{value:s,done:!1}}}class X extends j{constructor(){super(),this.outputQueue=new D,this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;0===this.outputQueue.length();)if(!await this.pump())return{value:null,done:!0};return{value:this.outputQueue.shift(),done:!1}}}class G extends X{constructor(t,e){super(),this.upstream=t,this.transform=e}summary(){return`${this.upstream.summary()} -> Flatmap`}async pump(){const e=await this.upstream.next();if(e.done)return!1;const r=t.tensor_util.getTensorsInContainer(e.value),s=this.transform(e.value),n=t.tensor_util.getTensorsInContainer(s);this.outputQueue.pushAll(s);for(const e of r)t.tensor_util.isTensorInList(e,n)||e.dispose();return!0}}class Z extends j{constructor(t,e){super(),this.baseErrorHandler=e,this.lastRead=null,this.iterator=null,this.moreIterators=t}summary(){return"TODO: fill in upstream of chained summaries -> Chained"}async next(){return this.lastRead=this.readFromChain(this.lastRead),this.lastRead}async readFromChain(t){if(await t,null==this.iterator){const t=await this.moreIterators.next();if(t.done)return{value:null,done:!0};this.iterator=t.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler))}const e=await this.iterator.next();return e.done?(this.iterator=null,this.readFromChain(t)):e}}!function(t){t[t.FAIL=0]="FAIL",t[t.SHORTEST=1]="SHORTEST",t[t.LONGEST=2]="LONGEST"}(z||(z={}));class J extends j{constructor(t,e=z.FAIL){super(),this.iterators=t,this.mismatchMode=e,this.count=0,this.currentPromise=null}summary(){return"{TODO: fill in upstream of zip summaries} -> Zip"}async nextState(t){await t;let e=0,r=0;const s=await k(this.iterators,(function(t){if(t instanceof j){return{value:t.next().then((t=>(e++,t.done&&r++,t.value))),recurse:!1}}return{value:null,recurse:!0}}));if(e===r)return{value:null,done:!0};if(r>0)switch(this.mismatchMode){case z.FAIL:throw new Error(`Zipped streams should have the same length. Mismatched at element ${this.count}.`);case z.SHORTEST:return{value:null,done:!0};case z.LONGEST:}return this.count++,{value:s,done:!1}}async next(){return this.currentPromise=this.nextState(this.currentPromise),this.currentPromise}}class Y extends j{constructor(t,e){super(),this.upstream=t,this.bufferSize=e,this.buffer=new _(e)}summary(){return`${this.upstream.summary()} -> Prefetch`}refill(){for(;!this.buffer.isFull();){const t=this.upstream.next();this.buffer.push(t)}}next(){return this.refill(),this.buffer.shift()}}class K extends Y{constructor(e,r,s){super(e,r),this.upstream=e,this.windowSize=r,this.upstreamExhausted=!1,this.random=E.alea(s||t.util.now().toString()),this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}randomInt(t){return Math.floor(this.random()*t)}chooseIndex(){return this.randomInt(this.buffer.length())}async serialNext(){for(this.upstreamExhausted||this.refill();!this.buffer.isEmpty();){const t=this.chooseIndex(),e=await this.buffer.shuffleExcise(t);if(!e.done)return this.refill(),e;this.upstreamExhausted=!0}return{value:null,done:!0}}}class tt{constructor(){this.size=null}batch(e,r=!0){const s=this;let n;return t.util.assert(e>0,(()=>`batchSize needs to be positive, but it is\n ${e}`)),n=this.size===1/0||null==this.size?this.size:r?Math.ceil(this.size/e):Math.floor(this.size/e),et((async()=>(await s.iterator()).columnMajorBatch(e,r,nt)),n)}concatenate(t){const e=this;let r;return r=this.size===1/0||t.size===1/0?1/0:null!=this.size&&null!=t.size?this.size+t.size:null,et((async()=>(await e.iterator()).concatenate(await t.iterator())),r)}filter(e){const r=this;let s;return s=this.size===1/0?1/0:null,et((async()=>(await r.iterator()).filter((r=>t.tidy((()=>e(r)))))),s)}async forEachAsync(t){return(await this.iterator()).forEachAsync(t)}map(e){const r=this;return et((async()=>(await r.iterator()).map((r=>t.tidy((()=>e(r)))))),this.size)}mapAsync(t){const e=this;return et((async()=>(await e.iterator()).mapAsync(t)),this.size)}prefetch(t){if(null==t)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");const e=this;return et((async()=>(await e.iterator()).prefetch(t)),this.size)}repeat(t){const e=this;let r;return r=null!=this.size&&t>0?this.size*t:0===t?0:null!=this.size&&(void 0===t||t<0)?1/0:null,et((async()=>{const r=M((async()=>({value:await e.iterator(),done:!1})));return s=r.take(t),new Z(s,n);var s,n}),r)}skip(t){const e=this;let r;return r=null!=this.size&&t>=0&&this.size>=t?this.size-t:null!=this.size&&(this.size<t||void 0===t||t<0)?0:null,et((async()=>(await e.iterator()).skip(t)),r)}shuffle(e,r,s=!0){if(null==e||e<0)throw null==this.size?new RangeError("`Dataset.shuffle()` requires bufferSize to be specified."):new RangeError(`\`Dataset.shuffle()\` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for \`tf.Tensor\`s), consider setting bufferSize to the dataset size (${this.size} elements)`);const n=this,i=E.alea(r||t.util.now().toString());return et((async()=>{let t=i.int32();return s&&(t+=i.int32()),(await n.iterator()).shuffle(e,t.toString())}),this.size)}take(t){const e=this;let r;return r=null!=this.size&&this.size>t?t:null!=this.size&&this.size<=t?this.size:null,et((async()=>(await e.iterator()).take(t)),r)}async toArray(){if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArray()}async toArrayForTest(){if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArrayForTest()}}function et(t,e=null){return new class extends tt{constructor(){super(...arguments),this.size=e}async iterator(){return t()}}}function rt(t){return et((async()=>O(t)),t.length)}function st(t){if(!F(t))throw new Error("The argument to zip() must be an object or array.");let e;if(Array.isArray(t))for(let r=0;r<t.length;r++)e=null==e?t[r].size:Math.min(e,t[r].size);else if(t instanceof Object)for(const r in t)e=null==e?t[r].size:Math.min(e,t[r].size);return et((async()=>function(t,e=z.FAIL){return new J(t,e)}(await k(t,(t=>{if(t instanceof tt)return{value:t.iterator(),recurse:!1};if(F(t))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")})),z.SHORTEST)),e)}function nt(e){if(null===e)return null;const r=e[0];if(null==(s=r)||null===(n=s)||"object"!=typeof n&&"function"!=typeof n||Array.isArray(s)||"object"==typeof s&&s instanceof t.Tensor||t.util.isTypedArray(s)){return{value:function(e){if(0===e.length)throw new Error("Can't make a batch of zero elements.");return e[0]instanceof t.Tensor?t.stack(e):t.tensor(e)}(e),recurse:!1}}var s,n;return{value:null,recurse:!0}}tt.MAX_BUFFER_SIZE=1e4;class it extends tt{constructor(t){super(),this.input=t}async iterator(){return(await this.input.iterator()).decodeUTF8().split("\n").map((t=>(t.endsWith("\r")&&(t=t.slice(0,-1)),t)))}}const at=Symbol("out"),ot=Symbol("field"),ut=Symbol("quote"),ht=Symbol("quoteafterquote"),lt=Symbol("quoteinquote");class ct extends tt{constructor(t,r){super(),this.input=t,this.hasHeader=!0,this.fullColumnNames=null,this.columnNamesValidated=!1,this.columnConfigs=null,this.configuredColumnsOnly=!1,this.delimiter=",",this.delimWhitespace=!1,this.base=new it(t),r||(r={}),this.hasHeader=!1!==r.hasHeader,this.fullColumnNames=r.columnNames,this.columnConfigs=r.columnConfigs,this.configuredColumnsOnly=r.configuredColumnsOnly,r.delimWhitespace?(e.assert(null==r.delimiter,(()=>"Delimiter should not be provided when delimWhitespace is true.")),this.delimWhitespace=!0,this.delimiter=" "):this.delimiter=r.delimiter?r.delimiter:","}async columnNames(){return this.columnNamesValidated||await this.setColumnNames(),this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames}async setColumnNames(){const t=await this.maybeReadHeaderLine();if(!this.fullColumnNames&&!t)throw new Error("Column names must be provided if there is no header line.");this.fullColumnNames&&t&&e.assert(t.length===this.fullColumnNames.length,(()=>"The length of provided columnNames ("+this.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+t.length.toString()+").")),this.fullColumnNames||(this.fullColumnNames=t);const r=this.fullColumnNames.reduce(((t,e)=>(t[e]=t[e]+1||1,t)),{}),s=Object.keys(r).filter((t=>r[t]>1));if(e.assert(0===s.length,(()=>"Duplicate column names found: "+s.toString())),this.columnConfigs)for(const t of Object.keys(this.columnConfigs)){if(-1===this.fullColumnNames.indexOf(t))throw new Error('The key "'+t+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").")}this.columnNamesValidated=!0}async maybeReadHeaderLine(){if(this.hasHeader){const t=await this.base.iterator(),e=await t.next();if(e.done)throw new Error("No data was found for CSV parsing.");const r=e.value;return this.parseRow(r,!1)}return null}async iterator(){this.columnNamesValidated||await this.setColumnNames();let t=await this.base.iterator();return this.hasHeader&&(t=t.skip(1)),t.map((t=>this.makeDataElement(t)))}makeDataElement(t){const e=this.parseRow(t),r={},s={};for(let n=0;n<this.fullColumnNames.length;n++){const i=this.fullColumnNames[n],a=this.columnConfigs?this.columnConfigs[i]:null;if(!this.configuredColumnsOnly||a){const o=e[n];let u=null;if(""===o)if(a&&void 0!==a.default)u=a.default;else{if(a&&(a.required||a.isLabel))throw new Error(`Required column ${i} is empty in this line: ${t}`);u=void 0}else{const t=Number(o);if(isNaN(t))u=a&&"bool"===a.dtype?this.getBoolean(o):o;else if(a&&a.dtype)switch(a.dtype){case"float32":default:u=t;break;case"int32":u=Math.floor(t);break;case"bool":u=this.getBoolean(o)}else u=t}a&&a.isLabel?s[i]=u:r[i]=u}}return 0===Object.keys(s).length?r:{xs:r,ys:s}}getBoolean(t){return"1"===t||"true"===t.toLowerCase()?1:0}parseRow(t,e=!0){const r=[];let s=0;const n=t.length;let i=at;for(let e=0;e<n;e++)switch(i){case at:switch(t.charAt(e)){case'"':s=e+1,i=ut;break;case this.delimiter:if(s=e+1," "===this.delimiter&&this.delimWhitespace)break;r.push(""),i=at;break;default:i=ot,s=e}break;case ot:if(t.charAt(e)===this.delimiter)r.push(t.substring(s,e)),i=at,s=e+1;break;case ut:if('"'===t.charAt(e))i=ht;break;case ht:switch(t.charAt(e)){case this.delimiter:r.push(t.substring(s,e-1)),i=at,s=e+1;break;case'"':i=ut;break;default:i=lt}break;case lt:if('"'===t.charAt(e))i=ut}if(i===ht?r.push(t.substring(s,n-1)):r.push(t.substring(s)),e&&r.length!==this.fullColumnNames.length)throw new Error(`Invalid row in csv file. Should have ${this.fullColumnNames.length} elements in a row, but got ${r}`);return r}}class ft extends j{constructor(t){super(),this.microphoneConfig=t,this.isClosed=!1,this.fftSize=t.fftSize||1024;const e=Math.log2(this.fftSize);if(this.fftSize<0||e<4||e>14||!Number.isInteger(e))throw new Error(`Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got ${this.fftSize}`);if(this.numFrames=t.numFramesPerSpectrogram||43,this.sampleRateHz=t.sampleRateHz,this.columnTruncateLength=t.columnTruncateLength||this.fftSize,this.audioTrackConstraints=t.audioTrackConstraints,this.smoothingTimeConstant=t.smoothingTimeConstant||0,this.includeSpectrogram=!1!==t.includeSpectrogram,this.includeWaveform=!0===t.includeWaveform,!this.includeSpectrogram&&!this.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.")}summary(){return"microphone"}static async create(t={}){if(!r().get("IS_BROWSER"))throw new Error("microphone API is only supported in browser environment.");const e=new ft(t);return await e.start(),e}async start(){try{this.stream=await navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1})}catch(t){throw new Error(`Error thrown while initializing video stream: ${t.message}`)}if(!this.stream)throw new Error("Could not obtain audio from microphone.");const t=window.AudioContext||window.webkitAudioContext;if(this.audioContext=new t,this.sampleRateHz){if(this.audioContext.sampleRate!==this.sampleRateHz)throw new Error(`Mismatch in sampling rate: Expected: ${this.sampleRateHz}; Actual: ${this.audioContext.sampleRate}`)}else this.sampleRateHz=this.audioContext.sampleRate;const e=this.audioContext.createMediaStreamSource(this.stream);this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,e.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize)}async next(){if(this.isClosed)return{value:null,done:!0};let t,e;const r=await this.getAudioData();if(this.includeSpectrogram){const e=this.flattenQueue(r.freqDataQueue);t=this.getTensorFromAudioDataArray(e,[this.numFrames,this.columnTruncateLength,1])}if(this.includeWaveform){const t=this.flattenQueue(r.timeDataQueue);e=this.getTensorFromAudioDataArray(t,[this.numFrames*this.fftSize,1])}return{value:{spectrogram:t,waveform:e},done:!1}}async capture(){return(await this.next()).value}async getAudioData(){const t=[],e=[];let r=0;return new Promise((s=>{const n=setInterval((()=>{this.includeSpectrogram&&(this.analyser.getFloatFrequencyData(this.freqData),this.freqData[0]===-1/0&&s({freqDataQueue:t,timeDataQueue:e}),t.push(this.freqData.slice(0,this.columnTruncateLength))),this.includeWaveform&&(this.analyser.getFloatTimeDomainData(this.timeData),e.push(this.timeData.slice())),++r===this.numFrames&&(clearInterval(n),s({freqDataQueue:t,timeDataQueue:e}))}),this.fftSize/this.sampleRateHz*1e3)}))}stop(){this.isClosed||(this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop())}toArray(){throw new Error("Can not convert infinite audio stream to array.")}getSampleRate(){return this.sampleRateHz}flattenQueue(t){const e=t[0].length,r=new Float32Array(t.length*e);return t.forEach(((t,s)=>r.set(t,s*e))),r}getTensorFromAudioDataArray(t,r){const n=new Float32Array(e.sizeFromShape(r));return n.set(t,n.length-t.length),s(n,r)}}class mt extends j{constructor(t,e){if(super(),this.webcamVideoElement=t,this.webcamConfig=e,this.isClosed=!0,this.resize=!1,this.needToResize())if(this.resize=!0,this.cropSize=[this.webcamConfig.resizeHeight,this.webcamConfig.resizeWidth],this.cropBoxInd=n([0],"int32"),this.webcamConfig.centerCrop){const t=1*this.webcamConfig.resizeWidth/this.webcamVideoElement.width,e=1*this.webcamConfig.resizeHeight/this.webcamVideoElement.height,r=(1-t)/2,s=(1-e)/2,n=r+t,a=e+s;this.cropBox=i([s,r,a,n],[1,4])}else this.cropBox=i([0,0,1,1],[1,4])}summary(){return"webcam"}static async create(t,e={}){if(!r().get("IS_BROWSER"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!t){if(t=document.createElement("video"),!e.resizeWidth||!e.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");t.width=e.resizeWidth,t.height=e.resizeHeight}const s=new mt(t,e);return await s.start(),s}async start(){this.webcamConfig.facingMode&&e.assert("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,(()=>`Invalid webcam facing mode: ${this.webcamConfig.facingMode}. Please provide 'user' or 'environment'`));try{this.stream=await navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})}catch(t){throw t.message=`Error thrown while initializing video stream: ${t.message}`,t}if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(t){console.log(t),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,new Promise((t=>{this.webcamVideoElement.onloadedmetadata=()=>{t()}}))}async next(){if(this.isClosed)return{value:null,done:!0};let t;try{t=a.fromPixels(this.webcamVideoElement)}catch(t){throw new Error(`Error thrown converting video to pixels: ${JSON.stringify(t)}`)}if(!this.resize)return{value:t,done:!1};try{return{value:this.cropAndResizeFrame(t),done:!1}}catch(t){throw new Error(`Error thrown cropping the video: ${t.message}`)}finally{t.dispose()}}needToResize(){return!(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight)}cropAndResizeFrame(t){return o((()=>{const e=u(h(t,"float32"),0);let r;r=l.cropAndResize(e,this.cropBox,this.cropBoxInd,this.cropSize,"bilinear");const s=r.shape;return c(r,s.slice(1))}))}async capture(){return(await this.next()).value}stop(){this.stream.getTracks().forEach((t=>t.stop()));try{this.webcamVideoElement.srcObject=null}catch(t){console.log(t),this.webcamVideoElement.src=null}this.isClosed=!0}toArray(){throw new Error("Can not convert infinite video stream to array.")}}class dt{}class pt extends j{split(t){return new wt(this,t)}}class wt extends pt{constructor(t,e){super(),this.upstream=t,this.impl=new yt(t,e)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class yt extends X{constructor(t,e){super(),this.upstream=t,this.separator=e,this.carryover=""}summary(){return`${this.upstream.summary()} -> Split('${this.separator}')`}async pump(){const t=await this.upstream.next();if(t.done)return""!==this.carryover&&(this.outputQueue.push(this.carryover),this.carryover="",!0);const e=t.value.split(this.separator);e[0]=this.carryover+e[0];for(const t of e.slice(0,-1))this.outputQueue.push(t);return this.carryover=e[e.length-1],!0}}class gt extends j{decodeUTF8(){return new xt(this)}}class xt extends pt{constructor(t){super(),this.upstream=t,this.impl=new vt(t)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class vt extends X{constructor(t){if(super(),this.upstream=t,r().get("IS_BROWSER"))this.decoder=new TextDecoder("utf-8");else{const{StringDecoder:t}=require("string_decoder");this.decoder=new t("utf8")}}summary(){return`${this.upstream.summary()} -> Utf8`}async pump(){const t=await this.upstream.next();let e,s;return!t.done&&(e=t.value,s=r().get("IS_BROWSER")?this.decoder.decode(e,{stream:!0}):this.decoder.write(Buffer.from(e.buffer)),this.outputQueue.push(s),!0)}}class bt extends gt{constructor(t,s={}){super(),this.file=t,this.options=s,e.assert(t instanceof Uint8Array||!!r().get("IS_BROWSER")&&(t instanceof File||t instanceof Blob),(()=>"FileChunkIterator only supports File, Blob and Uint8Array right now.")),this.offset=s.offset||0,this.chunkSize=s.chunkSize||1048576}summary(){return`FileChunks ${this.file}`}async next(){if(this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size))return{value:null,done:!0};const t=new Promise(((t,e)=>{const r=this.offset+this.chunkSize;if(this.file instanceof Uint8Array)t(new Uint8Array(this.file.slice(this.offset,r)));else{const s=new FileReader;s.onload=r=>{let n=s.result;if(n instanceof ArrayBuffer&&(n=new Uint8Array(n)),!(n instanceof Uint8Array))return e(new TypeError("FileReader returned unknown type."));t(n)},s.onabort=t=>e(new Error("Aborted")),s.onerror=t=>e(new Error(t.type));const n=this.file.slice(this.offset,r);s.readAsArrayBuffer(n)}this.offset=r}));return{value:await t,done:!1}}}const Ct=t=>({method:t.method,headers:t.headers,body:t.body,mode:t.mode,credentials:t.credentials,cache:t.cache,redirect:t.redirect,referrer:t.referrer,integrity:t.integrity});function zt(t){return"string"==typeof t&&"file://"===t.slice(0,7)}class Et extends dt{constructor(t,e={}){super(),this.input=t,this.options=e}async iterator(){if(zt(this.input)&&r().get("IS_NODE")){const t=require("fs");this.input=t.readFileSync(this.input.slice(7))}return new bt(this.input,this.options)}}class St extends dt{constructor(t,e={}){super(),this.url=t,this.fileOptions=e}async iterator(){return zt(this.url)?new Et(this.url,this.fileOptions).iterator():async function(t,r={},s){let n,i;"string"==typeof t?n=t:(n=t.url,i=Ct(t));const a=await(s||e.fetch)(n,i);if(a.ok){const t=new Uint8Array(await a.arrayBuffer());return new bt(t,r)}throw new Error(a.statusText)}(this.url,this.fileOptions)}}function At(t,e={}){return new ct(new St(t),e)}function Rt(t){const e=M(t);return et((async()=>e))}function Tt(t){return et((async()=>{const e=await t();return M((()=>e.next()))}))}async function kt(t,e){return mt.create(t,e)}async function Ft(t){return ft.create(t)}const Nt="4.2.0";export{ct as CSVDataset,tt as Dataset,Et as FileDataSource,it as TextLineDataset,St as URLDataSource,rt as array,At as csv,Rt as func,Tt as generator,Ft as microphone,Nt as version_data,kt as webcam,st as zip};
import*as t from"@tensorflow/tfjs-core";import{util as e,env as r,tensor as s,tensor1d as n,tensor2d as i,browser as a,tidy as o,expandDims as u,cast as h,image as l,reshape as c}from"@tensorflow/tfjs-core";var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function m(t){if(t.__esModule)return t;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach((function(r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})})),e}function d(t){var e={exports:{}};return t(e,e.exports),e.exports}var p=d((function(t){!function(t,e,r){function s(t){var e,r=this,s=(e=4022871197,function(t){t=String(t);for(var r=0;r<t.length;r++){var s=.02519603282416938*(e+=t.charCodeAt(r));s-=e=s>>>0,e=(s*=e)>>>0,e+=4294967296*(s-=e)}return 2.3283064365386963e-10*(e>>>0)});r.next=function(){var t=2091639*r.s0+2.3283064365386963e-10*r.c;return r.s0=r.s1,r.s1=r.s2,r.s2=t-(r.c=0|t)},r.c=1,r.s0=s(" "),r.s1=s(" "),r.s2=s(" "),r.s0-=s(t),r.s0<0&&(r.s0+=1),r.s1-=s(t),r.s1<0&&(r.s1+=1),r.s2-=s(t),r.s2<0&&(r.s2+=1),s=null}function n(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e}function i(t,e){var r=new s(t),i=e&&e.state,a=r.next;return a.int32=function(){return 4294967296*r.next()|0},a.double=function(){return a()+11102230246251565e-32*(2097152*a()|0)},a.quick=a,i&&("object"==typeof i&&n(i,r),a.state=function(){return n(r,{})}),a}e&&e.exports?e.exports=i:r&&r.amd?r((function(){return i})):this.alea=i}(0,t,!1)})),w=d((function(t){!function(t,e,r){function s(t){var e=this,r="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8},t===(0|t)?e.x=t:r+=t;for(var s=0;s<r.length+64;s++)e.x^=0|r.charCodeAt(s),e.next()}function n(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e}function i(t,e){var r=new s(t),i=e&&e.state,a=function(){return(r.next()>>>0)/4294967296};return a.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},a.int32=r.next,a.quick=a,i&&("object"==typeof i&&n(i,r),a.state=function(){return n(r,{})}),a}e&&e.exports?e.exports=i:r&&r.amd?r((function(){return i})):this.xor128=i}(0,t,!1)})),y=d((function(t){!function(t,e,r){function s(t){var e=this,r="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:r+=t;for(var s=0;s<r.length+64;s++)e.x^=0|r.charCodeAt(s),s==r.length&&(e.d=e.x<<10^e.x>>>4),e.next()}function n(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e}function i(t,e){var r=new s(t),i=e&&e.state,a=function(){return(r.next()>>>0)/4294967296};return a.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},a.int32=r.next,a.quick=a,i&&("object"==typeof i&&n(i,r),a.state=function(){return n(r,{})}),a}e&&e.exports?e.exports=i:r&&r.amd?r((function(){return i})):this.xorwow=i}(0,t,!1)})),g=d((function(t){!function(t,e,r){function s(t){var e=this;e.next=function(){var t,r,s=e.x,n=e.i;return t=s[n],r=(t^=t>>>7)^t<<24,r^=(t=s[n+1&7])^t>>>10,r^=(t=s[n+3&7])^t>>>3,r^=(t=s[n+4&7])^t<<7,t=s[n+7&7],r^=(t^=t<<13)^t<<9,s[n]=r,e.i=n+1&7,r},function(t,e){var r,s=[];if(e===(0|e))s[0]=e;else for(e=""+e,r=0;r<e.length;++r)s[7&r]=s[7&r]<<15^e.charCodeAt(r)+s[r+1&7]<<13;for(;s.length<8;)s.push(0);for(r=0;r<8&&0===s[r];++r);for(8==r&&(s[7]=-1),t.x=s,t.i=0,r=256;r>0;--r)t.next()}(e,t)}function n(t,e){return e.x=t.x.slice(),e.i=t.i,e}function i(t,e){null==t&&(t=+new Date);var r=new s(t),i=e&&e.state,a=function(){return(r.next()>>>0)/4294967296};return a.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},a.int32=r.next,a.quick=a,i&&(i.x&&n(i,r),a.state=function(){return n(r,{})}),a}e&&e.exports?e.exports=i:r&&r.amd?r((function(){return i})):this.xorshift7=i}(0,t,!1)})),x=d((function(t){!function(t,e,r){function s(t){var e=this;e.next=function(){var t,r,s=e.w,n=e.X,i=e.i;return e.w=s=s+1640531527|0,r=n[i+34&127],t=n[i=i+1&127],r^=r<<13,t^=t<<17,r^=r>>>15,t^=t>>>12,r=n[i]=r^t,e.i=i,r+(s^s>>>16)|0},function(t,e){var r,s,n,i,a,o=[],u=128;for(e===(0|e)?(s=e,e=null):(e+="\0",s=0,u=Math.max(u,e.length)),n=0,i=-32;i<u;++i)e&&(s^=e.charCodeAt((i+32)%e.length)),0===i&&(a=s),s^=s<<10,s^=s>>>15,s^=s<<4,s^=s>>>13,i>=0&&(a=a+1640531527|0,n=0==(r=o[127&i]^=s+a)?n+1:0);for(n>=128&&(o[127&(e&&e.length||0)]=-1),n=127,i=512;i>0;--i)s=o[n+34&127],r=o[n=n+1&127],s^=s<<13,r^=r<<17,s^=s>>>15,r^=r>>>12,o[n]=s^r;t.w=a,t.X=o,t.i=n}(e,t)}function n(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e}function i(t,e){null==t&&(t=+new Date);var r=new s(t),i=e&&e.state,a=function(){return(r.next()>>>0)/4294967296};return a.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},a.int32=r.next,a.quick=a,i&&(i.X&&n(i,r),a.state=function(){return n(r,{})}),a}e&&e.exports?e.exports=i:r&&r.amd?r((function(){return i})):this.xor4096=i}(0,t,!1)})),v=d((function(t){!function(t,e,r){function s(t){var e=this,r="";e.next=function(){var t=e.b,r=e.c,s=e.d,n=e.a;return t=t<<25^t>>>7^r,r=r-s|0,s=s<<24^s>>>8^n,n=n-t|0,e.b=t=t<<20^t>>>12^r,e.c=r=r-s|0,e.d=s<<16^r>>>16^n,e.a=n-t|0},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):r+=t;for(var s=0;s<r.length+20;s++)e.b^=0|r.charCodeAt(s),e.next()}function n(t,e){return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e}function i(t,e){var r=new s(t),i=e&&e.state,a=function(){return(r.next()>>>0)/4294967296};return a.double=function(){do{var t=((r.next()>>>11)+(r.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},a.int32=r.next,a.quick=a,i&&("object"==typeof i&&n(i,r),a.state=function(){return n(r,{})}),a}e&&e.exports?e.exports=i:r&&r.amd?r((function(){return i})):this.tychei=i}(0,t,!1)})),b=m({__proto__:null,default:{}}),C=d((function(t){!function(e,r,s){var n,i=256,a=s.pow(i,6),o=s.pow(2,52),u=2*o,h=255;function l(t,h,l){var w=[],y=d(m((h=1==h?{entropy:!0}:h||{}).entropy?[t,p(r)]:null==t?function(){try{var t;return n&&(t=n.randomBytes)?t=t(i):(t=new Uint8Array(i),(e.crypto||e.msCrypto).getRandomValues(t)),p(t)}catch(t){var s=e.navigator,a=s&&s.plugins;return[+new Date,e,a,e.screen,p(r)]}}():t,3),w),g=new c(w),x=function(){for(var t=g.g(6),e=a,r=0;t<o;)t=(t+r)*i,e*=i,r=g.g(1);for(;t>=u;)t/=2,e/=2,r>>>=1;return(t+r)/e};return x.int32=function(){return 0|g.g(4)},x.quick=function(){return g.g(4)/4294967296},x.double=x,d(p(g.S),r),(h.pass||l||function(t,e,r,n){return n&&(n.S&&f(n,g),t.state=function(){return f(g,{})}),r?(s.random=t,e):t})(x,y,"global"in h?h.global:this==s,h.state)}function c(t){var e,r=t.length,s=this,n=0,a=s.i=s.j=0,o=s.S=[];for(r||(t=[r++]);n<i;)o[n]=n++;for(n=0;n<i;n++)o[n]=o[a=h&a+t[n%r]+(e=o[n])],o[a]=e;(s.g=function(t){for(var e,r=0,n=s.i,a=s.j,o=s.S;t--;)e=o[n=h&n+1],r=r*i+o[h&(o[n]=o[a=h&a+e])+(o[a]=e)];return s.i=n,s.j=a,r})(i)}function f(t,e){return e.i=t.i,e.j=t.j,e.S=t.S.slice(),e}function m(t,e){var r,s=[],n=typeof t;if(e&&"object"==n)for(r in t)try{s.push(m(t[r],e-1))}catch(t){}return s.length?s:"string"==n?t:t+"\0"}function d(t,e){for(var r,s=t+"",n=0;n<s.length;)e[h&n]=h&(r^=19*e[h&n])+s.charCodeAt(n++);return p(e)}function p(t){return String.fromCharCode.apply(0,t)}if(d(s.random(),r),t.exports){t.exports=l;try{n=b}catch(t){}}else s.seedrandom=l}("undefined"!=typeof self?self:f,[],Math)}));C.alea=p,C.xor128=w,C.xorwow=y,C.xorshift7=g,C.xor4096=x,C.tychei=v;var z,E=C;function S(t,e,r=new Map,s=new Set){if(null==t)return null;if("function"==typeof Blob&&t instanceof Blob)return t.slice();if(s.has(t))throw new Error("Circular references are not supported.");if(r.has(t))return r.get(t);const n=e(t);if(n.recurse&&null!==n.value)throw new Error("A deep map function may not return both a value and recurse=true.");if(n.recurse){if(F(t)){const n=Array.isArray(t)?[]:{};s.add(t);for(const i in t){const a=S(t[i],e,r,s);n[i]=a}return s.delete(t),t.__proto__&&(n.__proto__=t.__proto__),n}throw new Error(`Can't recurse into non-iterable type: ${t}`)}return r.set(t,n.value),n.value}function A(t,e=T){return R(t,e)}function R(t,e,r=new Set){const s=t[0];if(r.has(s))throw new Error("Circular references are not supported.");const n=e(t);if(n.recurse&&null!==n.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(n.recurse){if(F(s)){const n=Array.isArray(s)?[]:{};r.add(s);for(const i in s){const s=R(t.map((t=>t[i])),e,r);n[i]=s}return r.delete(s),n}throw new Error(`Can't recurse into non-iterable type: ${s}`)}return n.value}function T(t){return null===t?null:F(t[0])?{value:null,recurse:!0}:{value:t,recurse:!1}}async function k(e,r){const s=new Map;S(e,r,s);for(const e of Array.from(s.keys())){const r=s.get(e);if(t.util.isPromise(r)){const t=await r;s.set(e,t)}}return S(e,r,s)}function F(e){let r=!1;if(t.env().get("IS_BROWSER"))r=e instanceof TextDecoder;else{const{StringDecoder:t}=require("string_decoder");r=e instanceof t}return null!=e&&!ArrayBuffer.isView(e)&&(Array.isArray(e)||"object"==typeof e&&!(e instanceof t.Tensor)&&!(e instanceof Promise)&&!r)}function N(t){return S(t,I)}function I(e){return e instanceof t.Tensor?{value:e.clone(),recurse:!1}:F(e)?{value:null,recurse:!0}:{value:e,recurse:!1}}class _{constructor(t){if(this.capacity=t,this.begin=0,this.end=0,null==t)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(t<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(t),this.doubledCapacity=2*t}wrap(t){for(;t<0;)t+=this.doubledCapacity;return t%this.doubledCapacity}get(t){if(t<0)throw new RangeError("Can't get item at a negative index.");return this.data[t%this.capacity]}set(t,e){if(t<0)throw new RangeError("Can't set item at a negative index.");this.data[t%this.capacity]=e}length(){let t=this.end-this.begin;return t<0&&(t=this.doubledCapacity+t),t}isFull(){return this.length()===this.capacity}isEmpty(){return 0===this.length()}push(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,t),this.end=this.wrap(this.end+1)}pushAll(t){for(const e of t)this.push(e)}pop(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);const t=this.get(this.end);return this.set(this.end,void 0),t}unshift(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,t)}shift(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");const t=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),t}shuffleExcise(t){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");const e=this.wrap(this.begin+t),r=this.get(e);return this.set(e,this.pop()),r}}class D extends _{constructor(){super(D.INITIAL_CAPACITY)}isFull(){return!1}push(t){super.isFull()&&this.expand(),super.push(t)}unshift(t){super.isFull()&&this.expand(),super.unshift(t)}expand(){const t=2*this.capacity,e=new Array(t),r=this.length();for(let t=0;t<r;t++)e[t]=this.get(this.wrap(this.begin+t));this.data=e,this.capacity=t,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=r}}function O(t){return new B(t)}function M(t){return new $(t)}D.INITIAL_CAPACITY=32;class j{async toArray(){const t=[];let e=await this.next();for(;!e.done;)t.push(e.value),e=await this.next();return t}async toArrayForTest(){const t=this.prefetch(100),e=[];let r=await t.next();for(;!r.done;)e.push(r.value),r=await t.next();return e}async resolveFully(){let t=await this.next();for(;!t.done;)t=await this.next()}async resolveWhile(t){let e=await this.next(),r=t(e.value);for(;!e.done&&r;)e=await this.next(),r=t(e.value)}handleErrors(t){return new U(this,t)}filter(t){return new W(this,t)}map(t){return new V(this,t)}mapAsync(t){return new Q(this,t)}serialMapAsync(t){return new Q(this,t).serial()}flatmap(t){return new G(this,t)}async forEachAsync(t){return this.map(t).resolveFully()}async serialForEach(t){return this.serialMapAsync(t).resolveWhile((t=>!0===t))}rowMajorBatch(t,e=!0){return new P(this,t,e)}columnMajorBatch(t,e=!0,r=T){return this.rowMajorBatch(t,e).map((t=>A(t,r)))}concatenate(t,e){return new Z(O([this,t]),e)}take(t){return t<0||null==t?this:new L(this,t)}skip(t){return t<0||null==t?this:new q(this,t)}prefetch(t){return new Y(this,t)}shuffle(t,e){return new K(this,t,e)}serial(){return new H(this)}}class B extends j{constructor(t){super(),this.items=t,this.trav=0}summary(){return`Array of ${this.items.length} items`}async next(){if(this.trav>=this.items.length)return{value:null,done:!0};const t=this.items[this.trav];return this.trav++,{value:N(t),done:!1}}}class $ extends j{constructor(t){super(),this.nextFn=t}summary(){return"Function call"}async next(){try{return this.nextFn()}catch(t){throw t.message=`Error thrown while iterating through a dataset: ${t.message}`,t}}}class H extends j{constructor(t){super(),this.upstream=t,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Serial`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){return this.upstream.next()}}class q extends j{constructor(t,e){super(),this.upstream=t,this.maxCount=e,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Skip`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;this.count++<this.maxCount;){const e=await this.upstream.next();if(e.done)return e;t.dispose(e.value)}return this.upstream.next()}}class L extends j{constructor(t,e){super(),this.upstream=t,this.maxCount=e,this.count=0}summary(){return`${this.upstream.summary()} -> Take`}async next(){return this.count++>=this.maxCount?{value:null,done:!0}:this.upstream.next()}}class P extends j{constructor(t,e,r=!0){super(),this.upstream=t,this.batchSize=e,this.enableSmallLastBatch=r,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> RowMajorBatch`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){const t=[];for(;t.length<this.batchSize;){const e=await this.upstream.next();if(e.done)return this.enableSmallLastBatch&&t.length>0?{value:t,done:!1}:{value:null,done:!0};t.push(e.value)}return{value:t,done:!1}}}class W extends j{constructor(t,e){super(),this.upstream=t,this.predicate=e,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> Filter`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;;){const e=await this.upstream.next();if(e.done||this.predicate(e.value))return e;t.dispose(e.value)}}}class V extends j{constructor(t,e){super(),this.upstream=t,this.transform=e}summary(){return`${this.upstream.summary()} -> Map`}async next(){const e=await this.upstream.next();if(e.done)return{value:null,done:!0};const r=t.tensor_util.getTensorsInContainer(e.value),s=this.transform(e.value),n=t.tensor_util.getTensorsInContainer(s);for(const e of r)t.tensor_util.isTensorInList(e,n)||e.dispose();return{value:s,done:!1}}}class U extends j{constructor(t,e){super(),this.upstream=t,this.handler=e,this.count=0,this.lastRead=Promise.resolve({value:null,done:!1})}summary(){return`${this.upstream.summary()} -> handleErrors`}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;;)try{return await this.upstream.next()}catch(t){if(!this.handler(t))return{value:null,done:!0}}}}class Q extends j{constructor(t,e){super(),this.upstream=t,this.transform=e}summary(){return`${this.upstream.summary()} -> AsyncMap`}async next(){const e=await this.upstream.next();if(e.done)return{value:null,done:!0};const r=t.tensor_util.getTensorsInContainer(e.value),s=await this.transform(e.value),n=t.tensor_util.getTensorsInContainer(s);for(const e of r)t.tensor_util.isTensorInList(e,n)||e.dispose();return{value:s,done:!1}}}class X extends j{constructor(){super(),this.outputQueue=new D,this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}async serialNext(){for(;0===this.outputQueue.length();)if(!await this.pump())return{value:null,done:!0};return{value:this.outputQueue.shift(),done:!1}}}class G extends X{constructor(t,e){super(),this.upstream=t,this.transform=e}summary(){return`${this.upstream.summary()} -> Flatmap`}async pump(){const e=await this.upstream.next();if(e.done)return!1;const r=t.tensor_util.getTensorsInContainer(e.value),s=this.transform(e.value),n=t.tensor_util.getTensorsInContainer(s);this.outputQueue.pushAll(s);for(const e of r)t.tensor_util.isTensorInList(e,n)||e.dispose();return!0}}class Z extends j{constructor(t,e){super(),this.baseErrorHandler=e,this.lastRead=null,this.iterator=null,this.moreIterators=t}summary(){return"TODO: fill in upstream of chained summaries -> Chained"}async next(){return this.lastRead=this.readFromChain(this.lastRead),this.lastRead}async readFromChain(t){if(await t,null==this.iterator){const t=await this.moreIterators.next();if(t.done)return{value:null,done:!0};this.iterator=t.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler))}const e=await this.iterator.next();return e.done?(this.iterator=null,this.readFromChain(t)):e}}!function(t){t[t.FAIL=0]="FAIL",t[t.SHORTEST=1]="SHORTEST",t[t.LONGEST=2]="LONGEST"}(z||(z={}));class J extends j{constructor(t,e=z.FAIL){super(),this.iterators=t,this.mismatchMode=e,this.count=0,this.currentPromise=null}summary(){return"{TODO: fill in upstream of zip summaries} -> Zip"}async nextState(t){await t;let e=0,r=0;const s=await k(this.iterators,(function(t){if(t instanceof j){return{value:t.next().then((t=>(e++,t.done&&r++,t.value))),recurse:!1}}return{value:null,recurse:!0}}));if(e===r)return{value:null,done:!0};if(r>0)switch(this.mismatchMode){case z.FAIL:throw new Error(`Zipped streams should have the same length. Mismatched at element ${this.count}.`);case z.SHORTEST:return{value:null,done:!0};case z.LONGEST:}return this.count++,{value:s,done:!1}}async next(){return this.currentPromise=this.nextState(this.currentPromise),this.currentPromise}}class Y extends j{constructor(t,e){super(),this.upstream=t,this.bufferSize=e,this.buffer=new _(e)}summary(){return`${this.upstream.summary()} -> Prefetch`}refill(){for(;!this.buffer.isFull();){const t=this.upstream.next();this.buffer.push(t)}}next(){return this.refill(),this.buffer.shift()}}class K extends Y{constructor(e,r,s){super(e,r),this.upstream=e,this.windowSize=r,this.upstreamExhausted=!1,this.random=E.alea(s||t.util.now().toString()),this.lastRead=Promise.resolve({value:null,done:!1})}async next(){return this.lastRead=this.lastRead.then((()=>this.serialNext())),this.lastRead}randomInt(t){return Math.floor(this.random()*t)}chooseIndex(){return this.randomInt(this.buffer.length())}async serialNext(){for(this.upstreamExhausted||this.refill();!this.buffer.isEmpty();){const t=this.chooseIndex(),e=await this.buffer.shuffleExcise(t);if(!e.done)return this.refill(),e;this.upstreamExhausted=!0}return{value:null,done:!0}}}class tt{constructor(){this.size=null}batch(e,r=!0){const s=this;let n;return t.util.assert(e>0,(()=>`batchSize needs to be positive, but it is\n ${e}`)),n=this.size===1/0||null==this.size?this.size:r?Math.ceil(this.size/e):Math.floor(this.size/e),et((async()=>(await s.iterator()).columnMajorBatch(e,r,nt)),n)}concatenate(t){const e=this;let r;return r=this.size===1/0||t.size===1/0?1/0:null!=this.size&&null!=t.size?this.size+t.size:null,et((async()=>(await e.iterator()).concatenate(await t.iterator())),r)}filter(e){const r=this;let s;return s=this.size===1/0?1/0:null,et((async()=>(await r.iterator()).filter((r=>t.tidy((()=>e(r)))))),s)}async forEachAsync(t){return(await this.iterator()).forEachAsync(t)}map(e){const r=this;return et((async()=>(await r.iterator()).map((r=>t.tidy((()=>e(r)))))),this.size)}mapAsync(t){const e=this;return et((async()=>(await e.iterator()).mapAsync(t)),this.size)}prefetch(t){if(null==t)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");const e=this;return et((async()=>(await e.iterator()).prefetch(t)),this.size)}repeat(t){const e=this;let r;return r=null!=this.size&&t>0?this.size*t:0===t?0:null!=this.size&&(void 0===t||t<0)?1/0:null,et((async()=>{const r=M((async()=>({value:await e.iterator(),done:!1})));return s=r.take(t),new Z(s,n);var s,n}),r)}skip(t){const e=this;let r;return r=null!=this.size&&t>=0&&this.size>=t?this.size-t:null!=this.size&&(this.size<t||void 0===t||t<0)?0:null,et((async()=>(await e.iterator()).skip(t)),r)}shuffle(e,r,s=!0){if(null==e||e<0)throw null==this.size?new RangeError("`Dataset.shuffle()` requires bufferSize to be specified."):new RangeError(`\`Dataset.shuffle()\` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for \`tf.Tensor\`s), consider setting bufferSize to the dataset size (${this.size} elements)`);const n=this,i=E.alea(r||t.util.now().toString());return et((async()=>{let t=i.int32();return s&&(t+=i.int32()),(await n.iterator()).shuffle(e,t.toString())}),this.size)}take(t){const e=this;let r;return r=null!=this.size&&this.size>t?t:null!=this.size&&this.size<=t?this.size:null,et((async()=>(await e.iterator()).take(t)),r)}async toArray(){if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArray()}async toArrayForTest(){if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return(await this.iterator()).toArrayForTest()}}function et(t,e=null){return new class extends tt{constructor(){super(...arguments),this.size=e}async iterator(){return t()}}}function rt(t){return et((async()=>O(t)),t.length)}function st(t){if(!F(t))throw new Error("The argument to zip() must be an object or array.");let e;if(Array.isArray(t))for(let r=0;r<t.length;r++)e=null==e?t[r].size:Math.min(e,t[r].size);else if(t instanceof Object)for(const r in t)e=null==e?t[r].size:Math.min(e,t[r].size);return et((async()=>function(t,e=z.FAIL){return new J(t,e)}(await k(t,(t=>{if(t instanceof tt)return{value:t.iterator(),recurse:!1};if(F(t))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")})),z.SHORTEST)),e)}function nt(e){if(null===e)return null;const r=e[0];if(null==(s=r)||null===(n=s)||"object"!=typeof n&&"function"!=typeof n||Array.isArray(s)||"object"==typeof s&&s instanceof t.Tensor||t.util.isTypedArray(s)){return{value:function(e){if(0===e.length)throw new Error("Can't make a batch of zero elements.");return e[0]instanceof t.Tensor?t.stack(e):t.tensor(e)}(e),recurse:!1}}var s,n;return{value:null,recurse:!0}}tt.MAX_BUFFER_SIZE=1e4;class it extends tt{constructor(t){super(),this.input=t}async iterator(){return(await this.input.iterator()).decodeUTF8().split("\n").map((t=>(t.endsWith("\r")&&(t=t.slice(0,-1)),t)))}}const at=Symbol("out"),ot=Symbol("field"),ut=Symbol("quote"),ht=Symbol("quoteafterquote"),lt=Symbol("quoteinquote");class ct extends tt{async columnNames(){return this.columnNamesValidated||await this.setColumnNames(),this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames}async setColumnNames(){const t=await this.maybeReadHeaderLine();if(!this.fullColumnNames&&!t)throw new Error("Column names must be provided if there is no header line.");this.fullColumnNames&&t&&e.assert(t.length===this.fullColumnNames.length,(()=>"The length of provided columnNames ("+this.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+t.length.toString()+").")),this.fullColumnNames||(this.fullColumnNames=t);const r=this.fullColumnNames.reduce(((t,e)=>(t[e]=t[e]+1||1,t)),{}),s=Object.keys(r).filter((t=>r[t]>1));if(e.assert(0===s.length,(()=>"Duplicate column names found: "+s.toString())),this.columnConfigs)for(const t of Object.keys(this.columnConfigs)){if(-1===this.fullColumnNames.indexOf(t))throw new Error('The key "'+t+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").")}this.columnNamesValidated=!0}async maybeReadHeaderLine(){if(this.hasHeader){const t=await this.base.iterator(),e=await t.next();if(e.done)throw new Error("No data was found for CSV parsing.");const r=e.value;return this.parseRow(r,!1)}return null}constructor(t,r){super(),this.input=t,this.hasHeader=!0,this.fullColumnNames=null,this.columnNamesValidated=!1,this.columnConfigs=null,this.configuredColumnsOnly=!1,this.delimiter=",",this.delimWhitespace=!1,this.base=new it(t),r||(r={}),this.hasHeader=!1!==r.hasHeader,this.fullColumnNames=r.columnNames,this.columnConfigs=r.columnConfigs,this.configuredColumnsOnly=r.configuredColumnsOnly,r.delimWhitespace?(e.assert(null==r.delimiter,(()=>"Delimiter should not be provided when delimWhitespace is true.")),this.delimWhitespace=!0,this.delimiter=" "):this.delimiter=r.delimiter?r.delimiter:","}async iterator(){this.columnNamesValidated||await this.setColumnNames();let t=await this.base.iterator();return this.hasHeader&&(t=t.skip(1)),t.map((t=>this.makeDataElement(t)))}makeDataElement(t){const e=this.parseRow(t),r={},s={};for(let n=0;n<this.fullColumnNames.length;n++){const i=this.fullColumnNames[n],a=this.columnConfigs?this.columnConfigs[i]:null;if(!this.configuredColumnsOnly||a){const o=e[n];let u=null;if(""===o)if(a&&void 0!==a.default)u=a.default;else{if(a&&(a.required||a.isLabel))throw new Error(`Required column ${i} is empty in this line: ${t}`);u=void 0}else{const t=Number(o);if(isNaN(t))u=a&&"bool"===a.dtype?this.getBoolean(o):o;else if(a&&a.dtype)switch(a.dtype){case"float32":default:u=t;break;case"int32":u=Math.floor(t);break;case"bool":u=this.getBoolean(o)}else u=t}a&&a.isLabel?s[i]=u:r[i]=u}}return 0===Object.keys(s).length?r:{xs:r,ys:s}}getBoolean(t){return"1"===t||"true"===t.toLowerCase()?1:0}parseRow(t,e=!0){const r=[];let s=0;const n=t.length;let i=at;for(let e=0;e<n;e++)switch(i){case at:switch(t.charAt(e)){case'"':s=e+1,i=ut;break;case this.delimiter:if(s=e+1," "===this.delimiter&&this.delimWhitespace)break;r.push(""),i=at;break;default:i=ot,s=e}break;case ot:if(t.charAt(e)===this.delimiter)r.push(t.substring(s,e)),i=at,s=e+1;break;case ut:if('"'===t.charAt(e))i=ht;break;case ht:switch(t.charAt(e)){case this.delimiter:r.push(t.substring(s,e-1)),i=at,s=e+1;break;case'"':i=ut;break;default:i=lt}break;case lt:if('"'===t.charAt(e))i=ut}if(i===ht?r.push(t.substring(s,n-1)):r.push(t.substring(s)),e&&r.length!==this.fullColumnNames.length)throw new Error(`Invalid row in csv file. Should have ${this.fullColumnNames.length} elements in a row, but got ${r}`);return r}}class ft extends j{constructor(t){super(),this.microphoneConfig=t,this.isClosed=!1,this.fftSize=t.fftSize||1024;const e=Math.log2(this.fftSize);if(this.fftSize<0||e<4||e>14||!Number.isInteger(e))throw new Error(`Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got ${this.fftSize}`);if(this.numFrames=t.numFramesPerSpectrogram||43,this.sampleRateHz=t.sampleRateHz,this.columnTruncateLength=t.columnTruncateLength||this.fftSize,this.audioTrackConstraints=t.audioTrackConstraints,this.smoothingTimeConstant=t.smoothingTimeConstant||0,this.includeSpectrogram=!1!==t.includeSpectrogram,this.includeWaveform=!0===t.includeWaveform,!this.includeSpectrogram&&!this.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.")}summary(){return"microphone"}static async create(t={}){if(!r().get("IS_BROWSER"))throw new Error("microphone API is only supported in browser environment.");const e=new ft(t);return await e.start(),e}async start(){try{this.stream=await navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1})}catch(t){throw new Error(`Error thrown while initializing video stream: ${t.message}`)}if(!this.stream)throw new Error("Could not obtain audio from microphone.");const t=window.AudioContext||window.webkitAudioContext;if(this.audioContext=new t,this.sampleRateHz){if(this.audioContext.sampleRate!==this.sampleRateHz)throw new Error(`Mismatch in sampling rate: Expected: ${this.sampleRateHz}; Actual: ${this.audioContext.sampleRate}`)}else this.sampleRateHz=this.audioContext.sampleRate;const e=this.audioContext.createMediaStreamSource(this.stream);this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,e.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize)}async next(){if(this.isClosed)return{value:null,done:!0};let t,e;const r=await this.getAudioData();if(this.includeSpectrogram){const e=this.flattenQueue(r.freqDataQueue);t=this.getTensorFromAudioDataArray(e,[this.numFrames,this.columnTruncateLength,1])}if(this.includeWaveform){const t=this.flattenQueue(r.timeDataQueue);e=this.getTensorFromAudioDataArray(t,[this.numFrames*this.fftSize,1])}return{value:{spectrogram:t,waveform:e},done:!1}}async capture(){return(await this.next()).value}async getAudioData(){const t=[],e=[];let r=0;return new Promise((s=>{const n=setInterval((()=>{this.includeSpectrogram&&(this.analyser.getFloatFrequencyData(this.freqData),this.freqData[0]===-1/0&&s({freqDataQueue:t,timeDataQueue:e}),t.push(this.freqData.slice(0,this.columnTruncateLength))),this.includeWaveform&&(this.analyser.getFloatTimeDomainData(this.timeData),e.push(this.timeData.slice())),++r===this.numFrames&&(clearInterval(n),s({freqDataQueue:t,timeDataQueue:e}))}),this.fftSize/this.sampleRateHz*1e3)}))}stop(){this.isClosed||(this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop())}toArray(){throw new Error("Can not convert infinite audio stream to array.")}getSampleRate(){return this.sampleRateHz}flattenQueue(t){const e=t[0].length,r=new Float32Array(t.length*e);return t.forEach(((t,s)=>r.set(t,s*e))),r}getTensorFromAudioDataArray(t,r){const n=new Float32Array(e.sizeFromShape(r));return n.set(t,n.length-t.length),s(n,r)}}class mt extends j{constructor(t,e){if(super(),this.webcamVideoElement=t,this.webcamConfig=e,this.isClosed=!0,this.resize=!1,this.needToResize())if(this.resize=!0,this.cropSize=[this.webcamConfig.resizeHeight,this.webcamConfig.resizeWidth],this.cropBoxInd=n([0],"int32"),this.webcamConfig.centerCrop){const t=1*this.webcamConfig.resizeWidth/this.webcamVideoElement.width,e=1*this.webcamConfig.resizeHeight/this.webcamVideoElement.height,r=(1-t)/2,s=(1-e)/2,n=r+t,a=e+s;this.cropBox=i([s,r,a,n],[1,4])}else this.cropBox=i([0,0,1,1],[1,4])}summary(){return"webcam"}static async create(t,e={}){if(!r().get("IS_BROWSER"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!t){if(t=document.createElement("video"),!e.resizeWidth||!e.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");t.width=e.resizeWidth,t.height=e.resizeHeight}const s=new mt(t,e);return await s.start(),s}async start(){this.webcamConfig.facingMode&&e.assert("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,(()=>`Invalid webcam facing mode: ${this.webcamConfig.facingMode}. Please provide 'user' or 'environment'`));try{this.stream=await navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})}catch(t){throw t.message=`Error thrown while initializing video stream: ${t.message}`,t}if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(t){console.log(t),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,new Promise((t=>{this.webcamVideoElement.onloadedmetadata=()=>{t()}}))}async next(){if(this.isClosed)return{value:null,done:!0};let t;try{t=a.fromPixels(this.webcamVideoElement)}catch(t){throw new Error(`Error thrown converting video to pixels: ${JSON.stringify(t)}`)}if(!this.resize)return{value:t,done:!1};try{return{value:this.cropAndResizeFrame(t),done:!1}}catch(t){throw new Error(`Error thrown cropping the video: ${t.message}`)}finally{t.dispose()}}needToResize(){return!(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight)}cropAndResizeFrame(t){return o((()=>{const e=u(h(t,"float32"),0);let r;r=l.cropAndResize(e,this.cropBox,this.cropBoxInd,this.cropSize,"bilinear");const s=r.shape;return c(r,s.slice(1))}))}async capture(){return(await this.next()).value}stop(){this.stream.getTracks().forEach((t=>t.stop()));try{this.webcamVideoElement.srcObject=null}catch(t){console.log(t),this.webcamVideoElement.src=null}this.isClosed=!0}toArray(){throw new Error("Can not convert infinite video stream to array.")}}class dt{}class pt extends j{split(t){return new wt(this,t)}}class wt extends pt{constructor(t,e){super(),this.upstream=t,this.impl=new yt(t,e)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class yt extends X{constructor(t,e){super(),this.upstream=t,this.separator=e,this.carryover=""}summary(){return`${this.upstream.summary()} -> Split('${this.separator}')`}async pump(){const t=await this.upstream.next();if(t.done)return""!==this.carryover&&(this.outputQueue.push(this.carryover),this.carryover="",!0);const e=t.value.split(this.separator);e[0]=this.carryover+e[0];for(const t of e.slice(0,-1))this.outputQueue.push(t);return this.carryover=e[e.length-1],!0}}class gt extends j{decodeUTF8(){return new xt(this)}}class xt extends pt{constructor(t){super(),this.upstream=t,this.impl=new vt(t)}summary(){return this.impl.summary()}async next(){return this.impl.next()}}class vt extends X{constructor(t){if(super(),this.upstream=t,r().get("IS_BROWSER"))this.decoder=new TextDecoder("utf-8");else{const{StringDecoder:t}=require("string_decoder");this.decoder=new t("utf8")}}summary(){return`${this.upstream.summary()} -> Utf8`}async pump(){const t=await this.upstream.next();let e,s;return!t.done&&(e=t.value,s=r().get("IS_BROWSER")?this.decoder.decode(e,{stream:!0}):this.decoder.write(Buffer.from(e.buffer)),this.outputQueue.push(s),!0)}}class bt extends gt{constructor(t,s={}){super(),this.file=t,this.options=s,e.assert(t instanceof Uint8Array||!!r().get("IS_BROWSER")&&(t instanceof File||t instanceof Blob),(()=>"FileChunkIterator only supports File, Blob and Uint8Array right now.")),this.offset=s.offset||0,this.chunkSize=s.chunkSize||1048576}summary(){return`FileChunks ${this.file}`}async next(){if(this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size))return{value:null,done:!0};const t=new Promise(((t,e)=>{const r=this.offset+this.chunkSize;if(this.file instanceof Uint8Array)t(new Uint8Array(this.file.slice(this.offset,r)));else{const s=new FileReader;s.onload=r=>{let n=s.result;if(n instanceof ArrayBuffer&&(n=new Uint8Array(n)),!(n instanceof Uint8Array))return e(new TypeError("FileReader returned unknown type."));t(n)},s.onabort=t=>e(new Error("Aborted")),s.onerror=t=>e(new Error(t.type));const n=this.file.slice(this.offset,r);s.readAsArrayBuffer(n)}this.offset=r}));return{value:await t,done:!1}}}const Ct=t=>({method:t.method,headers:t.headers,body:t.body,mode:t.mode,credentials:t.credentials,cache:t.cache,redirect:t.redirect,referrer:t.referrer,integrity:t.integrity});function zt(t){return"string"==typeof t&&"file://"===t.slice(0,7)}class Et extends dt{constructor(t,e={}){super(),this.input=t,this.options=e}async iterator(){if(zt(this.input)&&r().get("IS_NODE")){const t=require("fs");this.input=t.readFileSync(this.input.slice(7))}return new bt(this.input,this.options)}}class St extends dt{constructor(t,e={}){super(),this.url=t,this.fileOptions=e}async iterator(){return zt(this.url)?new Et(this.url,this.fileOptions).iterator():async function(t,r={},s){let n,i;"string"==typeof t?n=t:(n=t.url,i=Ct(t));const a=await(s||e.fetch)(n,i);if(a.ok){const t=new Uint8Array(await a.arrayBuffer());return new bt(t,r)}throw new Error(a.statusText)}(this.url,this.fileOptions)}}function At(t,e={}){return new ct(new St(t),e)}function Rt(t){const e=M(t);return et((async()=>e))}function Tt(t){return et((async()=>{const e=await t();return M((()=>e.next()))}))}async function kt(t,e){return mt.create(t,e)}async function Ft(t){return ft.create(t)}const Nt="4.3.0";export{ct as CSVDataset,tt as Dataset,Et as FileDataSource,it as TextLineDataset,St as URLDataSource,rt as array,At as csv,Rt as func,Tt as generator,Ft as microphone,Nt as version_data,kt as webcam,st as zip};
//# sourceMappingURL=tf-data.fesm.min.js.map

@@ -17,3 +17,3 @@ /**

*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@tensorflow/tfjs-core")):"function"==typeof define&&define.amd?define(["exports","@tensorflow/tfjs-core"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).tf=t.tf||{},t.tf)}(this,(function(t,e){"use strict";function n(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,e}var r=n(e),i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},i(t,e)};function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function u(t,e,n,r){return new(n||(n=Promise))((function(i,o){function u(t){try{a(r.next(t))}catch(t){o(t)}}function s(t){try{a(r.throw(t))}catch(t){o(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,s)}a((r=r.apply(t,e||[])).next())}))}function s(t,e){var n,r,i,o,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,r=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(!(i=u.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){u=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){u.label=o[1];break}if(6===o[0]&&u.label<i[1]){u.label=i[1],i=o;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(o);break}i[2]&&u.ops.pop(),u.trys.pop();continue}o=e.call(t,u)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function a(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)u.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return u}function l(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function h(t){if(t.__esModule)return t;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach((function(n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})})),e}function d(t){var e={exports:{}};return t(e,e.exports),e.exports}var p=d((function(t){!function(t,e,n){function r(t){var e,n=this,r=(e=4022871197,function(t){t=String(t);for(var n=0;n<t.length;n++){var r=.02519603282416938*(e+=t.charCodeAt(n));r-=e=r>>>0,e=(r*=e)>>>0,e+=4294967296*(r-=e)}return 2.3283064365386963e-10*(e>>>0)});n.next=function(){var t=2091639*n.s0+2.3283064365386963e-10*n.c;return n.s0=n.s1,n.s1=n.s2,n.s2=t-(n.c=0|t)},n.c=1,n.s0=r(" "),n.s1=r(" "),n.s2=r(" "),n.s0-=r(t),n.s0<0&&(n.s0+=1),n.s1-=r(t),n.s1<0&&(n.s1+=1),n.s2-=r(t),n.s2<0&&(n.s2+=1),r=null}function i(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e}function o(t,e){var n=new r(t),o=e&&e.state,u=n.next;return u.int32=function(){return 4294967296*n.next()|0},u.double=function(){return u()+11102230246251565e-32*(2097152*u()|0)},u.quick=u,o&&("object"==typeof o&&i(o,n),u.state=function(){return i(n,{})}),u}e&&e.exports?e.exports=o:n&&n.amd?n((function(){return o})):this.alea=o}(0,t,!1)})),v=d((function(t){!function(t,e,n){function r(t){var e=this,n="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8},t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++)e.x^=0|n.charCodeAt(r),e.next()}function i(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e}function o(t,e){var n=new r(t),o=e&&e.state,u=function(){return(n.next()>>>0)/4294967296};return u.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},u.int32=n.next,u.quick=u,o&&("object"==typeof o&&i(o,n),u.state=function(){return i(n,{})}),u}e&&e.exports?e.exports=o:n&&n.amd?n((function(){return o})):this.xor128=o}(0,t,!1)})),m=d((function(t){!function(t,e,n){function r(t){var e=this,n="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++)e.x^=0|n.charCodeAt(r),r==n.length&&(e.d=e.x<<10^e.x>>>4),e.next()}function i(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e}function o(t,e){var n=new r(t),o=e&&e.state,u=function(){return(n.next()>>>0)/4294967296};return u.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},u.int32=n.next,u.quick=u,o&&("object"==typeof o&&i(o,n),u.state=function(){return i(n,{})}),u}e&&e.exports?e.exports=o:n&&n.amd?n((function(){return o})):this.xorwow=o}(0,t,!1)})),y=d((function(t){!function(t,e,n){function r(t){var e=this;e.next=function(){var t,n,r=e.x,i=e.i;return t=r[i],n=(t^=t>>>7)^t<<24,n^=(t=r[i+1&7])^t>>>10,n^=(t=r[i+3&7])^t>>>3,n^=(t=r[i+4&7])^t<<7,t=r[i+7&7],n^=(t^=t<<13)^t<<9,r[i]=n,e.i=i+1&7,n},function(t,e){var n,r=[];if(e===(0|e))r[0]=e;else for(e=""+e,n=0;n<e.length;++n)r[7&n]=r[7&n]<<15^e.charCodeAt(n)+r[n+1&7]<<13;for(;r.length<8;)r.push(0);for(n=0;n<8&&0===r[n];++n);for(8==n&&(r[7]=-1),t.x=r,t.i=0,n=256;n>0;--n)t.next()}(e,t)}function i(t,e){return e.x=t.x.slice(),e.i=t.i,e}function o(t,e){null==t&&(t=+new Date);var n=new r(t),o=e&&e.state,u=function(){return(n.next()>>>0)/4294967296};return u.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},u.int32=n.next,u.quick=u,o&&(o.x&&i(o,n),u.state=function(){return i(n,{})}),u}e&&e.exports?e.exports=o:n&&n.amd?n((function(){return o})):this.xorshift7=o}(0,t,!1)})),w=d((function(t){!function(t,e,n){function r(t){var e=this;e.next=function(){var t,n,r=e.w,i=e.X,o=e.i;return e.w=r=r+1640531527|0,n=i[o+34&127],t=i[o=o+1&127],n^=n<<13,t^=t<<17,n^=n>>>15,t^=t>>>12,n=i[o]=n^t,e.i=o,n+(r^r>>>16)|0},function(t,e){var n,r,i,o,u,s=[],a=128;for(e===(0|e)?(r=e,e=null):(e+="\0",r=0,a=Math.max(a,e.length)),i=0,o=-32;o<a;++o)e&&(r^=e.charCodeAt((o+32)%e.length)),0===o&&(u=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,o>=0&&(u=u+1640531527|0,i=0==(n=s[127&o]^=r+u)?i+1:0);for(i>=128&&(s[127&(e&&e.length||0)]=-1),i=127,o=512;o>0;--o)r=s[i+34&127],n=s[i=i+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,s[i]=r^n;t.w=u,t.X=s,t.i=i}(e,t)}function i(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e}function o(t,e){null==t&&(t=+new Date);var n=new r(t),o=e&&e.state,u=function(){return(n.next()>>>0)/4294967296};return u.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},u.int32=n.next,u.quick=u,o&&(o.X&&i(o,n),u.state=function(){return i(n,{})}),u}e&&e.exports?e.exports=o:n&&n.amd?n((function(){return o})):this.xor4096=o}(0,t,!1)})),b=d((function(t){!function(t,e,n){function r(t){var e=this,n="";e.next=function(){var t=e.b,n=e.c,r=e.d,i=e.a;return t=t<<25^t>>>7^n,n=n-r|0,r=r<<24^r>>>8^i,i=i-t|0,e.b=t=t<<20^t>>>12^n,e.c=n=n-r|0,e.d=r<<16^n>>>16^i,e.a=i-t|0},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):n+=t;for(var r=0;r<n.length+20;r++)e.b^=0|n.charCodeAt(r),e.next()}function i(t,e){return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e}function o(t,e){var n=new r(t),o=e&&e.state,u=function(){return(n.next()>>>0)/4294967296};return u.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},u.int32=n.next,u.quick=u,o&&("object"==typeof o&&i(o,n),u.state=function(){return i(n,{})}),u}e&&e.exports?e.exports=o:n&&n.amd?n((function(){return o})):this.tychei=o}(0,t,!1)})),g=h({__proto__:null,default:{}}),x=d((function(t){!function(e,n,r){var i,o=256,u=r.pow(o,6),s=r.pow(2,52),a=2*s,c=255;function l(t,c,l){var m=[],y=p(d((c=1==c?{entropy:!0}:c||{}).entropy?[t,v(n)]:null==t?function(){try{var t;return i&&(t=i.randomBytes)?t=t(o):(t=new Uint8Array(o),(e.crypto||e.msCrypto).getRandomValues(t)),v(t)}catch(t){var r=e.navigator,u=r&&r.plugins;return[+new Date,e,u,e.screen,v(n)]}}():t,3),m),w=new f(m),b=function(){for(var t=w.g(6),e=u,n=0;t<s;)t=(t+n)*o,e*=o,n=w.g(1);for(;t>=a;)t/=2,e/=2,n>>>=1;return(t+n)/e};return b.int32=function(){return 0|w.g(4)},b.quick=function(){return w.g(4)/4294967296},b.double=b,p(v(w.S),n),(c.pass||l||function(t,e,n,i){return i&&(i.S&&h(i,w),t.state=function(){return h(w,{})}),n?(r.random=t,e):t})(b,y,"global"in c?c.global:this==r,c.state)}function f(t){var e,n=t.length,r=this,i=0,u=r.i=r.j=0,s=r.S=[];for(n||(t=[n++]);i<o;)s[i]=i++;for(i=0;i<o;i++)s[i]=s[u=c&u+t[i%n]+(e=s[i])],s[u]=e;(r.g=function(t){for(var e,n=0,i=r.i,u=r.j,s=r.S;t--;)e=s[i=c&i+1],n=n*o+s[c&(s[i]=s[u=c&u+e])+(s[u]=e)];return r.i=i,r.j=u,n})(o)}function h(t,e){return e.i=t.i,e.j=t.j,e.S=t.S.slice(),e}function d(t,e){var n,r=[],i=typeof t;if(e&&"object"==i)for(n in t)try{r.push(d(t[n],e-1))}catch(t){}return r.length?r:"string"==i?t:t+"\0"}function p(t,e){for(var n,r=t+"",i=0;i<r.length;)e[c&i]=c&(n^=19*e[c&i])+r.charCodeAt(i++);return v(e)}function v(t){return String.fromCharCode.apply(0,t)}if(p(r.random(),n),t.exports){t.exports=l;try{i=g}catch(t){}}else r.seedrandom=l}("undefined"!=typeof self?self:f,[],Math)}));x.alea=p,x.xor128=v,x.xorwow=m,x.xorshift7=y,x.xor4096=w,x.tychei=b;var C=x;function z(t,e,n,r){if(void 0===n&&(n=new Map),void 0===r&&(r=new Set),null==t)return null;if("function"==typeof Blob&&t instanceof Blob)return t.slice();if(r.has(t))throw new Error("Circular references are not supported.");if(n.has(t))return n.get(t);var i=e(t);if(i.recurse&&null!==i.value)throw new Error("A deep map function may not return both a value and recurse=true.");if(i.recurse){if(T(t)){var o=Array.isArray(t)?[]:{};for(var u in r.add(t),t){var s=z(t[u],e,n,r);o[u]=s}return r.delete(t),t.__proto__&&(o.__proto__=t.__proto__),o}throw new Error("Can't recurse into non-iterable type: ".concat(t))}return n.set(t,i.value),i.value}function E(t,e){return void 0===e&&(e=A),S(t,e)}function S(t,e,n){void 0===n&&(n=new Set);var r=t[0];if(n.has(r))throw new Error("Circular references are not supported.");var i=e(t);if(i.recurse&&null!==i.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(i.recurse){if(T(r)){var o=Array.isArray(r)?[]:{};n.add(r);var u=function(r){var i=S(t.map((function(t){return t[r]})),e,n);o[r]=i};for(var s in r)u(s);return n.delete(r),o}throw new Error("Can't recurse into non-iterable type: ".concat(r))}return i.value}function A(t){return null===t?null:T(t[0])?{value:null,recurse:!0}:{value:t,recurse:!1}}function R(t,e){return u(this,void 0,void 0,(function(){var n,i,o,u,c,l,f,h,d;return s(this,(function(s){switch(s.label){case 0:n=new Map,z(t,e,n),s.label=1;case 1:s.trys.push([1,6,7,8]),i=a(Array.from(n.keys())),o=i.next(),s.label=2;case 2:return o.done?[3,5]:(u=o.value,c=n.get(u),r.util.isPromise(c)?[4,c]:[3,4]);case 3:l=s.sent(),n.set(u,l),s.label=4;case 4:return o=i.next(),[3,2];case 5:return[3,8];case 6:return f=s.sent(),h={error:f},[3,8];case 7:try{o&&!o.done&&(d=i.return)&&d.call(i)}finally{if(h)throw h.error}return[7];case 8:return[2,z(t,e,n)]}}))}))}function T(t){var e=!1;r.env().get("IS_BROWSER")?e=t instanceof TextDecoder:e=t instanceof require("string_decoder").StringDecoder;return null!=t&&!ArrayBuffer.isView(t)&&(Array.isArray(t)||"object"==typeof t&&!(t instanceof r.Tensor)&&!(t instanceof Promise)&&!e)}function k(t){return z(t,F)}function F(t){return t instanceof r.Tensor?{value:t.clone(),recurse:!1}:T(t)?{value:null,recurse:!0}:{value:t,recurse:!1}}var _=function(){function t(t){if(this.capacity=t,this.begin=0,this.end=0,null==t)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(t<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(t),this.doubledCapacity=2*t}return t.prototype.wrap=function(t){for(;t<0;)t+=this.doubledCapacity;return t%this.doubledCapacity},t.prototype.get=function(t){if(t<0)throw new RangeError("Can't get item at a negative index.");return this.data[t%this.capacity]},t.prototype.set=function(t,e){if(t<0)throw new RangeError("Can't set item at a negative index.");this.data[t%this.capacity]=e},t.prototype.length=function(){var t=this.end-this.begin;return t<0&&(t=this.doubledCapacity+t),t},t.prototype.isFull=function(){return this.length()===this.capacity},t.prototype.isEmpty=function(){return 0===this.length()},t.prototype.push=function(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,t),this.end=this.wrap(this.end+1)},t.prototype.pushAll=function(t){var e,n;try{for(var r=a(t),i=r.next();!i.done;i=r.next()){var o=i.value;this.push(o)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}},t.prototype.pop=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);var t=this.get(this.end);return this.set(this.end,void 0),t},t.prototype.unshift=function(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,t)},t.prototype.shift=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var t=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),t},t.prototype.shuffleExcise=function(t){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var e=this.wrap(this.begin+t),n=this.get(e);return this.set(e,this.pop()),n},t}(),O=function(t){function e(){return t.call(this,e.INITIAL_CAPACITY)||this}return o(e,t),e.prototype.isFull=function(){return!1},e.prototype.push=function(e){t.prototype.isFull.call(this)&&this.expand(),t.prototype.push.call(this,e)},e.prototype.unshift=function(e){t.prototype.isFull.call(this)&&this.expand(),t.prototype.unshift.call(this,e)},e.prototype.expand=function(){for(var t=2*this.capacity,e=new Array(t),n=this.length(),r=0;r<n;r++)e[r]=this.get(this.wrap(this.begin+r));this.data=e,this.capacity=t,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=n},e}(_);function N(t){return new M(t)}function D(t){return new P(t)}O.INITIAL_CAPACITY=32;var I,j=function(){function t(){}return t.prototype.toArray=function(){return u(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t=[],[4,this.next()];case 1:e=n.sent(),n.label=2;case 2:return e.done?[3,4]:(t.push(e.value),[4,this.next()]);case 3:return e=n.sent(),[3,2];case 4:return[2,t]}}))}))},t.prototype.toArrayForTest=function(){return u(this,void 0,void 0,(function(){var t,e,n;return s(this,(function(r){switch(r.label){case 0:return t=this.prefetch(100),e=[],[4,t.next()];case 1:n=r.sent(),r.label=2;case 2:return n.done?[3,4]:(e.push(n.value),[4,t.next()]);case 3:return n=r.sent(),[3,2];case 4:return[2,e]}}))}))},t.prototype.resolveFully=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return[4,this.next()];case 1:t=e.sent(),e.label=2;case 2:return t.done?[3,4]:[4,this.next()];case 3:return t=e.sent(),[3,2];case 4:return[2]}}))}))},t.prototype.resolveWhile=function(t){return u(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){switch(r.label){case 0:return[4,this.next()];case 1:e=r.sent(),n=t(e.value),r.label=2;case 2:return e.done||!n?[3,4]:[4,this.next()];case 3:return e=r.sent(),n=t(e.value),[3,2];case 4:return[2]}}))}))},t.prototype.handleErrors=function(t){return new U(this,t)},t.prototype.filter=function(t){return new W(this,t)},t.prototype.map=function(t){return new V(this,t)},t.prototype.mapAsync=function(t){return new Q(this,t)},t.prototype.serialMapAsync=function(t){return new Q(this,t).serial()},t.prototype.flatmap=function(t){return new G(this,t)},t.prototype.forEachAsync=function(t){return u(this,void 0,void 0,(function(){return s(this,(function(e){return[2,this.map(t).resolveFully()]}))}))},t.prototype.serialForEach=function(t){return u(this,void 0,void 0,(function(){return s(this,(function(e){return[2,this.serialMapAsync(t).resolveWhile((function(t){return!0===t}))]}))}))},t.prototype.rowMajorBatch=function(t,e){return void 0===e&&(e=!0),new H(this,t,e)},t.prototype.columnMajorBatch=function(t,e,n){return void 0===e&&(e=!0),void 0===n&&(n=A),this.rowMajorBatch(t,e).map((function(t){return E(t,n)}))},t.prototype.concatenate=function(t,e){return new Z(N([this,t]),e)},t.prototype.take=function(t){return t<0||null==t?this:new q(this,t)},t.prototype.skip=function(t){return t<0||null==t?this:new L(this,t)},t.prototype.prefetch=function(t){return new Y(this,t)},t.prototype.shuffle=function(t,e){return new K(this,t,e)},t.prototype.serial=function(){return new B(this)},t}(),M=function(t){function e(e){var n=t.call(this)||this;return n.items=e,n.trav=0,n}return o(e,t),e.prototype.summary=function(){return"Array of ".concat(this.items.length," items")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(e){return this.trav>=this.items.length?[2,{value:null,done:!0}]:(t=this.items[this.trav],this.trav++,[2,{value:k(t),done:!1}])}))}))},e}(j),P=function(t){function e(e){var n=t.call(this)||this;return n.nextFn=e,n}return o(e,t),e.prototype.summary=function(){return"Function call"},e.prototype.next=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){try{return[2,this.nextFn()]}catch(t){throw t.message="Error thrown while iterating through a dataset: ".concat(t.message),t}return[2]}))}))},e}(j),B=function(t){function e(e){var n=t.call(this)||this;return n.upstream=e,n.lastRead=Promise.resolve({value:null,done:!1}),n}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Serial")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.upstream.next()]}))}))},e}(j),L=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.maxCount=n,r.count=0,r.lastRead=Promise.resolve({value:null,done:!1}),r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Skip")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return this.count++<this.maxCount?[4,this.upstream.next()]:[3,2];case 1:return(t=e.sent()).done?[2,t]:(r.dispose(t.value),[3,0]);case 2:return[2,this.upstream.next()]}}))}))},e}(j),q=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.maxCount=n,r.count=0,r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Take")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return this.count++>=this.maxCount?[2,{value:null,done:!0}]:[2,this.upstream.next()]}))}))},e}(j),H=function(t){function e(e,n,r){void 0===r&&(r=!0);var i=t.call(this)||this;return i.upstream=e,i.batchSize=n,i.enableSmallLastBatch=r,i.lastRead=Promise.resolve({value:null,done:!1}),i}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> RowMajorBatch")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:t=[],n.label=1;case 1:return t.length<this.batchSize?[4,this.upstream.next()]:[3,3];case 2:return(e=n.sent()).done?this.enableSmallLastBatch&&t.length>0?[2,{value:t,done:!1}]:[2,{value:null,done:!0}]:(t.push(e.value),[3,1]);case 3:return[2,{value:t,done:!1}]}}))}))},e}(j),W=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.predicate=n,r.lastRead=Promise.resolve({value:null,done:!1}),r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Filter")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return[4,this.upstream.next()];case 1:return(t=e.sent()).done||this.predicate(t.value)?[2,t]:(r.dispose(t.value),[3,0]);case 2:return[2]}}))}))},e}(j),V=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Map")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t,e,n,i,o,u,c,l,f;return s(this,(function(s){switch(s.label){case 0:return[4,this.upstream.next()];case 1:if((t=s.sent()).done)return[2,{value:null,done:!0}];e=r.tensor_util.getTensorsInContainer(t.value),n=this.transform(t.value),i=r.tensor_util.getTensorsInContainer(n);try{for(o=a(e),u=o.next();!u.done;u=o.next())c=u.value,r.tensor_util.isTensorInList(c,i)||c.dispose()}catch(t){l={error:t}}finally{try{u&&!u.done&&(f=o.return)&&f.call(o)}finally{if(l)throw l.error}}return[2,{value:n,done:!1}]}}))}))},e}(j),U=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.handler=n,r.count=0,r.lastRead=Promise.resolve({value:null,done:!1}),r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> handleErrors")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.upstream.next()];case 2:return[2,e.sent()];case 3:return t=e.sent(),this.handler(t)?[3,4]:[2,{value:null,done:!0}];case 4:return[3,0];case 5:return[2]}}))}))},e}(j),Q=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> AsyncMap")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t,e,n,i,o,u,c,l,f;return s(this,(function(s){switch(s.label){case 0:return[4,this.upstream.next()];case 1:return(t=s.sent()).done?[2,{value:null,done:!0}]:(e=r.tensor_util.getTensorsInContainer(t.value),[4,this.transform(t.value)]);case 2:n=s.sent(),i=r.tensor_util.getTensorsInContainer(n);try{for(o=a(e),u=o.next();!u.done;u=o.next())c=u.value,r.tensor_util.isTensorInList(c,i)||c.dispose()}catch(t){l={error:t}}finally{try{u&&!u.done&&(f=o.return)&&f.call(o)}finally{if(l)throw l.error}}return[2,{value:n,done:!1}]}}))}))},e}(j),X=function(t){function e(){var e=t.call(this)||this;return e.outputQueue=new O,e.lastRead=Promise.resolve({value:null,done:!1}),e}return o(e,t),e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return 0!==this.outputQueue.length()?[3,2]:[4,this.pump()];case 1:return t.sent()?[3,0]:[2,{value:null,done:!0}];case 2:return[2,{value:this.outputQueue.shift(),done:!1}]}}))}))},e}(j),G=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Flatmap")},e.prototype.pump=function(){return u(this,void 0,void 0,(function(){var t,e,n,i,o,u,c,l,f;return s(this,(function(s){switch(s.label){case 0:return[4,this.upstream.next()];case 1:if((t=s.sent()).done)return[2,!1];e=r.tensor_util.getTensorsInContainer(t.value),n=this.transform(t.value),i=r.tensor_util.getTensorsInContainer(n),this.outputQueue.pushAll(n);try{for(o=a(e),u=o.next();!u.done;u=o.next())c=u.value,r.tensor_util.isTensorInList(c,i)||c.dispose()}catch(t){l={error:t}}finally{try{u&&!u.done&&(f=o.return)&&f.call(o)}finally{if(l)throw l.error}}return[2,!0]}}))}))},e}(X),Z=function(t){function e(e,n){var r=t.call(this)||this;return r.baseErrorHandler=n,r.lastRead=null,r.iterator=null,r.moreIterators=e,r}return o(e,t),e.prototype.summary=function(){return"".concat("TODO: fill in upstream of chained summaries"," -> Chained")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return this.lastRead=this.readFromChain(this.lastRead),[2,this.lastRead]}))}))},e.prototype.readFromChain=function(t){return u(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){switch(r.label){case 0:return[4,t];case 1:return r.sent(),null!=this.iterator?[3,3]:[4,this.moreIterators.next()];case 2:if((e=r.sent()).done)return[2,{value:null,done:!0}];this.iterator=e.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler)),r.label=3;case 3:return[4,this.iterator.next()];case 4:return(n=r.sent()).done?(this.iterator=null,[2,this.readFromChain(t)]):[2,n]}}))}))},e}(j);!function(t){t[t.FAIL=0]="FAIL",t[t.SHORTEST=1]="SHORTEST",t[t.LONGEST=2]="LONGEST"}(I||(I={}));var J=function(t){function e(e,n){void 0===n&&(n=I.FAIL);var r=t.call(this)||this;return r.iterators=e,r.mismatchMode=n,r.count=0,r.currentPromise=null,r}return o(e,t),e.prototype.summary=function(){return"{".concat("TODO: fill in upstream of zip summaries","} -> Zip")},e.prototype.nextState=function(t){return u(this,void 0,void 0,(function(){function e(t){return t instanceof j?{value:t.next().then((function(t){return n++,t.done&&r++,t.value})),recurse:!1}:{value:null,recurse:!0}}var n,r,i;return s(this,(function(o){switch(o.label){case 0:return[4,t];case 1:return o.sent(),n=0,r=0,[4,R(this.iterators,e)];case 2:if(i=o.sent(),n===r)return[2,{value:null,done:!0}];if(r>0)switch(this.mismatchMode){case I.FAIL:throw new Error("Zipped streams should have the same length. "+"Mismatched at element ".concat(this.count,"."));case I.SHORTEST:return[2,{value:null,done:!0}];case I.LONGEST:}return this.count++,[2,{value:i,done:!1}]}}))}))},e.prototype.next=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return this.currentPromise=this.nextState(this.currentPromise),[2,this.currentPromise]}))}))},e}(j),Y=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.bufferSize=n,r.buffer=new _(n),r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Prefetch")},e.prototype.refill=function(){for(;!this.buffer.isFull();){var t=this.upstream.next();this.buffer.push(t)}},e.prototype.next=function(){return this.refill(),this.buffer.shift()},e}(j),K=function(t){function e(e,n,i){var o=t.call(this,e,n)||this;return o.upstream=e,o.windowSize=n,o.upstreamExhausted=!1,o.random=C.alea(i||r.util.now().toString()),o.lastRead=Promise.resolve({value:null,done:!1}),o}return o(e,t),e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.randomInt=function(t){return Math.floor(this.random()*t)},e.prototype.chooseIndex=function(){return this.randomInt(this.buffer.length())},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:this.upstreamExhausted||this.refill(),n.label=1;case 1:return this.buffer.isEmpty()?[3,3]:(t=this.chooseIndex(),[4,this.buffer.shuffleExcise(t)]);case 2:return(e=n.sent()).done?(this.upstreamExhausted=!0,[3,1]):(this.refill(),[2,e]);case 3:return[2,{value:null,done:!0}]}}))}))},e}(Y),$=function(){function t(){this.size=null}return t.prototype.batch=function(t,e){var n=this;void 0===e&&(e=!0);var i=this;return r.util.assert(t>0,(function(){return"batchSize needs to be positive, but it is\n ".concat(t)})),tt((function(){return u(n,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,i.iterator()];case 1:return[2,n.sent().columnMajorBatch(t,e,et)]}}))}))}),this.size===1/0||null==this.size?this.size:e?Math.ceil(this.size/t):Math.floor(this.size/t))},t.prototype.concatenate=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){var e,r;return s(this,(function(i){switch(i.label){case 0:return[4,n.iterator()];case 1:return r=(e=i.sent()).concatenate,[4,t.iterator()];case 2:return[2,r.apply(e,[i.sent()])]}}))}))}),this.size===1/0||t.size===1/0?1/0:null!=this.size&&null!=t.size?this.size+t.size:null)},t.prototype.filter=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().filter((function(e){return r.tidy((function(){return t(e)}))}))]}}))}))}),this.size===1/0?1/0:null)},t.prototype.forEachAsync=function(t){return u(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.iterator()];case 1:return[2,e.sent().forEachAsync(t)]}}))}))},t.prototype.map=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().map((function(e){return r.tidy((function(){return t(e)}))}))]}}))}))}),this.size)},t.prototype.mapAsync=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().mapAsync(t)]}}))}))}),this.size)},t.prototype.prefetch=function(t){var e=this;if(null==t)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");var n=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().prefetch(t)]}}))}))}),this.size)},t.prototype.repeat=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){var e,r=this;return s(this,(function(i){return e=D((function(){return u(r,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t={},[4,n.iterator()];case 1:return[2,(t.value=e.sent(),t.done=!1,t)]}}))}))})),[2,(o=e.take(t),new Z(o,a))];var o,a}))}))}),null!=this.size&&t>0?this.size*t:0===t?0:null!=this.size&&(void 0===t||t<0)?1/0:null)},t.prototype.skip=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().skip(t)]}}))}))}),null!=this.size&&t>=0&&this.size>=t?this.size-t:null!=this.size&&(this.size<t||void 0===t||t<0)?0:null)},t.prototype.shuffle=function(t,e,n){var i=this;if(void 0===n&&(n=!0),null==t||t<0)throw null==this.size?new RangeError("`Dataset.shuffle()` requires bufferSize to be specified."):new RangeError("`Dataset.shuffle()` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for `tf.Tensor`s), consider setting "+"bufferSize to the dataset size (".concat(this.size," elements)"));var o=this,a=C.alea(e||r.util.now().toString());return tt((function(){return u(i,void 0,void 0,(function(){var e;return s(this,(function(r){switch(r.label){case 0:return e=a.int32(),n&&(e+=a.int32()),[4,o.iterator()];case 1:return[2,r.sent().shuffle(t,e.toString())]}}))}))}),this.size)},t.prototype.take=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().take(t)]}}))}))}),null!=this.size&&this.size>t?t:null!=this.size&&this.size<=t?this.size:null)},t.prototype.toArray=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return[4,this.iterator()];case 1:return[2,t.sent().toArray()]}}))}))},t.prototype.toArrayForTest=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return[4,this.iterator()];case 1:return[2,t.sent().toArrayForTest()]}}))}))},t}();function tt(t,e){return void 0===e&&(e=null),new(function(n){function r(){var t=n.apply(this,l([],c(arguments),!1))||this;return t.size=e,t}return o(r,n),r.prototype.iterator=function(){return u(this,void 0,void 0,(function(){return s(this,(function(e){return[2,t()]}))}))},r}($))}function et(t){return null===t?null:function(t){return null==t||null===(e=t)||"object"!=typeof e&&"function"!=typeof e||Array.isArray(t)||"object"==typeof t&&t instanceof r.Tensor||r.util.isTypedArray(t);var e}(t[0])?{value:function(t){if(0===t.length)throw new Error("Can't make a batch of zero elements.");return t[0]instanceof r.Tensor?r.stack(t):r.tensor(t)}(t),recurse:!1}:{value:null,recurse:!0}}$.MAX_BUFFER_SIZE=1e4;var nt=function(t){function e(e){var n=t.call(this)||this;return n.input=e,n}return o(e,t),e.prototype.iterator=function(){return u(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return[4,this.input.iterator()];case 1:return t=n.sent(),e=t.decodeUTF8(),[2,e.split("\n").map((function(t){return t.endsWith("\r")&&(t=t.slice(0,-1)),t}))]}}))}))},e}($),rt='"',it=Symbol("out"),ot=Symbol("field"),ut=Symbol("quote"),st=Symbol("quoteafterquote"),at=Symbol("quoteinquote"),ct=function(t){function n(n,r){var i=t.call(this)||this;return i.input=n,i.hasHeader=!0,i.fullColumnNames=null,i.columnNamesValidated=!1,i.columnConfigs=null,i.configuredColumnsOnly=!1,i.delimiter=",",i.delimWhitespace=!1,i.base=new nt(n),r||(r={}),i.hasHeader=!1!==r.hasHeader,i.fullColumnNames=r.columnNames,i.columnConfigs=r.columnConfigs,i.configuredColumnsOnly=r.configuredColumnsOnly,r.delimWhitespace?(e.util.assert(null==r.delimiter,(function(){return"Delimiter should not be provided when delimWhitespace is true."})),i.delimWhitespace=!0,i.delimiter=" "):i.delimiter=r.delimiter?r.delimiter:",",i}return o(n,t),n.prototype.columnNames=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:t.sent(),t.label=2;case 2:return[2,this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames]}}))}))},n.prototype.setColumnNames=function(){return u(this,void 0,void 0,(function(){var t,n,r,i,o,u,c,l,f=this;return s(this,(function(s){switch(s.label){case 0:return[4,this.maybeReadHeaderLine()];case 1:if(t=s.sent(),!this.fullColumnNames&&!t)throw new Error("Column names must be provided if there is no header line.");if(this.fullColumnNames&&t&&e.util.assert(t.length===this.fullColumnNames.length,(function(){return"The length of provided columnNames ("+f.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+t.length.toString()+")."})),this.fullColumnNames||(this.fullColumnNames=t),n=this.fullColumnNames.reduce((function(t,e){return t[e]=t[e]+1||1,t}),{}),r=Object.keys(n).filter((function(t){return n[t]>1})),e.util.assert(0===r.length,(function(){return"Duplicate column names found: "+r.toString()})),this.columnConfigs)try{for(i=a(Object.keys(this.columnConfigs)),o=i.next();!o.done;o=i.next())if(u=o.value,-1===this.fullColumnNames.indexOf(u))throw new Error('The key "'+u+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").")}catch(t){c={error:t}}finally{try{o&&!o.done&&(l=i.return)&&l.call(i)}finally{if(c)throw c.error}}return this.columnNamesValidated=!0,[2]}}))}))},n.prototype.maybeReadHeaderLine=function(){return u(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return this.hasHeader?[4,this.base.iterator()]:[3,3];case 1:return[4,n.sent().next()];case 2:if((t=n.sent()).done)throw new Error("No data was found for CSV parsing.");return e=t.value,[2,this.parseRow(e,!1)];case 3:return[2,null]}}))}))},n.prototype.iterator=function(){return u(this,void 0,void 0,(function(){var t,e=this;return s(this,(function(n){switch(n.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:n.sent(),n.label=2;case 2:return[4,this.base.iterator()];case 3:return t=n.sent(),this.hasHeader&&(t=t.skip(1)),[2,t.map((function(t){return e.makeDataElement(t)}))]}}))}))},n.prototype.makeDataElement=function(t){for(var e=this.parseRow(t),n={},r={},i=0;i<this.fullColumnNames.length;i++){var o=this.fullColumnNames[i],u=this.columnConfigs?this.columnConfigs[o]:null;if(!this.configuredColumnsOnly||u){var s=e[i],a=null;if(""===s)if(u&&void 0!==u.default)a=u.default;else{if(u&&(u.required||u.isLabel))throw new Error("Required column ".concat(o," is empty in this line: ").concat(t));a=void 0}else{var c=Number(s);if(isNaN(c))a=u&&"bool"===u.dtype?this.getBoolean(s):s;else if(u&&u.dtype)switch(u.dtype){case"float32":default:a=c;break;case"int32":a=Math.floor(c);break;case"bool":a=this.getBoolean(s)}else a=c}u&&u.isLabel?r[o]=a:n[o]=a}}return 0===Object.keys(r).length?n:{xs:n,ys:r}},n.prototype.getBoolean=function(t){return"1"===t||"true"===t.toLowerCase()?1:0},n.prototype.parseRow=function(t,e){void 0===e&&(e=!0);for(var n=[],r=0,i=t.length,o=it,u=0;u<i;u++)switch(o){case it:switch(t.charAt(u)){case rt:r=u+1,o=ut;break;case this.delimiter:if(r=u+1," "===this.delimiter&&this.delimWhitespace)break;n.push(""),o=it;break;default:o=ot,r=u}break;case ot:if(t.charAt(u)===this.delimiter)n.push(t.substring(r,u)),o=it,r=u+1;break;case ut:if(t.charAt(u)===rt)o=st;break;case st:switch(t.charAt(u)){case this.delimiter:n.push(t.substring(r,u-1)),o=it,r=u+1;break;case rt:o=ut;break;default:o=at}break;case at:if(t.charAt(u)===rt)o=ut}if(o===st?n.push(t.substring(r,i-1)):n.push(t.substring(r)),e&&n.length!==this.fullColumnNames.length)throw new Error("Invalid row in csv file. Should have ".concat(this.fullColumnNames.length," elements in a row, but got ").concat(n));return n},n}($),lt=function(t){function n(e){var n=t.call(this)||this;n.microphoneConfig=e,n.isClosed=!1,n.fftSize=e.fftSize||1024;var r=Math.log2(n.fftSize);if(n.fftSize<0||r<4||r>14||!Number.isInteger(r))throw new Error("Invalid fftSize: it must be a power of 2 between "+"2 to 4 and 2 to 14, but got ".concat(n.fftSize));if(n.numFrames=e.numFramesPerSpectrogram||43,n.sampleRateHz=e.sampleRateHz,n.columnTruncateLength=e.columnTruncateLength||n.fftSize,n.audioTrackConstraints=e.audioTrackConstraints,n.smoothingTimeConstant=e.smoothingTimeConstant||0,n.includeSpectrogram=!1!==e.includeSpectrogram,n.includeWaveform=!0===e.includeWaveform,!n.includeSpectrogram&&!n.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.");return n}return o(n,t),n.prototype.summary=function(){return"microphone"},n.create=function(t){return void 0===t&&(t={}),u(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:if(!e.env().get("IS_BROWSER"))throw new Error("microphone API is only supported in browser environment.");return[4,(r=new n(t)).start()];case 1:return i.sent(),[2,r]}}))}))},n.prototype.start=function(){return u(this,void 0,void 0,(function(){var t,e,n,r;return s(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=this,[4,navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1})];case 1:return t.stream=i.sent(),[3,3];case 2:throw e=i.sent(),new Error("Error thrown while initializing video stream: ".concat(e.message));case 3:if(!this.stream)throw new Error("Could not obtain audio from microphone.");if(n=window.AudioContext||window.webkitAudioContext,this.audioContext=new n,this.sampleRateHz){if(this.audioContext.sampleRate!==this.sampleRateHz)throw new Error("Mismatch in sampling rate: "+"Expected: ".concat(this.sampleRateHz,"; ")+"Actual: ".concat(this.audioContext.sampleRate))}else this.sampleRateHz=this.audioContext.sampleRate;return r=this.audioContext.createMediaStreamSource(this.stream),this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,r.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize),[2]}}))}))},n.prototype.next=function(){return u(this,void 0,void 0,(function(){var t,e,n,r,i;return s(this,(function(o){switch(o.label){case 0:return this.isClosed?[2,{value:null,done:!0}]:[4,this.getAudioData()];case 1:return n=o.sent(),this.includeSpectrogram&&(r=this.flattenQueue(n.freqDataQueue),t=this.getTensorFromAudioDataArray(r,[this.numFrames,this.columnTruncateLength,1])),this.includeWaveform&&(i=this.flattenQueue(n.timeDataQueue),e=this.getTensorFromAudioDataArray(i,[this.numFrames*this.fftSize,1])),[2,{value:{spectrogram:t,waveform:e},done:!1}]}}))}))},n.prototype.capture=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.next()];case 1:return[2,t.sent().value]}}))}))},n.prototype.getAudioData=function(){return u(this,void 0,void 0,(function(){var t,e,n,r=this;return s(this,(function(i){return t=[],e=[],n=0,[2,new Promise((function(i){var o=setInterval((function(){r.includeSpectrogram&&(r.analyser.getFloatFrequencyData(r.freqData),r.freqData[0]===-1/0&&i({freqDataQueue:t,timeDataQueue:e}),t.push(r.freqData.slice(0,r.columnTruncateLength))),r.includeWaveform&&(r.analyser.getFloatTimeDomainData(r.timeData),e.push(r.timeData.slice())),++n===r.numFrames&&(clearInterval(o),i({freqDataQueue:t,timeDataQueue:e}))}),r.fftSize/r.sampleRateHz*1e3)}))]}))}))},n.prototype.stop=function(){this.isClosed||(this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop())},n.prototype.toArray=function(){throw new Error("Can not convert infinite audio stream to array.")},n.prototype.getSampleRate=function(){return this.sampleRateHz},n.prototype.flattenQueue=function(t){var e=t[0].length,n=new Float32Array(t.length*e);return t.forEach((function(t,r){return n.set(t,r*e)})),n},n.prototype.getTensorFromAudioDataArray=function(t,n){var r=new Float32Array(e.util.sizeFromShape(n));return r.set(t,r.length-t.length),e.tensor(r,n)},n}(j),ft=function(t){function n(n,r){var i=t.call(this)||this;if(i.webcamVideoElement=n,i.webcamConfig=r,i.isClosed=!0,i.resize=!1,i.needToResize())if(i.resize=!0,i.cropSize=[i.webcamConfig.resizeHeight,i.webcamConfig.resizeWidth],i.cropBoxInd=e.tensor1d([0],"int32"),i.webcamConfig.centerCrop){var o=1*i.webcamConfig.resizeWidth/i.webcamVideoElement.width,u=1*i.webcamConfig.resizeHeight/i.webcamVideoElement.height,s=(1-o)/2,a=(1-u)/2,c=s+o,l=u+a;i.cropBox=e.tensor2d([a,s,l,c],[1,4])}else i.cropBox=e.tensor2d([0,0,1,1],[1,4]);return i}return o(n,t),n.prototype.summary=function(){return"webcam"},n.create=function(t,r){return void 0===r&&(r={}),u(this,void 0,void 0,(function(){var i;return s(this,(function(o){switch(o.label){case 0:if(!e.env().get("IS_BROWSER"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!t){if(t=document.createElement("video"),!r.resizeWidth||!r.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");t.width=r.resizeWidth,t.height=r.resizeHeight}return[4,(i=new n(t,r)).start()];case 1:return o.sent(),[2,i]}}))}))},n.prototype.start=function(){return u(this,void 0,void 0,(function(){var t,n,r=this;return s(this,(function(i){switch(i.label){case 0:this.webcamConfig.facingMode&&e.util.assert("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,(function(){return"Invalid webcam facing mode: ".concat(r.webcamConfig.facingMode,". ")+"Please provide 'user' or 'environment'"})),i.label=1;case 1:return i.trys.push([1,3,,4]),t=this,[4,navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})];case 2:return t.stream=i.sent(),[3,4];case 3:throw(n=i.sent()).message="Error thrown while initializing video stream: ".concat(n.message),n;case 4:if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(t){console.log(t),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,[2,new Promise((function(t){r.webcamVideoElement.onloadedmetadata=function(){t()}}))]}}))}))},n.prototype.next=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(n){if(this.isClosed)return[2,{value:null,done:!0}];try{t=e.browser.fromPixels(this.webcamVideoElement)}catch(t){throw new Error("Error thrown converting video to pixels: ".concat(JSON.stringify(t)))}if(!this.resize)return[2,{value:t,done:!1}];try{return[2,{value:this.cropAndResizeFrame(t),done:!1}]}catch(t){throw new Error("Error thrown cropping the video: ".concat(t.message))}finally{t.dispose()}return[2]}))}))},n.prototype.needToResize=function(){return!(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight)},n.prototype.cropAndResizeFrame=function(t){var n=this;return e.tidy((function(){var r,i=e.expandDims(e.cast(t,"float32"),0),o=(r=e.image.cropAndResize(i,n.cropBox,n.cropBoxInd,n.cropSize,"bilinear")).shape;return e.reshape(r,o.slice(1))}))},n.prototype.capture=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.next()];case 1:return[2,t.sent().value]}}))}))},n.prototype.stop=function(){this.stream.getTracks().forEach((function(t){return t.stop()}));try{this.webcamVideoElement.srcObject=null}catch(t){console.log(t),this.webcamVideoElement.src=null}this.isClosed=!0},n.prototype.toArray=function(){throw new Error("Can not convert infinite video stream to array.")},n}(j),ht=function(){},dt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.split=function(t){return new pt(this,t)},e}(j),pt=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.impl=new vt(e,n),r}return o(e,t),e.prototype.summary=function(){return this.impl.summary()},e.prototype.next=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.impl.next()]}))}))},e}(dt),vt=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.separator=n,r.carryover="",r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Split('").concat(this.separator,"')")},e.prototype.pump=function(){return u(this,void 0,void 0,(function(){var t,e,n,r,i,o,u;return s(this,(function(s){switch(s.label){case 0:return[4,this.upstream.next()];case 1:if((t=s.sent()).done)return""===this.carryover?[2,!1]:(this.outputQueue.push(this.carryover),this.carryover="",[2,!0]);(e=t.value.split(this.separator))[0]=this.carryover+e[0];try{for(n=a(e.slice(0,-1)),r=n.next();!r.done;r=n.next())i=r.value,this.outputQueue.push(i)}catch(t){o={error:t}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}}return this.carryover=e[e.length-1],[2,!0]}}))}))},e}(X),mt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.decodeUTF8=function(){return new yt(this)},e}(j),yt=function(t){function e(e){var n=t.call(this)||this;return n.upstream=e,n.impl=new wt(e),n}return o(e,t),e.prototype.summary=function(){return this.impl.summary()},e.prototype.next=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.impl.next()]}))}))},e}(dt),wt=function(t){function n(n){var r=t.call(this)||this;if(r.upstream=n,e.env().get("IS_BROWSER"))r.decoder=new TextDecoder("utf-8");else{var i=require("string_decoder").StringDecoder;r.decoder=new i("utf8")}return r}return o(n,t),n.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Utf8")},n.prototype.pump=function(){return u(this,void 0,void 0,(function(){var t,n,r;return s(this,(function(i){switch(i.label){case 0:return[4,this.upstream.next()];case 1:return(t=i.sent()).done?[2,!1]:(n=t.value,r=e.env().get("IS_BROWSER")?this.decoder.decode(n,{stream:!0}):this.decoder.write(Buffer.from(n.buffer)),this.outputQueue.push(r),[2,!0])}}))}))},n}(X),bt=function(t){function n(n,r){void 0===r&&(r={});var i=t.call(this)||this;return i.file=n,i.options=r,e.util.assert(n instanceof Uint8Array||!!e.env().get("IS_BROWSER")&&(n instanceof File||n instanceof Blob),(function(){return"FileChunkIterator only supports File, Blob and Uint8Array right now."})),i.offset=r.offset||0,i.chunkSize=r.chunkSize||1048576,i}return o(n,t),n.prototype.summary=function(){return"FileChunks ".concat(this.file)},n.prototype.next=function(){return u(this,void 0,void 0,(function(){var t,e,n=this;return s(this,(function(r){switch(r.label){case 0:return this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size)?[2,{value:null,done:!0}]:(t=new Promise((function(t,e){var r=n.offset+n.chunkSize;if(n.file instanceof Uint8Array)t(new Uint8Array(n.file.slice(n.offset,r)));else{var i=new FileReader;i.onload=function(n){var r=i.result;if(r instanceof ArrayBuffer&&(r=new Uint8Array(r)),!(r instanceof Uint8Array))return e(new TypeError("FileReader returned unknown type."));t(r)},i.onabort=function(t){return e(new Error("Aborted"))},i.onerror=function(t){return e(new Error(t.type))};var o=n.file.slice(n.offset,r);i.readAsArrayBuffer(o)}n.offset=r})),e={},[4,t]);case 1:return[2,(e.value=r.sent(),e.done=!1,e)]}}))}))},n}(mt);function gt(t,n,r){return void 0===n&&(n={}),u(this,void 0,void 0,(function(){var i,o,u,a,c;return s(this,(function(s){switch(s.label){case 0:return"string"==typeof t?i=t:(i=t.url,o=xt(t)),[4,(r||e.util.fetch)(i,o)];case 1:return(u=s.sent()).ok?(c=Uint8Array.bind,[4,u.arrayBuffer()]):[3,3];case 2:return a=new(c.apply(Uint8Array,[void 0,s.sent()])),[2,new bt(a,n)];case 3:throw new Error(u.statusText)}}))}))}var xt=function(t){return{method:t.method,headers:t.headers,body:t.body,mode:t.mode,credentials:t.credentials,cache:t.cache,redirect:t.redirect,referrer:t.referrer,integrity:t.integrity}};function Ct(t){return"string"==typeof t&&"file://"===t.slice(0,7)}var zt=function(t){function n(e,n){void 0===n&&(n={});var r=t.call(this)||this;return r.input=e,r.options=n,r}return o(n,t),n.prototype.iterator=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(n){return Ct(this.input)&&e.env().get("IS_NODE")&&(t=require("fs"),this.input=t.readFileSync(this.input.slice(7))),[2,new bt(this.input,this.options)]}))}))},n}(ht),Et=function(t){function e(e,n){void 0===n&&(n={});var r=t.call(this)||this;return r.url=e,r.fileOptions=n,r}return o(e,t),e.prototype.iterator=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return Ct(this.url)?[2,new zt(this.url,this.fileOptions).iterator()]:[2,gt(this.url,this.fileOptions)]}))}))},e}(ht);t.CSVDataset=ct,t.Dataset=$,t.FileDataSource=zt,t.TextLineDataset=nt,t.URLDataSource=Et,t.array=function(t){var e=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){return[2,N(t)]}))}))}),t.length)},t.csv=function(t,e){return void 0===e&&(e={}),new ct(new Et(t),e)},t.func=function(t){var e=this,n=D(t);return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(t){return[2,n]}))}))}))},t.generator=function(t){var e=this;return tt((function(){return u(e,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return[4,t()];case 1:return e=n.sent(),[2,D((function(){return e.next()}))]}}))}))}))},t.microphone=function(t){return u(this,void 0,void 0,(function(){return s(this,(function(e){return[2,lt.create(t)]}))}))},t.version_data="4.2.0",t.webcam=function(t,e){return u(this,void 0,void 0,(function(){return s(this,(function(n){return[2,ft.create(t,e)]}))}))},t.zip=function(t){var e,n=this;if(!T(t))throw new Error("The argument to zip() must be an object or array.");if(Array.isArray(t))for(var r=0;r<t.length;r++)e=null==e?t[r].size:Math.min(e,t[r].size);else if(t instanceof Object)for(var i in t)e=null==e?t[i].size:Math.min(e,t[i].size);return tt((function(){return u(n,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return[4,R(t,(function(t){if(t instanceof $)return{value:t.iterator(),recurse:!1};if(T(t))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")}))];case 1:return e=n.sent(),[2,(r=e,i=I.SHORTEST,void 0===i&&(i=I.FAIL),new J(r,i))]}var r,i}))}))}),e)},Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@tensorflow/tfjs-core")):"function"==typeof define&&define.amd?define(["exports","@tensorflow/tfjs-core"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).tf=t.tf||{},t.tf)}(this,(function(t,e){"use strict";function n(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,e}var r=n(e),i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},i(t,e)};function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function u(t,e,n,r){return new(n||(n=Promise))((function(i,o){function u(t){try{a(r.next(t))}catch(t){o(t)}}function s(t){try{a(r.throw(t))}catch(t){o(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,s)}a((r=r.apply(t,e||[])).next())}))}function s(t,e){var n,r,i,o,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,r=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(!(i=u.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){u=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){u.label=o[1];break}if(6===o[0]&&u.label<i[1]){u.label=i[1],i=o;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(o);break}i[2]&&u.ops.pop(),u.trys.pop();continue}o=e.call(t,u)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function a(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)u.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return u}function l(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function h(t){if(t.__esModule)return t;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach((function(n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})})),e}function d(t){var e={exports:{}};return t(e,e.exports),e.exports}var p=d((function(t){!function(t,e,n){function r(t){var e,n=this,r=(e=4022871197,function(t){t=String(t);for(var n=0;n<t.length;n++){var r=.02519603282416938*(e+=t.charCodeAt(n));r-=e=r>>>0,e=(r*=e)>>>0,e+=4294967296*(r-=e)}return 2.3283064365386963e-10*(e>>>0)});n.next=function(){var t=2091639*n.s0+2.3283064365386963e-10*n.c;return n.s0=n.s1,n.s1=n.s2,n.s2=t-(n.c=0|t)},n.c=1,n.s0=r(" "),n.s1=r(" "),n.s2=r(" "),n.s0-=r(t),n.s0<0&&(n.s0+=1),n.s1-=r(t),n.s1<0&&(n.s1+=1),n.s2-=r(t),n.s2<0&&(n.s2+=1),r=null}function i(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e}function o(t,e){var n=new r(t),o=e&&e.state,u=n.next;return u.int32=function(){return 4294967296*n.next()|0},u.double=function(){return u()+11102230246251565e-32*(2097152*u()|0)},u.quick=u,o&&("object"==typeof o&&i(o,n),u.state=function(){return i(n,{})}),u}e&&e.exports?e.exports=o:n&&n.amd?n((function(){return o})):this.alea=o}(0,t,!1)})),v=d((function(t){!function(t,e,n){function r(t){var e=this,n="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8},t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++)e.x^=0|n.charCodeAt(r),e.next()}function i(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e}function o(t,e){var n=new r(t),o=e&&e.state,u=function(){return(n.next()>>>0)/4294967296};return u.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},u.int32=n.next,u.quick=u,o&&("object"==typeof o&&i(o,n),u.state=function(){return i(n,{})}),u}e&&e.exports?e.exports=o:n&&n.amd?n((function(){return o})):this.xor128=o}(0,t,!1)})),m=d((function(t){!function(t,e,n){function r(t){var e=this,n="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++)e.x^=0|n.charCodeAt(r),r==n.length&&(e.d=e.x<<10^e.x>>>4),e.next()}function i(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e}function o(t,e){var n=new r(t),o=e&&e.state,u=function(){return(n.next()>>>0)/4294967296};return u.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},u.int32=n.next,u.quick=u,o&&("object"==typeof o&&i(o,n),u.state=function(){return i(n,{})}),u}e&&e.exports?e.exports=o:n&&n.amd?n((function(){return o})):this.xorwow=o}(0,t,!1)})),y=d((function(t){!function(t,e,n){function r(t){var e=this;e.next=function(){var t,n,r=e.x,i=e.i;return t=r[i],n=(t^=t>>>7)^t<<24,n^=(t=r[i+1&7])^t>>>10,n^=(t=r[i+3&7])^t>>>3,n^=(t=r[i+4&7])^t<<7,t=r[i+7&7],n^=(t^=t<<13)^t<<9,r[i]=n,e.i=i+1&7,n},function(t,e){var n,r=[];if(e===(0|e))r[0]=e;else for(e=""+e,n=0;n<e.length;++n)r[7&n]=r[7&n]<<15^e.charCodeAt(n)+r[n+1&7]<<13;for(;r.length<8;)r.push(0);for(n=0;n<8&&0===r[n];++n);for(8==n&&(r[7]=-1),t.x=r,t.i=0,n=256;n>0;--n)t.next()}(e,t)}function i(t,e){return e.x=t.x.slice(),e.i=t.i,e}function o(t,e){null==t&&(t=+new Date);var n=new r(t),o=e&&e.state,u=function(){return(n.next()>>>0)/4294967296};return u.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},u.int32=n.next,u.quick=u,o&&(o.x&&i(o,n),u.state=function(){return i(n,{})}),u}e&&e.exports?e.exports=o:n&&n.amd?n((function(){return o})):this.xorshift7=o}(0,t,!1)})),w=d((function(t){!function(t,e,n){function r(t){var e=this;e.next=function(){var t,n,r=e.w,i=e.X,o=e.i;return e.w=r=r+1640531527|0,n=i[o+34&127],t=i[o=o+1&127],n^=n<<13,t^=t<<17,n^=n>>>15,t^=t>>>12,n=i[o]=n^t,e.i=o,n+(r^r>>>16)|0},function(t,e){var n,r,i,o,u,s=[],a=128;for(e===(0|e)?(r=e,e=null):(e+="\0",r=0,a=Math.max(a,e.length)),i=0,o=-32;o<a;++o)e&&(r^=e.charCodeAt((o+32)%e.length)),0===o&&(u=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,o>=0&&(u=u+1640531527|0,i=0==(n=s[127&o]^=r+u)?i+1:0);for(i>=128&&(s[127&(e&&e.length||0)]=-1),i=127,o=512;o>0;--o)r=s[i+34&127],n=s[i=i+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,s[i]=r^n;t.w=u,t.X=s,t.i=i}(e,t)}function i(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e}function o(t,e){null==t&&(t=+new Date);var n=new r(t),o=e&&e.state,u=function(){return(n.next()>>>0)/4294967296};return u.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},u.int32=n.next,u.quick=u,o&&(o.X&&i(o,n),u.state=function(){return i(n,{})}),u}e&&e.exports?e.exports=o:n&&n.amd?n((function(){return o})):this.xor4096=o}(0,t,!1)})),b=d((function(t){!function(t,e,n){function r(t){var e=this,n="";e.next=function(){var t=e.b,n=e.c,r=e.d,i=e.a;return t=t<<25^t>>>7^n,n=n-r|0,r=r<<24^r>>>8^i,i=i-t|0,e.b=t=t<<20^t>>>12^n,e.c=n=n-r|0,e.d=r<<16^n>>>16^i,e.a=i-t|0},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):n+=t;for(var r=0;r<n.length+20;r++)e.b^=0|n.charCodeAt(r),e.next()}function i(t,e){return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e}function o(t,e){var n=new r(t),o=e&&e.state,u=function(){return(n.next()>>>0)/4294967296};return u.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===t);return t},u.int32=n.next,u.quick=u,o&&("object"==typeof o&&i(o,n),u.state=function(){return i(n,{})}),u}e&&e.exports?e.exports=o:n&&n.amd?n((function(){return o})):this.tychei=o}(0,t,!1)})),g=h({__proto__:null,default:{}}),x=d((function(t){!function(e,n,r){var i,o=256,u=r.pow(o,6),s=r.pow(2,52),a=2*s,c=255;function l(t,c,l){var m=[],y=p(d((c=1==c?{entropy:!0}:c||{}).entropy?[t,v(n)]:null==t?function(){try{var t;return i&&(t=i.randomBytes)?t=t(o):(t=new Uint8Array(o),(e.crypto||e.msCrypto).getRandomValues(t)),v(t)}catch(t){var r=e.navigator,u=r&&r.plugins;return[+new Date,e,u,e.screen,v(n)]}}():t,3),m),w=new f(m),b=function(){for(var t=w.g(6),e=u,n=0;t<s;)t=(t+n)*o,e*=o,n=w.g(1);for(;t>=a;)t/=2,e/=2,n>>>=1;return(t+n)/e};return b.int32=function(){return 0|w.g(4)},b.quick=function(){return w.g(4)/4294967296},b.double=b,p(v(w.S),n),(c.pass||l||function(t,e,n,i){return i&&(i.S&&h(i,w),t.state=function(){return h(w,{})}),n?(r.random=t,e):t})(b,y,"global"in c?c.global:this==r,c.state)}function f(t){var e,n=t.length,r=this,i=0,u=r.i=r.j=0,s=r.S=[];for(n||(t=[n++]);i<o;)s[i]=i++;for(i=0;i<o;i++)s[i]=s[u=c&u+t[i%n]+(e=s[i])],s[u]=e;(r.g=function(t){for(var e,n=0,i=r.i,u=r.j,s=r.S;t--;)e=s[i=c&i+1],n=n*o+s[c&(s[i]=s[u=c&u+e])+(s[u]=e)];return r.i=i,r.j=u,n})(o)}function h(t,e){return e.i=t.i,e.j=t.j,e.S=t.S.slice(),e}function d(t,e){var n,r=[],i=typeof t;if(e&&"object"==i)for(n in t)try{r.push(d(t[n],e-1))}catch(t){}return r.length?r:"string"==i?t:t+"\0"}function p(t,e){for(var n,r=t+"",i=0;i<r.length;)e[c&i]=c&(n^=19*e[c&i])+r.charCodeAt(i++);return v(e)}function v(t){return String.fromCharCode.apply(0,t)}if(p(r.random(),n),t.exports){t.exports=l;try{i=g}catch(t){}}else r.seedrandom=l}("undefined"!=typeof self?self:f,[],Math)}));x.alea=p,x.xor128=v,x.xorwow=m,x.xorshift7=y,x.xor4096=w,x.tychei=b;var C=x;function z(t,e,n,r){if(void 0===n&&(n=new Map),void 0===r&&(r=new Set),null==t)return null;if("function"==typeof Blob&&t instanceof Blob)return t.slice();if(r.has(t))throw new Error("Circular references are not supported.");if(n.has(t))return n.get(t);var i=e(t);if(i.recurse&&null!==i.value)throw new Error("A deep map function may not return both a value and recurse=true.");if(i.recurse){if(T(t)){var o=Array.isArray(t)?[]:{};for(var u in r.add(t),t){var s=z(t[u],e,n,r);o[u]=s}return r.delete(t),t.__proto__&&(o.__proto__=t.__proto__),o}throw new Error("Can't recurse into non-iterable type: ".concat(t))}return n.set(t,i.value),i.value}function E(t,e){return void 0===e&&(e=A),S(t,e)}function S(t,e,n){void 0===n&&(n=new Set);var r=t[0];if(n.has(r))throw new Error("Circular references are not supported.");var i=e(t);if(i.recurse&&null!==i.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(i.recurse){if(T(r)){var o=Array.isArray(r)?[]:{};n.add(r);var u=function(r){var i=S(t.map((function(t){return t[r]})),e,n);o[r]=i};for(var s in r)u(s);return n.delete(r),o}throw new Error("Can't recurse into non-iterable type: ".concat(r))}return i.value}function A(t){return null===t?null:T(t[0])?{value:null,recurse:!0}:{value:t,recurse:!1}}function R(t,e){return u(this,void 0,void 0,(function(){var n,i,o,u,c,l,f,h,d;return s(this,(function(s){switch(s.label){case 0:n=new Map,z(t,e,n),s.label=1;case 1:s.trys.push([1,6,7,8]),i=a(Array.from(n.keys())),o=i.next(),s.label=2;case 2:return o.done?[3,5]:(u=o.value,c=n.get(u),r.util.isPromise(c)?[4,c]:[3,4]);case 3:l=s.sent(),n.set(u,l),s.label=4;case 4:return o=i.next(),[3,2];case 5:return[3,8];case 6:return f=s.sent(),h={error:f},[3,8];case 7:try{o&&!o.done&&(d=i.return)&&d.call(i)}finally{if(h)throw h.error}return[7];case 8:return[2,z(t,e,n)]}}))}))}function T(t){var e=!1;r.env().get("IS_BROWSER")?e=t instanceof TextDecoder:e=t instanceof require("string_decoder").StringDecoder;return null!=t&&!ArrayBuffer.isView(t)&&(Array.isArray(t)||"object"==typeof t&&!(t instanceof r.Tensor)&&!(t instanceof Promise)&&!e)}function k(t){return z(t,F)}function F(t){return t instanceof r.Tensor?{value:t.clone(),recurse:!1}:T(t)?{value:null,recurse:!0}:{value:t,recurse:!1}}var _=function(){function t(t){if(this.capacity=t,this.begin=0,this.end=0,null==t)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(t<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(t),this.doubledCapacity=2*t}return t.prototype.wrap=function(t){for(;t<0;)t+=this.doubledCapacity;return t%this.doubledCapacity},t.prototype.get=function(t){if(t<0)throw new RangeError("Can't get item at a negative index.");return this.data[t%this.capacity]},t.prototype.set=function(t,e){if(t<0)throw new RangeError("Can't set item at a negative index.");this.data[t%this.capacity]=e},t.prototype.length=function(){var t=this.end-this.begin;return t<0&&(t=this.doubledCapacity+t),t},t.prototype.isFull=function(){return this.length()===this.capacity},t.prototype.isEmpty=function(){return 0===this.length()},t.prototype.push=function(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,t),this.end=this.wrap(this.end+1)},t.prototype.pushAll=function(t){var e,n;try{for(var r=a(t),i=r.next();!i.done;i=r.next()){var o=i.value;this.push(o)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}},t.prototype.pop=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);var t=this.get(this.end);return this.set(this.end,void 0),t},t.prototype.unshift=function(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,t)},t.prototype.shift=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var t=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),t},t.prototype.shuffleExcise=function(t){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var e=this.wrap(this.begin+t),n=this.get(e);return this.set(e,this.pop()),n},t}(),O=function(t){function e(){return t.call(this,e.INITIAL_CAPACITY)||this}return o(e,t),e.prototype.isFull=function(){return!1},e.prototype.push=function(e){t.prototype.isFull.call(this)&&this.expand(),t.prototype.push.call(this,e)},e.prototype.unshift=function(e){t.prototype.isFull.call(this)&&this.expand(),t.prototype.unshift.call(this,e)},e.prototype.expand=function(){for(var t=2*this.capacity,e=new Array(t),n=this.length(),r=0;r<n;r++)e[r]=this.get(this.wrap(this.begin+r));this.data=e,this.capacity=t,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=n},e}(_);function N(t){return new M(t)}function D(t){return new P(t)}O.INITIAL_CAPACITY=32;var I,j=function(){function t(){}return t.prototype.toArray=function(){return u(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t=[],[4,this.next()];case 1:e=n.sent(),n.label=2;case 2:return e.done?[3,4]:(t.push(e.value),[4,this.next()]);case 3:return e=n.sent(),[3,2];case 4:return[2,t]}}))}))},t.prototype.toArrayForTest=function(){return u(this,void 0,void 0,(function(){var t,e,n;return s(this,(function(r){switch(r.label){case 0:return t=this.prefetch(100),e=[],[4,t.next()];case 1:n=r.sent(),r.label=2;case 2:return n.done?[3,4]:(e.push(n.value),[4,t.next()]);case 3:return n=r.sent(),[3,2];case 4:return[2,e]}}))}))},t.prototype.resolveFully=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return[4,this.next()];case 1:t=e.sent(),e.label=2;case 2:return t.done?[3,4]:[4,this.next()];case 3:return t=e.sent(),[3,2];case 4:return[2]}}))}))},t.prototype.resolveWhile=function(t){return u(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){switch(r.label){case 0:return[4,this.next()];case 1:e=r.sent(),n=t(e.value),r.label=2;case 2:return e.done||!n?[3,4]:[4,this.next()];case 3:return e=r.sent(),n=t(e.value),[3,2];case 4:return[2]}}))}))},t.prototype.handleErrors=function(t){return new U(this,t)},t.prototype.filter=function(t){return new W(this,t)},t.prototype.map=function(t){return new V(this,t)},t.prototype.mapAsync=function(t){return new Q(this,t)},t.prototype.serialMapAsync=function(t){return new Q(this,t).serial()},t.prototype.flatmap=function(t){return new G(this,t)},t.prototype.forEachAsync=function(t){return u(this,void 0,void 0,(function(){return s(this,(function(e){return[2,this.map(t).resolveFully()]}))}))},t.prototype.serialForEach=function(t){return u(this,void 0,void 0,(function(){return s(this,(function(e){return[2,this.serialMapAsync(t).resolveWhile((function(t){return!0===t}))]}))}))},t.prototype.rowMajorBatch=function(t,e){return void 0===e&&(e=!0),new H(this,t,e)},t.prototype.columnMajorBatch=function(t,e,n){return void 0===e&&(e=!0),void 0===n&&(n=A),this.rowMajorBatch(t,e).map((function(t){return E(t,n)}))},t.prototype.concatenate=function(t,e){return new Z(N([this,t]),e)},t.prototype.take=function(t){return t<0||null==t?this:new q(this,t)},t.prototype.skip=function(t){return t<0||null==t?this:new L(this,t)},t.prototype.prefetch=function(t){return new Y(this,t)},t.prototype.shuffle=function(t,e){return new K(this,t,e)},t.prototype.serial=function(){return new B(this)},t}(),M=function(t){function e(e){var n=t.call(this)||this;return n.items=e,n.trav=0,n}return o(e,t),e.prototype.summary=function(){return"Array of ".concat(this.items.length," items")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(e){return this.trav>=this.items.length?[2,{value:null,done:!0}]:(t=this.items[this.trav],this.trav++,[2,{value:k(t),done:!1}])}))}))},e}(j),P=function(t){function e(e){var n=t.call(this)||this;return n.nextFn=e,n}return o(e,t),e.prototype.summary=function(){return"Function call"},e.prototype.next=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){try{return[2,this.nextFn()]}catch(t){throw t.message="Error thrown while iterating through a dataset: ".concat(t.message),t}return[2]}))}))},e}(j),B=function(t){function e(e){var n=t.call(this)||this;return n.upstream=e,n.lastRead=Promise.resolve({value:null,done:!1}),n}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Serial")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.upstream.next()]}))}))},e}(j),L=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.maxCount=n,r.count=0,r.lastRead=Promise.resolve({value:null,done:!1}),r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Skip")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return this.count++<this.maxCount?[4,this.upstream.next()]:[3,2];case 1:return(t=e.sent()).done?[2,t]:(r.dispose(t.value),[3,0]);case 2:return[2,this.upstream.next()]}}))}))},e}(j),q=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.maxCount=n,r.count=0,r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Take")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return this.count++>=this.maxCount?[2,{value:null,done:!0}]:[2,this.upstream.next()]}))}))},e}(j),H=function(t){function e(e,n,r){void 0===r&&(r=!0);var i=t.call(this)||this;return i.upstream=e,i.batchSize=n,i.enableSmallLastBatch=r,i.lastRead=Promise.resolve({value:null,done:!1}),i}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> RowMajorBatch")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:t=[],n.label=1;case 1:return t.length<this.batchSize?[4,this.upstream.next()]:[3,3];case 2:return(e=n.sent()).done?this.enableSmallLastBatch&&t.length>0?[2,{value:t,done:!1}]:[2,{value:null,done:!0}]:(t.push(e.value),[3,1]);case 3:return[2,{value:t,done:!1}]}}))}))},e}(j),W=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.predicate=n,r.lastRead=Promise.resolve({value:null,done:!1}),r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Filter")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return[4,this.upstream.next()];case 1:return(t=e.sent()).done||this.predicate(t.value)?[2,t]:(r.dispose(t.value),[3,0]);case 2:return[2]}}))}))},e}(j),V=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Map")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t,e,n,i,o,u,c,l,f;return s(this,(function(s){switch(s.label){case 0:return[4,this.upstream.next()];case 1:if((t=s.sent()).done)return[2,{value:null,done:!0}];e=r.tensor_util.getTensorsInContainer(t.value),n=this.transform(t.value),i=r.tensor_util.getTensorsInContainer(n);try{for(o=a(e),u=o.next();!u.done;u=o.next())c=u.value,r.tensor_util.isTensorInList(c,i)||c.dispose()}catch(t){l={error:t}}finally{try{u&&!u.done&&(f=o.return)&&f.call(o)}finally{if(l)throw l.error}}return[2,{value:n,done:!1}]}}))}))},e}(j),U=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.handler=n,r.count=0,r.lastRead=Promise.resolve({value:null,done:!1}),r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> handleErrors")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.upstream.next()];case 2:return[2,e.sent()];case 3:return t=e.sent(),this.handler(t)?[3,4]:[2,{value:null,done:!0}];case 4:return[3,0];case 5:return[2]}}))}))},e}(j),Q=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> AsyncMap")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t,e,n,i,o,u,c,l,f;return s(this,(function(s){switch(s.label){case 0:return[4,this.upstream.next()];case 1:return(t=s.sent()).done?[2,{value:null,done:!0}]:(e=r.tensor_util.getTensorsInContainer(t.value),[4,this.transform(t.value)]);case 2:n=s.sent(),i=r.tensor_util.getTensorsInContainer(n);try{for(o=a(e),u=o.next();!u.done;u=o.next())c=u.value,r.tensor_util.isTensorInList(c,i)||c.dispose()}catch(t){l={error:t}}finally{try{u&&!u.done&&(f=o.return)&&f.call(o)}finally{if(l)throw l.error}}return[2,{value:n,done:!1}]}}))}))},e}(j),X=function(t){function e(){var e=t.call(this)||this;return e.outputQueue=new O,e.lastRead=Promise.resolve({value:null,done:!1}),e}return o(e,t),e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return 0!==this.outputQueue.length()?[3,2]:[4,this.pump()];case 1:return t.sent()?[3,0]:[2,{value:null,done:!0}];case 2:return[2,{value:this.outputQueue.shift(),done:!1}]}}))}))},e}(j),G=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Flatmap")},e.prototype.pump=function(){return u(this,void 0,void 0,(function(){var t,e,n,i,o,u,c,l,f;return s(this,(function(s){switch(s.label){case 0:return[4,this.upstream.next()];case 1:if((t=s.sent()).done)return[2,!1];e=r.tensor_util.getTensorsInContainer(t.value),n=this.transform(t.value),i=r.tensor_util.getTensorsInContainer(n),this.outputQueue.pushAll(n);try{for(o=a(e),u=o.next();!u.done;u=o.next())c=u.value,r.tensor_util.isTensorInList(c,i)||c.dispose()}catch(t){l={error:t}}finally{try{u&&!u.done&&(f=o.return)&&f.call(o)}finally{if(l)throw l.error}}return[2,!0]}}))}))},e}(X),Z=function(t){function e(e,n){var r=t.call(this)||this;return r.baseErrorHandler=n,r.lastRead=null,r.iterator=null,r.moreIterators=e,r}return o(e,t),e.prototype.summary=function(){return"".concat("TODO: fill in upstream of chained summaries"," -> Chained")},e.prototype.next=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return this.lastRead=this.readFromChain(this.lastRead),[2,this.lastRead]}))}))},e.prototype.readFromChain=function(t){return u(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){switch(r.label){case 0:return[4,t];case 1:return r.sent(),null!=this.iterator?[3,3]:[4,this.moreIterators.next()];case 2:if((e=r.sent()).done)return[2,{value:null,done:!0}];this.iterator=e.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler)),r.label=3;case 3:return[4,this.iterator.next()];case 4:return(n=r.sent()).done?(this.iterator=null,[2,this.readFromChain(t)]):[2,n]}}))}))},e}(j);!function(t){t[t.FAIL=0]="FAIL",t[t.SHORTEST=1]="SHORTEST",t[t.LONGEST=2]="LONGEST"}(I||(I={}));var J=function(t){function e(e,n){void 0===n&&(n=I.FAIL);var r=t.call(this)||this;return r.iterators=e,r.mismatchMode=n,r.count=0,r.currentPromise=null,r}return o(e,t),e.prototype.summary=function(){return"{".concat("TODO: fill in upstream of zip summaries","} -> Zip")},e.prototype.nextState=function(t){return u(this,void 0,void 0,(function(){function e(t){return t instanceof j?{value:t.next().then((function(t){return n++,t.done&&r++,t.value})),recurse:!1}:{value:null,recurse:!0}}var n,r,i;return s(this,(function(o){switch(o.label){case 0:return[4,t];case 1:return o.sent(),n=0,r=0,[4,R(this.iterators,e)];case 2:if(i=o.sent(),n===r)return[2,{value:null,done:!0}];if(r>0)switch(this.mismatchMode){case I.FAIL:throw new Error("Zipped streams should have the same length. "+"Mismatched at element ".concat(this.count,"."));case I.SHORTEST:return[2,{value:null,done:!0}];case I.LONGEST:}return this.count++,[2,{value:i,done:!1}]}}))}))},e.prototype.next=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return this.currentPromise=this.nextState(this.currentPromise),[2,this.currentPromise]}))}))},e}(j),Y=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.bufferSize=n,r.buffer=new _(n),r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Prefetch")},e.prototype.refill=function(){for(;!this.buffer.isFull();){var t=this.upstream.next();this.buffer.push(t)}},e.prototype.next=function(){return this.refill(),this.buffer.shift()},e}(j),K=function(t){function e(e,n,i){var o=t.call(this,e,n)||this;return o.upstream=e,o.windowSize=n,o.upstreamExhausted=!1,o.random=C.alea(i||r.util.now().toString()),o.lastRead=Promise.resolve({value:null,done:!1}),o}return o(e,t),e.prototype.next=function(){return u(this,void 0,void 0,(function(){var t=this;return s(this,(function(e){return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),[2,this.lastRead]}))}))},e.prototype.randomInt=function(t){return Math.floor(this.random()*t)},e.prototype.chooseIndex=function(){return this.randomInt(this.buffer.length())},e.prototype.serialNext=function(){return u(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:this.upstreamExhausted||this.refill(),n.label=1;case 1:return this.buffer.isEmpty()?[3,3]:(t=this.chooseIndex(),[4,this.buffer.shuffleExcise(t)]);case 2:return(e=n.sent()).done?(this.upstreamExhausted=!0,[3,1]):(this.refill(),[2,e]);case 3:return[2,{value:null,done:!0}]}}))}))},e}(Y),$=function(){function t(){this.size=null}return t.prototype.batch=function(t,e){var n=this;void 0===e&&(e=!0);var i=this;return r.util.assert(t>0,(function(){return"batchSize needs to be positive, but it is\n ".concat(t)})),tt((function(){return u(n,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,i.iterator()];case 1:return[2,n.sent().columnMajorBatch(t,e,et)]}}))}))}),this.size===1/0||null==this.size?this.size:e?Math.ceil(this.size/t):Math.floor(this.size/t))},t.prototype.concatenate=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){var e,r;return s(this,(function(i){switch(i.label){case 0:return[4,n.iterator()];case 1:return r=(e=i.sent()).concatenate,[4,t.iterator()];case 2:return[2,r.apply(e,[i.sent()])]}}))}))}),this.size===1/0||t.size===1/0?1/0:null!=this.size&&null!=t.size?this.size+t.size:null)},t.prototype.filter=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().filter((function(e){return r.tidy((function(){return t(e)}))}))]}}))}))}),this.size===1/0?1/0:null)},t.prototype.forEachAsync=function(t){return u(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.iterator()];case 1:return[2,e.sent().forEachAsync(t)]}}))}))},t.prototype.map=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().map((function(e){return r.tidy((function(){return t(e)}))}))]}}))}))}),this.size)},t.prototype.mapAsync=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().mapAsync(t)]}}))}))}),this.size)},t.prototype.prefetch=function(t){var e=this;if(null==t)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");var n=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().prefetch(t)]}}))}))}),this.size)},t.prototype.repeat=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){var e,r=this;return s(this,(function(i){return e=D((function(){return u(r,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t={},[4,n.iterator()];case 1:return[2,(t.value=e.sent(),t.done=!1,t)]}}))}))})),[2,(o=e.take(t),new Z(o,a))];var o,a}))}))}),null!=this.size&&t>0?this.size*t:0===t?0:null!=this.size&&(void 0===t||t<0)?1/0:null)},t.prototype.skip=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().skip(t)]}}))}))}),null!=this.size&&t>=0&&this.size>=t?this.size-t:null!=this.size&&(this.size<t||void 0===t||t<0)?0:null)},t.prototype.shuffle=function(t,e,n){var i=this;if(void 0===n&&(n=!0),null==t||t<0)throw null==this.size?new RangeError("`Dataset.shuffle()` requires bufferSize to be specified."):new RangeError("`Dataset.shuffle()` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for `tf.Tensor`s), consider setting "+"bufferSize to the dataset size (".concat(this.size," elements)"));var o=this,a=C.alea(e||r.util.now().toString());return tt((function(){return u(i,void 0,void 0,(function(){var e;return s(this,(function(r){switch(r.label){case 0:return e=a.int32(),n&&(e+=a.int32()),[4,o.iterator()];case 1:return[2,r.sent().shuffle(t,e.toString())]}}))}))}),this.size)},t.prototype.take=function(t){var e=this,n=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,n.iterator()];case 1:return[2,e.sent().take(t)]}}))}))}),null!=this.size&&this.size>t?t:null!=this.size&&this.size<=t?this.size:null)},t.prototype.toArray=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return[4,this.iterator()];case 1:return[2,t.sent().toArray()]}}))}))},t.prototype.toArrayForTest=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return[4,this.iterator()];case 1:return[2,t.sent().toArrayForTest()]}}))}))},t}();function tt(t,e){return void 0===e&&(e=null),new(function(n){function r(){var t=n.apply(this,l([],c(arguments),!1))||this;return t.size=e,t}return o(r,n),r.prototype.iterator=function(){return u(this,void 0,void 0,(function(){return s(this,(function(e){return[2,t()]}))}))},r}($))}function et(t){return null===t?null:function(t){return null==t||null===(e=t)||"object"!=typeof e&&"function"!=typeof e||Array.isArray(t)||"object"==typeof t&&t instanceof r.Tensor||r.util.isTypedArray(t);var e}(t[0])?{value:function(t){if(0===t.length)throw new Error("Can't make a batch of zero elements.");return t[0]instanceof r.Tensor?r.stack(t):r.tensor(t)}(t),recurse:!1}:{value:null,recurse:!0}}$.MAX_BUFFER_SIZE=1e4;var nt=function(t){function e(e){var n=t.call(this)||this;return n.input=e,n}return o(e,t),e.prototype.iterator=function(){return u(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return[4,this.input.iterator()];case 1:return t=n.sent(),e=t.decodeUTF8(),[2,e.split("\n").map((function(t){return t.endsWith("\r")&&(t=t.slice(0,-1)),t}))]}}))}))},e}($),rt='"',it=Symbol("out"),ot=Symbol("field"),ut=Symbol("quote"),st=Symbol("quoteafterquote"),at=Symbol("quoteinquote"),ct=function(t){function n(n,r){var i=t.call(this)||this;return i.input=n,i.hasHeader=!0,i.fullColumnNames=null,i.columnNamesValidated=!1,i.columnConfigs=null,i.configuredColumnsOnly=!1,i.delimiter=",",i.delimWhitespace=!1,i.base=new nt(n),r||(r={}),i.hasHeader=!1!==r.hasHeader,i.fullColumnNames=r.columnNames,i.columnConfigs=r.columnConfigs,i.configuredColumnsOnly=r.configuredColumnsOnly,r.delimWhitespace?(e.util.assert(null==r.delimiter,(function(){return"Delimiter should not be provided when delimWhitespace is true."})),i.delimWhitespace=!0,i.delimiter=" "):i.delimiter=r.delimiter?r.delimiter:",",i}return o(n,t),n.prototype.columnNames=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:t.sent(),t.label=2;case 2:return[2,this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames]}}))}))},n.prototype.setColumnNames=function(){return u(this,void 0,void 0,(function(){var t,n,r,i,o,u,c,l,f=this;return s(this,(function(s){switch(s.label){case 0:return[4,this.maybeReadHeaderLine()];case 1:if(t=s.sent(),!this.fullColumnNames&&!t)throw new Error("Column names must be provided if there is no header line.");if(this.fullColumnNames&&t&&e.util.assert(t.length===this.fullColumnNames.length,(function(){return"The length of provided columnNames ("+f.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+t.length.toString()+")."})),this.fullColumnNames||(this.fullColumnNames=t),n=this.fullColumnNames.reduce((function(t,e){return t[e]=t[e]+1||1,t}),{}),r=Object.keys(n).filter((function(t){return n[t]>1})),e.util.assert(0===r.length,(function(){return"Duplicate column names found: "+r.toString()})),this.columnConfigs)try{for(i=a(Object.keys(this.columnConfigs)),o=i.next();!o.done;o=i.next())if(u=o.value,-1===this.fullColumnNames.indexOf(u))throw new Error('The key "'+u+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").")}catch(t){c={error:t}}finally{try{o&&!o.done&&(l=i.return)&&l.call(i)}finally{if(c)throw c.error}}return this.columnNamesValidated=!0,[2]}}))}))},n.prototype.maybeReadHeaderLine=function(){return u(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return this.hasHeader?[4,this.base.iterator()]:[3,3];case 1:return[4,n.sent().next()];case 2:if((t=n.sent()).done)throw new Error("No data was found for CSV parsing.");return e=t.value,[2,this.parseRow(e,!1)];case 3:return[2,null]}}))}))},n.prototype.iterator=function(){return u(this,void 0,void 0,(function(){var t,e=this;return s(this,(function(n){switch(n.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:n.sent(),n.label=2;case 2:return[4,this.base.iterator()];case 3:return t=n.sent(),this.hasHeader&&(t=t.skip(1)),[2,t.map((function(t){return e.makeDataElement(t)}))]}}))}))},n.prototype.makeDataElement=function(t){for(var e=this.parseRow(t),n={},r={},i=0;i<this.fullColumnNames.length;i++){var o=this.fullColumnNames[i],u=this.columnConfigs?this.columnConfigs[o]:null;if(!this.configuredColumnsOnly||u){var s=e[i],a=null;if(""===s)if(u&&void 0!==u.default)a=u.default;else{if(u&&(u.required||u.isLabel))throw new Error("Required column ".concat(o," is empty in this line: ").concat(t));a=void 0}else{var c=Number(s);if(isNaN(c))a=u&&"bool"===u.dtype?this.getBoolean(s):s;else if(u&&u.dtype)switch(u.dtype){case"float32":default:a=c;break;case"int32":a=Math.floor(c);break;case"bool":a=this.getBoolean(s)}else a=c}u&&u.isLabel?r[o]=a:n[o]=a}}return 0===Object.keys(r).length?n:{xs:n,ys:r}},n.prototype.getBoolean=function(t){return"1"===t||"true"===t.toLowerCase()?1:0},n.prototype.parseRow=function(t,e){void 0===e&&(e=!0);for(var n=[],r=0,i=t.length,o=it,u=0;u<i;u++)switch(o){case it:switch(t.charAt(u)){case rt:r=u+1,o=ut;break;case this.delimiter:if(r=u+1," "===this.delimiter&&this.delimWhitespace)break;n.push(""),o=it;break;default:o=ot,r=u}break;case ot:if(t.charAt(u)===this.delimiter)n.push(t.substring(r,u)),o=it,r=u+1;break;case ut:if(t.charAt(u)===rt)o=st;break;case st:switch(t.charAt(u)){case this.delimiter:n.push(t.substring(r,u-1)),o=it,r=u+1;break;case rt:o=ut;break;default:o=at}break;case at:if(t.charAt(u)===rt)o=ut}if(o===st?n.push(t.substring(r,i-1)):n.push(t.substring(r)),e&&n.length!==this.fullColumnNames.length)throw new Error("Invalid row in csv file. Should have ".concat(this.fullColumnNames.length," elements in a row, but got ").concat(n));return n},n}($),lt=function(t){function n(e){var n=t.call(this)||this;n.microphoneConfig=e,n.isClosed=!1,n.fftSize=e.fftSize||1024;var r=Math.log2(n.fftSize);if(n.fftSize<0||r<4||r>14||!Number.isInteger(r))throw new Error("Invalid fftSize: it must be a power of 2 between "+"2 to 4 and 2 to 14, but got ".concat(n.fftSize));if(n.numFrames=e.numFramesPerSpectrogram||43,n.sampleRateHz=e.sampleRateHz,n.columnTruncateLength=e.columnTruncateLength||n.fftSize,n.audioTrackConstraints=e.audioTrackConstraints,n.smoothingTimeConstant=e.smoothingTimeConstant||0,n.includeSpectrogram=!1!==e.includeSpectrogram,n.includeWaveform=!0===e.includeWaveform,!n.includeSpectrogram&&!n.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.");return n}return o(n,t),n.prototype.summary=function(){return"microphone"},n.create=function(t){return void 0===t&&(t={}),u(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:if(!e.env().get("IS_BROWSER"))throw new Error("microphone API is only supported in browser environment.");return[4,(r=new n(t)).start()];case 1:return i.sent(),[2,r]}}))}))},n.prototype.start=function(){return u(this,void 0,void 0,(function(){var t,e,n,r;return s(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=this,[4,navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1})];case 1:return t.stream=i.sent(),[3,3];case 2:throw e=i.sent(),new Error("Error thrown while initializing video stream: ".concat(e.message));case 3:if(!this.stream)throw new Error("Could not obtain audio from microphone.");if(n=window.AudioContext||window.webkitAudioContext,this.audioContext=new n,this.sampleRateHz){if(this.audioContext.sampleRate!==this.sampleRateHz)throw new Error("Mismatch in sampling rate: "+"Expected: ".concat(this.sampleRateHz,"; ")+"Actual: ".concat(this.audioContext.sampleRate))}else this.sampleRateHz=this.audioContext.sampleRate;return r=this.audioContext.createMediaStreamSource(this.stream),this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,r.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize),[2]}}))}))},n.prototype.next=function(){return u(this,void 0,void 0,(function(){var t,e,n,r,i;return s(this,(function(o){switch(o.label){case 0:return this.isClosed?[2,{value:null,done:!0}]:[4,this.getAudioData()];case 1:return n=o.sent(),this.includeSpectrogram&&(r=this.flattenQueue(n.freqDataQueue),t=this.getTensorFromAudioDataArray(r,[this.numFrames,this.columnTruncateLength,1])),this.includeWaveform&&(i=this.flattenQueue(n.timeDataQueue),e=this.getTensorFromAudioDataArray(i,[this.numFrames*this.fftSize,1])),[2,{value:{spectrogram:t,waveform:e},done:!1}]}}))}))},n.prototype.capture=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.next()];case 1:return[2,t.sent().value]}}))}))},n.prototype.getAudioData=function(){return u(this,void 0,void 0,(function(){var t,e,n,r=this;return s(this,(function(i){return t=[],e=[],n=0,[2,new Promise((function(i){var o=setInterval((function(){r.includeSpectrogram&&(r.analyser.getFloatFrequencyData(r.freqData),r.freqData[0]===-1/0&&i({freqDataQueue:t,timeDataQueue:e}),t.push(r.freqData.slice(0,r.columnTruncateLength))),r.includeWaveform&&(r.analyser.getFloatTimeDomainData(r.timeData),e.push(r.timeData.slice())),++n===r.numFrames&&(clearInterval(o),i({freqDataQueue:t,timeDataQueue:e}))}),r.fftSize/r.sampleRateHz*1e3)}))]}))}))},n.prototype.stop=function(){this.isClosed||(this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop())},n.prototype.toArray=function(){throw new Error("Can not convert infinite audio stream to array.")},n.prototype.getSampleRate=function(){return this.sampleRateHz},n.prototype.flattenQueue=function(t){var e=t[0].length,n=new Float32Array(t.length*e);return t.forEach((function(t,r){return n.set(t,r*e)})),n},n.prototype.getTensorFromAudioDataArray=function(t,n){var r=new Float32Array(e.util.sizeFromShape(n));return r.set(t,r.length-t.length),e.tensor(r,n)},n}(j),ft=function(t){function n(n,r){var i=t.call(this)||this;if(i.webcamVideoElement=n,i.webcamConfig=r,i.isClosed=!0,i.resize=!1,i.needToResize())if(i.resize=!0,i.cropSize=[i.webcamConfig.resizeHeight,i.webcamConfig.resizeWidth],i.cropBoxInd=e.tensor1d([0],"int32"),i.webcamConfig.centerCrop){var o=1*i.webcamConfig.resizeWidth/i.webcamVideoElement.width,u=1*i.webcamConfig.resizeHeight/i.webcamVideoElement.height,s=(1-o)/2,a=(1-u)/2,c=s+o,l=u+a;i.cropBox=e.tensor2d([a,s,l,c],[1,4])}else i.cropBox=e.tensor2d([0,0,1,1],[1,4]);return i}return o(n,t),n.prototype.summary=function(){return"webcam"},n.create=function(t,r){return void 0===r&&(r={}),u(this,void 0,void 0,(function(){var i;return s(this,(function(o){switch(o.label){case 0:if(!e.env().get("IS_BROWSER"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!t){if(t=document.createElement("video"),!r.resizeWidth||!r.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");t.width=r.resizeWidth,t.height=r.resizeHeight}return[4,(i=new n(t,r)).start()];case 1:return o.sent(),[2,i]}}))}))},n.prototype.start=function(){return u(this,void 0,void 0,(function(){var t,n,r=this;return s(this,(function(i){switch(i.label){case 0:this.webcamConfig.facingMode&&e.util.assert("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,(function(){return"Invalid webcam facing mode: ".concat(r.webcamConfig.facingMode,". ")+"Please provide 'user' or 'environment'"})),i.label=1;case 1:return i.trys.push([1,3,,4]),t=this,[4,navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})];case 2:return t.stream=i.sent(),[3,4];case 3:throw(n=i.sent()).message="Error thrown while initializing video stream: ".concat(n.message),n;case 4:if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream}catch(t){console.log(t),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,[2,new Promise((function(t){r.webcamVideoElement.onloadedmetadata=function(){t()}}))]}}))}))},n.prototype.next=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(n){if(this.isClosed)return[2,{value:null,done:!0}];try{t=e.browser.fromPixels(this.webcamVideoElement)}catch(t){throw new Error("Error thrown converting video to pixels: ".concat(JSON.stringify(t)))}if(!this.resize)return[2,{value:t,done:!1}];try{return[2,{value:this.cropAndResizeFrame(t),done:!1}]}catch(t){throw new Error("Error thrown cropping the video: ".concat(t.message))}finally{t.dispose()}return[2]}))}))},n.prototype.needToResize=function(){return!(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight)},n.prototype.cropAndResizeFrame=function(t){var n=this;return e.tidy((function(){var r,i=e.expandDims(e.cast(t,"float32"),0),o=(r=e.image.cropAndResize(i,n.cropBox,n.cropBoxInd,n.cropSize,"bilinear")).shape;return e.reshape(r,o.slice(1))}))},n.prototype.capture=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.next()];case 1:return[2,t.sent().value]}}))}))},n.prototype.stop=function(){this.stream.getTracks().forEach((function(t){return t.stop()}));try{this.webcamVideoElement.srcObject=null}catch(t){console.log(t),this.webcamVideoElement.src=null}this.isClosed=!0},n.prototype.toArray=function(){throw new Error("Can not convert infinite video stream to array.")},n}(j),ht=function(){},dt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.split=function(t){return new pt(this,t)},e}(j),pt=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.impl=new vt(e,n),r}return o(e,t),e.prototype.summary=function(){return this.impl.summary()},e.prototype.next=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.impl.next()]}))}))},e}(dt),vt=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.separator=n,r.carryover="",r}return o(e,t),e.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Split('").concat(this.separator,"')")},e.prototype.pump=function(){return u(this,void 0,void 0,(function(){var t,e,n,r,i,o,u;return s(this,(function(s){switch(s.label){case 0:return[4,this.upstream.next()];case 1:if((t=s.sent()).done)return""===this.carryover?[2,!1]:(this.outputQueue.push(this.carryover),this.carryover="",[2,!0]);(e=t.value.split(this.separator))[0]=this.carryover+e[0];try{for(n=a(e.slice(0,-1)),r=n.next();!r.done;r=n.next())i=r.value,this.outputQueue.push(i)}catch(t){o={error:t}}finally{try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}}return this.carryover=e[e.length-1],[2,!0]}}))}))},e}(X),mt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.decodeUTF8=function(){return new yt(this)},e}(j),yt=function(t){function e(e){var n=t.call(this)||this;return n.upstream=e,n.impl=new wt(e),n}return o(e,t),e.prototype.summary=function(){return this.impl.summary()},e.prototype.next=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.impl.next()]}))}))},e}(dt),wt=function(t){function n(n){var r=t.call(this)||this;if(r.upstream=n,e.env().get("IS_BROWSER"))r.decoder=new TextDecoder("utf-8");else{var i=require("string_decoder").StringDecoder;r.decoder=new i("utf8")}return r}return o(n,t),n.prototype.summary=function(){return"".concat(this.upstream.summary()," -> Utf8")},n.prototype.pump=function(){return u(this,void 0,void 0,(function(){var t,n,r;return s(this,(function(i){switch(i.label){case 0:return[4,this.upstream.next()];case 1:return(t=i.sent()).done?[2,!1]:(n=t.value,r=e.env().get("IS_BROWSER")?this.decoder.decode(n,{stream:!0}):this.decoder.write(Buffer.from(n.buffer)),this.outputQueue.push(r),[2,!0])}}))}))},n}(X),bt=function(t){function n(n,r){void 0===r&&(r={});var i=t.call(this)||this;return i.file=n,i.options=r,e.util.assert(n instanceof Uint8Array||!!e.env().get("IS_BROWSER")&&(n instanceof File||n instanceof Blob),(function(){return"FileChunkIterator only supports File, Blob and Uint8Array right now."})),i.offset=r.offset||0,i.chunkSize=r.chunkSize||1048576,i}return o(n,t),n.prototype.summary=function(){return"FileChunks ".concat(this.file)},n.prototype.next=function(){return u(this,void 0,void 0,(function(){var t,e,n=this;return s(this,(function(r){switch(r.label){case 0:return this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size)?[2,{value:null,done:!0}]:(t=new Promise((function(t,e){var r=n.offset+n.chunkSize;if(n.file instanceof Uint8Array)t(new Uint8Array(n.file.slice(n.offset,r)));else{var i=new FileReader;i.onload=function(n){var r=i.result;if(r instanceof ArrayBuffer&&(r=new Uint8Array(r)),!(r instanceof Uint8Array))return e(new TypeError("FileReader returned unknown type."));t(r)},i.onabort=function(t){return e(new Error("Aborted"))},i.onerror=function(t){return e(new Error(t.type))};var o=n.file.slice(n.offset,r);i.readAsArrayBuffer(o)}n.offset=r})),e={},[4,t]);case 1:return[2,(e.value=r.sent(),e.done=!1,e)]}}))}))},n}(mt);function gt(t,n,r){return void 0===n&&(n={}),u(this,void 0,void 0,(function(){var i,o,u,a,c;return s(this,(function(s){switch(s.label){case 0:return"string"==typeof t?i=t:(i=t.url,o=xt(t)),[4,(r||e.util.fetch)(i,o)];case 1:return(u=s.sent()).ok?(c=Uint8Array.bind,[4,u.arrayBuffer()]):[3,3];case 2:return a=new(c.apply(Uint8Array,[void 0,s.sent()])),[2,new bt(a,n)];case 3:throw new Error(u.statusText)}}))}))}var xt=function(t){return{method:t.method,headers:t.headers,body:t.body,mode:t.mode,credentials:t.credentials,cache:t.cache,redirect:t.redirect,referrer:t.referrer,integrity:t.integrity}};function Ct(t){return"string"==typeof t&&"file://"===t.slice(0,7)}var zt=function(t){function n(e,n){void 0===n&&(n={});var r=t.call(this)||this;return r.input=e,r.options=n,r}return o(n,t),n.prototype.iterator=function(){return u(this,void 0,void 0,(function(){var t;return s(this,(function(n){return Ct(this.input)&&e.env().get("IS_NODE")&&(t=require("fs"),this.input=t.readFileSync(this.input.slice(7))),[2,new bt(this.input,this.options)]}))}))},n}(ht),Et=function(t){function e(e,n){void 0===n&&(n={});var r=t.call(this)||this;return r.url=e,r.fileOptions=n,r}return o(e,t),e.prototype.iterator=function(){return u(this,void 0,void 0,(function(){return s(this,(function(t){return Ct(this.url)?[2,new zt(this.url,this.fileOptions).iterator()]:[2,gt(this.url,this.fileOptions)]}))}))},e}(ht);t.CSVDataset=ct,t.Dataset=$,t.FileDataSource=zt,t.TextLineDataset=nt,t.URLDataSource=Et,t.array=function(t){var e=this;return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(e){return[2,N(t)]}))}))}),t.length)},t.csv=function(t,e){return void 0===e&&(e={}),new ct(new Et(t),e)},t.func=function(t){var e=this,n=D(t);return tt((function(){return u(e,void 0,void 0,(function(){return s(this,(function(t){return[2,n]}))}))}))},t.generator=function(t){var e=this;return tt((function(){return u(e,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return[4,t()];case 1:return e=n.sent(),[2,D((function(){return e.next()}))]}}))}))}))},t.microphone=function(t){return u(this,void 0,void 0,(function(){return s(this,(function(e){return[2,lt.create(t)]}))}))},t.version_data="4.3.0",t.webcam=function(t,e){return u(this,void 0,void 0,(function(){return s(this,(function(n){return[2,ft.create(t,e)]}))}))},t.zip=function(t){var e,n=this;if(!T(t))throw new Error("The argument to zip() must be an object or array.");if(Array.isArray(t))for(var r=0;r<t.length;r++)e=null==e?t[r].size:Math.min(e,t[r].size);else if(t instanceof Object)for(var i in t)e=null==e?t[i].size:Math.min(e,t[i].size);return tt((function(){return u(n,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return[4,R(t,(function(t){if(t instanceof $)return{value:t.iterator(),recurse:!1};if(T(t))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")}))];case 1:return e=n.sent(),[2,(r=e,i=I.SHORTEST,void 0===i&&(i=I.FAIL),new J(r,i))]}var r,i}))}))}),e)},Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=tf-data.min.js.map

@@ -20,4 +20,4 @@ /**

import { DataType, TensorContainer } from '@tensorflow/tfjs-core';
export declare type Container<T> = ContainerObject<T> | ContainerArray<T>;
export declare type ContainerOrT<T> = Container<T> | T;
export type Container<T> = ContainerObject<T> | ContainerArray<T>;
export type ContainerOrT<T> = Container<T> | T;
export interface ContainerObject<T> {

@@ -31,3 +31,3 @@ [x: string]: ContainerOrT<T>;

*/
export declare type FileElement = File | Blob | Uint8Array;
export type FileElement = File | Blob | Uint8Array;
/**

@@ -34,0 +34,0 @@ * A dictionary containing column level configurations when reading and decoding

@@ -25,3 +25,3 @@ /**

*/
export declare type DeepMapResult = {
export type DeepMapResult = {
value: any;

@@ -78,3 +78,3 @@ recurse: boolean;

*/
export declare type DeepMapAsyncResult = {
export type DeepMapAsyncResult = {
value: Promise<any>;

@@ -81,0 +81,0 @@ recurse: boolean;

/** @license See the LICENSE file. */
/// <amd-module name="@tensorflow/tfjs-data/dist/version" />
declare const version = "4.2.0";
declare const version = "4.3.0";
export { version };
/** @license See the LICENSE file. */
// This code is auto-generated, do not modify this file!
const version = '4.2.0';
const version = '4.3.0';
export { version };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmVyc2lvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3RmanMtZGF0YS9zcmMvdmVyc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxxQ0FBcUM7QUFFckMsd0RBQXdEO0FBQ3hELE1BQU0sT0FBTyxHQUFHLE9BQU8sQ0FBQztBQUN4QixPQUFPLEVBQUMsT0FBTyxFQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKiogQGxpY2Vuc2UgU2VlIHRoZSBMSUNFTlNFIGZpbGUuICovXG5cbi8vIFRoaXMgY29kZSBpcyBhdXRvLWdlbmVyYXRlZCwgZG8gbm90IG1vZGlmeSB0aGlzIGZpbGUhXG5jb25zdCB2ZXJzaW9uID0gJzQuMi4wJztcbmV4cG9ydCB7dmVyc2lvbn07XG4iXX0=
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmVyc2lvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3RmanMtZGF0YS9zcmMvdmVyc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxxQ0FBcUM7QUFFckMsd0RBQXdEO0FBQ3hELE1BQU0sT0FBTyxHQUFHLE9BQU8sQ0FBQztBQUN4QixPQUFPLEVBQUMsT0FBTyxFQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKiogQGxpY2Vuc2UgU2VlIHRoZSBMSUNFTlNFIGZpbGUuICovXG5cbi8vIFRoaXMgY29kZSBpcyBhdXRvLWdlbmVyYXRlZCwgZG8gbm90IG1vZGlmeSB0aGlzIGZpbGUhXG5jb25zdCB2ZXJzaW9uID0gJzQuMy4wJztcbmV4cG9ydCB7dmVyc2lvbn07XG4iXX0=
{
"name": "@tensorflow/tfjs-data",
"version": "4.2.0",
"version": "4.3.0",
"description": "TensorFlow Data API in JavaScript",

@@ -35,3 +35,3 @@ "private": false,

"peerDependencies": {
"@tensorflow/tfjs-core": "4.2.0",
"@tensorflow/tfjs-core": "4.3.0",
"seedrandom": "^3.0.5"

@@ -38,0 +38,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc