diff --git a/docs/dev_sources.concat.js b/docs/dev_sources.concat.js new file mode 100644 index 0000000..65e0d2e --- /dev/null +++ b/docs/dev_sources.concat.js @@ -0,0 +1,21965 @@ +(() => { + var __create = Object.create; + var __defProp = Object.defineProperty; + var __getOwnPropDesc = Object.getOwnPropertyDescriptor; + var __getOwnPropNames = Object.getOwnPropertyNames; + var __getProtoOf = Object.getPrototypeOf; + var __hasOwnProp = Object.prototype.hasOwnProperty; + var __commonJS = (cb, mod) => function __require() { + return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; + }; + var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; + }; + var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, + mod + )); + var __decorateClass = (decorators, target, key, kind) => { + var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target; + for (var i23 = decorators.length - 1, decorator; i23 >= 0; i23--) + if (decorator = decorators[i23]) + result = (kind ? decorator(target, key, result) : decorator(result)) || result; + if (kind && result) + __defProp(target, key, result); + return result; + }; + + // node_modules/jsdifflib/index.js + var require_jsdifflib = __commonJS({ + "node_modules/jsdifflib/index.js"(exports, module) { + __whitespace = { " ": true, " ": true, "\n": true, "\f": true, "\r": true }; + var difflib2 = module.exports = { + defaultJunkFunction: function(c12) { + return __whitespace.hasOwnProperty(c12); + }, + stripLinebreaks: function(str) { + return str.replace(/^[\n\r]*|[\n\r]*$/g, ""); + }, + stringAsLines: function(str) { + var lfpos = str.indexOf("\n"); + var crpos = str.indexOf("\r"); + var linebreak = lfpos > -1 && crpos > -1 || crpos < 0 ? "\n" : "\r"; + var lines = str.split(linebreak); + for (var i23 = 0; i23 < lines.length; i23++) { + lines[i23] = difflib2.stripLinebreaks(lines[i23]); + } + return lines; + }, + // iteration-based reduce implementation + __reduce: function(func, list, initial) { + if (initial != null) { + var value = initial; + var idx = 0; + } else if (list) { + var value = list[0]; + var idx = 1; + } else { + return null; + } + for (; idx < list.length; idx++) { + value = func(value, list[idx]); + } + return value; + }, + // comparison function for sorting lists of numeric tuples + __ntuplecomp: function(a11, b7) { + var mlen = Math.max(a11.length, b7.length); + for (var i23 = 0; i23 < mlen; i23++) { + if (a11[i23] < b7[i23]) + return -1; + if (a11[i23] > b7[i23]) + return 1; + } + return a11.length == b7.length ? 0 : a11.length < b7.length ? -1 : 1; + }, + __calculate_ratio: function(matches3, length) { + return length ? 2 * matches3 / length : 1; + }, + // returns a function that returns true if a key passed to the returned function + // is in the dict (js object) provided to this function; replaces being able to + // carry around dict.has_key in python... + __isindict: function(dict) { + return function(key) { + return dict.hasOwnProperty(key); + }; + }, + // replacement for python's dict.get function -- need easy default values + __dictget: function(dict, key, defaultValue) { + return dict.hasOwnProperty(key) ? dict[key] : defaultValue; + }, + SequenceMatcher: function(a11, b7, isjunk) { + this.set_seqs = function(a12, b8) { + this.set_seq1(a12); + this.set_seq2(b8); + }; + this.set_seq1 = function(a12) { + if (a12 == this.a) + return; + this.a = a12; + this.matching_blocks = this.opcodes = null; + }; + this.set_seq2 = function(b8) { + if (b8 == this.b) + return; + this.b = b8; + this.matching_blocks = this.opcodes = this.fullbcount = null; + this.__chain_b(); + }; + this.__chain_b = function() { + var b8 = this.b; + var n31 = b8.length; + var b2j = this.b2j = {}; + var populardict = {}; + for (var i23 = 0; i23 < b8.length; i23++) { + var elt = b8[i23]; + if (b2j.hasOwnProperty(elt)) { + var indices = b2j[elt]; + if (n31 >= 200 && indices.length * 100 > n31) { + populardict[elt] = 1; + delete b2j[elt]; + } else { + indices.push(i23); + } + } else { + b2j[elt] = [i23]; + } + } + for (var elt in populardict) { + if (populardict.hasOwnProperty(elt)) { + delete b2j[elt]; + } + } + var isjunk2 = this.isjunk; + var junkdict = {}; + if (isjunk2) { + for (var elt in populardict) { + if (populardict.hasOwnProperty(elt) && isjunk2(elt)) { + junkdict[elt] = 1; + delete populardict[elt]; + } + } + for (var elt in b2j) { + if (b2j.hasOwnProperty(elt) && isjunk2(elt)) { + junkdict[elt] = 1; + delete b2j[elt]; + } + } + } + this.isbjunk = difflib2.__isindict(junkdict); + this.isbpopular = difflib2.__isindict(populardict); + }; + this.find_longest_match = function(alo, ahi, blo, bhi) { + var a12 = this.a; + var b8 = this.b; + var b2j = this.b2j; + var isbjunk = this.isbjunk; + var besti = alo; + var bestj = blo; + var bestsize = 0; + var j3 = null; + var j2len = {}; + var nothing = []; + for (var i23 = alo; i23 < ahi; i23++) { + var newj2len = {}; + var jdict = difflib2.__dictget(b2j, a12[i23], nothing); + for (var jkey in jdict) { + if (jdict.hasOwnProperty(jkey)) { + j3 = jdict[jkey]; + if (j3 < blo) + continue; + if (j3 >= bhi) + break; + newj2len[j3] = k = difflib2.__dictget(j2len, j3 - 1, 0) + 1; + if (k > bestsize) { + besti = i23 - k + 1; + bestj = j3 - k + 1; + bestsize = k; + } + } + } + j2len = newj2len; + } + while (besti > alo && bestj > blo && !isbjunk(b8[bestj - 1]) && a12[besti - 1] == b8[bestj - 1]) { + besti--; + bestj--; + bestsize++; + } + while (besti + bestsize < ahi && bestj + bestsize < bhi && !isbjunk(b8[bestj + bestsize]) && a12[besti + bestsize] == b8[bestj + bestsize]) { + bestsize++; + } + while (besti > alo && bestj > blo && isbjunk(b8[bestj - 1]) && a12[besti - 1] == b8[bestj - 1]) { + besti--; + bestj--; + bestsize++; + } + while (besti + bestsize < ahi && bestj + bestsize < bhi && isbjunk(b8[bestj + bestsize]) && a12[besti + bestsize] == b8[bestj + bestsize]) { + bestsize++; + } + return [besti, bestj, bestsize]; + }; + this.get_matching_blocks = function() { + if (this.matching_blocks != null) + return this.matching_blocks; + var la = this.a.length; + var lb = this.b.length; + var queue = [[0, la, 0, lb]]; + var matching_blocks = []; + var alo, ahi, blo, bhi, qi, i23, j3, k8, x6; + while (queue.length) { + qi = queue.pop(); + alo = qi[0]; + ahi = qi[1]; + blo = qi[2]; + bhi = qi[3]; + x6 = this.find_longest_match(alo, ahi, blo, bhi); + i23 = x6[0]; + j3 = x6[1]; + k8 = x6[2]; + if (k8) { + matching_blocks.push(x6); + if (alo < i23 && blo < j3) + queue.push([alo, i23, blo, j3]); + if (i23 + k8 < ahi && j3 + k8 < bhi) + queue.push([i23 + k8, ahi, j3 + k8, bhi]); + } + } + matching_blocks.sort(difflib2.__ntuplecomp); + var i1 = j1 = k1 = block = 0; + var non_adjacent = []; + for (var idx in matching_blocks) { + if (matching_blocks.hasOwnProperty(idx)) { + block = matching_blocks[idx]; + i2 = block[0]; + j2 = block[1]; + k2 = block[2]; + if (i1 + k1 == i2 && j1 + k1 == j2) { + k1 += k2; + } else { + if (k1) + non_adjacent.push([i1, j1, k1]); + i1 = i2; + j1 = j2; + k1 = k2; + } + } + } + if (k1) + non_adjacent.push([i1, j1, k1]); + non_adjacent.push([la, lb, 0]); + this.matching_blocks = non_adjacent; + return this.matching_blocks; + }; + this.get_opcodes = function() { + if (this.opcodes != null) + return this.opcodes; + var i23 = 0; + var j3 = 0; + var answer = []; + this.opcodes = answer; + var block2, ai, bj, size, tag; + var blocks = this.get_matching_blocks(); + for (var idx in blocks) { + if (blocks.hasOwnProperty(idx)) { + block2 = blocks[idx]; + ai = block2[0]; + bj = block2[1]; + size = block2[2]; + tag = ""; + if (i23 < ai && j3 < bj) { + tag = "replace"; + } else if (i23 < ai) { + tag = "delete"; + } else if (j3 < bj) { + tag = "insert"; + } + if (tag) + answer.push([tag, i23, ai, j3, bj]); + i23 = ai + size; + j3 = bj + size; + if (size) + answer.push(["equal", ai, i23, bj, j3]); + } + } + return answer; + }; + this.get_grouped_opcodes = function(n31) { + if (!n31) + n31 = 3; + var codes = this.get_opcodes(); + if (!codes) + codes = [["equal", 0, 1, 0, 1]]; + var code2, tag, i1, i23, j12, j22; + if (codes[0][0] == "equal") { + code2 = codes[0]; + tag = code2[0]; + i1 = code2[1]; + i23 = code2[2]; + j12 = code2[3]; + j22 = code2[4]; + codes[0] = [tag, Math.max(i1, i23 - n31), i23, Math.max(j12, j22 - n31), j22]; + } + if (codes[codes.length - 1][0] == "equal") { + code2 = codes[codes.length - 1]; + tag = code2[0]; + i1 = code2[1]; + i23 = code2[2]; + j12 = code2[3]; + j22 = code2[4]; + codes[codes.length - 1] = [tag, i1, Math.min(i23, i1 + n31), j12, Math.min(j22, j12 + n31)]; + } + var nn = n31 + n31; + var groups = []; + for (var idx in codes) { + if (codes.hasOwnProperty(idx)) { + code2 = codes[idx]; + tag = code2[0]; + i1 = code2[1]; + i23 = code2[2]; + j12 = code2[3]; + j22 = code2[4]; + if (tag == "equal" && i23 - i1 > nn) { + groups.push([tag, i1, Math.min(i23, i1 + n31), j12, Math.min(j22, j12 + n31)]); + i1 = Math.max(i1, i23 - n31); + j12 = Math.max(j12, j22 - n31); + } + groups.push([tag, i1, i23, j12, j22]); + } + } + if (groups && groups[groups.length - 1][0] == "equal") + groups.pop(); + return groups; + }; + this.ratio = function() { + matches = difflib2.__reduce( + function(sum, triple) { + return sum + triple[triple.length - 1]; + }, + this.get_matching_blocks(), + 0 + ); + return difflib2.__calculate_ratio(matches, this.a.length + this.b.length); + }; + this.quick_ratio = function() { + var fullbcount, elt; + if (this.fullbcount == null) { + this.fullbcount = fullbcount = {}; + for (var i23 = 0; i23 < this.b.length; i23++) { + elt = this.b[i23]; + fullbcount[elt] = difflib2.__dictget(fullbcount, elt, 0) + 1; + } + } + fullbcount = this.fullbcount; + var avail = {}; + var availhas = difflib2.__isindict(avail); + var matches3 = numb = 0; + for (var i23 = 0; i23 < this.a.length; i23++) { + elt = this.a[i23]; + if (availhas(elt)) { + numb = avail[elt]; + } else { + numb = difflib2.__dictget(fullbcount, elt, 0); + } + avail[elt] = numb - 1; + if (numb > 0) + matches3++; + } + return difflib2.__calculate_ratio(matches3, this.a.length + this.b.length); + }; + this.real_quick_ratio = function() { + var la = this.a.length; + var lb = this.b.length; + return _calculate_ratio(Math.min(la, lb), la + lb); + }; + this.isjunk = isjunk ? isjunk : difflib2.defaultJunkFunction; + this.a = this.b = null; + this.set_seqs(a11, b7); + }, + /** + * Builds and returns a visual diff view. The single parameter, `params', should contain + * the following values: + * + * - baseText: the string that will be used as the base input to SequenceMatcher + * - nextText: the string that will be used as the new text input to SequenceMatcher + * + * or + * + * - baseTextLines: the array of strings that was used as the base text input to SequenceMatcher + * - newTextLines: the array of strings that was used as the new text input to SequenceMatcher + * - opcodes: the array of arrays returned by SequenceMatcher.get_opcodes() + * + * and: + * + * - baseTextName: the title to be displayed above the base text listing in the diff view; defaults + * to "Base Text" + * - newTextName: the title to be displayed above the new text listing in the diff view; defaults + * to "New Text" + * - contextSize: the number of lines of context to show around differences; by default, all lines + * are shown + * - inline: if false, a side-by-side diff view is generated (default); if true, an inline diff view is + * generated + */ + buildView: function(params) { + var baseTextLines = params.baseTextLines === void 0 ? difflib2.stringAsLines(params.baseText) : params.baseTextLines; + var newTextLines = params.newTextLines === void 0 ? difflib2.stringAsLines(params.newText) : params.newTextLines; + var opcodes = params.opcodes === void 0 ? new difflib2.SequenceMatcher(baseTextLines, newTextLines).get_opcodes() : params.opcodes; + var baseTextName = params.baseTextName ? params.baseTextName : "Base Text"; + var newTextName = params.newTextName ? params.newTextName : "New Text"; + var contextSize = params.contextSize; + var inline = params.inline || false; + if (baseTextLines == null) + throw "Cannot build diff view; baseTextLines is not defined."; + if (newTextLines == null) + throw "Cannot build diff view; newTextLines is not defined."; + if (!opcodes) + throw "Canno build diff view; opcodes is not defined."; + function celt(name, clazz) { + var e33 = document.createElement(name); + e33.className = clazz; + return e33; + } + function telt(name, text) { + var e33 = document.createElement(name); + e33.appendChild(document.createTextNode(text)); + return e33; + } + function ctelt(name, clazz, text) { + var e33 = document.createElement(name); + e33.className = clazz; + e33.appendChild(document.createTextNode(text)); + return e33; + } + var tdata = document.createElement("thead"); + var node = document.createElement("tr"); + tdata.appendChild(node); + if (inline) { + node.appendChild(document.createElement("th")); + node.appendChild(document.createElement("th")); + node.appendChild(ctelt("th", "texttitle", baseTextName + " vs. " + newTextName)); + } else { + node.appendChild(document.createElement("th")); + node.appendChild(ctelt("th", "texttitle", baseTextName)); + node.appendChild(document.createElement("th")); + node.appendChild(ctelt("th", "texttitle", newTextName)); + } + tdata = [tdata]; + var rows = []; + var node2; + function addCells(row, tidx, tend, textLines, change2) { + if (tidx < tend) { + row.appendChild(telt("th", (tidx + 1).toString())); + row.appendChild(ctelt("td", change2, textLines[tidx].replace(/\t/g, "\xA0\xA0\xA0\xA0"))); + return tidx + 1; + } else { + row.appendChild(document.createElement("th")); + row.appendChild(celt("td", "empty")); + return tidx; + } + } + function addCellsInline(row, tidx, tidx2, textLines, change2) { + row.className = change2; + row.appendChild(telt("th", tidx == null ? "" : (tidx + 1).toString())); + row.appendChild(telt("th", tidx2 == null ? "" : (tidx2 + 1).toString())); + row.appendChild(telt("td", textLines[tidx != null ? tidx : tidx2].replace(/\t/g, "\xA0\xA0\xA0\xA0"))); + } + for (var idx = 0; idx < opcodes.length; idx++) { + code = opcodes[idx]; + change = code[0]; + var b7 = code[1]; + var be = code[2]; + var n31 = code[3]; + var ne = code[4]; + var rowcnt = Math.max(be - b7, ne - n31); + var toprows = []; + var botrows = []; + for (var i23 = 0; i23 < rowcnt; i23++) { + if (contextSize && opcodes.length > 1 && (idx > 0 && i23 == contextSize || idx == 0 && i23 == 0) && change == "equal") { + var jump = rowcnt - (idx == 0 ? 1 : 2) * contextSize; + if (jump > 1) { + toprows.push(node = document.createElement("tr")); + b7 += jump; + n31 += jump; + i23 += jump - 1; + node.appendChild(telt("th", "...")); + if (!inline) + node.appendChild(ctelt("td", "skip", "")); + node.appendChild(telt("th", "...")); + node.appendChild(ctelt("td", "skip", "")); + if (idx + 1 == opcodes.length) { + break; + } else { + continue; + } + } + } + toprows.push(node = document.createElement("tr")); + if (inline) { + if (change == "insert") { + addCellsInline(node, null, n31++, newTextLines, change); + } else if (change == "replace") { + botrows.push(node2 = document.createElement("tr")); + if (b7 < be) + addCellsInline(node, b7++, null, baseTextLines, "delete"); + if (n31 < ne) + addCellsInline(node2, null, n31++, newTextLines, "insert"); + } else if (change == "delete") { + addCellsInline(node, b7++, null, baseTextLines, change); + } else { + addCellsInline(node, b7++, n31++, baseTextLines, change); + } + } else { + b7 = addCells(node, b7, be, baseTextLines, change); + n31 = addCells(node, n31, ne, newTextLines, change); + } + } + for (var i23 = 0; i23 < toprows.length; i23++) + rows.push(toprows[i23]); + for (var i23 = 0; i23 < botrows.length; i23++) + rows.push(botrows[i23]); + } + rows.push(node = ctelt("th", "author", "diff view generated by ")); + node.setAttribute("colspan", inline ? 3 : 4); + node.appendChild(node2 = telt("a", "jsdifflib")); + node2.setAttribute("href", "http://github.com/cemerick/jsdifflib"); + tdata.push(node = document.createElement("tbody")); + for (var idx in rows) + node.appendChild(rows[idx]); + node = celt("table", "diff" + (inline ? " inlinediff" : "")); + for (var idx in tdata) + node.appendChild(tdata[idx]); + return node; + } + }; + } + }); + + // node_modules/jstat/dist/jstat.js + var require_jstat = __commonJS({ + "node_modules/jstat/dist/jstat.js"(exports, module) { + (function(window2, factory) { + if (typeof exports === "object") { + module.exports = factory(); + } else if (typeof define === "function" && define.amd) { + define(factory); + } else { + window2.jStat = factory(); + } + })(exports, function() { + var jStat2 = function(Math2, undefined2) { + var concat = Array.prototype.concat; + var slice = Array.prototype.slice; + var toString2 = Object.prototype.toString; + function calcRdx(n31, m6) { + var val = n31 > m6 ? n31 : m6; + return Math2.pow( + 10, + 17 - ~~(Math2.log(val > 0 ? val : -val) * Math2.LOG10E) + ); + } + var isArray = Array.isArray || function isArray2(arg) { + return toString2.call(arg) === "[object Array]"; + }; + function isFunction2(arg) { + return toString2.call(arg) === "[object Function]"; + } + function isNumber(num) { + return typeof num === "number" ? num - num === 0 : false; + } + function toVector(arr) { + return concat.apply([], arr); + } + function jStat3() { + return new jStat3._init(arguments); + } + jStat3.fn = jStat3.prototype; + jStat3._init = function _init(args) { + if (isArray(args[0])) { + if (isArray(args[0][0])) { + if (isFunction2(args[1])) + args[0] = jStat3.map(args[0], args[1]); + for (var i23 = 0; i23 < args[0].length; i23++) + this[i23] = args[0][i23]; + this.length = args[0].length; + } else { + this[0] = isFunction2(args[1]) ? jStat3.map(args[0], args[1]) : args[0]; + this.length = 1; + } + } else if (isNumber(args[0])) { + this[0] = jStat3.seq.apply(null, args); + this.length = 1; + } else if (args[0] instanceof jStat3) { + return jStat3(args[0].toArray()); + } else { + this[0] = []; + this.length = 1; + } + return this; + }; + jStat3._init.prototype = jStat3.prototype; + jStat3._init.constructor = jStat3; + jStat3.utils = { + calcRdx, + isArray, + isFunction: isFunction2, + isNumber, + toVector + }; + jStat3._random_fn = Math2.random; + jStat3.setRandom = function setRandom(fn2) { + if (typeof fn2 !== "function") + throw new TypeError("fn is not a function"); + jStat3._random_fn = fn2; + }; + jStat3.extend = function extend(obj) { + var i23, j3; + if (arguments.length === 1) { + for (j3 in obj) + jStat3[j3] = obj[j3]; + return this; + } + for (i23 = 1; i23 < arguments.length; i23++) { + for (j3 in arguments[i23]) + obj[j3] = arguments[i23][j3]; + } + return obj; + }; + jStat3.rows = function rows(arr) { + return arr.length || 1; + }; + jStat3.cols = function cols(arr) { + return arr[0].length || 1; + }; + jStat3.dimensions = function dimensions(arr) { + return { + rows: jStat3.rows(arr), + cols: jStat3.cols(arr) + }; + }; + jStat3.row = function row(arr, index) { + if (isArray(index)) { + return index.map(function(i23) { + return jStat3.row(arr, i23); + }); + } + return arr[index]; + }; + jStat3.rowa = function rowa(arr, i23) { + return jStat3.row(arr, i23); + }; + jStat3.col = function col(arr, index) { + if (isArray(index)) { + var submat = jStat3.arange(arr.length).map(function() { + return new Array(index.length); + }); + index.forEach(function(ind, i24) { + jStat3.arange(arr.length).forEach(function(j3) { + submat[j3][i24] = arr[j3][ind]; + }); + }); + return submat; + } + var column = new Array(arr.length); + for (var i23 = 0; i23 < arr.length; i23++) + column[i23] = [arr[i23][index]]; + return column; + }; + jStat3.cola = function cola(arr, i23) { + return jStat3.col(arr, i23).map(function(a11) { + return a11[0]; + }); + }; + jStat3.diag = function diag(arr) { + var nrow = jStat3.rows(arr); + var res = new Array(nrow); + for (var row = 0; row < nrow; row++) + res[row] = [arr[row][row]]; + return res; + }; + jStat3.antidiag = function antidiag(arr) { + var nrow = jStat3.rows(arr) - 1; + var res = new Array(nrow); + for (var i23 = 0; nrow >= 0; nrow--, i23++) + res[i23] = [arr[i23][nrow]]; + return res; + }; + jStat3.transpose = function transpose(arr) { + var obj = []; + var objArr, rows, cols, j3, i23; + if (!isArray(arr[0])) + arr = [arr]; + rows = arr.length; + cols = arr[0].length; + for (i23 = 0; i23 < cols; i23++) { + objArr = new Array(rows); + for (j3 = 0; j3 < rows; j3++) + objArr[j3] = arr[j3][i23]; + obj.push(objArr); + } + return obj.length === 1 ? obj[0] : obj; + }; + jStat3.map = function map2(arr, func, toAlter) { + var row, nrow, ncol, res, col; + if (!isArray(arr[0])) + arr = [arr]; + nrow = arr.length; + ncol = arr[0].length; + res = toAlter ? arr : new Array(nrow); + for (row = 0; row < nrow; row++) { + if (!res[row]) + res[row] = new Array(ncol); + for (col = 0; col < ncol; col++) + res[row][col] = func(arr[row][col], row, col); + } + return res.length === 1 ? res[0] : res; + }; + jStat3.cumreduce = function cumreduce(arr, func, toAlter) { + var row, nrow, ncol, res, col; + if (!isArray(arr[0])) + arr = [arr]; + nrow = arr.length; + ncol = arr[0].length; + res = toAlter ? arr : new Array(nrow); + for (row = 0; row < nrow; row++) { + if (!res[row]) + res[row] = new Array(ncol); + if (ncol > 0) + res[row][0] = arr[row][0]; + for (col = 1; col < ncol; col++) + res[row][col] = func(res[row][col - 1], arr[row][col]); + } + return res.length === 1 ? res[0] : res; + }; + jStat3.alter = function alter(arr, func) { + return jStat3.map(arr, func, true); + }; + jStat3.create = function create(rows, cols, func) { + var res = new Array(rows); + var i23, j3; + if (isFunction2(cols)) { + func = cols; + cols = rows; + } + for (i23 = 0; i23 < rows; i23++) { + res[i23] = new Array(cols); + for (j3 = 0; j3 < cols; j3++) + res[i23][j3] = func(i23, j3); + } + return res; + }; + function retZero() { + return 0; + } + jStat3.zeros = function zeros(rows, cols) { + if (!isNumber(cols)) + cols = rows; + return jStat3.create(rows, cols, retZero); + }; + function retOne() { + return 1; + } + jStat3.ones = function ones(rows, cols) { + if (!isNumber(cols)) + cols = rows; + return jStat3.create(rows, cols, retOne); + }; + jStat3.rand = function rand(rows, cols) { + if (!isNumber(cols)) + cols = rows; + return jStat3.create(rows, cols, jStat3._random_fn); + }; + function retIdent(i23, j3) { + return i23 === j3 ? 1 : 0; + } + jStat3.identity = function identity(rows, cols) { + if (!isNumber(cols)) + cols = rows; + return jStat3.create(rows, cols, retIdent); + }; + jStat3.symmetric = function symmetric(arr) { + var size = arr.length; + var row, col; + if (arr.length !== arr[0].length) + return false; + for (row = 0; row < size; row++) { + for (col = 0; col < size; col++) + if (arr[col][row] !== arr[row][col]) + return false; + } + return true; + }; + jStat3.clear = function clear2(arr) { + return jStat3.alter(arr, retZero); + }; + jStat3.seq = function seq(min, max, length, func) { + if (!isFunction2(func)) + func = false; + var arr = []; + var hival = calcRdx(min, max); + var step = (max * hival - min * hival) / ((length - 1) * hival); + var current = min; + var cnt; + for (cnt = 0; current <= max && cnt < length; cnt++, current = (min * hival + step * hival * cnt) / hival) { + arr.push(func ? func(current, cnt) : current); + } + return arr; + }; + jStat3.arange = function arange(start, end, step) { + var rl = []; + var i23; + step = step || 1; + if (end === undefined2) { + end = start; + start = 0; + } + if (start === end || step === 0) { + return []; + } + if (start < end && step < 0) { + return []; + } + if (start > end && step > 0) { + return []; + } + if (step > 0) { + for (i23 = start; i23 < end; i23 += step) { + rl.push(i23); + } + } else { + for (i23 = start; i23 > end; i23 += step) { + rl.push(i23); + } + } + return rl; + }; + jStat3.slice = /* @__PURE__ */ function() { + function _slice(list, start, end, step) { + var i23; + var rl = []; + var length = list.length; + if (start === undefined2 && end === undefined2 && step === undefined2) { + return jStat3.copy(list); + } + start = start || 0; + end = end || list.length; + start = start >= 0 ? start : length + start; + end = end >= 0 ? end : length + end; + step = step || 1; + if (start === end || step === 0) { + return []; + } + if (start < end && step < 0) { + return []; + } + if (start > end && step > 0) { + return []; + } + if (step > 0) { + for (i23 = start; i23 < end; i23 += step) { + rl.push(list[i23]); + } + } else { + for (i23 = start; i23 > end; i23 += step) { + rl.push(list[i23]); + } + } + return rl; + } + function slice2(list, rcSlice) { + var colSlice, rowSlice; + rcSlice = rcSlice || {}; + if (isNumber(rcSlice.row)) { + if (isNumber(rcSlice.col)) + return list[rcSlice.row][rcSlice.col]; + var row = jStat3.rowa(list, rcSlice.row); + colSlice = rcSlice.col || {}; + return _slice(row, colSlice.start, colSlice.end, colSlice.step); + } + if (isNumber(rcSlice.col)) { + var col = jStat3.cola(list, rcSlice.col); + rowSlice = rcSlice.row || {}; + return _slice(col, rowSlice.start, rowSlice.end, rowSlice.step); + } + rowSlice = rcSlice.row || {}; + colSlice = rcSlice.col || {}; + var rows = _slice(list, rowSlice.start, rowSlice.end, rowSlice.step); + return rows.map(function(row2) { + return _slice(row2, colSlice.start, colSlice.end, colSlice.step); + }); + } + return slice2; + }(); + jStat3.sliceAssign = function sliceAssign(A6, rcSlice, B5) { + var nl, ml; + if (isNumber(rcSlice.row)) { + if (isNumber(rcSlice.col)) + return A6[rcSlice.row][rcSlice.col] = B5; + rcSlice.col = rcSlice.col || {}; + rcSlice.col.start = rcSlice.col.start || 0; + rcSlice.col.end = rcSlice.col.end || A6[0].length; + rcSlice.col.step = rcSlice.col.step || 1; + nl = jStat3.arange( + rcSlice.col.start, + Math2.min(A6.length, rcSlice.col.end), + rcSlice.col.step + ); + var m6 = rcSlice.row; + nl.forEach(function(n32, i23) { + A6[m6][n32] = B5[i23]; + }); + return A6; + } + if (isNumber(rcSlice.col)) { + rcSlice.row = rcSlice.row || {}; + rcSlice.row.start = rcSlice.row.start || 0; + rcSlice.row.end = rcSlice.row.end || A6.length; + rcSlice.row.step = rcSlice.row.step || 1; + ml = jStat3.arange( + rcSlice.row.start, + Math2.min(A6[0].length, rcSlice.row.end), + rcSlice.row.step + ); + var n31 = rcSlice.col; + ml.forEach(function(m7, j3) { + A6[m7][n31] = B5[j3]; + }); + return A6; + } + if (B5[0].length === undefined2) { + B5 = [B5]; + } + rcSlice.row.start = rcSlice.row.start || 0; + rcSlice.row.end = rcSlice.row.end || A6.length; + rcSlice.row.step = rcSlice.row.step || 1; + rcSlice.col.start = rcSlice.col.start || 0; + rcSlice.col.end = rcSlice.col.end || A6[0].length; + rcSlice.col.step = rcSlice.col.step || 1; + ml = jStat3.arange( + rcSlice.row.start, + Math2.min(A6.length, rcSlice.row.end), + rcSlice.row.step + ); + nl = jStat3.arange( + rcSlice.col.start, + Math2.min(A6[0].length, rcSlice.col.end), + rcSlice.col.step + ); + ml.forEach(function(m7, i23) { + nl.forEach(function(n32, j3) { + A6[m7][n32] = B5[i23][j3]; + }); + }); + return A6; + }; + jStat3.diagonal = function diagonal(diagArray) { + var mat = jStat3.zeros(diagArray.length, diagArray.length); + diagArray.forEach(function(t17, i23) { + mat[i23][i23] = t17; + }); + return mat; + }; + jStat3.copy = function copy(A6) { + return A6.map(function(row) { + if (isNumber(row)) + return row; + return row.map(function(t17) { + return t17; + }); + }); + }; + var jProto = jStat3.prototype; + jProto.length = 0; + jProto.push = Array.prototype.push; + jProto.sort = Array.prototype.sort; + jProto.splice = Array.prototype.splice; + jProto.slice = Array.prototype.slice; + jProto.toArray = function toArray() { + return this.length > 1 ? slice.call(this) : slice.call(this)[0]; + }; + jProto.map = function map2(func, toAlter) { + return jStat3(jStat3.map(this, func, toAlter)); + }; + jProto.cumreduce = function cumreduce(func, toAlter) { + return jStat3(jStat3.cumreduce(this, func, toAlter)); + }; + jProto.alter = function alter(func) { + jStat3.alter(this, func); + return this; + }; + (function(funcs) { + for (var i23 = 0; i23 < funcs.length; i23++) + (function(passfunc) { + jProto[passfunc] = function(func) { + var self2 = this, results; + if (func) { + setTimeout(function() { + func.call(self2, jProto[passfunc].call(self2)); + }); + return this; + } + results = jStat3[passfunc](this); + return isArray(results) ? jStat3(results) : results; + }; + })(funcs[i23]); + })("transpose clear symmetric rows cols dimensions diag antidiag".split(" ")); + (function(funcs) { + for (var i23 = 0; i23 < funcs.length; i23++) + (function(passfunc) { + jProto[passfunc] = function(index, func) { + var self2 = this; + if (func) { + setTimeout(function() { + func.call(self2, jProto[passfunc].call(self2, index)); + }); + return this; + } + return jStat3(jStat3[passfunc](this, index)); + }; + })(funcs[i23]); + })("row col".split(" ")); + (function(funcs) { + for (var i23 = 0; i23 < funcs.length; i23++) + (function(passfunc) { + jProto[passfunc] = function() { + return jStat3(jStat3[passfunc].apply(null, arguments)); + }; + })(funcs[i23]); + })("create zeros ones rand identity".split(" ")); + return jStat3; + }(Math); + (function(jStat3, Math2) { + var isFunction2 = jStat3.utils.isFunction; + function ascNum(a11, b7) { + return a11 - b7; + } + function clip(arg, min, max) { + return Math2.max(min, Math2.min(arg, max)); + } + jStat3.sum = function sum(arr) { + var sum2 = 0; + var i23 = arr.length; + while (--i23 >= 0) + sum2 += arr[i23]; + return sum2; + }; + jStat3.sumsqrd = function sumsqrd(arr) { + var sum = 0; + var i23 = arr.length; + while (--i23 >= 0) + sum += arr[i23] * arr[i23]; + return sum; + }; + jStat3.sumsqerr = function sumsqerr(arr) { + var mean = jStat3.mean(arr); + var sum = 0; + var i23 = arr.length; + var tmp; + while (--i23 >= 0) { + tmp = arr[i23] - mean; + sum += tmp * tmp; + } + return sum; + }; + jStat3.sumrow = function sumrow(arr) { + var sum = 0; + var i23 = arr.length; + while (--i23 >= 0) + sum += arr[i23]; + return sum; + }; + jStat3.product = function product(arr) { + var prod = 1; + var i23 = arr.length; + while (--i23 >= 0) + prod *= arr[i23]; + return prod; + }; + jStat3.min = function min(arr) { + var low = arr[0]; + var i23 = 0; + while (++i23 < arr.length) + if (arr[i23] < low) + low = arr[i23]; + return low; + }; + jStat3.max = function max(arr) { + var high = arr[0]; + var i23 = 0; + while (++i23 < arr.length) + if (arr[i23] > high) + high = arr[i23]; + return high; + }; + jStat3.unique = function unique2(arr) { + var hash = {}, _arr = []; + for (var i23 = 0; i23 < arr.length; i23++) { + if (!hash[arr[i23]]) { + hash[arr[i23]] = true; + _arr.push(arr[i23]); + } + } + return _arr; + }; + jStat3.mean = function mean(arr) { + return jStat3.sum(arr) / arr.length; + }; + jStat3.meansqerr = function meansqerr(arr) { + return jStat3.sumsqerr(arr) / arr.length; + }; + jStat3.geomean = function geomean(arr) { + var logs = arr.map(Math2.log); + var meanOfLogs = jStat3.mean(logs); + return Math2.exp(meanOfLogs); + }; + jStat3.median = function median(arr) { + var arrlen = arr.length; + var _arr = arr.slice().sort(ascNum); + return !(arrlen & 1) ? (_arr[arrlen / 2 - 1] + _arr[arrlen / 2]) / 2 : _arr[arrlen / 2 | 0]; + }; + jStat3.cumsum = function cumsum(arr) { + return jStat3.cumreduce(arr, function(a11, b7) { + return a11 + b7; + }); + }; + jStat3.cumprod = function cumprod(arr) { + return jStat3.cumreduce(arr, function(a11, b7) { + return a11 * b7; + }); + }; + jStat3.diff = function diff(arr) { + var diffs = []; + var arrLen = arr.length; + var i23; + for (i23 = 1; i23 < arrLen; i23++) + diffs.push(arr[i23] - arr[i23 - 1]); + return diffs; + }; + jStat3.rank = function(arr) { + var i23; + var distinctNumbers = []; + var numberCounts = {}; + for (i23 = 0; i23 < arr.length; i23++) { + var number = arr[i23]; + if (numberCounts[number]) { + numberCounts[number]++; + } else { + numberCounts[number] = 1; + distinctNumbers.push(number); + } + } + var sortedDistinctNumbers = distinctNumbers.sort(ascNum); + var numberRanks = {}; + var currentRank = 1; + for (i23 = 0; i23 < sortedDistinctNumbers.length; i23++) { + var number = sortedDistinctNumbers[i23]; + var count = numberCounts[number]; + var first = currentRank; + var last = currentRank + count - 1; + var rank = (first + last) / 2; + numberRanks[number] = rank; + currentRank += count; + } + return arr.map(function(number2) { + return numberRanks[number2]; + }); + }; + jStat3.mode = function mode(arr) { + var arrLen = arr.length; + var _arr = arr.slice().sort(ascNum); + var count = 1; + var maxCount = 0; + var numMaxCount = 0; + var mode_arr = []; + var i23; + for (i23 = 0; i23 < arrLen; i23++) { + if (_arr[i23] === _arr[i23 + 1]) { + count++; + } else { + if (count > maxCount) { + mode_arr = [_arr[i23]]; + maxCount = count; + numMaxCount = 0; + } else if (count === maxCount) { + mode_arr.push(_arr[i23]); + numMaxCount++; + } + count = 1; + } + } + return numMaxCount === 0 ? mode_arr[0] : mode_arr; + }; + jStat3.range = function range(arr) { + return jStat3.max(arr) - jStat3.min(arr); + }; + jStat3.variance = function variance(arr, flag) { + return jStat3.sumsqerr(arr) / (arr.length - (flag ? 1 : 0)); + }; + jStat3.pooledvariance = function pooledvariance(arr) { + var sumsqerr = arr.reduce(function(a11, samples) { + return a11 + jStat3.sumsqerr(samples); + }, 0); + var count = arr.reduce(function(a11, samples) { + return a11 + samples.length; + }, 0); + return sumsqerr / (count - arr.length); + }; + jStat3.deviation = function(arr) { + var mean = jStat3.mean(arr); + var arrlen = arr.length; + var dev = new Array(arrlen); + for (var i23 = 0; i23 < arrlen; i23++) { + dev[i23] = arr[i23] - mean; + } + return dev; + }; + jStat3.stdev = function stdev(arr, flag) { + return Math2.sqrt(jStat3.variance(arr, flag)); + }; + jStat3.pooledstdev = function pooledstdev(arr) { + return Math2.sqrt(jStat3.pooledvariance(arr)); + }; + jStat3.meandev = function meandev(arr) { + var mean = jStat3.mean(arr); + var a11 = []; + for (var i23 = arr.length - 1; i23 >= 0; i23--) { + a11.push(Math2.abs(arr[i23] - mean)); + } + return jStat3.mean(a11); + }; + jStat3.meddev = function meddev(arr) { + var median = jStat3.median(arr); + var a11 = []; + for (var i23 = arr.length - 1; i23 >= 0; i23--) { + a11.push(Math2.abs(arr[i23] - median)); + } + return jStat3.median(a11); + }; + jStat3.coeffvar = function coeffvar(arr) { + return jStat3.stdev(arr) / jStat3.mean(arr); + }; + jStat3.quartiles = function quartiles(arr) { + var arrlen = arr.length; + var _arr = arr.slice().sort(ascNum); + return [ + _arr[Math2.round(arrlen / 4) - 1], + _arr[Math2.round(arrlen / 2) - 1], + _arr[Math2.round(arrlen * 3 / 4) - 1] + ]; + }; + jStat3.quantiles = function quantiles(arr, quantilesArray, alphap, betap) { + var sortedArray = arr.slice().sort(ascNum); + var quantileVals = [quantilesArray.length]; + var n31 = arr.length; + var i23, p7, m6, aleph, k8, gamma; + if (typeof alphap === "undefined") + alphap = 3 / 8; + if (typeof betap === "undefined") + betap = 3 / 8; + for (i23 = 0; i23 < quantilesArray.length; i23++) { + p7 = quantilesArray[i23]; + m6 = alphap + p7 * (1 - alphap - betap); + aleph = n31 * p7 + m6; + k8 = Math2.floor(clip(aleph, 1, n31 - 1)); + gamma = clip(aleph - k8, 0, 1); + quantileVals[i23] = (1 - gamma) * sortedArray[k8 - 1] + gamma * sortedArray[k8]; + } + return quantileVals; + }; + jStat3.percentile = function percentile(arr, k8, exclusive) { + var _arr = arr.slice().sort(ascNum); + var realIndex = k8 * (_arr.length + (exclusive ? 1 : -1)) + (exclusive ? 0 : 1); + var index = parseInt(realIndex); + var frac = realIndex - index; + if (index + 1 < _arr.length) { + return _arr[index - 1] + frac * (_arr[index] - _arr[index - 1]); + } else { + return _arr[index - 1]; + } + }; + jStat3.percentileOfScore = function percentileOfScore(arr, score, kind) { + var counter = 0; + var len = arr.length; + var strict = false; + var value, i23; + if (kind === "strict") + strict = true; + for (i23 = 0; i23 < len; i23++) { + value = arr[i23]; + if (strict && value < score || !strict && value <= score) { + counter++; + } + } + return counter / len; + }; + jStat3.histogram = function histogram(arr, binCnt) { + binCnt = binCnt || 4; + var first = jStat3.min(arr); + var binWidth = (jStat3.max(arr) - first) / binCnt; + var len = arr.length; + var bins = []; + var i23; + for (i23 = 0; i23 < binCnt; i23++) + bins[i23] = 0; + for (i23 = 0; i23 < len; i23++) + bins[Math2.min(Math2.floor((arr[i23] - first) / binWidth), binCnt - 1)] += 1; + return bins; + }; + jStat3.covariance = function covariance(arr1, arr2) { + var u11 = jStat3.mean(arr1); + var v6 = jStat3.mean(arr2); + var arr1Len = arr1.length; + var sq_dev = new Array(arr1Len); + var i23; + for (i23 = 0; i23 < arr1Len; i23++) + sq_dev[i23] = (arr1[i23] - u11) * (arr2[i23] - v6); + return jStat3.sum(sq_dev) / (arr1Len - 1); + }; + jStat3.corrcoeff = function corrcoeff(arr1, arr2) { + return jStat3.covariance(arr1, arr2) / jStat3.stdev(arr1, 1) / jStat3.stdev(arr2, 1); + }; + jStat3.spearmancoeff = function(arr1, arr2) { + arr1 = jStat3.rank(arr1); + arr2 = jStat3.rank(arr2); + return jStat3.corrcoeff(arr1, arr2); + }; + jStat3.stanMoment = function stanMoment(arr, n31) { + var mu = jStat3.mean(arr); + var sigma = jStat3.stdev(arr); + var len = arr.length; + var skewSum = 0; + for (var i23 = 0; i23 < len; i23++) + skewSum += Math2.pow((arr[i23] - mu) / sigma, n31); + return skewSum / arr.length; + }; + jStat3.skewness = function skewness(arr) { + return jStat3.stanMoment(arr, 3); + }; + jStat3.kurtosis = function kurtosis(arr) { + return jStat3.stanMoment(arr, 4) - 3; + }; + var jProto = jStat3.prototype; + (function(funcs) { + for (var i23 = 0; i23 < funcs.length; i23++) + (function(passfunc) { + jProto[passfunc] = function(fullbool, func) { + var arr = []; + var i24 = 0; + var tmpthis = this; + if (isFunction2(fullbool)) { + func = fullbool; + fullbool = false; + } + if (func) { + setTimeout(function() { + func.call(tmpthis, jProto[passfunc].call(tmpthis, fullbool)); + }); + return this; + } + if (this.length > 1) { + tmpthis = fullbool === true ? this : this.transpose(); + for (; i24 < tmpthis.length; i24++) + arr[i24] = jStat3[passfunc](tmpthis[i24]); + return arr; + } + return jStat3[passfunc](this[0], fullbool); + }; + })(funcs[i23]); + })("cumsum cumprod".split(" ")); + (function(funcs) { + for (var i23 = 0; i23 < funcs.length; i23++) + (function(passfunc) { + jProto[passfunc] = function(fullbool, func) { + var arr = []; + var i24 = 0; + var tmpthis = this; + if (isFunction2(fullbool)) { + func = fullbool; + fullbool = false; + } + if (func) { + setTimeout(function() { + func.call(tmpthis, jProto[passfunc].call(tmpthis, fullbool)); + }); + return this; + } + if (this.length > 1) { + if (passfunc !== "sumrow") + tmpthis = fullbool === true ? this : this.transpose(); + for (; i24 < tmpthis.length; i24++) + arr[i24] = jStat3[passfunc](tmpthis[i24]); + return fullbool === true ? jStat3[passfunc](jStat3.utils.toVector(arr)) : arr; + } + return jStat3[passfunc](this[0], fullbool); + }; + })(funcs[i23]); + })("sum sumsqrd sumsqerr sumrow product min max unique mean meansqerr geomean median diff rank mode range variance deviation stdev meandev meddev coeffvar quartiles histogram skewness kurtosis".split(" ")); + (function(funcs) { + for (var i23 = 0; i23 < funcs.length; i23++) + (function(passfunc) { + jProto[passfunc] = function() { + var arr = []; + var i24 = 0; + var tmpthis = this; + var args = Array.prototype.slice.call(arguments); + var callbackFunction; + if (isFunction2(args[args.length - 1])) { + callbackFunction = args[args.length - 1]; + var argsToPass = args.slice(0, args.length - 1); + setTimeout(function() { + callbackFunction.call( + tmpthis, + jProto[passfunc].apply(tmpthis, argsToPass) + ); + }); + return this; + } else { + callbackFunction = void 0; + var curriedFunction = function curriedFunction2(vector) { + return jStat3[passfunc].apply(tmpthis, [vector].concat(args)); + }; + } + if (this.length > 1) { + tmpthis = tmpthis.transpose(); + for (; i24 < tmpthis.length; i24++) + arr[i24] = curriedFunction(tmpthis[i24]); + return arr; + } + return curriedFunction(this[0]); + }; + })(funcs[i23]); + })("quantiles percentileOfScore".split(" ")); + })(jStat2, Math); + (function(jStat3, Math2) { + jStat3.gammaln = function gammaln(x6) { + var j3 = 0; + var cof = [ + 76.18009172947146, + -86.50532032941678, + 24.01409824083091, + -1.231739572450155, + 0.001208650973866179, + -5395239384953e-18 + ]; + var ser = 1.000000000190015; + var xx, y7, tmp; + tmp = (y7 = xx = x6) + 5.5; + tmp -= (xx + 0.5) * Math2.log(tmp); + for (; j3 < 6; j3++) + ser += cof[j3] / ++y7; + return Math2.log(2.5066282746310007 * ser / xx) - tmp; + }; + jStat3.loggam = function loggam(x6) { + var x0, x22, xp, gl, gl0; + var k8, n31; + var a11 = [ + 0.08333333333333333, + -0.002777777777777778, + 7936507936507937e-19, + -5952380952380952e-19, + 8417508417508418e-19, + -0.001917526917526918, + 0.00641025641025641, + -0.02955065359477124, + 0.1796443723688307, + -1.3924322169059 + ]; + x0 = x6; + n31 = 0; + if (x6 == 1 || x6 == 2) { + return 0; + } + if (x6 <= 7) { + n31 = Math2.floor(7 - x6); + x0 = x6 + n31; + } + x22 = 1 / (x0 * x0); + xp = 2 * Math2.PI; + gl0 = a11[9]; + for (k8 = 8; k8 >= 0; k8--) { + gl0 *= x22; + gl0 += a11[k8]; + } + gl = gl0 / x0 + 0.5 * Math2.log(xp) + (x0 - 0.5) * Math2.log(x0) - x0; + if (x6 <= 7) { + for (k8 = 1; k8 <= n31; k8++) { + gl -= Math2.log(x0 - 1); + x0 -= 1; + } + } + return gl; + }; + jStat3.gammafn = function gammafn(x6) { + var p7 = [ + -1.716185138865495, + 24.76565080557592, + -379.80425647094563, + 629.3311553128184, + 866.9662027904133, + -31451.272968848367, + -36144.413418691176, + 66456.14382024054 + ]; + var q = [ + -30.8402300119739, + 315.35062697960416, + -1015.1563674902192, + -3107.771671572311, + 22538.11842098015, + 4755.846277527881, + -134659.9598649693, + -115132.2596755535 + ]; + var fact = false; + var n31 = 0; + var xden = 0; + var xnum = 0; + var y7 = x6; + var i23, z5, yi, res; + if (x6 > 171.6243769536076) { + return Infinity; + } + if (y7 <= 0) { + res = y7 % 1 + 36e-17; + if (res) { + fact = (!(y7 & 1) ? 1 : -1) * Math2.PI / Math2.sin(Math2.PI * res); + y7 = 1 - y7; + } else { + return Infinity; + } + } + yi = y7; + if (y7 < 1) { + z5 = y7++; + } else { + z5 = (y7 -= n31 = (y7 | 0) - 1) - 1; + } + for (i23 = 0; i23 < 8; ++i23) { + xnum = (xnum + p7[i23]) * z5; + xden = xden * z5 + q[i23]; + } + res = xnum / xden + 1; + if (yi < y7) { + res /= yi; + } else if (yi > y7) { + for (i23 = 0; i23 < n31; ++i23) { + res *= y7; + y7++; + } + } + if (fact) { + res = fact / res; + } + return res; + }; + jStat3.gammap = function gammap(a11, x6) { + return jStat3.lowRegGamma(a11, x6) * jStat3.gammafn(a11); + }; + jStat3.lowRegGamma = function lowRegGamma(a11, x6) { + var aln = jStat3.gammaln(a11); + var ap = a11; + var sum = 1 / a11; + var del = sum; + var b7 = x6 + 1 - a11; + var c12 = 1 / 1e-30; + var d11 = 1 / b7; + var h11 = d11; + var i23 = 1; + var ITMAX = -~(Math2.log(a11 >= 1 ? a11 : 1 / a11) * 8.5 + a11 * 0.4 + 17); + var an; + if (x6 < 0 || a11 <= 0) { + return NaN; + } else if (x6 < a11 + 1) { + for (; i23 <= ITMAX; i23++) { + sum += del *= x6 / ++ap; + } + return sum * Math2.exp(-x6 + a11 * Math2.log(x6) - aln); + } + for (; i23 <= ITMAX; i23++) { + an = -i23 * (i23 - a11); + b7 += 2; + d11 = an * d11 + b7; + c12 = b7 + an / c12; + d11 = 1 / d11; + h11 *= d11 * c12; + } + return 1 - h11 * Math2.exp(-x6 + a11 * Math2.log(x6) - aln); + }; + jStat3.factorialln = function factorialln(n31) { + return n31 < 0 ? NaN : jStat3.gammaln(n31 + 1); + }; + jStat3.factorial = function factorial(n31) { + return n31 < 0 ? NaN : jStat3.gammafn(n31 + 1); + }; + jStat3.combination = function combination(n31, m6) { + return n31 > 170 || m6 > 170 ? Math2.exp(jStat3.combinationln(n31, m6)) : jStat3.factorial(n31) / jStat3.factorial(m6) / jStat3.factorial(n31 - m6); + }; + jStat3.combinationln = function combinationln(n31, m6) { + return jStat3.factorialln(n31) - jStat3.factorialln(m6) - jStat3.factorialln(n31 - m6); + }; + jStat3.permutation = function permutation(n31, m6) { + return jStat3.factorial(n31) / jStat3.factorial(n31 - m6); + }; + jStat3.betafn = function betafn(x6, y7) { + if (x6 <= 0 || y7 <= 0) + return void 0; + return x6 + y7 > 170 ? Math2.exp(jStat3.betaln(x6, y7)) : jStat3.gammafn(x6) * jStat3.gammafn(y7) / jStat3.gammafn(x6 + y7); + }; + jStat3.betaln = function betaln(x6, y7) { + return jStat3.gammaln(x6) + jStat3.gammaln(y7) - jStat3.gammaln(x6 + y7); + }; + jStat3.betacf = function betacf(x6, a11, b7) { + var fpmin = 1e-30; + var m6 = 1; + var qab = a11 + b7; + var qap = a11 + 1; + var qam = a11 - 1; + var c12 = 1; + var d11 = 1 - qab * x6 / qap; + var m22, aa, del, h11; + if (Math2.abs(d11) < fpmin) + d11 = fpmin; + d11 = 1 / d11; + h11 = d11; + for (; m6 <= 100; m6++) { + m22 = 2 * m6; + aa = m6 * (b7 - m6) * x6 / ((qam + m22) * (a11 + m22)); + d11 = 1 + aa * d11; + if (Math2.abs(d11) < fpmin) + d11 = fpmin; + c12 = 1 + aa / c12; + if (Math2.abs(c12) < fpmin) + c12 = fpmin; + d11 = 1 / d11; + h11 *= d11 * c12; + aa = -(a11 + m6) * (qab + m6) * x6 / ((a11 + m22) * (qap + m22)); + d11 = 1 + aa * d11; + if (Math2.abs(d11) < fpmin) + d11 = fpmin; + c12 = 1 + aa / c12; + if (Math2.abs(c12) < fpmin) + c12 = fpmin; + d11 = 1 / d11; + del = d11 * c12; + h11 *= del; + if (Math2.abs(del - 1) < 3e-7) + break; + } + return h11; + }; + jStat3.gammapinv = function gammapinv(p7, a11) { + var j3 = 0; + var a1 = a11 - 1; + var EPS = 1e-8; + var gln = jStat3.gammaln(a11); + var x6, err, t17, u11, pp, lna1, afac; + if (p7 >= 1) + return Math2.max(100, a11 + 100 * Math2.sqrt(a11)); + if (p7 <= 0) + return 0; + if (a11 > 1) { + lna1 = Math2.log(a1); + afac = Math2.exp(a1 * (lna1 - 1) - gln); + pp = p7 < 0.5 ? p7 : 1 - p7; + t17 = Math2.sqrt(-2 * Math2.log(pp)); + x6 = (2.30753 + t17 * 0.27061) / (1 + t17 * (0.99229 + t17 * 0.04481)) - t17; + if (p7 < 0.5) + x6 = -x6; + x6 = Math2.max( + 1e-3, + a11 * Math2.pow(1 - 1 / (9 * a11) - x6 / (3 * Math2.sqrt(a11)), 3) + ); + } else { + t17 = 1 - a11 * (0.253 + a11 * 0.12); + if (p7 < t17) + x6 = Math2.pow(p7 / t17, 1 / a11); + else + x6 = 1 - Math2.log(1 - (p7 - t17) / (1 - t17)); + } + for (; j3 < 12; j3++) { + if (x6 <= 0) + return 0; + err = jStat3.lowRegGamma(a11, x6) - p7; + if (a11 > 1) + t17 = afac * Math2.exp(-(x6 - a1) + a1 * (Math2.log(x6) - lna1)); + else + t17 = Math2.exp(-x6 + a1 * Math2.log(x6) - gln); + u11 = err / t17; + x6 -= t17 = u11 / (1 - 0.5 * Math2.min(1, u11 * ((a11 - 1) / x6 - 1))); + if (x6 <= 0) + x6 = 0.5 * (x6 + t17); + if (Math2.abs(t17) < EPS * x6) + break; + } + return x6; + }; + jStat3.erf = function erf(x6) { + var cof = [ + -1.3026537197817094, + 0.6419697923564902, + 0.019476473204185836, + -0.00956151478680863, + -946595344482036e-18, + 366839497852761e-18, + 42523324806907e-18, + -20278578112534e-18, + -1624290004647e-18, + 130365583558e-17, + 15626441722e-18, + -85238095915e-18, + 6529054439e-18, + 5059343495e-18, + -991364156e-18, + -227365122e-18, + 96467911e-18, + 2394038e-18, + -6886027e-18, + 894487e-18, + 313092e-18, + -112708e-18, + 381e-18, + 7106e-18, + -1523e-18, + -94e-18, + 121e-18, + -28e-18 + ]; + var j3 = cof.length - 1; + var isneg = false; + var d11 = 0; + var dd = 0; + var t17, ty, tmp, res; + if (x6 < 0) { + x6 = -x6; + isneg = true; + } + t17 = 2 / (2 + x6); + ty = 4 * t17 - 2; + for (; j3 > 0; j3--) { + tmp = d11; + d11 = ty * d11 - dd + cof[j3]; + dd = tmp; + } + res = t17 * Math2.exp(-x6 * x6 + 0.5 * (cof[0] + ty * d11) - dd); + return isneg ? res - 1 : 1 - res; + }; + jStat3.erfc = function erfc(x6) { + return 1 - jStat3.erf(x6); + }; + jStat3.erfcinv = function erfcinv(p7) { + var j3 = 0; + var x6, err, t17, pp; + if (p7 >= 2) + return -100; + if (p7 <= 0) + return 100; + pp = p7 < 1 ? p7 : 2 - p7; + t17 = Math2.sqrt(-2 * Math2.log(pp / 2)); + x6 = -0.70711 * ((2.30753 + t17 * 0.27061) / (1 + t17 * (0.99229 + t17 * 0.04481)) - t17); + for (; j3 < 2; j3++) { + err = jStat3.erfc(x6) - pp; + x6 += err / (1.1283791670955126 * Math2.exp(-x6 * x6) - x6 * err); + } + return p7 < 1 ? x6 : -x6; + }; + jStat3.ibetainv = function ibetainv(p7, a11, b7) { + var EPS = 1e-8; + var a1 = a11 - 1; + var b1 = b7 - 1; + var j3 = 0; + var lna, lnb, pp, t17, u11, err, x6, al, h11, w6, afac; + if (p7 <= 0) + return 0; + if (p7 >= 1) + return 1; + if (a11 >= 1 && b7 >= 1) { + pp = p7 < 0.5 ? p7 : 1 - p7; + t17 = Math2.sqrt(-2 * Math2.log(pp)); + x6 = (2.30753 + t17 * 0.27061) / (1 + t17 * (0.99229 + t17 * 0.04481)) - t17; + if (p7 < 0.5) + x6 = -x6; + al = (x6 * x6 - 3) / 6; + h11 = 2 / (1 / (2 * a11 - 1) + 1 / (2 * b7 - 1)); + w6 = x6 * Math2.sqrt(al + h11) / h11 - (1 / (2 * b7 - 1) - 1 / (2 * a11 - 1)) * (al + 5 / 6 - 2 / (3 * h11)); + x6 = a11 / (a11 + b7 * Math2.exp(2 * w6)); + } else { + lna = Math2.log(a11 / (a11 + b7)); + lnb = Math2.log(b7 / (a11 + b7)); + t17 = Math2.exp(a11 * lna) / a11; + u11 = Math2.exp(b7 * lnb) / b7; + w6 = t17 + u11; + if (p7 < t17 / w6) + x6 = Math2.pow(a11 * w6 * p7, 1 / a11); + else + x6 = 1 - Math2.pow(b7 * w6 * (1 - p7), 1 / b7); + } + afac = -jStat3.gammaln(a11) - jStat3.gammaln(b7) + jStat3.gammaln(a11 + b7); + for (; j3 < 10; j3++) { + if (x6 === 0 || x6 === 1) + return x6; + err = jStat3.ibeta(x6, a11, b7) - p7; + t17 = Math2.exp(a1 * Math2.log(x6) + b1 * Math2.log(1 - x6) + afac); + u11 = err / t17; + x6 -= t17 = u11 / (1 - 0.5 * Math2.min(1, u11 * (a1 / x6 - b1 / (1 - x6)))); + if (x6 <= 0) + x6 = 0.5 * (x6 + t17); + if (x6 >= 1) + x6 = 0.5 * (x6 + t17 + 1); + if (Math2.abs(t17) < EPS * x6 && j3 > 0) + break; + } + return x6; + }; + jStat3.ibeta = function ibeta(x6, a11, b7) { + var bt = x6 === 0 || x6 === 1 ? 0 : Math2.exp(jStat3.gammaln(a11 + b7) - jStat3.gammaln(a11) - jStat3.gammaln(b7) + a11 * Math2.log(x6) + b7 * Math2.log(1 - x6)); + if (x6 < 0 || x6 > 1) + return false; + if (x6 < (a11 + 1) / (a11 + b7 + 2)) + return bt * jStat3.betacf(x6, a11, b7) / a11; + return 1 - bt * jStat3.betacf(1 - x6, b7, a11) / b7; + }; + jStat3.randn = function randn(n31, m6) { + var u11, v6, x6, y7, q; + if (!m6) + m6 = n31; + if (n31) + return jStat3.create(n31, m6, function() { + return jStat3.randn(); + }); + do { + u11 = jStat3._random_fn(); + v6 = 1.7156 * (jStat3._random_fn() - 0.5); + x6 = u11 - 0.449871; + y7 = Math2.abs(v6) + 0.386595; + q = x6 * x6 + y7 * (0.196 * y7 - 0.25472 * x6); + } while (q > 0.27597 && (q > 0.27846 || v6 * v6 > -4 * Math2.log(u11) * u11 * u11)); + return v6 / u11; + }; + jStat3.randg = function randg(shape, n31, m6) { + var oalph = shape; + var a1, a22, u11, v6, x6, mat; + if (!m6) + m6 = n31; + if (!shape) + shape = 1; + if (n31) { + mat = jStat3.zeros(n31, m6); + mat.alter(function() { + return jStat3.randg(shape); + }); + return mat; + } + if (shape < 1) + shape += 1; + a1 = shape - 1 / 3; + a22 = 1 / Math2.sqrt(9 * a1); + do { + do { + x6 = jStat3.randn(); + v6 = 1 + a22 * x6; + } while (v6 <= 0); + v6 = v6 * v6 * v6; + u11 = jStat3._random_fn(); + } while (u11 > 1 - 0.331 * Math2.pow(x6, 4) && Math2.log(u11) > 0.5 * x6 * x6 + a1 * (1 - v6 + Math2.log(v6))); + if (shape == oalph) + return a1 * v6; + do { + u11 = jStat3._random_fn(); + } while (u11 === 0); + return Math2.pow(u11, 1 / oalph) * a1 * v6; + }; + (function(funcs) { + for (var i23 = 0; i23 < funcs.length; i23++) + (function(passfunc) { + jStat3.fn[passfunc] = function() { + return jStat3( + jStat3.map(this, function(value) { + return jStat3[passfunc](value); + }) + ); + }; + })(funcs[i23]); + })("gammaln gammafn factorial factorialln".split(" ")); + (function(funcs) { + for (var i23 = 0; i23 < funcs.length; i23++) + (function(passfunc) { + jStat3.fn[passfunc] = function() { + return jStat3(jStat3[passfunc].apply(null, arguments)); + }; + })(funcs[i23]); + })("randn".split(" ")); + })(jStat2, Math); + (function(jStat3, Math2) { + (function(list) { + for (var i23 = 0; i23 < list.length; i23++) + (function(func) { + jStat3[func] = function f7(a11, b7, c12) { + if (!(this instanceof f7)) + return new f7(a11, b7, c12); + this._a = a11; + this._b = b7; + this._c = c12; + return this; + }; + jStat3.fn[func] = function(a11, b7, c12) { + var newthis = jStat3[func](a11, b7, c12); + newthis.data = this; + return newthis; + }; + jStat3[func].prototype.sample = function(arr) { + var a11 = this._a; + var b7 = this._b; + var c12 = this._c; + if (arr) + return jStat3.alter(arr, function() { + return jStat3[func].sample(a11, b7, c12); + }); + else + return jStat3[func].sample(a11, b7, c12); + }; + (function(vals) { + for (var i24 = 0; i24 < vals.length; i24++) + (function(fnfunc) { + jStat3[func].prototype[fnfunc] = function(x6) { + var a11 = this._a; + var b7 = this._b; + var c12 = this._c; + if (!x6 && x6 !== 0) + x6 = this.data; + if (typeof x6 !== "number") { + return jStat3.fn.map.call(x6, function(x7) { + return jStat3[func][fnfunc](x7, a11, b7, c12); + }); + } + return jStat3[func][fnfunc](x6, a11, b7, c12); + }; + })(vals[i24]); + })("pdf cdf inv".split(" ")); + (function(vals) { + for (var i24 = 0; i24 < vals.length; i24++) + (function(fnfunc) { + jStat3[func].prototype[fnfunc] = function() { + return jStat3[func][fnfunc](this._a, this._b, this._c); + }; + })(vals[i24]); + })("mean median mode variance".split(" ")); + })(list[i23]); + })("beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy laplace lognormal noncentralt normal pareto studentt weibull uniform binomial negbin hypgeom poisson triangular tukey arcsine".split(" ")); + jStat3.extend(jStat3.beta, { + pdf: function pdf(x6, alpha, beta) { + if (x6 > 1 || x6 < 0) + return 0; + if (alpha == 1 && beta == 1) + return 1; + if (alpha < 512 && beta < 512) { + return Math2.pow(x6, alpha - 1) * Math2.pow(1 - x6, beta - 1) / jStat3.betafn(alpha, beta); + } else { + return Math2.exp((alpha - 1) * Math2.log(x6) + (beta - 1) * Math2.log(1 - x6) - jStat3.betaln(alpha, beta)); + } + }, + cdf: function cdf(x6, alpha, beta) { + return x6 > 1 || x6 < 0 ? (x6 > 1) * 1 : jStat3.ibeta(x6, alpha, beta); + }, + inv: function inv(x6, alpha, beta) { + return jStat3.ibetainv(x6, alpha, beta); + }, + mean: function mean(alpha, beta) { + return alpha / (alpha + beta); + }, + median: function median(alpha, beta) { + return jStat3.ibetainv(0.5, alpha, beta); + }, + mode: function mode(alpha, beta) { + return (alpha - 1) / (alpha + beta - 2); + }, + // return a random sample + sample: function sample(alpha, beta) { + var u11 = jStat3.randg(alpha); + return u11 / (u11 + jStat3.randg(beta)); + }, + variance: function variance(alpha, beta) { + return alpha * beta / (Math2.pow(alpha + beta, 2) * (alpha + beta + 1)); + } + }); + jStat3.extend(jStat3.centralF, { + // This implementation of the pdf function avoids float overflow + // See the way that R calculates this value: + // https://svn.r-project.org/R/trunk/src/nmath/df.c + pdf: function pdf(x6, df1, df2) { + var p7, q, f7; + if (x6 < 0) + return 0; + if (df1 <= 2) { + if (x6 === 0 && df1 < 2) { + return Infinity; + } + if (x6 === 0 && df1 === 2) { + return 1; + } + return 1 / jStat3.betafn(df1 / 2, df2 / 2) * Math2.pow(df1 / df2, df1 / 2) * Math2.pow(x6, df1 / 2 - 1) * Math2.pow(1 + df1 / df2 * x6, -(df1 + df2) / 2); + } + p7 = df1 * x6 / (df2 + x6 * df1); + q = df2 / (df2 + x6 * df1); + f7 = df1 * q / 2; + return f7 * jStat3.binomial.pdf((df1 - 2) / 2, (df1 + df2 - 2) / 2, p7); + }, + cdf: function cdf(x6, df1, df2) { + if (x6 < 0) + return 0; + return jStat3.ibeta(df1 * x6 / (df1 * x6 + df2), df1 / 2, df2 / 2); + }, + inv: function inv(x6, df1, df2) { + return df2 / (df1 * (1 / jStat3.ibetainv(x6, df1 / 2, df2 / 2) - 1)); + }, + mean: function mean(df1, df2) { + return df2 > 2 ? df2 / (df2 - 2) : void 0; + }, + mode: function mode(df1, df2) { + return df1 > 2 ? df2 * (df1 - 2) / (df1 * (df2 + 2)) : void 0; + }, + // return a random sample + sample: function sample(df1, df2) { + var x1 = jStat3.randg(df1 / 2) * 2; + var x22 = jStat3.randg(df2 / 2) * 2; + return x1 / df1 / (x22 / df2); + }, + variance: function variance(df1, df2) { + if (df2 <= 4) + return void 0; + return 2 * df2 * df2 * (df1 + df2 - 2) / (df1 * (df2 - 2) * (df2 - 2) * (df2 - 4)); + } + }); + jStat3.extend(jStat3.cauchy, { + pdf: function pdf(x6, local, scale) { + if (scale < 0) { + return 0; + } + return scale / (Math2.pow(x6 - local, 2) + Math2.pow(scale, 2)) / Math2.PI; + }, + cdf: function cdf(x6, local, scale) { + return Math2.atan((x6 - local) / scale) / Math2.PI + 0.5; + }, + inv: function(p7, local, scale) { + return local + scale * Math2.tan(Math2.PI * (p7 - 0.5)); + }, + median: function median(local) { + return local; + }, + mode: function mode(local) { + return local; + }, + sample: function sample(local, scale) { + return jStat3.randn() * Math2.sqrt(1 / (2 * jStat3.randg(0.5))) * scale + local; + } + }); + jStat3.extend(jStat3.chisquare, { + pdf: function pdf(x6, dof) { + if (x6 < 0) + return 0; + return x6 === 0 && dof === 2 ? 0.5 : Math2.exp((dof / 2 - 1) * Math2.log(x6) - x6 / 2 - dof / 2 * Math2.log(2) - jStat3.gammaln(dof / 2)); + }, + cdf: function cdf(x6, dof) { + if (x6 < 0) + return 0; + return jStat3.lowRegGamma(dof / 2, x6 / 2); + }, + inv: function(p7, dof) { + return 2 * jStat3.gammapinv(p7, 0.5 * dof); + }, + mean: function(dof) { + return dof; + }, + // TODO: this is an approximation (is there a better way?) + median: function median(dof) { + return dof * Math2.pow(1 - 2 / (9 * dof), 3); + }, + mode: function mode(dof) { + return dof - 2 > 0 ? dof - 2 : 0; + }, + sample: function sample(dof) { + return jStat3.randg(dof / 2) * 2; + }, + variance: function variance(dof) { + return 2 * dof; + } + }); + jStat3.extend(jStat3.exponential, { + pdf: function pdf(x6, rate) { + return x6 < 0 ? 0 : rate * Math2.exp(-rate * x6); + }, + cdf: function cdf(x6, rate) { + return x6 < 0 ? 0 : 1 - Math2.exp(-rate * x6); + }, + inv: function(p7, rate) { + return -Math2.log(1 - p7) / rate; + }, + mean: function(rate) { + return 1 / rate; + }, + median: function(rate) { + return 1 / rate * Math2.log(2); + }, + mode: function mode() { + return 0; + }, + sample: function sample(rate) { + return -1 / rate * Math2.log(jStat3._random_fn()); + }, + variance: function(rate) { + return Math2.pow(rate, -2); + } + }); + jStat3.extend(jStat3.gamma, { + pdf: function pdf(x6, shape, scale) { + if (x6 < 0) + return 0; + return x6 === 0 && shape === 1 ? 1 / scale : Math2.exp((shape - 1) * Math2.log(x6) - x6 / scale - jStat3.gammaln(shape) - shape * Math2.log(scale)); + }, + cdf: function cdf(x6, shape, scale) { + if (x6 < 0) + return 0; + return jStat3.lowRegGamma(shape, x6 / scale); + }, + inv: function(p7, shape, scale) { + return jStat3.gammapinv(p7, shape) * scale; + }, + mean: function(shape, scale) { + return shape * scale; + }, + mode: function mode(shape, scale) { + if (shape > 1) + return (shape - 1) * scale; + return void 0; + }, + sample: function sample(shape, scale) { + return jStat3.randg(shape) * scale; + }, + variance: function variance(shape, scale) { + return shape * scale * scale; + } + }); + jStat3.extend(jStat3.invgamma, { + pdf: function pdf(x6, shape, scale) { + if (x6 <= 0) + return 0; + return Math2.exp(-(shape + 1) * Math2.log(x6) - scale / x6 - jStat3.gammaln(shape) + shape * Math2.log(scale)); + }, + cdf: function cdf(x6, shape, scale) { + if (x6 <= 0) + return 0; + return 1 - jStat3.lowRegGamma(shape, scale / x6); + }, + inv: function(p7, shape, scale) { + return scale / jStat3.gammapinv(1 - p7, shape); + }, + mean: function(shape, scale) { + return shape > 1 ? scale / (shape - 1) : void 0; + }, + mode: function mode(shape, scale) { + return scale / (shape + 1); + }, + sample: function sample(shape, scale) { + return scale / jStat3.randg(shape); + }, + variance: function variance(shape, scale) { + if (shape <= 2) + return void 0; + return scale * scale / ((shape - 1) * (shape - 1) * (shape - 2)); + } + }); + jStat3.extend(jStat3.kumaraswamy, { + pdf: function pdf(x6, alpha, beta) { + if (x6 === 0 && alpha === 1) + return beta; + else if (x6 === 1 && beta === 1) + return alpha; + return Math2.exp(Math2.log(alpha) + Math2.log(beta) + (alpha - 1) * Math2.log(x6) + (beta - 1) * Math2.log(1 - Math2.pow(x6, alpha))); + }, + cdf: function cdf(x6, alpha, beta) { + if (x6 < 0) + return 0; + else if (x6 > 1) + return 1; + return 1 - Math2.pow(1 - Math2.pow(x6, alpha), beta); + }, + inv: function inv(p7, alpha, beta) { + return Math2.pow(1 - Math2.pow(1 - p7, 1 / beta), 1 / alpha); + }, + mean: function(alpha, beta) { + return beta * jStat3.gammafn(1 + 1 / alpha) * jStat3.gammafn(beta) / jStat3.gammafn(1 + 1 / alpha + beta); + }, + median: function median(alpha, beta) { + return Math2.pow(1 - Math2.pow(2, -1 / beta), 1 / alpha); + }, + mode: function mode(alpha, beta) { + if (!(alpha >= 1 && beta >= 1 && (alpha !== 1 && beta !== 1))) + return void 0; + return Math2.pow((alpha - 1) / (alpha * beta - 1), 1 / alpha); + }, + variance: function variance() { + throw new Error("variance not yet implemented"); + } + }); + jStat3.extend(jStat3.lognormal, { + pdf: function pdf(x6, mu, sigma) { + if (x6 <= 0) + return 0; + return Math2.exp(-Math2.log(x6) - 0.5 * Math2.log(2 * Math2.PI) - Math2.log(sigma) - Math2.pow(Math2.log(x6) - mu, 2) / (2 * sigma * sigma)); + }, + cdf: function cdf(x6, mu, sigma) { + if (x6 < 0) + return 0; + return 0.5 + 0.5 * jStat3.erf((Math2.log(x6) - mu) / Math2.sqrt(2 * sigma * sigma)); + }, + inv: function(p7, mu, sigma) { + return Math2.exp(-1.4142135623730951 * sigma * jStat3.erfcinv(2 * p7) + mu); + }, + mean: function mean(mu, sigma) { + return Math2.exp(mu + sigma * sigma / 2); + }, + median: function median(mu) { + return Math2.exp(mu); + }, + mode: function mode(mu, sigma) { + return Math2.exp(mu - sigma * sigma); + }, + sample: function sample(mu, sigma) { + return Math2.exp(jStat3.randn() * sigma + mu); + }, + variance: function variance(mu, sigma) { + return (Math2.exp(sigma * sigma) - 1) * Math2.exp(2 * mu + sigma * sigma); + } + }); + jStat3.extend(jStat3.noncentralt, { + pdf: function pdf(x6, dof, ncp) { + var tol = 1e-14; + if (Math2.abs(ncp) < tol) + return jStat3.studentt.pdf(x6, dof); + if (Math2.abs(x6) < tol) { + return Math2.exp(jStat3.gammaln((dof + 1) / 2) - ncp * ncp / 2 - 0.5 * Math2.log(Math2.PI * dof) - jStat3.gammaln(dof / 2)); + } + return dof / x6 * (jStat3.noncentralt.cdf(x6 * Math2.sqrt(1 + 2 / dof), dof + 2, ncp) - jStat3.noncentralt.cdf(x6, dof, ncp)); + }, + cdf: function cdf(x6, dof, ncp) { + var tol = 1e-14; + var min_iterations = 200; + if (Math2.abs(ncp) < tol) + return jStat3.studentt.cdf(x6, dof); + var flip = false; + if (x6 < 0) { + flip = true; + ncp = -ncp; + } + var prob = jStat3.normal.cdf(-ncp, 0, 1); + var value = tol + 1; + var lastvalue = value; + var y7 = x6 * x6 / (x6 * x6 + dof); + var j3 = 0; + var p7 = Math2.exp(-ncp * ncp / 2); + var q = Math2.exp(-ncp * ncp / 2 - 0.5 * Math2.log(2) - jStat3.gammaln(3 / 2)) * ncp; + while (j3 < min_iterations || lastvalue > tol || value > tol) { + lastvalue = value; + if (j3 > 0) { + p7 *= ncp * ncp / (2 * j3); + q *= ncp * ncp / (2 * (j3 + 1 / 2)); + } + value = p7 * jStat3.beta.cdf(y7, j3 + 0.5, dof / 2) + q * jStat3.beta.cdf(y7, j3 + 1, dof / 2); + prob += 0.5 * value; + j3++; + } + return flip ? 1 - prob : prob; + } + }); + jStat3.extend(jStat3.normal, { + pdf: function pdf(x6, mean, std) { + return Math2.exp(-0.5 * Math2.log(2 * Math2.PI) - Math2.log(std) - Math2.pow(x6 - mean, 2) / (2 * std * std)); + }, + cdf: function cdf(x6, mean, std) { + return 0.5 * (1 + jStat3.erf((x6 - mean) / Math2.sqrt(2 * std * std))); + }, + inv: function(p7, mean, std) { + return -1.4142135623730951 * std * jStat3.erfcinv(2 * p7) + mean; + }, + mean: function(mean) { + return mean; + }, + median: function median(mean) { + return mean; + }, + mode: function(mean) { + return mean; + }, + sample: function sample(mean, std) { + return jStat3.randn() * std + mean; + }, + variance: function(mean, std) { + return std * std; + } + }); + jStat3.extend(jStat3.pareto, { + pdf: function pdf(x6, scale, shape) { + if (x6 < scale) + return 0; + return shape * Math2.pow(scale, shape) / Math2.pow(x6, shape + 1); + }, + cdf: function cdf(x6, scale, shape) { + if (x6 < scale) + return 0; + return 1 - Math2.pow(scale / x6, shape); + }, + inv: function inv(p7, scale, shape) { + return scale / Math2.pow(1 - p7, 1 / shape); + }, + mean: function mean(scale, shape) { + if (shape <= 1) + return void 0; + return shape * Math2.pow(scale, shape) / (shape - 1); + }, + median: function median(scale, shape) { + return scale * (shape * Math2.SQRT2); + }, + mode: function mode(scale) { + return scale; + }, + variance: function(scale, shape) { + if (shape <= 2) + return void 0; + return scale * scale * shape / (Math2.pow(shape - 1, 2) * (shape - 2)); + } + }); + jStat3.extend(jStat3.studentt, { + pdf: function pdf(x6, dof) { + dof = dof > 1e100 ? 1e100 : dof; + return 1 / (Math2.sqrt(dof) * jStat3.betafn(0.5, dof / 2)) * Math2.pow(1 + x6 * x6 / dof, -((dof + 1) / 2)); + }, + cdf: function cdf(x6, dof) { + var dof2 = dof / 2; + return jStat3.ibeta((x6 + Math2.sqrt(x6 * x6 + dof)) / (2 * Math2.sqrt(x6 * x6 + dof)), dof2, dof2); + }, + inv: function(p7, dof) { + var x6 = jStat3.ibetainv(2 * Math2.min(p7, 1 - p7), 0.5 * dof, 0.5); + x6 = Math2.sqrt(dof * (1 - x6) / x6); + return p7 > 0.5 ? x6 : -x6; + }, + mean: function mean(dof) { + return dof > 1 ? 0 : void 0; + }, + median: function median() { + return 0; + }, + mode: function mode() { + return 0; + }, + sample: function sample(dof) { + return jStat3.randn() * Math2.sqrt(dof / (2 * jStat3.randg(dof / 2))); + }, + variance: function variance(dof) { + return dof > 2 ? dof / (dof - 2) : dof > 1 ? Infinity : void 0; + } + }); + jStat3.extend(jStat3.weibull, { + pdf: function pdf(x6, scale, shape) { + if (x6 < 0 || scale < 0 || shape < 0) + return 0; + return shape / scale * Math2.pow(x6 / scale, shape - 1) * Math2.exp(-Math2.pow(x6 / scale, shape)); + }, + cdf: function cdf(x6, scale, shape) { + return x6 < 0 ? 0 : 1 - Math2.exp(-Math2.pow(x6 / scale, shape)); + }, + inv: function(p7, scale, shape) { + return scale * Math2.pow(-Math2.log(1 - p7), 1 / shape); + }, + mean: function(scale, shape) { + return scale * jStat3.gammafn(1 + 1 / shape); + }, + median: function median(scale, shape) { + return scale * Math2.pow(Math2.log(2), 1 / shape); + }, + mode: function mode(scale, shape) { + if (shape <= 1) + return 0; + return scale * Math2.pow((shape - 1) / shape, 1 / shape); + }, + sample: function sample(scale, shape) { + return scale * Math2.pow(-Math2.log(jStat3._random_fn()), 1 / shape); + }, + variance: function variance(scale, shape) { + return scale * scale * jStat3.gammafn(1 + 2 / shape) - Math2.pow(jStat3.weibull.mean(scale, shape), 2); + } + }); + jStat3.extend(jStat3.uniform, { + pdf: function pdf(x6, a11, b7) { + return x6 < a11 || x6 > b7 ? 0 : 1 / (b7 - a11); + }, + cdf: function cdf(x6, a11, b7) { + if (x6 < a11) + return 0; + else if (x6 < b7) + return (x6 - a11) / (b7 - a11); + return 1; + }, + inv: function(p7, a11, b7) { + return a11 + p7 * (b7 - a11); + }, + mean: function mean(a11, b7) { + return 0.5 * (a11 + b7); + }, + median: function median(a11, b7) { + return jStat3.mean(a11, b7); + }, + mode: function mode() { + throw new Error("mode is not yet implemented"); + }, + sample: function sample(a11, b7) { + return a11 / 2 + b7 / 2 + (b7 / 2 - a11 / 2) * (2 * jStat3._random_fn() - 1); + }, + variance: function variance(a11, b7) { + return Math2.pow(b7 - a11, 2) / 12; + } + }); + function betinc(x6, a11, b7, eps) { + var a0 = 0; + var b0 = 1; + var a1 = 1; + var b1 = 1; + var m9 = 0; + var a22 = 0; + var c92; + while (Math2.abs((a1 - a22) / a1) > eps) { + a22 = a1; + c92 = -(a11 + m9) * (a11 + b7 + m9) * x6 / (a11 + 2 * m9) / (a11 + 2 * m9 + 1); + a0 = a1 + c92 * a0; + b0 = b1 + c92 * b0; + m9 = m9 + 1; + c92 = m9 * (b7 - m9) * x6 / (a11 + 2 * m9 - 1) / (a11 + 2 * m9); + a1 = a0 + c92 * a1; + b1 = b0 + c92 * b1; + a0 = a0 / b1; + b0 = b0 / b1; + a1 = a1 / b1; + b1 = 1; + } + return a1 / a11; + } + jStat3.extend(jStat3.binomial, { + pdf: function pdf(k8, n31, p7) { + return p7 === 0 || p7 === 1 ? n31 * p7 === k8 ? 1 : 0 : jStat3.combination(n31, k8) * Math2.pow(p7, k8) * Math2.pow(1 - p7, n31 - k8); + }, + cdf: function cdf(x6, n31, p7) { + var betacdf; + var eps = 1e-10; + if (x6 < 0) + return 0; + if (x6 >= n31) + return 1; + if (p7 < 0 || p7 > 1 || n31 <= 0) + return NaN; + x6 = Math2.floor(x6); + var z5 = p7; + var a11 = x6 + 1; + var b7 = n31 - x6; + var s20 = a11 + b7; + var bt = Math2.exp(jStat3.gammaln(s20) - jStat3.gammaln(b7) - jStat3.gammaln(a11) + a11 * Math2.log(z5) + b7 * Math2.log(1 - z5)); + if (z5 < (a11 + 1) / (s20 + 2)) + betacdf = bt * betinc(z5, a11, b7, eps); + else + betacdf = 1 - bt * betinc(1 - z5, b7, a11, eps); + return Math2.round((1 - betacdf) * (1 / eps)) / (1 / eps); + } + }); + jStat3.extend(jStat3.negbin, { + pdf: function pdf(k8, r18, p7) { + if (k8 !== k8 >>> 0) + return false; + if (k8 < 0) + return 0; + return jStat3.combination(k8 + r18 - 1, r18 - 1) * Math2.pow(1 - p7, k8) * Math2.pow(p7, r18); + }, + cdf: function cdf(x6, r18, p7) { + var sum = 0, k8 = 0; + if (x6 < 0) + return 0; + for (; k8 <= x6; k8++) { + sum += jStat3.negbin.pdf(k8, r18, p7); + } + return sum; + } + }); + jStat3.extend(jStat3.hypgeom, { + pdf: function pdf(k8, N6, m6, n31) { + if (k8 !== k8 | 0) { + return false; + } else if (k8 < 0 || k8 < m6 - (N6 - n31)) { + return 0; + } else if (k8 > n31 || k8 > m6) { + return 0; + } else if (m6 * 2 > N6) { + if (n31 * 2 > N6) { + return jStat3.hypgeom.pdf(N6 - m6 - n31 + k8, N6, N6 - m6, N6 - n31); + } else { + return jStat3.hypgeom.pdf(n31 - k8, N6, N6 - m6, n31); + } + } else if (n31 * 2 > N6) { + return jStat3.hypgeom.pdf(m6 - k8, N6, m6, N6 - n31); + } else if (m6 < n31) { + return jStat3.hypgeom.pdf(k8, N6, n31, m6); + } else { + var scaledPDF = 1; + var samplesDone = 0; + for (var i23 = 0; i23 < k8; i23++) { + while (scaledPDF > 1 && samplesDone < n31) { + scaledPDF *= 1 - m6 / (N6 - samplesDone); + samplesDone++; + } + scaledPDF *= (n31 - i23) * (m6 - i23) / ((i23 + 1) * (N6 - m6 - n31 + i23 + 1)); + } + for (; samplesDone < n31; samplesDone++) { + scaledPDF *= 1 - m6 / (N6 - samplesDone); + } + return Math2.min(1, Math2.max(0, scaledPDF)); + } + }, + cdf: function cdf(x6, N6, m6, n31) { + if (x6 < 0 || x6 < m6 - (N6 - n31)) { + return 0; + } else if (x6 >= n31 || x6 >= m6) { + return 1; + } else if (m6 * 2 > N6) { + if (n31 * 2 > N6) { + return jStat3.hypgeom.cdf(N6 - m6 - n31 + x6, N6, N6 - m6, N6 - n31); + } else { + return 1 - jStat3.hypgeom.cdf(n31 - x6 - 1, N6, N6 - m6, n31); + } + } else if (n31 * 2 > N6) { + return 1 - jStat3.hypgeom.cdf(m6 - x6 - 1, N6, m6, N6 - n31); + } else if (m6 < n31) { + return jStat3.hypgeom.cdf(x6, N6, n31, m6); + } else { + var scaledCDF = 1; + var scaledPDF = 1; + var samplesDone = 0; + for (var i23 = 0; i23 < x6; i23++) { + while (scaledCDF > 1 && samplesDone < n31) { + var factor = 1 - m6 / (N6 - samplesDone); + scaledPDF *= factor; + scaledCDF *= factor; + samplesDone++; + } + scaledPDF *= (n31 - i23) * (m6 - i23) / ((i23 + 1) * (N6 - m6 - n31 + i23 + 1)); + scaledCDF += scaledPDF; + } + for (; samplesDone < n31; samplesDone++) { + scaledCDF *= 1 - m6 / (N6 - samplesDone); + } + return Math2.min(1, Math2.max(0, scaledCDF)); + } + } + }); + jStat3.extend(jStat3.poisson, { + pdf: function pdf(k8, l20) { + if (l20 < 0 || k8 % 1 !== 0 || k8 < 0) { + return 0; + } + return Math2.pow(l20, k8) * Math2.exp(-l20) / jStat3.factorial(k8); + }, + cdf: function cdf(x6, l20) { + var sumarr = [], k8 = 0; + if (x6 < 0) + return 0; + for (; k8 <= x6; k8++) { + sumarr.push(jStat3.poisson.pdf(k8, l20)); + } + return jStat3.sum(sumarr); + }, + mean: function(l20) { + return l20; + }, + variance: function(l20) { + return l20; + }, + sampleSmall: function sampleSmall(l20) { + var p7 = 1, k8 = 0, L6 = Math2.exp(-l20); + do { + k8++; + p7 *= jStat3._random_fn(); + } while (p7 > L6); + return k8 - 1; + }, + sampleLarge: function sampleLarge(l20) { + var lam = l20; + var k8; + var U, V6, slam, loglam, a11, b7, invalpha, vr, us; + slam = Math2.sqrt(lam); + loglam = Math2.log(lam); + b7 = 0.931 + 2.53 * slam; + a11 = -0.059 + 0.02483 * b7; + invalpha = 1.1239 + 1.1328 / (b7 - 3.4); + vr = 0.9277 - 3.6224 / (b7 - 2); + while (1) { + U = Math2.random() - 0.5; + V6 = Math2.random(); + us = 0.5 - Math2.abs(U); + k8 = Math2.floor((2 * a11 / us + b7) * U + lam + 0.43); + if (us >= 0.07 && V6 <= vr) { + return k8; + } + if (k8 < 0 || us < 0.013 && V6 > us) { + continue; + } + if (Math2.log(V6) + Math2.log(invalpha) - Math2.log(a11 / (us * us) + b7) <= -lam + k8 * loglam - jStat3.loggam(k8 + 1)) { + return k8; + } + } + }, + sample: function sample(l20) { + if (l20 < 10) + return this.sampleSmall(l20); + else + return this.sampleLarge(l20); + } + }); + jStat3.extend(jStat3.triangular, { + pdf: function pdf(x6, a11, b7, c12) { + if (b7 <= a11 || c12 < a11 || c12 > b7) { + return NaN; + } else { + if (x6 < a11 || x6 > b7) { + return 0; + } else if (x6 < c12) { + return 2 * (x6 - a11) / ((b7 - a11) * (c12 - a11)); + } else if (x6 === c12) { + return 2 / (b7 - a11); + } else { + return 2 * (b7 - x6) / ((b7 - a11) * (b7 - c12)); + } + } + }, + cdf: function cdf(x6, a11, b7, c12) { + if (b7 <= a11 || c12 < a11 || c12 > b7) + return NaN; + if (x6 <= a11) + return 0; + else if (x6 >= b7) + return 1; + if (x6 <= c12) + return Math2.pow(x6 - a11, 2) / ((b7 - a11) * (c12 - a11)); + else + return 1 - Math2.pow(b7 - x6, 2) / ((b7 - a11) * (b7 - c12)); + }, + inv: function inv(p7, a11, b7, c12) { + if (b7 <= a11 || c12 < a11 || c12 > b7) { + return NaN; + } else { + if (p7 <= (c12 - a11) / (b7 - a11)) { + return a11 + (b7 - a11) * Math2.sqrt(p7 * ((c12 - a11) / (b7 - a11))); + } else { + return a11 + (b7 - a11) * (1 - Math2.sqrt((1 - p7) * (1 - (c12 - a11) / (b7 - a11)))); + } + } + }, + mean: function mean(a11, b7, c12) { + return (a11 + b7 + c12) / 3; + }, + median: function median(a11, b7, c12) { + if (c12 <= (a11 + b7) / 2) { + return b7 - Math2.sqrt((b7 - a11) * (b7 - c12)) / Math2.sqrt(2); + } else if (c12 > (a11 + b7) / 2) { + return a11 + Math2.sqrt((b7 - a11) * (c12 - a11)) / Math2.sqrt(2); + } + }, + mode: function mode(a11, b7, c12) { + return c12; + }, + sample: function sample(a11, b7, c12) { + var u11 = jStat3._random_fn(); + if (u11 < (c12 - a11) / (b7 - a11)) + return a11 + Math2.sqrt(u11 * (b7 - a11) * (c12 - a11)); + return b7 - Math2.sqrt((1 - u11) * (b7 - a11) * (b7 - c12)); + }, + variance: function variance(a11, b7, c12) { + return (a11 * a11 + b7 * b7 + c12 * c12 - a11 * b7 - a11 * c12 - b7 * c12) / 18; + } + }); + jStat3.extend(jStat3.arcsine, { + pdf: function pdf(x6, a11, b7) { + if (b7 <= a11) + return NaN; + return x6 <= a11 || x6 >= b7 ? 0 : 2 / Math2.PI * Math2.pow(Math2.pow(b7 - a11, 2) - Math2.pow(2 * x6 - a11 - b7, 2), -0.5); + }, + cdf: function cdf(x6, a11, b7) { + if (x6 < a11) + return 0; + else if (x6 < b7) + return 2 / Math2.PI * Math2.asin(Math2.sqrt((x6 - a11) / (b7 - a11))); + return 1; + }, + inv: function(p7, a11, b7) { + return a11 + (0.5 - 0.5 * Math2.cos(Math2.PI * p7)) * (b7 - a11); + }, + mean: function mean(a11, b7) { + if (b7 <= a11) + return NaN; + return (a11 + b7) / 2; + }, + median: function median(a11, b7) { + if (b7 <= a11) + return NaN; + return (a11 + b7) / 2; + }, + mode: function mode() { + throw new Error("mode is not yet implemented"); + }, + sample: function sample(a11, b7) { + return (a11 + b7) / 2 + (b7 - a11) / 2 * Math2.sin(2 * Math2.PI * jStat3.uniform.sample(0, 1)); + }, + variance: function variance(a11, b7) { + if (b7 <= a11) + return NaN; + return Math2.pow(b7 - a11, 2) / 8; + } + }); + function laplaceSign(x6) { + return x6 / Math2.abs(x6); + } + jStat3.extend(jStat3.laplace, { + pdf: function pdf(x6, mu, b7) { + return b7 <= 0 ? 0 : Math2.exp(-Math2.abs(x6 - mu) / b7) / (2 * b7); + }, + cdf: function cdf(x6, mu, b7) { + if (b7 <= 0) { + return 0; + } + if (x6 < mu) { + return 0.5 * Math2.exp((x6 - mu) / b7); + } else { + return 1 - 0.5 * Math2.exp(-(x6 - mu) / b7); + } + }, + mean: function(mu) { + return mu; + }, + median: function(mu) { + return mu; + }, + mode: function(mu) { + return mu; + }, + variance: function(mu, b7) { + return 2 * b7 * b7; + }, + sample: function sample(mu, b7) { + var u11 = jStat3._random_fn() - 0.5; + return mu - b7 * laplaceSign(u11) * Math2.log(1 - 2 * Math2.abs(u11)); + } + }); + function tukeyWprob(w6, rr, cc) { + var nleg = 12; + var ihalf = 6; + var C1 = -30; + var C22 = -50; + var C32 = 60; + var bb = 8; + var wlar = 3; + var wincr1 = 2; + var wincr2 = 3; + var xleg = [ + 0.9815606342467192, + 0.9041172563704749, + 0.7699026741943047, + 0.5873179542866175, + 0.3678314989981802, + 0.1252334085114689 + ]; + var aleg = [ + 0.04717533638651183, + 0.10693932599531843, + 0.16007832854334622, + 0.20316742672306592, + 0.2334925365383548, + 0.24914704581340277 + ]; + var qsqz = w6 * 0.5; + if (qsqz >= bb) + return 1; + var pr_w = 2 * jStat3.normal.cdf(qsqz, 0, 1, 1, 0) - 1; + if (pr_w >= Math2.exp(C22 / cc)) + pr_w = Math2.pow(pr_w, cc); + else + pr_w = 0; + var wincr; + if (w6 > wlar) + wincr = wincr1; + else + wincr = wincr2; + var blb = qsqz; + var binc = (bb - qsqz) / wincr; + var bub = blb + binc; + var einsum = 0; + var cc1 = cc - 1; + for (var wi = 1; wi <= wincr; wi++) { + var elsum = 0; + var a11 = 0.5 * (bub + blb); + var b7 = 0.5 * (bub - blb); + for (var jj = 1; jj <= nleg; jj++) { + var j3, xx; + if (ihalf < jj) { + j3 = nleg - jj + 1; + xx = xleg[j3 - 1]; + } else { + j3 = jj; + xx = -xleg[j3 - 1]; + } + var c12 = b7 * xx; + var ac = a11 + c12; + var qexpo = ac * ac; + if (qexpo > C32) + break; + var pplus = 2 * jStat3.normal.cdf(ac, 0, 1, 1, 0); + var pminus = 2 * jStat3.normal.cdf(ac, w6, 1, 1, 0); + var rinsum = pplus * 0.5 - pminus * 0.5; + if (rinsum >= Math2.exp(C1 / cc1)) { + rinsum = aleg[j3 - 1] * Math2.exp(-(0.5 * qexpo)) * Math2.pow(rinsum, cc1); + elsum += rinsum; + } + } + elsum *= 2 * b7 * cc / Math2.sqrt(2 * Math2.PI); + einsum += elsum; + blb = bub; + bub += binc; + } + pr_w += einsum; + if (pr_w <= Math2.exp(C1 / rr)) + return 0; + pr_w = Math2.pow(pr_w, rr); + if (pr_w >= 1) + return 1; + return pr_w; + } + function tukeyQinv(p7, c12, v6) { + var p0 = 0.322232421088; + var q0 = 0.099348462606; + var p1 = -1; + var q1 = 0.588581570495; + var p22 = -0.342242088547; + var q2 = 0.531103462366; + var p32 = -0.204231210125; + var q3 = 0.10353775285; + var p42 = -453642210148e-16; + var q4 = 0.0038560700634; + var c1 = 0.8832; + var c22 = 0.2368; + var c32 = 1.214; + var c42 = 1.208; + var c52 = 1.4142; + var vmax = 120; + var ps = 0.5 - 0.5 * p7; + var yi = Math2.sqrt(Math2.log(1 / (ps * ps))); + var t17 = yi + ((((yi * p42 + p32) * yi + p22) * yi + p1) * yi + p0) / ((((yi * q4 + q3) * yi + q2) * yi + q1) * yi + q0); + if (v6 < vmax) + t17 += (t17 * t17 * t17 + t17) / v6 / 4; + var q = c1 - c22 * t17; + if (v6 < vmax) + q += -c32 / v6 + c42 * t17 / v6; + return t17 * (q * Math2.log(c12 - 1) + c52); + } + jStat3.extend(jStat3.tukey, { + cdf: function cdf(q, nmeans, df) { + var rr = 1; + var cc = nmeans; + var nlegq = 16; + var ihalfq = 8; + var eps1 = -30; + var eps2 = 1e-14; + var dhaf = 100; + var dquar = 800; + var deigh = 5e3; + var dlarg = 25e3; + var ulen1 = 1; + var ulen2 = 0.5; + var ulen3 = 0.25; + var ulen4 = 0.125; + var xlegq = [ + 0.9894009349916499, + 0.9445750230732326, + 0.8656312023878318, + 0.755404408355003, + 0.6178762444026438, + 0.45801677765722737, + 0.2816035507792589, + 0.09501250983763744 + ]; + var alegq = [ + 0.027152459411754096, + 0.062253523938647894, + 0.09515851168249279, + 0.12462897125553388, + 0.14959598881657674, + 0.16915651939500254, + 0.18260341504492358, + 0.1894506104550685 + ]; + if (q <= 0) + return 0; + if (df < 2 || rr < 1 || cc < 2) + return NaN; + if (!Number.isFinite(q)) + return 1; + if (df > dlarg) + return tukeyWprob(q, rr, cc); + var f22 = df * 0.5; + var f2lf = f22 * Math2.log(df) - df * Math2.log(2) - jStat3.gammaln(f22); + var f21 = f22 - 1; + var ff4 = df * 0.25; + var ulen; + if (df <= dhaf) + ulen = ulen1; + else if (df <= dquar) + ulen = ulen2; + else if (df <= deigh) + ulen = ulen3; + else + ulen = ulen4; + f2lf += Math2.log(ulen); + var ans = 0; + for (var i23 = 1; i23 <= 50; i23++) { + var otsum = 0; + var twa1 = (2 * i23 - 1) * ulen; + for (var jj = 1; jj <= nlegq; jj++) { + var j3, t1; + if (ihalfq < jj) { + j3 = jj - ihalfq - 1; + t1 = f2lf + f21 * Math2.log(twa1 + xlegq[j3] * ulen) - (xlegq[j3] * ulen + twa1) * ff4; + } else { + j3 = jj - 1; + t1 = f2lf + f21 * Math2.log(twa1 - xlegq[j3] * ulen) + (xlegq[j3] * ulen - twa1) * ff4; + } + var qsqz; + if (t1 >= eps1) { + if (ihalfq < jj) { + qsqz = q * Math2.sqrt((xlegq[j3] * ulen + twa1) * 0.5); + } else { + qsqz = q * Math2.sqrt((-(xlegq[j3] * ulen) + twa1) * 0.5); + } + var wprb = tukeyWprob(qsqz, rr, cc); + var rotsum = wprb * alegq[j3] * Math2.exp(t1); + otsum += rotsum; + } + } + if (i23 * ulen >= 1 && otsum <= eps2) + break; + ans += otsum; + } + if (otsum > eps2) { + throw new Error("tukey.cdf failed to converge"); + } + if (ans > 1) + ans = 1; + return ans; + }, + inv: function(p7, nmeans, df) { + var rr = 1; + var cc = nmeans; + var eps = 1e-4; + var maxiter = 50; + if (df < 2 || rr < 1 || cc < 2) + return NaN; + if (p7 < 0 || p7 > 1) + return NaN; + if (p7 === 0) + return 0; + if (p7 === 1) + return Infinity; + var x0 = tukeyQinv(p7, cc, df); + var valx0 = jStat3.tukey.cdf(x0, nmeans, df) - p7; + var x1; + if (valx0 > 0) + x1 = Math2.max(0, x0 - 1); + else + x1 = x0 + 1; + var valx1 = jStat3.tukey.cdf(x1, nmeans, df) - p7; + var ans; + for (var iter = 1; iter < maxiter; iter++) { + ans = x1 - valx1 * (x1 - x0) / (valx1 - valx0); + valx0 = valx1; + x0 = x1; + if (ans < 0) { + ans = 0; + valx1 = -p7; + } + valx1 = jStat3.tukey.cdf(ans, nmeans, df) - p7; + x1 = ans; + var xabs = Math2.abs(x1 - x0); + if (xabs < eps) + return ans; + } + throw new Error("tukey.inv failed to converge"); + } + }); + })(jStat2, Math); + (function(jStat3, Math2) { + var push2 = Array.prototype.push; + var isArray = jStat3.utils.isArray; + function isUsable(arg) { + return isArray(arg) || arg instanceof jStat3; + } + jStat3.extend({ + // add a vector/matrix to a vector/matrix or scalar + add: function add(arr, arg) { + if (isUsable(arg)) { + if (!isUsable(arg[0])) + arg = [arg]; + return jStat3.map(arr, function(value, row, col) { + return value + arg[row][col]; + }); + } + return jStat3.map(arr, function(value) { + return value + arg; + }); + }, + // subtract a vector or scalar from the vector + subtract: function subtract(arr, arg) { + if (isUsable(arg)) { + if (!isUsable(arg[0])) + arg = [arg]; + return jStat3.map(arr, function(value, row, col) { + return value - arg[row][col] || 0; + }); + } + return jStat3.map(arr, function(value) { + return value - arg; + }); + }, + // matrix division + divide: function divide(arr, arg) { + if (isUsable(arg)) { + if (!isUsable(arg[0])) + arg = [arg]; + return jStat3.multiply(arr, jStat3.inv(arg)); + } + return jStat3.map(arr, function(value) { + return value / arg; + }); + }, + // matrix multiplication + multiply: function multiply(arr, arg) { + var row, col, nrescols, sum, nrow, ncol, res, rescols; + if (arr.length === void 0 && arg.length === void 0) { + return arr * arg; + } + nrow = arr.length, ncol = arr[0].length, res = jStat3.zeros(nrow, nrescols = isUsable(arg) ? arg[0].length : ncol), rescols = 0; + if (isUsable(arg)) { + for (; rescols < nrescols; rescols++) { + for (row = 0; row < nrow; row++) { + sum = 0; + for (col = 0; col < ncol; col++) + sum += arr[row][col] * arg[col][rescols]; + res[row][rescols] = sum; + } + } + return nrow === 1 && rescols === 1 ? res[0][0] : res; + } + return jStat3.map(arr, function(value) { + return value * arg; + }); + }, + // outer([1,2,3],[4,5,6]) + // === + // [[1],[2],[3]] times [[4,5,6]] + // -> + // [[4,5,6],[8,10,12],[12,15,18]] + outer: function outer(A6, B5) { + return jStat3.multiply(A6.map(function(t17) { + return [t17]; + }), [B5]); + }, + // Returns the dot product of two matricies + dot: function dot(arr, arg) { + if (!isUsable(arr[0])) + arr = [arr]; + if (!isUsable(arg[0])) + arg = [arg]; + var left = arr[0].length === 1 && arr.length !== 1 ? jStat3.transpose(arr) : arr, right = arg[0].length === 1 && arg.length !== 1 ? jStat3.transpose(arg) : arg, res = [], row = 0, nrow = left.length, ncol = left[0].length, sum, col; + for (; row < nrow; row++) { + res[row] = []; + sum = 0; + for (col = 0; col < ncol; col++) + sum += left[row][col] * right[row][col]; + res[row] = sum; + } + return res.length === 1 ? res[0] : res; + }, + // raise every element by a scalar + pow: function pow(arr, arg) { + return jStat3.map(arr, function(value) { + return Math2.pow(value, arg); + }); + }, + // exponentiate every element + exp: function exp(arr) { + return jStat3.map(arr, function(value) { + return Math2.exp(value); + }); + }, + // generate the natural log of every element + log: function exp(arr) { + return jStat3.map(arr, function(value) { + return Math2.log(value); + }); + }, + // generate the absolute values of the vector + abs: function abs(arr) { + return jStat3.map(arr, function(value) { + return Math2.abs(value); + }); + }, + // computes the p-norm of the vector + // In the case that a matrix is passed, uses the first row as the vector + norm: function norm(arr, p7) { + var nnorm = 0, i23 = 0; + if (isNaN(p7)) + p7 = 2; + if (isUsable(arr[0])) + arr = arr[0]; + for (; i23 < arr.length; i23++) { + nnorm += Math2.pow(Math2.abs(arr[i23]), p7); + } + return Math2.pow(nnorm, 1 / p7); + }, + // computes the angle between two vectors in rads + // In case a matrix is passed, this uses the first row as the vector + angle: function angle(arr, arg) { + return Math2.acos(jStat3.dot(arr, arg) / (jStat3.norm(arr) * jStat3.norm(arg))); + }, + // augment one matrix by another + // Note: this function returns a matrix, not a jStat object + aug: function aug(a11, b7) { + var newarr = []; + var i23; + for (i23 = 0; i23 < a11.length; i23++) { + newarr.push(a11[i23].slice()); + } + for (i23 = 0; i23 < newarr.length; i23++) { + push2.apply(newarr[i23], b7[i23]); + } + return newarr; + }, + // The inv() function calculates the inverse of a matrix + // Create the inverse by augmenting the matrix by the identity matrix of the + // appropriate size, and then use G-J elimination on the augmented matrix. + inv: function inv(a11) { + var rows = a11.length; + var cols = a11[0].length; + var b7 = jStat3.identity(rows, cols); + var c12 = jStat3.gauss_jordan(a11, b7); + var result = []; + var i23 = 0; + var j3; + for (; i23 < rows; i23++) { + result[i23] = []; + for (j3 = cols; j3 < c12[0].length; j3++) + result[i23][j3 - cols] = c12[i23][j3]; + } + return result; + }, + // calculate the determinant of a matrix + det: function det(a11) { + if (a11.length === 2) { + return a11[0][0] * a11[1][1] - a11[0][1] * a11[1][0]; + } + var determinant = 0; + for (var i23 = 0; i23 < a11.length; i23++) { + var submatrix = []; + for (var row = 1; row < a11.length; row++) { + submatrix[row - 1] = []; + for (var col = 0; col < a11.length; col++) { + if (col < i23) { + submatrix[row - 1][col] = a11[row][col]; + } else if (col > i23) { + submatrix[row - 1][col - 1] = a11[row][col]; + } + } + } + var sign = i23 % 2 ? -1 : 1; + determinant += det(submatrix) * a11[0][i23] * sign; + } + return determinant; + }, + gauss_elimination: function gauss_elimination(a11, b7) { + var i23 = 0, j3 = 0, n31 = a11.length, m6 = a11[0].length, factor = 1, sum = 0, x6 = [], maug, pivot, temp, k8; + a11 = jStat3.aug(a11, b7); + maug = a11[0].length; + for (i23 = 0; i23 < n31; i23++) { + pivot = a11[i23][i23]; + j3 = i23; + for (k8 = i23 + 1; k8 < m6; k8++) { + if (pivot < Math2.abs(a11[k8][i23])) { + pivot = a11[k8][i23]; + j3 = k8; + } + } + if (j3 != i23) { + for (k8 = 0; k8 < maug; k8++) { + temp = a11[i23][k8]; + a11[i23][k8] = a11[j3][k8]; + a11[j3][k8] = temp; + } + } + for (j3 = i23 + 1; j3 < n31; j3++) { + factor = a11[j3][i23] / a11[i23][i23]; + for (k8 = i23; k8 < maug; k8++) { + a11[j3][k8] = a11[j3][k8] - factor * a11[i23][k8]; + } + } + } + for (i23 = n31 - 1; i23 >= 0; i23--) { + sum = 0; + for (j3 = i23 + 1; j3 <= n31 - 1; j3++) { + sum = sum + x6[j3] * a11[i23][j3]; + } + x6[i23] = (a11[i23][maug - 1] - sum) / a11[i23][i23]; + } + return x6; + }, + gauss_jordan: function gauss_jordan(a11, b7) { + var m6 = jStat3.aug(a11, b7); + var h11 = m6.length; + var w6 = m6[0].length; + var c12 = 0; + var x6, y7, y22; + for (y7 = 0; y7 < h11; y7++) { + var maxrow = y7; + for (y22 = y7 + 1; y22 < h11; y22++) { + if (Math2.abs(m6[y22][y7]) > Math2.abs(m6[maxrow][y7])) + maxrow = y22; + } + var tmp = m6[y7]; + m6[y7] = m6[maxrow]; + m6[maxrow] = tmp; + for (y22 = y7 + 1; y22 < h11; y22++) { + c12 = m6[y22][y7] / m6[y7][y7]; + for (x6 = y7; x6 < w6; x6++) { + m6[y22][x6] -= m6[y7][x6] * c12; + } + } + } + for (y7 = h11 - 1; y7 >= 0; y7--) { + c12 = m6[y7][y7]; + for (y22 = 0; y22 < y7; y22++) { + for (x6 = w6 - 1; x6 > y7 - 1; x6--) { + m6[y22][x6] -= m6[y7][x6] * m6[y22][y7] / c12; + } + } + m6[y7][y7] /= c12; + for (x6 = h11; x6 < w6; x6++) { + m6[y7][x6] /= c12; + } + } + return m6; + }, + // solve equation + // Ax=b + // A is upper triangular matrix + // A=[[1,2,3],[0,4,5],[0,6,7]] + // b=[1,2,3] + // triaUpSolve(A,b) // -> [2.666,0.1666,1.666] + // if you use matrix style + // A=[[1,2,3],[0,4,5],[0,6,7]] + // b=[[1],[2],[3]] + // will return [[2.666],[0.1666],[1.666]] + triaUpSolve: function triaUpSolve(A6, b7) { + var size = A6[0].length; + var x6 = jStat3.zeros(1, size)[0]; + var parts; + var matrix_mode = false; + if (b7[0].length != void 0) { + b7 = b7.map(function(i23) { + return i23[0]; + }); + matrix_mode = true; + } + jStat3.arange(size - 1, -1, -1).forEach(function(i23) { + parts = jStat3.arange(i23 + 1, size).map(function(j3) { + return x6[j3] * A6[i23][j3]; + }); + x6[i23] = (b7[i23] - jStat3.sum(parts)) / A6[i23][i23]; + }); + if (matrix_mode) + return x6.map(function(i23) { + return [i23]; + }); + return x6; + }, + triaLowSolve: function triaLowSolve(A6, b7) { + var size = A6[0].length; + var x6 = jStat3.zeros(1, size)[0]; + var parts; + var matrix_mode = false; + if (b7[0].length != void 0) { + b7 = b7.map(function(i23) { + return i23[0]; + }); + matrix_mode = true; + } + jStat3.arange(size).forEach(function(i23) { + parts = jStat3.arange(i23).map(function(j3) { + return A6[i23][j3] * x6[j3]; + }); + x6[i23] = (b7[i23] - jStat3.sum(parts)) / A6[i23][i23]; + }); + if (matrix_mode) + return x6.map(function(i23) { + return [i23]; + }); + return x6; + }, + // A -> [L,U] + // A=LU + // L is lower triangular matrix + // U is upper triangular matrix + lu: function lu(A6) { + var size = A6.length; + var L6 = jStat3.identity(size); + var R6 = jStat3.zeros(A6.length, A6[0].length); + var parts; + jStat3.arange(size).forEach(function(t17) { + R6[0][t17] = A6[0][t17]; + }); + jStat3.arange(1, size).forEach(function(l20) { + jStat3.arange(l20).forEach(function(i23) { + parts = jStat3.arange(i23).map(function(jj) { + return L6[l20][jj] * R6[jj][i23]; + }); + L6[l20][i23] = (A6[l20][i23] - jStat3.sum(parts)) / R6[i23][i23]; + }); + jStat3.arange(l20, size).forEach(function(j3) { + parts = jStat3.arange(l20).map(function(jj) { + return L6[l20][jj] * R6[jj][j3]; + }); + R6[l20][j3] = A6[parts.length][j3] - jStat3.sum(parts); + }); + }); + return [L6, R6]; + }, + // A -> T + // A=TT' + // T is lower triangular matrix + cholesky: function cholesky(A6) { + var size = A6.length; + var T6 = jStat3.zeros(A6.length, A6[0].length); + var parts; + jStat3.arange(size).forEach(function(i23) { + parts = jStat3.arange(i23).map(function(t17) { + return Math2.pow(T6[i23][t17], 2); + }); + T6[i23][i23] = Math2.sqrt(A6[i23][i23] - jStat3.sum(parts)); + jStat3.arange(i23 + 1, size).forEach(function(j3) { + parts = jStat3.arange(i23).map(function(t17) { + return T6[i23][t17] * T6[j3][t17]; + }); + T6[j3][i23] = (A6[i23][j3] - jStat3.sum(parts)) / T6[i23][i23]; + }); + }); + return T6; + }, + gauss_jacobi: function gauss_jacobi(a11, b7, x6, r18) { + var i23 = 0; + var j3 = 0; + var n31 = a11.length; + var l20 = []; + var u11 = []; + var d11 = []; + var xv, c12, h11, xk; + for (; i23 < n31; i23++) { + l20[i23] = []; + u11[i23] = []; + d11[i23] = []; + for (j3 = 0; j3 < n31; j3++) { + if (i23 > j3) { + l20[i23][j3] = a11[i23][j3]; + u11[i23][j3] = d11[i23][j3] = 0; + } else if (i23 < j3) { + u11[i23][j3] = a11[i23][j3]; + l20[i23][j3] = d11[i23][j3] = 0; + } else { + d11[i23][j3] = a11[i23][j3]; + l20[i23][j3] = u11[i23][j3] = 0; + } + } + } + h11 = jStat3.multiply(jStat3.multiply(jStat3.inv(d11), jStat3.add(l20, u11)), -1); + c12 = jStat3.multiply(jStat3.inv(d11), b7); + xv = x6; + xk = jStat3.add(jStat3.multiply(h11, x6), c12); + i23 = 2; + while (Math2.abs(jStat3.norm(jStat3.subtract(xk, xv))) > r18) { + xv = xk; + xk = jStat3.add(jStat3.multiply(h11, xv), c12); + i23++; + } + return xk; + }, + gauss_seidel: function gauss_seidel(a11, b7, x6, r18) { + var i23 = 0; + var n31 = a11.length; + var l20 = []; + var u11 = []; + var d11 = []; + var j3, xv, c12, h11, xk; + for (; i23 < n31; i23++) { + l20[i23] = []; + u11[i23] = []; + d11[i23] = []; + for (j3 = 0; j3 < n31; j3++) { + if (i23 > j3) { + l20[i23][j3] = a11[i23][j3]; + u11[i23][j3] = d11[i23][j3] = 0; + } else if (i23 < j3) { + u11[i23][j3] = a11[i23][j3]; + l20[i23][j3] = d11[i23][j3] = 0; + } else { + d11[i23][j3] = a11[i23][j3]; + l20[i23][j3] = u11[i23][j3] = 0; + } + } + } + h11 = jStat3.multiply(jStat3.multiply(jStat3.inv(jStat3.add(d11, l20)), u11), -1); + c12 = jStat3.multiply(jStat3.inv(jStat3.add(d11, l20)), b7); + xv = x6; + xk = jStat3.add(jStat3.multiply(h11, x6), c12); + i23 = 2; + while (Math2.abs(jStat3.norm(jStat3.subtract(xk, xv))) > r18) { + xv = xk; + xk = jStat3.add(jStat3.multiply(h11, xv), c12); + i23 = i23 + 1; + } + return xk; + }, + SOR: function SOR(a11, b7, x6, r18, w6) { + var i23 = 0; + var n31 = a11.length; + var l20 = []; + var u11 = []; + var d11 = []; + var j3, xv, c12, h11, xk; + for (; i23 < n31; i23++) { + l20[i23] = []; + u11[i23] = []; + d11[i23] = []; + for (j3 = 0; j3 < n31; j3++) { + if (i23 > j3) { + l20[i23][j3] = a11[i23][j3]; + u11[i23][j3] = d11[i23][j3] = 0; + } else if (i23 < j3) { + u11[i23][j3] = a11[i23][j3]; + l20[i23][j3] = d11[i23][j3] = 0; + } else { + d11[i23][j3] = a11[i23][j3]; + l20[i23][j3] = u11[i23][j3] = 0; + } + } + } + h11 = jStat3.multiply( + jStat3.inv(jStat3.add(d11, jStat3.multiply(l20, w6))), + jStat3.subtract( + jStat3.multiply(d11, 1 - w6), + jStat3.multiply(u11, w6) + ) + ); + c12 = jStat3.multiply(jStat3.multiply(jStat3.inv(jStat3.add( + d11, + jStat3.multiply(l20, w6) + )), b7), w6); + xv = x6; + xk = jStat3.add(jStat3.multiply(h11, x6), c12); + i23 = 2; + while (Math2.abs(jStat3.norm(jStat3.subtract(xk, xv))) > r18) { + xv = xk; + xk = jStat3.add(jStat3.multiply(h11, xv), c12); + i23++; + } + return xk; + }, + householder: function householder(a11) { + var m6 = a11.length; + var n31 = a11[0].length; + var i23 = 0; + var w6 = []; + var p7 = []; + var alpha, r18, k8, j3, factor; + for (; i23 < m6 - 1; i23++) { + alpha = 0; + for (j3 = i23 + 1; j3 < n31; j3++) + alpha += a11[j3][i23] * a11[j3][i23]; + factor = a11[i23 + 1][i23] > 0 ? -1 : 1; + alpha = factor * Math2.sqrt(alpha); + r18 = Math2.sqrt((alpha * alpha - a11[i23 + 1][i23] * alpha) / 2); + w6 = jStat3.zeros(m6, 1); + w6[i23 + 1][0] = (a11[i23 + 1][i23] - alpha) / (2 * r18); + for (k8 = i23 + 2; k8 < m6; k8++) + w6[k8][0] = a11[k8][i23] / (2 * r18); + p7 = jStat3.subtract( + jStat3.identity(m6, n31), + jStat3.multiply(jStat3.multiply(w6, jStat3.transpose(w6)), 2) + ); + a11 = jStat3.multiply(p7, jStat3.multiply(a11, p7)); + } + return a11; + }, + // A -> [Q,R] + // Q is orthogonal matrix + // R is upper triangular + QR: function() { + var sum = jStat3.sum; + var range = jStat3.arange; + function qr2(x6) { + var n31 = x6.length; + var p7 = x6[0].length; + var r18 = jStat3.zeros(p7, p7); + x6 = jStat3.copy(x6); + var i23, j3, k8; + for (j3 = 0; j3 < p7; j3++) { + r18[j3][j3] = Math2.sqrt(sum(range(n31).map(function(i24) { + return x6[i24][j3] * x6[i24][j3]; + }))); + for (i23 = 0; i23 < n31; i23++) { + x6[i23][j3] = x6[i23][j3] / r18[j3][j3]; + } + for (k8 = j3 + 1; k8 < p7; k8++) { + r18[j3][k8] = sum(range(n31).map(function(i24) { + return x6[i24][j3] * x6[i24][k8]; + })); + for (i23 = 0; i23 < n31; i23++) { + x6[i23][k8] = x6[i23][k8] - x6[i23][j3] * r18[j3][k8]; + } + } + } + return [x6, r18]; + } + return qr2; + }(), + lstsq: /* @__PURE__ */ function() { + function R_I(A6) { + A6 = jStat3.copy(A6); + var size = A6.length; + var I6 = jStat3.identity(size); + jStat3.arange(size - 1, -1, -1).forEach(function(i23) { + jStat3.sliceAssign( + I6, + { row: i23 }, + jStat3.divide(jStat3.slice(I6, { row: i23 }), A6[i23][i23]) + ); + jStat3.sliceAssign( + A6, + { row: i23 }, + jStat3.divide(jStat3.slice(A6, { row: i23 }), A6[i23][i23]) + ); + jStat3.arange(i23).forEach(function(j3) { + var c12 = jStat3.multiply(A6[j3][i23], -1); + var Aj = jStat3.slice(A6, { row: j3 }); + var cAi = jStat3.multiply(jStat3.slice(A6, { row: i23 }), c12); + jStat3.sliceAssign(A6, { row: j3 }, jStat3.add(Aj, cAi)); + var Ij = jStat3.slice(I6, { row: j3 }); + var cIi = jStat3.multiply(jStat3.slice(I6, { row: i23 }), c12); + jStat3.sliceAssign(I6, { row: j3 }, jStat3.add(Ij, cIi)); + }); + }); + return I6; + } + function qr_solve(A6, b7) { + var array_mode = false; + if (b7[0].length === void 0) { + b7 = b7.map(function(x7) { + return [x7]; + }); + array_mode = true; + } + var QR = jStat3.QR(A6); + var Q = QR[0]; + var R6 = QR[1]; + var attrs = A6[0].length; + var Q1 = jStat3.slice(Q, { col: { end: attrs } }); + var R1 = jStat3.slice(R6, { row: { end: attrs } }); + var RI = R_I(R1); + var Q2 = jStat3.transpose(Q1); + if (Q2[0].length === void 0) { + Q2 = [Q2]; + } + var x6 = jStat3.multiply(jStat3.multiply(RI, Q2), b7); + if (x6.length === void 0) { + x6 = [[x6]]; + } + if (array_mode) + return x6.map(function(i23) { + return i23[0]; + }); + return x6; + } + return qr_solve; + }(), + jacobi: function jacobi(a11) { + var condition = 1; + var n31 = a11.length; + var e33 = jStat3.identity(n31, n31); + var ev = []; + var b7, i23, j3, p7, q, maxim, theta, s20; + while (condition === 1) { + maxim = a11[0][1]; + p7 = 0; + q = 1; + for (i23 = 0; i23 < n31; i23++) { + for (j3 = 0; j3 < n31; j3++) { + if (i23 != j3) { + if (maxim < Math2.abs(a11[i23][j3])) { + maxim = Math2.abs(a11[i23][j3]); + p7 = i23; + q = j3; + } + } + } + } + if (a11[p7][p7] === a11[q][q]) + theta = a11[p7][q] > 0 ? Math2.PI / 4 : -Math2.PI / 4; + else + theta = Math2.atan(2 * a11[p7][q] / (a11[p7][p7] - a11[q][q])) / 2; + s20 = jStat3.identity(n31, n31); + s20[p7][p7] = Math2.cos(theta); + s20[p7][q] = -Math2.sin(theta); + s20[q][p7] = Math2.sin(theta); + s20[q][q] = Math2.cos(theta); + e33 = jStat3.multiply(e33, s20); + b7 = jStat3.multiply(jStat3.multiply(jStat3.inv(s20), a11), s20); + a11 = b7; + condition = 0; + for (i23 = 1; i23 < n31; i23++) { + for (j3 = 1; j3 < n31; j3++) { + if (i23 != j3 && Math2.abs(a11[i23][j3]) > 1e-3) { + condition = 1; + } + } + } + } + for (i23 = 0; i23 < n31; i23++) + ev.push(a11[i23][i23]); + return [e33, ev]; + }, + rungekutta: function rungekutta(f7, h11, p7, t_j, u_j, order) { + var k12, k22, u_j1, k32, k42; + if (order === 2) { + while (t_j <= p7) { + k12 = h11 * f7(t_j, u_j); + k22 = h11 * f7(t_j + h11, u_j + k12); + u_j1 = u_j + (k12 + k22) / 2; + u_j = u_j1; + t_j = t_j + h11; + } + } + if (order === 4) { + while (t_j <= p7) { + k12 = h11 * f7(t_j, u_j); + k22 = h11 * f7(t_j + h11 / 2, u_j + k12 / 2); + k32 = h11 * f7(t_j + h11 / 2, u_j + k22 / 2); + k42 = h11 * f7(t_j + h11, u_j + k32); + u_j1 = u_j + (k12 + 2 * k22 + 2 * k32 + k42) / 6; + u_j = u_j1; + t_j = t_j + h11; + } + } + return u_j; + }, + romberg: function romberg(f7, a11, b7, order) { + var i23 = 0; + var h11 = (b7 - a11) / 2; + var x6 = []; + var h1 = []; + var g6 = []; + var m6, a1, j3, k8, I6; + while (i23 < order / 2) { + I6 = f7(a11); + for (j3 = a11, k8 = 0; j3 <= b7; j3 = j3 + h11, k8++) + x6[k8] = j3; + m6 = x6.length; + for (j3 = 1; j3 < m6 - 1; j3++) { + I6 += (j3 % 2 !== 0 ? 4 : 2) * f7(x6[j3]); + } + I6 = h11 / 3 * (I6 + f7(b7)); + g6[i23] = I6; + h11 /= 2; + i23++; + } + a1 = g6.length; + m6 = 1; + while (a1 !== 1) { + for (j3 = 0; j3 < a1 - 1; j3++) + h1[j3] = (Math2.pow(4, m6) * g6[j3 + 1] - g6[j3]) / (Math2.pow(4, m6) - 1); + a1 = h1.length; + g6 = h1; + h1 = []; + m6++; + } + return g6; + }, + richardson: function richardson(X, f7, x6, h11) { + function pos(X2, x7) { + var i24 = 0; + var n31 = X2.length; + var p7; + for (; i24 < n31; i24++) + if (X2[i24] === x7) + p7 = i24; + return p7; + } + var h_min = Math2.abs(x6 - X[pos(X, x6) + 1]); + var i23 = 0; + var g6 = []; + var h1 = []; + var y1, y22, m6, a11, j3; + while (h11 >= h_min) { + y1 = pos(X, x6 + h11); + y22 = pos(X, x6); + g6[i23] = (f7[y1] - 2 * f7[y22] + f7[2 * y22 - y1]) / (h11 * h11); + h11 /= 2; + i23++; + } + a11 = g6.length; + m6 = 1; + while (a11 != 1) { + for (j3 = 0; j3 < a11 - 1; j3++) + h1[j3] = (Math2.pow(4, m6) * g6[j3 + 1] - g6[j3]) / (Math2.pow(4, m6) - 1); + a11 = h1.length; + g6 = h1; + h1 = []; + m6++; + } + return g6; + }, + simpson: function simpson(f7, a11, b7, n31) { + var h11 = (b7 - a11) / n31; + var I6 = f7(a11); + var x6 = []; + var j3 = a11; + var k8 = 0; + var i23 = 1; + var m6; + for (; j3 <= b7; j3 = j3 + h11, k8++) + x6[k8] = j3; + m6 = x6.length; + for (; i23 < m6 - 1; i23++) { + I6 += (i23 % 2 !== 0 ? 4 : 2) * f7(x6[i23]); + } + return h11 / 3 * (I6 + f7(b7)); + }, + hermite: function hermite(X, F, dF, value) { + var n31 = X.length; + var p7 = 0; + var i23 = 0; + var l20 = []; + var dl = []; + var A6 = []; + var B5 = []; + var j3; + for (; i23 < n31; i23++) { + l20[i23] = 1; + for (j3 = 0; j3 < n31; j3++) { + if (i23 != j3) + l20[i23] *= (value - X[j3]) / (X[i23] - X[j3]); + } + dl[i23] = 0; + for (j3 = 0; j3 < n31; j3++) { + if (i23 != j3) + dl[i23] += 1 / (X[i23] - X[j3]); + } + A6[i23] = (1 - 2 * (value - X[i23]) * dl[i23]) * (l20[i23] * l20[i23]); + B5[i23] = (value - X[i23]) * (l20[i23] * l20[i23]); + p7 += A6[i23] * F[i23] + B5[i23] * dF[i23]; + } + return p7; + }, + lagrange: function lagrange(X, F, value) { + var p7 = 0; + var i23 = 0; + var j3, l20; + var n31 = X.length; + for (; i23 < n31; i23++) { + l20 = F[i23]; + for (j3 = 0; j3 < n31; j3++) { + if (i23 != j3) + l20 *= (value - X[j3]) / (X[i23] - X[j3]); + } + p7 += l20; + } + return p7; + }, + cubic_spline: function cubic_spline(X, F, value) { + var n31 = X.length; + var i23 = 0, j3; + var A6 = []; + var B5 = []; + var alpha = []; + var c12 = []; + var h11 = []; + var b7 = []; + var d11 = []; + for (; i23 < n31 - 1; i23++) + h11[i23] = X[i23 + 1] - X[i23]; + alpha[0] = 0; + for (i23 = 1; i23 < n31 - 1; i23++) { + alpha[i23] = 3 / h11[i23] * (F[i23 + 1] - F[i23]) - 3 / h11[i23 - 1] * (F[i23] - F[i23 - 1]); + } + for (i23 = 1; i23 < n31 - 1; i23++) { + A6[i23] = []; + B5[i23] = []; + A6[i23][i23 - 1] = h11[i23 - 1]; + A6[i23][i23] = 2 * (h11[i23 - 1] + h11[i23]); + A6[i23][i23 + 1] = h11[i23]; + B5[i23][0] = alpha[i23]; + } + c12 = jStat3.multiply(jStat3.inv(A6), B5); + for (j3 = 0; j3 < n31 - 1; j3++) { + b7[j3] = (F[j3 + 1] - F[j3]) / h11[j3] - h11[j3] * (c12[j3 + 1][0] + 2 * c12[j3][0]) / 3; + d11[j3] = (c12[j3 + 1][0] - c12[j3][0]) / (3 * h11[j3]); + } + for (j3 = 0; j3 < n31; j3++) { + if (X[j3] > value) + break; + } + j3 -= 1; + return F[j3] + (value - X[j3]) * b7[j3] + jStat3.sq(value - X[j3]) * c12[j3] + (value - X[j3]) * jStat3.sq(value - X[j3]) * d11[j3]; + }, + gauss_quadrature: function gauss_quadrature() { + throw new Error("gauss_quadrature not yet implemented"); + }, + PCA: function PCA(X) { + var m6 = X.length; + var n31 = X[0].length; + var i23 = 0; + var j3, temp1; + var u11 = []; + var D5 = []; + var result = []; + var temp2 = []; + var Y = []; + var Bt = []; + var B5 = []; + var C6 = []; + var V6 = []; + var Vt = []; + for (i23 = 0; i23 < m6; i23++) { + u11[i23] = jStat3.sum(X[i23]) / n31; + } + for (i23 = 0; i23 < n31; i23++) { + B5[i23] = []; + for (j3 = 0; j3 < m6; j3++) { + B5[i23][j3] = X[j3][i23] - u11[j3]; + } + } + B5 = jStat3.transpose(B5); + for (i23 = 0; i23 < m6; i23++) { + C6[i23] = []; + for (j3 = 0; j3 < m6; j3++) { + C6[i23][j3] = jStat3.dot([B5[i23]], [B5[j3]]) / (n31 - 1); + } + } + result = jStat3.jacobi(C6); + V6 = result[0]; + D5 = result[1]; + Vt = jStat3.transpose(V6); + for (i23 = 0; i23 < D5.length; i23++) { + for (j3 = i23; j3 < D5.length; j3++) { + if (D5[i23] < D5[j3]) { + temp1 = D5[i23]; + D5[i23] = D5[j3]; + D5[j3] = temp1; + temp2 = Vt[i23]; + Vt[i23] = Vt[j3]; + Vt[j3] = temp2; + } + } + } + Bt = jStat3.transpose(B5); + for (i23 = 0; i23 < m6; i23++) { + Y[i23] = []; + for (j3 = 0; j3 < Bt.length; j3++) { + Y[i23][j3] = jStat3.dot([Vt[i23]], [Bt[j3]]); + } + } + return [X, D5, Vt, Y]; + } + }); + (function(funcs) { + for (var i23 = 0; i23 < funcs.length; i23++) + (function(passfunc) { + jStat3.fn[passfunc] = function(arg, func) { + var tmpthis = this; + if (func) { + setTimeout(function() { + func.call(tmpthis, jStat3.fn[passfunc].call(tmpthis, arg)); + }, 15); + return this; + } + if (typeof jStat3[passfunc](this, arg) === "number") + return jStat3[passfunc](this, arg); + else + return jStat3(jStat3[passfunc](this, arg)); + }; + })(funcs[i23]); + })("add divide multiply subtract dot pow exp log abs norm angle".split(" ")); + })(jStat2, Math); + (function(jStat3, Math2) { + var slice = [].slice; + var isNumber = jStat3.utils.isNumber; + var isArray = jStat3.utils.isArray; + jStat3.extend({ + // 2 different parameter lists: + // (value, mean, sd) + // (value, array, flag) + zscore: function zscore() { + var args = slice.call(arguments); + if (isNumber(args[1])) { + return (args[0] - args[1]) / args[2]; + } + return (args[0] - jStat3.mean(args[1])) / jStat3.stdev(args[1], args[2]); + }, + // 3 different paramter lists: + // (value, mean, sd, sides) + // (zscore, sides) + // (value, array, sides, flag) + ztest: function ztest() { + var args = slice.call(arguments); + var z5; + if (isArray(args[1])) { + z5 = jStat3.zscore(args[0], args[1], args[3]); + return args[2] === 1 ? jStat3.normal.cdf(-Math2.abs(z5), 0, 1) : jStat3.normal.cdf(-Math2.abs(z5), 0, 1) * 2; + } else { + if (args.length > 2) { + z5 = jStat3.zscore(args[0], args[1], args[2]); + return args[3] === 1 ? jStat3.normal.cdf(-Math2.abs(z5), 0, 1) : jStat3.normal.cdf(-Math2.abs(z5), 0, 1) * 2; + } else { + z5 = args[0]; + return args[1] === 1 ? jStat3.normal.cdf(-Math2.abs(z5), 0, 1) : jStat3.normal.cdf(-Math2.abs(z5), 0, 1) * 2; + } + } + } + }); + jStat3.extend(jStat3.fn, { + zscore: function zscore(value, flag) { + return (value - this.mean()) / this.stdev(flag); + }, + ztest: function ztest(value, sides, flag) { + var zscore = Math2.abs(this.zscore(value, flag)); + return sides === 1 ? jStat3.normal.cdf(-zscore, 0, 1) : jStat3.normal.cdf(-zscore, 0, 1) * 2; + } + }); + jStat3.extend({ + // 2 parameter lists + // (value, mean, sd, n) + // (value, array) + tscore: function tscore() { + var args = slice.call(arguments); + return args.length === 4 ? (args[0] - args[1]) / (args[2] / Math2.sqrt(args[3])) : (args[0] - jStat3.mean(args[1])) / (jStat3.stdev(args[1], true) / Math2.sqrt(args[1].length)); + }, + // 3 different paramter lists: + // (value, mean, sd, n, sides) + // (tscore, n, sides) + // (value, array, sides) + ttest: function ttest() { + var args = slice.call(arguments); + var tscore; + if (args.length === 5) { + tscore = Math2.abs(jStat3.tscore(args[0], args[1], args[2], args[3])); + return args[4] === 1 ? jStat3.studentt.cdf(-tscore, args[3] - 1) : jStat3.studentt.cdf(-tscore, args[3] - 1) * 2; + } + if (isNumber(args[1])) { + tscore = Math2.abs(args[0]); + return args[2] == 1 ? jStat3.studentt.cdf(-tscore, args[1] - 1) : jStat3.studentt.cdf(-tscore, args[1] - 1) * 2; + } + tscore = Math2.abs(jStat3.tscore(args[0], args[1])); + return args[2] == 1 ? jStat3.studentt.cdf(-tscore, args[1].length - 1) : jStat3.studentt.cdf(-tscore, args[1].length - 1) * 2; + } + }); + jStat3.extend(jStat3.fn, { + tscore: function tscore(value) { + return (value - this.mean()) / (this.stdev(true) / Math2.sqrt(this.cols())); + }, + ttest: function ttest(value, sides) { + return sides === 1 ? 1 - jStat3.studentt.cdf(Math2.abs(this.tscore(value)), this.cols() - 1) : jStat3.studentt.cdf(-Math2.abs(this.tscore(value)), this.cols() - 1) * 2; + } + }); + jStat3.extend({ + // Paramter list is as follows: + // (array1, array2, array3, ...) + // or it is an array of arrays + // array of arrays conversion + anovafscore: function anovafscore() { + var args = slice.call(arguments), expVar, sample, sampMean, sampSampMean, tmpargs, unexpVar, i23, j3; + if (args.length === 1) { + tmpargs = new Array(args[0].length); + for (i23 = 0; i23 < args[0].length; i23++) { + tmpargs[i23] = args[0][i23]; + } + args = tmpargs; + } + sample = new Array(); + for (i23 = 0; i23 < args.length; i23++) { + sample = sample.concat(args[i23]); + } + sampMean = jStat3.mean(sample); + expVar = 0; + for (i23 = 0; i23 < args.length; i23++) { + expVar = expVar + args[i23].length * Math2.pow(jStat3.mean(args[i23]) - sampMean, 2); + } + expVar /= args.length - 1; + unexpVar = 0; + for (i23 = 0; i23 < args.length; i23++) { + sampSampMean = jStat3.mean(args[i23]); + for (j3 = 0; j3 < args[i23].length; j3++) { + unexpVar += Math2.pow(args[i23][j3] - sampSampMean, 2); + } + } + unexpVar /= sample.length - args.length; + return expVar / unexpVar; + }, + // 2 different paramter setups + // (array1, array2, array3, ...) + // (anovafscore, df1, df2) + anovaftest: function anovaftest() { + var args = slice.call(arguments), df1, df2, n31, i23; + if (isNumber(args[0])) { + return 1 - jStat3.centralF.cdf(args[0], args[1], args[2]); + } + var anovafscore = jStat3.anovafscore(args); + df1 = args.length - 1; + n31 = 0; + for (i23 = 0; i23 < args.length; i23++) { + n31 = n31 + args[i23].length; + } + df2 = n31 - df1 - 1; + return 1 - jStat3.centralF.cdf(anovafscore, df1, df2); + }, + ftest: function ftest(fscore, df1, df2) { + return 1 - jStat3.centralF.cdf(fscore, df1, df2); + } + }); + jStat3.extend(jStat3.fn, { + anovafscore: function anovafscore() { + return jStat3.anovafscore(this.toArray()); + }, + anovaftes: function anovaftes() { + var n31 = 0; + var i23; + for (i23 = 0; i23 < this.length; i23++) { + n31 = n31 + this[i23].length; + } + return jStat3.ftest(this.anovafscore(), this.length - 1, n31 - this.length); + } + }); + jStat3.extend({ + // 2 parameter lists + // (mean1, mean2, n1, n2, sd) + // (array1, array2, sd) + qscore: function qscore() { + var args = slice.call(arguments); + var mean1, mean2, n1, n210, sd; + if (isNumber(args[0])) { + mean1 = args[0]; + mean2 = args[1]; + n1 = args[2]; + n210 = args[3]; + sd = args[4]; + } else { + mean1 = jStat3.mean(args[0]); + mean2 = jStat3.mean(args[1]); + n1 = args[0].length; + n210 = args[1].length; + sd = args[2]; + } + return Math2.abs(mean1 - mean2) / (sd * Math2.sqrt((1 / n1 + 1 / n210) / 2)); + }, + // 3 different parameter lists: + // (qscore, n, k) + // (mean1, mean2, n1, n2, sd, n, k) + // (array1, array2, sd, n, k) + qtest: function qtest() { + var args = slice.call(arguments); + var qscore; + if (args.length === 3) { + qscore = args[0]; + args = args.slice(1); + } else if (args.length === 7) { + qscore = jStat3.qscore(args[0], args[1], args[2], args[3], args[4]); + args = args.slice(5); + } else { + qscore = jStat3.qscore(args[0], args[1], args[2]); + args = args.slice(3); + } + var n31 = args[0]; + var k8 = args[1]; + return 1 - jStat3.tukey.cdf(qscore, k8, n31 - k8); + }, + tukeyhsd: function tukeyhsd(arrays) { + var sd = jStat3.pooledstdev(arrays); + var means = arrays.map(function(arr) { + return jStat3.mean(arr); + }); + var n31 = arrays.reduce(function(n32, arr) { + return n32 + arr.length; + }, 0); + var results = []; + for (var i23 = 0; i23 < arrays.length; ++i23) { + for (var j3 = i23 + 1; j3 < arrays.length; ++j3) { + var p7 = jStat3.qtest(means[i23], means[j3], arrays[i23].length, arrays[j3].length, sd, n31, arrays.length); + results.push([[i23, j3], p7]); + } + } + return results; + } + }); + jStat3.extend({ + // 2 different parameter setups + // (value, alpha, sd, n) + // (value, alpha, array) + normalci: function normalci() { + var args = slice.call(arguments), ans = new Array(2), change2; + if (args.length === 4) { + change2 = Math2.abs(jStat3.normal.inv(args[1] / 2, 0, 1) * args[2] / Math2.sqrt(args[3])); + } else { + change2 = Math2.abs(jStat3.normal.inv(args[1] / 2, 0, 1) * jStat3.stdev(args[2]) / Math2.sqrt(args[2].length)); + } + ans[0] = args[0] - change2; + ans[1] = args[0] + change2; + return ans; + }, + // 2 different parameter setups + // (value, alpha, sd, n) + // (value, alpha, array) + tci: function tci() { + var args = slice.call(arguments), ans = new Array(2), change2; + if (args.length === 4) { + change2 = Math2.abs(jStat3.studentt.inv(args[1] / 2, args[3] - 1) * args[2] / Math2.sqrt(args[3])); + } else { + change2 = Math2.abs(jStat3.studentt.inv(args[1] / 2, args[2].length - 1) * jStat3.stdev(args[2], true) / Math2.sqrt(args[2].length)); + } + ans[0] = args[0] - change2; + ans[1] = args[0] + change2; + return ans; + }, + significant: function significant(pvalue, alpha) { + return pvalue < alpha; + } + }); + jStat3.extend(jStat3.fn, { + normalci: function normalci(value, alpha) { + return jStat3.normalci(value, alpha, this.toArray()); + }, + tci: function tci(value, alpha) { + return jStat3.tci(value, alpha, this.toArray()); + } + }); + function differenceOfProportions(p1, n1, p22, n210) { + if (p1 > 1 || p22 > 1 || p1 <= 0 || p22 <= 0) { + throw new Error("Proportions should be greater than 0 and less than 1"); + } + var pooled = (p1 * n1 + p22 * n210) / (n1 + n210); + var se = Math2.sqrt(pooled * (1 - pooled) * (1 / n1 + 1 / n210)); + return (p1 - p22) / se; + } + jStat3.extend(jStat3.fn, { + oneSidedDifferenceOfProportions: function oneSidedDifferenceOfProportions(p1, n1, p22, n210) { + var z5 = differenceOfProportions(p1, n1, p22, n210); + return jStat3.ztest(z5, 1); + }, + twoSidedDifferenceOfProportions: function twoSidedDifferenceOfProportions(p1, n1, p22, n210) { + var z5 = differenceOfProportions(p1, n1, p22, n210); + return jStat3.ztest(z5, 2); + } + }); + })(jStat2, Math); + jStat2.models = /* @__PURE__ */ function() { + function sub_regress(exog) { + var var_count = exog[0].length; + var modelList = jStat2.arange(var_count).map(function(endog_index) { + var exog_index = jStat2.arange(var_count).filter(function(i23) { + return i23 !== endog_index; + }); + return ols( + jStat2.col(exog, endog_index).map(function(x6) { + return x6[0]; + }), + jStat2.col(exog, exog_index) + ); + }); + return modelList; + } + function ols(endog, exog) { + var nobs = endog.length; + var df_model = exog[0].length - 1; + var df_resid = nobs - df_model - 1; + var coef = jStat2.lstsq(exog, endog); + var predict = jStat2.multiply(exog, coef.map(function(x6) { + return [x6]; + })).map(function(p7) { + return p7[0]; + }); + var resid = jStat2.subtract(endog, predict); + var ybar = jStat2.mean(endog); + var SSE = jStat2.sum(predict.map(function(f7) { + return Math.pow(f7 - ybar, 2); + })); + var SSR = jStat2.sum(endog.map(function(y7, i23) { + return Math.pow(y7 - predict[i23], 2); + })); + var SST = SSE + SSR; + var R22 = SSE / SST; + return { + exog, + endog, + nobs, + df_model, + df_resid, + coef, + predict, + resid, + ybar, + SST, + SSE, + SSR, + R2: R22 + }; + } + function t_test(model) { + var subModelList = sub_regress(model.exog); + var sigmaHat = Math.sqrt(model.SSR / model.df_resid); + var seBetaHat = subModelList.map(function(mod) { + var SST = mod.SST; + var R22 = mod.R2; + return sigmaHat / Math.sqrt(SST * (1 - R22)); + }); + var tStatistic = model.coef.map(function(coef, i23) { + return (coef - 0) / seBetaHat[i23]; + }); + var pValue = tStatistic.map(function(t17) { + var leftppf = jStat2.studentt.cdf(t17, model.df_resid); + return (leftppf > 0.5 ? 1 - leftppf : leftppf) * 2; + }); + var c12 = jStat2.studentt.inv(0.975, model.df_resid); + var interval95 = model.coef.map(function(coef, i23) { + var d11 = c12 * seBetaHat[i23]; + return [coef - d11, coef + d11]; + }); + return { + se: seBetaHat, + t: tStatistic, + p: pValue, + sigmaHat, + interval95 + }; + } + function F_test(model) { + var F_statistic = model.R2 / model.df_model / ((1 - model.R2) / model.df_resid); + var fcdf = function(x6, n1, n210) { + return jStat2.beta.cdf(x6 / (n210 / n1 + x6), n1 / 2, n210 / 2); + }; + var pvalue = 1 - fcdf(F_statistic, model.df_model, model.df_resid); + return { F_statistic, pvalue }; + } + function ols_wrap(endog, exog) { + var model = ols(endog, exog); + var ttest = t_test(model); + var ftest = F_test(model); + var adjust_R2 = 1 - (1 - model.R2) * ((model.nobs - 1) / model.df_resid); + model.t = ttest; + model.f = ftest; + model.adjust_R2 = adjust_R2; + return model; + } + return { ols: ols_wrap }; + }(); + jStat2.extend({ + buildxmatrix: function buildxmatrix() { + var matrixRows = new Array(arguments.length); + for (var i23 = 0; i23 < arguments.length; i23++) { + var array2 = [1]; + matrixRows[i23] = array2.concat(arguments[i23]); + } + return jStat2(matrixRows); + }, + builddxmatrix: function builddxmatrix() { + var matrixRows = new Array(arguments[0].length); + for (var i23 = 0; i23 < arguments[0].length; i23++) { + var array2 = [1]; + matrixRows[i23] = array2.concat(arguments[0][i23]); + } + return jStat2(matrixRows); + }, + buildjxmatrix: function buildjxmatrix(jMat) { + var pass = new Array(jMat.length); + for (var i23 = 0; i23 < jMat.length; i23++) { + pass[i23] = jMat[i23]; + } + return jStat2.builddxmatrix(pass); + }, + buildymatrix: function buildymatrix(array2) { + return jStat2(array2).transpose(); + }, + buildjymatrix: function buildjymatrix(jMat) { + return jMat.transpose(); + }, + matrixmult: function matrixmult(A6, B5) { + var i23, j3, k8, result, sum; + if (A6.cols() == B5.rows()) { + if (B5.rows() > 1) { + result = []; + for (i23 = 0; i23 < A6.rows(); i23++) { + result[i23] = []; + for (j3 = 0; j3 < B5.cols(); j3++) { + sum = 0; + for (k8 = 0; k8 < A6.cols(); k8++) { + sum += A6.toArray()[i23][k8] * B5.toArray()[k8][j3]; + } + result[i23][j3] = sum; + } + } + return jStat2(result); + } + result = []; + for (i23 = 0; i23 < A6.rows(); i23++) { + result[i23] = []; + for (j3 = 0; j3 < B5.cols(); j3++) { + sum = 0; + for (k8 = 0; k8 < A6.cols(); k8++) { + sum += A6.toArray()[i23][k8] * B5.toArray()[j3]; + } + result[i23][j3] = sum; + } + } + return jStat2(result); + } + }, + //regress and regresst to be fixed + regress: function regress(jMatX, jMatY) { + var innerinv = jStat2.xtranspxinv(jMatX); + var xtransp = jMatX.transpose(); + var next = jStat2.matrixmult(jStat2(innerinv), xtransp); + return jStat2.matrixmult(next, jMatY); + }, + regresst: function regresst(jMatX, jMatY, sides) { + var beta = jStat2.regress(jMatX, jMatY); + var compile = {}; + compile.anova = {}; + var jMatYBar = jStat2.jMatYBar(jMatX, beta); + compile.yBar = jMatYBar; + var yAverage = jMatY.mean(); + compile.anova.residuals = jStat2.residuals(jMatY, jMatYBar); + compile.anova.ssr = jStat2.ssr(jMatYBar, yAverage); + compile.anova.msr = compile.anova.ssr / (jMatX[0].length - 1); + compile.anova.sse = jStat2.sse(jMatY, jMatYBar); + compile.anova.mse = compile.anova.sse / (jMatY.length - (jMatX[0].length - 1) - 1); + compile.anova.sst = jStat2.sst(jMatY, yAverage); + compile.anova.mst = compile.anova.sst / (jMatY.length - 1); + compile.anova.r2 = 1 - compile.anova.sse / compile.anova.sst; + if (compile.anova.r2 < 0) + compile.anova.r2 = 0; + compile.anova.fratio = compile.anova.msr / compile.anova.mse; + compile.anova.pvalue = jStat2.anovaftest( + compile.anova.fratio, + jMatX[0].length - 1, + jMatY.length - (jMatX[0].length - 1) - 1 + ); + compile.anova.rmse = Math.sqrt(compile.anova.mse); + compile.anova.r2adj = 1 - compile.anova.mse / compile.anova.mst; + if (compile.anova.r2adj < 0) + compile.anova.r2adj = 0; + compile.stats = new Array(jMatX[0].length); + var covar = jStat2.xtranspxinv(jMatX); + var sds, ts, ps; + for (var i23 = 0; i23 < beta.length; i23++) { + sds = Math.sqrt(compile.anova.mse * Math.abs(covar[i23][i23])); + ts = Math.abs(beta[i23] / sds); + ps = jStat2.ttest(ts, jMatY.length - jMatX[0].length - 1, sides); + compile.stats[i23] = [beta[i23], sds, ts, ps]; + } + compile.regress = beta; + return compile; + }, + xtranspx: function xtranspx(jMatX) { + return jStat2.matrixmult(jMatX.transpose(), jMatX); + }, + xtranspxinv: function xtranspxinv(jMatX) { + var inner = jStat2.matrixmult(jMatX.transpose(), jMatX); + var innerinv = jStat2.inv(inner); + return innerinv; + }, + jMatYBar: function jMatYBar(jMatX, beta) { + var yBar = jStat2.matrixmult(jMatX, beta); + return new jStat2(yBar); + }, + residuals: function residuals(jMatY, jMatYBar) { + return jStat2.matrixsubtract(jMatY, jMatYBar); + }, + ssr: function ssr(jMatYBar, yAverage) { + var ssr2 = 0; + for (var i23 = 0; i23 < jMatYBar.length; i23++) { + ssr2 += Math.pow(jMatYBar[i23] - yAverage, 2); + } + return ssr2; + }, + sse: function sse(jMatY, jMatYBar) { + var sse2 = 0; + for (var i23 = 0; i23 < jMatY.length; i23++) { + sse2 += Math.pow(jMatY[i23] - jMatYBar[i23], 2); + } + return sse2; + }, + sst: function sst(jMatY, yAverage) { + var sst2 = 0; + for (var i23 = 0; i23 < jMatY.length; i23++) { + sst2 += Math.pow(jMatY[i23] - yAverage, 2); + } + return sst2; + }, + matrixsubtract: function matrixsubtract(A6, B5) { + var ans = new Array(A6.length); + for (var i23 = 0; i23 < A6.length; i23++) { + ans[i23] = new Array(A6[i23].length); + for (var j3 = 0; j3 < A6[i23].length; j3++) { + ans[i23][j3] = A6[i23][j3] - B5[i23][j3]; + } + } + return jStat2(ans); + } + }); + jStat2.jStat = jStat2; + return jStat2; + }); + } + }); + + // node_modules/@adobe/lit-mobx/lib/mixin-custom.js + var reaction = Symbol("LitMobxRenderReaction"); + var cachedRequestUpdate = Symbol("LitMobxRequestUpdate"); + function MobxReactionUpdateCustom(constructor, ReactionConstructor) { + var _a2, _b2; + return _b2 = class MobxReactingElement extends constructor { + constructor() { + super(...arguments); + this[_a2] = () => { + this.requestUpdate(); + }; + } + connectedCallback() { + super.connectedCallback(); + const name = this.constructor.name || this.nodeName; + this[reaction] = new ReactionConstructor(`${name}.update()`, this[cachedRequestUpdate]); + if (this.hasUpdated) + this.requestUpdate(); + } + disconnectedCallback() { + super.disconnectedCallback(); + if (this[reaction]) { + this[reaction].dispose(); + this[reaction] = void 0; + } + } + update(changedProperties) { + if (this[reaction]) { + this[reaction].track(super.update.bind(this, changedProperties)); + } else { + super.update(changedProperties); + } + } + }, _a2 = cachedRequestUpdate, _b2; + } + + // node_modules/mobx/dist/mobx.esm.js + var niceErrors = { + 0: "Invalid value for configuration 'enforceActions', expected 'never', 'always' or 'observed'", + 1: function _(annotationType, key) { + return "Cannot apply '" + annotationType + "' to '" + key.toString() + "': Field not found."; + }, + /* + 2(prop) { + return `invalid decorator for '${prop.toString()}'` + }, + 3(prop) { + return `Cannot decorate '${prop.toString()}': action can only be used on properties with a function value.` + }, + 4(prop) { + return `Cannot decorate '${prop.toString()}': computed can only be used on getter properties.` + }, + */ + 5: "'keys()' can only be used on observable objects, arrays, sets and maps", + 6: "'values()' can only be used on observable objects, arrays, sets and maps", + 7: "'entries()' can only be used on observable objects, arrays and maps", + 8: "'set()' can only be used on observable objects, arrays and maps", + 9: "'remove()' can only be used on observable objects, arrays and maps", + 10: "'has()' can only be used on observable objects, arrays and maps", + 11: "'get()' can only be used on observable objects, arrays and maps", + 12: "Invalid annotation", + 13: "Dynamic observable objects cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)", + 14: "Intercept handlers should return nothing or a change object", + 15: "Observable arrays cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)", + 16: "Modification exception: the internal structure of an observable array was changed.", + 17: function _2(index, length) { + return "[mobx.array] Index out of bounds, " + index + " is larger than " + length; + }, + 18: "mobx.map requires Map polyfill for the current browser. Check babel-polyfill or core-js/es6/map.js", + 19: function _3(other) { + return "Cannot initialize from classes that inherit from Map: " + other.constructor.name; + }, + 20: function _4(other) { + return "Cannot initialize map from " + other; + }, + 21: function _5(dataStructure) { + return "Cannot convert to map from '" + dataStructure + "'"; + }, + 22: "mobx.set requires Set polyfill for the current browser. Check babel-polyfill or core-js/es6/set.js", + 23: "It is not possible to get index atoms from arrays", + 24: function _6(thing) { + return "Cannot obtain administration from " + thing; + }, + 25: function _7(property, name) { + return "the entry '" + property + "' does not exist in the observable map '" + name + "'"; + }, + 26: "please specify a property", + 27: function _8(property, name) { + return "no observable property '" + property.toString() + "' found on the observable object '" + name + "'"; + }, + 28: function _9(thing) { + return "Cannot obtain atom from " + thing; + }, + 29: "Expecting some object", + 30: "invalid action stack. did you forget to finish an action?", + 31: "missing option for computed: get", + 32: function _10(name, derivation) { + return "Cycle detected in computation " + name + ": " + derivation; + }, + 33: function _11(name) { + return "The setter of computed value '" + name + "' is trying to update itself. Did you intend to update an _observable_ value, instead of the computed property?"; + }, + 34: function _12(name) { + return "[ComputedValue '" + name + "'] It is not possible to assign a new value to a computed value."; + }, + 35: "There are multiple, different versions of MobX active. Make sure MobX is loaded only once or use `configure({ isolateGlobalState: true })`", + 36: "isolateGlobalState should be called before MobX is running any reactions", + 37: function _13(method) { + return "[mobx] `observableArray." + method + "()` mutates the array in-place, which is not allowed inside a derivation. Use `array.slice()." + method + "()` instead"; + }, + 38: "'ownKeys()' can only be used on observable objects", + 39: "'defineProperty()' can only be used on observable objects" + }; + var errors = true ? niceErrors : {}; + function die(error) { + for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + if (true) { + var e33 = typeof error === "string" ? error : errors[error]; + if (typeof e33 === "function") + e33 = e33.apply(null, args); + throw new Error("[MobX] " + e33); + } + throw new Error(typeof error === "number" ? "[MobX] minified error nr: " + error + (args.length ? " " + args.map(String).join(",") : "") + ". Find the full error at: https://github.com/mobxjs/mobx/blob/main/packages/mobx/src/errors.ts" : "[MobX] " + error); + } + var mockGlobal = {}; + function getGlobal() { + if (typeof globalThis !== "undefined") { + return globalThis; + } + if (typeof window !== "undefined") { + return window; + } + if (typeof global !== "undefined") { + return global; + } + if (typeof self !== "undefined") { + return self; + } + return mockGlobal; + } + var assign = Object.assign; + var getDescriptor = Object.getOwnPropertyDescriptor; + var defineProperty = Object.defineProperty; + var objectPrototype = Object.prototype; + var EMPTY_ARRAY = []; + Object.freeze(EMPTY_ARRAY); + var EMPTY_OBJECT = {}; + Object.freeze(EMPTY_OBJECT); + var hasProxy = typeof Proxy !== "undefined"; + var plainObjectString = /* @__PURE__ */ Object.toString(); + function assertProxies() { + if (!hasProxy) { + die(true ? "`Proxy` objects are not available in the current environment. Please configure MobX to enable a fallback implementation.`" : "Proxy not available"); + } + } + function warnAboutProxyRequirement(msg) { + if (globalState.verifyProxies) { + die("MobX is currently configured to be able to run in ES5 mode, but in ES5 MobX won't be able to " + msg); + } + } + function getNextId() { + return ++globalState.mobxGuid; + } + function once(func) { + var invoked = false; + return function() { + if (invoked) { + return; + } + invoked = true; + return func.apply(this, arguments); + }; + } + var noop = function noop2() { + }; + function isFunction(fn2) { + return typeof fn2 === "function"; + } + function isStringish(value) { + var t17 = typeof value; + switch (t17) { + case "string": + case "symbol": + case "number": + return true; + } + return false; + } + function isObject(value) { + return value !== null && typeof value === "object"; + } + function isPlainObject(value) { + if (!isObject(value)) { + return false; + } + var proto = Object.getPrototypeOf(value); + if (proto == null) { + return true; + } + var protoConstructor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor; + return typeof protoConstructor === "function" && protoConstructor.toString() === plainObjectString; + } + function isGenerator(obj) { + var constructor = obj == null ? void 0 : obj.constructor; + if (!constructor) { + return false; + } + if ("GeneratorFunction" === constructor.name || "GeneratorFunction" === constructor.displayName) { + return true; + } + return false; + } + function addHiddenProp(object2, propName, value) { + defineProperty(object2, propName, { + enumerable: false, + writable: true, + configurable: true, + value + }); + } + function addHiddenFinalProp(object2, propName, value) { + defineProperty(object2, propName, { + enumerable: false, + writable: false, + configurable: true, + value + }); + } + function createInstanceofPredicate(name, theClass) { + var propName = "isMobX" + name; + theClass.prototype[propName] = true; + return function(x6) { + return isObject(x6) && x6[propName] === true; + }; + } + function isES6Map(thing) { + return thing instanceof Map; + } + function isES6Set(thing) { + return thing instanceof Set; + } + var hasGetOwnPropertySymbols = typeof Object.getOwnPropertySymbols !== "undefined"; + function getPlainObjectKeys(object2) { + var keys = Object.keys(object2); + if (!hasGetOwnPropertySymbols) { + return keys; + } + var symbols = Object.getOwnPropertySymbols(object2); + if (!symbols.length) { + return keys; + } + return [].concat(keys, symbols.filter(function(s20) { + return objectPrototype.propertyIsEnumerable.call(object2, s20); + })); + } + var ownKeys = typeof Reflect !== "undefined" && Reflect.ownKeys ? Reflect.ownKeys : hasGetOwnPropertySymbols ? function(obj) { + return Object.getOwnPropertyNames(obj).concat(Object.getOwnPropertySymbols(obj)); + } : ( + /* istanbul ignore next */ + Object.getOwnPropertyNames + ); + function stringifyKey(key) { + if (typeof key === "string") { + return key; + } + if (typeof key === "symbol") { + return key.toString(); + } + return new String(key).toString(); + } + function toPrimitive(value) { + return value === null ? null : typeof value === "object" ? "" + value : value; + } + function hasProp(target, prop) { + return objectPrototype.hasOwnProperty.call(target, prop); + } + var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || function getOwnPropertyDescriptors2(target) { + var res = {}; + ownKeys(target).forEach(function(key) { + res[key] = getDescriptor(target, key); + }); + return res; + }; + function _defineProperties(target, props) { + for (var i23 = 0; i23 < props.length; i23++) { + var descriptor = props[i23]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) + descriptor.writable = true; + Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) + _defineProperties(Constructor.prototype, protoProps); + if (staticProps) + _defineProperties(Constructor, staticProps); + Object.defineProperty(Constructor, "prototype", { + writable: false + }); + return Constructor; + } + function _extends() { + _extends = Object.assign ? Object.assign.bind() : function(target) { + for (var i23 = 1; i23 < arguments.length; i23++) { + var source = arguments[i23]; + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + return target; + }; + return _extends.apply(this, arguments); + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o29, p7) { + _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf2(o30, p8) { + o30.__proto__ = p8; + return o30; + }; + return _setPrototypeOf(o29, p7); + } + function _assertThisInitialized(self2) { + if (self2 === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return self2; + } + function _unsupportedIterableToArray(o29, minLen) { + if (!o29) + return; + if (typeof o29 === "string") + return _arrayLikeToArray(o29, minLen); + var n31 = Object.prototype.toString.call(o29).slice(8, -1); + if (n31 === "Object" && o29.constructor) + n31 = o29.constructor.name; + if (n31 === "Map" || n31 === "Set") + return Array.from(o29); + if (n31 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n31)) + return _arrayLikeToArray(o29, minLen); + } + function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) + len = arr.length; + for (var i23 = 0, arr2 = new Array(len); i23 < len; i23++) + arr2[i23] = arr[i23]; + return arr2; + } + function _createForOfIteratorHelperLoose(o29, allowArrayLike) { + var it = typeof Symbol !== "undefined" && o29[Symbol.iterator] || o29["@@iterator"]; + if (it) + return (it = it.call(o29)).next.bind(it); + if (Array.isArray(o29) || (it = _unsupportedIterableToArray(o29)) || allowArrayLike && o29 && typeof o29.length === "number") { + if (it) + o29 = it; + var i23 = 0; + return function() { + if (i23 >= o29.length) + return { + done: true + }; + return { + done: false, + value: o29[i23++] + }; + }; + } + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + function _toPrimitive(input, hint) { + if (typeof input !== "object" || input === null) + return input; + var prim = input[Symbol.toPrimitive]; + if (prim !== void 0) { + var res = prim.call(input, hint || "default"); + if (typeof res !== "object") + return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + return (hint === "string" ? String : Number)(input); + } + function _toPropertyKey(arg) { + var key = _toPrimitive(arg, "string"); + return typeof key === "symbol" ? key : String(key); + } + var storedAnnotationsSymbol = /* @__PURE__ */ Symbol("mobx-stored-annotations"); + function createDecoratorAnnotation(annotation) { + function decorator(target, property) { + if (is20223Decorator(property)) { + return annotation.decorate_20223_(target, property); + } else { + storeAnnotation(target, property, annotation); + } + } + return Object.assign(decorator, annotation); + } + function storeAnnotation(prototype, key, annotation) { + if (!hasProp(prototype, storedAnnotationsSymbol)) { + addHiddenProp(prototype, storedAnnotationsSymbol, _extends({}, prototype[storedAnnotationsSymbol])); + } + if (isOverride(annotation) && !hasProp(prototype[storedAnnotationsSymbol], key)) { + var fieldName = prototype.constructor.name + ".prototype." + key.toString(); + die("'" + fieldName + "' is decorated with 'override', but no such decorated member was found on prototype."); + } + assertNotDecorated(prototype, annotation, key); + if (!isOverride(annotation)) { + prototype[storedAnnotationsSymbol][key] = annotation; + } + } + function assertNotDecorated(prototype, annotation, key) { + if (!isOverride(annotation) && hasProp(prototype[storedAnnotationsSymbol], key)) { + var fieldName = prototype.constructor.name + ".prototype." + key.toString(); + var currentAnnotationType = prototype[storedAnnotationsSymbol][key].annotationType_; + var requestedAnnotationType = annotation.annotationType_; + die("Cannot apply '@" + requestedAnnotationType + "' to '" + fieldName + "':" + ("\nThe field is already decorated with '@" + currentAnnotationType + "'.") + "\nRe-decorating fields is not allowed.\nUse '@override' decorator for methods overridden by subclass."); + } + } + function collectStoredAnnotations(target) { + if (!hasProp(target, storedAnnotationsSymbol)) { + addHiddenProp(target, storedAnnotationsSymbol, _extends({}, target[storedAnnotationsSymbol])); + } + return target[storedAnnotationsSymbol]; + } + function is20223Decorator(context) { + return typeof context == "object" && typeof context["kind"] == "string"; + } + function assert20223DecoratorType(context, types) { + if (!types.includes(context.kind)) { + die("The decorator applied to '" + String(context.name) + "' cannot be used on a " + context.kind + " element"); + } + } + var $mobx = /* @__PURE__ */ Symbol("mobx administration"); + var Atom = /* @__PURE__ */ function() { + function Atom2(name_) { + if (name_ === void 0) { + name_ = true ? "Atom@" + getNextId() : "Atom"; + } + this.name_ = void 0; + this.isPendingUnobservation_ = false; + this.isBeingObserved_ = false; + this.observers_ = /* @__PURE__ */ new Set(); + this.diffValue_ = 0; + this.lastAccessedBy_ = 0; + this.lowestObserverState_ = IDerivationState_.NOT_TRACKING_; + this.onBOL = void 0; + this.onBUOL = void 0; + this.name_ = name_; + } + var _proto = Atom2.prototype; + _proto.onBO = function onBO() { + if (this.onBOL) { + this.onBOL.forEach(function(listener) { + return listener(); + }); + } + }; + _proto.onBUO = function onBUO() { + if (this.onBUOL) { + this.onBUOL.forEach(function(listener) { + return listener(); + }); + } + }; + _proto.reportObserved = function reportObserved$1() { + return reportObserved(this); + }; + _proto.reportChanged = function reportChanged() { + startBatch(); + propagateChanged(this); + endBatch(); + }; + _proto.toString = function toString2() { + return this.name_; + }; + return Atom2; + }(); + var isAtom = /* @__PURE__ */ createInstanceofPredicate("Atom", Atom); + function createAtom(name, onBecomeObservedHandler, onBecomeUnobservedHandler) { + if (onBecomeObservedHandler === void 0) { + onBecomeObservedHandler = noop; + } + if (onBecomeUnobservedHandler === void 0) { + onBecomeUnobservedHandler = noop; + } + var atom = new Atom(name); + if (onBecomeObservedHandler !== noop) { + onBecomeObserved(atom, onBecomeObservedHandler); + } + if (onBecomeUnobservedHandler !== noop) { + onBecomeUnobserved(atom, onBecomeUnobservedHandler); + } + return atom; + } + function identityComparer(a11, b7) { + return a11 === b7; + } + function structuralComparer(a11, b7) { + return deepEqual(a11, b7); + } + function shallowComparer(a11, b7) { + return deepEqual(a11, b7, 1); + } + function defaultComparer(a11, b7) { + if (Object.is) { + return Object.is(a11, b7); + } + return a11 === b7 ? a11 !== 0 || 1 / a11 === 1 / b7 : a11 !== a11 && b7 !== b7; + } + var comparer = { + identity: identityComparer, + structural: structuralComparer, + "default": defaultComparer, + shallow: shallowComparer + }; + function deepEnhancer(v6, _19, name) { + if (isObservable(v6)) { + return v6; + } + if (Array.isArray(v6)) { + return observable.array(v6, { + name + }); + } + if (isPlainObject(v6)) { + return observable.object(v6, void 0, { + name + }); + } + if (isES6Map(v6)) { + return observable.map(v6, { + name + }); + } + if (isES6Set(v6)) { + return observable.set(v6, { + name + }); + } + if (typeof v6 === "function" && !isAction(v6) && !isFlow(v6)) { + if (isGenerator(v6)) { + return flow(v6); + } else { + return autoAction(name, v6); + } + } + return v6; + } + function shallowEnhancer(v6, _19, name) { + if (v6 === void 0 || v6 === null) { + return v6; + } + if (isObservableObject(v6) || isObservableArray(v6) || isObservableMap(v6) || isObservableSet(v6)) { + return v6; + } + if (Array.isArray(v6)) { + return observable.array(v6, { + name, + deep: false + }); + } + if (isPlainObject(v6)) { + return observable.object(v6, void 0, { + name, + deep: false + }); + } + if (isES6Map(v6)) { + return observable.map(v6, { + name, + deep: false + }); + } + if (isES6Set(v6)) { + return observable.set(v6, { + name, + deep: false + }); + } + if (true) { + die("The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets"); + } + } + function referenceEnhancer(newValue) { + return newValue; + } + function refStructEnhancer(v6, oldValue) { + if (isObservable(v6)) { + die("observable.struct should not be used with observable values"); + } + if (deepEqual(v6, oldValue)) { + return oldValue; + } + return v6; + } + var OVERRIDE = "override"; + function isOverride(annotation) { + return annotation.annotationType_ === OVERRIDE; + } + function createActionAnnotation(name, options) { + return { + annotationType_: name, + options_: options, + make_: make_$1, + extend_: extend_$1, + decorate_20223_: decorate_20223_$1 + }; + } + function make_$1(adm, key, descriptor, source) { + var _this$options_; + if ((_this$options_ = this.options_) != null && _this$options_.bound) { + return this.extend_(adm, key, descriptor, false) === null ? 0 : 1; + } + if (source === adm.target_) { + return this.extend_(adm, key, descriptor, false) === null ? 0 : 2; + } + if (isAction(descriptor.value)) { + return 1; + } + var actionDescriptor = createActionDescriptor(adm, this, key, descriptor, false); + defineProperty(source, key, actionDescriptor); + return 2; + } + function extend_$1(adm, key, descriptor, proxyTrap) { + var actionDescriptor = createActionDescriptor(adm, this, key, descriptor); + return adm.defineProperty_(key, actionDescriptor, proxyTrap); + } + function decorate_20223_$1(mthd, context) { + if (true) { + assert20223DecoratorType(context, ["method", "field"]); + } + var kind = context.kind, name = context.name, addInitializer = context.addInitializer; + var ann = this; + var _createAction = function _createAction2(m6) { + var _ann$options_$name, _ann$options_, _ann$options_$autoAct, _ann$options_2; + return createAction((_ann$options_$name = (_ann$options_ = ann.options_) == null ? void 0 : _ann$options_.name) != null ? _ann$options_$name : name.toString(), m6, (_ann$options_$autoAct = (_ann$options_2 = ann.options_) == null ? void 0 : _ann$options_2.autoAction) != null ? _ann$options_$autoAct : false); + }; + if (kind == "field") { + addInitializer(function() { + storeAnnotation(this, name, ann); + }); + return; + } + if (kind == "method") { + var _this$options_2; + if (!isAction(mthd)) { + mthd = _createAction(mthd); + } + if ((_this$options_2 = this.options_) != null && _this$options_2.bound) { + addInitializer(function() { + var self2 = this; + var bound = self2[name].bind(self2); + bound.isMobxAction = true; + self2[name] = bound; + }); + } + return mthd; + } + die("Cannot apply '" + ann.annotationType_ + "' to '" + String(name) + "' (kind: " + kind + "):" + ("\n'" + ann.annotationType_ + "' can only be used on properties with a function value.")); + } + function assertActionDescriptor(adm, _ref, key, _ref2) { + var annotationType_ = _ref.annotationType_; + var value = _ref2.value; + if (!isFunction(value)) { + die("Cannot apply '" + annotationType_ + "' to '" + adm.name_ + "." + key.toString() + "':" + ("\n'" + annotationType_ + "' can only be used on properties with a function value.")); + } + } + function createActionDescriptor(adm, annotation, key, descriptor, safeDescriptors) { + var _annotation$options_, _annotation$options_$, _annotation$options_2, _annotation$options_$2, _annotation$options_3, _annotation$options_4, _adm$proxy_2; + if (safeDescriptors === void 0) { + safeDescriptors = globalState.safeDescriptors; + } + assertActionDescriptor(adm, annotation, key, descriptor); + var value = descriptor.value; + if ((_annotation$options_ = annotation.options_) != null && _annotation$options_.bound) { + var _adm$proxy_; + value = value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_); + } + return { + value: createAction( + (_annotation$options_$ = (_annotation$options_2 = annotation.options_) == null ? void 0 : _annotation$options_2.name) != null ? _annotation$options_$ : key.toString(), + value, + (_annotation$options_$2 = (_annotation$options_3 = annotation.options_) == null ? void 0 : _annotation$options_3.autoAction) != null ? _annotation$options_$2 : false, + // https://github.com/mobxjs/mobx/discussions/3140 + (_annotation$options_4 = annotation.options_) != null && _annotation$options_4.bound ? (_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_ : void 0 + ), + // Non-configurable for classes + // prevents accidental field redefinition in subclass + configurable: safeDescriptors ? adm.isPlainObject_ : true, + // https://github.com/mobxjs/mobx/pull/2641#issuecomment-737292058 + enumerable: false, + // Non-obsevable, therefore non-writable + // Also prevents rewriting in subclass constructor + writable: safeDescriptors ? false : true + }; + } + function createFlowAnnotation(name, options) { + return { + annotationType_: name, + options_: options, + make_: make_$2, + extend_: extend_$2, + decorate_20223_: decorate_20223_$2 + }; + } + function make_$2(adm, key, descriptor, source) { + var _this$options_; + if (source === adm.target_) { + return this.extend_(adm, key, descriptor, false) === null ? 0 : 2; + } + if ((_this$options_ = this.options_) != null && _this$options_.bound && (!hasProp(adm.target_, key) || !isFlow(adm.target_[key]))) { + if (this.extend_(adm, key, descriptor, false) === null) { + return 0; + } + } + if (isFlow(descriptor.value)) { + return 1; + } + var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, false, false); + defineProperty(source, key, flowDescriptor); + return 2; + } + function extend_$2(adm, key, descriptor, proxyTrap) { + var _this$options_2; + var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, (_this$options_2 = this.options_) == null ? void 0 : _this$options_2.bound); + return adm.defineProperty_(key, flowDescriptor, proxyTrap); + } + function decorate_20223_$2(mthd, context) { + var _this$options_3; + if (true) { + assert20223DecoratorType(context, ["method"]); + } + var name = context.name, addInitializer = context.addInitializer; + if (!isFlow(mthd)) { + mthd = flow(mthd); + } + if ((_this$options_3 = this.options_) != null && _this$options_3.bound) { + addInitializer(function() { + var self2 = this; + var bound = self2[name].bind(self2); + bound.isMobXFlow = true; + self2[name] = bound; + }); + } + return mthd; + } + function assertFlowDescriptor(adm, _ref, key, _ref2) { + var annotationType_ = _ref.annotationType_; + var value = _ref2.value; + if (!isFunction(value)) { + die("Cannot apply '" + annotationType_ + "' to '" + adm.name_ + "." + key.toString() + "':" + ("\n'" + annotationType_ + "' can only be used on properties with a generator function value.")); + } + } + function createFlowDescriptor(adm, annotation, key, descriptor, bound, safeDescriptors) { + if (safeDescriptors === void 0) { + safeDescriptors = globalState.safeDescriptors; + } + assertFlowDescriptor(adm, annotation, key, descriptor); + var value = descriptor.value; + if (!isFlow(value)) { + value = flow(value); + } + if (bound) { + var _adm$proxy_; + value = value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_); + value.isMobXFlow = true; + } + return { + value, + // Non-configurable for classes + // prevents accidental field redefinition in subclass + configurable: safeDescriptors ? adm.isPlainObject_ : true, + // https://github.com/mobxjs/mobx/pull/2641#issuecomment-737292058 + enumerable: false, + // Non-obsevable, therefore non-writable + // Also prevents rewriting in subclass constructor + writable: safeDescriptors ? false : true + }; + } + function createComputedAnnotation(name, options) { + return { + annotationType_: name, + options_: options, + make_: make_$3, + extend_: extend_$3, + decorate_20223_: decorate_20223_$3 + }; + } + function make_$3(adm, key, descriptor) { + return this.extend_(adm, key, descriptor, false) === null ? 0 : 1; + } + function extend_$3(adm, key, descriptor, proxyTrap) { + assertComputedDescriptor(adm, this, key, descriptor); + return adm.defineComputedProperty_(key, _extends({}, this.options_, { + get: descriptor.get, + set: descriptor.set + }), proxyTrap); + } + function decorate_20223_$3(get3, context) { + if (true) { + assert20223DecoratorType(context, ["getter"]); + } + var ann = this; + var key = context.name, addInitializer = context.addInitializer; + addInitializer(function() { + var adm = asObservableObject(this)[$mobx]; + var options = _extends({}, ann.options_, { + get: get3, + context: this + }); + options.name || (options.name = true ? adm.name_ + "." + key.toString() : "ObservableObject." + key.toString()); + adm.values_.set(key, new ComputedValue(options)); + }); + return function() { + return this[$mobx].getObservablePropValue_(key); + }; + } + function assertComputedDescriptor(adm, _ref, key, _ref2) { + var annotationType_ = _ref.annotationType_; + var get3 = _ref2.get; + if (!get3) { + die("Cannot apply '" + annotationType_ + "' to '" + adm.name_ + "." + key.toString() + "':" + ("\n'" + annotationType_ + "' can only be used on getter(+setter) properties.")); + } + } + function createObservableAnnotation(name, options) { + return { + annotationType_: name, + options_: options, + make_: make_$4, + extend_: extend_$4, + decorate_20223_: decorate_20223_$4 + }; + } + function make_$4(adm, key, descriptor) { + return this.extend_(adm, key, descriptor, false) === null ? 0 : 1; + } + function extend_$4(adm, key, descriptor, proxyTrap) { + var _this$options_$enhanc, _this$options_; + assertObservableDescriptor(adm, this, key, descriptor); + return adm.defineObservableProperty_(key, descriptor.value, (_this$options_$enhanc = (_this$options_ = this.options_) == null ? void 0 : _this$options_.enhancer) != null ? _this$options_$enhanc : deepEnhancer, proxyTrap); + } + function decorate_20223_$4(desc, context) { + if (true) { + if (context.kind === "field") { + throw die("Please use `@observable accessor " + String(context.name) + "` instead of `@observable " + String(context.name) + "`"); + } + assert20223DecoratorType(context, ["accessor"]); + } + var ann = this; + var kind = context.kind, name = context.name; + var initializedObjects = /* @__PURE__ */ new WeakSet(); + function initializeObservable(target, value) { + var _ann$options_$enhance, _ann$options_; + var adm = asObservableObject(target)[$mobx]; + var observable2 = new ObservableValue(value, (_ann$options_$enhance = (_ann$options_ = ann.options_) == null ? void 0 : _ann$options_.enhancer) != null ? _ann$options_$enhance : deepEnhancer, true ? adm.name_ + "." + name.toString() : "ObservableObject." + name.toString(), false); + adm.values_.set(name, observable2); + initializedObjects.add(target); + } + if (kind == "accessor") { + return { + get: function get3() { + if (!initializedObjects.has(this)) { + initializeObservable(this, desc.get.call(this)); + } + return this[$mobx].getObservablePropValue_(name); + }, + set: function set4(value) { + if (!initializedObjects.has(this)) { + initializeObservable(this, value); + } + return this[$mobx].setObservablePropValue_(name, value); + }, + init: function init(value) { + if (!initializedObjects.has(this)) { + initializeObservable(this, value); + } + return value; + } + }; + } + return; + } + function assertObservableDescriptor(adm, _ref, key, descriptor) { + var annotationType_ = _ref.annotationType_; + if (!("value" in descriptor)) { + die("Cannot apply '" + annotationType_ + "' to '" + adm.name_ + "." + key.toString() + "':" + ("\n'" + annotationType_ + "' cannot be used on getter/setter properties")); + } + } + var AUTO = "true"; + var autoAnnotation = /* @__PURE__ */ createAutoAnnotation(); + function createAutoAnnotation(options) { + return { + annotationType_: AUTO, + options_: options, + make_: make_$5, + extend_: extend_$5, + decorate_20223_: decorate_20223_$5 + }; + } + function make_$5(adm, key, descriptor, source) { + var _this$options_3, _this$options_4; + if (descriptor.get) { + return computed.make_(adm, key, descriptor, source); + } + if (descriptor.set) { + var set4 = createAction(key.toString(), descriptor.set); + if (source === adm.target_) { + return adm.defineProperty_(key, { + configurable: globalState.safeDescriptors ? adm.isPlainObject_ : true, + set: set4 + }) === null ? 0 : 2; + } + defineProperty(source, key, { + configurable: true, + set: set4 + }); + return 2; + } + if (source !== adm.target_ && typeof descriptor.value === "function") { + var _this$options_2; + if (isGenerator(descriptor.value)) { + var _this$options_; + var flowAnnotation2 = (_this$options_ = this.options_) != null && _this$options_.autoBind ? flow.bound : flow; + return flowAnnotation2.make_(adm, key, descriptor, source); + } + var actionAnnotation2 = (_this$options_2 = this.options_) != null && _this$options_2.autoBind ? autoAction.bound : autoAction; + return actionAnnotation2.make_(adm, key, descriptor, source); + } + var observableAnnotation2 = ((_this$options_3 = this.options_) == null ? void 0 : _this$options_3.deep) === false ? observable.ref : observable; + if (typeof descriptor.value === "function" && (_this$options_4 = this.options_) != null && _this$options_4.autoBind) { + var _adm$proxy_; + descriptor.value = descriptor.value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_); + } + return observableAnnotation2.make_(adm, key, descriptor, source); + } + function extend_$5(adm, key, descriptor, proxyTrap) { + var _this$options_5, _this$options_6; + if (descriptor.get) { + return computed.extend_(adm, key, descriptor, proxyTrap); + } + if (descriptor.set) { + return adm.defineProperty_(key, { + configurable: globalState.safeDescriptors ? adm.isPlainObject_ : true, + set: createAction(key.toString(), descriptor.set) + }, proxyTrap); + } + if (typeof descriptor.value === "function" && (_this$options_5 = this.options_) != null && _this$options_5.autoBind) { + var _adm$proxy_2; + descriptor.value = descriptor.value.bind((_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_); + } + var observableAnnotation2 = ((_this$options_6 = this.options_) == null ? void 0 : _this$options_6.deep) === false ? observable.ref : observable; + return observableAnnotation2.extend_(adm, key, descriptor, proxyTrap); + } + function decorate_20223_$5(desc, context) { + die("'" + this.annotationType_ + "' cannot be used as a decorator"); + } + var OBSERVABLE = "observable"; + var OBSERVABLE_REF = "observable.ref"; + var OBSERVABLE_SHALLOW = "observable.shallow"; + var OBSERVABLE_STRUCT = "observable.struct"; + var defaultCreateObservableOptions = { + deep: true, + name: void 0, + defaultDecorator: void 0, + proxy: true + }; + Object.freeze(defaultCreateObservableOptions); + function asCreateObservableOptions(thing) { + return thing || defaultCreateObservableOptions; + } + var observableAnnotation = /* @__PURE__ */ createObservableAnnotation(OBSERVABLE); + var observableRefAnnotation = /* @__PURE__ */ createObservableAnnotation(OBSERVABLE_REF, { + enhancer: referenceEnhancer + }); + var observableShallowAnnotation = /* @__PURE__ */ createObservableAnnotation(OBSERVABLE_SHALLOW, { + enhancer: shallowEnhancer + }); + var observableStructAnnotation = /* @__PURE__ */ createObservableAnnotation(OBSERVABLE_STRUCT, { + enhancer: refStructEnhancer + }); + var observableDecoratorAnnotation = /* @__PURE__ */ createDecoratorAnnotation(observableAnnotation); + function getEnhancerFromOptions(options) { + return options.deep === true ? deepEnhancer : options.deep === false ? referenceEnhancer : getEnhancerFromAnnotation(options.defaultDecorator); + } + function getAnnotationFromOptions(options) { + var _options$defaultDecor; + return options ? (_options$defaultDecor = options.defaultDecorator) != null ? _options$defaultDecor : createAutoAnnotation(options) : void 0; + } + function getEnhancerFromAnnotation(annotation) { + var _annotation$options_$, _annotation$options_; + return !annotation ? deepEnhancer : (_annotation$options_$ = (_annotation$options_ = annotation.options_) == null ? void 0 : _annotation$options_.enhancer) != null ? _annotation$options_$ : deepEnhancer; + } + function createObservable(v6, arg2, arg3) { + if (is20223Decorator(arg2)) { + return observableAnnotation.decorate_20223_(v6, arg2); + } + if (isStringish(arg2)) { + storeAnnotation(v6, arg2, observableAnnotation); + return; + } + if (isObservable(v6)) { + return v6; + } + if (isPlainObject(v6)) { + return observable.object(v6, arg2, arg3); + } + if (Array.isArray(v6)) { + return observable.array(v6, arg2); + } + if (isES6Map(v6)) { + return observable.map(v6, arg2); + } + if (isES6Set(v6)) { + return observable.set(v6, arg2); + } + if (typeof v6 === "object" && v6 !== null) { + return v6; + } + return observable.box(v6, arg2); + } + assign(createObservable, observableDecoratorAnnotation); + var observableFactories = { + box: function box(value, options) { + var o29 = asCreateObservableOptions(options); + return new ObservableValue(value, getEnhancerFromOptions(o29), o29.name, true, o29.equals); + }, + array: function array(initialValues, options) { + var o29 = asCreateObservableOptions(options); + return (globalState.useProxies === false || o29.proxy === false ? createLegacyArray : createObservableArray)(initialValues, getEnhancerFromOptions(o29), o29.name); + }, + map: function map(initialValues, options) { + var o29 = asCreateObservableOptions(options); + return new ObservableMap(initialValues, getEnhancerFromOptions(o29), o29.name); + }, + set: function set(initialValues, options) { + var o29 = asCreateObservableOptions(options); + return new ObservableSet(initialValues, getEnhancerFromOptions(o29), o29.name); + }, + object: function object(props, decorators, options) { + return initObservable(function() { + return extendObservable(globalState.useProxies === false || (options == null ? void 0 : options.proxy) === false ? asObservableObject({}, options) : asDynamicObservableObject({}, options), props, decorators); + }); + }, + ref: /* @__PURE__ */ createDecoratorAnnotation(observableRefAnnotation), + shallow: /* @__PURE__ */ createDecoratorAnnotation(observableShallowAnnotation), + deep: observableDecoratorAnnotation, + struct: /* @__PURE__ */ createDecoratorAnnotation(observableStructAnnotation) + }; + var observable = /* @__PURE__ */ assign(createObservable, observableFactories); + var COMPUTED = "computed"; + var COMPUTED_STRUCT = "computed.struct"; + var computedAnnotation = /* @__PURE__ */ createComputedAnnotation(COMPUTED); + var computedStructAnnotation = /* @__PURE__ */ createComputedAnnotation(COMPUTED_STRUCT, { + equals: comparer.structural + }); + var computed = function computed2(arg1, arg2) { + if (is20223Decorator(arg2)) { + return computedAnnotation.decorate_20223_(arg1, arg2); + } + if (isStringish(arg2)) { + return storeAnnotation(arg1, arg2, computedAnnotation); + } + if (isPlainObject(arg1)) { + return createDecoratorAnnotation(createComputedAnnotation(COMPUTED, arg1)); + } + if (true) { + if (!isFunction(arg1)) { + die("First argument to `computed` should be an expression."); + } + if (isFunction(arg2)) { + die("A setter as second argument is no longer supported, use `{ set: fn }` option instead"); + } + } + var opts = isPlainObject(arg2) ? arg2 : {}; + opts.get = arg1; + opts.name || (opts.name = arg1.name || ""); + return new ComputedValue(opts); + }; + Object.assign(computed, computedAnnotation); + computed.struct = /* @__PURE__ */ createDecoratorAnnotation(computedStructAnnotation); + var _getDescriptor$config; + var _getDescriptor; + var currentActionId = 0; + var nextActionId = 1; + var isFunctionNameConfigurable = (_getDescriptor$config = (_getDescriptor = /* @__PURE__ */ getDescriptor(function() { + }, "name")) == null ? void 0 : _getDescriptor.configurable) != null ? _getDescriptor$config : false; + var tmpNameDescriptor = { + value: "action", + configurable: true, + writable: false, + enumerable: false + }; + function createAction(actionName, fn2, autoAction2, ref) { + if (autoAction2 === void 0) { + autoAction2 = false; + } + if (true) { + if (!isFunction(fn2)) { + die("`action` can only be invoked on functions"); + } + if (typeof actionName !== "string" || !actionName) { + die("actions should have valid names, got: '" + actionName + "'"); + } + } + function res() { + return executeAction(actionName, autoAction2, fn2, ref || this, arguments); + } + res.isMobxAction = true; + res.toString = function() { + return fn2.toString(); + }; + if (isFunctionNameConfigurable) { + tmpNameDescriptor.value = actionName; + defineProperty(res, "name", tmpNameDescriptor); + } + return res; + } + function executeAction(actionName, canRunAsDerivation, fn2, scope, args) { + var runInfo = _startAction(actionName, canRunAsDerivation, scope, args); + try { + return fn2.apply(scope, args); + } catch (err) { + runInfo.error_ = err; + throw err; + } finally { + _endAction(runInfo); + } + } + function _startAction(actionName, canRunAsDerivation, scope, args) { + var notifySpy_ = isSpyEnabled() && !!actionName; + var startTime_ = 0; + if (notifySpy_) { + startTime_ = Date.now(); + var flattenedArgs = args ? Array.from(args) : EMPTY_ARRAY; + spyReportStart({ + type: ACTION, + name: actionName, + object: scope, + arguments: flattenedArgs + }); + } + var prevDerivation_ = globalState.trackingDerivation; + var runAsAction = !canRunAsDerivation || !prevDerivation_; + startBatch(); + var prevAllowStateChanges_ = globalState.allowStateChanges; + if (runAsAction) { + untrackedStart(); + prevAllowStateChanges_ = allowStateChangesStart(true); + } + var prevAllowStateReads_ = allowStateReadsStart(true); + var runInfo = { + runAsAction_: runAsAction, + prevDerivation_, + prevAllowStateChanges_, + prevAllowStateReads_, + notifySpy_, + startTime_, + actionId_: nextActionId++, + parentActionId_: currentActionId + }; + currentActionId = runInfo.actionId_; + return runInfo; + } + function _endAction(runInfo) { + if (currentActionId !== runInfo.actionId_) { + die(30); + } + currentActionId = runInfo.parentActionId_; + if (runInfo.error_ !== void 0) { + globalState.suppressReactionErrors = true; + } + allowStateChangesEnd(runInfo.prevAllowStateChanges_); + allowStateReadsEnd(runInfo.prevAllowStateReads_); + endBatch(); + if (runInfo.runAsAction_) { + untrackedEnd(runInfo.prevDerivation_); + } + if (runInfo.notifySpy_) { + spyReportEnd({ + time: Date.now() - runInfo.startTime_ + }); + } + globalState.suppressReactionErrors = false; + } + function allowStateChangesStart(allowStateChanges) { + var prev = globalState.allowStateChanges; + globalState.allowStateChanges = allowStateChanges; + return prev; + } + function allowStateChangesEnd(prev) { + globalState.allowStateChanges = prev; + } + var _Symbol$toPrimitive; + var CREATE = "create"; + _Symbol$toPrimitive = Symbol.toPrimitive; + var ObservableValue = /* @__PURE__ */ function(_Atom) { + _inheritsLoose(ObservableValue2, _Atom); + function ObservableValue2(value, enhancer, name_, notifySpy, equals) { + var _this; + if (name_ === void 0) { + name_ = true ? "ObservableValue@" + getNextId() : "ObservableValue"; + } + if (notifySpy === void 0) { + notifySpy = true; + } + if (equals === void 0) { + equals = comparer["default"]; + } + _this = _Atom.call(this, name_) || this; + _this.enhancer = void 0; + _this.name_ = void 0; + _this.equals = void 0; + _this.hasUnreportedChange_ = false; + _this.interceptors_ = void 0; + _this.changeListeners_ = void 0; + _this.value_ = void 0; + _this.dehancer = void 0; + _this.enhancer = enhancer; + _this.name_ = name_; + _this.equals = equals; + _this.value_ = enhancer(value, void 0, name_); + if (notifySpy && isSpyEnabled()) { + spyReport({ + type: CREATE, + object: _assertThisInitialized(_this), + observableKind: "value", + debugObjectName: _this.name_, + newValue: "" + _this.value_ + }); + } + return _this; + } + var _proto = ObservableValue2.prototype; + _proto.dehanceValue = function dehanceValue(value) { + if (this.dehancer !== void 0) { + return this.dehancer(value); + } + return value; + }; + _proto.set = function set4(newValue) { + var oldValue = this.value_; + newValue = this.prepareNewValue_(newValue); + if (newValue !== globalState.UNCHANGED) { + var notifySpy = isSpyEnabled(); + if (notifySpy) { + spyReportStart({ + type: UPDATE, + object: this, + observableKind: "value", + debugObjectName: this.name_, + newValue, + oldValue + }); + } + this.setNewValue_(newValue); + if (notifySpy) { + spyReportEnd(); + } + } + }; + _proto.prepareNewValue_ = function prepareNewValue_(newValue) { + checkIfStateModificationsAreAllowed(this); + if (hasInterceptors(this)) { + var change2 = interceptChange(this, { + object: this, + type: UPDATE, + newValue + }); + if (!change2) { + return globalState.UNCHANGED; + } + newValue = change2.newValue; + } + newValue = this.enhancer(newValue, this.value_, this.name_); + return this.equals(this.value_, newValue) ? globalState.UNCHANGED : newValue; + }; + _proto.setNewValue_ = function setNewValue_(newValue) { + var oldValue = this.value_; + this.value_ = newValue; + this.reportChanged(); + if (hasListeners(this)) { + notifyListeners(this, { + type: UPDATE, + object: this, + newValue, + oldValue + }); + } + }; + _proto.get = function get3() { + this.reportObserved(); + return this.dehanceValue(this.value_); + }; + _proto.intercept_ = function intercept_(handler) { + return registerInterceptor(this, handler); + }; + _proto.observe_ = function observe_(listener, fireImmediately) { + if (fireImmediately) { + listener({ + observableKind: "value", + debugObjectName: this.name_, + object: this, + type: UPDATE, + newValue: this.value_, + oldValue: void 0 + }); + } + return registerListener(this, listener); + }; + _proto.raw = function raw() { + return this.value_; + }; + _proto.toJSON = function toJSON2() { + return this.get(); + }; + _proto.toString = function toString2() { + return this.name_ + "[" + this.value_ + "]"; + }; + _proto.valueOf = function valueOf() { + return toPrimitive(this.get()); + }; + _proto[_Symbol$toPrimitive] = function() { + return this.valueOf(); + }; + return ObservableValue2; + }(Atom); + var _Symbol$toPrimitive$1; + _Symbol$toPrimitive$1 = Symbol.toPrimitive; + var ComputedValue = /* @__PURE__ */ function() { + function ComputedValue2(options) { + this.dependenciesState_ = IDerivationState_.NOT_TRACKING_; + this.observing_ = []; + this.newObserving_ = null; + this.isBeingObserved_ = false; + this.isPendingUnobservation_ = false; + this.observers_ = /* @__PURE__ */ new Set(); + this.diffValue_ = 0; + this.runId_ = 0; + this.lastAccessedBy_ = 0; + this.lowestObserverState_ = IDerivationState_.UP_TO_DATE_; + this.unboundDepsCount_ = 0; + this.value_ = new CaughtException(null); + this.name_ = void 0; + this.triggeredBy_ = void 0; + this.isComputing_ = false; + this.isRunningSetter_ = false; + this.derivation = void 0; + this.setter_ = void 0; + this.isTracing_ = TraceMode.NONE; + this.scope_ = void 0; + this.equals_ = void 0; + this.requiresReaction_ = void 0; + this.keepAlive_ = void 0; + this.onBOL = void 0; + this.onBUOL = void 0; + if (!options.get) { + die(31); + } + this.derivation = options.get; + this.name_ = options.name || (true ? "ComputedValue@" + getNextId() : "ComputedValue"); + if (options.set) { + this.setter_ = createAction(true ? this.name_ + "-setter" : "ComputedValue-setter", options.set); + } + this.equals_ = options.equals || (options.compareStructural || options.struct ? comparer.structural : comparer["default"]); + this.scope_ = options.context; + this.requiresReaction_ = options.requiresReaction; + this.keepAlive_ = !!options.keepAlive; + } + var _proto = ComputedValue2.prototype; + _proto.onBecomeStale_ = function onBecomeStale_() { + propagateMaybeChanged(this); + }; + _proto.onBO = function onBO() { + if (this.onBOL) { + this.onBOL.forEach(function(listener) { + return listener(); + }); + } + }; + _proto.onBUO = function onBUO() { + if (this.onBUOL) { + this.onBUOL.forEach(function(listener) { + return listener(); + }); + } + }; + _proto.get = function get3() { + if (this.isComputing_) { + die(32, this.name_, this.derivation); + } + if (globalState.inBatch === 0 && // !globalState.trackingDerivatpion && + this.observers_.size === 0 && !this.keepAlive_) { + if (shouldCompute(this)) { + this.warnAboutUntrackedRead_(); + startBatch(); + this.value_ = this.computeValue_(false); + endBatch(); + } + } else { + reportObserved(this); + if (shouldCompute(this)) { + var prevTrackingContext = globalState.trackingContext; + if (this.keepAlive_ && !prevTrackingContext) { + globalState.trackingContext = this; + } + if (this.trackAndCompute()) { + propagateChangeConfirmed(this); + } + globalState.trackingContext = prevTrackingContext; + } + } + var result = this.value_; + if (isCaughtException(result)) { + throw result.cause; + } + return result; + }; + _proto.set = function set4(value) { + if (this.setter_) { + if (this.isRunningSetter_) { + die(33, this.name_); + } + this.isRunningSetter_ = true; + try { + this.setter_.call(this.scope_, value); + } finally { + this.isRunningSetter_ = false; + } + } else { + die(34, this.name_); + } + }; + _proto.trackAndCompute = function trackAndCompute() { + var oldValue = this.value_; + var wasSuspended = ( + /* see #1208 */ + this.dependenciesState_ === IDerivationState_.NOT_TRACKING_ + ); + var newValue = this.computeValue_(true); + var changed = wasSuspended || isCaughtException(oldValue) || isCaughtException(newValue) || !this.equals_(oldValue, newValue); + if (changed) { + this.value_ = newValue; + if (isSpyEnabled()) { + spyReport({ + observableKind: "computed", + debugObjectName: this.name_, + object: this.scope_, + type: "update", + oldValue, + newValue + }); + } + } + return changed; + }; + _proto.computeValue_ = function computeValue_(track) { + this.isComputing_ = true; + var prev = allowStateChangesStart(false); + var res; + if (track) { + res = trackDerivedFunction(this, this.derivation, this.scope_); + } else { + if (globalState.disableErrorBoundaries === true) { + res = this.derivation.call(this.scope_); + } else { + try { + res = this.derivation.call(this.scope_); + } catch (e33) { + res = new CaughtException(e33); + } + } + } + allowStateChangesEnd(prev); + this.isComputing_ = false; + return res; + }; + _proto.suspend_ = function suspend_() { + if (!this.keepAlive_) { + clearObserving(this); + this.value_ = void 0; + if (this.isTracing_ !== TraceMode.NONE) { + console.log("[mobx.trace] Computed value '" + this.name_ + "' was suspended and it will recompute on the next access."); + } + } + }; + _proto.observe_ = function observe_(listener, fireImmediately) { + var _this = this; + var firstTime = true; + var prevValue = void 0; + return autorun(function() { + var newValue = _this.get(); + if (!firstTime || fireImmediately) { + var prevU = untrackedStart(); + listener({ + observableKind: "computed", + debugObjectName: _this.name_, + type: UPDATE, + object: _this, + newValue, + oldValue: prevValue + }); + untrackedEnd(prevU); + } + firstTime = false; + prevValue = newValue; + }); + }; + _proto.warnAboutUntrackedRead_ = function warnAboutUntrackedRead_() { + if (false) { + return; + } + if (this.isTracing_ !== TraceMode.NONE) { + console.log("[mobx.trace] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute."); + } + if (typeof this.requiresReaction_ === "boolean" ? this.requiresReaction_ : globalState.computedRequiresReaction) { + console.warn("[mobx] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute."); + } + }; + _proto.toString = function toString2() { + return this.name_ + "[" + this.derivation.toString() + "]"; + }; + _proto.valueOf = function valueOf() { + return toPrimitive(this.get()); + }; + _proto[_Symbol$toPrimitive$1] = function() { + return this.valueOf(); + }; + return ComputedValue2; + }(); + var isComputedValue = /* @__PURE__ */ createInstanceofPredicate("ComputedValue", ComputedValue); + var IDerivationState_; + (function(IDerivationState_2) { + IDerivationState_2[IDerivationState_2["NOT_TRACKING_"] = -1] = "NOT_TRACKING_"; + IDerivationState_2[IDerivationState_2["UP_TO_DATE_"] = 0] = "UP_TO_DATE_"; + IDerivationState_2[IDerivationState_2["POSSIBLY_STALE_"] = 1] = "POSSIBLY_STALE_"; + IDerivationState_2[IDerivationState_2["STALE_"] = 2] = "STALE_"; + })(IDerivationState_ || (IDerivationState_ = {})); + var TraceMode; + (function(TraceMode2) { + TraceMode2[TraceMode2["NONE"] = 0] = "NONE"; + TraceMode2[TraceMode2["LOG"] = 1] = "LOG"; + TraceMode2[TraceMode2["BREAK"] = 2] = "BREAK"; + })(TraceMode || (TraceMode = {})); + var CaughtException = function CaughtException2(cause) { + this.cause = void 0; + this.cause = cause; + }; + function isCaughtException(e33) { + return e33 instanceof CaughtException; + } + function shouldCompute(derivation) { + switch (derivation.dependenciesState_) { + case IDerivationState_.UP_TO_DATE_: + return false; + case IDerivationState_.NOT_TRACKING_: + case IDerivationState_.STALE_: + return true; + case IDerivationState_.POSSIBLY_STALE_: { + var prevAllowStateReads = allowStateReadsStart(true); + var prevUntracked = untrackedStart(); + var obs = derivation.observing_, l20 = obs.length; + for (var i23 = 0; i23 < l20; i23++) { + var obj = obs[i23]; + if (isComputedValue(obj)) { + if (globalState.disableErrorBoundaries) { + obj.get(); + } else { + try { + obj.get(); + } catch (e33) { + untrackedEnd(prevUntracked); + allowStateReadsEnd(prevAllowStateReads); + return true; + } + } + if (derivation.dependenciesState_ === IDerivationState_.STALE_) { + untrackedEnd(prevUntracked); + allowStateReadsEnd(prevAllowStateReads); + return true; + } + } + } + changeDependenciesStateTo0(derivation); + untrackedEnd(prevUntracked); + allowStateReadsEnd(prevAllowStateReads); + return false; + } + } + } + function checkIfStateModificationsAreAllowed(atom) { + if (false) { + return; + } + var hasObservers = atom.observers_.size > 0; + if (!globalState.allowStateChanges && (hasObservers || globalState.enforceActions === "always")) { + console.warn("[MobX] " + (globalState.enforceActions ? "Since strict-mode is enabled, changing (observed) observable values without using an action is not allowed. Tried to modify: " : "Side effects like changing state are not allowed at this point. Are you trying to modify state from, for example, a computed value or the render function of a React component? You can wrap side effects in 'runInAction' (or decorate functions with 'action') if needed. Tried to modify: ") + atom.name_); + } + } + function checkIfStateReadsAreAllowed(observable2) { + if (!globalState.allowStateReads && globalState.observableRequiresReaction) { + console.warn("[mobx] Observable '" + observable2.name_ + "' being read outside a reactive context."); + } + } + function trackDerivedFunction(derivation, f7, context) { + var prevAllowStateReads = allowStateReadsStart(true); + changeDependenciesStateTo0(derivation); + derivation.newObserving_ = new Array( + // Reserve constant space for initial dependencies, dynamic space otherwise. + // See https://github.com/mobxjs/mobx/pull/3833 + derivation.runId_ === 0 ? 100 : derivation.observing_.length + ); + derivation.unboundDepsCount_ = 0; + derivation.runId_ = ++globalState.runId; + var prevTracking = globalState.trackingDerivation; + globalState.trackingDerivation = derivation; + globalState.inBatch++; + var result; + if (globalState.disableErrorBoundaries === true) { + result = f7.call(context); + } else { + try { + result = f7.call(context); + } catch (e33) { + result = new CaughtException(e33); + } + } + globalState.inBatch--; + globalState.trackingDerivation = prevTracking; + bindDependencies(derivation); + warnAboutDerivationWithoutDependencies(derivation); + allowStateReadsEnd(prevAllowStateReads); + return result; + } + function warnAboutDerivationWithoutDependencies(derivation) { + if (false) { + return; + } + if (derivation.observing_.length !== 0) { + return; + } + if (typeof derivation.requiresObservable_ === "boolean" ? derivation.requiresObservable_ : globalState.reactionRequiresObservable) { + console.warn("[mobx] Derivation '" + derivation.name_ + "' is created/updated without reading any observable value."); + } + } + function bindDependencies(derivation) { + var prevObserving = derivation.observing_; + var observing = derivation.observing_ = derivation.newObserving_; + var lowestNewObservingDerivationState = IDerivationState_.UP_TO_DATE_; + var i0 = 0, l20 = derivation.unboundDepsCount_; + for (var i23 = 0; i23 < l20; i23++) { + var dep = observing[i23]; + if (dep.diffValue_ === 0) { + dep.diffValue_ = 1; + if (i0 !== i23) { + observing[i0] = dep; + } + i0++; + } + if (dep.dependenciesState_ > lowestNewObservingDerivationState) { + lowestNewObservingDerivationState = dep.dependenciesState_; + } + } + observing.length = i0; + derivation.newObserving_ = null; + l20 = prevObserving.length; + while (l20--) { + var _dep = prevObserving[l20]; + if (_dep.diffValue_ === 0) { + removeObserver(_dep, derivation); + } + _dep.diffValue_ = 0; + } + while (i0--) { + var _dep2 = observing[i0]; + if (_dep2.diffValue_ === 1) { + _dep2.diffValue_ = 0; + addObserver(_dep2, derivation); + } + } + if (lowestNewObservingDerivationState !== IDerivationState_.UP_TO_DATE_) { + derivation.dependenciesState_ = lowestNewObservingDerivationState; + derivation.onBecomeStale_(); + } + } + function clearObserving(derivation) { + var obs = derivation.observing_; + derivation.observing_ = []; + var i23 = obs.length; + while (i23--) { + removeObserver(obs[i23], derivation); + } + derivation.dependenciesState_ = IDerivationState_.NOT_TRACKING_; + } + function untracked(action2) { + var prev = untrackedStart(); + try { + return action2(); + } finally { + untrackedEnd(prev); + } + } + function untrackedStart() { + var prev = globalState.trackingDerivation; + globalState.trackingDerivation = null; + return prev; + } + function untrackedEnd(prev) { + globalState.trackingDerivation = prev; + } + function allowStateReadsStart(allowStateReads) { + var prev = globalState.allowStateReads; + globalState.allowStateReads = allowStateReads; + return prev; + } + function allowStateReadsEnd(prev) { + globalState.allowStateReads = prev; + } + function changeDependenciesStateTo0(derivation) { + if (derivation.dependenciesState_ === IDerivationState_.UP_TO_DATE_) { + return; + } + derivation.dependenciesState_ = IDerivationState_.UP_TO_DATE_; + var obs = derivation.observing_; + var i23 = obs.length; + while (i23--) { + obs[i23].lowestObserverState_ = IDerivationState_.UP_TO_DATE_; + } + } + var MobXGlobals = function MobXGlobals2() { + this.version = 6; + this.UNCHANGED = {}; + this.trackingDerivation = null; + this.trackingContext = null; + this.runId = 0; + this.mobxGuid = 0; + this.inBatch = 0; + this.pendingUnobservations = []; + this.pendingReactions = []; + this.isRunningReactions = false; + this.allowStateChanges = false; + this.allowStateReads = true; + this.enforceActions = true; + this.spyListeners = []; + this.globalReactionErrorHandlers = []; + this.computedRequiresReaction = false; + this.reactionRequiresObservable = false; + this.observableRequiresReaction = false; + this.disableErrorBoundaries = false; + this.suppressReactionErrors = false; + this.useProxies = true; + this.verifyProxies = false; + this.safeDescriptors = true; + }; + var canMergeGlobalState = true; + var isolateCalled = false; + var globalState = /* @__PURE__ */ function() { + var global2 = /* @__PURE__ */ getGlobal(); + if (global2.__mobxInstanceCount > 0 && !global2.__mobxGlobals) { + canMergeGlobalState = false; + } + if (global2.__mobxGlobals && global2.__mobxGlobals.version !== new MobXGlobals().version) { + canMergeGlobalState = false; + } + if (!canMergeGlobalState) { + setTimeout(function() { + if (!isolateCalled) { + die(35); + } + }, 1); + return new MobXGlobals(); + } else if (global2.__mobxGlobals) { + global2.__mobxInstanceCount += 1; + if (!global2.__mobxGlobals.UNCHANGED) { + global2.__mobxGlobals.UNCHANGED = {}; + } + return global2.__mobxGlobals; + } else { + global2.__mobxInstanceCount = 1; + return global2.__mobxGlobals = /* @__PURE__ */ new MobXGlobals(); + } + }(); + function addObserver(observable2, node) { + observable2.observers_.add(node); + if (observable2.lowestObserverState_ > node.dependenciesState_) { + observable2.lowestObserverState_ = node.dependenciesState_; + } + } + function removeObserver(observable2, node) { + observable2.observers_["delete"](node); + if (observable2.observers_.size === 0) { + queueForUnobservation(observable2); + } + } + function queueForUnobservation(observable2) { + if (observable2.isPendingUnobservation_ === false) { + observable2.isPendingUnobservation_ = true; + globalState.pendingUnobservations.push(observable2); + } + } + function startBatch() { + globalState.inBatch++; + } + function endBatch() { + if (--globalState.inBatch === 0) { + runReactions(); + var list = globalState.pendingUnobservations; + for (var i23 = 0; i23 < list.length; i23++) { + var observable2 = list[i23]; + observable2.isPendingUnobservation_ = false; + if (observable2.observers_.size === 0) { + if (observable2.isBeingObserved_) { + observable2.isBeingObserved_ = false; + observable2.onBUO(); + } + if (observable2 instanceof ComputedValue) { + observable2.suspend_(); + } + } + } + globalState.pendingUnobservations = []; + } + } + function reportObserved(observable2) { + checkIfStateReadsAreAllowed(observable2); + var derivation = globalState.trackingDerivation; + if (derivation !== null) { + if (derivation.runId_ !== observable2.lastAccessedBy_) { + observable2.lastAccessedBy_ = derivation.runId_; + derivation.newObserving_[derivation.unboundDepsCount_++] = observable2; + if (!observable2.isBeingObserved_ && globalState.trackingContext) { + observable2.isBeingObserved_ = true; + observable2.onBO(); + } + } + return observable2.isBeingObserved_; + } else if (observable2.observers_.size === 0 && globalState.inBatch > 0) { + queueForUnobservation(observable2); + } + return false; + } + function propagateChanged(observable2) { + if (observable2.lowestObserverState_ === IDerivationState_.STALE_) { + return; + } + observable2.lowestObserverState_ = IDerivationState_.STALE_; + observable2.observers_.forEach(function(d11) { + if (d11.dependenciesState_ === IDerivationState_.UP_TO_DATE_) { + if (d11.isTracing_ !== TraceMode.NONE) { + logTraceInfo(d11, observable2); + } + d11.onBecomeStale_(); + } + d11.dependenciesState_ = IDerivationState_.STALE_; + }); + } + function propagateChangeConfirmed(observable2) { + if (observable2.lowestObserverState_ === IDerivationState_.STALE_) { + return; + } + observable2.lowestObserverState_ = IDerivationState_.STALE_; + observable2.observers_.forEach(function(d11) { + if (d11.dependenciesState_ === IDerivationState_.POSSIBLY_STALE_) { + d11.dependenciesState_ = IDerivationState_.STALE_; + if (d11.isTracing_ !== TraceMode.NONE) { + logTraceInfo(d11, observable2); + } + } else if (d11.dependenciesState_ === IDerivationState_.UP_TO_DATE_) { + observable2.lowestObserverState_ = IDerivationState_.UP_TO_DATE_; + } + }); + } + function propagateMaybeChanged(observable2) { + if (observable2.lowestObserverState_ !== IDerivationState_.UP_TO_DATE_) { + return; + } + observable2.lowestObserverState_ = IDerivationState_.POSSIBLY_STALE_; + observable2.observers_.forEach(function(d11) { + if (d11.dependenciesState_ === IDerivationState_.UP_TO_DATE_) { + d11.dependenciesState_ = IDerivationState_.POSSIBLY_STALE_; + d11.onBecomeStale_(); + } + }); + } + function logTraceInfo(derivation, observable2) { + console.log("[mobx.trace] '" + derivation.name_ + "' is invalidated due to a change in: '" + observable2.name_ + "'"); + if (derivation.isTracing_ === TraceMode.BREAK) { + var lines = []; + printDepTree(getDependencyTree(derivation), lines, 1); + new Function("debugger;\n/*\nTracing '" + derivation.name_ + "'\n\nYou are entering this break point because derivation '" + derivation.name_ + "' is being traced and '" + observable2.name_ + "' is now forcing it to update.\nJust follow the stacktrace you should now see in the devtools to see precisely what piece of your code is causing this update\nThe stackframe you are looking for is at least ~6-8 stack-frames up.\n\n" + (derivation instanceof ComputedValue ? derivation.derivation.toString().replace(/[*]\//g, "/") : "") + "\n\nThe dependencies for this derivation are:\n\n" + lines.join("\n") + "\n*/\n ")(); + } + } + function printDepTree(tree, lines, depth) { + if (lines.length >= 1e3) { + lines.push("(and many more)"); + return; + } + lines.push("" + " ".repeat(depth - 1) + tree.name); + if (tree.dependencies) { + tree.dependencies.forEach(function(child) { + return printDepTree(child, lines, depth + 1); + }); + } + } + var Reaction = /* @__PURE__ */ function() { + function Reaction2(name_, onInvalidate_, errorHandler_, requiresObservable_) { + if (name_ === void 0) { + name_ = true ? "Reaction@" + getNextId() : "Reaction"; + } + this.name_ = void 0; + this.onInvalidate_ = void 0; + this.errorHandler_ = void 0; + this.requiresObservable_ = void 0; + this.observing_ = []; + this.newObserving_ = []; + this.dependenciesState_ = IDerivationState_.NOT_TRACKING_; + this.diffValue_ = 0; + this.runId_ = 0; + this.unboundDepsCount_ = 0; + this.isDisposed_ = false; + this.isScheduled_ = false; + this.isTrackPending_ = false; + this.isRunning_ = false; + this.isTracing_ = TraceMode.NONE; + this.name_ = name_; + this.onInvalidate_ = onInvalidate_; + this.errorHandler_ = errorHandler_; + this.requiresObservable_ = requiresObservable_; + } + var _proto = Reaction2.prototype; + _proto.onBecomeStale_ = function onBecomeStale_() { + this.schedule_(); + }; + _proto.schedule_ = function schedule_() { + if (!this.isScheduled_) { + this.isScheduled_ = true; + globalState.pendingReactions.push(this); + runReactions(); + } + }; + _proto.isScheduled = function isScheduled() { + return this.isScheduled_; + }; + _proto.runReaction_ = function runReaction_() { + if (!this.isDisposed_) { + startBatch(); + this.isScheduled_ = false; + var prev = globalState.trackingContext; + globalState.trackingContext = this; + if (shouldCompute(this)) { + this.isTrackPending_ = true; + try { + this.onInvalidate_(); + if (this.isTrackPending_ && isSpyEnabled()) { + spyReport({ + name: this.name_, + type: "scheduled-reaction" + }); + } + } catch (e33) { + this.reportExceptionInDerivation_(e33); + } + } + globalState.trackingContext = prev; + endBatch(); + } + }; + _proto.track = function track(fn2) { + if (this.isDisposed_) { + return; + } + startBatch(); + var notify = isSpyEnabled(); + var startTime; + if (notify) { + startTime = Date.now(); + spyReportStart({ + name: this.name_, + type: "reaction" + }); + } + this.isRunning_ = true; + var prevReaction = globalState.trackingContext; + globalState.trackingContext = this; + var result = trackDerivedFunction(this, fn2, void 0); + globalState.trackingContext = prevReaction; + this.isRunning_ = false; + this.isTrackPending_ = false; + if (this.isDisposed_) { + clearObserving(this); + } + if (isCaughtException(result)) { + this.reportExceptionInDerivation_(result.cause); + } + if (notify) { + spyReportEnd({ + time: Date.now() - startTime + }); + } + endBatch(); + }; + _proto.reportExceptionInDerivation_ = function reportExceptionInDerivation_(error) { + var _this = this; + if (this.errorHandler_) { + this.errorHandler_(error, this); + return; + } + if (globalState.disableErrorBoundaries) { + throw error; + } + var message = true ? "[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '" + this + "'" : "[mobx] uncaught error in '" + this + "'"; + if (!globalState.suppressReactionErrors) { + console.error(message, error); + } else if (true) { + console.warn("[mobx] (error in reaction '" + this.name_ + "' suppressed, fix error of causing action below)"); + } + if (isSpyEnabled()) { + spyReport({ + type: "error", + name: this.name_, + message, + error: "" + error + }); + } + globalState.globalReactionErrorHandlers.forEach(function(f7) { + return f7(error, _this); + }); + }; + _proto.dispose = function dispose() { + if (!this.isDisposed_) { + this.isDisposed_ = true; + if (!this.isRunning_) { + startBatch(); + clearObserving(this); + endBatch(); + } + } + }; + _proto.getDisposer_ = function getDisposer_(abortSignal) { + var _this2 = this; + var dispose = function dispose2() { + _this2.dispose(); + abortSignal == null ? void 0 : abortSignal.removeEventListener == null ? void 0 : abortSignal.removeEventListener("abort", dispose2); + }; + abortSignal == null ? void 0 : abortSignal.addEventListener == null ? void 0 : abortSignal.addEventListener("abort", dispose); + dispose[$mobx] = this; + return dispose; + }; + _proto.toString = function toString2() { + return "Reaction[" + this.name_ + "]"; + }; + _proto.trace = function trace$1(enterBreakPoint) { + if (enterBreakPoint === void 0) { + enterBreakPoint = false; + } + trace(this, enterBreakPoint); + }; + return Reaction2; + }(); + var MAX_REACTION_ITERATIONS = 100; + var reactionScheduler = function reactionScheduler2(f7) { + return f7(); + }; + function runReactions() { + if (globalState.inBatch > 0 || globalState.isRunningReactions) { + return; + } + reactionScheduler(runReactionsHelper); + } + function runReactionsHelper() { + globalState.isRunningReactions = true; + var allReactions = globalState.pendingReactions; + var iterations = 0; + while (allReactions.length > 0) { + if (++iterations === MAX_REACTION_ITERATIONS) { + console.error(true ? "Reaction doesn't converge to a stable state after " + MAX_REACTION_ITERATIONS + " iterations." + (" Probably there is a cycle in the reactive function: " + allReactions[0]) : "[mobx] cycle in reaction: " + allReactions[0]); + allReactions.splice(0); + } + var remainingReactions = allReactions.splice(0); + for (var i23 = 0, l20 = remainingReactions.length; i23 < l20; i23++) { + remainingReactions[i23].runReaction_(); + } + } + globalState.isRunningReactions = false; + } + var isReaction = /* @__PURE__ */ createInstanceofPredicate("Reaction", Reaction); + function isSpyEnabled() { + return !!globalState.spyListeners.length; + } + function spyReport(event) { + if (false) { + return; + } + if (!globalState.spyListeners.length) { + return; + } + var listeners = globalState.spyListeners; + for (var i23 = 0, l20 = listeners.length; i23 < l20; i23++) { + listeners[i23](event); + } + } + function spyReportStart(event) { + if (false) { + return; + } + var change2 = _extends({}, event, { + spyReportStart: true + }); + spyReport(change2); + } + var END_EVENT = { + type: "report-end", + spyReportEnd: true + }; + function spyReportEnd(change2) { + if (false) { + return; + } + if (change2) { + spyReport(_extends({}, change2, { + type: "report-end", + spyReportEnd: true + })); + } else { + spyReport(END_EVENT); + } + } + function spy(listener) { + if (false) { + console.warn("[mobx.spy] Is a no-op in production builds"); + return function() { + }; + } else { + globalState.spyListeners.push(listener); + return once(function() { + globalState.spyListeners = globalState.spyListeners.filter(function(l20) { + return l20 !== listener; + }); + }); + } + } + var ACTION = "action"; + var ACTION_BOUND = "action.bound"; + var AUTOACTION = "autoAction"; + var AUTOACTION_BOUND = "autoAction.bound"; + var DEFAULT_ACTION_NAME = ""; + var actionAnnotation = /* @__PURE__ */ createActionAnnotation(ACTION); + var actionBoundAnnotation = /* @__PURE__ */ createActionAnnotation(ACTION_BOUND, { + bound: true + }); + var autoActionAnnotation = /* @__PURE__ */ createActionAnnotation(AUTOACTION, { + autoAction: true + }); + var autoActionBoundAnnotation = /* @__PURE__ */ createActionAnnotation(AUTOACTION_BOUND, { + autoAction: true, + bound: true + }); + function createActionFactory(autoAction2) { + var res = function action2(arg1, arg2) { + if (isFunction(arg1)) { + return createAction(arg1.name || DEFAULT_ACTION_NAME, arg1, autoAction2); + } + if (isFunction(arg2)) { + return createAction(arg1, arg2, autoAction2); + } + if (is20223Decorator(arg2)) { + return (autoAction2 ? autoActionAnnotation : actionAnnotation).decorate_20223_(arg1, arg2); + } + if (isStringish(arg2)) { + return storeAnnotation(arg1, arg2, autoAction2 ? autoActionAnnotation : actionAnnotation); + } + if (isStringish(arg1)) { + return createDecoratorAnnotation(createActionAnnotation(autoAction2 ? AUTOACTION : ACTION, { + name: arg1, + autoAction: autoAction2 + })); + } + if (true) { + die("Invalid arguments for `action`"); + } + }; + return res; + } + var action = /* @__PURE__ */ createActionFactory(false); + Object.assign(action, actionAnnotation); + var autoAction = /* @__PURE__ */ createActionFactory(true); + Object.assign(autoAction, autoActionAnnotation); + action.bound = /* @__PURE__ */ createDecoratorAnnotation(actionBoundAnnotation); + autoAction.bound = /* @__PURE__ */ createDecoratorAnnotation(autoActionBoundAnnotation); + function isAction(thing) { + return isFunction(thing) && thing.isMobxAction === true; + } + function autorun(view, opts) { + var _opts$name, _opts, _opts2, _opts2$signal, _opts3; + if (opts === void 0) { + opts = EMPTY_OBJECT; + } + if (true) { + if (!isFunction(view)) { + die("Autorun expects a function as first argument"); + } + if (isAction(view)) { + die("Autorun does not accept actions since actions are untrackable"); + } + } + var name = (_opts$name = (_opts = opts) == null ? void 0 : _opts.name) != null ? _opts$name : true ? view.name || "Autorun@" + getNextId() : "Autorun"; + var runSync = !opts.scheduler && !opts.delay; + var reaction2; + if (runSync) { + reaction2 = new Reaction(name, function() { + this.track(reactionRunner); + }, opts.onError, opts.requiresObservable); + } else { + var scheduler = createSchedulerFromOptions(opts); + var isScheduled = false; + reaction2 = new Reaction(name, function() { + if (!isScheduled) { + isScheduled = true; + scheduler(function() { + isScheduled = false; + if (!reaction2.isDisposed_) { + reaction2.track(reactionRunner); + } + }); + } + }, opts.onError, opts.requiresObservable); + } + function reactionRunner() { + view(reaction2); + } + if (!((_opts2 = opts) != null && (_opts2$signal = _opts2.signal) != null && _opts2$signal.aborted)) { + reaction2.schedule_(); + } + return reaction2.getDisposer_((_opts3 = opts) == null ? void 0 : _opts3.signal); + } + var run = function run2(f7) { + return f7(); + }; + function createSchedulerFromOptions(opts) { + return opts.scheduler ? opts.scheduler : opts.delay ? function(f7) { + return setTimeout(f7, opts.delay); + } : run; + } + var ON_BECOME_OBSERVED = "onBO"; + var ON_BECOME_UNOBSERVED = "onBUO"; + function onBecomeObserved(thing, arg2, arg3) { + return interceptHook(ON_BECOME_OBSERVED, thing, arg2, arg3); + } + function onBecomeUnobserved(thing, arg2, arg3) { + return interceptHook(ON_BECOME_UNOBSERVED, thing, arg2, arg3); + } + function interceptHook(hook, thing, arg2, arg3) { + var atom = typeof arg3 === "function" ? getAtom(thing, arg2) : getAtom(thing); + var cb = isFunction(arg3) ? arg3 : arg2; + var listenersKey = hook + "L"; + if (atom[listenersKey]) { + atom[listenersKey].add(cb); + } else { + atom[listenersKey] = /* @__PURE__ */ new Set([cb]); + } + return function() { + var hookListeners = atom[listenersKey]; + if (hookListeners) { + hookListeners["delete"](cb); + if (hookListeners.size === 0) { + delete atom[listenersKey]; + } + } + }; + } + function extendObservable(target, properties, annotations, options) { + if (true) { + if (arguments.length > 4) { + die("'extendObservable' expected 2-4 arguments"); + } + if (typeof target !== "object") { + die("'extendObservable' expects an object as first argument"); + } + if (isObservableMap(target)) { + die("'extendObservable' should not be used on maps, use map.merge instead"); + } + if (!isPlainObject(properties)) { + die("'extendObservable' only accepts plain objects as second argument"); + } + if (isObservable(properties) || isObservable(annotations)) { + die("Extending an object with another observable (object) is not supported"); + } + } + var descriptors = getOwnPropertyDescriptors(properties); + initObservable(function() { + var adm = asObservableObject(target, options)[$mobx]; + ownKeys(descriptors).forEach(function(key) { + adm.extend_( + key, + descriptors[key], + // must pass "undefined" for { key: undefined } + !annotations ? true : key in annotations ? annotations[key] : true + ); + }); + }); + return target; + } + function getDependencyTree(thing, property) { + return nodeToDependencyTree(getAtom(thing, property)); + } + function nodeToDependencyTree(node) { + var result = { + name: node.name_ + }; + if (node.observing_ && node.observing_.length > 0) { + result.dependencies = unique(node.observing_).map(nodeToDependencyTree); + } + return result; + } + function unique(list) { + return Array.from(new Set(list)); + } + var generatorId = 0; + function FlowCancellationError() { + this.message = "FLOW_CANCELLED"; + } + FlowCancellationError.prototype = /* @__PURE__ */ Object.create(Error.prototype); + var flowAnnotation = /* @__PURE__ */ createFlowAnnotation("flow"); + var flowBoundAnnotation = /* @__PURE__ */ createFlowAnnotation("flow.bound", { + bound: true + }); + var flow = /* @__PURE__ */ Object.assign(function flow2(arg1, arg2) { + if (is20223Decorator(arg2)) { + return flowAnnotation.decorate_20223_(arg1, arg2); + } + if (isStringish(arg2)) { + return storeAnnotation(arg1, arg2, flowAnnotation); + } + if (arguments.length !== 1) { + die("Flow expects single argument with generator function"); + } + var generator = arg1; + var name = generator.name || ""; + var res = function res2() { + var ctx = this; + var args = arguments; + var runId = ++generatorId; + var gen = action(name + " - runid: " + runId + " - init", generator).apply(ctx, args); + var rejector; + var pendingPromise = void 0; + var promise = new Promise(function(resolve, reject) { + var stepId = 0; + rejector = reject; + function onFulfilled(res3) { + pendingPromise = void 0; + var ret; + try { + ret = action(name + " - runid: " + runId + " - yield " + stepId++, gen.next).call(gen, res3); + } catch (e33) { + return reject(e33); + } + next(ret); + } + function onRejected(err) { + pendingPromise = void 0; + var ret; + try { + ret = action(name + " - runid: " + runId + " - yield " + stepId++, gen["throw"]).call(gen, err); + } catch (e33) { + return reject(e33); + } + next(ret); + } + function next(ret) { + if (isFunction(ret == null ? void 0 : ret.then)) { + ret.then(next, reject); + return; + } + if (ret.done) { + return resolve(ret.value); + } + pendingPromise = Promise.resolve(ret.value); + return pendingPromise.then(onFulfilled, onRejected); + } + onFulfilled(void 0); + }); + promise.cancel = action(name + " - runid: " + runId + " - cancel", function() { + try { + if (pendingPromise) { + cancelPromise(pendingPromise); + } + var _res = gen["return"](void 0); + var yieldedPromise = Promise.resolve(_res.value); + yieldedPromise.then(noop, noop); + cancelPromise(yieldedPromise); + rejector(new FlowCancellationError()); + } catch (e33) { + rejector(e33); + } + }); + return promise; + }; + res.isMobXFlow = true; + return res; + }, flowAnnotation); + flow.bound = /* @__PURE__ */ createDecoratorAnnotation(flowBoundAnnotation); + function cancelPromise(promise) { + if (isFunction(promise.cancel)) { + promise.cancel(); + } + } + function isFlow(fn2) { + return (fn2 == null ? void 0 : fn2.isMobXFlow) === true; + } + function _isObservable(value, property) { + if (!value) { + return false; + } + if (property !== void 0) { + if (isObservableMap(value) || isObservableArray(value)) { + return die("isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead."); + } + if (isObservableObject(value)) { + return value[$mobx].values_.has(property); + } + return false; + } + return isObservableObject(value) || !!value[$mobx] || isAtom(value) || isReaction(value) || isComputedValue(value); + } + function isObservable(value) { + if (arguments.length !== 1) { + die("isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property"); + } + return _isObservable(value); + } + function trace() { + if (false) { + return; + } + var enterBreakPoint = false; + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + if (typeof args[args.length - 1] === "boolean") { + enterBreakPoint = args.pop(); + } + var derivation = getAtomFromArgs(args); + if (!derivation) { + return die("'trace(break?)' can only be used inside a tracked computed value or a Reaction. Consider passing in the computed value or reaction explicitly"); + } + if (derivation.isTracing_ === TraceMode.NONE) { + console.log("[mobx.trace] '" + derivation.name_ + "' tracing enabled"); + } + derivation.isTracing_ = enterBreakPoint ? TraceMode.BREAK : TraceMode.LOG; + } + function getAtomFromArgs(args) { + switch (args.length) { + case 0: + return globalState.trackingDerivation; + case 1: + return getAtom(args[0]); + case 2: + return getAtom(args[0], args[1]); + } + } + function transaction(action2, thisArg) { + if (thisArg === void 0) { + thisArg = void 0; + } + startBatch(); + try { + return action2.apply(thisArg); + } finally { + endBatch(); + } + } + function getAdm(target) { + return target[$mobx]; + } + var objectProxyTraps = { + has: function has(target, name) { + if (globalState.trackingDerivation) { + warnAboutProxyRequirement("detect new properties using the 'in' operator. Use 'has' from 'mobx' instead."); + } + return getAdm(target).has_(name); + }, + get: function get(target, name) { + return getAdm(target).get_(name); + }, + set: function set2(target, name, value) { + var _getAdm$set_; + if (!isStringish(name)) { + return false; + } + if (!getAdm(target).values_.has(name)) { + warnAboutProxyRequirement("add a new observable property through direct assignment. Use 'set' from 'mobx' instead."); + } + return (_getAdm$set_ = getAdm(target).set_(name, value, true)) != null ? _getAdm$set_ : true; + }, + deleteProperty: function deleteProperty(target, name) { + var _getAdm$delete_; + if (true) { + warnAboutProxyRequirement("delete properties from an observable object. Use 'remove' from 'mobx' instead."); + } + if (!isStringish(name)) { + return false; + } + return (_getAdm$delete_ = getAdm(target).delete_(name, true)) != null ? _getAdm$delete_ : true; + }, + defineProperty: function defineProperty2(target, name, descriptor) { + var _getAdm$definePropert; + if (true) { + warnAboutProxyRequirement("define property on an observable object. Use 'defineProperty' from 'mobx' instead."); + } + return (_getAdm$definePropert = getAdm(target).defineProperty_(name, descriptor)) != null ? _getAdm$definePropert : true; + }, + ownKeys: function ownKeys2(target) { + if (globalState.trackingDerivation) { + warnAboutProxyRequirement("iterate keys to detect added / removed properties. Use 'keys' from 'mobx' instead."); + } + return getAdm(target).ownKeys_(); + }, + preventExtensions: function preventExtensions(target) { + die(13); + } + }; + function asDynamicObservableObject(target, options) { + var _target$$mobx, _target$$mobx$proxy_; + assertProxies(); + target = asObservableObject(target, options); + return (_target$$mobx$proxy_ = (_target$$mobx = target[$mobx]).proxy_) != null ? _target$$mobx$proxy_ : _target$$mobx.proxy_ = new Proxy(target, objectProxyTraps); + } + function hasInterceptors(interceptable) { + return interceptable.interceptors_ !== void 0 && interceptable.interceptors_.length > 0; + } + function registerInterceptor(interceptable, handler) { + var interceptors = interceptable.interceptors_ || (interceptable.interceptors_ = []); + interceptors.push(handler); + return once(function() { + var idx = interceptors.indexOf(handler); + if (idx !== -1) { + interceptors.splice(idx, 1); + } + }); + } + function interceptChange(interceptable, change2) { + var prevU = untrackedStart(); + try { + var interceptors = [].concat(interceptable.interceptors_ || []); + for (var i23 = 0, l20 = interceptors.length; i23 < l20; i23++) { + change2 = interceptors[i23](change2); + if (change2 && !change2.type) { + die(14); + } + if (!change2) { + break; + } + } + return change2; + } finally { + untrackedEnd(prevU); + } + } + function hasListeners(listenable) { + return listenable.changeListeners_ !== void 0 && listenable.changeListeners_.length > 0; + } + function registerListener(listenable, handler) { + var listeners = listenable.changeListeners_ || (listenable.changeListeners_ = []); + listeners.push(handler); + return once(function() { + var idx = listeners.indexOf(handler); + if (idx !== -1) { + listeners.splice(idx, 1); + } + }); + } + function notifyListeners(listenable, change2) { + var prevU = untrackedStart(); + var listeners = listenable.changeListeners_; + if (!listeners) { + return; + } + listeners = listeners.slice(); + for (var i23 = 0, l20 = listeners.length; i23 < l20; i23++) { + listeners[i23](change2); + } + untrackedEnd(prevU); + } + function makeObservable(target, annotations, options) { + initObservable(function() { + var _annotations; + var adm = asObservableObject(target, options)[$mobx]; + if (annotations && target[storedAnnotationsSymbol]) { + die("makeObservable second arg must be nullish when using decorators. Mixing @decorator syntax with annotations is not supported."); + } + (_annotations = annotations) != null ? _annotations : annotations = collectStoredAnnotations(target); + ownKeys(annotations).forEach(function(key) { + return adm.make_(key, annotations[key]); + }); + }); + return target; + } + var SPLICE = "splice"; + var UPDATE = "update"; + var MAX_SPLICE_SIZE = 1e4; + var arrayTraps = { + get: function get2(target, name) { + var adm = target[$mobx]; + if (name === $mobx) { + return adm; + } + if (name === "length") { + return adm.getArrayLength_(); + } + if (typeof name === "string" && !isNaN(name)) { + return adm.get_(parseInt(name)); + } + if (hasProp(arrayExtensions, name)) { + return arrayExtensions[name]; + } + return target[name]; + }, + set: function set3(target, name, value) { + var adm = target[$mobx]; + if (name === "length") { + adm.setArrayLength_(value); + } + if (typeof name === "symbol" || isNaN(name)) { + target[name] = value; + } else { + adm.set_(parseInt(name), value); + } + return true; + }, + preventExtensions: function preventExtensions2() { + die(15); + } + }; + var ObservableArrayAdministration = /* @__PURE__ */ function() { + function ObservableArrayAdministration2(name, enhancer, owned_, legacyMode_) { + if (name === void 0) { + name = true ? "ObservableArray@" + getNextId() : "ObservableArray"; + } + this.owned_ = void 0; + this.legacyMode_ = void 0; + this.atom_ = void 0; + this.values_ = []; + this.interceptors_ = void 0; + this.changeListeners_ = void 0; + this.enhancer_ = void 0; + this.dehancer = void 0; + this.proxy_ = void 0; + this.lastKnownLength_ = 0; + this.owned_ = owned_; + this.legacyMode_ = legacyMode_; + this.atom_ = new Atom(name); + this.enhancer_ = function(newV, oldV) { + return enhancer(newV, oldV, true ? name + "[..]" : "ObservableArray[..]"); + }; + } + var _proto = ObservableArrayAdministration2.prototype; + _proto.dehanceValue_ = function dehanceValue_(value) { + if (this.dehancer !== void 0) { + return this.dehancer(value); + } + return value; + }; + _proto.dehanceValues_ = function dehanceValues_(values) { + if (this.dehancer !== void 0 && values.length > 0) { + return values.map(this.dehancer); + } + return values; + }; + _proto.intercept_ = function intercept_(handler) { + return registerInterceptor(this, handler); + }; + _proto.observe_ = function observe_(listener, fireImmediately) { + if (fireImmediately === void 0) { + fireImmediately = false; + } + if (fireImmediately) { + listener({ + observableKind: "array", + object: this.proxy_, + debugObjectName: this.atom_.name_, + type: "splice", + index: 0, + added: this.values_.slice(), + addedCount: this.values_.length, + removed: [], + removedCount: 0 + }); + } + return registerListener(this, listener); + }; + _proto.getArrayLength_ = function getArrayLength_() { + this.atom_.reportObserved(); + return this.values_.length; + }; + _proto.setArrayLength_ = function setArrayLength_(newLength) { + if (typeof newLength !== "number" || isNaN(newLength) || newLength < 0) { + die("Out of range: " + newLength); + } + var currentLength = this.values_.length; + if (newLength === currentLength) { + return; + } else if (newLength > currentLength) { + var newItems = new Array(newLength - currentLength); + for (var i23 = 0; i23 < newLength - currentLength; i23++) { + newItems[i23] = void 0; + } + this.spliceWithArray_(currentLength, 0, newItems); + } else { + this.spliceWithArray_(newLength, currentLength - newLength); + } + }; + _proto.updateArrayLength_ = function updateArrayLength_(oldLength, delta) { + if (oldLength !== this.lastKnownLength_) { + die(16); + } + this.lastKnownLength_ += delta; + if (this.legacyMode_ && delta > 0) { + reserveArrayBuffer(oldLength + delta + 1); + } + }; + _proto.spliceWithArray_ = function spliceWithArray_(index, deleteCount, newItems) { + var _this = this; + checkIfStateModificationsAreAllowed(this.atom_); + var length = this.values_.length; + if (index === void 0) { + index = 0; + } else if (index > length) { + index = length; + } else if (index < 0) { + index = Math.max(0, length + index); + } + if (arguments.length === 1) { + deleteCount = length - index; + } else if (deleteCount === void 0 || deleteCount === null) { + deleteCount = 0; + } else { + deleteCount = Math.max(0, Math.min(deleteCount, length - index)); + } + if (newItems === void 0) { + newItems = EMPTY_ARRAY; + } + if (hasInterceptors(this)) { + var change2 = interceptChange(this, { + object: this.proxy_, + type: SPLICE, + index, + removedCount: deleteCount, + added: newItems + }); + if (!change2) { + return EMPTY_ARRAY; + } + deleteCount = change2.removedCount; + newItems = change2.added; + } + newItems = newItems.length === 0 ? newItems : newItems.map(function(v6) { + return _this.enhancer_(v6, void 0); + }); + if (this.legacyMode_ || true) { + var lengthDelta = newItems.length - deleteCount; + this.updateArrayLength_(length, lengthDelta); + } + var res = this.spliceItemsIntoValues_(index, deleteCount, newItems); + if (deleteCount !== 0 || newItems.length !== 0) { + this.notifyArraySplice_(index, newItems, res); + } + return this.dehanceValues_(res); + }; + _proto.spliceItemsIntoValues_ = function spliceItemsIntoValues_(index, deleteCount, newItems) { + if (newItems.length < MAX_SPLICE_SIZE) { + var _this$values_; + return (_this$values_ = this.values_).splice.apply(_this$values_, [index, deleteCount].concat(newItems)); + } else { + var res = this.values_.slice(index, index + deleteCount); + var oldItems = this.values_.slice(index + deleteCount); + this.values_.length += newItems.length - deleteCount; + for (var i23 = 0; i23 < newItems.length; i23++) { + this.values_[index + i23] = newItems[i23]; + } + for (var _i = 0; _i < oldItems.length; _i++) { + this.values_[index + newItems.length + _i] = oldItems[_i]; + } + return res; + } + }; + _proto.notifyArrayChildUpdate_ = function notifyArrayChildUpdate_(index, newValue, oldValue) { + var notifySpy = !this.owned_ && isSpyEnabled(); + var notify = hasListeners(this); + var change2 = notify || notifySpy ? { + observableKind: "array", + object: this.proxy_, + type: UPDATE, + debugObjectName: this.atom_.name_, + index, + newValue, + oldValue + } : null; + if (notifySpy) { + spyReportStart(change2); + } + this.atom_.reportChanged(); + if (notify) { + notifyListeners(this, change2); + } + if (notifySpy) { + spyReportEnd(); + } + }; + _proto.notifyArraySplice_ = function notifyArraySplice_(index, added, removed) { + var notifySpy = !this.owned_ && isSpyEnabled(); + var notify = hasListeners(this); + var change2 = notify || notifySpy ? { + observableKind: "array", + object: this.proxy_, + debugObjectName: this.atom_.name_, + type: SPLICE, + index, + removed, + added, + removedCount: removed.length, + addedCount: added.length + } : null; + if (notifySpy) { + spyReportStart(change2); + } + this.atom_.reportChanged(); + if (notify) { + notifyListeners(this, change2); + } + if (notifySpy) { + spyReportEnd(); + } + }; + _proto.get_ = function get_(index) { + if (this.legacyMode_ && index >= this.values_.length) { + console.warn(true ? "[mobx.array] Attempt to read an array index (" + index + ") that is out of bounds (" + this.values_.length + "). Please check length first. Out of bound indices will not be tracked by MobX" : "[mobx] Out of bounds read: " + index); + return void 0; + } + this.atom_.reportObserved(); + return this.dehanceValue_(this.values_[index]); + }; + _proto.set_ = function set_(index, newValue) { + var values = this.values_; + if (this.legacyMode_ && index > values.length) { + die(17, index, values.length); + } + if (index < values.length) { + checkIfStateModificationsAreAllowed(this.atom_); + var oldValue = values[index]; + if (hasInterceptors(this)) { + var change2 = interceptChange(this, { + type: UPDATE, + object: this.proxy_, + index, + newValue + }); + if (!change2) { + return; + } + newValue = change2.newValue; + } + newValue = this.enhancer_(newValue, oldValue); + var changed = newValue !== oldValue; + if (changed) { + values[index] = newValue; + this.notifyArrayChildUpdate_(index, newValue, oldValue); + } + } else { + var newItems = new Array(index + 1 - values.length); + for (var i23 = 0; i23 < newItems.length - 1; i23++) { + newItems[i23] = void 0; + } + newItems[newItems.length - 1] = newValue; + this.spliceWithArray_(values.length, 0, newItems); + } + }; + return ObservableArrayAdministration2; + }(); + function createObservableArray(initialValues, enhancer, name, owned) { + if (name === void 0) { + name = true ? "ObservableArray@" + getNextId() : "ObservableArray"; + } + if (owned === void 0) { + owned = false; + } + assertProxies(); + return initObservable(function() { + var adm = new ObservableArrayAdministration(name, enhancer, owned, false); + addHiddenFinalProp(adm.values_, $mobx, adm); + var proxy = new Proxy(adm.values_, arrayTraps); + adm.proxy_ = proxy; + if (initialValues && initialValues.length) { + adm.spliceWithArray_(0, 0, initialValues); + } + return proxy; + }); + } + var arrayExtensions = { + clear: function clear() { + return this.splice(0); + }, + replace: function replace(newItems) { + var adm = this[$mobx]; + return adm.spliceWithArray_(0, adm.values_.length, newItems); + }, + // Used by JSON.stringify + toJSON: function toJSON() { + return this.slice(); + }, + /* + * functions that do alter the internal structure of the array, (based on lib.es6.d.ts) + * since these functions alter the inner structure of the array, the have side effects. + * Because the have side effects, they should not be used in computed function, + * and for that reason the do not call dependencyState.notifyObserved + */ + splice: function splice(index, deleteCount) { + for (var _len = arguments.length, newItems = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + newItems[_key - 2] = arguments[_key]; + } + var adm = this[$mobx]; + switch (arguments.length) { + case 0: + return []; + case 1: + return adm.spliceWithArray_(index); + case 2: + return adm.spliceWithArray_(index, deleteCount); + } + return adm.spliceWithArray_(index, deleteCount, newItems); + }, + spliceWithArray: function spliceWithArray(index, deleteCount, newItems) { + return this[$mobx].spliceWithArray_(index, deleteCount, newItems); + }, + push: function push() { + var adm = this[$mobx]; + for (var _len2 = arguments.length, items = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + items[_key2] = arguments[_key2]; + } + adm.spliceWithArray_(adm.values_.length, 0, items); + return adm.values_.length; + }, + pop: function pop() { + return this.splice(Math.max(this[$mobx].values_.length - 1, 0), 1)[0]; + }, + shift: function shift() { + return this.splice(0, 1)[0]; + }, + unshift: function unshift() { + var adm = this[$mobx]; + for (var _len3 = arguments.length, items = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + items[_key3] = arguments[_key3]; + } + adm.spliceWithArray_(0, 0, items); + return adm.values_.length; + }, + reverse: function reverse() { + if (globalState.trackingDerivation) { + die(37, "reverse"); + } + this.replace(this.slice().reverse()); + return this; + }, + sort: function sort() { + if (globalState.trackingDerivation) { + die(37, "sort"); + } + var copy = this.slice(); + copy.sort.apply(copy, arguments); + this.replace(copy); + return this; + }, + remove: function remove(value) { + var adm = this[$mobx]; + var idx = adm.dehanceValues_(adm.values_).indexOf(value); + if (idx > -1) { + this.splice(idx, 1); + return true; + } + return false; + } + }; + addArrayExtension("at", simpleFunc); + addArrayExtension("concat", simpleFunc); + addArrayExtension("flat", simpleFunc); + addArrayExtension("includes", simpleFunc); + addArrayExtension("indexOf", simpleFunc); + addArrayExtension("join", simpleFunc); + addArrayExtension("lastIndexOf", simpleFunc); + addArrayExtension("slice", simpleFunc); + addArrayExtension("toString", simpleFunc); + addArrayExtension("toLocaleString", simpleFunc); + addArrayExtension("toSorted", simpleFunc); + addArrayExtension("toSpliced", simpleFunc); + addArrayExtension("with", simpleFunc); + addArrayExtension("every", mapLikeFunc); + addArrayExtension("filter", mapLikeFunc); + addArrayExtension("find", mapLikeFunc); + addArrayExtension("findIndex", mapLikeFunc); + addArrayExtension("findLast", mapLikeFunc); + addArrayExtension("findLastIndex", mapLikeFunc); + addArrayExtension("flatMap", mapLikeFunc); + addArrayExtension("forEach", mapLikeFunc); + addArrayExtension("map", mapLikeFunc); + addArrayExtension("some", mapLikeFunc); + addArrayExtension("toReversed", mapLikeFunc); + addArrayExtension("reduce", reduceLikeFunc); + addArrayExtension("reduceRight", reduceLikeFunc); + function addArrayExtension(funcName, funcFactory) { + if (typeof Array.prototype[funcName] === "function") { + arrayExtensions[funcName] = funcFactory(funcName); + } + } + function simpleFunc(funcName) { + return function() { + var adm = this[$mobx]; + adm.atom_.reportObserved(); + var dehancedValues = adm.dehanceValues_(adm.values_); + return dehancedValues[funcName].apply(dehancedValues, arguments); + }; + } + function mapLikeFunc(funcName) { + return function(callback, thisArg) { + var _this2 = this; + var adm = this[$mobx]; + adm.atom_.reportObserved(); + var dehancedValues = adm.dehanceValues_(adm.values_); + return dehancedValues[funcName](function(element, index) { + return callback.call(thisArg, element, index, _this2); + }); + }; + } + function reduceLikeFunc(funcName) { + return function() { + var _this3 = this; + var adm = this[$mobx]; + adm.atom_.reportObserved(); + var dehancedValues = adm.dehanceValues_(adm.values_); + var callback = arguments[0]; + arguments[0] = function(accumulator, currentValue, index) { + return callback(accumulator, currentValue, index, _this3); + }; + return dehancedValues[funcName].apply(dehancedValues, arguments); + }; + } + var isObservableArrayAdministration = /* @__PURE__ */ createInstanceofPredicate("ObservableArrayAdministration", ObservableArrayAdministration); + function isObservableArray(thing) { + return isObject(thing) && isObservableArrayAdministration(thing[$mobx]); + } + var _Symbol$iterator; + var _Symbol$toStringTag; + var ObservableMapMarker = {}; + var ADD = "add"; + var DELETE = "delete"; + _Symbol$iterator = Symbol.iterator; + _Symbol$toStringTag = Symbol.toStringTag; + var ObservableMap = /* @__PURE__ */ function() { + function ObservableMap2(initialData, enhancer_, name_) { + var _this = this; + if (enhancer_ === void 0) { + enhancer_ = deepEnhancer; + } + if (name_ === void 0) { + name_ = true ? "ObservableMap@" + getNextId() : "ObservableMap"; + } + this.enhancer_ = void 0; + this.name_ = void 0; + this[$mobx] = ObservableMapMarker; + this.data_ = void 0; + this.hasMap_ = void 0; + this.keysAtom_ = void 0; + this.interceptors_ = void 0; + this.changeListeners_ = void 0; + this.dehancer = void 0; + this.enhancer_ = enhancer_; + this.name_ = name_; + if (!isFunction(Map)) { + die(18); + } + initObservable(function() { + _this.keysAtom_ = createAtom(true ? _this.name_ + ".keys()" : "ObservableMap.keys()"); + _this.data_ = /* @__PURE__ */ new Map(); + _this.hasMap_ = /* @__PURE__ */ new Map(); + if (initialData) { + _this.merge(initialData); + } + }); + } + var _proto = ObservableMap2.prototype; + _proto.has_ = function has_(key) { + return this.data_.has(key); + }; + _proto.has = function has2(key) { + var _this2 = this; + if (!globalState.trackingDerivation) { + return this.has_(key); + } + var entry = this.hasMap_.get(key); + if (!entry) { + var newEntry = entry = new ObservableValue(this.has_(key), referenceEnhancer, true ? this.name_ + "." + stringifyKey(key) + "?" : "ObservableMap.key?", false); + this.hasMap_.set(key, newEntry); + onBecomeUnobserved(newEntry, function() { + return _this2.hasMap_["delete"](key); + }); + } + return entry.get(); + }; + _proto.set = function set4(key, value) { + var hasKey = this.has_(key); + if (hasInterceptors(this)) { + var change2 = interceptChange(this, { + type: hasKey ? UPDATE : ADD, + object: this, + newValue: value, + name: key + }); + if (!change2) { + return this; + } + value = change2.newValue; + } + if (hasKey) { + this.updateValue_(key, value); + } else { + this.addValue_(key, value); + } + return this; + }; + _proto["delete"] = function _delete(key) { + var _this3 = this; + checkIfStateModificationsAreAllowed(this.keysAtom_); + if (hasInterceptors(this)) { + var change2 = interceptChange(this, { + type: DELETE, + object: this, + name: key + }); + if (!change2) { + return false; + } + } + if (this.has_(key)) { + var notifySpy = isSpyEnabled(); + var notify = hasListeners(this); + var _change = notify || notifySpy ? { + observableKind: "map", + debugObjectName: this.name_, + type: DELETE, + object: this, + oldValue: this.data_.get(key).value_, + name: key + } : null; + if (notifySpy) { + spyReportStart(_change); + } + transaction(function() { + var _this3$hasMap_$get; + _this3.keysAtom_.reportChanged(); + (_this3$hasMap_$get = _this3.hasMap_.get(key)) == null ? void 0 : _this3$hasMap_$get.setNewValue_(false); + var observable2 = _this3.data_.get(key); + observable2.setNewValue_(void 0); + _this3.data_["delete"](key); + }); + if (notify) { + notifyListeners(this, _change); + } + if (notifySpy) { + spyReportEnd(); + } + return true; + } + return false; + }; + _proto.updateValue_ = function updateValue_(key, newValue) { + var observable2 = this.data_.get(key); + newValue = observable2.prepareNewValue_(newValue); + if (newValue !== globalState.UNCHANGED) { + var notifySpy = isSpyEnabled(); + var notify = hasListeners(this); + var change2 = notify || notifySpy ? { + observableKind: "map", + debugObjectName: this.name_, + type: UPDATE, + object: this, + oldValue: observable2.value_, + name: key, + newValue + } : null; + if (notifySpy) { + spyReportStart(change2); + } + observable2.setNewValue_(newValue); + if (notify) { + notifyListeners(this, change2); + } + if (notifySpy) { + spyReportEnd(); + } + } + }; + _proto.addValue_ = function addValue_(key, newValue) { + var _this4 = this; + checkIfStateModificationsAreAllowed(this.keysAtom_); + transaction(function() { + var _this4$hasMap_$get; + var observable2 = new ObservableValue(newValue, _this4.enhancer_, true ? _this4.name_ + "." + stringifyKey(key) : "ObservableMap.key", false); + _this4.data_.set(key, observable2); + newValue = observable2.value_; + (_this4$hasMap_$get = _this4.hasMap_.get(key)) == null ? void 0 : _this4$hasMap_$get.setNewValue_(true); + _this4.keysAtom_.reportChanged(); + }); + var notifySpy = isSpyEnabled(); + var notify = hasListeners(this); + var change2 = notify || notifySpy ? { + observableKind: "map", + debugObjectName: this.name_, + type: ADD, + object: this, + name: key, + newValue + } : null; + if (notifySpy) { + spyReportStart(change2); + } + if (notify) { + notifyListeners(this, change2); + } + if (notifySpy) { + spyReportEnd(); + } + }; + _proto.get = function get3(key) { + if (this.has(key)) { + return this.dehanceValue_(this.data_.get(key).get()); + } + return this.dehanceValue_(void 0); + }; + _proto.dehanceValue_ = function dehanceValue_(value) { + if (this.dehancer !== void 0) { + return this.dehancer(value); + } + return value; + }; + _proto.keys = function keys() { + this.keysAtom_.reportObserved(); + return this.data_.keys(); + }; + _proto.values = function values() { + var self2 = this; + var keys = this.keys(); + return makeIterable({ + next: function next() { + var _keys$next = keys.next(), done = _keys$next.done, value = _keys$next.value; + return { + done, + value: done ? void 0 : self2.get(value) + }; + } + }); + }; + _proto.entries = function entries() { + var self2 = this; + var keys = this.keys(); + return makeIterable({ + next: function next() { + var _keys$next2 = keys.next(), done = _keys$next2.done, value = _keys$next2.value; + return { + done, + value: done ? void 0 : [value, self2.get(value)] + }; + } + }); + }; + _proto[_Symbol$iterator] = function() { + return this.entries(); + }; + _proto.forEach = function forEach(callback, thisArg) { + for (var _iterator = _createForOfIteratorHelperLoose(this), _step; !(_step = _iterator()).done; ) { + var _step$value = _step.value, key = _step$value[0], value = _step$value[1]; + callback.call(thisArg, value, key, this); + } + }; + _proto.merge = function merge(other) { + var _this5 = this; + if (isObservableMap(other)) { + other = new Map(other); + } + transaction(function() { + if (isPlainObject(other)) { + getPlainObjectKeys(other).forEach(function(key) { + return _this5.set(key, other[key]); + }); + } else if (Array.isArray(other)) { + other.forEach(function(_ref) { + var key = _ref[0], value = _ref[1]; + return _this5.set(key, value); + }); + } else if (isES6Map(other)) { + if (other.constructor !== Map) { + die(19, other); + } + other.forEach(function(value, key) { + return _this5.set(key, value); + }); + } else if (other !== null && other !== void 0) { + die(20, other); + } + }); + return this; + }; + _proto.clear = function clear2() { + var _this6 = this; + transaction(function() { + untracked(function() { + for (var _iterator2 = _createForOfIteratorHelperLoose(_this6.keys()), _step2; !(_step2 = _iterator2()).done; ) { + var key = _step2.value; + _this6["delete"](key); + } + }); + }); + }; + _proto.replace = function replace2(values) { + var _this7 = this; + transaction(function() { + var replacementMap = convertToMap(values); + var orderedData = /* @__PURE__ */ new Map(); + var keysReportChangedCalled = false; + for (var _iterator3 = _createForOfIteratorHelperLoose(_this7.data_.keys()), _step3; !(_step3 = _iterator3()).done; ) { + var key = _step3.value; + if (!replacementMap.has(key)) { + var deleted = _this7["delete"](key); + if (deleted) { + keysReportChangedCalled = true; + } else { + var value = _this7.data_.get(key); + orderedData.set(key, value); + } + } + } + for (var _iterator4 = _createForOfIteratorHelperLoose(replacementMap.entries()), _step4; !(_step4 = _iterator4()).done; ) { + var _step4$value = _step4.value, _key = _step4$value[0], _value = _step4$value[1]; + var keyExisted = _this7.data_.has(_key); + _this7.set(_key, _value); + if (_this7.data_.has(_key)) { + var _value2 = _this7.data_.get(_key); + orderedData.set(_key, _value2); + if (!keyExisted) { + keysReportChangedCalled = true; + } + } + } + if (!keysReportChangedCalled) { + if (_this7.data_.size !== orderedData.size) { + _this7.keysAtom_.reportChanged(); + } else { + var iter1 = _this7.data_.keys(); + var iter2 = orderedData.keys(); + var next1 = iter1.next(); + var next2 = iter2.next(); + while (!next1.done) { + if (next1.value !== next2.value) { + _this7.keysAtom_.reportChanged(); + break; + } + next1 = iter1.next(); + next2 = iter2.next(); + } + } + } + _this7.data_ = orderedData; + }); + return this; + }; + _proto.toString = function toString2() { + return "[object ObservableMap]"; + }; + _proto.toJSON = function toJSON2() { + return Array.from(this); + }; + _proto.observe_ = function observe_(listener, fireImmediately) { + if (fireImmediately === true) { + die("`observe` doesn't support fireImmediately=true in combination with maps."); + } + return registerListener(this, listener); + }; + _proto.intercept_ = function intercept_(handler) { + return registerInterceptor(this, handler); + }; + _createClass(ObservableMap2, [{ + key: "size", + get: function get3() { + this.keysAtom_.reportObserved(); + return this.data_.size; + } + }, { + key: _Symbol$toStringTag, + get: function get3() { + return "Map"; + } + }]); + return ObservableMap2; + }(); + var isObservableMap = /* @__PURE__ */ createInstanceofPredicate("ObservableMap", ObservableMap); + function convertToMap(dataStructure) { + if (isES6Map(dataStructure) || isObservableMap(dataStructure)) { + return dataStructure; + } else if (Array.isArray(dataStructure)) { + return new Map(dataStructure); + } else if (isPlainObject(dataStructure)) { + var map2 = /* @__PURE__ */ new Map(); + for (var key in dataStructure) { + map2.set(key, dataStructure[key]); + } + return map2; + } else { + return die(21, dataStructure); + } + } + var _Symbol$iterator$1; + var _Symbol$toStringTag$1; + var ObservableSetMarker = {}; + _Symbol$iterator$1 = Symbol.iterator; + _Symbol$toStringTag$1 = Symbol.toStringTag; + var ObservableSet = /* @__PURE__ */ function() { + function ObservableSet2(initialData, enhancer, name_) { + var _this = this; + if (enhancer === void 0) { + enhancer = deepEnhancer; + } + if (name_ === void 0) { + name_ = true ? "ObservableSet@" + getNextId() : "ObservableSet"; + } + this.name_ = void 0; + this[$mobx] = ObservableSetMarker; + this.data_ = /* @__PURE__ */ new Set(); + this.atom_ = void 0; + this.changeListeners_ = void 0; + this.interceptors_ = void 0; + this.dehancer = void 0; + this.enhancer_ = void 0; + this.name_ = name_; + if (!isFunction(Set)) { + die(22); + } + this.enhancer_ = function(newV, oldV) { + return enhancer(newV, oldV, name_); + }; + initObservable(function() { + _this.atom_ = createAtom(_this.name_); + if (initialData) { + _this.replace(initialData); + } + }); + } + var _proto = ObservableSet2.prototype; + _proto.dehanceValue_ = function dehanceValue_(value) { + if (this.dehancer !== void 0) { + return this.dehancer(value); + } + return value; + }; + _proto.clear = function clear2() { + var _this2 = this; + transaction(function() { + untracked(function() { + for (var _iterator = _createForOfIteratorHelperLoose(_this2.data_.values()), _step; !(_step = _iterator()).done; ) { + var value = _step.value; + _this2["delete"](value); + } + }); + }); + }; + _proto.forEach = function forEach(callbackFn, thisArg) { + for (var _iterator2 = _createForOfIteratorHelperLoose(this), _step2; !(_step2 = _iterator2()).done; ) { + var value = _step2.value; + callbackFn.call(thisArg, value, value, this); + } + }; + _proto.add = function add(value) { + var _this3 = this; + checkIfStateModificationsAreAllowed(this.atom_); + if (hasInterceptors(this)) { + var change2 = interceptChange(this, { + type: ADD, + object: this, + newValue: value + }); + if (!change2) { + return this; + } + } + if (!this.has(value)) { + transaction(function() { + _this3.data_.add(_this3.enhancer_(value, void 0)); + _this3.atom_.reportChanged(); + }); + var notifySpy = isSpyEnabled(); + var notify = hasListeners(this); + var _change = notify || notifySpy ? { + observableKind: "set", + debugObjectName: this.name_, + type: ADD, + object: this, + newValue: value + } : null; + if (notifySpy && true) { + spyReportStart(_change); + } + if (notify) { + notifyListeners(this, _change); + } + if (notifySpy && true) { + spyReportEnd(); + } + } + return this; + }; + _proto["delete"] = function _delete(value) { + var _this4 = this; + if (hasInterceptors(this)) { + var change2 = interceptChange(this, { + type: DELETE, + object: this, + oldValue: value + }); + if (!change2) { + return false; + } + } + if (this.has(value)) { + var notifySpy = isSpyEnabled(); + var notify = hasListeners(this); + var _change2 = notify || notifySpy ? { + observableKind: "set", + debugObjectName: this.name_, + type: DELETE, + object: this, + oldValue: value + } : null; + if (notifySpy && true) { + spyReportStart(_change2); + } + transaction(function() { + _this4.atom_.reportChanged(); + _this4.data_["delete"](value); + }); + if (notify) { + notifyListeners(this, _change2); + } + if (notifySpy && true) { + spyReportEnd(); + } + return true; + } + return false; + }; + _proto.has = function has2(value) { + this.atom_.reportObserved(); + return this.data_.has(this.dehanceValue_(value)); + }; + _proto.entries = function entries() { + var nextIndex = 0; + var keys = Array.from(this.keys()); + var values = Array.from(this.values()); + return makeIterable({ + next: function next() { + var index = nextIndex; + nextIndex += 1; + return index < values.length ? { + value: [keys[index], values[index]], + done: false + } : { + done: true + }; + } + }); + }; + _proto.keys = function keys() { + return this.values(); + }; + _proto.values = function values() { + this.atom_.reportObserved(); + var self2 = this; + var nextIndex = 0; + var observableValues = Array.from(this.data_.values()); + return makeIterable({ + next: function next() { + return nextIndex < observableValues.length ? { + value: self2.dehanceValue_(observableValues[nextIndex++]), + done: false + } : { + done: true + }; + } + }); + }; + _proto.replace = function replace2(other) { + var _this5 = this; + if (isObservableSet(other)) { + other = new Set(other); + } + transaction(function() { + if (Array.isArray(other)) { + _this5.clear(); + other.forEach(function(value) { + return _this5.add(value); + }); + } else if (isES6Set(other)) { + _this5.clear(); + other.forEach(function(value) { + return _this5.add(value); + }); + } else if (other !== null && other !== void 0) { + die("Cannot initialize set from " + other); + } + }); + return this; + }; + _proto.observe_ = function observe_(listener, fireImmediately) { + if (fireImmediately === true) { + die("`observe` doesn't support fireImmediately=true in combination with sets."); + } + return registerListener(this, listener); + }; + _proto.intercept_ = function intercept_(handler) { + return registerInterceptor(this, handler); + }; + _proto.toJSON = function toJSON2() { + return Array.from(this); + }; + _proto.toString = function toString2() { + return "[object ObservableSet]"; + }; + _proto[_Symbol$iterator$1] = function() { + return this.values(); + }; + _createClass(ObservableSet2, [{ + key: "size", + get: function get3() { + this.atom_.reportObserved(); + return this.data_.size; + } + }, { + key: _Symbol$toStringTag$1, + get: function get3() { + return "Set"; + } + }]); + return ObservableSet2; + }(); + var isObservableSet = /* @__PURE__ */ createInstanceofPredicate("ObservableSet", ObservableSet); + var descriptorCache = /* @__PURE__ */ Object.create(null); + var REMOVE = "remove"; + var ObservableObjectAdministration = /* @__PURE__ */ function() { + function ObservableObjectAdministration2(target_, values_, name_, defaultAnnotation_) { + if (values_ === void 0) { + values_ = /* @__PURE__ */ new Map(); + } + if (defaultAnnotation_ === void 0) { + defaultAnnotation_ = autoAnnotation; + } + this.target_ = void 0; + this.values_ = void 0; + this.name_ = void 0; + this.defaultAnnotation_ = void 0; + this.keysAtom_ = void 0; + this.changeListeners_ = void 0; + this.interceptors_ = void 0; + this.proxy_ = void 0; + this.isPlainObject_ = void 0; + this.appliedAnnotations_ = void 0; + this.pendingKeys_ = void 0; + this.target_ = target_; + this.values_ = values_; + this.name_ = name_; + this.defaultAnnotation_ = defaultAnnotation_; + this.keysAtom_ = new Atom(true ? this.name_ + ".keys" : "ObservableObject.keys"); + this.isPlainObject_ = isPlainObject(this.target_); + if (!isAnnotation(this.defaultAnnotation_)) { + die("defaultAnnotation must be valid annotation"); + } + if (true) { + this.appliedAnnotations_ = {}; + } + } + var _proto = ObservableObjectAdministration2.prototype; + _proto.getObservablePropValue_ = function getObservablePropValue_(key) { + return this.values_.get(key).get(); + }; + _proto.setObservablePropValue_ = function setObservablePropValue_(key, newValue) { + var observable2 = this.values_.get(key); + if (observable2 instanceof ComputedValue) { + observable2.set(newValue); + return true; + } + if (hasInterceptors(this)) { + var change2 = interceptChange(this, { + type: UPDATE, + object: this.proxy_ || this.target_, + name: key, + newValue + }); + if (!change2) { + return null; + } + newValue = change2.newValue; + } + newValue = observable2.prepareNewValue_(newValue); + if (newValue !== globalState.UNCHANGED) { + var notify = hasListeners(this); + var notifySpy = isSpyEnabled(); + var _change = notify || notifySpy ? { + type: UPDATE, + observableKind: "object", + debugObjectName: this.name_, + object: this.proxy_ || this.target_, + oldValue: observable2.value_, + name: key, + newValue + } : null; + if (notifySpy) { + spyReportStart(_change); + } + observable2.setNewValue_(newValue); + if (notify) { + notifyListeners(this, _change); + } + if (notifySpy) { + spyReportEnd(); + } + } + return true; + }; + _proto.get_ = function get_(key) { + if (globalState.trackingDerivation && !hasProp(this.target_, key)) { + this.has_(key); + } + return this.target_[key]; + }; + _proto.set_ = function set_(key, value, proxyTrap) { + if (proxyTrap === void 0) { + proxyTrap = false; + } + if (hasProp(this.target_, key)) { + if (this.values_.has(key)) { + return this.setObservablePropValue_(key, value); + } else if (proxyTrap) { + return Reflect.set(this.target_, key, value); + } else { + this.target_[key] = value; + return true; + } + } else { + return this.extend_(key, { + value, + enumerable: true, + writable: true, + configurable: true + }, this.defaultAnnotation_, proxyTrap); + } + }; + _proto.has_ = function has_(key) { + if (!globalState.trackingDerivation) { + return key in this.target_; + } + this.pendingKeys_ || (this.pendingKeys_ = /* @__PURE__ */ new Map()); + var entry = this.pendingKeys_.get(key); + if (!entry) { + entry = new ObservableValue(key in this.target_, referenceEnhancer, true ? this.name_ + "." + stringifyKey(key) + "?" : "ObservableObject.key?", false); + this.pendingKeys_.set(key, entry); + } + return entry.get(); + }; + _proto.make_ = function make_(key, annotation) { + if (annotation === true) { + annotation = this.defaultAnnotation_; + } + if (annotation === false) { + return; + } + assertAnnotable(this, annotation, key); + if (!(key in this.target_)) { + var _this$target_$storedA; + if ((_this$target_$storedA = this.target_[storedAnnotationsSymbol]) != null && _this$target_$storedA[key]) { + return; + } else { + die(1, annotation.annotationType_, this.name_ + "." + key.toString()); + } + } + var source = this.target_; + while (source && source !== objectPrototype) { + var descriptor = getDescriptor(source, key); + if (descriptor) { + var outcome = annotation.make_(this, key, descriptor, source); + if (outcome === 0) { + return; + } + if (outcome === 1) { + break; + } + } + source = Object.getPrototypeOf(source); + } + recordAnnotationApplied(this, annotation, key); + }; + _proto.extend_ = function extend_(key, descriptor, annotation, proxyTrap) { + if (proxyTrap === void 0) { + proxyTrap = false; + } + if (annotation === true) { + annotation = this.defaultAnnotation_; + } + if (annotation === false) { + return this.defineProperty_(key, descriptor, proxyTrap); + } + assertAnnotable(this, annotation, key); + var outcome = annotation.extend_(this, key, descriptor, proxyTrap); + if (outcome) { + recordAnnotationApplied(this, annotation, key); + } + return outcome; + }; + _proto.defineProperty_ = function defineProperty_(key, descriptor, proxyTrap) { + if (proxyTrap === void 0) { + proxyTrap = false; + } + checkIfStateModificationsAreAllowed(this.keysAtom_); + try { + startBatch(); + var deleteOutcome = this.delete_(key); + if (!deleteOutcome) { + return deleteOutcome; + } + if (hasInterceptors(this)) { + var change2 = interceptChange(this, { + object: this.proxy_ || this.target_, + name: key, + type: ADD, + newValue: descriptor.value + }); + if (!change2) { + return null; + } + var newValue = change2.newValue; + if (descriptor.value !== newValue) { + descriptor = _extends({}, descriptor, { + value: newValue + }); + } + } + if (proxyTrap) { + if (!Reflect.defineProperty(this.target_, key, descriptor)) { + return false; + } + } else { + defineProperty(this.target_, key, descriptor); + } + this.notifyPropertyAddition_(key, descriptor.value); + } finally { + endBatch(); + } + return true; + }; + _proto.defineObservableProperty_ = function defineObservableProperty_(key, value, enhancer, proxyTrap) { + if (proxyTrap === void 0) { + proxyTrap = false; + } + checkIfStateModificationsAreAllowed(this.keysAtom_); + try { + startBatch(); + var deleteOutcome = this.delete_(key); + if (!deleteOutcome) { + return deleteOutcome; + } + if (hasInterceptors(this)) { + var change2 = interceptChange(this, { + object: this.proxy_ || this.target_, + name: key, + type: ADD, + newValue: value + }); + if (!change2) { + return null; + } + value = change2.newValue; + } + var cachedDescriptor = getCachedObservablePropDescriptor(key); + var descriptor = { + configurable: globalState.safeDescriptors ? this.isPlainObject_ : true, + enumerable: true, + get: cachedDescriptor.get, + set: cachedDescriptor.set + }; + if (proxyTrap) { + if (!Reflect.defineProperty(this.target_, key, descriptor)) { + return false; + } + } else { + defineProperty(this.target_, key, descriptor); + } + var observable2 = new ObservableValue(value, enhancer, true ? this.name_ + "." + key.toString() : "ObservableObject.key", false); + this.values_.set(key, observable2); + this.notifyPropertyAddition_(key, observable2.value_); + } finally { + endBatch(); + } + return true; + }; + _proto.defineComputedProperty_ = function defineComputedProperty_(key, options, proxyTrap) { + if (proxyTrap === void 0) { + proxyTrap = false; + } + checkIfStateModificationsAreAllowed(this.keysAtom_); + try { + startBatch(); + var deleteOutcome = this.delete_(key); + if (!deleteOutcome) { + return deleteOutcome; + } + if (hasInterceptors(this)) { + var change2 = interceptChange(this, { + object: this.proxy_ || this.target_, + name: key, + type: ADD, + newValue: void 0 + }); + if (!change2) { + return null; + } + } + options.name || (options.name = true ? this.name_ + "." + key.toString() : "ObservableObject.key"); + options.context = this.proxy_ || this.target_; + var cachedDescriptor = getCachedObservablePropDescriptor(key); + var descriptor = { + configurable: globalState.safeDescriptors ? this.isPlainObject_ : true, + enumerable: false, + get: cachedDescriptor.get, + set: cachedDescriptor.set + }; + if (proxyTrap) { + if (!Reflect.defineProperty(this.target_, key, descriptor)) { + return false; + } + } else { + defineProperty(this.target_, key, descriptor); + } + this.values_.set(key, new ComputedValue(options)); + this.notifyPropertyAddition_(key, void 0); + } finally { + endBatch(); + } + return true; + }; + _proto.delete_ = function delete_(key, proxyTrap) { + if (proxyTrap === void 0) { + proxyTrap = false; + } + checkIfStateModificationsAreAllowed(this.keysAtom_); + if (!hasProp(this.target_, key)) { + return true; + } + if (hasInterceptors(this)) { + var change2 = interceptChange(this, { + object: this.proxy_ || this.target_, + name: key, + type: REMOVE + }); + if (!change2) { + return null; + } + } + try { + var _this$pendingKeys_, _this$pendingKeys_$ge; + startBatch(); + var notify = hasListeners(this); + var notifySpy = isSpyEnabled(); + var observable2 = this.values_.get(key); + var value = void 0; + if (!observable2 && (notify || notifySpy)) { + var _getDescriptor2; + value = (_getDescriptor2 = getDescriptor(this.target_, key)) == null ? void 0 : _getDescriptor2.value; + } + if (proxyTrap) { + if (!Reflect.deleteProperty(this.target_, key)) { + return false; + } + } else { + delete this.target_[key]; + } + if (true) { + delete this.appliedAnnotations_[key]; + } + if (observable2) { + this.values_["delete"](key); + if (observable2 instanceof ObservableValue) { + value = observable2.value_; + } + propagateChanged(observable2); + } + this.keysAtom_.reportChanged(); + (_this$pendingKeys_ = this.pendingKeys_) == null ? void 0 : (_this$pendingKeys_$ge = _this$pendingKeys_.get(key)) == null ? void 0 : _this$pendingKeys_$ge.set(key in this.target_); + if (notify || notifySpy) { + var _change2 = { + type: REMOVE, + observableKind: "object", + object: this.proxy_ || this.target_, + debugObjectName: this.name_, + oldValue: value, + name: key + }; + if (notifySpy) { + spyReportStart(_change2); + } + if (notify) { + notifyListeners(this, _change2); + } + if (notifySpy) { + spyReportEnd(); + } + } + } finally { + endBatch(); + } + return true; + }; + _proto.observe_ = function observe_(callback, fireImmediately) { + if (fireImmediately === true) { + die("`observe` doesn't support the fire immediately property for observable objects."); + } + return registerListener(this, callback); + }; + _proto.intercept_ = function intercept_(handler) { + return registerInterceptor(this, handler); + }; + _proto.notifyPropertyAddition_ = function notifyPropertyAddition_(key, value) { + var _this$pendingKeys_2, _this$pendingKeys_2$g; + var notify = hasListeners(this); + var notifySpy = isSpyEnabled(); + if (notify || notifySpy) { + var change2 = notify || notifySpy ? { + type: ADD, + observableKind: "object", + debugObjectName: this.name_, + object: this.proxy_ || this.target_, + name: key, + newValue: value + } : null; + if (notifySpy) { + spyReportStart(change2); + } + if (notify) { + notifyListeners(this, change2); + } + if (notifySpy) { + spyReportEnd(); + } + } + (_this$pendingKeys_2 = this.pendingKeys_) == null ? void 0 : (_this$pendingKeys_2$g = _this$pendingKeys_2.get(key)) == null ? void 0 : _this$pendingKeys_2$g.set(true); + this.keysAtom_.reportChanged(); + }; + _proto.ownKeys_ = function ownKeys_() { + this.keysAtom_.reportObserved(); + return ownKeys(this.target_); + }; + _proto.keys_ = function keys_() { + this.keysAtom_.reportObserved(); + return Object.keys(this.target_); + }; + return ObservableObjectAdministration2; + }(); + function asObservableObject(target, options) { + var _options$name; + if (options && isObservableObject(target)) { + die("Options can't be provided for already observable objects."); + } + if (hasProp(target, $mobx)) { + if (!(getAdministration(target) instanceof ObservableObjectAdministration)) { + die("Cannot convert '" + getDebugName(target) + "' into observable object:\nThe target is already observable of different type.\nExtending builtins is not supported."); + } + return target; + } + if (!Object.isExtensible(target)) { + die("Cannot make the designated object observable; it is not extensible"); + } + var name = (_options$name = options == null ? void 0 : options.name) != null ? _options$name : true ? (isPlainObject(target) ? "ObservableObject" : target.constructor.name) + "@" + getNextId() : "ObservableObject"; + var adm = new ObservableObjectAdministration(target, /* @__PURE__ */ new Map(), String(name), getAnnotationFromOptions(options)); + addHiddenProp(target, $mobx, adm); + return target; + } + var isObservableObjectAdministration = /* @__PURE__ */ createInstanceofPredicate("ObservableObjectAdministration", ObservableObjectAdministration); + function getCachedObservablePropDescriptor(key) { + return descriptorCache[key] || (descriptorCache[key] = { + get: function get3() { + return this[$mobx].getObservablePropValue_(key); + }, + set: function set4(value) { + return this[$mobx].setObservablePropValue_(key, value); + } + }); + } + function isObservableObject(thing) { + if (isObject(thing)) { + return isObservableObjectAdministration(thing[$mobx]); + } + return false; + } + function recordAnnotationApplied(adm, annotation, key) { + var _adm$target_$storedAn; + if (true) { + adm.appliedAnnotations_[key] = annotation; + } + (_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null ? true : delete _adm$target_$storedAn[key]; + } + function assertAnnotable(adm, annotation, key) { + if (!isAnnotation(annotation)) { + die("Cannot annotate '" + adm.name_ + "." + key.toString() + "': Invalid annotation."); + } + if (!isOverride(annotation) && hasProp(adm.appliedAnnotations_, key)) { + var fieldName = adm.name_ + "." + key.toString(); + var currentAnnotationType = adm.appliedAnnotations_[key].annotationType_; + var requestedAnnotationType = annotation.annotationType_; + die("Cannot apply '" + requestedAnnotationType + "' to '" + fieldName + "':" + ("\nThe field is already annotated with '" + currentAnnotationType + "'.") + "\nRe-annotating fields is not allowed.\nUse 'override' annotation for methods overridden by subclass."); + } + } + var ENTRY_0 = /* @__PURE__ */ createArrayEntryDescriptor(0); + var safariPrototypeSetterInheritanceBug = /* @__PURE__ */ function() { + var v6 = false; + var p7 = {}; + Object.defineProperty(p7, "0", { + set: function set4() { + v6 = true; + } + }); + Object.create(p7)["0"] = 1; + return v6 === false; + }(); + var OBSERVABLE_ARRAY_BUFFER_SIZE = 0; + var StubArray = function StubArray2() { + }; + function inherit(ctor, proto) { + if (Object.setPrototypeOf) { + Object.setPrototypeOf(ctor.prototype, proto); + } else if (ctor.prototype.__proto__ !== void 0) { + ctor.prototype.__proto__ = proto; + } else { + ctor.prototype = proto; + } + } + inherit(StubArray, Array.prototype); + var LegacyObservableArray = /* @__PURE__ */ function(_StubArray, _Symbol$toStringTag2, _Symbol$iterator2) { + _inheritsLoose(LegacyObservableArray2, _StubArray); + function LegacyObservableArray2(initialValues, enhancer, name, owned) { + var _this; + if (name === void 0) { + name = true ? "ObservableArray@" + getNextId() : "ObservableArray"; + } + if (owned === void 0) { + owned = false; + } + _this = _StubArray.call(this) || this; + initObservable(function() { + var adm = new ObservableArrayAdministration(name, enhancer, owned, true); + adm.proxy_ = _assertThisInitialized(_this); + addHiddenFinalProp(_assertThisInitialized(_this), $mobx, adm); + if (initialValues && initialValues.length) { + _this.spliceWithArray(0, 0, initialValues); + } + if (safariPrototypeSetterInheritanceBug) { + Object.defineProperty(_assertThisInitialized(_this), "0", ENTRY_0); + } + }); + return _this; + } + var _proto = LegacyObservableArray2.prototype; + _proto.concat = function concat() { + this[$mobx].atom_.reportObserved(); + for (var _len = arguments.length, arrays = new Array(_len), _key = 0; _key < _len; _key++) { + arrays[_key] = arguments[_key]; + } + return Array.prototype.concat.apply( + this.slice(), + //@ts-ignore + arrays.map(function(a11) { + return isObservableArray(a11) ? a11.slice() : a11; + }) + ); + }; + _proto[_Symbol$iterator2] = function() { + var self2 = this; + var nextIndex = 0; + return makeIterable({ + next: function next() { + return nextIndex < self2.length ? { + value: self2[nextIndex++], + done: false + } : { + done: true, + value: void 0 + }; + } + }); + }; + _createClass(LegacyObservableArray2, [{ + key: "length", + get: function get3() { + return this[$mobx].getArrayLength_(); + }, + set: function set4(newLength) { + this[$mobx].setArrayLength_(newLength); + } + }, { + key: _Symbol$toStringTag2, + get: function get3() { + return "Array"; + } + }]); + return LegacyObservableArray2; + }(StubArray, Symbol.toStringTag, Symbol.iterator); + Object.entries(arrayExtensions).forEach(function(_ref) { + var prop = _ref[0], fn2 = _ref[1]; + if (prop !== "concat") { + addHiddenProp(LegacyObservableArray.prototype, prop, fn2); + } + }); + function createArrayEntryDescriptor(index) { + return { + enumerable: false, + configurable: true, + get: function get3() { + return this[$mobx].get_(index); + }, + set: function set4(value) { + this[$mobx].set_(index, value); + } + }; + } + function createArrayBufferItem(index) { + defineProperty(LegacyObservableArray.prototype, "" + index, createArrayEntryDescriptor(index)); + } + function reserveArrayBuffer(max) { + if (max > OBSERVABLE_ARRAY_BUFFER_SIZE) { + for (var index = OBSERVABLE_ARRAY_BUFFER_SIZE; index < max + 100; index++) { + createArrayBufferItem(index); + } + OBSERVABLE_ARRAY_BUFFER_SIZE = max; + } + } + reserveArrayBuffer(1e3); + function createLegacyArray(initialValues, enhancer, name) { + return new LegacyObservableArray(initialValues, enhancer, name); + } + function getAtom(thing, property) { + if (typeof thing === "object" && thing !== null) { + if (isObservableArray(thing)) { + if (property !== void 0) { + die(23); + } + return thing[$mobx].atom_; + } + if (isObservableSet(thing)) { + return thing.atom_; + } + if (isObservableMap(thing)) { + if (property === void 0) { + return thing.keysAtom_; + } + var observable2 = thing.data_.get(property) || thing.hasMap_.get(property); + if (!observable2) { + die(25, property, getDebugName(thing)); + } + return observable2; + } + if (isObservableObject(thing)) { + if (!property) { + return die(26); + } + var _observable = thing[$mobx].values_.get(property); + if (!_observable) { + die(27, property, getDebugName(thing)); + } + return _observable; + } + if (isAtom(thing) || isComputedValue(thing) || isReaction(thing)) { + return thing; + } + } else if (isFunction(thing)) { + if (isReaction(thing[$mobx])) { + return thing[$mobx]; + } + } + die(28); + } + function getAdministration(thing, property) { + if (!thing) { + die(29); + } + if (property !== void 0) { + return getAdministration(getAtom(thing, property)); + } + if (isAtom(thing) || isComputedValue(thing) || isReaction(thing)) { + return thing; + } + if (isObservableMap(thing) || isObservableSet(thing)) { + return thing; + } + if (thing[$mobx]) { + return thing[$mobx]; + } + die(24, thing); + } + function getDebugName(thing, property) { + var named; + if (property !== void 0) { + named = getAtom(thing, property); + } else if (isAction(thing)) { + return thing.name; + } else if (isObservableObject(thing) || isObservableMap(thing) || isObservableSet(thing)) { + named = getAdministration(thing); + } else { + named = getAtom(thing); + } + return named.name_; + } + function initObservable(cb) { + var derivation = untrackedStart(); + var allowStateChanges = allowStateChangesStart(true); + startBatch(); + try { + return cb(); + } finally { + endBatch(); + allowStateChangesEnd(allowStateChanges); + untrackedEnd(derivation); + } + } + var toString = objectPrototype.toString; + function deepEqual(a11, b7, depth) { + if (depth === void 0) { + depth = -1; + } + return eq(a11, b7, depth); + } + function eq(a11, b7, depth, aStack, bStack) { + if (a11 === b7) { + return a11 !== 0 || 1 / a11 === 1 / b7; + } + if (a11 == null || b7 == null) { + return false; + } + if (a11 !== a11) { + return b7 !== b7; + } + var type = typeof a11; + if (type !== "function" && type !== "object" && typeof b7 != "object") { + return false; + } + var className = toString.call(a11); + if (className !== toString.call(b7)) { + return false; + } + switch (className) { + case "[object RegExp]": + case "[object String]": + return "" + a11 === "" + b7; + case "[object Number]": + if (+a11 !== +a11) { + return +b7 !== +b7; + } + return +a11 === 0 ? 1 / +a11 === 1 / b7 : +a11 === +b7; + case "[object Date]": + case "[object Boolean]": + return +a11 === +b7; + case "[object Symbol]": + return typeof Symbol !== "undefined" && Symbol.valueOf.call(a11) === Symbol.valueOf.call(b7); + case "[object Map]": + case "[object Set]": + if (depth >= 0) { + depth++; + } + break; + } + a11 = unwrap(a11); + b7 = unwrap(b7); + var areArrays = className === "[object Array]"; + if (!areArrays) { + if (typeof a11 != "object" || typeof b7 != "object") { + return false; + } + var aCtor = a11.constructor, bCtor = b7.constructor; + if (aCtor !== bCtor && !(isFunction(aCtor) && aCtor instanceof aCtor && isFunction(bCtor) && bCtor instanceof bCtor) && "constructor" in a11 && "constructor" in b7) { + return false; + } + } + if (depth === 0) { + return false; + } else if (depth < 0) { + depth = -1; + } + aStack = aStack || []; + bStack = bStack || []; + var length = aStack.length; + while (length--) { + if (aStack[length] === a11) { + return bStack[length] === b7; + } + } + aStack.push(a11); + bStack.push(b7); + if (areArrays) { + length = a11.length; + if (length !== b7.length) { + return false; + } + while (length--) { + if (!eq(a11[length], b7[length], depth - 1, aStack, bStack)) { + return false; + } + } + } else { + var keys = Object.keys(a11); + var key; + length = keys.length; + if (Object.keys(b7).length !== length) { + return false; + } + while (length--) { + key = keys[length]; + if (!(hasProp(b7, key) && eq(a11[key], b7[key], depth - 1, aStack, bStack))) { + return false; + } + } + } + aStack.pop(); + bStack.pop(); + return true; + } + function unwrap(a11) { + if (isObservableArray(a11)) { + return a11.slice(); + } + if (isES6Map(a11) || isObservableMap(a11)) { + return Array.from(a11.entries()); + } + if (isES6Set(a11) || isObservableSet(a11)) { + return Array.from(a11.entries()); + } + return a11; + } + function makeIterable(iterator) { + iterator[Symbol.iterator] = getSelf; + return iterator; + } + function getSelf() { + return this; + } + function isAnnotation(thing) { + return ( + // Can be function + thing instanceof Object && typeof thing.annotationType_ === "string" && isFunction(thing.make_) && isFunction(thing.extend_) + ); + } + ["Symbol", "Map", "Set"].forEach(function(m6) { + var g6 = getGlobal(); + if (typeof g6[m6] === "undefined") { + die("MobX requires global '" + m6 + "' to be available or polyfilled"); + } + }); + if (typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__ === "object") { + __MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({ + spy, + extras: { + getDebugName + }, + $mobx + }); + } + + // node_modules/@adobe/lit-mobx/lib/mixin.js + function MobxReactionUpdate(constructor) { + return MobxReactionUpdateCustom(constructor, Reaction); + } + + // node_modules/@lit/reactive-element/css-tag.js + var t = globalThis; + var e = t.ShadowRoot && (void 0 === t.ShadyCSS || t.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype; + var s = Symbol(); + var o = /* @__PURE__ */ new WeakMap(); + var n = class { + constructor(t17, e33, o29) { + if (this._$cssResult$ = true, o29 !== s) + throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); + this.cssText = t17, this.t = e33; + } + get styleSheet() { + let t17 = this.o; + const s20 = this.t; + if (e && void 0 === t17) { + const e33 = void 0 !== s20 && 1 === s20.length; + e33 && (t17 = o.get(s20)), void 0 === t17 && ((this.o = t17 = new CSSStyleSheet()).replaceSync(this.cssText), e33 && o.set(s20, t17)); + } + return t17; + } + toString() { + return this.cssText; + } + }; + var r = (t17) => new n("string" == typeof t17 ? t17 : t17 + "", void 0, s); + var i = (t17, ...e33) => { + const o29 = 1 === t17.length ? t17[0] : e33.reduce((e34, s20, o30) => e34 + ((t18) => { + if (true === t18._$cssResult$) + return t18.cssText; + if ("number" == typeof t18) + return t18; + throw Error("Value passed to 'css' function must be a 'css' function result: " + t18 + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security."); + })(s20) + t17[o30 + 1], t17[0]); + return new n(o29, t17, s); + }; + var S = (s20, o29) => { + if (e) + s20.adoptedStyleSheets = o29.map((t17) => t17 instanceof CSSStyleSheet ? t17 : t17.styleSheet); + else + for (const e33 of o29) { + const o30 = document.createElement("style"), n31 = t.litNonce; + void 0 !== n31 && o30.setAttribute("nonce", n31), o30.textContent = e33.cssText, s20.appendChild(o30); + } + }; + var c = e ? (t17) => t17 : (t17) => t17 instanceof CSSStyleSheet ? ((t18) => { + let e33 = ""; + for (const s20 of t18.cssRules) + e33 += s20.cssText; + return r(e33); + })(t17) : t17; + + // node_modules/@lit/reactive-element/reactive-element.js + var { is: i3, defineProperty: e2, getOwnPropertyDescriptor: r2, getOwnPropertyNames: h, getOwnPropertySymbols: o2, getPrototypeOf: n2 } = Object; + var a = globalThis; + var c2 = a.trustedTypes; + var l = c2 ? c2.emptyScript : ""; + var p = a.reactiveElementPolyfillSupport; + var d = (t17, s20) => t17; + var u = { toAttribute(t17, s20) { + switch (s20) { + case Boolean: + t17 = t17 ? l : null; + break; + case Object: + case Array: + t17 = null == t17 ? t17 : JSON.stringify(t17); + } + return t17; + }, fromAttribute(t17, s20) { + let i23 = t17; + switch (s20) { + case Boolean: + i23 = null !== t17; + break; + case Number: + i23 = null === t17 ? null : Number(t17); + break; + case Object: + case Array: + try { + i23 = JSON.parse(t17); + } catch (t18) { + i23 = null; + } + } + return i23; + } }; + var f = (t17, s20) => !i3(t17, s20); + var y = { attribute: true, type: String, converter: u, reflect: false, hasChanged: f }; + Symbol.metadata ??= Symbol("metadata"), a.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap(); + var b = class extends HTMLElement { + static addInitializer(t17) { + this._$Ei(), (this.l ??= []).push(t17); + } + static get observedAttributes() { + return this.finalize(), this._$Eh && [...this._$Eh.keys()]; + } + static createProperty(t17, s20 = y) { + if (s20.state && (s20.attribute = false), this._$Ei(), this.elementProperties.set(t17, s20), !s20.noAccessor) { + const i23 = Symbol(), r18 = this.getPropertyDescriptor(t17, i23, s20); + void 0 !== r18 && e2(this.prototype, t17, r18); + } + } + static getPropertyDescriptor(t17, s20, i23) { + const { get: e33, set: h11 } = r2(this.prototype, t17) ?? { get() { + return this[s20]; + }, set(t18) { + this[s20] = t18; + } }; + return { get() { + return e33?.call(this); + }, set(s21) { + const r18 = e33?.call(this); + h11.call(this, s21), this.requestUpdate(t17, r18, i23); + }, configurable: true, enumerable: true }; + } + static getPropertyOptions(t17) { + return this.elementProperties.get(t17) ?? y; + } + static _$Ei() { + if (this.hasOwnProperty(d("elementProperties"))) + return; + const t17 = n2(this); + t17.finalize(), void 0 !== t17.l && (this.l = [...t17.l]), this.elementProperties = new Map(t17.elementProperties); + } + static finalize() { + if (this.hasOwnProperty(d("finalized"))) + return; + if (this.finalized = true, this._$Ei(), this.hasOwnProperty(d("properties"))) { + const t18 = this.properties, s20 = [...h(t18), ...o2(t18)]; + for (const i23 of s20) + this.createProperty(i23, t18[i23]); + } + const t17 = this[Symbol.metadata]; + if (null !== t17) { + const s20 = litPropertyMetadata.get(t17); + if (void 0 !== s20) + for (const [t18, i23] of s20) + this.elementProperties.set(t18, i23); + } + this._$Eh = /* @__PURE__ */ new Map(); + for (const [t18, s20] of this.elementProperties) { + const i23 = this._$Eu(t18, s20); + void 0 !== i23 && this._$Eh.set(i23, t18); + } + this.elementStyles = this.finalizeStyles(this.styles); + } + static finalizeStyles(s20) { + const i23 = []; + if (Array.isArray(s20)) { + const e33 = new Set(s20.flat(1 / 0).reverse()); + for (const s21 of e33) + i23.unshift(c(s21)); + } else + void 0 !== s20 && i23.push(c(s20)); + return i23; + } + static _$Eu(t17, s20) { + const i23 = s20.attribute; + return false === i23 ? void 0 : "string" == typeof i23 ? i23 : "string" == typeof t17 ? t17.toLowerCase() : void 0; + } + constructor() { + super(), this._$Ep = void 0, this.isUpdatePending = false, this.hasUpdated = false, this._$Em = null, this._$Ev(); + } + _$Ev() { + this._$ES = new Promise((t17) => this.enableUpdating = t17), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach((t17) => t17(this)); + } + addController(t17) { + (this._$EO ??= /* @__PURE__ */ new Set()).add(t17), void 0 !== this.renderRoot && this.isConnected && t17.hostConnected?.(); + } + removeController(t17) { + this._$EO?.delete(t17); + } + _$E_() { + const t17 = /* @__PURE__ */ new Map(), s20 = this.constructor.elementProperties; + for (const i23 of s20.keys()) + this.hasOwnProperty(i23) && (t17.set(i23, this[i23]), delete this[i23]); + t17.size > 0 && (this._$Ep = t17); + } + createRenderRoot() { + const t17 = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions); + return S(t17, this.constructor.elementStyles), t17; + } + connectedCallback() { + this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(true), this._$EO?.forEach((t17) => t17.hostConnected?.()); + } + enableUpdating(t17) { + } + disconnectedCallback() { + this._$EO?.forEach((t17) => t17.hostDisconnected?.()); + } + attributeChangedCallback(t17, s20, i23) { + this._$AK(t17, i23); + } + _$EC(t17, s20) { + const i23 = this.constructor.elementProperties.get(t17), e33 = this.constructor._$Eu(t17, i23); + if (void 0 !== e33 && true === i23.reflect) { + const r18 = (void 0 !== i23.converter?.toAttribute ? i23.converter : u).toAttribute(s20, i23.type); + this._$Em = t17, null == r18 ? this.removeAttribute(e33) : this.setAttribute(e33, r18), this._$Em = null; + } + } + _$AK(t17, s20) { + const i23 = this.constructor, e33 = i23._$Eh.get(t17); + if (void 0 !== e33 && this._$Em !== e33) { + const t18 = i23.getPropertyOptions(e33), r18 = "function" == typeof t18.converter ? { fromAttribute: t18.converter } : void 0 !== t18.converter?.fromAttribute ? t18.converter : u; + this._$Em = e33, this[e33] = r18.fromAttribute(s20, t18.type), this._$Em = null; + } + } + requestUpdate(t17, s20, i23) { + if (void 0 !== t17) { + if (i23 ??= this.constructor.getPropertyOptions(t17), !(i23.hasChanged ?? f)(this[t17], s20)) + return; + this.P(t17, s20, i23); + } + false === this.isUpdatePending && (this._$ES = this._$ET()); + } + P(t17, s20, i23) { + this._$AL.has(t17) || this._$AL.set(t17, s20), true === i23.reflect && this._$Em !== t17 && (this._$Ej ??= /* @__PURE__ */ new Set()).add(t17); + } + async _$ET() { + this.isUpdatePending = true; + try { + await this._$ES; + } catch (t18) { + Promise.reject(t18); + } + const t17 = this.scheduleUpdate(); + return null != t17 && await t17, !this.isUpdatePending; + } + scheduleUpdate() { + return this.performUpdate(); + } + performUpdate() { + if (!this.isUpdatePending) + return; + if (!this.hasUpdated) { + if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) { + for (const [t19, s21] of this._$Ep) + this[t19] = s21; + this._$Ep = void 0; + } + const t18 = this.constructor.elementProperties; + if (t18.size > 0) + for (const [s21, i23] of t18) + true !== i23.wrapped || this._$AL.has(s21) || void 0 === this[s21] || this.P(s21, this[s21], i23); + } + let t17 = false; + const s20 = this._$AL; + try { + t17 = this.shouldUpdate(s20), t17 ? (this.willUpdate(s20), this._$EO?.forEach((t18) => t18.hostUpdate?.()), this.update(s20)) : this._$EU(); + } catch (s21) { + throw t17 = false, this._$EU(), s21; + } + t17 && this._$AE(s20); + } + willUpdate(t17) { + } + _$AE(t17) { + this._$EO?.forEach((t18) => t18.hostUpdated?.()), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t17)), this.updated(t17); + } + _$EU() { + this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = false; + } + get updateComplete() { + return this.getUpdateComplete(); + } + getUpdateComplete() { + return this._$ES; + } + shouldUpdate(t17) { + return true; + } + update(t17) { + this._$Ej &&= this._$Ej.forEach((t18) => this._$EC(t18, this[t18])), this._$EU(); + } + updated(t17) { + } + firstUpdated(t17) { + } + }; + b.elementStyles = [], b.shadowRootOptions = { mode: "open" }, b[d("elementProperties")] = /* @__PURE__ */ new Map(), b[d("finalized")] = /* @__PURE__ */ new Map(), p?.({ ReactiveElement: b }), (a.reactiveElementVersions ??= []).push("2.0.4"); + + // node_modules/lit-html/lit-html.js + var t2 = globalThis; + var i4 = t2.trustedTypes; + var s2 = i4 ? i4.createPolicy("lit-html", { createHTML: (t17) => t17 }) : void 0; + var e3 = "$lit$"; + var h2 = `lit$${Math.random().toFixed(9).slice(2)}$`; + var o3 = "?" + h2; + var n3 = `<${o3}>`; + var r3 = document; + var l2 = () => r3.createComment(""); + var c3 = (t17) => null === t17 || "object" != typeof t17 && "function" != typeof t17; + var a2 = Array.isArray; + var u2 = (t17) => a2(t17) || "function" == typeof t17?.[Symbol.iterator]; + var d2 = "[ \n\f\r]"; + var f2 = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g; + var v = /-->/g; + var _14 = />/g; + var m = RegExp(`>|${d2}(?:([^\\s"'>=/]+)(${d2}*=${d2}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`, "g"); + var p2 = /'/g; + var g = /"/g; + var $ = /^(?:script|style|textarea|title)$/i; + var y2 = (t17) => (i23, ...s20) => ({ _$litType$: t17, strings: i23, values: s20 }); + var x = y2(1); + var b2 = y2(2); + var w = Symbol.for("lit-noChange"); + var T = Symbol.for("lit-nothing"); + var A = /* @__PURE__ */ new WeakMap(); + var E = r3.createTreeWalker(r3, 129); + function C(t17, i23) { + if (!Array.isArray(t17) || !t17.hasOwnProperty("raw")) + throw Error("invalid template strings array"); + return void 0 !== s2 ? s2.createHTML(i23) : i23; + } + var P = (t17, i23) => { + const s20 = t17.length - 1, o29 = []; + let r18, l20 = 2 === i23 ? "" : "", c12 = f2; + for (let i24 = 0; i24 < s20; i24++) { + const s21 = t17[i24]; + let a11, u11, d11 = -1, y7 = 0; + for (; y7 < s21.length && (c12.lastIndex = y7, u11 = c12.exec(s21), null !== u11); ) + y7 = c12.lastIndex, c12 === f2 ? "!--" === u11[1] ? c12 = v : void 0 !== u11[1] ? c12 = _14 : void 0 !== u11[2] ? ($.test(u11[2]) && (r18 = RegExp("" === u11[0] ? (c12 = r18 ?? f2, d11 = -1) : void 0 === u11[1] ? d11 = -2 : (d11 = c12.lastIndex - u11[2].length, a11 = u11[1], c12 = void 0 === u11[3] ? m : '"' === u11[3] ? g : p2) : c12 === g || c12 === p2 ? c12 = m : c12 === v || c12 === _14 ? c12 = f2 : (c12 = m, r18 = void 0); + const x6 = c12 === m && t17[i24 + 1].startsWith("/>") ? " " : ""; + l20 += c12 === f2 ? s21 + n3 : d11 >= 0 ? (o29.push(a11), s21.slice(0, d11) + e3 + s21.slice(d11) + h2 + x6) : s21 + h2 + (-2 === d11 ? i24 : x6); + } + return [C(t17, l20 + (t17[s20] || "") + (2 === i23 ? "" : "")), o29]; + }; + var V = class _V { + constructor({ strings: t17, _$litType$: s20 }, n31) { + let r18; + this.parts = []; + let c12 = 0, a11 = 0; + const u11 = t17.length - 1, d11 = this.parts, [f7, v6] = P(t17, s20); + if (this.el = _V.createElement(f7, n31), E.currentNode = this.el.content, 2 === s20) { + const t18 = this.el.content.firstChild; + t18.replaceWith(...t18.childNodes); + } + for (; null !== (r18 = E.nextNode()) && d11.length < u11; ) { + if (1 === r18.nodeType) { + if (r18.hasAttributes()) + for (const t18 of r18.getAttributeNames()) + if (t18.endsWith(e3)) { + const i23 = v6[a11++], s21 = r18.getAttribute(t18).split(h2), e33 = /([.?@])?(.*)/.exec(i23); + d11.push({ type: 1, index: c12, name: e33[2], strings: s21, ctor: "." === e33[1] ? k3 : "?" === e33[1] ? H : "@" === e33[1] ? I : R }), r18.removeAttribute(t18); + } else + t18.startsWith(h2) && (d11.push({ type: 6, index: c12 }), r18.removeAttribute(t18)); + if ($.test(r18.tagName)) { + const t18 = r18.textContent.split(h2), s21 = t18.length - 1; + if (s21 > 0) { + r18.textContent = i4 ? i4.emptyScript : ""; + for (let i23 = 0; i23 < s21; i23++) + r18.append(t18[i23], l2()), E.nextNode(), d11.push({ type: 2, index: ++c12 }); + r18.append(t18[s21], l2()); + } + } + } else if (8 === r18.nodeType) + if (r18.data === o3) + d11.push({ type: 2, index: c12 }); + else { + let t18 = -1; + for (; -1 !== (t18 = r18.data.indexOf(h2, t18 + 1)); ) + d11.push({ type: 7, index: c12 }), t18 += h2.length - 1; + } + c12++; + } + } + static createElement(t17, i23) { + const s20 = r3.createElement("template"); + return s20.innerHTML = t17, s20; + } + }; + function N(t17, i23, s20 = t17, e33) { + if (i23 === w) + return i23; + let h11 = void 0 !== e33 ? s20._$Co?.[e33] : s20._$Cl; + const o29 = c3(i23) ? void 0 : i23._$litDirective$; + return h11?.constructor !== o29 && (h11?._$AO?.(false), void 0 === o29 ? h11 = void 0 : (h11 = new o29(t17), h11._$AT(t17, s20, e33)), void 0 !== e33 ? (s20._$Co ??= [])[e33] = h11 : s20._$Cl = h11), void 0 !== h11 && (i23 = N(t17, h11._$AS(t17, i23.values), h11, e33)), i23; + } + var S2 = class { + constructor(t17, i23) { + this._$AV = [], this._$AN = void 0, this._$AD = t17, this._$AM = i23; + } + get parentNode() { + return this._$AM.parentNode; + } + get _$AU() { + return this._$AM._$AU; + } + u(t17) { + const { el: { content: i23 }, parts: s20 } = this._$AD, e33 = (t17?.creationScope ?? r3).importNode(i23, true); + E.currentNode = e33; + let h11 = E.nextNode(), o29 = 0, n31 = 0, l20 = s20[0]; + for (; void 0 !== l20; ) { + if (o29 === l20.index) { + let i24; + 2 === l20.type ? i24 = new M(h11, h11.nextSibling, this, t17) : 1 === l20.type ? i24 = new l20.ctor(h11, l20.name, l20.strings, this, t17) : 6 === l20.type && (i24 = new L(h11, this, t17)), this._$AV.push(i24), l20 = s20[++n31]; + } + o29 !== l20?.index && (h11 = E.nextNode(), o29++); + } + return E.currentNode = r3, e33; + } + p(t17) { + let i23 = 0; + for (const s20 of this._$AV) + void 0 !== s20 && (void 0 !== s20.strings ? (s20._$AI(t17, s20, i23), i23 += s20.strings.length - 2) : s20._$AI(t17[i23])), i23++; + } + }; + var M = class _M { + get _$AU() { + return this._$AM?._$AU ?? this._$Cv; + } + constructor(t17, i23, s20, e33) { + this.type = 2, this._$AH = T, this._$AN = void 0, this._$AA = t17, this._$AB = i23, this._$AM = s20, this.options = e33, this._$Cv = e33?.isConnected ?? true; + } + get parentNode() { + let t17 = this._$AA.parentNode; + const i23 = this._$AM; + return void 0 !== i23 && 11 === t17?.nodeType && (t17 = i23.parentNode), t17; + } + get startNode() { + return this._$AA; + } + get endNode() { + return this._$AB; + } + _$AI(t17, i23 = this) { + t17 = N(this, t17, i23), c3(t17) ? t17 === T || null == t17 || "" === t17 ? (this._$AH !== T && this._$AR(), this._$AH = T) : t17 !== this._$AH && t17 !== w && this._(t17) : void 0 !== t17._$litType$ ? this.$(t17) : void 0 !== t17.nodeType ? this.T(t17) : u2(t17) ? this.k(t17) : this._(t17); + } + S(t17) { + return this._$AA.parentNode.insertBefore(t17, this._$AB); + } + T(t17) { + this._$AH !== t17 && (this._$AR(), this._$AH = this.S(t17)); + } + _(t17) { + this._$AH !== T && c3(this._$AH) ? this._$AA.nextSibling.data = t17 : this.T(r3.createTextNode(t17)), this._$AH = t17; + } + $(t17) { + const { values: i23, _$litType$: s20 } = t17, e33 = "number" == typeof s20 ? this._$AC(t17) : (void 0 === s20.el && (s20.el = V.createElement(C(s20.h, s20.h[0]), this.options)), s20); + if (this._$AH?._$AD === e33) + this._$AH.p(i23); + else { + const t18 = new S2(e33, this), s21 = t18.u(this.options); + t18.p(i23), this.T(s21), this._$AH = t18; + } + } + _$AC(t17) { + let i23 = A.get(t17.strings); + return void 0 === i23 && A.set(t17.strings, i23 = new V(t17)), i23; + } + k(t17) { + a2(this._$AH) || (this._$AH = [], this._$AR()); + const i23 = this._$AH; + let s20, e33 = 0; + for (const h11 of t17) + e33 === i23.length ? i23.push(s20 = new _M(this.S(l2()), this.S(l2()), this, this.options)) : s20 = i23[e33], s20._$AI(h11), e33++; + e33 < i23.length && (this._$AR(s20 && s20._$AB.nextSibling, e33), i23.length = e33); + } + _$AR(t17 = this._$AA.nextSibling, i23) { + for (this._$AP?.(false, true, i23); t17 && t17 !== this._$AB; ) { + const i24 = t17.nextSibling; + t17.remove(), t17 = i24; + } + } + setConnected(t17) { + void 0 === this._$AM && (this._$Cv = t17, this._$AP?.(t17)); + } + }; + var R = class { + get tagName() { + return this.element.tagName; + } + get _$AU() { + return this._$AM._$AU; + } + constructor(t17, i23, s20, e33, h11) { + this.type = 1, this._$AH = T, this._$AN = void 0, this.element = t17, this.name = i23, this._$AM = e33, this.options = h11, s20.length > 2 || "" !== s20[0] || "" !== s20[1] ? (this._$AH = Array(s20.length - 1).fill(new String()), this.strings = s20) : this._$AH = T; + } + _$AI(t17, i23 = this, s20, e33) { + const h11 = this.strings; + let o29 = false; + if (void 0 === h11) + t17 = N(this, t17, i23, 0), o29 = !c3(t17) || t17 !== this._$AH && t17 !== w, o29 && (this._$AH = t17); + else { + const e34 = t17; + let n31, r18; + for (t17 = h11[0], n31 = 0; n31 < h11.length - 1; n31++) + r18 = N(this, e34[s20 + n31], i23, n31), r18 === w && (r18 = this._$AH[n31]), o29 ||= !c3(r18) || r18 !== this._$AH[n31], r18 === T ? t17 = T : t17 !== T && (t17 += (r18 ?? "") + h11[n31 + 1]), this._$AH[n31] = r18; + } + o29 && !e33 && this.j(t17); + } + j(t17) { + t17 === T ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t17 ?? ""); + } + }; + var k3 = class extends R { + constructor() { + super(...arguments), this.type = 3; + } + j(t17) { + this.element[this.name] = t17 === T ? void 0 : t17; + } + }; + var H = class extends R { + constructor() { + super(...arguments), this.type = 4; + } + j(t17) { + this.element.toggleAttribute(this.name, !!t17 && t17 !== T); + } + }; + var I = class extends R { + constructor(t17, i23, s20, e33, h11) { + super(t17, i23, s20, e33, h11), this.type = 5; + } + _$AI(t17, i23 = this) { + if ((t17 = N(this, t17, i23, 0) ?? T) === w) + return; + const s20 = this._$AH, e33 = t17 === T && s20 !== T || t17.capture !== s20.capture || t17.once !== s20.once || t17.passive !== s20.passive, h11 = t17 !== T && (s20 === T || e33); + e33 && this.element.removeEventListener(this.name, this, s20), h11 && this.element.addEventListener(this.name, this, t17), this._$AH = t17; + } + handleEvent(t17) { + "function" == typeof this._$AH ? this._$AH.call(this.options?.host ?? this.element, t17) : this._$AH.handleEvent(t17); + } + }; + var L = class { + constructor(t17, i23, s20) { + this.element = t17, this.type = 6, this._$AN = void 0, this._$AM = i23, this.options = s20; + } + get _$AU() { + return this._$AM._$AU; + } + _$AI(t17) { + N(this, t17); + } + }; + var Z = t2.litHtmlPolyfillSupport; + Z?.(V, M), (t2.litHtmlVersions ??= []).push("3.1.3"); + var j = (t17, i23, s20) => { + const e33 = s20?.renderBefore ?? i23; + let h11 = e33._$litPart$; + if (void 0 === h11) { + const t18 = s20?.renderBefore ?? null; + e33._$litPart$ = h11 = new M(i23.insertBefore(l2(), t18), t18, void 0, s20 ?? {}); + } + return h11._$AI(t17), h11; + }; + + // node_modules/lit-element/lit-element.js + var s3 = class extends b { + constructor() { + super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0; + } + createRenderRoot() { + const t17 = super.createRenderRoot(); + return this.renderOptions.renderBefore ??= t17.firstChild, t17; + } + update(t17) { + const i23 = this.render(); + this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t17), this._$Do = j(i23, this.renderRoot, this.renderOptions); + } + connectedCallback() { + super.connectedCallback(), this._$Do?.setConnected(true); + } + disconnectedCallback() { + super.disconnectedCallback(), this._$Do?.setConnected(false); + } + render() { + return w; + } + }; + s3._$litElement$ = true, s3["finalized", "finalized"] = true, globalThis.litElementHydrateSupport?.({ LitElement: s3 }); + var r4 = globalThis.litElementPolyfillSupport; + r4?.({ LitElement: s3 }); + (globalThis.litElementVersions ??= []).push("4.0.5"); + + // node_modules/@adobe/lit-mobx/lit-mobx.js + var MobxLitElement = class extends MobxReactionUpdate(s3) { + }; + + // node_modules/@lit/reactive-element/decorators/custom-element.js + var t3 = (t17) => (e33, o29) => { + void 0 !== o29 ? o29.addInitializer(() => { + customElements.define(t17, e33); + }) : customElements.define(t17, e33); + }; + + // node_modules/@lit/reactive-element/decorators/property.js + var o4 = { attribute: true, type: String, converter: u, reflect: false, hasChanged: f }; + var r5 = (t17 = o4, e33, r18) => { + const { kind: n31, metadata: i23 } = r18; + let s20 = globalThis.litPropertyMetadata.get(i23); + if (void 0 === s20 && globalThis.litPropertyMetadata.set(i23, s20 = /* @__PURE__ */ new Map()), s20.set(r18.name, t17), "accessor" === n31) { + const { name: o29 } = r18; + return { set(r19) { + const n32 = e33.get.call(this); + e33.set.call(this, r19), this.requestUpdate(o29, n32, t17); + }, init(e34) { + return void 0 !== e34 && this.P(o29, void 0, t17), e34; + } }; + } + if ("setter" === n31) { + const { name: o29 } = r18; + return function(r19) { + const n32 = this[o29]; + e33.call(this, r19), this.requestUpdate(o29, n32, t17); + }; + } + throw Error("Unsupported decorator location: " + n31); + }; + function n4(t17) { + return (e33, o29) => "object" == typeof o29 ? r5(t17, e33, o29) : ((t18, e34, o30) => { + const r18 = e34.hasOwnProperty(o30); + return e34.constructor.createProperty(o30, r18 ? { ...t18, wrapped: true } : t18), r18 ? Object.getOwnPropertyDescriptor(e34, o30) : void 0; + })(t17, e33, o29); + } + + // node_modules/lit-html/directive.js + var t4 = { ATTRIBUTE: 1, CHILD: 2, PROPERTY: 3, BOOLEAN_ATTRIBUTE: 4, EVENT: 5, ELEMENT: 6 }; + var e5 = (t17) => (...e33) => ({ _$litDirective$: t17, values: e33 }); + var i5 = class { + constructor(t17) { + } + get _$AU() { + return this._$AM._$AU; + } + _$AT(t17, e33, i23) { + this._$Ct = t17, this._$AM = e33, this._$Ci = i23; + } + _$AS(t17, e33) { + return this.update(t17, e33); + } + update(t17, e33) { + return this.render(...e33); + } + }; + + // node_modules/lit-html/directives/class-map.js + var e6 = e5(class extends i5 { + constructor(t17) { + if (super(t17), t17.type !== t4.ATTRIBUTE || "class" !== t17.name || t17.strings?.length > 2) + throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute."); + } + render(t17) { + return " " + Object.keys(t17).filter((s20) => t17[s20]).join(" ") + " "; + } + update(s20, [i23]) { + if (void 0 === this.st) { + this.st = /* @__PURE__ */ new Set(), void 0 !== s20.strings && (this.nt = new Set(s20.strings.join(" ").split(/\s/).filter((t17) => "" !== t17))); + for (const t17 in i23) + i23[t17] && !this.nt?.has(t17) && this.st.add(t17); + return this.render(i23); + } + const r18 = s20.element.classList; + for (const t17 of this.st) + t17 in i23 || (r18.remove(t17), this.st.delete(t17)); + for (const t17 in i23) { + const s21 = !!i23[t17]; + s21 === this.st.has(t17) || this.nt?.has(t17) || (s21 ? (r18.add(t17), this.st.add(t17)) : (r18.remove(t17), this.st.delete(t17))); + } + return w; + } + }); + + // client/lib/shared_styles.css + var styles = i`:host { + color: #111; + font-family: 'Google Sans Text', 'Roboto', sans-serif; + /* LINT.IfChange */ + font-size: 12px; + /* LINT.ThenChange(./constants.ts) */ + scrollbar-width: thin; + + /* TODO(b/305091034): Clean up color variables */ + --comparator-model-a: #4684d7; + --comparator-model-b: #c78901; + --comparator-model-a-win: #2291df; + --comparator-model-b-win: #cb6a20; + --comparator-model-a-win-bg: #2291df10; + --comparator-model-b-win-bg: #cb6a2010; + --comparator-model-a-win-bg-darker: #2291df30; + --comparator-model-b-win-bg-darker: #cb6a2030; + + --comparator-grey-100: #f7f7f7; + --comparator-grey-150: #f3f3f3; + --comparator-grey-200: #eeeeee; + --comparator-grey-250: #dddddd; + --comparator-grey-300: #cccccc; + --comparator-grey-400: #aaaaaa; + --comparator-grey-450: #919191; + --comparator-grey-500: #777777; + --comparator-grey-600: #5c5c5c; + --comparator-grey-800: #333333; + + --comparator-greygreen-100: #f0f2f0; + --comparator-greygreen-200: #eaecea; + --comparator-greygreen-300: #d1eed1; + --comparator-greygreen-700: #335533; + + --comparator-greyblue-300: #828082; + + --comparator-green-100: #f8fff8; + --comparator-green-200: #f3f9f3; + --comparator-green-500: #339c33; + + --comparator-custom-func-100: #fbf7ff; + --comparator-custom-func-200: #f2e7f9; + --comparator-custom-func-500: #aa7fd1; + --comparator-custom-func-800: #8622df; + + --comparator-search-match-background: #ffff9d; + --comparator-search-match-foreground: #b73092; + + --comparator-popup-color: #db68cc; +} + +::-webkit-scrollbar { + background-color: transparent; + height: 10px; + width: 10px; +} + +::-webkit-scrollbar-thumb { + background-color: var(--comparator-grey-250); + border-radius: 5px; +} + +::-webkit-scrollbar-thumb:hover { + background-color: var(--comparator-grey-300); + border-radius: 5px; +} + +table { + border-collapse: collapse; + table-layout: fixed; +} + +ul { + margin: 0; + padding-left: 12px; +} + +.clickable { + cursor: pointer; +} + +#container { + display: flex; + flex-direction: column; + height: 100vh; +} + +#main { + display: flex; + flex-grow: 1; + height: calc(100vh - 50px); +} + +#main-panel { + display: flex; + flex-direction: column; + flex-grow: 1; + overflow-x: auto; +} + +#main-table { + flex: 1; +} + +#example-details { + border-top: 3px solid var(--comparator-grey-300); + height: 40%; + overflow-y: hidden; +} + +#example-details.expanded { + height: 80%; +} + +.table-panel { + overflow-y: scroll; + padding-left: 15px; +} + +/* Header */ +#header { + align-items: center; + background-color: white; + border-bottom: 2px solid var(--comparator-grey-250); + color: var(--comparator-grey-800); + display: flex; + height: 32px; + padding: 9px 12px 7px 28px; +} + +h1 { + font-size: 20px; + font-weight: 500; + margin: 0 25px 0 10px; +} + +.selected-dataset-path { + border-radius: 10px; + cursor: pointer; + font-family: monospace; + margin: 0 20px; + max-width: calc(100vw - 500px); + overflow-x: hidden; + padding: 5px 10px; + white-space: nowrap; +} + +.selected-dataset-path:hover { + background-color: var(--comparator-grey-150); +} + +.load-data-button { + background-color: var(--comparator-grey-150); + border: 0; + border-radius: 10px; + cursor: pointer; + font-size: 13px; + margin: 0 20px; + padding: 5px 10px; +} + +.load-data-button:hover { + background-color: var(--comparator-grey-250); +} + +.header-icon-container { + display: flex; + margin-left: auto; +} + +.link-icon { + padding: 0 6px; + position: relative; +} + +.icon { + border-radius: 24px; + color: var(--comparator-grey-500); + cursor: pointer; + padding: 6px; +} + +.icon:hover { + background-color: var(--comparator-grey-200); +} + +/* Status message */ +.status-message-container { + align-items: center; + background-color: #333; + border-radius: 5px; + color: #fff; + display: flex; + font-size: 13px; + font-weight: 500; + justify-content: space-between; + left: 0; + margin: 0 auto; + padding: 10px 15px; + position: absolute; + right: 0; + top: 10px; + width: 350px; + z-index: 20; +} + +.status-message-container .error-message { + font-weight: normal; +} + +.dismiss-button { + color: #a8c7fa; +} + +.popup-tooltip { + align-items: center; + background: var(--comparator-popup-color); + border-radius: 1px; + bottom: 0; + display: flex; + gap: 4px; + position: absolute; + left: 50%; + padding: 2px 4px; + transform: translate(-80%, 90%); + white-space: nowrap; +} + +.popup-tooltip:after { + border-color: transparent transparent var(--comparator-popup-color) transparent; + border-style: solid; + border-width: 4px; + bottom: 100%; + content: ""; + left: 80%; + position: absolute; + transform: translateX(-50%); +} + +.popup-tooltip a { + color: white; + text-decoration: none; +} + +.popup-tooltip .close-icon { + color: var(--comparator-grey-100); + cursor: pointer; + font-size: 11px; +} + +/* Sidebar */ +#sidebar { + background-color: #f3f3f3; + border-left: 2px solid #fff; + display: flex; + flex: 0 0 360px; + flex-direction: column; + height: 100%; + overflow-y: auto; + padding: 0 5px; +} + +.sidebar-component { + background-color: white; + border: 1px solid #ddd; + border-radius: 8px; + margin: 5px 5px 10px 5px; +} + +.sidebar-component-title { + align-items: center; + border-bottom: 1px solid #ddd; + cursor: pointer; + display: flex; + font-size: 1.2em; + justify-content: space-between; + padding: 5px 8px; +} + +.additional-note { + color: #999; + font-size: 11px; +} + +.sidebar-component-content { + padding: 8px 10px; +} + +.sidebar-component-content .description { + color: var(--comparator-grey-500); + font-size: 12px; + padding-bottom: 4px; +} + +.sidebar-component-content table { + width: 100%; +} + +.sidebar-component-content th { + background-color: var(--comparator-grey-200); + font-size: 11px; + font-weight: 200; + padding: 4px 0; +} + +.sidebar-component-content .sort-selected { + font-weight: 900; +} + +.sidebar-component-content td { + padding: 2px 4px; +} + +.sidebar-component-content tr.selected td { + background-color: var(--comparator-greygreen-100); + color: black; +} + +.sidebar-component-content tr:hover td { + background-color: var(--comparator-greygreen-200); +} + +.sidebar-component-footer { + background-color: var(--comparator-grey-100); + align-items: center; + cursor: pointer; + display: flex; + font-size: 11px; + justify-content: center; + padding: 1px 8px; +} + +/* Tables */ +tr.second-row .model-a { + background-color: var(--comparator-model-a); + border-radius: 15px; + padding: 0 15px; +} + +tr.second-row .model-b { + background-color: var(--comparator-model-b); + border-radius: 15px; + padding: 0 15px; +} + +/* Filter chips */ +.filter-chip { + align-items: center; + background-color: var(--comparator-greygreen-300); + border-radius: 10px; + color: var(--comparator-greygreen-700); + display: flex; + margin-left: 3px; + padding: 2px 3px 2px 7px; +} + +.chip-cancel-icon { + cursor: pointer; + font-size: 11px; + margin-left: 2px; + opacity: 0.7; +} + +.chip-cancel-icon:hover { + opacity: 1.0; +} + +/* Sort icons */ +.sort-icons-container { + padding: 0 0 16px 20px; + position: absolute; + right: -4px; + top: 10px; +} + +.sort-icon { + color: var(--comparator-grey-300); + cursor: pointer; + position: absolute; + right: 0; +} + +.sort-icon.up { + top: -12px; +} + +.sort-icon.down { + top: 6px; +} + +.sort-icon:hover { + color: var(--comparator-grey-50); +} + +.sort-icon.active { + color: #fff; +} + +.expand-icon { + color: var(--comparator-grey-500); + font-size: 13px; +} + +/* Charts */ +rect.clickable-transparent-area { + cursor: pointer; + fill: #fff; + opacity: 0.2; + stroke: none; +} + +rect.clickable-transparent-area.selected, +rect.clickable-transparent-area:hover { + opacity: 0.01; +} + +text.right-aligned { + text-anchor: end; +} + +rect.a-color, circle.a-color { + fill: var(--comparator-model-a); +} + +rect.b-color, circle.b-color { + fill: var(--comparator-model-b); +} + +rect.a-win-color, circle.a-win-color { + fill: var(--comparator-model-a-win); +} + +rect.b-win-color, circle.b-win-color { + fill: var(--comparator-model-b-win); +} + +div.a-color, span.a-color { + background-color: var(--comparator-model-a); +} + +div.b-color, span.b-color { + background-color: var(--comparator-model-b); +} + +div.a-win-color, span.a-win-color { + background-color: var(--comparator-model-a-win); +} + +div.b-win-color, span.b-win-color { + background-color: var(--comparator-model-b-win); +} + +.a-color-bg { + background-color: var(--comparator-model-a-background); +} + +.b-color-bg { + background-color: var(--comparator-model-b-background); +} + +.a-win-color-bg { + background-color: var(--comparator-model-a-win-bg); +} + +.b-win-color-bg { + background-color: var(--comparator-model-b-win-bg); +} + +.a-win-color-bg-darker { + background-color: var(--comparator-model-a-win-bg-darker); +} + +.b-win-color-bg-darker { + background-color: var(--comparator-model-b-win-bg-darker); +} +`; + + // client/components/bar_chart.css + var styles2 = i`.bar-chart { + display: block; + margin: 0; +} + +text { + alignment-baseline: middle; + fill: var(--comparator-grey-800); + font-size: 11px; + text-anchor: middle; +} + +.bar { + fill: var(--comparator-grey-400); + fill-opacity: 0.5; + stroke-width: 0; +} + +.bar.some-selected, +.bar-label.some-selected { + fill-opacity: 0.2; +} + +.bar.selected, +.bar-label.selected, +.bar:hover { + fill-opacity: 1.0; +} + +text.bar-label { + font-size: 10px; + text-anchor: start; +} + +.bar-chart .axis { + fill: none; + stroke: var(--comparator-grey-400); + stroke-width: 1; +} + +.bar-chart .axis-label { + text-anchor: end; +} + +text.highlighted { + font-weight: 600; +}`; + + // client/components/bar_chart.ts + var BarChartElement = class extends MobxLitElement { + constructor() { + super(); + this.getValueDomain = () => []; + this.groupCount = 1; + this.isNested = false; + this.getDataValues = () => []; + this.getGroupedDataValues = () => []; + this.getGroupedNestedDataValues = () => []; + this.handleClickBar = () => { + }; + this.isAnyBarSelected = () => false; + this.isThisBarSelected = () => false; + this.getHighlightedValues = () => []; + this.svgWidth = 280; + this.barHeight = 14; + this.verticalPaddingBetweenBarsWithinGroup = 1; + this.verticalPadding = 1; + this.leftAxisWidth = 110; + this.rightPaddingDefault = 25; + this.rightPaddingForNested = 55; + makeObservable(this); + } + get aggregatedData() { + const aggregatedCount = {}; + this.getValueDomain().forEach((value) => { + const entryPair = Array.from({ length: this.groupCount }, () => { + return { count: 0, weight: 0 }; + }); + aggregatedCount[value] = entryPair; + }); + if (this.isNested === true) { + const groupedNestedDataValues = this.getGroupedNestedDataValues(); + groupedNestedDataValues.forEach( + (nestedValues, groupIndex) => { + nestedValues.forEach((values) => { + const elementCount = values.length; + values.forEach((value) => { + aggregatedCount[value][groupIndex].weight += 1 / elementCount; + }); + new Set(values).forEach((value) => { + aggregatedCount[value][groupIndex].count += 1; + }); + }); + } + ); + } else { + const groupedDataValues = this.groupCount > 1 ? this.getGroupedDataValues() : [this.getDataValues()]; + groupedDataValues.forEach((values, groupIndex) => { + values.forEach((value) => { + aggregatedCount[value][groupIndex].count += 1; + aggregatedCount[value][groupIndex].weight += 1; + }); + }); + } + return aggregatedCount; + } + get verticalPaddingForGroup() { + return Math.ceil(this.barHeight / 2); + } + get rightPadding() { + return this.isNested === true ? this.rightPaddingForNested : this.rightPaddingDefault; + } + get binHeight() { + return (this.barHeight + this.verticalPaddingBetweenBarsWithinGroup) * this.groupCount + this.verticalPaddingForGroup * 2; + } + get svgHeight() { + return this.binHeight * this.getValueDomain().length + this.verticalPadding * 2; + } + get barMaxWidth() { + return this.svgWidth - this.rightPadding - this.leftAxisWidth; + } + renderLeftAxis() { + const paddingBetweenBarAndAxisLine = 1; + const tickLength = 2; + const paddingBetweenTickAndLabel = 2; + const renderAxis = b2` + `; + const styleAxisLabel = (value) => e6({ + "axis-label": true, + "highlighted": this.getHighlightedValues().includes(value) + }); + const renderTicks = this.getValueDomain().map( + (value, tickIndex) => b2` + + + + ${value} + ${value} + + ` + ); + return b2` + ${renderAxis} + ${renderTicks}`; + } + renderGroupedBar(value, entryPair, maxCount, index) { + const renderBars = entryPair.map( + (entry, groupIndex) => { + const barWidth = entry.weight * this.barMaxWidth / maxCount; + const binRectClass = (value2) => e6({ + "bar": true, + "some-selected": this.isAnyBarSelected(groupIndex), + "selected": this.isThisBarSelected(value2, groupIndex), + "a-color": this.groupCount === 2 && groupIndex === 0, + "b-color": this.groupCount === 2 && groupIndex === 1 + }); + const binTextClass = (value2) => e6({ + "bar-label": true, + "some-selected": this.isAnyBarSelected(groupIndex), + "selected": this.isThisBarSelected(value2, groupIndex) + }); + const barAreaHeight = this.barHeight + this.verticalPaddingBetweenBarsWithinGroup; + return b2` + + + + ${entry.weight > 0 ? this.isNested === true ? `${entry.weight.toFixed(1)} (${entry.count})` : entry.count : ""} + + void this.handleClickBar(value, groupIndex)} /> + `; + } + ); + return b2` + + ${renderBars} + `; + } + render() { + const aggregatedWeights = Object.values(this.aggregatedData).flat(2).map((entry) => entry.weight); + const maxWeight = Math.max(1, Math.max(...aggregatedWeights)); + const renderGroupedBars = this.getValueDomain().map( + (value, index) => { + const entryPair = this.aggregatedData[value]; + return this.renderGroupedBar(value, entryPair, maxWeight, index); + } + ); + return x` + + + ${this.renderLeftAxis()} + ${renderGroupedBars} + + `; + } + }; + BarChartElement.styles = [styles, styles2]; + __decorateClass([ + n4({ type: Object }) + ], BarChartElement.prototype, "getValueDomain", 2); + __decorateClass([ + n4({ type: Number }) + ], BarChartElement.prototype, "groupCount", 2); + __decorateClass([ + n4({ type: Boolean }) + ], BarChartElement.prototype, "isNested", 2); + __decorateClass([ + n4({ type: Object }) + ], BarChartElement.prototype, "getDataValues", 2); + __decorateClass([ + n4({ type: Object }) + ], BarChartElement.prototype, "getGroupedDataValues", 2); + __decorateClass([ + n4({ type: Object }) + ], BarChartElement.prototype, "getGroupedNestedDataValues", 2); + __decorateClass([ + n4({ type: Object }) + ], BarChartElement.prototype, "handleClickBar", 2); + __decorateClass([ + n4({ type: Object }) + ], BarChartElement.prototype, "isAnyBarSelected", 2); + __decorateClass([ + n4({ type: Object }) + ], BarChartElement.prototype, "isThisBarSelected", 2); + __decorateClass([ + n4({ type: Object }) + ], BarChartElement.prototype, "getHighlightedValues", 2); + __decorateClass([ + n4({ type: Number }) + ], BarChartElement.prototype, "svgWidth", 2); + __decorateClass([ + n4({ type: Number }) + ], BarChartElement.prototype, "barHeight", 2); + __decorateClass([ + n4({ type: Number }) + ], BarChartElement.prototype, "leftAxisWidth", 2); + __decorateClass([ + computed + ], BarChartElement.prototype, "aggregatedData", 1); + __decorateClass([ + computed + ], BarChartElement.prototype, "verticalPaddingForGroup", 1); + __decorateClass([ + computed + ], BarChartElement.prototype, "rightPadding", 1); + __decorateClass([ + computed + ], BarChartElement.prototype, "binHeight", 1); + __decorateClass([ + computed + ], BarChartElement.prototype, "svgHeight", 1); + __decorateClass([ + computed + ], BarChartElement.prototype, "barMaxWidth", 1); + BarChartElement = __decorateClass([ + t3("comparator-bar-chart") + ], BarChartElement); + + // client/lib/types.ts + var AOrB = /* @__PURE__ */ ((AOrB2) => { + AOrB2["A"] = "A"; + AOrB2["B"] = "B"; + return AOrB2; + })(AOrB || {}); + var FieldType = /* @__PURE__ */ ((FieldType2) => { + FieldType2["NUMBER"] = "number"; + FieldType2["STRING"] = "string"; + FieldType2["CATEGORY"] = "category"; + FieldType2["TEXT"] = "text"; + FieldType2["URL"] = "url"; + FieldType2["IMAGE_PATH"] = "image_path"; + FieldType2["IMAGE_BYTE"] = "image_byte"; + FieldType2["PER_MODEL_BOOLEAN"] = "per_model_boolean"; + FieldType2["PER_MODEL_NUMBER"] = "per_model_number"; + FieldType2["PER_MODEL_CATEGORY"] = "per_model_category"; + FieldType2["PER_MODEL_TEXT"] = "per_model_text"; + FieldType2["PER_RATING_STRING"] = "per_rating_string"; + FieldType2["PER_RATING_PER_MODEL_CATEGORY"] = "per_rating_per_model_category"; + FieldType2["BASE"] = "base"; + return FieldType2; + })(FieldType || {}); + var CustomFuncType = /* @__PURE__ */ ((CustomFuncType2) => { + CustomFuncType2["REGEXP"] = "Regular Expr."; + CustomFuncType2["PRECOMPUTED"] = "Precomputed"; + return CustomFuncType2; + })(CustomFuncType || {}); + var CustomFuncReturnType = /* @__PURE__ */ ((CustomFuncReturnType2) => { + CustomFuncReturnType2["BOOLEAN"] = "Boolean"; + CustomFuncReturnType2["NUMBER"] = "Number"; + return CustomFuncReturnType2; + })(CustomFuncReturnType || {}); + + // client/lib/constants.ts + var BASE_FIELD_ID_PREFIX = "base:"; + var FIELD_ID_FOR_INDEX = `${BASE_FIELD_ID_PREFIX}index`; + var FIELD_ID_FOR_INPUT = `${BASE_FIELD_ID_PREFIX}input_text`; + var FIELD_ID_FOR_OUTPUT_A = `${BASE_FIELD_ID_PREFIX}output_text_a`; + var FIELD_ID_FOR_OUTPUT_B = `${BASE_FIELD_ID_PREFIX}output_text_b`; + var FIELD_ID_FOR_TAGS = `${BASE_FIELD_ID_PREFIX}tags`; + var FIELD_ID_FOR_SCORE = `${BASE_FIELD_ID_PREFIX}score`; + var FIELD_ID_FOR_RATIONALES = `${BASE_FIELD_ID_PREFIX}rationales`; + var FIELD_ID_FOR_RATIONALE_LIST = `${BASE_FIELD_ID_PREFIX}rationale_list`; + var DEFAULT_COLUMN_LIST = [ + { id: FIELD_ID_FOR_INDEX, name: "Index", type: "base" /* BASE */, visible: true }, + { id: FIELD_ID_FOR_INPUT, name: "Prompt", type: "base" /* BASE */, visible: true }, + { + id: FIELD_ID_FOR_TAGS, + name: "Prompt Categories", + type: "base" /* BASE */, + visible: false + }, + { + id: FIELD_ID_FOR_OUTPUT_A, + name: "Response from Model A", + type: "base" /* BASE */, + visible: true + }, + { + id: FIELD_ID_FOR_OUTPUT_B, + name: "Response from Model B", + type: "base" /* BASE */, + visible: true + }, + { id: FIELD_ID_FOR_SCORE, name: "Score", type: "base" /* BASE */, visible: true }, + { + id: FIELD_ID_FOR_RATIONALES, + name: "Rationales", + type: "base" /* BASE */, + visible: false + }, + { + id: FIELD_ID_FOR_RATIONALE_LIST, + name: "Rationale List", + type: "base" /* BASE */, + visible: false + } + ]; + var DEFAULT_SORTING_CRITERIA = { + column: "None" /* NONE */, + customField: null, + modelIndex: null, + order: "None" /* NONE */ + }; + var LINE_HEIGHT_IN_CELL = 17; + var DEFAULT_NUM_EXAMPLES_TO_DISPLAY = 50; + var DEFAULT_CHART_HEIGHT_FOR_CUSTOM_FUNCS = 60; + var DEFAULT_SXS_HISTOGRAM_HEIGHT_FOR_CUSTOM_FUNCS = 40; + var HISTOGRAM_BOTTOM_AXIS_HEIGHT = 9; + var DEFAULT_HISTOGRAM_SPEC = { + rangeLeft: -1.75, + rangeRight: 1.75, + numberOfBins: 7, + isBounded: false, + isDivergingScheme: true + }; + var FIVE_POINT_LIKERT_HISTOGRAM_SPEC = { + rangeLeft: 1, + rangeRight: 5, + numberOfBins: 9, + isBounded: true, + isDivergingScheme: true + }; + var DEFAULT_WIN_RATE_THRESHOLD = 0.25; + var DEFAULT_RATIONALE_CLUSTER_SIMILARITY_THRESHOLD = 0.8; + var BUILT_IN_DEMO_FILES = [ + "https://pair-code.github.io/llm-comparator/data/example_tiny.json", + "https://pair-code.github.io/llm-comparator/data/example_arena.json" + ]; + var INITIAL_CUSTOM_FUNCTIONS = [ + { + id: -1, + // Will be overwritten. + name: "Word count", + functionType: "Regular Expr." /* REGEXP */, + functionBody: "\\w+", + returnType: "Number" /* NUMBER */, + precomputed: false + }, + { + id: -1, + name: "Contains bulleted lists", + functionType: "Regular Expr." /* REGEXP */, + functionBody: "\\n([*-])\\s", + returnType: "Boolean" /* BOOLEAN */, + precomputed: false + }, + { + id: -1, + name: "Contains headings", + functionType: "Regular Expr." /* REGEXP */, + functionBody: "#+\\s+.+", + returnType: "Boolean" /* BOOLEAN */, + precomputed: false + }, + { + id: -1, + name: "Contains URLs", + functionType: "Regular Expr." /* REGEXP */, + functionBody: "https?://[-a-zA-Z0-9&@#/%?=+~_|!:,.;]*[-a-zA-Z0-9&@#/%=+~_|]", + returnType: "Boolean" /* BOOLEAN */, + precomputed: false + }, + { + id: -1, + name: 'Starts with "Sure"', + functionType: "Regular Expr." /* REGEXP */, + functionBody: "^Sure", + returnType: "Boolean" /* BOOLEAN */, + precomputed: false + } + ]; + + // client/lib/utils.ts + var import_jsdifflib = __toESM(require_jsdifflib()); + var import_jstat = __toESM(require_jstat()); + function getTextDiff(textA, textB) { + const tokenize = (text) => text.match(/[\w\d'-]+|\W+/g); + const wordsA = tokenize(textA) || []; + const wordsB = tokenize(textB) || []; + const replaceTokensThatThrowErrors = (token) => token === "hasOwnProperty" ? "_hasOwnProperty_" : token; + const cleanedWordsA = [...wordsA].map(replaceTokensThatThrowErrors); + const cleanedWordsB = [...wordsB].map(replaceTokensThatThrowErrors); + const matcher = new import_jsdifflib.default.SequenceMatcher(cleanedWordsA, cleanedWordsB); + const opcodes = matcher.get_opcodes(); + const textDiff = { parsedA: [], parsedB: [], isEquals: [] }; + for (const opcode of opcodes) { + const changeType = opcode[0]; + const startA = Number(opcode[1]); + const endA = Number(opcode[2]); + const startB = Number(opcode[3]); + const endB = Number(opcode[4]); + textDiff.parsedA.push(wordsA.slice(startA, endA).join("")); + textDiff.parsedB.push(wordsB.slice(startB, endB).join("")); + textDiff.isEquals.push(changeType === "equal"); + } + return textDiff; + } + function renderDiffString(strings2, equal) { + const displaySpans = strings2.map((output, i23) => { + const classes = e6({ "highlighted-match": equal[i23] }); + return x`${output}`; + }); + return displaySpans; + } + function renderSearchedString(text, searchText2, caseInsensitive = true) { + const pattern = new RegExp(searchText2, caseInsensitive === true ? "gi" : "g"); + const matches3 = text.matchAll(pattern); + const matchList = [...matches3]; + if (!matchList.length) { + return x`${text}`; + } + const matchedResults = matchList.map((match) => { + return { + index: match.index, + text: match[0] + }; + }); + const annotatedText = []; + for (let j3 = 0; j3 < matchedResults.length; j3++) { + if (j3 === 0) { + annotatedText.push(x`${text.substring(0, matchedResults[j3].index)}`); + } + annotatedText.push( + x`${matchedResults[j3].text}` + ); + annotatedText.push( + x`${text.substring( + matchedResults[j3].index + matchedResults[j3].text.length, + j3 < matchedResults.length - 1 ? matchedResults[j3 + 1].index : text.length + )}` + ); + } + return annotatedText; + } + function searchText(text, stringToSearch, ignoreCase = true) { + const pattern = new RegExp( + stringToSearch, + ignoreCase === true ? "i" : void 0 + ); + return pattern.test(text); + } + function formatRateToPercentage(rate) { + return `${(rate * 100).toFixed(1)}%`; + } + function getWinRate(entry) { + const sum = entry.results["a"] + entry.results["b"] + entry.results["tie"]; + if (sum === 0) { + return 0; + } else { + return (entry.results["a"] + 0.5 * entry.results["tie"]) / sum; + } + } + function getAvgScore(entry) { + const count = entry.count; + return count === 0 ? null : entry.scoreSum / count; + } + function makeNewSliceWinRate(sliceName) { + const sliceWinRate = { + sliceName, + count: 0, + results: { "a": 0, "b": 0, "tie": 0, "unknown": 0 }, + scoreSum: 0, + scoreSqSum: 0 + }; + return sliceWinRate; + } + function getZScoreFromConfidenceLevel(confidenceLevel) { + if (confidenceLevel === 0.95) { + return 1.96; + } else if (confidenceLevel === 0.99) { + return 2.576; + } else if (confidenceLevel === 0.9) { + return 1.645; + } else { + throw new Error(`Use 0.9, 0.95, or 0.99 for confidence level.`); + } + } + function calculateErrorMargin(count, scoreSum, scoreSqSum, confidenceLevel = 0.95) { + if (count === 0) { + return 0; + } else if (count === 1) { + return 1e4; + } + const variance = scoreSqSum - scoreSum ** 2 / count; + const standardDeviation = Math.sqrt(variance / (count - 1)); + const standardError = standardDeviation / Math.sqrt(count); + const zScore = getZScoreFromConfidenceLevel(confidenceLevel); + const marginOfError = zScore * standardError; + return marginOfError; + } + function getConfidenceIntervalForMeanFromAggregatedStats(count, sum, squareSum, isAxisReversed = false, confidenceLevel = 0.95) { + if (count === 0) { + return [0, 0]; + } + const errorMargin = calculateErrorMargin( + count, + sum, + squareSum, + confidenceLevel + ); + const mean = sum / count; + const errorMarginLeft = mean - errorMargin * (isAxisReversed === true ? -1 : 1); + const errorMarginRight = mean + errorMargin * (isAxisReversed === true ? -1 : 1); + return [errorMarginLeft, errorMarginRight]; + } + function getConfidenceIntervalForRate(countTrue, countFalse, confidenceLevel = 0.95) { + const alpha = countTrue + 0.5; + const beta = countFalse + 0.5; + const left = import_jstat.default.beta.inv(1 - confidenceLevel, alpha, beta); + const right = import_jstat.default.beta.inv(confidenceLevel, alpha, beta); + return [left, right]; + } + function getHistogramStepSize(histogramSpec) { + return (histogramSpec.rangeRight - histogramSpec.rangeLeft) / histogramSpec.numberOfBins; + } + function getHistogramBinIndexFromValue(histogramSpec, value) { + const stepSize = getHistogramStepSize(histogramSpec); + const binPositionValue = (value - histogramSpec.rangeLeft) / stepSize; + const binIndex = histogramSpec.isDivergingScheme === true && binPositionValue > histogramSpec.numberOfBins * 0.5 ? Math.ceil(binPositionValue) - 1 : Math.floor(binPositionValue); + if (binIndex < 0) { + return 0; + } else if (binIndex > histogramSpec.numberOfBins - 1) { + return histogramSpec.numberOfBins - 1; + } else { + return binIndex; + } + } + function getHistogramRangeFromBinIndex(histogramSpec, binIndex) { + const stepSize = getHistogramStepSize(histogramSpec); + return { + left: histogramSpec.rangeLeft + binIndex * stepSize, + right: histogramSpec.rangeLeft + (binIndex + 1) * stepSize + }; + } + function getFloatPrecisionForHistogram(histogramSpec) { + if (Math.abs(histogramSpec.rangeRight - histogramSpec.rangeLeft) < histogramSpec.numberOfBins) { + return 2; + } else if (Math.abs(histogramSpec.rangeRight - histogramSpec.rangeLeft) < histogramSpec.numberOfBins * 2) { + return 1; + } else { + return 0; + } + } + function getRangeInclusionFromBinIndex(histogramSpec, binIndex) { + return { + left: histogramSpec.isDivergingScheme === false || binIndex <= (histogramSpec.numberOfBins - 1) * 0.5, + right: binIndex === histogramSpec.numberOfBins - 1 || histogramSpec.isDivergingScheme === true && binIndex >= (histogramSpec.numberOfBins - 1) * 0.5 + }; + } + function makeNewCustomFunc(id) { + const customFunc = { + id, + name: "", + functionType: "Regular Expr." /* REGEXP */, + functionBody: "", + returnType: "Boolean" /* BOOLEAN */, + precomputed: false + }; + return customFunc; + } + function initializeCustomFuncSelections() { + return { "A": null, "B": null, "A-B": null }; + } + function getFieldIdForCustomFunc(customFuncId) { + return `custom_function:${customFuncId}`; + } + function isPerModelFieldType(field) { + return field.type === "per_model_boolean" /* PER_MODEL_BOOLEAN */ || field.type === "per_model_number" /* PER_MODEL_NUMBER */ || field.type === "per_model_category" /* PER_MODEL_CATEGORY */ || field.type === "per_model_text" /* PER_MODEL_TEXT */; + } + function isPerRatingFieldType(field) { + return field.type === "per_rating_string" /* PER_RATING_STRING */ || field.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */; + } + function toFixedIfNeeded(num) { + if (num % 1 !== 0) { + return num.toFixed(2); + } else { + return num.toString(); + } + } + function constructImageSrcFromByte(imageByte, imageType = "jpeg") { + return `data:image/${imageType};base64,${imageByte}`; + } + function getMinAndMax(values) { + const notNullValues = values.filter((value) => value != null).map((value) => value); + const minValue = notNullValues.length > 0 ? Math.min(...notNullValues) : 0; + const maxValue = notNullValues.length > 0 ? Math.max(...notNullValues) : 0; + return { minValue, maxValue }; + } + function groupByValues(values) { + const aggregatedCount = {}; + values.forEach((value) => { + if (!aggregatedCount[value]) { + aggregatedCount[value] = 0; + } + aggregatedCount[value] += 1; + }); + return aggregatedCount; + } + function groupByAndSortKeys(values) { + const aggregatedCount = groupByValues(values); + return Object.entries(aggregatedCount).sort((a11, b7) => b7[1] - a11[1]).map(([key, count]) => key); + } + function mergeTwoArrays(baseValues, extendedValues) { + const baseValueSet = new Set(baseValues); + return [ + ...baseValues, + ...extendedValues.filter((value) => !baseValueSet.has(value)) + ]; + } + function printCustomFuncResultValue(value) { + if (value == null) { + return "NULL"; + } else if (typeof value === "boolean") { + return value === true ? "True" : "False"; + } else if (typeof value === "number" && !Number.isInteger(value)) { + return value.toFixed(3); + } else { + return value; + } + } + function convertToNumber(value) { + if (typeof value === "number") { + return value; + } else if (value === null) { + return null; + } else if (typeof value === "string") { + const parsedNumber = Number(value); + if (!isNaN(parsedNumber)) { + return parsedNumber; + } + } + return null; + } + function isEqualSorting(a11, b7) { + return a11.column === b7.column && (a11.customField == null && b7.customField == null || a11.customField != null && b7.customField != null && a11.customField.id === b7.customField.id) && a11.modelIndex === b7.modelIndex && a11.order === b7.order; + } + function compareStringsWithNulls(a11, b7) { + if (a11 == null && b7 == null) + return 0; + if (a11 == null) + return 1; + if (b7 == null) + return -1; + return a11.localeCompare(b7); + } + function compareNumbersWithNulls(a11, b7, isDescending) { + if (a11 === null && b7 === null) { + return 0; + } else if (a11 === null) { + return 1; + } else if (b7 === null) { + return -1; + } else { + return isDescending === true ? b7 - a11 : a11 - b7; + } + } + function replaceSpaceWithUnderscore(text) { + return text.replaceAll(" ", "_"); + } + function getHistogramFilterLabel(fieldName, histogramSpec, binIndex, model = null) { + if (histogramSpec == null || binIndex == null) { + return ""; + } else { + const fieldNameWithNoSpace = replaceSpaceWithUnderscore(fieldName); + const { left, right } = getHistogramRangeFromBinIndex( + histogramSpec, + binIndex + ); + const leftStr = histogramSpec.isBounded === false && binIndex === 0 ? null : left.toFixed(getFloatPrecisionForHistogram(histogramSpec)); + const rightStr = histogramSpec.isBounded === false && binIndex === histogramSpec.numberOfBins - 1 ? null : right.toFixed(getFloatPrecisionForHistogram(histogramSpec)); + const revisedFieldName = model == null ? fieldNameWithNoSpace : model === "A-B" ? `${fieldNameWithNoSpace}(A) - ${fieldNameWithNoSpace}(B)` : `${fieldNameWithNoSpace}(${model})`; + const operator = getHistogramStepSize(histogramSpec) > 0 ? "<" : ">"; + const rangeInclusion = getRangeInclusionFromBinIndex( + histogramSpec, + binIndex + ); + const leftEqual = rangeInclusion.left === true ? "=" : ""; + const rightEqual = rangeInclusion.right === true ? "=" : ""; + if (leftStr !== null && rightStr !== null) { + return `${leftStr} ${operator}${leftEqual} ${revisedFieldName} ${operator}${rightEqual} ${rightStr}`; + } else if (leftStr == null) { + return `${revisedFieldName} ${operator}${rightEqual} ${rightStr}`; + } else { + const flippedOperator = operator === ">" ? "<" : ">"; + return `${revisedFieldName} ${flippedOperator}${leftEqual} ${leftStr}`; + } + } + } + function getBarFilterLabel(customFuncName, model, value) { + return `${customFuncName}(${replaceSpaceWithUnderscore(model)}) = ${value}`; + } + function extractTextFromTextOrSequenceChunks(val) { + if (typeof val === "string") { + return val; + } else { + return val.filter((chunk) => chunk.type === "text" /* TEXT */).map((chunk) => chunk.data).join("\n"); + } + } + + // client/components/histogram.css + var styles3 = i`.histogram { + display: block; + margin: 0 auto; +} + +text { + fill: var(--comparator-grey-500); + font-size: 10px; + text-anchor: middle; +} + +text.left-aligned { + text-anchor: start; +} + +text.right-aligned { + text-anchor: end; +} + +.histogram .axis { + fill: none; + stroke: var(--comparator-grey-400); + stroke-width: 1; +} + +.histogram .axis-label { + alignment-baseline: hanging; + fill: var(--comparator-grey-400); + font-size: 9px; +} + +.axis-end-label-bg { + fill-opacity: 0.8; +} + +.axis-end-desc { + alignment-baseline: hanging; + fill: white; + font-size: 10px; +} + +line.mean-rule { + fill: none; + stroke: var(--comparator-greygreen-700); + stroke-width: 2; +} + +text.mean-rule-label { + alignment-baseline: hanging; + fill: var(--comparator-greygreen-700); + font-size: 9px; + text-anchor: start; + visibility: hidden; +} + +text.mean-rule-label.shown { + visibility: visible; +} + +.chart-title { + alignment-baseline: middle; + fill: var(--comparator-grey-500); + text-anchor: end; +} + +.histogram-bar-clip-area { + fill: var(--comparator-grey-450); +} + +rect.clickable-transparent-area { + opacity: 0.25; +} + +rect.clickable-transparent-area.some-selected { + opacity: 0.8; +} + +rect.clickable-transparent-area.selected { + opacity: 0.15; +} + +rect.clickable-transparent-area.some-selected:hover { + opacity: 0.6; +} + +rect.clickable-transparent-area:hover, +rect.clickable-transparent-area.selected:hover { + opacity: 0.05; +}`; + + // client/components/histogram.ts + var HistogramElement = class extends MobxLitElement { + constructor() { + super(); + this.getHistogramSpec = () => DEFAULT_HISTOGRAM_SPEC; + this.getRawDataValues = () => []; + this.handleClickHistogramBar = () => { + }; + this.isAnyBinSelected = () => false; + this.isThisBinSelected = () => false; + this.svgWidth = 220; + this.svgHeight = 70; + this.neutralColorThreshold = () => null; + this.specificColorScheme = null; + this.showBottomAxis = true; + this.showAxisEndDescription = false; + this.isSimplified = false; + this.isFlipXAxis = () => false; + this.titleOnLeft = null; + this.barSidePadding = 1; + this.topPaddingDefault = 10; + this.topPaddingForSimplified = 3; + this.rightPadding = 5; + this.titlePadding = 20; + this.bottomAxisHeight = 18; + this.bottomAxisEndDescriptionHeight = 12; + this.paddingBetweenBarAndAxisLine = 1; + this.showRuleLabel = false; + this.minHeightToAlwaysShowRuleLabel = 50; + makeObservable(this); + } + get leftPadding() { + return this.titleOnLeft == null ? this.rightPadding : this.titlePadding; + } + get topPadding() { + return this.isSimplified === true ? this.topPaddingForSimplified : this.topPaddingDefault; + } + get histogramAreaWidth() { + return this.svgWidth - this.leftPadding - this.rightPadding; + } + get binWidth() { + const numberOfBins = this.getHistogramSpec().numberOfBins; + if (numberOfBins === 0) { + return 0; + } else { + return Math.floor(this.histogramAreaWidth / numberOfBins); + } + } + get bottomAxisAreaHeight() { + return this.showAxisEndDescription === true ? this.bottomAxisHeight + this.bottomAxisEndDescriptionHeight : this.bottomAxisEndDescriptionHeight; + } + get barMaxHeight() { + return this.svgHeight - this.topPadding - this.bottomAxisAreaHeight; + } + get useDivergingColorScheme() { + return this.getHistogramSpec().isDivergingScheme === true; + } + get binnedData() { + const values = Array.from({ + length: this.getHistogramSpec().numberOfBins + }).fill(0); + this.getRawDataValues().forEach((value) => { + const binIndex = getHistogramBinIndexFromValue( + this.getHistogramSpec(), + value + ); + values[binIndex] += 1; + }); + return values; + } + get maxCount() { + return Math.max(1, Math.max(...this.binnedData)); + } + get mean() { + const rawDataValues = this.getRawDataValues(); + if (rawDataValues.length === 0) { + return 0; + } else { + return rawDataValues.reduce((a11, b7) => a11 + b7, 0) / rawDataValues.length; + } + } + renderBottomAxis() { + const tickLength = 2; + const paddingBetweenTickAndLabel = 1; + const renderAxis = b2` + `; + const axisEndLabelWidth = 50; + const axisEndLabelHeight = 11; + const styleAxisEndLabelBg = (isRightSide) => e6({ + "axis-end-label-bg": true, + "a-win-color": isRightSide === !this.isFlipXAxis(), + "b-win-color": isRightSide === this.isFlipXAxis() + }); + const renderAxisEndDescriptions = this.showAxisEndDescription === true ? b2` + + + + + ${this.isFlipXAxis() === true ? "A" : "B"} is better + + + ${this.isFlipXAxis() === true ? "B" : "A"} is better + ` : ""; + const numberOfBins = this.getHistogramSpec().numberOfBins; + const renderTickLabel = (tickIndex) => { + let value = null; + if (this.getHistogramSpec().isBounded === true) { + if (tickIndex === 0 || tickIndex === numberOfBins) { + value = getHistogramRangeFromBinIndex( + this.getHistogramSpec(), + tickIndex + ).left; + } + } else { + if (tickIndex > 0 && tickIndex < numberOfBins) { + value = getHistogramRangeFromBinIndex( + this.getHistogramSpec(), + tickIndex + ).left; + } + } + const styleAxisLabel = e6({ + "axis-label": true, + "left-aligned": this.getHistogramSpec().isBounded === true && (this.isFlipXAxis() === false && tickIndex === 0 || this.isFlipXAxis() === true && tickIndex === numberOfBins), + "right-aligned": this.getHistogramSpec().isBounded === true && (this.isFlipXAxis() === false && tickIndex === numberOfBins || this.isFlipXAxis() === true && tickIndex === 0) + }); + return b2` + + ${value != null ? value.toFixed( + getFloatPrecisionForHistogram(this.getHistogramSpec()) + ) : ""} + `; + }; + const renderTicks = Array.from({ + length: this.getHistogramSpec().numberOfBins + 1 + }).map((tick, tickIndex) => { + const xOffsetRatio = tickIndex / this.getHistogramSpec().numberOfBins; + const xOffset = this.histogramAreaWidth * (this.isFlipXAxis() === true ? 1 - xOffsetRatio : xOffsetRatio); + return b2` + + + ${renderTickLabel(tickIndex)} + `; + }); + return b2` + + ${renderAxis} + ${renderAxisEndDescriptions} + ${renderTicks} + `; + } + // Draw the shape of the bars for clipping. + clipShapeOfHistogramBar(count, maxCount, index) { + const barHeight = count * this.barMaxHeight / maxCount; + const xIndex = this.isFlipXAxis() === true ? this.binnedData.length - 1 - index : index; + return b2` + `; + } + // Specify fill colors of histogram bars and clip the shape. + renderColoredBarAreas() { + const histogramSpec = this.getHistogramSpec(); + const thresholdValue = this.neutralColorThreshold() != null ? this.neutralColorThreshold() : 0; + const thresholdPoint = (histogramSpec.rangeLeft + histogramSpec.rangeRight) * 0.5 - thresholdValue * Math.sign(histogramSpec.rangeRight - histogramSpec.rangeLeft); + const widthRatioOfColoredArea = (thresholdPoint - histogramSpec.rangeLeft) / (histogramSpec.rangeRight - histogramSpec.rangeLeft); + const thresholdWidth = this.histogramAreaWidth * widthRatioOfColoredArea; + const styleHistogramBarDefault = e6({ + "histogram-bar-clip-area": true, + "a-color": this.specificColorScheme === "A", + "b-color": this.specificColorScheme === "B" + }); + return b2` + + ${this.useDivergingColorScheme === true && this.neutralColorThreshold() != null ? b2` + + ` : ""}`; + } + // Render number labels above bars and clickable transparent areas. + renderHistogramBarElements(count, maxCount, index) { + if (this.isSimplified === true) { + return b2``; + } + const barHeight = count * this.barMaxHeight / maxCount; + const binTextClass = (binIndex) => e6({ + "histogram-bar-label": true, + "some-selected": this.isAnyBinSelected(), + "selected": this.isThisBinSelected(binIndex) + }); + const binClickableAreaClass = (binIndex) => e6({ + "clickable-transparent-area": true, + "clickable": true, + "some-selected": this.isAnyBinSelected(), + "selected": this.isThisBinSelected(binIndex) + }); + const xOffset = (binIndex) => this.binWidth * (this.isFlipXAxis() === true ? this.binnedData.length - 1 - binIndex : binIndex); + const renderCountLabel = b2` + + ${count > 0 ? count : ""} + `; + const renderClickableArea = b2` + void this.handleClickHistogramBar(index)} + />`; + return b2` + + ${renderCountLabel} + ${renderClickableArea} + `; + } + // Render a vertical bar (i.e., rule) that indicates the mean value. + renderMeanRule() { + if (this.isSimplified === true || this.getRawDataValues().length <= 1) { + return b2``; + } + const binIndex = getHistogramBinIndexFromValue( + this.getHistogramSpec(), + this.mean + ); + const binStartingPosition = binIndex * this.histogramAreaWidth / this.getHistogramSpec().numberOfBins + this.barSidePadding; + const { left, right } = getHistogramRangeFromBinIndex( + this.getHistogramSpec(), + binIndex + ); + const binProportion = (this.mean - left) / (right - left); + const binInsideOffset = binProportion * (this.binWidth - this.barSidePadding * 2); + const xPositionBeforeFlipConsidered = binStartingPosition + binInsideOffset; + const xPosition = this.isFlipXAxis() === true ? this.histogramAreaWidth - xPositionBeforeFlipConsidered : xPositionBeforeFlipConsidered; + const styleMeanRuleLabel = e6({ + "mean-rule-label": true, + "shown": this.svgHeight >= this.minHeightToAlwaysShowRuleLabel || this.showRuleLabel + }); + return b2` + + this.showRuleLabel = true} + @mouseleave=${() => this.showRuleLabel = false} + /> + + μ=${this.mean.toFixed(2)} + + `; + } + renderTitleOnLeft() { + const paddingBetweenAxisAndTitle = 3; + return this.titleOnLeft != null ? b2` + + + + ${this.titleOnLeft} + + ` : ""; + } + render() { + const histogramSpec = this.getHistogramSpec(); + if (histogramSpec === void 0) { + return x``; + } + const binnedData = this.binnedData; + const renderHistogramElementsForBars = binnedData.map( + (value, index) => this.renderHistogramBarElements(value, this.maxCount, index) + ); + const clipShapeOfHistogramBars = binnedData.map( + (value, index) => this.clipShapeOfHistogramBar(value, this.maxCount, index) + ); + const adjustedSvgHeight = this.showBottomAxis === true ? this.svgHeight : this.svgHeight - HISTOGRAM_BOTTOM_AXIS_HEIGHT; + return x` + + + ${this.renderTitleOnLeft()} + ${this.renderBottomAxis()} + + + ${clipShapeOfHistogramBars} + + ${this.renderColoredBarAreas()} + ${renderHistogramElementsForBars} + + ${this.renderMeanRule()} + + `; + } + }; + HistogramElement.styles = [styles, styles3]; + __decorateClass([ + n4({ type: Object }) + ], HistogramElement.prototype, "getHistogramSpec", 2); + __decorateClass([ + n4({ type: Object }) + ], HistogramElement.prototype, "getRawDataValues", 2); + __decorateClass([ + n4({ type: Object }) + ], HistogramElement.prototype, "handleClickHistogramBar", 2); + __decorateClass([ + n4({ type: Object }) + ], HistogramElement.prototype, "isAnyBinSelected", 2); + __decorateClass([ + n4({ type: Object }) + ], HistogramElement.prototype, "isThisBinSelected", 2); + __decorateClass([ + n4({ type: Number }) + ], HistogramElement.prototype, "svgWidth", 2); + __decorateClass([ + n4({ type: Number }) + ], HistogramElement.prototype, "svgHeight", 2); + __decorateClass([ + n4({ type: Object }) + ], HistogramElement.prototype, "neutralColorThreshold", 2); + __decorateClass([ + n4({ type: String }) + ], HistogramElement.prototype, "specificColorScheme", 2); + __decorateClass([ + n4({ type: Boolean }) + ], HistogramElement.prototype, "showBottomAxis", 2); + __decorateClass([ + n4({ type: Boolean }) + ], HistogramElement.prototype, "showAxisEndDescription", 2); + __decorateClass([ + n4({ type: Boolean }) + ], HistogramElement.prototype, "isSimplified", 2); + __decorateClass([ + n4({ type: Object }) + ], HistogramElement.prototype, "isFlipXAxis", 2); + __decorateClass([ + n4({ type: String }) + ], HistogramElement.prototype, "titleOnLeft", 2); + __decorateClass([ + observable + ], HistogramElement.prototype, "showRuleLabel", 2); + __decorateClass([ + computed + ], HistogramElement.prototype, "leftPadding", 1); + __decorateClass([ + computed + ], HistogramElement.prototype, "topPadding", 1); + __decorateClass([ + computed + ], HistogramElement.prototype, "histogramAreaWidth", 1); + __decorateClass([ + computed + ], HistogramElement.prototype, "binWidth", 1); + __decorateClass([ + computed + ], HistogramElement.prototype, "bottomAxisAreaHeight", 1); + __decorateClass([ + computed + ], HistogramElement.prototype, "barMaxHeight", 1); + __decorateClass([ + computed + ], HistogramElement.prototype, "useDivergingColorScheme", 1); + __decorateClass([ + computed + ], HistogramElement.prototype, "binnedData", 1); + __decorateClass([ + computed + ], HistogramElement.prototype, "maxCount", 1); + __decorateClass([ + computed + ], HistogramElement.prototype, "mean", 1); + HistogramElement = __decorateClass([ + t3("comparator-histogram") + ], HistogramElement); + + // client/services/service.ts + var Service = class { + initialize() { + } + }; + + // client/services/custom_function_service.ts + var CustomFunctionService = class extends Service { + // Use regular expression to find matches in output_text. + // If the return type is number, count the pattern. + executeCustomFunctionRegExp(outputText, expression, returnType) { + if (returnType === "Number" /* NUMBER */) { + const regExp = new RegExp(expression, "g"); + const matches3 = outputText.match(regExp); + return matches3 != null ? matches3.length : 0; + } else { + const regExp = new RegExp(expression); + const matches3 = outputText.match(regExp); + return matches3 != null ? true : false; + } + } + executeCustomFunction(outputText, example, customFunc) { + if (customFunc.functionType === "Regular Expr." /* REGEXP */) { + return this.executeCustomFunctionRegExp( + outputText, + customFunc.functionBody, + customFunc.returnType + ); + } else { + console.warning( + `Unsupported custom function type: ${customFunc.functionType}` + ); + return; + } + } + }; + + // client/services/state_service.ts + var AppState = class extends Service { + constructor(customFunctionService) { + super(); + this.customFunctionService = customFunctionService; + this.metadata = { + source_path: "", + custom_fields_schema: [], + sampling_step_size: 1 + }; + this.models = [{ name: "" }, { name: "" }]; + this.examples = []; + this.rationaleClusters = []; + this.datasetPath = null; + this.isDatasetPathUploadedFile = false; + this.isOpenDatasetSelectionPanel = true; + this.exampleDatasetPaths = BUILT_IN_DEMO_FILES; + this.selectedTag = null; + this.currentSorting = DEFAULT_SORTING_CRITERIA; + this.isExampleExpanded = {}; + this.selectedExample = null; + this.showSelectedExampleDetails = false; + this.exampleDetailsPanelExpanded = false; + this.hasRationaleClusters = false; + this.selectedRationaleClusterId = null; + this.hoveredRationaleClusterId = null; + this.matchedRationaleClusterIds = []; + this.rationaleClusterSimilarityThreshold = DEFAULT_RATIONALE_CLUSTER_SIMILARITY_THRESHOLD; + this.columns = DEFAULT_COLUMN_LIST; + this.showSidebarComponents = {}; + this.selectedBarChartValues = {}; + this.histogramSpecForScores = DEFAULT_HISTOGRAM_SPEC; + this.selectedHistogramBinForScores = null; + this.histogramSpecForCustomFields = {}; + this.selectedHistogramBinForCustomFields = {}; + this.selectedHistogramBinForRatingsForSelectedExample = null; + this.selectedBarChartValueForSelectedExample = null; + this.winRateThreshold = DEFAULT_WIN_RATE_THRESHOLD; + this.isFlipScoreHistogramAxis = true; + this.statusMessage = ""; + this.isOpenStatusMessage = false; + this.statusMessageTimeout = null; + this.searchFilters = {}; + this.searchFilterInputs = {}; + this.isOpenSettingsPanel = false; + this.isShowTextDiff = true; + this.useMonospace = false; + this.numExamplesToDisplay = DEFAULT_NUM_EXAMPLES_TO_DISPLAY; + this.isShowTagChips = true; + this.isShowSidebar = true; + this.numberOfLinesPerOutputCell = 7; + this.customFunctions = {}; + this.histogramSpecForCustomFuncs = {}; + this.histogramSpecForCustomFuncsOfDiff = {}; + this.selectedCustomFuncId = null; + this.selectionsFromCustomFuncResults = {}; + this.isShowCustomFuncEditor = false; + this.valueDomainsForCustomFields = {}; + makeObservable(this); + } + getIsExampleExpanded(index) { + return this.isExampleExpanded[index] ?? false; + } + resetSearchFilter(fieldId) { + this.searchFilters[fieldId] = ""; + this.searchFilterInputs[fieldId] = ""; + } + // Columns. + getFieldFromId(fieldId) { + return this.columns.find((field) => field.id === fieldId); + } + isColumnVisible(fieldId) { + const matchedField = this.getFieldFromId(fieldId); + return matchedField !== void 0 && matchedField.visible === true; + } + get numberOfShownTextColumns() { + return (this.isColumnVisible(FIELD_ID_FOR_INPUT) === true ? 1 : 0) + (this.isColumnVisible(FIELD_ID_FOR_OUTPUT_A) === true ? 1 : 0) + (this.isColumnVisible(FIELD_ID_FOR_OUTPUT_B) === true ? 1 : 0) + (this.isColumnVisible(FIELD_ID_FOR_RATIONALES) === true ? 1 : 0) + this.metadata.custom_fields_schema.filter( + (field) => field.type === "text" /* TEXT */ && this.isColumnVisible(field.name) + ).length; + } + get scoreMiddlePoint() { + return (this.histogramSpecForScores.rangeLeft + this.histogramSpecForScores.rangeRight) * 0.5; + } + // Check if A or B is a winner from a score. + isWinnerFromScore(model, score) { + if (score == null) { + return false; + } + if (model === "A") { + return score > this.scoreMiddlePoint + this.winRateThreshold; + } else if (model === "B") { + return score < this.scoreMiddlePoint - this.winRateThreshold; + } else { + return false; + } + } + get isScoreDivergingScheme() { + return this.scoreMiddlePoint === 0 || this.histogramSpecForScores.rangeLeft === FIVE_POINT_LIKERT_HISTOGRAM_SPEC.rangeLeft && this.histogramSpecForScores.rangeRight === FIVE_POINT_LIKERT_HISTOGRAM_SPEC.rangeRight; + } + get selectedCustomFunc() { + if (this.selectedCustomFuncId != null) { + return this.customFunctions[this.selectedCustomFuncId]; + } else { + return null; + } + } + get selectedCustomFuncName() { + if (this.selectedCustomFunc != null) { + return this.selectedCustomFunc.name; + } else { + return ""; + } + } + get newCustomFuncId() { + if (Object.keys(this.customFunctions).length === 0) { + return 0; + } else { + return Math.max(...Object.keys(this.customFunctions).map(Number)) + 1; + } + } + get customFieldsOfNumberType() { + return this.columns.filter( + (field) => field.type === "number" /* NUMBER */ + ); + } + get customFieldsOfCategoryType() { + return this.columns.filter( + (field) => field.type === "category" /* CATEGORY */ + ); + } + get customFieldsOfPerModelNumberType() { + return this.columns.filter((field) => field.type === "per_model_number" /* PER_MODEL_NUMBER */).filter((field) => field.id.startsWith("custom_field:")); + } + get customFieldsOfPerModelCategoryTypeIncludingPerRating() { + return this.columns.filter( + (field) => field.type === "per_model_category" /* PER_MODEL_CATEGORY */ || field.type === "per_model_boolean" /* PER_MODEL_BOOLEAN */ || field.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */ + ).filter((field) => field.id.startsWith("custom_field:")); + } + customFieldsOfPerRatingTypesWithNoAggregationSupport() { + return ["per_rating_string" /* PER_RATING_STRING */]; + } + // Fields for per-rating types. + get customFieldsOfPerRatingType() { + return this.columns.filter((field) => isPerRatingFieldType(field)); + } + // Fields without per-rating types. + get customFieldsWithoutPerRatingType() { + return this.columns.filter( + (field) => !isPerRatingFieldType(field) && field.type !== "base" /* BASE */ + ); + } + get visibleColumns() { + return this.columns.filter((field) => field.visible === true); + } + // Columns without per rating types. + get columnsWithoutPerRatingTypes() { + return this.columns.filter((field) => !isPerRatingFieldType(field)); + } + // Get the value domain for custom fields for side-by-side bar charts. + // We display all the axis values even when their counts are zero. + computeValueDomainForCustomField(field) { + const groupIndices = Array.from( + { length: this.models.length }, + (unused, i23) => i23 + ); + const values = groupIndices.map( + (groupIndex) => this.examples.map( + (ex) => ex.individual_rater_scores.map( + (rating) => rating.custom_fields[field.id][groupIndex] + ).flat() + ).flat() + ).flat(); + if (field.domain !== void 0) { + this.valueDomainsForCustomFields[field.id] = mergeTwoArrays( + field.domain, + groupByAndSortKeys(values) + ); + } else { + this.valueDomainsForCustomFields[field.id] = groupByAndSortKeys(values); + } + } + get individualRatingScoreValueDomain() { + const scores = /* @__PURE__ */ new Set(); + this.examples.forEach((ex) => { + ex.individual_rater_scores.filter((rating) => rating.score != null).forEach((rating) => { + scores.add(rating.score); + }); + }); + return Array.from(scores).sort((a11, b7) => b7 - a11).map((score) => score.toString()); + } + // Models. + getModelIndexFromAOrB(model) { + if (model === "A") { + return 0; + } else if (model === "B") { + return 1; + } else { + throw new Error(`Unknown model: ${model}`); + } + } + get filteredExamplesExceptChartSelections() { + let examples = this.examples; + Object.entries(this.searchFilters).filter(([fieldId, stringToSearch]) => stringToSearch !== "").forEach(([fieldId, stringToSearch]) => { + examples = examples.filter((ex) => { + if (fieldId === FIELD_ID_FOR_INPUT) { + return searchText( + extractTextFromTextOrSequenceChunks(ex.input_text), + stringToSearch + ); + } else if (fieldId === FIELD_ID_FOR_OUTPUT_A) { + return searchText( + extractTextFromTextOrSequenceChunks(ex.output_text_a), + stringToSearch + ); + } else if (fieldId === FIELD_ID_FOR_OUTPUT_B) { + return searchText( + extractTextFromTextOrSequenceChunks(ex.output_text_b), + stringToSearch + ); + } else if (fieldId === FIELD_ID_FOR_RATIONALES) { + return searchText( + ex.individual_rater_scores.map((rating) => rating.rationale).join("\n"), + stringToSearch + ); + } else if (fieldId === FIELD_ID_FOR_RATIONALE_LIST) { + return searchText( + ex.rationale_list.map((item) => item.rationale).join("\n"), + stringToSearch + ); + } else { + return ex.custom_fields[fieldId] != null && searchText(ex.custom_fields[fieldId], stringToSearch); + } + }); + }); + Object.values(this.customFunctions).filter( + (customFunc) => customFunc.returnType === "Boolean" /* BOOLEAN */ + ).forEach((customFunc) => { + const fieldId = getFieldIdForCustomFunc(customFunc.id); + const selections = this.selectionsFromCustomFuncResults[customFunc.id]; + Object.values(AOrB).forEach((model, modelIndex) => { + if (selections[model] != null) { + examples = examples.filter( + (ex) => ex.custom_fields[fieldId][modelIndex] === selections[model] + ); + } + }); + }); + return examples; + } + applyHistogramFilterForScores(examplesBeforeThisFilter) { + let examples = examplesBeforeThisFilter; + if (this.selectedHistogramBinForScores != null) { + examples = examples.filter((ex) => ex.score != null).filter( + (ex) => getHistogramBinIndexFromValue( + this.histogramSpecForScores, + ex.score + ) === this.selectedHistogramBinForScores + ); + } + return examples; + } + // TODO: Merge with the side-by-side histograms. + applyHistogramFilterForCustomFuncs(examplesBeforeThisFilter, excludeId = null, excludeModel = null) { + let examples = examplesBeforeThisFilter; + Object.values(this.customFunctions).filter( + (customFunc) => customFunc.returnType === "Number" /* NUMBER */ + ).forEach((customFunc) => { + const fieldId = getFieldIdForCustomFunc(customFunc.id); + const selections = this.selectionsFromCustomFuncResults[customFunc.id]; + Object.values(AOrB).filter( + (model) => excludeId == null || !(excludeId === customFunc.id && excludeModel === model) + ).forEach((model) => { + const modelIndex = this.getModelIndexFromAOrB(model); + if (selections[model] != null) { + examples = examples.filter( + (ex) => ex.custom_fields[fieldId][modelIndex] != null + ).filter( + (ex) => getHistogramBinIndexFromValue( + this.histogramSpecForCustomFuncs[customFunc.id], + ex.custom_fields[fieldId][modelIndex] + ) === selections[model] + ); + } + }); + if (selections["A-B"] != null && (excludeId == null || !(excludeId === customFunc.id && excludeModel === "A-B"))) { + examples = examples.filter((ex) => { + const valA = ex.custom_fields[fieldId][0]; + const valB = ex.custom_fields[fieldId][1]; + if (valA != null && valB != null && typeof valA === "number" && typeof valB === "number") { + return getHistogramBinIndexFromValue( + this.histogramSpecForCustomFuncsOfDiff[customFunc.id], + valA - valB + ) === selections["A-B"]; + } else { + return false; + } + }); + } + }); + return examples; + } + applyHistogramFilterForCustomFields(examplesBeforeThisFilter, excludeField = null, excludeModel = null) { + let examples = examplesBeforeThisFilter; + Object.keys(this.selectedHistogramBinForCustomFields).forEach((fieldId) => { + const selections = this.selectedHistogramBinForCustomFields[fieldId]; + if (selections != null && typeof selections === "object") { + Object.values(AOrB).filter( + (model) => excludeField == null || !(excludeField === fieldId && excludeModel === model) + ).forEach((model) => { + const modelIndex = this.getModelIndexFromAOrB(model); + if (selections[model] != null) { + examples = examples.filter( + (ex) => ex.custom_fields[fieldId][modelIndex] != null + ).filter( + (ex) => getHistogramBinIndexFromValue( + this.histogramSpecForCustomFields[fieldId], + ex.custom_fields[fieldId][modelIndex] + ) === selections[model] + ); + } + }); + } else { + if (selections != null && fieldId !== excludeField) { + examples = examples.filter((ex) => ex.custom_fields[fieldId] != null).filter( + (ex) => getHistogramBinIndexFromValue( + this.histogramSpecForCustomFields[fieldId], + ex.custom_fields[fieldId] + ) === selections + ); + } + } + }); + return examples; + } + applyBarChartFilterForCustomFields(examplesBeforeThisFilter, excludeField = null, excludeGroupIndex = null) { + let examples = examplesBeforeThisFilter; + Object.entries(this.selectedBarChartValues).forEach( + ([fieldId, selectionsForGroups]) => { + selectionsForGroups.map((selectionForGroup, groupIndex) => [ + selectionForGroup, + groupIndex + ]).filter( + ([selectionForGroup, groupIndex]) => selectionForGroup != null && !(excludeField != null && excludeField === fieldId && excludeGroupIndex != null && excludeGroupIndex === groupIndex) + ).forEach(([selectionForGroup, groupIndex]) => { + examples = examples.filter((ex) => { + const fieldValue = ex.custom_fields[fieldId]; + const value = fieldValue instanceof Array ? fieldValue[groupIndex] : fieldValue; + return value instanceof Object ? Object.keys(value).includes(selectionForGroup) : value != null && value.toString() === selectionForGroup; + }); + }); + } + ); + return examples; + } + applyTagFilter(examplesBeforeThisFilter) { + let examples = examplesBeforeThisFilter; + if (this.selectedTag != null) { + examples = examples.filter( + (example) => example.tags.includes(this.selectedTag) + ); + } + return examples; + } + applyRationaleClusterFilter(examplesBeforeThisFilter) { + let examples = examplesBeforeThisFilter; + if (this.selectedRationaleClusterId != null) { + examples = examples.filter((example) => { + const clusterIds = example.rationale_list.map((rationale) => rationale.assignedClusterIds).flat(); + return clusterIds.includes(this.selectedRationaleClusterId); + }); + } + return examples; + } + // Get the list of examples for cases when a particular bin selection is not + // applied. This is to render non-selected bars in histograms, which are not + // part of this.filteredExamples. + // e.g., If there exist two selections, bin_for_score=2 and bin_for_field_x=5, + // the table shows filteredExamples that apply both of the filters. + // However, for the score histogram, it will show data for bin_for_field_x=5, + // because we want to visualize other bars (bin_for_score != 2) too with + // opacity < 1. In this case, + // @computed this.filteredExamples has data only for the two filters applied. + // this.getFilteredExamplesExceptForParticularChart({histogram, score})] + // returns data for when the bin_for_score=2 filter is not applied. + // this.getFilteredExamplesExceptForParticularChart({histogram, x}) returns + // data for when the bin_for_field_x=5 filter is not applied. + getFilteredExamplesExceptForParticularChart(chartKey) { + let examples = this.filteredExamplesExceptChartSelections; + if (chartKey.chartType === "histogram" /* HISTOGRAM */ && chartKey.fieldId === FIELD_ID_FOR_SCORE) { + examples = this.applyHistogramFilterForCustomFuncs(examples); + examples = this.applyHistogramFilterForCustomFields(examples); + examples = this.applyBarChartFilterForCustomFields(examples); + examples = this.applyTagFilter(examples); + examples = this.applyRationaleClusterFilter(examples); + } else if (chartKey.chartType === "histogram" /* HISTOGRAM */) { + examples = this.applyHistogramFilterForScores(examples); + examples = this.applyHistogramFilterForCustomFuncs(examples); + examples = this.applyBarChartFilterForCustomFields(examples); + examples = this.applyTagFilter(examples); + examples = this.applyRationaleClusterFilter(examples); + examples = this.applyHistogramFilterForCustomFields( + examples, + chartKey.fieldId, + chartKey.model + ); + } else if (chartKey.chartType === "custom_function" /* CUSTOM_FUNCTION */) { + examples = this.applyHistogramFilterForScores(examples); + examples = this.applyHistogramFilterForCustomFields(examples); + examples = this.applyBarChartFilterForCustomFields(examples); + examples = this.applyTagFilter(examples); + examples = this.applyRationaleClusterFilter(examples); + const splitFieldId = chartKey.fieldId.split(":"); + const customFuncIdOfHistogramToIgnore = splitFieldId.length === 2 ? Number(splitFieldId[1]) : null; + const modelFromCustomFuncOfHistogramToIgnore = chartKey.model; + examples = this.applyHistogramFilterForCustomFuncs( + examples, + customFuncIdOfHistogramToIgnore, + modelFromCustomFuncOfHistogramToIgnore + ); + } else if (chartKey.chartType === "bar" /* BAR_CHART */) { + examples = this.applyHistogramFilterForScores(examples); + examples = this.applyHistogramFilterForCustomFuncs(examples); + examples = this.applyHistogramFilterForCustomFields(examples); + examples = this.applyTagFilter(examples); + examples = this.applyRationaleClusterFilter(examples); + const modelIndex = chartKey.model == null ? 0 : chartKey.model; + examples = this.applyBarChartFilterForCustomFields( + examples, + chartKey.fieldId, + modelIndex + ); + } else if (chartKey.chartType === "tag" /* TAG */) { + examples = this.applyHistogramFilterForScores(examples); + examples = this.applyHistogramFilterForCustomFuncs(examples); + examples = this.applyHistogramFilterForCustomFields(examples); + examples = this.applyBarChartFilterForCustomFields(examples); + examples = this.applyRationaleClusterFilter(examples); + } else if (chartKey.chartType === "rationale_cluster" /* RATIONALE_CLUSTER */) { + examples = this.applyHistogramFilterForScores(examples); + examples = this.applyHistogramFilterForCustomFuncs(examples); + examples = this.applyHistogramFilterForCustomFields(examples); + examples = this.applyBarChartFilterForCustomFields(examples); + examples = this.applyTagFilter(examples); + } + return examples; + } + get filteredExamples() { + let examples = this.filteredExamplesExceptChartSelections; + examples = this.applyHistogramFilterForScores(examples); + examples = this.applyHistogramFilterForCustomFuncs(examples); + examples = this.applyHistogramFilterForCustomFields(examples); + examples = this.applyBarChartFilterForCustomFields(examples); + examples = this.applyTagFilter(examples); + examples = this.applyRationaleClusterFilter(examples); + return examples; + } + get sortedExamples() { + let examples = this.filteredExamples; + const sorting = this.currentSorting; + if (sorting.column === "None" /* NONE */ || sorting.order === "None" /* NONE */) { + return examples; + } + if (sorting.column === "score" /* SCORE */) { + examples = examples.slice().sort( + (a11, b7) => compareNumbersWithNulls( + a11.score, + b7.score, + sorting.order === "desc" /* DESC */ + ) + ); + } else if (sorting.column === "tags" /* TAGS */) { + examples = examples.slice().sort( + (a11, b7) => sorting.order === "desc" /* DESC */ ? b7.tags.join(",").localeCompare(a11.tags.join(",")) : a11.tags.join(",").localeCompare(b7.tags.join(",")) + ); + } else if (sorting.column === "value from selected Custom Function for Output A" /* FUNC_A */ || sorting.column === "value from selected Custom Function for Output B" /* FUNC_B */) { + const selectedCustomFunc = this.selectedCustomFunc; + const modelIndex = sorting.column === "value from selected Custom Function for Output A" /* FUNC_A */ ? 0 : 1; + if (selectedCustomFunc != null && selectedCustomFunc.returnType === "Number" /* NUMBER */) { + const fieldId = getFieldIdForCustomFunc(selectedCustomFunc.id); + examples = examples.slice().sort( + (ex0, ex1) => sorting.order === "desc" /* DESC */ ? ex1.custom_fields[fieldId][modelIndex] - ex0.custom_fields[fieldId][modelIndex] : ex0.custom_fields[fieldId][modelIndex] - ex1.custom_fields[fieldId][modelIndex] + ); + } + } else if (sorting.column === "custom attribute" /* CUSTOM_ATTRIBUTE */ && sorting.customField != null) { + const fieldId = sorting.customField.id; + const fieldType = this.columns.filter((field) => field.id === fieldId)[0].type; + if (fieldType === "per_model_number" && sorting.modelIndex != null) { + const getValueForPerModelNumber = (ex) => ex.custom_fields[fieldId][sorting.modelIndex]; + examples = examples.slice().sort( + (a11, b7) => compareNumbersWithNulls( + getValueForPerModelNumber(a11), + getValueForPerModelNumber(b7), + sorting.order === "desc" /* DESC */ + ) + ); + } else if ((fieldType === "per_model_boolean" || fieldType === "per_model_category") && sorting.modelIndex != null) { + const castToString = (value) => typeof value === "boolean" ? String(value) : value; + const getValueForPerModelString = (ex) => ex.custom_fields[fieldId].map( + (value) => castToString(value) + )[sorting.modelIndex]; + examples = examples.slice().sort( + (a11, b7) => sorting.order === "desc" /* DESC */ ? compareStringsWithNulls( + getValueForPerModelString(b7), + getValueForPerModelString(a11) + ) : compareStringsWithNulls( + getValueForPerModelString(a11), + getValueForPerModelString(b7) + ) + ); + } else if (fieldType === "number") { + const getValueForNumber = (ex) => ex.custom_fields[fieldId]; + examples = examples.slice().sort( + (a11, b7) => compareNumbersWithNulls( + getValueForNumber(a11), + getValueForNumber(b7), + sorting.order === "desc" /* DESC */ + ) + ); + } else { + const getValueForString = (ex) => ex.custom_fields[fieldId]; + examples = examples.slice().sort( + (a11, b7) => sorting.order === "desc" /* DESC */ ? compareStringsWithNulls( + getValueForString(b7), + getValueForString(a11) + ) : compareStringsWithNulls( + getValueForString(a11), + getValueForString(b7) + ) + ); + } + } else if (sorting.column === "similarity between cluster label and the most similar rationale" /* RATIONALE_CLUSTER */) { + const maxSimilarityValueFromRationaleListItems = (rationaleListItems) => Math.max( + ...rationaleListItems.filter( + (rationaleItem) => (rationaleItem.assignedClusterIds || []).includes( + this.selectedRationaleClusterId + ) + ).map( + (rationaleItem) => rationaleItem.similarities[this.selectedRationaleClusterId] + ) + ); + examples = examples.slice().sort( + (a11, b7) => maxSimilarityValueFromRationaleListItems(b7.rationale_list) - maxSimilarityValueFromRationaleListItems(a11.rationale_list) + ); + } + return examples; + } + get examplesForMainTable() { + return this.sortedExamples.slice(0, this.numExamplesToDisplay); + } + // Reset state variables. + resetVariables() { + this.isShowTextDiff = true; + this.selectedExample = null; + this.selectedTag = null; + this.selectedCustomFuncId = null; + this.isExampleExpanded = {}; + this.selectedHistogramBinForScores = null; + this.selectedHistogramBinForCustomFields = {}; + this.selectedBarChartValues = {}; + this.selectionsFromCustomFuncResults = {}; + this.selectedRationaleClusterId = null; + this.searchFilters = {}; + this.searchFilterInputs = {}; + [ + FIELD_ID_FOR_INPUT, + FIELD_ID_FOR_OUTPUT_A, + FIELD_ID_FOR_OUTPUT_B, + FIELD_ID_FOR_RATIONALES, + FIELD_ID_FOR_RATIONALE_LIST + ].forEach((fieldId) => void this.resetSearchFilter(fieldId)); + this.currentSorting = DEFAULT_SORTING_CRITERIA; + this.numExamplesToDisplay = DEFAULT_NUM_EXAMPLES_TO_DISPLAY; + this.columns = DEFAULT_COLUMN_LIST; + this.customFunctions = {}; + this.histogramSpecForCustomFuncs = {}; + this.histogramSpecForCustomFuncsOfDiff = {}; + this.histogramSpecForCustomFields = {}; + this.winRateThreshold = DEFAULT_WIN_RATE_THRESHOLD; + this.hasRationaleClusters = false; + } + initialize() { + const urlSearchParams = new URLSearchParams(window.location.search); + const params = {}; + for (const [key, value] of urlSearchParams) { + params[key] = decodeURIComponent(value); + } + if (params.hasOwnProperty("results_path")) { + const datasetPath = params["results_path"]; + const maxExamplesToLoad = params.hasOwnProperty("max_examples") ? Number(params["max_examples"]) : null; + const samplingStepSize = params.hasOwnProperty("sampling_step_size") ? Number(params["sampling_step_size"]) : null; + const columnsToHide = params.hasOwnProperty("hide_columns") ? params["hide_columns"].split(",") : []; + this.loadData( + datasetPath, + null, + maxExamplesToLoad, + samplingStepSize, + columnsToHide + ); + } + } + // Update the sorting option. + updateSorting(sorting) { + this.currentSorting = sorting; + } + // Reset the sorting option. + resetSorting() { + this.currentSorting = DEFAULT_SORTING_CRITERIA; + } + // Update the status message. + updateStatusMessage(message, hasTimeout = false) { + this.statusMessage = message; + this.isOpenStatusMessage = true; + if (this.statusMessageTimeout != null) { + clearTimeout(this.statusMessageTimeout); + } + if (hasTimeout === true) { + this.statusMessageTimeout = setTimeout( + () => this.isOpenStatusMessage = false, + 5e3 + ); + } + } + get appLink() { + return `https://pair-code.github.io/llm-comparator/`; + } + determineHistogramSpecForScores() { + let minValue = 0; + let maxValue = 0; + const individualRaterScores = this.examples.flatMap( + (ex) => ex.individual_rater_scores.map((rating) => rating.score) + ); + if (individualRaterScores.length > 0) { + const minAndMaxFromIndividualScores = getMinAndMax(individualRaterScores); + minValue = minAndMaxFromIndividualScores.minValue; + maxValue = minAndMaxFromIndividualScores.maxValue; + } else { + const minAndMax = getMinAndMax(this.examples.map((ex) => ex.score)); + minValue = minAndMax.minValue; + maxValue = minAndMax.maxValue; + } + if (minValue === 1 && maxValue === 5) { + this.histogramSpecForScores = FIVE_POINT_LIKERT_HISTOGRAM_SPEC; + } else if (minValue >= 1) { + this.histogramSpecForScores = { + rangeLeft: minValue, + rangeRight: maxValue, + numberOfBins: 7, + isBounded: true, + isDivergingScheme: false + }; + } else { + this.histogramSpecForScores = DEFAULT_HISTOGRAM_SPEC; + } + } + // Add histogram spec for custom functions with return type number. + // TODO: Merge with the side-by-side histograms. + addHistogramSpecForCustomFunc(customFunc) { + if (customFunc.returnType === "Number" /* NUMBER */) { + const fieldId = getFieldIdForCustomFunc(customFunc.id); + const minAndMaxValues = getMinAndMax([ + ...this.examples.map( + (ex) => ex.custom_fields[fieldId][0] + ), + ...this.examples.map( + (ex) => ex.custom_fields[fieldId][1] + ) + ]); + const rangeLeft = minAndMaxValues.minValue; + const verySmallValue = 1e-8; + const rangeRight = minAndMaxValues.maxValue === rangeLeft ? minAndMaxValues.maxValue + verySmallValue : minAndMaxValues.maxValue; + this.histogramSpecForCustomFuncs[customFunc.id] = { + rangeLeft, + rangeRight, + numberOfBins: 6, + isBounded: true, + isDivergingScheme: false + }; + const minAndMaxDiff = getMinAndMax( + this.examples.filter( + (ex) => ex.custom_fields[fieldId][0] != null && ex.custom_fields[fieldId][1] != null + ).map( + (ex) => ex.custom_fields[fieldId][0] - ex.custom_fields[fieldId][1] + ) + ); + const absoluteMax = Math.max( + Math.abs(minAndMaxDiff.minValue), + Math.abs(minAndMaxDiff.maxValue) + ); + const rangeEnd = absoluteMax === 0 ? 1 : absoluteMax; + this.histogramSpecForCustomFuncsOfDiff[customFunc.id] = { + rangeLeft: -rangeEnd, + rangeRight: rangeEnd, + numberOfBins: 7, + isBounded: true, + isDivergingScheme: true + }; + } + } + // Add histogram spec for custom functions for custom fields. + addHistogramSpecForCustomFields(field) { + if (field.type === "number" /* NUMBER */) { + const { minValue, maxValue } = getMinAndMax( + this.examples.map( + (ex) => convertToNumber(ex.custom_fields[field.id]) + ) + ); + this.histogramSpecForCustomFields[field.id] = { + rangeLeft: minValue, + rangeRight: maxValue, + numberOfBins: 6, + isBounded: true, + isDivergingScheme: false + }; + this.selectedHistogramBinForCustomFields[field.id] = null; + } else if (field.type === "per_model_number" /* PER_MODEL_NUMBER */) { + const minAndMaxValues = getMinAndMax([ + ...this.examples.map( + (ex) => ex.custom_fields[field.id][0] + ), + ...this.examples.map( + (ex) => ex.custom_fields[field.id][1] + ) + ]); + const rangeLeft = minAndMaxValues.minValue; + const verySmallValue = 1e-8; + const rangeRight = minAndMaxValues.maxValue === rangeLeft ? minAndMaxValues.maxValue + verySmallValue : minAndMaxValues.maxValue; + this.histogramSpecForCustomFields[field.id] = { + rangeLeft, + rangeRight, + numberOfBins: 6, + isBounded: true, + isDivergingScheme: false + }; + this.selectedHistogramBinForCustomFields[field.id] = { + "A": null, + "B": null + }; + } + } + // Read an uploaded json file. + readFileContent(file) { + return new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.onload = (event) => { + if (event.target?.result) { + resolve(event.target.result.toString()); + } else { + reject(new Error("Failed to read file content.")); + } + }; + reader.readAsText(file); + }); + } + // Load data either from a specified path or uploaded file. + async loadData(datasetPath, fileObject = null, maxNumExamplesToDisplay = null, samplingStepSize = null, columnsToHide = []) { + this.isOpenDatasetSelectionPanel = false; + this.updateStatusMessage("Loading the dataset... Please wait..."); + let dataResponse; + if (fileObject != null) { + try { + const fileContent = await this.readFileContent(fileObject); + const jsonResponse = JSON.parse(fileContent); + dataResponse = jsonResponse; + } catch (error) { + console.error(error); + this.updateStatusMessage( + `Encountered an error while loading file "${datasetPath}": ${error}` + ); + this.isOpenDatasetSelectionPanel = true; + return; + } + } else { + try { + let response = new Response(); + if (datasetPath.startsWith("http")) { + response = await fetch(datasetPath, { + headers: { "Accept": "application/json" } + }); + } else { + const errorMessage = "Unsupported data loading method. Please provide a web URL or use the file uploader."; + throw new Error(errorMessage); + } + if (response.status === 502) { + const errorMessage = `Failed to load the dataset. The server may not exist anymore, possibly with updated URLs. Try opening this URL (${this.appLink}), rather than refreshing the page.`; + throw new Error(errorMessage); + } + const jsonResponse = await response.json(); + if (jsonResponse.hasOwnProperty("error")) { + throw new Error(jsonResponse.error); + } + dataResponse = jsonResponse; + } catch (error) { + console.error(error); + this.updateStatusMessage( + `Encountered an error while loading "${datasetPath}": ${error}` + ); + this.isOpenDatasetSelectionPanel = true; + return; + } + } + this.datasetPath = datasetPath; + this.isDatasetPathUploadedFile = fileObject != null; + this.metadata = dataResponse.metadata; + this.models = dataResponse.models; + this.examples = dataResponse.examples.map( + (example, index) => { + example.index = index; + example.individual_rater_scores.forEach( + (rating, ratingIndex) => { + rating.index = ratingIndex; + } + ); + return example; + } + ); + this.resetVariables(); + if (dataResponse.rationale_clusters) { + this.rationaleClusters = [ + { + id: -1, + title: "(others)", + aWinCount: 0, + bWinCount: 0 + }, + ...dataResponse.rationale_clusters.map( + (cluster, clusterIndex) => { + return { + id: clusterIndex, + title: cluster.title, + aWinCount: 0, + bWinCount: 0 + }; + } + ) + ]; + this.hasRationaleClusters = this.rationaleClusters.length > 1; + if (this.hasRationaleClusters === true) { + this.columns.filter( + (field) => field.id === FIELD_ID_FOR_RATIONALE_LIST + )[0].visible = true; + this.reassignClusters(); + } + } + this.determineHistogramSpecForScores(); + const fieldTypes = Object.values(FieldType); + this.metadata.custom_fields_schema.forEach( + (loadedField) => { + if (!fieldTypes.includes(loadedField.type)) { + this.updateStatusMessage( + `${loadedField.name} is not a valid field type. It should be one of [${fieldTypes.join( + ", " + )}].` + ); + } + const fieldId = `custom_field:${loadedField.name}`; + const field = { + id: fieldId, + name: loadedField.name, + type: loadedField.type, + visible: !columnsToHide.includes(loadedField.name) && !this.customFieldsOfPerRatingTypesWithNoAggregationSupport().includes( + loadedField.type + ), + domain: loadedField.domain || void 0 + }; + this.columns.push(field); + } + ); + this.customFieldsWithoutPerRatingType.forEach((field) => { + this.examples.forEach((ex) => { + const value = ex.custom_fields[field.name]; + ex.custom_fields[field.id] = value; + delete ex.custom_fields[field.name]; + }); + this.addHistogramSpecForCustomFields(field); + if (field.type === "category" /* CATEGORY */) { + this.selectedBarChartValues[field.id] = [null]; + } else if (field.type === "per_model_category" /* PER_MODEL_CATEGORY */ || field.type === "per_model_boolean" /* PER_MODEL_BOOLEAN */) { + this.selectedBarChartValues[field.id] = [null, null]; + } + if (field.type === "text" /* TEXT */) { + this.resetSearchFilter(field.id); + } + }); + this.customFieldsOfPerRatingType.forEach((ratingField) => { + this.examples.forEach((ex) => { + if (ratingField.type === "per_rating_string" /* PER_RATING_STRING */) { + ex.individual_rater_scores.forEach((rating) => { + const value = rating.custom_fields[ratingField.name]; + rating.custom_fields[ratingField.id] = value; + delete rating.custom_fields[ratingField.name]; + }); + } else if (ratingField.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */) { + ex.individual_rater_scores.forEach((rating) => { + const value = rating.custom_fields[ratingField.name] || [ + null, + null + ]; + rating.custom_fields[ratingField.id] = value; + delete rating.custom_fields[ratingField.name]; + }); + } + }); + this.examples.forEach((ex) => { + if (ratingField.type === "per_rating_string" /* PER_RATING_STRING */) { + ex.custom_fields[ratingField.id] = ex.individual_rater_scores.map( + (rating) => rating.custom_fields[ratingField.id] + ).join("\n"); + } else if (ratingField.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */) { + ex.custom_fields[ratingField.id] = this.models.map( + (unused, modelIndex) => { + const valuesAcrossRatings = ex.individual_rater_scores.map( + (rating) => rating.custom_fields[ratingField.id][modelIndex] + ); + return groupByValues(valuesAcrossRatings); + } + ); + } + }); + if (ratingField.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */) { + this.computeValueDomainForCustomField(ratingField); + this.selectedBarChartValues[ratingField.id] = [null, null]; + } + }); + if (this.columns.filter((field) => field.type !== "base" /* BASE */).length > 0) { + this.isOpenSettingsPanel = true; + } + for (let i23 = 0; i23 < this.examples.length; i23++) { + const ex = this.examples[i23]; + if (typeof ex.output_text_a !== "string" || typeof ex.output_text_b !== "string") { + this.isShowTextDiff = false; + break; + } + } + INITIAL_CUSTOM_FUNCTIONS.forEach((customFunc) => { + const newId = this.newCustomFuncId; + customFunc.id = newId; + this.customFunctions[newId] = customFunc; + this.selectionsFromCustomFuncResults[newId] = initializeCustomFuncSelections(); + this.runCustomFunction(this.examples, customFunc); + }); + const statusMessage = `Loaded the dataset of ${this.examples.length} examples.`; + this.updateStatusMessage(statusMessage, true); + const url = new URL(window.location.href); + if (this.isDatasetPathUploadedFile === false) { + url.searchParams.set("results_path", this.datasetPath); + if (columnsToHide.length > 0) { + url.searchParams.set("hide_columns", columnsToHide.join(",")); + } else { + if (url.searchParams.has("hide_columns")) { + url.searchParams.delete("hide_columns"); + } + } + if (maxNumExamplesToDisplay != null) { + url.searchParams.set( + "max_examples", + maxNumExamplesToDisplay.toString() + ); + } else { + if (url.searchParams.has("max_examples")) { + url.searchParams.delete("max_examples"); + } + } + } else { + url.searchParams.delete("results_path"); + } + window.history.pushState({}, "", url.toString()); + } + // Run a custom function over all examples. + runCustomFunction(examples, customFunc) { + try { + const results = { "A": {}, "B": {} }; + examples.forEach((example, index) => { + Object.values(AOrB).forEach((model) => { + const output = model === "A" /* A */ ? example.output_text_a : example.output_text_b; + const result = this.customFunctionService.executeCustomFunction( + extractTextFromTextOrSequenceChunks(output), + example, + customFunc + ); + if (index === 0 && result === void 0) { + throw new Error( + "Encountered an error while executing the function. See console for details." + ); + } else if (result === void 0) { + results[model][example.index] = null; + } else { + results[model][example.index] = result; + } + }); + }); + const fieldId = getFieldIdForCustomFunc(customFunc.id); + examples.forEach((example) => { + example.custom_fields[fieldId] = [ + results["A" /* A */][example.index], + results["B" /* B */][example.index] + ]; + }); + this.customFunctions[customFunc.id] = customFunc; + this.selectionsFromCustomFuncResults[customFunc.id] = initializeCustomFuncSelections(); + this.addHistogramSpecForCustomFunc(customFunc); + this.isShowCustomFuncEditor = false; + const fieldType = customFunc.returnType === "Boolean" /* BOOLEAN */ ? "per_model_boolean" /* PER_MODEL_BOOLEAN */ : customFunc.returnType === "Number" /* NUMBER */ ? "per_model_number" /* PER_MODEL_NUMBER */ : "per_model_category" /* PER_MODEL_CATEGORY */; + const existingField = this.columns.filter( + (field) => field.id === fieldId + ); + if (existingField.length > 0) { + existingField[0].name = customFunc.name; + existingField[0].type = fieldType; + } else { + this.columns.push({ + id: fieldId, + name: customFunc.name, + type: fieldType, + visible: false + }); + } + this.updateStatusMessage( + "Completed executing the function over examples.", + true + ); + } catch (error) { + console.error(error); + this.updateStatusMessage(error, false); + } + } + // Remove a rationale cluster row. + removeCluster(clusterId) { + if (clusterId === this.selectedRationaleClusterId) { + this.selectedRationaleClusterId = null; + } + this.rationaleClusters = this.rationaleClusters.filter( + (cluster) => cluster.id !== clusterId + ); + this.reassignClusters(); + } + // Check if the similarity between a rationale phrase (each bullet item) + // and a cluster title is above the threshold. + reassignClusters() { + this.examples.forEach((example) => { + example.rationale_list.forEach((rationaleItem) => { + rationaleItem.assignedClusterIds = this.rationaleClusters.map((cluster) => cluster.id).filter( + (clusterId) => clusterId >= 0 && rationaleItem.similarities[clusterId] >= this.rationaleClusterSimilarityThreshold + ); + if (rationaleItem.assignedClusterIds.length === 0) { + rationaleItem.assignedClusterIds = [-1]; + } + }); + }); + } + }; + __decorateClass([ + observable + ], AppState.prototype, "metadata", 2); + __decorateClass([ + observable + ], AppState.prototype, "models", 2); + __decorateClass([ + observable + ], AppState.prototype, "examples", 2); + __decorateClass([ + observable + ], AppState.prototype, "rationaleClusters", 2); + __decorateClass([ + observable + ], AppState.prototype, "datasetPath", 2); + __decorateClass([ + observable + ], AppState.prototype, "isDatasetPathUploadedFile", 2); + __decorateClass([ + observable + ], AppState.prototype, "isOpenDatasetSelectionPanel", 2); + __decorateClass([ + observable + ], AppState.prototype, "exampleDatasetPaths", 2); + __decorateClass([ + observable + ], AppState.prototype, "selectedTag", 2); + __decorateClass([ + observable + ], AppState.prototype, "currentSorting", 2); + __decorateClass([ + observable + ], AppState.prototype, "isExampleExpanded", 2); + __decorateClass([ + observable + ], AppState.prototype, "selectedExample", 2); + __decorateClass([ + observable + ], AppState.prototype, "showSelectedExampleDetails", 2); + __decorateClass([ + observable + ], AppState.prototype, "exampleDetailsPanelExpanded", 2); + __decorateClass([ + observable + ], AppState.prototype, "hasRationaleClusters", 2); + __decorateClass([ + observable + ], AppState.prototype, "selectedRationaleClusterId", 2); + __decorateClass([ + observable + ], AppState.prototype, "hoveredRationaleClusterId", 2); + __decorateClass([ + observable + ], AppState.prototype, "matchedRationaleClusterIds", 2); + __decorateClass([ + observable + ], AppState.prototype, "rationaleClusterSimilarityThreshold", 2); + __decorateClass([ + observable + ], AppState.prototype, "columns", 2); + __decorateClass([ + observable + ], AppState.prototype, "showSidebarComponents", 2); + __decorateClass([ + observable + ], AppState.prototype, "selectedBarChartValues", 2); + __decorateClass([ + observable + ], AppState.prototype, "histogramSpecForScores", 2); + __decorateClass([ + observable + ], AppState.prototype, "selectedHistogramBinForScores", 2); + __decorateClass([ + observable + ], AppState.prototype, "histogramSpecForCustomFields", 2); + __decorateClass([ + observable + ], AppState.prototype, "selectedHistogramBinForCustomFields", 2); + __decorateClass([ + observable + ], AppState.prototype, "selectedHistogramBinForRatingsForSelectedExample", 2); + __decorateClass([ + observable + ], AppState.prototype, "selectedBarChartValueForSelectedExample", 2); + __decorateClass([ + observable + ], AppState.prototype, "winRateThreshold", 2); + __decorateClass([ + observable + ], AppState.prototype, "isFlipScoreHistogramAxis", 2); + __decorateClass([ + observable + ], AppState.prototype, "statusMessage", 2); + __decorateClass([ + observable + ], AppState.prototype, "isOpenStatusMessage", 2); + __decorateClass([ + observable + ], AppState.prototype, "searchFilters", 2); + __decorateClass([ + observable + ], AppState.prototype, "searchFilterInputs", 2); + __decorateClass([ + observable + ], AppState.prototype, "isOpenSettingsPanel", 2); + __decorateClass([ + observable + ], AppState.prototype, "isShowTextDiff", 2); + __decorateClass([ + observable + ], AppState.prototype, "useMonospace", 2); + __decorateClass([ + observable + ], AppState.prototype, "numExamplesToDisplay", 2); + __decorateClass([ + observable + ], AppState.prototype, "isShowTagChips", 2); + __decorateClass([ + observable + ], AppState.prototype, "isShowSidebar", 2); + __decorateClass([ + observable + ], AppState.prototype, "numberOfLinesPerOutputCell", 2); + __decorateClass([ + computed + ], AppState.prototype, "numberOfShownTextColumns", 1); + __decorateClass([ + computed + ], AppState.prototype, "scoreMiddlePoint", 1); + __decorateClass([ + computed + ], AppState.prototype, "isScoreDivergingScheme", 1); + __decorateClass([ + observable + ], AppState.prototype, "customFunctions", 2); + __decorateClass([ + observable + ], AppState.prototype, "histogramSpecForCustomFuncs", 2); + __decorateClass([ + observable + ], AppState.prototype, "histogramSpecForCustomFuncsOfDiff", 2); + __decorateClass([ + observable + ], AppState.prototype, "selectedCustomFuncId", 2); + __decorateClass([ + observable + ], AppState.prototype, "selectionsFromCustomFuncResults", 2); + __decorateClass([ + computed + ], AppState.prototype, "selectedCustomFunc", 1); + __decorateClass([ + computed + ], AppState.prototype, "selectedCustomFuncName", 1); + __decorateClass([ + computed + ], AppState.prototype, "newCustomFuncId", 1); + __decorateClass([ + observable + ], AppState.prototype, "isShowCustomFuncEditor", 2); + __decorateClass([ + computed + ], AppState.prototype, "customFieldsOfNumberType", 1); + __decorateClass([ + computed + ], AppState.prototype, "customFieldsOfCategoryType", 1); + __decorateClass([ + computed + ], AppState.prototype, "customFieldsOfPerModelNumberType", 1); + __decorateClass([ + computed + ], AppState.prototype, "customFieldsOfPerModelCategoryTypeIncludingPerRating", 1); + __decorateClass([ + computed + ], AppState.prototype, "visibleColumns", 1); + __decorateClass([ + observable + ], AppState.prototype, "valueDomainsForCustomFields", 2); + __decorateClass([ + computed + ], AppState.prototype, "individualRatingScoreValueDomain", 1); + __decorateClass([ + computed + ], AppState.prototype, "filteredExamplesExceptChartSelections", 1); + __decorateClass([ + computed + ], AppState.prototype, "filteredExamples", 1); + __decorateClass([ + computed + ], AppState.prototype, "sortedExamples", 1); + __decorateClass([ + computed + ], AppState.prototype, "examplesForMainTable", 1); + __decorateClass([ + computed + ], AppState.prototype, "appLink", 1); + + // client/core.ts + var Core = class { + constructor() { + this.services = /* @__PURE__ */ new Map(); + this.buildServices(); + } + async initialize() { + const appState = this.getService(AppState); + appState.initialize(); + } + buildServices() { + const customFunctionService = new CustomFunctionService(); + const appState = new AppState(customFunctionService); + this.services.set(CustomFunctionService, customFunctionService); + this.services.set(AppState, appState); + } + getService(t17) { + const service = this.services.get(t17); + if (service === void 0) { + throw new Error(`Service is undefined: ${t17.name}`); + } + return service; + } + }; + var core = new Core(); + + // client/components/charts.ts + var ChartsElement = class extends MobxLitElement { + constructor() { + super(...arguments); + this.appState = core.getService(AppState); + this.svgWidth = 220; + this.svgHeight = 110; + } + renderCustomFieldHistogram(field) { + const chartSelectionKey = { + chartType: "histogram" /* HISTOGRAM */, + fieldId: field.id, + model: null + }; + const getHistogramRawDataValues = () => this.appState.getFilteredExamplesExceptForParticularChart(chartSelectionKey).filter((ex) => ex.custom_fields[field.id] != null).map((ex) => ex.custom_fields[field.id]); + const handleClickHistogramBar = (binIndex) => { + if (this.appState.selectedHistogramBinForCustomFields[field.id] === binIndex) { + this.appState.selectedHistogramBinForCustomFields[field.id] = null; + } else { + this.appState.selectedHistogramBinForCustomFields[field.id] = binIndex; + } + }; + const isAnyBinSelected = () => this.appState.selectedHistogramBinForCustomFields[field.id] !== null; + const isThisBinSelected = (binIndex) => binIndex === this.appState.selectedHistogramBinForCustomFields[field.id]; + return x` + this.appState.histogramSpecForCustomFields[field.id]} + .getRawDataValues=${getHistogramRawDataValues} + .handleClickHistogramBar=${handleClickHistogramBar} + .isAnyBinSelected=${isAnyBinSelected} + .isThisBinSelected=${isThisBinSelected} + .svgHeight=${60}> + `; + } + renderCustomFieldSideBySideHistogram(field) { + const getHistogramSpec = () => this.appState.histogramSpecForCustomFields[field.id]; + const chartSelectionKey = (model) => ({ + chartType: "histogram" /* HISTOGRAM */, + fieldId: field.id, + model + }); + const getHistogramDataForA = () => this.appState.getFilteredExamplesExceptForParticularChart(chartSelectionKey("A")).filter( + (ex) => ex.custom_fields[field.id][0] != null + ).map((ex) => ex.custom_fields[field.id][0]); + const getHistogramDataForB = () => this.appState.getFilteredExamplesExceptForParticularChart(chartSelectionKey("B")).filter( + (ex) => ex.custom_fields[field.id][1] != null + ).map((ex) => ex.custom_fields[field.id][1]); + const handleClickHistogramBar = (binIndex, model) => { + if (this.appState.selectedHistogramBinForCustomFields[field.id][model] === binIndex) { + this.appState.selectedHistogramBinForCustomFields[field.id][model] = null; + } else { + this.appState.selectedHistogramBinForCustomFields[field.id][model] = binIndex; + } + }; + const handleClickHistogramBarForA = (binIndex) => void handleClickHistogramBar(binIndex, "A" /* A */); + const handleClickHistogramBarForB = (binIndex) => void handleClickHistogramBar(binIndex, "B" /* B */); + const selections = this.appState.selectedHistogramBinForCustomFields[field.id]; + const isAnyBinSelectedForA = () => selections["A"] != null; + const isAnyBinSelectedForB = () => selections["B"] != null; + const isThisBinSelectedForA = (binIndex) => selections["A"] === binIndex; + const isThisBinSelectedForB = (binIndex) => selections["B"] === binIndex; + if (getHistogramSpec() !== void 0) { + return x` + + + `; + } else { + return x``; + } + } + renderCustomFieldBarChart(field) { + const getValueDomain = () => { + const values = this.appState.examples.filter((ex) => ex.custom_fields[field.id] != null).map((ex) => ex.custom_fields[field.id]); + if (field.domain !== void 0) { + return mergeTwoArrays(field.domain, groupByAndSortKeys(values)); + } else { + return groupByAndSortKeys(values); + } + }; + const chartSelectionKey = { + chartType: "bar" /* BAR_CHART */, + fieldId: field.id, + model: null + }; + const getBarChartData = () => this.appState.getFilteredExamplesExceptForParticularChart(chartSelectionKey).filter((ex) => ex.custom_fields[field.id] != null).map((ex) => ex.custom_fields[field.id]); + const handleClickBar = (value) => { + if (this.appState.selectedBarChartValues[field.id][0] === value) { + this.appState.selectedBarChartValues[field.id][0] = null; + } else { + this.appState.selectedBarChartValues[field.id][0] = value; + } + }; + const isAnyBarSelected = () => this.appState.selectedBarChartValues[field.id][0] !== null; + const isThisBarSelected = (value) => this.appState.selectedBarChartValues[field.id][0] === value; + return x` + + `; + } + renderCustomFieldSideBySideBarChart(field) { + const groupCount = this.appState.models.length; + const groupIndices = Array.from({ length: groupCount }, (unused, i23) => i23); + const getValueDomain = () => { + const getValue = (ex) => ex.custom_fields[field.id]; + const values = groupIndices.flatMap( + (groupIndex) => this.appState.examples.filter((ex) => getValue(ex)[groupIndex] != null).map((ex) => getValue(ex)[groupIndex].toString()) + ); + if (field.domain !== void 0) { + return mergeTwoArrays(field.domain, groupByAndSortKeys(values)); + } else { + return groupByAndSortKeys(values); + } + }; + const chartSelectionKey = (groupIndex) => ({ + chartType: "bar" /* BAR_CHART */, + fieldId: field.id, + model: groupIndex + }); + const getBarChartData = () => { + const getValue = (ex) => ex.custom_fields[field.id]; + return groupIndices.map( + (groupIndex) => this.appState.getFilteredExamplesExceptForParticularChart( + chartSelectionKey(groupIndex) + ).filter((ex) => getValue(ex)[groupIndex] != null).map((ex) => getValue(ex)[groupIndex].toString()) + ); + }; + const handleClickBar = (value, groupIndex) => { + if (this.appState.selectedBarChartValues[field.id][groupIndex] === value) { + this.appState.selectedBarChartValues[field.id][groupIndex] = null; + } else { + this.appState.selectedBarChartValues[field.id][groupIndex] = value; + } + }; + const isAnyBarSelected = (groupIndex) => this.appState.selectedBarChartValues[field.id][groupIndex] !== null; + const isThisBarSelected = (value, groupIndex) => this.appState.selectedBarChartValues[field.id][groupIndex] === value; + return x` + `; + } + // Side-by-side bar charts for per-rating-per-model type. + renderCustomFieldPerRatingSideBySideBarChart(field) { + const groupCount = this.appState.models.length; + const groupIndices = Array.from({ length: groupCount }, (unused, i23) => i23); + const getValueDomain = () => { + return this.appState.valueDomainsForCustomFields[field.id]; + }; + const chartSelectionKey = (groupIndex) => ({ + chartType: "bar" /* BAR_CHART */, + fieldId: field.id, + model: groupIndex + }); + const getBarChartNestedData = () => { + return groupIndices.map( + (groupIndex) => this.appState.getFilteredExamplesExceptForParticularChart( + chartSelectionKey(groupIndex) + ).map((ex) => { + return ex.individual_rater_scores.map( + (rating) => rating.custom_fields[field.id][groupIndex] + ); + }) + ); + }; + const handleClickBar = (value, groupIndex) => { + if (this.appState.selectedBarChartValues[field.id][groupIndex] === value) { + this.appState.selectedBarChartValues[field.id][groupIndex] = null; + } else { + this.appState.selectedBarChartValues[field.id][groupIndex] = value; + } + }; + const isAnyBarSelected = (groupIndex) => this.appState.selectedBarChartValues[field.id][groupIndex] !== null; + const isThisBarSelected = (value, groupIndex) => this.appState.selectedBarChartValues[field.id][groupIndex] === value; + return x` + `; + } + render() { + const renderChartsForCustomFields = this.appState.columns.filter((field) => field.id.startsWith("custom_field:")).filter( + (field) => field.type === "number" /* NUMBER */ || field.type === "category" /* CATEGORY */ || field.type === "per_model_boolean" /* PER_MODEL_BOOLEAN */ || field.type === "per_model_number" /* PER_MODEL_NUMBER */ || field.type === "per_model_category" /* PER_MODEL_CATEGORY */ || field.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */ + ).map((field) => { + if (field.type === "number" /* NUMBER */) { + return [field.name, this.renderCustomFieldHistogram(field)]; + } else if (field.type === "per_model_number" /* PER_MODEL_NUMBER */) { + return [ + field.name, + this.renderCustomFieldSideBySideHistogram(field) + ]; + } else if (field.type === "per_model_category" /* PER_MODEL_CATEGORY */ || field.type === "per_model_boolean" /* PER_MODEL_BOOLEAN */) { + return [ + field.name, + this.renderCustomFieldSideBySideBarChart(field) + ]; + } else if (field.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */) { + return [ + field.name, + this.renderCustomFieldPerRatingSideBySideBarChart(field) + ]; + } else { + return [field.name, this.renderCustomFieldBarChart(field)]; + } + }); + const handleClickTitleBar = (fieldName) => { + const key = `custom_field:${fieldName}`; + if (!this.appState.showSidebarComponents.hasOwnProperty(key)) { + this.appState.showSidebarComponents[key] = true; + } else if (this.appState.showSidebarComponents[key] === false) { + this.appState.showSidebarComponents[key] = true; + } else { + this.appState.showSidebarComponents[key] = false; + } + }; + const renderSidebarComponents = renderChartsForCustomFields.map((chart) => { + const [fieldName, renderChart] = chart; + const key = `custom_field:${fieldName}`; + return x` + `; + }); + return x`${renderSidebarComponents}`; + } + }; + ChartsElement.styles = styles; + ChartsElement = __decorateClass([ + t3("comparator-charts") + ], ChartsElement); + + // client/components/custom_functions.css + var styles4 = i`td { + border-bottom: 1px solid #eee; + height: 60px; + vertical-align: top; +} + +tr:first-child td { + border-top: 1px solid #eee; +} + +tr.selected td, +tr:hover td { + background-color: var(--comparator-custom-func-100); + color: #000; +} + +td.function-info { + padding: 6px 4px 2px 8px; +} + +td.results-chart { + padding-top: 2px; + width: 132px; +} + +td.edit-remove-icons { + width: 20px; + vertical-align: middle; +} + +.function-name { + padding: 3px 0; +} + +.function-type { + color: var(--comparator-grey-450); + font-size: 10px; +} + +.icon { + color: var(--comparator-grey-300); + margin: 2px 0; + font-size: 12px; +} + +.icon.disabled { + visibility: hidden; +} + +line.axis { + fill: none; + stroke: #ccc; + stroke-width: 1; +} + +.custom-func-results-bar { + cursor: pointer; + fill: #f3f3f3; + stroke-width: 0; +} + +.custom-func-results-bar.value-no.selected, +.custom-func-results-bar.value-no:hover { + fill: #e7e7e7; +} + +.model-a { + fill: var(--comparator-model-a); +} + +.model-b { + fill: var(--comparator-model-b); +} + +.custom-func-results-mean { + stroke-width: 0; +} + +.histogram-bar { + fill-opacity: 0.75; +} + +.model-label { + alignment-baseline: hanging; + fill: var(--comparator-grey-500); + font-size: 11px; + text-anchor: middle; +} + +.number-label { + fill: var(--comparator-grey-500); + font-size: 11px; + text-anchor: middle; +} + +.number-label-description { + fill: #bbb; + font-size: 7px; + text-anchor: end; +} + +.edit-custom-function { + background-color: var(--comparator-grey-100); + display: flex; + flex-direction: column; + margin-top: 5px; + padding: 5px 10px; +} + +.edit-custom-function-title { + display: flex; + font-size: 13px; + justify-content: space-between; + padding: 4px 0; +} + +.edit-custom-function-form { + display: flex; + flex-direction: column; + margin-top: 4px; +} + +.field-row { + display: flex; + gap: 4px; + margin: 2px 0; +} + +.field-row .field-row-label { + font-weight: 500; + padding: 4px 0; + width: 45px; +} + +.field-row .field-row-content { + align-items: center; + display: flex; + gap: 8px; +} + +.edit-custom-function .func-name-input { + border: 1px solid var(--comparator-grey-300); + font-family: monospace; + padding: 4px 8px; + width: 220px; +} + +.edit-custom-function textarea { + border: 1px solid var(--comparator-grey-300); + margin-top: 4px; + padding: 4px 6px; + width: 220px; +} + +.run-button { + align-self: end; + background-color: var(--comparator-custom-func-200); + border: 0; + border-radius: 12px; + color: var(--comparator-custom-func-800); + cursor: pointer; + margin-top: 8px; + padding: 6px 0; + width: 80px; +} +`; + + // client/components/custom_functions.ts + var BinaryStackedBarChart = class extends s3 { + constructor() { + super(); + this.svgWidth = 100; + this.svgHeight = 40; + this.customFuncId = -1; + this.countA = 0; + this.countB = 0; + this.numExamples = 0; + this.appState = core.getService(AppState); + this.topPadding = 10; + this.bottomPadding = 15; + this.barSidePadding = 10; + makeObservable(this); + } + get barAreaHeight() { + return this.svgHeight - this.topPadding - this.bottomPadding; + } + get barWidth() { + return this.svgWidth * 0.5 - this.barSidePadding * 2; + } + render() { + const trueRateA = this.numExamples === 0 ? 0 : this.countA / this.numExamples; + const trueRateB = this.numExamples === 0 ? 0 : this.countB / this.numExamples; + const yPositionA = this.barAreaHeight * (1 - trueRateA); + const yPositionB = this.barAreaHeight * (1 - trueRateB); + const selections = this.appState.selectionsFromCustomFuncResults[this.customFuncId]; + const styleBarForFalse = (model) => e6({ + "custom-func-results-bar": true, + "value-no": true, + "selected": selections[model] === false + }); + const styleBarForTrue = (model) => e6({ + "custom-func-results-bar": true, + "model-a": model === "A" /* A */, + "model-b": model === "B" /* B */ + }); + const styleClickableAreasForTrue = (model) => e6({ + "clickable-transparent-area": true, + "selected": selections[model] === true + }); + const handleClickBar = (customFuncId, model, isTrue) => { + const selections2 = this.appState.selectionsFromCustomFuncResults[customFuncId]; + if (selections2[model] === isTrue) { + selections2[model] = null; + } else { + selections2[model] = isTrue; + this.appState.selectedCustomFuncId = customFuncId; + } + }; + const renderBottomAxis = b2` + + + A + B + `; + const renderBarsForFalse = b2` + void handleClickBar(this.customFuncId, "A" /* A */, false)} /> + void handleClickBar(this.customFuncId, "B" /* B */, false)} />`; + const renderBarsForTrue = b2` + + `; + const renderNumberLabelsForTrueCount = b2` + + ${this.countA} + + + ${this.countB} + `; + const renderClickableAreasForTrue = b2` + ${trueRateA > 0 ? b2` + void handleClickBar( + this.customFuncId, + "A" /* A */, + true + )} />` : ""} + ${trueRateB > 0 ? b2` + void handleClickBar( + this.customFuncId, + "B" /* B */, + true + )} />` : ""}`; + return x` + + ${renderBottomAxis} ${renderBarsForFalse} ${renderBarsForTrue} + ${renderNumberLabelsForTrueCount} ${renderClickableAreasForTrue} + + `; + } + }; + BinaryStackedBarChart.styles = [styles, styles4]; + __decorateClass([ + n4({ type: Number }) + ], BinaryStackedBarChart.prototype, "svgWidth", 2); + __decorateClass([ + n4({ type: Number }) + ], BinaryStackedBarChart.prototype, "svgHeight", 2); + __decorateClass([ + n4({ type: Number }) + ], BinaryStackedBarChart.prototype, "customFuncId", 2); + __decorateClass([ + n4({ type: Number }) + ], BinaryStackedBarChart.prototype, "countA", 2); + __decorateClass([ + n4({ type: Number }) + ], BinaryStackedBarChart.prototype, "countB", 2); + __decorateClass([ + n4({ type: Number }) + ], BinaryStackedBarChart.prototype, "numExamples", 2); + __decorateClass([ + computed + ], BinaryStackedBarChart.prototype, "barAreaHeight", 1); + __decorateClass([ + computed + ], BinaryStackedBarChart.prototype, "barWidth", 1); + BinaryStackedBarChart = __decorateClass([ + t3("comparator-binary-stacked-bar-chart") + ], BinaryStackedBarChart); + var CustomFunctionsElement = class extends MobxLitElement { + constructor() { + super(...arguments); + this.appState = core.getService(AppState); + this.svgWidth = 130; + this.editedCustomFunc = makeNewCustomFunc( + this.appState.newCustomFuncId + ); + } + renderChartForBooleanType(customFunc) { + const svgHeight = DEFAULT_CHART_HEIGHT_FOR_CUSTOM_FUNCS; + const filteredExamples = this.appState.filteredExamples; + const aggregatedResults = { + "A": { "true": 0, "false": 0 }, + "B": { "true": 0, "false": 0 } + }; + const fieldId = getFieldIdForCustomFunc(customFunc.id); + filteredExamples.forEach((ex) => { + if (ex.custom_fields[fieldId][0] != null) { + aggregatedResults["A"][ex.custom_fields[fieldId][0].toString()] += 1; + } + if (ex.custom_fields[fieldId][1] != null) { + aggregatedResults["B"][ex.custom_fields[fieldId][1].toString()] += 1; + } + }); + return x` + `; + } + // TODO: Merge into the side-by-side histogram code in charts.ts. + renderChartForNumberType(customFunc) { + const getHistogramSpec = () => this.appState.histogramSpecForCustomFuncs[customFunc.id]; + const getHistogramSpecForDiff = () => this.appState.histogramSpecForCustomFuncsOfDiff[customFunc.id]; + const fieldId = getFieldIdForCustomFunc(customFunc.id); + const chartSelectionKey = (model) => ({ chartType: "custom_function" /* CUSTOM_FUNCTION */, fieldId, model }); + const getHistogramDataForA = () => this.appState.getFilteredExamplesExceptForParticularChart(chartSelectionKey("A")).filter( + (ex) => ex.custom_fields[fieldId][0] != null + ).map((ex) => ex.custom_fields[fieldId][0]); + const getHistogramDataForB = () => this.appState.getFilteredExamplesExceptForParticularChart(chartSelectionKey("B")).filter( + (ex) => ex.custom_fields[fieldId][1] != null + ).map((ex) => ex.custom_fields[fieldId][1]); + const getHistogramDataForDiff = () => this.appState.getFilteredExamplesExceptForParticularChart(chartSelectionKey("A-B")).filter( + (ex) => ex.custom_fields[fieldId][0] != null && ex.custom_fields[fieldId][1] != null + ).map( + (ex) => ex.custom_fields[fieldId][0] - ex.custom_fields[fieldId][1] + ); + const handleClickHistogramBar = (binIndex, model) => { + const selections2 = this.appState.selectionsFromCustomFuncResults[customFunc.id]; + if (selections2[model] === binIndex) { + selections2[model] = null; + } else { + selections2[model] = binIndex; + this.appState.selectedCustomFuncId = customFunc.id; + } + }; + const handleClickHistogramBarForA = (binIndex) => void handleClickHistogramBar(binIndex, "A" /* A */); + const handleClickHistogramBarForB = (binIndex) => void handleClickHistogramBar(binIndex, "B" /* B */); + const handleClickHistogramBarForDiff = (binIndex) => void handleClickHistogramBar(binIndex, "A-B"); + const selections = this.appState.selectionsFromCustomFuncResults[customFunc.id]; + const isAnyBinSelectedForA = () => selections["A"] != null; + const isAnyBinSelectedForB = () => selections["B"] != null; + const isAnyBinSelectedForDiff = () => selections["A-B"] != null; + const isThisBinSelectedForA = (binIndex) => selections["A"] === binIndex; + const isThisBinSelectedForB = (binIndex) => selections["B"] === binIndex; + const isThisBinSelectedForDiff = (binIndex) => selections["A-B"] === binIndex; + if (getHistogramSpec() !== void 0) { + return x` + + + + + `; + } else { + return ""; + } + } + renderCustomFunctionRow(customFunc) { + const handleClickTableRow = (customFuncId) => { + if (this.appState.selectedCustomFuncId === customFuncId) { + this.appState.selectedCustomFuncId = null; + } else { + this.appState.selectedCustomFuncId = customFuncId; + } + }; + const customFuncRowStyle = (customFuncId) => e6({ + "selected": customFuncId === this.appState.selectedCustomFuncId + }); + const renderChart = customFunc.returnType === "Boolean" /* BOOLEAN */ ? x` + + ${this.renderChartForBooleanType(customFunc)} + ` : x` + + ${this.renderChartForNumberType(customFunc)} + `; + const handleClickEditIcon = () => { + this.editedCustomFunc = { + ...this.appState.customFunctions[customFunc.id] + }; + this.appState.selectedCustomFuncId = customFunc.id; + this.appState.isShowCustomFuncEditor = true; + }; + const handleClickRemoveIcon = () => { + if (this.appState.customFunctions[customFunc.id] !== void 0) { + if (this.appState.selectedCustomFuncId === customFunc.id) { + this.appState.selectedCustomFuncId = null; + } + const fieldId = getFieldIdForCustomFunc(customFunc.id); + if (this.appState.currentSorting.customField != null && this.appState.currentSorting.customField.id === fieldId) { + this.appState.resetSorting(); + } + delete this.appState.selectionsFromCustomFuncResults[customFunc.id]; + delete this.appState.customFunctions[customFunc.id]; + this.appState.columns = this.appState.columns.filter( + (field) => field.id !== fieldId + ); + this.appState.updateStatusMessage("Removed the custom function.", true); + } + }; + const styleEditIcon = e6({ + "icon": true, + "clickable": true, + "disabled": customFunc.precomputed === true + }); + return x` + + void handleClickTableRow(customFunc.id)}> +
${customFunc.name}
+
${customFunc.returnType}
+ + ${renderChart} + + + + edit + + + cancel + + + `; + } + renderCustomFunctionList() { + const customFuncRows = Object.values(this.appState.customFunctions).map( + (customFunc) => this.renderCustomFunctionRow(customFunc) + ); + return x` + ${customFuncRows} +
`; + } + renderCustomFunctionEditor() { + const handleCustomFuncNameChange = (e33) => { + this.editedCustomFunc.name = e33.target.value; + }; + const handleCustomFuncBodyChange = (e33) => { + this.editedCustomFunc.functionBody = e33.target.value; + }; + const handleClickRun = () => { + if (this.editedCustomFunc.functionBody === "") { + this.appState.updateStatusMessage("Write an expression."); + return; + } + if (this.editedCustomFunc.name === "") { + this.editedCustomFunc.name = this.editedCustomFunc.functionBody; + } + this.appState.runCustomFunction( + this.appState.examples, + this.editedCustomFunc + ); + }; + const handleClickCreateNewFuncButton = () => { + if (this.appState.isShowCustomFuncEditor === false) { + this.editedCustomFunc = makeNewCustomFunc( + this.appState.newCustomFuncId + ); + this.appState.isShowCustomFuncEditor = true; + } else { + this.appState.isShowCustomFuncEditor = false; + } + }; + return x` +
+
+
Create New Function
+
+ ${this.appState.isShowCustomFuncEditor === false ? x`unfold_more` : x`close`} +
+
+ ${this.appState.isShowCustomFuncEditor === true ? x` +
+
+
Name
+ +
+ +
+
Syntax
+
+ ${Object.values(CustomFuncType).filter((funcType) => funcType !== "Precomputed" /* PRECOMPUTED */).map( + (val) => x` +
+ this.editedCustomFunc.functionType = val} + /> + +
` + )} +
+
+ +
+
Expr.
+ +
+ +
+
Return
+
+ ${Object.values(CustomFuncReturnType).map( + (val) => x` +
+ this.editedCustomFunc.returnType = val} + /> + +
` + )} +
+
+ + +
+ ` : x``} +
`; + } + render() { + return x` `; + } + }; + CustomFunctionsElement.styles = [styles, styles4]; + __decorateClass([ + observable + ], CustomFunctionsElement.prototype, "editedCustomFunc", 2); + CustomFunctionsElement = __decorateClass([ + t3("comparator-custom-functions") + ], CustomFunctionsElement); + + // client/components/dataset_selection.css + var styles5 = i`.dataset-selection-container { + align-items: center; + background-color: rgba(0, 0, 0, 0.5); + display: flex; + height: calc(100vh - 57px); + justify-content: center; + position: absolute; + width: 100vw; + z-index: 10; +} + +.dataset-selection { + background-color: #fff; + border-radius: 10px; + font-size: 13px; + height: 520px; + overflow-y: auto; + padding: 40px; + position: relative; + width: 700px; +} + +.close-button { + padding: 20px; + position: absolute; + right: 0; + top: 0; +} + +.panel-title { + color: var(--comparator-grey-250); + font-size: 24px; + padding-bottom: 5px; +} + +.panel-title .selected { + color: var(--comparator-grey-800); +} + +.panel-instruction { + color: var(--comparator-grey-800); + line-height: 18px; + margin: 5px 0; + padding: 2px 0; +} + +.textarea-wrapper { + display: flex; + margin: 5px 0; +} + +.textarea-filepath { + border-radius: 5px; + font-family: monospace; + font-size: 14px; + margin-right: 5px; + padding: 5px; + width: calc(100% - 70px); + word-break: break-all; +} + +.filepath { + background-color: #f3f3f3; + font-family: monospace; + word-break: break-all; +} + +ul { + border-top: 1px solid #eee; + margin: 5px 0 25px 10px; + padding-left: 0; +} + +li { + background-color: #fff; + border-bottom: 1px solid #eee; + color: #777; + font-family: monospace; + list-style: none; + padding: 10px; + word-break: break-all; +} + +li:hover { + background-color: #eee; + color: #555; + text-decoration: underline; +} + +input, button { + font-size: 13px; + padding: 5px 7px; +} + +.file-upload { + font-size: 14px; + padding: 10px 0; +} +`; + + // client/components/dataset_selection.ts + var DatasetSelectionElement = class extends MobxLitElement { + constructor() { + super(); + this.appState = core.getService(AppState); + this.isShowFileUploadView = this.appState.isDatasetPathUploadedFile === true; + this.editedDatasetPath = ""; + makeObservable(this); + } + static get styles() { + return [styles, styles5]; + } + getDocumentationLinkString() { + const documentationLink = "https://github.com/PAIR-code/llm-comparator"; + return x` +
+ The json file must contain these three properties: + metadata, + models, + and examples. +
+ Each example in examples must have + input_text, + tags, + output_text_a, + output_text_b, + and score. +
+ Please refer to our document for details: + ${documentationLink} +
+ `; + } + renderViewForSpecifyingDataPath() { + if (this.appState.datasetPath != null && this.appState.isDatasetPathUploadedFile === false && this.editedDatasetPath === "") { + this.editedDatasetPath = this.appState.datasetPath; + } + const handleClickLoadButton = () => this.appState.loadData(this.editedDatasetPath, null); + const handleClickDatasetPath = (datasetPath) => { + this.appState.loadData(datasetPath, null); + }; + const handleChangeDatasetPath = (e33) => { + this.editedDatasetPath = e33.target.value; + }; + const selectedClassMap = (datasetPath) => e6({ + "clickable": true, + "selected": this.appState.datasetPath === datasetPath + }); + const textareaPlaceholder = "Enter a URL to load the json file from."; + const urlLoadPath = this.appState.appLink + "?results_path=https://.../...json"; + const panelIntro = x` + Enter the URL path of a json file prepared for LLM Comparator.`; + const panelOutro = x` + ${this.getDocumentationLinkString()}
+ Note that the server hosting the file must allow + Cross-Origin Resource Sharing.`; + const panelInstruction = x` + ${panelIntro} +
+ + +
+ ${panelOutro} + +


+ If you don't have your run, + click one of the following example runs. + +
    + ${this.appState.exampleDatasetPaths.map( + (path) => x`
  • void handleClickDatasetPath(path)}>${path}
  • ` + )} +
+ + Note: You can also directly load the tool with a path by + opening an URL like:
+ + ${urlLoadPath} + + `; + return panelInstruction; + } + renderViewForUploadingData() { + const handleFileUpload = (e33) => { + const input = e33.target; + if (input.files && input.files.length > 0) { + const file = input.files[0]; + this.appState.loadData(file.name, file); + } + }; + return x` +
+ + +
+ + ${this.getDocumentationLinkString()} + `; + } + render() { + if (this.appState.isOpenDatasetSelectionPanel === false) { + return x``; + } + const handleClickCloseButton = () => { + this.appState.isOpenDatasetSelectionPanel = false; + }; + const stylePanelTitle = (isUpload) => e6({ + "selected": isUpload === this.isShowFileUploadView, + "clickable": true + }); + const panelTitle = x` this.isShowFileUploadView = false}> + Select Data + + | + this.isShowFileUploadView = true}> + Upload File + `; + const panelInstruction = this.isShowFileUploadView === true ? this.renderViewForUploadingData() : this.renderViewForSpecifyingDataPath(); + return x`
+
+ ${this.appState.datasetPath !== null ? x`
+ close +
` : ""} +
${panelTitle}
+
${panelInstruction}
+
+
`; + } + }; + __decorateClass([ + observable + ], DatasetSelectionElement.prototype, "isShowFileUploadView", 2); + __decorateClass([ + observable + ], DatasetSelectionElement.prototype, "editedDatasetPath", 2); + DatasetSelectionElement = __decorateClass([ + t3("comparator-dataset-selection") + ], DatasetSelectionElement); + + // client/components/example_details.css + var styles6 = i`.panel-container { + display: flex; + flex-direction: column; + height: 100%; + padding-left: 15px; +} + +.panel-header { + align-items: center; + border-bottom: 1px solid var(--comparator-grey-200); + display: flex; + height: 34px; + justify-content: space-between; +} + +.panel-title { + align-items: center; + display: flex; + gap: 10px; +} + +.panel-title h3 { + font-size: 16px; + font-weight: 200; +} + +.filter-chips { + display: flex; + gap: 2px; +} + +.panel-contents { + display: flex; + gap: 10px; + height: calc(100% - 35px); +} + +.score-distribution-chart { + display: flex; + padding: 5px 10px; +} + +.rating-table { + overflow-y: scroll; +} + +thead { + position: sticky; + top: 0; + z-index: 1; +} + +th { + background-color: var(--comparator-grey-200); + color: var(--comparator-grey-800); + font-weight: normal; + padding: 6px 4px; + position: relative; + vertical-align: top; +} + +td { + border-bottom: 1px solid #ddd; + line-height: 13px; + padding: 6px 8px; + vertical-align: top; +} + +th.index { + width: 25px; +} + +th.score { + width: 55px; +} + +th.flipped { + width: 45px; +} + +th.rationale { + min-width: 300px; +} + +tr.second-row th { + color: white; + padding: 0 4px 2px; +} + +td.center-aligned { + text-align: center; +} + +td.highlighted { + font-weight: 600; +} + +td.a-win { + background-color: var(--comparator-model-a-win-bg); +} + +td.b-win { + background-color: var(--comparator-model-b-win-bg); +} + +td.rationale { + overflow-wrap: anywhere; + white-space: break-spaces; +} + +.sort-icon { + color: var(--comparator-grey-100); +} + +.sort-icon.up { + top: -12px; +} + +.sort-icon.down { + top: -2px; +} + +.sort-icon:hover { + color: var(--comparator-grey-300); +} + +.sort-icon.active { + color: var(--comparator-grey-500); +} +`; + + // client/components/example_details.ts + var ExampleDetailsElement = class extends MobxLitElement { + constructor() { + super(); + this.appState = core.getService(AppState); + this.sortOrder = "None" /* NONE */; + makeObservable(this); + } + get selectedExample() { + return this.appState.selectedExample; + } + get filteredRatings() { + if (this.selectedExample == null) { + return []; + } + return this.selectedExample.individual_rater_scores.filter( + (rating) => this.appState.selectedHistogramBinForRatingsForSelectedExample == null || rating.score != null && getHistogramBinIndexFromValue( + this.appState.histogramSpecForScores, + rating.score + ) === this.appState.selectedHistogramBinForRatingsForSelectedExample + ).filter((rating) => { + const selection = this.appState.selectedBarChartValueForSelectedExample; + return selection == null || rating.custom_fields[selection.fieldId][selection.modelIndex] === selection.value; + }); + } + get sortedRatings() { + return this.filteredRatings.sort( + (a11, b7) => this.sortOrder === "None" /* NONE */ ? 1 : compareNumbersWithNulls( + a11.score, + b7.score, + this.sortOrder === "desc" /* DESC */ + ) + ); + } + // Score histogram for the individual ratings for a selected example. + renderScoreHistogram() { + const svgWidth = 220; + const svgHeight = 110; + const getHistogramRawDataValues = () => { + return this.filteredRatings.filter((rating) => rating.score != null).map((rating) => rating.score); + }; + const handleClickHistogramBar = (binIndex) => { + if (this.appState.selectedHistogramBinForRatingsForSelectedExample === binIndex) { + this.appState.selectedHistogramBinForRatingsForSelectedExample = null; + } else { + this.appState.selectedHistogramBinForRatingsForSelectedExample = binIndex; + } + }; + const isAnyBinSelected = () => this.appState.selectedHistogramBinForRatingsForSelectedExample !== null; + const isThisBinSelected = (binIndex) => binIndex === this.appState.selectedHistogramBinForRatingsForSelectedExample; + return x` this.appState.histogramSpecForScores} + .getRawDataValues=${getHistogramRawDataValues} + .handleClickHistogramBar=${handleClickHistogramBar} + .isAnyBinSelected=${isAnyBinSelected} + .isThisBinSelected=${isThisBinSelected} + .svgWidth=${svgWidth} + .svgHeight=${svgHeight} + .neutralColorThreshold=${() => this.appState.winRateThreshold} + .showAxisEndDescription=${true} + .isFlipXAxis=${() => this.appState.isFlipScoreHistogramAxis}> + `; + } + // TODO: Create a separate data-table component. + renderRaterTable() { + const selectedExample = this.selectedExample; + if (selectedExample == null) { + return x``; + } + const readableRating = (label, isFlipped) => { + if (label == null) { + return ""; + } else if (label.endsWith("Than") || label.endsWith("SameAs")) { + return isFlipped === true ? `B is ${label} A` : `A is ${label} B`; + } else { + return label; + } + }; + const styleScore = (score) => e6({ + "center-aligned": true, + "a-win": this.appState.isScoreDivergingScheme === true && score != null && score > this.appState.scoreMiddlePoint, + "b-win": this.appState.isScoreDivergingScheme === true && score != null && score < this.appState.scoreMiddlePoint + }); + const styleSortIcons = (order) => e6({ + "sort-icon": true, + "up": order === "asc" /* ASC */, + "down": order === "desc" /* DESC */, + "active": this.sortOrder === order + }); + const handleClickSortIcon = (order) => { + if (order === this.sortOrder) { + this.sortOrder = "None" /* NONE */; + } else { + this.sortOrder = order; + } + }; + const renderSortIcons = () => x`
+ void handleClickSortIcon("asc" /* ASC */)}> + arrow_drop_up + + void handleClickSortIcon("desc" /* DESC */)}> + arrow_drop_down + +
`; + const renderCustomFieldHeaderCell = (field) => { + if (field.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */) { + return x` ${field.name}`; + } else { + return x` ${field.name}`; + } + }; + const renderCustomFieldHeaderCellSecondRow = (field) => { + if (field.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */) { + return x` A + B`; + } else { + return x``; + } + }; + const renderHeaderRow = x` + Index + Score ${renderSortIcons()} + Rating + Flipped? + Rationale + ${this.appState.customFieldsOfPerRatingType.map( + (field) => renderCustomFieldHeaderCell(field) + )} + + + ${this.appState.customFieldsOfPerRatingType.map( + (field) => renderCustomFieldHeaderCellSecondRow(field) + )} + `; + const selection = this.appState.selectedBarChartValueForSelectedExample; + const renderCustomField = (rating, field) => { + const styleCell = (modelIndex, value) => e6({ + "highlighted": selection != null && selection.fieldId === field.id && selection.modelIndex === modelIndex && selection.value === value + }); + if (field.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */) { + const value = rating.custom_fields[field.id] || [null, null]; + if (value.length !== 2) { + throw new Error(`Invalid value for field ${field.id}: ${value}`); + } + return x` ${value[0]} + ${value[1]}`; + } else { + return x` ${rating.custom_fields[field.id]}`; + } + }; + const renderRow = (rating) => { + return x` + ${rating.index} + ${rating.score} + ${readableRating(rating.rating_label, rating.is_flipped)} + + ${rating.is_flipped == null ? "Unknown" : rating.is_flipped === true ? "Y" : "N"} + + ${rating.rationale} + ${this.appState.customFieldsOfPerRatingType.map( + (field) => renderCustomField(rating, field) + )} + `; + }; + const renderSortedRatings = this.sortedRatings.map( + (rating) => renderRow(rating) + ); + return x` + ${renderHeaderRow} + ${renderSortedRatings} +
`; + } + // Filter chips at the top of the panel. + renderFilterChip(label, handleClickCancelButton) { + return x`
+ ${label} + + cancel + +
`; + } + renderFilterChips() { + const labelScore = getHistogramFilterLabel( + "score", + this.appState.histogramSpecForScores, + this.appState.selectedHistogramBinForRatingsForSelectedExample, + null + ); + const handleClickCancelButtonForScore = () => { + this.appState.selectedHistogramBinForRatingsForSelectedExample = null; + }; + const selection = this.appState.selectedBarChartValueForSelectedExample; + const selectionField = selection == null ? null : this.appState.getFieldFromId(selection.fieldId); + const labelCustomField = selection == null || selectionField == null ? "" : `${selectionField.name}(${Object.values(AOrB)[selection.modelIndex]}) = ${selection.value}`; + const handleClickCancelButtonForCustomField = () => { + this.appState.selectedBarChartValueForSelectedExample = null; + }; + return x` + ${this.appState.selectedHistogramBinForRatingsForSelectedExample != null ? this.renderFilterChip(labelScore, handleClickCancelButtonForScore) : x``} + ${this.appState.selectedBarChartValueForSelectedExample != null ? this.renderFilterChip( + labelCustomField, + handleClickCancelButtonForCustomField + ) : x``} + `; + } + render() { + const showSelectedExampleDetails = this.appState.showSelectedExampleDetails; + const selectedExample = this.appState.selectedExample; + if (showSelectedExampleDetails === false || selectedExample == null) { + return x``; + } + const handleClickCloseButton = () => { + this.appState.showSelectedExampleDetails = false; + this.appState.selectedExample = null; + this.appState.selectedHistogramBinForRatingsForSelectedExample = null; + this.appState.selectedBarChartValueForSelectedExample = null; + }; + const handleClickExpandButton = () => { + this.appState.exampleDetailsPanelExpanded = !this.appState.exampleDetailsPanelExpanded; + }; + return x` +
+
+
+

Individual Ratings for Selected Example

+
${this.renderFilterChips()}
+
+
+ + ${this.appState.exampleDetailsPanelExpanded === true ? "expand_more" : "expand_less"} + + + close + +
+
+
+
+ ${this.renderScoreHistogram()} +
+
+ ${this.renderRaterTable()} +
+
+
`; + } + }; + ExampleDetailsElement.styles = [styles, styles6]; + __decorateClass([ + observable + ], ExampleDetailsElement.prototype, "sortOrder", 2); + __decorateClass([ + computed + ], ExampleDetailsElement.prototype, "selectedExample", 1); + __decorateClass([ + computed + ], ExampleDetailsElement.prototype, "filteredRatings", 1); + __decorateClass([ + computed + ], ExampleDetailsElement.prototype, "sortedRatings", 1); + ExampleDetailsElement = __decorateClass([ + t3("comparator-example-details") + ], ExampleDetailsElement); + + // node_modules/tslib/tslib.es6.mjs + var extendStatics = function(d11, b7) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d12, b8) { + d12.__proto__ = b8; + } || function(d12, b8) { + for (var p7 in b8) + if (Object.prototype.hasOwnProperty.call(b8, p7)) + d12[p7] = b8[p7]; + }; + return extendStatics(d11, b7); + }; + function __extends(d11, b7) { + if (typeof b7 !== "function" && b7 !== null) + throw new TypeError("Class extends value " + String(b7) + " is not a constructor or null"); + extendStatics(d11, b7); + function __() { + this.constructor = d11; + } + d11.prototype = b7 === null ? Object.create(b7) : (__.prototype = b7.prototype, new __()); + } + var __assign = function() { + __assign = Object.assign || function __assign2(t17) { + for (var s20, i23 = 1, n31 = arguments.length; i23 < n31; i23++) { + s20 = arguments[i23]; + for (var p7 in s20) + if (Object.prototype.hasOwnProperty.call(s20, p7)) + t17[p7] = s20[p7]; + } + return t17; + }; + return __assign.apply(this, arguments); + }; + function __decorate(decorators, target, key, desc) { + var c12 = arguments.length, r18 = c12 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d11; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") + r18 = Reflect.decorate(decorators, target, key, desc); + else + for (var i23 = decorators.length - 1; i23 >= 0; i23--) + if (d11 = decorators[i23]) + r18 = (c12 < 3 ? d11(r18) : c12 > 3 ? d11(target, key, r18) : d11(target, key)) || r18; + return c12 > 3 && r18 && Object.defineProperty(target, key, r18), r18; + } + function __values(o29) { + var s20 = typeof Symbol === "function" && Symbol.iterator, m6 = s20 && o29[s20], i23 = 0; + if (m6) + return m6.call(o29); + if (o29 && typeof o29.length === "number") + return { + next: function() { + if (o29 && i23 >= o29.length) + o29 = void 0; + return { value: o29 && o29[i23++], done: !o29 }; + } + }; + throw new TypeError(s20 ? "Object is not iterable." : "Symbol.iterator is not defined."); + } + function __read(o29, n31) { + var m6 = typeof Symbol === "function" && o29[Symbol.iterator]; + if (!m6) + return o29; + var i23 = m6.call(o29), r18, ar = [], e33; + try { + while ((n31 === void 0 || n31-- > 0) && !(r18 = i23.next()).done) + ar.push(r18.value); + } catch (error) { + e33 = { error }; + } finally { + try { + if (r18 && !r18.done && (m6 = i23["return"])) + m6.call(i23); + } finally { + if (e33) + throw e33.error; + } + } + return ar; + } + function __spreadArray(to, from, pack) { + if (pack || arguments.length === 2) + for (var i23 = 0, l20 = from.length, ar; i23 < l20; i23++) { + if (ar || !(i23 in from)) { + if (!ar) + ar = Array.prototype.slice.call(from, 0, i23); + ar[i23] = from[i23]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); + } + + // node_modules/@material/mwc-icon/node_modules/@lit/reactive-element/css-tag.js + var t5 = window; + var e7 = t5.ShadowRoot && (void 0 === t5.ShadyCSS || t5.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype; + var s4 = Symbol(); + var n5 = /* @__PURE__ */ new WeakMap(); + var o5 = class { + constructor(t17, e33, n31) { + if (this._$cssResult$ = true, n31 !== s4) + throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); + this.cssText = t17, this.t = e33; + } + get styleSheet() { + let t17 = this.o; + const s20 = this.t; + if (e7 && void 0 === t17) { + const e33 = void 0 !== s20 && 1 === s20.length; + e33 && (t17 = n5.get(s20)), void 0 === t17 && ((this.o = t17 = new CSSStyleSheet()).replaceSync(this.cssText), e33 && n5.set(s20, t17)); + } + return t17; + } + toString() { + return this.cssText; + } + }; + var r6 = (t17) => new o5("string" == typeof t17 ? t17 : t17 + "", void 0, s4); + var i6 = (t17, ...e33) => { + const n31 = 1 === t17.length ? t17[0] : e33.reduce((e34, s20, n32) => e34 + ((t18) => { + if (true === t18._$cssResult$) + return t18.cssText; + if ("number" == typeof t18) + return t18; + throw Error("Value passed to 'css' function must be a 'css' function result: " + t18 + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security."); + })(s20) + t17[n32 + 1], t17[0]); + return new o5(n31, t17, s4); + }; + var S3 = (s20, n31) => { + e7 ? s20.adoptedStyleSheets = n31.map((t17) => t17 instanceof CSSStyleSheet ? t17 : t17.styleSheet) : n31.forEach((e33) => { + const n32 = document.createElement("style"), o29 = t5.litNonce; + void 0 !== o29 && n32.setAttribute("nonce", o29), n32.textContent = e33.cssText, s20.appendChild(n32); + }); + }; + var c4 = e7 ? (t17) => t17 : (t17) => t17 instanceof CSSStyleSheet ? ((t18) => { + let e33 = ""; + for (const s20 of t18.cssRules) + e33 += s20.cssText; + return r6(e33); + })(t17) : t17; + + // node_modules/@material/mwc-icon/node_modules/@lit/reactive-element/reactive-element.js + var s5; + var e8 = window; + var r7 = e8.trustedTypes; + var h3 = r7 ? r7.emptyScript : ""; + var o6 = e8.reactiveElementPolyfillSupport; + var n6 = { toAttribute(t17, i23) { + switch (i23) { + case Boolean: + t17 = t17 ? h3 : null; + break; + case Object: + case Array: + t17 = null == t17 ? t17 : JSON.stringify(t17); + } + return t17; + }, fromAttribute(t17, i23) { + let s20 = t17; + switch (i23) { + case Boolean: + s20 = null !== t17; + break; + case Number: + s20 = null === t17 ? null : Number(t17); + break; + case Object: + case Array: + try { + s20 = JSON.parse(t17); + } catch (t18) { + s20 = null; + } + } + return s20; + } }; + var a3 = (t17, i23) => i23 !== t17 && (i23 == i23 || t17 == t17); + var l3 = { attribute: true, type: String, converter: n6, reflect: false, hasChanged: a3 }; + var d3 = "finalized"; + var u3 = class extends HTMLElement { + constructor() { + super(), this._$Ei = /* @__PURE__ */ new Map(), this.isUpdatePending = false, this.hasUpdated = false, this._$El = null, this._$Eu(); + } + static addInitializer(t17) { + var i23; + this.finalize(), (null !== (i23 = this.h) && void 0 !== i23 ? i23 : this.h = []).push(t17); + } + static get observedAttributes() { + this.finalize(); + const t17 = []; + return this.elementProperties.forEach((i23, s20) => { + const e33 = this._$Ep(s20, i23); + void 0 !== e33 && (this._$Ev.set(e33, s20), t17.push(e33)); + }), t17; + } + static createProperty(t17, i23 = l3) { + if (i23.state && (i23.attribute = false), this.finalize(), this.elementProperties.set(t17, i23), !i23.noAccessor && !this.prototype.hasOwnProperty(t17)) { + const s20 = "symbol" == typeof t17 ? Symbol() : "__" + t17, e33 = this.getPropertyDescriptor(t17, s20, i23); + void 0 !== e33 && Object.defineProperty(this.prototype, t17, e33); + } + } + static getPropertyDescriptor(t17, i23, s20) { + return { get() { + return this[i23]; + }, set(e33) { + const r18 = this[t17]; + this[i23] = e33, this.requestUpdate(t17, r18, s20); + }, configurable: true, enumerable: true }; + } + static getPropertyOptions(t17) { + return this.elementProperties.get(t17) || l3; + } + static finalize() { + if (this.hasOwnProperty(d3)) + return false; + this[d3] = true; + const t17 = Object.getPrototypeOf(this); + if (t17.finalize(), void 0 !== t17.h && (this.h = [...t17.h]), this.elementProperties = new Map(t17.elementProperties), this._$Ev = /* @__PURE__ */ new Map(), this.hasOwnProperty("properties")) { + const t18 = this.properties, i23 = [...Object.getOwnPropertyNames(t18), ...Object.getOwnPropertySymbols(t18)]; + for (const s20 of i23) + this.createProperty(s20, t18[s20]); + } + return this.elementStyles = this.finalizeStyles(this.styles), true; + } + static finalizeStyles(i23) { + const s20 = []; + if (Array.isArray(i23)) { + const e33 = new Set(i23.flat(1 / 0).reverse()); + for (const i24 of e33) + s20.unshift(c4(i24)); + } else + void 0 !== i23 && s20.push(c4(i23)); + return s20; + } + static _$Ep(t17, i23) { + const s20 = i23.attribute; + return false === s20 ? void 0 : "string" == typeof s20 ? s20 : "string" == typeof t17 ? t17.toLowerCase() : void 0; + } + _$Eu() { + var t17; + this._$E_ = new Promise((t18) => this.enableUpdating = t18), this._$AL = /* @__PURE__ */ new Map(), this._$Eg(), this.requestUpdate(), null === (t17 = this.constructor.h) || void 0 === t17 || t17.forEach((t18) => t18(this)); + } + addController(t17) { + var i23, s20; + (null !== (i23 = this._$ES) && void 0 !== i23 ? i23 : this._$ES = []).push(t17), void 0 !== this.renderRoot && this.isConnected && (null === (s20 = t17.hostConnected) || void 0 === s20 || s20.call(t17)); + } + removeController(t17) { + var i23; + null === (i23 = this._$ES) || void 0 === i23 || i23.splice(this._$ES.indexOf(t17) >>> 0, 1); + } + _$Eg() { + this.constructor.elementProperties.forEach((t17, i23) => { + this.hasOwnProperty(i23) && (this._$Ei.set(i23, this[i23]), delete this[i23]); + }); + } + createRenderRoot() { + var t17; + const s20 = null !== (t17 = this.shadowRoot) && void 0 !== t17 ? t17 : this.attachShadow(this.constructor.shadowRootOptions); + return S3(s20, this.constructor.elementStyles), s20; + } + connectedCallback() { + var t17; + void 0 === this.renderRoot && (this.renderRoot = this.createRenderRoot()), this.enableUpdating(true), null === (t17 = this._$ES) || void 0 === t17 || t17.forEach((t18) => { + var i23; + return null === (i23 = t18.hostConnected) || void 0 === i23 ? void 0 : i23.call(t18); + }); + } + enableUpdating(t17) { + } + disconnectedCallback() { + var t17; + null === (t17 = this._$ES) || void 0 === t17 || t17.forEach((t18) => { + var i23; + return null === (i23 = t18.hostDisconnected) || void 0 === i23 ? void 0 : i23.call(t18); + }); + } + attributeChangedCallback(t17, i23, s20) { + this._$AK(t17, s20); + } + _$EO(t17, i23, s20 = l3) { + var e33; + const r18 = this.constructor._$Ep(t17, s20); + if (void 0 !== r18 && true === s20.reflect) { + const h11 = (void 0 !== (null === (e33 = s20.converter) || void 0 === e33 ? void 0 : e33.toAttribute) ? s20.converter : n6).toAttribute(i23, s20.type); + this._$El = t17, null == h11 ? this.removeAttribute(r18) : this.setAttribute(r18, h11), this._$El = null; + } + } + _$AK(t17, i23) { + var s20; + const e33 = this.constructor, r18 = e33._$Ev.get(t17); + if (void 0 !== r18 && this._$El !== r18) { + const t18 = e33.getPropertyOptions(r18), h11 = "function" == typeof t18.converter ? { fromAttribute: t18.converter } : void 0 !== (null === (s20 = t18.converter) || void 0 === s20 ? void 0 : s20.fromAttribute) ? t18.converter : n6; + this._$El = r18, this[r18] = h11.fromAttribute(i23, t18.type), this._$El = null; + } + } + requestUpdate(t17, i23, s20) { + let e33 = true; + void 0 !== t17 && (((s20 = s20 || this.constructor.getPropertyOptions(t17)).hasChanged || a3)(this[t17], i23) ? (this._$AL.has(t17) || this._$AL.set(t17, i23), true === s20.reflect && this._$El !== t17 && (void 0 === this._$EC && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(t17, s20))) : e33 = false), !this.isUpdatePending && e33 && (this._$E_ = this._$Ej()); + } + async _$Ej() { + this.isUpdatePending = true; + try { + await this._$E_; + } catch (t18) { + Promise.reject(t18); + } + const t17 = this.scheduleUpdate(); + return null != t17 && await t17, !this.isUpdatePending; + } + scheduleUpdate() { + return this.performUpdate(); + } + performUpdate() { + var t17; + if (!this.isUpdatePending) + return; + this.hasUpdated, this._$Ei && (this._$Ei.forEach((t18, i24) => this[i24] = t18), this._$Ei = void 0); + let i23 = false; + const s20 = this._$AL; + try { + i23 = this.shouldUpdate(s20), i23 ? (this.willUpdate(s20), null === (t17 = this._$ES) || void 0 === t17 || t17.forEach((t18) => { + var i24; + return null === (i24 = t18.hostUpdate) || void 0 === i24 ? void 0 : i24.call(t18); + }), this.update(s20)) : this._$Ek(); + } catch (t18) { + throw i23 = false, this._$Ek(), t18; + } + i23 && this._$AE(s20); + } + willUpdate(t17) { + } + _$AE(t17) { + var i23; + null === (i23 = this._$ES) || void 0 === i23 || i23.forEach((t18) => { + var i24; + return null === (i24 = t18.hostUpdated) || void 0 === i24 ? void 0 : i24.call(t18); + }), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t17)), this.updated(t17); + } + _$Ek() { + this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = false; + } + get updateComplete() { + return this.getUpdateComplete(); + } + getUpdateComplete() { + return this._$E_; + } + shouldUpdate(t17) { + return true; + } + update(t17) { + void 0 !== this._$EC && (this._$EC.forEach((t18, i23) => this._$EO(i23, this[i23], t18)), this._$EC = void 0), this._$Ek(); + } + updated(t17) { + } + firstUpdated(t17) { + } + }; + u3[d3] = true, u3.elementProperties = /* @__PURE__ */ new Map(), u3.elementStyles = [], u3.shadowRootOptions = { mode: "open" }, null == o6 || o6({ ReactiveElement: u3 }), (null !== (s5 = e8.reactiveElementVersions) && void 0 !== s5 ? s5 : e8.reactiveElementVersions = []).push("1.6.3"); + + // node_modules/@material/mwc-icon/node_modules/lit-html/lit-html.js + var t6; + var i7 = window; + var s6 = i7.trustedTypes; + var e9 = s6 ? s6.createPolicy("lit-html", { createHTML: (t17) => t17 }) : void 0; + var o7 = "$lit$"; + var n7 = `lit$${(Math.random() + "").slice(9)}$`; + var l4 = "?" + n7; + var h4 = `<${l4}>`; + var r8 = document; + var u4 = () => r8.createComment(""); + var d4 = (t17) => null === t17 || "object" != typeof t17 && "function" != typeof t17; + var c5 = Array.isArray; + var v2 = (t17) => c5(t17) || "function" == typeof (null == t17 ? void 0 : t17[Symbol.iterator]); + var a4 = "[ \n\f\r]"; + var f3 = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g; + var _15 = /-->/g; + var m2 = />/g; + var p3 = RegExp(`>|${a4}(?:([^\\s"'>=/]+)(${a4}*=${a4}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`, "g"); + var g2 = /'/g; + var $2 = /"/g; + var y3 = /^(?:script|style|textarea|title)$/i; + var w2 = (t17) => (i23, ...s20) => ({ _$litType$: t17, strings: i23, values: s20 }); + var x2 = w2(1); + var b3 = w2(2); + var T2 = Symbol.for("lit-noChange"); + var A2 = Symbol.for("lit-nothing"); + var E2 = /* @__PURE__ */ new WeakMap(); + var C2 = r8.createTreeWalker(r8, 129, null, false); + function P2(t17, i23) { + if (!Array.isArray(t17) || !t17.hasOwnProperty("raw")) + throw Error("invalid template strings array"); + return void 0 !== e9 ? e9.createHTML(i23) : i23; + } + var V2 = (t17, i23) => { + const s20 = t17.length - 1, e33 = []; + let l20, r18 = 2 === i23 ? "" : "", u11 = f3; + for (let i24 = 0; i24 < s20; i24++) { + const s21 = t17[i24]; + let d11, c12, v6 = -1, a11 = 0; + for (; a11 < s21.length && (u11.lastIndex = a11, c12 = u11.exec(s21), null !== c12); ) + a11 = u11.lastIndex, u11 === f3 ? "!--" === c12[1] ? u11 = _15 : void 0 !== c12[1] ? u11 = m2 : void 0 !== c12[2] ? (y3.test(c12[2]) && (l20 = RegExp("" === c12[0] ? (u11 = null != l20 ? l20 : f3, v6 = -1) : void 0 === c12[1] ? v6 = -2 : (v6 = u11.lastIndex - c12[2].length, d11 = c12[1], u11 = void 0 === c12[3] ? p3 : '"' === c12[3] ? $2 : g2) : u11 === $2 || u11 === g2 ? u11 = p3 : u11 === _15 || u11 === m2 ? u11 = f3 : (u11 = p3, l20 = void 0); + const w6 = u11 === p3 && t17[i24 + 1].startsWith("/>") ? " " : ""; + r18 += u11 === f3 ? s21 + h4 : v6 >= 0 ? (e33.push(d11), s21.slice(0, v6) + o7 + s21.slice(v6) + n7 + w6) : s21 + n7 + (-2 === v6 ? (e33.push(void 0), i24) : w6); + } + return [P2(t17, r18 + (t17[s20] || "") + (2 === i23 ? "" : "")), e33]; + }; + var N2 = class _N { + constructor({ strings: t17, _$litType$: i23 }, e33) { + let h11; + this.parts = []; + let r18 = 0, d11 = 0; + const c12 = t17.length - 1, v6 = this.parts, [a11, f7] = V2(t17, i23); + if (this.el = _N.createElement(a11, e33), C2.currentNode = this.el.content, 2 === i23) { + const t18 = this.el.content, i24 = t18.firstChild; + i24.remove(), t18.append(...i24.childNodes); + } + for (; null !== (h11 = C2.nextNode()) && v6.length < c12; ) { + if (1 === h11.nodeType) { + if (h11.hasAttributes()) { + const t18 = []; + for (const i24 of h11.getAttributeNames()) + if (i24.endsWith(o7) || i24.startsWith(n7)) { + const s20 = f7[d11++]; + if (t18.push(i24), void 0 !== s20) { + const t19 = h11.getAttribute(s20.toLowerCase() + o7).split(n7), i25 = /([.?@])?(.*)/.exec(s20); + v6.push({ type: 1, index: r18, name: i25[2], strings: t19, ctor: "." === i25[1] ? H2 : "?" === i25[1] ? L2 : "@" === i25[1] ? z : k4 }); + } else + v6.push({ type: 6, index: r18 }); + } + for (const i24 of t18) + h11.removeAttribute(i24); + } + if (y3.test(h11.tagName)) { + const t18 = h11.textContent.split(n7), i24 = t18.length - 1; + if (i24 > 0) { + h11.textContent = s6 ? s6.emptyScript : ""; + for (let s20 = 0; s20 < i24; s20++) + h11.append(t18[s20], u4()), C2.nextNode(), v6.push({ type: 2, index: ++r18 }); + h11.append(t18[i24], u4()); + } + } + } else if (8 === h11.nodeType) + if (h11.data === l4) + v6.push({ type: 2, index: r18 }); + else { + let t18 = -1; + for (; -1 !== (t18 = h11.data.indexOf(n7, t18 + 1)); ) + v6.push({ type: 7, index: r18 }), t18 += n7.length - 1; + } + r18++; + } + } + static createElement(t17, i23) { + const s20 = r8.createElement("template"); + return s20.innerHTML = t17, s20; + } + }; + function S4(t17, i23, s20 = t17, e33) { + var o29, n31, l20, h11; + if (i23 === T2) + return i23; + let r18 = void 0 !== e33 ? null === (o29 = s20._$Co) || void 0 === o29 ? void 0 : o29[e33] : s20._$Cl; + const u11 = d4(i23) ? void 0 : i23._$litDirective$; + return (null == r18 ? void 0 : r18.constructor) !== u11 && (null === (n31 = null == r18 ? void 0 : r18._$AO) || void 0 === n31 || n31.call(r18, false), void 0 === u11 ? r18 = void 0 : (r18 = new u11(t17), r18._$AT(t17, s20, e33)), void 0 !== e33 ? (null !== (l20 = (h11 = s20)._$Co) && void 0 !== l20 ? l20 : h11._$Co = [])[e33] = r18 : s20._$Cl = r18), void 0 !== r18 && (i23 = S4(t17, r18._$AS(t17, i23.values), r18, e33)), i23; + } + var M2 = class { + constructor(t17, i23) { + this._$AV = [], this._$AN = void 0, this._$AD = t17, this._$AM = i23; + } + get parentNode() { + return this._$AM.parentNode; + } + get _$AU() { + return this._$AM._$AU; + } + u(t17) { + var i23; + const { el: { content: s20 }, parts: e33 } = this._$AD, o29 = (null !== (i23 = null == t17 ? void 0 : t17.creationScope) && void 0 !== i23 ? i23 : r8).importNode(s20, true); + C2.currentNode = o29; + let n31 = C2.nextNode(), l20 = 0, h11 = 0, u11 = e33[0]; + for (; void 0 !== u11; ) { + if (l20 === u11.index) { + let i24; + 2 === u11.type ? i24 = new R2(n31, n31.nextSibling, this, t17) : 1 === u11.type ? i24 = new u11.ctor(n31, u11.name, u11.strings, this, t17) : 6 === u11.type && (i24 = new Z2(n31, this, t17)), this._$AV.push(i24), u11 = e33[++h11]; + } + l20 !== (null == u11 ? void 0 : u11.index) && (n31 = C2.nextNode(), l20++); + } + return C2.currentNode = r8, o29; + } + v(t17) { + let i23 = 0; + for (const s20 of this._$AV) + void 0 !== s20 && (void 0 !== s20.strings ? (s20._$AI(t17, s20, i23), i23 += s20.strings.length - 2) : s20._$AI(t17[i23])), i23++; + } + }; + var R2 = class _R { + constructor(t17, i23, s20, e33) { + var o29; + this.type = 2, this._$AH = A2, this._$AN = void 0, this._$AA = t17, this._$AB = i23, this._$AM = s20, this.options = e33, this._$Cp = null === (o29 = null == e33 ? void 0 : e33.isConnected) || void 0 === o29 || o29; + } + get _$AU() { + var t17, i23; + return null !== (i23 = null === (t17 = this._$AM) || void 0 === t17 ? void 0 : t17._$AU) && void 0 !== i23 ? i23 : this._$Cp; + } + get parentNode() { + let t17 = this._$AA.parentNode; + const i23 = this._$AM; + return void 0 !== i23 && 11 === (null == t17 ? void 0 : t17.nodeType) && (t17 = i23.parentNode), t17; + } + get startNode() { + return this._$AA; + } + get endNode() { + return this._$AB; + } + _$AI(t17, i23 = this) { + t17 = S4(this, t17, i23), d4(t17) ? t17 === A2 || null == t17 || "" === t17 ? (this._$AH !== A2 && this._$AR(), this._$AH = A2) : t17 !== this._$AH && t17 !== T2 && this._(t17) : void 0 !== t17._$litType$ ? this.g(t17) : void 0 !== t17.nodeType ? this.$(t17) : v2(t17) ? this.T(t17) : this._(t17); + } + k(t17) { + return this._$AA.parentNode.insertBefore(t17, this._$AB); + } + $(t17) { + this._$AH !== t17 && (this._$AR(), this._$AH = this.k(t17)); + } + _(t17) { + this._$AH !== A2 && d4(this._$AH) ? this._$AA.nextSibling.data = t17 : this.$(r8.createTextNode(t17)), this._$AH = t17; + } + g(t17) { + var i23; + const { values: s20, _$litType$: e33 } = t17, o29 = "number" == typeof e33 ? this._$AC(t17) : (void 0 === e33.el && (e33.el = N2.createElement(P2(e33.h, e33.h[0]), this.options)), e33); + if ((null === (i23 = this._$AH) || void 0 === i23 ? void 0 : i23._$AD) === o29) + this._$AH.v(s20); + else { + const t18 = new M2(o29, this), i24 = t18.u(this.options); + t18.v(s20), this.$(i24), this._$AH = t18; + } + } + _$AC(t17) { + let i23 = E2.get(t17.strings); + return void 0 === i23 && E2.set(t17.strings, i23 = new N2(t17)), i23; + } + T(t17) { + c5(this._$AH) || (this._$AH = [], this._$AR()); + const i23 = this._$AH; + let s20, e33 = 0; + for (const o29 of t17) + e33 === i23.length ? i23.push(s20 = new _R(this.k(u4()), this.k(u4()), this, this.options)) : s20 = i23[e33], s20._$AI(o29), e33++; + e33 < i23.length && (this._$AR(s20 && s20._$AB.nextSibling, e33), i23.length = e33); + } + _$AR(t17 = this._$AA.nextSibling, i23) { + var s20; + for (null === (s20 = this._$AP) || void 0 === s20 || s20.call(this, false, true, i23); t17 && t17 !== this._$AB; ) { + const i24 = t17.nextSibling; + t17.remove(), t17 = i24; + } + } + setConnected(t17) { + var i23; + void 0 === this._$AM && (this._$Cp = t17, null === (i23 = this._$AP) || void 0 === i23 || i23.call(this, t17)); + } + }; + var k4 = class { + constructor(t17, i23, s20, e33, o29) { + this.type = 1, this._$AH = A2, this._$AN = void 0, this.element = t17, this.name = i23, this._$AM = e33, this.options = o29, s20.length > 2 || "" !== s20[0] || "" !== s20[1] ? (this._$AH = Array(s20.length - 1).fill(new String()), this.strings = s20) : this._$AH = A2; + } + get tagName() { + return this.element.tagName; + } + get _$AU() { + return this._$AM._$AU; + } + _$AI(t17, i23 = this, s20, e33) { + const o29 = this.strings; + let n31 = false; + if (void 0 === o29) + t17 = S4(this, t17, i23, 0), n31 = !d4(t17) || t17 !== this._$AH && t17 !== T2, n31 && (this._$AH = t17); + else { + const e34 = t17; + let l20, h11; + for (t17 = o29[0], l20 = 0; l20 < o29.length - 1; l20++) + h11 = S4(this, e34[s20 + l20], i23, l20), h11 === T2 && (h11 = this._$AH[l20]), n31 || (n31 = !d4(h11) || h11 !== this._$AH[l20]), h11 === A2 ? t17 = A2 : t17 !== A2 && (t17 += (null != h11 ? h11 : "") + o29[l20 + 1]), this._$AH[l20] = h11; + } + n31 && !e33 && this.j(t17); + } + j(t17) { + t17 === A2 ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, null != t17 ? t17 : ""); + } + }; + var H2 = class extends k4 { + constructor() { + super(...arguments), this.type = 3; + } + j(t17) { + this.element[this.name] = t17 === A2 ? void 0 : t17; + } + }; + var I2 = s6 ? s6.emptyScript : ""; + var L2 = class extends k4 { + constructor() { + super(...arguments), this.type = 4; + } + j(t17) { + t17 && t17 !== A2 ? this.element.setAttribute(this.name, I2) : this.element.removeAttribute(this.name); + } + }; + var z = class extends k4 { + constructor(t17, i23, s20, e33, o29) { + super(t17, i23, s20, e33, o29), this.type = 5; + } + _$AI(t17, i23 = this) { + var s20; + if ((t17 = null !== (s20 = S4(this, t17, i23, 0)) && void 0 !== s20 ? s20 : A2) === T2) + return; + const e33 = this._$AH, o29 = t17 === A2 && e33 !== A2 || t17.capture !== e33.capture || t17.once !== e33.once || t17.passive !== e33.passive, n31 = t17 !== A2 && (e33 === A2 || o29); + o29 && this.element.removeEventListener(this.name, this, e33), n31 && this.element.addEventListener(this.name, this, t17), this._$AH = t17; + } + handleEvent(t17) { + var i23, s20; + "function" == typeof this._$AH ? this._$AH.call(null !== (s20 = null === (i23 = this.options) || void 0 === i23 ? void 0 : i23.host) && void 0 !== s20 ? s20 : this.element, t17) : this._$AH.handleEvent(t17); + } + }; + var Z2 = class { + constructor(t17, i23, s20) { + this.element = t17, this.type = 6, this._$AN = void 0, this._$AM = i23, this.options = s20; + } + get _$AU() { + return this._$AM._$AU; + } + _$AI(t17) { + S4(this, t17); + } + }; + var B = i7.litHtmlPolyfillSupport; + null == B || B(N2, R2), (null !== (t6 = i7.litHtmlVersions) && void 0 !== t6 ? t6 : i7.litHtmlVersions = []).push("2.8.0"); + var D = (t17, i23, s20) => { + var e33, o29; + const n31 = null !== (e33 = null == s20 ? void 0 : s20.renderBefore) && void 0 !== e33 ? e33 : i23; + let l20 = n31._$litPart$; + if (void 0 === l20) { + const t18 = null !== (o29 = null == s20 ? void 0 : s20.renderBefore) && void 0 !== o29 ? o29 : null; + n31._$litPart$ = l20 = new R2(i23.insertBefore(u4(), t18), t18, void 0, null != s20 ? s20 : {}); + } + return l20._$AI(t17), l20; + }; + + // node_modules/@material/mwc-icon/node_modules/lit-element/lit-element.js + var l5; + var o8; + var s7 = class extends u3 { + constructor() { + super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0; + } + createRenderRoot() { + var t17, e33; + const i23 = super.createRenderRoot(); + return null !== (t17 = (e33 = this.renderOptions).renderBefore) && void 0 !== t17 || (e33.renderBefore = i23.firstChild), i23; + } + update(t17) { + const i23 = this.render(); + this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t17), this._$Do = D(i23, this.renderRoot, this.renderOptions); + } + connectedCallback() { + var t17; + super.connectedCallback(), null === (t17 = this._$Do) || void 0 === t17 || t17.setConnected(true); + } + disconnectedCallback() { + var t17; + super.disconnectedCallback(), null === (t17 = this._$Do) || void 0 === t17 || t17.setConnected(false); + } + render() { + return T2; + } + }; + s7.finalized = true, s7._$litElement$ = true, null === (l5 = globalThis.litElementHydrateSupport) || void 0 === l5 || l5.call(globalThis, { LitElement: s7 }); + var n8 = globalThis.litElementPolyfillSupport; + null == n8 || n8({ LitElement: s7 }); + (null !== (o8 = globalThis.litElementVersions) && void 0 !== o8 ? o8 : globalThis.litElementVersions = []).push("3.3.3"); + + // node_modules/@material/mwc-icon/node_modules/@lit/reactive-element/decorators/custom-element.js + var e10 = (e33) => (n31) => "function" == typeof n31 ? ((e34, n32) => (customElements.define(e34, n32), n32))(e33, n31) : ((e34, n32) => { + const { kind: t17, elements: s20 } = n32; + return { kind: t17, elements: s20, finisher(n33) { + customElements.define(e34, n33); + } }; + })(e33, n31); + + // node_modules/@material/mwc-icon/node_modules/@lit/reactive-element/decorators/query-assigned-elements.js + var n10; + var e11 = null != (null === (n10 = window.HTMLSlotElement) || void 0 === n10 ? void 0 : n10.prototype.assignedElements) ? (o29, n31) => o29.assignedElements(n31) : (o29, n31) => o29.assignedNodes(n31).filter((o30) => o30.nodeType === Node.ELEMENT_NODE); + + // node_modules/@material/mwc-icon/mwc-icon-host.css.js + var styles7 = i6`:host{font-family:var(--mdc-icon-font, "Material Icons");font-weight:normal;font-style:normal;font-size:var(--mdc-icon-size, 24px);line-height:1;letter-spacing:normal;text-transform:none;display:inline-block;white-space:nowrap;word-wrap:normal;direction:ltr;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;-moz-osx-font-smoothing:grayscale;font-feature-settings:"liga"}`; + + // node_modules/@material/mwc-icon/mwc-icon.js + var Icon = class Icon2 extends s7 { + /** @soyTemplate */ + render() { + return x2``; + } + }; + Icon.styles = [styles7]; + Icon = __decorate([ + e10("mwc-icon") + ], Icon); + + // node_modules/lit-html/directives/style-map.js + var n11 = "important"; + var i8 = " !" + n11; + var o10 = e5(class extends i5 { + constructor(t17) { + if (super(t17), t17.type !== t4.ATTRIBUTE || "style" !== t17.name || t17.strings?.length > 2) + throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute."); + } + render(t17) { + return Object.keys(t17).reduce((e33, r18) => { + const s20 = t17[r18]; + return null == s20 ? e33 : e33 + `${r18 = r18.includes("-") ? r18 : r18.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g, "-$&").toLowerCase()}:${s20};`; + }, ""); + } + update(e33, [r18]) { + const { style: s20 } = e33.element; + if (void 0 === this.ft) + return this.ft = new Set(Object.keys(r18)), this.render(r18); + for (const t17 of this.ft) + null == r18[t17] && (this.ft.delete(t17), t17.includes("-") ? s20.removeProperty(t17) : s20[t17] = null); + for (const t17 in r18) { + const e34 = r18[t17]; + if (null != e34) { + this.ft.add(t17); + const r19 = "string" == typeof e34 && e34.endsWith(i8); + t17.includes("-") || r19 ? s20.setProperty(t17, r19 ? e34.slice(0, -11) : e34, r19 ? n11 : "") : s20[t17] = e34; + } + } + return w; + } + }); + + // client/components/example_table.css + var styles8 = i`thead { + height: 50px; + position: sticky; + top: 0; + z-index: 1; +} + +thead.search-box-shown { + height: 68px; +} + +th { + background-color: var(--comparator-greyblue-300); + color: white; + font-weight: normal; + line-height: 17px; + overflow: hidden; + padding: 8px 6px 2px 6px; + position: relative; + vertical-align: top; +} + +td { + border-bottom: 1px solid #ddd; + border-right: 1px solid var(--comparator-grey-200); + /* LINT.IfChange */ + line-height: 1.4em; + /* LINT.ThenChange(../lib/constants.ts) */ + padding: 8px 4px 2px 12px; + vertical-align: top; +} + +tr.selected td { + background-color: var(--comparator-green-100); +} + +/* Header row */ +th.example-index { + min-width: 25px; + width: 25px; +} + +th.input-text { + min-width: 300px; + width: 30%; +} + +th.output-text { + min-width: 300px; + overflow-x: hidden; + width: 35%; +} + +tr.one-text-column-hidden th.input-text, +tr.one-text-column-hidden th.output-text, +tr.one-text-column-hidden th.custom-text { + width: 50%; +} + +tr.two-text-columns-hidden th.input-text, +tr.two-text-columns-hidden th.output-text { + width: 100%; +} + +th.output-a { + background-color: var(--comparator-model-a); +} + +th.output-b { + background-color: var(--comparator-model-b); +} + +th.tags { + min-width: 60px; + width: 70px; +} + +th.score { + min-width: 70px; + padding-left: 2px; + padding-right: 10px; + width: 70px; +} + +th.rationales { + min-width: 250px; + width: 30%; +} + +th.rationale-list { + min-width: 200px; + width: 20%; +} + +th.custom-number { + min-width: 20px; + width: 50px; +} + +th.custom-string, +th.custom-category, +th.custom-url { + min-width: 100px; +} + +th.custom-text { + min-width: 250px; + width: 30%; +} + +th.custom-image { + width: 200px; +} + +th .custom-field-name { + max-width: 100px; +} + +th.custom-number .custom-field-name { + max-width: 50px; +} + +th.custom-per-model .custom-field-name { + max-width: 120px; +} + +th.custom-per-model-boolean { + min-width: 50px; +} + +th.custom-per-model-number { + min-width: 60px; +} + +th.custom-per-model-category { + min-width: 160px; +} + +th.custom-per-rating-string { + min-width: 100px; +} + +th.custom-per-rating-per-model-category { + min-width: 135px; +} + +tr.header-row th.custom-per-model { + height: auto; +} + +tr.second-row th { + height: 20px; + padding-top: 0; +} + +tr.second-row .sort-icons-container { + top: 1px; +} + +/* Change padding when holder exists */ +td.input-text, +td.output-text, +td.rationales, +td.custom-string, +td.custom-category, +td.custom-text, +td.custom-url, +td.custom-image, +td.custom-per-model-category, +td.custom-per-model-text, +td.custom-per-rating-string, +td.custom-per-rating-per-model-category { + padding: 0 0 0 12px; + position: relative; +} + +/* for list-holder */ +td.rationale-list { + padding: 0 0 0 8px; +} + +td.tags { + overflow-x: hidden; + word-break: break-word; +} + +td.score { + padding-left: 4px; + text-align: center; +} + +td.score.a-win { + background-color: var(--comparator-model-a-win-bg); +} + +td.score.b-win { + background-color: var(--comparator-model-b-win-bg); +} + +.score-number { + font-size: 14px; +} + +.score-description { + background-color: var(--comparator-grey-450); + border-radius: 5px; + color: white; + display: inline-block; + font-size: 11px; + margin: 2px 0; + opacity: 0.8; + padding: 0 3px; +} + +.rater-info-link { + color: var(--comparator-grey-600); + font-size: 11px; + padding: 4px 0; + text-decoration: underline; +} + +.selected .rater-info-link { + color: var(--comparator-grey-800); + font-weight: 600; +} + +td.score:hover .rater-info-link { + color: var(--comparator-grey-800); +} + +ul.rationale-list { + line-height: 1.3em; + padding-left: 15px; +} + +ul.rationale-list li { + border-radius: 5px; + margin: 0 2px 4px; + position: relative; +} + +/* for applying background-color also to the areas for the bulleted points */ +ul.rationale-list li::before { + border-radius: 5px; + content: ''; + height: 100%; + left: -16px; + position: absolute; + top: 0; + width: 35px; + z-index: -1; +} + +ul.rationale-list li.cluster-selected { + background-color: var(--comparator-greygreen-100); + color: #000; +} + +ul.rationale-list li:hover, +ul.rationale-list li:hover::before, +ul.rationale-list li.cluster-selected::before { + background-color: var(--comparator-greygreen-200); +} + +.text-holder, +.list-holder, +.sequence-chunks-holder, +.score-holder { + height: 119px; /* Set default as 17px x 7 rows */ + overflow-x: hidden; + overflow-y: scroll; + padding-top: 8px; +} + +.text-holder { + overflow-wrap: anywhere; + white-space: break-spaces; +} + +.custom-per-model-text +.text-holder { + width: 240px; +} + +.sequence-chunks-holder { + overflow-wrap: anywhere; +} + +.score-holder { + overflow-y: hidden; + padding-top: 0; +} + +tr.monospace .text-holder { + font-family: monospace; +} + +.text-chunk { + white-space: break-spaces; +} + +.highlighted-match { + color: var(--comparator-green-500); +} + +.highlighted-search-match { + background-color: var(--comparator-search-match-background); + color: var(--comparator-search-match-foreground); + font-weight: 600; +} + +/* For tag chips */ +.input-text { + overflow-x: hidden; +} + +.input-text .text-holder:after, +.input-text .sequence-chunks-holder:after { + content: ""; + display: block; + height: 28px; +} + +td .tag-chips { + bottom: 0; + display: flex; + margin: 3px 20px 3px 0; + padding-left: 0; + position: absolute; +} + +td .tag-chips .tag-chip { + background-color: var(--comparator-custom-func-200); + border: 1px solid var(--comparator-custom-func-500); + border-radius: 15px; + color: var(--comparator-custom-func-800); + list-style: none; + margin-right: 2px; + padding: 1px 10px; + white-space: nowrap; +} + +/* For custom function chips */ +.output-text .text-holder:after { + content: ""; + display: block; + height: 28px; +} + +td .custom-func-result-chip { + background-color: var(--comparator-custom-func-200); + border: 1px solid var(--comparator-custom-func-500); + bottom: 0; + border-radius: 15px; + color: var(--comparator-custom-func-800); + margin: 3px 20px 3px 0; + padding: 1px 15px; + position: absolute; +} + +td .custom-func-result-chip.greyscale { + background-color: var(--comparator-grey-100); + border: 1px solid var(--comparator-grey-200); + color: #aaa; +} + +/* Custom fields */ +td.custom-number { + text-align: right; +} + +td.custom-string, +td.custom-category { + word-break: break-word; +} + +td.custom-url { + word-break: break-all; +} + +/* Per-model fields */ +table.per-model-data { + width: 100%; +} + +table.per-model-data td { + min-width: 25px; + padding: 6px 4px; + width: 50%; +} + +td.custom-per-model-category td { + min-width: 50px; +} + +td.custom-per-model-first { + border-left: 1px solid var(--comparator-grey-300); +} + +td.custom-per-model-last { + border-right: 1px solid var(--comparator-grey-300); +} + +.chart-holder { + height: 119px; /* Set default as 17px x 7 rows */ + overflow-wrap: anywhere; + overflow-y: auto; + padding-top: 8px; +} + +/* Set scrollbar as optional */ +td.custom-string .text-holder, +td.custom-category .text-holder, +td.custom-url .text-holder, +td.custom-per-model-category .text-holder, +td.custom-per-model-text .text-holder { + overflow-y: auto; +} + +td.custom-image img { + max-height: 110px; + max-width: 180px; +} + +/* Sort icons */ +.sort-icons-container { + background-color: var(--comparator-greyblue-300); +} + +th.output-a .sort-icons-container { + background-color: var(--comparator-model-a); +} + +th.output-b .sort-icons-container { + background-color: var(--comparator-model-b); +} + +/* Search */ +.search-icon-container { + right: 14px; + position: absolute; + top: 10px; +} + +.search-icon-container .sort-icon { + font-size: 16px; +} + +th .search-field { + bottom: 3px; + display: flex; + font-size: 11px; + gap: 2px; + left: 5%; + position: absolute; + width: 90%; +} + +th .search-field input { + background: rgba(255, 255, 255, 0.5); + border: 0; + padding: 3px 5px; + width: 100%; +} + +th .search-field button { + border: 0; + color: var(--comparator-grey-500); +} + +/* Show more */ +.display-more-button { + background-color: var(--comparator-grey-100); + border: 0; + font-size: 13px; + margin: 10px 0; + text-align: center; + padding: 10px 0; + width: 100%; +} + +.display-more-button:hover { + background-color: var(--comparator-greygreen-100); +} +`; + + // client/components/example_table.ts + var ExampleTableElement = class extends MobxLitElement { + constructor() { + super(); + this.appState = core.getService(AppState); + this.showSearchBoxes = false; + makeObservable(this); + } + static get styles() { + return [styles, styles8]; + } + styleCustomField(field, modelIndex = null) { + return e6({ + "custom-number": field.type === "number" /* NUMBER */, + "custom-string": field.type === "string" /* STRING */, + "custom-category": field.type === "category" /* CATEGORY */, + "custom-text": field.type === "text" /* TEXT */, + "custom-url": field.type === "url" /* URL */, + "custom-image": field.type === "image_path" /* IMAGE_PATH */ || field.type === "image_byte" /* IMAGE_BYTE */, + "custom-per-model": isPerModelFieldType(field) === true, + "custom-per-model-boolean": field.type === "per_model_boolean" /* PER_MODEL_BOOLEAN */, + "custom-per-model-number": field.type === "per_model_number" /* PER_MODEL_NUMBER */, + "custom-per-model-category": field.type === "per_model_category" /* PER_MODEL_CATEGORY */, + "custom-per-model-text": field.type === "per_model_text" /* PER_MODEL_TEXT */, + "custom-per-model-first": modelIndex === 0, + "custom-per-model-last": modelIndex === this.appState.models.length - 1, + "custom-per-rating-string": field.type === "per_rating_string" /* PER_RATING_STRING */, + "custom-per-rating-per-model-category": field.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */ + }); + } + renderCustomFuncResultChip(value, customFunc) { + const customFuncResultChipStyle = e6({ + "custom-func-result-chip": true, + "greyscale": customFunc.returnType === "Boolean" /* BOOLEAN */ && value !== true + }); + return x`
+ ${customFunc.name}: + ${printCustomFuncResultValue(value)} +
`; + } + styleHolder(exampleIndex) { + return o10({ + "height": this.appState.getIsExampleExpanded(exampleIndex) !== true ? `${this.appState.numberOfLinesPerOutputCell * LINE_HEIGHT_IN_CELL}px` : "auto", + "min-height": this.appState.getIsExampleExpanded(exampleIndex) === true ? `${this.appState.numberOfLinesPerOutputCell * LINE_HEIGHT_IN_CELL}px` : null + }); + } + renderPerModelField(values, field, exampleIndex) { + if (values.length !== 2) { + throw new Error("Per-model fields must have exactly 2 values."); + } else { + const cells = values.map((value, modelIndex) => { + const renderValue = () => { + if (field.type === "per_model_number" /* PER_MODEL_NUMBER */ || field.type === "per_model_boolean" /* PER_MODEL_BOOLEAN */ || field.type === "per_model_category" /* PER_MODEL_CATEGORY */) { + if (typeof value === "number") { + return toFixedIfNeeded(value); + } else { + return value; + } + } else { + const styleHolder = this.styleHolder(exampleIndex); + return x`
${value}
`; + } + }; + return x` + ${renderValue()} + `; + }); + return x`${cells}`; + } + } + // Per-rating per-model-category case. + // (e.g., Quality: [['Awesome' (A), 'Bad' (B)] (Rater #0), ...]). + // We use rowIndex and columnIndex instead of example and field, to ensure + // the charts get updated when state variables get updated. + renderPerRatingPerModelCategoryField(rowIndex, columnIndex) { + const getValueDomain = () => { + const field = this.appState.visibleColumns[columnIndex]; + return this.appState.valueDomainsForCustomFields[field.id]; + }; + const getBarChartData = () => { + if (rowIndex >= this.appState.examplesForMainTable.length) { + return []; + } else { + const ex = this.appState.examplesForMainTable[rowIndex]; + const field = this.appState.visibleColumns[columnIndex]; + return [ + ex.individual_rater_scores.map( + (rating) => rating.custom_fields[field.id][0] + ), + ex.individual_rater_scores.map( + (rating) => rating.custom_fields[field.id][1] + ) + ]; + } + }; + const isAnyBarSelected = (groupIndex) => { + const field = this.appState.visibleColumns[columnIndex]; + return this.appState.selectedBarChartValueForSelectedExample != null && this.appState.selectedBarChartValueForSelectedExample.fieldId === field.id && this.appState.selectedBarChartValueForSelectedExample.modelIndex === groupIndex; + }; + const isThisBarSelected = (value, groupIndex) => { + const field = this.appState.visibleColumns[columnIndex]; + return this.appState.selectedBarChartValueForSelectedExample != null && this.appState.selectedBarChartValueForSelectedExample.fieldId === field.id && this.appState.selectedBarChartValueForSelectedExample.modelIndex === groupIndex && this.appState.selectedBarChartValueForSelectedExample.value === value; + }; + const handleClickBar = (value, groupIndex) => { + const field = this.appState.visibleColumns[columnIndex]; + const currentSelection = this.appState.selectedBarChartValueForSelectedExample; + if (currentSelection != null && currentSelection.fieldId === field.id && currentSelection.modelIndex === groupIndex && currentSelection.value === value) { + this.appState.selectedBarChartValueForSelectedExample = null; + } else { + this.appState.selectedExample = this.appState.examplesForMainTable[rowIndex]; + this.appState.showSelectedExampleDetails = true; + this.appState.selectedBarChartValueForSelectedExample = { + fieldId: field.id, + modelIndex: groupIndex, + value + }; + } + }; + const getHighlightedValues = () => { + const field = this.appState.visibleColumns[columnIndex]; + return this.appState.selectedBarChartValues[field.id].filter( + (value) => value != null + ); + }; + return x` +
+ + +
+ `; + } + renderRow(example, rowIndex) { + const handleDoubleClickRow = () => { + this.appState.isExampleExpanded[example.index] = this.appState.getIsExampleExpanded(example.index) === true ? false : true; + }; + const styleRow = e6({ + "selected": this.appState.selectedExample === example, + "monospace": this.appState.useMonospace === true + }); + const styleHolder = this.styleHolder(example.index); + const textDiff = typeof example.output_text_a === "string" && typeof example.output_text_b === "string" ? getTextDiff(example.output_text_a, example.output_text_b) : getTextDiff("", ""); + const renderTextString = (rawText, parsedText, searchQuery, selectedCustomFunc2) => { + if (searchQuery !== "") { + return renderSearchedString(rawText, searchQuery); + } else if (selectedCustomFunc2 != null && selectedCustomFunc2.functionType === "Regular Expr." /* REGEXP */) { + return renderSearchedString( + rawText, + selectedCustomFunc2.functionBody, + false + ); + } else if (parsedText != null && this.appState.isShowTextDiff === true) { + return renderDiffString(parsedText, textDiff.isEquals); + } else { + return rawText; + } + }; + const renderText = (rawText, parsedText, fieldId) => { + const searchQuery = this.appState.searchFilters[fieldId]; + if (typeof rawText === "string") { + const selectedCustomFunc2 = fieldId === FIELD_ID_FOR_OUTPUT_A || fieldId === FIELD_ID_FOR_OUTPUT_B ? this.appState.selectedCustomFunc : null; + return x`
${renderTextString( + rawText, + parsedText, + searchQuery, + selectedCustomFunc2 + )}
`; + } else { + return x`
+ ${rawText.map( + (chunk) => chunk.type === "text" /* TEXT */ ? x`
${searchQuery !== "" ? renderSearchedString(chunk.data, searchQuery) : chunk.data}
` : x`
+ +
` + )} +
`; + } + }; + const renderTag = (tag) => x`
  • ${tag}
  • `; + const renderTags = example.tags.length === 0 ? "" : example.tags.length === 1 ? example.tags[0] : x`
      ${example.tags.map((tag) => renderTag(tag))}
    `; + const handleClickRaterDetails = () => { + if (this.appState.selectedExample === example && this.appState.showSelectedExampleDetails === true) { + this.appState.selectedExample = null; + this.appState.showSelectedExampleDetails = false; + } else { + this.appState.selectedExample = example; + this.appState.showSelectedExampleDetails = true; + } + }; + const isABetter = this.appState.isWinnerFromScore("A", example.score); + const isBBetter = this.appState.isWinnerFromScore("B", example.score); + const isAAndBSame = example.score != null && example.score === this.appState.scoreMiddlePoint; + const getHistogramRawDataValues = () => { + if (rowIndex >= this.appState.examplesForMainTable.length) { + return []; + } else { + return this.appState.examplesForMainTable[rowIndex].individual_rater_scores.filter((rating) => rating.score != null).map((rating) => rating.score); + } + }; + const renderHistogram = x` this.appState.histogramSpecForScores} + .getRawDataValues=${getHistogramRawDataValues} + .svgWidth=${40} + .svgHeight=${35} + .showBottomAxis=${false} + .neutralColorThreshold=${() => this.appState.winRateThreshold} + .isSimplified=${true} + .isFlipXAxis=${() => this.appState.isFlipScoreHistogramAxis}> + `; + const scoreDescription = this.appState.isScoreDivergingScheme === true ? isABetter === true ? x`
    A is better
    ` : isBBetter === true ? x`
    B is better
    ` : isAAndBSame === true ? x`
    same
    ` : x`
    similar
    ` : ""; + const raterInfoLink = example.individual_rater_scores.length > 0 ? x` + ${renderHistogram}` : ""; + const renderScore = example.score == null ? "Null" : x` +
    +
    ${example.score.toFixed(2)}
    + ${scoreDescription} + ${raterInfoLink} +
    `; + const styleScore = e6({ + "score": true, + "clickable": true, + "a-win": this.appState.isScoreDivergingScheme === true && isABetter === true, + "b-win": this.appState.isScoreDivergingScheme === true && isBBetter === true + }); + const styleRationaleItem = (rationaleItem) => ( + // Check if there is a selected or hovered cluster from the sidebar. + e6({ + "cluster-selected": rationaleItem.assignedClusterIds != null && (this.appState.selectedRationaleClusterId != null && rationaleItem.assignedClusterIds.includes( + this.appState.selectedRationaleClusterId + ) || this.appState.hoveredRationaleClusterId != null && rationaleItem.assignedClusterIds.includes( + this.appState.hoveredRationaleClusterId + )) + }) + ); + const handleMouseenterRationaleItem = (rationaleItem) => { + this.appState.matchedRationaleClusterIds = rationaleItem.assignedClusterIds || []; + }; + const handleMouseleaveRationaleItem = () => { + this.appState.matchedRationaleClusterIds = []; + }; + const searchQueryForRationaleList = this.appState.searchFilters[FIELD_ID_FOR_RATIONALE_LIST]; + const renderRationaleList = example.rationale_list != null && (isABetter === true || isBBetter === true) ? x` +
    +
      + ${example.rationale_list.map( + (item) => x` +
    • void handleMouseenterRationaleItem(item)} + @mouseleave=${handleMouseleaveRationaleItem}> + ${searchQueryForRationaleList == null ? item.rationale : renderSearchedString( + item.rationale, + searchQueryForRationaleList + )} +
    • ` + )} +
    +
    ` : ""; + const renderTagChips = this.appState.isShowTagChips === true && example.tags.length > 0 ? x`
      ${example.tags.map( + (tag) => x`
    • ${tag}
    • ` + )}
    ` : x``; + const selectedCustomFunc = this.appState.selectedCustomFunc; + const renderCustomFuncResultChip = (modelIndex) => selectedCustomFunc != null ? this.renderCustomFuncResultChip( + (example.custom_fields[getFieldIdForCustomFunc( + selectedCustomFunc.id + )] || Array)[modelIndex], + selectedCustomFunc + ) : x``; + const renderCustomField = (field, columnIndex) => { + if (field.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */) { + return this.renderPerRatingPerModelCategoryField(rowIndex, columnIndex); + } else if (!(isPerModelFieldType(field) === true)) { + let content = x``; + if (example.custom_fields[field.id] == null) { + content = x``; + } else if (field.type === "number" /* NUMBER */) { + content = x` + ${toFixedIfNeeded(example.custom_fields[field.id])}`; + } else if (field.type === "string" /* STRING */ || field.type === "category" /* CATEGORY */) { + content = x` +
    ${example.custom_fields[field.id]}
    `; + } else if (field.type === "text" /* TEXT */) { + content = x`${renderText( + example.custom_fields[field.id], + null, + field.id + )}`; + } else if (field.type === "url" /* URL */) { + content = x` + `; + } else if (field.type === "image_path" /* IMAGE_PATH */) { + content = x` +
    `; + } else if (field.type === "image_byte" /* IMAGE_BYTE */) { + content = x` +
    `; + } else if (field.type === "per_rating_string" /* PER_RATING_STRING */) { + content = x` +
    ${example.individual_rater_scores.map( + (rating) => rating.custom_fields[field.id] + ).join("\n")}
    `; + } + return x`${content}`; + } else { + const values = example.custom_fields[field.id]; + return this.renderPerModelField(values, field, example.index); + } + }; + const rationalesText = example.individual_rater_scores.map((rating) => rating.rationale).join("\n__________\n\n"); + const columns = this.appState.visibleColumns; + const renderRow = columns.map((field, columnIndex) => { + if (field.id === FIELD_ID_FOR_INDEX) { + return x` ${example.index}`; + } else if (field.id === FIELD_ID_FOR_INPUT) { + return x` + ${renderText(example.input_text, null, field.id)} ${renderTagChips} + `; + } else if (field.id === FIELD_ID_FOR_OUTPUT_A) { + return x` + ${renderText(example.output_text_a, textDiff.parsedA, field.id)} + ${renderCustomFuncResultChip(0)} + `; + } else if (field.id === FIELD_ID_FOR_OUTPUT_B) { + return x` + ${renderText(example.output_text_b, textDiff.parsedB, field.id)} + ${renderCustomFuncResultChip(1)} + `; + } else if (field.id === FIELD_ID_FOR_TAGS) { + return x` ${renderTags} `; + } else if (field.id === FIELD_ID_FOR_SCORE) { + return x` 0 ? "Click to see individual ratings" : ""}> + ${renderScore} + `; + } else if (field.id === FIELD_ID_FOR_RATIONALES) { + return x` + ${renderText(rationalesText, null, field.id)} + `; + } else if (field.id === FIELD_ID_FOR_RATIONALE_LIST) { + return x` ${renderRationaleList} `; + } else { + return renderCustomField(field, columnIndex); + } + }); + return x` + ${renderRow} + `; + } + renderHeaderRow() { + const styleTextColumn = this.appState.numberOfShownTextColumns !== 3 ? o10({ + "width": `${(100 / this.appState.numberOfShownTextColumns).toFixed( + 1 + )}%` + }) : o10({}); + const handleClickSortIcon = (sorting) => { + const currentSorting2 = this.appState.currentSorting; + if (isEqualSorting(currentSorting2, sorting)) { + this.appState.resetSorting(); + } else { + this.appState.updateSorting(sorting); + } + }; + const currentSorting = this.appState.currentSorting; + const styleSortIcons = (sorting) => e6({ + "sort-icon": true, + "up": sorting.order === "asc" /* ASC */, + "down": sorting.order === "desc" /* DESC */, + "active": isEqualSorting(currentSorting, sorting) + }); + const isRenderSortIconsForFuncs = this.appState.selectedCustomFunc != null && this.appState.selectedCustomFunc.returnType === "Number" /* NUMBER */; + const renderSortIcons = (column, customField = null, modelIndex = null) => { + const sortingCriteria = (order) => ({ column, customField, modelIndex, order }); + return x`
    + void handleClickSortIcon(sortingCriteria("asc" /* ASC */))}> + arrow_drop_up + + void handleClickSortIcon(sortingCriteria("desc" /* DESC */))}> + arrow_drop_down + +
    `; + }; + const renderSearchIcon = x`
    + this.showSearchBoxes = !this.showSearchBoxes}> + search + +
    `; + const renderSearchInput = (fieldId) => { + const handleApplySearchFilter = () => { + this.appState.searchFilters[fieldId] = this.appState.searchFilterInputs[fieldId]; + }; + const handleChangeSearchFieldText = (e33) => { + this.appState.searchFilterInputs[fieldId] = e33.target.value; + if (this.appState.searchFilterInputs[fieldId].length === 0) { + handleApplySearchFilter(); + } + }; + return this.showSearchBoxes === true ? x`
    + + +
    ` : ""; + }; + const columns = this.appState.visibleColumns; + const firstRow = columns.filter((field) => field.visible === true).map((field) => { + if (field.id === FIELD_ID_FOR_INDEX) { + return x` #`; + } else if (field.id === FIELD_ID_FOR_INPUT) { + return x` + ${field.name} + ${renderSearchIcon} + ${renderSearchInput(FIELD_ID_FOR_INPUT)} + `; + } else if (field.id === FIELD_ID_FOR_OUTPUT_A) { + return x` + ${field.name} + ${renderSearchIcon} +
    (${this.appState.models[0].name}) + ${isRenderSortIconsForFuncs === true ? renderSortIcons("value from selected Custom Function for Output A" /* FUNC_A */) : ""} + ${renderSearchInput(FIELD_ID_FOR_OUTPUT_A)} + `; + } else if (field.id === FIELD_ID_FOR_OUTPUT_B) { + return x` + ${field.name} + ${renderSearchIcon} +
    (${this.appState.models[1].name}) + ${isRenderSortIconsForFuncs === true ? renderSortIcons("value from selected Custom Function for Output B" /* FUNC_B */) : ""} + ${renderSearchInput(FIELD_ID_FOR_OUTPUT_B)} + `; + } else if (field.id === FIELD_ID_FOR_TAGS) { + return x` + ${field.name} ${renderSortIcons("tags" /* TAGS */)} + `; + } else if (field.id === FIELD_ID_FOR_SCORE) { + return x` + ${field.name} ${renderSortIcons("score" /* SCORE */)} + `; + } else if (field.id === FIELD_ID_FOR_RATIONALES) { + return x` + ${field.name} +
    (Be careful! A and B might be flipped.) + ${renderSearchIcon} + ${renderSearchInput(FIELD_ID_FOR_RATIONALES)} + `; + } else if (field.id === FIELD_ID_FOR_RATIONALE_LIST) { + return x` + + ${field.name} + ${renderSearchIcon} + ${renderSearchInput(FIELD_ID_FOR_RATIONALE_LIST)} + `; + } else if (isPerModelFieldType(field) === true) { + return x` +
    + ${field.name} +
    + `; + } else if (field.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */) { + return x` +
    + ${field.name} +
    + `; + } else { + const sortIcons = field.type === "image_path" /* IMAGE_PATH */ || field.type === "image_byte" /* IMAGE_BYTE */ || field.type === "text" /* TEXT */ ? "" : renderSortIcons("custom attribute" /* CUSTOM_ATTRIBUTE */, field); + const searchIconAndInput = field.type === "text" /* TEXT */ ? x` + ${renderSearchIcon} + ${renderSearchInput(field.id)}` : ""; + return x` +
    + ${field.name} +
    + ${sortIcons} + ${searchIconAndInput} + `; + } + }); + const secondRow = columns.filter((field) => field.visible === true).filter((field) => isPerModelFieldType(field) === true).map( + (field) => x` + A + ${renderSortIcons("custom attribute" /* CUSTOM_ATTRIBUTE */, field, 0)} + + + B + ${renderSortIcons("custom attribute" /* CUSTOM_ATTRIBUTE */, field, 1)} + ` + ); + return x` ${firstRow} + ${secondRow}`; + } + // Render button for displaying 50 more examples. + renderDisplayMoreButton() { + const numFilteredExamples = this.appState.filteredExamples.length; + const numExamplesToShowMore = Math.min( + DEFAULT_NUM_EXAMPLES_TO_DISPLAY, + numFilteredExamples - this.appState.numExamplesToDisplay + ); + const handleClickMoreExamples = () => { + this.appState.numExamplesToDisplay += numExamplesToShowMore; + }; + return x` +
    + ${numFilteredExamples > this.appState.numExamplesToDisplay ? x` + ` : ""} +
    `; + } + render() { + const styleHeader = e6({ + "search-box-shown": this.showSearchBoxes + }); + try { + const renderRows = this.appState.examplesForMainTable.map( + (example, rowIndex) => this.renderRow(example, rowIndex) + ); + return x` + + + ${this.renderHeaderRow()} + + + ${renderRows} + +
    + ${this.renderDisplayMoreButton()} + `; + } catch (error) { + console.error(error); + this.appState.updateStatusMessage( + "Encountered an error while displaying the table." + ); + return; + } + } + }; + __decorateClass([ + observable + ], ExampleTableElement.prototype, "showSearchBoxes", 2); + ExampleTableElement = __decorateClass([ + t3("comparator-example-table") + ], ExampleTableElement); + + // client/components/metrics_by_slice.css + var styles9 = i`thead { + position: sticky; + top: 0; +} + +th.score-avg { + width: 98px; /* width sum for score-avg-number and score-avg-chart */ +} + +td.tag-and-count { + align-items: center; + display: flex; + white-space: nowrap; +} + +td.tag-and-count .tag { + overflow-x: hidden; + text-overflow: ellipsis; +} + +small { + color: var(--comparator-grey-300); + font-size: 9px; + min-width: 15px; + padding-left: 2px; +} + +.number, +small .number { + color: var(--comparator-grey-500); + font-family: Roboto; + font-size: 11px; +} + +.number span { + border-radius: 2px; + padding: 0 1px; +} + +.score-avg-container, +.win-rate-container { + align-items: center; + display: flex; + gap: 2px; + justify-content: center; +} + +.score-avg-container .number, +.win-rate-container .number { + text-align: right; + width: 36px; +} + +.score-avg-chart { + font-size: 0; + width: 62px; /* distributionAreaWidth + 2px padding */ +} + +svg { + background-color: var(--comparator-grey-100); +} + +.win-rate-chart { + font-family: Roboto; + width: 62px; /* barAreaWidth + 2px padding */ +} + +td.score-avg, +td.win-rate-percentage { + text-align: right; +} + +.win-rate-chart svg { + display: block; +} + +.win-rate-chart text { + fill: var(--comparator-grey-100); + font-size: 11px; +} + +.win-rate-vertical { + fill: none; + stroke: var(--comparator-grey-600); + stroke-width: 2; +} + +.win-rate-point { + fill: var(--comparator-grey-600); + stroke-width: 0; +} + +.win-rate-confidence-interval { + fill: none; + stroke: var(--comparator-grey-600); + stroke-width: 1; +} + +rect.bar { + fill-opacity: 0.75; +} + +tr.selected rect.bar { + fill-opacity: 1.0; +} + +rect.bar.win-rate-result-a { + fill: var(--comparator-model-a-win); +} + +rect.bar.win-rate-result-b { + fill: var(--comparator-model-b-win); +} + +rect.bar.win-rate-result-tie { + fill: var(--comparator-grey-400); +} + +.collapsed .table-container { + max-height: 220px; + overflow-y: scroll; +} + +line.middle-point-vertical { + fill: none; + stroke: var(--comparator-grey-300); + stroke-width: 1; +} + +line.error-bar { + fill: none; + stroke: var(--comparator-grey-600); + stroke-width: 1; +} + +line.error-bar.a-win-color, +line.win-rate-confidence-interval.a-win-color { + fill: none; + stroke: var(--comparator-model-a-win); +} + +line.error-bar.b-win-color, +line.win-rate-confidence-interval.b-win-color { + fill: none; + stroke: var(--comparator-model-b-win); +} + +circle { + fill: var(--comparator-grey-600); + stroke-width: 0; +}`; + + // client/components/metrics_by_slice.ts + var MetricsBySliceElement = class extends MobxLitElement { + constructor() { + super(); + this.appState = core.getService(AppState); + this.distributionAreaWidth = 60; + this.barAreaWidth = 60; + this.barHeight = 16; + this.numRowsDisplayedWhenCollapsed = 10; + this.sortColumn = "count" /* COUNT */; + this.sortOrder = "desc" /* DESC */; + this.isChartCollapsed = true; + this.winRateMiddlePoint = 0.5; + makeObservable(this); + } + get listTagValues() { + const valueSet = new Set( + this.appState.examples.map((ex) => ex.tags).flat() + ); + return [...valueSet]; + } + /** + * Determine the win rate for a score and accumulate to SliceWinRate. + */ + accumulateWinRateForExample(sliceWinRate, ex, threshold = this.appState.winRateThreshold) { + sliceWinRate.count += 1; + if (ex.score == null) { + sliceWinRate.results["unknown" /* Unknown */] += 1; + } else if (ex.score > this.appState.scoreMiddlePoint + threshold) { + sliceWinRate.results["a" /* A */] += 1; + } else if (ex.score < this.appState.scoreMiddlePoint - threshold) { + sliceWinRate.results["b" /* B */] += 1; + } else { + sliceWinRate.results["tie" /* Tie */] += 1; + } + if (ex.score != null) { + sliceWinRate.scoreSum += ex.score; + sliceWinRate.scoreSqSum += ex.score ** 2; + } + } + get computeWinRatesByTags() { + const chartSelectionKey = { + chartType: "tag" /* TAG */, + fieldId: "tag", + model: null + }; + const filteredExamples = this.appState.getFilteredExamplesExceptForParticularChart( + chartSelectionKey + ); + const aggregatedByTags = {}; + aggregatedByTags["All"] = makeNewSliceWinRate("All"); + this.listTagValues.forEach((tag) => { + aggregatedByTags[tag] = makeNewSliceWinRate(tag); + }); + filteredExamples.forEach((ex) => { + this.accumulateWinRateForExample(aggregatedByTags["All"], ex); + ex.tags.forEach((tag) => { + this.accumulateWinRateForExample(aggregatedByTags[tag], ex); + }); + }); + const smallNumber = 1e-4; + const rate = (winnerCount, tieCount, totalCount) => { + if (totalCount === 0) { + return 0; + } + return (winnerCount + 0.5 * tieCount + smallNumber) / totalCount; + }; + return Object.values(aggregatedByTags).sort((i23, j3) => { + if (this.sortColumn === "count" /* COUNT */) { + if (this.sortOrder === "desc" /* DESC */) { + return j3.count - i23.count; + } else { + return i23.count - j3.count; + } + } else if (this.sortColumn === "avg_score" /* AVG_SCORE */) { + return compareNumbersWithNulls( + getAvgScore(i23), + getAvgScore(j3), + this.sortOrder === "desc" /* DESC */ + ); + } else if (this.sortColumn === "win_rate" /* WIN_RATE */) { + if (this.sortOrder === "desc" /* DESC */) { + return rate(j3.results["a"], j3.results["tie"], j3.count) - rate(i23.results["a"], i23.results["tie"], i23.count); + } else { + return rate(j3.results["b"], j3.results["tie"], j3.count) - rate(i23.results["b"], i23.results["tie"], i23.count); + } + } else { + if (this.sortOrder === "desc" /* DESC */) { + return j3.sliceName.localeCompare(i23.sliceName); + } else { + return i23.sliceName.localeCompare(j3.sliceName); + } + } + }); + } + // Render one of the three bars (e.g., for a, b, or tie) in a row. + renderWinRateBar(entry, result) { + const results = entry.results; + const barCount = results[result]; + const barWidth = this.barAreaWidth * barCount / (entry.count - results["unknown"]); + const xOffset = this.barAreaWidth * (result === "b" ? results["a"] + results["tie"] : result === "tie" ? results["a"] : 0) / (entry.count - results["unknown"]); + const xTextOffset = result !== "b" ? 3 : barWidth - 3; + const textClass = e6({ "right-aligned": result === "b" }); + return b2` + + + ${result !== "tie" && barCount > 0 ? b2` + + ${barCount} + ` : ""} + `; + } + // Check if the value is significantly higher or lower than the base value. + isSignificantWinner(model, value, baseValue, intervalLeft, intervalRight) { + if (value == null) { + return false; + } + if (model === "A" /* A */) { + return value - baseValue > 0 && intervalLeft - baseValue > 0 && intervalRight - baseValue > 0; + } else { + return value - baseValue < 0 && intervalLeft - baseValue < 0 && intervalRight - baseValue < 0; + } + } + // Render a confidence interval chart for average scores. + renderScoreConfIntervalChart(avgScore, intervalLeft, intervalRight) { + if (avgScore == null) { + return x``; + } + const histogramSpec = this.appState.histogramSpecForScores; + const xValue = (score) => { + const ratio = (score - histogramSpec.rangeLeft) / (histogramSpec.rangeRight - histogramSpec.rangeLeft); + return this.distributionAreaWidth * (this.appState.isFlipScoreHistogramAxis === true ? 1 - ratio : ratio); + }; + const styleElement = (className) => e6({ + "avg-score-point": className === "avg-score-point", + "error-bar": className === "error-bar", + "a-win-color": this.isSignificantWinner( + "A" /* A */, + avgScore, + this.appState.scoreMiddlePoint, + intervalLeft, + intervalRight + ), + "b-win-color": this.isSignificantWinner( + "B" /* B */, + avgScore, + this.appState.scoreMiddlePoint, + intervalLeft, + intervalRight + ) + }); + const tooltipText = `${`95% CI: [${intervalLeft.toFixed( + 3 + )}, ${intervalRight.toFixed(3)}]`}`; + return x` + + + + + + ${tooltipText} + + + `; + } + renderAvgScoreCell(entry) { + const avgScore = getAvgScore(entry); + const histogramSpec = this.appState.histogramSpecForScores; + const [intervalLeft, intervalRight] = getConfidenceIntervalForMeanFromAggregatedStats( + entry.count, + entry.scoreSum, + entry.scoreSqSum, + histogramSpec.rangeLeft - histogramSpec.rangeRight > 0 + ); + const styleAvgScoreNumber = e6({ + "a-win-color-bg-darker": this.isSignificantWinner( + "A" /* A */, + avgScore, + this.appState.scoreMiddlePoint, + intervalLeft, + intervalRight + ), + "b-win-color-bg-darker": this.isSignificantWinner( + "B" /* B */, + avgScore, + this.appState.scoreMiddlePoint, + intervalLeft, + intervalRight + ) + }); + const renderScoreConfIntervalChart = this.renderScoreConfIntervalChart( + avgScore, + intervalLeft, + intervalRight + ); + return x`
    +
    + + ${avgScore == null ? "" : avgScore.toFixed(2)} + +
    +
    ${renderScoreConfIntervalChart}
    +
    `; + } + // Render a win rate chart using a stacked percentage bar chart. + renderWinRateChart(winRate, entry, intervalLeft, intervalRight) { + const styleElement = (className) => e6({ + "win-rate-point": className === "win-rate-point", + "win-rate-confidence-interval": className === "win-rate-confidence-interval", + "a-win-color": intervalLeft != null && intervalRight != null && this.isSignificantWinner( + "A" /* A */, + winRate, + this.winRateMiddlePoint, + intervalLeft, + intervalRight + ), + "b-win-color": intervalLeft != null && intervalRight != null && this.isSignificantWinner( + "B" /* B */, + winRate, + this.winRateMiddlePoint, + intervalLeft, + intervalRight + ) + }); + const renderConfidenceInterval = intervalLeft != null && intervalRight != null ? b2` + ` : b2``; + const tooltipText = intervalLeft != null && intervalRight != null ? `${`95% CI: [${intervalLeft.toFixed(3)}, ${intervalRight.toFixed( + 3 + )}]`}` : ""; + const renderWinRatePoint = b2` + + ${tooltipText} + `; + return x` + + + ${entry.count - entry.results["unknown" /* Unknown */] > 0 ? b2` + ${this.renderWinRateBar(entry, "tie" /* Tie */)} + ${this.renderWinRateBar(entry, "b" /* B */)} + ${this.renderWinRateBar(entry, "a" /* A */)} + + ${renderConfidenceInterval} + ${renderWinRatePoint}` : ""} + + `; + } + renderWinRateCell(entry) { + const winRate = getWinRate(entry); + const [winRateIntervalLeft, winRateIntervalRight] = getConfidenceIntervalForRate( + entry.results["a"] + entry.results["tie"] * 0.5, + entry.results["b"] + entry.results["tie"] * 0.5 + ); + const styleWinRateNumber = e6({ + "a-win-color-bg-darker": this.isSignificantWinner( + "A" /* A */, + winRate, + this.winRateMiddlePoint, + winRateIntervalLeft, + winRateIntervalRight + ), + "b-win-color-bg-darker": this.isSignificantWinner( + "B" /* B */, + winRate, + this.winRateMiddlePoint, + winRateIntervalLeft, + winRateIntervalRight + ) + }); + const renderWinRateChart = this.renderWinRateChart( + winRate, + entry, + winRateIntervalLeft, + winRateIntervalRight + ); + return x`
    +
    + + ${entry.count > 0 ? x`${formatRateToPercentage(winRate)}` : ""} + +
    +
    ${renderWinRateChart}
    +
    `; + } + // Render a stacked bar chart for a slice. + renderSliceRow(entry) { + const sliceName = entry.sliceName; + const handleClickSliceRow = () => { + if (sliceName === "All" || sliceName === this.appState.selectedTag) { + this.appState.selectedTag = null; + } else { + this.appState.selectedTag = sliceName; + } + }; + return x` + + ${entry.sliceName} + + (${entry.count}) + + + ${this.renderAvgScoreCell(entry)} + ${this.renderWinRateCell(entry)} + `; + } + // Render a list of stacked bar charts for slices. + renderWinRateBySliceChart() { + const renderSliceRows = this.computeWinRatesByTags.map( + (entry) => this.renderSliceRow(entry) + ); + const styleComponentContent = e6({ + "sidebar-component-content": true, + "collapsed": this.isChartCollapsed === true + }); + const handleClickSortHeader = (columnName) => { + if (this.sortColumn === columnName) { + this.sortOrder = this.sortOrder === "asc" /* ASC */ ? "desc" /* DESC */ : "asc" /* ASC */; + } else { + this.sortColumn = columnName; + } + }; + const styleHeaderCell = (columnName) => e6({ + "tag": columnName === "tag", + "example-count": columnName === "count", + "score-avg": columnName === "avg_score", + "win-rate": columnName === "win_rate", + "clickable": true, + "sort-selected": this.sortColumn === columnName + }); + return x` + `; + } + render() { + return x`${this.renderWinRateBySliceChart()}`; + } + }; + MetricsBySliceElement.styles = [styles, styles9]; + __decorateClass([ + observable + ], MetricsBySliceElement.prototype, "sortColumn", 2); + __decorateClass([ + observable + ], MetricsBySliceElement.prototype, "sortOrder", 2); + __decorateClass([ + observable + ], MetricsBySliceElement.prototype, "isChartCollapsed", 2); + __decorateClass([ + computed + ], MetricsBySliceElement.prototype, "listTagValues", 1); + __decorateClass([ + computed + ], MetricsBySliceElement.prototype, "computeWinRatesByTags", 1); + MetricsBySliceElement = __decorateClass([ + t3("comparator-metrics-by-slice") + ], MetricsBySliceElement); + + // client/components/rationale_summary.css + var styles10 = i`th.example-count { + cursor: pointer; + width: 50px; +} + +th.remove { + width: 26px; +} + +text.bar-count-text { + alignment-baseline: central; + fill: var(--comparator-grey-500); + font-size: 10px; + text-anchor: start; +} + +text.bar-count-text.right-aligned { + fill: var(--comparator-grey-100); + text-anchor: end; +} + +svg.bar-svg { + height: 16px; + width: 42px; +} + +td.remove { + pointer-events: none; +} + +.icon { + color: var(--comparator-grey-300); + font-size: 12px; + margin: 0; + padding: 3px; + pointer-events: auto; +}`; + + // client/components/rationale_summary.ts + var RationaleSummaryElement = class extends MobxLitElement { + constructor() { + super(); + this.appState = core.getService(AppState); + this.barMaxWidth = 40; + this.barHeight = 16; + this.widthOfNumberLabel = 10; + this.showOthers = false; + this.sortColumn = "A"; + makeObservable(this); + } + get filteredExamples() { + const chartSelectionKey = { + chartType: "rationale_cluster" /* RATIONALE_CLUSTER */, + fieldId: "rationale_cluster", + model: null + }; + return this.appState.getFilteredExamplesExceptForParticularChart( + chartSelectionKey + ); + } + get rationaleClustersWithCounts() { + const aWinExamples = this.filteredExamples.filter( + (example) => this.appState.isWinnerFromScore("A", example.score) + ); + const bWinExamples = this.filteredExamples.filter( + (example) => this.appState.isWinnerFromScore("B", example.score) + ); + return this.appState.rationaleClusters.filter( + (cluster) => this.showOthers === false ? cluster.id >= 0 : true + ).map((cluster) => { + const aWinCount = aWinExamples.filter((example) => { + const clusterIds = example.rationale_list.map( + (item) => item.assignedClusterIds + ).flat(); + return clusterIds.includes(cluster.id); + }).length; + const bWinCount = bWinExamples.filter((example) => { + const clusterIds = example.rationale_list.map( + (item) => item.assignedClusterIds + ).flat(); + return clusterIds.includes(cluster.id); + }).length; + return { + id: cluster.id, + title: cluster.title, + aWinCount, + bWinCount + }; + }); + } + get sortedClusters() { + return this.rationaleClustersWithCounts.filter( + (cluster) => cluster.aWinCount > 0 || cluster.bWinCount > 0 + ).sort((i23, j3) => { + if (i23.id === -1) { + return 1; + } else if (j3.id === -1) { + return -1; + } else if (this.sortColumn === "A") { + return j3.aWinCount - i23.aWinCount; + } else if (this.sortColumn === "B") { + return j3.bWinCount - i23.bWinCount; + } else { + return i23.title.localeCompare(j3.title); + } + }); + } + renderHeaderRow() { + const styleHeaderCell = (column) => e6({ + "cluster-title": column === "label", + "example-count": column === "A" || column === "B", + "sort-selected": this.sortColumn === column, + "clickable": true + }); + const handleClickSortHeader = (column) => { + this.sortColumn = column; + }; + return x` + void handleClickSortHeader("label")}> + Cluster Label + + void handleClickSortHeader("A")}> + A better + + void handleClickSortHeader("B")}> + B better + + + `; + } + // Render a row of the table on the Rationale Summary sidebar component. + renderClusterRow(cluster, maxCount) { + const handleClickClusterRow = (clusterId) => { + if (clusterId === this.appState.selectedRationaleClusterId) { + this.appState.selectedRationaleClusterId = null; + this.appState.currentSorting = DEFAULT_SORTING_CRITERIA; + } else { + this.appState.selectedRationaleClusterId = clusterId; + this.appState.currentSorting = { + column: "similarity between cluster label and the most similar rationale" /* RATIONALE_CLUSTER */, + customField: null, + modelIndex: null, + order: "desc" /* DESC */ + }; + } + }; + const renderBarCell = (count, maxCount2, model) => { + const barWidth = this.barMaxWidth * (count / maxCount2); + const styleBar = e6({ + "bar": true, + "a-win-color": model === "A", + "b-win-color": model === "B" + }); + const styleBarCountText = e6({ + "bar-count-text": true, + "right-aligned": this.barMaxWidth - barWidth < this.widthOfNumberLabel + }); + const textHorizontalPadding = this.barMaxWidth - barWidth < this.widthOfNumberLabel ? barWidth - 1 : barWidth + 1; + return x` + + + ${count} + + `; + }; + const handleMouseEnterRow = (clusterId) => this.appState.hoveredRationaleClusterId = clusterId; + const handleMouseLeaveRow = () => this.appState.hoveredRationaleClusterId = null; + return x` void handleMouseEnterRow(cluster.id)} + @mouseleave=${handleMouseLeaveRow}> + void handleClickClusterRow(cluster.id)}> + ${cluster.title} + + void handleClickClusterRow(cluster.id)}> + ${renderBarCell(cluster.aWinCount, maxCount, "A")} + + void handleClickClusterRow(cluster.id)}> + ${renderBarCell(cluster.bWinCount, maxCount, "B")} + + + void this.appState.removeCluster(cluster.id)}> + cancel + + + `; + } + render() { + if (this.appState.hasRationaleClusters === false) { + return x``; + } + const maxCount = Math.max( + 1, + ...this.sortedClusters.map( + (cluster) => cluster.aWinCount + ), + ...this.sortedClusters.map( + (cluster) => cluster.bWinCount + ) + ); + const renderClusters = this.sortedClusters.map( + (cluster) => this.renderClusterRow(cluster, maxCount) + ); + return x``; + } + }; + RationaleSummaryElement.styles = [styles, styles10]; + __decorateClass([ + observable + ], RationaleSummaryElement.prototype, "showOthers", 2); + __decorateClass([ + observable + ], RationaleSummaryElement.prototype, "sortColumn", 2); + __decorateClass([ + computed + ], RationaleSummaryElement.prototype, "filteredExamples", 1); + __decorateClass([ + computed + ], RationaleSummaryElement.prototype, "rationaleClustersWithCounts", 1); + __decorateClass([ + computed + ], RationaleSummaryElement.prototype, "sortedClusters", 1); + RationaleSummaryElement = __decorateClass([ + t3("comparator-rationale-summary") + ], RationaleSummaryElement); + + // client/components/score_histogram.css + var styles11 = i``; + + // client/components/score_histogram.ts + var ScoreHistogramElement = class extends MobxLitElement { + constructor() { + super(...arguments); + this.appState = core.getService(AppState); + this.svgWidth = 220; + this.svgHeight = 110; + } + renderScoreHistogram() { + const chartSelectionKey = { + chartType: "histogram" /* HISTOGRAM */, + fieldId: FIELD_ID_FOR_SCORE, + model: null + }; + const getHistogramRawDataValues = () => this.appState.getFilteredExamplesExceptForParticularChart(chartSelectionKey).filter((ex) => ex.score != null).map((ex) => ex.score); + const handleClickHistogramBar = (binIndex) => { + if (this.appState.selectedHistogramBinForScores === binIndex) { + this.appState.selectedHistogramBinForScores = null; + } else { + this.appState.selectedHistogramBinForScores = binIndex; + } + }; + const isAnyBinSelected = () => this.appState.selectedHistogramBinForScores !== null; + const isThisBinSelected = (binIndex) => binIndex === this.appState.selectedHistogramBinForScores; + return x` + `; + } + render() { + return x` ${this.renderScoreHistogram()}`; + } + }; + ScoreHistogramElement.styles = [styles, styles11]; + ScoreHistogramElement = __decorateClass([ + t3("comparator-score-histogram") + ], ScoreHistogramElement); + + // node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/decorators/custom-element.js + var e12 = (e33) => (n31) => "function" == typeof n31 ? ((e34, n32) => (customElements.define(e34, n32), n32))(e33, n31) : ((e34, n32) => { + const { kind: t17, elements: s20 } = n32; + return { kind: t17, elements: s20, finisher(n33) { + customElements.define(e34, n33); + } }; + })(e33, n31); + + // node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/decorators/property.js + var i9 = (i23, e33) => "method" === e33.kind && e33.descriptor && !("value" in e33.descriptor) ? { ...e33, finisher(n31) { + n31.createProperty(e33.key, i23); + } } : { kind: "field", key: Symbol(), placement: "own", descriptor: {}, originalKey: e33.key, initializer() { + "function" == typeof e33.initializer && (this[e33.key] = e33.initializer.call(this)); + }, finisher(n31) { + n31.createProperty(e33.key, i23); + } }; + var e13 = (i23, e33, n31) => { + e33.constructor.createProperty(n31, i23); + }; + function n12(n31) { + return (t17, o29) => void 0 !== o29 ? e13(n31, t17, o29) : i9(n31, t17); + } + + // node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/decorators/state.js + function t7(t17) { + return n12({ ...t17, state: true }); + } + + // node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/decorators/base.js + var o11 = ({ finisher: e33, descriptor: t17 }) => (o29, n31) => { + var r18; + if (void 0 === n31) { + const n32 = null !== (r18 = o29.originalKey) && void 0 !== r18 ? r18 : o29.key, i23 = null != t17 ? { kind: "method", placement: "prototype", key: n32, descriptor: t17(o29.key) } : { ...o29, key: n32 }; + return null != e33 && (i23.finisher = function(t18) { + e33(t18, n32); + }), i23; + } + { + const r19 = o29.constructor; + void 0 !== t17 && Object.defineProperty(o29, n31, t17(n31)), null == e33 || e33(r19, n31); + } + }; + + // node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/decorators/event-options.js + function e14(e33) { + return o11({ finisher: (r18, t17) => { + Object.assign(r18.prototype[t17], e33); + } }); + } + + // node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/decorators/query.js + function i10(i23, n31) { + return o11({ descriptor: (o29) => { + const t17 = { get() { + var o30, n32; + return null !== (n32 = null === (o30 = this.renderRoot) || void 0 === o30 ? void 0 : o30.querySelector(i23)) && void 0 !== n32 ? n32 : null; + }, enumerable: true, configurable: true }; + if (n31) { + const n32 = "symbol" == typeof o29 ? Symbol() : "__" + o29; + t17.get = function() { + var o30, t18; + return void 0 === this[n32] && (this[n32] = null !== (t18 = null === (o30 = this.renderRoot) || void 0 === o30 ? void 0 : o30.querySelector(i23)) && void 0 !== t18 ? t18 : null), this[n32]; + }; + } + return t17; + } }); + } + + // node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/decorators/query-async.js + function e15(e33) { + return o11({ descriptor: (r18) => ({ async get() { + var r19; + return await this.updateComplete, null === (r19 = this.renderRoot) || void 0 === r19 ? void 0 : r19.querySelector(e33); + }, enumerable: true, configurable: true }) }); + } + + // node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/decorators/query-assigned-elements.js + var n13; + var e16 = null != (null === (n13 = window.HTMLSlotElement) || void 0 === n13 ? void 0 : n13.prototype.assignedElements) ? (o29, n31) => o29.assignedElements(n31) : (o29, n31) => o29.assignedNodes(n31).filter((o30) => o30.nodeType === Node.ELEMENT_NODE); + + // node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/decorators/custom-element.js + var e17 = (e33) => (n31) => "function" == typeof n31 ? ((e34, n32) => (customElements.define(e34, n32), n32))(e33, n31) : ((e34, n32) => { + const { kind: t17, elements: s20 } = n32; + return { kind: t17, elements: s20, finisher(n33) { + customElements.define(e34, n33); + } }; + })(e33, n31); + + // node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/decorators/property.js + var i11 = (i23, e33) => "method" === e33.kind && e33.descriptor && !("value" in e33.descriptor) ? { ...e33, finisher(n31) { + n31.createProperty(e33.key, i23); + } } : { kind: "field", key: Symbol(), placement: "own", descriptor: {}, originalKey: e33.key, initializer() { + "function" == typeof e33.initializer && (this[e33.key] = e33.initializer.call(this)); + }, finisher(n31) { + n31.createProperty(e33.key, i23); + } }; + var e18 = (i23, e33, n31) => { + e33.constructor.createProperty(n31, i23); + }; + function n14(n31) { + return (t17, o29) => void 0 !== o29 ? e18(n31, t17, o29) : i11(n31, t17); + } + + // node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/decorators/state.js + function t8(t17) { + return n14({ ...t17, state: true }); + } + + // node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/decorators/base.js + var o12 = ({ finisher: e33, descriptor: t17 }) => (o29, n31) => { + var r18; + if (void 0 === n31) { + const n32 = null !== (r18 = o29.originalKey) && void 0 !== r18 ? r18 : o29.key, i23 = null != t17 ? { kind: "method", placement: "prototype", key: n32, descriptor: t17(o29.key) } : { ...o29, key: n32 }; + return null != e33 && (i23.finisher = function(t18) { + e33(t18, n32); + }), i23; + } + { + const r19 = o29.constructor; + void 0 !== t17 && Object.defineProperty(o29, n31, t17(n31)), null == e33 || e33(r19, n31); + } + }; + + // node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/decorators/query.js + function i12(i23, n31) { + return o12({ descriptor: (o29) => { + const t17 = { get() { + var o30, n32; + return null !== (n32 = null === (o30 = this.renderRoot) || void 0 === o30 ? void 0 : o30.querySelector(i23)) && void 0 !== n32 ? n32 : null; + }, enumerable: true, configurable: true }; + if (n31) { + const n32 = "symbol" == typeof o29 ? Symbol() : "__" + o29; + t17.get = function() { + var o30, t18; + return void 0 === this[n32] && (this[n32] = null !== (t18 = null === (o30 = this.renderRoot) || void 0 === o30 ? void 0 : o30.querySelector(i23)) && void 0 !== t18 ? t18 : null), this[n32]; + }; + } + return t17; + } }); + } + + // node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/decorators/query-assigned-elements.js + var n15; + var e19 = null != (null === (n15 = window.HTMLSlotElement) || void 0 === n15 ? void 0 : n15.prototype.assignedElements) ? (o29, n31) => o29.assignedElements(n31) : (o29, n31) => o29.assignedNodes(n31).filter((o30) => o30.nodeType === Node.ELEMENT_NODE); + + // node_modules/@material/dom/ponyfill.js + function matches2(element, selector) { + var nativeMatches = element.matches || element.webkitMatchesSelector || element.msMatchesSelector; + return nativeMatches.call(element, selector); + } + + // node_modules/@material/mwc-base/node_modules/@lit/reactive-element/css-tag.js + var t9 = window; + var e20 = t9.ShadowRoot && (void 0 === t9.ShadyCSS || t9.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype; + var s8 = Symbol(); + var n16 = /* @__PURE__ */ new WeakMap(); + var o13 = class { + constructor(t17, e33, n31) { + if (this._$cssResult$ = true, n31 !== s8) + throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); + this.cssText = t17, this.t = e33; + } + get styleSheet() { + let t17 = this.o; + const s20 = this.t; + if (e20 && void 0 === t17) { + const e33 = void 0 !== s20 && 1 === s20.length; + e33 && (t17 = n16.get(s20)), void 0 === t17 && ((this.o = t17 = new CSSStyleSheet()).replaceSync(this.cssText), e33 && n16.set(s20, t17)); + } + return t17; + } + toString() { + return this.cssText; + } + }; + var r9 = (t17) => new o13("string" == typeof t17 ? t17 : t17 + "", void 0, s8); + var S5 = (s20, n31) => { + e20 ? s20.adoptedStyleSheets = n31.map((t17) => t17 instanceof CSSStyleSheet ? t17 : t17.styleSheet) : n31.forEach((e33) => { + const n32 = document.createElement("style"), o29 = t9.litNonce; + void 0 !== o29 && n32.setAttribute("nonce", o29), n32.textContent = e33.cssText, s20.appendChild(n32); + }); + }; + var c6 = e20 ? (t17) => t17 : (t17) => t17 instanceof CSSStyleSheet ? ((t18) => { + let e33 = ""; + for (const s20 of t18.cssRules) + e33 += s20.cssText; + return r9(e33); + })(t17) : t17; + + // node_modules/@material/mwc-base/node_modules/@lit/reactive-element/reactive-element.js + var s9; + var e21 = window; + var r10 = e21.trustedTypes; + var h5 = r10 ? r10.emptyScript : ""; + var o14 = e21.reactiveElementPolyfillSupport; + var n17 = { toAttribute(t17, i23) { + switch (i23) { + case Boolean: + t17 = t17 ? h5 : null; + break; + case Object: + case Array: + t17 = null == t17 ? t17 : JSON.stringify(t17); + } + return t17; + }, fromAttribute(t17, i23) { + let s20 = t17; + switch (i23) { + case Boolean: + s20 = null !== t17; + break; + case Number: + s20 = null === t17 ? null : Number(t17); + break; + case Object: + case Array: + try { + s20 = JSON.parse(t17); + } catch (t18) { + s20 = null; + } + } + return s20; + } }; + var a5 = (t17, i23) => i23 !== t17 && (i23 == i23 || t17 == t17); + var l9 = { attribute: true, type: String, converter: n17, reflect: false, hasChanged: a5 }; + var d5 = "finalized"; + var u5 = class extends HTMLElement { + constructor() { + super(), this._$Ei = /* @__PURE__ */ new Map(), this.isUpdatePending = false, this.hasUpdated = false, this._$El = null, this._$Eu(); + } + static addInitializer(t17) { + var i23; + this.finalize(), (null !== (i23 = this.h) && void 0 !== i23 ? i23 : this.h = []).push(t17); + } + static get observedAttributes() { + this.finalize(); + const t17 = []; + return this.elementProperties.forEach((i23, s20) => { + const e33 = this._$Ep(s20, i23); + void 0 !== e33 && (this._$Ev.set(e33, s20), t17.push(e33)); + }), t17; + } + static createProperty(t17, i23 = l9) { + if (i23.state && (i23.attribute = false), this.finalize(), this.elementProperties.set(t17, i23), !i23.noAccessor && !this.prototype.hasOwnProperty(t17)) { + const s20 = "symbol" == typeof t17 ? Symbol() : "__" + t17, e33 = this.getPropertyDescriptor(t17, s20, i23); + void 0 !== e33 && Object.defineProperty(this.prototype, t17, e33); + } + } + static getPropertyDescriptor(t17, i23, s20) { + return { get() { + return this[i23]; + }, set(e33) { + const r18 = this[t17]; + this[i23] = e33, this.requestUpdate(t17, r18, s20); + }, configurable: true, enumerable: true }; + } + static getPropertyOptions(t17) { + return this.elementProperties.get(t17) || l9; + } + static finalize() { + if (this.hasOwnProperty(d5)) + return false; + this[d5] = true; + const t17 = Object.getPrototypeOf(this); + if (t17.finalize(), void 0 !== t17.h && (this.h = [...t17.h]), this.elementProperties = new Map(t17.elementProperties), this._$Ev = /* @__PURE__ */ new Map(), this.hasOwnProperty("properties")) { + const t18 = this.properties, i23 = [...Object.getOwnPropertyNames(t18), ...Object.getOwnPropertySymbols(t18)]; + for (const s20 of i23) + this.createProperty(s20, t18[s20]); + } + return this.elementStyles = this.finalizeStyles(this.styles), true; + } + static finalizeStyles(i23) { + const s20 = []; + if (Array.isArray(i23)) { + const e33 = new Set(i23.flat(1 / 0).reverse()); + for (const i24 of e33) + s20.unshift(c6(i24)); + } else + void 0 !== i23 && s20.push(c6(i23)); + return s20; + } + static _$Ep(t17, i23) { + const s20 = i23.attribute; + return false === s20 ? void 0 : "string" == typeof s20 ? s20 : "string" == typeof t17 ? t17.toLowerCase() : void 0; + } + _$Eu() { + var t17; + this._$E_ = new Promise((t18) => this.enableUpdating = t18), this._$AL = /* @__PURE__ */ new Map(), this._$Eg(), this.requestUpdate(), null === (t17 = this.constructor.h) || void 0 === t17 || t17.forEach((t18) => t18(this)); + } + addController(t17) { + var i23, s20; + (null !== (i23 = this._$ES) && void 0 !== i23 ? i23 : this._$ES = []).push(t17), void 0 !== this.renderRoot && this.isConnected && (null === (s20 = t17.hostConnected) || void 0 === s20 || s20.call(t17)); + } + removeController(t17) { + var i23; + null === (i23 = this._$ES) || void 0 === i23 || i23.splice(this._$ES.indexOf(t17) >>> 0, 1); + } + _$Eg() { + this.constructor.elementProperties.forEach((t17, i23) => { + this.hasOwnProperty(i23) && (this._$Ei.set(i23, this[i23]), delete this[i23]); + }); + } + createRenderRoot() { + var t17; + const s20 = null !== (t17 = this.shadowRoot) && void 0 !== t17 ? t17 : this.attachShadow(this.constructor.shadowRootOptions); + return S5(s20, this.constructor.elementStyles), s20; + } + connectedCallback() { + var t17; + void 0 === this.renderRoot && (this.renderRoot = this.createRenderRoot()), this.enableUpdating(true), null === (t17 = this._$ES) || void 0 === t17 || t17.forEach((t18) => { + var i23; + return null === (i23 = t18.hostConnected) || void 0 === i23 ? void 0 : i23.call(t18); + }); + } + enableUpdating(t17) { + } + disconnectedCallback() { + var t17; + null === (t17 = this._$ES) || void 0 === t17 || t17.forEach((t18) => { + var i23; + return null === (i23 = t18.hostDisconnected) || void 0 === i23 ? void 0 : i23.call(t18); + }); + } + attributeChangedCallback(t17, i23, s20) { + this._$AK(t17, s20); + } + _$EO(t17, i23, s20 = l9) { + var e33; + const r18 = this.constructor._$Ep(t17, s20); + if (void 0 !== r18 && true === s20.reflect) { + const h11 = (void 0 !== (null === (e33 = s20.converter) || void 0 === e33 ? void 0 : e33.toAttribute) ? s20.converter : n17).toAttribute(i23, s20.type); + this._$El = t17, null == h11 ? this.removeAttribute(r18) : this.setAttribute(r18, h11), this._$El = null; + } + } + _$AK(t17, i23) { + var s20; + const e33 = this.constructor, r18 = e33._$Ev.get(t17); + if (void 0 !== r18 && this._$El !== r18) { + const t18 = e33.getPropertyOptions(r18), h11 = "function" == typeof t18.converter ? { fromAttribute: t18.converter } : void 0 !== (null === (s20 = t18.converter) || void 0 === s20 ? void 0 : s20.fromAttribute) ? t18.converter : n17; + this._$El = r18, this[r18] = h11.fromAttribute(i23, t18.type), this._$El = null; + } + } + requestUpdate(t17, i23, s20) { + let e33 = true; + void 0 !== t17 && (((s20 = s20 || this.constructor.getPropertyOptions(t17)).hasChanged || a5)(this[t17], i23) ? (this._$AL.has(t17) || this._$AL.set(t17, i23), true === s20.reflect && this._$El !== t17 && (void 0 === this._$EC && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(t17, s20))) : e33 = false), !this.isUpdatePending && e33 && (this._$E_ = this._$Ej()); + } + async _$Ej() { + this.isUpdatePending = true; + try { + await this._$E_; + } catch (t18) { + Promise.reject(t18); + } + const t17 = this.scheduleUpdate(); + return null != t17 && await t17, !this.isUpdatePending; + } + scheduleUpdate() { + return this.performUpdate(); + } + performUpdate() { + var t17; + if (!this.isUpdatePending) + return; + this.hasUpdated, this._$Ei && (this._$Ei.forEach((t18, i24) => this[i24] = t18), this._$Ei = void 0); + let i23 = false; + const s20 = this._$AL; + try { + i23 = this.shouldUpdate(s20), i23 ? (this.willUpdate(s20), null === (t17 = this._$ES) || void 0 === t17 || t17.forEach((t18) => { + var i24; + return null === (i24 = t18.hostUpdate) || void 0 === i24 ? void 0 : i24.call(t18); + }), this.update(s20)) : this._$Ek(); + } catch (t18) { + throw i23 = false, this._$Ek(), t18; + } + i23 && this._$AE(s20); + } + willUpdate(t17) { + } + _$AE(t17) { + var i23; + null === (i23 = this._$ES) || void 0 === i23 || i23.forEach((t18) => { + var i24; + return null === (i24 = t18.hostUpdated) || void 0 === i24 ? void 0 : i24.call(t18); + }), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t17)), this.updated(t17); + } + _$Ek() { + this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = false; + } + get updateComplete() { + return this.getUpdateComplete(); + } + getUpdateComplete() { + return this._$E_; + } + shouldUpdate(t17) { + return true; + } + update(t17) { + void 0 !== this._$EC && (this._$EC.forEach((t18, i23) => this._$EO(i23, this[i23], t18)), this._$EC = void 0), this._$Ek(); + } + updated(t17) { + } + firstUpdated(t17) { + } + }; + u5[d5] = true, u5.elementProperties = /* @__PURE__ */ new Map(), u5.elementStyles = [], u5.shadowRootOptions = { mode: "open" }, null == o14 || o14({ ReactiveElement: u5 }), (null !== (s9 = e21.reactiveElementVersions) && void 0 !== s9 ? s9 : e21.reactiveElementVersions = []).push("1.6.3"); + + // node_modules/@material/mwc-base/node_modules/lit-html/lit-html.js + var t10; + var i14 = window; + var s10 = i14.trustedTypes; + var e22 = s10 ? s10.createPolicy("lit-html", { createHTML: (t17) => t17 }) : void 0; + var o15 = "$lit$"; + var n18 = `lit$${(Math.random() + "").slice(9)}$`; + var l10 = "?" + n18; + var h6 = `<${l10}>`; + var r11 = document; + var u6 = () => r11.createComment(""); + var d6 = (t17) => null === t17 || "object" != typeof t17 && "function" != typeof t17; + var c7 = Array.isArray; + var v3 = (t17) => c7(t17) || "function" == typeof (null == t17 ? void 0 : t17[Symbol.iterator]); + var a6 = "[ \n\f\r]"; + var f4 = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g; + var _16 = /-->/g; + var m3 = />/g; + var p4 = RegExp(`>|${a6}(?:([^\\s"'>=/]+)(${a6}*=${a6}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`, "g"); + var g3 = /'/g; + var $3 = /"/g; + var y4 = /^(?:script|style|textarea|title)$/i; + var w3 = (t17) => (i23, ...s20) => ({ _$litType$: t17, strings: i23, values: s20 }); + var x3 = w3(1); + var b4 = w3(2); + var T3 = Symbol.for("lit-noChange"); + var A3 = Symbol.for("lit-nothing"); + var E3 = /* @__PURE__ */ new WeakMap(); + var C3 = r11.createTreeWalker(r11, 129, null, false); + function P3(t17, i23) { + if (!Array.isArray(t17) || !t17.hasOwnProperty("raw")) + throw Error("invalid template strings array"); + return void 0 !== e22 ? e22.createHTML(i23) : i23; + } + var V3 = (t17, i23) => { + const s20 = t17.length - 1, e33 = []; + let l20, r18 = 2 === i23 ? "" : "", u11 = f4; + for (let i24 = 0; i24 < s20; i24++) { + const s21 = t17[i24]; + let d11, c12, v6 = -1, a11 = 0; + for (; a11 < s21.length && (u11.lastIndex = a11, c12 = u11.exec(s21), null !== c12); ) + a11 = u11.lastIndex, u11 === f4 ? "!--" === c12[1] ? u11 = _16 : void 0 !== c12[1] ? u11 = m3 : void 0 !== c12[2] ? (y4.test(c12[2]) && (l20 = RegExp("" === c12[0] ? (u11 = null != l20 ? l20 : f4, v6 = -1) : void 0 === c12[1] ? v6 = -2 : (v6 = u11.lastIndex - c12[2].length, d11 = c12[1], u11 = void 0 === c12[3] ? p4 : '"' === c12[3] ? $3 : g3) : u11 === $3 || u11 === g3 ? u11 = p4 : u11 === _16 || u11 === m3 ? u11 = f4 : (u11 = p4, l20 = void 0); + const w6 = u11 === p4 && t17[i24 + 1].startsWith("/>") ? " " : ""; + r18 += u11 === f4 ? s21 + h6 : v6 >= 0 ? (e33.push(d11), s21.slice(0, v6) + o15 + s21.slice(v6) + n18 + w6) : s21 + n18 + (-2 === v6 ? (e33.push(void 0), i24) : w6); + } + return [P3(t17, r18 + (t17[s20] || "") + (2 === i23 ? "" : "")), e33]; + }; + var N3 = class _N { + constructor({ strings: t17, _$litType$: i23 }, e33) { + let h11; + this.parts = []; + let r18 = 0, d11 = 0; + const c12 = t17.length - 1, v6 = this.parts, [a11, f7] = V3(t17, i23); + if (this.el = _N.createElement(a11, e33), C3.currentNode = this.el.content, 2 === i23) { + const t18 = this.el.content, i24 = t18.firstChild; + i24.remove(), t18.append(...i24.childNodes); + } + for (; null !== (h11 = C3.nextNode()) && v6.length < c12; ) { + if (1 === h11.nodeType) { + if (h11.hasAttributes()) { + const t18 = []; + for (const i24 of h11.getAttributeNames()) + if (i24.endsWith(o15) || i24.startsWith(n18)) { + const s20 = f7[d11++]; + if (t18.push(i24), void 0 !== s20) { + const t19 = h11.getAttribute(s20.toLowerCase() + o15).split(n18), i25 = /([.?@])?(.*)/.exec(s20); + v6.push({ type: 1, index: r18, name: i25[2], strings: t19, ctor: "." === i25[1] ? H3 : "?" === i25[1] ? L3 : "@" === i25[1] ? z2 : k5 }); + } else + v6.push({ type: 6, index: r18 }); + } + for (const i24 of t18) + h11.removeAttribute(i24); + } + if (y4.test(h11.tagName)) { + const t18 = h11.textContent.split(n18), i24 = t18.length - 1; + if (i24 > 0) { + h11.textContent = s10 ? s10.emptyScript : ""; + for (let s20 = 0; s20 < i24; s20++) + h11.append(t18[s20], u6()), C3.nextNode(), v6.push({ type: 2, index: ++r18 }); + h11.append(t18[i24], u6()); + } + } + } else if (8 === h11.nodeType) + if (h11.data === l10) + v6.push({ type: 2, index: r18 }); + else { + let t18 = -1; + for (; -1 !== (t18 = h11.data.indexOf(n18, t18 + 1)); ) + v6.push({ type: 7, index: r18 }), t18 += n18.length - 1; + } + r18++; + } + } + static createElement(t17, i23) { + const s20 = r11.createElement("template"); + return s20.innerHTML = t17, s20; + } + }; + function S6(t17, i23, s20 = t17, e33) { + var o29, n31, l20, h11; + if (i23 === T3) + return i23; + let r18 = void 0 !== e33 ? null === (o29 = s20._$Co) || void 0 === o29 ? void 0 : o29[e33] : s20._$Cl; + const u11 = d6(i23) ? void 0 : i23._$litDirective$; + return (null == r18 ? void 0 : r18.constructor) !== u11 && (null === (n31 = null == r18 ? void 0 : r18._$AO) || void 0 === n31 || n31.call(r18, false), void 0 === u11 ? r18 = void 0 : (r18 = new u11(t17), r18._$AT(t17, s20, e33)), void 0 !== e33 ? (null !== (l20 = (h11 = s20)._$Co) && void 0 !== l20 ? l20 : h11._$Co = [])[e33] = r18 : s20._$Cl = r18), void 0 !== r18 && (i23 = S6(t17, r18._$AS(t17, i23.values), r18, e33)), i23; + } + var M3 = class { + constructor(t17, i23) { + this._$AV = [], this._$AN = void 0, this._$AD = t17, this._$AM = i23; + } + get parentNode() { + return this._$AM.parentNode; + } + get _$AU() { + return this._$AM._$AU; + } + u(t17) { + var i23; + const { el: { content: s20 }, parts: e33 } = this._$AD, o29 = (null !== (i23 = null == t17 ? void 0 : t17.creationScope) && void 0 !== i23 ? i23 : r11).importNode(s20, true); + C3.currentNode = o29; + let n31 = C3.nextNode(), l20 = 0, h11 = 0, u11 = e33[0]; + for (; void 0 !== u11; ) { + if (l20 === u11.index) { + let i24; + 2 === u11.type ? i24 = new R3(n31, n31.nextSibling, this, t17) : 1 === u11.type ? i24 = new u11.ctor(n31, u11.name, u11.strings, this, t17) : 6 === u11.type && (i24 = new Z3(n31, this, t17)), this._$AV.push(i24), u11 = e33[++h11]; + } + l20 !== (null == u11 ? void 0 : u11.index) && (n31 = C3.nextNode(), l20++); + } + return C3.currentNode = r11, o29; + } + v(t17) { + let i23 = 0; + for (const s20 of this._$AV) + void 0 !== s20 && (void 0 !== s20.strings ? (s20._$AI(t17, s20, i23), i23 += s20.strings.length - 2) : s20._$AI(t17[i23])), i23++; + } + }; + var R3 = class _R { + constructor(t17, i23, s20, e33) { + var o29; + this.type = 2, this._$AH = A3, this._$AN = void 0, this._$AA = t17, this._$AB = i23, this._$AM = s20, this.options = e33, this._$Cp = null === (o29 = null == e33 ? void 0 : e33.isConnected) || void 0 === o29 || o29; + } + get _$AU() { + var t17, i23; + return null !== (i23 = null === (t17 = this._$AM) || void 0 === t17 ? void 0 : t17._$AU) && void 0 !== i23 ? i23 : this._$Cp; + } + get parentNode() { + let t17 = this._$AA.parentNode; + const i23 = this._$AM; + return void 0 !== i23 && 11 === (null == t17 ? void 0 : t17.nodeType) && (t17 = i23.parentNode), t17; + } + get startNode() { + return this._$AA; + } + get endNode() { + return this._$AB; + } + _$AI(t17, i23 = this) { + t17 = S6(this, t17, i23), d6(t17) ? t17 === A3 || null == t17 || "" === t17 ? (this._$AH !== A3 && this._$AR(), this._$AH = A3) : t17 !== this._$AH && t17 !== T3 && this._(t17) : void 0 !== t17._$litType$ ? this.g(t17) : void 0 !== t17.nodeType ? this.$(t17) : v3(t17) ? this.T(t17) : this._(t17); + } + k(t17) { + return this._$AA.parentNode.insertBefore(t17, this._$AB); + } + $(t17) { + this._$AH !== t17 && (this._$AR(), this._$AH = this.k(t17)); + } + _(t17) { + this._$AH !== A3 && d6(this._$AH) ? this._$AA.nextSibling.data = t17 : this.$(r11.createTextNode(t17)), this._$AH = t17; + } + g(t17) { + var i23; + const { values: s20, _$litType$: e33 } = t17, o29 = "number" == typeof e33 ? this._$AC(t17) : (void 0 === e33.el && (e33.el = N3.createElement(P3(e33.h, e33.h[0]), this.options)), e33); + if ((null === (i23 = this._$AH) || void 0 === i23 ? void 0 : i23._$AD) === o29) + this._$AH.v(s20); + else { + const t18 = new M3(o29, this), i24 = t18.u(this.options); + t18.v(s20), this.$(i24), this._$AH = t18; + } + } + _$AC(t17) { + let i23 = E3.get(t17.strings); + return void 0 === i23 && E3.set(t17.strings, i23 = new N3(t17)), i23; + } + T(t17) { + c7(this._$AH) || (this._$AH = [], this._$AR()); + const i23 = this._$AH; + let s20, e33 = 0; + for (const o29 of t17) + e33 === i23.length ? i23.push(s20 = new _R(this.k(u6()), this.k(u6()), this, this.options)) : s20 = i23[e33], s20._$AI(o29), e33++; + e33 < i23.length && (this._$AR(s20 && s20._$AB.nextSibling, e33), i23.length = e33); + } + _$AR(t17 = this._$AA.nextSibling, i23) { + var s20; + for (null === (s20 = this._$AP) || void 0 === s20 || s20.call(this, false, true, i23); t17 && t17 !== this._$AB; ) { + const i24 = t17.nextSibling; + t17.remove(), t17 = i24; + } + } + setConnected(t17) { + var i23; + void 0 === this._$AM && (this._$Cp = t17, null === (i23 = this._$AP) || void 0 === i23 || i23.call(this, t17)); + } + }; + var k5 = class { + constructor(t17, i23, s20, e33, o29) { + this.type = 1, this._$AH = A3, this._$AN = void 0, this.element = t17, this.name = i23, this._$AM = e33, this.options = o29, s20.length > 2 || "" !== s20[0] || "" !== s20[1] ? (this._$AH = Array(s20.length - 1).fill(new String()), this.strings = s20) : this._$AH = A3; + } + get tagName() { + return this.element.tagName; + } + get _$AU() { + return this._$AM._$AU; + } + _$AI(t17, i23 = this, s20, e33) { + const o29 = this.strings; + let n31 = false; + if (void 0 === o29) + t17 = S6(this, t17, i23, 0), n31 = !d6(t17) || t17 !== this._$AH && t17 !== T3, n31 && (this._$AH = t17); + else { + const e34 = t17; + let l20, h11; + for (t17 = o29[0], l20 = 0; l20 < o29.length - 1; l20++) + h11 = S6(this, e34[s20 + l20], i23, l20), h11 === T3 && (h11 = this._$AH[l20]), n31 || (n31 = !d6(h11) || h11 !== this._$AH[l20]), h11 === A3 ? t17 = A3 : t17 !== A3 && (t17 += (null != h11 ? h11 : "") + o29[l20 + 1]), this._$AH[l20] = h11; + } + n31 && !e33 && this.j(t17); + } + j(t17) { + t17 === A3 ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, null != t17 ? t17 : ""); + } + }; + var H3 = class extends k5 { + constructor() { + super(...arguments), this.type = 3; + } + j(t17) { + this.element[this.name] = t17 === A3 ? void 0 : t17; + } + }; + var I3 = s10 ? s10.emptyScript : ""; + var L3 = class extends k5 { + constructor() { + super(...arguments), this.type = 4; + } + j(t17) { + t17 && t17 !== A3 ? this.element.setAttribute(this.name, I3) : this.element.removeAttribute(this.name); + } + }; + var z2 = class extends k5 { + constructor(t17, i23, s20, e33, o29) { + super(t17, i23, s20, e33, o29), this.type = 5; + } + _$AI(t17, i23 = this) { + var s20; + if ((t17 = null !== (s20 = S6(this, t17, i23, 0)) && void 0 !== s20 ? s20 : A3) === T3) + return; + const e33 = this._$AH, o29 = t17 === A3 && e33 !== A3 || t17.capture !== e33.capture || t17.once !== e33.once || t17.passive !== e33.passive, n31 = t17 !== A3 && (e33 === A3 || o29); + o29 && this.element.removeEventListener(this.name, this, e33), n31 && this.element.addEventListener(this.name, this, t17), this._$AH = t17; + } + handleEvent(t17) { + var i23, s20; + "function" == typeof this._$AH ? this._$AH.call(null !== (s20 = null === (i23 = this.options) || void 0 === i23 ? void 0 : i23.host) && void 0 !== s20 ? s20 : this.element, t17) : this._$AH.handleEvent(t17); + } + }; + var Z3 = class { + constructor(t17, i23, s20) { + this.element = t17, this.type = 6, this._$AN = void 0, this._$AM = i23, this.options = s20; + } + get _$AU() { + return this._$AM._$AU; + } + _$AI(t17) { + S6(this, t17); + } + }; + var B2 = i14.litHtmlPolyfillSupport; + null == B2 || B2(N3, R3), (null !== (t10 = i14.litHtmlVersions) && void 0 !== t10 ? t10 : i14.litHtmlVersions = []).push("2.8.0"); + var D2 = (t17, i23, s20) => { + var e33, o29; + const n31 = null !== (e33 = null == s20 ? void 0 : s20.renderBefore) && void 0 !== e33 ? e33 : i23; + let l20 = n31._$litPart$; + if (void 0 === l20) { + const t18 = null !== (o29 = null == s20 ? void 0 : s20.renderBefore) && void 0 !== o29 ? o29 : null; + n31._$litPart$ = l20 = new R3(i23.insertBefore(u6(), t18), t18, void 0, null != s20 ? s20 : {}); + } + return l20._$AI(t17), l20; + }; + + // node_modules/@material/mwc-base/node_modules/lit-element/lit-element.js + var l11; + var o16; + var s11 = class extends u5 { + constructor() { + super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0; + } + createRenderRoot() { + var t17, e33; + const i23 = super.createRenderRoot(); + return null !== (t17 = (e33 = this.renderOptions).renderBefore) && void 0 !== t17 || (e33.renderBefore = i23.firstChild), i23; + } + update(t17) { + const i23 = this.render(); + this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t17), this._$Do = D2(i23, this.renderRoot, this.renderOptions); + } + connectedCallback() { + var t17; + super.connectedCallback(), null === (t17 = this._$Do) || void 0 === t17 || t17.setConnected(true); + } + disconnectedCallback() { + var t17; + super.disconnectedCallback(), null === (t17 = this._$Do) || void 0 === t17 || t17.setConnected(false); + } + render() { + return T3; + } + }; + s11.finalized = true, s11._$litElement$ = true, null === (l11 = globalThis.litElementHydrateSupport) || void 0 === l11 || l11.call(globalThis, { LitElement: s11 }); + var n19 = globalThis.litElementPolyfillSupport; + null == n19 || n19({ LitElement: s11 }); + (null !== (o16 = globalThis.litElementVersions) && void 0 !== o16 ? o16 : globalThis.litElementVersions = []).push("3.3.3"); + + // node_modules/@material/mwc-base/utils.js + var supportsPassive = false; + var fn = () => { + }; + var optionsBlock = { + get passive() { + supportsPassive = true; + return false; + } + }; + document.addEventListener("x", fn, optionsBlock); + document.removeEventListener("x", fn); + + // node_modules/@material/mwc-base/base-element.js + var BaseElement = class extends s11 { + click() { + if (this.mdcRoot) { + this.mdcRoot.focus(); + this.mdcRoot.click(); + return; + } + super.click(); + } + /** + * Create and attach the MDC Foundation to the instance + */ + createFoundation() { + if (this.mdcFoundation !== void 0) { + this.mdcFoundation.destroy(); + } + if (this.mdcFoundationClass) { + this.mdcFoundation = new this.mdcFoundationClass(this.createAdapter()); + this.mdcFoundation.init(); + } + } + firstUpdated() { + this.createFoundation(); + } + }; + + // node_modules/@material/base/foundation.js + var MDCFoundation = ( + /** @class */ + function() { + function MDCFoundation2(adapter) { + if (adapter === void 0) { + adapter = {}; + } + this.adapter = adapter; + } + Object.defineProperty(MDCFoundation2, "cssClasses", { + get: function() { + return {}; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(MDCFoundation2, "strings", { + get: function() { + return {}; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(MDCFoundation2, "numbers", { + get: function() { + return {}; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(MDCFoundation2, "defaultAdapter", { + get: function() { + return {}; + }, + enumerable: false, + configurable: true + }); + MDCFoundation2.prototype.init = function() { + }; + MDCFoundation2.prototype.destroy = function() { + }; + return MDCFoundation2; + }() + ); + + // node_modules/@material/ripple/constants.js + var cssClasses = { + // Ripple is a special case where the "root" component is really a "mixin" of sorts, + // given that it's an 'upgrade' to an existing component. That being said it is the root + // CSS class that all other CSS classes derive from. + BG_FOCUSED: "mdc-ripple-upgraded--background-focused", + FG_ACTIVATION: "mdc-ripple-upgraded--foreground-activation", + FG_DEACTIVATION: "mdc-ripple-upgraded--foreground-deactivation", + ROOT: "mdc-ripple-upgraded", + UNBOUNDED: "mdc-ripple-upgraded--unbounded" + }; + var strings = { + VAR_FG_SCALE: "--mdc-ripple-fg-scale", + VAR_FG_SIZE: "--mdc-ripple-fg-size", + VAR_FG_TRANSLATE_END: "--mdc-ripple-fg-translate-end", + VAR_FG_TRANSLATE_START: "--mdc-ripple-fg-translate-start", + VAR_LEFT: "--mdc-ripple-left", + VAR_TOP: "--mdc-ripple-top" + }; + var numbers = { + DEACTIVATION_TIMEOUT_MS: 225, + FG_DEACTIVATION_MS: 150, + INITIAL_ORIGIN_SCALE: 0.6, + PADDING: 10, + TAP_DELAY_MS: 300 + // Delay between touch and simulated mouse events on touch devices + }; + + // node_modules/@material/ripple/util.js + function getNormalizedEventCoords(evt, pageOffset, clientRect) { + if (!evt) { + return { x: 0, y: 0 }; + } + var x6 = pageOffset.x, y7 = pageOffset.y; + var documentX = x6 + clientRect.left; + var documentY = y7 + clientRect.top; + var normalizedX; + var normalizedY; + if (evt.type === "touchstart") { + var touchEvent = evt; + normalizedX = touchEvent.changedTouches[0].pageX - documentX; + normalizedY = touchEvent.changedTouches[0].pageY - documentY; + } else { + var mouseEvent = evt; + normalizedX = mouseEvent.pageX - documentX; + normalizedY = mouseEvent.pageY - documentY; + } + return { x: normalizedX, y: normalizedY }; + } + + // node_modules/@material/ripple/foundation.js + var ACTIVATION_EVENT_TYPES = [ + "touchstart", + "pointerdown", + "mousedown", + "keydown" + ]; + var POINTER_DEACTIVATION_EVENT_TYPES = [ + "touchend", + "pointerup", + "mouseup", + "contextmenu" + ]; + var activatedTargets = []; + var MDCRippleFoundation = ( + /** @class */ + function(_super) { + __extends(MDCRippleFoundation2, _super); + function MDCRippleFoundation2(adapter) { + var _this = _super.call(this, __assign(__assign({}, MDCRippleFoundation2.defaultAdapter), adapter)) || this; + _this.activationAnimationHasEnded = false; + _this.activationTimer = 0; + _this.fgDeactivationRemovalTimer = 0; + _this.fgScale = "0"; + _this.frame = { width: 0, height: 0 }; + _this.initialSize = 0; + _this.layoutFrame = 0; + _this.maxRadius = 0; + _this.unboundedCoords = { left: 0, top: 0 }; + _this.activationState = _this.defaultActivationState(); + _this.activationTimerCallback = function() { + _this.activationAnimationHasEnded = true; + _this.runDeactivationUXLogicIfReady(); + }; + _this.activateHandler = function(e33) { + _this.activateImpl(e33); + }; + _this.deactivateHandler = function() { + _this.deactivateImpl(); + }; + _this.focusHandler = function() { + _this.handleFocus(); + }; + _this.blurHandler = function() { + _this.handleBlur(); + }; + _this.resizeHandler = function() { + _this.layout(); + }; + return _this; + } + Object.defineProperty(MDCRippleFoundation2, "cssClasses", { + get: function() { + return cssClasses; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(MDCRippleFoundation2, "strings", { + get: function() { + return strings; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(MDCRippleFoundation2, "numbers", { + get: function() { + return numbers; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(MDCRippleFoundation2, "defaultAdapter", { + get: function() { + return { + addClass: function() { + return void 0; + }, + browserSupportsCssVars: function() { + return true; + }, + computeBoundingRect: function() { + return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 }; + }, + containsEventTarget: function() { + return true; + }, + deregisterDocumentInteractionHandler: function() { + return void 0; + }, + deregisterInteractionHandler: function() { + return void 0; + }, + deregisterResizeHandler: function() { + return void 0; + }, + getWindowPageOffset: function() { + return { x: 0, y: 0 }; + }, + isSurfaceActive: function() { + return true; + }, + isSurfaceDisabled: function() { + return true; + }, + isUnbounded: function() { + return true; + }, + registerDocumentInteractionHandler: function() { + return void 0; + }, + registerInteractionHandler: function() { + return void 0; + }, + registerResizeHandler: function() { + return void 0; + }, + removeClass: function() { + return void 0; + }, + updateCssVariable: function() { + return void 0; + } + }; + }, + enumerable: false, + configurable: true + }); + MDCRippleFoundation2.prototype.init = function() { + var _this = this; + var supportsPressRipple = this.supportsPressRipple(); + this.registerRootHandlers(supportsPressRipple); + if (supportsPressRipple) { + var _a2 = MDCRippleFoundation2.cssClasses, ROOT_1 = _a2.ROOT, UNBOUNDED_1 = _a2.UNBOUNDED; + requestAnimationFrame(function() { + _this.adapter.addClass(ROOT_1); + if (_this.adapter.isUnbounded()) { + _this.adapter.addClass(UNBOUNDED_1); + _this.layoutInternal(); + } + }); + } + }; + MDCRippleFoundation2.prototype.destroy = function() { + var _this = this; + if (this.supportsPressRipple()) { + if (this.activationTimer) { + clearTimeout(this.activationTimer); + this.activationTimer = 0; + this.adapter.removeClass(MDCRippleFoundation2.cssClasses.FG_ACTIVATION); + } + if (this.fgDeactivationRemovalTimer) { + clearTimeout(this.fgDeactivationRemovalTimer); + this.fgDeactivationRemovalTimer = 0; + this.adapter.removeClass(MDCRippleFoundation2.cssClasses.FG_DEACTIVATION); + } + var _a2 = MDCRippleFoundation2.cssClasses, ROOT_2 = _a2.ROOT, UNBOUNDED_2 = _a2.UNBOUNDED; + requestAnimationFrame(function() { + _this.adapter.removeClass(ROOT_2); + _this.adapter.removeClass(UNBOUNDED_2); + _this.removeCssVars(); + }); + } + this.deregisterRootHandlers(); + this.deregisterDeactivationHandlers(); + }; + MDCRippleFoundation2.prototype.activate = function(evt) { + this.activateImpl(evt); + }; + MDCRippleFoundation2.prototype.deactivate = function() { + this.deactivateImpl(); + }; + MDCRippleFoundation2.prototype.layout = function() { + var _this = this; + if (this.layoutFrame) { + cancelAnimationFrame(this.layoutFrame); + } + this.layoutFrame = requestAnimationFrame(function() { + _this.layoutInternal(); + _this.layoutFrame = 0; + }); + }; + MDCRippleFoundation2.prototype.setUnbounded = function(unbounded) { + var UNBOUNDED = MDCRippleFoundation2.cssClasses.UNBOUNDED; + if (unbounded) { + this.adapter.addClass(UNBOUNDED); + } else { + this.adapter.removeClass(UNBOUNDED); + } + }; + MDCRippleFoundation2.prototype.handleFocus = function() { + var _this = this; + requestAnimationFrame(function() { + return _this.adapter.addClass(MDCRippleFoundation2.cssClasses.BG_FOCUSED); + }); + }; + MDCRippleFoundation2.prototype.handleBlur = function() { + var _this = this; + requestAnimationFrame(function() { + return _this.adapter.removeClass(MDCRippleFoundation2.cssClasses.BG_FOCUSED); + }); + }; + MDCRippleFoundation2.prototype.supportsPressRipple = function() { + return this.adapter.browserSupportsCssVars(); + }; + MDCRippleFoundation2.prototype.defaultActivationState = function() { + return { + activationEvent: void 0, + hasDeactivationUXRun: false, + isActivated: false, + isProgrammatic: false, + wasActivatedByPointer: false, + wasElementMadeActive: false + }; + }; + MDCRippleFoundation2.prototype.registerRootHandlers = function(supportsPressRipple) { + var e_1, _a2; + if (supportsPressRipple) { + try { + for (var ACTIVATION_EVENT_TYPES_1 = __values(ACTIVATION_EVENT_TYPES), ACTIVATION_EVENT_TYPES_1_1 = ACTIVATION_EVENT_TYPES_1.next(); !ACTIVATION_EVENT_TYPES_1_1.done; ACTIVATION_EVENT_TYPES_1_1 = ACTIVATION_EVENT_TYPES_1.next()) { + var evtType = ACTIVATION_EVENT_TYPES_1_1.value; + this.adapter.registerInteractionHandler(evtType, this.activateHandler); + } + } catch (e_1_1) { + e_1 = { error: e_1_1 }; + } finally { + try { + if (ACTIVATION_EVENT_TYPES_1_1 && !ACTIVATION_EVENT_TYPES_1_1.done && (_a2 = ACTIVATION_EVENT_TYPES_1.return)) + _a2.call(ACTIVATION_EVENT_TYPES_1); + } finally { + if (e_1) + throw e_1.error; + } + } + if (this.adapter.isUnbounded()) { + this.adapter.registerResizeHandler(this.resizeHandler); + } + } + this.adapter.registerInteractionHandler("focus", this.focusHandler); + this.adapter.registerInteractionHandler("blur", this.blurHandler); + }; + MDCRippleFoundation2.prototype.registerDeactivationHandlers = function(evt) { + var e_2, _a2; + if (evt.type === "keydown") { + this.adapter.registerInteractionHandler("keyup", this.deactivateHandler); + } else { + try { + for (var POINTER_DEACTIVATION_EVENT_TYPES_1 = __values(POINTER_DEACTIVATION_EVENT_TYPES), POINTER_DEACTIVATION_EVENT_TYPES_1_1 = POINTER_DEACTIVATION_EVENT_TYPES_1.next(); !POINTER_DEACTIVATION_EVENT_TYPES_1_1.done; POINTER_DEACTIVATION_EVENT_TYPES_1_1 = POINTER_DEACTIVATION_EVENT_TYPES_1.next()) { + var evtType = POINTER_DEACTIVATION_EVENT_TYPES_1_1.value; + this.adapter.registerDocumentInteractionHandler(evtType, this.deactivateHandler); + } + } catch (e_2_1) { + e_2 = { error: e_2_1 }; + } finally { + try { + if (POINTER_DEACTIVATION_EVENT_TYPES_1_1 && !POINTER_DEACTIVATION_EVENT_TYPES_1_1.done && (_a2 = POINTER_DEACTIVATION_EVENT_TYPES_1.return)) + _a2.call(POINTER_DEACTIVATION_EVENT_TYPES_1); + } finally { + if (e_2) + throw e_2.error; + } + } + } + }; + MDCRippleFoundation2.prototype.deregisterRootHandlers = function() { + var e_3, _a2; + try { + for (var ACTIVATION_EVENT_TYPES_2 = __values(ACTIVATION_EVENT_TYPES), ACTIVATION_EVENT_TYPES_2_1 = ACTIVATION_EVENT_TYPES_2.next(); !ACTIVATION_EVENT_TYPES_2_1.done; ACTIVATION_EVENT_TYPES_2_1 = ACTIVATION_EVENT_TYPES_2.next()) { + var evtType = ACTIVATION_EVENT_TYPES_2_1.value; + this.adapter.deregisterInteractionHandler(evtType, this.activateHandler); + } + } catch (e_3_1) { + e_3 = { error: e_3_1 }; + } finally { + try { + if (ACTIVATION_EVENT_TYPES_2_1 && !ACTIVATION_EVENT_TYPES_2_1.done && (_a2 = ACTIVATION_EVENT_TYPES_2.return)) + _a2.call(ACTIVATION_EVENT_TYPES_2); + } finally { + if (e_3) + throw e_3.error; + } + } + this.adapter.deregisterInteractionHandler("focus", this.focusHandler); + this.adapter.deregisterInteractionHandler("blur", this.blurHandler); + if (this.adapter.isUnbounded()) { + this.adapter.deregisterResizeHandler(this.resizeHandler); + } + }; + MDCRippleFoundation2.prototype.deregisterDeactivationHandlers = function() { + var e_4, _a2; + this.adapter.deregisterInteractionHandler("keyup", this.deactivateHandler); + try { + for (var POINTER_DEACTIVATION_EVENT_TYPES_2 = __values(POINTER_DEACTIVATION_EVENT_TYPES), POINTER_DEACTIVATION_EVENT_TYPES_2_1 = POINTER_DEACTIVATION_EVENT_TYPES_2.next(); !POINTER_DEACTIVATION_EVENT_TYPES_2_1.done; POINTER_DEACTIVATION_EVENT_TYPES_2_1 = POINTER_DEACTIVATION_EVENT_TYPES_2.next()) { + var evtType = POINTER_DEACTIVATION_EVENT_TYPES_2_1.value; + this.adapter.deregisterDocumentInteractionHandler(evtType, this.deactivateHandler); + } + } catch (e_4_1) { + e_4 = { error: e_4_1 }; + } finally { + try { + if (POINTER_DEACTIVATION_EVENT_TYPES_2_1 && !POINTER_DEACTIVATION_EVENT_TYPES_2_1.done && (_a2 = POINTER_DEACTIVATION_EVENT_TYPES_2.return)) + _a2.call(POINTER_DEACTIVATION_EVENT_TYPES_2); + } finally { + if (e_4) + throw e_4.error; + } + } + }; + MDCRippleFoundation2.prototype.removeCssVars = function() { + var _this = this; + var rippleStrings = MDCRippleFoundation2.strings; + var keys = Object.keys(rippleStrings); + keys.forEach(function(key) { + if (key.indexOf("VAR_") === 0) { + _this.adapter.updateCssVariable(rippleStrings[key], null); + } + }); + }; + MDCRippleFoundation2.prototype.activateImpl = function(evt) { + var _this = this; + if (this.adapter.isSurfaceDisabled()) { + return; + } + var activationState = this.activationState; + if (activationState.isActivated) { + return; + } + var previousActivationEvent = this.previousActivationEvent; + var isSameInteraction = previousActivationEvent && evt !== void 0 && previousActivationEvent.type !== evt.type; + if (isSameInteraction) { + return; + } + activationState.isActivated = true; + activationState.isProgrammatic = evt === void 0; + activationState.activationEvent = evt; + activationState.wasActivatedByPointer = activationState.isProgrammatic ? false : evt !== void 0 && (evt.type === "mousedown" || evt.type === "touchstart" || evt.type === "pointerdown"); + var hasActivatedChild = evt !== void 0 && activatedTargets.length > 0 && activatedTargets.some(function(target) { + return _this.adapter.containsEventTarget(target); + }); + if (hasActivatedChild) { + this.resetActivationState(); + return; + } + if (evt !== void 0) { + activatedTargets.push(evt.target); + this.registerDeactivationHandlers(evt); + } + activationState.wasElementMadeActive = this.checkElementMadeActive(evt); + if (activationState.wasElementMadeActive) { + this.animateActivation(); + } + requestAnimationFrame(function() { + activatedTargets = []; + if (!activationState.wasElementMadeActive && evt !== void 0 && (evt.key === " " || evt.keyCode === 32)) { + activationState.wasElementMadeActive = _this.checkElementMadeActive(evt); + if (activationState.wasElementMadeActive) { + _this.animateActivation(); + } + } + if (!activationState.wasElementMadeActive) { + _this.activationState = _this.defaultActivationState(); + } + }); + }; + MDCRippleFoundation2.prototype.checkElementMadeActive = function(evt) { + return evt !== void 0 && evt.type === "keydown" ? this.adapter.isSurfaceActive() : true; + }; + MDCRippleFoundation2.prototype.animateActivation = function() { + var _this = this; + var _a2 = MDCRippleFoundation2.strings, VAR_FG_TRANSLATE_START = _a2.VAR_FG_TRANSLATE_START, VAR_FG_TRANSLATE_END = _a2.VAR_FG_TRANSLATE_END; + var _b2 = MDCRippleFoundation2.cssClasses, FG_DEACTIVATION = _b2.FG_DEACTIVATION, FG_ACTIVATION = _b2.FG_ACTIVATION; + var DEACTIVATION_TIMEOUT_MS = MDCRippleFoundation2.numbers.DEACTIVATION_TIMEOUT_MS; + this.layoutInternal(); + var translateStart = ""; + var translateEnd = ""; + if (!this.adapter.isUnbounded()) { + var _c = this.getFgTranslationCoordinates(), startPoint = _c.startPoint, endPoint = _c.endPoint; + translateStart = startPoint.x + "px, " + startPoint.y + "px"; + translateEnd = endPoint.x + "px, " + endPoint.y + "px"; + } + this.adapter.updateCssVariable(VAR_FG_TRANSLATE_START, translateStart); + this.adapter.updateCssVariable(VAR_FG_TRANSLATE_END, translateEnd); + clearTimeout(this.activationTimer); + clearTimeout(this.fgDeactivationRemovalTimer); + this.rmBoundedActivationClasses(); + this.adapter.removeClass(FG_DEACTIVATION); + this.adapter.computeBoundingRect(); + this.adapter.addClass(FG_ACTIVATION); + this.activationTimer = setTimeout(function() { + _this.activationTimerCallback(); + }, DEACTIVATION_TIMEOUT_MS); + }; + MDCRippleFoundation2.prototype.getFgTranslationCoordinates = function() { + var _a2 = this.activationState, activationEvent = _a2.activationEvent, wasActivatedByPointer = _a2.wasActivatedByPointer; + var startPoint; + if (wasActivatedByPointer) { + startPoint = getNormalizedEventCoords(activationEvent, this.adapter.getWindowPageOffset(), this.adapter.computeBoundingRect()); + } else { + startPoint = { + x: this.frame.width / 2, + y: this.frame.height / 2 + }; + } + startPoint = { + x: startPoint.x - this.initialSize / 2, + y: startPoint.y - this.initialSize / 2 + }; + var endPoint = { + x: this.frame.width / 2 - this.initialSize / 2, + y: this.frame.height / 2 - this.initialSize / 2 + }; + return { startPoint, endPoint }; + }; + MDCRippleFoundation2.prototype.runDeactivationUXLogicIfReady = function() { + var _this = this; + var FG_DEACTIVATION = MDCRippleFoundation2.cssClasses.FG_DEACTIVATION; + var _a2 = this.activationState, hasDeactivationUXRun = _a2.hasDeactivationUXRun, isActivated = _a2.isActivated; + var activationHasEnded = hasDeactivationUXRun || !isActivated; + if (activationHasEnded && this.activationAnimationHasEnded) { + this.rmBoundedActivationClasses(); + this.adapter.addClass(FG_DEACTIVATION); + this.fgDeactivationRemovalTimer = setTimeout(function() { + _this.adapter.removeClass(FG_DEACTIVATION); + }, numbers.FG_DEACTIVATION_MS); + } + }; + MDCRippleFoundation2.prototype.rmBoundedActivationClasses = function() { + var FG_ACTIVATION = MDCRippleFoundation2.cssClasses.FG_ACTIVATION; + this.adapter.removeClass(FG_ACTIVATION); + this.activationAnimationHasEnded = false; + this.adapter.computeBoundingRect(); + }; + MDCRippleFoundation2.prototype.resetActivationState = function() { + var _this = this; + this.previousActivationEvent = this.activationState.activationEvent; + this.activationState = this.defaultActivationState(); + setTimeout(function() { + return _this.previousActivationEvent = void 0; + }, MDCRippleFoundation2.numbers.TAP_DELAY_MS); + }; + MDCRippleFoundation2.prototype.deactivateImpl = function() { + var _this = this; + var activationState = this.activationState; + if (!activationState.isActivated) { + return; + } + var state = __assign({}, activationState); + if (activationState.isProgrammatic) { + requestAnimationFrame(function() { + _this.animateDeactivation(state); + }); + this.resetActivationState(); + } else { + this.deregisterDeactivationHandlers(); + requestAnimationFrame(function() { + _this.activationState.hasDeactivationUXRun = true; + _this.animateDeactivation(state); + _this.resetActivationState(); + }); + } + }; + MDCRippleFoundation2.prototype.animateDeactivation = function(_a2) { + var wasActivatedByPointer = _a2.wasActivatedByPointer, wasElementMadeActive = _a2.wasElementMadeActive; + if (wasActivatedByPointer || wasElementMadeActive) { + this.runDeactivationUXLogicIfReady(); + } + }; + MDCRippleFoundation2.prototype.layoutInternal = function() { + var _this = this; + this.frame = this.adapter.computeBoundingRect(); + var maxDim = Math.max(this.frame.height, this.frame.width); + var getBoundedRadius = function() { + var hypotenuse = Math.sqrt(Math.pow(_this.frame.width, 2) + Math.pow(_this.frame.height, 2)); + return hypotenuse + MDCRippleFoundation2.numbers.PADDING; + }; + this.maxRadius = this.adapter.isUnbounded() ? maxDim : getBoundedRadius(); + var initialSize = Math.floor(maxDim * MDCRippleFoundation2.numbers.INITIAL_ORIGIN_SCALE); + if (this.adapter.isUnbounded() && initialSize % 2 !== 0) { + this.initialSize = initialSize - 1; + } else { + this.initialSize = initialSize; + } + this.fgScale = "" + this.maxRadius / this.initialSize; + this.updateLayoutCssVars(); + }; + MDCRippleFoundation2.prototype.updateLayoutCssVars = function() { + var _a2 = MDCRippleFoundation2.strings, VAR_FG_SIZE = _a2.VAR_FG_SIZE, VAR_LEFT = _a2.VAR_LEFT, VAR_TOP = _a2.VAR_TOP, VAR_FG_SCALE = _a2.VAR_FG_SCALE; + this.adapter.updateCssVariable(VAR_FG_SIZE, this.initialSize + "px"); + this.adapter.updateCssVariable(VAR_FG_SCALE, this.fgScale); + if (this.adapter.isUnbounded()) { + this.unboundedCoords = { + left: Math.round(this.frame.width / 2 - this.initialSize / 2), + top: Math.round(this.frame.height / 2 - this.initialSize / 2) + }; + this.adapter.updateCssVariable(VAR_LEFT, this.unboundedCoords.left + "px"); + this.adapter.updateCssVariable(VAR_TOP, this.unboundedCoords.top + "px"); + } + }; + return MDCRippleFoundation2; + }(MDCFoundation) + ); + var foundation_default = MDCRippleFoundation; + + // node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/css-tag.js + var t11 = window; + var e23 = t11.ShadowRoot && (void 0 === t11.ShadyCSS || t11.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype; + var s12 = Symbol(); + var n20 = /* @__PURE__ */ new WeakMap(); + var o17 = class { + constructor(t17, e33, n31) { + if (this._$cssResult$ = true, n31 !== s12) + throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); + this.cssText = t17, this.t = e33; + } + get styleSheet() { + let t17 = this.o; + const s20 = this.t; + if (e23 && void 0 === t17) { + const e33 = void 0 !== s20 && 1 === s20.length; + e33 && (t17 = n20.get(s20)), void 0 === t17 && ((this.o = t17 = new CSSStyleSheet()).replaceSync(this.cssText), e33 && n20.set(s20, t17)); + } + return t17; + } + toString() { + return this.cssText; + } + }; + var r12 = (t17) => new o17("string" == typeof t17 ? t17 : t17 + "", void 0, s12); + var i15 = (t17, ...e33) => { + const n31 = 1 === t17.length ? t17[0] : e33.reduce((e34, s20, n32) => e34 + ((t18) => { + if (true === t18._$cssResult$) + return t18.cssText; + if ("number" == typeof t18) + return t18; + throw Error("Value passed to 'css' function must be a 'css' function result: " + t18 + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security."); + })(s20) + t17[n32 + 1], t17[0]); + return new o17(n31, t17, s12); + }; + var S7 = (s20, n31) => { + e23 ? s20.adoptedStyleSheets = n31.map((t17) => t17 instanceof CSSStyleSheet ? t17 : t17.styleSheet) : n31.forEach((e33) => { + const n32 = document.createElement("style"), o29 = t11.litNonce; + void 0 !== o29 && n32.setAttribute("nonce", o29), n32.textContent = e33.cssText, s20.appendChild(n32); + }); + }; + var c8 = e23 ? (t17) => t17 : (t17) => t17 instanceof CSSStyleSheet ? ((t18) => { + let e33 = ""; + for (const s20 of t18.cssRules) + e33 += s20.cssText; + return r12(e33); + })(t17) : t17; + + // node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/reactive-element.js + var s13; + var e24 = window; + var r13 = e24.trustedTypes; + var h7 = r13 ? r13.emptyScript : ""; + var o18 = e24.reactiveElementPolyfillSupport; + var n21 = { toAttribute(t17, i23) { + switch (i23) { + case Boolean: + t17 = t17 ? h7 : null; + break; + case Object: + case Array: + t17 = null == t17 ? t17 : JSON.stringify(t17); + } + return t17; + }, fromAttribute(t17, i23) { + let s20 = t17; + switch (i23) { + case Boolean: + s20 = null !== t17; + break; + case Number: + s20 = null === t17 ? null : Number(t17); + break; + case Object: + case Array: + try { + s20 = JSON.parse(t17); + } catch (t18) { + s20 = null; + } + } + return s20; + } }; + var a7 = (t17, i23) => i23 !== t17 && (i23 == i23 || t17 == t17); + var l12 = { attribute: true, type: String, converter: n21, reflect: false, hasChanged: a7 }; + var d7 = "finalized"; + var u7 = class extends HTMLElement { + constructor() { + super(), this._$Ei = /* @__PURE__ */ new Map(), this.isUpdatePending = false, this.hasUpdated = false, this._$El = null, this._$Eu(); + } + static addInitializer(t17) { + var i23; + this.finalize(), (null !== (i23 = this.h) && void 0 !== i23 ? i23 : this.h = []).push(t17); + } + static get observedAttributes() { + this.finalize(); + const t17 = []; + return this.elementProperties.forEach((i23, s20) => { + const e33 = this._$Ep(s20, i23); + void 0 !== e33 && (this._$Ev.set(e33, s20), t17.push(e33)); + }), t17; + } + static createProperty(t17, i23 = l12) { + if (i23.state && (i23.attribute = false), this.finalize(), this.elementProperties.set(t17, i23), !i23.noAccessor && !this.prototype.hasOwnProperty(t17)) { + const s20 = "symbol" == typeof t17 ? Symbol() : "__" + t17, e33 = this.getPropertyDescriptor(t17, s20, i23); + void 0 !== e33 && Object.defineProperty(this.prototype, t17, e33); + } + } + static getPropertyDescriptor(t17, i23, s20) { + return { get() { + return this[i23]; + }, set(e33) { + const r18 = this[t17]; + this[i23] = e33, this.requestUpdate(t17, r18, s20); + }, configurable: true, enumerable: true }; + } + static getPropertyOptions(t17) { + return this.elementProperties.get(t17) || l12; + } + static finalize() { + if (this.hasOwnProperty(d7)) + return false; + this[d7] = true; + const t17 = Object.getPrototypeOf(this); + if (t17.finalize(), void 0 !== t17.h && (this.h = [...t17.h]), this.elementProperties = new Map(t17.elementProperties), this._$Ev = /* @__PURE__ */ new Map(), this.hasOwnProperty("properties")) { + const t18 = this.properties, i23 = [...Object.getOwnPropertyNames(t18), ...Object.getOwnPropertySymbols(t18)]; + for (const s20 of i23) + this.createProperty(s20, t18[s20]); + } + return this.elementStyles = this.finalizeStyles(this.styles), true; + } + static finalizeStyles(i23) { + const s20 = []; + if (Array.isArray(i23)) { + const e33 = new Set(i23.flat(1 / 0).reverse()); + for (const i24 of e33) + s20.unshift(c8(i24)); + } else + void 0 !== i23 && s20.push(c8(i23)); + return s20; + } + static _$Ep(t17, i23) { + const s20 = i23.attribute; + return false === s20 ? void 0 : "string" == typeof s20 ? s20 : "string" == typeof t17 ? t17.toLowerCase() : void 0; + } + _$Eu() { + var t17; + this._$E_ = new Promise((t18) => this.enableUpdating = t18), this._$AL = /* @__PURE__ */ new Map(), this._$Eg(), this.requestUpdate(), null === (t17 = this.constructor.h) || void 0 === t17 || t17.forEach((t18) => t18(this)); + } + addController(t17) { + var i23, s20; + (null !== (i23 = this._$ES) && void 0 !== i23 ? i23 : this._$ES = []).push(t17), void 0 !== this.renderRoot && this.isConnected && (null === (s20 = t17.hostConnected) || void 0 === s20 || s20.call(t17)); + } + removeController(t17) { + var i23; + null === (i23 = this._$ES) || void 0 === i23 || i23.splice(this._$ES.indexOf(t17) >>> 0, 1); + } + _$Eg() { + this.constructor.elementProperties.forEach((t17, i23) => { + this.hasOwnProperty(i23) && (this._$Ei.set(i23, this[i23]), delete this[i23]); + }); + } + createRenderRoot() { + var t17; + const s20 = null !== (t17 = this.shadowRoot) && void 0 !== t17 ? t17 : this.attachShadow(this.constructor.shadowRootOptions); + return S7(s20, this.constructor.elementStyles), s20; + } + connectedCallback() { + var t17; + void 0 === this.renderRoot && (this.renderRoot = this.createRenderRoot()), this.enableUpdating(true), null === (t17 = this._$ES) || void 0 === t17 || t17.forEach((t18) => { + var i23; + return null === (i23 = t18.hostConnected) || void 0 === i23 ? void 0 : i23.call(t18); + }); + } + enableUpdating(t17) { + } + disconnectedCallback() { + var t17; + null === (t17 = this._$ES) || void 0 === t17 || t17.forEach((t18) => { + var i23; + return null === (i23 = t18.hostDisconnected) || void 0 === i23 ? void 0 : i23.call(t18); + }); + } + attributeChangedCallback(t17, i23, s20) { + this._$AK(t17, s20); + } + _$EO(t17, i23, s20 = l12) { + var e33; + const r18 = this.constructor._$Ep(t17, s20); + if (void 0 !== r18 && true === s20.reflect) { + const h11 = (void 0 !== (null === (e33 = s20.converter) || void 0 === e33 ? void 0 : e33.toAttribute) ? s20.converter : n21).toAttribute(i23, s20.type); + this._$El = t17, null == h11 ? this.removeAttribute(r18) : this.setAttribute(r18, h11), this._$El = null; + } + } + _$AK(t17, i23) { + var s20; + const e33 = this.constructor, r18 = e33._$Ev.get(t17); + if (void 0 !== r18 && this._$El !== r18) { + const t18 = e33.getPropertyOptions(r18), h11 = "function" == typeof t18.converter ? { fromAttribute: t18.converter } : void 0 !== (null === (s20 = t18.converter) || void 0 === s20 ? void 0 : s20.fromAttribute) ? t18.converter : n21; + this._$El = r18, this[r18] = h11.fromAttribute(i23, t18.type), this._$El = null; + } + } + requestUpdate(t17, i23, s20) { + let e33 = true; + void 0 !== t17 && (((s20 = s20 || this.constructor.getPropertyOptions(t17)).hasChanged || a7)(this[t17], i23) ? (this._$AL.has(t17) || this._$AL.set(t17, i23), true === s20.reflect && this._$El !== t17 && (void 0 === this._$EC && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(t17, s20))) : e33 = false), !this.isUpdatePending && e33 && (this._$E_ = this._$Ej()); + } + async _$Ej() { + this.isUpdatePending = true; + try { + await this._$E_; + } catch (t18) { + Promise.reject(t18); + } + const t17 = this.scheduleUpdate(); + return null != t17 && await t17, !this.isUpdatePending; + } + scheduleUpdate() { + return this.performUpdate(); + } + performUpdate() { + var t17; + if (!this.isUpdatePending) + return; + this.hasUpdated, this._$Ei && (this._$Ei.forEach((t18, i24) => this[i24] = t18), this._$Ei = void 0); + let i23 = false; + const s20 = this._$AL; + try { + i23 = this.shouldUpdate(s20), i23 ? (this.willUpdate(s20), null === (t17 = this._$ES) || void 0 === t17 || t17.forEach((t18) => { + var i24; + return null === (i24 = t18.hostUpdate) || void 0 === i24 ? void 0 : i24.call(t18); + }), this.update(s20)) : this._$Ek(); + } catch (t18) { + throw i23 = false, this._$Ek(), t18; + } + i23 && this._$AE(s20); + } + willUpdate(t17) { + } + _$AE(t17) { + var i23; + null === (i23 = this._$ES) || void 0 === i23 || i23.forEach((t18) => { + var i24; + return null === (i24 = t18.hostUpdated) || void 0 === i24 ? void 0 : i24.call(t18); + }), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t17)), this.updated(t17); + } + _$Ek() { + this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = false; + } + get updateComplete() { + return this.getUpdateComplete(); + } + getUpdateComplete() { + return this._$E_; + } + shouldUpdate(t17) { + return true; + } + update(t17) { + void 0 !== this._$EC && (this._$EC.forEach((t18, i23) => this._$EO(i23, this[i23], t18)), this._$EC = void 0), this._$Ek(); + } + updated(t17) { + } + firstUpdated(t17) { + } + }; + u7[d7] = true, u7.elementProperties = /* @__PURE__ */ new Map(), u7.elementStyles = [], u7.shadowRootOptions = { mode: "open" }, null == o18 || o18({ ReactiveElement: u7 }), (null !== (s13 = e24.reactiveElementVersions) && void 0 !== s13 ? s13 : e24.reactiveElementVersions = []).push("1.6.3"); + + // node_modules/@material/mwc-ripple/node_modules/lit-html/lit-html.js + var t12; + var i16 = window; + var s14 = i16.trustedTypes; + var e25 = s14 ? s14.createPolicy("lit-html", { createHTML: (t17) => t17 }) : void 0; + var o19 = "$lit$"; + var n22 = `lit$${(Math.random() + "").slice(9)}$`; + var l13 = "?" + n22; + var h8 = `<${l13}>`; + var r14 = document; + var u8 = () => r14.createComment(""); + var d8 = (t17) => null === t17 || "object" != typeof t17 && "function" != typeof t17; + var c9 = Array.isArray; + var v4 = (t17) => c9(t17) || "function" == typeof (null == t17 ? void 0 : t17[Symbol.iterator]); + var a8 = "[ \n\f\r]"; + var f5 = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g; + var _17 = /-->/g; + var m4 = />/g; + var p5 = RegExp(`>|${a8}(?:([^\\s"'>=/]+)(${a8}*=${a8}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`, "g"); + var g4 = /'/g; + var $4 = /"/g; + var y5 = /^(?:script|style|textarea|title)$/i; + var w4 = (t17) => (i23, ...s20) => ({ _$litType$: t17, strings: i23, values: s20 }); + var x4 = w4(1); + var b5 = w4(2); + var T4 = Symbol.for("lit-noChange"); + var A4 = Symbol.for("lit-nothing"); + var E4 = /* @__PURE__ */ new WeakMap(); + var C4 = r14.createTreeWalker(r14, 129, null, false); + function P4(t17, i23) { + if (!Array.isArray(t17) || !t17.hasOwnProperty("raw")) + throw Error("invalid template strings array"); + return void 0 !== e25 ? e25.createHTML(i23) : i23; + } + var V4 = (t17, i23) => { + const s20 = t17.length - 1, e33 = []; + let l20, r18 = 2 === i23 ? "" : "", u11 = f5; + for (let i24 = 0; i24 < s20; i24++) { + const s21 = t17[i24]; + let d11, c12, v6 = -1, a11 = 0; + for (; a11 < s21.length && (u11.lastIndex = a11, c12 = u11.exec(s21), null !== c12); ) + a11 = u11.lastIndex, u11 === f5 ? "!--" === c12[1] ? u11 = _17 : void 0 !== c12[1] ? u11 = m4 : void 0 !== c12[2] ? (y5.test(c12[2]) && (l20 = RegExp("" === c12[0] ? (u11 = null != l20 ? l20 : f5, v6 = -1) : void 0 === c12[1] ? v6 = -2 : (v6 = u11.lastIndex - c12[2].length, d11 = c12[1], u11 = void 0 === c12[3] ? p5 : '"' === c12[3] ? $4 : g4) : u11 === $4 || u11 === g4 ? u11 = p5 : u11 === _17 || u11 === m4 ? u11 = f5 : (u11 = p5, l20 = void 0); + const w6 = u11 === p5 && t17[i24 + 1].startsWith("/>") ? " " : ""; + r18 += u11 === f5 ? s21 + h8 : v6 >= 0 ? (e33.push(d11), s21.slice(0, v6) + o19 + s21.slice(v6) + n22 + w6) : s21 + n22 + (-2 === v6 ? (e33.push(void 0), i24) : w6); + } + return [P4(t17, r18 + (t17[s20] || "") + (2 === i23 ? "" : "")), e33]; + }; + var N4 = class _N { + constructor({ strings: t17, _$litType$: i23 }, e33) { + let h11; + this.parts = []; + let r18 = 0, d11 = 0; + const c12 = t17.length - 1, v6 = this.parts, [a11, f7] = V4(t17, i23); + if (this.el = _N.createElement(a11, e33), C4.currentNode = this.el.content, 2 === i23) { + const t18 = this.el.content, i24 = t18.firstChild; + i24.remove(), t18.append(...i24.childNodes); + } + for (; null !== (h11 = C4.nextNode()) && v6.length < c12; ) { + if (1 === h11.nodeType) { + if (h11.hasAttributes()) { + const t18 = []; + for (const i24 of h11.getAttributeNames()) + if (i24.endsWith(o19) || i24.startsWith(n22)) { + const s20 = f7[d11++]; + if (t18.push(i24), void 0 !== s20) { + const t19 = h11.getAttribute(s20.toLowerCase() + o19).split(n22), i25 = /([.?@])?(.*)/.exec(s20); + v6.push({ type: 1, index: r18, name: i25[2], strings: t19, ctor: "." === i25[1] ? H4 : "?" === i25[1] ? L4 : "@" === i25[1] ? z3 : k6 }); + } else + v6.push({ type: 6, index: r18 }); + } + for (const i24 of t18) + h11.removeAttribute(i24); + } + if (y5.test(h11.tagName)) { + const t18 = h11.textContent.split(n22), i24 = t18.length - 1; + if (i24 > 0) { + h11.textContent = s14 ? s14.emptyScript : ""; + for (let s20 = 0; s20 < i24; s20++) + h11.append(t18[s20], u8()), C4.nextNode(), v6.push({ type: 2, index: ++r18 }); + h11.append(t18[i24], u8()); + } + } + } else if (8 === h11.nodeType) + if (h11.data === l13) + v6.push({ type: 2, index: r18 }); + else { + let t18 = -1; + for (; -1 !== (t18 = h11.data.indexOf(n22, t18 + 1)); ) + v6.push({ type: 7, index: r18 }), t18 += n22.length - 1; + } + r18++; + } + } + static createElement(t17, i23) { + const s20 = r14.createElement("template"); + return s20.innerHTML = t17, s20; + } + }; + function S8(t17, i23, s20 = t17, e33) { + var o29, n31, l20, h11; + if (i23 === T4) + return i23; + let r18 = void 0 !== e33 ? null === (o29 = s20._$Co) || void 0 === o29 ? void 0 : o29[e33] : s20._$Cl; + const u11 = d8(i23) ? void 0 : i23._$litDirective$; + return (null == r18 ? void 0 : r18.constructor) !== u11 && (null === (n31 = null == r18 ? void 0 : r18._$AO) || void 0 === n31 || n31.call(r18, false), void 0 === u11 ? r18 = void 0 : (r18 = new u11(t17), r18._$AT(t17, s20, e33)), void 0 !== e33 ? (null !== (l20 = (h11 = s20)._$Co) && void 0 !== l20 ? l20 : h11._$Co = [])[e33] = r18 : s20._$Cl = r18), void 0 !== r18 && (i23 = S8(t17, r18._$AS(t17, i23.values), r18, e33)), i23; + } + var M4 = class { + constructor(t17, i23) { + this._$AV = [], this._$AN = void 0, this._$AD = t17, this._$AM = i23; + } + get parentNode() { + return this._$AM.parentNode; + } + get _$AU() { + return this._$AM._$AU; + } + u(t17) { + var i23; + const { el: { content: s20 }, parts: e33 } = this._$AD, o29 = (null !== (i23 = null == t17 ? void 0 : t17.creationScope) && void 0 !== i23 ? i23 : r14).importNode(s20, true); + C4.currentNode = o29; + let n31 = C4.nextNode(), l20 = 0, h11 = 0, u11 = e33[0]; + for (; void 0 !== u11; ) { + if (l20 === u11.index) { + let i24; + 2 === u11.type ? i24 = new R4(n31, n31.nextSibling, this, t17) : 1 === u11.type ? i24 = new u11.ctor(n31, u11.name, u11.strings, this, t17) : 6 === u11.type && (i24 = new Z4(n31, this, t17)), this._$AV.push(i24), u11 = e33[++h11]; + } + l20 !== (null == u11 ? void 0 : u11.index) && (n31 = C4.nextNode(), l20++); + } + return C4.currentNode = r14, o29; + } + v(t17) { + let i23 = 0; + for (const s20 of this._$AV) + void 0 !== s20 && (void 0 !== s20.strings ? (s20._$AI(t17, s20, i23), i23 += s20.strings.length - 2) : s20._$AI(t17[i23])), i23++; + } + }; + var R4 = class _R { + constructor(t17, i23, s20, e33) { + var o29; + this.type = 2, this._$AH = A4, this._$AN = void 0, this._$AA = t17, this._$AB = i23, this._$AM = s20, this.options = e33, this._$Cp = null === (o29 = null == e33 ? void 0 : e33.isConnected) || void 0 === o29 || o29; + } + get _$AU() { + var t17, i23; + return null !== (i23 = null === (t17 = this._$AM) || void 0 === t17 ? void 0 : t17._$AU) && void 0 !== i23 ? i23 : this._$Cp; + } + get parentNode() { + let t17 = this._$AA.parentNode; + const i23 = this._$AM; + return void 0 !== i23 && 11 === (null == t17 ? void 0 : t17.nodeType) && (t17 = i23.parentNode), t17; + } + get startNode() { + return this._$AA; + } + get endNode() { + return this._$AB; + } + _$AI(t17, i23 = this) { + t17 = S8(this, t17, i23), d8(t17) ? t17 === A4 || null == t17 || "" === t17 ? (this._$AH !== A4 && this._$AR(), this._$AH = A4) : t17 !== this._$AH && t17 !== T4 && this._(t17) : void 0 !== t17._$litType$ ? this.g(t17) : void 0 !== t17.nodeType ? this.$(t17) : v4(t17) ? this.T(t17) : this._(t17); + } + k(t17) { + return this._$AA.parentNode.insertBefore(t17, this._$AB); + } + $(t17) { + this._$AH !== t17 && (this._$AR(), this._$AH = this.k(t17)); + } + _(t17) { + this._$AH !== A4 && d8(this._$AH) ? this._$AA.nextSibling.data = t17 : this.$(r14.createTextNode(t17)), this._$AH = t17; + } + g(t17) { + var i23; + const { values: s20, _$litType$: e33 } = t17, o29 = "number" == typeof e33 ? this._$AC(t17) : (void 0 === e33.el && (e33.el = N4.createElement(P4(e33.h, e33.h[0]), this.options)), e33); + if ((null === (i23 = this._$AH) || void 0 === i23 ? void 0 : i23._$AD) === o29) + this._$AH.v(s20); + else { + const t18 = new M4(o29, this), i24 = t18.u(this.options); + t18.v(s20), this.$(i24), this._$AH = t18; + } + } + _$AC(t17) { + let i23 = E4.get(t17.strings); + return void 0 === i23 && E4.set(t17.strings, i23 = new N4(t17)), i23; + } + T(t17) { + c9(this._$AH) || (this._$AH = [], this._$AR()); + const i23 = this._$AH; + let s20, e33 = 0; + for (const o29 of t17) + e33 === i23.length ? i23.push(s20 = new _R(this.k(u8()), this.k(u8()), this, this.options)) : s20 = i23[e33], s20._$AI(o29), e33++; + e33 < i23.length && (this._$AR(s20 && s20._$AB.nextSibling, e33), i23.length = e33); + } + _$AR(t17 = this._$AA.nextSibling, i23) { + var s20; + for (null === (s20 = this._$AP) || void 0 === s20 || s20.call(this, false, true, i23); t17 && t17 !== this._$AB; ) { + const i24 = t17.nextSibling; + t17.remove(), t17 = i24; + } + } + setConnected(t17) { + var i23; + void 0 === this._$AM && (this._$Cp = t17, null === (i23 = this._$AP) || void 0 === i23 || i23.call(this, t17)); + } + }; + var k6 = class { + constructor(t17, i23, s20, e33, o29) { + this.type = 1, this._$AH = A4, this._$AN = void 0, this.element = t17, this.name = i23, this._$AM = e33, this.options = o29, s20.length > 2 || "" !== s20[0] || "" !== s20[1] ? (this._$AH = Array(s20.length - 1).fill(new String()), this.strings = s20) : this._$AH = A4; + } + get tagName() { + return this.element.tagName; + } + get _$AU() { + return this._$AM._$AU; + } + _$AI(t17, i23 = this, s20, e33) { + const o29 = this.strings; + let n31 = false; + if (void 0 === o29) + t17 = S8(this, t17, i23, 0), n31 = !d8(t17) || t17 !== this._$AH && t17 !== T4, n31 && (this._$AH = t17); + else { + const e34 = t17; + let l20, h11; + for (t17 = o29[0], l20 = 0; l20 < o29.length - 1; l20++) + h11 = S8(this, e34[s20 + l20], i23, l20), h11 === T4 && (h11 = this._$AH[l20]), n31 || (n31 = !d8(h11) || h11 !== this._$AH[l20]), h11 === A4 ? t17 = A4 : t17 !== A4 && (t17 += (null != h11 ? h11 : "") + o29[l20 + 1]), this._$AH[l20] = h11; + } + n31 && !e33 && this.j(t17); + } + j(t17) { + t17 === A4 ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, null != t17 ? t17 : ""); + } + }; + var H4 = class extends k6 { + constructor() { + super(...arguments), this.type = 3; + } + j(t17) { + this.element[this.name] = t17 === A4 ? void 0 : t17; + } + }; + var I4 = s14 ? s14.emptyScript : ""; + var L4 = class extends k6 { + constructor() { + super(...arguments), this.type = 4; + } + j(t17) { + t17 && t17 !== A4 ? this.element.setAttribute(this.name, I4) : this.element.removeAttribute(this.name); + } + }; + var z3 = class extends k6 { + constructor(t17, i23, s20, e33, o29) { + super(t17, i23, s20, e33, o29), this.type = 5; + } + _$AI(t17, i23 = this) { + var s20; + if ((t17 = null !== (s20 = S8(this, t17, i23, 0)) && void 0 !== s20 ? s20 : A4) === T4) + return; + const e33 = this._$AH, o29 = t17 === A4 && e33 !== A4 || t17.capture !== e33.capture || t17.once !== e33.once || t17.passive !== e33.passive, n31 = t17 !== A4 && (e33 === A4 || o29); + o29 && this.element.removeEventListener(this.name, this, e33), n31 && this.element.addEventListener(this.name, this, t17), this._$AH = t17; + } + handleEvent(t17) { + var i23, s20; + "function" == typeof this._$AH ? this._$AH.call(null !== (s20 = null === (i23 = this.options) || void 0 === i23 ? void 0 : i23.host) && void 0 !== s20 ? s20 : this.element, t17) : this._$AH.handleEvent(t17); + } + }; + var Z4 = class { + constructor(t17, i23, s20) { + this.element = t17, this.type = 6, this._$AN = void 0, this._$AM = i23, this.options = s20; + } + get _$AU() { + return this._$AM._$AU; + } + _$AI(t17) { + S8(this, t17); + } + }; + var B3 = i16.litHtmlPolyfillSupport; + null == B3 || B3(N4, R4), (null !== (t12 = i16.litHtmlVersions) && void 0 !== t12 ? t12 : i16.litHtmlVersions = []).push("2.8.0"); + var D3 = (t17, i23, s20) => { + var e33, o29; + const n31 = null !== (e33 = null == s20 ? void 0 : s20.renderBefore) && void 0 !== e33 ? e33 : i23; + let l20 = n31._$litPart$; + if (void 0 === l20) { + const t18 = null !== (o29 = null == s20 ? void 0 : s20.renderBefore) && void 0 !== o29 ? o29 : null; + n31._$litPart$ = l20 = new R4(i23.insertBefore(u8(), t18), t18, void 0, null != s20 ? s20 : {}); + } + return l20._$AI(t17), l20; + }; + + // node_modules/@material/mwc-ripple/node_modules/lit-element/lit-element.js + var l14; + var o20; + var s15 = class extends u7 { + constructor() { + super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0; + } + createRenderRoot() { + var t17, e33; + const i23 = super.createRenderRoot(); + return null !== (t17 = (e33 = this.renderOptions).renderBefore) && void 0 !== t17 || (e33.renderBefore = i23.firstChild), i23; + } + update(t17) { + const i23 = this.render(); + this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t17), this._$Do = D3(i23, this.renderRoot, this.renderOptions); + } + connectedCallback() { + var t17; + super.connectedCallback(), null === (t17 = this._$Do) || void 0 === t17 || t17.setConnected(true); + } + disconnectedCallback() { + var t17; + super.disconnectedCallback(), null === (t17 = this._$Do) || void 0 === t17 || t17.setConnected(false); + } + render() { + return T4; + } + }; + s15.finalized = true, s15._$litElement$ = true, null === (l14 = globalThis.litElementHydrateSupport) || void 0 === l14 || l14.call(globalThis, { LitElement: s15 }); + var n23 = globalThis.litElementPolyfillSupport; + null == n23 || n23({ LitElement: s15 }); + (null !== (o20 = globalThis.litElementVersions) && void 0 !== o20 ? o20 : globalThis.litElementVersions = []).push("3.3.3"); + + // node_modules/@material/mwc-ripple/node_modules/lit-html/directive.js + var t13 = { ATTRIBUTE: 1, CHILD: 2, PROPERTY: 3, BOOLEAN_ATTRIBUTE: 4, EVENT: 5, ELEMENT: 6 }; + var e26 = (t17) => (...e33) => ({ _$litDirective$: t17, values: e33 }); + var i17 = class { + constructor(t17) { + } + get _$AU() { + return this._$AM._$AU; + } + _$AT(t17, e33, i23) { + this._$Ct = t17, this._$AM = e33, this._$Ci = i23; + } + _$AS(t17, e33) { + return this.update(t17, e33); + } + update(t17, e33) { + return this.render(...e33); + } + }; + + // node_modules/@material/mwc-ripple/node_modules/lit-html/directives/class-map.js + var o21 = e26(class extends i17 { + constructor(t17) { + var i23; + if (super(t17), t17.type !== t13.ATTRIBUTE || "class" !== t17.name || (null === (i23 = t17.strings) || void 0 === i23 ? void 0 : i23.length) > 2) + throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute."); + } + render(t17) { + return " " + Object.keys(t17).filter((i23) => t17[i23]).join(" ") + " "; + } + update(i23, [s20]) { + var r18, o29; + if (void 0 === this.it) { + this.it = /* @__PURE__ */ new Set(), void 0 !== i23.strings && (this.nt = new Set(i23.strings.join(" ").split(/\s/).filter((t17) => "" !== t17))); + for (const t17 in s20) + s20[t17] && !(null === (r18 = this.nt) || void 0 === r18 ? void 0 : r18.has(t17)) && this.it.add(t17); + return this.render(s20); + } + const e33 = i23.element.classList; + this.it.forEach((t17) => { + t17 in s20 || (e33.remove(t17), this.it.delete(t17)); + }); + for (const t17 in s20) { + const i24 = !!s20[t17]; + i24 === this.it.has(t17) || (null === (o29 = this.nt) || void 0 === o29 ? void 0 : o29.has(t17)) || (i24 ? (e33.add(t17), this.it.add(t17)) : (e33.remove(t17), this.it.delete(t17))); + } + return T4; + } + }); + + // node_modules/@material/mwc-ripple/node_modules/lit-html/directives/style-map.js + var i18 = "important"; + var n24 = " !" + i18; + var o22 = e26(class extends i17 { + constructor(t17) { + var e33; + if (super(t17), t17.type !== t13.ATTRIBUTE || "style" !== t17.name || (null === (e33 = t17.strings) || void 0 === e33 ? void 0 : e33.length) > 2) + throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute."); + } + render(t17) { + return Object.keys(t17).reduce((e33, r18) => { + const s20 = t17[r18]; + return null == s20 ? e33 : e33 + `${r18 = r18.includes("-") ? r18 : r18.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g, "-$&").toLowerCase()}:${s20};`; + }, ""); + } + update(e33, [r18]) { + const { style: s20 } = e33.element; + if (void 0 === this.ht) { + this.ht = /* @__PURE__ */ new Set(); + for (const t17 in r18) + this.ht.add(t17); + return this.render(r18); + } + this.ht.forEach((t17) => { + null == r18[t17] && (this.ht.delete(t17), t17.includes("-") ? s20.removeProperty(t17) : s20[t17] = ""); + }); + for (const t17 in r18) { + const e34 = r18[t17]; + if (null != e34) { + this.ht.add(t17); + const r19 = "string" == typeof e34 && e34.endsWith(n24); + t17.includes("-") || r19 ? s20.setProperty(t17, r19 ? e34.slice(0, -11) : e34, r19 ? i18 : "") : s20[t17] = e34; + } + } + return T4; + } + }); + + // node_modules/@material/mwc-ripple/mwc-ripple-base.js + var RippleBase = class extends BaseElement { + constructor() { + super(...arguments); + this.primary = false; + this.accent = false; + this.unbounded = false; + this.disabled = false; + this.activated = false; + this.selected = false; + this.internalUseStateLayerCustomProperties = false; + this.hovering = false; + this.bgFocused = false; + this.fgActivation = false; + this.fgDeactivation = false; + this.fgScale = ""; + this.fgSize = ""; + this.translateStart = ""; + this.translateEnd = ""; + this.leftPos = ""; + this.topPos = ""; + this.mdcFoundationClass = foundation_default; + } + get isActive() { + return matches2(this.parentElement || this, ":active"); + } + createAdapter() { + return { + browserSupportsCssVars: () => true, + isUnbounded: () => this.unbounded, + isSurfaceActive: () => this.isActive, + isSurfaceDisabled: () => this.disabled, + addClass: (className) => { + switch (className) { + case "mdc-ripple-upgraded--background-focused": + this.bgFocused = true; + break; + case "mdc-ripple-upgraded--foreground-activation": + this.fgActivation = true; + break; + case "mdc-ripple-upgraded--foreground-deactivation": + this.fgDeactivation = true; + break; + default: + break; + } + }, + removeClass: (className) => { + switch (className) { + case "mdc-ripple-upgraded--background-focused": + this.bgFocused = false; + break; + case "mdc-ripple-upgraded--foreground-activation": + this.fgActivation = false; + break; + case "mdc-ripple-upgraded--foreground-deactivation": + this.fgDeactivation = false; + break; + default: + break; + } + }, + containsEventTarget: () => true, + registerInteractionHandler: () => void 0, + deregisterInteractionHandler: () => void 0, + registerDocumentInteractionHandler: () => void 0, + deregisterDocumentInteractionHandler: () => void 0, + registerResizeHandler: () => void 0, + deregisterResizeHandler: () => void 0, + updateCssVariable: (varName, value) => { + switch (varName) { + case "--mdc-ripple-fg-scale": + this.fgScale = value; + break; + case "--mdc-ripple-fg-size": + this.fgSize = value; + break; + case "--mdc-ripple-fg-translate-end": + this.translateEnd = value; + break; + case "--mdc-ripple-fg-translate-start": + this.translateStart = value; + break; + case "--mdc-ripple-left": + this.leftPos = value; + break; + case "--mdc-ripple-top": + this.topPos = value; + break; + default: + break; + } + }, + computeBoundingRect: () => (this.parentElement || this).getBoundingClientRect(), + getWindowPageOffset: () => ({ x: window.pageXOffset, y: window.pageYOffset }) + }; + } + startPress(ev) { + this.waitForFoundation(() => { + this.mdcFoundation.activate(ev); + }); + } + endPress() { + this.waitForFoundation(() => { + this.mdcFoundation.deactivate(); + }); + } + startFocus() { + this.waitForFoundation(() => { + this.mdcFoundation.handleFocus(); + }); + } + endFocus() { + this.waitForFoundation(() => { + this.mdcFoundation.handleBlur(); + }); + } + startHover() { + this.hovering = true; + } + endHover() { + this.hovering = false; + } + /** + * Wait for the MDCFoundation to be created by `firstUpdated` + */ + waitForFoundation(fn2) { + if (this.mdcFoundation) { + fn2(); + } else { + this.updateComplete.then(fn2); + } + } + update(changedProperties) { + if (changedProperties.has("disabled")) { + if (this.disabled) { + this.endHover(); + } + } + super.update(changedProperties); + } + /** @soyTemplate */ + render() { + const shouldActivateInPrimary = this.activated && (this.primary || !this.accent); + const shouldSelectInPrimary = this.selected && (this.primary || !this.accent); + const classes = { + "mdc-ripple-surface--accent": this.accent, + "mdc-ripple-surface--primary--activated": shouldActivateInPrimary, + "mdc-ripple-surface--accent--activated": this.accent && this.activated, + "mdc-ripple-surface--primary--selected": shouldSelectInPrimary, + "mdc-ripple-surface--accent--selected": this.accent && this.selected, + "mdc-ripple-surface--disabled": this.disabled, + "mdc-ripple-surface--hover": this.hovering, + "mdc-ripple-surface--primary": this.primary, + "mdc-ripple-surface--selected": this.selected, + "mdc-ripple-upgraded--background-focused": this.bgFocused, + "mdc-ripple-upgraded--foreground-activation": this.fgActivation, + "mdc-ripple-upgraded--foreground-deactivation": this.fgDeactivation, + "mdc-ripple-upgraded--unbounded": this.unbounded, + "mdc-ripple-surface--internal-use-state-layer-custom-properties": this.internalUseStateLayerCustomProperties + }; + return x4` +
    `; + } + }; + __decorate([ + i12(".mdc-ripple-surface") + ], RippleBase.prototype, "mdcRoot", void 0); + __decorate([ + n14({ type: Boolean }) + ], RippleBase.prototype, "primary", void 0); + __decorate([ + n14({ type: Boolean }) + ], RippleBase.prototype, "accent", void 0); + __decorate([ + n14({ type: Boolean }) + ], RippleBase.prototype, "unbounded", void 0); + __decorate([ + n14({ type: Boolean }) + ], RippleBase.prototype, "disabled", void 0); + __decorate([ + n14({ type: Boolean }) + ], RippleBase.prototype, "activated", void 0); + __decorate([ + n14({ type: Boolean }) + ], RippleBase.prototype, "selected", void 0); + __decorate([ + n14({ type: Boolean }) + ], RippleBase.prototype, "internalUseStateLayerCustomProperties", void 0); + __decorate([ + t8() + ], RippleBase.prototype, "hovering", void 0); + __decorate([ + t8() + ], RippleBase.prototype, "bgFocused", void 0); + __decorate([ + t8() + ], RippleBase.prototype, "fgActivation", void 0); + __decorate([ + t8() + ], RippleBase.prototype, "fgDeactivation", void 0); + __decorate([ + t8() + ], RippleBase.prototype, "fgScale", void 0); + __decorate([ + t8() + ], RippleBase.prototype, "fgSize", void 0); + __decorate([ + t8() + ], RippleBase.prototype, "translateStart", void 0); + __decorate([ + t8() + ], RippleBase.prototype, "translateEnd", void 0); + __decorate([ + t8() + ], RippleBase.prototype, "leftPos", void 0); + __decorate([ + t8() + ], RippleBase.prototype, "topPos", void 0); + + // node_modules/@material/mwc-ripple/mwc-ripple.css.js + var styles12 = i15`.mdc-ripple-surface{--mdc-ripple-fg-size: 0;--mdc-ripple-left: 0;--mdc-ripple-top: 0;--mdc-ripple-fg-scale: 1;--mdc-ripple-fg-translate-end: 0;--mdc-ripple-fg-translate-start: 0;-webkit-tap-highlight-color:rgba(0,0,0,0);will-change:transform,opacity;position:relative;outline:none;overflow:hidden}.mdc-ripple-surface::before,.mdc-ripple-surface::after{position:absolute;border-radius:50%;opacity:0;pointer-events:none;content:""}.mdc-ripple-surface::before{transition:opacity 15ms linear,background-color 15ms linear;z-index:1;z-index:var(--mdc-ripple-z-index, 1)}.mdc-ripple-surface::after{z-index:0;z-index:var(--mdc-ripple-z-index, 0)}.mdc-ripple-surface.mdc-ripple-upgraded::before{transform:scale(var(--mdc-ripple-fg-scale, 1))}.mdc-ripple-surface.mdc-ripple-upgraded::after{top:0;left:0;transform:scale(0);transform-origin:center center}.mdc-ripple-surface.mdc-ripple-upgraded--unbounded::after{top:var(--mdc-ripple-top, 0);left:var(--mdc-ripple-left, 0)}.mdc-ripple-surface.mdc-ripple-upgraded--foreground-activation::after{animation:mdc-ripple-fg-radius-in 225ms forwards,mdc-ripple-fg-opacity-in 75ms forwards}.mdc-ripple-surface.mdc-ripple-upgraded--foreground-deactivation::after{animation:mdc-ripple-fg-opacity-out 150ms;transform:translate(var(--mdc-ripple-fg-translate-end, 0)) scale(var(--mdc-ripple-fg-scale, 1))}.mdc-ripple-surface::before,.mdc-ripple-surface::after{top:calc(50% - 100%);left:calc(50% - 100%);width:200%;height:200%}.mdc-ripple-surface.mdc-ripple-upgraded::after{width:var(--mdc-ripple-fg-size, 100%);height:var(--mdc-ripple-fg-size, 100%)}.mdc-ripple-surface[data-mdc-ripple-is-unbounded],.mdc-ripple-upgraded--unbounded{overflow:visible}.mdc-ripple-surface[data-mdc-ripple-is-unbounded]::before,.mdc-ripple-surface[data-mdc-ripple-is-unbounded]::after,.mdc-ripple-upgraded--unbounded::before,.mdc-ripple-upgraded--unbounded::after{top:calc(50% - 50%);left:calc(50% - 50%);width:100%;height:100%}.mdc-ripple-surface[data-mdc-ripple-is-unbounded].mdc-ripple-upgraded::before,.mdc-ripple-surface[data-mdc-ripple-is-unbounded].mdc-ripple-upgraded::after,.mdc-ripple-upgraded--unbounded.mdc-ripple-upgraded::before,.mdc-ripple-upgraded--unbounded.mdc-ripple-upgraded::after{top:var(--mdc-ripple-top, calc(50% - 50%));left:var(--mdc-ripple-left, calc(50% - 50%));width:var(--mdc-ripple-fg-size, 100%);height:var(--mdc-ripple-fg-size, 100%)}.mdc-ripple-surface[data-mdc-ripple-is-unbounded].mdc-ripple-upgraded::after,.mdc-ripple-upgraded--unbounded.mdc-ripple-upgraded::after{width:var(--mdc-ripple-fg-size, 100%);height:var(--mdc-ripple-fg-size, 100%)}.mdc-ripple-surface::before,.mdc-ripple-surface::after{background-color:#000;background-color:var(--mdc-ripple-color, #000)}.mdc-ripple-surface:hover::before,.mdc-ripple-surface.mdc-ripple-surface--hover::before{opacity:0.04;opacity:var(--mdc-ripple-hover-opacity, 0.04)}.mdc-ripple-surface.mdc-ripple-upgraded--background-focused::before,.mdc-ripple-surface:not(.mdc-ripple-upgraded):focus::before{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-focus-opacity, 0.12)}.mdc-ripple-surface:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-ripple-surface:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-press-opacity, 0.12)}.mdc-ripple-surface.mdc-ripple-upgraded{--mdc-ripple-fg-opacity:var(--mdc-ripple-press-opacity, 0.12)}@keyframes mdc-ripple-fg-radius-in{from{animation-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transform:translate(var(--mdc-ripple-fg-translate-start, 0)) scale(1)}to{transform:translate(var(--mdc-ripple-fg-translate-end, 0)) scale(var(--mdc-ripple-fg-scale, 1))}}@keyframes mdc-ripple-fg-opacity-in{from{animation-timing-function:linear;opacity:0}to{opacity:var(--mdc-ripple-fg-opacity, 0)}}@keyframes mdc-ripple-fg-opacity-out{from{animation-timing-function:linear;opacity:var(--mdc-ripple-fg-opacity, 0)}to{opacity:0}}:host{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;display:block}:host .mdc-ripple-surface{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;will-change:unset}.mdc-ripple-surface--primary::before,.mdc-ripple-surface--primary::after{background-color:#6200ee;background-color:var(--mdc-ripple-color, var(--mdc-theme-primary, #6200ee))}.mdc-ripple-surface--primary:hover::before,.mdc-ripple-surface--primary.mdc-ripple-surface--hover::before{opacity:0.04;opacity:var(--mdc-ripple-hover-opacity, 0.04)}.mdc-ripple-surface--primary.mdc-ripple-upgraded--background-focused::before,.mdc-ripple-surface--primary:not(.mdc-ripple-upgraded):focus::before{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-focus-opacity, 0.12)}.mdc-ripple-surface--primary:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-ripple-surface--primary:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-press-opacity, 0.12)}.mdc-ripple-surface--primary.mdc-ripple-upgraded{--mdc-ripple-fg-opacity:var(--mdc-ripple-press-opacity, 0.12)}.mdc-ripple-surface--primary--activated::before{opacity:0.12;opacity:var(--mdc-ripple-activated-opacity, 0.12)}.mdc-ripple-surface--primary--activated::before,.mdc-ripple-surface--primary--activated::after{background-color:#6200ee;background-color:var(--mdc-ripple-color, var(--mdc-theme-primary, #6200ee))}.mdc-ripple-surface--primary--activated:hover::before,.mdc-ripple-surface--primary--activated.mdc-ripple-surface--hover::before{opacity:0.16;opacity:var(--mdc-ripple-hover-opacity, 0.16)}.mdc-ripple-surface--primary--activated.mdc-ripple-upgraded--background-focused::before,.mdc-ripple-surface--primary--activated:not(.mdc-ripple-upgraded):focus::before{transition-duration:75ms;opacity:0.24;opacity:var(--mdc-ripple-focus-opacity, 0.24)}.mdc-ripple-surface--primary--activated:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-ripple-surface--primary--activated:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:0.24;opacity:var(--mdc-ripple-press-opacity, 0.24)}.mdc-ripple-surface--primary--activated.mdc-ripple-upgraded{--mdc-ripple-fg-opacity:var(--mdc-ripple-press-opacity, 0.24)}.mdc-ripple-surface--primary--selected::before{opacity:0.08;opacity:var(--mdc-ripple-selected-opacity, 0.08)}.mdc-ripple-surface--primary--selected::before,.mdc-ripple-surface--primary--selected::after{background-color:#6200ee;background-color:var(--mdc-ripple-color, var(--mdc-theme-primary, #6200ee))}.mdc-ripple-surface--primary--selected:hover::before,.mdc-ripple-surface--primary--selected.mdc-ripple-surface--hover::before{opacity:0.12;opacity:var(--mdc-ripple-hover-opacity, 0.12)}.mdc-ripple-surface--primary--selected.mdc-ripple-upgraded--background-focused::before,.mdc-ripple-surface--primary--selected:not(.mdc-ripple-upgraded):focus::before{transition-duration:75ms;opacity:0.2;opacity:var(--mdc-ripple-focus-opacity, 0.2)}.mdc-ripple-surface--primary--selected:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-ripple-surface--primary--selected:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:0.2;opacity:var(--mdc-ripple-press-opacity, 0.2)}.mdc-ripple-surface--primary--selected.mdc-ripple-upgraded{--mdc-ripple-fg-opacity:var(--mdc-ripple-press-opacity, 0.2)}.mdc-ripple-surface--accent::before,.mdc-ripple-surface--accent::after{background-color:#018786;background-color:var(--mdc-ripple-color, var(--mdc-theme-secondary, #018786))}.mdc-ripple-surface--accent:hover::before,.mdc-ripple-surface--accent.mdc-ripple-surface--hover::before{opacity:0.04;opacity:var(--mdc-ripple-hover-opacity, 0.04)}.mdc-ripple-surface--accent.mdc-ripple-upgraded--background-focused::before,.mdc-ripple-surface--accent:not(.mdc-ripple-upgraded):focus::before{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-focus-opacity, 0.12)}.mdc-ripple-surface--accent:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-ripple-surface--accent:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-press-opacity, 0.12)}.mdc-ripple-surface--accent.mdc-ripple-upgraded{--mdc-ripple-fg-opacity:var(--mdc-ripple-press-opacity, 0.12)}.mdc-ripple-surface--accent--activated::before{opacity:0.12;opacity:var(--mdc-ripple-activated-opacity, 0.12)}.mdc-ripple-surface--accent--activated::before,.mdc-ripple-surface--accent--activated::after{background-color:#018786;background-color:var(--mdc-ripple-color, var(--mdc-theme-secondary, #018786))}.mdc-ripple-surface--accent--activated:hover::before,.mdc-ripple-surface--accent--activated.mdc-ripple-surface--hover::before{opacity:0.16;opacity:var(--mdc-ripple-hover-opacity, 0.16)}.mdc-ripple-surface--accent--activated.mdc-ripple-upgraded--background-focused::before,.mdc-ripple-surface--accent--activated:not(.mdc-ripple-upgraded):focus::before{transition-duration:75ms;opacity:0.24;opacity:var(--mdc-ripple-focus-opacity, 0.24)}.mdc-ripple-surface--accent--activated:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-ripple-surface--accent--activated:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:0.24;opacity:var(--mdc-ripple-press-opacity, 0.24)}.mdc-ripple-surface--accent--activated.mdc-ripple-upgraded{--mdc-ripple-fg-opacity:var(--mdc-ripple-press-opacity, 0.24)}.mdc-ripple-surface--accent--selected::before{opacity:0.08;opacity:var(--mdc-ripple-selected-opacity, 0.08)}.mdc-ripple-surface--accent--selected::before,.mdc-ripple-surface--accent--selected::after{background-color:#018786;background-color:var(--mdc-ripple-color, var(--mdc-theme-secondary, #018786))}.mdc-ripple-surface--accent--selected:hover::before,.mdc-ripple-surface--accent--selected.mdc-ripple-surface--hover::before{opacity:0.12;opacity:var(--mdc-ripple-hover-opacity, 0.12)}.mdc-ripple-surface--accent--selected.mdc-ripple-upgraded--background-focused::before,.mdc-ripple-surface--accent--selected:not(.mdc-ripple-upgraded):focus::before{transition-duration:75ms;opacity:0.2;opacity:var(--mdc-ripple-focus-opacity, 0.2)}.mdc-ripple-surface--accent--selected:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-ripple-surface--accent--selected:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:0.2;opacity:var(--mdc-ripple-press-opacity, 0.2)}.mdc-ripple-surface--accent--selected.mdc-ripple-upgraded{--mdc-ripple-fg-opacity:var(--mdc-ripple-press-opacity, 0.2)}.mdc-ripple-surface--disabled{opacity:0}.mdc-ripple-surface--internal-use-state-layer-custom-properties::before,.mdc-ripple-surface--internal-use-state-layer-custom-properties::after{background-color:#000;background-color:var(--mdc-ripple-hover-state-layer-color, #000)}.mdc-ripple-surface--internal-use-state-layer-custom-properties:hover::before,.mdc-ripple-surface--internal-use-state-layer-custom-properties.mdc-ripple-surface--hover::before{opacity:0.04;opacity:var(--mdc-ripple-hover-state-layer-opacity, 0.04)}.mdc-ripple-surface--internal-use-state-layer-custom-properties.mdc-ripple-upgraded--background-focused::before,.mdc-ripple-surface--internal-use-state-layer-custom-properties:not(.mdc-ripple-upgraded):focus::before{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-focus-state-layer-opacity, 0.12)}.mdc-ripple-surface--internal-use-state-layer-custom-properties:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-ripple-surface--internal-use-state-layer-custom-properties:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-pressed-state-layer-opacity, 0.12)}.mdc-ripple-surface--internal-use-state-layer-custom-properties.mdc-ripple-upgraded{--mdc-ripple-fg-opacity:var(--mdc-ripple-pressed-state-layer-opacity, 0.12)}`; + + // node_modules/@material/mwc-ripple/mwc-ripple.js + var Ripple = class Ripple2 extends RippleBase { + }; + Ripple.styles = [styles12]; + Ripple = __decorate([ + e17("mwc-ripple") + ], Ripple); + + // node_modules/@material/mwc-base/aria-property.js + function tsDecorator(prototype, name, descriptor) { + const constructor = prototype.constructor; + if (!descriptor) { + const litInternalPropertyKey = `__${name}`; + descriptor = constructor.getPropertyDescriptor(name, litInternalPropertyKey); + if (!descriptor) { + throw new Error("@ariaProperty must be used after a @property decorator"); + } + } + const propDescriptor = descriptor; + let attribute = ""; + if (!propDescriptor.set) { + throw new Error(`@ariaProperty requires a setter for ${name}`); + } + if (prototype.dispatchWizEvent) { + return descriptor; + } + const wrappedDescriptor = { + configurable: true, + enumerable: true, + set(value) { + if (attribute === "") { + const options = constructor.getPropertyOptions(name); + attribute = typeof options.attribute === "string" ? options.attribute : name; + } + if (this.hasAttribute(attribute)) { + this.removeAttribute(attribute); + } + propDescriptor.set.call(this, value); + } + }; + if (propDescriptor.get) { + wrappedDescriptor.get = function() { + return propDescriptor.get.call(this); + }; + } + return wrappedDescriptor; + } + function ariaProperty(protoOrDescriptor, name, descriptor) { + if (name !== void 0) { + return tsDecorator(protoOrDescriptor, name, descriptor); + } else { + throw new Error("@ariaProperty only supports TypeScript Decorators"); + } + } + + // node_modules/@material/mwc-base/node_modules/@lit/reactive-element/decorators/property.js + var i19 = (i23, e33) => "method" === e33.kind && e33.descriptor && !("value" in e33.descriptor) ? { ...e33, finisher(n31) { + n31.createProperty(e33.key, i23); + } } : { kind: "field", key: Symbol(), placement: "own", descriptor: {}, originalKey: e33.key, initializer() { + "function" == typeof e33.initializer && (this[e33.key] = e33.initializer.call(this)); + }, finisher(n31) { + n31.createProperty(e33.key, i23); + } }; + var e27 = (i23, e33, n31) => { + e33.constructor.createProperty(n31, i23); + }; + function n25(n31) { + return (t17, o29) => void 0 !== o29 ? e27(n31, t17, o29) : i19(n31, t17); + } + + // node_modules/@material/mwc-base/node_modules/@lit/reactive-element/decorators/query-assigned-elements.js + var n26; + var e28 = null != (null === (n26 = window.HTMLSlotElement) || void 0 === n26 ? void 0 : n26.prototype.assignedElements) ? (o29, n31) => o29.assignedElements(n31) : (o29, n31) => o29.assignedNodes(n31).filter((o30) => o30.nodeType === Node.ELEMENT_NODE); + + // node_modules/@material/mwc-base/form-element.js + var _a; + var _b; + var USING_SHADY_DOM = (_b = (_a = window.ShadyDOM) === null || _a === void 0 ? void 0 : _a.inUse) !== null && _b !== void 0 ? _b : false; + var FormElement = class extends BaseElement { + constructor() { + super(...arguments); + this.disabled = false; + this.containingForm = null; + this.formDataListener = (ev) => { + if (!this.disabled) { + this.setFormData(ev.formData); + } + }; + } + findFormElement() { + if (!this.shadowRoot || USING_SHADY_DOM) { + return null; + } + const root = this.getRootNode(); + const forms = root.querySelectorAll("form"); + for (const form of Array.from(forms)) { + if (form.contains(this)) { + return form; + } + } + return null; + } + connectedCallback() { + var _a2; + super.connectedCallback(); + this.containingForm = this.findFormElement(); + (_a2 = this.containingForm) === null || _a2 === void 0 ? void 0 : _a2.addEventListener("formdata", this.formDataListener); + } + disconnectedCallback() { + var _a2; + super.disconnectedCallback(); + (_a2 = this.containingForm) === null || _a2 === void 0 ? void 0 : _a2.removeEventListener("formdata", this.formDataListener); + this.containingForm = null; + } + click() { + if (this.formElement && !this.disabled) { + this.formElement.focus(); + this.formElement.click(); + } + } + firstUpdated() { + super.firstUpdated(); + if (this.shadowRoot) { + this.mdcRoot.addEventListener("change", (e33) => { + this.dispatchEvent(new Event("change", e33)); + }); + } + } + }; + FormElement.shadowRootOptions = { mode: "open", delegatesFocus: true }; + __decorate([ + n25({ type: Boolean }) + ], FormElement.prototype, "disabled", void 0); + + // node_modules/@material/mwc-ripple/ripple-handlers.js + var RippleHandlers = class { + constructor(rippleFn) { + this.startPress = (ev) => { + rippleFn().then((r18) => { + r18 && r18.startPress(ev); + }); + }; + this.endPress = () => { + rippleFn().then((r18) => { + r18 && r18.endPress(); + }); + }; + this.startFocus = () => { + rippleFn().then((r18) => { + r18 && r18.startFocus(); + }); + }; + this.endFocus = () => { + rippleFn().then((r18) => { + r18 && r18.endFocus(); + }); + }; + this.startHover = () => { + rippleFn().then((r18) => { + r18 && r18.startHover(); + }); + }; + this.endHover = () => { + rippleFn().then((r18) => { + r18 && r18.endHover(); + }); + }; + } + }; + + // node_modules/@material/base/observer.js + function observeProperty(target, property, observer) { + var targetObservers = installObserver(target, property); + var observers = targetObservers.getObservers(property); + observers.push(observer); + return function() { + observers.splice(observers.indexOf(observer), 1); + }; + } + var allTargetObservers = /* @__PURE__ */ new WeakMap(); + function installObserver(target, property) { + var observersMap = /* @__PURE__ */ new Map(); + if (!allTargetObservers.has(target)) { + allTargetObservers.set(target, { + isEnabled: true, + getObservers: function(key) { + var observers = observersMap.get(key) || []; + if (!observersMap.has(key)) { + observersMap.set(key, observers); + } + return observers; + }, + installedProperties: /* @__PURE__ */ new Set() + }); + } + var targetObservers = allTargetObservers.get(target); + if (targetObservers.installedProperties.has(property)) { + return targetObservers; + } + var descriptor = getDescriptor2(target, property) || { + configurable: true, + enumerable: true, + value: target[property], + writable: true + }; + var observedDescriptor = __assign({}, descriptor); + var descGet = descriptor.get, descSet = descriptor.set; + if ("value" in descriptor) { + delete observedDescriptor.value; + delete observedDescriptor.writable; + var value_1 = descriptor.value; + descGet = function() { + return value_1; + }; + if (descriptor.writable) { + descSet = function(newValue) { + value_1 = newValue; + }; + } + } + if (descGet) { + observedDescriptor.get = function() { + return descGet.call(this); + }; + } + if (descSet) { + observedDescriptor.set = function(newValue) { + var e_4, _a2; + var previous = descGet ? descGet.call(this) : newValue; + descSet.call(this, newValue); + if (targetObservers.isEnabled && (!descGet || newValue !== previous)) { + try { + for (var _b2 = __values(targetObservers.getObservers(property)), _c = _b2.next(); !_c.done; _c = _b2.next()) { + var observer = _c.value; + observer(newValue, previous); + } + } catch (e_4_1) { + e_4 = { error: e_4_1 }; + } finally { + try { + if (_c && !_c.done && (_a2 = _b2.return)) + _a2.call(_b2); + } finally { + if (e_4) + throw e_4.error; + } + } + } + }; + } + targetObservers.installedProperties.add(property); + Object.defineProperty(target, property, observedDescriptor); + return targetObservers; + } + function getDescriptor2(target, property) { + var descriptorTarget = target; + var descriptor; + while (descriptorTarget) { + descriptor = Object.getOwnPropertyDescriptor(descriptorTarget, property); + if (descriptor) { + break; + } + descriptorTarget = Object.getPrototypeOf(descriptorTarget); + } + return descriptor; + } + function setObserversEnabled(target, enabled) { + var targetObservers = allTargetObservers.get(target); + if (targetObservers) { + targetObservers.isEnabled = enabled; + } + } + + // node_modules/@material/base/observer-foundation.js + var MDCObserverFoundation = ( + /** @class */ + function(_super) { + __extends(MDCObserverFoundation2, _super); + function MDCObserverFoundation2(adapter) { + var _this = _super.call(this, adapter) || this; + _this.unobserves = /* @__PURE__ */ new Set(); + return _this; + } + MDCObserverFoundation2.prototype.destroy = function() { + _super.prototype.destroy.call(this); + this.unobserve(); + }; + MDCObserverFoundation2.prototype.observe = function(target, observers) { + var e_1, _a2; + var _this = this; + var cleanup = []; + try { + for (var _b2 = __values(Object.keys(observers)), _c = _b2.next(); !_c.done; _c = _b2.next()) { + var property = _c.value; + var observer = observers[property].bind(this); + cleanup.push(this.observeProperty(target, property, observer)); + } + } catch (e_1_1) { + e_1 = { error: e_1_1 }; + } finally { + try { + if (_c && !_c.done && (_a2 = _b2.return)) + _a2.call(_b2); + } finally { + if (e_1) + throw e_1.error; + } + } + var unobserve = function() { + var e_2, _a3; + try { + for (var cleanup_1 = __values(cleanup), cleanup_1_1 = cleanup_1.next(); !cleanup_1_1.done; cleanup_1_1 = cleanup_1.next()) { + var cleanupFn = cleanup_1_1.value; + cleanupFn(); + } + } catch (e_2_1) { + e_2 = { error: e_2_1 }; + } finally { + try { + if (cleanup_1_1 && !cleanup_1_1.done && (_a3 = cleanup_1.return)) + _a3.call(cleanup_1); + } finally { + if (e_2) + throw e_2.error; + } + } + _this.unobserves.delete(unobserve); + }; + this.unobserves.add(unobserve); + return unobserve; + }; + MDCObserverFoundation2.prototype.observeProperty = function(target, property, observer) { + return observeProperty(target, property, observer); + }; + MDCObserverFoundation2.prototype.setObserversEnabled = function(target, enabled) { + setObserversEnabled(target, enabled); + }; + MDCObserverFoundation2.prototype.unobserve = function() { + var e_3, _a2; + try { + for (var _b2 = __values(__spreadArray([], __read(this.unobserves))), _c = _b2.next(); !_c.done; _c = _b2.next()) { + var unobserve = _c.value; + unobserve(); + } + } catch (e_3_1) { + e_3 = { error: e_3_1 }; + } finally { + try { + if (_c && !_c.done && (_a2 = _b2.return)) + _a2.call(_b2); + } finally { + if (e_3) + throw e_3.error; + } + } + }; + return MDCObserverFoundation2; + }(MDCFoundation) + ); + + // node_modules/@material/switch/constants.js + var CssClasses; + (function(CssClasses2) { + CssClasses2["PROCESSING"] = "mdc-switch--processing"; + CssClasses2["SELECTED"] = "mdc-switch--selected"; + CssClasses2["UNSELECTED"] = "mdc-switch--unselected"; + })(CssClasses || (CssClasses = {})); + var Selectors; + (function(Selectors2) { + Selectors2["RIPPLE"] = ".mdc-switch__ripple"; + })(Selectors || (Selectors = {})); + + // node_modules/@material/switch/foundation.js + var MDCSwitchFoundation = ( + /** @class */ + function(_super) { + __extends(MDCSwitchFoundation2, _super); + function MDCSwitchFoundation2(adapter) { + var _this = _super.call(this, adapter) || this; + _this.handleClick = _this.handleClick.bind(_this); + return _this; + } + MDCSwitchFoundation2.prototype.init = function() { + this.observe(this.adapter.state, { + disabled: this.stopProcessingIfDisabled, + processing: this.stopProcessingIfDisabled + }); + }; + MDCSwitchFoundation2.prototype.handleClick = function() { + if (this.adapter.state.disabled) { + return; + } + this.adapter.state.selected = !this.adapter.state.selected; + }; + MDCSwitchFoundation2.prototype.stopProcessingIfDisabled = function() { + if (this.adapter.state.disabled) { + this.adapter.state.processing = false; + } + }; + return MDCSwitchFoundation2; + }(MDCObserverFoundation) + ); + var MDCSwitchRenderFoundation = ( + /** @class */ + function(_super) { + __extends(MDCSwitchRenderFoundation2, _super); + function MDCSwitchRenderFoundation2() { + return _super !== null && _super.apply(this, arguments) || this; + } + MDCSwitchRenderFoundation2.prototype.init = function() { + _super.prototype.init.call(this); + this.observe(this.adapter.state, { + disabled: this.onDisabledChange, + processing: this.onProcessingChange, + selected: this.onSelectedChange + }); + }; + MDCSwitchRenderFoundation2.prototype.initFromDOM = function() { + this.setObserversEnabled(this.adapter.state, false); + this.adapter.state.selected = this.adapter.hasClass(CssClasses.SELECTED); + this.onSelectedChange(); + this.adapter.state.disabled = this.adapter.isDisabled(); + this.adapter.state.processing = this.adapter.hasClass(CssClasses.PROCESSING); + this.setObserversEnabled(this.adapter.state, true); + this.stopProcessingIfDisabled(); + }; + MDCSwitchRenderFoundation2.prototype.onDisabledChange = function() { + this.adapter.setDisabled(this.adapter.state.disabled); + }; + MDCSwitchRenderFoundation2.prototype.onProcessingChange = function() { + this.toggleClass(this.adapter.state.processing, CssClasses.PROCESSING); + }; + MDCSwitchRenderFoundation2.prototype.onSelectedChange = function() { + this.adapter.setAriaChecked(String(this.adapter.state.selected)); + this.toggleClass(this.adapter.state.selected, CssClasses.SELECTED); + this.toggleClass(!this.adapter.state.selected, CssClasses.UNSELECTED); + }; + MDCSwitchRenderFoundation2.prototype.toggleClass = function(addClass, className) { + if (addClass) { + this.adapter.addClass(className); + } else { + this.adapter.removeClass(className); + } + }; + return MDCSwitchRenderFoundation2; + }(MDCSwitchFoundation) + ); + + // node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/css-tag.js + var t14 = window; + var e29 = t14.ShadowRoot && (void 0 === t14.ShadyCSS || t14.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype; + var s16 = Symbol(); + var n27 = /* @__PURE__ */ new WeakMap(); + var o24 = class { + constructor(t17, e33, n31) { + if (this._$cssResult$ = true, n31 !== s16) + throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); + this.cssText = t17, this.t = e33; + } + get styleSheet() { + let t17 = this.o; + const s20 = this.t; + if (e29 && void 0 === t17) { + const e33 = void 0 !== s20 && 1 === s20.length; + e33 && (t17 = n27.get(s20)), void 0 === t17 && ((this.o = t17 = new CSSStyleSheet()).replaceSync(this.cssText), e33 && n27.set(s20, t17)); + } + return t17; + } + toString() { + return this.cssText; + } + }; + var r15 = (t17) => new o24("string" == typeof t17 ? t17 : t17 + "", void 0, s16); + var i20 = (t17, ...e33) => { + const n31 = 1 === t17.length ? t17[0] : e33.reduce((e34, s20, n32) => e34 + ((t18) => { + if (true === t18._$cssResult$) + return t18.cssText; + if ("number" == typeof t18) + return t18; + throw Error("Value passed to 'css' function must be a 'css' function result: " + t18 + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security."); + })(s20) + t17[n32 + 1], t17[0]); + return new o24(n31, t17, s16); + }; + var S9 = (s20, n31) => { + e29 ? s20.adoptedStyleSheets = n31.map((t17) => t17 instanceof CSSStyleSheet ? t17 : t17.styleSheet) : n31.forEach((e33) => { + const n32 = document.createElement("style"), o29 = t14.litNonce; + void 0 !== o29 && n32.setAttribute("nonce", o29), n32.textContent = e33.cssText, s20.appendChild(n32); + }); + }; + var c10 = e29 ? (t17) => t17 : (t17) => t17 instanceof CSSStyleSheet ? ((t18) => { + let e33 = ""; + for (const s20 of t18.cssRules) + e33 += s20.cssText; + return r15(e33); + })(t17) : t17; + + // node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/reactive-element.js + var s17; + var e30 = window; + var r16 = e30.trustedTypes; + var h9 = r16 ? r16.emptyScript : ""; + var o25 = e30.reactiveElementPolyfillSupport; + var n28 = { toAttribute(t17, i23) { + switch (i23) { + case Boolean: + t17 = t17 ? h9 : null; + break; + case Object: + case Array: + t17 = null == t17 ? t17 : JSON.stringify(t17); + } + return t17; + }, fromAttribute(t17, i23) { + let s20 = t17; + switch (i23) { + case Boolean: + s20 = null !== t17; + break; + case Number: + s20 = null === t17 ? null : Number(t17); + break; + case Object: + case Array: + try { + s20 = JSON.parse(t17); + } catch (t18) { + s20 = null; + } + } + return s20; + } }; + var a9 = (t17, i23) => i23 !== t17 && (i23 == i23 || t17 == t17); + var l16 = { attribute: true, type: String, converter: n28, reflect: false, hasChanged: a9 }; + var d9 = "finalized"; + var u9 = class extends HTMLElement { + constructor() { + super(), this._$Ei = /* @__PURE__ */ new Map(), this.isUpdatePending = false, this.hasUpdated = false, this._$El = null, this._$Eu(); + } + static addInitializer(t17) { + var i23; + this.finalize(), (null !== (i23 = this.h) && void 0 !== i23 ? i23 : this.h = []).push(t17); + } + static get observedAttributes() { + this.finalize(); + const t17 = []; + return this.elementProperties.forEach((i23, s20) => { + const e33 = this._$Ep(s20, i23); + void 0 !== e33 && (this._$Ev.set(e33, s20), t17.push(e33)); + }), t17; + } + static createProperty(t17, i23 = l16) { + if (i23.state && (i23.attribute = false), this.finalize(), this.elementProperties.set(t17, i23), !i23.noAccessor && !this.prototype.hasOwnProperty(t17)) { + const s20 = "symbol" == typeof t17 ? Symbol() : "__" + t17, e33 = this.getPropertyDescriptor(t17, s20, i23); + void 0 !== e33 && Object.defineProperty(this.prototype, t17, e33); + } + } + static getPropertyDescriptor(t17, i23, s20) { + return { get() { + return this[i23]; + }, set(e33) { + const r18 = this[t17]; + this[i23] = e33, this.requestUpdate(t17, r18, s20); + }, configurable: true, enumerable: true }; + } + static getPropertyOptions(t17) { + return this.elementProperties.get(t17) || l16; + } + static finalize() { + if (this.hasOwnProperty(d9)) + return false; + this[d9] = true; + const t17 = Object.getPrototypeOf(this); + if (t17.finalize(), void 0 !== t17.h && (this.h = [...t17.h]), this.elementProperties = new Map(t17.elementProperties), this._$Ev = /* @__PURE__ */ new Map(), this.hasOwnProperty("properties")) { + const t18 = this.properties, i23 = [...Object.getOwnPropertyNames(t18), ...Object.getOwnPropertySymbols(t18)]; + for (const s20 of i23) + this.createProperty(s20, t18[s20]); + } + return this.elementStyles = this.finalizeStyles(this.styles), true; + } + static finalizeStyles(i23) { + const s20 = []; + if (Array.isArray(i23)) { + const e33 = new Set(i23.flat(1 / 0).reverse()); + for (const i24 of e33) + s20.unshift(c10(i24)); + } else + void 0 !== i23 && s20.push(c10(i23)); + return s20; + } + static _$Ep(t17, i23) { + const s20 = i23.attribute; + return false === s20 ? void 0 : "string" == typeof s20 ? s20 : "string" == typeof t17 ? t17.toLowerCase() : void 0; + } + _$Eu() { + var t17; + this._$E_ = new Promise((t18) => this.enableUpdating = t18), this._$AL = /* @__PURE__ */ new Map(), this._$Eg(), this.requestUpdate(), null === (t17 = this.constructor.h) || void 0 === t17 || t17.forEach((t18) => t18(this)); + } + addController(t17) { + var i23, s20; + (null !== (i23 = this._$ES) && void 0 !== i23 ? i23 : this._$ES = []).push(t17), void 0 !== this.renderRoot && this.isConnected && (null === (s20 = t17.hostConnected) || void 0 === s20 || s20.call(t17)); + } + removeController(t17) { + var i23; + null === (i23 = this._$ES) || void 0 === i23 || i23.splice(this._$ES.indexOf(t17) >>> 0, 1); + } + _$Eg() { + this.constructor.elementProperties.forEach((t17, i23) => { + this.hasOwnProperty(i23) && (this._$Ei.set(i23, this[i23]), delete this[i23]); + }); + } + createRenderRoot() { + var t17; + const s20 = null !== (t17 = this.shadowRoot) && void 0 !== t17 ? t17 : this.attachShadow(this.constructor.shadowRootOptions); + return S9(s20, this.constructor.elementStyles), s20; + } + connectedCallback() { + var t17; + void 0 === this.renderRoot && (this.renderRoot = this.createRenderRoot()), this.enableUpdating(true), null === (t17 = this._$ES) || void 0 === t17 || t17.forEach((t18) => { + var i23; + return null === (i23 = t18.hostConnected) || void 0 === i23 ? void 0 : i23.call(t18); + }); + } + enableUpdating(t17) { + } + disconnectedCallback() { + var t17; + null === (t17 = this._$ES) || void 0 === t17 || t17.forEach((t18) => { + var i23; + return null === (i23 = t18.hostDisconnected) || void 0 === i23 ? void 0 : i23.call(t18); + }); + } + attributeChangedCallback(t17, i23, s20) { + this._$AK(t17, s20); + } + _$EO(t17, i23, s20 = l16) { + var e33; + const r18 = this.constructor._$Ep(t17, s20); + if (void 0 !== r18 && true === s20.reflect) { + const h11 = (void 0 !== (null === (e33 = s20.converter) || void 0 === e33 ? void 0 : e33.toAttribute) ? s20.converter : n28).toAttribute(i23, s20.type); + this._$El = t17, null == h11 ? this.removeAttribute(r18) : this.setAttribute(r18, h11), this._$El = null; + } + } + _$AK(t17, i23) { + var s20; + const e33 = this.constructor, r18 = e33._$Ev.get(t17); + if (void 0 !== r18 && this._$El !== r18) { + const t18 = e33.getPropertyOptions(r18), h11 = "function" == typeof t18.converter ? { fromAttribute: t18.converter } : void 0 !== (null === (s20 = t18.converter) || void 0 === s20 ? void 0 : s20.fromAttribute) ? t18.converter : n28; + this._$El = r18, this[r18] = h11.fromAttribute(i23, t18.type), this._$El = null; + } + } + requestUpdate(t17, i23, s20) { + let e33 = true; + void 0 !== t17 && (((s20 = s20 || this.constructor.getPropertyOptions(t17)).hasChanged || a9)(this[t17], i23) ? (this._$AL.has(t17) || this._$AL.set(t17, i23), true === s20.reflect && this._$El !== t17 && (void 0 === this._$EC && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(t17, s20))) : e33 = false), !this.isUpdatePending && e33 && (this._$E_ = this._$Ej()); + } + async _$Ej() { + this.isUpdatePending = true; + try { + await this._$E_; + } catch (t18) { + Promise.reject(t18); + } + const t17 = this.scheduleUpdate(); + return null != t17 && await t17, !this.isUpdatePending; + } + scheduleUpdate() { + return this.performUpdate(); + } + performUpdate() { + var t17; + if (!this.isUpdatePending) + return; + this.hasUpdated, this._$Ei && (this._$Ei.forEach((t18, i24) => this[i24] = t18), this._$Ei = void 0); + let i23 = false; + const s20 = this._$AL; + try { + i23 = this.shouldUpdate(s20), i23 ? (this.willUpdate(s20), null === (t17 = this._$ES) || void 0 === t17 || t17.forEach((t18) => { + var i24; + return null === (i24 = t18.hostUpdate) || void 0 === i24 ? void 0 : i24.call(t18); + }), this.update(s20)) : this._$Ek(); + } catch (t18) { + throw i23 = false, this._$Ek(), t18; + } + i23 && this._$AE(s20); + } + willUpdate(t17) { + } + _$AE(t17) { + var i23; + null === (i23 = this._$ES) || void 0 === i23 || i23.forEach((t18) => { + var i24; + return null === (i24 = t18.hostUpdated) || void 0 === i24 ? void 0 : i24.call(t18); + }), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t17)), this.updated(t17); + } + _$Ek() { + this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = false; + } + get updateComplete() { + return this.getUpdateComplete(); + } + getUpdateComplete() { + return this._$E_; + } + shouldUpdate(t17) { + return true; + } + update(t17) { + void 0 !== this._$EC && (this._$EC.forEach((t18, i23) => this._$EO(i23, this[i23], t18)), this._$EC = void 0), this._$Ek(); + } + updated(t17) { + } + firstUpdated(t17) { + } + }; + u9[d9] = true, u9.elementProperties = /* @__PURE__ */ new Map(), u9.elementStyles = [], u9.shadowRootOptions = { mode: "open" }, null == o25 || o25({ ReactiveElement: u9 }), (null !== (s17 = e30.reactiveElementVersions) && void 0 !== s17 ? s17 : e30.reactiveElementVersions = []).push("1.6.3"); + + // node_modules/@material/mwc-switch/node_modules/lit-html/lit-html.js + var t15; + var i21 = window; + var s18 = i21.trustedTypes; + var e31 = s18 ? s18.createPolicy("lit-html", { createHTML: (t17) => t17 }) : void 0; + var o26 = "$lit$"; + var n29 = `lit$${(Math.random() + "").slice(9)}$`; + var l17 = "?" + n29; + var h10 = `<${l17}>`; + var r17 = document; + var u10 = () => r17.createComment(""); + var d10 = (t17) => null === t17 || "object" != typeof t17 && "function" != typeof t17; + var c11 = Array.isArray; + var v5 = (t17) => c11(t17) || "function" == typeof (null == t17 ? void 0 : t17[Symbol.iterator]); + var a10 = "[ \n\f\r]"; + var f6 = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g; + var _18 = /-->/g; + var m5 = />/g; + var p6 = RegExp(`>|${a10}(?:([^\\s"'>=/]+)(${a10}*=${a10}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`, "g"); + var g5 = /'/g; + var $5 = /"/g; + var y6 = /^(?:script|style|textarea|title)$/i; + var w5 = (t17) => (i23, ...s20) => ({ _$litType$: t17, strings: i23, values: s20 }); + var x5 = w5(1); + var b6 = w5(2); + var T5 = Symbol.for("lit-noChange"); + var A5 = Symbol.for("lit-nothing"); + var E5 = /* @__PURE__ */ new WeakMap(); + var C5 = r17.createTreeWalker(r17, 129, null, false); + function P5(t17, i23) { + if (!Array.isArray(t17) || !t17.hasOwnProperty("raw")) + throw Error("invalid template strings array"); + return void 0 !== e31 ? e31.createHTML(i23) : i23; + } + var V5 = (t17, i23) => { + const s20 = t17.length - 1, e33 = []; + let l20, r18 = 2 === i23 ? "" : "", u11 = f6; + for (let i24 = 0; i24 < s20; i24++) { + const s21 = t17[i24]; + let d11, c12, v6 = -1, a11 = 0; + for (; a11 < s21.length && (u11.lastIndex = a11, c12 = u11.exec(s21), null !== c12); ) + a11 = u11.lastIndex, u11 === f6 ? "!--" === c12[1] ? u11 = _18 : void 0 !== c12[1] ? u11 = m5 : void 0 !== c12[2] ? (y6.test(c12[2]) && (l20 = RegExp("" === c12[0] ? (u11 = null != l20 ? l20 : f6, v6 = -1) : void 0 === c12[1] ? v6 = -2 : (v6 = u11.lastIndex - c12[2].length, d11 = c12[1], u11 = void 0 === c12[3] ? p6 : '"' === c12[3] ? $5 : g5) : u11 === $5 || u11 === g5 ? u11 = p6 : u11 === _18 || u11 === m5 ? u11 = f6 : (u11 = p6, l20 = void 0); + const w6 = u11 === p6 && t17[i24 + 1].startsWith("/>") ? " " : ""; + r18 += u11 === f6 ? s21 + h10 : v6 >= 0 ? (e33.push(d11), s21.slice(0, v6) + o26 + s21.slice(v6) + n29 + w6) : s21 + n29 + (-2 === v6 ? (e33.push(void 0), i24) : w6); + } + return [P5(t17, r18 + (t17[s20] || "") + (2 === i23 ? "" : "")), e33]; + }; + var N5 = class _N { + constructor({ strings: t17, _$litType$: i23 }, e33) { + let h11; + this.parts = []; + let r18 = 0, d11 = 0; + const c12 = t17.length - 1, v6 = this.parts, [a11, f7] = V5(t17, i23); + if (this.el = _N.createElement(a11, e33), C5.currentNode = this.el.content, 2 === i23) { + const t18 = this.el.content, i24 = t18.firstChild; + i24.remove(), t18.append(...i24.childNodes); + } + for (; null !== (h11 = C5.nextNode()) && v6.length < c12; ) { + if (1 === h11.nodeType) { + if (h11.hasAttributes()) { + const t18 = []; + for (const i24 of h11.getAttributeNames()) + if (i24.endsWith(o26) || i24.startsWith(n29)) { + const s20 = f7[d11++]; + if (t18.push(i24), void 0 !== s20) { + const t19 = h11.getAttribute(s20.toLowerCase() + o26).split(n29), i25 = /([.?@])?(.*)/.exec(s20); + v6.push({ type: 1, index: r18, name: i25[2], strings: t19, ctor: "." === i25[1] ? H5 : "?" === i25[1] ? L5 : "@" === i25[1] ? z4 : k7 }); + } else + v6.push({ type: 6, index: r18 }); + } + for (const i24 of t18) + h11.removeAttribute(i24); + } + if (y6.test(h11.tagName)) { + const t18 = h11.textContent.split(n29), i24 = t18.length - 1; + if (i24 > 0) { + h11.textContent = s18 ? s18.emptyScript : ""; + for (let s20 = 0; s20 < i24; s20++) + h11.append(t18[s20], u10()), C5.nextNode(), v6.push({ type: 2, index: ++r18 }); + h11.append(t18[i24], u10()); + } + } + } else if (8 === h11.nodeType) + if (h11.data === l17) + v6.push({ type: 2, index: r18 }); + else { + let t18 = -1; + for (; -1 !== (t18 = h11.data.indexOf(n29, t18 + 1)); ) + v6.push({ type: 7, index: r18 }), t18 += n29.length - 1; + } + r18++; + } + } + static createElement(t17, i23) { + const s20 = r17.createElement("template"); + return s20.innerHTML = t17, s20; + } + }; + function S10(t17, i23, s20 = t17, e33) { + var o29, n31, l20, h11; + if (i23 === T5) + return i23; + let r18 = void 0 !== e33 ? null === (o29 = s20._$Co) || void 0 === o29 ? void 0 : o29[e33] : s20._$Cl; + const u11 = d10(i23) ? void 0 : i23._$litDirective$; + return (null == r18 ? void 0 : r18.constructor) !== u11 && (null === (n31 = null == r18 ? void 0 : r18._$AO) || void 0 === n31 || n31.call(r18, false), void 0 === u11 ? r18 = void 0 : (r18 = new u11(t17), r18._$AT(t17, s20, e33)), void 0 !== e33 ? (null !== (l20 = (h11 = s20)._$Co) && void 0 !== l20 ? l20 : h11._$Co = [])[e33] = r18 : s20._$Cl = r18), void 0 !== r18 && (i23 = S10(t17, r18._$AS(t17, i23.values), r18, e33)), i23; + } + var M5 = class { + constructor(t17, i23) { + this._$AV = [], this._$AN = void 0, this._$AD = t17, this._$AM = i23; + } + get parentNode() { + return this._$AM.parentNode; + } + get _$AU() { + return this._$AM._$AU; + } + u(t17) { + var i23; + const { el: { content: s20 }, parts: e33 } = this._$AD, o29 = (null !== (i23 = null == t17 ? void 0 : t17.creationScope) && void 0 !== i23 ? i23 : r17).importNode(s20, true); + C5.currentNode = o29; + let n31 = C5.nextNode(), l20 = 0, h11 = 0, u11 = e33[0]; + for (; void 0 !== u11; ) { + if (l20 === u11.index) { + let i24; + 2 === u11.type ? i24 = new R5(n31, n31.nextSibling, this, t17) : 1 === u11.type ? i24 = new u11.ctor(n31, u11.name, u11.strings, this, t17) : 6 === u11.type && (i24 = new Z5(n31, this, t17)), this._$AV.push(i24), u11 = e33[++h11]; + } + l20 !== (null == u11 ? void 0 : u11.index) && (n31 = C5.nextNode(), l20++); + } + return C5.currentNode = r17, o29; + } + v(t17) { + let i23 = 0; + for (const s20 of this._$AV) + void 0 !== s20 && (void 0 !== s20.strings ? (s20._$AI(t17, s20, i23), i23 += s20.strings.length - 2) : s20._$AI(t17[i23])), i23++; + } + }; + var R5 = class _R { + constructor(t17, i23, s20, e33) { + var o29; + this.type = 2, this._$AH = A5, this._$AN = void 0, this._$AA = t17, this._$AB = i23, this._$AM = s20, this.options = e33, this._$Cp = null === (o29 = null == e33 ? void 0 : e33.isConnected) || void 0 === o29 || o29; + } + get _$AU() { + var t17, i23; + return null !== (i23 = null === (t17 = this._$AM) || void 0 === t17 ? void 0 : t17._$AU) && void 0 !== i23 ? i23 : this._$Cp; + } + get parentNode() { + let t17 = this._$AA.parentNode; + const i23 = this._$AM; + return void 0 !== i23 && 11 === (null == t17 ? void 0 : t17.nodeType) && (t17 = i23.parentNode), t17; + } + get startNode() { + return this._$AA; + } + get endNode() { + return this._$AB; + } + _$AI(t17, i23 = this) { + t17 = S10(this, t17, i23), d10(t17) ? t17 === A5 || null == t17 || "" === t17 ? (this._$AH !== A5 && this._$AR(), this._$AH = A5) : t17 !== this._$AH && t17 !== T5 && this._(t17) : void 0 !== t17._$litType$ ? this.g(t17) : void 0 !== t17.nodeType ? this.$(t17) : v5(t17) ? this.T(t17) : this._(t17); + } + k(t17) { + return this._$AA.parentNode.insertBefore(t17, this._$AB); + } + $(t17) { + this._$AH !== t17 && (this._$AR(), this._$AH = this.k(t17)); + } + _(t17) { + this._$AH !== A5 && d10(this._$AH) ? this._$AA.nextSibling.data = t17 : this.$(r17.createTextNode(t17)), this._$AH = t17; + } + g(t17) { + var i23; + const { values: s20, _$litType$: e33 } = t17, o29 = "number" == typeof e33 ? this._$AC(t17) : (void 0 === e33.el && (e33.el = N5.createElement(P5(e33.h, e33.h[0]), this.options)), e33); + if ((null === (i23 = this._$AH) || void 0 === i23 ? void 0 : i23._$AD) === o29) + this._$AH.v(s20); + else { + const t18 = new M5(o29, this), i24 = t18.u(this.options); + t18.v(s20), this.$(i24), this._$AH = t18; + } + } + _$AC(t17) { + let i23 = E5.get(t17.strings); + return void 0 === i23 && E5.set(t17.strings, i23 = new N5(t17)), i23; + } + T(t17) { + c11(this._$AH) || (this._$AH = [], this._$AR()); + const i23 = this._$AH; + let s20, e33 = 0; + for (const o29 of t17) + e33 === i23.length ? i23.push(s20 = new _R(this.k(u10()), this.k(u10()), this, this.options)) : s20 = i23[e33], s20._$AI(o29), e33++; + e33 < i23.length && (this._$AR(s20 && s20._$AB.nextSibling, e33), i23.length = e33); + } + _$AR(t17 = this._$AA.nextSibling, i23) { + var s20; + for (null === (s20 = this._$AP) || void 0 === s20 || s20.call(this, false, true, i23); t17 && t17 !== this._$AB; ) { + const i24 = t17.nextSibling; + t17.remove(), t17 = i24; + } + } + setConnected(t17) { + var i23; + void 0 === this._$AM && (this._$Cp = t17, null === (i23 = this._$AP) || void 0 === i23 || i23.call(this, t17)); + } + }; + var k7 = class { + constructor(t17, i23, s20, e33, o29) { + this.type = 1, this._$AH = A5, this._$AN = void 0, this.element = t17, this.name = i23, this._$AM = e33, this.options = o29, s20.length > 2 || "" !== s20[0] || "" !== s20[1] ? (this._$AH = Array(s20.length - 1).fill(new String()), this.strings = s20) : this._$AH = A5; + } + get tagName() { + return this.element.tagName; + } + get _$AU() { + return this._$AM._$AU; + } + _$AI(t17, i23 = this, s20, e33) { + const o29 = this.strings; + let n31 = false; + if (void 0 === o29) + t17 = S10(this, t17, i23, 0), n31 = !d10(t17) || t17 !== this._$AH && t17 !== T5, n31 && (this._$AH = t17); + else { + const e34 = t17; + let l20, h11; + for (t17 = o29[0], l20 = 0; l20 < o29.length - 1; l20++) + h11 = S10(this, e34[s20 + l20], i23, l20), h11 === T5 && (h11 = this._$AH[l20]), n31 || (n31 = !d10(h11) || h11 !== this._$AH[l20]), h11 === A5 ? t17 = A5 : t17 !== A5 && (t17 += (null != h11 ? h11 : "") + o29[l20 + 1]), this._$AH[l20] = h11; + } + n31 && !e33 && this.j(t17); + } + j(t17) { + t17 === A5 ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, null != t17 ? t17 : ""); + } + }; + var H5 = class extends k7 { + constructor() { + super(...arguments), this.type = 3; + } + j(t17) { + this.element[this.name] = t17 === A5 ? void 0 : t17; + } + }; + var I5 = s18 ? s18.emptyScript : ""; + var L5 = class extends k7 { + constructor() { + super(...arguments), this.type = 4; + } + j(t17) { + t17 && t17 !== A5 ? this.element.setAttribute(this.name, I5) : this.element.removeAttribute(this.name); + } + }; + var z4 = class extends k7 { + constructor(t17, i23, s20, e33, o29) { + super(t17, i23, s20, e33, o29), this.type = 5; + } + _$AI(t17, i23 = this) { + var s20; + if ((t17 = null !== (s20 = S10(this, t17, i23, 0)) && void 0 !== s20 ? s20 : A5) === T5) + return; + const e33 = this._$AH, o29 = t17 === A5 && e33 !== A5 || t17.capture !== e33.capture || t17.once !== e33.once || t17.passive !== e33.passive, n31 = t17 !== A5 && (e33 === A5 || o29); + o29 && this.element.removeEventListener(this.name, this, e33), n31 && this.element.addEventListener(this.name, this, t17), this._$AH = t17; + } + handleEvent(t17) { + var i23, s20; + "function" == typeof this._$AH ? this._$AH.call(null !== (s20 = null === (i23 = this.options) || void 0 === i23 ? void 0 : i23.host) && void 0 !== s20 ? s20 : this.element, t17) : this._$AH.handleEvent(t17); + } + }; + var Z5 = class { + constructor(t17, i23, s20) { + this.element = t17, this.type = 6, this._$AN = void 0, this._$AM = i23, this.options = s20; + } + get _$AU() { + return this._$AM._$AU; + } + _$AI(t17) { + S10(this, t17); + } + }; + var B4 = i21.litHtmlPolyfillSupport; + null == B4 || B4(N5, R5), (null !== (t15 = i21.litHtmlVersions) && void 0 !== t15 ? t15 : i21.litHtmlVersions = []).push("2.8.0"); + var D4 = (t17, i23, s20) => { + var e33, o29; + const n31 = null !== (e33 = null == s20 ? void 0 : s20.renderBefore) && void 0 !== e33 ? e33 : i23; + let l20 = n31._$litPart$; + if (void 0 === l20) { + const t18 = null !== (o29 = null == s20 ? void 0 : s20.renderBefore) && void 0 !== o29 ? o29 : null; + n31._$litPart$ = l20 = new R5(i23.insertBefore(u10(), t18), t18, void 0, null != s20 ? s20 : {}); + } + return l20._$AI(t17), l20; + }; + + // node_modules/@material/mwc-switch/node_modules/lit-element/lit-element.js + var l18; + var o27; + var s19 = class extends u9 { + constructor() { + super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0; + } + createRenderRoot() { + var t17, e33; + const i23 = super.createRenderRoot(); + return null !== (t17 = (e33 = this.renderOptions).renderBefore) && void 0 !== t17 || (e33.renderBefore = i23.firstChild), i23; + } + update(t17) { + const i23 = this.render(); + this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t17), this._$Do = D4(i23, this.renderRoot, this.renderOptions); + } + connectedCallback() { + var t17; + super.connectedCallback(), null === (t17 = this._$Do) || void 0 === t17 || t17.setConnected(true); + } + disconnectedCallback() { + var t17; + super.disconnectedCallback(), null === (t17 = this._$Do) || void 0 === t17 || t17.setConnected(false); + } + render() { + return T5; + } + }; + s19.finalized = true, s19._$litElement$ = true, null === (l18 = globalThis.litElementHydrateSupport) || void 0 === l18 || l18.call(globalThis, { LitElement: s19 }); + var n30 = globalThis.litElementPolyfillSupport; + null == n30 || n30({ LitElement: s19 }); + (null !== (o27 = globalThis.litElementVersions) && void 0 !== o27 ? o27 : globalThis.litElementVersions = []).push("3.3.3"); + + // node_modules/@material/mwc-switch/node_modules/lit-html/directive.js + var t16 = { ATTRIBUTE: 1, CHILD: 2, PROPERTY: 3, BOOLEAN_ATTRIBUTE: 4, EVENT: 5, ELEMENT: 6 }; + var e32 = (t17) => (...e33) => ({ _$litDirective$: t17, values: e33 }); + var i22 = class { + constructor(t17) { + } + get _$AU() { + return this._$AM._$AU; + } + _$AT(t17, e33, i23) { + this._$Ct = t17, this._$AM = e33, this._$Ci = i23; + } + _$AS(t17, e33) { + return this.update(t17, e33); + } + update(t17, e33) { + return this.render(...e33); + } + }; + + // node_modules/@material/mwc-switch/node_modules/lit-html/directives/class-map.js + var o28 = e32(class extends i22 { + constructor(t17) { + var i23; + if (super(t17), t17.type !== t16.ATTRIBUTE || "class" !== t17.name || (null === (i23 = t17.strings) || void 0 === i23 ? void 0 : i23.length) > 2) + throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute."); + } + render(t17) { + return " " + Object.keys(t17).filter((i23) => t17[i23]).join(" ") + " "; + } + update(i23, [s20]) { + var r18, o29; + if (void 0 === this.it) { + this.it = /* @__PURE__ */ new Set(), void 0 !== i23.strings && (this.nt = new Set(i23.strings.join(" ").split(/\s/).filter((t17) => "" !== t17))); + for (const t17 in s20) + s20[t17] && !(null === (r18 = this.nt) || void 0 === r18 ? void 0 : r18.has(t17)) && this.it.add(t17); + return this.render(s20); + } + const e33 = i23.element.classList; + this.it.forEach((t17) => { + t17 in s20 || (e33.remove(t17), this.it.delete(t17)); + }); + for (const t17 in s20) { + const i24 = !!s20[t17]; + i24 === this.it.has(t17) || (null === (o29 = this.nt) || void 0 === o29 ? void 0 : o29.has(t17)) || (i24 ? (e33.add(t17), this.it.add(t17)) : (e33.remove(t17), this.it.delete(t17))); + } + return T5; + } + }); + + // node_modules/@material/mwc-switch/node_modules/lit-html/directives/if-defined.js + var l19 = (l20) => null != l20 ? l20 : A5; + + // node_modules/@material/mwc-switch/mwc-switch-base.js + var SwitchBase = class extends FormElement { + constructor() { + super(...arguments); + this.processing = false; + this.selected = false; + this.ariaLabel = ""; + this.ariaLabelledBy = ""; + this.shouldRenderRipple = false; + this.rippleHandlers = new RippleHandlers(() => { + this.shouldRenderRipple = true; + return this.ripple; + }); + this.name = ""; + this.value = "on"; + this.mdcFoundationClass = MDCSwitchFoundation; + } + setFormData(formData) { + if (this.name && this.selected) { + formData.append(this.name, this.value); + } + } + click() { + var _a2, _b2; + if (this.disabled) { + return; + } + (_a2 = this.mdcRoot) === null || _a2 === void 0 ? void 0 : _a2.focus(); + (_b2 = this.mdcRoot) === null || _b2 === void 0 ? void 0 : _b2.click(); + } + /** @soyTemplate */ + render() { + return x5` + + + + `; + } + /** @soyTemplate */ + getRenderClasses() { + return { + "mdc-switch--processing": this.processing, + "mdc-switch--selected": this.selected, + "mdc-switch--unselected": !this.selected + }; + } + /** @soyTemplate */ + renderHandle() { + return x5` +
    + ${this.renderShadow()} + ${this.renderRipple()} +
    + ${this.renderOnIcon()} + ${this.renderOffIcon()} +
    +
    + `; + } + /** @soyTemplate */ + renderShadow() { + return x5` +
    +
    +
    + `; + } + /** @soyTemplate */ + renderRipple() { + if (this.shouldRenderRipple) { + return x5` +
    + + +
    + `; + } else { + return x5``; + } + } + /** @soyTemplate */ + renderOnIcon() { + return x5` + + + + `; + } + /** @soyTemplate */ + renderOffIcon() { + return x5` + + + + `; + } + handleClick() { + var _a2; + (_a2 = this.mdcFoundation) === null || _a2 === void 0 ? void 0 : _a2.handleClick(); + } + handleFocus() { + this.rippleHandlers.startFocus(); + } + handleBlur() { + this.rippleHandlers.endFocus(); + } + handlePointerDown(event) { + event.target.setPointerCapture(event.pointerId); + this.rippleHandlers.startPress(event); + } + handlePointerUp() { + this.rippleHandlers.endPress(); + } + handlePointerEnter() { + this.rippleHandlers.startHover(); + } + handlePointerLeave() { + this.rippleHandlers.endHover(); + } + createAdapter() { + return { state: this }; + } + }; + __decorate([ + n12({ type: Boolean }) + ], SwitchBase.prototype, "processing", void 0); + __decorate([ + n12({ type: Boolean }) + ], SwitchBase.prototype, "selected", void 0); + __decorate([ + ariaProperty, + n12({ type: String, attribute: "aria-label" }) + ], SwitchBase.prototype, "ariaLabel", void 0); + __decorate([ + ariaProperty, + n12({ type: String, attribute: "aria-labelledby" }) + ], SwitchBase.prototype, "ariaLabelledBy", void 0); + __decorate([ + e15("mwc-ripple") + ], SwitchBase.prototype, "ripple", void 0); + __decorate([ + t7() + ], SwitchBase.prototype, "shouldRenderRipple", void 0); + __decorate([ + n12({ type: String, reflect: true }) + ], SwitchBase.prototype, "name", void 0); + __decorate([ + n12({ type: String }) + ], SwitchBase.prototype, "value", void 0); + __decorate([ + i10("input") + ], SwitchBase.prototype, "formElement", void 0); + __decorate([ + i10(".mdc-switch") + ], SwitchBase.prototype, "mdcRoot", void 0); + __decorate([ + e14({ passive: true }) + ], SwitchBase.prototype, "handlePointerDown", null); + + // node_modules/@material/mwc-switch/styles.css.js + var styles13 = i20`.mdc-elevation-overlay{position:absolute;border-radius:inherit;pointer-events:none;opacity:0;opacity:var(--mdc-elevation-overlay-opacity, 0);transition:opacity 280ms cubic-bezier(0.4, 0, 0.2, 1);background-color:#fff;background-color:var(--mdc-elevation-overlay-color, #fff)}.mdc-switch{align-items:center;background:none;border:none;cursor:pointer;display:inline-flex;flex-shrink:0;margin:0;outline:none;overflow:visible;padding:0;position:relative}.mdc-switch:disabled{cursor:default;pointer-events:none}.mdc-switch__track{overflow:hidden;position:relative;width:100%}.mdc-switch__track::before,.mdc-switch__track::after{border:1px solid transparent;border-radius:inherit;box-sizing:border-box;content:"";height:100%;left:0;position:absolute;width:100%}@media screen and (forced-colors: active){.mdc-switch__track::before,.mdc-switch__track::after{border-color:currentColor}}.mdc-switch__track::before{transition:transform 75ms 0ms cubic-bezier(0, 0, 0.2, 1);transform:translateX(0)}.mdc-switch__track::after{transition:transform 75ms 0ms cubic-bezier(0.4, 0, 0.6, 1);transform:translateX(-100%)}[dir=rtl] .mdc-switch__track::after,.mdc-switch__track[dir=rtl]::after{transform:translateX(100%)}.mdc-switch--selected .mdc-switch__track::before{transition:transform 75ms 0ms cubic-bezier(0.4, 0, 0.6, 1);transform:translateX(100%)}[dir=rtl] .mdc-switch--selected .mdc-switch__track::before,.mdc-switch--selected .mdc-switch__track[dir=rtl]::before{transform:translateX(-100%)}.mdc-switch--selected .mdc-switch__track::after{transition:transform 75ms 0ms cubic-bezier(0, 0, 0.2, 1);transform:translateX(0)}.mdc-switch__handle-track{height:100%;pointer-events:none;position:absolute;top:0;transition:transform 75ms 0ms cubic-bezier(0.4, 0, 0.2, 1);left:0;right:auto;transform:translateX(0)}[dir=rtl] .mdc-switch__handle-track,.mdc-switch__handle-track[dir=rtl]{left:auto;right:0}.mdc-switch--selected .mdc-switch__handle-track{transform:translateX(100%)}[dir=rtl] .mdc-switch--selected .mdc-switch__handle-track,.mdc-switch--selected .mdc-switch__handle-track[dir=rtl]{transform:translateX(-100%)}.mdc-switch__handle{display:flex;pointer-events:auto;position:absolute;top:50%;transform:translateY(-50%);left:0;right:auto}[dir=rtl] .mdc-switch__handle,.mdc-switch__handle[dir=rtl]{left:auto;right:0}.mdc-switch__handle::before,.mdc-switch__handle::after{border:1px solid transparent;border-radius:inherit;box-sizing:border-box;content:"";width:100%;height:100%;left:0;position:absolute;top:0;transition:background-color 75ms 0ms cubic-bezier(0.4, 0, 0.2, 1),border-color 75ms 0ms cubic-bezier(0.4, 0, 0.2, 1);z-index:-1}@media screen and (forced-colors: active){.mdc-switch__handle::before,.mdc-switch__handle::after{border-color:currentColor}}.mdc-switch__shadow{border-radius:inherit;bottom:0;left:0;position:absolute;right:0;top:0}.mdc-elevation-overlay{bottom:0;left:0;right:0;top:0}.mdc-switch__ripple{left:50%;position:absolute;top:50%;transform:translate(-50%, -50%);z-index:-1}.mdc-switch:disabled .mdc-switch__ripple{display:none}.mdc-switch__icons{height:100%;position:relative;width:100%;z-index:1}.mdc-switch__icon{bottom:0;left:0;margin:auto;position:absolute;right:0;top:0;opacity:0;transition:opacity 30ms 0ms cubic-bezier(0.4, 0, 1, 1)}.mdc-switch--selected .mdc-switch__icon--on,.mdc-switch--unselected .mdc-switch__icon--off{opacity:1;transition:opacity 45ms 30ms cubic-bezier(0, 0, 0.2, 1)}:host{display:inline-flex;outline:none}input{display:none}.mdc-switch{width:36px;width:var(--mdc-switch-track-width, 36px)}.mdc-switch.mdc-switch--selected:enabled .mdc-switch__handle::after{background:#6200ee;background:var(--mdc-switch-selected-handle-color, var(--mdc-theme-primary, #6200ee))}.mdc-switch.mdc-switch--selected:enabled:hover:not(:focus):not(:active) .mdc-switch__handle::after{background:#310077;background:var(--mdc-switch-selected-hover-handle-color, #310077)}.mdc-switch.mdc-switch--selected:enabled:focus:not(:active) .mdc-switch__handle::after{background:#310077;background:var(--mdc-switch-selected-focus-handle-color, #310077)}.mdc-switch.mdc-switch--selected:enabled:active .mdc-switch__handle::after{background:#310077;background:var(--mdc-switch-selected-pressed-handle-color, #310077)}.mdc-switch.mdc-switch--selected:disabled .mdc-switch__handle::after{background:#424242;background:var(--mdc-switch-disabled-selected-handle-color, #424242)}.mdc-switch.mdc-switch--unselected:enabled .mdc-switch__handle::after{background:#616161;background:var(--mdc-switch-unselected-handle-color, #616161)}.mdc-switch.mdc-switch--unselected:enabled:hover:not(:focus):not(:active) .mdc-switch__handle::after{background:#212121;background:var(--mdc-switch-unselected-hover-handle-color, #212121)}.mdc-switch.mdc-switch--unselected:enabled:focus:not(:active) .mdc-switch__handle::after{background:#212121;background:var(--mdc-switch-unselected-focus-handle-color, #212121)}.mdc-switch.mdc-switch--unselected:enabled:active .mdc-switch__handle::after{background:#212121;background:var(--mdc-switch-unselected-pressed-handle-color, #212121)}.mdc-switch.mdc-switch--unselected:disabled .mdc-switch__handle::after{background:#424242;background:var(--mdc-switch-disabled-unselected-handle-color, #424242)}.mdc-switch .mdc-switch__handle::before{background:#fff;background:var(--mdc-switch-handle-surface-color, var(--mdc-theme-surface, #fff))}.mdc-switch:enabled .mdc-switch__shadow{--mdc-elevation-box-shadow-for-gss:0px 2px 1px -1px rgba(0, 0, 0, 0.2), 0px 1px 1px 0px rgba(0, 0, 0, 0.14), 0px 1px 3px 0px rgba(0, 0, 0, 0.12);box-shadow:0px 2px 1px -1px rgba(0, 0, 0, 0.2), 0px 1px 1px 0px rgba(0, 0, 0, 0.14), 0px 1px 3px 0px rgba(0, 0, 0, 0.12);box-shadow:var(--mdc-switch-handle-elevation, var(--mdc-elevation-box-shadow-for-gss))}.mdc-switch:disabled .mdc-switch__shadow{--mdc-elevation-box-shadow-for-gss:0px 0px 0px 0px rgba(0, 0, 0, 0.2), 0px 0px 0px 0px rgba(0, 0, 0, 0.14), 0px 0px 0px 0px rgba(0, 0, 0, 0.12);box-shadow:0px 0px 0px 0px rgba(0, 0, 0, 0.2), 0px 0px 0px 0px rgba(0, 0, 0, 0.14), 0px 0px 0px 0px rgba(0, 0, 0, 0.12);box-shadow:var(--mdc-switch-disabled-handle-elevation, var(--mdc-elevation-box-shadow-for-gss))}.mdc-switch .mdc-switch__focus-ring-wrapper,.mdc-switch .mdc-switch__handle{height:20px;height:var(--mdc-switch-handle-height, 20px)}.mdc-switch:disabled .mdc-switch__handle::after{opacity:0.38;opacity:var(--mdc-switch-disabled-handle-opacity, 0.38)}.mdc-switch .mdc-switch__handle{border-radius:10px;border-radius:var(--mdc-switch-handle-shape, 10px)}.mdc-switch .mdc-switch__handle{width:20px;width:var(--mdc-switch-handle-width, 20px)}.mdc-switch .mdc-switch__handle-track{width:calc(100% - 20px);width:calc(100% - var(--mdc-switch-handle-width, 20px))}.mdc-switch.mdc-switch--selected:enabled .mdc-switch__icon{fill:#fff;fill:var(--mdc-switch-selected-icon-color, var(--mdc-theme-on-primary, #fff))}.mdc-switch.mdc-switch--selected:disabled .mdc-switch__icon{fill:#fff;fill:var(--mdc-switch-disabled-selected-icon-color, var(--mdc-theme-on-primary, #fff))}.mdc-switch.mdc-switch--unselected:enabled .mdc-switch__icon{fill:#fff;fill:var(--mdc-switch-unselected-icon-color, var(--mdc-theme-on-primary, #fff))}.mdc-switch.mdc-switch--unselected:disabled .mdc-switch__icon{fill:#fff;fill:var(--mdc-switch-disabled-unselected-icon-color, var(--mdc-theme-on-primary, #fff))}.mdc-switch.mdc-switch--selected:disabled .mdc-switch__icons{opacity:0.38;opacity:var(--mdc-switch-disabled-selected-icon-opacity, 0.38)}.mdc-switch.mdc-switch--unselected:disabled .mdc-switch__icons{opacity:0.38;opacity:var(--mdc-switch-disabled-unselected-icon-opacity, 0.38)}.mdc-switch.mdc-switch--selected .mdc-switch__icon{width:18px;width:var(--mdc-switch-selected-icon-size, 18px);height:18px;height:var(--mdc-switch-selected-icon-size, 18px)}.mdc-switch.mdc-switch--unselected .mdc-switch__icon{width:18px;width:var(--mdc-switch-unselected-icon-size, 18px);height:18px;height:var(--mdc-switch-unselected-icon-size, 18px)}.mdc-switch .mdc-switch__ripple{height:48px;height:var(--mdc-switch-state-layer-size, 48px);width:48px;width:var(--mdc-switch-state-layer-size, 48px)}.mdc-switch .mdc-switch__track{height:14px;height:var(--mdc-switch-track-height, 14px)}.mdc-switch:disabled .mdc-switch__track{opacity:0.12;opacity:var(--mdc-switch-disabled-track-opacity, 0.12)}.mdc-switch:enabled .mdc-switch__track::after{background:#d7bbff;background:var(--mdc-switch-selected-track-color, #d7bbff)}.mdc-switch:enabled:hover:not(:focus):not(:active) .mdc-switch__track::after{background:#d7bbff;background:var(--mdc-switch-selected-hover-track-color, #d7bbff)}.mdc-switch:enabled:focus:not(:active) .mdc-switch__track::after{background:#d7bbff;background:var(--mdc-switch-selected-focus-track-color, #d7bbff)}.mdc-switch:enabled:active .mdc-switch__track::after{background:#d7bbff;background:var(--mdc-switch-selected-pressed-track-color, #d7bbff)}.mdc-switch:disabled .mdc-switch__track::after{background:#424242;background:var(--mdc-switch-disabled-selected-track-color, #424242)}.mdc-switch:enabled .mdc-switch__track::before{background:#e0e0e0;background:var(--mdc-switch-unselected-track-color, #e0e0e0)}.mdc-switch:enabled:hover:not(:focus):not(:active) .mdc-switch__track::before{background:#e0e0e0;background:var(--mdc-switch-unselected-hover-track-color, #e0e0e0)}.mdc-switch:enabled:focus:not(:active) .mdc-switch__track::before{background:#e0e0e0;background:var(--mdc-switch-unselected-focus-track-color, #e0e0e0)}.mdc-switch:enabled:active .mdc-switch__track::before{background:#e0e0e0;background:var(--mdc-switch-unselected-pressed-track-color, #e0e0e0)}.mdc-switch:disabled .mdc-switch__track::before{background:#424242;background:var(--mdc-switch-disabled-unselected-track-color, #424242)}.mdc-switch .mdc-switch__track{border-radius:7px;border-radius:var(--mdc-switch-track-shape, 7px)}.mdc-switch.mdc-switch--selected{--mdc-ripple-focus-state-layer-color:var(--mdc-switch-selected-focus-state-layer-color, var(--mdc-theme-primary, #6200ee));--mdc-ripple-focus-state-layer-opacity:var(--mdc-switch-selected-focus-state-layer-opacity, 0.12);--mdc-ripple-hover-state-layer-color:var(--mdc-switch-selected-hover-state-layer-color, var(--mdc-theme-primary, #6200ee));--mdc-ripple-hover-state-layer-opacity:var(--mdc-switch-selected-hover-state-layer-opacity, 0.04);--mdc-ripple-pressed-state-layer-color:var(--mdc-switch-selected-pressed-state-layer-color, var(--mdc-theme-primary, #6200ee));--mdc-ripple-pressed-state-layer-opacity:var(--mdc-switch-selected-pressed-state-layer-opacity, 0.1)}.mdc-switch.mdc-switch--selected:enabled:focus:not(:active){--mdc-ripple-hover-state-layer-color:var(--mdc-switch-selected-focus-state-layer-color, var(--mdc-theme-primary, #6200ee))}.mdc-switch.mdc-switch--selected:enabled:active{--mdc-ripple-hover-state-layer-color:var(--mdc-switch-selected-pressed-state-layer-color, var(--mdc-theme-primary, #6200ee))}.mdc-switch.mdc-switch--unselected{--mdc-ripple-focus-state-layer-color:var(--mdc-switch-unselected-focus-state-layer-color, #424242);--mdc-ripple-focus-state-layer-opacity:var(--mdc-switch-unselected-focus-state-layer-opacity, 0.12);--mdc-ripple-hover-state-layer-color:var(--mdc-switch-unselected-hover-state-layer-color, #424242);--mdc-ripple-hover-state-layer-opacity:var(--mdc-switch-unselected-hover-state-layer-opacity, 0.04);--mdc-ripple-pressed-state-layer-color:var(--mdc-switch-unselected-pressed-state-layer-color, #424242);--mdc-ripple-pressed-state-layer-opacity:var(--mdc-switch-unselected-pressed-state-layer-opacity, 0.1)}.mdc-switch.mdc-switch--unselected:enabled:focus:not(:active){--mdc-ripple-hover-state-layer-color:var(--mdc-switch-unselected-focus-state-layer-color, #424242)}.mdc-switch.mdc-switch--unselected:enabled:active{--mdc-ripple-hover-state-layer-color:var(--mdc-switch-unselected-pressed-state-layer-color, #424242)}@media screen and (forced-colors: active),(-ms-high-contrast: active){.mdc-switch:disabled .mdc-switch__handle::after{opacity:1;opacity:var(--mdc-switch-disabled-handle-opacity, 1)}.mdc-switch.mdc-switch--selected:enabled .mdc-switch__icon{fill:ButtonText;fill:var(--mdc-switch-selected-icon-color, ButtonText)}.mdc-switch.mdc-switch--selected:disabled .mdc-switch__icon{fill:GrayText;fill:var(--mdc-switch-disabled-selected-icon-color, GrayText)}.mdc-switch.mdc-switch--unselected:enabled .mdc-switch__icon{fill:ButtonText;fill:var(--mdc-switch-unselected-icon-color, ButtonText)}.mdc-switch.mdc-switch--unselected:disabled .mdc-switch__icon{fill:GrayText;fill:var(--mdc-switch-disabled-unselected-icon-color, GrayText)}.mdc-switch.mdc-switch--selected:disabled .mdc-switch__icons{opacity:1;opacity:var(--mdc-switch-disabled-selected-icon-opacity, 1)}.mdc-switch.mdc-switch--unselected:disabled .mdc-switch__icons{opacity:1;opacity:var(--mdc-switch-disabled-unselected-icon-opacity, 1)}.mdc-switch:disabled .mdc-switch__track{opacity:1;opacity:var(--mdc-switch-disabled-track-opacity, 1)}}`; + + // node_modules/@material/mwc-switch/mwc-switch.js + var Switch = class Switch2 extends SwitchBase { + }; + Switch.styles = [styles13]; + Switch = __decorate([ + e12("mwc-switch") + ], Switch); + + // client/components/settings.css + var styles14 = i`#settings-panel { + background-color: var(--comparator-greygreen-100); + border-right: 2px solid var(--comparator-greygreen-200); + display: flex; + flex-direction: column; + height: 100%; + overflow-y: auto; + padding: 0 10px 0 20px; + width: 184px; +} + +.panel-title { + align-items: center; + display: flex; + font-size: 16px; + justify-content: space-between; + margin: 30px 0 20px; +} + +.section-title { + margin-top: 20px; + font-size: 13px; + padding: 5px 0; +} + +.settings-row { + display: flex; + gap: 5px; + padding: 10px 0; +} + +mwc-switch { + --mdc-switch-selected-handle-color: var(--comparator-greygreen-700); + --mdc-switch-selected-track-color: var(--comparator-greygreen-300); + --mdc-switch-selected-hover-handle-color: var(--comparator-greygreen-700); + --mdc-switch-selected-hover-track-color: var(--comparator-greygreen-300); + --mdc-switch-selected-focus-handle-color: var(--comparator-greygreen-700); + --mdc-switch-selected-focus-track-color: var(--comparator-greygreen-300); + --mdc-switch-selected-pressed-handle-color: var(--comparator-greygreen-700); + --mdc-switch-selected-pressed-track-color: var(--comparator-greygreen-300); + /* Hide the ripple effect. */ + --mdc-switch-selected-focus-state-layer-opacity: 0; + --mdc-switch-selected-hover-state-layer-opacity: 0; + --mdc-switch-selected-pressed-state-layer-opacity: 0; + --mdc-switch-unselected-focus-state-layer-opacity: 0; + --mdc-switch-unselected-hover-state-layer-opacity: 0; + --mdc-switch-unselected-pressed-state-layer-opacity: 0; +} +`; + + // client/components/settings.ts + var NumericInput = class extends s3 { + constructor() { + super(...arguments); + this.min = 1; + this.max = 20; + this.step = 1; + this.value = 5; + } + render() { + const onInputChange = (e33) => { + const { value } = e33.target; + const numberValue = Number(value); + if (numberValue < this.min) { + this.value = this.min; + } else if (numberValue > this.max) { + this.value = this.max; + } else { + this.value = numberValue; + } + this.dispatchEvent(new Event("change")); + }; + return x` `; + } + }; + NumericInput.styles = i` + input { + width: 40px; + } + `; + __decorateClass([ + n4({ type: Number }) + ], NumericInput.prototype, "min", 2); + __decorateClass([ + n4({ type: Number }) + ], NumericInput.prototype, "max", 2); + __decorateClass([ + n4({ type: Number }) + ], NumericInput.prototype, "step", 2); + __decorateClass([ + n4({ type: Number }) + ], NumericInput.prototype, "value", 2); + NumericInput = __decorateClass([ + t3("comparator-numeric-input") + ], NumericInput); + var ComparatorSettingsElement = class extends MobxLitElement { + constructor() { + super(...arguments); + this.appState = core.getService(AppState); + } + static get styles() { + return [styles, styles14]; + } + renderMainToggles() { + const handleChangeRationaleClusterSimilarityThreshold = (e33) => { + this.appState.rationaleClusterSimilarityThreshold = Number(e33.target.value); + this.appState.reassignClusters(); + }; + return x`
    + this.appState.isShowTextDiff = !this.appState.isShowTextDiff}> + + +
    + +
    + this.appState.useMonospace = !this.appState.useMonospace}> + + +
    + +
    + this.appState.numberOfLinesPerOutputCell = Number( + e33.target.value + )}> + + +
    + +
    + this.appState.numExamplesToDisplay = Number( + e33.target.value + )}> + + +
    + +
    + this.appState.isShowTagChips = !this.appState.isShowTagChips}> + + +
    + +
    + this.appState.isFlipScoreHistogramAxis = !this.appState.isFlipScoreHistogramAxis}> + + +
    + +
    + this.appState.winRateThreshold = Number( + e33.target.value + )}> + + +
    + + ${this.appState.hasRationaleClusters === true ? x` +
    + + + +
    ` : x``} + +
    + this.appState.isShowSidebar = !this.appState.isShowSidebar}> + + +
    `; + } + renderColumnVisibilityToggles() { + const renderColumnToggle = (field) => x`
    + field.visible = !field.visible}> + + +
    `; + return x`
    + ${this.appState.columns.map((field) => renderColumnToggle(field))} +
    `; + } + render() { + return x` +
    +
    + Settings + this.appState.isOpenSettingsPanel = false}> + close + +
    + +
    + ${this.renderMainToggles()} +
    + +
    +
    + Table Column Visibility +
    + ${this.renderColumnVisibilityToggles()} +
    +
    `; + } + }; + ComparatorSettingsElement = __decorateClass([ + t3("comparator-settings") + ], ComparatorSettingsElement); + + // client/components/toolbar.css + var styles15 = i`#toolbar { + align-items: center; + background-color: var(--comparator-green-200); + border-radius: 20px; + display: flex; + height: 18px; + justify-content: space-between; + margin: 7px 16px 8px 15px; + overflow-x: clip; + padding: 6px 12px 4px; +} + +.toolbar-item { + align-items: center; + display: flex; + flex: 0 0 auto; + margin: 0 15px; +} + +.toolbar-item input { + margin-bottom: 0; + margin-top: 0; +} + +.toolbar-item.example-count { + text-align: right; /* to make "(N total)" stay in the same pos */ + width: 240px; /* space for four-digit counts */ +} + +.toolbar-item.example-count span { + margin-left: auto; +} + +.toolbar-item.filters { + margin-right: auto; +} + +.toolbar-item label { + margin-right: 3px; +} +`; + + // client/components/toolbar.ts + var ToolbarElement = class extends MobxLitElement { + constructor() { + super(...arguments); + this.appState = core.getService(AppState); + } + static get styles() { + return [styles, styles15]; + } + renderFilterChip(label, handleClickCancel) { + return x`
    + ${label} + + cancel + +
    `; + } + renderFilterChips() { + const chipForTag = this.appState.selectedTag != null ? this.renderFilterChip( + `Categories contain "${this.appState.selectedTag}"`, + () => { + this.appState.selectedTag = null; + } + ) : ""; + const chipForSearch = Object.entries(this.appState.searchFilters).filter(([fieldId, stringToSearch]) => stringToSearch !== "").map(([fieldId, stringToSearch]) => { + const field = this.appState.getFieldFromId(fieldId); + return this.renderFilterChip( + `${field ? field.name : fieldId} matches "${stringToSearch}"`, + () => { + this.appState.resetSearchFilter(fieldId); + } + ); + }); + const chipForScore = this.appState.selectedHistogramBinForScores != null ? this.renderFilterChip( + `${getHistogramFilterLabel( + "score", + this.appState.histogramSpecForScores, + this.appState.selectedHistogramBinForScores + )}`, + () => { + this.appState.selectedHistogramBinForScores = null; + } + ) : ""; + const chipsForCustomFuncs = Object.values( + this.appState.customFunctions + ).flatMap((customFunc) => { + const selections = this.appState.selectionsFromCustomFuncResults[customFunc.id]; + return Object.entries(selections).filter(([key, value]) => value != null).map(([key, value]) => { + const histogramSpec = customFunc.returnType === "Number" /* NUMBER */ ? key === "A-B" ? this.appState.histogramSpecForCustomFuncsOfDiff[customFunc.id] : this.appState.histogramSpecForCustomFuncs[customFunc.id] : null; + const label = customFunc.returnType === "Boolean" /* BOOLEAN */ ? getBarFilterLabel( + customFunc.name, + key, + selections[key] + ) : getHistogramFilterLabel( + customFunc.name, + histogramSpec, + selections[key], + key + ); + const cancelCallback = () => { + selections[key] = null; + }; + return this.renderFilterChip(label, cancelCallback); + }); + }); + const chipsForHistogramsForCustomFields = this.appState.customFieldsOfNumberType.filter( + (field) => this.appState.selectedHistogramBinForCustomFields[field.id] != null + ).map( + (field) => this.renderFilterChip( + getHistogramFilterLabel( + field.name, + this.appState.histogramSpecForCustomFields[field.id], + this.appState.selectedHistogramBinForCustomFields[field.id] + ), + () => { + this.appState.selectedHistogramBinForCustomFields[field.id] = null; + } + ) + ); + const chipsForSideBySideHistograms = this.appState.customFieldsOfPerModelNumberType.flatMap((field) => { + const selections = this.appState.selectedHistogramBinForCustomFields[field.id]; + return Object.values(AOrB).filter((model) => selections[model] != null).map((model) => { + const label = getHistogramFilterLabel( + field.name, + this.appState.histogramSpecForCustomFields[field.id], + selections[model], + model + ); + const cancelCallback = () => { + selections[model] = null; + }; + return this.renderFilterChip(label, cancelCallback); + }); + }); + const chipsForBarChartsForCustomFields = this.appState.customFieldsOfCategoryType.filter( + (field) => this.appState.selectedBarChartValues[field.id][0] != null + ).map( + (field) => this.renderFilterChip( + `${field.name} = "${this.appState.selectedBarChartValues[field.id][0]}"`, + () => { + this.appState.selectedBarChartValues[field.id][0] = null; + } + ) + ); + const chipsForGroupedBarChartsForCustomFields = this.appState.customFieldsOfPerModelCategoryTypeIncludingPerRating.flatMap( + (field) => { + const selection = this.appState.selectedBarChartValues[field.id]; + return Object.values(AOrB).map((model, groupIndex) => [model, groupIndex]).filter( + ([model, groupIndex]) => selection[groupIndex] != null + ).map(([model, groupIndex]) => { + const isPerRating = field.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */; + const operator = isPerRating === true ? "has" : "="; + return this.renderFilterChip( + `${field.name}(${model}) ${operator} "${selection[groupIndex]}"`, + () => { + selection[groupIndex] = null; + } + ); + }); + } + ); + const chipForRationaleCluster = this.appState.selectedRationaleClusterId != null ? this.renderFilterChip( + `Rationale Cluster = "${this.appState.rationaleClusters.filter( + (cluster) => cluster.id === this.appState.selectedRationaleClusterId + )[0].title}"`, + () => { + this.appState.selectedRationaleClusterId = null; + } + ) : ""; + return x` ${chipForTag} ${chipForSearch} ${chipForScore} + ${chipsForCustomFuncs} ${chipForRationaleCluster} + ${chipsForHistogramsForCustomFields} ${chipsForSideBySideHistograms} + ${chipsForBarChartsForCustomFields} + ${chipsForGroupedBarChartsForCustomFields}`; + } + render() { + const totalNum = this.appState.examples.length; + const filteredNum = this.appState.filteredExamples.length; + const shownNum = this.appState.examplesForMainTable.length; + const renderFilterChips = this.renderFilterChips(); + const isAnyFilter = filteredNum < totalNum; + const currentSorting = this.appState.currentSorting; + return x` +
    +
    + + ${shownNum} displayed + ${filteredNum !== totalNum ? x` + of ${this.appState.filteredExamples.length} + filtered` : ""} + (${totalNum} total) + +
    + +
    + ${isAnyFilter === true ? x` ${renderFilterChips}` : ""} +
    + + ${currentSorting.column !== "None" /* NONE */ ? x` +
    + + + + ${currentSorting.column === "custom attribute" /* CUSTOM_ATTRIBUTE */ ? currentSorting.customField.name : currentSorting.column} + ${currentSorting.modelIndex != null ? ` for Response ${Object.values(AOrB)[currentSorting.modelIndex]}` : ""} + + ${currentSorting.order} + +
    ` : ""} +
    `; + } + }; + ToolbarElement = __decorateClass([ + t3("comparator-toolbar") + ], ToolbarElement); + + // client/app.ts + var LlmComparatorAppElement = class extends MobxLitElement { + constructor() { + super(); + this.appState = core.getService(AppState); + this.isShowFeedbackTooltip = false; + makeObservable(this); + } + static get styles() { + return [styles, i``]; + } + renderHeader() { + const toggleSettingsIcon = () => { + this.appState.isOpenSettingsPanel = !this.appState.isOpenSettingsPanel; + }; + const feedbackLink = "https://github.com/PAIR-code/llm-comparator/issues"; + const documentationLink = "https://github.com/PAIR-code/llm-comparator"; + const handleClickLoadData = () => { + this.appState.isOpenDatasetSelectionPanel = !this.appState.isOpenDatasetSelectionPanel; + }; + const renderLoadDataLink = x` + `; + return x` + `; + } + renderStatusMessage() { + return x` +
    +
    ${this.appState.statusMessage}
    +
    this.appState.isOpenStatusMessage = false}> + Dismiss +
    +
    `; + } + renderSidebar() { + const components = x` + + + + + `; + return x``; + } + render() { + const styleExampleDetailsPanel = e6({ + "expanded": this.appState.exampleDetailsPanelExpanded === true + }); + return x` +
    + ${this.renderHeader()} +
    + + ${this.appState.isOpenSettingsPanel === true ? x`` : ""} +
    + +
    + +
    + ${this.appState.showSelectedExampleDetails === true && this.appState.selectedExample != null ? x` +
    + +
    ` : ""} +
    + ${this.appState.isShowSidebar === true ? this.renderSidebar() : ""} +
    + ${this.appState.isOpenStatusMessage === true ? this.renderStatusMessage() : ""} +
    `; + } + }; + __decorateClass([ + observable + ], LlmComparatorAppElement.prototype, "isShowFeedbackTooltip", 2); + LlmComparatorAppElement = __decorateClass([ + t3("llm-comparator-app") + ], LlmComparatorAppElement); + + // client/index.ts + async function main() { + window.addEventListener("load", () => { + core.initialize(); + }); + j( + x``, + document.querySelector("#app-container") + ); + } + main(); +})(); +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*! Bundled license information: + +@lit/reactive-element/css-tag.js: + (** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/reactive-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/lit-html.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-element/lit-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/is-server.js: + (** + * @license + * Copyright 2022 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/custom-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/property.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/state.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/event-options.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/base.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-all.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-async.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-assigned-elements.js: + (** + * @license + * Copyright 2021 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-assigned-nodes.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/directive.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/directives/class-map.js: + (** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/css-tag.js: + (** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/reactive-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/lit-html.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-element/lit-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/is-server.js: + (** + * @license + * Copyright 2022 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/custom-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/property.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/state.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/base.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/event-options.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-all.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-async.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-assigned-elements.js: + (** + * @license + * Copyright 2021 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-assigned-nodes.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@material/mwc-icon/mwc-icon-host.css.js: + (** + * @license + * Copyright 2021 Google LLC + * SPDX-LIcense-Identifier: Apache-2.0 + *) + +@material/mwc-icon/mwc-icon.js: + (** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: Apache-2.0 + *) + +lit-html/directives/style-map.js: + (** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/custom-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/property.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/state.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/base.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/event-options.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-all.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-async.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-assigned-elements.js: + (** + * @license + * Copyright 2021 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-assigned-nodes.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/custom-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/property.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/state.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/base.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/event-options.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-all.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-async.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-assigned-elements.js: + (** + * @license + * Copyright 2021 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-assigned-nodes.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@material/dom/ponyfill.js: + (** + * @license + * Copyright 2018 Google Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + *) + +@lit/reactive-element/css-tag.js: + (** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/reactive-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/lit-html.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-element/lit-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/is-server.js: + (** + * @license + * Copyright 2022 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@material/mwc-base/utils.js: + (** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: Apache-2.0 + *) + +@material/mwc-base/base-element.js: + (** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: Apache-2.0 + *) + +@material/base/foundation.js: + (** + * @license + * Copyright 2016 Google Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + *) + +@material/ripple/constants.js: + (** + * @license + * Copyright 2016 Google Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + *) + +@material/ripple/foundation.js: + (** + * @license + * Copyright 2016 Google Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + *) + +@lit/reactive-element/css-tag.js: + (** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/reactive-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/lit-html.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-element/lit-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/is-server.js: + (** + * @license + * Copyright 2022 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/directive.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/directives/class-map.js: + (** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/directives/style-map.js: + (** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@material/mwc-ripple/mwc-ripple-base.js: + (** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: Apache-2.0 + *) + +@material/mwc-ripple/mwc-ripple.css.js: + (** + * @license + * Copyright 2021 Google LLC + * SPDX-LIcense-Identifier: Apache-2.0 + *) + +@material/mwc-ripple/mwc-ripple.js: + (** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: Apache-2.0 + *) + +@material/mwc-base/aria-property.js: + (** + * @license + * Copyright 2021 Google LLC + * SPDX-License-Identifier: Apache-2.0 + *) + +@lit/reactive-element/decorators/custom-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/property.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/state.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/base.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/event-options.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-all.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-async.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-assigned-elements.js: + (** + * @license + * Copyright 2021 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-assigned-nodes.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@material/mwc-base/form-element.js: + (** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: Apache-2.0 + *) + +@material/mwc-ripple/ripple-handlers.js: + (** + * @license + * Copyright 2020 Google LLC + * SPDX-License-Identifier: Apache-2.0 + *) + +@material/base/observer.js: + (** + * @license + * Copyright 2021 Google Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + *) + +@material/base/observer-foundation.js: + (** + * @license + * Copyright 2021 Google Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + *) + +@material/switch/constants.js: + (** + * @license + * Copyright 2021 Google Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + *) + +@material/switch/foundation.js: + (** + * @license + * Copyright 2021 Google Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + *) + +@lit/reactive-element/css-tag.js: + (** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/reactive-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/lit-html.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-element/lit-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/is-server.js: + (** + * @license + * Copyright 2022 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/directive.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/directives/class-map.js: + (** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/directives/if-defined.js: + (** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@material/mwc-switch/mwc-switch-base.js: + (** + * @license + * Copyright 2021 Google LLC + * SPDX-License-Identifier: Apache-2.0 + *) + +@material/mwc-switch/styles.css.js: + (** + * @license + * Copyright 2021 Google LLC + * SPDX-LIcense-Identifier: Apache-2.0 + *) + +@material/mwc-switch/mwc-switch.js: + (** + * @license + * Copyright 2021 Google LLC + * SPDX-License-Identifier: Apache-2.0 + *) +*/ +//# sourceMappingURL=dev_sources.concat.js.map diff --git a/docs/dev_sources.concat.js.map b/docs/dev_sources.concat.js.map new file mode 100644 index 0000000..f4541e8 --- /dev/null +++ b/docs/dev_sources.concat.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": ["../node_modules/jsdifflib/index.js", "../node_modules/jstat/dist/jstat.js", "../node_modules/@adobe/lit-mobx/src/lib/mixin-custom.ts", "../node_modules/mobx/src/errors.ts", "../node_modules/mobx/src/utils/global.ts", "../node_modules/mobx/src/utils/utils.ts", "../node_modules/mobx/src/api/decorators.ts", "../node_modules/mobx/src/core/atom.ts", "../node_modules/mobx/src/utils/comparer.ts", "../node_modules/mobx/src/types/modifiers.ts", "../node_modules/mobx/src/types/overrideannotation.ts", "../node_modules/mobx/src/types/actionannotation.ts", "../node_modules/mobx/src/types/flowannotation.ts", "../node_modules/mobx/src/types/computedannotation.ts", "../node_modules/mobx/src/types/observableannotation.ts", "../node_modules/mobx/src/types/autoannotation.ts", "../node_modules/mobx/src/api/observable.ts", "../node_modules/mobx/src/api/computed.ts", "../node_modules/mobx/src/core/action.ts", "../node_modules/mobx/src/types/observablevalue.ts", "../node_modules/mobx/src/core/computedvalue.ts", "../node_modules/mobx/src/core/derivation.ts", "../node_modules/mobx/src/core/globalstate.ts", "../node_modules/mobx/src/core/observable.ts", "../node_modules/mobx/src/core/reaction.ts", "../node_modules/mobx/src/core/spy.ts", "../node_modules/mobx/src/api/action.ts", "../node_modules/mobx/src/api/autorun.ts", "../node_modules/mobx/src/api/become-observed.ts", "../node_modules/mobx/src/api/configure.ts", "../node_modules/mobx/src/api/extendobservable.ts", "../node_modules/mobx/src/api/extras.ts", "../node_modules/mobx/src/api/flow.ts", "../node_modules/mobx/src/api/intercept-read.ts", "../node_modules/mobx/src/api/intercept.ts", "../node_modules/mobx/src/api/iscomputed.ts", "../node_modules/mobx/src/api/isobservable.ts", "../node_modules/mobx/src/api/object-api.ts", "../node_modules/mobx/src/api/observe.ts", "../node_modules/mobx/src/api/tojs.ts", "../node_modules/mobx/src/api/trace.ts", "../node_modules/mobx/src/api/transaction.ts", "../node_modules/mobx/src/api/when.ts", "../node_modules/mobx/src/types/dynamicobject.ts", "../node_modules/mobx/src/types/intercept-utils.ts", "../node_modules/mobx/src/types/listen-utils.ts", "../node_modules/mobx/src/api/makeObservable.ts", "../node_modules/mobx/src/types/observablearray.ts", "../node_modules/mobx/src/types/observablemap.ts", "../node_modules/mobx/src/types/observableset.ts", "../node_modules/mobx/src/types/observableobject.ts", "../node_modules/mobx/src/types/legacyobservablearray.ts", "../node_modules/mobx/src/types/type-utils.ts", "../node_modules/mobx/src/utils/eq.ts", "../node_modules/mobx/src/utils/iterable.ts", "../node_modules/mobx/src/api/annotation.ts", "../node_modules/mobx/src/mobx.ts", "../node_modules/@adobe/lit-mobx/src/lib/mixin.ts", "../node_modules/@lit/reactive-element/src/css-tag.ts", "../node_modules/@lit/reactive-element/src/reactive-element.ts", "../node_modules/lit-html/src/lit-html.ts", "../node_modules/lit-element/src/lit-element.ts", "../node_modules/@adobe/lit-mobx/src/lit-mobx.ts", "../node_modules/@lit/reactive-element/src/decorators/custom-element.ts", "../node_modules/@lit/reactive-element/src/decorators/property.ts", "../node_modules/lit-html/src/directive.ts", "../node_modules/lit-html/src/directives/class-map.ts", "../client/lib/shared_styles.css", "../client/components/bar_chart.css", "../client/components/bar_chart.ts", "../client/lib/types.ts", "../client/lib/constants.ts", "../client/lib/utils.ts", "../client/components/histogram.css", "../client/components/histogram.ts", "../client/services/service.ts", "../client/services/custom_function_service.ts", "../client/services/state_service.ts", "../client/core.ts", "../client/components/charts.ts", "../client/components/custom_functions.css", "../client/components/custom_functions.ts", "../client/components/dataset_selection.css", "../client/components/dataset_selection.ts", "../client/components/example_details.css", "../client/components/example_details.ts", "../node_modules/tslib/tslib.es6.mjs", "../node_modules/@material/mwc-icon/node_modules/@lit/reactive-element/src/css-tag.ts", "../node_modules/@material/mwc-icon/node_modules/@lit/reactive-element/src/reactive-element.ts", "../node_modules/@material/mwc-icon/node_modules/lit-html/src/lit-html.ts", "../node_modules/@material/mwc-icon/node_modules/lit-element/src/lit-element.ts", "../node_modules/@material/mwc-icon/node_modules/@lit/reactive-element/src/decorators/custom-element.ts", "../node_modules/@material/mwc-icon/node_modules/@lit/reactive-element/src/decorators/query-assigned-elements.ts", "../node_modules/@material/mwc-icon/mwc-icon-host.css.ts", "../node_modules/@material/mwc-icon/mwc-icon.ts", "../node_modules/lit-html/src/directives/style-map.ts", "../client/components/example_table.css", "../client/components/example_table.ts", "../client/components/metrics_by_slice.css", "../client/components/metrics_by_slice.ts", "../client/components/rationale_summary.css", "../client/components/rationale_summary.ts", "../client/components/score_histogram.css", "../client/components/score_histogram.ts", "../node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/src/decorators/custom-element.ts", "../node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/src/decorators/property.ts", "../node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/src/decorators/state.ts", "../node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/src/decorators/base.ts", "../node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/src/decorators/event-options.ts", "../node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/src/decorators/query.ts", "../node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/src/decorators/query-async.ts", "../node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/src/decorators/query-assigned-elements.ts", "../node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/src/decorators/custom-element.ts", "../node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/src/decorators/property.ts", "../node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/src/decorators/state.ts", "../node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/src/decorators/base.ts", "../node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/src/decorators/query.ts", "../node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/src/decorators/query-assigned-elements.ts", "../node_modules/@material/dom/ponyfill.ts", "../node_modules/@material/mwc-base/node_modules/@lit/reactive-element/src/css-tag.ts", "../node_modules/@material/mwc-base/node_modules/@lit/reactive-element/src/reactive-element.ts", "../node_modules/@material/mwc-base/node_modules/lit-html/src/lit-html.ts", "../node_modules/@material/mwc-base/node_modules/lit-element/src/lit-element.ts", "../node_modules/@material/mwc-base/utils.ts", "../node_modules/@material/mwc-base/base-element.ts", "../node_modules/@material/base/foundation.ts", "../node_modules/@material/ripple/constants.ts", "../node_modules/@material/ripple/util.ts", "../node_modules/@material/ripple/foundation.ts", "../node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/src/css-tag.ts", "../node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/src/reactive-element.ts", "../node_modules/@material/mwc-ripple/node_modules/lit-html/src/lit-html.ts", "../node_modules/@material/mwc-ripple/node_modules/lit-element/src/lit-element.ts", "../node_modules/@material/mwc-ripple/node_modules/lit-html/src/directive.ts", "../node_modules/@material/mwc-ripple/node_modules/lit-html/src/directives/class-map.ts", "../node_modules/@material/mwc-ripple/node_modules/lit-html/src/directives/style-map.ts", "../node_modules/@material/mwc-ripple/mwc-ripple-base.ts", "../node_modules/@material/mwc-ripple/mwc-ripple.css.ts", "../node_modules/@material/mwc-ripple/mwc-ripple.ts", "../node_modules/@material/mwc-base/aria-property.ts", "../node_modules/@material/mwc-base/node_modules/@lit/reactive-element/src/decorators/property.ts", "../node_modules/@material/mwc-base/node_modules/@lit/reactive-element/src/decorators/query-assigned-elements.ts", "../node_modules/@material/mwc-base/form-element.ts", "../node_modules/@material/mwc-ripple/ripple-handlers.ts", "../node_modules/@material/base/observer.ts", "../node_modules/@material/base/observer-foundation.ts", "../node_modules/@material/switch/constants.ts", "../node_modules/@material/switch/foundation.ts", "../node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/src/css-tag.ts", "../node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/src/reactive-element.ts", "../node_modules/@material/mwc-switch/node_modules/lit-html/src/lit-html.ts", "../node_modules/@material/mwc-switch/node_modules/lit-element/src/lit-element.ts", "../node_modules/@material/mwc-switch/node_modules/lit-html/src/directive.ts", "../node_modules/@material/mwc-switch/node_modules/lit-html/src/directives/class-map.ts", "../node_modules/@material/mwc-switch/node_modules/lit-html/src/directives/if-defined.ts", "../node_modules/@material/mwc-switch/mwc-switch-base.ts", "../node_modules/@material/mwc-switch/styles.css.ts", "../node_modules/@material/mwc-switch/mwc-switch.ts", "../client/components/settings.css", "../client/components/settings.ts", "../client/components/toolbar.css", "../client/components/toolbar.ts", "../client/app.ts", "../client/index.ts"], + "sourcesContent": ["/***\r\nThis is part of jsdifflib v1.0. \r\n\r\nCopyright (c) 2007, Snowtide Informatics Systems, Inc.\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n * Redistributions in binary form must reproduce the above copyright notice,\r\n this list of conditions and the following disclaimer in the documentation\r\n and/or other materials provided with the distribution.\r\n * Neither the name of the Snowtide Informatics Systems nor the names of its\r\n contributors may be used to endorse or promote products derived from this\r\n software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY\r\nEXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\r\nOF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT\r\nSHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r\nTO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\r\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\nCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r\nANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH\r\nDAMAGE.\r\n***/\r\n/* Author: Chas Emerick */\r\n__whitespace = {\" \":true, \"\\t\":true, \"\\n\":true, \"\\f\":true, \"\\r\":true};\r\n\r\nvar difflib = module.exports = {\r\n defaultJunkFunction: function (c) {\r\n return __whitespace.hasOwnProperty(c);\r\n },\r\n \r\n stripLinebreaks: function (str) { return str.replace(/^[\\n\\r]*|[\\n\\r]*$/g, \"\"); },\r\n \r\n stringAsLines: function (str) {\r\n var lfpos = str.indexOf(\"\\n\");\r\n var crpos = str.indexOf(\"\\r\");\r\n var linebreak = ((lfpos > -1 && crpos > -1) || crpos < 0) ? \"\\n\" : \"\\r\";\r\n \r\n var lines = str.split(linebreak);\r\n for (var i = 0; i < lines.length; i++) {\r\n lines[i] = difflib.stripLinebreaks(lines[i]);\r\n }\r\n \r\n return lines;\r\n },\r\n \r\n // iteration-based reduce implementation\r\n __reduce: function (func, list, initial) {\r\n if (initial != null) {\r\n var value = initial;\r\n var idx = 0;\r\n } else if (list) {\r\n var value = list[0];\r\n var idx = 1;\r\n } else {\r\n return null;\r\n }\r\n \r\n for (; idx < list.length; idx++) {\r\n value = func(value, list[idx]);\r\n }\r\n \r\n return value;\r\n },\r\n \r\n // comparison function for sorting lists of numeric tuples\r\n __ntuplecomp: function (a, b) {\r\n var mlen = Math.max(a.length, b.length);\r\n for (var i = 0; i < mlen; i++) {\r\n if (a[i] < b[i]) return -1;\r\n if (a[i] > b[i]) return 1;\r\n }\r\n \r\n return a.length == b.length ? 0 : (a.length < b.length ? -1 : 1);\r\n },\r\n \r\n __calculate_ratio: function (matches, length) {\r\n return length ? 2.0 * matches / length : 1.0;\r\n },\r\n \r\n // returns a function that returns true if a key passed to the returned function\r\n // is in the dict (js object) provided to this function; replaces being able to\r\n // carry around dict.has_key in python...\r\n __isindict: function (dict) {\r\n return function (key) { return dict.hasOwnProperty(key); };\r\n },\r\n \r\n // replacement for python's dict.get function -- need easy default values\r\n __dictget: function (dict, key, defaultValue) {\r\n return dict.hasOwnProperty(key) ? dict[key] : defaultValue;\r\n }, \r\n \r\n SequenceMatcher: function (a, b, isjunk) {\r\n this.set_seqs = function (a, b) {\r\n this.set_seq1(a);\r\n this.set_seq2(b);\r\n }\r\n \r\n this.set_seq1 = function (a) {\r\n if (a == this.a) return;\r\n this.a = a;\r\n this.matching_blocks = this.opcodes = null;\r\n }\r\n \r\n this.set_seq2 = function (b) {\r\n if (b == this.b) return;\r\n this.b = b;\r\n this.matching_blocks = this.opcodes = this.fullbcount = null;\r\n this.__chain_b();\r\n }\r\n \r\n this.__chain_b = function () {\r\n var b = this.b;\r\n var n = b.length;\r\n var b2j = this.b2j = {};\r\n var populardict = {};\r\n for (var i = 0; i < b.length; i++) {\r\n var elt = b[i];\r\n if (b2j.hasOwnProperty(elt)) {\r\n var indices = b2j[elt];\r\n if (n >= 200 && indices.length * 100 > n) {\r\n populardict[elt] = 1;\r\n delete b2j[elt];\r\n } else {\r\n indices.push(i);\r\n }\r\n } else {\r\n b2j[elt] = [i];\r\n }\r\n }\r\n \r\n for (var elt in populardict) {\r\n if (populardict.hasOwnProperty(elt)) {\r\n delete b2j[elt];\r\n }\r\n }\r\n \r\n var isjunk = this.isjunk;\r\n var junkdict = {};\r\n if (isjunk) {\r\n for (var elt in populardict) {\r\n if (populardict.hasOwnProperty(elt) && isjunk(elt)) {\r\n junkdict[elt] = 1;\r\n delete populardict[elt];\r\n }\r\n }\r\n for (var elt in b2j) {\r\n if (b2j.hasOwnProperty(elt) && isjunk(elt)) {\r\n junkdict[elt] = 1;\r\n delete b2j[elt];\r\n }\r\n }\r\n }\r\n \r\n this.isbjunk = difflib.__isindict(junkdict);\r\n this.isbpopular = difflib.__isindict(populardict);\r\n }\r\n \r\n this.find_longest_match = function (alo, ahi, blo, bhi) {\r\n var a = this.a;\r\n var b = this.b;\r\n var b2j = this.b2j;\r\n var isbjunk = this.isbjunk;\r\n var besti = alo;\r\n var bestj = blo;\r\n var bestsize = 0;\r\n var j = null;\r\n \r\n var j2len = {};\r\n var nothing = [];\r\n for (var i = alo; i < ahi; i++) {\r\n var newj2len = {};\r\n var jdict = difflib.__dictget(b2j, a[i], nothing);\r\n for (var jkey in jdict) {\r\n if (jdict.hasOwnProperty(jkey)) {\r\n j = jdict[jkey];\r\n if (j < blo) continue;\r\n if (j >= bhi) break;\r\n newj2len[j] = k = difflib.__dictget(j2len, j - 1, 0) + 1;\r\n if (k > bestsize) {\r\n besti = i - k + 1;\r\n bestj = j - k + 1;\r\n bestsize = k;\r\n }\r\n }\r\n }\r\n j2len = newj2len;\r\n }\r\n \r\n while (besti > alo && bestj > blo && !isbjunk(b[bestj - 1]) && a[besti - 1] == b[bestj - 1]) {\r\n besti--;\r\n bestj--;\r\n bestsize++;\r\n }\r\n \r\n while (besti + bestsize < ahi && bestj + bestsize < bhi &&\r\n !isbjunk(b[bestj + bestsize]) &&\r\n a[besti + bestsize] == b[bestj + bestsize]) {\r\n bestsize++;\r\n }\r\n \r\n while (besti > alo && bestj > blo && isbjunk(b[bestj - 1]) && a[besti - 1] == b[bestj - 1]) {\r\n besti--;\r\n bestj--;\r\n bestsize++;\r\n }\r\n \r\n while (besti + bestsize < ahi && bestj + bestsize < bhi && isbjunk(b[bestj + bestsize]) &&\r\n a[besti + bestsize] == b[bestj + bestsize]) {\r\n bestsize++;\r\n }\r\n \r\n return [besti, bestj, bestsize];\r\n }\r\n \r\n this.get_matching_blocks = function () {\r\n if (this.matching_blocks != null) return this.matching_blocks;\r\n var la = this.a.length;\r\n var lb = this.b.length;\r\n \r\n var queue = [[0, la, 0, lb]];\r\n var matching_blocks = [];\r\n var alo, ahi, blo, bhi, qi, i, j, k, x;\r\n while (queue.length) {\r\n qi = queue.pop();\r\n alo = qi[0];\r\n ahi = qi[1];\r\n blo = qi[2];\r\n bhi = qi[3];\r\n x = this.find_longest_match(alo, ahi, blo, bhi);\r\n i = x[0];\r\n j = x[1];\r\n k = x[2];\r\n \r\n if (k) {\r\n matching_blocks.push(x);\r\n if (alo < i && blo < j)\r\n queue.push([alo, i, blo, j]);\r\n if (i+k < ahi && j+k < bhi)\r\n queue.push([i + k, ahi, j + k, bhi]);\r\n }\r\n }\r\n \r\n matching_blocks.sort(difflib.__ntuplecomp);\r\n \r\n var i1 = j1 = k1 = block = 0;\r\n var non_adjacent = [];\r\n for (var idx in matching_blocks) {\r\n if (matching_blocks.hasOwnProperty(idx)) {\r\n block = matching_blocks[idx];\r\n i2 = block[0];\r\n j2 = block[1];\r\n k2 = block[2];\r\n if (i1 + k1 == i2 && j1 + k1 == j2) {\r\n k1 += k2;\r\n } else {\r\n if (k1) non_adjacent.push([i1, j1, k1]);\r\n i1 = i2;\r\n j1 = j2;\r\n k1 = k2;\r\n }\r\n }\r\n }\r\n \r\n if (k1) non_adjacent.push([i1, j1, k1]);\r\n \r\n non_adjacent.push([la, lb, 0]);\r\n this.matching_blocks = non_adjacent;\r\n return this.matching_blocks;\r\n }\r\n \r\n this.get_opcodes = function () {\r\n if (this.opcodes != null) return this.opcodes;\r\n var i = 0;\r\n var j = 0;\r\n var answer = [];\r\n this.opcodes = answer;\r\n var block, ai, bj, size, tag;\r\n var blocks = this.get_matching_blocks();\r\n for (var idx in blocks) {\r\n if (blocks.hasOwnProperty(idx)) {\r\n block = blocks[idx];\r\n ai = block[0];\r\n bj = block[1];\r\n size = block[2];\r\n tag = '';\r\n if (i < ai && j < bj) {\r\n tag = 'replace';\r\n } else if (i < ai) {\r\n tag = 'delete';\r\n } else if (j < bj) {\r\n tag = 'insert';\r\n }\r\n if (tag) answer.push([tag, i, ai, j, bj]);\r\n i = ai + size;\r\n j = bj + size;\r\n \r\n if (size) answer.push(['equal', ai, i, bj, j]);\r\n }\r\n }\r\n \r\n return answer;\r\n }\r\n \r\n // this is a generator function in the python lib, which of course is not supported in javascript\r\n // the reimplementation builds up the grouped opcodes into a list in their entirety and returns that.\r\n this.get_grouped_opcodes = function (n) {\r\n if (!n) n = 3;\r\n var codes = this.get_opcodes();\r\n if (!codes) codes = [[\"equal\", 0, 1, 0, 1]];\r\n var code, tag, i1, i2, j1, j2;\r\n if (codes[0][0] == 'equal') {\r\n code = codes[0];\r\n tag = code[0];\r\n i1 = code[1];\r\n i2 = code[2];\r\n j1 = code[3];\r\n j2 = code[4];\r\n codes[0] = [tag, Math.max(i1, i2 - n), i2, Math.max(j1, j2 - n), j2];\r\n }\r\n if (codes[codes.length - 1][0] == 'equal') {\r\n code = codes[codes.length - 1];\r\n tag = code[0];\r\n i1 = code[1];\r\n i2 = code[2];\r\n j1 = code[3];\r\n j2 = code[4];\r\n codes[codes.length - 1] = [tag, i1, Math.min(i2, i1 + n), j1, Math.min(j2, j1 + n)];\r\n }\r\n \r\n var nn = n + n;\r\n var groups = [];\r\n for (var idx in codes) {\r\n if (codes.hasOwnProperty(idx)) {\r\n code = codes[idx];\r\n tag = code[0];\r\n i1 = code[1];\r\n i2 = code[2];\r\n j1 = code[3];\r\n j2 = code[4];\r\n if (tag == 'equal' && i2 - i1 > nn) {\r\n groups.push([tag, i1, Math.min(i2, i1 + n), j1, Math.min(j2, j1 + n)]);\r\n i1 = Math.max(i1, i2-n);\r\n j1 = Math.max(j1, j2-n);\r\n }\r\n \r\n groups.push([tag, i1, i2, j1, j2]);\r\n }\r\n }\r\n \r\n if (groups && groups[groups.length - 1][0] == 'equal') groups.pop();\r\n \r\n return groups;\r\n }\r\n \r\n this.ratio = function () {\r\n matches = difflib.__reduce(\r\n function (sum, triple) { return sum + triple[triple.length - 1]; },\r\n this.get_matching_blocks(), 0);\r\n return difflib.__calculate_ratio(matches, this.a.length + this.b.length);\r\n }\r\n \r\n this.quick_ratio = function () {\r\n var fullbcount, elt;\r\n if (this.fullbcount == null) {\r\n this.fullbcount = fullbcount = {};\r\n for (var i = 0; i < this.b.length; i++) {\r\n elt = this.b[i];\r\n fullbcount[elt] = difflib.__dictget(fullbcount, elt, 0) + 1;\r\n }\r\n }\r\n fullbcount = this.fullbcount;\r\n \r\n var avail = {};\r\n var availhas = difflib.__isindict(avail);\r\n var matches = numb = 0;\r\n for (var i = 0; i < this.a.length; i++) {\r\n elt = this.a[i];\r\n if (availhas(elt)) {\r\n numb = avail[elt];\r\n } else {\r\n numb = difflib.__dictget(fullbcount, elt, 0);\r\n }\r\n avail[elt] = numb - 1;\r\n if (numb > 0) matches++;\r\n }\r\n \r\n return difflib.__calculate_ratio(matches, this.a.length + this.b.length);\r\n }\r\n \r\n this.real_quick_ratio = function () {\r\n var la = this.a.length;\r\n var lb = this.b.length;\r\n return _calculate_ratio(Math.min(la, lb), la + lb);\r\n }\r\n \r\n this.isjunk = isjunk ? isjunk : difflib.defaultJunkFunction;\r\n this.a = this.b = null;\r\n this.set_seqs(a, b);\r\n },\r\n\r\n /**\r\n * Builds and returns a visual diff view. The single parameter, `params', should contain\r\n * the following values:\r\n *\r\n * - baseText: the string that will be used as the base input to SequenceMatcher\r\n * - nextText: the string that will be used as the new text input to SequenceMatcher\r\n *\r\n * or\r\n *\r\n * - baseTextLines: the array of strings that was used as the base text input to SequenceMatcher\r\n * - newTextLines: the array of strings that was used as the new text input to SequenceMatcher\r\n * - opcodes: the array of arrays returned by SequenceMatcher.get_opcodes()\r\n *\r\n * and:\r\n *\r\n * - baseTextName: the title to be displayed above the base text listing in the diff view; defaults\r\n * to \"Base Text\"\r\n * - newTextName: the title to be displayed above the new text listing in the diff view; defaults\r\n * to \"New Text\"\r\n * - contextSize: the number of lines of context to show around differences; by default, all lines\r\n * are shown\r\n * - inline: if false, a side-by-side diff view is generated (default); if true, an inline diff view is\r\n * generated\r\n */\r\n buildView: function (params) {\r\n var baseTextLines = params.baseTextLines === undefined ?\r\n difflib.stringAsLines(params.baseText) :\r\n params.baseTextLines;\r\n var newTextLines = params.newTextLines === undefined ?\r\n difflib.stringAsLines(params.newText) :\r\n params.newTextLines;\r\n var opcodes = params.opcodes === undefined ?\r\n (new difflib.SequenceMatcher(baseTextLines, newTextLines)).get_opcodes() :\r\n params.opcodes;\r\n var baseTextName = params.baseTextName ? params.baseTextName : \"Base Text\";\r\n var newTextName = params.newTextName ? params.newTextName : \"New Text\";\r\n var contextSize = params.contextSize;\r\n var inline = params.inline || false;\r\n\r\n if (baseTextLines == null)\r\n throw \"Cannot build diff view; baseTextLines is not defined.\";\r\n if (newTextLines == null)\r\n throw \"Cannot build diff view; newTextLines is not defined.\";\r\n if (!opcodes)\r\n throw \"Canno build diff view; opcodes is not defined.\";\r\n \r\n function celt (name, clazz) {\r\n var e = document.createElement(name);\r\n e.className = clazz;\r\n return e;\r\n }\r\n \r\n function telt (name, text) {\r\n var e = document.createElement(name);\r\n e.appendChild(document.createTextNode(text));\r\n return e;\r\n }\r\n \r\n function ctelt (name, clazz, text) {\r\n var e = document.createElement(name);\r\n e.className = clazz;\r\n e.appendChild(document.createTextNode(text));\r\n return e;\r\n }\r\n \r\n var tdata = document.createElement(\"thead\");\r\n var node = document.createElement(\"tr\");\r\n tdata.appendChild(node);\r\n if (inline) {\r\n node.appendChild(document.createElement(\"th\"));\r\n node.appendChild(document.createElement(\"th\"));\r\n node.appendChild(ctelt(\"th\", \"texttitle\", baseTextName + \" vs. \" + newTextName));\r\n } else {\r\n node.appendChild(document.createElement(\"th\"));\r\n node.appendChild(ctelt(\"th\", \"texttitle\", baseTextName));\r\n node.appendChild(document.createElement(\"th\"));\r\n node.appendChild(ctelt(\"th\", \"texttitle\", newTextName));\r\n }\r\n tdata = [tdata];\r\n \r\n var rows = [];\r\n var node2;\r\n \r\n /**\r\n * Adds two cells to the given row; if the given row corresponds to a real\r\n * line number (based on the line index tidx and the endpoint of the \r\n * range in question tend), then the cells will contain the line number\r\n * and the line of text from textLines at position tidx (with the class of\r\n * the second cell set to the name of the change represented), and tidx + 1 will\r\n * be returned. Otherwise, tidx is returned, and two empty cells are added\r\n * to the given row.\r\n */\r\n function addCells (row, tidx, tend, textLines, change) {\r\n if (tidx < tend) {\r\n row.appendChild(telt(\"th\", (tidx + 1).toString()));\r\n row.appendChild(ctelt(\"td\", change, textLines[tidx].replace(/\\t/g, \"\\u00a0\\u00a0\\u00a0\\u00a0\")));\r\n return tidx + 1;\r\n } else {\r\n row.appendChild(document.createElement(\"th\"));\r\n row.appendChild(celt(\"td\", \"empty\"));\r\n return tidx;\r\n }\r\n }\r\n \r\n function addCellsInline (row, tidx, tidx2, textLines, change) {\r\n row.className = change;\r\n row.appendChild(telt(\"th\", tidx == null ? \"\" : (tidx + 1).toString()));\r\n row.appendChild(telt(\"th\", tidx2 == null ? \"\" : (tidx2 + 1).toString()));\r\n row.appendChild(telt(\"td\", textLines[tidx != null ? tidx : tidx2].replace(/\\t/g, \"\\u00a0\\u00a0\\u00a0\\u00a0\")));\r\n }\r\n \r\n for (var idx = 0; idx < opcodes.length; idx++) {\r\n code = opcodes[idx];\r\n change = code[0];\r\n var b = code[1];\r\n var be = code[2];\r\n var n = code[3];\r\n var ne = code[4];\r\n var rowcnt = Math.max(be - b, ne - n);\r\n var toprows = [];\r\n var botrows = [];\r\n for (var i = 0; i < rowcnt; i++) {\r\n // jump ahead if we've alredy provided leading context or if this is the first range\r\n if (contextSize && opcodes.length > 1 && ((idx > 0 && i == contextSize) || (idx == 0 && i == 0)) && change==\"equal\") {\r\n var jump = rowcnt - ((idx == 0 ? 1 : 2) * contextSize);\r\n if (jump > 1) {\r\n toprows.push(node = document.createElement(\"tr\"));\r\n \r\n b += jump;\r\n n += jump;\r\n i += jump - 1;\r\n node.appendChild(telt(\"th\", \"...\"));\r\n if (!inline) node.appendChild(ctelt(\"td\", \"skip\", \"\"));\r\n node.appendChild(telt(\"th\", \"...\"));\r\n node.appendChild(ctelt(\"td\", \"skip\", \"\"));\r\n \r\n // skip last lines if they're all equal\r\n if (idx + 1 == opcodes.length) {\r\n break;\r\n } else {\r\n continue;\r\n }\r\n }\r\n }\r\n \r\n toprows.push(node = document.createElement(\"tr\"));\r\n if (inline) {\r\n if (change == \"insert\") {\r\n addCellsInline(node, null, n++, newTextLines, change);\r\n } else if (change == \"replace\") {\r\n botrows.push(node2 = document.createElement(\"tr\"));\r\n if (b < be) addCellsInline(node, b++, null, baseTextLines, \"delete\");\r\n if (n < ne) addCellsInline(node2, null, n++, newTextLines, \"insert\");\r\n } else if (change == \"delete\") {\r\n addCellsInline(node, b++, null, baseTextLines, change);\r\n } else {\r\n // equal\r\n addCellsInline(node, b++, n++, baseTextLines, change);\r\n }\r\n } else {\r\n b = addCells(node, b, be, baseTextLines, change);\r\n n = addCells(node, n, ne, newTextLines, change);\r\n }\r\n }\r\n\r\n for (var i = 0; i < toprows.length; i++) rows.push(toprows[i]);\r\n for (var i = 0; i < botrows.length; i++) rows.push(botrows[i]);\r\n }\r\n \r\n rows.push(node = ctelt(\"th\", \"author\", \"diff view generated by \"));\r\n node.setAttribute(\"colspan\", inline ? 3 : 4);\r\n node.appendChild(node2 = telt(\"a\", \"jsdifflib\"));\r\n node2.setAttribute(\"href\", \"http://github.com/cemerick/jsdifflib\");\r\n \r\n tdata.push(node = document.createElement(\"tbody\"));\r\n for (var idx in rows) node.appendChild(rows[idx]);\r\n \r\n node = celt(\"table\", \"diff\" + (inline ? \" inlinediff\" : \"\"));\r\n for (var idx in tdata) node.appendChild(tdata[idx]);\r\n return node;\r\n }\r\n}\r\n", "(function (window, factory) {\n if (typeof exports === 'object') {\n module.exports = factory();\n } else if (typeof define === 'function' && define.amd) {\n define(factory);\n } else {\n window.jStat = factory();\n }\n})(this, function () {\nvar jStat = (function(Math, undefined) {\n\n// For quick reference.\nvar concat = Array.prototype.concat;\nvar slice = Array.prototype.slice;\nvar toString = Object.prototype.toString;\n\n// Calculate correction for IEEE error\n// TODO: This calculation can be improved.\nfunction calcRdx(n, m) {\n var val = n > m ? n : m;\n return Math.pow(10,\n 17 - ~~(Math.log(((val > 0) ? val : -val)) * Math.LOG10E));\n}\n\n\nvar isArray = Array.isArray || function isArray(arg) {\n return toString.call(arg) === '[object Array]';\n};\n\n\nfunction isFunction(arg) {\n return toString.call(arg) === '[object Function]';\n}\n\n\nfunction isNumber(num) {\n return (typeof num === 'number') ? num - num === 0 : false;\n}\n\n\n// Converts the jStat matrix to vector.\nfunction toVector(arr) {\n return concat.apply([], arr);\n}\n\n\n// The one and only jStat constructor.\nfunction jStat() {\n return new jStat._init(arguments);\n}\n\n\n// TODO: Remove after all references in src files have been removed.\njStat.fn = jStat.prototype;\n\n\n// By separating the initializer from the constructor it's easier to handle\n// always returning a new instance whether \"new\" was used or not.\njStat._init = function _init(args) {\n // If first argument is an array, must be vector or matrix.\n if (isArray(args[0])) {\n // Check if matrix.\n if (isArray(args[0][0])) {\n // See if a mapping function was also passed.\n if (isFunction(args[1]))\n args[0] = jStat.map(args[0], args[1]);\n // Iterate over each is faster than this.push.apply(this, args[0].\n for (var i = 0; i < args[0].length; i++)\n this[i] = args[0][i];\n this.length = args[0].length;\n\n // Otherwise must be a vector.\n } else {\n this[0] = isFunction(args[1]) ? jStat.map(args[0], args[1]) : args[0];\n this.length = 1;\n }\n\n // If first argument is number, assume creation of sequence.\n } else if (isNumber(args[0])) {\n this[0] = jStat.seq.apply(null, args);\n this.length = 1;\n\n // Handle case when jStat object is passed to jStat.\n } else if (args[0] instanceof jStat) {\n // Duplicate the object and pass it back.\n return jStat(args[0].toArray());\n\n // Unexpected argument value, return empty jStat object.\n // TODO: This is strange behavior. Shouldn't this throw or some such to let\n // the user know they had bad arguments?\n } else {\n this[0] = [];\n this.length = 1;\n }\n\n return this;\n};\njStat._init.prototype = jStat.prototype;\njStat._init.constructor = jStat;\n\n\n// Utility functions.\n// TODO: for internal use only?\njStat.utils = {\n calcRdx: calcRdx,\n isArray: isArray,\n isFunction: isFunction,\n isNumber: isNumber,\n toVector: toVector\n};\n\n\njStat._random_fn = Math.random;\njStat.setRandom = function setRandom(fn) {\n if (typeof fn !== 'function')\n throw new TypeError('fn is not a function');\n jStat._random_fn = fn;\n};\n\n\n// Easily extend the jStat object.\n// TODO: is this seriously necessary?\njStat.extend = function extend(obj) {\n var i, j;\n\n if (arguments.length === 1) {\n for (j in obj)\n jStat[j] = obj[j];\n return this;\n }\n\n for (i = 1; i < arguments.length; i++) {\n for (j in arguments[i])\n obj[j] = arguments[i][j];\n }\n\n return obj;\n};\n\n\n// Returns the number of rows in the matrix.\njStat.rows = function rows(arr) {\n return arr.length || 1;\n};\n\n\n// Returns the number of columns in the matrix.\njStat.cols = function cols(arr) {\n return arr[0].length || 1;\n};\n\n\n// Returns the dimensions of the object { rows: i, cols: j }\njStat.dimensions = function dimensions(arr) {\n return {\n rows: jStat.rows(arr),\n cols: jStat.cols(arr)\n };\n};\n\n\n// Returns a specified row as a vector or return a sub matrix by pick some rows\njStat.row = function row(arr, index) {\n if (isArray(index)) {\n return index.map(function(i) {\n return jStat.row(arr, i);\n })\n }\n return arr[index];\n};\n\n\n// return row as array\n// rowa([[1,2],[3,4]],0) -> [1,2]\njStat.rowa = function rowa(arr, i) {\n return jStat.row(arr, i);\n};\n\n\n// Returns the specified column as a vector or return a sub matrix by pick some\n// columns\njStat.col = function col(arr, index) {\n if (isArray(index)) {\n var submat = jStat.arange(arr.length).map(function() {\n return new Array(index.length);\n });\n index.forEach(function(ind, i){\n jStat.arange(arr.length).forEach(function(j) {\n submat[j][i] = arr[j][ind];\n });\n });\n return submat;\n }\n var column = new Array(arr.length);\n for (var i = 0; i < arr.length; i++)\n column[i] = [arr[i][index]];\n return column;\n};\n\n\n// return column as array\n// cola([[1,2],[3,4]],0) -> [1,3]\njStat.cola = function cola(arr, i) {\n return jStat.col(arr, i).map(function(a){ return a[0] });\n};\n\n\n// Returns the diagonal of the matrix\njStat.diag = function diag(arr) {\n var nrow = jStat.rows(arr);\n var res = new Array(nrow);\n for (var row = 0; row < nrow; row++)\n res[row] = [arr[row][row]];\n return res;\n};\n\n\n// Returns the anti-diagonal of the matrix\njStat.antidiag = function antidiag(arr) {\n var nrow = jStat.rows(arr) - 1;\n var res = new Array(nrow);\n for (var i = 0; nrow >= 0; nrow--, i++)\n res[i] = [arr[i][nrow]];\n return res;\n};\n\n// Transpose a matrix or array.\njStat.transpose = function transpose(arr) {\n var obj = [];\n var objArr, rows, cols, j, i;\n\n // Make sure arr is in matrix format.\n if (!isArray(arr[0]))\n arr = [arr];\n\n rows = arr.length;\n cols = arr[0].length;\n\n for (i = 0; i < cols; i++) {\n objArr = new Array(rows);\n for (j = 0; j < rows; j++)\n objArr[j] = arr[j][i];\n obj.push(objArr);\n }\n\n // If obj is vector, return only single array.\n return obj.length === 1 ? obj[0] : obj;\n};\n\n\n// Map a function to an array or array of arrays.\n// \"toAlter\" is an internal variable.\njStat.map = function map(arr, func, toAlter) {\n var row, nrow, ncol, res, col;\n\n if (!isArray(arr[0]))\n arr = [arr];\n\n nrow = arr.length;\n ncol = arr[0].length;\n res = toAlter ? arr : new Array(nrow);\n\n for (row = 0; row < nrow; row++) {\n // if the row doesn't exist, create it\n if (!res[row])\n res[row] = new Array(ncol);\n for (col = 0; col < ncol; col++)\n res[row][col] = func(arr[row][col], row, col);\n }\n\n return res.length === 1 ? res[0] : res;\n};\n\n\n// Cumulatively combine the elements of an array or array of arrays using a function.\njStat.cumreduce = function cumreduce(arr, func, toAlter) {\n var row, nrow, ncol, res, col;\n\n if (!isArray(arr[0]))\n arr = [arr];\n\n nrow = arr.length;\n ncol = arr[0].length;\n res = toAlter ? arr : new Array(nrow);\n\n for (row = 0; row < nrow; row++) {\n // if the row doesn't exist, create it\n if (!res[row])\n res[row] = new Array(ncol);\n if (ncol > 0)\n res[row][0] = arr[row][0];\n for (col = 1; col < ncol; col++)\n res[row][col] = func(res[row][col-1], arr[row][col]);\n }\n return res.length === 1 ? res[0] : res;\n};\n\n\n// Destructively alter an array.\njStat.alter = function alter(arr, func) {\n return jStat.map(arr, func, true);\n};\n\n\n// Generate a rows x cols matrix according to the supplied function.\njStat.create = function create(rows, cols, func) {\n var res = new Array(rows);\n var i, j;\n\n if (isFunction(cols)) {\n func = cols;\n cols = rows;\n }\n\n for (i = 0; i < rows; i++) {\n res[i] = new Array(cols);\n for (j = 0; j < cols; j++)\n res[i][j] = func(i, j);\n }\n\n return res;\n};\n\n\nfunction retZero() { return 0; }\n\n\n// Generate a rows x cols matrix of zeros.\njStat.zeros = function zeros(rows, cols) {\n if (!isNumber(cols))\n cols = rows;\n return jStat.create(rows, cols, retZero);\n};\n\n\nfunction retOne() { return 1; }\n\n\n// Generate a rows x cols matrix of ones.\njStat.ones = function ones(rows, cols) {\n if (!isNumber(cols))\n cols = rows;\n return jStat.create(rows, cols, retOne);\n};\n\n\n// Generate a rows x cols matrix of uniformly random numbers.\njStat.rand = function rand(rows, cols) {\n if (!isNumber(cols))\n cols = rows;\n return jStat.create(rows, cols, jStat._random_fn);\n};\n\n\nfunction retIdent(i, j) { return i === j ? 1 : 0; }\n\n\n// Generate an identity matrix of size row x cols.\njStat.identity = function identity(rows, cols) {\n if (!isNumber(cols))\n cols = rows;\n return jStat.create(rows, cols, retIdent);\n};\n\n\n// Tests whether a matrix is symmetric\njStat.symmetric = function symmetric(arr) {\n var size = arr.length;\n var row, col;\n\n if (arr.length !== arr[0].length)\n return false;\n\n for (row = 0; row < size; row++) {\n for (col = 0; col < size; col++)\n if (arr[col][row] !== arr[row][col])\n return false;\n }\n\n return true;\n};\n\n\n// Set all values to zero.\njStat.clear = function clear(arr) {\n return jStat.alter(arr, retZero);\n};\n\n\n// Generate sequence.\njStat.seq = function seq(min, max, length, func) {\n if (!isFunction(func))\n func = false;\n\n var arr = [];\n var hival = calcRdx(min, max);\n var step = (max * hival - min * hival) / ((length - 1) * hival);\n var current = min;\n var cnt;\n\n // Current is assigned using a technique to compensate for IEEE error.\n // TODO: Needs better implementation.\n for (cnt = 0;\n current <= max && cnt < length;\n cnt++, current = (min * hival + step * hival * cnt) / hival) {\n arr.push((func ? func(current, cnt) : current));\n }\n\n return arr;\n};\n\n\n// arange(5) -> [0,1,2,3,4]\n// arange(1,5) -> [1,2,3,4]\n// arange(5,1,-1) -> [5,4,3,2]\njStat.arange = function arange(start, end, step) {\n var rl = [];\n var i;\n step = step || 1;\n if (end === undefined) {\n end = start;\n start = 0;\n }\n if (start === end || step === 0) {\n return [];\n }\n if (start < end && step < 0) {\n return [];\n }\n if (start > end && step > 0) {\n return [];\n }\n if (step > 0) {\n for (i = start; i < end; i += step) {\n rl.push(i);\n }\n } else {\n for (i = start; i > end; i += step) {\n rl.push(i);\n }\n }\n return rl;\n};\n\n\n// A=[[1,2,3],[4,5,6],[7,8,9]]\n// slice(A,{row:{end:2},col:{start:1}}) -> [[2,3],[5,6]]\n// slice(A,1,{start:1}) -> [5,6]\n// as numpy code A[:2,1:]\njStat.slice = (function(){\n function _slice(list, start, end, step) {\n // note it's not equal to range.map mode it's a bug\n var i;\n var rl = [];\n var length = list.length;\n if (start === undefined && end === undefined && step === undefined) {\n return jStat.copy(list);\n }\n\n start = start || 0;\n end = end || list.length;\n start = start >= 0 ? start : length + start;\n end = end >= 0 ? end : length + end;\n step = step || 1;\n if (start === end || step === 0) {\n return [];\n }\n if (start < end && step < 0) {\n return [];\n }\n if (start > end && step > 0) {\n return [];\n }\n if (step > 0) {\n for (i = start; i < end; i += step) {\n rl.push(list[i]);\n }\n } else {\n for (i = start; i > end;i += step) {\n rl.push(list[i]);\n }\n }\n return rl;\n }\n\n function slice(list, rcSlice) {\n var colSlice, rowSlice;\n rcSlice = rcSlice || {};\n if (isNumber(rcSlice.row)) {\n if (isNumber(rcSlice.col))\n return list[rcSlice.row][rcSlice.col];\n var row = jStat.rowa(list, rcSlice.row);\n colSlice = rcSlice.col || {};\n return _slice(row, colSlice.start, colSlice.end, colSlice.step);\n }\n\n if (isNumber(rcSlice.col)) {\n var col = jStat.cola(list, rcSlice.col);\n rowSlice = rcSlice.row || {};\n return _slice(col, rowSlice.start, rowSlice.end, rowSlice.step);\n }\n\n rowSlice = rcSlice.row || {};\n colSlice = rcSlice.col || {};\n var rows = _slice(list, rowSlice.start, rowSlice.end, rowSlice.step);\n return rows.map(function(row) {\n return _slice(row, colSlice.start, colSlice.end, colSlice.step);\n });\n }\n\n return slice;\n}());\n\n\n// A=[[1,2,3],[4,5,6],[7,8,9]]\n// sliceAssign(A,{row:{start:1},col:{start:1}},[[0,0],[0,0]])\n// A=[[1,2,3],[4,0,0],[7,0,0]]\njStat.sliceAssign = function sliceAssign(A, rcSlice, B) {\n var nl, ml;\n if (isNumber(rcSlice.row)) {\n if (isNumber(rcSlice.col))\n return A[rcSlice.row][rcSlice.col] = B;\n rcSlice.col = rcSlice.col || {};\n rcSlice.col.start = rcSlice.col.start || 0;\n rcSlice.col.end = rcSlice.col.end || A[0].length;\n rcSlice.col.step = rcSlice.col.step || 1;\n nl = jStat.arange(rcSlice.col.start,\n Math.min(A.length, rcSlice.col.end),\n rcSlice.col.step);\n var m = rcSlice.row;\n nl.forEach(function(n, i) {\n A[m][n] = B[i];\n });\n return A;\n }\n\n if (isNumber(rcSlice.col)) {\n rcSlice.row = rcSlice.row || {};\n rcSlice.row.start = rcSlice.row.start || 0;\n rcSlice.row.end = rcSlice.row.end || A.length;\n rcSlice.row.step = rcSlice.row.step || 1;\n ml = jStat.arange(rcSlice.row.start,\n Math.min(A[0].length, rcSlice.row.end),\n rcSlice.row.step);\n var n = rcSlice.col;\n ml.forEach(function(m, j) {\n A[m][n] = B[j];\n });\n return A;\n }\n\n if (B[0].length === undefined) {\n B = [B];\n }\n rcSlice.row.start = rcSlice.row.start || 0;\n rcSlice.row.end = rcSlice.row.end || A.length;\n rcSlice.row.step = rcSlice.row.step || 1;\n rcSlice.col.start = rcSlice.col.start || 0;\n rcSlice.col.end = rcSlice.col.end || A[0].length;\n rcSlice.col.step = rcSlice.col.step || 1;\n ml = jStat.arange(rcSlice.row.start,\n Math.min(A.length, rcSlice.row.end),\n rcSlice.row.step);\n nl = jStat.arange(rcSlice.col.start,\n Math.min(A[0].length, rcSlice.col.end),\n rcSlice.col.step);\n ml.forEach(function(m, i) {\n nl.forEach(function(n, j) {\n A[m][n] = B[i][j];\n });\n });\n return A;\n};\n\n\n// [1,2,3] ->\n// [[1,0,0],[0,2,0],[0,0,3]]\njStat.diagonal = function diagonal(diagArray) {\n var mat = jStat.zeros(diagArray.length, diagArray.length);\n diagArray.forEach(function(t, i) {\n mat[i][i] = t;\n });\n return mat;\n};\n\n\n// return copy of A\njStat.copy = function copy(A) {\n return A.map(function(row) {\n if (isNumber(row))\n return row;\n return row.map(function(t) {\n return t;\n });\n });\n};\n\n\n// TODO: Go over this entire implementation. Seems a tragic waste of resources\n// doing all this work. Instead, and while ugly, use new Function() to generate\n// a custom function for each static method.\n\n// Quick reference.\nvar jProto = jStat.prototype;\n\n// Default length.\njProto.length = 0;\n\n// For internal use only.\n// TODO: Check if they're actually used, and if they are then rename them\n// to _*\njProto.push = Array.prototype.push;\njProto.sort = Array.prototype.sort;\njProto.splice = Array.prototype.splice;\njProto.slice = Array.prototype.slice;\n\n\n// Return a clean array.\njProto.toArray = function toArray() {\n return this.length > 1 ? slice.call(this) : slice.call(this)[0];\n};\n\n\n// Map a function to a matrix or vector.\njProto.map = function map(func, toAlter) {\n return jStat(jStat.map(this, func, toAlter));\n};\n\n\n// Cumulatively combine the elements of a matrix or vector using a function.\njProto.cumreduce = function cumreduce(func, toAlter) {\n return jStat(jStat.cumreduce(this, func, toAlter));\n};\n\n\n// Destructively alter an array.\njProto.alter = function alter(func) {\n jStat.alter(this, func);\n return this;\n};\n\n\n// Extend prototype with methods that have no argument.\n(function(funcs) {\n for (var i = 0; i < funcs.length; i++) (function(passfunc) {\n jProto[passfunc] = function(func) {\n var self = this,\n results;\n // Check for callback.\n if (func) {\n setTimeout(function() {\n func.call(self, jProto[passfunc].call(self));\n });\n return this;\n }\n results = jStat[passfunc](this);\n return isArray(results) ? jStat(results) : results;\n };\n })(funcs[i]);\n})('transpose clear symmetric rows cols dimensions diag antidiag'.split(' '));\n\n\n// Extend prototype with methods that have one argument.\n(function(funcs) {\n for (var i = 0; i < funcs.length; i++) (function(passfunc) {\n jProto[passfunc] = function(index, func) {\n var self = this;\n // check for callback\n if (func) {\n setTimeout(function() {\n func.call(self, jProto[passfunc].call(self, index));\n });\n return this;\n }\n return jStat(jStat[passfunc](this, index));\n };\n })(funcs[i]);\n})('row col'.split(' '));\n\n\n// Extend prototype with simple shortcut methods.\n(function(funcs) {\n for (var i = 0; i < funcs.length; i++) (function(passfunc) {\n jProto[passfunc] = function() {\n return jStat(jStat[passfunc].apply(null, arguments));\n };\n })(funcs[i]);\n})('create zeros ones rand identity'.split(' '));\n\n\n// Exposing jStat.\nreturn jStat;\n\n}(Math));\n(function(jStat, Math) {\n\nvar isFunction = jStat.utils.isFunction;\n\n// Ascending functions for sort\nfunction ascNum(a, b) { return a - b; }\n\nfunction clip(arg, min, max) {\n return Math.max(min, Math.min(arg, max));\n}\n\n\n// sum of an array\njStat.sum = function sum(arr) {\n var sum = 0;\n var i = arr.length;\n while (--i >= 0)\n sum += arr[i];\n return sum;\n};\n\n\n// sum squared\njStat.sumsqrd = function sumsqrd(arr) {\n var sum = 0;\n var i = arr.length;\n while (--i >= 0)\n sum += arr[i] * arr[i];\n return sum;\n};\n\n\n// sum of squared errors of prediction (SSE)\njStat.sumsqerr = function sumsqerr(arr) {\n var mean = jStat.mean(arr);\n var sum = 0;\n var i = arr.length;\n var tmp;\n while (--i >= 0) {\n tmp = arr[i] - mean;\n sum += tmp * tmp;\n }\n return sum;\n};\n\n// sum of an array in each row\njStat.sumrow = function sumrow(arr) {\n var sum = 0;\n var i = arr.length;\n while (--i >= 0)\n sum += arr[i];\n return sum;\n};\n\n// product of an array\njStat.product = function product(arr) {\n var prod = 1;\n var i = arr.length;\n while (--i >= 0)\n prod *= arr[i];\n return prod;\n};\n\n\n// minimum value of an array\njStat.min = function min(arr) {\n var low = arr[0];\n var i = 0;\n while (++i < arr.length)\n if (arr[i] < low)\n low = arr[i];\n return low;\n};\n\n\n// maximum value of an array\njStat.max = function max(arr) {\n var high = arr[0];\n var i = 0;\n while (++i < arr.length)\n if (arr[i] > high)\n high = arr[i];\n return high;\n};\n\n\n// unique values of an array\njStat.unique = function unique(arr) {\n var hash = {}, _arr = [];\n for(var i = 0; i < arr.length; i++) {\n if (!hash[arr[i]]) {\n hash[arr[i]] = true;\n _arr.push(arr[i]);\n }\n }\n return _arr;\n};\n\n\n// mean value of an array\njStat.mean = function mean(arr) {\n return jStat.sum(arr) / arr.length;\n};\n\n\n// mean squared error (MSE)\njStat.meansqerr = function meansqerr(arr) {\n return jStat.sumsqerr(arr) / arr.length;\n};\n\n\n// geometric mean of an array\njStat.geomean = function geomean(arr) {\n var logs = arr.map(Math.log)\n var meanOfLogs = jStat.mean(logs)\n return Math.exp(meanOfLogs)\n};\n\n\n// median of an array\njStat.median = function median(arr) {\n var arrlen = arr.length;\n var _arr = arr.slice().sort(ascNum);\n // check if array is even or odd, then return the appropriate\n return !(arrlen & 1)\n ? (_arr[(arrlen / 2) - 1 ] + _arr[(arrlen / 2)]) / 2\n : _arr[(arrlen / 2) | 0 ];\n};\n\n\n// cumulative sum of an array\njStat.cumsum = function cumsum(arr) {\n return jStat.cumreduce(arr, function (a, b) { return a + b; });\n};\n\n\n// cumulative product of an array\njStat.cumprod = function cumprod(arr) {\n return jStat.cumreduce(arr, function (a, b) { return a * b; });\n};\n\n\n// successive differences of a sequence\njStat.diff = function diff(arr) {\n var diffs = [];\n var arrLen = arr.length;\n var i;\n for (i = 1; i < arrLen; i++)\n diffs.push(arr[i] - arr[i - 1]);\n return diffs;\n};\n\n\n// ranks of an array\njStat.rank = function (arr) {\n var i;\n var distinctNumbers = [];\n var numberCounts = {};\n for (i = 0; i < arr.length; i++) {\n var number = arr[i];\n if (numberCounts[number]) {\n numberCounts[number]++;\n } else {\n numberCounts[number] = 1;\n distinctNumbers.push(number);\n }\n }\n\n var sortedDistinctNumbers = distinctNumbers.sort(ascNum);\n var numberRanks = {};\n var currentRank = 1;\n for (i = 0; i < sortedDistinctNumbers.length; i++) {\n var number = sortedDistinctNumbers[i];\n var count = numberCounts[number];\n var first = currentRank;\n var last = currentRank + count - 1;\n var rank = (first + last) / 2;\n numberRanks[number] = rank;\n currentRank += count;\n }\n\n return arr.map(function (number) {\n return numberRanks[number];\n });\n};\n\n\n// mode of an array\n// if there are multiple modes of an array, return all of them\n// is this the appropriate way of handling it?\njStat.mode = function mode(arr) {\n var arrLen = arr.length;\n var _arr = arr.slice().sort(ascNum);\n var count = 1;\n var maxCount = 0;\n var numMaxCount = 0;\n var mode_arr = [];\n var i;\n\n for (i = 0; i < arrLen; i++) {\n if (_arr[i] === _arr[i + 1]) {\n count++;\n } else {\n if (count > maxCount) {\n mode_arr = [_arr[i]];\n maxCount = count;\n numMaxCount = 0;\n }\n // are there multiple max counts\n else if (count === maxCount) {\n mode_arr.push(_arr[i]);\n numMaxCount++;\n }\n // resetting count for new value in array\n count = 1;\n }\n }\n\n return numMaxCount === 0 ? mode_arr[0] : mode_arr;\n};\n\n\n// range of an array\njStat.range = function range(arr) {\n return jStat.max(arr) - jStat.min(arr);\n};\n\n// variance of an array\n// flag = true indicates sample instead of population\njStat.variance = function variance(arr, flag) {\n return jStat.sumsqerr(arr) / (arr.length - (flag ? 1 : 0));\n};\n\n// pooled variance of an array of arrays\njStat.pooledvariance = function pooledvariance(arr) {\n var sumsqerr = arr.reduce(function (a, samples) {return a + jStat.sumsqerr(samples);}, 0);\n var count = arr.reduce(function (a, samples) {return a + samples.length;}, 0);\n return sumsqerr / (count - arr.length);\n};\n\n// deviation of an array\njStat.deviation = function (arr) {\n var mean = jStat.mean(arr);\n var arrlen = arr.length;\n var dev = new Array(arrlen);\n for (var i = 0; i < arrlen; i++) {\n dev[i] = arr[i] - mean;\n }\n return dev;\n};\n\n// standard deviation of an array\n// flag = true indicates sample instead of population\njStat.stdev = function stdev(arr, flag) {\n return Math.sqrt(jStat.variance(arr, flag));\n};\n\n// pooled standard deviation of an array of arrays\njStat.pooledstdev = function pooledstdev(arr) {\n return Math.sqrt(jStat.pooledvariance(arr));\n};\n\n// mean deviation (mean absolute deviation) of an array\njStat.meandev = function meandev(arr) {\n var mean = jStat.mean(arr);\n var a = [];\n for (var i = arr.length - 1; i >= 0; i--) {\n a.push(Math.abs(arr[i] - mean));\n }\n return jStat.mean(a);\n};\n\n\n// median deviation (median absolute deviation) of an array\njStat.meddev = function meddev(arr) {\n var median = jStat.median(arr);\n var a = [];\n for (var i = arr.length - 1; i >= 0; i--) {\n a.push(Math.abs(arr[i] - median));\n }\n return jStat.median(a);\n};\n\n\n// coefficient of variation\njStat.coeffvar = function coeffvar(arr) {\n return jStat.stdev(arr) / jStat.mean(arr);\n};\n\n\n// quartiles of an array\njStat.quartiles = function quartiles(arr) {\n var arrlen = arr.length;\n var _arr = arr.slice().sort(ascNum);\n return [\n _arr[ Math.round((arrlen) / 4) - 1 ],\n _arr[ Math.round((arrlen) / 2) - 1 ],\n _arr[ Math.round((arrlen) * 3 / 4) - 1 ]\n ];\n};\n\n\n// Arbitary quantiles of an array. Direct port of the scipy.stats\n// implementation by Pierre GF Gerard-Marchant.\njStat.quantiles = function quantiles(arr, quantilesArray, alphap, betap) {\n var sortedArray = arr.slice().sort(ascNum);\n var quantileVals = [quantilesArray.length];\n var n = arr.length;\n var i, p, m, aleph, k, gamma;\n\n if (typeof alphap === 'undefined')\n alphap = 3 / 8;\n if (typeof betap === 'undefined')\n betap = 3 / 8;\n\n for (i = 0; i < quantilesArray.length; i++) {\n p = quantilesArray[i];\n m = alphap + p * (1 - alphap - betap);\n aleph = n * p + m;\n k = Math.floor(clip(aleph, 1, n - 1));\n gamma = clip(aleph - k, 0, 1);\n quantileVals[i] = (1 - gamma) * sortedArray[k - 1] + gamma * sortedArray[k];\n }\n\n return quantileVals;\n};\n\n// Return the k-th percentile of values in a range, where k is in the range 0..1, inclusive.\n// Passing true for the exclusive parameter excludes both endpoints of the range.\njStat.percentile = function percentile(arr, k, exclusive) {\n var _arr = arr.slice().sort(ascNum);\n var realIndex = k * (_arr.length + (exclusive ? 1 : -1)) + (exclusive ? 0 : 1);\n var index = parseInt(realIndex);\n var frac = realIndex - index;\n if (index + 1 < _arr.length) {\n return _arr[index - 1] + frac * (_arr[index] - _arr[index - 1]);\n } else {\n return _arr[index - 1];\n }\n}\n\n// The percentile rank of score in a given array. Returns the percentage\n// of all values in the input array that are less than (kind='strict') or\n// less or equal than (kind='weak') score. Default is weak.\njStat.percentileOfScore = function percentileOfScore(arr, score, kind) {\n var counter = 0;\n var len = arr.length;\n var strict = false;\n var value, i;\n\n if (kind === 'strict')\n strict = true;\n\n for (i = 0; i < len; i++) {\n value = arr[i];\n if ((strict && value < score) ||\n (!strict && value <= score)) {\n counter++;\n }\n }\n\n return counter / len;\n};\n\n\n// Histogram (bin count) data\njStat.histogram = function histogram(arr, binCnt) {\n binCnt = binCnt || 4;\n var first = jStat.min(arr);\n var binWidth = (jStat.max(arr) - first) / binCnt;\n var len = arr.length;\n var bins = [];\n var i;\n\n for (i = 0; i < binCnt; i++)\n bins[i] = 0;\n for (i = 0; i < len; i++)\n bins[Math.min(Math.floor(((arr[i] - first) / binWidth)), binCnt - 1)] += 1;\n\n return bins;\n};\n\n\n// covariance of two arrays\njStat.covariance = function covariance(arr1, arr2) {\n var u = jStat.mean(arr1);\n var v = jStat.mean(arr2);\n var arr1Len = arr1.length;\n var sq_dev = new Array(arr1Len);\n var i;\n\n for (i = 0; i < arr1Len; i++)\n sq_dev[i] = (arr1[i] - u) * (arr2[i] - v);\n\n return jStat.sum(sq_dev) / (arr1Len - 1);\n};\n\n\n// (pearson's) population correlation coefficient, rho\njStat.corrcoeff = function corrcoeff(arr1, arr2) {\n return jStat.covariance(arr1, arr2) /\n jStat.stdev(arr1, 1) /\n jStat.stdev(arr2, 1);\n};\n\n // (spearman's) rank correlation coefficient, sp\njStat.spearmancoeff = function (arr1, arr2) {\n arr1 = jStat.rank(arr1);\n arr2 = jStat.rank(arr2);\n //return pearson's correlation of the ranks:\n return jStat.corrcoeff(arr1, arr2);\n}\n\n\n// statistical standardized moments (general form of skew/kurt)\njStat.stanMoment = function stanMoment(arr, n) {\n var mu = jStat.mean(arr);\n var sigma = jStat.stdev(arr);\n var len = arr.length;\n var skewSum = 0;\n\n for (var i = 0; i < len; i++)\n skewSum += Math.pow((arr[i] - mu) / sigma, n);\n\n return skewSum / arr.length;\n};\n\n// (pearson's) moment coefficient of skewness\njStat.skewness = function skewness(arr) {\n return jStat.stanMoment(arr, 3);\n};\n\n// (pearson's) (excess) kurtosis\njStat.kurtosis = function kurtosis(arr) {\n return jStat.stanMoment(arr, 4) - 3;\n};\n\n\nvar jProto = jStat.prototype;\n\n\n// Extend jProto with method for calculating cumulative sums and products.\n// This differs from the similar extension below as cumsum and cumprod should\n// not be run again in the case fullbool === true.\n// If a matrix is passed, automatically assume operation should be done on the\n// columns.\n(function(funcs) {\n for (var i = 0; i < funcs.length; i++) (function(passfunc) {\n // If a matrix is passed, automatically assume operation should be done on\n // the columns.\n jProto[passfunc] = function(fullbool, func) {\n var arr = [];\n var i = 0;\n var tmpthis = this;\n // Assignment reassignation depending on how parameters were passed in.\n if (isFunction(fullbool)) {\n func = fullbool;\n fullbool = false;\n }\n // Check if a callback was passed with the function.\n if (func) {\n setTimeout(function() {\n func.call(tmpthis, jProto[passfunc].call(tmpthis, fullbool));\n });\n return this;\n }\n // Check if matrix and run calculations.\n if (this.length > 1) {\n tmpthis = fullbool === true ? this : this.transpose();\n for (; i < tmpthis.length; i++)\n arr[i] = jStat[passfunc](tmpthis[i]);\n return arr;\n }\n // Pass fullbool if only vector, not a matrix. for variance and stdev.\n return jStat[passfunc](this[0], fullbool);\n };\n })(funcs[i]);\n})(('cumsum cumprod').split(' '));\n\n\n// Extend jProto with methods which don't require arguments and work on columns.\n(function(funcs) {\n for (var i = 0; i < funcs.length; i++) (function(passfunc) {\n // If a matrix is passed, automatically assume operation should be done on\n // the columns.\n jProto[passfunc] = function(fullbool, func) {\n var arr = [];\n var i = 0;\n var tmpthis = this;\n // Assignment reassignation depending on how parameters were passed in.\n if (isFunction(fullbool)) {\n func = fullbool;\n fullbool = false;\n }\n // Check if a callback was passed with the function.\n if (func) {\n setTimeout(function() {\n func.call(tmpthis, jProto[passfunc].call(tmpthis, fullbool));\n });\n return this;\n }\n // Check if matrix and run calculations.\n if (this.length > 1) {\n if (passfunc !== 'sumrow')\n tmpthis = fullbool === true ? this : this.transpose();\n for (; i < tmpthis.length; i++)\n arr[i] = jStat[passfunc](tmpthis[i]);\n return fullbool === true\n ? jStat[passfunc](jStat.utils.toVector(arr))\n : arr;\n }\n // Pass fullbool if only vector, not a matrix. for variance and stdev.\n return jStat[passfunc](this[0], fullbool);\n };\n })(funcs[i]);\n})(('sum sumsqrd sumsqerr sumrow product min max unique mean meansqerr ' +\n 'geomean median diff rank mode range variance deviation stdev meandev ' +\n 'meddev coeffvar quartiles histogram skewness kurtosis').split(' '));\n\n\n// Extend jProto with functions that take arguments. Operations on matrices are\n// done on columns.\n(function(funcs) {\n for (var i = 0; i < funcs.length; i++) (function(passfunc) {\n jProto[passfunc] = function() {\n var arr = [];\n var i = 0;\n var tmpthis = this;\n var args = Array.prototype.slice.call(arguments);\n var callbackFunction;\n\n // If the last argument is a function, we assume it's a callback; we\n // strip the callback out and call the function again.\n if (isFunction(args[args.length - 1])) {\n callbackFunction = args[args.length - 1];\n var argsToPass = args.slice(0, args.length - 1);\n\n setTimeout(function() {\n callbackFunction.call(tmpthis,\n jProto[passfunc].apply(tmpthis, argsToPass));\n });\n return this;\n\n // Otherwise we curry the function args and call normally.\n } else {\n callbackFunction = undefined;\n var curriedFunction = function curriedFunction(vector) {\n return jStat[passfunc].apply(tmpthis, [vector].concat(args));\n }\n }\n\n // If this is a matrix, run column-by-column.\n if (this.length > 1) {\n tmpthis = tmpthis.transpose();\n for (; i < tmpthis.length; i++)\n arr[i] = curriedFunction(tmpthis[i]);\n return arr;\n }\n\n // Otherwise run on the vector.\n return curriedFunction(this[0]);\n };\n })(funcs[i]);\n})('quantiles percentileOfScore'.split(' '));\n\n}(jStat, Math));\n// Special functions //\n(function(jStat, Math) {\n\n// Log-gamma function\njStat.gammaln = function gammaln(x) {\n var j = 0;\n var cof = [\n 76.18009172947146, -86.50532032941677, 24.01409824083091,\n -1.231739572450155, 0.1208650973866179e-2, -0.5395239384953e-5\n ];\n var ser = 1.000000000190015;\n var xx, y, tmp;\n tmp = (y = xx = x) + 5.5;\n tmp -= (xx + 0.5) * Math.log(tmp);\n for (; j < 6; j++)\n ser += cof[j] / ++y;\n return Math.log(2.5066282746310005 * ser / xx) - tmp;\n};\n\n/*\n * log-gamma function to support poisson distribution sampling. The\n * algorithm comes from SPECFUN by Shanjie Zhang and Jianming Jin and their\n * book \"Computation of Special Functions\", 1996, John Wiley & Sons, Inc.\n */\njStat.loggam = function loggam(x) {\n var x0, x2, xp, gl, gl0;\n var k, n;\n\n var a = [8.333333333333333e-02, -2.777777777777778e-03,\n 7.936507936507937e-04, -5.952380952380952e-04,\n 8.417508417508418e-04, -1.917526917526918e-03,\n 6.410256410256410e-03, -2.955065359477124e-02,\n 1.796443723688307e-01, -1.39243221690590e+00];\n x0 = x;\n n = 0;\n if ((x == 1.0) || (x == 2.0)) {\n return 0.0;\n }\n if (x <= 7.0) {\n n = Math.floor(7 - x);\n x0 = x + n;\n }\n x2 = 1.0 / (x0 * x0);\n xp = 2 * Math.PI;\n gl0 = a[9];\n for (k = 8; k >= 0; k--) {\n gl0 *= x2;\n gl0 += a[k];\n }\n gl = gl0 / x0 + 0.5 * Math.log(xp) + (x0 - 0.5) * Math.log(x0) - x0;\n if (x <= 7.0) {\n for (k = 1; k <= n; k++) {\n gl -= Math.log(x0 - 1.0);\n x0 -= 1.0;\n }\n }\n return gl;\n}\n\n// gamma of x\njStat.gammafn = function gammafn(x) {\n var p = [-1.716185138865495, 24.76565080557592, -379.80425647094563,\n 629.3311553128184, 866.9662027904133, -31451.272968848367,\n -36144.413418691176, 66456.14382024054\n ];\n var q = [-30.8402300119739, 315.35062697960416, -1015.1563674902192,\n -3107.771671572311, 22538.118420980151, 4755.8462775278811,\n -134659.9598649693, -115132.2596755535];\n var fact = false;\n var n = 0;\n var xden = 0;\n var xnum = 0;\n var y = x;\n var i, z, yi, res;\n if (x > 171.6243769536076) {\n return Infinity;\n }\n if (y <= 0) {\n res = y % 1 + 3.6e-16;\n if (res) {\n fact = (!(y & 1) ? 1 : -1) * Math.PI / Math.sin(Math.PI * res);\n y = 1 - y;\n } else {\n return Infinity;\n }\n }\n yi = y;\n if (y < 1) {\n z = y++;\n } else {\n z = (y -= n = (y | 0) - 1) - 1;\n }\n for (i = 0; i < 8; ++i) {\n xnum = (xnum + p[i]) * z;\n xden = xden * z + q[i];\n }\n res = xnum / xden + 1;\n if (yi < y) {\n res /= yi;\n } else if (yi > y) {\n for (i = 0; i < n; ++i) {\n res *= y;\n y++;\n }\n }\n if (fact) {\n res = fact / res;\n }\n return res;\n};\n\n\n// lower incomplete gamma function, which is usually typeset with a\n// lower-case greek gamma as the function symbol\njStat.gammap = function gammap(a, x) {\n return jStat.lowRegGamma(a, x) * jStat.gammafn(a);\n};\n\n\n// The lower regularized incomplete gamma function, usually written P(a,x)\njStat.lowRegGamma = function lowRegGamma(a, x) {\n var aln = jStat.gammaln(a);\n var ap = a;\n var sum = 1 / a;\n var del = sum;\n var b = x + 1 - a;\n var c = 1 / 1.0e-30;\n var d = 1 / b;\n var h = d;\n var i = 1;\n // calculate maximum number of itterations required for a\n var ITMAX = -~(Math.log((a >= 1) ? a : 1 / a) * 8.5 + a * 0.4 + 17);\n var an;\n\n if (x < 0 || a <= 0) {\n return NaN;\n } else if (x < a + 1) {\n for (; i <= ITMAX; i++) {\n sum += del *= x / ++ap;\n }\n return (sum * Math.exp(-x + a * Math.log(x) - (aln)));\n }\n\n for (; i <= ITMAX; i++) {\n an = -i * (i - a);\n b += 2;\n d = an * d + b;\n c = b + an / c;\n d = 1 / d;\n h *= d * c;\n }\n\n return (1 - h * Math.exp(-x + a * Math.log(x) - (aln)));\n};\n\n// natural log factorial of n\njStat.factorialln = function factorialln(n) {\n return n < 0 ? NaN : jStat.gammaln(n + 1);\n};\n\n// factorial of n\njStat.factorial = function factorial(n) {\n return n < 0 ? NaN : jStat.gammafn(n + 1);\n};\n\n// combinations of n, m\njStat.combination = function combination(n, m) {\n // make sure n or m don't exceed the upper limit of usable values\n return (n > 170 || m > 170)\n ? Math.exp(jStat.combinationln(n, m))\n : (jStat.factorial(n) / jStat.factorial(m)) / jStat.factorial(n - m);\n};\n\n\njStat.combinationln = function combinationln(n, m){\n return jStat.factorialln(n) - jStat.factorialln(m) - jStat.factorialln(n - m);\n};\n\n\n// permutations of n, m\njStat.permutation = function permutation(n, m) {\n return jStat.factorial(n) / jStat.factorial(n - m);\n};\n\n\n// beta function\njStat.betafn = function betafn(x, y) {\n // ensure arguments are positive\n if (x <= 0 || y <= 0)\n return undefined;\n // make sure x + y doesn't exceed the upper limit of usable values\n return (x + y > 170)\n ? Math.exp(jStat.betaln(x, y))\n : jStat.gammafn(x) * jStat.gammafn(y) / jStat.gammafn(x + y);\n};\n\n\n// natural logarithm of beta function\njStat.betaln = function betaln(x, y) {\n return jStat.gammaln(x) + jStat.gammaln(y) - jStat.gammaln(x + y);\n};\n\n\n// Evaluates the continued fraction for incomplete beta function by modified\n// Lentz's method.\njStat.betacf = function betacf(x, a, b) {\n var fpmin = 1e-30;\n var m = 1;\n var qab = a + b;\n var qap = a + 1;\n var qam = a - 1;\n var c = 1;\n var d = 1 - qab * x / qap;\n var m2, aa, del, h;\n\n // These q's will be used in factors that occur in the coefficients\n if (Math.abs(d) < fpmin)\n d = fpmin;\n d = 1 / d;\n h = d;\n\n for (; m <= 100; m++) {\n m2 = 2 * m;\n aa = m * (b - m) * x / ((qam + m2) * (a + m2));\n // One step (the even one) of the recurrence\n d = 1 + aa * d;\n if (Math.abs(d) < fpmin)\n d = fpmin;\n c = 1 + aa / c;\n if (Math.abs(c) < fpmin)\n c = fpmin;\n d = 1 / d;\n h *= d * c;\n aa = -(a + m) * (qab + m) * x / ((a + m2) * (qap + m2));\n // Next step of the recurrence (the odd one)\n d = 1 + aa * d;\n if (Math.abs(d) < fpmin)\n d = fpmin;\n c = 1 + aa / c;\n if (Math.abs(c) < fpmin)\n c = fpmin;\n d = 1 / d;\n del = d * c;\n h *= del;\n if (Math.abs(del - 1.0) < 3e-7)\n break;\n }\n\n return h;\n};\n\n\n// Returns the inverse of the lower regularized inomplete gamma function\njStat.gammapinv = function gammapinv(p, a) {\n var j = 0;\n var a1 = a - 1;\n var EPS = 1e-8;\n var gln = jStat.gammaln(a);\n var x, err, t, u, pp, lna1, afac;\n\n if (p >= 1)\n return Math.max(100, a + 100 * Math.sqrt(a));\n if (p <= 0)\n return 0;\n if (a > 1) {\n lna1 = Math.log(a1);\n afac = Math.exp(a1 * (lna1 - 1) - gln);\n pp = (p < 0.5) ? p : 1 - p;\n t = Math.sqrt(-2 * Math.log(pp));\n x = (2.30753 + t * 0.27061) / (1 + t * (0.99229 + t * 0.04481)) - t;\n if (p < 0.5)\n x = -x;\n x = Math.max(1e-3,\n a * Math.pow(1 - 1 / (9 * a) - x / (3 * Math.sqrt(a)), 3));\n } else {\n t = 1 - a * (0.253 + a * 0.12);\n if (p < t)\n x = Math.pow(p / t, 1 / a);\n else\n x = 1 - Math.log(1 - (p - t) / (1 - t));\n }\n\n for(; j < 12; j++) {\n if (x <= 0)\n return 0;\n err = jStat.lowRegGamma(a, x) - p;\n if (a > 1)\n t = afac * Math.exp(-(x - a1) + a1 * (Math.log(x) - lna1));\n else\n t = Math.exp(-x + a1 * Math.log(x) - gln);\n u = err / t;\n x -= (t = u / (1 - 0.5 * Math.min(1, u * ((a - 1) / x - 1))));\n if (x <= 0)\n x = 0.5 * (x + t);\n if (Math.abs(t) < EPS * x)\n break;\n }\n\n return x;\n};\n\n\n// Returns the error function erf(x)\njStat.erf = function erf(x) {\n var cof = [-1.3026537197817094, 6.4196979235649026e-1, 1.9476473204185836e-2,\n -9.561514786808631e-3, -9.46595344482036e-4, 3.66839497852761e-4,\n 4.2523324806907e-5, -2.0278578112534e-5, -1.624290004647e-6,\n 1.303655835580e-6, 1.5626441722e-8, -8.5238095915e-8,\n 6.529054439e-9, 5.059343495e-9, -9.91364156e-10,\n -2.27365122e-10, 9.6467911e-11, 2.394038e-12,\n -6.886027e-12, 8.94487e-13, 3.13092e-13,\n -1.12708e-13, 3.81e-16, 7.106e-15,\n -1.523e-15, -9.4e-17, 1.21e-16,\n -2.8e-17];\n var j = cof.length - 1;\n var isneg = false;\n var d = 0;\n var dd = 0;\n var t, ty, tmp, res;\n\n if (x < 0) {\n x = -x;\n isneg = true;\n }\n\n t = 2 / (2 + x);\n ty = 4 * t - 2;\n\n for(; j > 0; j--) {\n tmp = d;\n d = ty * d - dd + cof[j];\n dd = tmp;\n }\n\n res = t * Math.exp(-x * x + 0.5 * (cof[0] + ty * d) - dd);\n return isneg ? res - 1 : 1 - res;\n};\n\n\n// Returns the complmentary error function erfc(x)\njStat.erfc = function erfc(x) {\n return 1 - jStat.erf(x);\n};\n\n\n// Returns the inverse of the complementary error function\njStat.erfcinv = function erfcinv(p) {\n var j = 0;\n var x, err, t, pp;\n if (p >= 2)\n return -100;\n if (p <= 0)\n return 100;\n pp = (p < 1) ? p : 2 - p;\n t = Math.sqrt(-2 * Math.log(pp / 2));\n x = -0.70711 * ((2.30753 + t * 0.27061) /\n (1 + t * (0.99229 + t * 0.04481)) - t);\n for (; j < 2; j++) {\n err = jStat.erfc(x) - pp;\n x += err / (1.12837916709551257 * Math.exp(-x * x) - x * err);\n }\n return (p < 1) ? x : -x;\n};\n\n\n// Returns the inverse of the incomplete beta function\njStat.ibetainv = function ibetainv(p, a, b) {\n var EPS = 1e-8;\n var a1 = a - 1;\n var b1 = b - 1;\n var j = 0;\n var lna, lnb, pp, t, u, err, x, al, h, w, afac;\n if (p <= 0)\n return 0;\n if (p >= 1)\n return 1;\n if (a >= 1 && b >= 1) {\n pp = (p < 0.5) ? p : 1 - p;\n t = Math.sqrt(-2 * Math.log(pp));\n x = (2.30753 + t * 0.27061) / (1 + t* (0.99229 + t * 0.04481)) - t;\n if (p < 0.5)\n x = -x;\n al = (x * x - 3) / 6;\n h = 2 / (1 / (2 * a - 1) + 1 / (2 * b - 1));\n w = (x * Math.sqrt(al + h) / h) - (1 / (2 * b - 1) - 1 / (2 * a - 1)) *\n (al + 5 / 6 - 2 / (3 * h));\n x = a / (a + b * Math.exp(2 * w));\n } else {\n lna = Math.log(a / (a + b));\n lnb = Math.log(b / (a + b));\n t = Math.exp(a * lna) / a;\n u = Math.exp(b * lnb) / b;\n w = t + u;\n if (p < t / w)\n x = Math.pow(a * w * p, 1 / a);\n else\n x = 1 - Math.pow(b * w * (1 - p), 1 / b);\n }\n afac = -jStat.gammaln(a) - jStat.gammaln(b) + jStat.gammaln(a + b);\n for(; j < 10; j++) {\n if (x === 0 || x === 1)\n return x;\n err = jStat.ibeta(x, a, b) - p;\n t = Math.exp(a1 * Math.log(x) + b1 * Math.log(1 - x) + afac);\n u = err / t;\n x -= (t = u / (1 - 0.5 * Math.min(1, u * (a1 / x - b1 / (1 - x)))));\n if (x <= 0)\n x = 0.5 * (x + t);\n if (x >= 1)\n x = 0.5 * (x + t + 1);\n if (Math.abs(t) < EPS * x && j > 0)\n break;\n }\n return x;\n};\n\n\n// Returns the incomplete beta function I_x(a,b)\njStat.ibeta = function ibeta(x, a, b) {\n // Factors in front of the continued fraction.\n var bt = (x === 0 || x === 1) ? 0 :\n Math.exp(jStat.gammaln(a + b) - jStat.gammaln(a) -\n jStat.gammaln(b) + a * Math.log(x) + b *\n Math.log(1 - x));\n if (x < 0 || x > 1)\n return false;\n if (x < (a + 1) / (a + b + 2))\n // Use continued fraction directly.\n return bt * jStat.betacf(x, a, b) / a;\n // else use continued fraction after making the symmetry transformation.\n return 1 - bt * jStat.betacf(1 - x, b, a) / b;\n};\n\n\n// Returns a normal deviate (mu=0, sigma=1).\n// If n and m are specified it returns a object of normal deviates.\njStat.randn = function randn(n, m) {\n var u, v, x, y, q;\n if (!m)\n m = n;\n if (n)\n return jStat.create(n, m, function() { return jStat.randn(); });\n do {\n u = jStat._random_fn();\n v = 1.7156 * (jStat._random_fn() - 0.5);\n x = u - 0.449871;\n y = Math.abs(v) + 0.386595;\n q = x * x + y * (0.19600 * y - 0.25472 * x);\n } while (q > 0.27597 && (q > 0.27846 || v * v > -4 * Math.log(u) * u * u));\n return v / u;\n};\n\n\n// Returns a gamma deviate by the method of Marsaglia and Tsang.\njStat.randg = function randg(shape, n, m) {\n var oalph = shape;\n var a1, a2, u, v, x, mat;\n if (!m)\n m = n;\n if (!shape)\n shape = 1;\n if (n) {\n mat = jStat.zeros(n,m);\n mat.alter(function() { return jStat.randg(shape); });\n return mat;\n }\n if (shape < 1)\n shape += 1;\n a1 = shape - 1 / 3;\n a2 = 1 / Math.sqrt(9 * a1);\n do {\n do {\n x = jStat.randn();\n v = 1 + a2 * x;\n } while(v <= 0);\n v = v * v * v;\n u = jStat._random_fn();\n } while(u > 1 - 0.331 * Math.pow(x, 4) &&\n Math.log(u) > 0.5 * x*x + a1 * (1 - v + Math.log(v)));\n // alpha > 1\n if (shape == oalph)\n return a1 * v;\n // alpha < 1\n do {\n u = jStat._random_fn();\n } while(u === 0);\n return Math.pow(u, 1 / oalph) * a1 * v;\n};\n\n\n// making use of static methods on the instance\n(function(funcs) {\n for (var i = 0; i < funcs.length; i++) (function(passfunc) {\n jStat.fn[passfunc] = function() {\n return jStat(\n jStat.map(this, function(value) { return jStat[passfunc](value); }));\n }\n })(funcs[i]);\n})('gammaln gammafn factorial factorialln'.split(' '));\n\n\n(function(funcs) {\n for (var i = 0; i < funcs.length; i++) (function(passfunc) {\n jStat.fn[passfunc] = function() {\n return jStat(jStat[passfunc].apply(null, arguments));\n };\n })(funcs[i]);\n})('randn'.split(' '));\n\n}(jStat, Math));\n(function(jStat, Math) {\n\n// generate all distribution instance methods\n(function(list) {\n for (var i = 0; i < list.length; i++) (function(func) {\n // distribution instance method\n jStat[func] = function f(a, b, c) {\n if (!(this instanceof f))\n return new f(a, b, c);\n this._a = a;\n this._b = b;\n this._c = c;\n return this;\n };\n // distribution method to be used on a jStat instance\n jStat.fn[func] = function(a, b, c) {\n var newthis = jStat[func](a, b, c);\n newthis.data = this;\n return newthis;\n };\n // sample instance method\n jStat[func].prototype.sample = function(arr) {\n var a = this._a;\n var b = this._b;\n var c = this._c;\n if (arr)\n return jStat.alter(arr, function() {\n return jStat[func].sample(a, b, c);\n });\n else\n return jStat[func].sample(a, b, c);\n };\n // generate the pdf, cdf and inv instance methods\n (function(vals) {\n for (var i = 0; i < vals.length; i++) (function(fnfunc) {\n jStat[func].prototype[fnfunc] = function(x) {\n var a = this._a;\n var b = this._b;\n var c = this._c;\n if (!x && x !== 0)\n x = this.data;\n if (typeof x !== 'number') {\n return jStat.fn.map.call(x, function(x) {\n return jStat[func][fnfunc](x, a, b, c);\n });\n }\n return jStat[func][fnfunc](x, a, b, c);\n };\n })(vals[i]);\n })('pdf cdf inv'.split(' '));\n // generate the mean, median, mode and variance instance methods\n (function(vals) {\n for (var i = 0; i < vals.length; i++) (function(fnfunc) {\n jStat[func].prototype[fnfunc] = function() {\n return jStat[func][fnfunc](this._a, this._b, this._c);\n };\n })(vals[i]);\n })('mean median mode variance'.split(' '));\n })(list[i]);\n})((\n 'beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy ' +\n 'laplace lognormal noncentralt normal pareto studentt weibull uniform ' +\n 'binomial negbin hypgeom poisson triangular tukey arcsine'\n).split(' '));\n\n\n\n// extend beta function with static methods\njStat.extend(jStat.beta, {\n pdf: function pdf(x, alpha, beta) {\n // PDF is zero outside the support\n if (x > 1 || x < 0)\n return 0;\n // PDF is one for the uniform case\n if (alpha == 1 && beta == 1)\n return 1;\n\n if (alpha < 512 && beta < 512) {\n return (Math.pow(x, alpha - 1) * Math.pow(1 - x, beta - 1)) /\n jStat.betafn(alpha, beta);\n } else {\n return Math.exp((alpha - 1) * Math.log(x) +\n (beta - 1) * Math.log(1 - x) -\n jStat.betaln(alpha, beta));\n }\n },\n\n cdf: function cdf(x, alpha, beta) {\n return (x > 1 || x < 0) ? (x > 1) * 1 : jStat.ibeta(x, alpha, beta);\n },\n\n inv: function inv(x, alpha, beta) {\n return jStat.ibetainv(x, alpha, beta);\n },\n\n mean: function mean(alpha, beta) {\n return alpha / (alpha + beta);\n },\n\n median: function median(alpha, beta) {\n return jStat.ibetainv(0.5, alpha, beta);\n },\n\n mode: function mode(alpha, beta) {\n return (alpha - 1 ) / ( alpha + beta - 2);\n },\n\n // return a random sample\n sample: function sample(alpha, beta) {\n var u = jStat.randg(alpha);\n return u / (u + jStat.randg(beta));\n },\n\n variance: function variance(alpha, beta) {\n return (alpha * beta) / (Math.pow(alpha + beta, 2) * (alpha + beta + 1));\n }\n});\n\n// extend F function with static methods\njStat.extend(jStat.centralF, {\n // This implementation of the pdf function avoids float overflow\n // See the way that R calculates this value:\n // https://svn.r-project.org/R/trunk/src/nmath/df.c\n pdf: function pdf(x, df1, df2) {\n var p, q, f;\n\n if (x < 0)\n return 0;\n\n if (df1 <= 2) {\n if (x === 0 && df1 < 2) {\n return Infinity;\n }\n if (x === 0 && df1 === 2) {\n return 1;\n }\n return (1 / jStat.betafn(df1 / 2, df2 / 2)) *\n Math.pow(df1 / df2, df1 / 2) *\n Math.pow(x, (df1/2) - 1) *\n Math.pow((1 + (df1 / df2) * x), -(df1 + df2) / 2);\n }\n\n p = (df1 * x) / (df2 + x * df1);\n q = df2 / (df2 + x * df1);\n f = df1 * q / 2.0;\n return f * jStat.binomial.pdf((df1 - 2) / 2, (df1 + df2 - 2) / 2, p);\n },\n\n cdf: function cdf(x, df1, df2) {\n if (x < 0)\n return 0;\n return jStat.ibeta((df1 * x) / (df1 * x + df2), df1 / 2, df2 / 2);\n },\n\n inv: function inv(x, df1, df2) {\n return df2 / (df1 * (1 / jStat.ibetainv(x, df1 / 2, df2 / 2) - 1));\n },\n\n mean: function mean(df1, df2) {\n return (df2 > 2) ? df2 / (df2 - 2) : undefined;\n },\n\n mode: function mode(df1, df2) {\n return (df1 > 2) ? (df2 * (df1 - 2)) / (df1 * (df2 + 2)) : undefined;\n },\n\n // return a random sample\n sample: function sample(df1, df2) {\n var x1 = jStat.randg(df1 / 2) * 2;\n var x2 = jStat.randg(df2 / 2) * 2;\n return (x1 / df1) / (x2 / df2);\n },\n\n variance: function variance(df1, df2) {\n if (df2 <= 4)\n return undefined;\n return 2 * df2 * df2 * (df1 + df2 - 2) /\n (df1 * (df2 - 2) * (df2 - 2) * (df2 - 4));\n }\n});\n\n\n// extend cauchy function with static methods\njStat.extend(jStat.cauchy, {\n pdf: function pdf(x, local, scale) {\n if (scale < 0) { return 0; }\n\n return (scale / (Math.pow(x - local, 2) + Math.pow(scale, 2))) / Math.PI;\n },\n\n cdf: function cdf(x, local, scale) {\n return Math.atan((x - local) / scale) / Math.PI + 0.5;\n },\n\n inv: function(p, local, scale) {\n return local + scale * Math.tan(Math.PI * (p - 0.5));\n },\n\n median: function median(local/*, scale*/) {\n return local;\n },\n\n mode: function mode(local/*, scale*/) {\n return local;\n },\n\n sample: function sample(local, scale) {\n return jStat.randn() *\n Math.sqrt(1 / (2 * jStat.randg(0.5))) * scale + local;\n }\n});\n\n\n\n// extend chisquare function with static methods\njStat.extend(jStat.chisquare, {\n pdf: function pdf(x, dof) {\n if (x < 0)\n return 0;\n return (x === 0 && dof === 2) ? 0.5 :\n Math.exp((dof / 2 - 1) * Math.log(x) - x / 2 - (dof / 2) *\n Math.log(2) - jStat.gammaln(dof / 2));\n },\n\n cdf: function cdf(x, dof) {\n if (x < 0)\n return 0;\n return jStat.lowRegGamma(dof / 2, x / 2);\n },\n\n inv: function(p, dof) {\n return 2 * jStat.gammapinv(p, 0.5 * dof);\n },\n\n mean : function(dof) {\n return dof;\n },\n\n // TODO: this is an approximation (is there a better way?)\n median: function median(dof) {\n return dof * Math.pow(1 - (2 / (9 * dof)), 3);\n },\n\n mode: function mode(dof) {\n return (dof - 2 > 0) ? dof - 2 : 0;\n },\n\n sample: function sample(dof) {\n return jStat.randg(dof / 2) * 2;\n },\n\n variance: function variance(dof) {\n return 2 * dof;\n }\n});\n\n\n\n// extend exponential function with static methods\njStat.extend(jStat.exponential, {\n pdf: function pdf(x, rate) {\n return x < 0 ? 0 : rate * Math.exp(-rate * x);\n },\n\n cdf: function cdf(x, rate) {\n return x < 0 ? 0 : 1 - Math.exp(-rate * x);\n },\n\n inv: function(p, rate) {\n return -Math.log(1 - p) / rate;\n },\n\n mean : function(rate) {\n return 1 / rate;\n },\n\n median: function (rate) {\n return (1 / rate) * Math.log(2);\n },\n\n mode: function mode(/*rate*/) {\n return 0;\n },\n\n sample: function sample(rate) {\n return -1 / rate * Math.log(jStat._random_fn());\n },\n\n variance : function(rate) {\n return Math.pow(rate, -2);\n }\n});\n\n\n\n// extend gamma function with static methods\njStat.extend(jStat.gamma, {\n pdf: function pdf(x, shape, scale) {\n if (x < 0)\n return 0;\n return (x === 0 && shape === 1) ? 1 / scale :\n Math.exp((shape - 1) * Math.log(x) - x / scale -\n jStat.gammaln(shape) - shape * Math.log(scale));\n },\n\n cdf: function cdf(x, shape, scale) {\n if (x < 0)\n return 0;\n return jStat.lowRegGamma(shape, x / scale);\n },\n\n inv: function(p, shape, scale) {\n return jStat.gammapinv(p, shape) * scale;\n },\n\n mean : function(shape, scale) {\n return shape * scale;\n },\n\n mode: function mode(shape, scale) {\n if(shape > 1) return (shape - 1) * scale;\n return undefined;\n },\n\n sample: function sample(shape, scale) {\n return jStat.randg(shape) * scale;\n },\n\n variance: function variance(shape, scale) {\n return shape * scale * scale;\n }\n});\n\n// extend inverse gamma function with static methods\njStat.extend(jStat.invgamma, {\n pdf: function pdf(x, shape, scale) {\n if (x <= 0)\n return 0;\n return Math.exp(-(shape + 1) * Math.log(x) - scale / x -\n jStat.gammaln(shape) + shape * Math.log(scale));\n },\n\n cdf: function cdf(x, shape, scale) {\n if (x <= 0)\n return 0;\n return 1 - jStat.lowRegGamma(shape, scale / x);\n },\n\n inv: function(p, shape, scale) {\n return scale / jStat.gammapinv(1 - p, shape);\n },\n\n mean : function(shape, scale) {\n return (shape > 1) ? scale / (shape - 1) : undefined;\n },\n\n mode: function mode(shape, scale) {\n return scale / (shape + 1);\n },\n\n sample: function sample(shape, scale) {\n return scale / jStat.randg(shape);\n },\n\n variance: function variance(shape, scale) {\n if (shape <= 2)\n return undefined;\n return scale * scale / ((shape - 1) * (shape - 1) * (shape - 2));\n }\n});\n\n\n// extend kumaraswamy function with static methods\njStat.extend(jStat.kumaraswamy, {\n pdf: function pdf(x, alpha, beta) {\n if (x === 0 && alpha === 1)\n return beta;\n else if (x === 1 && beta === 1)\n return alpha;\n return Math.exp(Math.log(alpha) + Math.log(beta) + (alpha - 1) *\n Math.log(x) + (beta - 1) *\n Math.log(1 - Math.pow(x, alpha)));\n },\n\n cdf: function cdf(x, alpha, beta) {\n if (x < 0)\n return 0;\n else if (x > 1)\n return 1;\n return (1 - Math.pow(1 - Math.pow(x, alpha), beta));\n },\n\n inv: function inv(p, alpha, beta) {\n return Math.pow(1 - Math.pow(1 - p, 1 / beta), 1 / alpha);\n },\n\n mean : function(alpha, beta) {\n return (beta * jStat.gammafn(1 + 1 / alpha) *\n jStat.gammafn(beta)) / (jStat.gammafn(1 + 1 / alpha + beta));\n },\n\n median: function median(alpha, beta) {\n return Math.pow(1 - Math.pow(2, -1 / beta), 1 / alpha);\n },\n\n mode: function mode(alpha, beta) {\n if (!(alpha >= 1 && beta >= 1 && (alpha !== 1 && beta !== 1)))\n return undefined;\n return Math.pow((alpha - 1) / (alpha * beta - 1), 1 / alpha);\n },\n\n variance: function variance(/*alpha, beta*/) {\n throw new Error('variance not yet implemented');\n // TODO: complete this\n }\n});\n\n\n\n// extend lognormal function with static methods\njStat.extend(jStat.lognormal, {\n pdf: function pdf(x, mu, sigma) {\n if (x <= 0)\n return 0;\n return Math.exp(-Math.log(x) - 0.5 * Math.log(2 * Math.PI) -\n Math.log(sigma) - Math.pow(Math.log(x) - mu, 2) /\n (2 * sigma * sigma));\n },\n\n cdf: function cdf(x, mu, sigma) {\n if (x < 0)\n return 0;\n return 0.5 +\n (0.5 * jStat.erf((Math.log(x) - mu) / Math.sqrt(2 * sigma * sigma)));\n },\n\n inv: function(p, mu, sigma) {\n return Math.exp(-1.41421356237309505 * sigma * jStat.erfcinv(2 * p) + mu);\n },\n\n mean: function mean(mu, sigma) {\n return Math.exp(mu + sigma * sigma / 2);\n },\n\n median: function median(mu/*, sigma*/) {\n return Math.exp(mu);\n },\n\n mode: function mode(mu, sigma) {\n return Math.exp(mu - sigma * sigma);\n },\n\n sample: function sample(mu, sigma) {\n return Math.exp(jStat.randn() * sigma + mu);\n },\n\n variance: function variance(mu, sigma) {\n return (Math.exp(sigma * sigma) - 1) * Math.exp(2 * mu + sigma * sigma);\n }\n});\n\n\n\n// extend noncentralt function with static methods\njStat.extend(jStat.noncentralt, {\n pdf: function pdf(x, dof, ncp) {\n var tol = 1e-14;\n if (Math.abs(ncp) < tol) // ncp approx 0; use student-t\n return jStat.studentt.pdf(x, dof)\n\n if (Math.abs(x) < tol) { // different formula for x == 0\n return Math.exp(jStat.gammaln((dof + 1) / 2) - ncp * ncp / 2 -\n 0.5 * Math.log(Math.PI * dof) - jStat.gammaln(dof / 2));\n }\n\n // formula for x != 0\n return dof / x *\n (jStat.noncentralt.cdf(x * Math.sqrt(1 + 2 / dof), dof+2, ncp) -\n jStat.noncentralt.cdf(x, dof, ncp));\n },\n\n cdf: function cdf(x, dof, ncp) {\n var tol = 1e-14;\n var min_iterations = 200;\n\n if (Math.abs(ncp) < tol) // ncp approx 0; use student-t\n return jStat.studentt.cdf(x, dof);\n\n // turn negative x into positive and flip result afterwards\n var flip = false;\n if (x < 0) {\n flip = true;\n ncp = -ncp;\n }\n\n var prob = jStat.normal.cdf(-ncp, 0, 1);\n var value = tol + 1;\n // use value at last two steps to determine convergence\n var lastvalue = value;\n var y = x * x / (x * x + dof);\n var j = 0;\n var p = Math.exp(-ncp * ncp / 2);\n var q = Math.exp(-ncp * ncp / 2 - 0.5 * Math.log(2) -\n jStat.gammaln(3 / 2)) * ncp;\n while (j < min_iterations || lastvalue > tol || value > tol) {\n lastvalue = value;\n if (j > 0) {\n p *= (ncp * ncp) / (2 * j);\n q *= (ncp * ncp) / (2 * (j + 1 / 2));\n }\n value = p * jStat.beta.cdf(y, j + 0.5, dof / 2) +\n q * jStat.beta.cdf(y, j+1, dof/2);\n prob += 0.5 * value;\n j++;\n }\n\n return flip ? (1 - prob) : prob;\n }\n});\n\n\n// extend normal function with static methods\njStat.extend(jStat.normal, {\n pdf: function pdf(x, mean, std) {\n return Math.exp(-0.5 * Math.log(2 * Math.PI) -\n Math.log(std) - Math.pow(x - mean, 2) / (2 * std * std));\n },\n\n cdf: function cdf(x, mean, std) {\n return 0.5 * (1 + jStat.erf((x - mean) / Math.sqrt(2 * std * std)));\n },\n\n inv: function(p, mean, std) {\n return -1.41421356237309505 * std * jStat.erfcinv(2 * p) + mean;\n },\n\n mean : function(mean/*, std*/) {\n return mean;\n },\n\n median: function median(mean/*, std*/) {\n return mean;\n },\n\n mode: function (mean/*, std*/) {\n return mean;\n },\n\n sample: function sample(mean, std) {\n return jStat.randn() * std + mean;\n },\n\n variance : function(mean, std) {\n return std * std;\n }\n});\n\n\n\n// extend pareto function with static methods\njStat.extend(jStat.pareto, {\n pdf: function pdf(x, scale, shape) {\n if (x < scale)\n return 0;\n return (shape * Math.pow(scale, shape)) / Math.pow(x, shape + 1);\n },\n\n cdf: function cdf(x, scale, shape) {\n if (x < scale)\n return 0;\n return 1 - Math.pow(scale / x, shape);\n },\n\n inv: function inv(p, scale, shape) {\n return scale / Math.pow(1 - p, 1 / shape);\n },\n\n mean: function mean(scale, shape) {\n if (shape <= 1)\n return undefined;\n return (shape * Math.pow(scale, shape)) / (shape - 1);\n },\n\n median: function median(scale, shape) {\n return scale * (shape * Math.SQRT2);\n },\n\n mode: function mode(scale/*, shape*/) {\n return scale;\n },\n\n variance : function(scale, shape) {\n if (shape <= 2)\n return undefined;\n return (scale*scale * shape) / (Math.pow(shape - 1, 2) * (shape - 2));\n }\n});\n\n\n\n// extend studentt function with static methods\njStat.extend(jStat.studentt, {\n pdf: function pdf(x, dof) {\n dof = dof > 1e100 ? 1e100 : dof;\n return (1/(Math.sqrt(dof) * jStat.betafn(0.5, dof/2))) *\n Math.pow(1 + ((x * x) / dof), -((dof + 1) / 2));\n },\n\n cdf: function cdf(x, dof) {\n var dof2 = dof / 2;\n return jStat.ibeta((x + Math.sqrt(x * x + dof)) /\n (2 * Math.sqrt(x * x + dof)), dof2, dof2);\n },\n\n inv: function(p, dof) {\n var x = jStat.ibetainv(2 * Math.min(p, 1 - p), 0.5 * dof, 0.5);\n x = Math.sqrt(dof * (1 - x) / x);\n return (p > 0.5) ? x : -x;\n },\n\n mean: function mean(dof) {\n return (dof > 1) ? 0 : undefined;\n },\n\n median: function median(/*dof*/) {\n return 0;\n },\n\n mode: function mode(/*dof*/) {\n return 0;\n },\n\n sample: function sample(dof) {\n return jStat.randn() * Math.sqrt(dof / (2 * jStat.randg(dof / 2)));\n },\n\n variance: function variance(dof) {\n return (dof > 2) ? dof / (dof - 2) : (dof > 1) ? Infinity : undefined;\n }\n});\n\n\n\n// extend weibull function with static methods\njStat.extend(jStat.weibull, {\n pdf: function pdf(x, scale, shape) {\n if (x < 0 || scale < 0 || shape < 0)\n return 0;\n return (shape / scale) * Math.pow((x / scale), (shape - 1)) *\n Math.exp(-(Math.pow((x / scale), shape)));\n },\n\n cdf: function cdf(x, scale, shape) {\n return x < 0 ? 0 : 1 - Math.exp(-Math.pow((x / scale), shape));\n },\n\n inv: function(p, scale, shape) {\n return scale * Math.pow(-Math.log(1 - p), 1 / shape);\n },\n\n mean : function(scale, shape) {\n return scale * jStat.gammafn(1 + 1 / shape);\n },\n\n median: function median(scale, shape) {\n return scale * Math.pow(Math.log(2), 1 / shape);\n },\n\n mode: function mode(scale, shape) {\n if (shape <= 1)\n return 0;\n return scale * Math.pow((shape - 1) / shape, 1 / shape);\n },\n\n sample: function sample(scale, shape) {\n return scale * Math.pow(-Math.log(jStat._random_fn()), 1 / shape);\n },\n\n variance: function variance(scale, shape) {\n return scale * scale * jStat.gammafn(1 + 2 / shape) -\n Math.pow(jStat.weibull.mean(scale, shape), 2);\n }\n});\n\n\n\n// extend uniform function with static methods\njStat.extend(jStat.uniform, {\n pdf: function pdf(x, a, b) {\n return (x < a || x > b) ? 0 : 1 / (b - a);\n },\n\n cdf: function cdf(x, a, b) {\n if (x < a)\n return 0;\n else if (x < b)\n return (x - a) / (b - a);\n return 1;\n },\n\n inv: function(p, a, b) {\n return a + (p * (b - a));\n },\n\n mean: function mean(a, b) {\n return 0.5 * (a + b);\n },\n\n median: function median(a, b) {\n return jStat.mean(a, b);\n },\n\n mode: function mode(/*a, b*/) {\n throw new Error('mode is not yet implemented');\n },\n\n sample: function sample(a, b) {\n return (a / 2 + b / 2) + (b / 2 - a / 2) * (2 * jStat._random_fn() - 1);\n },\n\n variance: function variance(a, b) {\n return Math.pow(b - a, 2) / 12;\n }\n});\n\n\n// Got this from http://www.math.ucla.edu/~tom/distributions/binomial.html\nfunction betinc(x, a, b, eps) {\n var a0 = 0;\n var b0 = 1;\n var a1 = 1;\n var b1 = 1;\n var m9 = 0;\n var a2 = 0;\n var c9;\n\n while (Math.abs((a1 - a2) / a1) > eps) {\n a2 = a1;\n c9 = -(a + m9) * (a + b + m9) * x / (a + 2 * m9) / (a + 2 * m9 + 1);\n a0 = a1 + c9 * a0;\n b0 = b1 + c9 * b0;\n m9 = m9 + 1;\n c9 = m9 * (b - m9) * x / (a + 2 * m9 - 1) / (a + 2 * m9);\n a1 = a0 + c9 * a1;\n b1 = b0 + c9 * b1;\n a0 = a0 / b1;\n b0 = b0 / b1;\n a1 = a1 / b1;\n b1 = 1;\n }\n\n return a1 / a;\n}\n\n\n// extend uniform function with static methods\njStat.extend(jStat.binomial, {\n pdf: function pdf(k, n, p) {\n return (p === 0 || p === 1) ?\n ((n * p) === k ? 1 : 0) :\n jStat.combination(n, k) * Math.pow(p, k) * Math.pow(1 - p, n - k);\n },\n\n cdf: function cdf(x, n, p) {\n var betacdf;\n var eps = 1e-10;\n\n if (x < 0)\n return 0;\n if (x >= n)\n return 1;\n if (p < 0 || p > 1 || n <= 0)\n return NaN;\n\n x = Math.floor(x);\n var z = p;\n var a = x + 1;\n var b = n - x;\n var s = a + b;\n var bt = Math.exp(jStat.gammaln(s) - jStat.gammaln(b) -\n jStat.gammaln(a) + a * Math.log(z) + b * Math.log(1 - z));\n\n if (z < (a + 1) / (s + 2))\n betacdf = bt * betinc(z, a, b, eps);\n else\n betacdf = 1 - bt * betinc(1 - z, b, a, eps);\n\n return Math.round((1 - betacdf) * (1 / eps)) / (1 / eps);\n }\n});\n\n\n\n// extend uniform function with static methods\njStat.extend(jStat.negbin, {\n pdf: function pdf(k, r, p) {\n if (k !== k >>> 0)\n return false;\n if (k < 0)\n return 0;\n return jStat.combination(k + r - 1, r - 1) *\n Math.pow(1 - p, k) * Math.pow(p, r);\n },\n\n cdf: function cdf(x, r, p) {\n var sum = 0,\n k = 0;\n if (x < 0) return 0;\n for (; k <= x; k++) {\n sum += jStat.negbin.pdf(k, r, p);\n }\n return sum;\n }\n});\n\n\n\n// extend uniform function with static methods\njStat.extend(jStat.hypgeom, {\n pdf: function pdf(k, N, m, n) {\n // Hypergeometric PDF.\n\n // A simplification of the CDF algorithm below.\n\n // k = number of successes drawn\n // N = population size\n // m = number of successes in population\n // n = number of items drawn from population\n\n if(k !== k | 0) {\n return false;\n } else if(k < 0 || k < m - (N - n)) {\n // It's impossible to have this few successes drawn.\n return 0;\n } else if(k > n || k > m) {\n // It's impossible to have this many successes drawn.\n return 0;\n } else if (m * 2 > N) {\n // More than half the population is successes.\n\n if(n * 2 > N) {\n // More than half the population is sampled.\n\n return jStat.hypgeom.pdf(N - m - n + k, N, N - m, N - n)\n } else {\n // Half or less of the population is sampled.\n\n return jStat.hypgeom.pdf(n - k, N, N - m, n);\n }\n\n } else if(n * 2 > N) {\n // Half or less is successes.\n\n return jStat.hypgeom.pdf(m - k, N, m, N - n);\n\n } else if(m < n) {\n // We want to have the number of things sampled to be less than the\n // successes available. So swap the definitions of successful and sampled.\n return jStat.hypgeom.pdf(k, N, n, m);\n } else {\n // If we get here, half or less of the population was sampled, half or\n // less of it was successes, and we had fewer sampled things than\n // successes. Now we can do this complicated iterative algorithm in an\n // efficient way.\n\n // The basic premise of the algorithm is that we partially normalize our\n // intermediate product to keep it in a numerically good region, and then\n // finish the normalization at the end.\n\n // This variable holds the scaled probability of the current number of\n // successes.\n var scaledPDF = 1;\n\n // This keeps track of how much we have normalized.\n var samplesDone = 0;\n\n for(var i = 0; i < k; i++) {\n // For every possible number of successes up to that observed...\n\n while(scaledPDF > 1 && samplesDone < n) {\n // Intermediate result is growing too big. Apply some of the\n // normalization to shrink everything.\n\n scaledPDF *= 1 - (m / (N - samplesDone));\n\n // Say we've normalized by this sample already.\n samplesDone++;\n }\n\n // Work out the partially-normalized hypergeometric PDF for the next\n // number of successes\n scaledPDF *= (n - i) * (m - i) / ((i + 1) * (N - m - n + i + 1));\n }\n\n for(; samplesDone < n; samplesDone++) {\n // Apply all the rest of the normalization\n scaledPDF *= 1 - (m / (N - samplesDone));\n }\n\n // Bound answer sanely before returning.\n return Math.min(1, Math.max(0, scaledPDF));\n }\n },\n\n cdf: function cdf(x, N, m, n) {\n // Hypergeometric CDF.\n\n // This algorithm is due to Prof. Thomas S. Ferguson, ,\n // and comes from his hypergeometric test calculator at\n // .\n\n // x = number of successes drawn\n // N = population size\n // m = number of successes in population\n // n = number of items drawn from population\n\n if(x < 0 || x < m - (N - n)) {\n // It's impossible to have this few successes drawn or fewer.\n return 0;\n } else if(x >= n || x >= m) {\n // We will always have this many successes or fewer.\n return 1;\n } else if (m * 2 > N) {\n // More than half the population is successes.\n\n if(n * 2 > N) {\n // More than half the population is sampled.\n\n return jStat.hypgeom.cdf(N - m - n + x, N, N - m, N - n)\n } else {\n // Half or less of the population is sampled.\n\n return 1 - jStat.hypgeom.cdf(n - x - 1, N, N - m, n);\n }\n\n } else if(n * 2 > N) {\n // Half or less is successes.\n\n return 1 - jStat.hypgeom.cdf(m - x - 1, N, m, N - n);\n\n } else if(m < n) {\n // We want to have the number of things sampled to be less than the\n // successes available. So swap the definitions of successful and sampled.\n return jStat.hypgeom.cdf(x, N, n, m);\n } else {\n // If we get here, half or less of the population was sampled, half or\n // less of it was successes, and we had fewer sampled things than\n // successes. Now we can do this complicated iterative algorithm in an\n // efficient way.\n\n // The basic premise of the algorithm is that we partially normalize our\n // intermediate sum to keep it in a numerically good region, and then\n // finish the normalization at the end.\n\n // Holds the intermediate, scaled total CDF.\n var scaledCDF = 1;\n\n // This variable holds the scaled probability of the current number of\n // successes.\n var scaledPDF = 1;\n\n // This keeps track of how much we have normalized.\n var samplesDone = 0;\n\n for(var i = 0; i < x; i++) {\n // For every possible number of successes up to that observed...\n\n while(scaledCDF > 1 && samplesDone < n) {\n // Intermediate result is growing too big. Apply some of the\n // normalization to shrink everything.\n\n var factor = 1 - (m / (N - samplesDone));\n\n scaledPDF *= factor;\n scaledCDF *= factor;\n\n // Say we've normalized by this sample already.\n samplesDone++;\n }\n\n // Work out the partially-normalized hypergeometric PDF for the next\n // number of successes\n scaledPDF *= (n - i) * (m - i) / ((i + 1) * (N - m - n + i + 1));\n\n // Add to the CDF answer.\n scaledCDF += scaledPDF;\n }\n\n for(; samplesDone < n; samplesDone++) {\n // Apply all the rest of the normalization\n scaledCDF *= 1 - (m / (N - samplesDone));\n }\n\n // Bound answer sanely before returning.\n return Math.min(1, Math.max(0, scaledCDF));\n }\n }\n});\n\n\n\n// extend uniform function with static methods\njStat.extend(jStat.poisson, {\n pdf: function pdf(k, l) {\n if (l < 0 || (k % 1) !== 0 || k < 0) {\n return 0;\n }\n\n return Math.pow(l, k) * Math.exp(-l) / jStat.factorial(k);\n },\n\n cdf: function cdf(x, l) {\n var sumarr = [],\n k = 0;\n if (x < 0) return 0;\n for (; k <= x; k++) {\n sumarr.push(jStat.poisson.pdf(k, l));\n }\n return jStat.sum(sumarr);\n },\n\n mean : function(l) {\n return l;\n },\n\n variance : function(l) {\n return l;\n },\n\n sampleSmall: function sampleSmall(l) {\n var p = 1, k = 0, L = Math.exp(-l);\n do {\n k++;\n p *= jStat._random_fn();\n } while (p > L);\n return k - 1;\n },\n\n sampleLarge: function sampleLarge(l) {\n var lam = l;\n var k;\n var U, V, slam, loglam, a, b, invalpha, vr, us;\n\n slam = Math.sqrt(lam);\n loglam = Math.log(lam);\n b = 0.931 + 2.53 * slam;\n a = -0.059 + 0.02483 * b;\n invalpha = 1.1239 + 1.1328 / (b - 3.4);\n vr = 0.9277 - 3.6224 / (b - 2);\n\n while (1) {\n U = Math.random() - 0.5;\n V = Math.random();\n us = 0.5 - Math.abs(U);\n k = Math.floor((2 * a / us + b) * U + lam + 0.43);\n if ((us >= 0.07) && (V <= vr)) {\n return k;\n }\n if ((k < 0) || ((us < 0.013) && (V > us))) {\n continue;\n }\n /* log(V) == log(0.0) ok here */\n /* if U==0.0 so that us==0.0, log is ok since always returns */\n if ((Math.log(V) + Math.log(invalpha) - Math.log(a / (us * us) + b)) <= (-lam + k * loglam - jStat.loggam(k + 1))) {\n return k;\n }\n }\n },\n\n sample: function sample(l) {\n if (l < 10)\n return this.sampleSmall(l);\n else\n return this.sampleLarge(l);\n }\n});\n\n// extend triangular function with static methods\njStat.extend(jStat.triangular, {\n pdf: function pdf(x, a, b, c) {\n if (b <= a || c < a || c > b) {\n return NaN;\n } else {\n if (x < a || x > b) {\n return 0;\n } else if (x < c) {\n return (2 * (x - a)) / ((b - a) * (c - a));\n } else if (x === c) {\n return (2 / (b - a));\n } else { // x > c\n return (2 * (b - x)) / ((b - a) * (b - c));\n }\n }\n },\n\n cdf: function cdf(x, a, b, c) {\n if (b <= a || c < a || c > b)\n return NaN;\n if (x <= a)\n return 0;\n else if (x >= b)\n return 1;\n if (x <= c)\n return Math.pow(x - a, 2) / ((b - a) * (c - a));\n else // x > c\n return 1 - Math.pow(b - x, 2) / ((b - a) * (b - c));\n },\n\n inv: function inv(p, a, b, c) {\n if (b <= a || c < a || c > b) {\n return NaN;\n } else {\n if (p <= ((c - a) / (b - a))) {\n return a + (b - a) * Math.sqrt(p * ((c - a) / (b - a)));\n } else { // p > ((c - a) / (b - a))\n return a + (b - a) * (1 - Math.sqrt((1 - p) * (1 - ((c - a) / (b - a)))));\n }\n }\n },\n\n mean: function mean(a, b, c) {\n return (a + b + c) / 3;\n },\n\n median: function median(a, b, c) {\n if (c <= (a + b) / 2) {\n return b - Math.sqrt((b - a) * (b - c)) / Math.sqrt(2);\n } else if (c > (a + b) / 2) {\n return a + Math.sqrt((b - a) * (c - a)) / Math.sqrt(2);\n }\n },\n\n mode: function mode(a, b, c) {\n return c;\n },\n\n sample: function sample(a, b, c) {\n var u = jStat._random_fn();\n if (u < ((c - a) / (b - a)))\n return a + Math.sqrt(u * (b - a) * (c - a))\n return b - Math.sqrt((1 - u) * (b - a) * (b - c));\n },\n\n variance: function variance(a, b, c) {\n return (a * a + b * b + c * c - a * b - a * c - b * c) / 18;\n }\n});\n\n\n// extend arcsine function with static methods\njStat.extend(jStat.arcsine, {\n pdf: function pdf(x, a, b) {\n if (b <= a) return NaN;\n\n return (x <= a || x >= b) ? 0 :\n (2 / Math.PI) *\n Math.pow(Math.pow(b - a, 2) -\n Math.pow(2 * x - a - b, 2), -0.5);\n },\n\n cdf: function cdf(x, a, b) {\n if (x < a)\n return 0;\n else if (x < b)\n return (2 / Math.PI) * Math.asin(Math.sqrt((x - a)/(b - a)));\n return 1;\n },\n\n inv: function(p, a, b) {\n return a + (0.5 - 0.5 * Math.cos(Math.PI * p)) * (b - a);\n },\n\n mean: function mean(a, b) {\n if (b <= a) return NaN;\n return (a + b) / 2;\n },\n\n median: function median(a, b) {\n if (b <= a) return NaN;\n return (a + b) / 2;\n },\n\n mode: function mode(/*a, b*/) {\n throw new Error('mode is not yet implemented');\n },\n\n sample: function sample(a, b) {\n return ((a + b) / 2) + ((b - a) / 2) *\n Math.sin(2 * Math.PI * jStat.uniform.sample(0, 1));\n },\n\n variance: function variance(a, b) {\n if (b <= a) return NaN;\n return Math.pow(b - a, 2) / 8;\n }\n});\n\n\nfunction laplaceSign(x) { return x / Math.abs(x); }\n\njStat.extend(jStat.laplace, {\n pdf: function pdf(x, mu, b) {\n return (b <= 0) ? 0 : (Math.exp(-Math.abs(x - mu) / b)) / (2 * b);\n },\n\n cdf: function cdf(x, mu, b) {\n if (b <= 0) { return 0; }\n\n if(x < mu) {\n return 0.5 * Math.exp((x - mu) / b);\n } else {\n return 1 - 0.5 * Math.exp(- (x - mu) / b);\n }\n },\n\n mean: function(mu/*, b*/) {\n return mu;\n },\n\n median: function(mu/*, b*/) {\n return mu;\n },\n\n mode: function(mu/*, b*/) {\n return mu;\n },\n\n variance: function(mu, b) {\n return 2 * b * b;\n },\n\n sample: function sample(mu, b) {\n var u = jStat._random_fn() - 0.5;\n\n return mu - (b * laplaceSign(u) * Math.log(1 - (2 * Math.abs(u))));\n }\n});\n\nfunction tukeyWprob(w, rr, cc) {\n var nleg = 12;\n var ihalf = 6;\n\n var C1 = -30;\n var C2 = -50;\n var C3 = 60;\n var bb = 8;\n var wlar = 3;\n var wincr1 = 2;\n var wincr2 = 3;\n var xleg = [\n 0.981560634246719250690549090149,\n 0.904117256370474856678465866119,\n 0.769902674194304687036893833213,\n 0.587317954286617447296702418941,\n 0.367831498998180193752691536644,\n 0.125233408511468915472441369464\n ];\n var aleg = [\n 0.047175336386511827194615961485,\n 0.106939325995318430960254718194,\n 0.160078328543346226334652529543,\n 0.203167426723065921749064455810,\n 0.233492536538354808760849898925,\n 0.249147045813402785000562436043\n ];\n\n var qsqz = w * 0.5;\n\n // if w >= 16 then the integral lower bound (occurs for c=20)\n // is 0.99999999999995 so return a value of 1.\n\n if (qsqz >= bb)\n return 1.0;\n\n // find (f(w/2) - 1) ^ cc\n // (first term in integral of hartley's form).\n\n var pr_w = 2 * jStat.normal.cdf(qsqz, 0, 1, 1, 0) - 1; // erf(qsqz / M_SQRT2)\n // if pr_w ^ cc < 2e-22 then set pr_w = 0\n if (pr_w >= Math.exp(C2 / cc))\n pr_w = Math.pow(pr_w, cc);\n else\n pr_w = 0.0;\n\n // if w is large then the second component of the\n // integral is small, so fewer intervals are needed.\n\n var wincr;\n if (w > wlar)\n wincr = wincr1;\n else\n wincr = wincr2;\n\n // find the integral of second term of hartley's form\n // for the integral of the range for equal-length\n // intervals using legendre quadrature. limits of\n // integration are from (w/2, 8). two or three\n // equal-length intervals are used.\n\n // blb and bub are lower and upper limits of integration.\n\n var blb = qsqz;\n var binc = (bb - qsqz) / wincr;\n var bub = blb + binc;\n var einsum = 0.0;\n\n // integrate over each interval\n\n var cc1 = cc - 1.0;\n for (var wi = 1; wi <= wincr; wi++) {\n var elsum = 0.0;\n var a = 0.5 * (bub + blb);\n\n // legendre quadrature with order = nleg\n\n var b = 0.5 * (bub - blb);\n\n for (var jj = 1; jj <= nleg; jj++) {\n var j, xx;\n if (ihalf < jj) {\n j = (nleg - jj) + 1;\n xx = xleg[j-1];\n } else {\n j = jj;\n xx = -xleg[j-1];\n }\n var c = b * xx;\n var ac = a + c;\n\n // if exp(-qexpo/2) < 9e-14,\n // then doesn't contribute to integral\n\n var qexpo = ac * ac;\n if (qexpo > C3)\n break;\n\n var pplus = 2 * jStat.normal.cdf(ac, 0, 1, 1, 0);\n var pminus= 2 * jStat.normal.cdf(ac, w, 1, 1, 0);\n\n // if rinsum ^ (cc-1) < 9e-14,\n // then doesn't contribute to integral\n\n var rinsum = (pplus * 0.5) - (pminus * 0.5);\n if (rinsum >= Math.exp(C1 / cc1)) {\n rinsum = (aleg[j-1] * Math.exp(-(0.5 * qexpo))) * Math.pow(rinsum, cc1);\n elsum += rinsum;\n }\n }\n elsum *= (((2.0 * b) * cc) / Math.sqrt(2 * Math.PI));\n einsum += elsum;\n blb = bub;\n bub += binc;\n }\n\n // if pr_w ^ rr < 9e-14, then return 0\n pr_w += einsum;\n if (pr_w <= Math.exp(C1 / rr))\n return 0;\n\n pr_w = Math.pow(pr_w, rr);\n if (pr_w >= 1) // 1 was iMax was eps\n return 1;\n return pr_w;\n}\n\nfunction tukeyQinv(p, c, v) {\n var p0 = 0.322232421088;\n var q0 = 0.993484626060e-01;\n var p1 = -1.0;\n var q1 = 0.588581570495;\n var p2 = -0.342242088547;\n var q2 = 0.531103462366;\n var p3 = -0.204231210125;\n var q3 = 0.103537752850;\n var p4 = -0.453642210148e-04;\n var q4 = 0.38560700634e-02;\n var c1 = 0.8832;\n var c2 = 0.2368;\n var c3 = 1.214;\n var c4 = 1.208;\n var c5 = 1.4142;\n var vmax = 120.0;\n\n var ps = 0.5 - 0.5 * p;\n var yi = Math.sqrt(Math.log(1.0 / (ps * ps)));\n var t = yi + (((( yi * p4 + p3) * yi + p2) * yi + p1) * yi + p0)\n / (((( yi * q4 + q3) * yi + q2) * yi + q1) * yi + q0);\n if (v < vmax) t += (t * t * t + t) / v / 4.0;\n var q = c1 - c2 * t;\n if (v < vmax) q += -c3 / v + c4 * t / v;\n return t * (q * Math.log(c - 1.0) + c5);\n}\n\njStat.extend(jStat.tukey, {\n cdf: function cdf(q, nmeans, df) {\n // Identical implementation as the R ptukey() function as of commit 68947\n var rr = 1;\n var cc = nmeans;\n\n var nlegq = 16;\n var ihalfq = 8;\n\n var eps1 = -30.0;\n var eps2 = 1.0e-14;\n var dhaf = 100.0;\n var dquar = 800.0;\n var deigh = 5000.0;\n var dlarg = 25000.0;\n var ulen1 = 1.0;\n var ulen2 = 0.5;\n var ulen3 = 0.25;\n var ulen4 = 0.125;\n var xlegq = [\n 0.989400934991649932596154173450,\n 0.944575023073232576077988415535,\n 0.865631202387831743880467897712,\n 0.755404408355003033895101194847,\n 0.617876244402643748446671764049,\n 0.458016777657227386342419442984,\n 0.281603550779258913230460501460,\n 0.950125098376374401853193354250e-1\n ];\n var alegq = [\n 0.271524594117540948517805724560e-1,\n 0.622535239386478928628438369944e-1,\n 0.951585116824927848099251076022e-1,\n 0.124628971255533872052476282192,\n 0.149595988816576732081501730547,\n 0.169156519395002538189312079030,\n 0.182603415044923588866763667969,\n 0.189450610455068496285396723208\n ];\n\n if (q <= 0)\n return 0;\n\n // df must be > 1\n // there must be at least two values\n\n if (df < 2 || rr < 1 || cc < 2) return NaN;\n\n if (!Number.isFinite(q))\n return 1;\n\n if (df > dlarg)\n return tukeyWprob(q, rr, cc);\n\n // calculate leading constant\n\n var f2 = df * 0.5;\n var f2lf = ((f2 * Math.log(df)) - (df * Math.log(2))) - jStat.gammaln(f2);\n var f21 = f2 - 1.0;\n\n // integral is divided into unit, half-unit, quarter-unit, or\n // eighth-unit length intervals depending on the value of the\n // degrees of freedom.\n\n var ff4 = df * 0.25;\n var ulen;\n if (df <= dhaf) ulen = ulen1;\n else if (df <= dquar) ulen = ulen2;\n else if (df <= deigh) ulen = ulen3;\n else ulen = ulen4;\n\n f2lf += Math.log(ulen);\n\n // integrate over each subinterval\n\n var ans = 0.0;\n\n for (var i = 1; i <= 50; i++) {\n var otsum = 0.0;\n\n // legendre quadrature with order = nlegq\n // nodes (stored in xlegq) are symmetric around zero.\n\n var twa1 = (2 * i - 1) * ulen;\n\n for (var jj = 1; jj <= nlegq; jj++) {\n var j, t1;\n if (ihalfq < jj) {\n j = jj - ihalfq - 1;\n t1 = (f2lf + (f21 * Math.log(twa1 + (xlegq[j] * ulen))))\n - (((xlegq[j] * ulen) + twa1) * ff4);\n } else {\n j = jj - 1;\n t1 = (f2lf + (f21 * Math.log(twa1 - (xlegq[j] * ulen))))\n + (((xlegq[j] * ulen) - twa1) * ff4);\n }\n\n // if exp(t1) < 9e-14, then doesn't contribute to integral\n var qsqz;\n if (t1 >= eps1) {\n if (ihalfq < jj) {\n qsqz = q * Math.sqrt(((xlegq[j] * ulen) + twa1) * 0.5);\n } else {\n qsqz = q * Math.sqrt(((-(xlegq[j] * ulen)) + twa1) * 0.5);\n }\n\n // call wprob to find integral of range portion\n\n var wprb = tukeyWprob(qsqz, rr, cc);\n var rotsum = (wprb * alegq[j]) * Math.exp(t1);\n otsum += rotsum;\n }\n // end legendre integral for interval i\n // L200:\n }\n\n // if integral for interval i < 1e-14, then stop.\n // However, in order to avoid small area under left tail,\n // at least 1 / ulen intervals are calculated.\n if (i * ulen >= 1.0 && otsum <= eps2)\n break;\n\n // end of interval i\n // L330:\n\n ans += otsum;\n }\n\n if (otsum > eps2) { // not converged\n throw new Error('tukey.cdf failed to converge');\n }\n if (ans > 1)\n ans = 1;\n return ans;\n },\n\n inv: function(p, nmeans, df) {\n // Identical implementation as the R qtukey() function as of commit 68947\n var rr = 1;\n var cc = nmeans;\n\n var eps = 0.0001;\n var maxiter = 50;\n\n // df must be > 1 ; there must be at least two values\n if (df < 2 || rr < 1 || cc < 2) return NaN;\n\n if (p < 0 || p > 1) return NaN;\n if (p === 0) return 0;\n if (p === 1) return Infinity;\n\n // Initial value\n\n var x0 = tukeyQinv(p, cc, df);\n\n // Find prob(value < x0)\n\n var valx0 = jStat.tukey.cdf(x0, nmeans, df) - p;\n\n // Find the second iterate and prob(value < x1).\n // If the first iterate has probability value\n // exceeding p then second iterate is 1 less than\n // first iterate; otherwise it is 1 greater.\n\n var x1;\n if (valx0 > 0.0)\n x1 = Math.max(0.0, x0 - 1.0);\n else\n x1 = x0 + 1.0;\n var valx1 = jStat.tukey.cdf(x1, nmeans, df) - p;\n\n // Find new iterate\n\n var ans;\n for(var iter = 1; iter < maxiter; iter++) {\n ans = x1 - ((valx1 * (x1 - x0)) / (valx1 - valx0));\n valx0 = valx1;\n\n // New iterate must be >= 0\n\n x0 = x1;\n if (ans < 0.0) {\n ans = 0.0;\n valx1 = -p;\n }\n // Find prob(value < new iterate)\n\n valx1 = jStat.tukey.cdf(ans, nmeans, df) - p;\n x1 = ans;\n\n // If the difference between two successive\n // iterates is less than eps, stop\n\n var xabs = Math.abs(x1 - x0);\n if (xabs < eps)\n return ans;\n }\n\n throw new Error('tukey.inv failed to converge');\n }\n});\n\n}(jStat, Math));\n/* Provides functions for the solution of linear system of equations, integration, extrapolation,\n * interpolation, eigenvalue problems, differential equations and PCA analysis. */\n\n(function(jStat, Math) {\n\nvar push = Array.prototype.push;\nvar isArray = jStat.utils.isArray;\n\nfunction isUsable(arg) {\n return isArray(arg) || arg instanceof jStat;\n}\n\njStat.extend({\n\n // add a vector/matrix to a vector/matrix or scalar\n add: function add(arr, arg) {\n // check if arg is a vector or scalar\n if (isUsable(arg)) {\n if (!isUsable(arg[0])) arg = [ arg ];\n return jStat.map(arr, function(value, row, col) {\n return value + arg[row][col];\n });\n }\n return jStat.map(arr, function(value) { return value + arg; });\n },\n\n // subtract a vector or scalar from the vector\n subtract: function subtract(arr, arg) {\n // check if arg is a vector or scalar\n if (isUsable(arg)) {\n if (!isUsable(arg[0])) arg = [ arg ];\n return jStat.map(arr, function(value, row, col) {\n return value - arg[row][col] || 0;\n });\n }\n return jStat.map(arr, function(value) { return value - arg; });\n },\n\n // matrix division\n divide: function divide(arr, arg) {\n if (isUsable(arg)) {\n if (!isUsable(arg[0])) arg = [ arg ];\n return jStat.multiply(arr, jStat.inv(arg));\n }\n return jStat.map(arr, function(value) { return value / arg; });\n },\n\n // matrix multiplication\n multiply: function multiply(arr, arg) {\n var row, col, nrescols, sum, nrow, ncol, res, rescols;\n // eg: arr = 2 arg = 3 -> 6 for res[0][0] statement closure\n if (arr.length === undefined && arg.length === undefined) {\n return arr * arg;\n }\n nrow = arr.length,\n ncol = arr[0].length,\n res = jStat.zeros(nrow, nrescols = (isUsable(arg)) ? arg[0].length : ncol),\n rescols = 0;\n if (isUsable(arg)) {\n for (; rescols < nrescols; rescols++) {\n for (row = 0; row < nrow; row++) {\n sum = 0;\n for (col = 0; col < ncol; col++)\n sum += arr[row][col] * arg[col][rescols];\n res[row][rescols] = sum;\n }\n }\n return (nrow === 1 && rescols === 1) ? res[0][0] : res;\n }\n return jStat.map(arr, function(value) { return value * arg; });\n },\n\n // outer([1,2,3],[4,5,6])\n // ===\n // [[1],[2],[3]] times [[4,5,6]]\n // ->\n // [[4,5,6],[8,10,12],[12,15,18]]\n outer:function outer(A, B) {\n return jStat.multiply(A.map(function(t){ return [t] }), [B]);\n },\n\n\n // Returns the dot product of two matricies\n dot: function dot(arr, arg) {\n if (!isUsable(arr[0])) arr = [ arr ];\n if (!isUsable(arg[0])) arg = [ arg ];\n // convert column to row vector\n var left = (arr[0].length === 1 && arr.length !== 1) ? jStat.transpose(arr) : arr,\n right = (arg[0].length === 1 && arg.length !== 1) ? jStat.transpose(arg) : arg,\n res = [],\n row = 0,\n nrow = left.length,\n ncol = left[0].length,\n sum, col;\n for (; row < nrow; row++) {\n res[row] = [];\n sum = 0;\n for (col = 0; col < ncol; col++)\n sum += left[row][col] * right[row][col];\n res[row] = sum;\n }\n return (res.length === 1) ? res[0] : res;\n },\n\n // raise every element by a scalar\n pow: function pow(arr, arg) {\n return jStat.map(arr, function(value) { return Math.pow(value, arg); });\n },\n\n // exponentiate every element\n exp: function exp(arr) {\n return jStat.map(arr, function(value) { return Math.exp(value); });\n },\n\n // generate the natural log of every element\n log: function exp(arr) {\n return jStat.map(arr, function(value) { return Math.log(value); });\n },\n\n // generate the absolute values of the vector\n abs: function abs(arr) {\n return jStat.map(arr, function(value) { return Math.abs(value); });\n },\n\n // computes the p-norm of the vector\n // In the case that a matrix is passed, uses the first row as the vector\n norm: function norm(arr, p) {\n var nnorm = 0,\n i = 0;\n // check the p-value of the norm, and set for most common case\n if (isNaN(p)) p = 2;\n // check if multi-dimensional array, and make vector correction\n if (isUsable(arr[0])) arr = arr[0];\n // vector norm\n for (; i < arr.length; i++) {\n nnorm += Math.pow(Math.abs(arr[i]), p);\n }\n return Math.pow(nnorm, 1 / p);\n },\n\n // computes the angle between two vectors in rads\n // In case a matrix is passed, this uses the first row as the vector\n angle: function angle(arr, arg) {\n return Math.acos(jStat.dot(arr, arg) / (jStat.norm(arr) * jStat.norm(arg)));\n },\n\n // augment one matrix by another\n // Note: this function returns a matrix, not a jStat object\n aug: function aug(a, b) {\n var newarr = [];\n var i;\n for (i = 0; i < a.length; i++) {\n newarr.push(a[i].slice());\n }\n for (i = 0; i < newarr.length; i++) {\n push.apply(newarr[i], b[i]);\n }\n return newarr;\n },\n\n // The inv() function calculates the inverse of a matrix\n // Create the inverse by augmenting the matrix by the identity matrix of the\n // appropriate size, and then use G-J elimination on the augmented matrix.\n inv: function inv(a) {\n var rows = a.length;\n var cols = a[0].length;\n var b = jStat.identity(rows, cols);\n var c = jStat.gauss_jordan(a, b);\n var result = [];\n var i = 0;\n var j;\n\n //We need to copy the inverse portion to a new matrix to rid G-J artifacts\n for (; i < rows; i++) {\n result[i] = [];\n for (j = cols; j < c[0].length; j++)\n result[i][j - cols] = c[i][j];\n }\n return result;\n },\n\n // calculate the determinant of a matrix\n det: function det(a) {\n if (a.length === 2) {\n return a[0][0] * a[1][1] - a[0][1] * a[1][0];\n }\n\n var determinant = 0;\n for (var i = 0; i < a.length; i++) {\n // build a sub matrix without column `i`\n var submatrix = [];\n for (var row = 1; row < a.length; row++) {\n submatrix[row - 1] = [];\n for (var col = 0; col < a.length; col++) {\n if (col < i) {\n submatrix[row - 1][col] = a[row][col];\n } else if (col > i) {\n submatrix[row - 1][col - 1] = a[row][col];\n }\n }\n }\n\n // alternate between + and - between determinants\n var sign = i % 2 ? -1 : 1;\n determinant += det(submatrix) * a[0][i] * sign;\n }\n\n return determinant\n },\n\n gauss_elimination: function gauss_elimination(a, b) {\n var i = 0,\n j = 0,\n n = a.length,\n m = a[0].length,\n factor = 1,\n sum = 0,\n x = [],\n maug, pivot, temp, k;\n a = jStat.aug(a, b);\n maug = a[0].length;\n for(i = 0; i < n; i++) {\n pivot = a[i][i];\n j = i;\n for (k = i + 1; k < m; k++) {\n if (pivot < Math.abs(a[k][i])) {\n pivot = a[k][i];\n j = k;\n }\n }\n if (j != i) {\n for(k = 0; k < maug; k++) {\n temp = a[i][k];\n a[i][k] = a[j][k];\n a[j][k] = temp;\n }\n }\n for (j = i + 1; j < n; j++) {\n factor = a[j][i] / a[i][i];\n for(k = i; k < maug; k++) {\n a[j][k] = a[j][k] - factor * a[i][k];\n }\n }\n }\n for (i = n - 1; i >= 0; i--) {\n sum = 0;\n for (j = i + 1; j<= n - 1; j++) {\n sum = sum + x[j] * a[i][j];\n }\n x[i] =(a[i][maug - 1] - sum) / a[i][i];\n }\n return x;\n },\n\n gauss_jordan: function gauss_jordan(a, b) {\n var m = jStat.aug(a, b);\n var h = m.length;\n var w = m[0].length;\n var c = 0;\n var x, y, y2;\n // find max pivot\n for (y = 0; y < h; y++) {\n var maxrow = y;\n for (y2 = y+1; y2 < h; y2++) {\n if (Math.abs(m[y2][y]) > Math.abs(m[maxrow][y]))\n maxrow = y2;\n }\n var tmp = m[y];\n m[y] = m[maxrow];\n m[maxrow] = tmp\n for (y2 = y+1; y2 < h; y2++) {\n c = m[y2][y] / m[y][y];\n for (x = y; x < w; x++) {\n m[y2][x] -= m[y][x] * c;\n }\n }\n }\n // backsubstitute\n for (y = h-1; y >= 0; y--) {\n c = m[y][y];\n for (y2 = 0; y2 < y; y2++) {\n for (x = w-1; x > y-1; x--) {\n m[y2][x] -= m[y][x] * m[y2][y] / c;\n }\n }\n m[y][y] /= c;\n for (x = h; x < w; x++) {\n m[y][x] /= c;\n }\n }\n return m;\n },\n\n // solve equation\n // Ax=b\n // A is upper triangular matrix\n // A=[[1,2,3],[0,4,5],[0,6,7]]\n // b=[1,2,3]\n // triaUpSolve(A,b) // -> [2.666,0.1666,1.666]\n // if you use matrix style\n // A=[[1,2,3],[0,4,5],[0,6,7]]\n // b=[[1],[2],[3]]\n // will return [[2.666],[0.1666],[1.666]]\n triaUpSolve: function triaUpSolve(A, b) {\n var size = A[0].length;\n var x = jStat.zeros(1, size)[0];\n var parts;\n var matrix_mode = false;\n\n if (b[0].length != undefined) {\n b = b.map(function(i){ return i[0] });\n matrix_mode = true;\n }\n\n jStat.arange(size - 1, -1, -1).forEach(function(i) {\n parts = jStat.arange(i + 1, size).map(function(j) {\n return x[j] * A[i][j];\n });\n x[i] = (b[i] - jStat.sum(parts)) / A[i][i];\n });\n\n if (matrix_mode)\n return x.map(function(i){ return [i] });\n return x;\n },\n\n triaLowSolve: function triaLowSolve(A, b) {\n // like to triaUpSolve but A is lower triangular matrix\n var size = A[0].length;\n var x = jStat.zeros(1, size)[0];\n var parts;\n\n var matrix_mode=false;\n if (b[0].length != undefined) {\n b = b.map(function(i){ return i[0] });\n matrix_mode = true;\n }\n\n jStat.arange(size).forEach(function(i) {\n parts = jStat.arange(i).map(function(j) {\n return A[i][j] * x[j];\n });\n x[i] = (b[i] - jStat.sum(parts)) / A[i][i];\n })\n\n if (matrix_mode)\n return x.map(function(i){ return [i] });\n return x;\n },\n\n\n // A -> [L,U]\n // A=LU\n // L is lower triangular matrix\n // U is upper triangular matrix\n lu: function lu(A) {\n var size = A.length;\n //var L=jStat.diagonal(jStat.ones(1,size)[0]);\n var L = jStat.identity(size);\n var R = jStat.zeros(A.length, A[0].length);\n var parts;\n jStat.arange(size).forEach(function(t) {\n R[0][t] = A[0][t];\n });\n jStat.arange(1, size).forEach(function(l) {\n jStat.arange(l).forEach(function(i) {\n parts = jStat.arange(i).map(function(jj) {\n return L[l][jj] * R[jj][i];\n });\n L[l][i] = (A[l][i] - jStat.sum(parts)) / R[i][i];\n });\n jStat.arange(l, size).forEach(function(j) {\n parts = jStat.arange(l).map(function(jj) {\n return L[l][jj] * R[jj][j];\n });\n R[l][j] = A[parts.length][j] - jStat.sum(parts);\n });\n });\n return [L, R];\n },\n\n // A -> T\n // A=TT'\n // T is lower triangular matrix\n cholesky: function cholesky(A) {\n var size = A.length;\n var T = jStat.zeros(A.length, A[0].length);\n var parts;\n jStat.arange(size).forEach(function(i) {\n parts = jStat.arange(i).map(function(t) {\n return Math.pow(T[i][t],2);\n });\n T[i][i] = Math.sqrt(A[i][i] - jStat.sum(parts));\n jStat.arange(i + 1, size).forEach(function(j) {\n parts = jStat.arange(i).map(function(t) {\n return T[i][t] * T[j][t];\n });\n T[j][i] = (A[i][j] - jStat.sum(parts)) / T[i][i];\n });\n });\n return T;\n },\n\n\n gauss_jacobi: function gauss_jacobi(a, b, x, r) {\n var i = 0;\n var j = 0;\n var n = a.length;\n var l = [];\n var u = [];\n var d = [];\n var xv, c, h, xk;\n for (; i < n; i++) {\n l[i] = [];\n u[i] = [];\n d[i] = [];\n for (j = 0; j < n; j++) {\n if (i > j) {\n l[i][j] = a[i][j];\n u[i][j] = d[i][j] = 0;\n } else if (i < j) {\n u[i][j] = a[i][j];\n l[i][j] = d[i][j] = 0;\n } else {\n d[i][j] = a[i][j];\n l[i][j] = u[i][j] = 0;\n }\n }\n }\n h = jStat.multiply(jStat.multiply(jStat.inv(d), jStat.add(l, u)), -1);\n c = jStat.multiply(jStat.inv(d), b);\n xv = x;\n xk = jStat.add(jStat.multiply(h, x), c);\n i = 2;\n while (Math.abs(jStat.norm(jStat.subtract(xk,xv))) > r) {\n xv = xk;\n xk = jStat.add(jStat.multiply(h, xv), c);\n i++;\n }\n return xk;\n },\n\n gauss_seidel: function gauss_seidel(a, b, x, r) {\n var i = 0;\n var n = a.length;\n var l = [];\n var u = [];\n var d = [];\n var j, xv, c, h, xk;\n for (; i < n; i++) {\n l[i] = [];\n u[i] = [];\n d[i] = [];\n for (j = 0; j < n; j++) {\n if (i > j) {\n l[i][j] = a[i][j];\n u[i][j] = d[i][j] = 0;\n } else if (i < j) {\n u[i][j] = a[i][j];\n l[i][j] = d[i][j] = 0;\n } else {\n d[i][j] = a[i][j];\n l[i][j] = u[i][j] = 0;\n }\n }\n }\n h = jStat.multiply(jStat.multiply(jStat.inv(jStat.add(d, l)), u), -1);\n c = jStat.multiply(jStat.inv(jStat.add(d, l)), b);\n xv = x;\n xk = jStat.add(jStat.multiply(h, x), c);\n i = 2;\n while (Math.abs(jStat.norm(jStat.subtract(xk, xv))) > r) {\n xv = xk;\n xk = jStat.add(jStat.multiply(h, xv), c);\n i = i + 1;\n }\n return xk;\n },\n\n SOR: function SOR(a, b, x, r, w) {\n var i = 0;\n var n = a.length;\n var l = [];\n var u = [];\n var d = [];\n var j, xv, c, h, xk;\n for (; i < n; i++) {\n l[i] = [];\n u[i] = [];\n d[i] = [];\n for (j = 0; j < n; j++) {\n if (i > j) {\n l[i][j] = a[i][j];\n u[i][j] = d[i][j] = 0;\n } else if (i < j) {\n u[i][j] = a[i][j];\n l[i][j] = d[i][j] = 0;\n } else {\n d[i][j] = a[i][j];\n l[i][j] = u[i][j] = 0;\n }\n }\n }\n h = jStat.multiply(jStat.inv(jStat.add(d, jStat.multiply(l, w))),\n jStat.subtract(jStat.multiply(d, 1 - w),\n jStat.multiply(u, w)));\n c = jStat.multiply(jStat.multiply(jStat.inv(jStat.add(d,\n jStat.multiply(l, w))), b), w);\n xv = x;\n xk = jStat.add(jStat.multiply(h, x), c);\n i = 2;\n while (Math.abs(jStat.norm(jStat.subtract(xk, xv))) > r) {\n xv = xk;\n xk = jStat.add(jStat.multiply(h, xv), c);\n i++;\n }\n return xk;\n },\n\n householder: function householder(a) {\n var m = a.length;\n var n = a[0].length;\n var i = 0;\n var w = [];\n var p = [];\n var alpha, r, k, j, factor;\n for (; i < m - 1; i++) {\n alpha = 0;\n for (j = i + 1; j < n; j++)\n alpha += (a[j][i] * a[j][i]);\n factor = (a[i + 1][i] > 0) ? -1 : 1;\n alpha = factor * Math.sqrt(alpha);\n r = Math.sqrt((((alpha * alpha) - a[i + 1][i] * alpha) / 2));\n w = jStat.zeros(m, 1);\n w[i + 1][0] = (a[i + 1][i] - alpha) / (2 * r);\n for (k = i + 2; k < m; k++) w[k][0] = a[k][i] / (2 * r);\n p = jStat.subtract(jStat.identity(m, n),\n jStat.multiply(jStat.multiply(w, jStat.transpose(w)), 2));\n a = jStat.multiply(p, jStat.multiply(a, p));\n }\n return a;\n },\n\n // A -> [Q,R]\n // Q is orthogonal matrix\n // R is upper triangular\n QR: (function() {\n // x -> Q\n // find a orthogonal matrix Q st.\n // Qx=y\n // y is [||x||,0,0,...]\n\n // quick ref\n var sum = jStat.sum;\n var range = jStat.arange;\n\n function qr2(x) {\n // quick impletation\n // https://www.stat.wisc.edu/~larget/math496/qr.html\n\n var n = x.length;\n var p = x[0].length;\n\n var r = jStat.zeros(p, p);\n x = jStat.copy(x);\n\n var i,j,k;\n for(j = 0; j < p; j++){\n r[j][j] = Math.sqrt(sum(range(n).map(function(i){\n return x[i][j] * x[i][j];\n })));\n for(i = 0; i < n; i++){\n x[i][j] = x[i][j] / r[j][j];\n }\n for(k = j+1; k < p; k++){\n r[j][k] = sum(range(n).map(function(i){\n return x[i][j] * x[i][k];\n }));\n for(i = 0; i < n; i++){\n x[i][k] = x[i][k] - x[i][j]*r[j][k];\n }\n }\n }\n return [x, r];\n }\n\n return qr2;\n }()),\n\n lstsq: (function() {\n // solve least squard problem for Ax=b as QR decomposition way if b is\n // [[b1],[b2],[b3]] form will return [[x1],[x2],[x3]] array form solution\n // else b is [b1,b2,b3] form will return [x1,x2,x3] array form solution\n function R_I(A) {\n A = jStat.copy(A);\n var size = A.length;\n var I = jStat.identity(size);\n jStat.arange(size - 1, -1, -1).forEach(function(i) {\n jStat.sliceAssign(\n I, { row: i }, jStat.divide(jStat.slice(I, { row: i }), A[i][i]));\n jStat.sliceAssign(\n A, { row: i }, jStat.divide(jStat.slice(A, { row: i }), A[i][i]));\n jStat.arange(i).forEach(function(j) {\n var c = jStat.multiply(A[j][i], -1);\n var Aj = jStat.slice(A, { row: j });\n var cAi = jStat.multiply(jStat.slice(A, { row: i }), c);\n jStat.sliceAssign(A, { row: j }, jStat.add(Aj, cAi));\n var Ij = jStat.slice(I, { row: j });\n var cIi = jStat.multiply(jStat.slice(I, { row: i }), c);\n jStat.sliceAssign(I, { row: j }, jStat.add(Ij, cIi));\n })\n });\n return I;\n }\n\n function qr_solve(A, b){\n var array_mode = false;\n if (b[0].length === undefined) {\n // [c1,c2,c3] mode\n b = b.map(function(x){ return [x] });\n array_mode = true;\n }\n var QR = jStat.QR(A);\n var Q = QR[0];\n var R = QR[1];\n var attrs = A[0].length;\n var Q1 = jStat.slice(Q,{col:{end:attrs}});\n var R1 = jStat.slice(R,{row:{end:attrs}});\n var RI = R_I(R1);\n var Q2 = jStat.transpose(Q1);\n\n if(Q2[0].length === undefined){\n Q2 = [Q2]; // The confusing jStat.multifly implementation threat nature process again.\n }\n\n var x = jStat.multiply(jStat.multiply(RI, Q2), b);\n\n if(x.length === undefined){\n x = [[x]]; // The confusing jStat.multifly implementation threat nature process again.\n }\n\n\n if (array_mode)\n return x.map(function(i){ return i[0] });\n return x;\n }\n\n return qr_solve;\n }()),\n\n jacobi: function jacobi(a) {\n var condition = 1;\n var n = a.length;\n var e = jStat.identity(n, n);\n var ev = [];\n var b, i, j, p, q, maxim, theta, s;\n // condition === 1 only if tolerance is not reached\n while (condition === 1) {\n maxim = a[0][1];\n p = 0;\n q = 1;\n for (i = 0; i < n; i++) {\n for (j = 0; j < n; j++) {\n if (i != j) {\n if (maxim < Math.abs(a[i][j])) {\n maxim = Math.abs(a[i][j]);\n p = i;\n q = j;\n }\n }\n }\n }\n if (a[p][p] === a[q][q])\n theta = (a[p][q] > 0) ? Math.PI / 4 : -Math.PI / 4;\n else\n theta = Math.atan(2 * a[p][q] / (a[p][p] - a[q][q])) / 2;\n s = jStat.identity(n, n);\n s[p][p] = Math.cos(theta);\n s[p][q] = -Math.sin(theta);\n s[q][p] = Math.sin(theta);\n s[q][q] = Math.cos(theta);\n // eigen vector matrix\n e = jStat.multiply(e, s);\n b = jStat.multiply(jStat.multiply(jStat.inv(s), a), s);\n a = b;\n condition = 0;\n for (i = 1; i < n; i++) {\n for (j = 1; j < n; j++) {\n if (i != j && Math.abs(a[i][j]) > 0.001) {\n condition = 1;\n }\n }\n }\n }\n for (i = 0; i < n; i++) ev.push(a[i][i]);\n //returns both the eigenvalue and eigenmatrix\n return [e, ev];\n },\n\n rungekutta: function rungekutta(f, h, p, t_j, u_j, order) {\n var k1, k2, u_j1, k3, k4;\n if (order === 2) {\n while (t_j <= p) {\n k1 = h * f(t_j, u_j);\n k2 = h * f(t_j + h, u_j + k1);\n u_j1 = u_j + (k1 + k2) / 2;\n u_j = u_j1;\n t_j = t_j + h;\n }\n }\n if (order === 4) {\n while (t_j <= p) {\n k1 = h * f(t_j, u_j);\n k2 = h * f(t_j + h / 2, u_j + k1 / 2);\n k3 = h * f(t_j + h / 2, u_j + k2 / 2);\n k4 = h * f(t_j +h, u_j + k3);\n u_j1 = u_j + (k1 + 2 * k2 + 2 * k3 + k4) / 6;\n u_j = u_j1;\n t_j = t_j + h;\n }\n }\n return u_j;\n },\n\n romberg: function romberg(f, a, b, order) {\n var i = 0;\n var h = (b - a) / 2;\n var x = [];\n var h1 = [];\n var g = [];\n var m, a1, j, k, I;\n while (i < order / 2) {\n I = f(a);\n for (j = a, k = 0; j <= b; j = j + h, k++) x[k] = j;\n m = x.length;\n for (j = 1; j < m - 1; j++) {\n I += (((j % 2) !== 0) ? 4 : 2) * f(x[j]);\n }\n I = (h / 3) * (I + f(b));\n g[i] = I;\n h /= 2;\n i++;\n }\n a1 = g.length;\n m = 1;\n while (a1 !== 1) {\n for (j = 0; j < a1 - 1; j++)\n h1[j] = ((Math.pow(4, m)) * g[j + 1] - g[j]) / (Math.pow(4, m) - 1);\n a1 = h1.length;\n g = h1;\n h1 = [];\n m++;\n }\n return g;\n },\n\n richardson: function richardson(X, f, x, h) {\n function pos(X, x) {\n var i = 0;\n var n = X.length;\n var p;\n for (; i < n; i++)\n if (X[i] === x) p = i;\n return p;\n }\n var h_min = Math.abs(x - X[pos(X, x) + 1]);\n var i = 0;\n var g = [];\n var h1 = [];\n var y1, y2, m, a, j;\n while (h >= h_min) {\n y1 = pos(X, x + h);\n y2 = pos(X, x);\n g[i] = (f[y1] - 2 * f[y2] + f[2 * y2 - y1]) / (h * h);\n h /= 2;\n i++;\n }\n a = g.length;\n m = 1;\n while (a != 1) {\n for (j = 0; j < a - 1; j++)\n h1[j] = ((Math.pow(4, m)) * g[j + 1] - g[j]) / (Math.pow(4, m) - 1);\n a = h1.length;\n g = h1;\n h1 = [];\n m++;\n }\n return g;\n },\n\n simpson: function simpson(f, a, b, n) {\n var h = (b - a) / n;\n var I = f(a);\n var x = [];\n var j = a;\n var k = 0;\n var i = 1;\n var m;\n for (; j <= b; j = j + h, k++)\n x[k] = j;\n m = x.length;\n for (; i < m - 1; i++) {\n I += ((i % 2 !== 0) ? 4 : 2) * f(x[i]);\n }\n return (h / 3) * (I + f(b));\n },\n\n hermite: function hermite(X, F, dF, value) {\n var n = X.length;\n var p = 0;\n var i = 0;\n var l = [];\n var dl = [];\n var A = [];\n var B = [];\n var j;\n for (; i < n; i++) {\n l[i] = 1;\n for (j = 0; j < n; j++) {\n if (i != j) l[i] *= (value - X[j]) / (X[i] - X[j]);\n }\n dl[i] = 0;\n for (j = 0; j < n; j++) {\n if (i != j) dl[i] += 1 / (X [i] - X[j]);\n }\n A[i] = (1 - 2 * (value - X[i]) * dl[i]) * (l[i] * l[i]);\n B[i] = (value - X[i]) * (l[i] * l[i]);\n p += (A[i] * F[i] + B[i] * dF[i]);\n }\n return p;\n },\n\n lagrange: function lagrange(X, F, value) {\n var p = 0;\n var i = 0;\n var j, l;\n var n = X.length;\n for (; i < n; i++) {\n l = F[i];\n for (j = 0; j < n; j++) {\n // calculating the lagrange polynomial L_i\n if (i != j) l *= (value - X[j]) / (X[i] - X[j]);\n }\n // adding the lagrange polynomials found above\n p += l;\n }\n return p;\n },\n\n cubic_spline: function cubic_spline(X, F, value) {\n var n = X.length;\n var i = 0, j;\n var A = [];\n var B = [];\n var alpha = [];\n var c = [];\n var h = [];\n var b = [];\n var d = [];\n for (; i < n - 1; i++)\n h[i] = X[i + 1] - X[i];\n alpha[0] = 0;\n for (i = 1; i < n - 1; i++) {\n alpha[i] = (3 / h[i]) * (F[i + 1] - F[i]) -\n (3 / h[i-1]) * (F[i] - F[i-1]);\n }\n for (i = 1; i < n - 1; i++) {\n A[i] = [];\n B[i] = [];\n A[i][i-1] = h[i-1];\n A[i][i] = 2 * (h[i - 1] + h[i]);\n A[i][i+1] = h[i];\n B[i][0] = alpha[i];\n }\n c = jStat.multiply(jStat.inv(A), B);\n for (j = 0; j < n - 1; j++) {\n b[j] = (F[j + 1] - F[j]) / h[j] - h[j] * (c[j + 1][0] + 2 * c[j][0]) / 3;\n d[j] = (c[j + 1][0] - c[j][0]) / (3 * h[j]);\n }\n for (j = 0; j < n; j++) {\n if (X[j] > value) break;\n }\n j -= 1;\n return F[j] + (value - X[j]) * b[j] + jStat.sq(value-X[j]) *\n c[j] + (value - X[j]) * jStat.sq(value - X[j]) * d[j];\n },\n\n gauss_quadrature: function gauss_quadrature() {\n throw new Error('gauss_quadrature not yet implemented');\n },\n\n PCA: function PCA(X) {\n var m = X.length;\n var n = X[0].length;\n var i = 0;\n var j, temp1;\n var u = [];\n var D = [];\n var result = [];\n var temp2 = [];\n var Y = [];\n var Bt = [];\n var B = [];\n var C = [];\n var V = [];\n var Vt = [];\n for (i = 0; i < m; i++) {\n u[i] = jStat.sum(X[i]) / n;\n }\n for (i = 0; i < n; i++) {\n B[i] = [];\n for(j = 0; j < m; j++) {\n B[i][j] = X[j][i] - u[j];\n }\n }\n B = jStat.transpose(B);\n for (i = 0; i < m; i++) {\n C[i] = [];\n for (j = 0; j < m; j++) {\n C[i][j] = (jStat.dot([B[i]], [B[j]])) / (n - 1);\n }\n }\n result = jStat.jacobi(C);\n V = result[0];\n D = result[1];\n Vt = jStat.transpose(V);\n for (i = 0; i < D.length; i++) {\n for (j = i; j < D.length; j++) {\n if(D[i] < D[j]) {\n temp1 = D[i];\n D[i] = D[j];\n D[j] = temp1;\n temp2 = Vt[i];\n Vt[i] = Vt[j];\n Vt[j] = temp2;\n }\n }\n }\n Bt = jStat.transpose(B);\n for (i = 0; i < m; i++) {\n Y[i] = [];\n for (j = 0; j < Bt.length; j++) {\n Y[i][j] = jStat.dot([Vt[i]], [Bt[j]]);\n }\n }\n return [X, D, Vt, Y];\n }\n});\n\n// extend jStat.fn with methods that require one argument\n(function(funcs) {\n for (var i = 0; i < funcs.length; i++) (function(passfunc) {\n jStat.fn[passfunc] = function(arg, func) {\n var tmpthis = this;\n // check for callback\n if (func) {\n setTimeout(function() {\n func.call(tmpthis, jStat.fn[passfunc].call(tmpthis, arg));\n }, 15);\n return this;\n }\n if (typeof jStat[passfunc](this, arg) === 'number')\n return jStat[passfunc](this, arg);\n else\n return jStat(jStat[passfunc](this, arg));\n };\n }(funcs[i]));\n}('add divide multiply subtract dot pow exp log abs norm angle'.split(' ')));\n\n}(jStat, Math));\n(function(jStat, Math) {\n\nvar slice = [].slice;\nvar isNumber = jStat.utils.isNumber;\nvar isArray = jStat.utils.isArray;\n\n// flag==true denotes use of sample standard deviation\n// Z Statistics\njStat.extend({\n // 2 different parameter lists:\n // (value, mean, sd)\n // (value, array, flag)\n zscore: function zscore() {\n var args = slice.call(arguments);\n if (isNumber(args[1])) {\n return (args[0] - args[1]) / args[2];\n }\n return (args[0] - jStat.mean(args[1])) / jStat.stdev(args[1], args[2]);\n },\n\n // 3 different paramter lists:\n // (value, mean, sd, sides)\n // (zscore, sides)\n // (value, array, sides, flag)\n ztest: function ztest() {\n var args = slice.call(arguments);\n var z;\n if (isArray(args[1])) {\n // (value, array, sides, flag)\n z = jStat.zscore(args[0],args[1],args[3]);\n return (args[2] === 1) ?\n (jStat.normal.cdf(-Math.abs(z), 0, 1)) :\n (jStat.normal.cdf(-Math.abs(z), 0, 1)*2);\n } else {\n if (args.length > 2) {\n // (value, mean, sd, sides)\n z = jStat.zscore(args[0],args[1],args[2]);\n return (args[3] === 1) ?\n (jStat.normal.cdf(-Math.abs(z),0,1)) :\n (jStat.normal.cdf(-Math.abs(z),0,1)* 2);\n } else {\n // (zscore, sides)\n z = args[0];\n return (args[1] === 1) ?\n (jStat.normal.cdf(-Math.abs(z),0,1)) :\n (jStat.normal.cdf(-Math.abs(z),0,1)*2);\n }\n }\n }\n});\n\njStat.extend(jStat.fn, {\n zscore: function zscore(value, flag) {\n return (value - this.mean()) / this.stdev(flag);\n },\n\n ztest: function ztest(value, sides, flag) {\n var zscore = Math.abs(this.zscore(value, flag));\n return (sides === 1) ?\n (jStat.normal.cdf(-zscore, 0, 1)) :\n (jStat.normal.cdf(-zscore, 0, 1) * 2);\n }\n});\n\n// T Statistics\njStat.extend({\n // 2 parameter lists\n // (value, mean, sd, n)\n // (value, array)\n tscore: function tscore() {\n var args = slice.call(arguments);\n return (args.length === 4) ?\n ((args[0] - args[1]) / (args[2] / Math.sqrt(args[3]))) :\n ((args[0] - jStat.mean(args[1])) /\n (jStat.stdev(args[1], true) / Math.sqrt(args[1].length)));\n },\n\n // 3 different paramter lists:\n // (value, mean, sd, n, sides)\n // (tscore, n, sides)\n // (value, array, sides)\n ttest: function ttest() {\n var args = slice.call(arguments);\n var tscore;\n if (args.length === 5) {\n tscore = Math.abs(jStat.tscore(args[0], args[1], args[2], args[3]));\n return (args[4] === 1) ?\n (jStat.studentt.cdf(-tscore, args[3]-1)) :\n (jStat.studentt.cdf(-tscore, args[3]-1)*2);\n }\n if (isNumber(args[1])) {\n tscore = Math.abs(args[0])\n return (args[2] == 1) ?\n (jStat.studentt.cdf(-tscore, args[1]-1)) :\n (jStat.studentt.cdf(-tscore, args[1]-1) * 2);\n }\n tscore = Math.abs(jStat.tscore(args[0], args[1]))\n return (args[2] == 1) ?\n (jStat.studentt.cdf(-tscore, args[1].length-1)) :\n (jStat.studentt.cdf(-tscore, args[1].length-1) * 2);\n }\n});\n\njStat.extend(jStat.fn, {\n tscore: function tscore(value) {\n return (value - this.mean()) / (this.stdev(true) / Math.sqrt(this.cols()));\n },\n\n ttest: function ttest(value, sides) {\n return (sides === 1) ?\n (1 - jStat.studentt.cdf(Math.abs(this.tscore(value)), this.cols()-1)) :\n (jStat.studentt.cdf(-Math.abs(this.tscore(value)), this.cols()-1)*2);\n }\n});\n\n// F Statistics\njStat.extend({\n // Paramter list is as follows:\n // (array1, array2, array3, ...)\n // or it is an array of arrays\n // array of arrays conversion\n anovafscore: function anovafscore() {\n var args = slice.call(arguments),\n expVar, sample, sampMean, sampSampMean, tmpargs, unexpVar, i, j;\n if (args.length === 1) {\n tmpargs = new Array(args[0].length);\n for (i = 0; i < args[0].length; i++) {\n tmpargs[i] = args[0][i];\n }\n args = tmpargs;\n }\n // Builds sample array\n sample = new Array();\n for (i = 0; i < args.length; i++) {\n sample = sample.concat(args[i]);\n }\n sampMean = jStat.mean(sample);\n // Computes the explained variance\n expVar = 0;\n for (i = 0; i < args.length; i++) {\n expVar = expVar + args[i].length * Math.pow(jStat.mean(args[i]) - sampMean, 2);\n }\n expVar /= (args.length - 1);\n // Computes unexplained variance\n unexpVar = 0;\n for (i = 0; i < args.length; i++) {\n sampSampMean = jStat.mean(args[i]);\n for (j = 0; j < args[i].length; j++) {\n unexpVar += Math.pow(args[i][j] - sampSampMean, 2);\n }\n }\n unexpVar /= (sample.length - args.length);\n return expVar / unexpVar;\n },\n\n // 2 different paramter setups\n // (array1, array2, array3, ...)\n // (anovafscore, df1, df2)\n anovaftest: function anovaftest() {\n var args = slice.call(arguments),\n df1, df2, n, i;\n if (isNumber(args[0])) {\n return 1 - jStat.centralF.cdf(args[0], args[1], args[2]);\n }\n var anovafscore = jStat.anovafscore(args);\n df1 = args.length - 1;\n n = 0;\n for (i = 0; i < args.length; i++) {\n n = n + args[i].length;\n }\n df2 = n - df1 - 1;\n return 1 - jStat.centralF.cdf(anovafscore, df1, df2);\n },\n\n ftest: function ftest(fscore, df1, df2) {\n return 1 - jStat.centralF.cdf(fscore, df1, df2);\n }\n});\n\njStat.extend(jStat.fn, {\n anovafscore: function anovafscore() {\n return jStat.anovafscore(this.toArray());\n },\n\n anovaftes: function anovaftes() {\n var n = 0;\n var i;\n for (i = 0; i < this.length; i++) {\n n = n + this[i].length;\n }\n return jStat.ftest(this.anovafscore(), this.length - 1, n - this.length);\n }\n});\n\n// Tukey's range test\njStat.extend({\n // 2 parameter lists\n // (mean1, mean2, n1, n2, sd)\n // (array1, array2, sd)\n qscore: function qscore() {\n var args = slice.call(arguments);\n var mean1, mean2, n1, n2, sd;\n if (isNumber(args[0])) {\n mean1 = args[0];\n mean2 = args[1];\n n1 = args[2];\n n2 = args[3];\n sd = args[4];\n } else {\n mean1 = jStat.mean(args[0]);\n mean2 = jStat.mean(args[1]);\n n1 = args[0].length;\n n2 = args[1].length;\n sd = args[2];\n }\n return Math.abs(mean1 - mean2) / (sd * Math.sqrt((1 / n1 + 1 / n2) / 2));\n },\n\n // 3 different parameter lists:\n // (qscore, n, k)\n // (mean1, mean2, n1, n2, sd, n, k)\n // (array1, array2, sd, n, k)\n qtest: function qtest() {\n var args = slice.call(arguments);\n\n var qscore;\n if (args.length === 3) {\n qscore = args[0];\n args = args.slice(1);\n } else if (args.length === 7) {\n qscore = jStat.qscore(args[0], args[1], args[2], args[3], args[4]);\n args = args.slice(5);\n } else {\n qscore = jStat.qscore(args[0], args[1], args[2]);\n args = args.slice(3);\n }\n\n var n = args[0];\n var k = args[1];\n\n return 1 - jStat.tukey.cdf(qscore, k, n - k);\n },\n\n tukeyhsd: function tukeyhsd(arrays) {\n var sd = jStat.pooledstdev(arrays);\n var means = arrays.map(function (arr) {return jStat.mean(arr);});\n var n = arrays.reduce(function (n, arr) {return n + arr.length;}, 0);\n\n var results = [];\n for (var i = 0; i < arrays.length; ++i) {\n for (var j = i + 1; j < arrays.length; ++j) {\n var p = jStat.qtest(means[i], means[j], arrays[i].length, arrays[j].length, sd, n, arrays.length);\n results.push([[i, j], p]);\n }\n }\n\n return results;\n }\n});\n\n// Error Bounds\njStat.extend({\n // 2 different parameter setups\n // (value, alpha, sd, n)\n // (value, alpha, array)\n normalci: function normalci() {\n var args = slice.call(arguments),\n ans = new Array(2),\n change;\n if (args.length === 4) {\n change = Math.abs(jStat.normal.inv(args[1] / 2, 0, 1) *\n args[2] / Math.sqrt(args[3]));\n } else {\n change = Math.abs(jStat.normal.inv(args[1] / 2, 0, 1) *\n jStat.stdev(args[2]) / Math.sqrt(args[2].length));\n }\n ans[0] = args[0] - change;\n ans[1] = args[0] + change;\n return ans;\n },\n\n // 2 different parameter setups\n // (value, alpha, sd, n)\n // (value, alpha, array)\n tci: function tci() {\n var args = slice.call(arguments),\n ans = new Array(2),\n change;\n if (args.length === 4) {\n change = Math.abs(jStat.studentt.inv(args[1] / 2, args[3] - 1) *\n args[2] / Math.sqrt(args[3]));\n } else {\n change = Math.abs(jStat.studentt.inv(args[1] / 2, args[2].length - 1) *\n jStat.stdev(args[2], true) / Math.sqrt(args[2].length));\n }\n ans[0] = args[0] - change;\n ans[1] = args[0] + change;\n return ans;\n },\n\n significant: function significant(pvalue, alpha) {\n return pvalue < alpha;\n }\n});\n\njStat.extend(jStat.fn, {\n normalci: function normalci(value, alpha) {\n return jStat.normalci(value, alpha, this.toArray());\n },\n\n tci: function tci(value, alpha) {\n return jStat.tci(value, alpha, this.toArray());\n }\n});\n\n// internal method for calculating the z-score for a difference of proportions test\nfunction differenceOfProportions(p1, n1, p2, n2) {\n if (p1 > 1 || p2 > 1 || p1 <= 0 || p2 <= 0) {\n throw new Error(\"Proportions should be greater than 0 and less than 1\")\n }\n var pooled = (p1 * n1 + p2 * n2) / (n1 + n2);\n var se = Math.sqrt(pooled * (1 - pooled) * ((1/n1) + (1/n2)));\n return (p1 - p2) / se;\n}\n\n// Difference of Proportions\njStat.extend(jStat.fn, {\n oneSidedDifferenceOfProportions: function oneSidedDifferenceOfProportions(p1, n1, p2, n2) {\n var z = differenceOfProportions(p1, n1, p2, n2);\n return jStat.ztest(z, 1);\n },\n\n twoSidedDifferenceOfProportions: function twoSidedDifferenceOfProportions(p1, n1, p2, n2) {\n var z = differenceOfProportions(p1, n1, p2, n2);\n return jStat.ztest(z, 2);\n }\n});\n\n}(jStat, Math));\njStat.models = (function(){\n function sub_regress(exog) {\n var var_count = exog[0].length;\n var modelList = jStat.arange(var_count).map(function(endog_index) {\n var exog_index =\n jStat.arange(var_count).filter(function(i){return i!==endog_index});\n return ols(jStat.col(exog, endog_index).map(function(x){ return x[0] }),\n jStat.col(exog, exog_index))\n });\n return modelList;\n }\n\n // do OLS model regress\n // exog have include const columns ,it will not generate it .In fact, exog is\n // \"design matrix\" look at\n //https://en.wikipedia.org/wiki/Design_matrix\n function ols(endog, exog) {\n var nobs = endog.length;\n var df_model = exog[0].length - 1;\n var df_resid = nobs-df_model - 1;\n var coef = jStat.lstsq(exog, endog);\n var predict =\n jStat.multiply(exog, coef.map(function(x) { return [x] }))\n .map(function(p) { return p[0] });\n var resid = jStat.subtract(endog, predict);\n var ybar = jStat.mean(endog);\n // constant cause problem\n // var SST = jStat.sum(endog.map(function(y) {\n // return Math.pow(y-ybar,2);\n // }));\n var SSE = jStat.sum(predict.map(function(f) {\n return Math.pow(f - ybar, 2);\n }));\n var SSR = jStat.sum(endog.map(function(y, i) {\n return Math.pow(y - predict[i], 2);\n }));\n var SST = SSE + SSR;\n var R2 = (SSE / SST);\n return {\n exog:exog,\n endog:endog,\n nobs:nobs,\n df_model:df_model,\n df_resid:df_resid,\n coef:coef,\n predict:predict,\n resid:resid,\n ybar:ybar,\n SST:SST,\n SSE:SSE,\n SSR:SSR,\n R2:R2\n };\n }\n\n // H0: b_I=0\n // H1: b_I!=0\n function t_test(model) {\n var subModelList = sub_regress(model.exog);\n //var sigmaHat=jStat.stdev(model.resid);\n var sigmaHat = Math.sqrt(model.SSR / (model.df_resid));\n var seBetaHat = subModelList.map(function(mod) {\n var SST = mod.SST;\n var R2 = mod.R2;\n return sigmaHat / Math.sqrt(SST * (1 - R2));\n });\n var tStatistic = model.coef.map(function(coef, i) {\n return (coef - 0) / seBetaHat[i];\n });\n var pValue = tStatistic.map(function(t) {\n var leftppf = jStat.studentt.cdf(t, model.df_resid);\n return (leftppf > 0.5 ? 1 - leftppf : leftppf) * 2;\n });\n var c = jStat.studentt.inv(0.975, model.df_resid);\n var interval95 = model.coef.map(function(coef, i) {\n var d = c * seBetaHat[i];\n return [coef - d, coef + d];\n })\n return {\n se: seBetaHat,\n t: tStatistic,\n p: pValue,\n sigmaHat: sigmaHat,\n interval95: interval95\n };\n }\n\n function F_test(model) {\n var F_statistic =\n (model.R2 / model.df_model) / ((1 - model.R2) / model.df_resid);\n var fcdf = function(x, n1, n2) {\n return jStat.beta.cdf(x / (n2 / n1 + x), n1 / 2, n2 / 2)\n }\n var pvalue = 1 - fcdf(F_statistic, model.df_model, model.df_resid);\n return { F_statistic: F_statistic, pvalue: pvalue };\n }\n\n function ols_wrap(endog, exog) {\n var model = ols(endog,exog);\n var ttest = t_test(model);\n var ftest = F_test(model);\n // Provide the Wherry / Ezekiel / McNemar / Cohen Adjusted R^2\n // Which matches the 'adjusted R^2' provided by R's lm package\n var adjust_R2 =\n 1 - (1 - model.R2) * ((model.nobs - 1) / (model.df_resid));\n model.t = ttest;\n model.f = ftest;\n model.adjust_R2 = adjust_R2;\n return model;\n }\n\n return { ols: ols_wrap };\n})();\n//To regress, simply build X matrix\n//(append column of 1's) using\n//buildxmatrix and build the Y\n//matrix using buildymatrix\n//(simply the transpose)\n//and run regress.\n\n\n\n//Regressions\n\njStat.extend({\n buildxmatrix: function buildxmatrix(){\n //Parameters will be passed in as such\n //(array1,array2,array3,...)\n //as (x1,x2,x3,...)\n //needs to be (1,x1,x2,x3,...)\n var matrixRows = new Array(arguments.length);\n for(var i=0;i1){\n result = [];\n for (i = 0; i < A.rows(); i++) {\n result[i] = [];\n for (j = 0; j < B.cols(); j++) {\n sum = 0;\n for (k = 0; k < A.cols(); k++) {\n sum += A.toArray()[i][k] * B.toArray()[k][j];\n }\n result[i][j] = sum;\n }\n }\n return jStat(result);\n }\n result = [];\n for (i = 0; i < A.rows(); i++) {\n result[i] = [];\n for (j = 0; j < B.cols(); j++) {\n sum = 0;\n for (k = 0; k < A.cols(); k++) {\n sum += A.toArray()[i][k] * B.toArray()[j];\n }\n result[i][j] = sum;\n }\n }\n return jStat(result);\n }\n },\n\n //regress and regresst to be fixed\n\n regress: function regress(jMatX,jMatY){\n //print(\"regressin!\");\n //print(jMatX.toArray());\n var innerinv = jStat.xtranspxinv(jMatX);\n //print(innerinv);\n var xtransp = jMatX.transpose();\n var next = jStat.matrixmult(jStat(innerinv),xtransp);\n return jStat.matrixmult(next,jMatY);\n\n },\n\n regresst: function regresst(jMatX,jMatY,sides){\n var beta = jStat.regress(jMatX,jMatY);\n\n var compile = {};\n compile.anova = {};\n var jMatYBar = jStat.jMatYBar(jMatX, beta);\n compile.yBar = jMatYBar;\n var yAverage = jMatY.mean();\n compile.anova.residuals = jStat.residuals(jMatY, jMatYBar);\n\n compile.anova.ssr = jStat.ssr(jMatYBar, yAverage);\n compile.anova.msr = compile.anova.ssr / (jMatX[0].length - 1);\n\n compile.anova.sse = jStat.sse(jMatY, jMatYBar);\n compile.anova.mse =\n compile.anova.sse / (jMatY.length - (jMatX[0].length - 1) - 1);\n\n compile.anova.sst = jStat.sst(jMatY, yAverage);\n compile.anova.mst = compile.anova.sst / (jMatY.length - 1);\n\n compile.anova.r2 = 1 - (compile.anova.sse / compile.anova.sst);\n if (compile.anova.r2 < 0) compile.anova.r2 = 0;\n\n compile.anova.fratio = compile.anova.msr / compile.anova.mse;\n compile.anova.pvalue =\n jStat.anovaftest(compile.anova.fratio,\n jMatX[0].length - 1,\n jMatY.length - (jMatX[0].length - 1) - 1);\n\n compile.anova.rmse = Math.sqrt(compile.anova.mse);\n\n compile.anova.r2adj = 1 - (compile.anova.mse / compile.anova.mst);\n if (compile.anova.r2adj < 0) compile.anova.r2adj = 0;\n\n compile.stats = new Array(jMatX[0].length);\n var covar = jStat.xtranspxinv(jMatX);\n var sds, ts, ps;\n\n for(var i=0; i ReactiveElement;\n\nexport interface ReactionConstructor {\n new (...args: any[]): Reaction;\n}\n\n/**\n * A class mixin which can be applied to lit-element's\n * [ReactiveElement](https://lit.dev/docs/api/ReactiveElement/)\n * derived classes. This mixin adds a mobx reaction which tracks the update method of ReactiveElement.\n *\n * Any observables used in the render template of the element will be tracked by a reaction\n * and cause an update of the element upon change.\n *\n * @param constructor the constructor to extend from to add the mobx reaction, must be derived from ReactiveElement.\n * @param reaction a constructor for the Reaction implementation from mobx, used to provide custom Reactions and\n * makes it easier to handle multiple versions of mobx within a single application.\n */\nexport function MobxReactionUpdateCustom(\n constructor: T,\n ReactionConstructor: ReactionConstructor\n): T {\n return class MobxReactingElement extends constructor {\n // NOTE: using a symbol here to avoid potential name collisions in derived classes\n private [reaction]: Reaction | undefined;\n\n private [cachedRequestUpdate] = () => {\n this.requestUpdate();\n };\n\n public connectedCallback(): void {\n super.connectedCallback();\n const name =\n this.constructor.name /* c8 ignore next */ || this.nodeName;\n this[reaction] = new ReactionConstructor(\n `${name}.update()`,\n this[cachedRequestUpdate]\n );\n if (this.hasUpdated) this.requestUpdate();\n }\n\n public disconnectedCallback(): void {\n super.disconnectedCallback();\n if (this[reaction]) {\n this[reaction]!.dispose();\n this[reaction] = undefined;\n }\n }\n\n protected update(changedProperties: PropertyValues): void {\n if (this[reaction]) {\n this[reaction]!.track(\n super.update.bind(this, changedProperties)\n );\n /* c8 ignore next 4 */\n } else {\n // this should never happen, but just in case\n super.update(changedProperties);\n }\n }\n };\n}\n", "const niceErrors = {\n 0: `Invalid value for configuration 'enforceActions', expected 'never', 'always' or 'observed'`,\n 1(annotationType, key: PropertyKey) {\n return `Cannot apply '${annotationType}' to '${key.toString()}': Field not found.`\n },\n /*\n 2(prop) {\n return `invalid decorator for '${prop.toString()}'`\n },\n 3(prop) {\n return `Cannot decorate '${prop.toString()}': action can only be used on properties with a function value.`\n },\n 4(prop) {\n return `Cannot decorate '${prop.toString()}': computed can only be used on getter properties.`\n },\n */\n 5: \"'keys()' can only be used on observable objects, arrays, sets and maps\",\n 6: \"'values()' can only be used on observable objects, arrays, sets and maps\",\n 7: \"'entries()' can only be used on observable objects, arrays and maps\",\n 8: \"'set()' can only be used on observable objects, arrays and maps\",\n 9: \"'remove()' can only be used on observable objects, arrays and maps\",\n 10: \"'has()' can only be used on observable objects, arrays and maps\",\n 11: \"'get()' can only be used on observable objects, arrays and maps\",\n 12: `Invalid annotation`,\n 13: `Dynamic observable objects cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)`,\n 14: \"Intercept handlers should return nothing or a change object\",\n 15: `Observable arrays cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)`,\n 16: `Modification exception: the internal structure of an observable array was changed.`,\n 17(index, length) {\n return `[mobx.array] Index out of bounds, ${index} is larger than ${length}`\n },\n 18: \"mobx.map requires Map polyfill for the current browser. Check babel-polyfill or core-js/es6/map.js\",\n 19(other) {\n return \"Cannot initialize from classes that inherit from Map: \" + other.constructor.name\n },\n 20(other) {\n return \"Cannot initialize map from \" + other\n },\n 21(dataStructure) {\n return `Cannot convert to map from '${dataStructure}'`\n },\n 22: \"mobx.set requires Set polyfill for the current browser. Check babel-polyfill or core-js/es6/set.js\",\n 23: \"It is not possible to get index atoms from arrays\",\n 24(thing) {\n return \"Cannot obtain administration from \" + thing\n },\n 25(property, name) {\n return `the entry '${property}' does not exist in the observable map '${name}'`\n },\n 26: \"please specify a property\",\n 27(property, name) {\n return `no observable property '${property.toString()}' found on the observable object '${name}'`\n },\n 28(thing) {\n return \"Cannot obtain atom from \" + thing\n },\n 29: \"Expecting some object\",\n 30: \"invalid action stack. did you forget to finish an action?\",\n 31: \"missing option for computed: get\",\n 32(name, derivation) {\n return `Cycle detected in computation ${name}: ${derivation}`\n },\n 33(name) {\n return `The setter of computed value '${name}' is trying to update itself. Did you intend to update an _observable_ value, instead of the computed property?`\n },\n 34(name) {\n return `[ComputedValue '${name}'] It is not possible to assign a new value to a computed value.`\n },\n 35: \"There are multiple, different versions of MobX active. Make sure MobX is loaded only once or use `configure({ isolateGlobalState: true })`\",\n 36: \"isolateGlobalState should be called before MobX is running any reactions\",\n 37(method) {\n return `[mobx] \\`observableArray.${method}()\\` mutates the array in-place, which is not allowed inside a derivation. Use \\`array.slice().${method}()\\` instead`\n },\n 38: \"'ownKeys()' can only be used on observable objects\",\n 39: \"'defineProperty()' can only be used on observable objects\"\n} as const\n\nconst errors: typeof niceErrors = __DEV__ ? niceErrors : ({} as any)\n\nexport function die(error: string | keyof typeof errors, ...args: any[]): never {\n if (__DEV__) {\n let e: any = typeof error === \"string\" ? error : errors[error]\n if (typeof e === \"function\") e = e.apply(null, args as any)\n throw new Error(`[MobX] ${e}`)\n }\n throw new Error(\n typeof error === \"number\"\n ? `[MobX] minified error nr: ${error}${\n args.length ? \" \" + args.map(String).join(\",\") : \"\"\n }. Find the full error at: https://github.com/mobxjs/mobx/blob/main/packages/mobx/src/errors.ts`\n : `[MobX] ${error}`\n )\n}\n", "declare const window: any\ndeclare const self: any\n\nconst mockGlobal = {}\n\nexport function getGlobal() {\n if (typeof globalThis !== \"undefined\") {\n return globalThis\n }\n if (typeof window !== \"undefined\") {\n return window\n }\n if (typeof global !== \"undefined\") {\n return global\n }\n if (typeof self !== \"undefined\") {\n return self\n }\n return mockGlobal\n}\n", "import { globalState, die } from \"../internal\"\n\n// We shorten anything used > 5 times\nexport const assign = Object.assign\nexport const getDescriptor = Object.getOwnPropertyDescriptor\nexport const defineProperty = Object.defineProperty\nexport const objectPrototype = Object.prototype\n\nexport const EMPTY_ARRAY = []\nObject.freeze(EMPTY_ARRAY)\n\nexport const EMPTY_OBJECT = {}\nObject.freeze(EMPTY_OBJECT)\n\nexport interface Lambda {\n (): void\n name?: string\n}\n\nconst hasProxy = typeof Proxy !== \"undefined\"\nconst plainObjectString = Object.toString()\n\nexport function assertProxies() {\n if (!hasProxy) {\n die(\n __DEV__\n ? \"`Proxy` objects are not available in the current environment. Please configure MobX to enable a fallback implementation.`\"\n : \"Proxy not available\"\n )\n }\n}\n\nexport function warnAboutProxyRequirement(msg: string) {\n if (__DEV__ && globalState.verifyProxies) {\n die(\n \"MobX is currently configured to be able to run in ES5 mode, but in ES5 MobX won't be able to \" +\n msg\n )\n }\n}\n\nexport function getNextId() {\n return ++globalState.mobxGuid\n}\n\n/**\n * Makes sure that the provided function is invoked at most once.\n */\nexport function once(func: Lambda): Lambda {\n let invoked = false\n return function () {\n if (invoked) {\n return\n }\n invoked = true\n return (func as any).apply(this, arguments)\n }\n}\n\nexport const noop = () => {}\n\nexport function isFunction(fn: any): fn is Function {\n return typeof fn === \"function\"\n}\n\nexport function isString(value: any): value is string {\n return typeof value === \"string\"\n}\n\nexport function isStringish(value: any): value is string | number | symbol {\n const t = typeof value\n switch (t) {\n case \"string\":\n case \"symbol\":\n case \"number\":\n return true\n }\n return false\n}\n\nexport function isObject(value: any): value is Object {\n return value !== null && typeof value === \"object\"\n}\n\nexport function isPlainObject(value: any) {\n if (!isObject(value)) {\n return false\n }\n const proto = Object.getPrototypeOf(value)\n if (proto == null) {\n return true\n }\n const protoConstructor = Object.hasOwnProperty.call(proto, \"constructor\") && proto.constructor\n return (\n typeof protoConstructor === \"function\" && protoConstructor.toString() === plainObjectString\n )\n}\n\n// https://stackoverflow.com/a/37865170\nexport function isGenerator(obj: any): boolean {\n const constructor = obj?.constructor\n if (!constructor) {\n return false\n }\n if (\n \"GeneratorFunction\" === constructor.name ||\n \"GeneratorFunction\" === constructor.displayName\n ) {\n return true\n }\n return false\n}\n\nexport function addHiddenProp(object: any, propName: PropertyKey, value: any) {\n defineProperty(object, propName, {\n enumerable: false,\n writable: true,\n configurable: true,\n value\n })\n}\n\nexport function addHiddenFinalProp(object: any, propName: PropertyKey, value: any) {\n defineProperty(object, propName, {\n enumerable: false,\n writable: false,\n configurable: true,\n value\n })\n}\n\nexport function createInstanceofPredicate(\n name: string,\n theClass: new (...args: any[]) => T\n): (x: any) => x is T {\n const propName = \"isMobX\" + name\n theClass.prototype[propName] = true\n return function (x) {\n return isObject(x) && x[propName] === true\n } as any\n}\n\nexport function isES6Map(thing: any): thing is Map {\n return thing instanceof Map\n}\n\nexport function isES6Set(thing: any): thing is Set {\n return thing instanceof Set\n}\n\nconst hasGetOwnPropertySymbols = typeof Object.getOwnPropertySymbols !== \"undefined\"\n\n/**\n * Returns the following: own enumerable keys and symbols.\n */\nexport function getPlainObjectKeys(object: any) {\n const keys = Object.keys(object)\n // Not supported in IE, so there are not going to be symbol props anyway...\n if (!hasGetOwnPropertySymbols) {\n return keys\n }\n const symbols = Object.getOwnPropertySymbols(object)\n if (!symbols.length) {\n return keys\n }\n return [...keys, ...symbols.filter(s => objectPrototype.propertyIsEnumerable.call(object, s))]\n}\n\n// From Immer utils\n// Returns all own keys, including non-enumerable and symbolic\nexport const ownKeys: (target: any) => Array =\n typeof Reflect !== \"undefined\" && Reflect.ownKeys\n ? Reflect.ownKeys\n : hasGetOwnPropertySymbols\n ? obj => Object.getOwnPropertyNames(obj).concat(Object.getOwnPropertySymbols(obj) as any)\n : /* istanbul ignore next */ Object.getOwnPropertyNames\n\nexport function stringifyKey(key: any): string {\n if (typeof key === \"string\") {\n return key\n }\n if (typeof key === \"symbol\") {\n return key.toString()\n }\n return new String(key).toString()\n}\n\nexport function toPrimitive(value: any) {\n return value === null ? null : typeof value === \"object\" ? \"\" + value : value\n}\n\nexport function hasProp(target: Object, prop: PropertyKey): boolean {\n return objectPrototype.hasOwnProperty.call(target, prop)\n}\n\n// From Immer utils\nexport const getOwnPropertyDescriptors =\n Object.getOwnPropertyDescriptors ||\n function getOwnPropertyDescriptors(target: any) {\n // Polyfill needed for Hermes and IE, see https://github.com/facebook/hermes/issues/274\n const res: any = {}\n // Note: without polyfill for ownKeys, symbols won't be picked up\n ownKeys(target).forEach(key => {\n res[key] = getDescriptor(target, key)\n })\n return res\n }\n", "import { Annotation, addHiddenProp, AnnotationsMap, hasProp, die, isOverride } from \"../internal\"\n\nimport type { Decorator } from \"../types/decorator_fills\"\n\nexport const storedAnnotationsSymbol = Symbol(\"mobx-stored-annotations\")\n\n/**\n * Creates a function that acts as\n * - decorator\n * - annotation object\n */\nexport function createDecoratorAnnotation(\n annotation: Annotation\n): PropertyDecorator & Annotation & D {\n function decorator(target, property) {\n if (is20223Decorator(property)) {\n return annotation.decorate_20223_(target, property)\n } else {\n storeAnnotation(target, property, annotation)\n }\n }\n return Object.assign(decorator, annotation) as any\n}\n\n/**\n * Stores annotation to prototype,\n * so it can be inspected later by `makeObservable` called from constructor\n */\nexport function storeAnnotation(prototype: any, key: PropertyKey, annotation: Annotation) {\n if (!hasProp(prototype, storedAnnotationsSymbol)) {\n addHiddenProp(prototype, storedAnnotationsSymbol, {\n // Inherit annotations\n ...prototype[storedAnnotationsSymbol]\n })\n }\n // @override must override something\n if (__DEV__ && isOverride(annotation) && !hasProp(prototype[storedAnnotationsSymbol], key)) {\n const fieldName = `${prototype.constructor.name}.prototype.${key.toString()}`\n die(\n `'${fieldName}' is decorated with 'override', ` +\n `but no such decorated member was found on prototype.`\n )\n }\n // Cannot re-decorate\n assertNotDecorated(prototype, annotation, key)\n\n // Ignore override\n if (!isOverride(annotation)) {\n prototype[storedAnnotationsSymbol][key] = annotation\n }\n}\n\nfunction assertNotDecorated(prototype: object, annotation: Annotation, key: PropertyKey) {\n if (__DEV__ && !isOverride(annotation) && hasProp(prototype[storedAnnotationsSymbol], key)) {\n const fieldName = `${prototype.constructor.name}.prototype.${key.toString()}`\n const currentAnnotationType = prototype[storedAnnotationsSymbol][key].annotationType_\n const requestedAnnotationType = annotation.annotationType_\n die(\n `Cannot apply '@${requestedAnnotationType}' to '${fieldName}':` +\n `\\nThe field is already decorated with '@${currentAnnotationType}'.` +\n `\\nRe-decorating fields is not allowed.` +\n `\\nUse '@override' decorator for methods overridden by subclass.`\n )\n }\n}\n\n/**\n * Collects annotations from prototypes and stores them on target (instance)\n */\nexport function collectStoredAnnotations(target): AnnotationsMap {\n if (!hasProp(target, storedAnnotationsSymbol)) {\n // if (__DEV__ && !target[storedAnnotationsSymbol]) {\n // die(\n // `No annotations were passed to makeObservable, but no decorated members have been found either`\n // )\n // }\n // We need a copy as we will remove annotation from the list once it's applied.\n addHiddenProp(target, storedAnnotationsSymbol, { ...target[storedAnnotationsSymbol] })\n }\n return target[storedAnnotationsSymbol]\n}\n\nexport function is20223Decorator(context): context is DecoratorContext {\n return typeof context == \"object\" && typeof context[\"kind\"] == \"string\"\n}\n\nexport function assert20223DecoratorType(\n context: DecoratorContext,\n types: DecoratorContext[\"kind\"][]\n) {\n if (__DEV__ && !types.includes(context.kind)) {\n die(\n `The decorator applied to '${String(context.name)}' cannot be used on a ${\n context.kind\n } element`\n )\n }\n}\n", "import {\n IDerivationState_,\n IObservable,\n IDerivation,\n createInstanceofPredicate,\n endBatch,\n getNextId,\n noop,\n onBecomeObserved,\n onBecomeUnobserved,\n propagateChanged,\n reportObserved,\n startBatch,\n Lambda\n} from \"../internal\"\n\nexport const $mobx = Symbol(\"mobx administration\")\n\nexport interface IAtom extends IObservable {\n reportObserved(): boolean\n reportChanged(): void\n}\n\nexport class Atom implements IAtom {\n isPendingUnobservation_ = false // for effective unobserving. BaseAtom has true, for extra optimization, so its onBecomeUnobserved never gets called, because it's not needed\n isBeingObserved_ = false\n observers_ = new Set()\n\n diffValue_ = 0\n lastAccessedBy_ = 0\n lowestObserverState_ = IDerivationState_.NOT_TRACKING_\n /**\n * Create a new atom. For debugging purposes it is recommended to give it a name.\n * The onBecomeObserved and onBecomeUnobserved callbacks can be used for resource management.\n */\n constructor(public name_ = __DEV__ ? \"Atom@\" + getNextId() : \"Atom\") {}\n\n // onBecomeObservedListeners\n public onBOL: Set | undefined\n // onBecomeUnobservedListeners\n public onBUOL: Set | undefined\n\n public onBO() {\n if (this.onBOL) {\n this.onBOL.forEach(listener => listener())\n }\n }\n\n public onBUO() {\n if (this.onBUOL) {\n this.onBUOL.forEach(listener => listener())\n }\n }\n\n /**\n * Invoke this method to notify mobx that your atom has been used somehow.\n * Returns true if there is currently a reactive context.\n */\n public reportObserved(): boolean {\n return reportObserved(this)\n }\n\n /**\n * Invoke this method _after_ this method has changed to signal mobx that all its observers should invalidate.\n */\n public reportChanged() {\n startBatch()\n propagateChanged(this)\n endBatch()\n }\n\n toString() {\n return this.name_\n }\n}\n\nexport const isAtom = createInstanceofPredicate(\"Atom\", Atom)\n\nexport function createAtom(\n name: string,\n onBecomeObservedHandler: () => void = noop,\n onBecomeUnobservedHandler: () => void = noop\n): IAtom {\n const atom = new Atom(name)\n // default `noop` listener will not initialize the hook Set\n if (onBecomeObservedHandler !== noop) {\n onBecomeObserved(atom, onBecomeObservedHandler)\n }\n\n if (onBecomeUnobservedHandler !== noop) {\n onBecomeUnobserved(atom, onBecomeUnobservedHandler)\n }\n return atom\n}\n", "import { deepEqual } from \"../internal\"\n\nexport interface IEqualsComparer {\n (a: T, b: T): boolean\n}\n\nfunction identityComparer(a: any, b: any): boolean {\n return a === b\n}\n\nfunction structuralComparer(a: any, b: any): boolean {\n return deepEqual(a, b)\n}\n\nfunction shallowComparer(a: any, b: any): boolean {\n return deepEqual(a, b, 1)\n}\n\nfunction defaultComparer(a: any, b: any): boolean {\n if (Object.is) {\n return Object.is(a, b)\n }\n\n return a === b ? a !== 0 || 1 / a === 1 / b : a !== a && b !== b\n}\n\nexport const comparer = {\n identity: identityComparer,\n structural: structuralComparer,\n default: defaultComparer,\n shallow: shallowComparer\n}\n", "import {\n deepEqual,\n isES6Map,\n isES6Set,\n isObservable,\n isObservableArray,\n isObservableMap,\n isObservableSet,\n isObservableObject,\n isPlainObject,\n observable,\n die,\n isAction,\n autoAction,\n flow,\n isFlow,\n isGenerator\n} from \"../internal\"\n\nexport interface IEnhancer {\n (newValue: T, oldValue: T | undefined, name: string): T\n}\n\nexport function deepEnhancer(v, _, name) {\n // it is an observable already, done\n if (isObservable(v)) {\n return v\n }\n\n // something that can be converted and mutated?\n if (Array.isArray(v)) {\n return observable.array(v, { name })\n }\n if (isPlainObject(v)) {\n return observable.object(v, undefined, { name })\n }\n if (isES6Map(v)) {\n return observable.map(v, { name })\n }\n if (isES6Set(v)) {\n return observable.set(v, { name })\n }\n if (typeof v === \"function\" && !isAction(v) && !isFlow(v)) {\n if (isGenerator(v)) {\n return flow(v)\n } else {\n return autoAction(name, v)\n }\n }\n return v\n}\n\nexport function shallowEnhancer(v, _, name): any {\n if (v === undefined || v === null) {\n return v\n }\n if (isObservableObject(v) || isObservableArray(v) || isObservableMap(v) || isObservableSet(v)) {\n return v\n }\n if (Array.isArray(v)) {\n return observable.array(v, { name, deep: false })\n }\n if (isPlainObject(v)) {\n return observable.object(v, undefined, { name, deep: false })\n }\n if (isES6Map(v)) {\n return observable.map(v, { name, deep: false })\n }\n if (isES6Set(v)) {\n return observable.set(v, { name, deep: false })\n }\n\n if (__DEV__) {\n die(\n \"The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets\"\n )\n }\n}\n\nexport function referenceEnhancer(newValue?) {\n // never turn into an observable\n return newValue\n}\n\nexport function refStructEnhancer(v, oldValue): any {\n if (__DEV__ && isObservable(v)) {\n die(`observable.struct should not be used with observable values`)\n }\n if (deepEqual(v, oldValue)) {\n return oldValue\n }\n return v\n}\n", "import {\n die,\n Annotation,\n hasProp,\n createDecoratorAnnotation,\n ObservableObjectAdministration,\n MakeResult\n} from \"../internal\"\n\nimport type { ClassMethodDecorator } from \"./decorator_fills\"\n\nconst OVERRIDE = \"override\"\n\nexport const override: Annotation & PropertyDecorator & ClassMethodDecorator =\n createDecoratorAnnotation({\n annotationType_: OVERRIDE,\n make_,\n extend_,\n decorate_20223_\n })\n\nexport function isOverride(annotation: Annotation): boolean {\n return annotation.annotationType_ === OVERRIDE\n}\n\nfunction make_(this: Annotation, adm: ObservableObjectAdministration, key): MakeResult {\n // Must not be plain object\n if (__DEV__ && adm.isPlainObject_) {\n die(\n `Cannot apply '${this.annotationType_}' to '${adm.name_}.${key.toString()}':` +\n `\\n'${this.annotationType_}' cannot be used on plain objects.`\n )\n }\n // Must override something\n if (__DEV__ && !hasProp(adm.appliedAnnotations_!, key)) {\n die(\n `'${adm.name_}.${key.toString()}' is annotated with '${this.annotationType_}', ` +\n `but no such annotated member was found on prototype.`\n )\n }\n return MakeResult.Cancel\n}\n\nfunction extend_(this: Annotation, adm, key, descriptor, proxyTrap): boolean {\n die(`'${this.annotationType_}' can only be used with 'makeObservable'`)\n}\n\nfunction decorate_20223_(this: Annotation, desc, context: DecoratorContext) {\n console.warn(`'${this.annotationType_}' cannot be used with decorators - this is a no-op`)\n}\n", "import {\n ObservableObjectAdministration,\n createAction,\n isAction,\n defineProperty,\n die,\n isFunction,\n Annotation,\n globalState,\n MakeResult,\n assert20223DecoratorType,\n storeAnnotation\n} from \"../internal\"\n\nexport function createActionAnnotation(name: string, options?: object): Annotation {\n return {\n annotationType_: name,\n options_: options,\n make_,\n extend_,\n decorate_20223_\n }\n}\n\nfunction make_(\n this: Annotation,\n adm: ObservableObjectAdministration,\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n source: object\n): MakeResult {\n // bound\n if (this.options_?.bound) {\n return this.extend_(adm, key, descriptor, false) === null\n ? MakeResult.Cancel\n : MakeResult.Break\n }\n // own\n if (source === adm.target_) {\n return this.extend_(adm, key, descriptor, false) === null\n ? MakeResult.Cancel\n : MakeResult.Continue\n }\n // prototype\n if (isAction(descriptor.value)) {\n // A prototype could have been annotated already by other constructor,\n // rest of the proto chain must be annotated already\n return MakeResult.Break\n }\n const actionDescriptor = createActionDescriptor(adm, this, key, descriptor, false)\n defineProperty(source, key, actionDescriptor)\n return MakeResult.Continue\n}\n\nfunction extend_(\n this: Annotation,\n adm: ObservableObjectAdministration,\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n proxyTrap: boolean\n): boolean | null {\n const actionDescriptor = createActionDescriptor(adm, this, key, descriptor)\n return adm.defineProperty_(key, actionDescriptor, proxyTrap)\n}\n\nfunction decorate_20223_(this: Annotation, mthd, context: DecoratorContext) {\n if (__DEV__) {\n assert20223DecoratorType(context, [\"method\", \"field\"])\n }\n const { kind, name, addInitializer } = context\n const ann = this\n\n const _createAction = m =>\n createAction(ann.options_?.name ?? name!.toString(), m, ann.options_?.autoAction ?? false)\n\n // Backwards/Legacy behavior, expects makeObservable(this)\n if (kind == \"field\") {\n addInitializer(function () {\n storeAnnotation(this, name, ann)\n })\n return\n }\n\n if (kind == \"method\") {\n if (!isAction(mthd)) {\n mthd = _createAction(mthd)\n }\n\n if (this.options_?.bound) {\n addInitializer(function () {\n const self = this as any\n const bound = self[name].bind(self)\n bound.isMobxAction = true\n self[name] = bound\n })\n }\n\n return mthd\n }\n\n die(\n `Cannot apply '${ann.annotationType_}' to '${String(name)}' (kind: ${kind}):` +\n `\\n'${ann.annotationType_}' can only be used on properties with a function value.`\n )\n}\n\nfunction assertActionDescriptor(\n adm: ObservableObjectAdministration,\n { annotationType_ }: Annotation,\n key: PropertyKey,\n { value }: PropertyDescriptor\n) {\n if (__DEV__ && !isFunction(value)) {\n die(\n `Cannot apply '${annotationType_}' to '${adm.name_}.${key.toString()}':` +\n `\\n'${annotationType_}' can only be used on properties with a function value.`\n )\n }\n}\n\nexport function createActionDescriptor(\n adm: ObservableObjectAdministration,\n annotation: Annotation,\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n // provides ability to disable safeDescriptors for prototypes\n safeDescriptors: boolean = globalState.safeDescriptors\n) {\n assertActionDescriptor(adm, annotation, key, descriptor)\n let { value } = descriptor\n if (annotation.options_?.bound) {\n value = value.bind(adm.proxy_ ?? adm.target_)\n }\n return {\n value: createAction(\n annotation.options_?.name ?? key.toString(),\n value,\n annotation.options_?.autoAction ?? false,\n // https://github.com/mobxjs/mobx/discussions/3140\n annotation.options_?.bound ? adm.proxy_ ?? adm.target_ : undefined\n ),\n // Non-configurable for classes\n // prevents accidental field redefinition in subclass\n configurable: safeDescriptors ? adm.isPlainObject_ : true,\n // https://github.com/mobxjs/mobx/pull/2641#issuecomment-737292058\n enumerable: false,\n // Non-obsevable, therefore non-writable\n // Also prevents rewriting in subclass constructor\n writable: safeDescriptors ? false : true\n }\n}\n", "import {\n ObservableObjectAdministration,\n Annotation,\n defineProperty,\n die,\n flow,\n isFlow,\n isFunction,\n globalState,\n MakeResult,\n hasProp,\n assert20223DecoratorType\n} from \"../internal\"\n\nexport function createFlowAnnotation(name: string, options?: object): Annotation {\n return {\n annotationType_: name,\n options_: options,\n make_,\n extend_,\n decorate_20223_\n }\n}\n\nfunction make_(\n this: Annotation,\n adm: ObservableObjectAdministration,\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n source: object\n): MakeResult {\n // own\n if (source === adm.target_) {\n return this.extend_(adm, key, descriptor, false) === null\n ? MakeResult.Cancel\n : MakeResult.Continue\n }\n // prototype\n // bound - must annotate protos to support super.flow()\n if (this.options_?.bound && (!hasProp(adm.target_, key) || !isFlow(adm.target_[key]))) {\n if (this.extend_(adm, key, descriptor, false) === null) {\n return MakeResult.Cancel\n }\n }\n if (isFlow(descriptor.value)) {\n // A prototype could have been annotated already by other constructor,\n // rest of the proto chain must be annotated already\n return MakeResult.Break\n }\n const flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, false, false)\n defineProperty(source, key, flowDescriptor)\n return MakeResult.Continue\n}\n\nfunction extend_(\n this: Annotation,\n adm: ObservableObjectAdministration,\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n proxyTrap: boolean\n): boolean | null {\n const flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, this.options_?.bound)\n return adm.defineProperty_(key, flowDescriptor, proxyTrap)\n}\n\nfunction decorate_20223_(this: Annotation, mthd, context: ClassMethodDecoratorContext) {\n if (__DEV__) {\n assert20223DecoratorType(context, [\"method\"])\n }\n const { name, addInitializer } = context\n\n if (!isFlow(mthd)) {\n mthd = flow(mthd)\n }\n\n if (this.options_?.bound) {\n addInitializer(function () {\n const self = this as any\n const bound = self[name].bind(self)\n bound.isMobXFlow = true\n self[name] = bound\n })\n }\n\n return mthd\n}\n\nfunction assertFlowDescriptor(\n adm: ObservableObjectAdministration,\n { annotationType_ }: Annotation,\n key: PropertyKey,\n { value }: PropertyDescriptor\n) {\n if (__DEV__ && !isFunction(value)) {\n die(\n `Cannot apply '${annotationType_}' to '${adm.name_}.${key.toString()}':` +\n `\\n'${annotationType_}' can only be used on properties with a generator function value.`\n )\n }\n}\n\nfunction createFlowDescriptor(\n adm: ObservableObjectAdministration,\n annotation: Annotation,\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n bound: boolean,\n // provides ability to disable safeDescriptors for prototypes\n safeDescriptors: boolean = globalState.safeDescriptors\n): PropertyDescriptor {\n assertFlowDescriptor(adm, annotation, key, descriptor)\n let { value } = descriptor\n // In case of flow.bound, the descriptor can be from already annotated prototype\n if (!isFlow(value)) {\n value = flow(value)\n }\n if (bound) {\n // We do not keep original function around, so we bind the existing flow\n value = value.bind(adm.proxy_ ?? adm.target_)\n // This is normally set by `flow`, but `bind` returns new function...\n value.isMobXFlow = true\n }\n return {\n value,\n // Non-configurable for classes\n // prevents accidental field redefinition in subclass\n configurable: safeDescriptors ? adm.isPlainObject_ : true,\n // https://github.com/mobxjs/mobx/pull/2641#issuecomment-737292058\n enumerable: false,\n // Non-obsevable, therefore non-writable\n // Also prevents rewriting in subclass constructor\n writable: safeDescriptors ? false : true\n }\n}\n", "import {\n ObservableObjectAdministration,\n die,\n Annotation,\n MakeResult,\n assert20223DecoratorType,\n $mobx,\n asObservableObject,\n ComputedValue\n} from \"../internal\"\n\nexport function createComputedAnnotation(name: string, options?: object): Annotation {\n return {\n annotationType_: name,\n options_: options,\n make_,\n extend_,\n decorate_20223_\n }\n}\n\nfunction make_(\n this: Annotation,\n adm: ObservableObjectAdministration,\n key: PropertyKey,\n descriptor: PropertyDescriptor\n): MakeResult {\n return this.extend_(adm, key, descriptor, false) === null ? MakeResult.Cancel : MakeResult.Break\n}\n\nfunction extend_(\n this: Annotation,\n adm: ObservableObjectAdministration,\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n proxyTrap: boolean\n): boolean | null {\n assertComputedDescriptor(adm, this, key, descriptor)\n return adm.defineComputedProperty_(\n key,\n {\n ...this.options_,\n get: descriptor.get,\n set: descriptor.set\n },\n proxyTrap\n )\n}\n\nfunction decorate_20223_(this: Annotation, get, context: ClassGetterDecoratorContext) {\n if (__DEV__) {\n assert20223DecoratorType(context, [\"getter\"])\n }\n const ann = this\n const { name: key, addInitializer } = context\n\n addInitializer(function () {\n const adm: ObservableObjectAdministration = asObservableObject(this)[$mobx]\n const options = {\n ...ann.options_,\n get,\n context: this\n }\n options.name ||= __DEV__\n ? `${adm.name_}.${key.toString()}`\n : `ObservableObject.${key.toString()}`\n adm.values_.set(key, new ComputedValue(options))\n })\n\n return function () {\n return this[$mobx].getObservablePropValue_(key)\n }\n}\n\nfunction assertComputedDescriptor(\n adm: ObservableObjectAdministration,\n { annotationType_ }: Annotation,\n key: PropertyKey,\n { get }: PropertyDescriptor\n) {\n if (__DEV__ && !get) {\n die(\n `Cannot apply '${annotationType_}' to '${adm.name_}.${key.toString()}':` +\n `\\n'${annotationType_}' can only be used on getter(+setter) properties.`\n )\n }\n}\n", "import {\n ObservableObjectAdministration,\n deepEnhancer,\n die,\n Annotation,\n MakeResult,\n assert20223DecoratorType,\n ObservableValue,\n asObservableObject,\n $mobx\n} from \"../internal\"\n\nexport function createObservableAnnotation(name: string, options?: object): Annotation {\n return {\n annotationType_: name,\n options_: options,\n make_,\n extend_,\n decorate_20223_\n }\n}\n\nfunction make_(\n this: Annotation,\n adm: ObservableObjectAdministration,\n key: PropertyKey,\n descriptor: PropertyDescriptor\n): MakeResult {\n return this.extend_(adm, key, descriptor, false) === null ? MakeResult.Cancel : MakeResult.Break\n}\n\nfunction extend_(\n this: Annotation,\n adm: ObservableObjectAdministration,\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n proxyTrap: boolean\n): boolean | null {\n assertObservableDescriptor(adm, this, key, descriptor)\n return adm.defineObservableProperty_(\n key,\n descriptor.value,\n this.options_?.enhancer ?? deepEnhancer,\n proxyTrap\n )\n}\n\nfunction decorate_20223_(\n this: Annotation,\n desc,\n context: ClassAccessorDecoratorContext | ClassFieldDecoratorContext\n) {\n if (__DEV__) {\n if (context.kind === \"field\") {\n throw die(\n `Please use \\`@observable accessor ${String(\n context.name\n )}\\` instead of \\`@observable ${String(context.name)}\\``\n )\n }\n assert20223DecoratorType(context, [\"accessor\"])\n }\n\n const ann = this\n const { kind, name } = context\n\n // The laziness here is not ideal... It's a workaround to how 2022.3 Decorators are implemented:\n // `addInitializer` callbacks are executed _before_ any accessors are defined (instead of the ideal-for-us right after each).\n // This means that, if we were to do our stuff in an `addInitializer`, we'd attempt to read a private slot\n // before it has been initialized. The runtime doesn't like that and throws a `Cannot read private member\n // from an object whose class did not declare it` error.\n // TODO: it seems that this will not be required anymore in the final version of the spec\n // See TODO: link\n const initializedObjects = new WeakSet()\n\n function initializeObservable(target, value) {\n const adm: ObservableObjectAdministration = asObservableObject(target)[$mobx]\n const observable = new ObservableValue(\n value,\n ann.options_?.enhancer ?? deepEnhancer,\n __DEV__ ? `${adm.name_}.${name.toString()}` : `ObservableObject.${name.toString()}`,\n false\n )\n adm.values_.set(name, observable)\n initializedObjects.add(target)\n }\n\n if (kind == \"accessor\") {\n return {\n get() {\n if (!initializedObjects.has(this)) {\n initializeObservable(this, desc.get.call(this))\n }\n return this[$mobx].getObservablePropValue_(name)\n },\n set(value) {\n if (!initializedObjects.has(this)) {\n initializeObservable(this, value)\n }\n return this[$mobx].setObservablePropValue_(name, value)\n },\n init(value) {\n if (!initializedObjects.has(this)) {\n initializeObservable(this, value)\n }\n return value\n }\n }\n }\n\n return\n}\n\nfunction assertObservableDescriptor(\n adm: ObservableObjectAdministration,\n { annotationType_ }: Annotation,\n key: PropertyKey,\n descriptor: PropertyDescriptor\n) {\n if (__DEV__ && !(\"value\" in descriptor)) {\n die(\n `Cannot apply '${annotationType_}' to '${adm.name_}.${key.toString()}':` +\n `\\n'${annotationType_}' cannot be used on getter/setter properties`\n )\n }\n}\n", "import {\n ObservableObjectAdministration,\n observable,\n Annotation,\n defineProperty,\n createAction,\n globalState,\n flow,\n computed,\n autoAction,\n isGenerator,\n MakeResult,\n die\n} from \"../internal\"\n\nconst AUTO = \"true\"\n\nexport const autoAnnotation: Annotation = createAutoAnnotation()\n\nexport function createAutoAnnotation(options?: object): Annotation {\n return {\n annotationType_: AUTO,\n options_: options,\n make_,\n extend_,\n decorate_20223_\n }\n}\n\nfunction make_(\n adm: ObservableObjectAdministration,\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n source: object\n): MakeResult {\n // getter -> computed\n if (descriptor.get) {\n return computed.make_(adm, key, descriptor, source)\n }\n // lone setter -> action setter\n if (descriptor.set) {\n // TODO make action applicable to setter and delegate to action.make_\n const set = createAction(key.toString(), descriptor.set) as (v: any) => void\n // own\n if (source === adm.target_) {\n return adm.defineProperty_(key, {\n configurable: globalState.safeDescriptors ? adm.isPlainObject_ : true,\n set\n }) === null\n ? MakeResult.Cancel\n : MakeResult.Continue\n }\n // proto\n defineProperty(source, key, {\n configurable: true,\n set\n })\n return MakeResult.Continue\n }\n // function on proto -> autoAction/flow\n if (source !== adm.target_ && typeof descriptor.value === \"function\") {\n if (isGenerator(descriptor.value)) {\n const flowAnnotation = this.options_?.autoBind ? flow.bound : flow\n return flowAnnotation.make_(adm, key, descriptor, source)\n }\n const actionAnnotation = this.options_?.autoBind ? autoAction.bound : autoAction\n return actionAnnotation.make_(adm, key, descriptor, source)\n }\n // other -> observable\n // Copy props from proto as well, see test:\n // \"decorate should work with Object.create\"\n let observableAnnotation = this.options_?.deep === false ? observable.ref : observable\n // if function respect autoBind option\n if (typeof descriptor.value === \"function\" && this.options_?.autoBind) {\n descriptor.value = descriptor.value.bind(adm.proxy_ ?? adm.target_)\n }\n return observableAnnotation.make_(adm, key, descriptor, source)\n}\n\nfunction extend_(\n adm: ObservableObjectAdministration,\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n proxyTrap: boolean\n): boolean | null {\n // getter -> computed\n if (descriptor.get) {\n return computed.extend_(adm, key, descriptor, proxyTrap)\n }\n // lone setter -> action setter\n if (descriptor.set) {\n // TODO make action applicable to setter and delegate to action.extend_\n return adm.defineProperty_(\n key,\n {\n configurable: globalState.safeDescriptors ? adm.isPlainObject_ : true,\n set: createAction(key.toString(), descriptor.set) as (v: any) => void\n },\n proxyTrap\n )\n }\n // other -> observable\n // if function respect autoBind option\n if (typeof descriptor.value === \"function\" && this.options_?.autoBind) {\n descriptor.value = descriptor.value.bind(adm.proxy_ ?? adm.target_)\n }\n let observableAnnotation = this.options_?.deep === false ? observable.ref : observable\n return observableAnnotation.extend_(adm, key, descriptor, proxyTrap)\n}\n\nfunction decorate_20223_(this: Annotation, desc, context: ClassGetterDecoratorContext) {\n die(`'${this.annotationType_}' cannot be used as a decorator`)\n}\n", "import {\n IEnhancer,\n IEqualsComparer,\n IObservableArray,\n IObservableMapInitialValues,\n IObservableSetInitialValues,\n IObservableValue,\n ObservableMap,\n ObservableSet,\n ObservableValue,\n asDynamicObservableObject,\n createObservableArray,\n deepEnhancer,\n extendObservable,\n isES6Map,\n isES6Set,\n isObservable,\n isPlainObject,\n referenceEnhancer,\n Annotation,\n shallowEnhancer,\n refStructEnhancer,\n AnnotationsMap,\n asObservableObject,\n storeAnnotation,\n createDecoratorAnnotation,\n createLegacyArray,\n globalState,\n assign,\n isStringish,\n createObservableAnnotation,\n createAutoAnnotation,\n is20223Decorator,\n initObservable\n} from \"../internal\"\n\nimport type { ClassAccessorDecorator, ClassFieldDecorator } from \"../types/decorator_fills\"\n\nexport const OBSERVABLE = \"observable\"\nexport const OBSERVABLE_REF = \"observable.ref\"\nexport const OBSERVABLE_SHALLOW = \"observable.shallow\"\nexport const OBSERVABLE_STRUCT = \"observable.struct\"\n\nexport type CreateObservableOptions = {\n name?: string\n equals?: IEqualsComparer\n deep?: boolean\n defaultDecorator?: Annotation\n proxy?: boolean\n autoBind?: boolean\n}\n\n// Predefined bags of create observable options, to avoid allocating temporarily option objects\n// in the majority of cases\nexport const defaultCreateObservableOptions: CreateObservableOptions = {\n deep: true,\n name: undefined,\n defaultDecorator: undefined,\n proxy: true\n}\nObject.freeze(defaultCreateObservableOptions)\n\nexport function asCreateObservableOptions(thing: any): CreateObservableOptions {\n return thing || defaultCreateObservableOptions\n}\n\nconst observableAnnotation = createObservableAnnotation(OBSERVABLE)\nconst observableRefAnnotation = createObservableAnnotation(OBSERVABLE_REF, {\n enhancer: referenceEnhancer\n})\nconst observableShallowAnnotation = createObservableAnnotation(OBSERVABLE_SHALLOW, {\n enhancer: shallowEnhancer\n})\nconst observableStructAnnotation = createObservableAnnotation(OBSERVABLE_STRUCT, {\n enhancer: refStructEnhancer\n})\nconst observableDecoratorAnnotation =\n createDecoratorAnnotation(observableAnnotation)\n\nexport function getEnhancerFromOptions(options: CreateObservableOptions): IEnhancer {\n return options.deep === true\n ? deepEnhancer\n : options.deep === false\n ? referenceEnhancer\n : getEnhancerFromAnnotation(options.defaultDecorator)\n}\n\nexport function getAnnotationFromOptions(\n options?: CreateObservableOptions\n): Annotation | undefined {\n return options ? options.defaultDecorator ?? createAutoAnnotation(options) : undefined\n}\n\nexport function getEnhancerFromAnnotation(annotation?: Annotation): IEnhancer {\n return !annotation ? deepEnhancer : annotation.options_?.enhancer ?? deepEnhancer\n}\n\n/**\n * Turns an object, array or function into a reactive structure.\n * @param v the value which should become observable.\n */\nfunction createObservable(v: any, arg2?: any, arg3?: any) {\n // @observable someProp; (2022.3 Decorators)\n if (is20223Decorator(arg2)) {\n return observableAnnotation.decorate_20223_(v, arg2)\n }\n\n // @observable someProp;\n if (isStringish(arg2)) {\n storeAnnotation(v, arg2, observableAnnotation)\n return\n }\n\n // already observable - ignore\n if (isObservable(v)) {\n return v\n }\n\n // plain object\n if (isPlainObject(v)) {\n return observable.object(v, arg2, arg3)\n }\n\n // Array\n if (Array.isArray(v)) {\n return observable.array(v, arg2)\n }\n\n // Map\n if (isES6Map(v)) {\n return observable.map(v, arg2)\n }\n\n // Set\n if (isES6Set(v)) {\n return observable.set(v, arg2)\n }\n\n // other object - ignore\n if (typeof v === \"object\" && v !== null) {\n return v\n }\n\n // anything else\n return observable.box(v, arg2)\n}\nassign(createObservable, observableDecoratorAnnotation)\n\nexport interface IObservableValueFactory {\n (value: T, options?: CreateObservableOptions): IObservableValue\n (value?: T, options?: CreateObservableOptions): IObservableValue\n}\n\nexport interface IObservableFactory\n extends Annotation,\n PropertyDecorator,\n ClassAccessorDecorator,\n ClassFieldDecorator {\n // TODO: remove ClassFieldDecorator, this is only temporarily support for legacy decorators\n (value: T[], options?: CreateObservableOptions): IObservableArray\n (value: Set, options?: CreateObservableOptions): ObservableSet\n (value: Map, options?: CreateObservableOptions): ObservableMap\n (\n value: T,\n decorators?: AnnotationsMap,\n options?: CreateObservableOptions\n ): T\n\n box: IObservableValueFactory\n array: (initialValues?: T[], options?: CreateObservableOptions) => IObservableArray\n set: (\n initialValues?: IObservableSetInitialValues,\n options?: CreateObservableOptions\n ) => ObservableSet\n map: (\n initialValues?: IObservableMapInitialValues,\n options?: CreateObservableOptions\n ) => ObservableMap\n object: (\n props: T,\n decorators?: AnnotationsMap,\n options?: CreateObservableOptions\n ) => T\n\n /**\n * Decorator that creates an observable that only observes the references, but doesn't try to turn the assigned value into an observable.ts.\n */\n ref: Annotation & PropertyDecorator & ClassAccessorDecorator & ClassFieldDecorator\n /**\n * Decorator that creates an observable converts its value (objects, maps or arrays) into a shallow observable structure\n */\n shallow: Annotation & PropertyDecorator & ClassAccessorDecorator & ClassFieldDecorator\n deep: Annotation & PropertyDecorator & ClassAccessorDecorator & ClassFieldDecorator\n struct: Annotation & PropertyDecorator & ClassAccessorDecorator & ClassFieldDecorator\n}\n\nconst observableFactories: IObservableFactory = {\n box(value: T, options?: CreateObservableOptions): IObservableValue {\n const o = asCreateObservableOptions(options)\n return new ObservableValue(value, getEnhancerFromOptions(o), o.name, true, o.equals)\n },\n array(initialValues?: T[], options?: CreateObservableOptions): IObservableArray {\n const o = asCreateObservableOptions(options)\n return (\n globalState.useProxies === false || o.proxy === false\n ? createLegacyArray\n : createObservableArray\n )(initialValues, getEnhancerFromOptions(o), o.name)\n },\n map(\n initialValues?: IObservableMapInitialValues,\n options?: CreateObservableOptions\n ): ObservableMap {\n const o = asCreateObservableOptions(options)\n return new ObservableMap(initialValues, getEnhancerFromOptions(o), o.name)\n },\n set(\n initialValues?: IObservableSetInitialValues,\n options?: CreateObservableOptions\n ): ObservableSet {\n const o = asCreateObservableOptions(options)\n return new ObservableSet(initialValues, getEnhancerFromOptions(o), o.name)\n },\n object(\n props: T,\n decorators?: AnnotationsMap,\n options?: CreateObservableOptions\n ): T {\n return initObservable(() =>\n extendObservable(\n globalState.useProxies === false || options?.proxy === false\n ? asObservableObject({}, options)\n : asDynamicObservableObject({}, options),\n props,\n decorators\n )\n )\n },\n ref: createDecoratorAnnotation(observableRefAnnotation),\n shallow: createDecoratorAnnotation(observableShallowAnnotation),\n deep: observableDecoratorAnnotation,\n struct: createDecoratorAnnotation(observableStructAnnotation)\n} as any\n\n// eslint-disable-next-line\nexport var observable: IObservableFactory = assign(createObservable, observableFactories)\n", "import {\n ComputedValue,\n IComputedValueOptions,\n Annotation,\n storeAnnotation,\n createDecoratorAnnotation,\n isStringish,\n isPlainObject,\n isFunction,\n die,\n IComputedValue,\n createComputedAnnotation,\n comparer,\n is20223Decorator\n} from \"../internal\"\n\nimport type { ClassGetterDecorator } from \"../types/decorator_fills\"\n\nexport const COMPUTED = \"computed\"\nexport const COMPUTED_STRUCT = \"computed.struct\"\n\nexport interface IComputedFactory extends Annotation, PropertyDecorator, ClassGetterDecorator {\n // @computed(opts)\n (options: IComputedValueOptions): Annotation & PropertyDecorator & ClassGetterDecorator\n // computed(fn, opts)\n (func: () => T, options?: IComputedValueOptions): IComputedValue\n\n struct: Annotation & PropertyDecorator & ClassGetterDecorator\n}\n\nconst computedAnnotation = createComputedAnnotation(COMPUTED)\nconst computedStructAnnotation = createComputedAnnotation(COMPUTED_STRUCT, {\n equals: comparer.structural\n})\n\n/**\n * Decorator for class properties: @computed get value() { return expr; }.\n * For legacy purposes also invokable as ES5 observable created: `computed(() => expr)`;\n */\nexport const computed: IComputedFactory = function computed(arg1, arg2) {\n if (is20223Decorator(arg2)) {\n // @computed (2022.3 Decorators)\n return computedAnnotation.decorate_20223_(arg1, arg2)\n }\n if (isStringish(arg2)) {\n // @computed\n return storeAnnotation(arg1, arg2, computedAnnotation)\n }\n if (isPlainObject(arg1)) {\n // @computed({ options })\n return createDecoratorAnnotation(createComputedAnnotation(COMPUTED, arg1))\n }\n\n // computed(expr, options?)\n if (__DEV__) {\n if (!isFunction(arg1)) {\n die(\"First argument to `computed` should be an expression.\")\n }\n if (isFunction(arg2)) {\n die(\n \"A setter as second argument is no longer supported, use `{ set: fn }` option instead\"\n )\n }\n }\n const opts: IComputedValueOptions = isPlainObject(arg2) ? arg2 : {}\n opts.get = arg1\n opts.name ||= arg1.name || \"\" /* for generated name */\n\n return new ComputedValue(opts)\n} as any\n\nObject.assign(computed, computedAnnotation)\n\ncomputed.struct = createDecoratorAnnotation(computedStructAnnotation)\n", "import {\n IDerivation,\n endBatch,\n globalState,\n isSpyEnabled,\n spyReportEnd,\n spyReportStart,\n startBatch,\n untrackedEnd,\n untrackedStart,\n isFunction,\n allowStateReadsStart,\n allowStateReadsEnd,\n ACTION,\n EMPTY_ARRAY,\n die,\n getDescriptor,\n defineProperty\n} from \"../internal\"\n\n// we don't use globalState for these in order to avoid possible issues with multiple\n// mobx versions\nlet currentActionId = 0\nlet nextActionId = 1\nconst isFunctionNameConfigurable = getDescriptor(() => {}, \"name\")?.configurable ?? false\n\n// we can safely recycle this object\nconst tmpNameDescriptor: PropertyDescriptor = {\n value: \"action\",\n configurable: true,\n writable: false,\n enumerable: false\n}\n\nexport function createAction(\n actionName: string,\n fn: Function,\n autoAction: boolean = false,\n ref?: Object\n): Function {\n if (__DEV__) {\n if (!isFunction(fn)) {\n die(\"`action` can only be invoked on functions\")\n }\n if (typeof actionName !== \"string\" || !actionName) {\n die(`actions should have valid names, got: '${actionName}'`)\n }\n }\n function res() {\n return executeAction(actionName, autoAction, fn, ref || this, arguments)\n }\n res.isMobxAction = true\n res.toString = () => fn.toString()\n if (isFunctionNameConfigurable) {\n tmpNameDescriptor.value = actionName\n defineProperty(res, \"name\", tmpNameDescriptor)\n }\n return res\n}\n\nexport function executeAction(\n actionName: string,\n canRunAsDerivation: boolean,\n fn: Function,\n scope?: any,\n args?: IArguments\n) {\n const runInfo = _startAction(actionName, canRunAsDerivation, scope, args)\n try {\n return fn.apply(scope, args)\n } catch (err) {\n runInfo.error_ = err\n throw err\n } finally {\n _endAction(runInfo)\n }\n}\n\nexport interface IActionRunInfo {\n prevDerivation_: IDerivation | null\n prevAllowStateChanges_: boolean\n prevAllowStateReads_: boolean\n notifySpy_: boolean\n startTime_: number\n error_?: any\n parentActionId_: number\n actionId_: number\n runAsAction_?: boolean\n}\n\nexport function _startAction(\n actionName: string,\n canRunAsDerivation: boolean, // true for autoAction\n scope: any,\n args?: IArguments\n): IActionRunInfo {\n const notifySpy_ = __DEV__ && isSpyEnabled() && !!actionName\n let startTime_: number = 0\n if (__DEV__ && notifySpy_) {\n startTime_ = Date.now()\n const flattenedArgs = args ? Array.from(args) : EMPTY_ARRAY\n spyReportStart({\n type: ACTION,\n name: actionName,\n object: scope,\n arguments: flattenedArgs\n })\n }\n const prevDerivation_ = globalState.trackingDerivation\n const runAsAction = !canRunAsDerivation || !prevDerivation_\n startBatch()\n let prevAllowStateChanges_ = globalState.allowStateChanges // by default preserve previous allow\n if (runAsAction) {\n untrackedStart()\n prevAllowStateChanges_ = allowStateChangesStart(true)\n }\n const prevAllowStateReads_ = allowStateReadsStart(true)\n const runInfo = {\n runAsAction_: runAsAction,\n prevDerivation_,\n prevAllowStateChanges_,\n prevAllowStateReads_,\n notifySpy_,\n startTime_,\n actionId_: nextActionId++,\n parentActionId_: currentActionId\n }\n currentActionId = runInfo.actionId_\n return runInfo\n}\n\nexport function _endAction(runInfo: IActionRunInfo) {\n if (currentActionId !== runInfo.actionId_) {\n die(30)\n }\n currentActionId = runInfo.parentActionId_\n\n if (runInfo.error_ !== undefined) {\n globalState.suppressReactionErrors = true\n }\n allowStateChangesEnd(runInfo.prevAllowStateChanges_)\n allowStateReadsEnd(runInfo.prevAllowStateReads_)\n endBatch()\n if (runInfo.runAsAction_) {\n untrackedEnd(runInfo.prevDerivation_)\n }\n if (__DEV__ && runInfo.notifySpy_) {\n spyReportEnd({ time: Date.now() - runInfo.startTime_ })\n }\n globalState.suppressReactionErrors = false\n}\n\nexport function allowStateChanges(allowStateChanges: boolean, func: () => T): T {\n const prev = allowStateChangesStart(allowStateChanges)\n try {\n return func()\n } finally {\n allowStateChangesEnd(prev)\n }\n}\n\nexport function allowStateChangesStart(allowStateChanges: boolean) {\n const prev = globalState.allowStateChanges\n globalState.allowStateChanges = allowStateChanges\n return prev\n}\n\nexport function allowStateChangesEnd(prev: boolean) {\n globalState.allowStateChanges = prev\n}\n", "import {\n Atom,\n IEnhancer,\n IInterceptable,\n IEqualsComparer,\n IInterceptor,\n IListenable,\n Lambda,\n checkIfStateModificationsAreAllowed,\n comparer,\n createInstanceofPredicate,\n getNextId,\n hasInterceptors,\n hasListeners,\n interceptChange,\n isSpyEnabled,\n notifyListeners,\n registerInterceptor,\n registerListener,\n spyReport,\n spyReportEnd,\n spyReportStart,\n toPrimitive,\n globalState,\n IUNCHANGED,\n UPDATE\n} from \"../internal\"\n\nexport interface IValueWillChange {\n object: IObservableValue\n type: \"update\"\n newValue: T\n}\n\nexport type IValueDidChange = {\n type: \"update\"\n observableKind: \"value\"\n object: IObservableValue\n debugObjectName: string\n newValue: T\n oldValue: T | undefined\n}\nexport type IBoxDidChange =\n | {\n type: \"create\"\n observableKind: \"value\"\n object: IObservableValue\n debugObjectName: string\n newValue: T\n }\n | IValueDidChange\n\nexport interface IObservableValue {\n get(): T\n set(value: T): void\n}\n\nconst CREATE = \"create\"\n\nexport class ObservableValue\n extends Atom\n implements IObservableValue, IInterceptable>, IListenable\n{\n hasUnreportedChange_ = false\n interceptors_\n changeListeners_\n value_\n dehancer: any\n\n constructor(\n value: T,\n public enhancer: IEnhancer,\n public name_ = __DEV__ ? \"ObservableValue@\" + getNextId() : \"ObservableValue\",\n notifySpy = true,\n private equals: IEqualsComparer = comparer.default\n ) {\n super(name_)\n this.value_ = enhancer(value, undefined, name_)\n if (__DEV__ && notifySpy && isSpyEnabled()) {\n // only notify spy if this is a stand-alone observable\n spyReport({\n type: CREATE,\n object: this,\n observableKind: \"value\",\n debugObjectName: this.name_,\n newValue: \"\" + this.value_\n })\n }\n }\n\n private dehanceValue(value: T): T {\n if (this.dehancer !== undefined) {\n return this.dehancer(value)\n }\n return value\n }\n\n public set(newValue: T) {\n const oldValue = this.value_\n newValue = this.prepareNewValue_(newValue) as any\n if (newValue !== globalState.UNCHANGED) {\n const notifySpy = isSpyEnabled()\n if (__DEV__ && notifySpy) {\n spyReportStart({\n type: UPDATE,\n object: this,\n observableKind: \"value\",\n debugObjectName: this.name_,\n newValue,\n oldValue\n })\n }\n this.setNewValue_(newValue)\n if (__DEV__ && notifySpy) {\n spyReportEnd()\n }\n }\n }\n\n private prepareNewValue_(newValue): T | IUNCHANGED {\n checkIfStateModificationsAreAllowed(this)\n if (hasInterceptors(this)) {\n const change = interceptChange>(this, {\n object: this,\n type: UPDATE,\n newValue\n })\n if (!change) {\n return globalState.UNCHANGED\n }\n newValue = change.newValue\n }\n // apply modifier\n newValue = this.enhancer(newValue, this.value_, this.name_)\n return this.equals(this.value_, newValue) ? globalState.UNCHANGED : newValue\n }\n\n setNewValue_(newValue: T) {\n const oldValue = this.value_\n this.value_ = newValue\n this.reportChanged()\n if (hasListeners(this)) {\n notifyListeners(this, {\n type: UPDATE,\n object: this,\n newValue,\n oldValue\n })\n }\n }\n\n public get(): T {\n this.reportObserved()\n return this.dehanceValue(this.value_)\n }\n\n intercept_(handler: IInterceptor>): Lambda {\n return registerInterceptor(this, handler)\n }\n\n observe_(listener: (change: IValueDidChange) => void, fireImmediately?: boolean): Lambda {\n if (fireImmediately) {\n listener({\n observableKind: \"value\",\n debugObjectName: this.name_,\n object: this,\n type: UPDATE,\n newValue: this.value_,\n oldValue: undefined\n })\n }\n return registerListener(this, listener)\n }\n\n raw() {\n // used by MST ot get undehanced value\n return this.value_\n }\n\n toJSON() {\n return this.get()\n }\n\n toString() {\n return `${this.name_}[${this.value_}]`\n }\n\n valueOf(): T {\n return toPrimitive(this.get())\n }\n\n [Symbol.toPrimitive]() {\n return this.valueOf()\n }\n}\n\nexport const isObservableValue = createInstanceofPredicate(\"ObservableValue\", ObservableValue) as (\n x: any\n) => x is IObservableValue\n", "import {\n CaughtException,\n IDerivation,\n IDerivationState_,\n IEqualsComparer,\n IObservable,\n Lambda,\n TraceMode,\n autorun,\n clearObserving,\n comparer,\n createAction,\n createInstanceofPredicate,\n endBatch,\n getNextId,\n globalState,\n isCaughtException,\n isSpyEnabled,\n propagateChangeConfirmed,\n propagateMaybeChanged,\n reportObserved,\n shouldCompute,\n spyReport,\n startBatch,\n toPrimitive,\n trackDerivedFunction,\n untrackedEnd,\n untrackedStart,\n UPDATE,\n die,\n allowStateChangesStart,\n allowStateChangesEnd\n} from \"../internal\"\n\nexport interface IComputedValue {\n get(): T\n set(value: T): void\n}\n\nexport interface IComputedValueOptions {\n get?: () => T\n set?: (value: T) => void\n name?: string\n equals?: IEqualsComparer\n context?: any\n requiresReaction?: boolean\n keepAlive?: boolean\n}\n\nexport type IComputedDidChange = {\n type: \"update\"\n observableKind: \"computed\"\n object: unknown\n debugObjectName: string\n newValue: T\n oldValue: T | undefined\n}\n\n/**\n * A node in the state dependency root that observes other nodes, and can be observed itself.\n *\n * ComputedValue will remember the result of the computation for the duration of the batch, or\n * while being observed.\n *\n * During this time it will recompute only when one of its direct dependencies changed,\n * but only when it is being accessed with `ComputedValue.get()`.\n *\n * Implementation description:\n * 1. First time it's being accessed it will compute and remember result\n * give back remembered result until 2. happens\n * 2. First time any deep dependency change, propagate POSSIBLY_STALE to all observers, wait for 3.\n * 3. When it's being accessed, recompute if any shallow dependency changed.\n * if result changed: propagate STALE to all observers, that were POSSIBLY_STALE from the last step.\n * go to step 2. either way\n *\n * If at any point it's outside batch and it isn't observed: reset everything and go to 1.\n */\nexport class ComputedValue implements IObservable, IComputedValue, IDerivation {\n dependenciesState_ = IDerivationState_.NOT_TRACKING_\n observing_: IObservable[] = [] // nodes we are looking at. Our value depends on these nodes\n newObserving_ = null // during tracking it's an array with new observed observers\n isBeingObserved_ = false\n isPendingUnobservation_: boolean = false\n observers_ = new Set()\n diffValue_ = 0\n runId_ = 0\n lastAccessedBy_ = 0\n lowestObserverState_ = IDerivationState_.UP_TO_DATE_\n unboundDepsCount_ = 0\n protected value_: T | undefined | CaughtException = new CaughtException(null)\n name_: string\n triggeredBy_?: string\n isComputing_: boolean = false // to check for cycles\n isRunningSetter_: boolean = false\n derivation: () => T // N.B: unminified as it is used by MST\n setter_?: (value: T) => void\n isTracing_: TraceMode = TraceMode.NONE\n scope_: Object | undefined\n private equals_: IEqualsComparer\n private requiresReaction_: boolean | undefined\n keepAlive_: boolean\n\n /**\n * Create a new computed value based on a function expression.\n *\n * The `name` property is for debug purposes only.\n *\n * The `equals` property specifies the comparer function to use to determine if a newly produced\n * value differs from the previous value. Two comparers are provided in the library; `defaultComparer`\n * compares based on identity comparison (===), and `structuralComparer` deeply compares the structure.\n * Structural comparison can be convenient if you always produce a new aggregated object and\n * don't want to notify observers if it is structurally the same.\n * This is useful for working with vectors, mouse coordinates etc.\n */\n constructor(options: IComputedValueOptions) {\n if (!options.get) {\n die(31)\n }\n this.derivation = options.get!\n this.name_ = options.name || (__DEV__ ? \"ComputedValue@\" + getNextId() : \"ComputedValue\")\n if (options.set) {\n this.setter_ = createAction(\n __DEV__ ? this.name_ + \"-setter\" : \"ComputedValue-setter\",\n options.set\n ) as any\n }\n this.equals_ =\n options.equals ||\n ((options as any).compareStructural || (options as any).struct\n ? comparer.structural\n : comparer.default)\n this.scope_ = options.context\n this.requiresReaction_ = options.requiresReaction\n this.keepAlive_ = !!options.keepAlive\n }\n\n onBecomeStale_() {\n propagateMaybeChanged(this)\n }\n\n public onBOL: Set | undefined\n public onBUOL: Set | undefined\n\n public onBO() {\n if (this.onBOL) {\n this.onBOL.forEach(listener => listener())\n }\n }\n\n public onBUO() {\n if (this.onBUOL) {\n this.onBUOL.forEach(listener => listener())\n }\n }\n\n /**\n * Returns the current value of this computed value.\n * Will evaluate its computation first if needed.\n */\n public get(): T {\n if (this.isComputing_) {\n die(32, this.name_, this.derivation)\n }\n if (\n globalState.inBatch === 0 &&\n // !globalState.trackingDerivatpion &&\n this.observers_.size === 0 &&\n !this.keepAlive_\n ) {\n if (shouldCompute(this)) {\n this.warnAboutUntrackedRead_()\n startBatch() // See perf test 'computed memoization'\n this.value_ = this.computeValue_(false)\n endBatch()\n }\n } else {\n reportObserved(this)\n if (shouldCompute(this)) {\n let prevTrackingContext = globalState.trackingContext\n if (this.keepAlive_ && !prevTrackingContext) {\n globalState.trackingContext = this\n }\n if (this.trackAndCompute()) {\n propagateChangeConfirmed(this)\n }\n globalState.trackingContext = prevTrackingContext\n }\n }\n const result = this.value_!\n\n if (isCaughtException(result)) {\n throw result.cause\n }\n return result\n }\n\n public set(value: T) {\n if (this.setter_) {\n if (this.isRunningSetter_) {\n die(33, this.name_)\n }\n this.isRunningSetter_ = true\n try {\n this.setter_.call(this.scope_, value)\n } finally {\n this.isRunningSetter_ = false\n }\n } else {\n die(34, this.name_)\n }\n }\n\n trackAndCompute(): boolean {\n // N.B: unminified as it is used by MST\n const oldValue = this.value_\n const wasSuspended =\n /* see #1208 */ this.dependenciesState_ === IDerivationState_.NOT_TRACKING_\n const newValue = this.computeValue_(true)\n\n const changed =\n wasSuspended ||\n isCaughtException(oldValue) ||\n isCaughtException(newValue) ||\n !this.equals_(oldValue, newValue)\n\n if (changed) {\n this.value_ = newValue\n\n if (__DEV__ && isSpyEnabled()) {\n spyReport({\n observableKind: \"computed\",\n debugObjectName: this.name_,\n object: this.scope_,\n type: \"update\",\n oldValue,\n newValue\n } as IComputedDidChange)\n }\n }\n\n return changed\n }\n\n computeValue_(track: boolean) {\n this.isComputing_ = true\n // don't allow state changes during computation\n const prev = allowStateChangesStart(false)\n let res: T | CaughtException\n if (track) {\n res = trackDerivedFunction(this, this.derivation, this.scope_)\n } else {\n if (globalState.disableErrorBoundaries === true) {\n res = this.derivation.call(this.scope_)\n } else {\n try {\n res = this.derivation.call(this.scope_)\n } catch (e) {\n res = new CaughtException(e)\n }\n }\n }\n allowStateChangesEnd(prev)\n this.isComputing_ = false\n return res\n }\n\n suspend_() {\n if (!this.keepAlive_) {\n clearObserving(this)\n this.value_ = undefined // don't hold on to computed value!\n if (__DEV__ && this.isTracing_ !== TraceMode.NONE) {\n console.log(\n `[mobx.trace] Computed value '${this.name_}' was suspended and it will recompute on the next access.`\n )\n }\n }\n }\n\n observe_(listener: (change: IComputedDidChange) => void, fireImmediately?: boolean): Lambda {\n let firstTime = true\n let prevValue: T | undefined = undefined\n return autorun(() => {\n // TODO: why is this in a different place than the spyReport() function? in all other observables it's called in the same place\n let newValue = this.get()\n if (!firstTime || fireImmediately) {\n const prevU = untrackedStart()\n listener({\n observableKind: \"computed\",\n debugObjectName: this.name_,\n type: UPDATE,\n object: this,\n newValue,\n oldValue: prevValue\n })\n untrackedEnd(prevU)\n }\n firstTime = false\n prevValue = newValue\n })\n }\n\n warnAboutUntrackedRead_() {\n if (!__DEV__) {\n return\n }\n if (this.isTracing_ !== TraceMode.NONE) {\n console.log(\n `[mobx.trace] Computed value '${this.name_}' is being read outside a reactive context. Doing a full recompute.`\n )\n }\n if (\n typeof this.requiresReaction_ === \"boolean\"\n ? this.requiresReaction_\n : globalState.computedRequiresReaction\n ) {\n console.warn(\n `[mobx] Computed value '${this.name_}' is being read outside a reactive context. Doing a full recompute.`\n )\n }\n }\n\n toString() {\n return `${this.name_}[${this.derivation.toString()}]`\n }\n\n valueOf(): T {\n return toPrimitive(this.get())\n }\n\n [Symbol.toPrimitive]() {\n return this.valueOf()\n }\n}\n\nexport const isComputedValue = createInstanceofPredicate(\"ComputedValue\", ComputedValue)\n", "import {\n IAtom,\n IDepTreeNode,\n IObservable,\n addObserver,\n globalState,\n isComputedValue,\n removeObserver\n} from \"../internal\"\n\nexport enum IDerivationState_ {\n // before being run or (outside batch and not being observed)\n // at this point derivation is not holding any data about dependency tree\n NOT_TRACKING_ = -1,\n // no shallow dependency changed since last computation\n // won't recalculate derivation\n // this is what makes mobx fast\n UP_TO_DATE_ = 0,\n // some deep dependency changed, but don't know if shallow dependency changed\n // will require to check first if UP_TO_DATE or POSSIBLY_STALE\n // currently only ComputedValue will propagate POSSIBLY_STALE\n //\n // having this state is second big optimization:\n // don't have to recompute on every dependency change, but only when it's needed\n POSSIBLY_STALE_ = 1,\n // A shallow dependency has changed since last computation and the derivation\n // will need to recompute when it's needed next.\n STALE_ = 2\n}\n\nexport enum TraceMode {\n NONE,\n LOG,\n BREAK\n}\n\n/**\n * A derivation is everything that can be derived from the state (all the atoms) in a pure manner.\n * See https://medium.com/@mweststrate/becoming-fully-reactive-an-in-depth-explanation-of-mobservable-55995262a254#.xvbh6qd74\n */\nexport interface IDerivation extends IDepTreeNode {\n observing_: IObservable[]\n newObserving_: null | IObservable[]\n dependenciesState_: IDerivationState_\n /**\n * Id of the current run of a derivation. Each time the derivation is tracked\n * this number is increased by one. This number is globally unique\n */\n runId_: number\n /**\n * amount of dependencies used by the derivation in this run, which has not been bound yet.\n */\n unboundDepsCount_: number\n onBecomeStale_(): void\n isTracing_: TraceMode\n\n /**\n * warn if the derivation has no dependencies after creation/update\n */\n requiresObservable_?: boolean\n}\n\nexport class CaughtException {\n constructor(public cause: any) {\n // Empty\n }\n}\n\nexport function isCaughtException(e: any): e is CaughtException {\n return e instanceof CaughtException\n}\n\n/**\n * Finds out whether any dependency of the derivation has actually changed.\n * If dependenciesState is 1 then it will recalculate dependencies,\n * if any dependency changed it will propagate it by changing dependenciesState to 2.\n *\n * By iterating over the dependencies in the same order that they were reported and\n * stopping on the first change, all the recalculations are only called for ComputedValues\n * that will be tracked by derivation. That is because we assume that if the first x\n * dependencies of the derivation doesn't change then the derivation should run the same way\n * up until accessing x-th dependency.\n */\nexport function shouldCompute(derivation: IDerivation): boolean {\n switch (derivation.dependenciesState_) {\n case IDerivationState_.UP_TO_DATE_:\n return false\n case IDerivationState_.NOT_TRACKING_:\n case IDerivationState_.STALE_:\n return true\n case IDerivationState_.POSSIBLY_STALE_: {\n // state propagation can occur outside of action/reactive context #2195\n const prevAllowStateReads = allowStateReadsStart(true)\n const prevUntracked = untrackedStart() // no need for those computeds to be reported, they will be picked up in trackDerivedFunction.\n const obs = derivation.observing_,\n l = obs.length\n for (let i = 0; i < l; i++) {\n const obj = obs[i]\n if (isComputedValue(obj)) {\n if (globalState.disableErrorBoundaries) {\n obj.get()\n } else {\n try {\n obj.get()\n } catch (e) {\n // we are not interested in the value *or* exception at this moment, but if there is one, notify all\n untrackedEnd(prevUntracked)\n allowStateReadsEnd(prevAllowStateReads)\n return true\n }\n }\n // if ComputedValue `obj` actually changed it will be computed and propagated to its observers.\n // and `derivation` is an observer of `obj`\n // invariantShouldCompute(derivation)\n if ((derivation.dependenciesState_ as any) === IDerivationState_.STALE_) {\n untrackedEnd(prevUntracked)\n allowStateReadsEnd(prevAllowStateReads)\n return true\n }\n }\n }\n changeDependenciesStateTo0(derivation)\n untrackedEnd(prevUntracked)\n allowStateReadsEnd(prevAllowStateReads)\n return false\n }\n }\n}\n\nexport function isComputingDerivation() {\n return globalState.trackingDerivation !== null // filter out actions inside computations\n}\n\nexport function checkIfStateModificationsAreAllowed(atom: IAtom) {\n if (!__DEV__) {\n return\n }\n const hasObservers = atom.observers_.size > 0\n // Should not be possible to change observed state outside strict mode, except during initialization, see #563\n if (\n !globalState.allowStateChanges &&\n (hasObservers || globalState.enforceActions === \"always\")\n ) {\n console.warn(\n \"[MobX] \" +\n (globalState.enforceActions\n ? \"Since strict-mode is enabled, changing (observed) observable values without using an action is not allowed. Tried to modify: \"\n : \"Side effects like changing state are not allowed at this point. Are you trying to modify state from, for example, a computed value or the render function of a React component? You can wrap side effects in 'runInAction' (or decorate functions with 'action') if needed. Tried to modify: \") +\n atom.name_\n )\n }\n}\n\nexport function checkIfStateReadsAreAllowed(observable: IObservable) {\n if (__DEV__ && !globalState.allowStateReads && globalState.observableRequiresReaction) {\n console.warn(\n `[mobx] Observable '${observable.name_}' being read outside a reactive context.`\n )\n }\n}\n\n/**\n * Executes the provided function `f` and tracks which observables are being accessed.\n * The tracking information is stored on the `derivation` object and the derivation is registered\n * as observer of any of the accessed observables.\n */\nexport function trackDerivedFunction(derivation: IDerivation, f: () => T, context: any) {\n const prevAllowStateReads = allowStateReadsStart(true)\n changeDependenciesStateTo0(derivation)\n // Preallocate array; will be trimmed by bindDependencies.\n derivation.newObserving_ = new Array(\n // Reserve constant space for initial dependencies, dynamic space otherwise.\n // See https://github.com/mobxjs/mobx/pull/3833\n derivation.runId_ === 0 ? 100 : derivation.observing_.length\n )\n derivation.unboundDepsCount_ = 0\n derivation.runId_ = ++globalState.runId\n const prevTracking = globalState.trackingDerivation\n globalState.trackingDerivation = derivation\n globalState.inBatch++\n let result\n if (globalState.disableErrorBoundaries === true) {\n result = f.call(context)\n } else {\n try {\n result = f.call(context)\n } catch (e) {\n result = new CaughtException(e)\n }\n }\n globalState.inBatch--\n globalState.trackingDerivation = prevTracking\n bindDependencies(derivation)\n\n warnAboutDerivationWithoutDependencies(derivation)\n allowStateReadsEnd(prevAllowStateReads)\n return result\n}\n\nfunction warnAboutDerivationWithoutDependencies(derivation: IDerivation) {\n if (!__DEV__) {\n return\n }\n\n if (derivation.observing_.length !== 0) {\n return\n }\n\n if (\n typeof derivation.requiresObservable_ === \"boolean\"\n ? derivation.requiresObservable_\n : globalState.reactionRequiresObservable\n ) {\n console.warn(\n `[mobx] Derivation '${derivation.name_}' is created/updated without reading any observable value.`\n )\n }\n}\n\n/**\n * diffs newObserving with observing.\n * update observing to be newObserving with unique observables\n * notify observers that become observed/unobserved\n */\nfunction bindDependencies(derivation: IDerivation) {\n // invariant(derivation.dependenciesState !== IDerivationState.NOT_TRACKING, \"INTERNAL ERROR bindDependencies expects derivation.dependenciesState !== -1\");\n const prevObserving = derivation.observing_\n const observing = (derivation.observing_ = derivation.newObserving_!)\n let lowestNewObservingDerivationState = IDerivationState_.UP_TO_DATE_\n\n // Go through all new observables and check diffValue: (this list can contain duplicates):\n // 0: first occurrence, change to 1 and keep it\n // 1: extra occurrence, drop it\n let i0 = 0,\n l = derivation.unboundDepsCount_\n for (let i = 0; i < l; i++) {\n const dep = observing[i]\n if (dep.diffValue_ === 0) {\n dep.diffValue_ = 1\n if (i0 !== i) {\n observing[i0] = dep\n }\n i0++\n }\n\n // Upcast is 'safe' here, because if dep is IObservable, `dependenciesState` will be undefined,\n // not hitting the condition\n if ((dep as any as IDerivation).dependenciesState_ > lowestNewObservingDerivationState) {\n lowestNewObservingDerivationState = (dep as any as IDerivation).dependenciesState_\n }\n }\n observing.length = i0\n\n derivation.newObserving_ = null // newObserving shouldn't be needed outside tracking (statement moved down to work around FF bug, see #614)\n\n // Go through all old observables and check diffValue: (it is unique after last bindDependencies)\n // 0: it's not in new observables, unobserve it\n // 1: it keeps being observed, don't want to notify it. change to 0\n l = prevObserving.length\n while (l--) {\n const dep = prevObserving[l]\n if (dep.diffValue_ === 0) {\n removeObserver(dep, derivation)\n }\n dep.diffValue_ = 0\n }\n\n // Go through all new observables and check diffValue: (now it should be unique)\n // 0: it was set to 0 in last loop. don't need to do anything.\n // 1: it wasn't observed, let's observe it. set back to 0\n while (i0--) {\n const dep = observing[i0]\n if (dep.diffValue_ === 1) {\n dep.diffValue_ = 0\n addObserver(dep, derivation)\n }\n }\n\n // Some new observed derivations may become stale during this derivation computation\n // so they have had no chance to propagate staleness (#916)\n if (lowestNewObservingDerivationState !== IDerivationState_.UP_TO_DATE_) {\n derivation.dependenciesState_ = lowestNewObservingDerivationState\n derivation.onBecomeStale_()\n }\n}\n\nexport function clearObserving(derivation: IDerivation) {\n // invariant(globalState.inBatch > 0, \"INTERNAL ERROR clearObserving should be called only inside batch\");\n const obs = derivation.observing_\n derivation.observing_ = []\n let i = obs.length\n while (i--) {\n removeObserver(obs[i], derivation)\n }\n\n derivation.dependenciesState_ = IDerivationState_.NOT_TRACKING_\n}\n\nexport function untracked(action: () => T): T {\n const prev = untrackedStart()\n try {\n return action()\n } finally {\n untrackedEnd(prev)\n }\n}\n\nexport function untrackedStart(): IDerivation | null {\n const prev = globalState.trackingDerivation\n globalState.trackingDerivation = null\n return prev\n}\n\nexport function untrackedEnd(prev: IDerivation | null) {\n globalState.trackingDerivation = prev\n}\n\nexport function allowStateReadsStart(allowStateReads: boolean) {\n const prev = globalState.allowStateReads\n globalState.allowStateReads = allowStateReads\n return prev\n}\n\nexport function allowStateReadsEnd(prev: boolean) {\n globalState.allowStateReads = prev\n}\n\n/**\n * needed to keep `lowestObserverState` correct. when changing from (2 or 1) to 0\n *\n */\nexport function changeDependenciesStateTo0(derivation: IDerivation) {\n if (derivation.dependenciesState_ === IDerivationState_.UP_TO_DATE_) {\n return\n }\n derivation.dependenciesState_ = IDerivationState_.UP_TO_DATE_\n\n const obs = derivation.observing_\n let i = obs.length\n while (i--) {\n obs[i].lowestObserverState_ = IDerivationState_.UP_TO_DATE_\n }\n}\n", "import { IDerivation, IObservable, Reaction, die, getGlobal } from \"../internal\"\nimport { ComputedValue } from \"./computedvalue\"\n\n/**\n * These values will persist if global state is reset\n */\nconst persistentKeys: (keyof MobXGlobals)[] = [\n \"mobxGuid\",\n \"spyListeners\",\n \"enforceActions\",\n \"computedRequiresReaction\",\n \"reactionRequiresObservable\",\n \"observableRequiresReaction\",\n \"allowStateReads\",\n \"disableErrorBoundaries\",\n \"runId\",\n \"UNCHANGED\",\n \"useProxies\"\n]\n\nexport type IUNCHANGED = {}\n\nexport class MobXGlobals {\n /**\n * MobXGlobals version.\n * MobX compatiblity with other versions loaded in memory as long as this version matches.\n * It indicates that the global state still stores similar information\n *\n * N.B: this version is unrelated to the package version of MobX, and is only the version of the\n * internal state storage of MobX, and can be the same across many different package versions\n */\n version = 6\n\n /**\n * globally unique token to signal unchanged\n */\n UNCHANGED: IUNCHANGED = {}\n\n /**\n * Currently running derivation\n */\n trackingDerivation: IDerivation | null = null\n\n /**\n * Currently running reaction. This determines if we currently have a reactive context.\n * (Tracking derivation is also set for temporal tracking of computed values inside actions,\n * but trackingReaction can only be set by a form of Reaction)\n */\n trackingContext: Reaction | ComputedValue | null = null\n\n /**\n * Each time a derivation is tracked, it is assigned a unique run-id\n */\n runId = 0\n\n /**\n * 'guid' for general purpose. Will be persisted amongst resets.\n */\n mobxGuid = 0\n\n /**\n * Are we in a batch block? (and how many of them)\n */\n inBatch: number = 0\n\n /**\n * Observables that don't have observers anymore, and are about to be\n * suspended, unless somebody else accesses it in the same batch\n *\n * @type {IObservable[]}\n */\n pendingUnobservations: IObservable[] = []\n\n /**\n * List of scheduled, not yet executed, reactions.\n */\n pendingReactions: Reaction[] = []\n\n /**\n * Are we currently processing reactions?\n */\n isRunningReactions = false\n\n /**\n * Is it allowed to change observables at this point?\n * In general, MobX doesn't allow that when running computations and React.render.\n * To ensure that those functions stay pure.\n */\n allowStateChanges = false\n\n /**\n * Is it allowed to read observables at this point?\n * Used to hold the state needed for `observableRequiresReaction`\n */\n allowStateReads = true\n\n /**\n * If strict mode is enabled, state changes are by default not allowed\n */\n enforceActions: boolean | \"always\" = true\n\n /**\n * Spy callbacks\n */\n spyListeners: { (change: any): void }[] = []\n\n /**\n * Globally attached error handlers that react specifically to errors in reactions\n */\n globalReactionErrorHandlers: ((error: any, derivation: IDerivation) => void)[] = []\n\n /**\n * Warn if computed values are accessed outside a reactive context\n */\n computedRequiresReaction = false\n\n /**\n * (Experimental)\n * Warn if you try to create to derivation / reactive context without accessing any observable.\n */\n reactionRequiresObservable = false\n\n /**\n * (Experimental)\n * Warn if observables are accessed outside a reactive context\n */\n observableRequiresReaction = false\n\n /*\n * Don't catch and rethrow exceptions. This is useful for inspecting the state of\n * the stack when an exception occurs while debugging.\n */\n disableErrorBoundaries = false\n\n /*\n * If true, we are already handling an exception in an action. Any errors in reactions should be suppressed, as\n * they are not the cause, see: https://github.com/mobxjs/mobx/issues/1836\n */\n suppressReactionErrors = false\n\n useProxies = true\n /*\n * print warnings about code that would fail if proxies weren't available\n */\n verifyProxies = false\n\n /**\n * False forces all object's descriptors to\n * writable: true\n * configurable: true\n */\n safeDescriptors = true\n}\n\nlet canMergeGlobalState = true\nlet isolateCalled = false\n\nexport let globalState: MobXGlobals = (function () {\n let global = getGlobal()\n if (global.__mobxInstanceCount > 0 && !global.__mobxGlobals) {\n canMergeGlobalState = false\n }\n if (global.__mobxGlobals && global.__mobxGlobals.version !== new MobXGlobals().version) {\n canMergeGlobalState = false\n }\n\n if (!canMergeGlobalState) {\n // Because this is a IIFE we need to let isolateCalled a chance to change\n // so we run it after the event loop completed at least 1 iteration\n setTimeout(() => {\n if (!isolateCalled) {\n die(35)\n }\n }, 1)\n return new MobXGlobals()\n } else if (global.__mobxGlobals) {\n global.__mobxInstanceCount += 1\n if (!global.__mobxGlobals.UNCHANGED) {\n global.__mobxGlobals.UNCHANGED = {}\n } // make merge backward compatible\n return global.__mobxGlobals\n } else {\n global.__mobxInstanceCount = 1\n return (global.__mobxGlobals = new MobXGlobals())\n }\n})()\n\nexport function isolateGlobalState() {\n if (\n globalState.pendingReactions.length ||\n globalState.inBatch ||\n globalState.isRunningReactions\n ) {\n die(36)\n }\n isolateCalled = true\n if (canMergeGlobalState) {\n let global = getGlobal()\n if (--global.__mobxInstanceCount === 0) {\n global.__mobxGlobals = undefined\n }\n globalState = new MobXGlobals()\n }\n}\n\nexport function getGlobalState(): any {\n return globalState\n}\n\n/**\n * For testing purposes only; this will break the internal state of existing observables,\n * but can be used to get back at a stable state after throwing errors\n */\nexport function resetGlobalState() {\n const defaultGlobals = new MobXGlobals()\n for (let key in defaultGlobals) {\n if (persistentKeys.indexOf(key as any) === -1) {\n globalState[key] = defaultGlobals[key]\n }\n }\n globalState.allowStateChanges = !globalState.enforceActions\n}\n", "import {\n Lambda,\n ComputedValue,\n IDependencyTree,\n IDerivation,\n IDerivationState_,\n TraceMode,\n getDependencyTree,\n globalState,\n runReactions,\n checkIfStateReadsAreAllowed\n} from \"../internal\"\n\nexport interface IDepTreeNode {\n name_: string\n observing_?: IObservable[]\n}\n\nexport interface IObservable extends IDepTreeNode {\n diffValue_: number\n /**\n * Id of the derivation *run* that last accessed this observable.\n * If this id equals the *run* id of the current derivation,\n * the dependency is already established\n */\n lastAccessedBy_: number\n isBeingObserved_: boolean\n\n lowestObserverState_: IDerivationState_ // Used to avoid redundant propagations\n isPendingUnobservation_: boolean // Used to push itself to global.pendingUnobservations at most once per batch.\n\n observers_: Set\n\n onBUO(): void\n onBO(): void\n\n onBUOL: Set | undefined\n onBOL: Set | undefined\n}\n\nexport function hasObservers(observable: IObservable): boolean {\n return observable.observers_ && observable.observers_.size > 0\n}\n\nexport function getObservers(observable: IObservable): Set {\n return observable.observers_\n}\n\n// function invariantObservers(observable: IObservable) {\n// const list = observable.observers\n// const map = observable.observersIndexes\n// const l = list.length\n// for (let i = 0; i < l; i++) {\n// const id = list[i].__mapid\n// if (i) {\n// invariant(map[id] === i, \"INTERNAL ERROR maps derivation.__mapid to index in list\") // for performance\n// } else {\n// invariant(!(id in map), \"INTERNAL ERROR observer on index 0 shouldn't be held in map.\") // for performance\n// }\n// }\n// invariant(\n// list.length === 0 || Object.keys(map).length === list.length - 1,\n// \"INTERNAL ERROR there is no junk in map\"\n// )\n// }\nexport function addObserver(observable: IObservable, node: IDerivation) {\n // invariant(node.dependenciesState !== -1, \"INTERNAL ERROR, can add only dependenciesState !== -1\");\n // invariant(observable._observers.indexOf(node) === -1, \"INTERNAL ERROR add already added node\");\n // invariantObservers(observable);\n\n observable.observers_.add(node)\n if (observable.lowestObserverState_ > node.dependenciesState_) {\n observable.lowestObserverState_ = node.dependenciesState_\n }\n\n // invariantObservers(observable);\n // invariant(observable._observers.indexOf(node) !== -1, \"INTERNAL ERROR didn't add node\");\n}\n\nexport function removeObserver(observable: IObservable, node: IDerivation) {\n // invariant(globalState.inBatch > 0, \"INTERNAL ERROR, remove should be called only inside batch\");\n // invariant(observable._observers.indexOf(node) !== -1, \"INTERNAL ERROR remove already removed node\");\n // invariantObservers(observable);\n observable.observers_.delete(node)\n if (observable.observers_.size === 0) {\n // deleting last observer\n queueForUnobservation(observable)\n }\n // invariantObservers(observable);\n // invariant(observable._observers.indexOf(node) === -1, \"INTERNAL ERROR remove already removed node2\");\n}\n\nexport function queueForUnobservation(observable: IObservable) {\n if (observable.isPendingUnobservation_ === false) {\n // invariant(observable._observers.length === 0, \"INTERNAL ERROR, should only queue for unobservation unobserved observables\");\n observable.isPendingUnobservation_ = true\n globalState.pendingUnobservations.push(observable)\n }\n}\n\n/**\n * Batch starts a transaction, at least for purposes of memoizing ComputedValues when nothing else does.\n * During a batch `onBecomeUnobserved` will be called at most once per observable.\n * Avoids unnecessary recalculations.\n */\nexport function startBatch() {\n globalState.inBatch++\n}\n\nexport function endBatch() {\n if (--globalState.inBatch === 0) {\n runReactions()\n // the batch is actually about to finish, all unobserving should happen here.\n const list = globalState.pendingUnobservations\n for (let i = 0; i < list.length; i++) {\n const observable = list[i]\n observable.isPendingUnobservation_ = false\n if (observable.observers_.size === 0) {\n if (observable.isBeingObserved_) {\n // if this observable had reactive observers, trigger the hooks\n observable.isBeingObserved_ = false\n observable.onBUO()\n }\n if (observable instanceof ComputedValue) {\n // computed values are automatically teared down when the last observer leaves\n // this process happens recursively, this computed might be the last observabe of another, etc..\n observable.suspend_()\n }\n }\n }\n globalState.pendingUnobservations = []\n }\n}\n\nexport function reportObserved(observable: IObservable): boolean {\n checkIfStateReadsAreAllowed(observable)\n\n const derivation = globalState.trackingDerivation\n if (derivation !== null) {\n /**\n * Simple optimization, give each derivation run an unique id (runId)\n * Check if last time this observable was accessed the same runId is used\n * if this is the case, the relation is already known\n */\n if (derivation.runId_ !== observable.lastAccessedBy_) {\n observable.lastAccessedBy_ = derivation.runId_\n // Tried storing newObserving, or observing, or both as Set, but performance didn't come close...\n derivation.newObserving_![derivation.unboundDepsCount_++] = observable\n if (!observable.isBeingObserved_ && globalState.trackingContext) {\n observable.isBeingObserved_ = true\n observable.onBO()\n }\n }\n return observable.isBeingObserved_\n } else if (observable.observers_.size === 0 && globalState.inBatch > 0) {\n queueForUnobservation(observable)\n }\n\n return false\n}\n\n// function invariantLOS(observable: IObservable, msg: string) {\n// // it's expensive so better not run it in produciton. but temporarily helpful for testing\n// const min = getObservers(observable).reduce((a, b) => Math.min(a, b.dependenciesState), 2)\n// if (min >= observable.lowestObserverState) return // <- the only assumption about `lowestObserverState`\n// throw new Error(\n// \"lowestObserverState is wrong for \" +\n// msg +\n// \" because \" +\n// min +\n// \" < \" +\n// observable.lowestObserverState\n// )\n// }\n\n/**\n * NOTE: current propagation mechanism will in case of self reruning autoruns behave unexpectedly\n * It will propagate changes to observers from previous run\n * It's hard or maybe impossible (with reasonable perf) to get it right with current approach\n * Hopefully self reruning autoruns aren't a feature people should depend on\n * Also most basic use cases should be ok\n */\n\n// Called by Atom when its value changes\nexport function propagateChanged(observable: IObservable) {\n // invariantLOS(observable, \"changed start\");\n if (observable.lowestObserverState_ === IDerivationState_.STALE_) {\n return\n }\n observable.lowestObserverState_ = IDerivationState_.STALE_\n\n // Ideally we use for..of here, but the downcompiled version is really slow...\n observable.observers_.forEach(d => {\n if (d.dependenciesState_ === IDerivationState_.UP_TO_DATE_) {\n if (__DEV__ && d.isTracing_ !== TraceMode.NONE) {\n logTraceInfo(d, observable)\n }\n d.onBecomeStale_()\n }\n d.dependenciesState_ = IDerivationState_.STALE_\n })\n // invariantLOS(observable, \"changed end\");\n}\n\n// Called by ComputedValue when it recalculate and its value changed\nexport function propagateChangeConfirmed(observable: IObservable) {\n // invariantLOS(observable, \"confirmed start\");\n if (observable.lowestObserverState_ === IDerivationState_.STALE_) {\n return\n }\n observable.lowestObserverState_ = IDerivationState_.STALE_\n\n observable.observers_.forEach(d => {\n if (d.dependenciesState_ === IDerivationState_.POSSIBLY_STALE_) {\n d.dependenciesState_ = IDerivationState_.STALE_\n if (__DEV__ && d.isTracing_ !== TraceMode.NONE) {\n logTraceInfo(d, observable)\n }\n } else if (\n d.dependenciesState_ === IDerivationState_.UP_TO_DATE_ // this happens during computing of `d`, just keep lowestObserverState up to date.\n ) {\n observable.lowestObserverState_ = IDerivationState_.UP_TO_DATE_\n }\n })\n // invariantLOS(observable, \"confirmed end\");\n}\n\n// Used by computed when its dependency changed, but we don't wan't to immediately recompute.\nexport function propagateMaybeChanged(observable: IObservable) {\n // invariantLOS(observable, \"maybe start\");\n if (observable.lowestObserverState_ !== IDerivationState_.UP_TO_DATE_) {\n return\n }\n observable.lowestObserverState_ = IDerivationState_.POSSIBLY_STALE_\n\n observable.observers_.forEach(d => {\n if (d.dependenciesState_ === IDerivationState_.UP_TO_DATE_) {\n d.dependenciesState_ = IDerivationState_.POSSIBLY_STALE_\n d.onBecomeStale_()\n }\n })\n // invariantLOS(observable, \"maybe end\");\n}\n\nfunction logTraceInfo(derivation: IDerivation, observable: IObservable) {\n console.log(\n `[mobx.trace] '${derivation.name_}' is invalidated due to a change in: '${observable.name_}'`\n )\n if (derivation.isTracing_ === TraceMode.BREAK) {\n const lines = []\n printDepTree(getDependencyTree(derivation), lines, 1)\n\n // prettier-ignore\n new Function(\n`debugger;\n/*\nTracing '${derivation.name_}'\n\nYou are entering this break point because derivation '${derivation.name_}' is being traced and '${observable.name_}' is now forcing it to update.\nJust follow the stacktrace you should now see in the devtools to see precisely what piece of your code is causing this update\nThe stackframe you are looking for is at least ~6-8 stack-frames up.\n\n${derivation instanceof ComputedValue ? derivation.derivation.toString().replace(/[*]\\//g, \"/\") : \"\"}\n\nThe dependencies for this derivation are:\n\n${lines.join(\"\\n\")}\n*/\n `)()\n }\n}\n\nfunction printDepTree(tree: IDependencyTree, lines: string[], depth: number) {\n if (lines.length >= 1000) {\n lines.push(\"(and many more)\")\n return\n }\n lines.push(`${\"\\t\".repeat(depth - 1)}${tree.name}`)\n if (tree.dependencies) {\n tree.dependencies.forEach(child => printDepTree(child, lines, depth + 1))\n }\n}\n", "import {\n $mobx,\n IDerivation,\n IDerivationState_,\n IObservable,\n Lambda,\n TraceMode,\n clearObserving,\n createInstanceofPredicate,\n endBatch,\n getNextId,\n globalState,\n isCaughtException,\n isSpyEnabled,\n shouldCompute,\n spyReport,\n spyReportEnd,\n spyReportStart,\n startBatch,\n trace,\n trackDerivedFunction,\n GenericAbortSignal\n} from \"../internal\"\n\n/**\n * Reactions are a special kind of derivations. Several things distinguishes them from normal reactive computations\n *\n * 1) They will always run, whether they are used by other computations or not.\n * This means that they are very suitable for triggering side effects like logging, updating the DOM and making network requests.\n * 2) They are not observable themselves\n * 3) They will always run after any 'normal' derivations\n * 4) They are allowed to change the state and thereby triggering themselves again, as long as they make sure the state propagates to a stable state in a reasonable amount of iterations.\n *\n * The state machine of a Reaction is as follows:\n *\n * 1) after creating, the reaction should be started by calling `runReaction` or by scheduling it (see also `autorun`)\n * 2) the `onInvalidate` handler should somehow result in a call to `this.track(someFunction)`\n * 3) all observables accessed in `someFunction` will be observed by this reaction.\n * 4) as soon as some of the dependencies has changed the Reaction will be rescheduled for another run (after the current mutation or transaction). `isScheduled` will yield true once a dependency is stale and during this period\n * 5) `onInvalidate` will be called, and we are back at step 1.\n *\n */\n\nexport interface IReactionPublic {\n dispose(): void\n trace(enterBreakPoint?: boolean): void\n}\n\nexport interface IReactionDisposer {\n (): void\n [$mobx]: Reaction\n}\n\nexport class Reaction implements IDerivation, IReactionPublic {\n observing_: IObservable[] = [] // nodes we are looking at. Our value depends on these nodes\n newObserving_: IObservable[] = []\n dependenciesState_ = IDerivationState_.NOT_TRACKING_\n diffValue_ = 0\n runId_ = 0\n unboundDepsCount_ = 0\n isDisposed_ = false\n isScheduled_ = false\n isTrackPending_ = false\n isRunning_ = false\n isTracing_: TraceMode = TraceMode.NONE\n\n constructor(\n public name_: string = __DEV__ ? \"Reaction@\" + getNextId() : \"Reaction\",\n private onInvalidate_: () => void,\n private errorHandler_?: (error: any, derivation: IDerivation) => void,\n public requiresObservable_?\n ) {}\n\n onBecomeStale_() {\n this.schedule_()\n }\n\n schedule_() {\n if (!this.isScheduled_) {\n this.isScheduled_ = true\n globalState.pendingReactions.push(this)\n runReactions()\n }\n }\n\n isScheduled() {\n return this.isScheduled_\n }\n\n /**\n * internal, use schedule() if you intend to kick off a reaction\n */\n runReaction_() {\n if (!this.isDisposed_) {\n startBatch()\n this.isScheduled_ = false\n const prev = globalState.trackingContext\n globalState.trackingContext = this\n if (shouldCompute(this)) {\n this.isTrackPending_ = true\n\n try {\n this.onInvalidate_()\n if (__DEV__ && this.isTrackPending_ && isSpyEnabled()) {\n // onInvalidate didn't trigger track right away..\n spyReport({\n name: this.name_,\n type: \"scheduled-reaction\"\n })\n }\n } catch (e) {\n this.reportExceptionInDerivation_(e)\n }\n }\n globalState.trackingContext = prev\n endBatch()\n }\n }\n\n track(fn: () => void) {\n if (this.isDisposed_) {\n return\n // console.warn(\"Reaction already disposed\") // Note: Not a warning / error in mobx 4 either\n }\n startBatch()\n const notify = isSpyEnabled()\n let startTime\n if (__DEV__ && notify) {\n startTime = Date.now()\n spyReportStart({\n name: this.name_,\n type: \"reaction\"\n })\n }\n this.isRunning_ = true\n const prevReaction = globalState.trackingContext // reactions could create reactions...\n globalState.trackingContext = this\n const result = trackDerivedFunction(this, fn, undefined)\n globalState.trackingContext = prevReaction\n this.isRunning_ = false\n this.isTrackPending_ = false\n if (this.isDisposed_) {\n // disposed during last run. Clean up everything that was bound after the dispose call.\n clearObserving(this)\n }\n if (isCaughtException(result)) {\n this.reportExceptionInDerivation_(result.cause)\n }\n if (__DEV__ && notify) {\n spyReportEnd({\n time: Date.now() - startTime\n })\n }\n endBatch()\n }\n\n reportExceptionInDerivation_(error: any) {\n if (this.errorHandler_) {\n this.errorHandler_(error, this)\n return\n }\n\n if (globalState.disableErrorBoundaries) {\n throw error\n }\n\n const message = __DEV__\n ? `[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '${this}'`\n : `[mobx] uncaught error in '${this}'`\n if (!globalState.suppressReactionErrors) {\n console.error(message, error)\n /** If debugging brought you here, please, read the above message :-). Tnx! */\n } else if (__DEV__) { console.warn(`[mobx] (error in reaction '${this.name_}' suppressed, fix error of causing action below)`) } // prettier-ignore\n\n if (__DEV__ && isSpyEnabled()) {\n spyReport({\n type: \"error\",\n name: this.name_,\n message,\n error: \"\" + error\n })\n }\n\n globalState.globalReactionErrorHandlers.forEach(f => f(error, this))\n }\n\n dispose() {\n if (!this.isDisposed_) {\n this.isDisposed_ = true\n if (!this.isRunning_) {\n // if disposed while running, clean up later. Maybe not optimal, but rare case\n startBatch()\n clearObserving(this)\n endBatch()\n }\n }\n }\n\n getDisposer_(abortSignal?: GenericAbortSignal): IReactionDisposer {\n const dispose = (() => {\n this.dispose()\n abortSignal?.removeEventListener?.(\"abort\", dispose)\n }) as IReactionDisposer\n abortSignal?.addEventListener?.(\"abort\", dispose)\n dispose[$mobx] = this\n\n return dispose\n }\n\n toString() {\n return `Reaction[${this.name_}]`\n }\n\n trace(enterBreakPoint: boolean = false) {\n trace(this, enterBreakPoint)\n }\n}\n\nexport function onReactionError(handler: (error: any, derivation: IDerivation) => void): Lambda {\n globalState.globalReactionErrorHandlers.push(handler)\n return () => {\n const idx = globalState.globalReactionErrorHandlers.indexOf(handler)\n if (idx >= 0) {\n globalState.globalReactionErrorHandlers.splice(idx, 1)\n }\n }\n}\n\n/**\n * Magic number alert!\n * Defines within how many times a reaction is allowed to re-trigger itself\n * until it is assumed that this is gonna be a never ending loop...\n */\nconst MAX_REACTION_ITERATIONS = 100\n\nlet reactionScheduler: (fn: () => void) => void = f => f()\n\nexport function runReactions() {\n // Trampolining, if runReactions are already running, new reactions will be picked up\n if (globalState.inBatch > 0 || globalState.isRunningReactions) {\n return\n }\n reactionScheduler(runReactionsHelper)\n}\n\nfunction runReactionsHelper() {\n globalState.isRunningReactions = true\n const allReactions = globalState.pendingReactions\n let iterations = 0\n\n // While running reactions, new reactions might be triggered.\n // Hence we work with two variables and check whether\n // we converge to no remaining reactions after a while.\n while (allReactions.length > 0) {\n if (++iterations === MAX_REACTION_ITERATIONS) {\n console.error(\n __DEV__\n ? `Reaction doesn't converge to a stable state after ${MAX_REACTION_ITERATIONS} iterations.` +\n ` Probably there is a cycle in the reactive function: ${allReactions[0]}`\n : `[mobx] cycle in reaction: ${allReactions[0]}`\n )\n allReactions.splice(0) // clear reactions\n }\n let remainingReactions = allReactions.splice(0)\n for (let i = 0, l = remainingReactions.length; i < l; i++) {\n remainingReactions[i].runReaction_()\n }\n }\n globalState.isRunningReactions = false\n}\n\nexport const isReaction = createInstanceofPredicate(\"Reaction\", Reaction)\n\nexport function setReactionScheduler(fn: (f: () => void) => void) {\n const baseScheduler = reactionScheduler\n reactionScheduler = f => fn(() => baseScheduler(f))\n}\n", "import { IComputedDidChange } from \"./computedvalue\"\nimport { IValueDidChange, IBoxDidChange } from \"./../types/observablevalue\"\nimport { IObjectDidChange } from \"./../types/observableobject\"\nimport { IArrayDidChange } from \"./../types/observablearray\"\nimport { Lambda, globalState, once, ISetDidChange, IMapDidChange } from \"../internal\"\n\nexport function isSpyEnabled() {\n return __DEV__ && !!globalState.spyListeners.length\n}\n\nexport type PureSpyEvent =\n | { type: \"action\"; name: string; object: unknown; arguments: unknown[] }\n | { type: \"scheduled-reaction\"; name: string }\n | { type: \"reaction\"; name: string }\n | { type: \"error\"; name: string; message: string; error: string }\n | IComputedDidChange\n | IObjectDidChange\n | IArrayDidChange\n | IMapDidChange\n | ISetDidChange\n | IValueDidChange\n | IBoxDidChange\n | { type: \"report-end\"; spyReportEnd: true; time?: number }\n\ntype SpyEvent = PureSpyEvent & { spyReportStart?: true }\n\nexport function spyReport(event: SpyEvent) {\n if (!__DEV__) {\n return\n } // dead code elimination can do the rest\n if (!globalState.spyListeners.length) {\n return\n }\n const listeners = globalState.spyListeners\n for (let i = 0, l = listeners.length; i < l; i++) {\n listeners[i](event)\n }\n}\n\nexport function spyReportStart(event: PureSpyEvent) {\n if (!__DEV__) {\n return\n }\n const change = { ...event, spyReportStart: true as const }\n spyReport(change)\n}\n\nconst END_EVENT: SpyEvent = { type: \"report-end\", spyReportEnd: true }\n\nexport function spyReportEnd(change?: { time?: number }) {\n if (!__DEV__) {\n return\n }\n if (change) {\n spyReport({ ...change, type: \"report-end\", spyReportEnd: true })\n } else {\n spyReport(END_EVENT)\n }\n}\n\nexport function spy(listener: (change: SpyEvent) => void): Lambda {\n if (!__DEV__) {\n console.warn(`[mobx.spy] Is a no-op in production builds`)\n return function () {}\n } else {\n globalState.spyListeners.push(listener)\n return once(() => {\n globalState.spyListeners = globalState.spyListeners.filter(l => l !== listener)\n })\n }\n}\n", "import {\n createAction,\n executeAction,\n Annotation,\n storeAnnotation,\n die,\n isFunction,\n isStringish,\n createDecoratorAnnotation,\n createActionAnnotation,\n is20223Decorator\n} from \"../internal\"\n\nimport type { ClassFieldDecorator, ClassMethodDecorator } from \"../types/decorator_fills\"\n\nexport const ACTION = \"action\"\nexport const ACTION_BOUND = \"action.bound\"\nexport const AUTOACTION = \"autoAction\"\nexport const AUTOACTION_BOUND = \"autoAction.bound\"\n\nconst DEFAULT_ACTION_NAME = \"\"\n\nconst actionAnnotation = createActionAnnotation(ACTION)\nconst actionBoundAnnotation = createActionAnnotation(ACTION_BOUND, {\n bound: true\n})\nconst autoActionAnnotation = createActionAnnotation(AUTOACTION, {\n autoAction: true\n})\nconst autoActionBoundAnnotation = createActionAnnotation(AUTOACTION_BOUND, {\n autoAction: true,\n bound: true\n})\n\nexport interface IActionFactory\n extends Annotation,\n PropertyDecorator,\n ClassMethodDecorator,\n ClassFieldDecorator {\n // nameless actions\n (fn: T): T\n // named actions\n (name: string, fn: T): T\n\n // named decorator\n (customName: string): PropertyDecorator &\n Annotation &\n ClassMethodDecorator &\n ClassFieldDecorator\n\n // decorator (name no longer supported)\n bound: Annotation & PropertyDecorator & ClassMethodDecorator & ClassFieldDecorator\n}\n\nfunction createActionFactory(autoAction: boolean): IActionFactory {\n const res: IActionFactory = function action(arg1, arg2?): any {\n // action(fn() {})\n if (isFunction(arg1)) {\n return createAction(arg1.name || DEFAULT_ACTION_NAME, arg1, autoAction)\n }\n // action(\"name\", fn() {})\n if (isFunction(arg2)) {\n return createAction(arg1, arg2, autoAction)\n }\n // @action (2022.3 Decorators)\n if (is20223Decorator(arg2)) {\n return (autoAction ? autoActionAnnotation : actionAnnotation).decorate_20223_(\n arg1,\n arg2\n )\n }\n // @action\n if (isStringish(arg2)) {\n return storeAnnotation(arg1, arg2, autoAction ? autoActionAnnotation : actionAnnotation)\n }\n // action(\"name\") & @action(\"name\")\n if (isStringish(arg1)) {\n return createDecoratorAnnotation(\n createActionAnnotation(autoAction ? AUTOACTION : ACTION, {\n name: arg1,\n autoAction\n })\n )\n }\n\n if (__DEV__) {\n die(\"Invalid arguments for `action`\")\n }\n } as IActionFactory\n return res\n}\n\nexport const action: IActionFactory = createActionFactory(false)\nObject.assign(action, actionAnnotation)\nexport const autoAction: IActionFactory = createActionFactory(true)\nObject.assign(autoAction, autoActionAnnotation)\n\naction.bound = createDecoratorAnnotation(actionBoundAnnotation)\nautoAction.bound = createDecoratorAnnotation(autoActionBoundAnnotation)\n\nexport function runInAction(fn: () => T): T {\n return executeAction(fn.name || DEFAULT_ACTION_NAME, false, fn, this, undefined)\n}\n\nexport function isAction(thing: any) {\n return isFunction(thing) && thing.isMobxAction === true\n}\n", "import {\n EMPTY_OBJECT,\n IEqualsComparer,\n IReactionDisposer,\n IReactionPublic,\n Lambda,\n Reaction,\n action,\n comparer,\n getNextId,\n isAction,\n isFunction,\n isPlainObject,\n die,\n allowStateChanges,\n GenericAbortSignal\n} from \"../internal\"\n\nexport interface IAutorunOptions {\n delay?: number\n name?: string\n /**\n * Experimental.\n * Warns if the view doesn't track observables\n */\n requiresObservable?: boolean\n scheduler?: (callback: () => void) => any\n onError?: (error: any) => void\n signal?: GenericAbortSignal\n}\n\n/**\n * Creates a named reactive view and keeps it alive, so that the view is always\n * updated if one of the dependencies changes, even when the view is not further used by something else.\n * @param view The reactive view\n * @returns disposer function, which can be used to stop the view from being updated in the future.\n */\nexport function autorun(\n view: (r: IReactionPublic) => any,\n opts: IAutorunOptions = EMPTY_OBJECT\n): IReactionDisposer {\n if (__DEV__) {\n if (!isFunction(view)) {\n die(\"Autorun expects a function as first argument\")\n }\n if (isAction(view)) {\n die(\"Autorun does not accept actions since actions are untrackable\")\n }\n }\n\n const name: string =\n opts?.name ?? (__DEV__ ? (view as any).name || \"Autorun@\" + getNextId() : \"Autorun\")\n const runSync = !opts.scheduler && !opts.delay\n let reaction: Reaction\n\n if (runSync) {\n // normal autorun\n reaction = new Reaction(\n name,\n function (this: Reaction) {\n this.track(reactionRunner)\n },\n opts.onError,\n opts.requiresObservable\n )\n } else {\n const scheduler = createSchedulerFromOptions(opts)\n // debounced autorun\n let isScheduled = false\n\n reaction = new Reaction(\n name,\n () => {\n if (!isScheduled) {\n isScheduled = true\n scheduler(() => {\n isScheduled = false\n if (!reaction.isDisposed_) {\n reaction.track(reactionRunner)\n }\n })\n }\n },\n opts.onError,\n opts.requiresObservable\n )\n }\n\n function reactionRunner() {\n view(reaction)\n }\n\n if(!opts?.signal?.aborted) {\n reaction.schedule_()\n }\n return reaction.getDisposer_(opts?.signal)\n}\n\nexport type IReactionOptions = IAutorunOptions & {\n fireImmediately?: FireImmediately\n equals?: IEqualsComparer\n}\n\nconst run = (f: Lambda) => f()\n\nfunction createSchedulerFromOptions(opts: IAutorunOptions) {\n return opts.scheduler\n ? opts.scheduler\n : opts.delay\n ? (f: Lambda) => setTimeout(f, opts.delay!)\n : run\n}\n\nexport function reaction(\n expression: (r: IReactionPublic) => T,\n effect: (\n arg: T,\n prev: FireImmediately extends true ? T | undefined : T,\n r: IReactionPublic\n ) => void,\n opts: IReactionOptions = EMPTY_OBJECT\n): IReactionDisposer {\n if (__DEV__) {\n if (!isFunction(expression) || !isFunction(effect)) {\n die(\"First and second argument to reaction should be functions\")\n }\n if (!isPlainObject(opts)) {\n die(\"Third argument of reactions should be an object\")\n }\n }\n const name = opts.name ?? (__DEV__ ? \"Reaction@\" + getNextId() : \"Reaction\")\n const effectAction = action(\n name,\n opts.onError ? wrapErrorHandler(opts.onError, effect) : effect\n )\n const runSync = !opts.scheduler && !opts.delay\n const scheduler = createSchedulerFromOptions(opts)\n\n let firstTime = true\n let isScheduled = false\n let value: T\n\n const equals: IEqualsComparer = (opts as any).compareStructural\n ? comparer.structural\n : opts.equals || comparer.default\n\n const r = new Reaction(\n name,\n () => {\n if (firstTime || runSync) {\n reactionRunner()\n } else if (!isScheduled) {\n isScheduled = true\n scheduler!(reactionRunner)\n }\n },\n opts.onError,\n opts.requiresObservable\n )\n\n function reactionRunner() {\n isScheduled = false\n if (r.isDisposed_) {\n return\n }\n let changed: boolean = false\n const oldValue = value\n r.track(() => {\n const nextValue = allowStateChanges(false, () => expression(r))\n changed = firstTime || !equals(value, nextValue)\n value = nextValue\n })\n\n // This casting is nesessary as TS cannot infer proper type in current function implementation\n type OldValue = FireImmediately extends true ? T | undefined : T\n if (firstTime && opts.fireImmediately!) {\n effectAction(value, oldValue as OldValue, r)\n } else if (!firstTime && changed) {\n effectAction(value, oldValue as OldValue, r)\n }\n firstTime = false\n }\n\n if(!opts?.signal?.aborted) {\n r.schedule_()\n }\n return r.getDisposer_(opts?.signal)\n}\n\nfunction wrapErrorHandler(errorHandler, baseFn) {\n return function () {\n try {\n return baseFn.apply(this, arguments)\n } catch (e) {\n errorHandler.call(this, e)\n }\n }\n}\n", "import {\n IComputedValue,\n IObservable,\n IObservableArray,\n Lambda,\n ObservableMap,\n getAtom,\n ObservableSet,\n isFunction,\n IObservableValue\n} from \"../internal\"\n\nconst ON_BECOME_OBSERVED = \"onBO\"\nconst ON_BECOME_UNOBSERVED = \"onBUO\"\n\nexport function onBecomeObserved(\n value:\n | IObservable\n | IComputedValue\n | IObservableArray\n | ObservableMap\n | ObservableSet\n | IObservableValue,\n listener: Lambda\n): Lambda\nexport function onBecomeObserved(\n value: ObservableMap | Object,\n property: K,\n listener: Lambda\n): Lambda\nexport function onBecomeObserved(thing, arg2, arg3?): Lambda {\n return interceptHook(ON_BECOME_OBSERVED, thing, arg2, arg3)\n}\n\nexport function onBecomeUnobserved(\n value:\n | IObservable\n | IComputedValue\n | IObservableArray\n | ObservableMap\n | ObservableSet\n | IObservableValue,\n listener: Lambda\n): Lambda\nexport function onBecomeUnobserved(\n value: ObservableMap | Object,\n property: K,\n listener: Lambda\n): Lambda\nexport function onBecomeUnobserved(thing, arg2, arg3?): Lambda {\n return interceptHook(ON_BECOME_UNOBSERVED, thing, arg2, arg3)\n}\n\nfunction interceptHook(hook: \"onBO\" | \"onBUO\", thing, arg2, arg3) {\n const atom: IObservable =\n typeof arg3 === \"function\" ? getAtom(thing, arg2) : (getAtom(thing) as any)\n const cb = isFunction(arg3) ? arg3 : arg2\n const listenersKey = `${hook}L` as \"onBOL\" | \"onBUOL\"\n\n if (atom[listenersKey]) {\n atom[listenersKey]!.add(cb)\n } else {\n atom[listenersKey] = new Set([cb])\n }\n\n return function () {\n const hookListeners = atom[listenersKey]\n if (hookListeners) {\n hookListeners.delete(cb)\n if (hookListeners.size === 0) {\n delete atom[listenersKey]\n }\n }\n }\n}\n", "import { globalState, isolateGlobalState, setReactionScheduler } from \"../internal\"\n\nconst NEVER = \"never\"\nconst ALWAYS = \"always\"\nconst OBSERVED = \"observed\"\n// const IF_AVAILABLE = \"ifavailable\"\n\nexport function configure(options: {\n enforceActions?: \"never\" | \"always\" | \"observed\"\n computedRequiresReaction?: boolean\n /**\n * Warn if you try to create to derivation / reactive context without accessing any observable.\n */\n reactionRequiresObservable?: boolean\n /**\n * Warn if observables are accessed outside a reactive context\n */\n observableRequiresReaction?: boolean\n isolateGlobalState?: boolean\n disableErrorBoundaries?: boolean\n safeDescriptors?: boolean\n reactionScheduler?: (f: () => void) => void\n useProxies?: \"always\" | \"never\" | \"ifavailable\"\n}): void {\n if (options.isolateGlobalState === true) {\n isolateGlobalState()\n }\n const { useProxies, enforceActions } = options\n if (useProxies !== undefined) {\n globalState.useProxies =\n useProxies === ALWAYS\n ? true\n : useProxies === NEVER\n ? false\n : typeof Proxy !== \"undefined\"\n }\n if (useProxies === \"ifavailable\") {\n globalState.verifyProxies = true\n }\n if (enforceActions !== undefined) {\n const ea = enforceActions === ALWAYS ? ALWAYS : enforceActions === OBSERVED\n globalState.enforceActions = ea\n globalState.allowStateChanges = ea === true || ea === ALWAYS ? false : true\n }\n ;[\n \"computedRequiresReaction\",\n \"reactionRequiresObservable\",\n \"observableRequiresReaction\",\n \"disableErrorBoundaries\",\n \"safeDescriptors\"\n ].forEach(key => {\n if (key in options) {\n globalState[key] = !!options[key]\n }\n })\n globalState.allowStateReads = !globalState.observableRequiresReaction\n if (__DEV__ && globalState.disableErrorBoundaries === true) {\n console.warn(\n \"WARNING: Debug feature only. MobX will NOT recover from errors when `disableErrorBoundaries` is enabled.\"\n )\n }\n if (options.reactionScheduler) {\n setReactionScheduler(options.reactionScheduler)\n }\n}\n", "import {\n CreateObservableOptions,\n isObservableMap,\n AnnotationsMap,\n asObservableObject,\n isPlainObject,\n ObservableObjectAdministration,\n isObservable,\n die,\n getOwnPropertyDescriptors,\n $mobx,\n ownKeys,\n initObservable\n} from \"../internal\"\n\nexport function extendObservable(\n target: A,\n properties: B,\n annotations?: AnnotationsMap,\n options?: CreateObservableOptions\n): A & B {\n if (__DEV__) {\n if (arguments.length > 4) {\n die(\"'extendObservable' expected 2-4 arguments\")\n }\n if (typeof target !== \"object\") {\n die(\"'extendObservable' expects an object as first argument\")\n }\n if (isObservableMap(target)) {\n die(\"'extendObservable' should not be used on maps, use map.merge instead\")\n }\n if (!isPlainObject(properties)) {\n die(`'extendObservable' only accepts plain objects as second argument`)\n }\n if (isObservable(properties) || isObservable(annotations)) {\n die(`Extending an object with another observable (object) is not supported`)\n }\n }\n // Pull descriptors first, so we don't have to deal with props added by administration ($mobx)\n const descriptors = getOwnPropertyDescriptors(properties)\n\n initObservable(() => {\n const adm: ObservableObjectAdministration = asObservableObject(target, options)[$mobx]\n ownKeys(descriptors).forEach(key => {\n adm.extend_(\n key,\n descriptors[key as any],\n // must pass \"undefined\" for { key: undefined }\n !annotations ? true : key in annotations ? annotations[key] : true\n )\n })\n })\n\n return target as any\n}\n", "import { IDepTreeNode, getAtom, getObservers, hasObservers } from \"../internal\"\n\nexport interface IDependencyTree {\n name: string\n dependencies?: IDependencyTree[]\n}\n\nexport interface IObserverTree {\n name: string\n observers?: IObserverTree[]\n}\n\nexport function getDependencyTree(thing: any, property?: string): IDependencyTree {\n return nodeToDependencyTree(getAtom(thing, property))\n}\n\nfunction nodeToDependencyTree(node: IDepTreeNode): IDependencyTree {\n const result: IDependencyTree = {\n name: node.name_\n }\n if (node.observing_ && node.observing_.length > 0) {\n result.dependencies = unique(node.observing_).map(nodeToDependencyTree)\n }\n return result\n}\n\nexport function getObserverTree(thing: any, property?: string): IObserverTree {\n return nodeToObserverTree(getAtom(thing, property))\n}\n\nfunction nodeToObserverTree(node: IDepTreeNode): IObserverTree {\n const result: IObserverTree = {\n name: node.name_\n }\n if (hasObservers(node as any)) {\n result.observers = Array.from(getObservers(node as any)).map(nodeToObserverTree)\n }\n return result\n}\n\nfunction unique(list: T[]): T[] {\n return Array.from(new Set(list))\n}\n", "import {\n action,\n noop,\n die,\n isFunction,\n Annotation,\n isStringish,\n storeAnnotation,\n createFlowAnnotation,\n createDecoratorAnnotation,\n is20223Decorator\n} from \"../internal\"\n\nimport type { ClassMethodDecorator } from \"../types/decorator_fills\"\n\nexport const FLOW = \"flow\"\n\nlet generatorId = 0\n\nexport function FlowCancellationError() {\n this.message = \"FLOW_CANCELLED\"\n}\nFlowCancellationError.prototype = Object.create(Error.prototype)\n\nexport function isFlowCancellationError(error: Error) {\n return error instanceof FlowCancellationError\n}\n\nexport type CancellablePromise = Promise & { cancel(): void }\n\ninterface Flow extends Annotation, PropertyDecorator, ClassMethodDecorator {\n (\n generator: (...args: Args) => Generator | AsyncGenerator\n ): (...args: Args) => CancellablePromise\n bound: Annotation & PropertyDecorator & ClassMethodDecorator\n}\n\nconst flowAnnotation = createFlowAnnotation(\"flow\")\nconst flowBoundAnnotation = createFlowAnnotation(\"flow.bound\", { bound: true })\n\nexport const flow: Flow = Object.assign(\n function flow(arg1, arg2?) {\n // @flow (2022.3 Decorators)\n if (is20223Decorator(arg2)) {\n return flowAnnotation.decorate_20223_(arg1, arg2)\n }\n // @flow\n if (isStringish(arg2)) {\n return storeAnnotation(arg1, arg2, flowAnnotation)\n }\n // flow(fn)\n if (__DEV__ && arguments.length !== 1) {\n die(`Flow expects single argument with generator function`)\n }\n const generator = arg1\n const name = generator.name || \"\"\n\n // Implementation based on https://github.com/tj/co/blob/master/index.js\n const res = function () {\n const ctx = this\n const args = arguments\n const runId = ++generatorId\n const gen = action(`${name} - runid: ${runId} - init`, generator).apply(ctx, args)\n let rejector: (error: any) => void\n let pendingPromise: CancellablePromise | undefined = undefined\n\n const promise = new Promise(function (resolve, reject) {\n let stepId = 0\n rejector = reject\n\n function onFulfilled(res: any) {\n pendingPromise = undefined\n let ret\n try {\n ret = action(\n `${name} - runid: ${runId} - yield ${stepId++}`,\n gen.next\n ).call(gen, res)\n } catch (e) {\n return reject(e)\n }\n\n next(ret)\n }\n\n function onRejected(err: any) {\n pendingPromise = undefined\n let ret\n try {\n ret = action(\n `${name} - runid: ${runId} - yield ${stepId++}`,\n gen.throw!\n ).call(gen, err)\n } catch (e) {\n return reject(e)\n }\n next(ret)\n }\n\n function next(ret: any) {\n if (isFunction(ret?.then)) {\n // an async iterator\n ret.then(next, reject)\n return\n }\n if (ret.done) {\n return resolve(ret.value)\n }\n pendingPromise = Promise.resolve(ret.value) as any\n return pendingPromise!.then(onFulfilled, onRejected)\n }\n\n onFulfilled(undefined) // kick off the process\n }) as any\n\n promise.cancel = action(`${name} - runid: ${runId} - cancel`, function () {\n try {\n if (pendingPromise) {\n cancelPromise(pendingPromise)\n }\n // Finally block can return (or yield) stuff..\n const res = gen.return!(undefined as any)\n // eat anything that promise would do, it's cancelled!\n const yieldedPromise = Promise.resolve(res.value)\n yieldedPromise.then(noop, noop)\n cancelPromise(yieldedPromise) // maybe it can be cancelled :)\n // reject our original promise\n rejector(new FlowCancellationError())\n } catch (e) {\n rejector(e) // there could be a throwing finally block\n }\n })\n return promise\n }\n res.isMobXFlow = true\n return res\n } as any,\n flowAnnotation\n)\n\nflow.bound = createDecoratorAnnotation(flowBoundAnnotation)\n\nfunction cancelPromise(promise) {\n if (isFunction(promise.cancel)) {\n promise.cancel()\n }\n}\n\nexport function flowResult(\n result: T\n): T extends Generator\n ? CancellablePromise\n : T extends CancellablePromise\n ? T\n : never {\n return result as any // just tricking TypeScript :)\n}\n\nexport function isFlow(fn: any): boolean {\n return fn?.isMobXFlow === true\n}\n", "import {\n IObservableArray,\n IObservableValue,\n Lambda,\n ObservableMap,\n getAdministration,\n isObservableArray,\n isObservableMap,\n isObservableObject,\n isObservableValue,\n ObservableSet,\n die,\n isStringish\n} from \"../internal\"\n\nexport type ReadInterceptor = (value: any) => T\n\n/** Experimental feature right now, tested indirectly via Mobx-State-Tree */\nexport function interceptReads(value: IObservableValue, handler: ReadInterceptor): Lambda\nexport function interceptReads(\n observableArray: IObservableArray,\n handler: ReadInterceptor\n): Lambda\nexport function interceptReads(\n observableMap: ObservableMap,\n handler: ReadInterceptor\n): Lambda\nexport function interceptReads(\n observableSet: ObservableSet,\n handler: ReadInterceptor\n): Lambda\nexport function interceptReads(\n object: Object,\n property: string,\n handler: ReadInterceptor\n): Lambda\nexport function interceptReads(thing, propOrHandler?, handler?): Lambda {\n let target\n if (isObservableMap(thing) || isObservableArray(thing) || isObservableValue(thing)) {\n target = getAdministration(thing)\n } else if (isObservableObject(thing)) {\n if (__DEV__ && !isStringish(propOrHandler)) {\n return die(\n `InterceptReads can only be used with a specific property, not with an object in general`\n )\n }\n target = getAdministration(thing, propOrHandler)\n } else if (__DEV__) {\n return die(`Expected observable map, object or array as first array`)\n }\n if (__DEV__ && target.dehancer !== undefined) {\n return die(`An intercept reader was already established`)\n }\n target.dehancer = typeof propOrHandler === \"function\" ? propOrHandler : handler\n return () => {\n target.dehancer = undefined\n }\n}\n", "import {\n IArrayWillChange,\n IArrayWillSplice,\n IInterceptor,\n IMapWillChange,\n IObjectWillChange,\n IObservableArray,\n IObservableValue,\n IValueWillChange,\n Lambda,\n ObservableMap,\n getAdministration,\n ObservableSet,\n ISetWillChange,\n isFunction\n} from \"../internal\"\n\nexport function intercept(\n value: IObservableValue,\n handler: IInterceptor>\n): Lambda\nexport function intercept(\n observableArray: IObservableArray | Array,\n handler: IInterceptor | IArrayWillSplice>\n): Lambda\nexport function intercept(\n observableMap: ObservableMap | Map,\n handler: IInterceptor>\n): Lambda\nexport function intercept(\n observableSet: ObservableSet | Set,\n handler: IInterceptor>\n): Lambda\nexport function intercept(\n observableMap: ObservableMap | Map,\n property: K,\n handler: IInterceptor>\n): Lambda\nexport function intercept(object: object, handler: IInterceptor): Lambda\nexport function intercept(\n object: T,\n property: K,\n handler: IInterceptor>\n): Lambda\nexport function intercept(thing, propOrHandler?, handler?): Lambda {\n if (isFunction(handler)) {\n return interceptProperty(thing, propOrHandler, handler)\n } else {\n return interceptInterceptable(thing, propOrHandler)\n }\n}\n\nfunction interceptInterceptable(thing, handler) {\n return getAdministration(thing).intercept_(handler)\n}\n\nfunction interceptProperty(thing, property, handler) {\n return getAdministration(thing, property).intercept_(handler)\n}\n", "import { $mobx, getAtom, isComputedValue, isObservableObject, die, isStringish } from \"../internal\"\n\nexport function _isComputed(value, property?: PropertyKey): boolean {\n if (property === undefined) {\n return isComputedValue(value)\n }\n if (isObservableObject(value) === false) {\n return false\n }\n if (!value[$mobx].values_.has(property)) {\n return false\n }\n const atom = getAtom(value, property)\n return isComputedValue(atom)\n}\n\nexport function isComputed(value: any): boolean {\n if (__DEV__ && arguments.length > 1) {\n return die(\n `isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property`\n )\n }\n return _isComputed(value)\n}\n\nexport function isComputedProp(value: any, propName: PropertyKey): boolean {\n if (__DEV__ && !isStringish(propName)) {\n return die(`isComputed expected a property name as second argument`)\n }\n return _isComputed(value, propName)\n}\n", "import {\n $mobx,\n isAtom,\n isComputedValue,\n isObservableArray,\n isObservableMap,\n isObservableObject,\n isReaction,\n die,\n isStringish\n} from \"../internal\"\n\nfunction _isObservable(value, property?: PropertyKey): boolean {\n if (!value) {\n return false\n }\n if (property !== undefined) {\n if (__DEV__ && (isObservableMap(value) || isObservableArray(value))) {\n return die(\n \"isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead.\"\n )\n }\n if (isObservableObject(value)) {\n return value[$mobx].values_.has(property)\n }\n return false\n }\n // For first check, see #701\n return (\n isObservableObject(value) ||\n !!value[$mobx] ||\n isAtom(value) ||\n isReaction(value) ||\n isComputedValue(value)\n )\n}\n\nexport function isObservable(value: any): boolean {\n if (__DEV__ && arguments.length !== 1) {\n die(\n `isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property`\n )\n }\n return _isObservable(value)\n}\n\nexport function isObservableProp(value: any, propName: PropertyKey): boolean {\n if (__DEV__ && !isStringish(propName)) {\n return die(`expected a property name as second argument`)\n }\n return _isObservable(value, propName)\n}\n", "import {\n $mobx,\n IIsObservableObject,\n IObservableArray,\n ObservableMap,\n ObservableSet,\n ObservableObjectAdministration,\n endBatch,\n isObservableArray,\n isObservableMap,\n isObservableSet,\n isObservableObject,\n startBatch,\n die\n} from \"../internal\"\n\nexport function keys(map: ObservableMap): ReadonlyArray\nexport function keys(ar: IObservableArray): ReadonlyArray\nexport function keys(set: ObservableSet): ReadonlyArray\nexport function keys(obj: T): ReadonlyArray\nexport function keys(obj: any): any {\n if (isObservableObject(obj)) {\n return (\n (obj as any as IIsObservableObject)[$mobx] as ObservableObjectAdministration\n ).keys_()\n }\n if (isObservableMap(obj) || isObservableSet(obj)) {\n return Array.from(obj.keys())\n }\n if (isObservableArray(obj)) {\n return obj.map((_, index) => index)\n }\n die(5)\n}\n\nexport function values(map: ObservableMap): ReadonlyArray\nexport function values(set: ObservableSet): ReadonlyArray\nexport function values(ar: IObservableArray): ReadonlyArray\nexport function values(obj: T): ReadonlyArray\nexport function values(obj: any): string[] {\n if (isObservableObject(obj)) {\n return keys(obj).map(key => obj[key])\n }\n if (isObservableMap(obj)) {\n return keys(obj).map(key => obj.get(key))\n }\n if (isObservableSet(obj)) {\n return Array.from(obj.values())\n }\n if (isObservableArray(obj)) {\n return obj.slice()\n }\n die(6)\n}\n\nexport function entries(map: ObservableMap): ReadonlyArray<[K, T]>\nexport function entries(set: ObservableSet): ReadonlyArray<[T, T]>\nexport function entries(ar: IObservableArray): ReadonlyArray<[number, T]>\nexport function entries(\n obj: T\n): ReadonlyArray<[string, T extends object ? T[keyof T] : any]>\nexport function entries(obj: any): any {\n if (isObservableObject(obj)) {\n return keys(obj).map(key => [key, obj[key]])\n }\n if (isObservableMap(obj)) {\n return keys(obj).map(key => [key, obj.get(key)])\n }\n if (isObservableSet(obj)) {\n return Array.from(obj.entries())\n }\n if (isObservableArray(obj)) {\n return obj.map((key, index) => [index, key])\n }\n die(7)\n}\n\nexport function set(obj: ObservableMap, values: { [key: string]: V })\nexport function set(obj: ObservableMap, key: K, value: V)\nexport function set(obj: ObservableSet, value: T)\nexport function set(obj: IObservableArray, index: number, value: T)\nexport function set(obj: T, values: { [key: string]: any })\nexport function set(obj: T, key: PropertyKey, value: any)\nexport function set(obj: any, key: any, value?: any): void {\n if (arguments.length === 2 && !isObservableSet(obj)) {\n startBatch()\n const values = key\n try {\n for (let key in values) {\n set(obj, key, values[key])\n }\n } finally {\n endBatch()\n }\n return\n }\n if (isObservableObject(obj)) {\n ;(obj as any as IIsObservableObject)[$mobx].set_(key, value)\n } else if (isObservableMap(obj)) {\n obj.set(key, value)\n } else if (isObservableSet(obj)) {\n obj.add(key)\n } else if (isObservableArray(obj)) {\n if (typeof key !== \"number\") {\n key = parseInt(key, 10)\n }\n if (key < 0) {\n die(`Invalid index: '${key}'`)\n }\n startBatch()\n if (key >= obj.length) {\n obj.length = key + 1\n }\n obj[key] = value\n endBatch()\n } else {\n die(8)\n }\n}\n\nexport function remove(obj: ObservableMap, key: K)\nexport function remove(obj: ObservableSet, key: T)\nexport function remove(obj: IObservableArray, index: number)\nexport function remove(obj: T, key: string)\nexport function remove(obj: any, key: any): void {\n if (isObservableObject(obj)) {\n ;(obj as any as IIsObservableObject)[$mobx].delete_(key)\n } else if (isObservableMap(obj)) {\n obj.delete(key)\n } else if (isObservableSet(obj)) {\n obj.delete(key)\n } else if (isObservableArray(obj)) {\n if (typeof key !== \"number\") {\n key = parseInt(key, 10)\n }\n obj.splice(key, 1)\n } else {\n die(9)\n }\n}\n\nexport function has(obj: ObservableMap, key: K): boolean\nexport function has(obj: ObservableSet, key: T): boolean\nexport function has(obj: IObservableArray, index: number): boolean\nexport function has(obj: T, key: string): boolean\nexport function has(obj: any, key: any): boolean {\n if (isObservableObject(obj)) {\n return (obj as any as IIsObservableObject)[$mobx].has_(key)\n } else if (isObservableMap(obj)) {\n return obj.has(key)\n } else if (isObservableSet(obj)) {\n return obj.has(key)\n } else if (isObservableArray(obj)) {\n return key >= 0 && key < obj.length\n }\n die(10)\n}\n\nexport function get(obj: ObservableMap, key: K): V | undefined\nexport function get(obj: IObservableArray, index: number): T | undefined\nexport function get(obj: T, key: string): any\nexport function get(obj: any, key: any): any {\n if (!has(obj, key)) {\n return undefined\n }\n if (isObservableObject(obj)) {\n return (obj as any as IIsObservableObject)[$mobx].get_(key)\n } else if (isObservableMap(obj)) {\n return obj.get(key)\n } else if (isObservableArray(obj)) {\n return obj[key]\n }\n die(11)\n}\n\nexport function apiDefineProperty(obj: Object, key: PropertyKey, descriptor: PropertyDescriptor) {\n if (isObservableObject(obj)) {\n return (obj as any as IIsObservableObject)[$mobx].defineProperty_(key, descriptor)\n }\n die(39)\n}\n\nexport function apiOwnKeys(obj: Object) {\n if (isObservableObject(obj)) {\n return (obj as any as IIsObservableObject)[$mobx].ownKeys_()\n }\n die(38)\n}\n", "import {\n IArrayDidChange,\n IComputedValue,\n IMapDidChange,\n IObjectDidChange,\n IObservableArray,\n IObservableValue,\n IValueDidChange,\n Lambda,\n ObservableMap,\n getAdministration,\n ObservableSet,\n ISetDidChange,\n isFunction\n} from \"../internal\"\n\nexport function observe(\n value: IObservableValue | IComputedValue,\n listener: (change: IValueDidChange) => void,\n fireImmediately?: boolean\n): Lambda\nexport function observe(\n observableArray: IObservableArray | Array,\n listener: (change: IArrayDidChange) => void,\n fireImmediately?: boolean\n): Lambda\nexport function observe(\n // ObservableSet/ObservableMap are required despite they implement Set/Map: https://github.com/mobxjs/mobx/pull/3180#discussion_r746542929\n observableSet: ObservableSet | Set,\n listener: (change: ISetDidChange) => void,\n fireImmediately?: boolean\n): Lambda\nexport function observe(\n observableMap: ObservableMap | Map,\n listener: (change: IMapDidChange) => void,\n fireImmediately?: boolean\n): Lambda\nexport function observe(\n observableMap: ObservableMap | Map,\n property: K,\n listener: (change: IValueDidChange) => void,\n fireImmediately?: boolean\n): Lambda\nexport function observe(\n object: Object,\n listener: (change: IObjectDidChange) => void,\n fireImmediately?: boolean\n): Lambda\nexport function observe(\n object: T,\n property: K,\n listener: (change: IValueDidChange) => void,\n fireImmediately?: boolean\n): Lambda\nexport function observe(thing, propOrCb?, cbOrFire?, fireImmediately?): Lambda {\n if (isFunction(cbOrFire)) {\n return observeObservableProperty(thing, propOrCb, cbOrFire, fireImmediately)\n } else {\n return observeObservable(thing, propOrCb, cbOrFire)\n }\n}\n\nfunction observeObservable(thing, listener, fireImmediately: boolean) {\n return getAdministration(thing).observe_(listener, fireImmediately)\n}\n\nfunction observeObservableProperty(thing, property, listener, fireImmediately: boolean) {\n return getAdministration(thing, property).observe_(listener, fireImmediately)\n}\n", "import {\n isObservable,\n isObservableArray,\n isObservableValue,\n isObservableMap,\n isObservableSet,\n isComputedValue,\n die,\n apiOwnKeys,\n objectPrototype\n} from \"../internal\"\n\nfunction cache(map: Map, key: K, value: V): V {\n map.set(key, value)\n return value\n}\n\nfunction toJSHelper(source, __alreadySeen: Map) {\n if (\n source == null ||\n typeof source !== \"object\" ||\n source instanceof Date ||\n !isObservable(source)\n ) {\n return source\n }\n\n if (isObservableValue(source) || isComputedValue(source)) {\n return toJSHelper(source.get(), __alreadySeen)\n }\n if (__alreadySeen.has(source)) {\n return __alreadySeen.get(source)\n }\n if (isObservableArray(source)) {\n const res = cache(__alreadySeen, source, new Array(source.length))\n source.forEach((value, idx) => {\n res[idx] = toJSHelper(value, __alreadySeen)\n })\n return res\n }\n if (isObservableSet(source)) {\n const res = cache(__alreadySeen, source, new Set())\n source.forEach(value => {\n res.add(toJSHelper(value, __alreadySeen))\n })\n return res\n }\n if (isObservableMap(source)) {\n const res = cache(__alreadySeen, source, new Map())\n source.forEach((value, key) => {\n res.set(key, toJSHelper(value, __alreadySeen))\n })\n return res\n } else {\n // must be observable object\n const res = cache(__alreadySeen, source, {})\n apiOwnKeys(source).forEach((key: any) => {\n if (objectPrototype.propertyIsEnumerable.call(source, key)) {\n res[key] = toJSHelper(source[key], __alreadySeen)\n }\n })\n return res\n }\n}\n\n/**\n * Recursively converts an observable to it's non-observable native counterpart.\n * It does NOT recurse into non-observables, these are left as they are, even if they contain observables.\n * Computed and other non-enumerable properties are completely ignored.\n * Complex scenarios require custom solution, eg implementing `toJSON` or using `serializr` lib.\n */\nexport function toJS(source: T, options?: any): T {\n if (__DEV__ && options) {\n die(\"toJS no longer supports options\")\n }\n return toJSHelper(source, new Map())\n}\n", "import { TraceMode, die, getAtom, globalState } from \"../internal\"\n\nexport function trace(thing?: any, prop?: string, enterBreakPoint?: boolean): void\nexport function trace(thing?: any, enterBreakPoint?: boolean): void\nexport function trace(enterBreakPoint?: boolean): void\nexport function trace(...args: any[]): void {\n if (!__DEV__) {\n return\n }\n let enterBreakPoint = false\n if (typeof args[args.length - 1] === \"boolean\") {\n enterBreakPoint = args.pop()\n }\n const derivation = getAtomFromArgs(args)\n if (!derivation) {\n return die(\n `'trace(break?)' can only be used inside a tracked computed value or a Reaction. Consider passing in the computed value or reaction explicitly`\n )\n }\n if (derivation.isTracing_ === TraceMode.NONE) {\n console.log(`[mobx.trace] '${derivation.name_}' tracing enabled`)\n }\n derivation.isTracing_ = enterBreakPoint ? TraceMode.BREAK : TraceMode.LOG\n}\n\nfunction getAtomFromArgs(args): any {\n switch (args.length) {\n case 0:\n return globalState.trackingDerivation\n case 1:\n return getAtom(args[0])\n case 2:\n return getAtom(args[0], args[1])\n }\n}\n", "import { endBatch, startBatch } from \"../internal\"\n\n/**\n * During a transaction no views are updated until the end of the transaction.\n * The transaction will be run synchronously nonetheless.\n *\n * @param action a function that updates some reactive state\n * @returns any value that was returned by the 'action' parameter.\n */\nexport function transaction(action: () => T, thisArg = undefined): T {\n startBatch()\n try {\n return action.apply(thisArg)\n } finally {\n endBatch()\n }\n}\n", "import {\n $mobx,\n IReactionDisposer,\n Lambda,\n autorun,\n createAction,\n getNextId,\n die,\n allowStateChanges,\n GenericAbortSignal\n} from \"../internal\"\n\nexport interface IWhenOptions {\n name?: string\n timeout?: number\n onError?: (error: any) => void\n signal?: GenericAbortSignal\n}\n\nexport function when(\n predicate: () => boolean,\n opts?: IWhenOptions\n): Promise & { cancel(): void }\nexport function when(\n predicate: () => boolean,\n effect: Lambda,\n opts?: IWhenOptions\n): IReactionDisposer\nexport function when(predicate: any, arg1?: any, arg2?: any): any {\n if (arguments.length === 1 || (arg1 && typeof arg1 === \"object\")) {\n return whenPromise(predicate, arg1)\n }\n return _when(predicate, arg1, arg2 || {})\n}\n\nfunction _when(predicate: () => boolean, effect: Lambda, opts: IWhenOptions): IReactionDisposer {\n let timeoutHandle: any\n if (typeof opts.timeout === \"number\") {\n const error = new Error(\"WHEN_TIMEOUT\")\n timeoutHandle = setTimeout(() => {\n if (!disposer[$mobx].isDisposed_) {\n disposer()\n if (opts.onError) {\n opts.onError(error)\n } else {\n throw error\n }\n }\n }, opts.timeout)\n }\n\n opts.name = __DEV__ ? opts.name || \"When@\" + getNextId() : \"When\"\n const effectAction = createAction(\n __DEV__ ? opts.name + \"-effect\" : \"When-effect\",\n effect as Function\n )\n // eslint-disable-next-line\n var disposer = autorun(r => {\n // predicate should not change state\n let cond = allowStateChanges(false, predicate)\n if (cond) {\n r.dispose()\n if (timeoutHandle) {\n clearTimeout(timeoutHandle)\n }\n effectAction()\n }\n }, opts)\n return disposer\n}\n\nfunction whenPromise(\n predicate: () => boolean,\n opts?: IWhenOptions\n): Promise & { cancel(): void } {\n if (__DEV__ && opts && opts.onError) {\n return die(`the options 'onError' and 'promise' cannot be combined`)\n }\n if (opts?.signal?.aborted) {\n return Object.assign(Promise.reject(new Error(\"WHEN_ABORTED\")), { cancel: () => null })\n }\n let cancel\n let abort\n const res = new Promise((resolve, reject) => {\n let disposer = _when(predicate, resolve as Lambda, { ...opts, onError: reject })\n cancel = () => {\n disposer()\n reject(new Error(\"WHEN_CANCELLED\"))\n }\n abort = () => {\n disposer()\n reject(new Error(\"WHEN_ABORTED\"))\n }\n opts?.signal?.addEventListener?.(\"abort\", abort)\n }).finally(() => opts?.signal?.removeEventListener?.(\"abort\", abort))\n ;(res as any).cancel = cancel\n return res as any\n}\n", "import {\n $mobx,\n IIsObservableObject,\n ObservableObjectAdministration,\n warnAboutProxyRequirement,\n assertProxies,\n die,\n isStringish,\n globalState,\n CreateObservableOptions,\n asObservableObject\n} from \"../internal\"\n\nfunction getAdm(target): ObservableObjectAdministration {\n return target[$mobx]\n}\n\n// Optimization: we don't need the intermediate objects and could have a completely custom administration for DynamicObjects,\n// and skip either the internal values map, or the base object with its property descriptors!\nconst objectProxyTraps: ProxyHandler = {\n has(target: IIsObservableObject, name: PropertyKey): boolean {\n if (__DEV__ && globalState.trackingDerivation) {\n warnAboutProxyRequirement(\n \"detect new properties using the 'in' operator. Use 'has' from 'mobx' instead.\"\n )\n }\n return getAdm(target).has_(name)\n },\n get(target: IIsObservableObject, name: PropertyKey): any {\n return getAdm(target).get_(name)\n },\n set(target: IIsObservableObject, name: PropertyKey, value: any): boolean {\n if (!isStringish(name)) {\n return false\n }\n if (__DEV__ && !getAdm(target).values_.has(name)) {\n warnAboutProxyRequirement(\n \"add a new observable property through direct assignment. Use 'set' from 'mobx' instead.\"\n )\n }\n // null (intercepted) -> true (success)\n return getAdm(target).set_(name, value, true) ?? true\n },\n deleteProperty(target: IIsObservableObject, name: PropertyKey): boolean {\n if (__DEV__) {\n warnAboutProxyRequirement(\n \"delete properties from an observable object. Use 'remove' from 'mobx' instead.\"\n )\n }\n if (!isStringish(name)) {\n return false\n }\n // null (intercepted) -> true (success)\n return getAdm(target).delete_(name, true) ?? true\n },\n defineProperty(\n target: IIsObservableObject,\n name: PropertyKey,\n descriptor: PropertyDescriptor\n ): boolean {\n if (__DEV__) {\n warnAboutProxyRequirement(\n \"define property on an observable object. Use 'defineProperty' from 'mobx' instead.\"\n )\n }\n // null (intercepted) -> true (success)\n return getAdm(target).defineProperty_(name, descriptor) ?? true\n },\n ownKeys(target: IIsObservableObject): ArrayLike {\n if (__DEV__ && globalState.trackingDerivation) {\n warnAboutProxyRequirement(\n \"iterate keys to detect added / removed properties. Use 'keys' from 'mobx' instead.\"\n )\n }\n return getAdm(target).ownKeys_()\n },\n preventExtensions(target) {\n die(13)\n }\n}\n\nexport function asDynamicObservableObject(\n target: any,\n options?: CreateObservableOptions\n): IIsObservableObject {\n assertProxies()\n target = asObservableObject(target, options)\n return (target[$mobx].proxy_ ??= new Proxy(target, objectProxyTraps))\n}\n", "import { Lambda, once, untrackedEnd, untrackedStart, die } from \"../internal\"\n\nexport type IInterceptor = (change: T) => T | null\n\nexport interface IInterceptable {\n interceptors_: IInterceptor[] | undefined\n}\n\nexport function hasInterceptors(interceptable: IInterceptable) {\n return interceptable.interceptors_ !== undefined && interceptable.interceptors_.length > 0\n}\n\nexport function registerInterceptor(\n interceptable: IInterceptable,\n handler: IInterceptor\n): Lambda {\n const interceptors = interceptable.interceptors_ || (interceptable.interceptors_ = [])\n interceptors.push(handler)\n return once(() => {\n const idx = interceptors.indexOf(handler)\n if (idx !== -1) {\n interceptors.splice(idx, 1)\n }\n })\n}\n\nexport function interceptChange(\n interceptable: IInterceptable,\n change: T | null\n): T | null {\n const prevU = untrackedStart()\n try {\n // Interceptor can modify the array, copy it to avoid concurrent modification, see #1950\n const interceptors = [...(interceptable.interceptors_ || [])]\n for (let i = 0, l = interceptors.length; i < l; i++) {\n change = interceptors[i](change)\n if (change && !(change as any).type) {\n die(14)\n }\n if (!change) {\n break\n }\n }\n return change\n } finally {\n untrackedEnd(prevU)\n }\n}\n", "import { Lambda, once, untrackedEnd, untrackedStart } from \"../internal\"\n\nexport interface IListenable {\n changeListeners_: Function[] | undefined\n}\n\nexport function hasListeners(listenable: IListenable) {\n return listenable.changeListeners_ !== undefined && listenable.changeListeners_.length > 0\n}\n\nexport function registerListener(listenable: IListenable, handler: Function): Lambda {\n const listeners = listenable.changeListeners_ || (listenable.changeListeners_ = [])\n listeners.push(handler)\n return once(() => {\n const idx = listeners.indexOf(handler)\n if (idx !== -1) {\n listeners.splice(idx, 1)\n }\n })\n}\n\nexport function notifyListeners(listenable: IListenable, change: T) {\n const prevU = untrackedStart()\n let listeners = listenable.changeListeners_\n if (!listeners) {\n return\n }\n listeners = listeners.slice()\n for (let i = 0, l = listeners.length; i < l; i++) {\n listeners[i](change)\n }\n untrackedEnd(prevU)\n}\n", "import {\n $mobx,\n asObservableObject,\n AnnotationsMap,\n CreateObservableOptions,\n ObservableObjectAdministration,\n collectStoredAnnotations,\n isPlainObject,\n isObservableObject,\n die,\n ownKeys,\n extendObservable,\n addHiddenProp,\n storedAnnotationsSymbol,\n initObservable\n} from \"../internal\"\n\n// Hack based on https://github.com/Microsoft/TypeScript/issues/14829#issuecomment-322267089\n// We need this, because otherwise, AdditionalKeys is going to be inferred to be any\n// set of superfluous keys. But, we rather want to get a compile error unless AdditionalKeys is\n// _explicity_ passed as generic argument\n// Fixes: https://github.com/mobxjs/mobx/issues/2325#issuecomment-691070022\ntype NoInfer = [T][T extends any ? 0 : never]\n\ntype MakeObservableOptions = Omit\n\nexport function makeObservable(\n target: T,\n annotations?: AnnotationsMap>,\n options?: MakeObservableOptions\n): T {\n initObservable(() => {\n const adm: ObservableObjectAdministration = asObservableObject(target, options)[$mobx]\n if (__DEV__ && annotations && target[storedAnnotationsSymbol]) {\n die(\n `makeObservable second arg must be nullish when using decorators. Mixing @decorator syntax with annotations is not supported.`\n )\n }\n // Default to decorators\n annotations ??= collectStoredAnnotations(target)\n\n // Annotate\n ownKeys(annotations).forEach(key => adm.make_(key, annotations![key]))\n })\n return target\n}\n\n// proto[keysSymbol] = new Set()\nconst keysSymbol = Symbol(\"mobx-keys\")\n\nexport function makeAutoObservable(\n target: T,\n overrides?: AnnotationsMap>,\n options?: MakeObservableOptions\n): T {\n if (__DEV__) {\n if (!isPlainObject(target) && !isPlainObject(Object.getPrototypeOf(target))) {\n die(`'makeAutoObservable' can only be used for classes that don't have a superclass`)\n }\n if (isObservableObject(target)) {\n die(`makeAutoObservable can only be used on objects not already made observable`)\n }\n }\n\n // Optimization: avoid visiting protos\n // Assumes that annotation.make_/.extend_ works the same for plain objects\n if (isPlainObject(target)) {\n return extendObservable(target, target, overrides, options)\n }\n\n initObservable(() => {\n const adm: ObservableObjectAdministration = asObservableObject(target, options)[$mobx]\n\n // Optimization: cache keys on proto\n // Assumes makeAutoObservable can be called only once per object and can't be used in subclass\n if (!target[keysSymbol]) {\n const proto = Object.getPrototypeOf(target)\n const keys = new Set([...ownKeys(target), ...ownKeys(proto)])\n keys.delete(\"constructor\")\n keys.delete($mobx)\n addHiddenProp(proto, keysSymbol, keys)\n }\n\n target[keysSymbol].forEach(key =>\n adm.make_(\n key,\n // must pass \"undefined\" for { key: undefined }\n !overrides ? true : key in overrides ? overrides[key] : true\n )\n )\n })\n\n return target\n}\n", "import {\n $mobx,\n Atom,\n EMPTY_ARRAY,\n IAtom,\n IEnhancer,\n IInterceptable,\n IInterceptor,\n IListenable,\n Lambda,\n addHiddenFinalProp,\n checkIfStateModificationsAreAllowed,\n createInstanceofPredicate,\n getNextId,\n hasInterceptors,\n hasListeners,\n interceptChange,\n isObject,\n isSpyEnabled,\n notifyListeners,\n registerInterceptor,\n registerListener,\n spyReportEnd,\n spyReportStart,\n assertProxies,\n reserveArrayBuffer,\n hasProp,\n die,\n globalState,\n initObservable\n} from \"../internal\"\n\nconst SPLICE = \"splice\"\nexport const UPDATE = \"update\"\nexport const MAX_SPLICE_SIZE = 10000 // See e.g. https://github.com/mobxjs/mobx/issues/859\n\nexport interface IObservableArray extends Array {\n spliceWithArray(index: number, deleteCount?: number, newItems?: T[]): T[]\n clear(): T[]\n replace(newItems: T[]): T[]\n remove(value: T): boolean\n toJSON(): T[]\n}\n\ninterface IArrayBaseChange {\n object: IObservableArray\n observableKind: \"array\"\n debugObjectName: string\n index: number\n}\n\nexport type IArrayDidChange = IArrayUpdate | IArraySplice\n\nexport interface IArrayUpdate extends IArrayBaseChange {\n type: \"update\"\n newValue: T\n oldValue: T\n}\n\nexport interface IArraySplice extends IArrayBaseChange {\n type: \"splice\"\n added: T[]\n addedCount: number\n removed: T[]\n removedCount: number\n}\n\nexport interface IArrayWillChange {\n object: IObservableArray\n index: number\n type: \"update\"\n newValue: T\n}\n\nexport interface IArrayWillSplice {\n object: IObservableArray\n index: number\n type: \"splice\"\n added: T[]\n removedCount: number\n}\n\nconst arrayTraps = {\n get(target, name) {\n const adm: ObservableArrayAdministration = target[$mobx]\n if (name === $mobx) {\n return adm\n }\n if (name === \"length\") {\n return adm.getArrayLength_()\n }\n if (typeof name === \"string\" && !isNaN(name as any)) {\n return adm.get_(parseInt(name))\n }\n if (hasProp(arrayExtensions, name)) {\n return arrayExtensions[name]\n }\n return target[name]\n },\n set(target, name, value): boolean {\n const adm: ObservableArrayAdministration = target[$mobx]\n if (name === \"length\") {\n adm.setArrayLength_(value)\n }\n if (typeof name === \"symbol\" || isNaN(name)) {\n target[name] = value\n } else {\n // numeric string\n adm.set_(parseInt(name), value)\n }\n return true\n },\n preventExtensions() {\n die(15)\n }\n}\n\nexport class ObservableArrayAdministration\n implements IInterceptable | IArrayWillSplice>, IListenable\n{\n atom_: IAtom\n readonly values_: any[] = [] // this is the prop that gets proxied, so can't replace it!\n interceptors_\n changeListeners_\n enhancer_: (newV: any, oldV: any | undefined) => any\n dehancer: any\n proxy_!: IObservableArray\n lastKnownLength_ = 0\n\n constructor(\n name = __DEV__ ? \"ObservableArray@\" + getNextId() : \"ObservableArray\",\n enhancer: IEnhancer,\n public owned_: boolean,\n public legacyMode_: boolean\n ) {\n this.atom_ = new Atom(name)\n this.enhancer_ = (newV, oldV) =>\n enhancer(newV, oldV, __DEV__ ? name + \"[..]\" : \"ObservableArray[..]\")\n }\n\n dehanceValue_(value: any): any {\n if (this.dehancer !== undefined) {\n return this.dehancer(value)\n }\n return value\n }\n\n dehanceValues_(values: any[]): any[] {\n if (this.dehancer !== undefined && values.length > 0) {\n return values.map(this.dehancer) as any\n }\n return values\n }\n\n intercept_(handler: IInterceptor | IArrayWillSplice>): Lambda {\n return registerInterceptor | IArrayWillSplice>(this, handler)\n }\n\n observe_(\n listener: (changeData: IArrayDidChange) => void,\n fireImmediately = false\n ): Lambda {\n if (fireImmediately) {\n listener(>{\n observableKind: \"array\",\n object: this.proxy_ as any,\n debugObjectName: this.atom_.name_,\n type: \"splice\",\n index: 0,\n added: this.values_.slice(),\n addedCount: this.values_.length,\n removed: [],\n removedCount: 0\n })\n }\n return registerListener(this, listener)\n }\n\n getArrayLength_(): number {\n this.atom_.reportObserved()\n return this.values_.length\n }\n\n setArrayLength_(newLength: number) {\n if (typeof newLength !== \"number\" || isNaN(newLength) || newLength < 0) {\n die(\"Out of range: \" + newLength)\n }\n let currentLength = this.values_.length\n if (newLength === currentLength) {\n return\n } else if (newLength > currentLength) {\n const newItems = new Array(newLength - currentLength)\n for (let i = 0; i < newLength - currentLength; i++) {\n newItems[i] = undefined\n } // No Array.fill everywhere...\n this.spliceWithArray_(currentLength, 0, newItems)\n } else {\n this.spliceWithArray_(newLength, currentLength - newLength)\n }\n }\n\n updateArrayLength_(oldLength: number, delta: number) {\n if (oldLength !== this.lastKnownLength_) {\n die(16)\n }\n this.lastKnownLength_ += delta\n if (this.legacyMode_ && delta > 0) {\n reserveArrayBuffer(oldLength + delta + 1)\n }\n }\n\n spliceWithArray_(index: number, deleteCount?: number, newItems?: any[]): any[] {\n checkIfStateModificationsAreAllowed(this.atom_)\n const length = this.values_.length\n\n if (index === undefined) {\n index = 0\n } else if (index > length) {\n index = length\n } else if (index < 0) {\n index = Math.max(0, length + index)\n }\n\n if (arguments.length === 1) {\n deleteCount = length - index\n } else if (deleteCount === undefined || deleteCount === null) {\n deleteCount = 0\n } else {\n deleteCount = Math.max(0, Math.min(deleteCount, length - index))\n }\n\n if (newItems === undefined) {\n newItems = EMPTY_ARRAY\n }\n\n if (hasInterceptors(this)) {\n const change = interceptChange>(this as any, {\n object: this.proxy_ as any,\n type: SPLICE,\n index,\n removedCount: deleteCount,\n added: newItems\n })\n if (!change) {\n return EMPTY_ARRAY\n }\n deleteCount = change.removedCount\n newItems = change.added\n }\n\n newItems =\n newItems.length === 0 ? newItems : newItems.map(v => this.enhancer_(v, undefined))\n if (this.legacyMode_ || __DEV__) {\n const lengthDelta = newItems.length - deleteCount\n this.updateArrayLength_(length, lengthDelta) // checks if internal array wasn't modified\n }\n const res = this.spliceItemsIntoValues_(index, deleteCount, newItems)\n\n if (deleteCount !== 0 || newItems.length !== 0) {\n this.notifyArraySplice_(index, newItems, res)\n }\n return this.dehanceValues_(res)\n }\n\n spliceItemsIntoValues_(index: number, deleteCount: number, newItems: any[]): any[] {\n if (newItems.length < MAX_SPLICE_SIZE) {\n return this.values_.splice(index, deleteCount, ...newItems)\n } else {\n // The items removed by the splice\n const res = this.values_.slice(index, index + deleteCount)\n // The items that that should remain at the end of the array\n let oldItems = this.values_.slice(index + deleteCount)\n // New length is the previous length + addition count - deletion count\n this.values_.length += newItems.length - deleteCount\n for (let i = 0; i < newItems.length; i++) {\n this.values_[index + i] = newItems[i]\n }\n for (let i = 0; i < oldItems.length; i++) {\n this.values_[index + newItems.length + i] = oldItems[i]\n }\n return res\n }\n }\n\n notifyArrayChildUpdate_(index: number, newValue: any, oldValue: any) {\n const notifySpy = !this.owned_ && isSpyEnabled()\n const notify = hasListeners(this)\n const change: IArrayDidChange | null =\n notify || notifySpy\n ? ({\n observableKind: \"array\",\n object: this.proxy_,\n type: UPDATE,\n debugObjectName: this.atom_.name_,\n index,\n newValue,\n oldValue\n } as const)\n : null\n\n // The reason why this is on right hand side here (and not above), is this way the uglifier will drop it, but it won't\n // cause any runtime overhead in development mode without NODE_ENV set, unless spying is enabled\n if (__DEV__ && notifySpy) {\n spyReportStart(change!)\n }\n this.atom_.reportChanged()\n if (notify) {\n notifyListeners(this, change)\n }\n if (__DEV__ && notifySpy) {\n spyReportEnd()\n }\n }\n\n notifyArraySplice_(index: number, added: any[], removed: any[]) {\n const notifySpy = !this.owned_ && isSpyEnabled()\n const notify = hasListeners(this)\n const change: IArraySplice | null =\n notify || notifySpy\n ? ({\n observableKind: \"array\",\n object: this.proxy_,\n debugObjectName: this.atom_.name_,\n type: SPLICE,\n index,\n removed,\n added,\n removedCount: removed.length,\n addedCount: added.length\n } as const)\n : null\n\n if (__DEV__ && notifySpy) {\n spyReportStart(change!)\n }\n this.atom_.reportChanged()\n // conform: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/observe\n if (notify) {\n notifyListeners(this, change)\n }\n if (__DEV__ && notifySpy) {\n spyReportEnd()\n }\n }\n\n get_(index: number): any | undefined {\n if (this.legacyMode_ && index >= this.values_.length) {\n console.warn(\n __DEV__\n ? `[mobx.array] Attempt to read an array index (${index}) that is out of bounds (${this.values_.length}). Please check length first. Out of bound indices will not be tracked by MobX`\n : `[mobx] Out of bounds read: ${index}`\n )\n return undefined\n }\n this.atom_.reportObserved()\n return this.dehanceValue_(this.values_[index])\n }\n\n set_(index: number, newValue: any) {\n const values = this.values_\n if (this.legacyMode_ && index > values.length) {\n // out of bounds\n die(17, index, values.length)\n }\n if (index < values.length) {\n // update at index in range\n checkIfStateModificationsAreAllowed(this.atom_)\n const oldValue = values[index]\n if (hasInterceptors(this)) {\n const change = interceptChange>(this as any, {\n type: UPDATE,\n object: this.proxy_ as any, // since \"this\" is the real array we need to pass its proxy\n index,\n newValue\n })\n if (!change) {\n return\n }\n newValue = change.newValue\n }\n newValue = this.enhancer_(newValue, oldValue)\n const changed = newValue !== oldValue\n if (changed) {\n values[index] = newValue\n this.notifyArrayChildUpdate_(index, newValue, oldValue)\n }\n } else {\n // For out of bound index, we don't create an actual sparse array,\n // but rather fill the holes with undefined (same as setArrayLength_).\n // This could be considered a bug.\n const newItems = new Array(index + 1 - values.length)\n for (let i = 0; i < newItems.length - 1; i++) {\n newItems[i] = undefined\n } // No Array.fill everywhere...\n newItems[newItems.length - 1] = newValue\n this.spliceWithArray_(values.length, 0, newItems)\n }\n }\n}\n\nexport function createObservableArray(\n initialValues: T[] | undefined,\n enhancer: IEnhancer,\n name = __DEV__ ? \"ObservableArray@\" + getNextId() : \"ObservableArray\",\n owned = false\n): IObservableArray {\n assertProxies()\n return initObservable(() => {\n const adm = new ObservableArrayAdministration(name, enhancer, owned, false)\n addHiddenFinalProp(adm.values_, $mobx, adm)\n const proxy = new Proxy(adm.values_, arrayTraps) as any\n adm.proxy_ = proxy\n if (initialValues && initialValues.length) {\n adm.spliceWithArray_(0, 0, initialValues)\n }\n return proxy\n })\n}\n\n// eslint-disable-next-line\nexport var arrayExtensions = {\n clear(): any[] {\n return this.splice(0)\n },\n\n replace(newItems: any[]) {\n const adm: ObservableArrayAdministration = this[$mobx]\n return adm.spliceWithArray_(0, adm.values_.length, newItems)\n },\n\n // Used by JSON.stringify\n toJSON(): any[] {\n return this.slice()\n },\n\n /*\n * functions that do alter the internal structure of the array, (based on lib.es6.d.ts)\n * since these functions alter the inner structure of the array, the have side effects.\n * Because the have side effects, they should not be used in computed function,\n * and for that reason the do not call dependencyState.notifyObserved\n */\n splice(index: number, deleteCount?: number, ...newItems: any[]): any[] {\n const adm: ObservableArrayAdministration = this[$mobx]\n switch (arguments.length) {\n case 0:\n return []\n case 1:\n return adm.spliceWithArray_(index)\n case 2:\n return adm.spliceWithArray_(index, deleteCount)\n }\n return adm.spliceWithArray_(index, deleteCount, newItems)\n },\n\n spliceWithArray(index: number, deleteCount?: number, newItems?: any[]): any[] {\n return (this[$mobx] as ObservableArrayAdministration).spliceWithArray_(\n index,\n deleteCount,\n newItems\n )\n },\n\n push(...items: any[]): number {\n const adm: ObservableArrayAdministration = this[$mobx]\n adm.spliceWithArray_(adm.values_.length, 0, items)\n return adm.values_.length\n },\n\n pop() {\n return this.splice(Math.max(this[$mobx].values_.length - 1, 0), 1)[0]\n },\n\n shift() {\n return this.splice(0, 1)[0]\n },\n\n unshift(...items: any[]): number {\n const adm: ObservableArrayAdministration = this[$mobx]\n adm.spliceWithArray_(0, 0, items)\n return adm.values_.length\n },\n\n reverse(): any[] {\n // reverse by default mutates in place before returning the result\n // which makes it both a 'derivation' and a 'mutation'.\n if (globalState.trackingDerivation) {\n die(37, \"reverse\")\n }\n this.replace(this.slice().reverse())\n return this\n },\n\n sort(): any[] {\n // sort by default mutates in place before returning the result\n // which goes against all good practices. Let's not change the array in place!\n if (globalState.trackingDerivation) {\n die(37, \"sort\")\n }\n const copy = this.slice()\n copy.sort.apply(copy, arguments)\n this.replace(copy)\n return this\n },\n\n remove(value: any): boolean {\n const adm: ObservableArrayAdministration = this[$mobx]\n const idx = adm.dehanceValues_(adm.values_).indexOf(value)\n if (idx > -1) {\n this.splice(idx, 1)\n return true\n }\n return false\n }\n}\n\n/**\n * Wrap function from prototype\n * Without this, everything works as well, but this works\n * faster as everything works on unproxied values\n */\naddArrayExtension(\"at\", simpleFunc)\naddArrayExtension(\"concat\", simpleFunc)\naddArrayExtension(\"flat\", simpleFunc)\naddArrayExtension(\"includes\", simpleFunc)\naddArrayExtension(\"indexOf\", simpleFunc)\naddArrayExtension(\"join\", simpleFunc)\naddArrayExtension(\"lastIndexOf\", simpleFunc)\naddArrayExtension(\"slice\", simpleFunc)\naddArrayExtension(\"toString\", simpleFunc)\naddArrayExtension(\"toLocaleString\", simpleFunc)\naddArrayExtension(\"toSorted\", simpleFunc)\naddArrayExtension(\"toSpliced\", simpleFunc)\naddArrayExtension(\"with\", simpleFunc)\n// map\naddArrayExtension(\"every\", mapLikeFunc)\naddArrayExtension(\"filter\", mapLikeFunc)\naddArrayExtension(\"find\", mapLikeFunc)\naddArrayExtension(\"findIndex\", mapLikeFunc)\naddArrayExtension(\"findLast\", mapLikeFunc)\naddArrayExtension(\"findLastIndex\", mapLikeFunc)\naddArrayExtension(\"flatMap\", mapLikeFunc)\naddArrayExtension(\"forEach\", mapLikeFunc)\naddArrayExtension(\"map\", mapLikeFunc)\naddArrayExtension(\"some\", mapLikeFunc)\naddArrayExtension(\"toReversed\", mapLikeFunc)\n// reduce\naddArrayExtension(\"reduce\", reduceLikeFunc)\naddArrayExtension(\"reduceRight\", reduceLikeFunc)\n\nfunction addArrayExtension(funcName, funcFactory) {\n if (typeof Array.prototype[funcName] === \"function\") {\n arrayExtensions[funcName] = funcFactory(funcName)\n }\n}\n\n// Report and delegate to dehanced array\nfunction simpleFunc(funcName) {\n return function () {\n const adm: ObservableArrayAdministration = this[$mobx]\n adm.atom_.reportObserved()\n const dehancedValues = adm.dehanceValues_(adm.values_)\n return dehancedValues[funcName].apply(dehancedValues, arguments)\n }\n}\n\n// Make sure callbacks receive correct array arg #2326\nfunction mapLikeFunc(funcName) {\n return function (callback, thisArg) {\n const adm: ObservableArrayAdministration = this[$mobx]\n adm.atom_.reportObserved()\n const dehancedValues = adm.dehanceValues_(adm.values_)\n return dehancedValues[funcName]((element, index) => {\n return callback.call(thisArg, element, index, this)\n })\n }\n}\n\n// Make sure callbacks receive correct array arg #2326\nfunction reduceLikeFunc(funcName) {\n return function () {\n const adm: ObservableArrayAdministration = this[$mobx]\n adm.atom_.reportObserved()\n const dehancedValues = adm.dehanceValues_(adm.values_)\n // #2432 - reduce behavior depends on arguments.length\n const callback = arguments[0]\n arguments[0] = (accumulator, currentValue, index) => {\n return callback(accumulator, currentValue, index, this)\n }\n return dehancedValues[funcName].apply(dehancedValues, arguments)\n }\n}\n\nconst isObservableArrayAdministration = createInstanceofPredicate(\n \"ObservableArrayAdministration\",\n ObservableArrayAdministration\n)\n\nexport function isObservableArray(thing): thing is IObservableArray {\n return isObject(thing) && isObservableArrayAdministration(thing[$mobx])\n}\n", "import {\n $mobx,\n IEnhancer,\n IInterceptable,\n IInterceptor,\n IListenable,\n Lambda,\n ObservableValue,\n checkIfStateModificationsAreAllowed,\n createAtom,\n createInstanceofPredicate,\n deepEnhancer,\n getNextId,\n getPlainObjectKeys,\n hasInterceptors,\n hasListeners,\n interceptChange,\n isES6Map,\n isPlainObject,\n isSpyEnabled,\n makeIterable,\n notifyListeners,\n referenceEnhancer,\n registerInterceptor,\n registerListener,\n spyReportEnd,\n spyReportStart,\n stringifyKey,\n transaction,\n untracked,\n onBecomeUnobserved,\n globalState,\n die,\n isFunction,\n UPDATE,\n IAtom,\n PureSpyEvent,\n initObservable\n} from \"../internal\"\n\nexport interface IKeyValueMap {\n [key: string]: V\n}\n\nexport type IMapEntry = [K, V]\nexport type IReadonlyMapEntry = readonly [K, V]\nexport type IMapEntries = IMapEntry[]\nexport type IReadonlyMapEntries = IReadonlyMapEntry[]\n\nexport type IMapDidChange = { observableKind: \"map\"; debugObjectName: string } & (\n | {\n object: ObservableMap\n name: K // actual the key or index, but this is based on the ancient .observe proposal for consistency\n type: \"update\"\n newValue: V\n oldValue: V\n }\n | {\n object: ObservableMap\n name: K\n type: \"add\"\n newValue: V\n }\n | {\n object: ObservableMap\n name: K\n type: \"delete\"\n oldValue: V\n }\n)\n\nexport interface IMapWillChange {\n object: ObservableMap\n type: \"update\" | \"add\" | \"delete\"\n name: K\n newValue?: V\n}\n\nconst ObservableMapMarker = {}\n\nexport const ADD = \"add\"\nexport const DELETE = \"delete\"\n\nexport type IObservableMapInitialValues =\n | IMapEntries\n | IReadonlyMapEntries\n | IKeyValueMap\n | Map\n\n// just extend Map? See also https://gist.github.com/nestharus/13b4d74f2ef4a2f4357dbd3fc23c1e54\n// But: https://github.com/mobxjs/mobx/issues/1556\nexport class ObservableMap\n implements Map, IInterceptable>, IListenable\n{\n [$mobx] = ObservableMapMarker\n data_!: Map>\n hasMap_!: Map> // hasMap, not hashMap >-).\n keysAtom_!: IAtom\n interceptors_\n changeListeners_\n dehancer: any\n\n constructor(\n initialData?: IObservableMapInitialValues,\n public enhancer_: IEnhancer = deepEnhancer,\n public name_ = __DEV__ ? \"ObservableMap@\" + getNextId() : \"ObservableMap\"\n ) {\n if (!isFunction(Map)) {\n die(18)\n }\n initObservable(() => {\n this.keysAtom_ = createAtom(__DEV__ ? `${this.name_}.keys()` : \"ObservableMap.keys()\")\n this.data_ = new Map()\n this.hasMap_ = new Map()\n if (initialData) {\n this.merge(initialData)\n }\n })\n }\n\n private has_(key: K): boolean {\n return this.data_.has(key)\n }\n\n has(key: K): boolean {\n if (!globalState.trackingDerivation) {\n return this.has_(key)\n }\n\n let entry = this.hasMap_.get(key)\n if (!entry) {\n const newEntry = (entry = new ObservableValue(\n this.has_(key),\n referenceEnhancer,\n __DEV__ ? `${this.name_}.${stringifyKey(key)}?` : \"ObservableMap.key?\",\n false\n ))\n this.hasMap_.set(key, newEntry)\n onBecomeUnobserved(newEntry, () => this.hasMap_.delete(key))\n }\n\n return entry.get()\n }\n\n set(key: K, value: V) {\n const hasKey = this.has_(key)\n if (hasInterceptors(this)) {\n const change = interceptChange>(this, {\n type: hasKey ? UPDATE : ADD,\n object: this,\n newValue: value,\n name: key\n })\n if (!change) {\n return this\n }\n value = change.newValue!\n }\n if (hasKey) {\n this.updateValue_(key, value)\n } else {\n this.addValue_(key, value)\n }\n return this\n }\n\n delete(key: K): boolean {\n checkIfStateModificationsAreAllowed(this.keysAtom_)\n if (hasInterceptors(this)) {\n const change = interceptChange>(this, {\n type: DELETE,\n object: this,\n name: key\n })\n if (!change) {\n return false\n }\n }\n if (this.has_(key)) {\n const notifySpy = isSpyEnabled()\n const notify = hasListeners(this)\n const change: IMapDidChange | null =\n notify || notifySpy\n ? {\n observableKind: \"map\",\n debugObjectName: this.name_,\n type: DELETE,\n object: this,\n oldValue: (this.data_.get(key)).value_,\n name: key\n }\n : null\n\n if (__DEV__ && notifySpy) {\n spyReportStart(change! as PureSpyEvent)\n } // TODO fix type\n transaction(() => {\n this.keysAtom_.reportChanged()\n this.hasMap_.get(key)?.setNewValue_(false)\n const observable = this.data_.get(key)!\n observable.setNewValue_(undefined as any)\n this.data_.delete(key)\n })\n if (notify) {\n notifyListeners(this, change)\n }\n if (__DEV__ && notifySpy) {\n spyReportEnd()\n }\n return true\n }\n return false\n }\n\n private updateValue_(key: K, newValue: V | undefined) {\n const observable = this.data_.get(key)!\n newValue = (observable as any).prepareNewValue_(newValue) as V\n if (newValue !== globalState.UNCHANGED) {\n const notifySpy = isSpyEnabled()\n const notify = hasListeners(this)\n const change: IMapDidChange | null =\n notify || notifySpy\n ? {\n observableKind: \"map\",\n debugObjectName: this.name_,\n type: UPDATE,\n object: this,\n oldValue: (observable as any).value_,\n name: key,\n newValue\n }\n : null\n if (__DEV__ && notifySpy) {\n spyReportStart(change! as PureSpyEvent)\n } // TODO fix type\n observable.setNewValue_(newValue as V)\n if (notify) {\n notifyListeners(this, change)\n }\n if (__DEV__ && notifySpy) {\n spyReportEnd()\n }\n }\n }\n\n private addValue_(key: K, newValue: V) {\n checkIfStateModificationsAreAllowed(this.keysAtom_)\n transaction(() => {\n const observable = new ObservableValue(\n newValue,\n this.enhancer_,\n __DEV__ ? `${this.name_}.${stringifyKey(key)}` : \"ObservableMap.key\",\n false\n )\n this.data_.set(key, observable)\n newValue = (observable as any).value_ // value might have been changed\n this.hasMap_.get(key)?.setNewValue_(true)\n this.keysAtom_.reportChanged()\n })\n const notifySpy = isSpyEnabled()\n const notify = hasListeners(this)\n const change: IMapDidChange | null =\n notify || notifySpy\n ? {\n observableKind: \"map\",\n debugObjectName: this.name_,\n type: ADD,\n object: this,\n name: key,\n newValue\n }\n : null\n if (__DEV__ && notifySpy) {\n spyReportStart(change! as PureSpyEvent)\n } // TODO fix type\n if (notify) {\n notifyListeners(this, change)\n }\n if (__DEV__ && notifySpy) {\n spyReportEnd()\n }\n }\n\n get(key: K): V | undefined {\n if (this.has(key)) {\n return this.dehanceValue_(this.data_.get(key)!.get())\n }\n return this.dehanceValue_(undefined)\n }\n\n private dehanceValue_(value: X): X {\n if (this.dehancer !== undefined) {\n return this.dehancer(value)\n }\n return value\n }\n\n keys(): IterableIterator {\n this.keysAtom_.reportObserved()\n return this.data_.keys()\n }\n\n values(): IterableIterator {\n const self = this\n const keys = this.keys()\n return makeIterable({\n next() {\n const { done, value } = keys.next()\n return {\n done,\n value: done ? (undefined as any) : self.get(value)\n }\n }\n })\n }\n\n entries(): IterableIterator> {\n const self = this\n const keys = this.keys()\n return makeIterable({\n next() {\n const { done, value } = keys.next()\n return {\n done,\n value: done ? (undefined as any) : ([value, self.get(value)!] as [K, V])\n }\n }\n })\n }\n\n [Symbol.iterator]() {\n return this.entries()\n }\n\n forEach(callback: (value: V, key: K, object: Map) => void, thisArg?) {\n for (const [key, value] of this) {\n callback.call(thisArg, value, key, this)\n }\n }\n\n /** Merge another object into this object, returns this. */\n merge(other?: IObservableMapInitialValues): ObservableMap {\n if (isObservableMap(other)) {\n other = new Map(other)\n }\n transaction(() => {\n if (isPlainObject(other)) {\n getPlainObjectKeys(other).forEach((key: any) =>\n this.set(key as K, (other as IKeyValueMap)[key])\n )\n } else if (Array.isArray(other)) {\n other.forEach(([key, value]) => this.set(key, value))\n } else if (isES6Map(other)) {\n if (other.constructor !== Map) {\n die(19, other)\n }\n other.forEach((value, key) => this.set(key, value))\n } else if (other !== null && other !== undefined) {\n die(20, other)\n }\n })\n return this\n }\n\n clear() {\n transaction(() => {\n untracked(() => {\n for (const key of this.keys()) {\n this.delete(key)\n }\n })\n })\n }\n\n replace(values: IObservableMapInitialValues): ObservableMap {\n // Implementation requirements:\n // - respect ordering of replacement map\n // - allow interceptors to run and potentially prevent individual operations\n // - don't recreate observables that already exist in original map (so we don't destroy existing subscriptions)\n // - don't _keysAtom.reportChanged if the keys of resulting map are indentical (order matters!)\n // - note that result map may differ from replacement map due to the interceptors\n transaction(() => {\n // Convert to map so we can do quick key lookups\n const replacementMap = convertToMap(values)\n const orderedData = new Map()\n // Used for optimization\n let keysReportChangedCalled = false\n // Delete keys that don't exist in replacement map\n // if the key deletion is prevented by interceptor\n // add entry at the beginning of the result map\n for (const key of this.data_.keys()) {\n // Concurrently iterating/deleting keys\n // iterator should handle this correctly\n if (!replacementMap.has(key)) {\n const deleted = this.delete(key)\n // Was the key removed?\n if (deleted) {\n // _keysAtom.reportChanged() was already called\n keysReportChangedCalled = true\n } else {\n // Delete prevented by interceptor\n const value = this.data_.get(key)\n orderedData.set(key, value)\n }\n }\n }\n // Merge entries\n for (const [key, value] of replacementMap.entries()) {\n // We will want to know whether a new key is added\n const keyExisted = this.data_.has(key)\n // Add or update value\n this.set(key, value)\n // The addition could have been prevent by interceptor\n if (this.data_.has(key)) {\n // The update could have been prevented by interceptor\n // and also we want to preserve existing values\n // so use value from _data map (instead of replacement map)\n const value = this.data_.get(key)\n orderedData.set(key, value)\n // Was a new key added?\n if (!keyExisted) {\n // _keysAtom.reportChanged() was already called\n keysReportChangedCalled = true\n }\n }\n }\n // Check for possible key order change\n if (!keysReportChangedCalled) {\n if (this.data_.size !== orderedData.size) {\n // If size differs, keys are definitely modified\n this.keysAtom_.reportChanged()\n } else {\n const iter1 = this.data_.keys()\n const iter2 = orderedData.keys()\n let next1 = iter1.next()\n let next2 = iter2.next()\n while (!next1.done) {\n if (next1.value !== next2.value) {\n this.keysAtom_.reportChanged()\n break\n }\n next1 = iter1.next()\n next2 = iter2.next()\n }\n }\n }\n // Use correctly ordered map\n this.data_ = orderedData\n })\n return this\n }\n\n get size(): number {\n this.keysAtom_.reportObserved()\n return this.data_.size\n }\n\n toString(): string {\n return \"[object ObservableMap]\"\n }\n\n toJSON(): [K, V][] {\n return Array.from(this)\n }\n\n get [Symbol.toStringTag]() {\n return \"Map\"\n }\n\n /**\n * Observes this object. Triggers for the events 'add', 'update' and 'delete'.\n * See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe\n * for callback details\n */\n observe_(listener: (changes: IMapDidChange) => void, fireImmediately?: boolean): Lambda {\n if (__DEV__ && fireImmediately === true) {\n die(\"`observe` doesn't support fireImmediately=true in combination with maps.\")\n }\n return registerListener(this, listener)\n }\n\n intercept_(handler: IInterceptor>): Lambda {\n return registerInterceptor(this, handler)\n }\n}\n\n// eslint-disable-next-line\nexport var isObservableMap = createInstanceofPredicate(\"ObservableMap\", ObservableMap) as (\n thing: any\n) => thing is ObservableMap\n\nfunction convertToMap(dataStructure: any): Map {\n if (isES6Map(dataStructure) || isObservableMap(dataStructure)) {\n return dataStructure\n } else if (Array.isArray(dataStructure)) {\n return new Map(dataStructure)\n } else if (isPlainObject(dataStructure)) {\n const map = new Map()\n for (const key in dataStructure) {\n map.set(key, dataStructure[key])\n }\n return map\n } else {\n return die(21, dataStructure)\n }\n}\n", "import {\n $mobx,\n createAtom,\n deepEnhancer,\n getNextId,\n IEnhancer,\n isSpyEnabled,\n hasListeners,\n IListenable,\n registerListener,\n Lambda,\n spyReportStart,\n notifyListeners,\n spyReportEnd,\n createInstanceofPredicate,\n hasInterceptors,\n interceptChange,\n IInterceptable,\n IInterceptor,\n registerInterceptor,\n checkIfStateModificationsAreAllowed,\n untracked,\n makeIterable,\n transaction,\n isES6Set,\n IAtom,\n DELETE,\n ADD,\n die,\n isFunction,\n initObservable\n} from \"../internal\"\n\nconst ObservableSetMarker = {}\n\nexport type IObservableSetInitialValues = Set | readonly T[]\n\nexport type ISetDidChange =\n | {\n object: ObservableSet\n observableKind: \"set\"\n debugObjectName: string\n type: \"add\"\n newValue: T\n }\n | {\n object: ObservableSet\n observableKind: \"set\"\n debugObjectName: string\n type: \"delete\"\n oldValue: T\n }\n\nexport type ISetWillChange =\n | {\n type: \"delete\"\n object: ObservableSet\n oldValue: T\n }\n | {\n type: \"add\"\n object: ObservableSet\n newValue: T\n }\n\nexport class ObservableSet implements Set, IInterceptable, IListenable {\n [$mobx] = ObservableSetMarker\n private data_: Set = new Set()\n atom_!: IAtom\n changeListeners_\n interceptors_\n dehancer: any\n enhancer_: (newV: any, oldV: any | undefined) => any\n\n constructor(\n initialData?: IObservableSetInitialValues,\n enhancer: IEnhancer = deepEnhancer,\n public name_ = __DEV__ ? \"ObservableSet@\" + getNextId() : \"ObservableSet\"\n ) {\n if (!isFunction(Set)) {\n die(22)\n }\n this.enhancer_ = (newV, oldV) => enhancer(newV, oldV, name_)\n initObservable(() => {\n this.atom_ = createAtom(this.name_)\n if (initialData) {\n this.replace(initialData)\n }\n })\n }\n\n private dehanceValue_(value: X): X {\n if (this.dehancer !== undefined) {\n return this.dehancer(value)\n }\n return value\n }\n\n clear() {\n transaction(() => {\n untracked(() => {\n for (const value of this.data_.values()) {\n this.delete(value)\n }\n })\n })\n }\n\n forEach(callbackFn: (value: T, value2: T, set: Set) => void, thisArg?: any) {\n for (const value of this) {\n callbackFn.call(thisArg, value, value, this)\n }\n }\n\n get size() {\n this.atom_.reportObserved()\n return this.data_.size\n }\n\n add(value: T) {\n checkIfStateModificationsAreAllowed(this.atom_)\n if (hasInterceptors(this)) {\n const change = interceptChange>(this, {\n type: ADD,\n object: this,\n newValue: value\n })\n if (!change) {\n return this\n }\n // ideally, value = change.value would be done here, so that values can be\n // changed by interceptor. Same applies for other Set and Map api's.\n }\n if (!this.has(value)) {\n transaction(() => {\n this.data_.add(this.enhancer_(value, undefined))\n this.atom_.reportChanged()\n })\n const notifySpy = __DEV__ && isSpyEnabled()\n const notify = hasListeners(this)\n const change =\n notify || notifySpy\n ? >{\n observableKind: \"set\",\n debugObjectName: this.name_,\n type: ADD,\n object: this,\n newValue: value\n }\n : null\n if (notifySpy && __DEV__) {\n spyReportStart(change!)\n }\n if (notify) {\n notifyListeners(this, change)\n }\n if (notifySpy && __DEV__) {\n spyReportEnd()\n }\n }\n\n return this\n }\n\n delete(value: T) {\n if (hasInterceptors(this)) {\n const change = interceptChange>(this, {\n type: DELETE,\n object: this,\n oldValue: value\n })\n if (!change) {\n return false\n }\n }\n if (this.has(value)) {\n const notifySpy = __DEV__ && isSpyEnabled()\n const notify = hasListeners(this)\n const change =\n notify || notifySpy\n ? >{\n observableKind: \"set\",\n debugObjectName: this.name_,\n type: DELETE,\n object: this,\n oldValue: value\n }\n : null\n\n if (notifySpy && __DEV__) {\n spyReportStart(change!)\n }\n transaction(() => {\n this.atom_.reportChanged()\n this.data_.delete(value)\n })\n if (notify) {\n notifyListeners(this, change)\n }\n if (notifySpy && __DEV__) {\n spyReportEnd()\n }\n return true\n }\n return false\n }\n\n has(value: T) {\n this.atom_.reportObserved()\n return this.data_.has(this.dehanceValue_(value))\n }\n\n entries() {\n let nextIndex = 0\n const keys = Array.from(this.keys())\n const values = Array.from(this.values())\n return makeIterable<[T, T]>({\n next() {\n const index = nextIndex\n nextIndex += 1\n return index < values.length\n ? { value: [keys[index], values[index]], done: false }\n : { done: true }\n }\n } as any)\n }\n\n keys(): IterableIterator {\n return this.values()\n }\n\n values(): IterableIterator {\n this.atom_.reportObserved()\n const self = this\n let nextIndex = 0\n const observableValues = Array.from(this.data_.values())\n return makeIterable({\n next() {\n return nextIndex < observableValues.length\n ? { value: self.dehanceValue_(observableValues[nextIndex++]), done: false }\n : { done: true }\n }\n } as any)\n }\n\n replace(other: ObservableSet | IObservableSetInitialValues): ObservableSet {\n if (isObservableSet(other)) {\n other = new Set(other)\n }\n\n transaction(() => {\n if (Array.isArray(other)) {\n this.clear()\n other.forEach(value => this.add(value))\n } else if (isES6Set(other)) {\n this.clear()\n other.forEach(value => this.add(value))\n } else if (other !== null && other !== undefined) {\n die(\"Cannot initialize set from \" + other)\n }\n })\n\n return this\n }\n observe_(listener: (changes: ISetDidChange) => void, fireImmediately?: boolean): Lambda {\n // ... 'fireImmediately' could also be true?\n if (__DEV__ && fireImmediately === true) {\n die(\"`observe` doesn't support fireImmediately=true in combination with sets.\")\n }\n return registerListener(this, listener)\n }\n\n intercept_(handler: IInterceptor>): Lambda {\n return registerInterceptor(this, handler)\n }\n\n toJSON(): T[] {\n return Array.from(this)\n }\n\n toString(): string {\n return \"[object ObservableSet]\"\n }\n\n [Symbol.iterator]() {\n return this.values()\n }\n\n get [Symbol.toStringTag]() {\n return \"Set\"\n }\n}\n\n// eslint-disable-next-line\nexport var isObservableSet = createInstanceofPredicate(\"ObservableSet\", ObservableSet) as (\n thing: any\n) => thing is ObservableSet\n", "import {\n CreateObservableOptions,\n getAnnotationFromOptions,\n propagateChanged,\n isAnnotation,\n $mobx,\n Atom,\n Annotation,\n ComputedValue,\n IAtom,\n IComputedValueOptions,\n IEnhancer,\n IInterceptable,\n IListenable,\n Lambda,\n ObservableValue,\n addHiddenProp,\n createInstanceofPredicate,\n endBatch,\n getNextId,\n hasInterceptors,\n hasListeners,\n interceptChange,\n isObject,\n isPlainObject,\n isSpyEnabled,\n notifyListeners,\n referenceEnhancer,\n registerInterceptor,\n registerListener,\n spyReportEnd,\n spyReportStart,\n startBatch,\n stringifyKey,\n globalState,\n ADD,\n UPDATE,\n die,\n hasProp,\n getDescriptor,\n storedAnnotationsSymbol,\n ownKeys,\n isOverride,\n defineProperty,\n autoAnnotation,\n getAdministration,\n getDebugName,\n objectPrototype,\n MakeResult,\n checkIfStateModificationsAreAllowed\n} from \"../internal\"\n\nconst descriptorCache = Object.create(null)\n\nexport type IObjectDidChange = {\n observableKind: \"object\"\n name: PropertyKey\n object: T\n debugObjectName: string\n} & (\n | {\n type: \"add\"\n newValue: any\n }\n | {\n type: \"update\"\n oldValue: any\n newValue: any\n }\n | {\n type: \"remove\"\n oldValue: any\n }\n)\n\nexport type IObjectWillChange =\n | {\n object: T\n type: \"update\" | \"add\"\n name: PropertyKey\n newValue: any\n }\n | {\n object: T\n type: \"remove\"\n name: PropertyKey\n }\n\nconst REMOVE = \"remove\"\n\nexport class ObservableObjectAdministration\n implements IInterceptable, IListenable\n{\n keysAtom_: IAtom\n changeListeners_\n interceptors_\n proxy_: any\n isPlainObject_: boolean\n appliedAnnotations_?: object\n private pendingKeys_: undefined | Map>\n\n constructor(\n public target_: any,\n public values_ = new Map | ComputedValue>(),\n public name_: string,\n // Used anytime annotation is not explicitely provided\n public defaultAnnotation_: Annotation = autoAnnotation\n ) {\n this.keysAtom_ = new Atom(__DEV__ ? `${this.name_}.keys` : \"ObservableObject.keys\")\n // Optimization: we use this frequently\n this.isPlainObject_ = isPlainObject(this.target_)\n if (__DEV__ && !isAnnotation(this.defaultAnnotation_)) {\n die(`defaultAnnotation must be valid annotation`)\n }\n if (__DEV__) {\n // Prepare structure for tracking which fields were already annotated\n this.appliedAnnotations_ = {}\n }\n }\n\n getObservablePropValue_(key: PropertyKey): any {\n return this.values_.get(key)!.get()\n }\n\n setObservablePropValue_(key: PropertyKey, newValue): boolean | null {\n const observable = this.values_.get(key)\n if (observable instanceof ComputedValue) {\n observable.set(newValue)\n return true\n }\n\n // intercept\n if (hasInterceptors(this)) {\n const change = interceptChange(this, {\n type: UPDATE,\n object: this.proxy_ || this.target_,\n name: key,\n newValue\n })\n if (!change) {\n return null\n }\n newValue = (change as any).newValue\n }\n newValue = (observable as any).prepareNewValue_(newValue)\n\n // notify spy & observers\n if (newValue !== globalState.UNCHANGED) {\n const notify = hasListeners(this)\n const notifySpy = __DEV__ && isSpyEnabled()\n const change: IObjectDidChange | null =\n notify || notifySpy\n ? {\n type: UPDATE,\n observableKind: \"object\",\n debugObjectName: this.name_,\n object: this.proxy_ || this.target_,\n oldValue: (observable as any).value_,\n name: key,\n newValue\n }\n : null\n\n if (__DEV__ && notifySpy) {\n spyReportStart(change!)\n }\n ;(observable as ObservableValue).setNewValue_(newValue)\n if (notify) {\n notifyListeners(this, change)\n }\n if (__DEV__ && notifySpy) {\n spyReportEnd()\n }\n }\n return true\n }\n\n get_(key: PropertyKey): any {\n if (globalState.trackingDerivation && !hasProp(this.target_, key)) {\n // Key doesn't exist yet, subscribe for it in case it's added later\n this.has_(key)\n }\n return this.target_[key]\n }\n\n /**\n * @param {PropertyKey} key\n * @param {any} value\n * @param {Annotation|boolean} annotation true - use default annotation, false - copy as is\n * @param {boolean} proxyTrap whether it's called from proxy trap\n * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor\n */\n set_(key: PropertyKey, value: any, proxyTrap: boolean = false): boolean | null {\n // Don't use .has(key) - we care about own\n if (hasProp(this.target_, key)) {\n // Existing prop\n if (this.values_.has(key)) {\n // Observable (can be intercepted)\n return this.setObservablePropValue_(key, value)\n } else if (proxyTrap) {\n // Non-observable - proxy\n return Reflect.set(this.target_, key, value)\n } else {\n // Non-observable\n this.target_[key] = value\n return true\n }\n } else {\n // New prop\n return this.extend_(\n key,\n { value, enumerable: true, writable: true, configurable: true },\n this.defaultAnnotation_,\n proxyTrap\n )\n }\n }\n\n // Trap for \"in\"\n has_(key: PropertyKey): boolean {\n if (!globalState.trackingDerivation) {\n // Skip key subscription outside derivation\n return key in this.target_\n }\n this.pendingKeys_ ||= new Map()\n let entry = this.pendingKeys_.get(key)\n if (!entry) {\n entry = new ObservableValue(\n key in this.target_,\n referenceEnhancer,\n __DEV__ ? `${this.name_}.${stringifyKey(key)}?` : \"ObservableObject.key?\",\n false\n )\n this.pendingKeys_.set(key, entry)\n }\n return entry.get()\n }\n\n /**\n * @param {PropertyKey} key\n * @param {Annotation|boolean} annotation true - use default annotation, false - ignore prop\n */\n make_(key: PropertyKey, annotation: Annotation | boolean): void {\n if (annotation === true) {\n annotation = this.defaultAnnotation_\n }\n if (annotation === false) {\n return\n }\n assertAnnotable(this, annotation, key)\n if (!(key in this.target_)) {\n // Throw on missing key, except for decorators:\n // Decorator annotations are collected from whole prototype chain.\n // When called from super() some props may not exist yet.\n // However we don't have to worry about missing prop,\n // because the decorator must have been applied to something.\n if (this.target_[storedAnnotationsSymbol]?.[key]) {\n return // will be annotated by subclass constructor\n } else {\n die(1, annotation.annotationType_, `${this.name_}.${key.toString()}`)\n }\n }\n let source = this.target_\n while (source && source !== objectPrototype) {\n const descriptor = getDescriptor(source, key)\n if (descriptor) {\n const outcome = annotation.make_(this, key, descriptor, source)\n if (outcome === MakeResult.Cancel) {\n return\n }\n if (outcome === MakeResult.Break) {\n break\n }\n }\n source = Object.getPrototypeOf(source)\n }\n recordAnnotationApplied(this, annotation, key)\n }\n\n /**\n * @param {PropertyKey} key\n * @param {PropertyDescriptor} descriptor\n * @param {Annotation|boolean} annotation true - use default annotation, false - copy as is\n * @param {boolean} proxyTrap whether it's called from proxy trap\n * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor\n */\n extend_(\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n annotation: Annotation | boolean,\n proxyTrap: boolean = false\n ): boolean | null {\n if (annotation === true) {\n annotation = this.defaultAnnotation_\n }\n if (annotation === false) {\n return this.defineProperty_(key, descriptor, proxyTrap)\n }\n assertAnnotable(this, annotation, key)\n const outcome = annotation.extend_(this, key, descriptor, proxyTrap)\n if (outcome) {\n recordAnnotationApplied(this, annotation, key)\n }\n return outcome\n }\n\n /**\n * @param {PropertyKey} key\n * @param {PropertyDescriptor} descriptor\n * @param {boolean} proxyTrap whether it's called from proxy trap\n * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor\n */\n defineProperty_(\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n proxyTrap: boolean = false\n ): boolean | null {\n checkIfStateModificationsAreAllowed(this.keysAtom_)\n try {\n startBatch()\n\n // Delete\n const deleteOutcome = this.delete_(key)\n if (!deleteOutcome) {\n // Failure or intercepted\n return deleteOutcome\n }\n\n // ADD interceptor\n if (hasInterceptors(this)) {\n const change = interceptChange(this, {\n object: this.proxy_ || this.target_,\n name: key,\n type: ADD,\n newValue: descriptor.value\n })\n if (!change) {\n return null\n }\n const { newValue } = change as any\n if (descriptor.value !== newValue) {\n descriptor = {\n ...descriptor,\n value: newValue\n }\n }\n }\n\n // Define\n if (proxyTrap) {\n if (!Reflect.defineProperty(this.target_, key, descriptor)) {\n return false\n }\n } else {\n defineProperty(this.target_, key, descriptor)\n }\n\n // Notify\n this.notifyPropertyAddition_(key, descriptor.value)\n } finally {\n endBatch()\n }\n return true\n }\n\n // If original descriptor becomes relevant, move this to annotation directly\n defineObservableProperty_(\n key: PropertyKey,\n value: any,\n enhancer: IEnhancer,\n proxyTrap: boolean = false\n ): boolean | null {\n checkIfStateModificationsAreAllowed(this.keysAtom_)\n try {\n startBatch()\n\n // Delete\n const deleteOutcome = this.delete_(key)\n if (!deleteOutcome) {\n // Failure or intercepted\n return deleteOutcome\n }\n\n // ADD interceptor\n if (hasInterceptors(this)) {\n const change = interceptChange(this, {\n object: this.proxy_ || this.target_,\n name: key,\n type: ADD,\n newValue: value\n })\n if (!change) {\n return null\n }\n value = (change as any).newValue\n }\n\n const cachedDescriptor = getCachedObservablePropDescriptor(key)\n const descriptor = {\n configurable: globalState.safeDescriptors ? this.isPlainObject_ : true,\n enumerable: true,\n get: cachedDescriptor.get,\n set: cachedDescriptor.set\n }\n\n // Define\n if (proxyTrap) {\n if (!Reflect.defineProperty(this.target_, key, descriptor)) {\n return false\n }\n } else {\n defineProperty(this.target_, key, descriptor)\n }\n\n const observable = new ObservableValue(\n value,\n enhancer,\n __DEV__ ? `${this.name_}.${key.toString()}` : \"ObservableObject.key\",\n false\n )\n\n this.values_.set(key, observable)\n\n // Notify (value possibly changed by ObservableValue)\n this.notifyPropertyAddition_(key, observable.value_)\n } finally {\n endBatch()\n }\n return true\n }\n\n // If original descriptor becomes relevant, move this to annotation directly\n defineComputedProperty_(\n key: PropertyKey,\n options: IComputedValueOptions,\n proxyTrap: boolean = false\n ): boolean | null {\n checkIfStateModificationsAreAllowed(this.keysAtom_)\n try {\n startBatch()\n\n // Delete\n const deleteOutcome = this.delete_(key)\n if (!deleteOutcome) {\n // Failure or intercepted\n return deleteOutcome\n }\n\n // ADD interceptor\n if (hasInterceptors(this)) {\n const change = interceptChange(this, {\n object: this.proxy_ || this.target_,\n name: key,\n type: ADD,\n newValue: undefined\n })\n if (!change) {\n return null\n }\n }\n options.name ||= __DEV__ ? `${this.name_}.${key.toString()}` : \"ObservableObject.key\"\n options.context = this.proxy_ || this.target_\n const cachedDescriptor = getCachedObservablePropDescriptor(key)\n const descriptor = {\n configurable: globalState.safeDescriptors ? this.isPlainObject_ : true,\n enumerable: false,\n get: cachedDescriptor.get,\n set: cachedDescriptor.set\n }\n\n // Define\n if (proxyTrap) {\n if (!Reflect.defineProperty(this.target_, key, descriptor)) {\n return false\n }\n } else {\n defineProperty(this.target_, key, descriptor)\n }\n\n this.values_.set(key, new ComputedValue(options))\n\n // Notify\n this.notifyPropertyAddition_(key, undefined)\n } finally {\n endBatch()\n }\n return true\n }\n\n /**\n * @param {PropertyKey} key\n * @param {PropertyDescriptor} descriptor\n * @param {boolean} proxyTrap whether it's called from proxy trap\n * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor\n */\n delete_(key: PropertyKey, proxyTrap: boolean = false): boolean | null {\n checkIfStateModificationsAreAllowed(this.keysAtom_)\n // No such prop\n if (!hasProp(this.target_, key)) {\n return true\n }\n\n // Intercept\n if (hasInterceptors(this)) {\n const change = interceptChange(this, {\n object: this.proxy_ || this.target_,\n name: key,\n type: REMOVE\n })\n // Cancelled\n if (!change) {\n return null\n }\n }\n\n // Delete\n try {\n startBatch()\n const notify = hasListeners(this)\n const notifySpy = __DEV__ && isSpyEnabled()\n const observable = this.values_.get(key)\n // Value needed for spies/listeners\n let value = undefined\n // Optimization: don't pull the value unless we will need it\n if (!observable && (notify || notifySpy)) {\n value = getDescriptor(this.target_, key)?.value\n }\n // delete prop (do first, may fail)\n if (proxyTrap) {\n if (!Reflect.deleteProperty(this.target_, key)) {\n return false\n }\n } else {\n delete this.target_[key]\n }\n // Allow re-annotating this field\n if (__DEV__) {\n delete this.appliedAnnotations_![key]\n }\n // Clear observable\n if (observable) {\n this.values_.delete(key)\n // for computed, value is undefined\n if (observable instanceof ObservableValue) {\n value = observable.value_\n }\n // Notify: autorun(() => obj[key]), see #1796\n propagateChanged(observable)\n }\n // Notify \"keys/entries/values\" observers\n this.keysAtom_.reportChanged()\n\n // Notify \"has\" observers\n // \"in\" as it may still exist in proto\n this.pendingKeys_?.get(key)?.set(key in this.target_)\n\n // Notify spies/listeners\n if (notify || notifySpy) {\n const change: IObjectDidChange = {\n type: REMOVE,\n observableKind: \"object\",\n object: this.proxy_ || this.target_,\n debugObjectName: this.name_,\n oldValue: value,\n name: key\n }\n if (__DEV__ && notifySpy) {\n spyReportStart(change!)\n }\n if (notify) {\n notifyListeners(this, change)\n }\n if (__DEV__ && notifySpy) {\n spyReportEnd()\n }\n }\n } finally {\n endBatch()\n }\n return true\n }\n\n /**\n * Observes this object. Triggers for the events 'add', 'update' and 'delete'.\n * See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe\n * for callback details\n */\n observe_(callback: (changes: IObjectDidChange) => void, fireImmediately?: boolean): Lambda {\n if (__DEV__ && fireImmediately === true) {\n die(\"`observe` doesn't support the fire immediately property for observable objects.\")\n }\n return registerListener(this, callback)\n }\n\n intercept_(handler): Lambda {\n return registerInterceptor(this, handler)\n }\n\n notifyPropertyAddition_(key: PropertyKey, value: any) {\n const notify = hasListeners(this)\n const notifySpy = __DEV__ && isSpyEnabled()\n if (notify || notifySpy) {\n const change: IObjectDidChange | null =\n notify || notifySpy\n ? ({\n type: ADD,\n observableKind: \"object\",\n debugObjectName: this.name_,\n object: this.proxy_ || this.target_,\n name: key,\n newValue: value\n } as const)\n : null\n\n if (__DEV__ && notifySpy) {\n spyReportStart(change!)\n }\n if (notify) {\n notifyListeners(this, change)\n }\n if (__DEV__ && notifySpy) {\n spyReportEnd()\n }\n }\n\n this.pendingKeys_?.get(key)?.set(true)\n\n // Notify \"keys/entries/values\" observers\n this.keysAtom_.reportChanged()\n }\n\n ownKeys_(): Array {\n this.keysAtom_.reportObserved()\n return ownKeys(this.target_)\n }\n\n keys_(): PropertyKey[] {\n // Returns enumerable && own, but unfortunately keysAtom will report on ANY key change.\n // There is no way to distinguish between Object.keys(object) and Reflect.ownKeys(object) - both are handled by ownKeys trap.\n // We can either over-report in Object.keys(object) or under-report in Reflect.ownKeys(object)\n // We choose to over-report in Object.keys(object), because:\n // - typically it's used with simple data objects\n // - when symbolic/non-enumerable keys are relevant Reflect.ownKeys works as expected\n this.keysAtom_.reportObserved()\n return Object.keys(this.target_)\n }\n}\n\nexport interface IIsObservableObject {\n [$mobx]: ObservableObjectAdministration\n}\n\nexport function asObservableObject(\n target: any,\n options?: CreateObservableOptions\n): IIsObservableObject {\n if (__DEV__ && options && isObservableObject(target)) {\n die(`Options can't be provided for already observable objects.`)\n }\n\n if (hasProp(target, $mobx)) {\n if (__DEV__ && !(getAdministration(target) instanceof ObservableObjectAdministration)) {\n die(\n `Cannot convert '${getDebugName(target)}' into observable object:` +\n `\\nThe target is already observable of different type.` +\n `\\nExtending builtins is not supported.`\n )\n }\n return target\n }\n\n if (__DEV__ && !Object.isExtensible(target)) {\n die(\"Cannot make the designated object observable; it is not extensible\")\n }\n\n const name =\n options?.name ??\n (__DEV__\n ? `${\n isPlainObject(target) ? \"ObservableObject\" : target.constructor.name\n }@${getNextId()}`\n : \"ObservableObject\")\n\n const adm = new ObservableObjectAdministration(\n target,\n new Map(),\n String(name),\n getAnnotationFromOptions(options)\n )\n\n addHiddenProp(target, $mobx, adm)\n\n return target\n}\n\nconst isObservableObjectAdministration = createInstanceofPredicate(\n \"ObservableObjectAdministration\",\n ObservableObjectAdministration\n)\n\nfunction getCachedObservablePropDescriptor(key) {\n return (\n descriptorCache[key] ||\n (descriptorCache[key] = {\n get() {\n return this[$mobx].getObservablePropValue_(key)\n },\n set(value) {\n return this[$mobx].setObservablePropValue_(key, value)\n }\n })\n )\n}\n\nexport function isObservableObject(thing: any): boolean {\n if (isObject(thing)) {\n return isObservableObjectAdministration((thing as any)[$mobx])\n }\n return false\n}\n\nexport function recordAnnotationApplied(\n adm: ObservableObjectAdministration,\n annotation: Annotation,\n key: PropertyKey\n) {\n if (__DEV__) {\n adm.appliedAnnotations_![key] = annotation\n }\n // Remove applied decorator annotation so we don't try to apply it again in subclass constructor\n delete adm.target_[storedAnnotationsSymbol]?.[key]\n}\n\nfunction assertAnnotable(\n adm: ObservableObjectAdministration,\n annotation: Annotation,\n key: PropertyKey\n) {\n // Valid annotation\n if (__DEV__ && !isAnnotation(annotation)) {\n die(`Cannot annotate '${adm.name_}.${key.toString()}': Invalid annotation.`)\n }\n\n /*\n // Configurable, not sealed, not frozen\n // Possibly not needed, just a little better error then the one thrown by engine.\n // Cases where this would be useful the most (subclass field initializer) are not interceptable by this.\n if (__DEV__) {\n const configurable = getDescriptor(adm.target_, key)?.configurable\n const frozen = Object.isFrozen(adm.target_)\n const sealed = Object.isSealed(adm.target_)\n if (!configurable || frozen || sealed) {\n const fieldName = `${adm.name_}.${key.toString()}`\n const requestedAnnotationType = annotation.annotationType_\n let error = `Cannot apply '${requestedAnnotationType}' to '${fieldName}':`\n if (frozen) {\n error += `\\nObject is frozen.`\n }\n if (sealed) {\n error += `\\nObject is sealed.`\n }\n if (!configurable) {\n error += `\\nproperty is not configurable.`\n // Mention only if caused by us to avoid confusion\n if (hasProp(adm.appliedAnnotations!, key)) {\n error += `\\nTo prevent accidental re-definition of a field by a subclass, `\n error += `all annotated fields of non-plain objects (classes) are not configurable.`\n }\n }\n die(error)\n }\n }\n */\n\n // Not annotated\n if (__DEV__ && !isOverride(annotation) && hasProp(adm.appliedAnnotations_!, key)) {\n const fieldName = `${adm.name_}.${key.toString()}`\n const currentAnnotationType = adm.appliedAnnotations_![key].annotationType_\n const requestedAnnotationType = annotation.annotationType_\n die(\n `Cannot apply '${requestedAnnotationType}' to '${fieldName}':` +\n `\\nThe field is already annotated with '${currentAnnotationType}'.` +\n `\\nRe-annotating fields is not allowed.` +\n `\\nUse 'override' annotation for methods overridden by subclass.`\n )\n }\n}\n", "import {\n getNextId,\n addHiddenFinalProp,\n makeIterable,\n addHiddenProp,\n ObservableArrayAdministration,\n $mobx,\n arrayExtensions,\n IEnhancer,\n isObservableArray,\n IObservableArray,\n defineProperty,\n initObservable\n} from \"../internal\"\n\n// Bug in safari 9.* (or iOS 9 safari mobile). See #364\nconst ENTRY_0 = createArrayEntryDescriptor(0)\n\nconst safariPrototypeSetterInheritanceBug = (() => {\n let v = false\n const p = {}\n Object.defineProperty(p, \"0\", {\n set: () => {\n v = true\n }\n })\n Object.create(p)[\"0\"] = 1\n return v === false\n})()\n\n/**\n * This array buffer contains two lists of properties, so that all arrays\n * can recycle their property definitions, which significantly improves performance of creating\n * properties on the fly.\n */\nlet OBSERVABLE_ARRAY_BUFFER_SIZE = 0\n\n// Typescript workaround to make sure ObservableArray extends Array\nclass StubArray {}\nfunction inherit(ctor, proto) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(ctor.prototype, proto)\n } else if (ctor.prototype.__proto__ !== undefined) {\n ctor.prototype.__proto__ = proto\n } else {\n ctor.prototype = proto\n }\n}\ninherit(StubArray, Array.prototype)\n\n// Weex proto freeze protection was here,\n// but it is unclear why the hack is need as MobX never changed the prototype\n// anyway, so removed it in V6\n\nexport class LegacyObservableArray extends StubArray {\n constructor(\n initialValues: T[] | undefined,\n enhancer: IEnhancer,\n name = __DEV__ ? \"ObservableArray@\" + getNextId() : \"ObservableArray\",\n owned = false\n ) {\n super()\n initObservable(() => {\n const adm = new ObservableArrayAdministration(name, enhancer, owned, true)\n adm.proxy_ = this as any\n addHiddenFinalProp(this, $mobx, adm)\n\n if (initialValues && initialValues.length) {\n // @ts-ignore\n this.spliceWithArray(0, 0, initialValues)\n }\n\n if (safariPrototypeSetterInheritanceBug) {\n // Seems that Safari won't use numeric prototype setter until any * numeric property is\n // defined on the instance. After that it works fine, even if this property is deleted.\n Object.defineProperty(this, \"0\", ENTRY_0)\n }\n })\n }\n\n concat(...arrays: T[][]): T[] {\n ;(this[$mobx] as ObservableArrayAdministration).atom_.reportObserved()\n return Array.prototype.concat.apply(\n (this as any).slice(),\n //@ts-ignore\n arrays.map(a => (isObservableArray(a) ? a.slice() : a))\n )\n }\n\n get length(): number {\n return (this[$mobx] as ObservableArrayAdministration).getArrayLength_()\n }\n\n set length(newLength: number) {\n ;(this[$mobx] as ObservableArrayAdministration).setArrayLength_(newLength)\n }\n\n get [Symbol.toStringTag]() {\n return \"Array\"\n }\n\n [Symbol.iterator]() {\n const self = this\n let nextIndex = 0\n return makeIterable({\n next() {\n return nextIndex < self.length\n ? { value: self[nextIndex++], done: false }\n : { done: true, value: undefined }\n }\n })\n }\n}\n\nObject.entries(arrayExtensions).forEach(([prop, fn]) => {\n if (prop !== \"concat\") {\n addHiddenProp(LegacyObservableArray.prototype, prop, fn)\n }\n})\n\nfunction createArrayEntryDescriptor(index: number) {\n return {\n enumerable: false,\n configurable: true,\n get: function () {\n return this[$mobx].get_(index)\n },\n set: function (value) {\n this[$mobx].set_(index, value)\n }\n }\n}\n\nfunction createArrayBufferItem(index: number) {\n defineProperty(LegacyObservableArray.prototype, \"\" + index, createArrayEntryDescriptor(index))\n}\n\nexport function reserveArrayBuffer(max: number) {\n if (max > OBSERVABLE_ARRAY_BUFFER_SIZE) {\n for (let index = OBSERVABLE_ARRAY_BUFFER_SIZE; index < max + 100; index++) {\n createArrayBufferItem(index)\n }\n OBSERVABLE_ARRAY_BUFFER_SIZE = max\n }\n}\n\nreserveArrayBuffer(1000)\n\nexport function createLegacyArray(\n initialValues: T[] | undefined,\n enhancer: IEnhancer,\n name?: string\n): IObservableArray {\n return new LegacyObservableArray(initialValues, enhancer, name) as any\n}\n", "import { isAction } from \"../api/action\"\nimport {\n $mobx,\n IDepTreeNode,\n isAtom,\n isComputedValue,\n isObservableArray,\n isObservableMap,\n isObservableObject,\n isReaction,\n isObservableSet,\n die,\n isFunction,\n allowStateChangesStart,\n untrackedStart,\n allowStateChangesEnd,\n untrackedEnd,\n startBatch,\n endBatch\n} from \"../internal\"\n\nexport function getAtom(thing: any, property?: PropertyKey): IDepTreeNode {\n if (typeof thing === \"object\" && thing !== null) {\n if (isObservableArray(thing)) {\n if (property !== undefined) {\n die(23)\n }\n return (thing as any)[$mobx].atom_\n }\n if (isObservableSet(thing)) {\n return thing.atom_\n }\n if (isObservableMap(thing)) {\n if (property === undefined) {\n return thing.keysAtom_\n }\n const observable = thing.data_.get(property) || thing.hasMap_.get(property)\n if (!observable) {\n die(25, property, getDebugName(thing))\n }\n return observable\n }\n if (property && !thing[$mobx]) {\n thing[property]\n } // See #1072\n if (isObservableObject(thing)) {\n if (!property) {\n return die(26)\n }\n const observable = (thing as any)[$mobx].values_.get(property)\n if (!observable) {\n die(27, property, getDebugName(thing))\n }\n return observable\n }\n if (isAtom(thing) || isComputedValue(thing) || isReaction(thing)) {\n return thing\n }\n } else if (isFunction(thing)) {\n if (isReaction(thing[$mobx])) {\n // disposer function\n return thing[$mobx]\n }\n }\n die(28)\n}\n\nexport function getAdministration(thing: any, property?: string) {\n if (!thing) {\n die(29)\n }\n if (property !== undefined) {\n return getAdministration(getAtom(thing, property))\n }\n if (isAtom(thing) || isComputedValue(thing) || isReaction(thing)) {\n return thing\n }\n if (isObservableMap(thing) || isObservableSet(thing)) {\n return thing\n }\n if (thing[$mobx]) {\n return thing[$mobx]\n }\n die(24, thing)\n}\n\nexport function getDebugName(thing: any, property?: string): string {\n let named\n if (property !== undefined) {\n named = getAtom(thing, property)\n } else if (isAction(thing)) {\n return thing.name\n } else if (isObservableObject(thing) || isObservableMap(thing) || isObservableSet(thing)) {\n named = getAdministration(thing)\n } else {\n // valid for arrays as well\n named = getAtom(thing)\n }\n return named.name_\n}\n\n/**\n * Helper function for initializing observable structures, it applies:\n * 1. allowStateChanges so we don't violate enforceActions.\n * 2. untracked so we don't accidentaly subscribe to anything observable accessed during init in case the observable is created inside derivation.\n * 3. batch to avoid state version updates\n */\nexport function initObservable(cb: () => T): T {\n const derivation = untrackedStart()\n const allowStateChanges = allowStateChangesStart(true)\n startBatch()\n try {\n return cb()\n } finally {\n endBatch()\n allowStateChangesEnd(allowStateChanges)\n untrackedEnd(derivation)\n }\n}\n", "import {\n isES6Map,\n isObservableArray,\n isObservableMap,\n isES6Set,\n isObservableSet,\n hasProp,\n isFunction,\n objectPrototype\n} from \"../internal\"\n\ndeclare const Symbol\nconst toString = objectPrototype.toString\n\nexport function deepEqual(a: any, b: any, depth: number = -1): boolean {\n return eq(a, b, depth)\n}\n\n// Copied from https://github.com/jashkenas/underscore/blob/5c237a7c682fb68fd5378203f0bf22dce1624854/underscore.js#L1186-L1289\n// Internal recursive comparison function for `isEqual`.\nfunction eq(a: any, b: any, depth: number, aStack?: any[], bStack?: any[]) {\n // Identical objects are equal. `0 === -0`, but they aren't identical.\n // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).\n if (a === b) {\n return a !== 0 || 1 / a === 1 / b\n }\n // `null` or `undefined` only equal to itself (strict comparison).\n if (a == null || b == null) {\n return false\n }\n // `NaN`s are equivalent, but non-reflexive.\n if (a !== a) {\n return b !== b\n }\n // Exhaust primitive checks\n const type = typeof a\n if (type !== \"function\" && type !== \"object\" && typeof b != \"object\") {\n return false\n }\n\n // Compare `[[Class]]` names.\n const className = toString.call(a)\n if (className !== toString.call(b)) {\n return false\n }\n switch (className) {\n // Strings, numbers, regular expressions, dates, and booleans are compared by value.\n case \"[object RegExp]\":\n // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i')\n case \"[object String]\":\n // Primitives and their corresponding object wrappers are equivalent; thus, `\"5\"` is\n // equivalent to `new String(\"5\")`.\n return \"\" + a === \"\" + b\n case \"[object Number]\":\n // `NaN`s are equivalent, but non-reflexive.\n // Object(NaN) is equivalent to NaN.\n if (+a !== +a) {\n return +b !== +b\n }\n // An `egal` comparison is performed for other numeric values.\n return +a === 0 ? 1 / +a === 1 / b : +a === +b\n case \"[object Date]\":\n case \"[object Boolean]\":\n // Coerce dates and booleans to numeric primitive values. Dates are compared by their\n // millisecond representations. Note that invalid dates with millisecond representations\n // of `NaN` are not equivalent.\n return +a === +b\n case \"[object Symbol]\":\n return (\n typeof Symbol !== \"undefined\" && Symbol.valueOf.call(a) === Symbol.valueOf.call(b)\n )\n case \"[object Map]\":\n case \"[object Set]\":\n // Maps and Sets are unwrapped to arrays of entry-pairs, adding an incidental level.\n // Hide this extra level by increasing the depth.\n if (depth >= 0) {\n depth++\n }\n break\n }\n // Unwrap any wrapped objects.\n a = unwrap(a)\n b = unwrap(b)\n\n const areArrays = className === \"[object Array]\"\n if (!areArrays) {\n if (typeof a != \"object\" || typeof b != \"object\") {\n return false\n }\n\n // Objects with different constructors are not equivalent, but `Object`s or `Array`s\n // from different frames are.\n const aCtor = a.constructor,\n bCtor = b.constructor\n if (\n aCtor !== bCtor &&\n !(\n isFunction(aCtor) &&\n aCtor instanceof aCtor &&\n isFunction(bCtor) &&\n bCtor instanceof bCtor\n ) &&\n \"constructor\" in a &&\n \"constructor\" in b\n ) {\n return false\n }\n }\n\n if (depth === 0) {\n return false\n } else if (depth < 0) {\n depth = -1\n }\n\n // Assume equality for cyclic structures. The algorithm for detecting cyclic\n // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.\n\n // Initializing stack of traversed objects.\n // It's done here since we only need them for objects and arrays comparison.\n aStack = aStack || []\n bStack = bStack || []\n let length = aStack.length\n while (length--) {\n // Linear search. Performance is inversely proportional to the number of\n // unique nested structures.\n if (aStack[length] === a) {\n return bStack[length] === b\n }\n }\n\n // Add the first object to the stack of traversed objects.\n aStack.push(a)\n bStack.push(b)\n\n // Recursively compare objects and arrays.\n if (areArrays) {\n // Compare array lengths to determine if a deep comparison is necessary.\n length = a.length\n if (length !== b.length) {\n return false\n }\n // Deep compare the contents, ignoring non-numeric properties.\n while (length--) {\n if (!eq(a[length], b[length], depth - 1, aStack, bStack)) {\n return false\n }\n }\n } else {\n // Deep compare objects.\n const keys = Object.keys(a)\n let key\n length = keys.length\n // Ensure that both objects contain the same number of properties before comparing deep equality.\n if (Object.keys(b).length !== length) {\n return false\n }\n while (length--) {\n // Deep compare each member\n key = keys[length]\n if (!(hasProp(b, key) && eq(a[key], b[key], depth - 1, aStack, bStack))) {\n return false\n }\n }\n }\n // Remove the first object from the stack of traversed objects.\n aStack.pop()\n bStack.pop()\n return true\n}\n\nfunction unwrap(a: any) {\n if (isObservableArray(a)) {\n return a.slice()\n }\n if (isES6Map(a) || isObservableMap(a)) {\n return Array.from(a.entries())\n }\n if (isES6Set(a) || isObservableSet(a)) {\n return Array.from(a.entries())\n }\n return a\n}\n", "export function makeIterable(iterator: Iterator): IterableIterator {\n iterator[Symbol.iterator] = getSelf\n return iterator as any\n}\n\nfunction getSelf() {\n return this\n}\n", "import { ObservableObjectAdministration, isFunction } from \"../internal\"\n\nexport const enum MakeResult {\n Cancel,\n Break,\n Continue\n}\n\nexport type Annotation = {\n annotationType_: string\n make_(\n adm: ObservableObjectAdministration,\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n source: object\n ): MakeResult\n extend_(\n adm: ObservableObjectAdministration,\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n proxyTrap: boolean\n ): boolean | null\n decorate_20223_(value: any, context: DecoratorContext)\n options_?: any\n}\n\nexport type AnnotationMapEntry =\n | Annotation\n | true /* follow the default decorator, usually deep */\n | false /* don't decorate this property */\n\n// AdditionalFields can be used to declare additional keys that can be used, for example to be able to\n// declare annotations for private/ protected members, see #2339\nexport type AnnotationsMap = {\n [P in Exclude]?: AnnotationMapEntry\n} & Record\n\nexport function isAnnotation(thing: any) {\n return (\n // Can be function\n thing instanceof Object &&\n typeof thing.annotationType_ === \"string\" &&\n isFunction(thing.make_) &&\n isFunction(thing.extend_)\n )\n}\n\nexport function isAnnotationMapEntry(thing: any) {\n return typeof thing === \"boolean\" || isAnnotation(thing)\n}\n", "/**\n * (c) Michel Weststrate 2015 - 2020\n * MIT Licensed\n *\n * Welcome to the mobx sources! To get a global overview of how MobX internally works,\n * this is a good place to start:\n * https://medium.com/@mweststrate/becoming-fully-reactive-an-in-depth-explanation-of-mobservable-55995262a254#.xvbh6qd74\n *\n * Source folders:\n * ===============\n *\n * - api/ Most of the public static methods exposed by the module can be found here.\n * - core/ Implementation of the MobX algorithm; atoms, derivations, reactions, dependency trees, optimizations. Cool stuff can be found here.\n * - types/ All the magic that is need to have observable objects, arrays and values is in this folder. Including the modifiers like `asFlat`.\n * - utils/ Utility stuff.\n *\n */\nimport { die } from \"./errors\"\nimport { getGlobal } from \"./utils/global\"\n;[\"Symbol\", \"Map\", \"Set\"].forEach(m => {\n let g = getGlobal()\n if (typeof g[m] === \"undefined\") {\n die(`MobX requires global '${m}' to be available or polyfilled`)\n }\n})\n\nimport { spy, getDebugName, $mobx } from \"./internal\"\n\nexport {\n IObservable,\n IDepTreeNode,\n Reaction,\n IReactionPublic,\n IReactionDisposer,\n untracked,\n IAtom,\n createAtom,\n spy,\n IComputedValue,\n IEqualsComparer,\n comparer,\n IEnhancer,\n IInterceptable,\n IInterceptor,\n IListenable,\n IObjectWillChange,\n IObjectDidChange,\n isObservableObject,\n IValueDidChange,\n IValueWillChange,\n IObservableValue,\n isObservableValue as isBoxedObservable,\n IObservableArray,\n IArrayWillChange,\n IArrayWillSplice,\n IArraySplice,\n IArrayUpdate,\n IArrayDidChange,\n isObservableArray,\n IKeyValueMap,\n ObservableMap,\n IMapEntries,\n IMapEntry,\n IMapWillChange,\n IMapDidChange,\n isObservableMap,\n IObservableMapInitialValues,\n ObservableSet,\n isObservableSet,\n ISetDidChange,\n ISetWillChange,\n IObservableSetInitialValues,\n transaction,\n observable,\n IObservableFactory,\n CreateObservableOptions,\n computed,\n IComputedFactory,\n isObservable,\n isObservableProp,\n isComputed,\n isComputedProp,\n extendObservable,\n observe,\n intercept,\n autorun,\n IAutorunOptions,\n reaction,\n IReactionOptions,\n when,\n IWhenOptions,\n action,\n isAction,\n runInAction,\n IActionFactory,\n keys,\n values,\n entries,\n set,\n remove,\n has,\n get,\n apiOwnKeys as ownKeys,\n apiDefineProperty as defineProperty,\n configure,\n onBecomeObserved,\n onBecomeUnobserved,\n flow,\n isFlow,\n flowResult,\n FlowCancellationError,\n isFlowCancellationError,\n toJS,\n trace,\n IObserverTree,\n IDependencyTree,\n getDependencyTree,\n getObserverTree,\n resetGlobalState as _resetGlobalState,\n getGlobalState as _getGlobalState,\n getDebugName,\n getAtom,\n getAdministration as _getAdministration,\n allowStateChanges as _allowStateChanges,\n runInAction as _allowStateChangesInsideComputed, // This has become the default behavior in Mobx 6\n Lambda,\n $mobx,\n isComputingDerivation as _isComputingDerivation,\n onReactionError,\n interceptReads as _interceptReads,\n IComputedValueOptions,\n IActionRunInfo,\n _startAction,\n _endAction,\n allowStateReadsStart as _allowStateReadsStart,\n allowStateReadsEnd as _allowStateReadsEnd,\n makeObservable,\n makeAutoObservable,\n autoAction as _autoAction,\n AnnotationsMap,\n AnnotationMapEntry,\n override\n} from \"./internal\"\n\n// Devtools support\ndeclare const __MOBX_DEVTOOLS_GLOBAL_HOOK__: { injectMobx: (any) => void }\nif (typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__ === \"object\") {\n // See: https://github.com/andykog/mobx-devtools/\n __MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({\n spy,\n extras: {\n getDebugName\n },\n $mobx\n })\n}\n", "/*\nCopyright 2018 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n MobxReactionUpdateCustom,\n ReactiveElementConstructor,\n} from './mixin-custom.js';\nimport { Reaction } from 'mobx';\n\nexport { ReactiveElementConstructor } from './mixin-custom';\n\n/**\n * A class mixin which can be applied to lit-element's\n * [ReactiveElement](https://lit.dev/docs/api/ReactiveElement/)\n * derived classes. This mixin adds a mobx reaction which tracks the update method of ReactiveElement.\n *\n * Any observables used in the render template of the element will be tracked by a reaction\n * and cause an update of the element upon change.\n *\n * @param constructor the constructor to extend from to add the mobx reaction, must be derived from ReactiveElement.\n */\nexport function MobxReactionUpdate(\n constructor: T\n): T {\n return MobxReactionUpdateCustom(constructor, Reaction);\n}\n", "/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nconst NODE_MODE = false;\n\n// Allows minifiers to rename references to globalThis\nconst global = globalThis;\n\n/**\n * Whether the current browser supports `adoptedStyleSheets`.\n */\nexport const supportsAdoptingStyleSheets: boolean =\n global.ShadowRoot &&\n (global.ShadyCSS === undefined || global.ShadyCSS.nativeShadow) &&\n 'adoptedStyleSheets' in Document.prototype &&\n 'replace' in CSSStyleSheet.prototype;\n\n/**\n * A CSSResult or native CSSStyleSheet.\n *\n * In browsers that support constructible CSS style sheets, CSSStyleSheet\n * object can be used for styling along side CSSResult from the `css`\n * template tag.\n */\nexport type CSSResultOrNative = CSSResult | CSSStyleSheet;\n\nexport type CSSResultArray = Array;\n\n/**\n * A single CSSResult, CSSStyleSheet, or an array or nested arrays of those.\n */\nexport type CSSResultGroup = CSSResultOrNative | CSSResultArray;\n\nconst constructionToken = Symbol();\n\nconst cssTagCache = new WeakMap();\n\n/**\n * A container for a string of CSS text, that may be used to create a CSSStyleSheet.\n *\n * CSSResult is the return value of `css`-tagged template literals and\n * `unsafeCSS()`. In order to ensure that CSSResults are only created via the\n * `css` tag and `unsafeCSS()`, CSSResult cannot be constructed directly.\n */\nexport class CSSResult {\n // This property needs to remain unminified.\n ['_$cssResult$'] = true;\n readonly cssText: string;\n private _styleSheet?: CSSStyleSheet;\n private _strings: TemplateStringsArray | undefined;\n\n private constructor(\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ) {\n if (safeToken !== constructionToken) {\n throw new Error(\n 'CSSResult is not constructable. Use `unsafeCSS` or `css` instead.'\n );\n }\n this.cssText = cssText;\n this._strings = strings;\n }\n\n // This is a getter so that it's lazy. In practice, this means stylesheets\n // are not created until the first element instance is made.\n get styleSheet(): CSSStyleSheet | undefined {\n // If `supportsAdoptingStyleSheets` is true then we assume CSSStyleSheet is\n // constructable.\n let styleSheet = this._styleSheet;\n const strings = this._strings;\n if (supportsAdoptingStyleSheets && styleSheet === undefined) {\n const cacheable = strings !== undefined && strings.length === 1;\n if (cacheable) {\n styleSheet = cssTagCache.get(strings);\n }\n if (styleSheet === undefined) {\n (this._styleSheet = styleSheet = new CSSStyleSheet()).replaceSync(\n this.cssText\n );\n if (cacheable) {\n cssTagCache.set(strings, styleSheet);\n }\n }\n }\n return styleSheet;\n }\n\n toString(): string {\n return this.cssText;\n }\n}\n\ntype ConstructableCSSResult = CSSResult & {\n new (\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ): CSSResult;\n};\n\nconst textFromCSSResult = (value: CSSResultGroup | number) => {\n // This property needs to remain unminified.\n if ((value as CSSResult)['_$cssResult$'] === true) {\n return (value as CSSResult).cssText;\n } else if (typeof value === 'number') {\n return value;\n } else {\n throw new Error(\n `Value passed to 'css' function must be a 'css' function result: ` +\n `${value}. Use 'unsafeCSS' to pass non-literal values, but take care ` +\n `to ensure page security.`\n );\n }\n};\n\n/**\n * Wrap a value for interpolation in a {@linkcode css} tagged template literal.\n *\n * This is unsafe because untrusted CSS text can be used to phone home\n * or exfiltrate data to an attacker controlled site. Take care to only use\n * this with trusted input.\n */\nexport const unsafeCSS = (value: unknown) =>\n new (CSSResult as ConstructableCSSResult)(\n typeof value === 'string' ? value : String(value),\n undefined,\n constructionToken\n );\n\n/**\n * A template literal tag which can be used with LitElement's\n * {@linkcode LitElement.styles} property to set element styles.\n *\n * For security reasons, only literal string values and number may be used in\n * embedded expressions. To incorporate non-literal values {@linkcode unsafeCSS}\n * may be used inside an expression.\n */\nexport const css = (\n strings: TemplateStringsArray,\n ...values: (CSSResultGroup | number)[]\n): CSSResult => {\n const cssText =\n strings.length === 1\n ? strings[0]\n : values.reduce(\n (acc, v, idx) => acc + textFromCSSResult(v) + strings[idx + 1],\n strings[0]\n );\n return new (CSSResult as ConstructableCSSResult)(\n cssText,\n strings,\n constructionToken\n );\n};\n\n/**\n * Applies the given styles to a `shadowRoot`. When Shadow DOM is\n * available but `adoptedStyleSheets` is not, styles are appended to the\n * `shadowRoot` to [mimic spec behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).\n * Note, when shimming is used, any styles that are subsequently placed into\n * the shadowRoot should be placed *before* any shimmed adopted styles. This\n * will match spec behavior that gives adopted sheets precedence over styles in\n * shadowRoot.\n */\nexport const adoptStyles = (\n renderRoot: ShadowRoot,\n styles: Array\n) => {\n if (supportsAdoptingStyleSheets) {\n (renderRoot as ShadowRoot).adoptedStyleSheets = styles.map((s) =>\n s instanceof CSSStyleSheet ? s : s.styleSheet!\n );\n } else {\n for (const s of styles) {\n const style = document.createElement('style');\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nonce = (global as any)['litNonce'];\n if (nonce !== undefined) {\n style.setAttribute('nonce', nonce);\n }\n style.textContent = (s as CSSResult).cssText;\n renderRoot.appendChild(style);\n }\n }\n};\n\nconst cssResultFromStyleSheet = (sheet: CSSStyleSheet) => {\n let cssText = '';\n for (const rule of sheet.cssRules) {\n cssText += rule.cssText;\n }\n return unsafeCSS(cssText);\n};\n\nexport const getCompatibleStyle =\n supportsAdoptingStyleSheets ||\n (NODE_MODE && global.CSSStyleSheet === undefined)\n ? (s: CSSResultOrNative) => s\n : (s: CSSResultOrNative) =>\n s instanceof CSSStyleSheet ? cssResultFromStyleSheet(s) : s;\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Use this module if you want to create your own base class extending\n * {@link ReactiveElement}.\n * @packageDocumentation\n */\n\nimport {\n getCompatibleStyle,\n adoptStyles,\n CSSResultGroup,\n CSSResultOrNative,\n} from './css-tag.js';\nimport type {\n ReactiveController,\n ReactiveControllerHost,\n} from './reactive-controller.js';\n\n// In the Node build, this import will be injected by Rollup:\n// import {HTMLElement, customElements} from '@lit-labs/ssr-dom-shim';\n\nexport * from './css-tag.js';\nexport type {\n ReactiveController,\n ReactiveControllerHost,\n} from './reactive-controller.js';\n\n/**\n * Removes the `readonly` modifier from properties in the union K.\n *\n * This is a safer way to cast a value to a type with a mutable version of a\n * readonly field, than casting to an interface with the field re-declared\n * because it preserves the type of all the fields and warns on typos.\n */\ntype Mutable = Omit & {\n -readonly [P in keyof Pick]: P extends K ? T[P] : never;\n};\n\n// TODO (justinfagnani): Add `hasOwn` here when we ship ES2022\nconst {\n is,\n defineProperty,\n getOwnPropertyDescriptor,\n getOwnPropertyNames,\n getOwnPropertySymbols,\n getPrototypeOf,\n} = Object;\n\nconst NODE_MODE = false;\n\n// Lets a minifier replace globalThis references with a minified name\nconst global = globalThis;\n\nif (NODE_MODE) {\n global.customElements ??= customElements;\n}\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nconst trustedTypes = (global as unknown as {trustedTypes?: {emptyScript: ''}})\n .trustedTypes;\n\n// Temporary workaround for https://crbug.com/993268\n// Currently, any attribute starting with \"on\" is considered to be a\n// TrustedScript source. Such boolean attributes must be set to the equivalent\n// trusted emptyScript value.\nconst emptyStringForBooleanAttribute = trustedTypes\n ? (trustedTypes.emptyScript as unknown as '')\n : '';\n\nconst polyfillSupport = DEV_MODE\n ? global.reactiveElementPolyfillSupportDevMode\n : global.reactiveElementPolyfillSupport;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n const issuedWarnings: Set = (global.litIssuedWarnings ??=\n new Set());\n\n // Issue a warning, if we haven't already.\n issueWarning = (code: string, warning: string) => {\n warning += ` See https://lit.dev/msg/${code} for more information.`;\n if (!issuedWarnings.has(warning)) {\n console.warn(warning);\n issuedWarnings.add(warning);\n }\n };\n\n issueWarning(\n 'dev-mode',\n `Lit is in dev mode. Not recommended for production!`\n );\n\n // Issue polyfill support warning.\n if (global.ShadyDOM?.inUse && polyfillSupport === undefined) {\n issueWarning(\n 'polyfill-support-missing',\n `Shadow DOM is being polyfilled via \\`ShadyDOM\\` but ` +\n `the \\`polyfill-support\\` module has not been loaded.`\n );\n }\n}\n\n/**\n * Contains types that are part of the unstable debug API.\n *\n * Everything in this API is not stable and may change or be removed in the future,\n * even on patch releases.\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace ReactiveUnstable {\n /**\n * When Lit is running in dev mode and `window.emitLitDebugLogEvents` is true,\n * we will emit 'lit-debug' events to window, with live details about the update and render\n * lifecycle. These can be useful for writing debug tooling and visualizations.\n *\n * Please be aware that running with window.emitLitDebugLogEvents has performance overhead,\n * making certain operations that are normally very cheap (like a no-op render) much slower,\n * because we must copy data and dispatch events.\n */\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace DebugLog {\n export type Entry = Update;\n export interface Update {\n kind: 'update';\n }\n }\n}\n\ninterface DebugLoggingWindow {\n // Even in dev mode, we generally don't want to emit these events, as that's\n // another level of cost, so only emit them when DEV_MODE is true _and_ when\n // window.emitLitDebugEvents is true.\n emitLitDebugLogEvents?: boolean;\n}\n\n/**\n * Useful for visualizing and logging insights into what the Lit template system is doing.\n *\n * Compiled out of prod mode builds.\n */\nconst debugLogEvent = DEV_MODE\n ? (event: ReactiveUnstable.DebugLog.Entry) => {\n const shouldEmit = (global as unknown as DebugLoggingWindow)\n .emitLitDebugLogEvents;\n if (!shouldEmit) {\n return;\n }\n global.dispatchEvent(\n new CustomEvent('lit-debug', {\n detail: event,\n })\n );\n }\n : undefined;\n\n/*\n * When using Closure Compiler, JSCompiler_renameProperty(property, object) is\n * replaced at compile time by the munged name for object[property]. We cannot\n * alias this function, so we have to use a small shim that has the same\n * behavior when not compiling.\n */\n/*@__INLINE__*/\nconst JSCompiler_renameProperty =

    (\n prop: P,\n _obj: unknown\n): P => prop;\n\n/**\n * Converts property values to and from attribute values.\n */\nexport interface ComplexAttributeConverter {\n /**\n * Called to convert an attribute value to a property\n * value.\n */\n fromAttribute?(value: string | null, type?: TypeHint): Type;\n\n /**\n * Called to convert a property value to an attribute\n * value.\n *\n * It returns unknown instead of string, to be compatible with\n * https://github.com/WICG/trusted-types (and similar efforts).\n */\n toAttribute?(value: Type, type?: TypeHint): unknown;\n}\n\ntype AttributeConverter =\n | ComplexAttributeConverter\n | ((value: string | null, type?: TypeHint) => Type);\n\n/**\n * Defines options for a property accessor.\n */\nexport interface PropertyDeclaration {\n /**\n * When set to `true`, indicates the property is internal private state. The\n * property should not be set by users. When using TypeScript, this property\n * should be marked as `private` or `protected`, and it is also a common\n * practice to use a leading `_` in the name. The property is not added to\n * `observedAttributes`.\n */\n readonly state?: boolean;\n\n /**\n * Indicates how and whether the property becomes an observed attribute.\n * If the value is `false`, the property is not added to `observedAttributes`.\n * If true or absent, the lowercased property name is observed (e.g. `fooBar`\n * becomes `foobar`). If a string, the string value is observed (e.g\n * `attribute: 'foo-bar'`).\n */\n readonly attribute?: boolean | string;\n\n /**\n * Indicates the type of the property. This is used only as a hint for the\n * `converter` to determine how to convert the attribute\n * to/from a property.\n */\n readonly type?: TypeHint;\n\n /**\n * Indicates how to convert the attribute to/from a property. If this value\n * is a function, it is used to convert the attribute value a the property\n * value. If it's an object, it can have keys for `fromAttribute` and\n * `toAttribute`. If no `toAttribute` function is provided and\n * `reflect` is set to `true`, the property value is set directly to the\n * attribute. A default `converter` is used if none is provided; it supports\n * `Boolean`, `String`, `Number`, `Object`, and `Array`. Note,\n * when a property changes and the converter is used to update the attribute,\n * the property is never updated again as a result of the attribute changing,\n * and vice versa.\n */\n readonly converter?: AttributeConverter;\n\n /**\n * Indicates if the property should reflect to an attribute.\n * If `true`, when the property is set, the attribute is set using the\n * attribute name determined according to the rules for the `attribute`\n * property option and the value of the property converted using the rules\n * from the `converter` property option.\n */\n readonly reflect?: boolean;\n\n /**\n * A function that indicates if a property should be considered changed when\n * it is set. The function should take the `newValue` and `oldValue` and\n * return `true` if an update should be requested.\n */\n hasChanged?(value: Type, oldValue: Type): boolean;\n\n /**\n * Indicates whether an accessor will be created for this property. By\n * default, an accessor will be generated for this property that requests an\n * update when set. If this flag is `true`, no accessor will be created, and\n * it will be the user's responsibility to call\n * `this.requestUpdate(propertyName, oldValue)` to request an update when\n * the property changes.\n */\n readonly noAccessor?: boolean;\n\n /**\n * Whether this property is wrapping accessors. This is set by `@property`\n * to control the initial value change and reflection logic.\n *\n * @internal\n */\n wrapped?: boolean;\n}\n\n/**\n * Map of properties to PropertyDeclaration options. For each property an\n * accessor is made, and the property is processed according to the\n * PropertyDeclaration options.\n */\nexport interface PropertyDeclarations {\n readonly [key: string]: PropertyDeclaration;\n}\n\ntype PropertyDeclarationMap = Map;\n\ntype AttributeMap = Map;\n\n/**\n * A Map of property keys to values.\n *\n * Takes an optional type parameter T, which when specified as a non-any,\n * non-unknown type, will make the Map more strongly-typed, associating the map\n * keys with their corresponding value type on T.\n *\n * Use `PropertyValues` when overriding ReactiveElement.update() and\n * other lifecycle methods in order to get stronger type-checking on keys\n * and values.\n */\n// This type is conditional so that if the parameter T is not specified, or\n// is `any`, the type will include `Map`. Since T is not\n// given in the uses of PropertyValues in this file, all uses here fallback to\n// meaning `Map`, but if a developer uses\n// `PropertyValues` (or any other value for T) they will get a\n// strongly-typed Map type.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type PropertyValues = T extends object\n ? PropertyValueMap\n : Map;\n\n/**\n * Do not use, instead prefer {@linkcode PropertyValues}.\n */\n// This type must be exported such that JavaScript generated by the Google\n// Closure Compiler can import a type reference.\nexport interface PropertyValueMap extends Map {\n get(k: K): T[K] | undefined;\n set(key: K, value: T[K]): this;\n has(k: K): boolean;\n delete(k: K): boolean;\n}\n\nexport const defaultConverter: ComplexAttributeConverter = {\n toAttribute(value: unknown, type?: unknown): unknown {\n switch (type) {\n case Boolean:\n value = value ? emptyStringForBooleanAttribute : null;\n break;\n case Object:\n case Array:\n // if the value is `null` or `undefined` pass this through\n // to allow removing/no change behavior.\n value = value == null ? value : JSON.stringify(value);\n break;\n }\n return value;\n },\n\n fromAttribute(value: string | null, type?: unknown) {\n let fromValue: unknown = value;\n switch (type) {\n case Boolean:\n fromValue = value !== null;\n break;\n case Number:\n fromValue = value === null ? null : Number(value);\n break;\n case Object:\n case Array:\n // Do *not* generate exception when invalid JSON is set as elements\n // don't normally complain on being mis-configured.\n // TODO(sorvell): Do generate exception in *dev mode*.\n try {\n // Assert to adhere to Bazel's \"must type assert JSON parse\" rule.\n fromValue = JSON.parse(value!) as unknown;\n } catch (e) {\n fromValue = null;\n }\n break;\n }\n return fromValue;\n },\n};\n\nexport interface HasChanged {\n (value: unknown, old: unknown): boolean;\n}\n\n/**\n * Change function that returns true if `value` is different from `oldValue`.\n * This method is used as the default for a property's `hasChanged` function.\n */\nexport const notEqual: HasChanged = (value: unknown, old: unknown): boolean =>\n !is(value, old);\n\nconst defaultPropertyDeclaration: PropertyDeclaration = {\n attribute: true,\n type: String,\n converter: defaultConverter,\n reflect: false,\n hasChanged: notEqual,\n};\n\n/**\n * A string representing one of the supported dev mode warning categories.\n */\nexport type WarningKind =\n | 'change-in-update'\n | 'migration'\n | 'async-perform-update';\n\nexport type Initializer = (element: ReactiveElement) => void;\n\n// Temporary, until google3 is on TypeScript 5.2\ndeclare global {\n interface SymbolConstructor {\n readonly metadata: unique symbol;\n }\n}\n\n// Ensure metadata is enabled. TypeScript does not polyfill\n// Symbol.metadata, so we must ensure that it exists.\n(Symbol as {metadata: symbol}).metadata ??= Symbol('metadata');\n\ndeclare global {\n // This is public global API, do not change!\n // eslint-disable-next-line no-var\n var litPropertyMetadata: WeakMap<\n object,\n Map\n >;\n}\n\n// Map from a class's metadata object to property options\n// Note that we must use nullish-coalescing assignment so that we only use one\n// map even if we load multiple version of this module.\nglobal.litPropertyMetadata ??= new WeakMap<\n object,\n Map\n>();\n\n/**\n * Base element class which manages element properties and attributes. When\n * properties change, the `update` method is asynchronously called. This method\n * should be supplied by subclasses to render updates as desired.\n * @noInheritDoc\n */\nexport abstract class ReactiveElement\n // In the Node build, this `extends` clause will be substituted with\n // `(globalThis.HTMLElement ?? HTMLElement)`.\n //\n // This way, we will first prefer any global `HTMLElement` polyfill that the\n // user has assigned, and then fall back to the `HTMLElement` shim which has\n // been imported (see note at the top of this file about how this import is\n // generated by Rollup). Note that the `HTMLElement` variable has been\n // shadowed by this import, so it no longer refers to the global.\n extends HTMLElement\n implements ReactiveControllerHost\n{\n // Note: these are patched in only in DEV_MODE.\n /**\n * Read or set all the enabled warning categories for this class.\n *\n * This property is only used in development builds.\n *\n * @nocollapse\n * @category dev-mode\n */\n static enabledWarnings?: WarningKind[];\n\n /**\n * Enable the given warning category for this class.\n *\n * This method only exists in development builds, so it should be accessed\n * with a guard like:\n *\n * ```ts\n * // Enable for all ReactiveElement subclasses\n * ReactiveElement.enableWarning?.('migration');\n *\n * // Enable for only MyElement and subclasses\n * MyElement.enableWarning?.('migration');\n * ```\n *\n * @nocollapse\n * @category dev-mode\n */\n static enableWarning?: (warningKind: WarningKind) => void;\n\n /**\n * Disable the given warning category for this class.\n *\n * This method only exists in development builds, so it should be accessed\n * with a guard like:\n *\n * ```ts\n * // Disable for all ReactiveElement subclasses\n * ReactiveElement.disableWarning?.('migration');\n *\n * // Disable for only MyElement and subclasses\n * MyElement.disableWarning?.('migration');\n * ```\n *\n * @nocollapse\n * @category dev-mode\n */\n static disableWarning?: (warningKind: WarningKind) => void;\n\n /**\n * Adds an initializer function to the class that is called during instance\n * construction.\n *\n * This is useful for code that runs against a `ReactiveElement`\n * subclass, such as a decorator, that needs to do work for each\n * instance, such as setting up a `ReactiveController`.\n *\n * ```ts\n * const myDecorator = (target: typeof ReactiveElement, key: string) => {\n * target.addInitializer((instance: ReactiveElement) => {\n * // This is run during construction of the element\n * new MyController(instance);\n * });\n * }\n * ```\n *\n * Decorating a field will then cause each instance to run an initializer\n * that adds a controller:\n *\n * ```ts\n * class MyElement extends LitElement {\n * @myDecorator foo;\n * }\n * ```\n *\n * Initializers are stored per-constructor. Adding an initializer to a\n * subclass does not add it to a superclass. Since initializers are run in\n * constructors, initializers will run in order of the class hierarchy,\n * starting with superclasses and progressing to the instance's class.\n *\n * @nocollapse\n */\n static addInitializer(initializer: Initializer) {\n this.__prepare();\n (this._initializers ??= []).push(initializer);\n }\n\n static _initializers?: Initializer[];\n\n /*\n * Due to closure compiler ES6 compilation bugs, @nocollapse is required on\n * all static methods and properties with initializers. Reference:\n * - https://github.com/google/closure-compiler/issues/1776\n */\n\n /**\n * Maps attribute names to properties; for example `foobar` attribute to\n * `fooBar` property. Created lazily on user subclasses when finalizing the\n * class.\n * @nocollapse\n */\n private static __attributeToPropertyMap: AttributeMap;\n\n /**\n * Marks class as having been finalized, which includes creating properties\n * from `static properties`, but does *not* include all properties created\n * from decorators.\n * @nocollapse\n */\n protected static finalized: true | undefined;\n\n /**\n * Memoized list of all element properties, including any superclass\n * properties. Created lazily on user subclasses when finalizing the class.\n *\n * @nocollapse\n * @category properties\n */\n static elementProperties: PropertyDeclarationMap;\n\n /**\n * User-supplied object that maps property names to `PropertyDeclaration`\n * objects containing options for configuring reactive properties. When\n * a reactive property is set the element will update and render.\n *\n * By default properties are public fields, and as such, they should be\n * considered as primarily settable by element users, either via attribute or\n * the property itself.\n *\n * Generally, properties that are changed by the element should be private or\n * protected fields and should use the `state: true` option. Properties\n * marked as `state` do not reflect from the corresponding attribute\n *\n * However, sometimes element code does need to set a public property. This\n * should typically only be done in response to user interaction, and an event\n * should be fired informing the user; for example, a checkbox sets its\n * `checked` property when clicked and fires a `changed` event. Mutating\n * public properties should typically not be done for non-primitive (object or\n * array) properties. In other cases when an element needs to manage state, a\n * private property set with the `state: true` option should be used. When\n * needed, state properties can be initialized via public properties to\n * facilitate complex interactions.\n * @nocollapse\n * @category properties\n */\n static properties: PropertyDeclarations;\n\n /**\n * Memoized list of all element styles.\n * Created lazily on user subclasses when finalizing the class.\n * @nocollapse\n * @category styles\n */\n static elementStyles: Array = [];\n\n /**\n * Array of styles to apply to the element. The styles should be defined\n * using the {@linkcode css} tag function, via constructible stylesheets, or\n * imported from native CSS module scripts.\n *\n * Note on Content Security Policy:\n *\n * Element styles are implemented with ` + + +

    + + + diff --git a/docs/static/favicon.svg b/docs/static/favicon.svg new file mode 100644 index 0000000..3ae1370 --- /dev/null +++ b/docs/static/favicon.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..f4a6ffb --- /dev/null +++ b/package-lock.json @@ -0,0 +1,5880 @@ +{ + "name": "llm-comparator", + "version": "1.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "llm-comparator", + "version": "1.0.0", + "license": "Apache-2.0", + "dependencies": { + "@adobe/lit-mobx": "2.2.2", + "@material/mwc-icon": "0.27.0", + "@material/mwc-switch": "0.27.0", + "jsdifflib": "1.1.0", + "jstat": "1.9.6", + "lit": "3.1.3", + "mobx": "6.12.3" + }, + "devDependencies": { + "@web/dev-server": "0.4.4", + "esbuild": "0.20.2", + "esbuild-plugin-lit-css": "3.0.0" + } + }, + "node_modules/@75lb/deep-merge": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@75lb/deep-merge/-/deep-merge-1.1.1.tgz", + "integrity": "sha512-xvgv6pkMGBA6GwdyJbNAnDmfAIR/DfWhrj9jgWh3TY7gRm3KO46x/GPjRg6wJ0nOepwqrNxFfojebh0Df4h4Tw==", + "dev": true, + "dependencies": { + "lodash.assignwith": "^4.2.0", + "typical": "^7.1.1" + }, + "engines": { + "node": ">=12.17" + } + }, + "node_modules/@75lb/deep-merge/node_modules/typical": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/typical/-/typical-7.1.1.tgz", + "integrity": "sha512-T+tKVNs6Wu7IWiAce5BgMd7OZfNYUndHwc5MknN+UHOudi7sGZzuHdCadllRuqJ3fPtgFtIH9+lt9qRv6lmpfA==", + "dev": true, + "engines": { + "node": ">=12.17" + } + }, + "node_modules/@adobe/lit-mobx": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/@adobe/lit-mobx/-/lit-mobx-2.2.2.tgz", + "integrity": "sha512-TKmaEgu0m8dxydo0cAhJ5qaNoa/moQr8I3E9DtxVb0OSu/huXps+gUg/6oz7sYllcSl4KFZtzfyfx7EstbQ9tw==", + "peerDependencies": { + "lit": "^2.0.0 || ^3.0.0", + "mobx": "^5.0.0 || ^6.0.0" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.24.2", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.24.2.tgz", + "integrity": "sha512-y5+tLQyV8pg3fsiln67BVLD1P13Eg4lh5RW9mF0zUuvLrv9uIQ4MCL+CRT+FTsBlBjcIan6PGsLcBN0m3ClUyQ==", + "dev": true, + "dependencies": { + "@babel/highlight": "^7.24.2", + "picocolors": "^1.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.24.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.5.tgz", + "integrity": "sha512-3q93SSKX2TWCG30M2G2kwaKeTYgEUp5Snjuj8qm729SObL6nbtUldAi37qbxkD5gg3xnBio+f9nqpSepGZMvxA==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight": { + "version": "7.24.5", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.24.5.tgz", + "integrity": "sha512-8lLmua6AVh/8SLJRRVD6V8p73Hir9w5mJrhE+IPpILG31KKlI9iz5zmBYKcWPS59qSfgP9RaSBQSHHE81WKuEw==", + "dev": true, + "dependencies": { + "@babel/helper-validator-identifier": "^7.24.5", + "chalk": "^2.4.2", + "js-tokens": "^4.0.0", + "picocolors": "^1.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.20.2.tgz", + "integrity": "sha512-1MdwI6OOTsfQfek8sLwgyjOXAu+wKhLEoaOLTjbijk6E2WONYpH9ZU2mNtR+lZ2B4uwr+usqGuVfFT9tMtGvGw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@lit-labs/ssr-dom-shim": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.2.0.tgz", + "integrity": "sha512-yWJKmpGE6lUURKAaIltoPIE/wrbY3TEkqQt+X0m+7fQNnAv0keydnYvbiJFP1PnMhizmIWRWOG5KLhYyc/xl+g==" + }, + "node_modules/@lit/reactive-element": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-2.0.4.tgz", + "integrity": "sha512-GFn91inaUa2oHLak8awSIigYz0cU0Payr1rcFsrkf5OJ5eSPxElyZfKh0f2p9FsTiZWXQdWGJeXZICEfXXYSXQ==", + "dependencies": { + "@lit-labs/ssr-dom-shim": "^1.2.0" + } + }, + "node_modules/@material/animation": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/animation/-/animation-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-GBuR4VmcTQW1D0lPXEosf5Giho72LLbyGIydWGtaEUtLJoive/D9kFkwTN4Fsyt9Kkl7hbhs35vrNe6QkAH4/Q==", + "dependencies": { + "tslib": "^2.1.0" + } + }, + "node_modules/@material/base": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/base/-/base-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-UJKbXwZtkrA3sfQDmj8Zbw1Q3Tqtl6KdfVFws95Yf7TCUgTFzbZI/FSx1w7dVugQPOEnIBuZnzqZam/MtHkx4w==", + "dependencies": { + "tslib": "^2.1.0" + } + }, + "node_modules/@material/density": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/density/-/density-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-Eh/vZ3vVyqtpylg5Ci33qlgtToS4H1/ppd450Ib3tcdISIoodgijYY0w4XsRvrnZgbI/h/1STFdLxdzS0UNuFw==", + "dependencies": { + "tslib": "^2.1.0" + } + }, + "node_modules/@material/dom": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/dom/-/dom-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-aR+rfncF6oi2ivdOlKSJI4UXwNzWV5rXM88MLDoSJF1D7lXxhAKhge+tMUBodWGV/q0+FnXLuVAa0WYTrKjo+A==", + "dependencies": { + "@material/feature-targeting": "14.0.0-canary.53b3cad2f.0", + "tslib": "^2.1.0" + } + }, + "node_modules/@material/elevation": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/elevation/-/elevation-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-3h+EkR588RMZ5TSNQ4UeXD1FOBnL3ABQix0DQIGwtNJCqSMoPndT/oJEFvwQbTkZNDbFIKN9p1Q7/KuFPVY8Pw==", + "dependencies": { + "@material/animation": "14.0.0-canary.53b3cad2f.0", + "@material/base": "14.0.0-canary.53b3cad2f.0", + "@material/feature-targeting": "14.0.0-canary.53b3cad2f.0", + "@material/rtl": "14.0.0-canary.53b3cad2f.0", + "@material/theme": "14.0.0-canary.53b3cad2f.0", + "tslib": "^2.1.0" + } + }, + "node_modules/@material/feature-targeting": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/feature-targeting/-/feature-targeting-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-fn7Af3PRyARtNeYqtjxXmE3Y/dCpnpQVWWys57MqiGR/nvc6qpgOfJ6rOdcu/MrOysOE/oebTUDmDnTmwpe9Hw==", + "dependencies": { + "tslib": "^2.1.0" + } + }, + "node_modules/@material/focus-ring": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/focus-ring/-/focus-ring-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-exPX5VrjQimipBwgcFDGRiEE783sOBgpkFui59A6i6iGvS2UrLHlYY2E65fyyyQnD1f/rv4Po1OOnCesE1kulg==", + "dependencies": { + "@material/dom": "14.0.0-canary.53b3cad2f.0", + "@material/feature-targeting": "14.0.0-canary.53b3cad2f.0", + "@material/rtl": "14.0.0-canary.53b3cad2f.0" + } + }, + "node_modules/@material/mwc-base": { + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@material/mwc-base/-/mwc-base-0.27.0.tgz", + "integrity": "sha512-oCWWtjbyQ52AaUbzINLGBKScIPyqhps2Y7c8t6Gu6fcFeDxhKXMV1Cqvtj/OMhtAt53XjHfD2XruWwYv3cYYUA==", + "deprecated": "MWC beta is longer supported. Please upgrade to @material/web", + "dependencies": { + "@material/base": "=14.0.0-canary.53b3cad2f.0", + "@material/dom": "=14.0.0-canary.53b3cad2f.0", + "lit": "^2.0.0", + "tslib": "^2.0.1" + } + }, + "node_modules/@material/mwc-base/node_modules/@lit/reactive-element": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-1.6.3.tgz", + "integrity": "sha512-QuTgnG52Poic7uM1AN5yJ09QMe0O28e10XzSvWDz02TJiiKee4stsiownEIadWm8nYzyDAyT+gKzUoZmiWQtsQ==", + "dependencies": { + "@lit-labs/ssr-dom-shim": "^1.0.0" + } + }, + "node_modules/@material/mwc-base/node_modules/lit": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/lit/-/lit-2.8.0.tgz", + "integrity": "sha512-4Sc3OFX9QHOJaHbmTMk28SYgVxLN3ePDjg7hofEft2zWlehFL3LiAuapWc4U/kYwMYJSh2hTCPZ6/LIC7ii0MA==", + "dependencies": { + "@lit/reactive-element": "^1.6.0", + "lit-element": "^3.3.0", + "lit-html": "^2.8.0" + } + }, + "node_modules/@material/mwc-base/node_modules/lit-element": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/lit-element/-/lit-element-3.3.3.tgz", + "integrity": "sha512-XbeRxmTHubXENkV4h8RIPyr8lXc+Ff28rkcQzw3G6up2xg5E8Zu1IgOWIwBLEQsu3cOVFqdYwiVi0hv0SlpqUA==", + "dependencies": { + "@lit-labs/ssr-dom-shim": "^1.1.0", + "@lit/reactive-element": "^1.3.0", + "lit-html": "^2.8.0" + } + }, + "node_modules/@material/mwc-base/node_modules/lit-html": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-2.8.0.tgz", + "integrity": "sha512-o9t+MQM3P4y7M7yNzqAyjp7z+mQGa4NS4CxiyLqFPyFWyc4O+nodLrkrxSaCTrla6M5YOLaT3RpbbqjszB5g3Q==", + "dependencies": { + "@types/trusted-types": "^2.0.2" + } + }, + "node_modules/@material/mwc-icon": { + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@material/mwc-icon/-/mwc-icon-0.27.0.tgz", + "integrity": "sha512-Sul44I37M9Ewynn0A9DjkEBrmll2VtNbth6Pxj7I1A/EAwEfaCrPvryyGqfIu1T2hTsRcaojzQx6QjF+B5QW9A==", + "deprecated": "MWC beta is longer supported. Please upgrade to @material/web", + "dependencies": { + "lit": "^2.0.0", + "tslib": "^2.0.1" + } + }, + "node_modules/@material/mwc-icon/node_modules/@lit/reactive-element": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-1.6.3.tgz", + "integrity": "sha512-QuTgnG52Poic7uM1AN5yJ09QMe0O28e10XzSvWDz02TJiiKee4stsiownEIadWm8nYzyDAyT+gKzUoZmiWQtsQ==", + "dependencies": { + "@lit-labs/ssr-dom-shim": "^1.0.0" + } + }, + "node_modules/@material/mwc-icon/node_modules/lit": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/lit/-/lit-2.8.0.tgz", + "integrity": "sha512-4Sc3OFX9QHOJaHbmTMk28SYgVxLN3ePDjg7hofEft2zWlehFL3LiAuapWc4U/kYwMYJSh2hTCPZ6/LIC7ii0MA==", + "dependencies": { + "@lit/reactive-element": "^1.6.0", + "lit-element": "^3.3.0", + "lit-html": "^2.8.0" + } + }, + "node_modules/@material/mwc-icon/node_modules/lit-element": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/lit-element/-/lit-element-3.3.3.tgz", + "integrity": "sha512-XbeRxmTHubXENkV4h8RIPyr8lXc+Ff28rkcQzw3G6up2xg5E8Zu1IgOWIwBLEQsu3cOVFqdYwiVi0hv0SlpqUA==", + "dependencies": { + "@lit-labs/ssr-dom-shim": "^1.1.0", + "@lit/reactive-element": "^1.3.0", + "lit-html": "^2.8.0" + } + }, + "node_modules/@material/mwc-icon/node_modules/lit-html": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-2.8.0.tgz", + "integrity": "sha512-o9t+MQM3P4y7M7yNzqAyjp7z+mQGa4NS4CxiyLqFPyFWyc4O+nodLrkrxSaCTrla6M5YOLaT3RpbbqjszB5g3Q==", + "dependencies": { + "@types/trusted-types": "^2.0.2" + } + }, + "node_modules/@material/mwc-ripple": { + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@material/mwc-ripple/-/mwc-ripple-0.27.0.tgz", + "integrity": "sha512-by0O8d8g3Rd96/sUB8hxy6MrDx1QTstqOsA64vqypWd526hMTBGRik08jTNap5sVIyrN9Vq17jb4NJLWQLnNHQ==", + "deprecated": "MWC beta is longer supported. Please upgrade to @material/web", + "dependencies": { + "@material/dom": "=14.0.0-canary.53b3cad2f.0", + "@material/mwc-base": "^0.27.0", + "@material/ripple": "=14.0.0-canary.53b3cad2f.0", + "lit": "^2.0.0", + "tslib": "^2.0.1" + } + }, + "node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-1.6.3.tgz", + "integrity": "sha512-QuTgnG52Poic7uM1AN5yJ09QMe0O28e10XzSvWDz02TJiiKee4stsiownEIadWm8nYzyDAyT+gKzUoZmiWQtsQ==", + "dependencies": { + "@lit-labs/ssr-dom-shim": "^1.0.0" + } + }, + "node_modules/@material/mwc-ripple/node_modules/lit": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/lit/-/lit-2.8.0.tgz", + "integrity": "sha512-4Sc3OFX9QHOJaHbmTMk28SYgVxLN3ePDjg7hofEft2zWlehFL3LiAuapWc4U/kYwMYJSh2hTCPZ6/LIC7ii0MA==", + "dependencies": { + "@lit/reactive-element": "^1.6.0", + "lit-element": "^3.3.0", + "lit-html": "^2.8.0" + } + }, + "node_modules/@material/mwc-ripple/node_modules/lit-element": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/lit-element/-/lit-element-3.3.3.tgz", + "integrity": "sha512-XbeRxmTHubXENkV4h8RIPyr8lXc+Ff28rkcQzw3G6up2xg5E8Zu1IgOWIwBLEQsu3cOVFqdYwiVi0hv0SlpqUA==", + "dependencies": { + "@lit-labs/ssr-dom-shim": "^1.1.0", + "@lit/reactive-element": "^1.3.0", + "lit-html": "^2.8.0" + } + }, + "node_modules/@material/mwc-ripple/node_modules/lit-html": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-2.8.0.tgz", + "integrity": "sha512-o9t+MQM3P4y7M7yNzqAyjp7z+mQGa4NS4CxiyLqFPyFWyc4O+nodLrkrxSaCTrla6M5YOLaT3RpbbqjszB5g3Q==", + "dependencies": { + "@types/trusted-types": "^2.0.2" + } + }, + "node_modules/@material/mwc-switch": { + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@material/mwc-switch/-/mwc-switch-0.27.0.tgz", + "integrity": "sha512-MKKjm42f8YyHN1HmvfgppgTPJUxulcmOqND5R7zI/kB38vFcWDxEhnpdUYr2kEsFtebpYNSF0j6FXcKV/W+fJw==", + "deprecated": "MWC beta is longer supported. Please upgrade to @material/web", + "dependencies": { + "@material/mwc-base": "^0.27.0", + "@material/mwc-ripple": "^0.27.0", + "@material/switch": "=14.0.0-canary.53b3cad2f.0", + "lit": "^2.0.0", + "tslib": "^2.0.1" + } + }, + "node_modules/@material/mwc-switch/node_modules/@lit/reactive-element": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-1.6.3.tgz", + "integrity": "sha512-QuTgnG52Poic7uM1AN5yJ09QMe0O28e10XzSvWDz02TJiiKee4stsiownEIadWm8nYzyDAyT+gKzUoZmiWQtsQ==", + "dependencies": { + "@lit-labs/ssr-dom-shim": "^1.0.0" + } + }, + "node_modules/@material/mwc-switch/node_modules/lit": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/lit/-/lit-2.8.0.tgz", + "integrity": "sha512-4Sc3OFX9QHOJaHbmTMk28SYgVxLN3ePDjg7hofEft2zWlehFL3LiAuapWc4U/kYwMYJSh2hTCPZ6/LIC7ii0MA==", + "dependencies": { + "@lit/reactive-element": "^1.6.0", + "lit-element": "^3.3.0", + "lit-html": "^2.8.0" + } + }, + "node_modules/@material/mwc-switch/node_modules/lit-element": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/lit-element/-/lit-element-3.3.3.tgz", + "integrity": "sha512-XbeRxmTHubXENkV4h8RIPyr8lXc+Ff28rkcQzw3G6up2xg5E8Zu1IgOWIwBLEQsu3cOVFqdYwiVi0hv0SlpqUA==", + "dependencies": { + "@lit-labs/ssr-dom-shim": "^1.1.0", + "@lit/reactive-element": "^1.3.0", + "lit-html": "^2.8.0" + } + }, + "node_modules/@material/mwc-switch/node_modules/lit-html": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-2.8.0.tgz", + "integrity": "sha512-o9t+MQM3P4y7M7yNzqAyjp7z+mQGa4NS4CxiyLqFPyFWyc4O+nodLrkrxSaCTrla6M5YOLaT3RpbbqjszB5g3Q==", + "dependencies": { + "@types/trusted-types": "^2.0.2" + } + }, + "node_modules/@material/ripple": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/ripple/-/ripple-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-6g2G62vd8DsMuIUSXlRrzb98qkZ4o8ZREknNwNP2zaLQEOkJ//4j9HaqDt98/3LIjUTY9UIVFTQENiMmlwKHYQ==", + "dependencies": { + "@material/animation": "14.0.0-canary.53b3cad2f.0", + "@material/base": "14.0.0-canary.53b3cad2f.0", + "@material/dom": "14.0.0-canary.53b3cad2f.0", + "@material/feature-targeting": "14.0.0-canary.53b3cad2f.0", + "@material/rtl": "14.0.0-canary.53b3cad2f.0", + "@material/theme": "14.0.0-canary.53b3cad2f.0", + "tslib": "^2.1.0" + } + }, + "node_modules/@material/rtl": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/rtl/-/rtl-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-f08LT0HSa0WYU+4Jz/tbm1TQ9Fcf2k+H6dPPYv0J1sZmX6hMgCEmNiUdUFLQFvszoXx2XrRi1/hIFjbz2e69Yg==", + "dependencies": { + "@material/theme": "14.0.0-canary.53b3cad2f.0", + "tslib": "^2.1.0" + } + }, + "node_modules/@material/shape": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/shape/-/shape-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-RyjInLCNe+nI/ulKea0ZLHphXQDiDqYazS25SRn18g8Hoa5qGNaY5oOBncDXUYn3jm5oI5kFc9oif//kulkbjg==", + "dependencies": { + "@material/feature-targeting": "14.0.0-canary.53b3cad2f.0", + "@material/rtl": "14.0.0-canary.53b3cad2f.0", + "@material/theme": "14.0.0-canary.53b3cad2f.0", + "tslib": "^2.1.0" + } + }, + "node_modules/@material/switch": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/switch/-/switch-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-hL7lOF8tgYaS1Spce6zlxfveoqUlqDTW+vv+R7TIHwzLD5HJCdhTiotXshOKCZLoSi7Ljx7JpCdvNqGlv4rpIw==", + "dependencies": { + "@material/animation": "14.0.0-canary.53b3cad2f.0", + "@material/base": "14.0.0-canary.53b3cad2f.0", + "@material/density": "14.0.0-canary.53b3cad2f.0", + "@material/dom": "14.0.0-canary.53b3cad2f.0", + "@material/elevation": "14.0.0-canary.53b3cad2f.0", + "@material/feature-targeting": "14.0.0-canary.53b3cad2f.0", + "@material/focus-ring": "14.0.0-canary.53b3cad2f.0", + "@material/ripple": "14.0.0-canary.53b3cad2f.0", + "@material/rtl": "14.0.0-canary.53b3cad2f.0", + "@material/shape": "14.0.0-canary.53b3cad2f.0", + "@material/theme": "14.0.0-canary.53b3cad2f.0", + "@material/tokens": "14.0.0-canary.53b3cad2f.0", + "tslib": "^2.1.0" + } + }, + "node_modules/@material/theme": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/theme/-/theme-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-S06XAevDCDWMe+GgsEpITMS07imUidzadNaTbJsqssFajBLr53QWVZsG84BpjXKXoYvyEJvb0hX5U0lq6ip9UQ==", + "dependencies": { + "@material/feature-targeting": "14.0.0-canary.53b3cad2f.0", + "tslib": "^2.1.0" + } + }, + "node_modules/@material/tokens": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/tokens/-/tokens-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-myHFB7vac8zErA3qgkqmV+kpE+i9JEwc/6Yf0MOumDSpylJGw28QikpNC6eAVBK2EmPQTaFn20mqUxyud8dGqw==", + "dependencies": { + "@material/elevation": "14.0.0-canary.53b3cad2f.0" + } + }, + "node_modules/@pwrs/lit-css": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@pwrs/lit-css/-/lit-css-3.0.0.tgz", + "integrity": "sha512-10Xod+Z8jh/uHRmgRjMwroXHoG7hVgMcl3G+4FvS3B1yzyopF0niFjCEyg+ZXeLWBJ45BckyyP8aZtZhtk5EYQ==", + "dev": true, + "dependencies": { + "cssnano": "^6.1.2" + } + }, + "node_modules/@rollup/plugin-node-resolve": { + "version": "15.2.3", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.2.3.tgz", + "integrity": "sha512-j/lym8nf5E21LwBT4Df1VD6hRO2L2iwUeUmP7litikRsVp1H6NWx20NEp0Y7su+7XGc476GnXXc4kFeZNGmaSQ==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "@types/resolve": "1.20.2", + "deepmerge": "^4.2.2", + "is-builtin-module": "^3.2.1", + "is-module": "^1.0.0", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.78.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/pluginutils": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.0.tgz", + "integrity": "sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==", + "dev": true, + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.17.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.17.2.tgz", + "integrity": "sha512-Hy7pLwByUOuyaFC6mAr7m+oMC+V7qyifzs/nW2OJfC8H4hbCzOX07Ov0VFk/zP3kBsELWNFi7rJtgbKYsav9QQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.17.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.17.2.tgz", + "integrity": "sha512-h1+yTWeYbRdAyJ/jMiVw0l6fOOm/0D1vNLui9iPuqgRGnXA0u21gAqOyB5iHjlM9MMfNOm9RHCQ7zLIzT0x11Q==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@trysound/sax": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@trysound/sax/-/sax-0.2.0.tgz", + "integrity": "sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==", + "dev": true, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/@types/accepts": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/@types/accepts/-/accepts-1.3.7.tgz", + "integrity": "sha512-Pay9fq2lM2wXPWbteBsRAGiWH2hig4ZE2asK+mm7kUzlxRTfL961rj89I6zV/E3PcIkDqyuBEcMxFT7rccugeQ==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/body-parser": { + "version": "1.19.5", + "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.5.tgz", + "integrity": "sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg==", + "dev": true, + "dependencies": { + "@types/connect": "*", + "@types/node": "*" + } + }, + "node_modules/@types/command-line-args": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/@types/command-line-args/-/command-line-args-5.2.3.tgz", + "integrity": "sha512-uv0aG6R0Y8WHZLTamZwtfsDLVRnOa+n+n5rEvFWL5Na5gZ8V2Teab/duDPFzIIIhs9qizDpcavCusCLJZu62Kw==", + "dev": true + }, + "node_modules/@types/connect": { + "version": "3.4.38", + "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz", + "integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/content-disposition": { + "version": "0.5.8", + "resolved": "https://registry.npmjs.org/@types/content-disposition/-/content-disposition-0.5.8.tgz", + "integrity": "sha512-QVSSvno3dE0MgO76pJhmv4Qyi/j0Yk9pBp0Y7TJ2Tlj+KCgJWY6qX7nnxCOLkZ3VYRSIk1WTxCvwUSdx6CCLdg==", + "dev": true + }, + "node_modules/@types/cookies": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/@types/cookies/-/cookies-0.9.0.tgz", + "integrity": "sha512-40Zk8qR147RABiQ7NQnBzWzDcjKzNrntB5BAmeGCb2p/MIyOE+4BVvc17wumsUqUw00bJYqoXFHYygQnEFh4/Q==", + "dev": true, + "dependencies": { + "@types/connect": "*", + "@types/express": "*", + "@types/keygrip": "*", + "@types/node": "*" + } + }, + "node_modules/@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "dev": true + }, + "node_modules/@types/express": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.21.tgz", + "integrity": "sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ==", + "dev": true, + "dependencies": { + "@types/body-parser": "*", + "@types/express-serve-static-core": "^4.17.33", + "@types/qs": "*", + "@types/serve-static": "*" + } + }, + "node_modules/@types/express-serve-static-core": { + "version": "4.19.0", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.19.0.tgz", + "integrity": "sha512-bGyep3JqPCRry1wq+O5n7oiBgGWmeIJXPjXXCo8EK0u8duZGSYar7cGqd3ML2JUsLGeB7fmc06KYo9fLGWqPvQ==", + "dev": true, + "dependencies": { + "@types/node": "*", + "@types/qs": "*", + "@types/range-parser": "*", + "@types/send": "*" + } + }, + "node_modules/@types/http-assert": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@types/http-assert/-/http-assert-1.5.5.tgz", + "integrity": "sha512-4+tE/lwdAahgZT1g30Jkdm9PzFRde0xwxBNUyRsCitRvCQB90iuA2uJYdUnhnANRcqGXaWOGY4FEoxeElNAK2g==", + "dev": true + }, + "node_modules/@types/http-errors": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.4.tgz", + "integrity": "sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA==", + "dev": true + }, + "node_modules/@types/keygrip": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/keygrip/-/keygrip-1.0.6.tgz", + "integrity": "sha512-lZuNAY9xeJt7Bx4t4dx0rYCDqGPW8RXhQZK1td7d4H6E9zYbLoOtjBvfwdTKpsyxQI/2jv+armjX/RW+ZNpXOQ==", + "dev": true + }, + "node_modules/@types/koa": { + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/@types/koa/-/koa-2.15.0.tgz", + "integrity": "sha512-7QFsywoE5URbuVnG3loe03QXuGajrnotr3gQkXcEBShORai23MePfFYdhz90FEtBBpkyIYQbVD+evKtloCgX3g==", + "dev": true, + "dependencies": { + "@types/accepts": "*", + "@types/content-disposition": "*", + "@types/cookies": "*", + "@types/http-assert": "*", + "@types/http-errors": "*", + "@types/keygrip": "*", + "@types/koa-compose": "*", + "@types/node": "*" + } + }, + "node_modules/@types/koa-compose": { + "version": "3.2.8", + "resolved": "https://registry.npmjs.org/@types/koa-compose/-/koa-compose-3.2.8.tgz", + "integrity": "sha512-4Olc63RY+MKvxMwVknCUDhRQX1pFQoBZ/lXcRLP69PQkEpze/0cr8LNqJQe5NFb/b19DWi2a5bTi2VAlQzhJuA==", + "dev": true, + "dependencies": { + "@types/koa": "*" + } + }, + "node_modules/@types/mime": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz", + "integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==", + "dev": true + }, + "node_modules/@types/node": { + "version": "20.12.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.11.tgz", + "integrity": "sha512-vDg9PZ/zi+Nqp6boSOT7plNuthRugEKixDv5sFTIpkE89MmNtEArAShI4mxuX2+UrLEe9pxC1vm2cjm9YlWbJw==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/@types/parse5": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/@types/parse5/-/parse5-6.0.3.tgz", + "integrity": "sha512-SuT16Q1K51EAVPz1K29DJ/sXjhSQ0zjvsypYJ6tlwVsRV9jwW5Adq2ch8Dq8kDBCkYnELS7N7VNCSB5nC56t/g==", + "dev": true + }, + "node_modules/@types/qs": { + "version": "6.9.15", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.15.tgz", + "integrity": "sha512-uXHQKES6DQKKCLh441Xv/dwxOq1TVS3JPUMlEqoEglvlhR6Mxnlew/Xq/LRVHpLyk7iK3zODe1qYHIMltO7XGg==", + "dev": true + }, + "node_modules/@types/range-parser": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.7.tgz", + "integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==", + "dev": true + }, + "node_modules/@types/resolve": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", + "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==", + "dev": true + }, + "node_modules/@types/send": { + "version": "0.17.4", + "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.4.tgz", + "integrity": "sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA==", + "dev": true, + "dependencies": { + "@types/mime": "^1", + "@types/node": "*" + } + }, + "node_modules/@types/serve-static": { + "version": "1.15.7", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.7.tgz", + "integrity": "sha512-W8Ym+h8nhuRwaKPaDw34QUkwsGi6Rc4yYqvKFo5rm2FUEhCFbzVWrxXUxuKK8TASjWsysJY0nsmNCGhCOIsrOw==", + "dev": true, + "dependencies": { + "@types/http-errors": "*", + "@types/node": "*", + "@types/send": "*" + } + }, + "node_modules/@types/trusted-types": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", + "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==" + }, + "node_modules/@types/ws": { + "version": "7.4.7", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz", + "integrity": "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@web/config-loader": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@web/config-loader/-/config-loader-0.3.1.tgz", + "integrity": "sha512-IYjHXUgSGGNpO3YJQ9foLcazbJlAWDdJGRe9be7aOhon0Nd6Na5JIOJAej7jsMu76fKHr4b4w2LfIdNQ4fJ8pA==", + "dev": true, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@web/dev-server": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/@web/dev-server/-/dev-server-0.4.4.tgz", + "integrity": "sha512-Gye0DhDbst/KVNRCFzRd+4V9LJmuuQYJBsf6UXeEbCYuBSKeshEW4AA1esLsfy1gONsD6NIGiru5509l35P9Ug==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.12.11", + "@types/command-line-args": "^5.0.0", + "@web/config-loader": "^0.3.0", + "@web/dev-server-core": "^0.7.1", + "@web/dev-server-rollup": "^0.6.1", + "camelcase": "^6.2.0", + "command-line-args": "^5.1.1", + "command-line-usage": "^7.0.1", + "debounce": "^1.2.0", + "deepmerge": "^4.2.2", + "ip": "^2.0.1", + "nanocolors": "^0.2.1", + "open": "^8.0.2", + "portfinder": "^1.0.32" + }, + "bin": { + "wds": "dist/bin.js", + "web-dev-server": "dist/bin.js" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@web/dev-server-core": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/@web/dev-server-core/-/dev-server-core-0.7.2.tgz", + "integrity": "sha512-Q/0jpF13Ipk+qGGQ+Yx/FW1TQBYazpkfgYHHo96HBE7qv4V4KKHqHglZcSUxti/zd4bToxX1cFTz8dmbTlb8JA==", + "dev": true, + "dependencies": { + "@types/koa": "^2.11.6", + "@types/ws": "^7.4.0", + "@web/parse5-utils": "^2.1.0", + "chokidar": "^3.4.3", + "clone": "^2.1.2", + "es-module-lexer": "^1.0.0", + "get-stream": "^6.0.0", + "is-stream": "^2.0.0", + "isbinaryfile": "^5.0.0", + "koa": "^2.13.0", + "koa-etag": "^4.0.0", + "koa-send": "^5.0.1", + "koa-static": "^5.0.0", + "lru-cache": "^8.0.4", + "mime-types": "^2.1.27", + "parse5": "^6.0.1", + "picomatch": "^2.2.2", + "ws": "^7.4.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@web/dev-server-rollup": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/@web/dev-server-rollup/-/dev-server-rollup-0.6.3.tgz", + "integrity": "sha512-dzMwQRBk9Rhpfoo7vvQGvRP18sDELejJCwxsMdt509aLouIB6fviv0i87DJQWbXH24hBeq6+jSILI3JTtVaPZQ==", + "dev": true, + "dependencies": { + "@rollup/plugin-node-resolve": "^15.0.1", + "@web/dev-server-core": "^0.7.2", + "nanocolors": "^0.2.1", + "parse5": "^6.0.1", + "rollup": "^4.4.0", + "whatwg-url": "^11.0.0" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@web/parse5-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@web/parse5-utils/-/parse5-utils-2.1.0.tgz", + "integrity": "sha512-GzfK5disEJ6wEjoPwx8AVNwUe9gYIiwc+x//QYxYDAFKUp4Xb1OJAGLc2l2gVrSQmtPGLKrTRcW90Hv4pEq1qA==", + "dev": true, + "dependencies": { + "@types/parse5": "^6.0.1", + "parse5": "^6.0.1" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "dev": true, + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/array-back": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-3.1.0.tgz", + "integrity": "sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/async": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", + "dev": true, + "dependencies": { + "lodash": "^4.17.14" + } + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", + "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==", + "dev": true + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browserslist": { + "version": "4.23.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.0.tgz", + "integrity": "sha512-QW8HiM1shhT2GuzkvklfjcKDiWFXHOeFCIA/huJPwHsslwcydgk7X+z2zXpEijP98UCY7HbubZt5J2Zgvf0CaQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "caniuse-lite": "^1.0.30001587", + "electron-to-chromium": "^1.4.668", + "node-releases": "^2.0.14", + "update-browserslist-db": "^1.0.13" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/builtin-modules": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", + "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", + "dev": true, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/cache-content-type": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cache-content-type/-/cache-content-type-1.0.1.tgz", + "integrity": "sha512-IKufZ1o4Ut42YUrZSo8+qnMTrFuKkvyoLXUywKz9GJ5BrhOFGhLdkx9sG4KAnVvbY6kEcSFjLQul+DVmBm2bgA==", + "dev": true, + "dependencies": { + "mime-types": "^2.1.18", + "ylru": "^1.2.0" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/caniuse-api": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/caniuse-api/-/caniuse-api-3.0.0.tgz", + "integrity": "sha512-bsTwuIg/BZZK/vreVTYYbSWoe2F+71P7K5QGEX+pT250DZbfU1MQ5prOKpPR+LL6uWKK3KMwMCAS74QB3Um1uw==", + "dev": true, + "dependencies": { + "browserslist": "^4.0.0", + "caniuse-lite": "^1.0.0", + "lodash.memoize": "^4.1.2", + "lodash.uniq": "^4.5.0" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001617", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001617.tgz", + "integrity": "sha512-mLyjzNI9I+Pix8zwcrpxEbGlfqOkF9kM3ptzmKNw5tizSyYwMe+nGLTqMK9cO+0E+Bh6TsBxNAaHWEM8xwSsmA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ] + }, + "node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/chalk-template": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/chalk-template/-/chalk-template-0.4.0.tgz", + "integrity": "sha512-/ghrgmhfY8RaSdeo43hNXxpoHAtxdbskUHjPpfqUWGttFgycUhYPGx3YZBCnUCvOa7Doivn1IZec3DEGFoMgLg==", + "dev": true, + "dependencies": { + "chalk": "^4.1.2" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/chalk-template?sponsor=1" + } + }, + "node_modules/chalk-template/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/chalk-template/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chalk-template/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/chalk-template/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/chalk-template/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/chalk-template/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/clone": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", + "integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==", + "dev": true, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==", + "dev": true, + "engines": { + "iojs": ">= 1.0.0", + "node": ">= 0.12.0" + } + }, + "node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, + "node_modules/colord": { + "version": "2.9.3", + "resolved": "https://registry.npmjs.org/colord/-/colord-2.9.3.tgz", + "integrity": "sha512-jeC1axXpnb0/2nn/Y1LPuLdgXBLH7aDcHu4KEKfqw3CUhX7ZpfBSlPKyqXE6btIgEzfWtrX3/tyBCaCvXvMkOw==", + "dev": true + }, + "node_modules/command-line-args": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/command-line-args/-/command-line-args-5.2.1.tgz", + "integrity": "sha512-H4UfQhZyakIjC74I9d34fGYDwk3XpSr17QhEd0Q3I9Xq1CETHo4Hcuo87WyWHpAF1aSLjLRf5lD9ZGX2qStUvg==", + "dev": true, + "dependencies": { + "array-back": "^3.1.0", + "find-replace": "^3.0.0", + "lodash.camelcase": "^4.3.0", + "typical": "^4.0.0" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/command-line-usage": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/command-line-usage/-/command-line-usage-7.0.1.tgz", + "integrity": "sha512-NCyznE//MuTjwi3y84QVUGEOT+P5oto1e1Pk/jFPVdPPfsG03qpTIl3yw6etR+v73d0lXsoojRpvbru2sqePxQ==", + "dev": true, + "dependencies": { + "array-back": "^6.2.2", + "chalk-template": "^0.4.0", + "table-layout": "^3.0.0", + "typical": "^7.1.1" + }, + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/command-line-usage/node_modules/array-back": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-6.2.2.tgz", + "integrity": "sha512-gUAZ7HPyb4SJczXAMUXMGAvI976JoK3qEx9v1FTmeYuJj0IBiaKttG1ydtGKdkfqWkIkouke7nG8ufGy77+Cvw==", + "dev": true, + "engines": { + "node": ">=12.17" + } + }, + "node_modules/command-line-usage/node_modules/typical": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/typical/-/typical-7.1.1.tgz", + "integrity": "sha512-T+tKVNs6Wu7IWiAce5BgMd7OZfNYUndHwc5MknN+UHOudi7sGZzuHdCadllRuqJ3fPtgFtIH9+lt9qRv6lmpfA==", + "dev": true, + "engines": { + "node": ">=12.17" + } + }, + "node_modules/commander": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", + "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", + "dev": true, + "engines": { + "node": ">= 10" + } + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "dev": true, + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookies": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/cookies/-/cookies-0.9.1.tgz", + "integrity": "sha512-TG2hpqe4ELx54QER/S3HQ9SRVnQnGBtKUz5bLQWtYAQ+o6GpgMs6sYUvaiJjVxb+UXwhRhAEP3m7LbsIZ77Hmw==", + "dev": true, + "dependencies": { + "depd": "~2.0.0", + "keygrip": "~1.1.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/css-declaration-sorter": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-7.2.0.tgz", + "integrity": "sha512-h70rUM+3PNFuaBDTLe8wF/cdWu+dOZmb7pJt8Z2sedYbAcQVQV/tEchueg3GWxwqS0cxtbxmaHEdkNACqcvsow==", + "dev": true, + "engines": { + "node": "^14 || ^16 || >=18" + }, + "peerDependencies": { + "postcss": "^8.0.9" + } + }, + "node_modules/css-select": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz", + "integrity": "sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==", + "dev": true, + "dependencies": { + "boolbase": "^1.0.0", + "css-what": "^6.1.0", + "domhandler": "^5.0.2", + "domutils": "^3.0.1", + "nth-check": "^2.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/css-tree": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.3.1.tgz", + "integrity": "sha512-6Fv1DV/TYw//QF5IzQdqsNDjx/wc8TrMBZsqjL9eW01tWb7R7k/mq+/VXfJCl7SoD5emsJop9cOByJZfs8hYIw==", + "dev": true, + "dependencies": { + "mdn-data": "2.0.30", + "source-map-js": "^1.0.1" + }, + "engines": { + "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0" + } + }, + "node_modules/css-what": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.1.0.tgz", + "integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==", + "dev": true, + "engines": { + "node": ">= 6" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/cssesc": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", + "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", + "dev": true, + "bin": { + "cssesc": "bin/cssesc" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/cssnano": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/cssnano/-/cssnano-6.1.2.tgz", + "integrity": "sha512-rYk5UeX7VAM/u0lNqewCdasdtPK81CgX8wJFLEIXHbV2oldWRgJAsZrdhRXkV1NJzA2g850KiFm9mMU2HxNxMA==", + "dev": true, + "dependencies": { + "cssnano-preset-default": "^6.1.2", + "lilconfig": "^3.1.1" + }, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/cssnano" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/cssnano-preset-default": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/cssnano-preset-default/-/cssnano-preset-default-6.1.2.tgz", + "integrity": "sha512-1C0C+eNaeN8OcHQa193aRgYexyJtU8XwbdieEjClw+J9d94E41LwT6ivKH0WT+fYwYWB0Zp3I3IZ7tI/BbUbrg==", + "dev": true, + "dependencies": { + "browserslist": "^4.23.0", + "css-declaration-sorter": "^7.2.0", + "cssnano-utils": "^4.0.2", + "postcss-calc": "^9.0.1", + "postcss-colormin": "^6.1.0", + "postcss-convert-values": "^6.1.0", + "postcss-discard-comments": "^6.0.2", + "postcss-discard-duplicates": "^6.0.3", + "postcss-discard-empty": "^6.0.3", + "postcss-discard-overridden": "^6.0.2", + "postcss-merge-longhand": "^6.0.5", + "postcss-merge-rules": "^6.1.1", + "postcss-minify-font-values": "^6.1.0", + "postcss-minify-gradients": "^6.0.3", + "postcss-minify-params": "^6.1.0", + "postcss-minify-selectors": "^6.0.4", + "postcss-normalize-charset": "^6.0.2", + "postcss-normalize-display-values": "^6.0.2", + "postcss-normalize-positions": "^6.0.2", + "postcss-normalize-repeat-style": "^6.0.2", + "postcss-normalize-string": "^6.0.2", + "postcss-normalize-timing-functions": "^6.0.2", + "postcss-normalize-unicode": "^6.1.0", + "postcss-normalize-url": "^6.0.2", + "postcss-normalize-whitespace": "^6.0.2", + "postcss-ordered-values": "^6.0.2", + "postcss-reduce-initial": "^6.1.0", + "postcss-reduce-transforms": "^6.0.2", + "postcss-svgo": "^6.0.3", + "postcss-unique-selectors": "^6.0.4" + }, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/cssnano-utils": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/cssnano-utils/-/cssnano-utils-4.0.2.tgz", + "integrity": "sha512-ZR1jHg+wZ8o4c3zqf1SIUSTIvm/9mU343FMR6Obe/unskbvpGhZOo1J6d/r8D1pzkRQYuwbcH3hToOuoA2G7oQ==", + "dev": true, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/csso": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/csso/-/csso-5.0.5.tgz", + "integrity": "sha512-0LrrStPOdJj+SPCCrGhzryycLjwcgUSHBtxNA8aIDxf0GLsRh1cKYhB00Gd1lDOS4yGH69+SNn13+TWbVHETFQ==", + "dev": true, + "dependencies": { + "css-tree": "~2.2.0" + }, + "engines": { + "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0", + "npm": ">=7.0.0" + } + }, + "node_modules/csso/node_modules/css-tree": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.2.1.tgz", + "integrity": "sha512-OA0mILzGc1kCOCSJerOeqDxDQ4HOh+G8NbOJFOTgOCzpw7fCBubk0fEyxp8AgOL/jvLgYA/uV0cMbe43ElF1JA==", + "dev": true, + "dependencies": { + "mdn-data": "2.0.28", + "source-map-js": "^1.0.1" + }, + "engines": { + "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0", + "npm": ">=7.0.0" + } + }, + "node_modules/csso/node_modules/mdn-data": { + "version": "2.0.28", + "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.28.tgz", + "integrity": "sha512-aylIc7Z9y4yzHYAJNuESG3hfhC+0Ibp/MAMiaOZgNv4pmEdFyfZhhhny4MNiAfWdBQ1RQ2mfDWmM1x8SvGyp8g==", + "dev": true + }, + "node_modules/debounce": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/debounce/-/debounce-1.2.1.tgz", + "integrity": "sha512-XRRe6Glud4rd/ZGQfiV1ruXSfbvfJedlV9Y6zOlP+2K04vBYiJEte6stfFkCP03aMnY5tsipamumUjL14fofug==", + "dev": true + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deep-equal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", + "integrity": "sha512-bHtC0iYvWhyaTzvV3CZgPeZQqCOBGyGsVV7v4eevpdkLHfiSrXUdBG+qAuSz4RI70sszvjQ1QSZ98An1yNwpSw==", + "dev": true + }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/define-lazy-prop": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz", + "integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==", + "dev": true + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "dev": true, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "dev": true, + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + }, + "funding": { + "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" + } + }, + "node_modules/domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ] + }, + "node_modules/domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "dev": true, + "dependencies": { + "domelementtype": "^2.3.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/domutils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.1.0.tgz", + "integrity": "sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==", + "dev": true, + "dependencies": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3" + }, + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "dev": true + }, + "node_modules/electron-to-chromium": { + "version": "1.4.764", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.764.tgz", + "integrity": "sha512-ZXbPV46Y4dNCA+k7YHB+BYlzcoMtZ1yH6V0tQ1ul0wmA7RiwJfS29LSdRlE1myWBXRzEgm/Lz6tryj5WVQiLmg==", + "dev": true + }, + "node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "dev": true, + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/es-module-lexer": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.5.2.tgz", + "integrity": "sha512-l60ETUTmLqbVbVHv1J4/qj+M8nq7AwMzEcg3kmJDt9dCNrTk+yHcYFf/Kw75pMDwd9mPcIGCG5LcS20SxYRzFA==", + "dev": true + }, + "node_modules/esbuild": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.20.2.tgz", + "integrity": "sha512-WdOOppmUNU+IbZ0PaDiTst80zjnrOkyJNHoKupIcVyU8Lvla3Ugx94VzkQ32Ijqd7UhHJy75gNWDMUekcrSJ6g==", + "dev": true, + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.20.2", + "@esbuild/android-arm": "0.20.2", + "@esbuild/android-arm64": "0.20.2", + "@esbuild/android-x64": "0.20.2", + "@esbuild/darwin-arm64": "0.20.2", + "@esbuild/darwin-x64": "0.20.2", + "@esbuild/freebsd-arm64": "0.20.2", + "@esbuild/freebsd-x64": "0.20.2", + "@esbuild/linux-arm": "0.20.2", + "@esbuild/linux-arm64": "0.20.2", + "@esbuild/linux-ia32": "0.20.2", + "@esbuild/linux-loong64": "0.20.2", + "@esbuild/linux-mips64el": "0.20.2", + "@esbuild/linux-ppc64": "0.20.2", + "@esbuild/linux-riscv64": "0.20.2", + "@esbuild/linux-s390x": "0.20.2", + "@esbuild/linux-x64": "0.20.2", + "@esbuild/netbsd-x64": "0.20.2", + "@esbuild/openbsd-x64": "0.20.2", + "@esbuild/sunos-x64": "0.20.2", + "@esbuild/win32-arm64": "0.20.2", + "@esbuild/win32-ia32": "0.20.2", + "@esbuild/win32-x64": "0.20.2" + } + }, + "node_modules/esbuild-plugin-lit-css": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/esbuild-plugin-lit-css/-/esbuild-plugin-lit-css-3.0.0.tgz", + "integrity": "sha512-5xpMa9Kt6C07Qvjp6k0j5sbcnePd0+ejgeP/DXQFQSeTvNoF0uGrr/Tn8Y5oRZzFWtw9OkW3s/dZ7HvLR5APmQ==", + "dev": true, + "dependencies": { + "@pwrs/lit-css": "^3.0.0" + }, + "peerDependencies": { + "esbuild": "^0.16.17 || ^0.17.16 || ^0.18.1 || ^0.19.5 || ^0.20.0", + "lit": "^2.7.2 || ^3.0.0" + } + }, + "node_modules/escalade": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", + "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "dev": true + }, + "node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-replace": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-replace/-/find-replace-3.0.0.tgz", + "integrity": "sha512-6Tb2myMioCAgv5kfvP5/PkZZ/ntTpVK39fHY7WkWBgvbeE+VHd/tZuZ4mrC+bxh4cfOZeYKVPaJIZtZXV7GNCQ==", + "dev": true, + "dependencies": { + "array-back": "^3.0.1" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "dev": true, + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-assert": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/http-assert/-/http-assert-1.5.0.tgz", + "integrity": "sha512-uPpH7OKX4H25hBmU6G1jWNaqJGpTXxey+YOUizJUAgu0AjLUeC8D73hTrhvDS5D+GJN1DN1+hhc/eF/wpxtp0w==", + "dev": true, + "dependencies": { + "deep-equal": "~1.0.1", + "http-errors": "~1.8.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/http-errors": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", + "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", + "dev": true, + "dependencies": { + "depd": "~1.1.2", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/http-errors/node_modules/depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/ip": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.1.tgz", + "integrity": "sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==", + "dev": true + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-builtin-module": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.1.tgz", + "integrity": "sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==", + "dev": true, + "dependencies": { + "builtin-modules": "^3.3.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-core-module": { + "version": "2.13.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.1.tgz", + "integrity": "sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==", + "dev": true, + "dependencies": { + "hasown": "^2.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-docker": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "dev": true, + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-generator-function": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.10.tgz", + "integrity": "sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A==", + "dev": true, + "dependencies": { + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==", + "dev": true + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "dependencies": { + "is-docker": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/isbinaryfile": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-5.0.2.tgz", + "integrity": "sha512-GvcjojwonMjWbTkfMpnVHVqXW/wKMYDfEpY94/8zy8HFMOqb/VL6oeONq9v87q4ttVlaTLnGXnJD4B5B1OTGIg==", + "dev": true, + "engines": { + "node": ">= 18.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/gjtorikian/" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "node_modules/jsdifflib": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/jsdifflib/-/jsdifflib-1.1.0.tgz", + "integrity": "sha512-wsb7MeyPgKr7yNkyJa4VsM8uiqzchaZ4km5kcDzuYkGy8HNNEmeQGbPCnMy/yHWnPinORwIQSB+dnrdt8TFZPQ==" + }, + "node_modules/jstat": { + "version": "1.9.6", + "resolved": "https://registry.npmjs.org/jstat/-/jstat-1.9.6.tgz", + "integrity": "sha512-rPBkJbK2TnA8pzs93QcDDPlKcrtZWuuCo2dVR0TFLOJSxhqfWOVCSp8aV3/oSbn+4uY4yw1URtLpHQedtmXfug==" + }, + "node_modules/keygrip": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/keygrip/-/keygrip-1.1.0.tgz", + "integrity": "sha512-iYSchDJ+liQ8iwbSI2QqsQOvqv58eJCEanyJPJi+Khyu8smkcKSFUCbPwzFcL7YVtZ6eONjqRX/38caJ7QjRAQ==", + "dev": true, + "dependencies": { + "tsscmp": "1.0.6" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/koa": { + "version": "2.15.3", + "resolved": "https://registry.npmjs.org/koa/-/koa-2.15.3.tgz", + "integrity": "sha512-j/8tY9j5t+GVMLeioLaxweJiKUayFhlGqNTzf2ZGwL0ZCQijd2RLHK0SLW5Tsko8YyyqCZC2cojIb0/s62qTAg==", + "dev": true, + "dependencies": { + "accepts": "^1.3.5", + "cache-content-type": "^1.0.0", + "content-disposition": "~0.5.2", + "content-type": "^1.0.4", + "cookies": "~0.9.0", + "debug": "^4.3.2", + "delegates": "^1.0.0", + "depd": "^2.0.0", + "destroy": "^1.0.4", + "encodeurl": "^1.0.2", + "escape-html": "^1.0.3", + "fresh": "~0.5.2", + "http-assert": "^1.3.0", + "http-errors": "^1.6.3", + "is-generator-function": "^1.0.7", + "koa-compose": "^4.1.0", + "koa-convert": "^2.0.0", + "on-finished": "^2.3.0", + "only": "~0.0.2", + "parseurl": "^1.3.2", + "statuses": "^1.5.0", + "type-is": "^1.6.16", + "vary": "^1.1.2" + }, + "engines": { + "node": "^4.8.4 || ^6.10.1 || ^7.10.1 || >= 8.1.4" + } + }, + "node_modules/koa-compose": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/koa-compose/-/koa-compose-4.1.0.tgz", + "integrity": "sha512-8ODW8TrDuMYvXRwra/Kh7/rJo9BtOfPc6qO8eAfC80CnCvSjSl0bkRM24X6/XBBEyj0v1nRUQ1LyOy3dbqOWXw==", + "dev": true + }, + "node_modules/koa-convert": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/koa-convert/-/koa-convert-2.0.0.tgz", + "integrity": "sha512-asOvN6bFlSnxewce2e/DK3p4tltyfC4VM7ZwuTuepI7dEQVcvpyFuBcEARu1+Hxg8DIwytce2n7jrZtRlPrARA==", + "dev": true, + "dependencies": { + "co": "^4.6.0", + "koa-compose": "^4.1.0" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/koa-etag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/koa-etag/-/koa-etag-4.0.0.tgz", + "integrity": "sha512-1cSdezCkBWlyuB9l6c/IFoe1ANCDdPBxkDkRiaIup40xpUub6U/wwRXoKBZw/O5BifX9OlqAjYnDyzM6+l+TAg==", + "dev": true, + "dependencies": { + "etag": "^1.8.1" + } + }, + "node_modules/koa-send": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/koa-send/-/koa-send-5.0.1.tgz", + "integrity": "sha512-tmcyQ/wXXuxpDxyNXv5yNNkdAMdFRqwtegBXUaowiQzUKqJehttS0x2j0eOZDQAyloAth5w6wwBImnFzkUz3pQ==", + "dev": true, + "dependencies": { + "debug": "^4.1.1", + "http-errors": "^1.7.3", + "resolve-path": "^1.4.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/koa-static": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/koa-static/-/koa-static-5.0.0.tgz", + "integrity": "sha512-UqyYyH5YEXaJrf9S8E23GoJFQZXkBVJ9zYYMPGz919MSX1KuvAcycIuS0ci150HCoPf4XQVhQ84Qf8xRPWxFaQ==", + "dev": true, + "dependencies": { + "debug": "^3.1.0", + "koa-send": "^5.0.0" + }, + "engines": { + "node": ">= 7.6.0" + } + }, + "node_modules/koa-static/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/lilconfig": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.1.tgz", + "integrity": "sha512-O18pf7nyvHTckunPWCV1XUNXU1piu01y2b7ATJ0ppkUkk8ocqVWBrYjJBCwHDjD/ZWcfyrA0P4gKhzWGi5EINQ==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antonk52" + } + }, + "node_modules/lit": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/lit/-/lit-3.1.3.tgz", + "integrity": "sha512-l4slfspEsnCcHVRTvaP7YnkTZEZggNFywLEIhQaGhYDczG+tu/vlgm/KaWIEjIp+ZyV20r2JnZctMb8LeLCG7Q==", + "dependencies": { + "@lit/reactive-element": "^2.0.4", + "lit-element": "^4.0.4", + "lit-html": "^3.1.2" + } + }, + "node_modules/lit-element": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/lit-element/-/lit-element-4.0.5.tgz", + "integrity": "sha512-iTWskWZEtn9SyEf4aBG6rKT8GABZMrTWop1+jopsEOgEcugcXJGKuX5bEbkq9qfzY+XB4MAgCaSPwnNpdsNQ3Q==", + "dependencies": { + "@lit-labs/ssr-dom-shim": "^1.2.0", + "@lit/reactive-element": "^2.0.4", + "lit-html": "^3.1.2" + } + }, + "node_modules/lit-html": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-3.1.3.tgz", + "integrity": "sha512-FwIbqDD8O/8lM4vUZ4KvQZjPPNx7V1VhT7vmRB8RBAO0AU6wuTVdoXiu2CivVjEGdugvcbPNBLtPE1y0ifplHA==", + "dependencies": { + "@types/trusted-types": "^2.0.2" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true + }, + "node_modules/lodash.assignwith": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lodash.assignwith/-/lodash.assignwith-4.2.0.tgz", + "integrity": "sha512-ZznplvbvtjK2gMvnQ1BR/zqPFZmS6jbK4p+6Up4xcRYA7yMIwxHCfbTcrYxXKzzqLsQ05eJPVznEW3tuwV7k1g==", + "dev": true + }, + "node_modules/lodash.camelcase": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", + "integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==", + "dev": true + }, + "node_modules/lodash.memoize": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", + "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==", + "dev": true + }, + "node_modules/lodash.uniq": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz", + "integrity": "sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==", + "dev": true + }, + "node_modules/lru-cache": { + "version": "8.0.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-8.0.5.tgz", + "integrity": "sha512-MhWWlVnuab1RG5/zMRRcVGXZLCXrZTgfwMikgzCegsPnG62yDQo5JnqKkrK4jO5iKqDAZGItAqN5CtKBCBWRUA==", + "dev": true, + "engines": { + "node": ">=16.14" + } + }, + "node_modules/mdn-data": { + "version": "2.0.30", + "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.30.tgz", + "integrity": "sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==", + "dev": true + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/mobx": { + "version": "6.12.3", + "resolved": "https://registry.npmjs.org/mobx/-/mobx-6.12.3.tgz", + "integrity": "sha512-c8NKkO4R2lShkSXZ2Ongj1ycjugjzFFo/UswHBnS62y07DMcTc9Rvo03/3nRyszIvwPNljlkd4S828zIBv/piw==", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mobx" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/nanocolors": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/nanocolors/-/nanocolors-0.2.13.tgz", + "integrity": "sha512-0n3mSAQLPpGLV9ORXT5+C/D4mwew7Ebws69Hx4E2sgz2ZA5+32Q80B9tL8PbL7XHnRDiAxH/pnrUJ9a4fkTNTA==", + "dev": true + }, + "node_modules/nanoid": { + "version": "3.3.7", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", + "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "peer": true, + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/node-releases": { + "version": "2.0.14", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz", + "integrity": "sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==", + "dev": true + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/nth-check": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", + "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", + "dev": true, + "dependencies": { + "boolbase": "^1.0.0" + }, + "funding": { + "url": "https://github.com/fb55/nth-check?sponsor=1" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "dev": true, + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/only": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/only/-/only-0.0.2.tgz", + "integrity": "sha512-Fvw+Jemq5fjjyWz6CpKx6w9s7xxqo3+JCyM0WXWeCSOboZ8ABkyvP8ID4CZuChA/wxSx+XSJmdOm8rGVyJ1hdQ==", + "dev": true + }, + "node_modules/open": { + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/open/-/open-8.4.2.tgz", + "integrity": "sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==", + "dev": true, + "dependencies": { + "define-lazy-prop": "^2.0.0", + "is-docker": "^2.1.1", + "is-wsl": "^2.2.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/parse5": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz", + "integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==", + "dev": true + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "node_modules/picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", + "dev": true + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/portfinder": { + "version": "1.0.32", + "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.32.tgz", + "integrity": "sha512-on2ZJVVDXRADWE6jnQaX0ioEylzgBpQk8r55NE4wjXW1ZxO+BgDlY6DXwj20i0V8eB4SenDQ00WEaxfiIQPcxg==", + "dev": true, + "dependencies": { + "async": "^2.6.4", + "debug": "^3.2.7", + "mkdirp": "^0.5.6" + }, + "engines": { + "node": ">= 0.12.0" + } + }, + "node_modules/portfinder/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/postcss": { + "version": "8.4.38", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.38.tgz", + "integrity": "sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "peer": true, + "dependencies": { + "nanoid": "^3.3.7", + "picocolors": "^1.0.0", + "source-map-js": "^1.2.0" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/postcss-calc": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/postcss-calc/-/postcss-calc-9.0.1.tgz", + "integrity": "sha512-TipgjGyzP5QzEhsOZUaIkeO5mKeMFpebWzRogWG/ysonUlnHcq5aJe0jOjpfzUU8PeSaBQnrE8ehR0QA5vs8PQ==", + "dev": true, + "dependencies": { + "postcss-selector-parser": "^6.0.11", + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.2.2" + } + }, + "node_modules/postcss-colormin": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/postcss-colormin/-/postcss-colormin-6.1.0.tgz", + "integrity": "sha512-x9yX7DOxeMAR+BgGVnNSAxmAj98NX/YxEMNFP+SDCEeNLb2r3i6Hh1ksMsnW8Ub5SLCpbescQqn9YEbE9554Sw==", + "dev": true, + "dependencies": { + "browserslist": "^4.23.0", + "caniuse-api": "^3.0.0", + "colord": "^2.9.3", + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-convert-values": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/postcss-convert-values/-/postcss-convert-values-6.1.0.tgz", + "integrity": "sha512-zx8IwP/ts9WvUM6NkVSkiU902QZL1bwPhaVaLynPtCsOTqp+ZKbNi+s6XJg3rfqpKGA/oc7Oxk5t8pOQJcwl/w==", + "dev": true, + "dependencies": { + "browserslist": "^4.23.0", + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-discard-comments": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-discard-comments/-/postcss-discard-comments-6.0.2.tgz", + "integrity": "sha512-65w/uIqhSBBfQmYnG92FO1mWZjJ4GL5b8atm5Yw2UgrwD7HiNiSSNwJor1eCFGzUgYnN/iIknhNRVqjrrpuglw==", + "dev": true, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-discard-duplicates": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/postcss-discard-duplicates/-/postcss-discard-duplicates-6.0.3.tgz", + "integrity": "sha512-+JA0DCvc5XvFAxwx6f/e68gQu/7Z9ud584VLmcgto28eB8FqSFZwtrLwB5Kcp70eIoWP/HXqz4wpo8rD8gpsTw==", + "dev": true, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-discard-empty": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/postcss-discard-empty/-/postcss-discard-empty-6.0.3.tgz", + "integrity": "sha512-znyno9cHKQsK6PtxL5D19Fj9uwSzC2mB74cpT66fhgOadEUPyXFkbgwm5tvc3bt3NAy8ltE5MrghxovZRVnOjQ==", + "dev": true, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-discard-overridden": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-discard-overridden/-/postcss-discard-overridden-6.0.2.tgz", + "integrity": "sha512-j87xzI4LUggC5zND7KdjsI25APtyMuynXZSujByMaav2roV6OZX+8AaCUcZSWqckZpjAjRyFDdpqybgjFO0HJQ==", + "dev": true, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-merge-longhand": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/postcss-merge-longhand/-/postcss-merge-longhand-6.0.5.tgz", + "integrity": "sha512-5LOiordeTfi64QhICp07nzzuTDjNSO8g5Ksdibt44d+uvIIAE1oZdRn8y/W5ZtYgRH/lnLDlvi9F8btZcVzu3w==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0", + "stylehacks": "^6.1.1" + }, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-merge-rules": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/postcss-merge-rules/-/postcss-merge-rules-6.1.1.tgz", + "integrity": "sha512-KOdWF0gju31AQPZiD+2Ar9Qjowz1LTChSjFFbS+e2sFgc4uHOp3ZvVX4sNeTlk0w2O31ecFGgrFzhO0RSWbWwQ==", + "dev": true, + "dependencies": { + "browserslist": "^4.23.0", + "caniuse-api": "^3.0.0", + "cssnano-utils": "^4.0.2", + "postcss-selector-parser": "^6.0.16" + }, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-minify-font-values": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/postcss-minify-font-values/-/postcss-minify-font-values-6.1.0.tgz", + "integrity": "sha512-gklfI/n+9rTh8nYaSJXlCo3nOKqMNkxuGpTn/Qm0gstL3ywTr9/WRKznE+oy6fvfolH6dF+QM4nCo8yPLdvGJg==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-minify-gradients": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/postcss-minify-gradients/-/postcss-minify-gradients-6.0.3.tgz", + "integrity": "sha512-4KXAHrYlzF0Rr7uc4VrfwDJ2ajrtNEpNEuLxFgwkhFZ56/7gaE4Nr49nLsQDZyUe+ds+kEhf+YAUolJiYXF8+Q==", + "dev": true, + "dependencies": { + "colord": "^2.9.3", + "cssnano-utils": "^4.0.2", + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-minify-params": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/postcss-minify-params/-/postcss-minify-params-6.1.0.tgz", + "integrity": "sha512-bmSKnDtyyE8ujHQK0RQJDIKhQ20Jq1LYiez54WiaOoBtcSuflfK3Nm596LvbtlFcpipMjgClQGyGr7GAs+H1uA==", + "dev": true, + "dependencies": { + "browserslist": "^4.23.0", + "cssnano-utils": "^4.0.2", + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-minify-selectors": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/postcss-minify-selectors/-/postcss-minify-selectors-6.0.4.tgz", + "integrity": "sha512-L8dZSwNLgK7pjTto9PzWRoMbnLq5vsZSTu8+j1P/2GB8qdtGQfn+K1uSvFgYvgh83cbyxT5m43ZZhUMTJDSClQ==", + "dev": true, + "dependencies": { + "postcss-selector-parser": "^6.0.16" + }, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-normalize-charset": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-normalize-charset/-/postcss-normalize-charset-6.0.2.tgz", + "integrity": "sha512-a8N9czmdnrjPHa3DeFlwqst5eaL5W8jYu3EBbTTkI5FHkfMhFZh1EGbku6jhHhIzTA6tquI2P42NtZ59M/H/kQ==", + "dev": true, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-normalize-display-values": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-normalize-display-values/-/postcss-normalize-display-values-6.0.2.tgz", + "integrity": "sha512-8H04Mxsb82ON/aAkPeq8kcBbAtI5Q2a64X/mnRRfPXBq7XeogoQvReqxEfc0B4WPq1KimjezNC8flUtC3Qz6jg==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-normalize-positions": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-normalize-positions/-/postcss-normalize-positions-6.0.2.tgz", + "integrity": "sha512-/JFzI441OAB9O7VnLA+RtSNZvQ0NCFZDOtp6QPFo1iIyawyXg0YI3CYM9HBy1WvwCRHnPep/BvI1+dGPKoXx/Q==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-normalize-repeat-style": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-normalize-repeat-style/-/postcss-normalize-repeat-style-6.0.2.tgz", + "integrity": "sha512-YdCgsfHkJ2jEXwR4RR3Tm/iOxSfdRt7jplS6XRh9Js9PyCR/aka/FCb6TuHT2U8gQubbm/mPmF6L7FY9d79VwQ==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-normalize-string": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-normalize-string/-/postcss-normalize-string-6.0.2.tgz", + "integrity": "sha512-vQZIivlxlfqqMp4L9PZsFE4YUkWniziKjQWUtsxUiVsSSPelQydwS8Wwcuw0+83ZjPWNTl02oxlIvXsmmG+CiQ==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-normalize-timing-functions": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-normalize-timing-functions/-/postcss-normalize-timing-functions-6.0.2.tgz", + "integrity": "sha512-a+YrtMox4TBtId/AEwbA03VcJgtyW4dGBizPl7e88cTFULYsprgHWTbfyjSLyHeBcK/Q9JhXkt2ZXiwaVHoMzA==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-normalize-unicode": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/postcss-normalize-unicode/-/postcss-normalize-unicode-6.1.0.tgz", + "integrity": "sha512-QVC5TQHsVj33otj8/JD869Ndr5Xcc/+fwRh4HAsFsAeygQQXm+0PySrKbr/8tkDKzW+EVT3QkqZMfFrGiossDg==", + "dev": true, + "dependencies": { + "browserslist": "^4.23.0", + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-normalize-url": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-normalize-url/-/postcss-normalize-url-6.0.2.tgz", + "integrity": "sha512-kVNcWhCeKAzZ8B4pv/DnrU1wNh458zBNp8dh4y5hhxih5RZQ12QWMuQrDgPRw3LRl8mN9vOVfHl7uhvHYMoXsQ==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-normalize-whitespace": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-normalize-whitespace/-/postcss-normalize-whitespace-6.0.2.tgz", + "integrity": "sha512-sXZ2Nj1icbJOKmdjXVT9pnyHQKiSAyuNQHSgRCUgThn2388Y9cGVDR+E9J9iAYbSbLHI+UUwLVl1Wzco/zgv0Q==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-ordered-values": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-ordered-values/-/postcss-ordered-values-6.0.2.tgz", + "integrity": "sha512-VRZSOB+JU32RsEAQrO94QPkClGPKJEL/Z9PCBImXMhIeK5KAYo6slP/hBYlLgrCjFxyqvn5VC81tycFEDBLG1Q==", + "dev": true, + "dependencies": { + "cssnano-utils": "^4.0.2", + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-reduce-initial": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/postcss-reduce-initial/-/postcss-reduce-initial-6.1.0.tgz", + "integrity": "sha512-RarLgBK/CrL1qZags04oKbVbrrVK2wcxhvta3GCxrZO4zveibqbRPmm2VI8sSgCXwoUHEliRSbOfpR0b/VIoiw==", + "dev": true, + "dependencies": { + "browserslist": "^4.23.0", + "caniuse-api": "^3.0.0" + }, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-reduce-transforms": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-reduce-transforms/-/postcss-reduce-transforms-6.0.2.tgz", + "integrity": "sha512-sB+Ya++3Xj1WaT9+5LOOdirAxP7dJZms3GRcYheSPi1PiTMigsxHAdkrbItHxwYHr4kt1zL7mmcHstgMYT+aiA==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0" + }, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-selector-parser": { + "version": "6.0.16", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.16.tgz", + "integrity": "sha512-A0RVJrX+IUkVZbW3ClroRWurercFhieevHB38sr2+l9eUClMqome3LmEmnhlNy+5Mr2EYN6B2Kaw9wYdd+VHiw==", + "dev": true, + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/postcss-svgo": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/postcss-svgo/-/postcss-svgo-6.0.3.tgz", + "integrity": "sha512-dlrahRmxP22bX6iKEjOM+c8/1p+81asjKT+V5lrgOH944ryx/OHpclnIbGsKVd3uWOXFLYJwCVf0eEkJGvO96g==", + "dev": true, + "dependencies": { + "postcss-value-parser": "^4.2.0", + "svgo": "^3.2.0" + }, + "engines": { + "node": "^14 || ^16 || >= 18" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-unique-selectors": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/postcss-unique-selectors/-/postcss-unique-selectors-6.0.4.tgz", + "integrity": "sha512-K38OCaIrO8+PzpArzkLKB42dSARtC2tmG6PvD4b1o1Q2E9Os8jzfWFfSy/rixsHwohtsDdFtAWGjFVFUdwYaMg==", + "dev": true, + "dependencies": { + "postcss-selector-parser": "^6.0.16" + }, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/postcss-value-parser": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", + "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", + "dev": true + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/resolve": { + "version": "1.22.8", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", + "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", + "dev": true, + "dependencies": { + "is-core-module": "^2.13.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve-path": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/resolve-path/-/resolve-path-1.4.0.tgz", + "integrity": "sha512-i1xevIst/Qa+nA9olDxLWnLk8YZbi8R/7JPbCMcgyWaFR6bKWaexgJgEB5oc2PKMjYdrHynyz0NY+if+H98t1w==", + "dev": true, + "dependencies": { + "http-errors": "~1.6.2", + "path-is-absolute": "1.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/resolve-path/node_modules/depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/resolve-path/node_modules/http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha512-lks+lVC8dgGyh97jxvxeYTWQFvh4uw4yC12gVl63Cg30sjPX4wuGcdkICVXDAESr6OJGjqGA8Iz5mkeN6zlD7A==", + "dev": true, + "dependencies": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": ">= 1.4.0 < 2" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/resolve-path/node_modules/inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==", + "dev": true + }, + "node_modules/resolve-path/node_modules/setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==", + "dev": true + }, + "node_modules/rollup": { + "version": "4.17.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.17.2.tgz", + "integrity": "sha512-/9ClTJPByC0U4zNLowV1tMBe8yMEAxewtR3cUNX5BoEpGH3dQEWpJLr6CLp0fPdYRF/fzVOgvDb1zXuakwF5kQ==", + "dev": true, + "dependencies": { + "@types/estree": "1.0.5" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.17.2", + "@rollup/rollup-android-arm64": "4.17.2", + "@rollup/rollup-darwin-arm64": "4.17.2", + "@rollup/rollup-darwin-x64": "4.17.2", + "@rollup/rollup-linux-arm-gnueabihf": "4.17.2", + "@rollup/rollup-linux-arm-musleabihf": "4.17.2", + "@rollup/rollup-linux-arm64-gnu": "4.17.2", + "@rollup/rollup-linux-arm64-musl": "4.17.2", + "@rollup/rollup-linux-powerpc64le-gnu": "4.17.2", + "@rollup/rollup-linux-riscv64-gnu": "4.17.2", + "@rollup/rollup-linux-s390x-gnu": "4.17.2", + "@rollup/rollup-linux-x64-gnu": "4.17.2", + "@rollup/rollup-linux-x64-musl": "4.17.2", + "@rollup/rollup-win32-arm64-msvc": "4.17.2", + "@rollup/rollup-win32-ia32-msvc": "4.17.2", + "@rollup/rollup-win32-x64-msvc": "4.17.2", + "fsevents": "~2.3.2" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "dev": true + }, + "node_modules/source-map-js": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz", + "integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/stream-read-all": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/stream-read-all/-/stream-read-all-3.0.1.tgz", + "integrity": "sha512-EWZT9XOceBPlVJRrYcykW8jyRSZYbkb/0ZK36uLEmoWVO5gxBOnntNTseNzfREsqxqdfEGQrD8SXQ3QWbBmq8A==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/stylehacks": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/stylehacks/-/stylehacks-6.1.1.tgz", + "integrity": "sha512-gSTTEQ670cJNoaeIp9KX6lZmm8LJ3jPB5yJmX8Zq/wQxOsAFXV3qjWzHas3YYk1qesuVIyYWWUpZ0vSE/dTSGg==", + "dev": true, + "dependencies": { + "browserslist": "^4.23.0", + "postcss-selector-parser": "^6.0.16" + }, + "engines": { + "node": "^14 || ^16 || >=18.0" + }, + "peerDependencies": { + "postcss": "^8.4.31" + } + }, + "node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/svgo": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/svgo/-/svgo-3.3.2.tgz", + "integrity": "sha512-OoohrmuUlBs8B8o6MB2Aevn+pRIH9zDALSR+6hhqVfa6fRwG/Qw9VUMSMW9VNg2CFc/MTIfabtdOVl9ODIJjpw==", + "dev": true, + "dependencies": { + "@trysound/sax": "0.2.0", + "commander": "^7.2.0", + "css-select": "^5.1.0", + "css-tree": "^2.3.1", + "css-what": "^6.1.0", + "csso": "^5.0.5", + "picocolors": "^1.0.0" + }, + "bin": { + "svgo": "bin/svgo" + }, + "engines": { + "node": ">=14.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/svgo" + } + }, + "node_modules/table-layout": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/table-layout/-/table-layout-3.0.2.tgz", + "integrity": "sha512-rpyNZYRw+/C+dYkcQ3Pr+rLxW4CfHpXjPDnG7lYhdRoUcZTUt+KEsX+94RGp/aVp/MQU35JCITv2T/beY4m+hw==", + "dev": true, + "dependencies": { + "@75lb/deep-merge": "^1.1.1", + "array-back": "^6.2.2", + "command-line-args": "^5.2.1", + "command-line-usage": "^7.0.0", + "stream-read-all": "^3.0.1", + "typical": "^7.1.1", + "wordwrapjs": "^5.1.0" + }, + "bin": { + "table-layout": "bin/cli.js" + }, + "engines": { + "node": ">=12.17" + } + }, + "node_modules/table-layout/node_modules/array-back": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-6.2.2.tgz", + "integrity": "sha512-gUAZ7HPyb4SJczXAMUXMGAvI976JoK3qEx9v1FTmeYuJj0IBiaKttG1ydtGKdkfqWkIkouke7nG8ufGy77+Cvw==", + "dev": true, + "engines": { + "node": ">=12.17" + } + }, + "node_modules/table-layout/node_modules/typical": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/typical/-/typical-7.1.1.tgz", + "integrity": "sha512-T+tKVNs6Wu7IWiAce5BgMd7OZfNYUndHwc5MknN+UHOudi7sGZzuHdCadllRuqJ3fPtgFtIH9+lt9qRv6lmpfA==", + "dev": true, + "engines": { + "node": ">=12.17" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "dev": true, + "engines": { + "node": ">=0.6" + } + }, + "node_modules/tr46": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-3.0.0.tgz", + "integrity": "sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==", + "dev": true, + "dependencies": { + "punycode": "^2.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" + }, + "node_modules/tsscmp": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/tsscmp/-/tsscmp-1.0.6.tgz", + "integrity": "sha512-LxhtAkPDTkVCMQjt2h6eBVY28KCjikZqZfMcC15YBeNjkgUpdCfBu5HoiOTDu86v6smE8yOjyEktJ8hlbANHQA==", + "dev": true, + "engines": { + "node": ">=0.6.x" + } + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "dev": true, + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/typical": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/typical/-/typical-4.0.0.tgz", + "integrity": "sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + }, + "node_modules/update-browserslist-db": { + "version": "1.0.15", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.15.tgz", + "integrity": "sha512-K9HWH62x3/EalU1U6sjSZiylm9C8tgq2mSvshZpqc7QE69RaA2qjhkW2HlNA0tFpEbtyFz7HTqbSdN4MSwUodA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "escalade": "^3.1.2", + "picocolors": "^1.0.0" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/whatwg-url": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-11.0.0.tgz", + "integrity": "sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ==", + "dev": true, + "dependencies": { + "tr46": "^3.0.0", + "webidl-conversions": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/wordwrapjs": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wordwrapjs/-/wordwrapjs-5.1.0.tgz", + "integrity": "sha512-JNjcULU2e4KJwUNv6CHgI46UvDGitb6dGryHajXTDiLgg1/RiGoPSDw4kZfYnwGtEXf2ZMeIewDQgFGzkCB2Sg==", + "dev": true, + "engines": { + "node": ">=12.17" + } + }, + "node_modules/ws": { + "version": "7.5.9", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", + "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "dev": true, + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/ylru": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ylru/-/ylru-1.4.0.tgz", + "integrity": "sha512-2OQsPNEmBCvXuFlIni/a+Rn+R2pHW9INm0BxXJ4hVDA8TirqMj+J/Rp9ItLatT/5pZqWwefVrTQcHpixsxnVlA==", + "dev": true, + "engines": { + "node": ">= 4.0.0" + } + } + }, + "dependencies": { + "@75lb/deep-merge": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@75lb/deep-merge/-/deep-merge-1.1.1.tgz", + "integrity": "sha512-xvgv6pkMGBA6GwdyJbNAnDmfAIR/DfWhrj9jgWh3TY7gRm3KO46x/GPjRg6wJ0nOepwqrNxFfojebh0Df4h4Tw==", + "dev": true, + "requires": { + "lodash.assignwith": "^4.2.0", + "typical": "^7.1.1" + }, + "dependencies": { + "typical": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/typical/-/typical-7.1.1.tgz", + "integrity": "sha512-T+tKVNs6Wu7IWiAce5BgMd7OZfNYUndHwc5MknN+UHOudi7sGZzuHdCadllRuqJ3fPtgFtIH9+lt9qRv6lmpfA==", + "dev": true + } + } + }, + "@adobe/lit-mobx": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/@adobe/lit-mobx/-/lit-mobx-2.2.2.tgz", + "integrity": "sha512-TKmaEgu0m8dxydo0cAhJ5qaNoa/moQr8I3E9DtxVb0OSu/huXps+gUg/6oz7sYllcSl4KFZtzfyfx7EstbQ9tw==", + "requires": {} + }, + "@babel/code-frame": { + "version": "7.24.2", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.24.2.tgz", + "integrity": "sha512-y5+tLQyV8pg3fsiln67BVLD1P13Eg4lh5RW9mF0zUuvLrv9uIQ4MCL+CRT+FTsBlBjcIan6PGsLcBN0m3ClUyQ==", + "dev": true, + "requires": { + "@babel/highlight": "^7.24.2", + "picocolors": "^1.0.0" + } + }, + "@babel/helper-validator-identifier": { + "version": "7.24.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.5.tgz", + "integrity": "sha512-3q93SSKX2TWCG30M2G2kwaKeTYgEUp5Snjuj8qm729SObL6nbtUldAi37qbxkD5gg3xnBio+f9nqpSepGZMvxA==", + "dev": true + }, + "@babel/highlight": { + "version": "7.24.5", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.24.5.tgz", + "integrity": "sha512-8lLmua6AVh/8SLJRRVD6V8p73Hir9w5mJrhE+IPpILG31KKlI9iz5zmBYKcWPS59qSfgP9RaSBQSHHE81WKuEw==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.24.5", + "chalk": "^2.4.2", + "js-tokens": "^4.0.0", + "picocolors": "^1.0.0" + } + }, + "@esbuild/linux-x64": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.20.2.tgz", + "integrity": "sha512-1MdwI6OOTsfQfek8sLwgyjOXAu+wKhLEoaOLTjbijk6E2WONYpH9ZU2mNtR+lZ2B4uwr+usqGuVfFT9tMtGvGw==", + "dev": true, + "optional": true + }, + "@lit-labs/ssr-dom-shim": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.2.0.tgz", + "integrity": "sha512-yWJKmpGE6lUURKAaIltoPIE/wrbY3TEkqQt+X0m+7fQNnAv0keydnYvbiJFP1PnMhizmIWRWOG5KLhYyc/xl+g==" + }, + "@lit/reactive-element": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-2.0.4.tgz", + "integrity": "sha512-GFn91inaUa2oHLak8awSIigYz0cU0Payr1rcFsrkf5OJ5eSPxElyZfKh0f2p9FsTiZWXQdWGJeXZICEfXXYSXQ==", + "requires": { + "@lit-labs/ssr-dom-shim": "^1.2.0" + } + }, + "@material/animation": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/animation/-/animation-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-GBuR4VmcTQW1D0lPXEosf5Giho72LLbyGIydWGtaEUtLJoive/D9kFkwTN4Fsyt9Kkl7hbhs35vrNe6QkAH4/Q==", + "requires": { + "tslib": "^2.1.0" + } + }, + "@material/base": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/base/-/base-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-UJKbXwZtkrA3sfQDmj8Zbw1Q3Tqtl6KdfVFws95Yf7TCUgTFzbZI/FSx1w7dVugQPOEnIBuZnzqZam/MtHkx4w==", + "requires": { + "tslib": "^2.1.0" + } + }, + "@material/density": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/density/-/density-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-Eh/vZ3vVyqtpylg5Ci33qlgtToS4H1/ppd450Ib3tcdISIoodgijYY0w4XsRvrnZgbI/h/1STFdLxdzS0UNuFw==", + "requires": { + "tslib": "^2.1.0" + } + }, + "@material/dom": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/dom/-/dom-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-aR+rfncF6oi2ivdOlKSJI4UXwNzWV5rXM88MLDoSJF1D7lXxhAKhge+tMUBodWGV/q0+FnXLuVAa0WYTrKjo+A==", + "requires": { + "@material/feature-targeting": "14.0.0-canary.53b3cad2f.0", + "tslib": "^2.1.0" + } + }, + "@material/elevation": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/elevation/-/elevation-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-3h+EkR588RMZ5TSNQ4UeXD1FOBnL3ABQix0DQIGwtNJCqSMoPndT/oJEFvwQbTkZNDbFIKN9p1Q7/KuFPVY8Pw==", + "requires": { + "@material/animation": "14.0.0-canary.53b3cad2f.0", + "@material/base": "14.0.0-canary.53b3cad2f.0", + "@material/feature-targeting": "14.0.0-canary.53b3cad2f.0", + "@material/rtl": "14.0.0-canary.53b3cad2f.0", + "@material/theme": "14.0.0-canary.53b3cad2f.0", + "tslib": "^2.1.0" + } + }, + "@material/feature-targeting": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/feature-targeting/-/feature-targeting-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-fn7Af3PRyARtNeYqtjxXmE3Y/dCpnpQVWWys57MqiGR/nvc6qpgOfJ6rOdcu/MrOysOE/oebTUDmDnTmwpe9Hw==", + "requires": { + "tslib": "^2.1.0" + } + }, + "@material/focus-ring": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/focus-ring/-/focus-ring-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-exPX5VrjQimipBwgcFDGRiEE783sOBgpkFui59A6i6iGvS2UrLHlYY2E65fyyyQnD1f/rv4Po1OOnCesE1kulg==", + "requires": { + "@material/dom": "14.0.0-canary.53b3cad2f.0", + "@material/feature-targeting": "14.0.0-canary.53b3cad2f.0", + "@material/rtl": "14.0.0-canary.53b3cad2f.0" + } + }, + "@material/mwc-base": { + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@material/mwc-base/-/mwc-base-0.27.0.tgz", + "integrity": "sha512-oCWWtjbyQ52AaUbzINLGBKScIPyqhps2Y7c8t6Gu6fcFeDxhKXMV1Cqvtj/OMhtAt53XjHfD2XruWwYv3cYYUA==", + "requires": { + "@material/base": "=14.0.0-canary.53b3cad2f.0", + "@material/dom": "=14.0.0-canary.53b3cad2f.0", + "lit": "^2.0.0", + "tslib": "^2.0.1" + }, + "dependencies": { + "@lit/reactive-element": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-1.6.3.tgz", + "integrity": "sha512-QuTgnG52Poic7uM1AN5yJ09QMe0O28e10XzSvWDz02TJiiKee4stsiownEIadWm8nYzyDAyT+gKzUoZmiWQtsQ==", + "requires": { + "@lit-labs/ssr-dom-shim": "^1.0.0" + } + }, + "lit": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/lit/-/lit-2.8.0.tgz", + "integrity": "sha512-4Sc3OFX9QHOJaHbmTMk28SYgVxLN3ePDjg7hofEft2zWlehFL3LiAuapWc4U/kYwMYJSh2hTCPZ6/LIC7ii0MA==", + "requires": { + "@lit/reactive-element": "^1.6.0", + "lit-element": "^3.3.0", + "lit-html": "^2.8.0" + } + }, + "lit-element": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/lit-element/-/lit-element-3.3.3.tgz", + "integrity": "sha512-XbeRxmTHubXENkV4h8RIPyr8lXc+Ff28rkcQzw3G6up2xg5E8Zu1IgOWIwBLEQsu3cOVFqdYwiVi0hv0SlpqUA==", + "requires": { + "@lit-labs/ssr-dom-shim": "^1.1.0", + "@lit/reactive-element": "^1.3.0", + "lit-html": "^2.8.0" + } + }, + "lit-html": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-2.8.0.tgz", + "integrity": "sha512-o9t+MQM3P4y7M7yNzqAyjp7z+mQGa4NS4CxiyLqFPyFWyc4O+nodLrkrxSaCTrla6M5YOLaT3RpbbqjszB5g3Q==", + "requires": { + "@types/trusted-types": "^2.0.2" + } + } + } + }, + "@material/mwc-icon": { + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@material/mwc-icon/-/mwc-icon-0.27.0.tgz", + "integrity": "sha512-Sul44I37M9Ewynn0A9DjkEBrmll2VtNbth6Pxj7I1A/EAwEfaCrPvryyGqfIu1T2hTsRcaojzQx6QjF+B5QW9A==", + "requires": { + "lit": "^2.0.0", + "tslib": "^2.0.1" + }, + "dependencies": { + "@lit/reactive-element": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-1.6.3.tgz", + "integrity": "sha512-QuTgnG52Poic7uM1AN5yJ09QMe0O28e10XzSvWDz02TJiiKee4stsiownEIadWm8nYzyDAyT+gKzUoZmiWQtsQ==", + "requires": { + "@lit-labs/ssr-dom-shim": "^1.0.0" + } + }, + "lit": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/lit/-/lit-2.8.0.tgz", + "integrity": "sha512-4Sc3OFX9QHOJaHbmTMk28SYgVxLN3ePDjg7hofEft2zWlehFL3LiAuapWc4U/kYwMYJSh2hTCPZ6/LIC7ii0MA==", + "requires": { + "@lit/reactive-element": "^1.6.0", + "lit-element": "^3.3.0", + "lit-html": "^2.8.0" + } + }, + "lit-element": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/lit-element/-/lit-element-3.3.3.tgz", + "integrity": "sha512-XbeRxmTHubXENkV4h8RIPyr8lXc+Ff28rkcQzw3G6up2xg5E8Zu1IgOWIwBLEQsu3cOVFqdYwiVi0hv0SlpqUA==", + "requires": { + "@lit-labs/ssr-dom-shim": "^1.1.0", + "@lit/reactive-element": "^1.3.0", + "lit-html": "^2.8.0" + } + }, + "lit-html": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-2.8.0.tgz", + "integrity": "sha512-o9t+MQM3P4y7M7yNzqAyjp7z+mQGa4NS4CxiyLqFPyFWyc4O+nodLrkrxSaCTrla6M5YOLaT3RpbbqjszB5g3Q==", + "requires": { + "@types/trusted-types": "^2.0.2" + } + } + } + }, + "@material/mwc-ripple": { + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@material/mwc-ripple/-/mwc-ripple-0.27.0.tgz", + "integrity": "sha512-by0O8d8g3Rd96/sUB8hxy6MrDx1QTstqOsA64vqypWd526hMTBGRik08jTNap5sVIyrN9Vq17jb4NJLWQLnNHQ==", + "requires": { + "@material/dom": "=14.0.0-canary.53b3cad2f.0", + "@material/mwc-base": "^0.27.0", + "@material/ripple": "=14.0.0-canary.53b3cad2f.0", + "lit": "^2.0.0", + "tslib": "^2.0.1" + }, + "dependencies": { + "@lit/reactive-element": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-1.6.3.tgz", + "integrity": "sha512-QuTgnG52Poic7uM1AN5yJ09QMe0O28e10XzSvWDz02TJiiKee4stsiownEIadWm8nYzyDAyT+gKzUoZmiWQtsQ==", + "requires": { + "@lit-labs/ssr-dom-shim": "^1.0.0" + } + }, + "lit": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/lit/-/lit-2.8.0.tgz", + "integrity": "sha512-4Sc3OFX9QHOJaHbmTMk28SYgVxLN3ePDjg7hofEft2zWlehFL3LiAuapWc4U/kYwMYJSh2hTCPZ6/LIC7ii0MA==", + "requires": { + "@lit/reactive-element": "^1.6.0", + "lit-element": "^3.3.0", + "lit-html": "^2.8.0" + } + }, + "lit-element": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/lit-element/-/lit-element-3.3.3.tgz", + "integrity": "sha512-XbeRxmTHubXENkV4h8RIPyr8lXc+Ff28rkcQzw3G6up2xg5E8Zu1IgOWIwBLEQsu3cOVFqdYwiVi0hv0SlpqUA==", + "requires": { + "@lit-labs/ssr-dom-shim": "^1.1.0", + "@lit/reactive-element": "^1.3.0", + "lit-html": "^2.8.0" + } + }, + "lit-html": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-2.8.0.tgz", + "integrity": "sha512-o9t+MQM3P4y7M7yNzqAyjp7z+mQGa4NS4CxiyLqFPyFWyc4O+nodLrkrxSaCTrla6M5YOLaT3RpbbqjszB5g3Q==", + "requires": { + "@types/trusted-types": "^2.0.2" + } + } + } + }, + "@material/mwc-switch": { + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@material/mwc-switch/-/mwc-switch-0.27.0.tgz", + "integrity": "sha512-MKKjm42f8YyHN1HmvfgppgTPJUxulcmOqND5R7zI/kB38vFcWDxEhnpdUYr2kEsFtebpYNSF0j6FXcKV/W+fJw==", + "requires": { + "@material/mwc-base": "^0.27.0", + "@material/mwc-ripple": "^0.27.0", + "@material/switch": "=14.0.0-canary.53b3cad2f.0", + "lit": "^2.0.0", + "tslib": "^2.0.1" + }, + "dependencies": { + "@lit/reactive-element": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-1.6.3.tgz", + "integrity": "sha512-QuTgnG52Poic7uM1AN5yJ09QMe0O28e10XzSvWDz02TJiiKee4stsiownEIadWm8nYzyDAyT+gKzUoZmiWQtsQ==", + "requires": { + "@lit-labs/ssr-dom-shim": "^1.0.0" + } + }, + "lit": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/lit/-/lit-2.8.0.tgz", + "integrity": "sha512-4Sc3OFX9QHOJaHbmTMk28SYgVxLN3ePDjg7hofEft2zWlehFL3LiAuapWc4U/kYwMYJSh2hTCPZ6/LIC7ii0MA==", + "requires": { + "@lit/reactive-element": "^1.6.0", + "lit-element": "^3.3.0", + "lit-html": "^2.8.0" + } + }, + "lit-element": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/lit-element/-/lit-element-3.3.3.tgz", + "integrity": "sha512-XbeRxmTHubXENkV4h8RIPyr8lXc+Ff28rkcQzw3G6up2xg5E8Zu1IgOWIwBLEQsu3cOVFqdYwiVi0hv0SlpqUA==", + "requires": { + "@lit-labs/ssr-dom-shim": "^1.1.0", + "@lit/reactive-element": "^1.3.0", + "lit-html": "^2.8.0" + } + }, + "lit-html": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-2.8.0.tgz", + "integrity": "sha512-o9t+MQM3P4y7M7yNzqAyjp7z+mQGa4NS4CxiyLqFPyFWyc4O+nodLrkrxSaCTrla6M5YOLaT3RpbbqjszB5g3Q==", + "requires": { + "@types/trusted-types": "^2.0.2" + } + } + } + }, + "@material/ripple": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/ripple/-/ripple-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-6g2G62vd8DsMuIUSXlRrzb98qkZ4o8ZREknNwNP2zaLQEOkJ//4j9HaqDt98/3LIjUTY9UIVFTQENiMmlwKHYQ==", + "requires": { + "@material/animation": "14.0.0-canary.53b3cad2f.0", + "@material/base": "14.0.0-canary.53b3cad2f.0", + "@material/dom": "14.0.0-canary.53b3cad2f.0", + "@material/feature-targeting": "14.0.0-canary.53b3cad2f.0", + "@material/rtl": "14.0.0-canary.53b3cad2f.0", + "@material/theme": "14.0.0-canary.53b3cad2f.0", + "tslib": "^2.1.0" + } + }, + "@material/rtl": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/rtl/-/rtl-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-f08LT0HSa0WYU+4Jz/tbm1TQ9Fcf2k+H6dPPYv0J1sZmX6hMgCEmNiUdUFLQFvszoXx2XrRi1/hIFjbz2e69Yg==", + "requires": { + "@material/theme": "14.0.0-canary.53b3cad2f.0", + "tslib": "^2.1.0" + } + }, + "@material/shape": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/shape/-/shape-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-RyjInLCNe+nI/ulKea0ZLHphXQDiDqYazS25SRn18g8Hoa5qGNaY5oOBncDXUYn3jm5oI5kFc9oif//kulkbjg==", + "requires": { + "@material/feature-targeting": "14.0.0-canary.53b3cad2f.0", + "@material/rtl": "14.0.0-canary.53b3cad2f.0", + "@material/theme": "14.0.0-canary.53b3cad2f.0", + "tslib": "^2.1.0" + } + }, + "@material/switch": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/switch/-/switch-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-hL7lOF8tgYaS1Spce6zlxfveoqUlqDTW+vv+R7TIHwzLD5HJCdhTiotXshOKCZLoSi7Ljx7JpCdvNqGlv4rpIw==", + "requires": { + "@material/animation": "14.0.0-canary.53b3cad2f.0", + "@material/base": "14.0.0-canary.53b3cad2f.0", + "@material/density": "14.0.0-canary.53b3cad2f.0", + "@material/dom": "14.0.0-canary.53b3cad2f.0", + "@material/elevation": "14.0.0-canary.53b3cad2f.0", + "@material/feature-targeting": "14.0.0-canary.53b3cad2f.0", + "@material/focus-ring": "14.0.0-canary.53b3cad2f.0", + "@material/ripple": "14.0.0-canary.53b3cad2f.0", + "@material/rtl": "14.0.0-canary.53b3cad2f.0", + "@material/shape": "14.0.0-canary.53b3cad2f.0", + "@material/theme": "14.0.0-canary.53b3cad2f.0", + "@material/tokens": "14.0.0-canary.53b3cad2f.0", + "tslib": "^2.1.0" + } + }, + "@material/theme": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/theme/-/theme-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-S06XAevDCDWMe+GgsEpITMS07imUidzadNaTbJsqssFajBLr53QWVZsG84BpjXKXoYvyEJvb0hX5U0lq6ip9UQ==", + "requires": { + "@material/feature-targeting": "14.0.0-canary.53b3cad2f.0", + "tslib": "^2.1.0" + } + }, + "@material/tokens": { + "version": "14.0.0-canary.53b3cad2f.0", + "resolved": "https://registry.npmjs.org/@material/tokens/-/tokens-14.0.0-canary.53b3cad2f.0.tgz", + "integrity": "sha512-myHFB7vac8zErA3qgkqmV+kpE+i9JEwc/6Yf0MOumDSpylJGw28QikpNC6eAVBK2EmPQTaFn20mqUxyud8dGqw==", + "requires": { + "@material/elevation": "14.0.0-canary.53b3cad2f.0" + } + }, + "@pwrs/lit-css": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@pwrs/lit-css/-/lit-css-3.0.0.tgz", + "integrity": "sha512-10Xod+Z8jh/uHRmgRjMwroXHoG7hVgMcl3G+4FvS3B1yzyopF0niFjCEyg+ZXeLWBJ45BckyyP8aZtZhtk5EYQ==", + "dev": true, + "requires": { + "cssnano": "^6.1.2" + } + }, + "@rollup/plugin-node-resolve": { + "version": "15.2.3", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.2.3.tgz", + "integrity": "sha512-j/lym8nf5E21LwBT4Df1VD6hRO2L2iwUeUmP7litikRsVp1H6NWx20NEp0Y7su+7XGc476GnXXc4kFeZNGmaSQ==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^5.0.1", + "@types/resolve": "1.20.2", + "deepmerge": "^4.2.2", + "is-builtin-module": "^3.2.1", + "is-module": "^1.0.0", + "resolve": "^1.22.1" + } + }, + "@rollup/pluginutils": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.0.tgz", + "integrity": "sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==", + "dev": true, + "requires": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + } + }, + "@rollup/rollup-linux-x64-gnu": { + "version": "4.17.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.17.2.tgz", + "integrity": "sha512-Hy7pLwByUOuyaFC6mAr7m+oMC+V7qyifzs/nW2OJfC8H4hbCzOX07Ov0VFk/zP3kBsELWNFi7rJtgbKYsav9QQ==", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-x64-musl": { + "version": "4.17.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.17.2.tgz", + "integrity": "sha512-h1+yTWeYbRdAyJ/jMiVw0l6fOOm/0D1vNLui9iPuqgRGnXA0u21gAqOyB5iHjlM9MMfNOm9RHCQ7zLIzT0x11Q==", + "dev": true, + "optional": true + }, + "@trysound/sax": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@trysound/sax/-/sax-0.2.0.tgz", + "integrity": "sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==", + "dev": true + }, + "@types/accepts": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/@types/accepts/-/accepts-1.3.7.tgz", + "integrity": "sha512-Pay9fq2lM2wXPWbteBsRAGiWH2hig4ZE2asK+mm7kUzlxRTfL961rj89I6zV/E3PcIkDqyuBEcMxFT7rccugeQ==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "@types/body-parser": { + "version": "1.19.5", + "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.5.tgz", + "integrity": "sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg==", + "dev": true, + "requires": { + "@types/connect": "*", + "@types/node": "*" + } + }, + "@types/command-line-args": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/@types/command-line-args/-/command-line-args-5.2.3.tgz", + "integrity": "sha512-uv0aG6R0Y8WHZLTamZwtfsDLVRnOa+n+n5rEvFWL5Na5gZ8V2Teab/duDPFzIIIhs9qizDpcavCusCLJZu62Kw==", + "dev": true + }, + "@types/connect": { + "version": "3.4.38", + "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz", + "integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "@types/content-disposition": { + "version": "0.5.8", + "resolved": "https://registry.npmjs.org/@types/content-disposition/-/content-disposition-0.5.8.tgz", + "integrity": "sha512-QVSSvno3dE0MgO76pJhmv4Qyi/j0Yk9pBp0Y7TJ2Tlj+KCgJWY6qX7nnxCOLkZ3VYRSIk1WTxCvwUSdx6CCLdg==", + "dev": true + }, + "@types/cookies": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/@types/cookies/-/cookies-0.9.0.tgz", + "integrity": "sha512-40Zk8qR147RABiQ7NQnBzWzDcjKzNrntB5BAmeGCb2p/MIyOE+4BVvc17wumsUqUw00bJYqoXFHYygQnEFh4/Q==", + "dev": true, + "requires": { + "@types/connect": "*", + "@types/express": "*", + "@types/keygrip": "*", + "@types/node": "*" + } + }, + "@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "dev": true + }, + "@types/express": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.21.tgz", + "integrity": "sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ==", + "dev": true, + "requires": { + "@types/body-parser": "*", + "@types/express-serve-static-core": "^4.17.33", + "@types/qs": "*", + "@types/serve-static": "*" + } + }, + "@types/express-serve-static-core": { + "version": "4.19.0", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.19.0.tgz", + "integrity": "sha512-bGyep3JqPCRry1wq+O5n7oiBgGWmeIJXPjXXCo8EK0u8duZGSYar7cGqd3ML2JUsLGeB7fmc06KYo9fLGWqPvQ==", + "dev": true, + "requires": { + "@types/node": "*", + "@types/qs": "*", + "@types/range-parser": "*", + "@types/send": "*" + } + }, + "@types/http-assert": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@types/http-assert/-/http-assert-1.5.5.tgz", + "integrity": "sha512-4+tE/lwdAahgZT1g30Jkdm9PzFRde0xwxBNUyRsCitRvCQB90iuA2uJYdUnhnANRcqGXaWOGY4FEoxeElNAK2g==", + "dev": true + }, + "@types/http-errors": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.4.tgz", + "integrity": "sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA==", + "dev": true + }, + "@types/keygrip": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/keygrip/-/keygrip-1.0.6.tgz", + "integrity": "sha512-lZuNAY9xeJt7Bx4t4dx0rYCDqGPW8RXhQZK1td7d4H6E9zYbLoOtjBvfwdTKpsyxQI/2jv+armjX/RW+ZNpXOQ==", + "dev": true + }, + "@types/koa": { + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/@types/koa/-/koa-2.15.0.tgz", + "integrity": "sha512-7QFsywoE5URbuVnG3loe03QXuGajrnotr3gQkXcEBShORai23MePfFYdhz90FEtBBpkyIYQbVD+evKtloCgX3g==", + "dev": true, + "requires": { + "@types/accepts": "*", + "@types/content-disposition": "*", + "@types/cookies": "*", + "@types/http-assert": "*", + "@types/http-errors": "*", + "@types/keygrip": "*", + "@types/koa-compose": "*", + "@types/node": "*" + } + }, + "@types/koa-compose": { + "version": "3.2.8", + "resolved": "https://registry.npmjs.org/@types/koa-compose/-/koa-compose-3.2.8.tgz", + "integrity": "sha512-4Olc63RY+MKvxMwVknCUDhRQX1pFQoBZ/lXcRLP69PQkEpze/0cr8LNqJQe5NFb/b19DWi2a5bTi2VAlQzhJuA==", + "dev": true, + "requires": { + "@types/koa": "*" + } + }, + "@types/mime": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz", + "integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==", + "dev": true + }, + "@types/node": { + "version": "20.12.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.11.tgz", + "integrity": "sha512-vDg9PZ/zi+Nqp6boSOT7plNuthRugEKixDv5sFTIpkE89MmNtEArAShI4mxuX2+UrLEe9pxC1vm2cjm9YlWbJw==", + "dev": true, + "requires": { + "undici-types": "~5.26.4" + } + }, + "@types/parse5": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/@types/parse5/-/parse5-6.0.3.tgz", + "integrity": "sha512-SuT16Q1K51EAVPz1K29DJ/sXjhSQ0zjvsypYJ6tlwVsRV9jwW5Adq2ch8Dq8kDBCkYnELS7N7VNCSB5nC56t/g==", + "dev": true + }, + "@types/qs": { + "version": "6.9.15", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.15.tgz", + "integrity": "sha512-uXHQKES6DQKKCLh441Xv/dwxOq1TVS3JPUMlEqoEglvlhR6Mxnlew/Xq/LRVHpLyk7iK3zODe1qYHIMltO7XGg==", + "dev": true + }, + "@types/range-parser": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.7.tgz", + "integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==", + "dev": true + }, + "@types/resolve": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", + "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==", + "dev": true + }, + "@types/send": { + "version": "0.17.4", + "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.4.tgz", + "integrity": "sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA==", + "dev": true, + "requires": { + "@types/mime": "^1", + "@types/node": "*" + } + }, + "@types/serve-static": { + "version": "1.15.7", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.7.tgz", + "integrity": "sha512-W8Ym+h8nhuRwaKPaDw34QUkwsGi6Rc4yYqvKFo5rm2FUEhCFbzVWrxXUxuKK8TASjWsysJY0nsmNCGhCOIsrOw==", + "dev": true, + "requires": { + "@types/http-errors": "*", + "@types/node": "*", + "@types/send": "*" + } + }, + "@types/trusted-types": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", + "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==" + }, + "@types/ws": { + "version": "7.4.7", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz", + "integrity": "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "@web/config-loader": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@web/config-loader/-/config-loader-0.3.1.tgz", + "integrity": "sha512-IYjHXUgSGGNpO3YJQ9foLcazbJlAWDdJGRe9be7aOhon0Nd6Na5JIOJAej7jsMu76fKHr4b4w2LfIdNQ4fJ8pA==", + "dev": true + }, + "@web/dev-server": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/@web/dev-server/-/dev-server-0.4.4.tgz", + "integrity": "sha512-Gye0DhDbst/KVNRCFzRd+4V9LJmuuQYJBsf6UXeEbCYuBSKeshEW4AA1esLsfy1gONsD6NIGiru5509l35P9Ug==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.12.11", + "@types/command-line-args": "^5.0.0", + "@web/config-loader": "^0.3.0", + "@web/dev-server-core": "^0.7.1", + "@web/dev-server-rollup": "^0.6.1", + "camelcase": "^6.2.0", + "command-line-args": "^5.1.1", + "command-line-usage": "^7.0.1", + "debounce": "^1.2.0", + "deepmerge": "^4.2.2", + "ip": "^2.0.1", + "nanocolors": "^0.2.1", + "open": "^8.0.2", + "portfinder": "^1.0.32" + } + }, + "@web/dev-server-core": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/@web/dev-server-core/-/dev-server-core-0.7.2.tgz", + "integrity": "sha512-Q/0jpF13Ipk+qGGQ+Yx/FW1TQBYazpkfgYHHo96HBE7qv4V4KKHqHglZcSUxti/zd4bToxX1cFTz8dmbTlb8JA==", + "dev": true, + "requires": { + "@types/koa": "^2.11.6", + "@types/ws": "^7.4.0", + "@web/parse5-utils": "^2.1.0", + "chokidar": "^3.4.3", + "clone": "^2.1.2", + "es-module-lexer": "^1.0.0", + "get-stream": "^6.0.0", + "is-stream": "^2.0.0", + "isbinaryfile": "^5.0.0", + "koa": "^2.13.0", + "koa-etag": "^4.0.0", + "koa-send": "^5.0.1", + "koa-static": "^5.0.0", + "lru-cache": "^8.0.4", + "mime-types": "^2.1.27", + "parse5": "^6.0.1", + "picomatch": "^2.2.2", + "ws": "^7.4.2" + } + }, + "@web/dev-server-rollup": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/@web/dev-server-rollup/-/dev-server-rollup-0.6.3.tgz", + "integrity": "sha512-dzMwQRBk9Rhpfoo7vvQGvRP18sDELejJCwxsMdt509aLouIB6fviv0i87DJQWbXH24hBeq6+jSILI3JTtVaPZQ==", + "dev": true, + "requires": { + "@rollup/plugin-node-resolve": "^15.0.1", + "@web/dev-server-core": "^0.7.2", + "nanocolors": "^0.2.1", + "parse5": "^6.0.1", + "rollup": "^4.4.0", + "whatwg-url": "^11.0.0" + } + }, + "@web/parse5-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@web/parse5-utils/-/parse5-utils-2.1.0.tgz", + "integrity": "sha512-GzfK5disEJ6wEjoPwx8AVNwUe9gYIiwc+x//QYxYDAFKUp4Xb1OJAGLc2l2gVrSQmtPGLKrTRcW90Hv4pEq1qA==", + "dev": true, + "requires": { + "@types/parse5": "^6.0.1", + "parse5": "^6.0.1" + } + }, + "accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "dev": true, + "requires": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + } + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, + "array-back": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-3.1.0.tgz", + "integrity": "sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==", + "dev": true + }, + "async": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", + "dev": true, + "requires": { + "lodash": "^4.17.14" + } + }, + "binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true + }, + "boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", + "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==", + "dev": true + }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "browserslist": { + "version": "4.23.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.0.tgz", + "integrity": "sha512-QW8HiM1shhT2GuzkvklfjcKDiWFXHOeFCIA/huJPwHsslwcydgk7X+z2zXpEijP98UCY7HbubZt5J2Zgvf0CaQ==", + "dev": true, + "requires": { + "caniuse-lite": "^1.0.30001587", + "electron-to-chromium": "^1.4.668", + "node-releases": "^2.0.14", + "update-browserslist-db": "^1.0.13" + } + }, + "builtin-modules": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", + "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", + "dev": true + }, + "cache-content-type": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cache-content-type/-/cache-content-type-1.0.1.tgz", + "integrity": "sha512-IKufZ1o4Ut42YUrZSo8+qnMTrFuKkvyoLXUywKz9GJ5BrhOFGhLdkx9sG4KAnVvbY6kEcSFjLQul+DVmBm2bgA==", + "dev": true, + "requires": { + "mime-types": "^2.1.18", + "ylru": "^1.2.0" + } + }, + "camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true + }, + "caniuse-api": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/caniuse-api/-/caniuse-api-3.0.0.tgz", + "integrity": "sha512-bsTwuIg/BZZK/vreVTYYbSWoe2F+71P7K5QGEX+pT250DZbfU1MQ5prOKpPR+LL6uWKK3KMwMCAS74QB3Um1uw==", + "dev": true, + "requires": { + "browserslist": "^4.0.0", + "caniuse-lite": "^1.0.0", + "lodash.memoize": "^4.1.2", + "lodash.uniq": "^4.5.0" + } + }, + "caniuse-lite": { + "version": "1.0.30001617", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001617.tgz", + "integrity": "sha512-mLyjzNI9I+Pix8zwcrpxEbGlfqOkF9kM3ptzmKNw5tizSyYwMe+nGLTqMK9cO+0E+Bh6TsBxNAaHWEM8xwSsmA==", + "dev": true + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "chalk-template": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/chalk-template/-/chalk-template-0.4.0.tgz", + "integrity": "sha512-/ghrgmhfY8RaSdeo43hNXxpoHAtxdbskUHjPpfqUWGttFgycUhYPGx3YZBCnUCvOa7Doivn1IZec3DEGFoMgLg==", + "dev": true, + "requires": { + "chalk": "^4.1.2" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "requires": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "fsevents": "~2.3.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + } + }, + "clone": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", + "integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==", + "dev": true + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==", + "dev": true + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, + "colord": { + "version": "2.9.3", + "resolved": "https://registry.npmjs.org/colord/-/colord-2.9.3.tgz", + "integrity": "sha512-jeC1axXpnb0/2nn/Y1LPuLdgXBLH7aDcHu4KEKfqw3CUhX7ZpfBSlPKyqXE6btIgEzfWtrX3/tyBCaCvXvMkOw==", + "dev": true + }, + "command-line-args": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/command-line-args/-/command-line-args-5.2.1.tgz", + "integrity": "sha512-H4UfQhZyakIjC74I9d34fGYDwk3XpSr17QhEd0Q3I9Xq1CETHo4Hcuo87WyWHpAF1aSLjLRf5lD9ZGX2qStUvg==", + "dev": true, + "requires": { + "array-back": "^3.1.0", + "find-replace": "^3.0.0", + "lodash.camelcase": "^4.3.0", + "typical": "^4.0.0" + } + }, + "command-line-usage": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/command-line-usage/-/command-line-usage-7.0.1.tgz", + "integrity": "sha512-NCyznE//MuTjwi3y84QVUGEOT+P5oto1e1Pk/jFPVdPPfsG03qpTIl3yw6etR+v73d0lXsoojRpvbru2sqePxQ==", + "dev": true, + "requires": { + "array-back": "^6.2.2", + "chalk-template": "^0.4.0", + "table-layout": "^3.0.0", + "typical": "^7.1.1" + }, + "dependencies": { + "array-back": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-6.2.2.tgz", + "integrity": "sha512-gUAZ7HPyb4SJczXAMUXMGAvI976JoK3qEx9v1FTmeYuJj0IBiaKttG1ydtGKdkfqWkIkouke7nG8ufGy77+Cvw==", + "dev": true + }, + "typical": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/typical/-/typical-7.1.1.tgz", + "integrity": "sha512-T+tKVNs6Wu7IWiAce5BgMd7OZfNYUndHwc5MknN+UHOudi7sGZzuHdCadllRuqJ3fPtgFtIH9+lt9qRv6lmpfA==", + "dev": true + } + } + }, + "commander": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", + "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", + "dev": true + }, + "content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "dev": true, + "requires": { + "safe-buffer": "5.2.1" + } + }, + "content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "dev": true + }, + "cookies": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/cookies/-/cookies-0.9.1.tgz", + "integrity": "sha512-TG2hpqe4ELx54QER/S3HQ9SRVnQnGBtKUz5bLQWtYAQ+o6GpgMs6sYUvaiJjVxb+UXwhRhAEP3m7LbsIZ77Hmw==", + "dev": true, + "requires": { + "depd": "~2.0.0", + "keygrip": "~1.1.0" + } + }, + "css-declaration-sorter": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-7.2.0.tgz", + "integrity": "sha512-h70rUM+3PNFuaBDTLe8wF/cdWu+dOZmb7pJt8Z2sedYbAcQVQV/tEchueg3GWxwqS0cxtbxmaHEdkNACqcvsow==", + "dev": true, + "requires": {} + }, + "css-select": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz", + "integrity": "sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==", + "dev": true, + "requires": { + "boolbase": "^1.0.0", + "css-what": "^6.1.0", + "domhandler": "^5.0.2", + "domutils": "^3.0.1", + "nth-check": "^2.0.1" + } + }, + "css-tree": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.3.1.tgz", + "integrity": "sha512-6Fv1DV/TYw//QF5IzQdqsNDjx/wc8TrMBZsqjL9eW01tWb7R7k/mq+/VXfJCl7SoD5emsJop9cOByJZfs8hYIw==", + "dev": true, + "requires": { + "mdn-data": "2.0.30", + "source-map-js": "^1.0.1" + } + }, + "css-what": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.1.0.tgz", + "integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==", + "dev": true + }, + "cssesc": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", + "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", + "dev": true + }, + "cssnano": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/cssnano/-/cssnano-6.1.2.tgz", + "integrity": "sha512-rYk5UeX7VAM/u0lNqewCdasdtPK81CgX8wJFLEIXHbV2oldWRgJAsZrdhRXkV1NJzA2g850KiFm9mMU2HxNxMA==", + "dev": true, + "requires": { + "cssnano-preset-default": "^6.1.2", + "lilconfig": "^3.1.1" + } + }, + "cssnano-preset-default": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/cssnano-preset-default/-/cssnano-preset-default-6.1.2.tgz", + "integrity": "sha512-1C0C+eNaeN8OcHQa193aRgYexyJtU8XwbdieEjClw+J9d94E41LwT6ivKH0WT+fYwYWB0Zp3I3IZ7tI/BbUbrg==", + "dev": true, + "requires": { + "browserslist": "^4.23.0", + "css-declaration-sorter": "^7.2.0", + "cssnano-utils": "^4.0.2", + "postcss-calc": "^9.0.1", + "postcss-colormin": "^6.1.0", + "postcss-convert-values": "^6.1.0", + "postcss-discard-comments": "^6.0.2", + "postcss-discard-duplicates": "^6.0.3", + "postcss-discard-empty": "^6.0.3", + "postcss-discard-overridden": "^6.0.2", + "postcss-merge-longhand": "^6.0.5", + "postcss-merge-rules": "^6.1.1", + "postcss-minify-font-values": "^6.1.0", + "postcss-minify-gradients": "^6.0.3", + "postcss-minify-params": "^6.1.0", + "postcss-minify-selectors": "^6.0.4", + "postcss-normalize-charset": "^6.0.2", + "postcss-normalize-display-values": "^6.0.2", + "postcss-normalize-positions": "^6.0.2", + "postcss-normalize-repeat-style": "^6.0.2", + "postcss-normalize-string": "^6.0.2", + "postcss-normalize-timing-functions": "^6.0.2", + "postcss-normalize-unicode": "^6.1.0", + "postcss-normalize-url": "^6.0.2", + "postcss-normalize-whitespace": "^6.0.2", + "postcss-ordered-values": "^6.0.2", + "postcss-reduce-initial": "^6.1.0", + "postcss-reduce-transforms": "^6.0.2", + "postcss-svgo": "^6.0.3", + "postcss-unique-selectors": "^6.0.4" + } + }, + "cssnano-utils": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/cssnano-utils/-/cssnano-utils-4.0.2.tgz", + "integrity": "sha512-ZR1jHg+wZ8o4c3zqf1SIUSTIvm/9mU343FMR6Obe/unskbvpGhZOo1J6d/r8D1pzkRQYuwbcH3hToOuoA2G7oQ==", + "dev": true, + "requires": {} + }, + "csso": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/csso/-/csso-5.0.5.tgz", + "integrity": "sha512-0LrrStPOdJj+SPCCrGhzryycLjwcgUSHBtxNA8aIDxf0GLsRh1cKYhB00Gd1lDOS4yGH69+SNn13+TWbVHETFQ==", + "dev": true, + "requires": { + "css-tree": "~2.2.0" + }, + "dependencies": { + "css-tree": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.2.1.tgz", + "integrity": "sha512-OA0mILzGc1kCOCSJerOeqDxDQ4HOh+G8NbOJFOTgOCzpw7fCBubk0fEyxp8AgOL/jvLgYA/uV0cMbe43ElF1JA==", + "dev": true, + "requires": { + "mdn-data": "2.0.28", + "source-map-js": "^1.0.1" + } + }, + "mdn-data": { + "version": "2.0.28", + "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.28.tgz", + "integrity": "sha512-aylIc7Z9y4yzHYAJNuESG3hfhC+0Ibp/MAMiaOZgNv4pmEdFyfZhhhny4MNiAfWdBQ1RQ2mfDWmM1x8SvGyp8g==", + "dev": true + } + } + }, + "debounce": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/debounce/-/debounce-1.2.1.tgz", + "integrity": "sha512-XRRe6Glud4rd/ZGQfiV1ruXSfbvfJedlV9Y6zOlP+2K04vBYiJEte6stfFkCP03aMnY5tsipamumUjL14fofug==", + "dev": true + }, + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "deep-equal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", + "integrity": "sha512-bHtC0iYvWhyaTzvV3CZgPeZQqCOBGyGsVV7v4eevpdkLHfiSrXUdBG+qAuSz4RI70sszvjQ1QSZ98An1yNwpSw==", + "dev": true + }, + "deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true + }, + "define-lazy-prop": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz", + "integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==", + "dev": true + }, + "delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==", + "dev": true + }, + "depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "dev": true + }, + "destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "dev": true + }, + "dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "dev": true, + "requires": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + } + }, + "domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", + "dev": true + }, + "domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "dev": true, + "requires": { + "domelementtype": "^2.3.0" + } + }, + "domutils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.1.0.tgz", + "integrity": "sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==", + "dev": true, + "requires": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3" + } + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "dev": true + }, + "electron-to-chromium": { + "version": "1.4.764", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.764.tgz", + "integrity": "sha512-ZXbPV46Y4dNCA+k7YHB+BYlzcoMtZ1yH6V0tQ1ul0wmA7RiwJfS29LSdRlE1myWBXRzEgm/Lz6tryj5WVQiLmg==", + "dev": true + }, + "encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "dev": true + }, + "entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "dev": true + }, + "es-module-lexer": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.5.2.tgz", + "integrity": "sha512-l60ETUTmLqbVbVHv1J4/qj+M8nq7AwMzEcg3kmJDt9dCNrTk+yHcYFf/Kw75pMDwd9mPcIGCG5LcS20SxYRzFA==", + "dev": true + }, + "esbuild": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.20.2.tgz", + "integrity": "sha512-WdOOppmUNU+IbZ0PaDiTst80zjnrOkyJNHoKupIcVyU8Lvla3Ugx94VzkQ32Ijqd7UhHJy75gNWDMUekcrSJ6g==", + "dev": true, + "requires": { + "@esbuild/aix-ppc64": "0.20.2", + "@esbuild/android-arm": "0.20.2", + "@esbuild/android-arm64": "0.20.2", + "@esbuild/android-x64": "0.20.2", + "@esbuild/darwin-arm64": "0.20.2", + "@esbuild/darwin-x64": "0.20.2", + "@esbuild/freebsd-arm64": "0.20.2", + "@esbuild/freebsd-x64": "0.20.2", + "@esbuild/linux-arm": "0.20.2", + "@esbuild/linux-arm64": "0.20.2", + "@esbuild/linux-ia32": "0.20.2", + "@esbuild/linux-loong64": "0.20.2", + "@esbuild/linux-mips64el": "0.20.2", + "@esbuild/linux-ppc64": "0.20.2", + "@esbuild/linux-riscv64": "0.20.2", + "@esbuild/linux-s390x": "0.20.2", + "@esbuild/linux-x64": "0.20.2", + "@esbuild/netbsd-x64": "0.20.2", + "@esbuild/openbsd-x64": "0.20.2", + "@esbuild/sunos-x64": "0.20.2", + "@esbuild/win32-arm64": "0.20.2", + "@esbuild/win32-ia32": "0.20.2", + "@esbuild/win32-x64": "0.20.2" + } + }, + "esbuild-plugin-lit-css": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/esbuild-plugin-lit-css/-/esbuild-plugin-lit-css-3.0.0.tgz", + "integrity": "sha512-5xpMa9Kt6C07Qvjp6k0j5sbcnePd0+ejgeP/DXQFQSeTvNoF0uGrr/Tn8Y5oRZzFWtw9OkW3s/dZ7HvLR5APmQ==", + "dev": true, + "requires": { + "@pwrs/lit-css": "^3.0.0" + } + }, + "escalade": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", + "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", + "dev": true + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true + }, + "estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true + }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "dev": true + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "find-replace": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-replace/-/find-replace-3.0.0.tgz", + "integrity": "sha512-6Tb2myMioCAgv5kfvP5/PkZZ/ntTpVK39fHY7WkWBgvbeE+VHd/tZuZ4mrC+bxh4cfOZeYKVPaJIZtZXV7GNCQ==", + "dev": true, + "requires": { + "array-back": "^3.0.1" + } + }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "dev": true + }, + "function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true + }, + "get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "dev": true + }, + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true + }, + "has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "dev": true + }, + "has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "dev": true, + "requires": { + "has-symbols": "^1.0.3" + } + }, + "hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dev": true, + "requires": { + "function-bind": "^1.1.2" + } + }, + "http-assert": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/http-assert/-/http-assert-1.5.0.tgz", + "integrity": "sha512-uPpH7OKX4H25hBmU6G1jWNaqJGpTXxey+YOUizJUAgu0AjLUeC8D73hTrhvDS5D+GJN1DN1+hhc/eF/wpxtp0w==", + "dev": true, + "requires": { + "deep-equal": "~1.0.1", + "http-errors": "~1.8.0" + } + }, + "http-errors": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", + "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", + "dev": true, + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.1" + }, + "dependencies": { + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", + "dev": true + } + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "ip": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.1.tgz", + "integrity": "sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==", + "dev": true + }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "requires": { + "binary-extensions": "^2.0.0" + } + }, + "is-builtin-module": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.1.tgz", + "integrity": "sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==", + "dev": true, + "requires": { + "builtin-modules": "^3.3.0" + } + }, + "is-core-module": { + "version": "2.13.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.1.tgz", + "integrity": "sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==", + "dev": true, + "requires": { + "hasown": "^2.0.0" + } + }, + "is-docker": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "dev": true + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true + }, + "is-generator-function": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.10.tgz", + "integrity": "sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A==", + "dev": true, + "requires": { + "has-tostringtag": "^1.0.0" + } + }, + "is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==", + "dev": true + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, + "is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true + }, + "is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "requires": { + "is-docker": "^2.0.0" + } + }, + "isbinaryfile": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-5.0.2.tgz", + "integrity": "sha512-GvcjojwonMjWbTkfMpnVHVqXW/wKMYDfEpY94/8zy8HFMOqb/VL6oeONq9v87q4ttVlaTLnGXnJD4B5B1OTGIg==", + "dev": true + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "jsdifflib": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/jsdifflib/-/jsdifflib-1.1.0.tgz", + "integrity": "sha512-wsb7MeyPgKr7yNkyJa4VsM8uiqzchaZ4km5kcDzuYkGy8HNNEmeQGbPCnMy/yHWnPinORwIQSB+dnrdt8TFZPQ==" + }, + "jstat": { + "version": "1.9.6", + "resolved": "https://registry.npmjs.org/jstat/-/jstat-1.9.6.tgz", + "integrity": "sha512-rPBkJbK2TnA8pzs93QcDDPlKcrtZWuuCo2dVR0TFLOJSxhqfWOVCSp8aV3/oSbn+4uY4yw1URtLpHQedtmXfug==" + }, + "keygrip": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/keygrip/-/keygrip-1.1.0.tgz", + "integrity": "sha512-iYSchDJ+liQ8iwbSI2QqsQOvqv58eJCEanyJPJi+Khyu8smkcKSFUCbPwzFcL7YVtZ6eONjqRX/38caJ7QjRAQ==", + "dev": true, + "requires": { + "tsscmp": "1.0.6" + } + }, + "koa": { + "version": "2.15.3", + "resolved": "https://registry.npmjs.org/koa/-/koa-2.15.3.tgz", + "integrity": "sha512-j/8tY9j5t+GVMLeioLaxweJiKUayFhlGqNTzf2ZGwL0ZCQijd2RLHK0SLW5Tsko8YyyqCZC2cojIb0/s62qTAg==", + "dev": true, + "requires": { + "accepts": "^1.3.5", + "cache-content-type": "^1.0.0", + "content-disposition": "~0.5.2", + "content-type": "^1.0.4", + "cookies": "~0.9.0", + "debug": "^4.3.2", + "delegates": "^1.0.0", + "depd": "^2.0.0", + "destroy": "^1.0.4", + "encodeurl": "^1.0.2", + "escape-html": "^1.0.3", + "fresh": "~0.5.2", + "http-assert": "^1.3.0", + "http-errors": "^1.6.3", + "is-generator-function": "^1.0.7", + "koa-compose": "^4.1.0", + "koa-convert": "^2.0.0", + "on-finished": "^2.3.0", + "only": "~0.0.2", + "parseurl": "^1.3.2", + "statuses": "^1.5.0", + "type-is": "^1.6.16", + "vary": "^1.1.2" + } + }, + "koa-compose": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/koa-compose/-/koa-compose-4.1.0.tgz", + "integrity": "sha512-8ODW8TrDuMYvXRwra/Kh7/rJo9BtOfPc6qO8eAfC80CnCvSjSl0bkRM24X6/XBBEyj0v1nRUQ1LyOy3dbqOWXw==", + "dev": true + }, + "koa-convert": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/koa-convert/-/koa-convert-2.0.0.tgz", + "integrity": "sha512-asOvN6bFlSnxewce2e/DK3p4tltyfC4VM7ZwuTuepI7dEQVcvpyFuBcEARu1+Hxg8DIwytce2n7jrZtRlPrARA==", + "dev": true, + "requires": { + "co": "^4.6.0", + "koa-compose": "^4.1.0" + } + }, + "koa-etag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/koa-etag/-/koa-etag-4.0.0.tgz", + "integrity": "sha512-1cSdezCkBWlyuB9l6c/IFoe1ANCDdPBxkDkRiaIup40xpUub6U/wwRXoKBZw/O5BifX9OlqAjYnDyzM6+l+TAg==", + "dev": true, + "requires": { + "etag": "^1.8.1" + } + }, + "koa-send": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/koa-send/-/koa-send-5.0.1.tgz", + "integrity": "sha512-tmcyQ/wXXuxpDxyNXv5yNNkdAMdFRqwtegBXUaowiQzUKqJehttS0x2j0eOZDQAyloAth5w6wwBImnFzkUz3pQ==", + "dev": true, + "requires": { + "debug": "^4.1.1", + "http-errors": "^1.7.3", + "resolve-path": "^1.4.0" + } + }, + "koa-static": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/koa-static/-/koa-static-5.0.0.tgz", + "integrity": "sha512-UqyYyH5YEXaJrf9S8E23GoJFQZXkBVJ9zYYMPGz919MSX1KuvAcycIuS0ci150HCoPf4XQVhQ84Qf8xRPWxFaQ==", + "dev": true, + "requires": { + "debug": "^3.1.0", + "koa-send": "^5.0.0" + }, + "dependencies": { + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + } + } + }, + "lilconfig": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.1.tgz", + "integrity": "sha512-O18pf7nyvHTckunPWCV1XUNXU1piu01y2b7ATJ0ppkUkk8ocqVWBrYjJBCwHDjD/ZWcfyrA0P4gKhzWGi5EINQ==", + "dev": true + }, + "lit": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/lit/-/lit-3.1.3.tgz", + "integrity": "sha512-l4slfspEsnCcHVRTvaP7YnkTZEZggNFywLEIhQaGhYDczG+tu/vlgm/KaWIEjIp+ZyV20r2JnZctMb8LeLCG7Q==", + "requires": { + "@lit/reactive-element": "^2.0.4", + "lit-element": "^4.0.4", + "lit-html": "^3.1.2" + } + }, + "lit-element": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/lit-element/-/lit-element-4.0.5.tgz", + "integrity": "sha512-iTWskWZEtn9SyEf4aBG6rKT8GABZMrTWop1+jopsEOgEcugcXJGKuX5bEbkq9qfzY+XB4MAgCaSPwnNpdsNQ3Q==", + "requires": { + "@lit-labs/ssr-dom-shim": "^1.2.0", + "@lit/reactive-element": "^2.0.4", + "lit-html": "^3.1.2" + } + }, + "lit-html": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-3.1.3.tgz", + "integrity": "sha512-FwIbqDD8O/8lM4vUZ4KvQZjPPNx7V1VhT7vmRB8RBAO0AU6wuTVdoXiu2CivVjEGdugvcbPNBLtPE1y0ifplHA==", + "requires": { + "@types/trusted-types": "^2.0.2" + } + }, + "lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true + }, + "lodash.assignwith": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lodash.assignwith/-/lodash.assignwith-4.2.0.tgz", + "integrity": "sha512-ZznplvbvtjK2gMvnQ1BR/zqPFZmS6jbK4p+6Up4xcRYA7yMIwxHCfbTcrYxXKzzqLsQ05eJPVznEW3tuwV7k1g==", + "dev": true + }, + "lodash.camelcase": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", + "integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==", + "dev": true + }, + "lodash.memoize": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", + "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==", + "dev": true + }, + "lodash.uniq": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz", + "integrity": "sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==", + "dev": true + }, + "lru-cache": { + "version": "8.0.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-8.0.5.tgz", + "integrity": "sha512-MhWWlVnuab1RG5/zMRRcVGXZLCXrZTgfwMikgzCegsPnG62yDQo5JnqKkrK4jO5iKqDAZGItAqN5CtKBCBWRUA==", + "dev": true + }, + "mdn-data": { + "version": "2.0.30", + "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.30.tgz", + "integrity": "sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==", + "dev": true + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "dev": true + }, + "mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true + }, + "mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, + "requires": { + "mime-db": "1.52.0" + } + }, + "minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true + }, + "mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "requires": { + "minimist": "^1.2.6" + } + }, + "mobx": { + "version": "6.12.3", + "resolved": "https://registry.npmjs.org/mobx/-/mobx-6.12.3.tgz", + "integrity": "sha512-c8NKkO4R2lShkSXZ2Ongj1ycjugjzFFo/UswHBnS62y07DMcTc9Rvo03/3nRyszIvwPNljlkd4S828zIBv/piw==" + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "nanocolors": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/nanocolors/-/nanocolors-0.2.13.tgz", + "integrity": "sha512-0n3mSAQLPpGLV9ORXT5+C/D4mwew7Ebws69Hx4E2sgz2ZA5+32Q80B9tL8PbL7XHnRDiAxH/pnrUJ9a4fkTNTA==", + "dev": true + }, + "nanoid": { + "version": "3.3.7", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", + "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "dev": true, + "peer": true + }, + "negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "dev": true + }, + "node-releases": { + "version": "2.0.14", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz", + "integrity": "sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==", + "dev": true + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true + }, + "nth-check": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", + "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", + "dev": true, + "requires": { + "boolbase": "^1.0.0" + } + }, + "on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "dev": true, + "requires": { + "ee-first": "1.1.1" + } + }, + "only": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/only/-/only-0.0.2.tgz", + "integrity": "sha512-Fvw+Jemq5fjjyWz6CpKx6w9s7xxqo3+JCyM0WXWeCSOboZ8ABkyvP8ID4CZuChA/wxSx+XSJmdOm8rGVyJ1hdQ==", + "dev": true + }, + "open": { + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/open/-/open-8.4.2.tgz", + "integrity": "sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==", + "dev": true, + "requires": { + "define-lazy-prop": "^2.0.0", + "is-docker": "^2.1.1", + "is-wsl": "^2.2.0" + } + }, + "parse5": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz", + "integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==", + "dev": true + }, + "parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true + }, + "path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", + "dev": true + }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + }, + "portfinder": { + "version": "1.0.32", + "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.32.tgz", + "integrity": "sha512-on2ZJVVDXRADWE6jnQaX0ioEylzgBpQk8r55NE4wjXW1ZxO+BgDlY6DXwj20i0V8eB4SenDQ00WEaxfiIQPcxg==", + "dev": true, + "requires": { + "async": "^2.6.4", + "debug": "^3.2.7", + "mkdirp": "^0.5.6" + }, + "dependencies": { + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + } + } + }, + "postcss": { + "version": "8.4.38", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.38.tgz", + "integrity": "sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==", + "dev": true, + "peer": true, + "requires": { + "nanoid": "^3.3.7", + "picocolors": "^1.0.0", + "source-map-js": "^1.2.0" + } + }, + "postcss-calc": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/postcss-calc/-/postcss-calc-9.0.1.tgz", + "integrity": "sha512-TipgjGyzP5QzEhsOZUaIkeO5mKeMFpebWzRogWG/ysonUlnHcq5aJe0jOjpfzUU8PeSaBQnrE8ehR0QA5vs8PQ==", + "dev": true, + "requires": { + "postcss-selector-parser": "^6.0.11", + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-colormin": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/postcss-colormin/-/postcss-colormin-6.1.0.tgz", + "integrity": "sha512-x9yX7DOxeMAR+BgGVnNSAxmAj98NX/YxEMNFP+SDCEeNLb2r3i6Hh1ksMsnW8Ub5SLCpbescQqn9YEbE9554Sw==", + "dev": true, + "requires": { + "browserslist": "^4.23.0", + "caniuse-api": "^3.0.0", + "colord": "^2.9.3", + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-convert-values": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/postcss-convert-values/-/postcss-convert-values-6.1.0.tgz", + "integrity": "sha512-zx8IwP/ts9WvUM6NkVSkiU902QZL1bwPhaVaLynPtCsOTqp+ZKbNi+s6XJg3rfqpKGA/oc7Oxk5t8pOQJcwl/w==", + "dev": true, + "requires": { + "browserslist": "^4.23.0", + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-discard-comments": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-discard-comments/-/postcss-discard-comments-6.0.2.tgz", + "integrity": "sha512-65w/uIqhSBBfQmYnG92FO1mWZjJ4GL5b8atm5Yw2UgrwD7HiNiSSNwJor1eCFGzUgYnN/iIknhNRVqjrrpuglw==", + "dev": true, + "requires": {} + }, + "postcss-discard-duplicates": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/postcss-discard-duplicates/-/postcss-discard-duplicates-6.0.3.tgz", + "integrity": "sha512-+JA0DCvc5XvFAxwx6f/e68gQu/7Z9ud584VLmcgto28eB8FqSFZwtrLwB5Kcp70eIoWP/HXqz4wpo8rD8gpsTw==", + "dev": true, + "requires": {} + }, + "postcss-discard-empty": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/postcss-discard-empty/-/postcss-discard-empty-6.0.3.tgz", + "integrity": "sha512-znyno9cHKQsK6PtxL5D19Fj9uwSzC2mB74cpT66fhgOadEUPyXFkbgwm5tvc3bt3NAy8ltE5MrghxovZRVnOjQ==", + "dev": true, + "requires": {} + }, + "postcss-discard-overridden": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-discard-overridden/-/postcss-discard-overridden-6.0.2.tgz", + "integrity": "sha512-j87xzI4LUggC5zND7KdjsI25APtyMuynXZSujByMaav2roV6OZX+8AaCUcZSWqckZpjAjRyFDdpqybgjFO0HJQ==", + "dev": true, + "requires": {} + }, + "postcss-merge-longhand": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/postcss-merge-longhand/-/postcss-merge-longhand-6.0.5.tgz", + "integrity": "sha512-5LOiordeTfi64QhICp07nzzuTDjNSO8g5Ksdibt44d+uvIIAE1oZdRn8y/W5ZtYgRH/lnLDlvi9F8btZcVzu3w==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0", + "stylehacks": "^6.1.1" + } + }, + "postcss-merge-rules": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/postcss-merge-rules/-/postcss-merge-rules-6.1.1.tgz", + "integrity": "sha512-KOdWF0gju31AQPZiD+2Ar9Qjowz1LTChSjFFbS+e2sFgc4uHOp3ZvVX4sNeTlk0w2O31ecFGgrFzhO0RSWbWwQ==", + "dev": true, + "requires": { + "browserslist": "^4.23.0", + "caniuse-api": "^3.0.0", + "cssnano-utils": "^4.0.2", + "postcss-selector-parser": "^6.0.16" + } + }, + "postcss-minify-font-values": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/postcss-minify-font-values/-/postcss-minify-font-values-6.1.0.tgz", + "integrity": "sha512-gklfI/n+9rTh8nYaSJXlCo3nOKqMNkxuGpTn/Qm0gstL3ywTr9/WRKznE+oy6fvfolH6dF+QM4nCo8yPLdvGJg==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-minify-gradients": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/postcss-minify-gradients/-/postcss-minify-gradients-6.0.3.tgz", + "integrity": "sha512-4KXAHrYlzF0Rr7uc4VrfwDJ2ajrtNEpNEuLxFgwkhFZ56/7gaE4Nr49nLsQDZyUe+ds+kEhf+YAUolJiYXF8+Q==", + "dev": true, + "requires": { + "colord": "^2.9.3", + "cssnano-utils": "^4.0.2", + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-minify-params": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/postcss-minify-params/-/postcss-minify-params-6.1.0.tgz", + "integrity": "sha512-bmSKnDtyyE8ujHQK0RQJDIKhQ20Jq1LYiez54WiaOoBtcSuflfK3Nm596LvbtlFcpipMjgClQGyGr7GAs+H1uA==", + "dev": true, + "requires": { + "browserslist": "^4.23.0", + "cssnano-utils": "^4.0.2", + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-minify-selectors": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/postcss-minify-selectors/-/postcss-minify-selectors-6.0.4.tgz", + "integrity": "sha512-L8dZSwNLgK7pjTto9PzWRoMbnLq5vsZSTu8+j1P/2GB8qdtGQfn+K1uSvFgYvgh83cbyxT5m43ZZhUMTJDSClQ==", + "dev": true, + "requires": { + "postcss-selector-parser": "^6.0.16" + } + }, + "postcss-normalize-charset": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-normalize-charset/-/postcss-normalize-charset-6.0.2.tgz", + "integrity": "sha512-a8N9czmdnrjPHa3DeFlwqst5eaL5W8jYu3EBbTTkI5FHkfMhFZh1EGbku6jhHhIzTA6tquI2P42NtZ59M/H/kQ==", + "dev": true, + "requires": {} + }, + "postcss-normalize-display-values": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-normalize-display-values/-/postcss-normalize-display-values-6.0.2.tgz", + "integrity": "sha512-8H04Mxsb82ON/aAkPeq8kcBbAtI5Q2a64X/mnRRfPXBq7XeogoQvReqxEfc0B4WPq1KimjezNC8flUtC3Qz6jg==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-normalize-positions": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-normalize-positions/-/postcss-normalize-positions-6.0.2.tgz", + "integrity": "sha512-/JFzI441OAB9O7VnLA+RtSNZvQ0NCFZDOtp6QPFo1iIyawyXg0YI3CYM9HBy1WvwCRHnPep/BvI1+dGPKoXx/Q==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-normalize-repeat-style": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-normalize-repeat-style/-/postcss-normalize-repeat-style-6.0.2.tgz", + "integrity": "sha512-YdCgsfHkJ2jEXwR4RR3Tm/iOxSfdRt7jplS6XRh9Js9PyCR/aka/FCb6TuHT2U8gQubbm/mPmF6L7FY9d79VwQ==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-normalize-string": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-normalize-string/-/postcss-normalize-string-6.0.2.tgz", + "integrity": "sha512-vQZIivlxlfqqMp4L9PZsFE4YUkWniziKjQWUtsxUiVsSSPelQydwS8Wwcuw0+83ZjPWNTl02oxlIvXsmmG+CiQ==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-normalize-timing-functions": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-normalize-timing-functions/-/postcss-normalize-timing-functions-6.0.2.tgz", + "integrity": "sha512-a+YrtMox4TBtId/AEwbA03VcJgtyW4dGBizPl7e88cTFULYsprgHWTbfyjSLyHeBcK/Q9JhXkt2ZXiwaVHoMzA==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-normalize-unicode": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/postcss-normalize-unicode/-/postcss-normalize-unicode-6.1.0.tgz", + "integrity": "sha512-QVC5TQHsVj33otj8/JD869Ndr5Xcc/+fwRh4HAsFsAeygQQXm+0PySrKbr/8tkDKzW+EVT3QkqZMfFrGiossDg==", + "dev": true, + "requires": { + "browserslist": "^4.23.0", + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-normalize-url": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-normalize-url/-/postcss-normalize-url-6.0.2.tgz", + "integrity": "sha512-kVNcWhCeKAzZ8B4pv/DnrU1wNh458zBNp8dh4y5hhxih5RZQ12QWMuQrDgPRw3LRl8mN9vOVfHl7uhvHYMoXsQ==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-normalize-whitespace": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-normalize-whitespace/-/postcss-normalize-whitespace-6.0.2.tgz", + "integrity": "sha512-sXZ2Nj1icbJOKmdjXVT9pnyHQKiSAyuNQHSgRCUgThn2388Y9cGVDR+E9J9iAYbSbLHI+UUwLVl1Wzco/zgv0Q==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-ordered-values": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-ordered-values/-/postcss-ordered-values-6.0.2.tgz", + "integrity": "sha512-VRZSOB+JU32RsEAQrO94QPkClGPKJEL/Z9PCBImXMhIeK5KAYo6slP/hBYlLgrCjFxyqvn5VC81tycFEDBLG1Q==", + "dev": true, + "requires": { + "cssnano-utils": "^4.0.2", + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-reduce-initial": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/postcss-reduce-initial/-/postcss-reduce-initial-6.1.0.tgz", + "integrity": "sha512-RarLgBK/CrL1qZags04oKbVbrrVK2wcxhvta3GCxrZO4zveibqbRPmm2VI8sSgCXwoUHEliRSbOfpR0b/VIoiw==", + "dev": true, + "requires": { + "browserslist": "^4.23.0", + "caniuse-api": "^3.0.0" + } + }, + "postcss-reduce-transforms": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/postcss-reduce-transforms/-/postcss-reduce-transforms-6.0.2.tgz", + "integrity": "sha512-sB+Ya++3Xj1WaT9+5LOOdirAxP7dJZms3GRcYheSPi1PiTMigsxHAdkrbItHxwYHr4kt1zL7mmcHstgMYT+aiA==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0" + } + }, + "postcss-selector-parser": { + "version": "6.0.16", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.16.tgz", + "integrity": "sha512-A0RVJrX+IUkVZbW3ClroRWurercFhieevHB38sr2+l9eUClMqome3LmEmnhlNy+5Mr2EYN6B2Kaw9wYdd+VHiw==", + "dev": true, + "requires": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + } + }, + "postcss-svgo": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/postcss-svgo/-/postcss-svgo-6.0.3.tgz", + "integrity": "sha512-dlrahRmxP22bX6iKEjOM+c8/1p+81asjKT+V5lrgOH944ryx/OHpclnIbGsKVd3uWOXFLYJwCVf0eEkJGvO96g==", + "dev": true, + "requires": { + "postcss-value-parser": "^4.2.0", + "svgo": "^3.2.0" + } + }, + "postcss-unique-selectors": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/postcss-unique-selectors/-/postcss-unique-selectors-6.0.4.tgz", + "integrity": "sha512-K38OCaIrO8+PzpArzkLKB42dSARtC2tmG6PvD4b1o1Q2E9Os8jzfWFfSy/rixsHwohtsDdFtAWGjFVFUdwYaMg==", + "dev": true, + "requires": { + "postcss-selector-parser": "^6.0.16" + } + }, + "postcss-value-parser": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", + "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", + "dev": true + }, + "punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true + }, + "readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "requires": { + "picomatch": "^2.2.1" + } + }, + "resolve": { + "version": "1.22.8", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", + "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", + "dev": true, + "requires": { + "is-core-module": "^2.13.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + } + }, + "resolve-path": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/resolve-path/-/resolve-path-1.4.0.tgz", + "integrity": "sha512-i1xevIst/Qa+nA9olDxLWnLk8YZbi8R/7JPbCMcgyWaFR6bKWaexgJgEB5oc2PKMjYdrHynyz0NY+if+H98t1w==", + "dev": true, + "requires": { + "http-errors": "~1.6.2", + "path-is-absolute": "1.0.1" + }, + "dependencies": { + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", + "dev": true + }, + "http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha512-lks+lVC8dgGyh97jxvxeYTWQFvh4uw4yC12gVl63Cg30sjPX4wuGcdkICVXDAESr6OJGjqGA8Iz5mkeN6zlD7A==", + "dev": true, + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": ">= 1.4.0 < 2" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==", + "dev": true + }, + "setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==", + "dev": true + } + } + }, + "rollup": { + "version": "4.17.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.17.2.tgz", + "integrity": "sha512-/9ClTJPByC0U4zNLowV1tMBe8yMEAxewtR3cUNX5BoEpGH3dQEWpJLr6CLp0fPdYRF/fzVOgvDb1zXuakwF5kQ==", + "dev": true, + "requires": { + "@rollup/rollup-android-arm-eabi": "4.17.2", + "@rollup/rollup-android-arm64": "4.17.2", + "@rollup/rollup-darwin-arm64": "4.17.2", + "@rollup/rollup-darwin-x64": "4.17.2", + "@rollup/rollup-linux-arm-gnueabihf": "4.17.2", + "@rollup/rollup-linux-arm-musleabihf": "4.17.2", + "@rollup/rollup-linux-arm64-gnu": "4.17.2", + "@rollup/rollup-linux-arm64-musl": "4.17.2", + "@rollup/rollup-linux-powerpc64le-gnu": "4.17.2", + "@rollup/rollup-linux-riscv64-gnu": "4.17.2", + "@rollup/rollup-linux-s390x-gnu": "4.17.2", + "@rollup/rollup-linux-x64-gnu": "4.17.2", + "@rollup/rollup-linux-x64-musl": "4.17.2", + "@rollup/rollup-win32-arm64-msvc": "4.17.2", + "@rollup/rollup-win32-ia32-msvc": "4.17.2", + "@rollup/rollup-win32-x64-msvc": "4.17.2", + "@types/estree": "1.0.5", + "fsevents": "~2.3.2" + } + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true + }, + "setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "dev": true + }, + "source-map-js": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz", + "integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==", + "dev": true + }, + "statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==", + "dev": true + }, + "stream-read-all": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/stream-read-all/-/stream-read-all-3.0.1.tgz", + "integrity": "sha512-EWZT9XOceBPlVJRrYcykW8jyRSZYbkb/0ZK36uLEmoWVO5gxBOnntNTseNzfREsqxqdfEGQrD8SXQ3QWbBmq8A==", + "dev": true + }, + "stylehacks": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/stylehacks/-/stylehacks-6.1.1.tgz", + "integrity": "sha512-gSTTEQ670cJNoaeIp9KX6lZmm8LJ3jPB5yJmX8Zq/wQxOsAFXV3qjWzHas3YYk1qesuVIyYWWUpZ0vSE/dTSGg==", + "dev": true, + "requires": { + "browserslist": "^4.23.0", + "postcss-selector-parser": "^6.0.16" + } + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true + }, + "svgo": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/svgo/-/svgo-3.3.2.tgz", + "integrity": "sha512-OoohrmuUlBs8B8o6MB2Aevn+pRIH9zDALSR+6hhqVfa6fRwG/Qw9VUMSMW9VNg2CFc/MTIfabtdOVl9ODIJjpw==", + "dev": true, + "requires": { + "@trysound/sax": "0.2.0", + "commander": "^7.2.0", + "css-select": "^5.1.0", + "css-tree": "^2.3.1", + "css-what": "^6.1.0", + "csso": "^5.0.5", + "picocolors": "^1.0.0" + } + }, + "table-layout": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/table-layout/-/table-layout-3.0.2.tgz", + "integrity": "sha512-rpyNZYRw+/C+dYkcQ3Pr+rLxW4CfHpXjPDnG7lYhdRoUcZTUt+KEsX+94RGp/aVp/MQU35JCITv2T/beY4m+hw==", + "dev": true, + "requires": { + "@75lb/deep-merge": "^1.1.1", + "array-back": "^6.2.2", + "command-line-args": "^5.2.1", + "command-line-usage": "^7.0.0", + "stream-read-all": "^3.0.1", + "typical": "^7.1.1", + "wordwrapjs": "^5.1.0" + }, + "dependencies": { + "array-back": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-6.2.2.tgz", + "integrity": "sha512-gUAZ7HPyb4SJczXAMUXMGAvI976JoK3qEx9v1FTmeYuJj0IBiaKttG1ydtGKdkfqWkIkouke7nG8ufGy77+Cvw==", + "dev": true + }, + "typical": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/typical/-/typical-7.1.1.tgz", + "integrity": "sha512-T+tKVNs6Wu7IWiAce5BgMd7OZfNYUndHwc5MknN+UHOudi7sGZzuHdCadllRuqJ3fPtgFtIH9+lt9qRv6lmpfA==", + "dev": true + } + } + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.0" + } + }, + "toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "dev": true + }, + "tr46": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-3.0.0.tgz", + "integrity": "sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==", + "dev": true, + "requires": { + "punycode": "^2.1.1" + } + }, + "tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" + }, + "tsscmp": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/tsscmp/-/tsscmp-1.0.6.tgz", + "integrity": "sha512-LxhtAkPDTkVCMQjt2h6eBVY28KCjikZqZfMcC15YBeNjkgUpdCfBu5HoiOTDu86v6smE8yOjyEktJ8hlbANHQA==", + "dev": true + }, + "type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "dev": true, + "requires": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + } + }, + "typical": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/typical/-/typical-4.0.0.tgz", + "integrity": "sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw==", + "dev": true + }, + "undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + }, + "update-browserslist-db": { + "version": "1.0.15", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.15.tgz", + "integrity": "sha512-K9HWH62x3/EalU1U6sjSZiylm9C8tgq2mSvshZpqc7QE69RaA2qjhkW2HlNA0tFpEbtyFz7HTqbSdN4MSwUodA==", + "dev": true, + "requires": { + "escalade": "^3.1.2", + "picocolors": "^1.0.0" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "dev": true + }, + "webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "dev": true + }, + "whatwg-url": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-11.0.0.tgz", + "integrity": "sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ==", + "dev": true, + "requires": { + "tr46": "^3.0.0", + "webidl-conversions": "^7.0.0" + } + }, + "wordwrapjs": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wordwrapjs/-/wordwrapjs-5.1.0.tgz", + "integrity": "sha512-JNjcULU2e4KJwUNv6CHgI46UvDGitb6dGryHajXTDiLgg1/RiGoPSDw4kZfYnwGtEXf2ZMeIewDQgFGzkCB2Sg==", + "dev": true + }, + "ws": { + "version": "7.5.9", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", + "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "dev": true, + "requires": {} + }, + "ylru": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ylru/-/ylru-1.4.0.tgz", + "integrity": "sha512-2OQsPNEmBCvXuFlIni/a+Rn+R2pHW9INm0BxXJ4hVDA8TirqMj+J/Rp9ItLatT/5pZqWwefVrTQcHpixsxnVlA==", + "dev": true + } + } +} diff --git a/python/src/llm_comparator/data/dev_sources.concat.js b/python/src/llm_comparator/data/dev_sources.concat.js new file mode 100644 index 0000000..65e0d2e --- /dev/null +++ b/python/src/llm_comparator/data/dev_sources.concat.js @@ -0,0 +1,21965 @@ +(() => { + var __create = Object.create; + var __defProp = Object.defineProperty; + var __getOwnPropDesc = Object.getOwnPropertyDescriptor; + var __getOwnPropNames = Object.getOwnPropertyNames; + var __getProtoOf = Object.getPrototypeOf; + var __hasOwnProp = Object.prototype.hasOwnProperty; + var __commonJS = (cb, mod) => function __require() { + return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; + }; + var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; + }; + var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, + mod + )); + var __decorateClass = (decorators, target, key, kind) => { + var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target; + for (var i23 = decorators.length - 1, decorator; i23 >= 0; i23--) + if (decorator = decorators[i23]) + result = (kind ? decorator(target, key, result) : decorator(result)) || result; + if (kind && result) + __defProp(target, key, result); + return result; + }; + + // node_modules/jsdifflib/index.js + var require_jsdifflib = __commonJS({ + "node_modules/jsdifflib/index.js"(exports, module) { + __whitespace = { " ": true, " ": true, "\n": true, "\f": true, "\r": true }; + var difflib2 = module.exports = { + defaultJunkFunction: function(c12) { + return __whitespace.hasOwnProperty(c12); + }, + stripLinebreaks: function(str) { + return str.replace(/^[\n\r]*|[\n\r]*$/g, ""); + }, + stringAsLines: function(str) { + var lfpos = str.indexOf("\n"); + var crpos = str.indexOf("\r"); + var linebreak = lfpos > -1 && crpos > -1 || crpos < 0 ? "\n" : "\r"; + var lines = str.split(linebreak); + for (var i23 = 0; i23 < lines.length; i23++) { + lines[i23] = difflib2.stripLinebreaks(lines[i23]); + } + return lines; + }, + // iteration-based reduce implementation + __reduce: function(func, list, initial) { + if (initial != null) { + var value = initial; + var idx = 0; + } else if (list) { + var value = list[0]; + var idx = 1; + } else { + return null; + } + for (; idx < list.length; idx++) { + value = func(value, list[idx]); + } + return value; + }, + // comparison function for sorting lists of numeric tuples + __ntuplecomp: function(a11, b7) { + var mlen = Math.max(a11.length, b7.length); + for (var i23 = 0; i23 < mlen; i23++) { + if (a11[i23] < b7[i23]) + return -1; + if (a11[i23] > b7[i23]) + return 1; + } + return a11.length == b7.length ? 0 : a11.length < b7.length ? -1 : 1; + }, + __calculate_ratio: function(matches3, length) { + return length ? 2 * matches3 / length : 1; + }, + // returns a function that returns true if a key passed to the returned function + // is in the dict (js object) provided to this function; replaces being able to + // carry around dict.has_key in python... + __isindict: function(dict) { + return function(key) { + return dict.hasOwnProperty(key); + }; + }, + // replacement for python's dict.get function -- need easy default values + __dictget: function(dict, key, defaultValue) { + return dict.hasOwnProperty(key) ? dict[key] : defaultValue; + }, + SequenceMatcher: function(a11, b7, isjunk) { + this.set_seqs = function(a12, b8) { + this.set_seq1(a12); + this.set_seq2(b8); + }; + this.set_seq1 = function(a12) { + if (a12 == this.a) + return; + this.a = a12; + this.matching_blocks = this.opcodes = null; + }; + this.set_seq2 = function(b8) { + if (b8 == this.b) + return; + this.b = b8; + this.matching_blocks = this.opcodes = this.fullbcount = null; + this.__chain_b(); + }; + this.__chain_b = function() { + var b8 = this.b; + var n31 = b8.length; + var b2j = this.b2j = {}; + var populardict = {}; + for (var i23 = 0; i23 < b8.length; i23++) { + var elt = b8[i23]; + if (b2j.hasOwnProperty(elt)) { + var indices = b2j[elt]; + if (n31 >= 200 && indices.length * 100 > n31) { + populardict[elt] = 1; + delete b2j[elt]; + } else { + indices.push(i23); + } + } else { + b2j[elt] = [i23]; + } + } + for (var elt in populardict) { + if (populardict.hasOwnProperty(elt)) { + delete b2j[elt]; + } + } + var isjunk2 = this.isjunk; + var junkdict = {}; + if (isjunk2) { + for (var elt in populardict) { + if (populardict.hasOwnProperty(elt) && isjunk2(elt)) { + junkdict[elt] = 1; + delete populardict[elt]; + } + } + for (var elt in b2j) { + if (b2j.hasOwnProperty(elt) && isjunk2(elt)) { + junkdict[elt] = 1; + delete b2j[elt]; + } + } + } + this.isbjunk = difflib2.__isindict(junkdict); + this.isbpopular = difflib2.__isindict(populardict); + }; + this.find_longest_match = function(alo, ahi, blo, bhi) { + var a12 = this.a; + var b8 = this.b; + var b2j = this.b2j; + var isbjunk = this.isbjunk; + var besti = alo; + var bestj = blo; + var bestsize = 0; + var j3 = null; + var j2len = {}; + var nothing = []; + for (var i23 = alo; i23 < ahi; i23++) { + var newj2len = {}; + var jdict = difflib2.__dictget(b2j, a12[i23], nothing); + for (var jkey in jdict) { + if (jdict.hasOwnProperty(jkey)) { + j3 = jdict[jkey]; + if (j3 < blo) + continue; + if (j3 >= bhi) + break; + newj2len[j3] = k = difflib2.__dictget(j2len, j3 - 1, 0) + 1; + if (k > bestsize) { + besti = i23 - k + 1; + bestj = j3 - k + 1; + bestsize = k; + } + } + } + j2len = newj2len; + } + while (besti > alo && bestj > blo && !isbjunk(b8[bestj - 1]) && a12[besti - 1] == b8[bestj - 1]) { + besti--; + bestj--; + bestsize++; + } + while (besti + bestsize < ahi && bestj + bestsize < bhi && !isbjunk(b8[bestj + bestsize]) && a12[besti + bestsize] == b8[bestj + bestsize]) { + bestsize++; + } + while (besti > alo && bestj > blo && isbjunk(b8[bestj - 1]) && a12[besti - 1] == b8[bestj - 1]) { + besti--; + bestj--; + bestsize++; + } + while (besti + bestsize < ahi && bestj + bestsize < bhi && isbjunk(b8[bestj + bestsize]) && a12[besti + bestsize] == b8[bestj + bestsize]) { + bestsize++; + } + return [besti, bestj, bestsize]; + }; + this.get_matching_blocks = function() { + if (this.matching_blocks != null) + return this.matching_blocks; + var la = this.a.length; + var lb = this.b.length; + var queue = [[0, la, 0, lb]]; + var matching_blocks = []; + var alo, ahi, blo, bhi, qi, i23, j3, k8, x6; + while (queue.length) { + qi = queue.pop(); + alo = qi[0]; + ahi = qi[1]; + blo = qi[2]; + bhi = qi[3]; + x6 = this.find_longest_match(alo, ahi, blo, bhi); + i23 = x6[0]; + j3 = x6[1]; + k8 = x6[2]; + if (k8) { + matching_blocks.push(x6); + if (alo < i23 && blo < j3) + queue.push([alo, i23, blo, j3]); + if (i23 + k8 < ahi && j3 + k8 < bhi) + queue.push([i23 + k8, ahi, j3 + k8, bhi]); + } + } + matching_blocks.sort(difflib2.__ntuplecomp); + var i1 = j1 = k1 = block = 0; + var non_adjacent = []; + for (var idx in matching_blocks) { + if (matching_blocks.hasOwnProperty(idx)) { + block = matching_blocks[idx]; + i2 = block[0]; + j2 = block[1]; + k2 = block[2]; + if (i1 + k1 == i2 && j1 + k1 == j2) { + k1 += k2; + } else { + if (k1) + non_adjacent.push([i1, j1, k1]); + i1 = i2; + j1 = j2; + k1 = k2; + } + } + } + if (k1) + non_adjacent.push([i1, j1, k1]); + non_adjacent.push([la, lb, 0]); + this.matching_blocks = non_adjacent; + return this.matching_blocks; + }; + this.get_opcodes = function() { + if (this.opcodes != null) + return this.opcodes; + var i23 = 0; + var j3 = 0; + var answer = []; + this.opcodes = answer; + var block2, ai, bj, size, tag; + var blocks = this.get_matching_blocks(); + for (var idx in blocks) { + if (blocks.hasOwnProperty(idx)) { + block2 = blocks[idx]; + ai = block2[0]; + bj = block2[1]; + size = block2[2]; + tag = ""; + if (i23 < ai && j3 < bj) { + tag = "replace"; + } else if (i23 < ai) { + tag = "delete"; + } else if (j3 < bj) { + tag = "insert"; + } + if (tag) + answer.push([tag, i23, ai, j3, bj]); + i23 = ai + size; + j3 = bj + size; + if (size) + answer.push(["equal", ai, i23, bj, j3]); + } + } + return answer; + }; + this.get_grouped_opcodes = function(n31) { + if (!n31) + n31 = 3; + var codes = this.get_opcodes(); + if (!codes) + codes = [["equal", 0, 1, 0, 1]]; + var code2, tag, i1, i23, j12, j22; + if (codes[0][0] == "equal") { + code2 = codes[0]; + tag = code2[0]; + i1 = code2[1]; + i23 = code2[2]; + j12 = code2[3]; + j22 = code2[4]; + codes[0] = [tag, Math.max(i1, i23 - n31), i23, Math.max(j12, j22 - n31), j22]; + } + if (codes[codes.length - 1][0] == "equal") { + code2 = codes[codes.length - 1]; + tag = code2[0]; + i1 = code2[1]; + i23 = code2[2]; + j12 = code2[3]; + j22 = code2[4]; + codes[codes.length - 1] = [tag, i1, Math.min(i23, i1 + n31), j12, Math.min(j22, j12 + n31)]; + } + var nn = n31 + n31; + var groups = []; + for (var idx in codes) { + if (codes.hasOwnProperty(idx)) { + code2 = codes[idx]; + tag = code2[0]; + i1 = code2[1]; + i23 = code2[2]; + j12 = code2[3]; + j22 = code2[4]; + if (tag == "equal" && i23 - i1 > nn) { + groups.push([tag, i1, Math.min(i23, i1 + n31), j12, Math.min(j22, j12 + n31)]); + i1 = Math.max(i1, i23 - n31); + j12 = Math.max(j12, j22 - n31); + } + groups.push([tag, i1, i23, j12, j22]); + } + } + if (groups && groups[groups.length - 1][0] == "equal") + groups.pop(); + return groups; + }; + this.ratio = function() { + matches = difflib2.__reduce( + function(sum, triple) { + return sum + triple[triple.length - 1]; + }, + this.get_matching_blocks(), + 0 + ); + return difflib2.__calculate_ratio(matches, this.a.length + this.b.length); + }; + this.quick_ratio = function() { + var fullbcount, elt; + if (this.fullbcount == null) { + this.fullbcount = fullbcount = {}; + for (var i23 = 0; i23 < this.b.length; i23++) { + elt = this.b[i23]; + fullbcount[elt] = difflib2.__dictget(fullbcount, elt, 0) + 1; + } + } + fullbcount = this.fullbcount; + var avail = {}; + var availhas = difflib2.__isindict(avail); + var matches3 = numb = 0; + for (var i23 = 0; i23 < this.a.length; i23++) { + elt = this.a[i23]; + if (availhas(elt)) { + numb = avail[elt]; + } else { + numb = difflib2.__dictget(fullbcount, elt, 0); + } + avail[elt] = numb - 1; + if (numb > 0) + matches3++; + } + return difflib2.__calculate_ratio(matches3, this.a.length + this.b.length); + }; + this.real_quick_ratio = function() { + var la = this.a.length; + var lb = this.b.length; + return _calculate_ratio(Math.min(la, lb), la + lb); + }; + this.isjunk = isjunk ? isjunk : difflib2.defaultJunkFunction; + this.a = this.b = null; + this.set_seqs(a11, b7); + }, + /** + * Builds and returns a visual diff view. The single parameter, `params', should contain + * the following values: + * + * - baseText: the string that will be used as the base input to SequenceMatcher + * - nextText: the string that will be used as the new text input to SequenceMatcher + * + * or + * + * - baseTextLines: the array of strings that was used as the base text input to SequenceMatcher + * - newTextLines: the array of strings that was used as the new text input to SequenceMatcher + * - opcodes: the array of arrays returned by SequenceMatcher.get_opcodes() + * + * and: + * + * - baseTextName: the title to be displayed above the base text listing in the diff view; defaults + * to "Base Text" + * - newTextName: the title to be displayed above the new text listing in the diff view; defaults + * to "New Text" + * - contextSize: the number of lines of context to show around differences; by default, all lines + * are shown + * - inline: if false, a side-by-side diff view is generated (default); if true, an inline diff view is + * generated + */ + buildView: function(params) { + var baseTextLines = params.baseTextLines === void 0 ? difflib2.stringAsLines(params.baseText) : params.baseTextLines; + var newTextLines = params.newTextLines === void 0 ? difflib2.stringAsLines(params.newText) : params.newTextLines; + var opcodes = params.opcodes === void 0 ? new difflib2.SequenceMatcher(baseTextLines, newTextLines).get_opcodes() : params.opcodes; + var baseTextName = params.baseTextName ? params.baseTextName : "Base Text"; + var newTextName = params.newTextName ? params.newTextName : "New Text"; + var contextSize = params.contextSize; + var inline = params.inline || false; + if (baseTextLines == null) + throw "Cannot build diff view; baseTextLines is not defined."; + if (newTextLines == null) + throw "Cannot build diff view; newTextLines is not defined."; + if (!opcodes) + throw "Canno build diff view; opcodes is not defined."; + function celt(name, clazz) { + var e33 = document.createElement(name); + e33.className = clazz; + return e33; + } + function telt(name, text) { + var e33 = document.createElement(name); + e33.appendChild(document.createTextNode(text)); + return e33; + } + function ctelt(name, clazz, text) { + var e33 = document.createElement(name); + e33.className = clazz; + e33.appendChild(document.createTextNode(text)); + return e33; + } + var tdata = document.createElement("thead"); + var node = document.createElement("tr"); + tdata.appendChild(node); + if (inline) { + node.appendChild(document.createElement("th")); + node.appendChild(document.createElement("th")); + node.appendChild(ctelt("th", "texttitle", baseTextName + " vs. " + newTextName)); + } else { + node.appendChild(document.createElement("th")); + node.appendChild(ctelt("th", "texttitle", baseTextName)); + node.appendChild(document.createElement("th")); + node.appendChild(ctelt("th", "texttitle", newTextName)); + } + tdata = [tdata]; + var rows = []; + var node2; + function addCells(row, tidx, tend, textLines, change2) { + if (tidx < tend) { + row.appendChild(telt("th", (tidx + 1).toString())); + row.appendChild(ctelt("td", change2, textLines[tidx].replace(/\t/g, "\xA0\xA0\xA0\xA0"))); + return tidx + 1; + } else { + row.appendChild(document.createElement("th")); + row.appendChild(celt("td", "empty")); + return tidx; + } + } + function addCellsInline(row, tidx, tidx2, textLines, change2) { + row.className = change2; + row.appendChild(telt("th", tidx == null ? "" : (tidx + 1).toString())); + row.appendChild(telt("th", tidx2 == null ? "" : (tidx2 + 1).toString())); + row.appendChild(telt("td", textLines[tidx != null ? tidx : tidx2].replace(/\t/g, "\xA0\xA0\xA0\xA0"))); + } + for (var idx = 0; idx < opcodes.length; idx++) { + code = opcodes[idx]; + change = code[0]; + var b7 = code[1]; + var be = code[2]; + var n31 = code[3]; + var ne = code[4]; + var rowcnt = Math.max(be - b7, ne - n31); + var toprows = []; + var botrows = []; + for (var i23 = 0; i23 < rowcnt; i23++) { + if (contextSize && opcodes.length > 1 && (idx > 0 && i23 == contextSize || idx == 0 && i23 == 0) && change == "equal") { + var jump = rowcnt - (idx == 0 ? 1 : 2) * contextSize; + if (jump > 1) { + toprows.push(node = document.createElement("tr")); + b7 += jump; + n31 += jump; + i23 += jump - 1; + node.appendChild(telt("th", "...")); + if (!inline) + node.appendChild(ctelt("td", "skip", "")); + node.appendChild(telt("th", "...")); + node.appendChild(ctelt("td", "skip", "")); + if (idx + 1 == opcodes.length) { + break; + } else { + continue; + } + } + } + toprows.push(node = document.createElement("tr")); + if (inline) { + if (change == "insert") { + addCellsInline(node, null, n31++, newTextLines, change); + } else if (change == "replace") { + botrows.push(node2 = document.createElement("tr")); + if (b7 < be) + addCellsInline(node, b7++, null, baseTextLines, "delete"); + if (n31 < ne) + addCellsInline(node2, null, n31++, newTextLines, "insert"); + } else if (change == "delete") { + addCellsInline(node, b7++, null, baseTextLines, change); + } else { + addCellsInline(node, b7++, n31++, baseTextLines, change); + } + } else { + b7 = addCells(node, b7, be, baseTextLines, change); + n31 = addCells(node, n31, ne, newTextLines, change); + } + } + for (var i23 = 0; i23 < toprows.length; i23++) + rows.push(toprows[i23]); + for (var i23 = 0; i23 < botrows.length; i23++) + rows.push(botrows[i23]); + } + rows.push(node = ctelt("th", "author", "diff view generated by ")); + node.setAttribute("colspan", inline ? 3 : 4); + node.appendChild(node2 = telt("a", "jsdifflib")); + node2.setAttribute("href", "http://github.com/cemerick/jsdifflib"); + tdata.push(node = document.createElement("tbody")); + for (var idx in rows) + node.appendChild(rows[idx]); + node = celt("table", "diff" + (inline ? " inlinediff" : "")); + for (var idx in tdata) + node.appendChild(tdata[idx]); + return node; + } + }; + } + }); + + // node_modules/jstat/dist/jstat.js + var require_jstat = __commonJS({ + "node_modules/jstat/dist/jstat.js"(exports, module) { + (function(window2, factory) { + if (typeof exports === "object") { + module.exports = factory(); + } else if (typeof define === "function" && define.amd) { + define(factory); + } else { + window2.jStat = factory(); + } + })(exports, function() { + var jStat2 = function(Math2, undefined2) { + var concat = Array.prototype.concat; + var slice = Array.prototype.slice; + var toString2 = Object.prototype.toString; + function calcRdx(n31, m6) { + var val = n31 > m6 ? n31 : m6; + return Math2.pow( + 10, + 17 - ~~(Math2.log(val > 0 ? val : -val) * Math2.LOG10E) + ); + } + var isArray = Array.isArray || function isArray2(arg) { + return toString2.call(arg) === "[object Array]"; + }; + function isFunction2(arg) { + return toString2.call(arg) === "[object Function]"; + } + function isNumber(num) { + return typeof num === "number" ? num - num === 0 : false; + } + function toVector(arr) { + return concat.apply([], arr); + } + function jStat3() { + return new jStat3._init(arguments); + } + jStat3.fn = jStat3.prototype; + jStat3._init = function _init(args) { + if (isArray(args[0])) { + if (isArray(args[0][0])) { + if (isFunction2(args[1])) + args[0] = jStat3.map(args[0], args[1]); + for (var i23 = 0; i23 < args[0].length; i23++) + this[i23] = args[0][i23]; + this.length = args[0].length; + } else { + this[0] = isFunction2(args[1]) ? jStat3.map(args[0], args[1]) : args[0]; + this.length = 1; + } + } else if (isNumber(args[0])) { + this[0] = jStat3.seq.apply(null, args); + this.length = 1; + } else if (args[0] instanceof jStat3) { + return jStat3(args[0].toArray()); + } else { + this[0] = []; + this.length = 1; + } + return this; + }; + jStat3._init.prototype = jStat3.prototype; + jStat3._init.constructor = jStat3; + jStat3.utils = { + calcRdx, + isArray, + isFunction: isFunction2, + isNumber, + toVector + }; + jStat3._random_fn = Math2.random; + jStat3.setRandom = function setRandom(fn2) { + if (typeof fn2 !== "function") + throw new TypeError("fn is not a function"); + jStat3._random_fn = fn2; + }; + jStat3.extend = function extend(obj) { + var i23, j3; + if (arguments.length === 1) { + for (j3 in obj) + jStat3[j3] = obj[j3]; + return this; + } + for (i23 = 1; i23 < arguments.length; i23++) { + for (j3 in arguments[i23]) + obj[j3] = arguments[i23][j3]; + } + return obj; + }; + jStat3.rows = function rows(arr) { + return arr.length || 1; + }; + jStat3.cols = function cols(arr) { + return arr[0].length || 1; + }; + jStat3.dimensions = function dimensions(arr) { + return { + rows: jStat3.rows(arr), + cols: jStat3.cols(arr) + }; + }; + jStat3.row = function row(arr, index) { + if (isArray(index)) { + return index.map(function(i23) { + return jStat3.row(arr, i23); + }); + } + return arr[index]; + }; + jStat3.rowa = function rowa(arr, i23) { + return jStat3.row(arr, i23); + }; + jStat3.col = function col(arr, index) { + if (isArray(index)) { + var submat = jStat3.arange(arr.length).map(function() { + return new Array(index.length); + }); + index.forEach(function(ind, i24) { + jStat3.arange(arr.length).forEach(function(j3) { + submat[j3][i24] = arr[j3][ind]; + }); + }); + return submat; + } + var column = new Array(arr.length); + for (var i23 = 0; i23 < arr.length; i23++) + column[i23] = [arr[i23][index]]; + return column; + }; + jStat3.cola = function cola(arr, i23) { + return jStat3.col(arr, i23).map(function(a11) { + return a11[0]; + }); + }; + jStat3.diag = function diag(arr) { + var nrow = jStat3.rows(arr); + var res = new Array(nrow); + for (var row = 0; row < nrow; row++) + res[row] = [arr[row][row]]; + return res; + }; + jStat3.antidiag = function antidiag(arr) { + var nrow = jStat3.rows(arr) - 1; + var res = new Array(nrow); + for (var i23 = 0; nrow >= 0; nrow--, i23++) + res[i23] = [arr[i23][nrow]]; + return res; + }; + jStat3.transpose = function transpose(arr) { + var obj = []; + var objArr, rows, cols, j3, i23; + if (!isArray(arr[0])) + arr = [arr]; + rows = arr.length; + cols = arr[0].length; + for (i23 = 0; i23 < cols; i23++) { + objArr = new Array(rows); + for (j3 = 0; j3 < rows; j3++) + objArr[j3] = arr[j3][i23]; + obj.push(objArr); + } + return obj.length === 1 ? obj[0] : obj; + }; + jStat3.map = function map2(arr, func, toAlter) { + var row, nrow, ncol, res, col; + if (!isArray(arr[0])) + arr = [arr]; + nrow = arr.length; + ncol = arr[0].length; + res = toAlter ? arr : new Array(nrow); + for (row = 0; row < nrow; row++) { + if (!res[row]) + res[row] = new Array(ncol); + for (col = 0; col < ncol; col++) + res[row][col] = func(arr[row][col], row, col); + } + return res.length === 1 ? res[0] : res; + }; + jStat3.cumreduce = function cumreduce(arr, func, toAlter) { + var row, nrow, ncol, res, col; + if (!isArray(arr[0])) + arr = [arr]; + nrow = arr.length; + ncol = arr[0].length; + res = toAlter ? arr : new Array(nrow); + for (row = 0; row < nrow; row++) { + if (!res[row]) + res[row] = new Array(ncol); + if (ncol > 0) + res[row][0] = arr[row][0]; + for (col = 1; col < ncol; col++) + res[row][col] = func(res[row][col - 1], arr[row][col]); + } + return res.length === 1 ? res[0] : res; + }; + jStat3.alter = function alter(arr, func) { + return jStat3.map(arr, func, true); + }; + jStat3.create = function create(rows, cols, func) { + var res = new Array(rows); + var i23, j3; + if (isFunction2(cols)) { + func = cols; + cols = rows; + } + for (i23 = 0; i23 < rows; i23++) { + res[i23] = new Array(cols); + for (j3 = 0; j3 < cols; j3++) + res[i23][j3] = func(i23, j3); + } + return res; + }; + function retZero() { + return 0; + } + jStat3.zeros = function zeros(rows, cols) { + if (!isNumber(cols)) + cols = rows; + return jStat3.create(rows, cols, retZero); + }; + function retOne() { + return 1; + } + jStat3.ones = function ones(rows, cols) { + if (!isNumber(cols)) + cols = rows; + return jStat3.create(rows, cols, retOne); + }; + jStat3.rand = function rand(rows, cols) { + if (!isNumber(cols)) + cols = rows; + return jStat3.create(rows, cols, jStat3._random_fn); + }; + function retIdent(i23, j3) { + return i23 === j3 ? 1 : 0; + } + jStat3.identity = function identity(rows, cols) { + if (!isNumber(cols)) + cols = rows; + return jStat3.create(rows, cols, retIdent); + }; + jStat3.symmetric = function symmetric(arr) { + var size = arr.length; + var row, col; + if (arr.length !== arr[0].length) + return false; + for (row = 0; row < size; row++) { + for (col = 0; col < size; col++) + if (arr[col][row] !== arr[row][col]) + return false; + } + return true; + }; + jStat3.clear = function clear2(arr) { + return jStat3.alter(arr, retZero); + }; + jStat3.seq = function seq(min, max, length, func) { + if (!isFunction2(func)) + func = false; + var arr = []; + var hival = calcRdx(min, max); + var step = (max * hival - min * hival) / ((length - 1) * hival); + var current = min; + var cnt; + for (cnt = 0; current <= max && cnt < length; cnt++, current = (min * hival + step * hival * cnt) / hival) { + arr.push(func ? func(current, cnt) : current); + } + return arr; + }; + jStat3.arange = function arange(start, end, step) { + var rl = []; + var i23; + step = step || 1; + if (end === undefined2) { + end = start; + start = 0; + } + if (start === end || step === 0) { + return []; + } + if (start < end && step < 0) { + return []; + } + if (start > end && step > 0) { + return []; + } + if (step > 0) { + for (i23 = start; i23 < end; i23 += step) { + rl.push(i23); + } + } else { + for (i23 = start; i23 > end; i23 += step) { + rl.push(i23); + } + } + return rl; + }; + jStat3.slice = /* @__PURE__ */ function() { + function _slice(list, start, end, step) { + var i23; + var rl = []; + var length = list.length; + if (start === undefined2 && end === undefined2 && step === undefined2) { + return jStat3.copy(list); + } + start = start || 0; + end = end || list.length; + start = start >= 0 ? start : length + start; + end = end >= 0 ? end : length + end; + step = step || 1; + if (start === end || step === 0) { + return []; + } + if (start < end && step < 0) { + return []; + } + if (start > end && step > 0) { + return []; + } + if (step > 0) { + for (i23 = start; i23 < end; i23 += step) { + rl.push(list[i23]); + } + } else { + for (i23 = start; i23 > end; i23 += step) { + rl.push(list[i23]); + } + } + return rl; + } + function slice2(list, rcSlice) { + var colSlice, rowSlice; + rcSlice = rcSlice || {}; + if (isNumber(rcSlice.row)) { + if (isNumber(rcSlice.col)) + return list[rcSlice.row][rcSlice.col]; + var row = jStat3.rowa(list, rcSlice.row); + colSlice = rcSlice.col || {}; + return _slice(row, colSlice.start, colSlice.end, colSlice.step); + } + if (isNumber(rcSlice.col)) { + var col = jStat3.cola(list, rcSlice.col); + rowSlice = rcSlice.row || {}; + return _slice(col, rowSlice.start, rowSlice.end, rowSlice.step); + } + rowSlice = rcSlice.row || {}; + colSlice = rcSlice.col || {}; + var rows = _slice(list, rowSlice.start, rowSlice.end, rowSlice.step); + return rows.map(function(row2) { + return _slice(row2, colSlice.start, colSlice.end, colSlice.step); + }); + } + return slice2; + }(); + jStat3.sliceAssign = function sliceAssign(A6, rcSlice, B5) { + var nl, ml; + if (isNumber(rcSlice.row)) { + if (isNumber(rcSlice.col)) + return A6[rcSlice.row][rcSlice.col] = B5; + rcSlice.col = rcSlice.col || {}; + rcSlice.col.start = rcSlice.col.start || 0; + rcSlice.col.end = rcSlice.col.end || A6[0].length; + rcSlice.col.step = rcSlice.col.step || 1; + nl = jStat3.arange( + rcSlice.col.start, + Math2.min(A6.length, rcSlice.col.end), + rcSlice.col.step + ); + var m6 = rcSlice.row; + nl.forEach(function(n32, i23) { + A6[m6][n32] = B5[i23]; + }); + return A6; + } + if (isNumber(rcSlice.col)) { + rcSlice.row = rcSlice.row || {}; + rcSlice.row.start = rcSlice.row.start || 0; + rcSlice.row.end = rcSlice.row.end || A6.length; + rcSlice.row.step = rcSlice.row.step || 1; + ml = jStat3.arange( + rcSlice.row.start, + Math2.min(A6[0].length, rcSlice.row.end), + rcSlice.row.step + ); + var n31 = rcSlice.col; + ml.forEach(function(m7, j3) { + A6[m7][n31] = B5[j3]; + }); + return A6; + } + if (B5[0].length === undefined2) { + B5 = [B5]; + } + rcSlice.row.start = rcSlice.row.start || 0; + rcSlice.row.end = rcSlice.row.end || A6.length; + rcSlice.row.step = rcSlice.row.step || 1; + rcSlice.col.start = rcSlice.col.start || 0; + rcSlice.col.end = rcSlice.col.end || A6[0].length; + rcSlice.col.step = rcSlice.col.step || 1; + ml = jStat3.arange( + rcSlice.row.start, + Math2.min(A6.length, rcSlice.row.end), + rcSlice.row.step + ); + nl = jStat3.arange( + rcSlice.col.start, + Math2.min(A6[0].length, rcSlice.col.end), + rcSlice.col.step + ); + ml.forEach(function(m7, i23) { + nl.forEach(function(n32, j3) { + A6[m7][n32] = B5[i23][j3]; + }); + }); + return A6; + }; + jStat3.diagonal = function diagonal(diagArray) { + var mat = jStat3.zeros(diagArray.length, diagArray.length); + diagArray.forEach(function(t17, i23) { + mat[i23][i23] = t17; + }); + return mat; + }; + jStat3.copy = function copy(A6) { + return A6.map(function(row) { + if (isNumber(row)) + return row; + return row.map(function(t17) { + return t17; + }); + }); + }; + var jProto = jStat3.prototype; + jProto.length = 0; + jProto.push = Array.prototype.push; + jProto.sort = Array.prototype.sort; + jProto.splice = Array.prototype.splice; + jProto.slice = Array.prototype.slice; + jProto.toArray = function toArray() { + return this.length > 1 ? slice.call(this) : slice.call(this)[0]; + }; + jProto.map = function map2(func, toAlter) { + return jStat3(jStat3.map(this, func, toAlter)); + }; + jProto.cumreduce = function cumreduce(func, toAlter) { + return jStat3(jStat3.cumreduce(this, func, toAlter)); + }; + jProto.alter = function alter(func) { + jStat3.alter(this, func); + return this; + }; + (function(funcs) { + for (var i23 = 0; i23 < funcs.length; i23++) + (function(passfunc) { + jProto[passfunc] = function(func) { + var self2 = this, results; + if (func) { + setTimeout(function() { + func.call(self2, jProto[passfunc].call(self2)); + }); + return this; + } + results = jStat3[passfunc](this); + return isArray(results) ? jStat3(results) : results; + }; + })(funcs[i23]); + })("transpose clear symmetric rows cols dimensions diag antidiag".split(" ")); + (function(funcs) { + for (var i23 = 0; i23 < funcs.length; i23++) + (function(passfunc) { + jProto[passfunc] = function(index, func) { + var self2 = this; + if (func) { + setTimeout(function() { + func.call(self2, jProto[passfunc].call(self2, index)); + }); + return this; + } + return jStat3(jStat3[passfunc](this, index)); + }; + })(funcs[i23]); + })("row col".split(" ")); + (function(funcs) { + for (var i23 = 0; i23 < funcs.length; i23++) + (function(passfunc) { + jProto[passfunc] = function() { + return jStat3(jStat3[passfunc].apply(null, arguments)); + }; + })(funcs[i23]); + })("create zeros ones rand identity".split(" ")); + return jStat3; + }(Math); + (function(jStat3, Math2) { + var isFunction2 = jStat3.utils.isFunction; + function ascNum(a11, b7) { + return a11 - b7; + } + function clip(arg, min, max) { + return Math2.max(min, Math2.min(arg, max)); + } + jStat3.sum = function sum(arr) { + var sum2 = 0; + var i23 = arr.length; + while (--i23 >= 0) + sum2 += arr[i23]; + return sum2; + }; + jStat3.sumsqrd = function sumsqrd(arr) { + var sum = 0; + var i23 = arr.length; + while (--i23 >= 0) + sum += arr[i23] * arr[i23]; + return sum; + }; + jStat3.sumsqerr = function sumsqerr(arr) { + var mean = jStat3.mean(arr); + var sum = 0; + var i23 = arr.length; + var tmp; + while (--i23 >= 0) { + tmp = arr[i23] - mean; + sum += tmp * tmp; + } + return sum; + }; + jStat3.sumrow = function sumrow(arr) { + var sum = 0; + var i23 = arr.length; + while (--i23 >= 0) + sum += arr[i23]; + return sum; + }; + jStat3.product = function product(arr) { + var prod = 1; + var i23 = arr.length; + while (--i23 >= 0) + prod *= arr[i23]; + return prod; + }; + jStat3.min = function min(arr) { + var low = arr[0]; + var i23 = 0; + while (++i23 < arr.length) + if (arr[i23] < low) + low = arr[i23]; + return low; + }; + jStat3.max = function max(arr) { + var high = arr[0]; + var i23 = 0; + while (++i23 < arr.length) + if (arr[i23] > high) + high = arr[i23]; + return high; + }; + jStat3.unique = function unique2(arr) { + var hash = {}, _arr = []; + for (var i23 = 0; i23 < arr.length; i23++) { + if (!hash[arr[i23]]) { + hash[arr[i23]] = true; + _arr.push(arr[i23]); + } + } + return _arr; + }; + jStat3.mean = function mean(arr) { + return jStat3.sum(arr) / arr.length; + }; + jStat3.meansqerr = function meansqerr(arr) { + return jStat3.sumsqerr(arr) / arr.length; + }; + jStat3.geomean = function geomean(arr) { + var logs = arr.map(Math2.log); + var meanOfLogs = jStat3.mean(logs); + return Math2.exp(meanOfLogs); + }; + jStat3.median = function median(arr) { + var arrlen = arr.length; + var _arr = arr.slice().sort(ascNum); + return !(arrlen & 1) ? (_arr[arrlen / 2 - 1] + _arr[arrlen / 2]) / 2 : _arr[arrlen / 2 | 0]; + }; + jStat3.cumsum = function cumsum(arr) { + return jStat3.cumreduce(arr, function(a11, b7) { + return a11 + b7; + }); + }; + jStat3.cumprod = function cumprod(arr) { + return jStat3.cumreduce(arr, function(a11, b7) { + return a11 * b7; + }); + }; + jStat3.diff = function diff(arr) { + var diffs = []; + var arrLen = arr.length; + var i23; + for (i23 = 1; i23 < arrLen; i23++) + diffs.push(arr[i23] - arr[i23 - 1]); + return diffs; + }; + jStat3.rank = function(arr) { + var i23; + var distinctNumbers = []; + var numberCounts = {}; + for (i23 = 0; i23 < arr.length; i23++) { + var number = arr[i23]; + if (numberCounts[number]) { + numberCounts[number]++; + } else { + numberCounts[number] = 1; + distinctNumbers.push(number); + } + } + var sortedDistinctNumbers = distinctNumbers.sort(ascNum); + var numberRanks = {}; + var currentRank = 1; + for (i23 = 0; i23 < sortedDistinctNumbers.length; i23++) { + var number = sortedDistinctNumbers[i23]; + var count = numberCounts[number]; + var first = currentRank; + var last = currentRank + count - 1; + var rank = (first + last) / 2; + numberRanks[number] = rank; + currentRank += count; + } + return arr.map(function(number2) { + return numberRanks[number2]; + }); + }; + jStat3.mode = function mode(arr) { + var arrLen = arr.length; + var _arr = arr.slice().sort(ascNum); + var count = 1; + var maxCount = 0; + var numMaxCount = 0; + var mode_arr = []; + var i23; + for (i23 = 0; i23 < arrLen; i23++) { + if (_arr[i23] === _arr[i23 + 1]) { + count++; + } else { + if (count > maxCount) { + mode_arr = [_arr[i23]]; + maxCount = count; + numMaxCount = 0; + } else if (count === maxCount) { + mode_arr.push(_arr[i23]); + numMaxCount++; + } + count = 1; + } + } + return numMaxCount === 0 ? mode_arr[0] : mode_arr; + }; + jStat3.range = function range(arr) { + return jStat3.max(arr) - jStat3.min(arr); + }; + jStat3.variance = function variance(arr, flag) { + return jStat3.sumsqerr(arr) / (arr.length - (flag ? 1 : 0)); + }; + jStat3.pooledvariance = function pooledvariance(arr) { + var sumsqerr = arr.reduce(function(a11, samples) { + return a11 + jStat3.sumsqerr(samples); + }, 0); + var count = arr.reduce(function(a11, samples) { + return a11 + samples.length; + }, 0); + return sumsqerr / (count - arr.length); + }; + jStat3.deviation = function(arr) { + var mean = jStat3.mean(arr); + var arrlen = arr.length; + var dev = new Array(arrlen); + for (var i23 = 0; i23 < arrlen; i23++) { + dev[i23] = arr[i23] - mean; + } + return dev; + }; + jStat3.stdev = function stdev(arr, flag) { + return Math2.sqrt(jStat3.variance(arr, flag)); + }; + jStat3.pooledstdev = function pooledstdev(arr) { + return Math2.sqrt(jStat3.pooledvariance(arr)); + }; + jStat3.meandev = function meandev(arr) { + var mean = jStat3.mean(arr); + var a11 = []; + for (var i23 = arr.length - 1; i23 >= 0; i23--) { + a11.push(Math2.abs(arr[i23] - mean)); + } + return jStat3.mean(a11); + }; + jStat3.meddev = function meddev(arr) { + var median = jStat3.median(arr); + var a11 = []; + for (var i23 = arr.length - 1; i23 >= 0; i23--) { + a11.push(Math2.abs(arr[i23] - median)); + } + return jStat3.median(a11); + }; + jStat3.coeffvar = function coeffvar(arr) { + return jStat3.stdev(arr) / jStat3.mean(arr); + }; + jStat3.quartiles = function quartiles(arr) { + var arrlen = arr.length; + var _arr = arr.slice().sort(ascNum); + return [ + _arr[Math2.round(arrlen / 4) - 1], + _arr[Math2.round(arrlen / 2) - 1], + _arr[Math2.round(arrlen * 3 / 4) - 1] + ]; + }; + jStat3.quantiles = function quantiles(arr, quantilesArray, alphap, betap) { + var sortedArray = arr.slice().sort(ascNum); + var quantileVals = [quantilesArray.length]; + var n31 = arr.length; + var i23, p7, m6, aleph, k8, gamma; + if (typeof alphap === "undefined") + alphap = 3 / 8; + if (typeof betap === "undefined") + betap = 3 / 8; + for (i23 = 0; i23 < quantilesArray.length; i23++) { + p7 = quantilesArray[i23]; + m6 = alphap + p7 * (1 - alphap - betap); + aleph = n31 * p7 + m6; + k8 = Math2.floor(clip(aleph, 1, n31 - 1)); + gamma = clip(aleph - k8, 0, 1); + quantileVals[i23] = (1 - gamma) * sortedArray[k8 - 1] + gamma * sortedArray[k8]; + } + return quantileVals; + }; + jStat3.percentile = function percentile(arr, k8, exclusive) { + var _arr = arr.slice().sort(ascNum); + var realIndex = k8 * (_arr.length + (exclusive ? 1 : -1)) + (exclusive ? 0 : 1); + var index = parseInt(realIndex); + var frac = realIndex - index; + if (index + 1 < _arr.length) { + return _arr[index - 1] + frac * (_arr[index] - _arr[index - 1]); + } else { + return _arr[index - 1]; + } + }; + jStat3.percentileOfScore = function percentileOfScore(arr, score, kind) { + var counter = 0; + var len = arr.length; + var strict = false; + var value, i23; + if (kind === "strict") + strict = true; + for (i23 = 0; i23 < len; i23++) { + value = arr[i23]; + if (strict && value < score || !strict && value <= score) { + counter++; + } + } + return counter / len; + }; + jStat3.histogram = function histogram(arr, binCnt) { + binCnt = binCnt || 4; + var first = jStat3.min(arr); + var binWidth = (jStat3.max(arr) - first) / binCnt; + var len = arr.length; + var bins = []; + var i23; + for (i23 = 0; i23 < binCnt; i23++) + bins[i23] = 0; + for (i23 = 0; i23 < len; i23++) + bins[Math2.min(Math2.floor((arr[i23] - first) / binWidth), binCnt - 1)] += 1; + return bins; + }; + jStat3.covariance = function covariance(arr1, arr2) { + var u11 = jStat3.mean(arr1); + var v6 = jStat3.mean(arr2); + var arr1Len = arr1.length; + var sq_dev = new Array(arr1Len); + var i23; + for (i23 = 0; i23 < arr1Len; i23++) + sq_dev[i23] = (arr1[i23] - u11) * (arr2[i23] - v6); + return jStat3.sum(sq_dev) / (arr1Len - 1); + }; + jStat3.corrcoeff = function corrcoeff(arr1, arr2) { + return jStat3.covariance(arr1, arr2) / jStat3.stdev(arr1, 1) / jStat3.stdev(arr2, 1); + }; + jStat3.spearmancoeff = function(arr1, arr2) { + arr1 = jStat3.rank(arr1); + arr2 = jStat3.rank(arr2); + return jStat3.corrcoeff(arr1, arr2); + }; + jStat3.stanMoment = function stanMoment(arr, n31) { + var mu = jStat3.mean(arr); + var sigma = jStat3.stdev(arr); + var len = arr.length; + var skewSum = 0; + for (var i23 = 0; i23 < len; i23++) + skewSum += Math2.pow((arr[i23] - mu) / sigma, n31); + return skewSum / arr.length; + }; + jStat3.skewness = function skewness(arr) { + return jStat3.stanMoment(arr, 3); + }; + jStat3.kurtosis = function kurtosis(arr) { + return jStat3.stanMoment(arr, 4) - 3; + }; + var jProto = jStat3.prototype; + (function(funcs) { + for (var i23 = 0; i23 < funcs.length; i23++) + (function(passfunc) { + jProto[passfunc] = function(fullbool, func) { + var arr = []; + var i24 = 0; + var tmpthis = this; + if (isFunction2(fullbool)) { + func = fullbool; + fullbool = false; + } + if (func) { + setTimeout(function() { + func.call(tmpthis, jProto[passfunc].call(tmpthis, fullbool)); + }); + return this; + } + if (this.length > 1) { + tmpthis = fullbool === true ? this : this.transpose(); + for (; i24 < tmpthis.length; i24++) + arr[i24] = jStat3[passfunc](tmpthis[i24]); + return arr; + } + return jStat3[passfunc](this[0], fullbool); + }; + })(funcs[i23]); + })("cumsum cumprod".split(" ")); + (function(funcs) { + for (var i23 = 0; i23 < funcs.length; i23++) + (function(passfunc) { + jProto[passfunc] = function(fullbool, func) { + var arr = []; + var i24 = 0; + var tmpthis = this; + if (isFunction2(fullbool)) { + func = fullbool; + fullbool = false; + } + if (func) { + setTimeout(function() { + func.call(tmpthis, jProto[passfunc].call(tmpthis, fullbool)); + }); + return this; + } + if (this.length > 1) { + if (passfunc !== "sumrow") + tmpthis = fullbool === true ? this : this.transpose(); + for (; i24 < tmpthis.length; i24++) + arr[i24] = jStat3[passfunc](tmpthis[i24]); + return fullbool === true ? jStat3[passfunc](jStat3.utils.toVector(arr)) : arr; + } + return jStat3[passfunc](this[0], fullbool); + }; + })(funcs[i23]); + })("sum sumsqrd sumsqerr sumrow product min max unique mean meansqerr geomean median diff rank mode range variance deviation stdev meandev meddev coeffvar quartiles histogram skewness kurtosis".split(" ")); + (function(funcs) { + for (var i23 = 0; i23 < funcs.length; i23++) + (function(passfunc) { + jProto[passfunc] = function() { + var arr = []; + var i24 = 0; + var tmpthis = this; + var args = Array.prototype.slice.call(arguments); + var callbackFunction; + if (isFunction2(args[args.length - 1])) { + callbackFunction = args[args.length - 1]; + var argsToPass = args.slice(0, args.length - 1); + setTimeout(function() { + callbackFunction.call( + tmpthis, + jProto[passfunc].apply(tmpthis, argsToPass) + ); + }); + return this; + } else { + callbackFunction = void 0; + var curriedFunction = function curriedFunction2(vector) { + return jStat3[passfunc].apply(tmpthis, [vector].concat(args)); + }; + } + if (this.length > 1) { + tmpthis = tmpthis.transpose(); + for (; i24 < tmpthis.length; i24++) + arr[i24] = curriedFunction(tmpthis[i24]); + return arr; + } + return curriedFunction(this[0]); + }; + })(funcs[i23]); + })("quantiles percentileOfScore".split(" ")); + })(jStat2, Math); + (function(jStat3, Math2) { + jStat3.gammaln = function gammaln(x6) { + var j3 = 0; + var cof = [ + 76.18009172947146, + -86.50532032941678, + 24.01409824083091, + -1.231739572450155, + 0.001208650973866179, + -5395239384953e-18 + ]; + var ser = 1.000000000190015; + var xx, y7, tmp; + tmp = (y7 = xx = x6) + 5.5; + tmp -= (xx + 0.5) * Math2.log(tmp); + for (; j3 < 6; j3++) + ser += cof[j3] / ++y7; + return Math2.log(2.5066282746310007 * ser / xx) - tmp; + }; + jStat3.loggam = function loggam(x6) { + var x0, x22, xp, gl, gl0; + var k8, n31; + var a11 = [ + 0.08333333333333333, + -0.002777777777777778, + 7936507936507937e-19, + -5952380952380952e-19, + 8417508417508418e-19, + -0.001917526917526918, + 0.00641025641025641, + -0.02955065359477124, + 0.1796443723688307, + -1.3924322169059 + ]; + x0 = x6; + n31 = 0; + if (x6 == 1 || x6 == 2) { + return 0; + } + if (x6 <= 7) { + n31 = Math2.floor(7 - x6); + x0 = x6 + n31; + } + x22 = 1 / (x0 * x0); + xp = 2 * Math2.PI; + gl0 = a11[9]; + for (k8 = 8; k8 >= 0; k8--) { + gl0 *= x22; + gl0 += a11[k8]; + } + gl = gl0 / x0 + 0.5 * Math2.log(xp) + (x0 - 0.5) * Math2.log(x0) - x0; + if (x6 <= 7) { + for (k8 = 1; k8 <= n31; k8++) { + gl -= Math2.log(x0 - 1); + x0 -= 1; + } + } + return gl; + }; + jStat3.gammafn = function gammafn(x6) { + var p7 = [ + -1.716185138865495, + 24.76565080557592, + -379.80425647094563, + 629.3311553128184, + 866.9662027904133, + -31451.272968848367, + -36144.413418691176, + 66456.14382024054 + ]; + var q = [ + -30.8402300119739, + 315.35062697960416, + -1015.1563674902192, + -3107.771671572311, + 22538.11842098015, + 4755.846277527881, + -134659.9598649693, + -115132.2596755535 + ]; + var fact = false; + var n31 = 0; + var xden = 0; + var xnum = 0; + var y7 = x6; + var i23, z5, yi, res; + if (x6 > 171.6243769536076) { + return Infinity; + } + if (y7 <= 0) { + res = y7 % 1 + 36e-17; + if (res) { + fact = (!(y7 & 1) ? 1 : -1) * Math2.PI / Math2.sin(Math2.PI * res); + y7 = 1 - y7; + } else { + return Infinity; + } + } + yi = y7; + if (y7 < 1) { + z5 = y7++; + } else { + z5 = (y7 -= n31 = (y7 | 0) - 1) - 1; + } + for (i23 = 0; i23 < 8; ++i23) { + xnum = (xnum + p7[i23]) * z5; + xden = xden * z5 + q[i23]; + } + res = xnum / xden + 1; + if (yi < y7) { + res /= yi; + } else if (yi > y7) { + for (i23 = 0; i23 < n31; ++i23) { + res *= y7; + y7++; + } + } + if (fact) { + res = fact / res; + } + return res; + }; + jStat3.gammap = function gammap(a11, x6) { + return jStat3.lowRegGamma(a11, x6) * jStat3.gammafn(a11); + }; + jStat3.lowRegGamma = function lowRegGamma(a11, x6) { + var aln = jStat3.gammaln(a11); + var ap = a11; + var sum = 1 / a11; + var del = sum; + var b7 = x6 + 1 - a11; + var c12 = 1 / 1e-30; + var d11 = 1 / b7; + var h11 = d11; + var i23 = 1; + var ITMAX = -~(Math2.log(a11 >= 1 ? a11 : 1 / a11) * 8.5 + a11 * 0.4 + 17); + var an; + if (x6 < 0 || a11 <= 0) { + return NaN; + } else if (x6 < a11 + 1) { + for (; i23 <= ITMAX; i23++) { + sum += del *= x6 / ++ap; + } + return sum * Math2.exp(-x6 + a11 * Math2.log(x6) - aln); + } + for (; i23 <= ITMAX; i23++) { + an = -i23 * (i23 - a11); + b7 += 2; + d11 = an * d11 + b7; + c12 = b7 + an / c12; + d11 = 1 / d11; + h11 *= d11 * c12; + } + return 1 - h11 * Math2.exp(-x6 + a11 * Math2.log(x6) - aln); + }; + jStat3.factorialln = function factorialln(n31) { + return n31 < 0 ? NaN : jStat3.gammaln(n31 + 1); + }; + jStat3.factorial = function factorial(n31) { + return n31 < 0 ? NaN : jStat3.gammafn(n31 + 1); + }; + jStat3.combination = function combination(n31, m6) { + return n31 > 170 || m6 > 170 ? Math2.exp(jStat3.combinationln(n31, m6)) : jStat3.factorial(n31) / jStat3.factorial(m6) / jStat3.factorial(n31 - m6); + }; + jStat3.combinationln = function combinationln(n31, m6) { + return jStat3.factorialln(n31) - jStat3.factorialln(m6) - jStat3.factorialln(n31 - m6); + }; + jStat3.permutation = function permutation(n31, m6) { + return jStat3.factorial(n31) / jStat3.factorial(n31 - m6); + }; + jStat3.betafn = function betafn(x6, y7) { + if (x6 <= 0 || y7 <= 0) + return void 0; + return x6 + y7 > 170 ? Math2.exp(jStat3.betaln(x6, y7)) : jStat3.gammafn(x6) * jStat3.gammafn(y7) / jStat3.gammafn(x6 + y7); + }; + jStat3.betaln = function betaln(x6, y7) { + return jStat3.gammaln(x6) + jStat3.gammaln(y7) - jStat3.gammaln(x6 + y7); + }; + jStat3.betacf = function betacf(x6, a11, b7) { + var fpmin = 1e-30; + var m6 = 1; + var qab = a11 + b7; + var qap = a11 + 1; + var qam = a11 - 1; + var c12 = 1; + var d11 = 1 - qab * x6 / qap; + var m22, aa, del, h11; + if (Math2.abs(d11) < fpmin) + d11 = fpmin; + d11 = 1 / d11; + h11 = d11; + for (; m6 <= 100; m6++) { + m22 = 2 * m6; + aa = m6 * (b7 - m6) * x6 / ((qam + m22) * (a11 + m22)); + d11 = 1 + aa * d11; + if (Math2.abs(d11) < fpmin) + d11 = fpmin; + c12 = 1 + aa / c12; + if (Math2.abs(c12) < fpmin) + c12 = fpmin; + d11 = 1 / d11; + h11 *= d11 * c12; + aa = -(a11 + m6) * (qab + m6) * x6 / ((a11 + m22) * (qap + m22)); + d11 = 1 + aa * d11; + if (Math2.abs(d11) < fpmin) + d11 = fpmin; + c12 = 1 + aa / c12; + if (Math2.abs(c12) < fpmin) + c12 = fpmin; + d11 = 1 / d11; + del = d11 * c12; + h11 *= del; + if (Math2.abs(del - 1) < 3e-7) + break; + } + return h11; + }; + jStat3.gammapinv = function gammapinv(p7, a11) { + var j3 = 0; + var a1 = a11 - 1; + var EPS = 1e-8; + var gln = jStat3.gammaln(a11); + var x6, err, t17, u11, pp, lna1, afac; + if (p7 >= 1) + return Math2.max(100, a11 + 100 * Math2.sqrt(a11)); + if (p7 <= 0) + return 0; + if (a11 > 1) { + lna1 = Math2.log(a1); + afac = Math2.exp(a1 * (lna1 - 1) - gln); + pp = p7 < 0.5 ? p7 : 1 - p7; + t17 = Math2.sqrt(-2 * Math2.log(pp)); + x6 = (2.30753 + t17 * 0.27061) / (1 + t17 * (0.99229 + t17 * 0.04481)) - t17; + if (p7 < 0.5) + x6 = -x6; + x6 = Math2.max( + 1e-3, + a11 * Math2.pow(1 - 1 / (9 * a11) - x6 / (3 * Math2.sqrt(a11)), 3) + ); + } else { + t17 = 1 - a11 * (0.253 + a11 * 0.12); + if (p7 < t17) + x6 = Math2.pow(p7 / t17, 1 / a11); + else + x6 = 1 - Math2.log(1 - (p7 - t17) / (1 - t17)); + } + for (; j3 < 12; j3++) { + if (x6 <= 0) + return 0; + err = jStat3.lowRegGamma(a11, x6) - p7; + if (a11 > 1) + t17 = afac * Math2.exp(-(x6 - a1) + a1 * (Math2.log(x6) - lna1)); + else + t17 = Math2.exp(-x6 + a1 * Math2.log(x6) - gln); + u11 = err / t17; + x6 -= t17 = u11 / (1 - 0.5 * Math2.min(1, u11 * ((a11 - 1) / x6 - 1))); + if (x6 <= 0) + x6 = 0.5 * (x6 + t17); + if (Math2.abs(t17) < EPS * x6) + break; + } + return x6; + }; + jStat3.erf = function erf(x6) { + var cof = [ + -1.3026537197817094, + 0.6419697923564902, + 0.019476473204185836, + -0.00956151478680863, + -946595344482036e-18, + 366839497852761e-18, + 42523324806907e-18, + -20278578112534e-18, + -1624290004647e-18, + 130365583558e-17, + 15626441722e-18, + -85238095915e-18, + 6529054439e-18, + 5059343495e-18, + -991364156e-18, + -227365122e-18, + 96467911e-18, + 2394038e-18, + -6886027e-18, + 894487e-18, + 313092e-18, + -112708e-18, + 381e-18, + 7106e-18, + -1523e-18, + -94e-18, + 121e-18, + -28e-18 + ]; + var j3 = cof.length - 1; + var isneg = false; + var d11 = 0; + var dd = 0; + var t17, ty, tmp, res; + if (x6 < 0) { + x6 = -x6; + isneg = true; + } + t17 = 2 / (2 + x6); + ty = 4 * t17 - 2; + for (; j3 > 0; j3--) { + tmp = d11; + d11 = ty * d11 - dd + cof[j3]; + dd = tmp; + } + res = t17 * Math2.exp(-x6 * x6 + 0.5 * (cof[0] + ty * d11) - dd); + return isneg ? res - 1 : 1 - res; + }; + jStat3.erfc = function erfc(x6) { + return 1 - jStat3.erf(x6); + }; + jStat3.erfcinv = function erfcinv(p7) { + var j3 = 0; + var x6, err, t17, pp; + if (p7 >= 2) + return -100; + if (p7 <= 0) + return 100; + pp = p7 < 1 ? p7 : 2 - p7; + t17 = Math2.sqrt(-2 * Math2.log(pp / 2)); + x6 = -0.70711 * ((2.30753 + t17 * 0.27061) / (1 + t17 * (0.99229 + t17 * 0.04481)) - t17); + for (; j3 < 2; j3++) { + err = jStat3.erfc(x6) - pp; + x6 += err / (1.1283791670955126 * Math2.exp(-x6 * x6) - x6 * err); + } + return p7 < 1 ? x6 : -x6; + }; + jStat3.ibetainv = function ibetainv(p7, a11, b7) { + var EPS = 1e-8; + var a1 = a11 - 1; + var b1 = b7 - 1; + var j3 = 0; + var lna, lnb, pp, t17, u11, err, x6, al, h11, w6, afac; + if (p7 <= 0) + return 0; + if (p7 >= 1) + return 1; + if (a11 >= 1 && b7 >= 1) { + pp = p7 < 0.5 ? p7 : 1 - p7; + t17 = Math2.sqrt(-2 * Math2.log(pp)); + x6 = (2.30753 + t17 * 0.27061) / (1 + t17 * (0.99229 + t17 * 0.04481)) - t17; + if (p7 < 0.5) + x6 = -x6; + al = (x6 * x6 - 3) / 6; + h11 = 2 / (1 / (2 * a11 - 1) + 1 / (2 * b7 - 1)); + w6 = x6 * Math2.sqrt(al + h11) / h11 - (1 / (2 * b7 - 1) - 1 / (2 * a11 - 1)) * (al + 5 / 6 - 2 / (3 * h11)); + x6 = a11 / (a11 + b7 * Math2.exp(2 * w6)); + } else { + lna = Math2.log(a11 / (a11 + b7)); + lnb = Math2.log(b7 / (a11 + b7)); + t17 = Math2.exp(a11 * lna) / a11; + u11 = Math2.exp(b7 * lnb) / b7; + w6 = t17 + u11; + if (p7 < t17 / w6) + x6 = Math2.pow(a11 * w6 * p7, 1 / a11); + else + x6 = 1 - Math2.pow(b7 * w6 * (1 - p7), 1 / b7); + } + afac = -jStat3.gammaln(a11) - jStat3.gammaln(b7) + jStat3.gammaln(a11 + b7); + for (; j3 < 10; j3++) { + if (x6 === 0 || x6 === 1) + return x6; + err = jStat3.ibeta(x6, a11, b7) - p7; + t17 = Math2.exp(a1 * Math2.log(x6) + b1 * Math2.log(1 - x6) + afac); + u11 = err / t17; + x6 -= t17 = u11 / (1 - 0.5 * Math2.min(1, u11 * (a1 / x6 - b1 / (1 - x6)))); + if (x6 <= 0) + x6 = 0.5 * (x6 + t17); + if (x6 >= 1) + x6 = 0.5 * (x6 + t17 + 1); + if (Math2.abs(t17) < EPS * x6 && j3 > 0) + break; + } + return x6; + }; + jStat3.ibeta = function ibeta(x6, a11, b7) { + var bt = x6 === 0 || x6 === 1 ? 0 : Math2.exp(jStat3.gammaln(a11 + b7) - jStat3.gammaln(a11) - jStat3.gammaln(b7) + a11 * Math2.log(x6) + b7 * Math2.log(1 - x6)); + if (x6 < 0 || x6 > 1) + return false; + if (x6 < (a11 + 1) / (a11 + b7 + 2)) + return bt * jStat3.betacf(x6, a11, b7) / a11; + return 1 - bt * jStat3.betacf(1 - x6, b7, a11) / b7; + }; + jStat3.randn = function randn(n31, m6) { + var u11, v6, x6, y7, q; + if (!m6) + m6 = n31; + if (n31) + return jStat3.create(n31, m6, function() { + return jStat3.randn(); + }); + do { + u11 = jStat3._random_fn(); + v6 = 1.7156 * (jStat3._random_fn() - 0.5); + x6 = u11 - 0.449871; + y7 = Math2.abs(v6) + 0.386595; + q = x6 * x6 + y7 * (0.196 * y7 - 0.25472 * x6); + } while (q > 0.27597 && (q > 0.27846 || v6 * v6 > -4 * Math2.log(u11) * u11 * u11)); + return v6 / u11; + }; + jStat3.randg = function randg(shape, n31, m6) { + var oalph = shape; + var a1, a22, u11, v6, x6, mat; + if (!m6) + m6 = n31; + if (!shape) + shape = 1; + if (n31) { + mat = jStat3.zeros(n31, m6); + mat.alter(function() { + return jStat3.randg(shape); + }); + return mat; + } + if (shape < 1) + shape += 1; + a1 = shape - 1 / 3; + a22 = 1 / Math2.sqrt(9 * a1); + do { + do { + x6 = jStat3.randn(); + v6 = 1 + a22 * x6; + } while (v6 <= 0); + v6 = v6 * v6 * v6; + u11 = jStat3._random_fn(); + } while (u11 > 1 - 0.331 * Math2.pow(x6, 4) && Math2.log(u11) > 0.5 * x6 * x6 + a1 * (1 - v6 + Math2.log(v6))); + if (shape == oalph) + return a1 * v6; + do { + u11 = jStat3._random_fn(); + } while (u11 === 0); + return Math2.pow(u11, 1 / oalph) * a1 * v6; + }; + (function(funcs) { + for (var i23 = 0; i23 < funcs.length; i23++) + (function(passfunc) { + jStat3.fn[passfunc] = function() { + return jStat3( + jStat3.map(this, function(value) { + return jStat3[passfunc](value); + }) + ); + }; + })(funcs[i23]); + })("gammaln gammafn factorial factorialln".split(" ")); + (function(funcs) { + for (var i23 = 0; i23 < funcs.length; i23++) + (function(passfunc) { + jStat3.fn[passfunc] = function() { + return jStat3(jStat3[passfunc].apply(null, arguments)); + }; + })(funcs[i23]); + })("randn".split(" ")); + })(jStat2, Math); + (function(jStat3, Math2) { + (function(list) { + for (var i23 = 0; i23 < list.length; i23++) + (function(func) { + jStat3[func] = function f7(a11, b7, c12) { + if (!(this instanceof f7)) + return new f7(a11, b7, c12); + this._a = a11; + this._b = b7; + this._c = c12; + return this; + }; + jStat3.fn[func] = function(a11, b7, c12) { + var newthis = jStat3[func](a11, b7, c12); + newthis.data = this; + return newthis; + }; + jStat3[func].prototype.sample = function(arr) { + var a11 = this._a; + var b7 = this._b; + var c12 = this._c; + if (arr) + return jStat3.alter(arr, function() { + return jStat3[func].sample(a11, b7, c12); + }); + else + return jStat3[func].sample(a11, b7, c12); + }; + (function(vals) { + for (var i24 = 0; i24 < vals.length; i24++) + (function(fnfunc) { + jStat3[func].prototype[fnfunc] = function(x6) { + var a11 = this._a; + var b7 = this._b; + var c12 = this._c; + if (!x6 && x6 !== 0) + x6 = this.data; + if (typeof x6 !== "number") { + return jStat3.fn.map.call(x6, function(x7) { + return jStat3[func][fnfunc](x7, a11, b7, c12); + }); + } + return jStat3[func][fnfunc](x6, a11, b7, c12); + }; + })(vals[i24]); + })("pdf cdf inv".split(" ")); + (function(vals) { + for (var i24 = 0; i24 < vals.length; i24++) + (function(fnfunc) { + jStat3[func].prototype[fnfunc] = function() { + return jStat3[func][fnfunc](this._a, this._b, this._c); + }; + })(vals[i24]); + })("mean median mode variance".split(" ")); + })(list[i23]); + })("beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy laplace lognormal noncentralt normal pareto studentt weibull uniform binomial negbin hypgeom poisson triangular tukey arcsine".split(" ")); + jStat3.extend(jStat3.beta, { + pdf: function pdf(x6, alpha, beta) { + if (x6 > 1 || x6 < 0) + return 0; + if (alpha == 1 && beta == 1) + return 1; + if (alpha < 512 && beta < 512) { + return Math2.pow(x6, alpha - 1) * Math2.pow(1 - x6, beta - 1) / jStat3.betafn(alpha, beta); + } else { + return Math2.exp((alpha - 1) * Math2.log(x6) + (beta - 1) * Math2.log(1 - x6) - jStat3.betaln(alpha, beta)); + } + }, + cdf: function cdf(x6, alpha, beta) { + return x6 > 1 || x6 < 0 ? (x6 > 1) * 1 : jStat3.ibeta(x6, alpha, beta); + }, + inv: function inv(x6, alpha, beta) { + return jStat3.ibetainv(x6, alpha, beta); + }, + mean: function mean(alpha, beta) { + return alpha / (alpha + beta); + }, + median: function median(alpha, beta) { + return jStat3.ibetainv(0.5, alpha, beta); + }, + mode: function mode(alpha, beta) { + return (alpha - 1) / (alpha + beta - 2); + }, + // return a random sample + sample: function sample(alpha, beta) { + var u11 = jStat3.randg(alpha); + return u11 / (u11 + jStat3.randg(beta)); + }, + variance: function variance(alpha, beta) { + return alpha * beta / (Math2.pow(alpha + beta, 2) * (alpha + beta + 1)); + } + }); + jStat3.extend(jStat3.centralF, { + // This implementation of the pdf function avoids float overflow + // See the way that R calculates this value: + // https://svn.r-project.org/R/trunk/src/nmath/df.c + pdf: function pdf(x6, df1, df2) { + var p7, q, f7; + if (x6 < 0) + return 0; + if (df1 <= 2) { + if (x6 === 0 && df1 < 2) { + return Infinity; + } + if (x6 === 0 && df1 === 2) { + return 1; + } + return 1 / jStat3.betafn(df1 / 2, df2 / 2) * Math2.pow(df1 / df2, df1 / 2) * Math2.pow(x6, df1 / 2 - 1) * Math2.pow(1 + df1 / df2 * x6, -(df1 + df2) / 2); + } + p7 = df1 * x6 / (df2 + x6 * df1); + q = df2 / (df2 + x6 * df1); + f7 = df1 * q / 2; + return f7 * jStat3.binomial.pdf((df1 - 2) / 2, (df1 + df2 - 2) / 2, p7); + }, + cdf: function cdf(x6, df1, df2) { + if (x6 < 0) + return 0; + return jStat3.ibeta(df1 * x6 / (df1 * x6 + df2), df1 / 2, df2 / 2); + }, + inv: function inv(x6, df1, df2) { + return df2 / (df1 * (1 / jStat3.ibetainv(x6, df1 / 2, df2 / 2) - 1)); + }, + mean: function mean(df1, df2) { + return df2 > 2 ? df2 / (df2 - 2) : void 0; + }, + mode: function mode(df1, df2) { + return df1 > 2 ? df2 * (df1 - 2) / (df1 * (df2 + 2)) : void 0; + }, + // return a random sample + sample: function sample(df1, df2) { + var x1 = jStat3.randg(df1 / 2) * 2; + var x22 = jStat3.randg(df2 / 2) * 2; + return x1 / df1 / (x22 / df2); + }, + variance: function variance(df1, df2) { + if (df2 <= 4) + return void 0; + return 2 * df2 * df2 * (df1 + df2 - 2) / (df1 * (df2 - 2) * (df2 - 2) * (df2 - 4)); + } + }); + jStat3.extend(jStat3.cauchy, { + pdf: function pdf(x6, local, scale) { + if (scale < 0) { + return 0; + } + return scale / (Math2.pow(x6 - local, 2) + Math2.pow(scale, 2)) / Math2.PI; + }, + cdf: function cdf(x6, local, scale) { + return Math2.atan((x6 - local) / scale) / Math2.PI + 0.5; + }, + inv: function(p7, local, scale) { + return local + scale * Math2.tan(Math2.PI * (p7 - 0.5)); + }, + median: function median(local) { + return local; + }, + mode: function mode(local) { + return local; + }, + sample: function sample(local, scale) { + return jStat3.randn() * Math2.sqrt(1 / (2 * jStat3.randg(0.5))) * scale + local; + } + }); + jStat3.extend(jStat3.chisquare, { + pdf: function pdf(x6, dof) { + if (x6 < 0) + return 0; + return x6 === 0 && dof === 2 ? 0.5 : Math2.exp((dof / 2 - 1) * Math2.log(x6) - x6 / 2 - dof / 2 * Math2.log(2) - jStat3.gammaln(dof / 2)); + }, + cdf: function cdf(x6, dof) { + if (x6 < 0) + return 0; + return jStat3.lowRegGamma(dof / 2, x6 / 2); + }, + inv: function(p7, dof) { + return 2 * jStat3.gammapinv(p7, 0.5 * dof); + }, + mean: function(dof) { + return dof; + }, + // TODO: this is an approximation (is there a better way?) + median: function median(dof) { + return dof * Math2.pow(1 - 2 / (9 * dof), 3); + }, + mode: function mode(dof) { + return dof - 2 > 0 ? dof - 2 : 0; + }, + sample: function sample(dof) { + return jStat3.randg(dof / 2) * 2; + }, + variance: function variance(dof) { + return 2 * dof; + } + }); + jStat3.extend(jStat3.exponential, { + pdf: function pdf(x6, rate) { + return x6 < 0 ? 0 : rate * Math2.exp(-rate * x6); + }, + cdf: function cdf(x6, rate) { + return x6 < 0 ? 0 : 1 - Math2.exp(-rate * x6); + }, + inv: function(p7, rate) { + return -Math2.log(1 - p7) / rate; + }, + mean: function(rate) { + return 1 / rate; + }, + median: function(rate) { + return 1 / rate * Math2.log(2); + }, + mode: function mode() { + return 0; + }, + sample: function sample(rate) { + return -1 / rate * Math2.log(jStat3._random_fn()); + }, + variance: function(rate) { + return Math2.pow(rate, -2); + } + }); + jStat3.extend(jStat3.gamma, { + pdf: function pdf(x6, shape, scale) { + if (x6 < 0) + return 0; + return x6 === 0 && shape === 1 ? 1 / scale : Math2.exp((shape - 1) * Math2.log(x6) - x6 / scale - jStat3.gammaln(shape) - shape * Math2.log(scale)); + }, + cdf: function cdf(x6, shape, scale) { + if (x6 < 0) + return 0; + return jStat3.lowRegGamma(shape, x6 / scale); + }, + inv: function(p7, shape, scale) { + return jStat3.gammapinv(p7, shape) * scale; + }, + mean: function(shape, scale) { + return shape * scale; + }, + mode: function mode(shape, scale) { + if (shape > 1) + return (shape - 1) * scale; + return void 0; + }, + sample: function sample(shape, scale) { + return jStat3.randg(shape) * scale; + }, + variance: function variance(shape, scale) { + return shape * scale * scale; + } + }); + jStat3.extend(jStat3.invgamma, { + pdf: function pdf(x6, shape, scale) { + if (x6 <= 0) + return 0; + return Math2.exp(-(shape + 1) * Math2.log(x6) - scale / x6 - jStat3.gammaln(shape) + shape * Math2.log(scale)); + }, + cdf: function cdf(x6, shape, scale) { + if (x6 <= 0) + return 0; + return 1 - jStat3.lowRegGamma(shape, scale / x6); + }, + inv: function(p7, shape, scale) { + return scale / jStat3.gammapinv(1 - p7, shape); + }, + mean: function(shape, scale) { + return shape > 1 ? scale / (shape - 1) : void 0; + }, + mode: function mode(shape, scale) { + return scale / (shape + 1); + }, + sample: function sample(shape, scale) { + return scale / jStat3.randg(shape); + }, + variance: function variance(shape, scale) { + if (shape <= 2) + return void 0; + return scale * scale / ((shape - 1) * (shape - 1) * (shape - 2)); + } + }); + jStat3.extend(jStat3.kumaraswamy, { + pdf: function pdf(x6, alpha, beta) { + if (x6 === 0 && alpha === 1) + return beta; + else if (x6 === 1 && beta === 1) + return alpha; + return Math2.exp(Math2.log(alpha) + Math2.log(beta) + (alpha - 1) * Math2.log(x6) + (beta - 1) * Math2.log(1 - Math2.pow(x6, alpha))); + }, + cdf: function cdf(x6, alpha, beta) { + if (x6 < 0) + return 0; + else if (x6 > 1) + return 1; + return 1 - Math2.pow(1 - Math2.pow(x6, alpha), beta); + }, + inv: function inv(p7, alpha, beta) { + return Math2.pow(1 - Math2.pow(1 - p7, 1 / beta), 1 / alpha); + }, + mean: function(alpha, beta) { + return beta * jStat3.gammafn(1 + 1 / alpha) * jStat3.gammafn(beta) / jStat3.gammafn(1 + 1 / alpha + beta); + }, + median: function median(alpha, beta) { + return Math2.pow(1 - Math2.pow(2, -1 / beta), 1 / alpha); + }, + mode: function mode(alpha, beta) { + if (!(alpha >= 1 && beta >= 1 && (alpha !== 1 && beta !== 1))) + return void 0; + return Math2.pow((alpha - 1) / (alpha * beta - 1), 1 / alpha); + }, + variance: function variance() { + throw new Error("variance not yet implemented"); + } + }); + jStat3.extend(jStat3.lognormal, { + pdf: function pdf(x6, mu, sigma) { + if (x6 <= 0) + return 0; + return Math2.exp(-Math2.log(x6) - 0.5 * Math2.log(2 * Math2.PI) - Math2.log(sigma) - Math2.pow(Math2.log(x6) - mu, 2) / (2 * sigma * sigma)); + }, + cdf: function cdf(x6, mu, sigma) { + if (x6 < 0) + return 0; + return 0.5 + 0.5 * jStat3.erf((Math2.log(x6) - mu) / Math2.sqrt(2 * sigma * sigma)); + }, + inv: function(p7, mu, sigma) { + return Math2.exp(-1.4142135623730951 * sigma * jStat3.erfcinv(2 * p7) + mu); + }, + mean: function mean(mu, sigma) { + return Math2.exp(mu + sigma * sigma / 2); + }, + median: function median(mu) { + return Math2.exp(mu); + }, + mode: function mode(mu, sigma) { + return Math2.exp(mu - sigma * sigma); + }, + sample: function sample(mu, sigma) { + return Math2.exp(jStat3.randn() * sigma + mu); + }, + variance: function variance(mu, sigma) { + return (Math2.exp(sigma * sigma) - 1) * Math2.exp(2 * mu + sigma * sigma); + } + }); + jStat3.extend(jStat3.noncentralt, { + pdf: function pdf(x6, dof, ncp) { + var tol = 1e-14; + if (Math2.abs(ncp) < tol) + return jStat3.studentt.pdf(x6, dof); + if (Math2.abs(x6) < tol) { + return Math2.exp(jStat3.gammaln((dof + 1) / 2) - ncp * ncp / 2 - 0.5 * Math2.log(Math2.PI * dof) - jStat3.gammaln(dof / 2)); + } + return dof / x6 * (jStat3.noncentralt.cdf(x6 * Math2.sqrt(1 + 2 / dof), dof + 2, ncp) - jStat3.noncentralt.cdf(x6, dof, ncp)); + }, + cdf: function cdf(x6, dof, ncp) { + var tol = 1e-14; + var min_iterations = 200; + if (Math2.abs(ncp) < tol) + return jStat3.studentt.cdf(x6, dof); + var flip = false; + if (x6 < 0) { + flip = true; + ncp = -ncp; + } + var prob = jStat3.normal.cdf(-ncp, 0, 1); + var value = tol + 1; + var lastvalue = value; + var y7 = x6 * x6 / (x6 * x6 + dof); + var j3 = 0; + var p7 = Math2.exp(-ncp * ncp / 2); + var q = Math2.exp(-ncp * ncp / 2 - 0.5 * Math2.log(2) - jStat3.gammaln(3 / 2)) * ncp; + while (j3 < min_iterations || lastvalue > tol || value > tol) { + lastvalue = value; + if (j3 > 0) { + p7 *= ncp * ncp / (2 * j3); + q *= ncp * ncp / (2 * (j3 + 1 / 2)); + } + value = p7 * jStat3.beta.cdf(y7, j3 + 0.5, dof / 2) + q * jStat3.beta.cdf(y7, j3 + 1, dof / 2); + prob += 0.5 * value; + j3++; + } + return flip ? 1 - prob : prob; + } + }); + jStat3.extend(jStat3.normal, { + pdf: function pdf(x6, mean, std) { + return Math2.exp(-0.5 * Math2.log(2 * Math2.PI) - Math2.log(std) - Math2.pow(x6 - mean, 2) / (2 * std * std)); + }, + cdf: function cdf(x6, mean, std) { + return 0.5 * (1 + jStat3.erf((x6 - mean) / Math2.sqrt(2 * std * std))); + }, + inv: function(p7, mean, std) { + return -1.4142135623730951 * std * jStat3.erfcinv(2 * p7) + mean; + }, + mean: function(mean) { + return mean; + }, + median: function median(mean) { + return mean; + }, + mode: function(mean) { + return mean; + }, + sample: function sample(mean, std) { + return jStat3.randn() * std + mean; + }, + variance: function(mean, std) { + return std * std; + } + }); + jStat3.extend(jStat3.pareto, { + pdf: function pdf(x6, scale, shape) { + if (x6 < scale) + return 0; + return shape * Math2.pow(scale, shape) / Math2.pow(x6, shape + 1); + }, + cdf: function cdf(x6, scale, shape) { + if (x6 < scale) + return 0; + return 1 - Math2.pow(scale / x6, shape); + }, + inv: function inv(p7, scale, shape) { + return scale / Math2.pow(1 - p7, 1 / shape); + }, + mean: function mean(scale, shape) { + if (shape <= 1) + return void 0; + return shape * Math2.pow(scale, shape) / (shape - 1); + }, + median: function median(scale, shape) { + return scale * (shape * Math2.SQRT2); + }, + mode: function mode(scale) { + return scale; + }, + variance: function(scale, shape) { + if (shape <= 2) + return void 0; + return scale * scale * shape / (Math2.pow(shape - 1, 2) * (shape - 2)); + } + }); + jStat3.extend(jStat3.studentt, { + pdf: function pdf(x6, dof) { + dof = dof > 1e100 ? 1e100 : dof; + return 1 / (Math2.sqrt(dof) * jStat3.betafn(0.5, dof / 2)) * Math2.pow(1 + x6 * x6 / dof, -((dof + 1) / 2)); + }, + cdf: function cdf(x6, dof) { + var dof2 = dof / 2; + return jStat3.ibeta((x6 + Math2.sqrt(x6 * x6 + dof)) / (2 * Math2.sqrt(x6 * x6 + dof)), dof2, dof2); + }, + inv: function(p7, dof) { + var x6 = jStat3.ibetainv(2 * Math2.min(p7, 1 - p7), 0.5 * dof, 0.5); + x6 = Math2.sqrt(dof * (1 - x6) / x6); + return p7 > 0.5 ? x6 : -x6; + }, + mean: function mean(dof) { + return dof > 1 ? 0 : void 0; + }, + median: function median() { + return 0; + }, + mode: function mode() { + return 0; + }, + sample: function sample(dof) { + return jStat3.randn() * Math2.sqrt(dof / (2 * jStat3.randg(dof / 2))); + }, + variance: function variance(dof) { + return dof > 2 ? dof / (dof - 2) : dof > 1 ? Infinity : void 0; + } + }); + jStat3.extend(jStat3.weibull, { + pdf: function pdf(x6, scale, shape) { + if (x6 < 0 || scale < 0 || shape < 0) + return 0; + return shape / scale * Math2.pow(x6 / scale, shape - 1) * Math2.exp(-Math2.pow(x6 / scale, shape)); + }, + cdf: function cdf(x6, scale, shape) { + return x6 < 0 ? 0 : 1 - Math2.exp(-Math2.pow(x6 / scale, shape)); + }, + inv: function(p7, scale, shape) { + return scale * Math2.pow(-Math2.log(1 - p7), 1 / shape); + }, + mean: function(scale, shape) { + return scale * jStat3.gammafn(1 + 1 / shape); + }, + median: function median(scale, shape) { + return scale * Math2.pow(Math2.log(2), 1 / shape); + }, + mode: function mode(scale, shape) { + if (shape <= 1) + return 0; + return scale * Math2.pow((shape - 1) / shape, 1 / shape); + }, + sample: function sample(scale, shape) { + return scale * Math2.pow(-Math2.log(jStat3._random_fn()), 1 / shape); + }, + variance: function variance(scale, shape) { + return scale * scale * jStat3.gammafn(1 + 2 / shape) - Math2.pow(jStat3.weibull.mean(scale, shape), 2); + } + }); + jStat3.extend(jStat3.uniform, { + pdf: function pdf(x6, a11, b7) { + return x6 < a11 || x6 > b7 ? 0 : 1 / (b7 - a11); + }, + cdf: function cdf(x6, a11, b7) { + if (x6 < a11) + return 0; + else if (x6 < b7) + return (x6 - a11) / (b7 - a11); + return 1; + }, + inv: function(p7, a11, b7) { + return a11 + p7 * (b7 - a11); + }, + mean: function mean(a11, b7) { + return 0.5 * (a11 + b7); + }, + median: function median(a11, b7) { + return jStat3.mean(a11, b7); + }, + mode: function mode() { + throw new Error("mode is not yet implemented"); + }, + sample: function sample(a11, b7) { + return a11 / 2 + b7 / 2 + (b7 / 2 - a11 / 2) * (2 * jStat3._random_fn() - 1); + }, + variance: function variance(a11, b7) { + return Math2.pow(b7 - a11, 2) / 12; + } + }); + function betinc(x6, a11, b7, eps) { + var a0 = 0; + var b0 = 1; + var a1 = 1; + var b1 = 1; + var m9 = 0; + var a22 = 0; + var c92; + while (Math2.abs((a1 - a22) / a1) > eps) { + a22 = a1; + c92 = -(a11 + m9) * (a11 + b7 + m9) * x6 / (a11 + 2 * m9) / (a11 + 2 * m9 + 1); + a0 = a1 + c92 * a0; + b0 = b1 + c92 * b0; + m9 = m9 + 1; + c92 = m9 * (b7 - m9) * x6 / (a11 + 2 * m9 - 1) / (a11 + 2 * m9); + a1 = a0 + c92 * a1; + b1 = b0 + c92 * b1; + a0 = a0 / b1; + b0 = b0 / b1; + a1 = a1 / b1; + b1 = 1; + } + return a1 / a11; + } + jStat3.extend(jStat3.binomial, { + pdf: function pdf(k8, n31, p7) { + return p7 === 0 || p7 === 1 ? n31 * p7 === k8 ? 1 : 0 : jStat3.combination(n31, k8) * Math2.pow(p7, k8) * Math2.pow(1 - p7, n31 - k8); + }, + cdf: function cdf(x6, n31, p7) { + var betacdf; + var eps = 1e-10; + if (x6 < 0) + return 0; + if (x6 >= n31) + return 1; + if (p7 < 0 || p7 > 1 || n31 <= 0) + return NaN; + x6 = Math2.floor(x6); + var z5 = p7; + var a11 = x6 + 1; + var b7 = n31 - x6; + var s20 = a11 + b7; + var bt = Math2.exp(jStat3.gammaln(s20) - jStat3.gammaln(b7) - jStat3.gammaln(a11) + a11 * Math2.log(z5) + b7 * Math2.log(1 - z5)); + if (z5 < (a11 + 1) / (s20 + 2)) + betacdf = bt * betinc(z5, a11, b7, eps); + else + betacdf = 1 - bt * betinc(1 - z5, b7, a11, eps); + return Math2.round((1 - betacdf) * (1 / eps)) / (1 / eps); + } + }); + jStat3.extend(jStat3.negbin, { + pdf: function pdf(k8, r18, p7) { + if (k8 !== k8 >>> 0) + return false; + if (k8 < 0) + return 0; + return jStat3.combination(k8 + r18 - 1, r18 - 1) * Math2.pow(1 - p7, k8) * Math2.pow(p7, r18); + }, + cdf: function cdf(x6, r18, p7) { + var sum = 0, k8 = 0; + if (x6 < 0) + return 0; + for (; k8 <= x6; k8++) { + sum += jStat3.negbin.pdf(k8, r18, p7); + } + return sum; + } + }); + jStat3.extend(jStat3.hypgeom, { + pdf: function pdf(k8, N6, m6, n31) { + if (k8 !== k8 | 0) { + return false; + } else if (k8 < 0 || k8 < m6 - (N6 - n31)) { + return 0; + } else if (k8 > n31 || k8 > m6) { + return 0; + } else if (m6 * 2 > N6) { + if (n31 * 2 > N6) { + return jStat3.hypgeom.pdf(N6 - m6 - n31 + k8, N6, N6 - m6, N6 - n31); + } else { + return jStat3.hypgeom.pdf(n31 - k8, N6, N6 - m6, n31); + } + } else if (n31 * 2 > N6) { + return jStat3.hypgeom.pdf(m6 - k8, N6, m6, N6 - n31); + } else if (m6 < n31) { + return jStat3.hypgeom.pdf(k8, N6, n31, m6); + } else { + var scaledPDF = 1; + var samplesDone = 0; + for (var i23 = 0; i23 < k8; i23++) { + while (scaledPDF > 1 && samplesDone < n31) { + scaledPDF *= 1 - m6 / (N6 - samplesDone); + samplesDone++; + } + scaledPDF *= (n31 - i23) * (m6 - i23) / ((i23 + 1) * (N6 - m6 - n31 + i23 + 1)); + } + for (; samplesDone < n31; samplesDone++) { + scaledPDF *= 1 - m6 / (N6 - samplesDone); + } + return Math2.min(1, Math2.max(0, scaledPDF)); + } + }, + cdf: function cdf(x6, N6, m6, n31) { + if (x6 < 0 || x6 < m6 - (N6 - n31)) { + return 0; + } else if (x6 >= n31 || x6 >= m6) { + return 1; + } else if (m6 * 2 > N6) { + if (n31 * 2 > N6) { + return jStat3.hypgeom.cdf(N6 - m6 - n31 + x6, N6, N6 - m6, N6 - n31); + } else { + return 1 - jStat3.hypgeom.cdf(n31 - x6 - 1, N6, N6 - m6, n31); + } + } else if (n31 * 2 > N6) { + return 1 - jStat3.hypgeom.cdf(m6 - x6 - 1, N6, m6, N6 - n31); + } else if (m6 < n31) { + return jStat3.hypgeom.cdf(x6, N6, n31, m6); + } else { + var scaledCDF = 1; + var scaledPDF = 1; + var samplesDone = 0; + for (var i23 = 0; i23 < x6; i23++) { + while (scaledCDF > 1 && samplesDone < n31) { + var factor = 1 - m6 / (N6 - samplesDone); + scaledPDF *= factor; + scaledCDF *= factor; + samplesDone++; + } + scaledPDF *= (n31 - i23) * (m6 - i23) / ((i23 + 1) * (N6 - m6 - n31 + i23 + 1)); + scaledCDF += scaledPDF; + } + for (; samplesDone < n31; samplesDone++) { + scaledCDF *= 1 - m6 / (N6 - samplesDone); + } + return Math2.min(1, Math2.max(0, scaledCDF)); + } + } + }); + jStat3.extend(jStat3.poisson, { + pdf: function pdf(k8, l20) { + if (l20 < 0 || k8 % 1 !== 0 || k8 < 0) { + return 0; + } + return Math2.pow(l20, k8) * Math2.exp(-l20) / jStat3.factorial(k8); + }, + cdf: function cdf(x6, l20) { + var sumarr = [], k8 = 0; + if (x6 < 0) + return 0; + for (; k8 <= x6; k8++) { + sumarr.push(jStat3.poisson.pdf(k8, l20)); + } + return jStat3.sum(sumarr); + }, + mean: function(l20) { + return l20; + }, + variance: function(l20) { + return l20; + }, + sampleSmall: function sampleSmall(l20) { + var p7 = 1, k8 = 0, L6 = Math2.exp(-l20); + do { + k8++; + p7 *= jStat3._random_fn(); + } while (p7 > L6); + return k8 - 1; + }, + sampleLarge: function sampleLarge(l20) { + var lam = l20; + var k8; + var U, V6, slam, loglam, a11, b7, invalpha, vr, us; + slam = Math2.sqrt(lam); + loglam = Math2.log(lam); + b7 = 0.931 + 2.53 * slam; + a11 = -0.059 + 0.02483 * b7; + invalpha = 1.1239 + 1.1328 / (b7 - 3.4); + vr = 0.9277 - 3.6224 / (b7 - 2); + while (1) { + U = Math2.random() - 0.5; + V6 = Math2.random(); + us = 0.5 - Math2.abs(U); + k8 = Math2.floor((2 * a11 / us + b7) * U + lam + 0.43); + if (us >= 0.07 && V6 <= vr) { + return k8; + } + if (k8 < 0 || us < 0.013 && V6 > us) { + continue; + } + if (Math2.log(V6) + Math2.log(invalpha) - Math2.log(a11 / (us * us) + b7) <= -lam + k8 * loglam - jStat3.loggam(k8 + 1)) { + return k8; + } + } + }, + sample: function sample(l20) { + if (l20 < 10) + return this.sampleSmall(l20); + else + return this.sampleLarge(l20); + } + }); + jStat3.extend(jStat3.triangular, { + pdf: function pdf(x6, a11, b7, c12) { + if (b7 <= a11 || c12 < a11 || c12 > b7) { + return NaN; + } else { + if (x6 < a11 || x6 > b7) { + return 0; + } else if (x6 < c12) { + return 2 * (x6 - a11) / ((b7 - a11) * (c12 - a11)); + } else if (x6 === c12) { + return 2 / (b7 - a11); + } else { + return 2 * (b7 - x6) / ((b7 - a11) * (b7 - c12)); + } + } + }, + cdf: function cdf(x6, a11, b7, c12) { + if (b7 <= a11 || c12 < a11 || c12 > b7) + return NaN; + if (x6 <= a11) + return 0; + else if (x6 >= b7) + return 1; + if (x6 <= c12) + return Math2.pow(x6 - a11, 2) / ((b7 - a11) * (c12 - a11)); + else + return 1 - Math2.pow(b7 - x6, 2) / ((b7 - a11) * (b7 - c12)); + }, + inv: function inv(p7, a11, b7, c12) { + if (b7 <= a11 || c12 < a11 || c12 > b7) { + return NaN; + } else { + if (p7 <= (c12 - a11) / (b7 - a11)) { + return a11 + (b7 - a11) * Math2.sqrt(p7 * ((c12 - a11) / (b7 - a11))); + } else { + return a11 + (b7 - a11) * (1 - Math2.sqrt((1 - p7) * (1 - (c12 - a11) / (b7 - a11)))); + } + } + }, + mean: function mean(a11, b7, c12) { + return (a11 + b7 + c12) / 3; + }, + median: function median(a11, b7, c12) { + if (c12 <= (a11 + b7) / 2) { + return b7 - Math2.sqrt((b7 - a11) * (b7 - c12)) / Math2.sqrt(2); + } else if (c12 > (a11 + b7) / 2) { + return a11 + Math2.sqrt((b7 - a11) * (c12 - a11)) / Math2.sqrt(2); + } + }, + mode: function mode(a11, b7, c12) { + return c12; + }, + sample: function sample(a11, b7, c12) { + var u11 = jStat3._random_fn(); + if (u11 < (c12 - a11) / (b7 - a11)) + return a11 + Math2.sqrt(u11 * (b7 - a11) * (c12 - a11)); + return b7 - Math2.sqrt((1 - u11) * (b7 - a11) * (b7 - c12)); + }, + variance: function variance(a11, b7, c12) { + return (a11 * a11 + b7 * b7 + c12 * c12 - a11 * b7 - a11 * c12 - b7 * c12) / 18; + } + }); + jStat3.extend(jStat3.arcsine, { + pdf: function pdf(x6, a11, b7) { + if (b7 <= a11) + return NaN; + return x6 <= a11 || x6 >= b7 ? 0 : 2 / Math2.PI * Math2.pow(Math2.pow(b7 - a11, 2) - Math2.pow(2 * x6 - a11 - b7, 2), -0.5); + }, + cdf: function cdf(x6, a11, b7) { + if (x6 < a11) + return 0; + else if (x6 < b7) + return 2 / Math2.PI * Math2.asin(Math2.sqrt((x6 - a11) / (b7 - a11))); + return 1; + }, + inv: function(p7, a11, b7) { + return a11 + (0.5 - 0.5 * Math2.cos(Math2.PI * p7)) * (b7 - a11); + }, + mean: function mean(a11, b7) { + if (b7 <= a11) + return NaN; + return (a11 + b7) / 2; + }, + median: function median(a11, b7) { + if (b7 <= a11) + return NaN; + return (a11 + b7) / 2; + }, + mode: function mode() { + throw new Error("mode is not yet implemented"); + }, + sample: function sample(a11, b7) { + return (a11 + b7) / 2 + (b7 - a11) / 2 * Math2.sin(2 * Math2.PI * jStat3.uniform.sample(0, 1)); + }, + variance: function variance(a11, b7) { + if (b7 <= a11) + return NaN; + return Math2.pow(b7 - a11, 2) / 8; + } + }); + function laplaceSign(x6) { + return x6 / Math2.abs(x6); + } + jStat3.extend(jStat3.laplace, { + pdf: function pdf(x6, mu, b7) { + return b7 <= 0 ? 0 : Math2.exp(-Math2.abs(x6 - mu) / b7) / (2 * b7); + }, + cdf: function cdf(x6, mu, b7) { + if (b7 <= 0) { + return 0; + } + if (x6 < mu) { + return 0.5 * Math2.exp((x6 - mu) / b7); + } else { + return 1 - 0.5 * Math2.exp(-(x6 - mu) / b7); + } + }, + mean: function(mu) { + return mu; + }, + median: function(mu) { + return mu; + }, + mode: function(mu) { + return mu; + }, + variance: function(mu, b7) { + return 2 * b7 * b7; + }, + sample: function sample(mu, b7) { + var u11 = jStat3._random_fn() - 0.5; + return mu - b7 * laplaceSign(u11) * Math2.log(1 - 2 * Math2.abs(u11)); + } + }); + function tukeyWprob(w6, rr, cc) { + var nleg = 12; + var ihalf = 6; + var C1 = -30; + var C22 = -50; + var C32 = 60; + var bb = 8; + var wlar = 3; + var wincr1 = 2; + var wincr2 = 3; + var xleg = [ + 0.9815606342467192, + 0.9041172563704749, + 0.7699026741943047, + 0.5873179542866175, + 0.3678314989981802, + 0.1252334085114689 + ]; + var aleg = [ + 0.04717533638651183, + 0.10693932599531843, + 0.16007832854334622, + 0.20316742672306592, + 0.2334925365383548, + 0.24914704581340277 + ]; + var qsqz = w6 * 0.5; + if (qsqz >= bb) + return 1; + var pr_w = 2 * jStat3.normal.cdf(qsqz, 0, 1, 1, 0) - 1; + if (pr_w >= Math2.exp(C22 / cc)) + pr_w = Math2.pow(pr_w, cc); + else + pr_w = 0; + var wincr; + if (w6 > wlar) + wincr = wincr1; + else + wincr = wincr2; + var blb = qsqz; + var binc = (bb - qsqz) / wincr; + var bub = blb + binc; + var einsum = 0; + var cc1 = cc - 1; + for (var wi = 1; wi <= wincr; wi++) { + var elsum = 0; + var a11 = 0.5 * (bub + blb); + var b7 = 0.5 * (bub - blb); + for (var jj = 1; jj <= nleg; jj++) { + var j3, xx; + if (ihalf < jj) { + j3 = nleg - jj + 1; + xx = xleg[j3 - 1]; + } else { + j3 = jj; + xx = -xleg[j3 - 1]; + } + var c12 = b7 * xx; + var ac = a11 + c12; + var qexpo = ac * ac; + if (qexpo > C32) + break; + var pplus = 2 * jStat3.normal.cdf(ac, 0, 1, 1, 0); + var pminus = 2 * jStat3.normal.cdf(ac, w6, 1, 1, 0); + var rinsum = pplus * 0.5 - pminus * 0.5; + if (rinsum >= Math2.exp(C1 / cc1)) { + rinsum = aleg[j3 - 1] * Math2.exp(-(0.5 * qexpo)) * Math2.pow(rinsum, cc1); + elsum += rinsum; + } + } + elsum *= 2 * b7 * cc / Math2.sqrt(2 * Math2.PI); + einsum += elsum; + blb = bub; + bub += binc; + } + pr_w += einsum; + if (pr_w <= Math2.exp(C1 / rr)) + return 0; + pr_w = Math2.pow(pr_w, rr); + if (pr_w >= 1) + return 1; + return pr_w; + } + function tukeyQinv(p7, c12, v6) { + var p0 = 0.322232421088; + var q0 = 0.099348462606; + var p1 = -1; + var q1 = 0.588581570495; + var p22 = -0.342242088547; + var q2 = 0.531103462366; + var p32 = -0.204231210125; + var q3 = 0.10353775285; + var p42 = -453642210148e-16; + var q4 = 0.0038560700634; + var c1 = 0.8832; + var c22 = 0.2368; + var c32 = 1.214; + var c42 = 1.208; + var c52 = 1.4142; + var vmax = 120; + var ps = 0.5 - 0.5 * p7; + var yi = Math2.sqrt(Math2.log(1 / (ps * ps))); + var t17 = yi + ((((yi * p42 + p32) * yi + p22) * yi + p1) * yi + p0) / ((((yi * q4 + q3) * yi + q2) * yi + q1) * yi + q0); + if (v6 < vmax) + t17 += (t17 * t17 * t17 + t17) / v6 / 4; + var q = c1 - c22 * t17; + if (v6 < vmax) + q += -c32 / v6 + c42 * t17 / v6; + return t17 * (q * Math2.log(c12 - 1) + c52); + } + jStat3.extend(jStat3.tukey, { + cdf: function cdf(q, nmeans, df) { + var rr = 1; + var cc = nmeans; + var nlegq = 16; + var ihalfq = 8; + var eps1 = -30; + var eps2 = 1e-14; + var dhaf = 100; + var dquar = 800; + var deigh = 5e3; + var dlarg = 25e3; + var ulen1 = 1; + var ulen2 = 0.5; + var ulen3 = 0.25; + var ulen4 = 0.125; + var xlegq = [ + 0.9894009349916499, + 0.9445750230732326, + 0.8656312023878318, + 0.755404408355003, + 0.6178762444026438, + 0.45801677765722737, + 0.2816035507792589, + 0.09501250983763744 + ]; + var alegq = [ + 0.027152459411754096, + 0.062253523938647894, + 0.09515851168249279, + 0.12462897125553388, + 0.14959598881657674, + 0.16915651939500254, + 0.18260341504492358, + 0.1894506104550685 + ]; + if (q <= 0) + return 0; + if (df < 2 || rr < 1 || cc < 2) + return NaN; + if (!Number.isFinite(q)) + return 1; + if (df > dlarg) + return tukeyWprob(q, rr, cc); + var f22 = df * 0.5; + var f2lf = f22 * Math2.log(df) - df * Math2.log(2) - jStat3.gammaln(f22); + var f21 = f22 - 1; + var ff4 = df * 0.25; + var ulen; + if (df <= dhaf) + ulen = ulen1; + else if (df <= dquar) + ulen = ulen2; + else if (df <= deigh) + ulen = ulen3; + else + ulen = ulen4; + f2lf += Math2.log(ulen); + var ans = 0; + for (var i23 = 1; i23 <= 50; i23++) { + var otsum = 0; + var twa1 = (2 * i23 - 1) * ulen; + for (var jj = 1; jj <= nlegq; jj++) { + var j3, t1; + if (ihalfq < jj) { + j3 = jj - ihalfq - 1; + t1 = f2lf + f21 * Math2.log(twa1 + xlegq[j3] * ulen) - (xlegq[j3] * ulen + twa1) * ff4; + } else { + j3 = jj - 1; + t1 = f2lf + f21 * Math2.log(twa1 - xlegq[j3] * ulen) + (xlegq[j3] * ulen - twa1) * ff4; + } + var qsqz; + if (t1 >= eps1) { + if (ihalfq < jj) { + qsqz = q * Math2.sqrt((xlegq[j3] * ulen + twa1) * 0.5); + } else { + qsqz = q * Math2.sqrt((-(xlegq[j3] * ulen) + twa1) * 0.5); + } + var wprb = tukeyWprob(qsqz, rr, cc); + var rotsum = wprb * alegq[j3] * Math2.exp(t1); + otsum += rotsum; + } + } + if (i23 * ulen >= 1 && otsum <= eps2) + break; + ans += otsum; + } + if (otsum > eps2) { + throw new Error("tukey.cdf failed to converge"); + } + if (ans > 1) + ans = 1; + return ans; + }, + inv: function(p7, nmeans, df) { + var rr = 1; + var cc = nmeans; + var eps = 1e-4; + var maxiter = 50; + if (df < 2 || rr < 1 || cc < 2) + return NaN; + if (p7 < 0 || p7 > 1) + return NaN; + if (p7 === 0) + return 0; + if (p7 === 1) + return Infinity; + var x0 = tukeyQinv(p7, cc, df); + var valx0 = jStat3.tukey.cdf(x0, nmeans, df) - p7; + var x1; + if (valx0 > 0) + x1 = Math2.max(0, x0 - 1); + else + x1 = x0 + 1; + var valx1 = jStat3.tukey.cdf(x1, nmeans, df) - p7; + var ans; + for (var iter = 1; iter < maxiter; iter++) { + ans = x1 - valx1 * (x1 - x0) / (valx1 - valx0); + valx0 = valx1; + x0 = x1; + if (ans < 0) { + ans = 0; + valx1 = -p7; + } + valx1 = jStat3.tukey.cdf(ans, nmeans, df) - p7; + x1 = ans; + var xabs = Math2.abs(x1 - x0); + if (xabs < eps) + return ans; + } + throw new Error("tukey.inv failed to converge"); + } + }); + })(jStat2, Math); + (function(jStat3, Math2) { + var push2 = Array.prototype.push; + var isArray = jStat3.utils.isArray; + function isUsable(arg) { + return isArray(arg) || arg instanceof jStat3; + } + jStat3.extend({ + // add a vector/matrix to a vector/matrix or scalar + add: function add(arr, arg) { + if (isUsable(arg)) { + if (!isUsable(arg[0])) + arg = [arg]; + return jStat3.map(arr, function(value, row, col) { + return value + arg[row][col]; + }); + } + return jStat3.map(arr, function(value) { + return value + arg; + }); + }, + // subtract a vector or scalar from the vector + subtract: function subtract(arr, arg) { + if (isUsable(arg)) { + if (!isUsable(arg[0])) + arg = [arg]; + return jStat3.map(arr, function(value, row, col) { + return value - arg[row][col] || 0; + }); + } + return jStat3.map(arr, function(value) { + return value - arg; + }); + }, + // matrix division + divide: function divide(arr, arg) { + if (isUsable(arg)) { + if (!isUsable(arg[0])) + arg = [arg]; + return jStat3.multiply(arr, jStat3.inv(arg)); + } + return jStat3.map(arr, function(value) { + return value / arg; + }); + }, + // matrix multiplication + multiply: function multiply(arr, arg) { + var row, col, nrescols, sum, nrow, ncol, res, rescols; + if (arr.length === void 0 && arg.length === void 0) { + return arr * arg; + } + nrow = arr.length, ncol = arr[0].length, res = jStat3.zeros(nrow, nrescols = isUsable(arg) ? arg[0].length : ncol), rescols = 0; + if (isUsable(arg)) { + for (; rescols < nrescols; rescols++) { + for (row = 0; row < nrow; row++) { + sum = 0; + for (col = 0; col < ncol; col++) + sum += arr[row][col] * arg[col][rescols]; + res[row][rescols] = sum; + } + } + return nrow === 1 && rescols === 1 ? res[0][0] : res; + } + return jStat3.map(arr, function(value) { + return value * arg; + }); + }, + // outer([1,2,3],[4,5,6]) + // === + // [[1],[2],[3]] times [[4,5,6]] + // -> + // [[4,5,6],[8,10,12],[12,15,18]] + outer: function outer(A6, B5) { + return jStat3.multiply(A6.map(function(t17) { + return [t17]; + }), [B5]); + }, + // Returns the dot product of two matricies + dot: function dot(arr, arg) { + if (!isUsable(arr[0])) + arr = [arr]; + if (!isUsable(arg[0])) + arg = [arg]; + var left = arr[0].length === 1 && arr.length !== 1 ? jStat3.transpose(arr) : arr, right = arg[0].length === 1 && arg.length !== 1 ? jStat3.transpose(arg) : arg, res = [], row = 0, nrow = left.length, ncol = left[0].length, sum, col; + for (; row < nrow; row++) { + res[row] = []; + sum = 0; + for (col = 0; col < ncol; col++) + sum += left[row][col] * right[row][col]; + res[row] = sum; + } + return res.length === 1 ? res[0] : res; + }, + // raise every element by a scalar + pow: function pow(arr, arg) { + return jStat3.map(arr, function(value) { + return Math2.pow(value, arg); + }); + }, + // exponentiate every element + exp: function exp(arr) { + return jStat3.map(arr, function(value) { + return Math2.exp(value); + }); + }, + // generate the natural log of every element + log: function exp(arr) { + return jStat3.map(arr, function(value) { + return Math2.log(value); + }); + }, + // generate the absolute values of the vector + abs: function abs(arr) { + return jStat3.map(arr, function(value) { + return Math2.abs(value); + }); + }, + // computes the p-norm of the vector + // In the case that a matrix is passed, uses the first row as the vector + norm: function norm(arr, p7) { + var nnorm = 0, i23 = 0; + if (isNaN(p7)) + p7 = 2; + if (isUsable(arr[0])) + arr = arr[0]; + for (; i23 < arr.length; i23++) { + nnorm += Math2.pow(Math2.abs(arr[i23]), p7); + } + return Math2.pow(nnorm, 1 / p7); + }, + // computes the angle between two vectors in rads + // In case a matrix is passed, this uses the first row as the vector + angle: function angle(arr, arg) { + return Math2.acos(jStat3.dot(arr, arg) / (jStat3.norm(arr) * jStat3.norm(arg))); + }, + // augment one matrix by another + // Note: this function returns a matrix, not a jStat object + aug: function aug(a11, b7) { + var newarr = []; + var i23; + for (i23 = 0; i23 < a11.length; i23++) { + newarr.push(a11[i23].slice()); + } + for (i23 = 0; i23 < newarr.length; i23++) { + push2.apply(newarr[i23], b7[i23]); + } + return newarr; + }, + // The inv() function calculates the inverse of a matrix + // Create the inverse by augmenting the matrix by the identity matrix of the + // appropriate size, and then use G-J elimination on the augmented matrix. + inv: function inv(a11) { + var rows = a11.length; + var cols = a11[0].length; + var b7 = jStat3.identity(rows, cols); + var c12 = jStat3.gauss_jordan(a11, b7); + var result = []; + var i23 = 0; + var j3; + for (; i23 < rows; i23++) { + result[i23] = []; + for (j3 = cols; j3 < c12[0].length; j3++) + result[i23][j3 - cols] = c12[i23][j3]; + } + return result; + }, + // calculate the determinant of a matrix + det: function det(a11) { + if (a11.length === 2) { + return a11[0][0] * a11[1][1] - a11[0][1] * a11[1][0]; + } + var determinant = 0; + for (var i23 = 0; i23 < a11.length; i23++) { + var submatrix = []; + for (var row = 1; row < a11.length; row++) { + submatrix[row - 1] = []; + for (var col = 0; col < a11.length; col++) { + if (col < i23) { + submatrix[row - 1][col] = a11[row][col]; + } else if (col > i23) { + submatrix[row - 1][col - 1] = a11[row][col]; + } + } + } + var sign = i23 % 2 ? -1 : 1; + determinant += det(submatrix) * a11[0][i23] * sign; + } + return determinant; + }, + gauss_elimination: function gauss_elimination(a11, b7) { + var i23 = 0, j3 = 0, n31 = a11.length, m6 = a11[0].length, factor = 1, sum = 0, x6 = [], maug, pivot, temp, k8; + a11 = jStat3.aug(a11, b7); + maug = a11[0].length; + for (i23 = 0; i23 < n31; i23++) { + pivot = a11[i23][i23]; + j3 = i23; + for (k8 = i23 + 1; k8 < m6; k8++) { + if (pivot < Math2.abs(a11[k8][i23])) { + pivot = a11[k8][i23]; + j3 = k8; + } + } + if (j3 != i23) { + for (k8 = 0; k8 < maug; k8++) { + temp = a11[i23][k8]; + a11[i23][k8] = a11[j3][k8]; + a11[j3][k8] = temp; + } + } + for (j3 = i23 + 1; j3 < n31; j3++) { + factor = a11[j3][i23] / a11[i23][i23]; + for (k8 = i23; k8 < maug; k8++) { + a11[j3][k8] = a11[j3][k8] - factor * a11[i23][k8]; + } + } + } + for (i23 = n31 - 1; i23 >= 0; i23--) { + sum = 0; + for (j3 = i23 + 1; j3 <= n31 - 1; j3++) { + sum = sum + x6[j3] * a11[i23][j3]; + } + x6[i23] = (a11[i23][maug - 1] - sum) / a11[i23][i23]; + } + return x6; + }, + gauss_jordan: function gauss_jordan(a11, b7) { + var m6 = jStat3.aug(a11, b7); + var h11 = m6.length; + var w6 = m6[0].length; + var c12 = 0; + var x6, y7, y22; + for (y7 = 0; y7 < h11; y7++) { + var maxrow = y7; + for (y22 = y7 + 1; y22 < h11; y22++) { + if (Math2.abs(m6[y22][y7]) > Math2.abs(m6[maxrow][y7])) + maxrow = y22; + } + var tmp = m6[y7]; + m6[y7] = m6[maxrow]; + m6[maxrow] = tmp; + for (y22 = y7 + 1; y22 < h11; y22++) { + c12 = m6[y22][y7] / m6[y7][y7]; + for (x6 = y7; x6 < w6; x6++) { + m6[y22][x6] -= m6[y7][x6] * c12; + } + } + } + for (y7 = h11 - 1; y7 >= 0; y7--) { + c12 = m6[y7][y7]; + for (y22 = 0; y22 < y7; y22++) { + for (x6 = w6 - 1; x6 > y7 - 1; x6--) { + m6[y22][x6] -= m6[y7][x6] * m6[y22][y7] / c12; + } + } + m6[y7][y7] /= c12; + for (x6 = h11; x6 < w6; x6++) { + m6[y7][x6] /= c12; + } + } + return m6; + }, + // solve equation + // Ax=b + // A is upper triangular matrix + // A=[[1,2,3],[0,4,5],[0,6,7]] + // b=[1,2,3] + // triaUpSolve(A,b) // -> [2.666,0.1666,1.666] + // if you use matrix style + // A=[[1,2,3],[0,4,5],[0,6,7]] + // b=[[1],[2],[3]] + // will return [[2.666],[0.1666],[1.666]] + triaUpSolve: function triaUpSolve(A6, b7) { + var size = A6[0].length; + var x6 = jStat3.zeros(1, size)[0]; + var parts; + var matrix_mode = false; + if (b7[0].length != void 0) { + b7 = b7.map(function(i23) { + return i23[0]; + }); + matrix_mode = true; + } + jStat3.arange(size - 1, -1, -1).forEach(function(i23) { + parts = jStat3.arange(i23 + 1, size).map(function(j3) { + return x6[j3] * A6[i23][j3]; + }); + x6[i23] = (b7[i23] - jStat3.sum(parts)) / A6[i23][i23]; + }); + if (matrix_mode) + return x6.map(function(i23) { + return [i23]; + }); + return x6; + }, + triaLowSolve: function triaLowSolve(A6, b7) { + var size = A6[0].length; + var x6 = jStat3.zeros(1, size)[0]; + var parts; + var matrix_mode = false; + if (b7[0].length != void 0) { + b7 = b7.map(function(i23) { + return i23[0]; + }); + matrix_mode = true; + } + jStat3.arange(size).forEach(function(i23) { + parts = jStat3.arange(i23).map(function(j3) { + return A6[i23][j3] * x6[j3]; + }); + x6[i23] = (b7[i23] - jStat3.sum(parts)) / A6[i23][i23]; + }); + if (matrix_mode) + return x6.map(function(i23) { + return [i23]; + }); + return x6; + }, + // A -> [L,U] + // A=LU + // L is lower triangular matrix + // U is upper triangular matrix + lu: function lu(A6) { + var size = A6.length; + var L6 = jStat3.identity(size); + var R6 = jStat3.zeros(A6.length, A6[0].length); + var parts; + jStat3.arange(size).forEach(function(t17) { + R6[0][t17] = A6[0][t17]; + }); + jStat3.arange(1, size).forEach(function(l20) { + jStat3.arange(l20).forEach(function(i23) { + parts = jStat3.arange(i23).map(function(jj) { + return L6[l20][jj] * R6[jj][i23]; + }); + L6[l20][i23] = (A6[l20][i23] - jStat3.sum(parts)) / R6[i23][i23]; + }); + jStat3.arange(l20, size).forEach(function(j3) { + parts = jStat3.arange(l20).map(function(jj) { + return L6[l20][jj] * R6[jj][j3]; + }); + R6[l20][j3] = A6[parts.length][j3] - jStat3.sum(parts); + }); + }); + return [L6, R6]; + }, + // A -> T + // A=TT' + // T is lower triangular matrix + cholesky: function cholesky(A6) { + var size = A6.length; + var T6 = jStat3.zeros(A6.length, A6[0].length); + var parts; + jStat3.arange(size).forEach(function(i23) { + parts = jStat3.arange(i23).map(function(t17) { + return Math2.pow(T6[i23][t17], 2); + }); + T6[i23][i23] = Math2.sqrt(A6[i23][i23] - jStat3.sum(parts)); + jStat3.arange(i23 + 1, size).forEach(function(j3) { + parts = jStat3.arange(i23).map(function(t17) { + return T6[i23][t17] * T6[j3][t17]; + }); + T6[j3][i23] = (A6[i23][j3] - jStat3.sum(parts)) / T6[i23][i23]; + }); + }); + return T6; + }, + gauss_jacobi: function gauss_jacobi(a11, b7, x6, r18) { + var i23 = 0; + var j3 = 0; + var n31 = a11.length; + var l20 = []; + var u11 = []; + var d11 = []; + var xv, c12, h11, xk; + for (; i23 < n31; i23++) { + l20[i23] = []; + u11[i23] = []; + d11[i23] = []; + for (j3 = 0; j3 < n31; j3++) { + if (i23 > j3) { + l20[i23][j3] = a11[i23][j3]; + u11[i23][j3] = d11[i23][j3] = 0; + } else if (i23 < j3) { + u11[i23][j3] = a11[i23][j3]; + l20[i23][j3] = d11[i23][j3] = 0; + } else { + d11[i23][j3] = a11[i23][j3]; + l20[i23][j3] = u11[i23][j3] = 0; + } + } + } + h11 = jStat3.multiply(jStat3.multiply(jStat3.inv(d11), jStat3.add(l20, u11)), -1); + c12 = jStat3.multiply(jStat3.inv(d11), b7); + xv = x6; + xk = jStat3.add(jStat3.multiply(h11, x6), c12); + i23 = 2; + while (Math2.abs(jStat3.norm(jStat3.subtract(xk, xv))) > r18) { + xv = xk; + xk = jStat3.add(jStat3.multiply(h11, xv), c12); + i23++; + } + return xk; + }, + gauss_seidel: function gauss_seidel(a11, b7, x6, r18) { + var i23 = 0; + var n31 = a11.length; + var l20 = []; + var u11 = []; + var d11 = []; + var j3, xv, c12, h11, xk; + for (; i23 < n31; i23++) { + l20[i23] = []; + u11[i23] = []; + d11[i23] = []; + for (j3 = 0; j3 < n31; j3++) { + if (i23 > j3) { + l20[i23][j3] = a11[i23][j3]; + u11[i23][j3] = d11[i23][j3] = 0; + } else if (i23 < j3) { + u11[i23][j3] = a11[i23][j3]; + l20[i23][j3] = d11[i23][j3] = 0; + } else { + d11[i23][j3] = a11[i23][j3]; + l20[i23][j3] = u11[i23][j3] = 0; + } + } + } + h11 = jStat3.multiply(jStat3.multiply(jStat3.inv(jStat3.add(d11, l20)), u11), -1); + c12 = jStat3.multiply(jStat3.inv(jStat3.add(d11, l20)), b7); + xv = x6; + xk = jStat3.add(jStat3.multiply(h11, x6), c12); + i23 = 2; + while (Math2.abs(jStat3.norm(jStat3.subtract(xk, xv))) > r18) { + xv = xk; + xk = jStat3.add(jStat3.multiply(h11, xv), c12); + i23 = i23 + 1; + } + return xk; + }, + SOR: function SOR(a11, b7, x6, r18, w6) { + var i23 = 0; + var n31 = a11.length; + var l20 = []; + var u11 = []; + var d11 = []; + var j3, xv, c12, h11, xk; + for (; i23 < n31; i23++) { + l20[i23] = []; + u11[i23] = []; + d11[i23] = []; + for (j3 = 0; j3 < n31; j3++) { + if (i23 > j3) { + l20[i23][j3] = a11[i23][j3]; + u11[i23][j3] = d11[i23][j3] = 0; + } else if (i23 < j3) { + u11[i23][j3] = a11[i23][j3]; + l20[i23][j3] = d11[i23][j3] = 0; + } else { + d11[i23][j3] = a11[i23][j3]; + l20[i23][j3] = u11[i23][j3] = 0; + } + } + } + h11 = jStat3.multiply( + jStat3.inv(jStat3.add(d11, jStat3.multiply(l20, w6))), + jStat3.subtract( + jStat3.multiply(d11, 1 - w6), + jStat3.multiply(u11, w6) + ) + ); + c12 = jStat3.multiply(jStat3.multiply(jStat3.inv(jStat3.add( + d11, + jStat3.multiply(l20, w6) + )), b7), w6); + xv = x6; + xk = jStat3.add(jStat3.multiply(h11, x6), c12); + i23 = 2; + while (Math2.abs(jStat3.norm(jStat3.subtract(xk, xv))) > r18) { + xv = xk; + xk = jStat3.add(jStat3.multiply(h11, xv), c12); + i23++; + } + return xk; + }, + householder: function householder(a11) { + var m6 = a11.length; + var n31 = a11[0].length; + var i23 = 0; + var w6 = []; + var p7 = []; + var alpha, r18, k8, j3, factor; + for (; i23 < m6 - 1; i23++) { + alpha = 0; + for (j3 = i23 + 1; j3 < n31; j3++) + alpha += a11[j3][i23] * a11[j3][i23]; + factor = a11[i23 + 1][i23] > 0 ? -1 : 1; + alpha = factor * Math2.sqrt(alpha); + r18 = Math2.sqrt((alpha * alpha - a11[i23 + 1][i23] * alpha) / 2); + w6 = jStat3.zeros(m6, 1); + w6[i23 + 1][0] = (a11[i23 + 1][i23] - alpha) / (2 * r18); + for (k8 = i23 + 2; k8 < m6; k8++) + w6[k8][0] = a11[k8][i23] / (2 * r18); + p7 = jStat3.subtract( + jStat3.identity(m6, n31), + jStat3.multiply(jStat3.multiply(w6, jStat3.transpose(w6)), 2) + ); + a11 = jStat3.multiply(p7, jStat3.multiply(a11, p7)); + } + return a11; + }, + // A -> [Q,R] + // Q is orthogonal matrix + // R is upper triangular + QR: function() { + var sum = jStat3.sum; + var range = jStat3.arange; + function qr2(x6) { + var n31 = x6.length; + var p7 = x6[0].length; + var r18 = jStat3.zeros(p7, p7); + x6 = jStat3.copy(x6); + var i23, j3, k8; + for (j3 = 0; j3 < p7; j3++) { + r18[j3][j3] = Math2.sqrt(sum(range(n31).map(function(i24) { + return x6[i24][j3] * x6[i24][j3]; + }))); + for (i23 = 0; i23 < n31; i23++) { + x6[i23][j3] = x6[i23][j3] / r18[j3][j3]; + } + for (k8 = j3 + 1; k8 < p7; k8++) { + r18[j3][k8] = sum(range(n31).map(function(i24) { + return x6[i24][j3] * x6[i24][k8]; + })); + for (i23 = 0; i23 < n31; i23++) { + x6[i23][k8] = x6[i23][k8] - x6[i23][j3] * r18[j3][k8]; + } + } + } + return [x6, r18]; + } + return qr2; + }(), + lstsq: /* @__PURE__ */ function() { + function R_I(A6) { + A6 = jStat3.copy(A6); + var size = A6.length; + var I6 = jStat3.identity(size); + jStat3.arange(size - 1, -1, -1).forEach(function(i23) { + jStat3.sliceAssign( + I6, + { row: i23 }, + jStat3.divide(jStat3.slice(I6, { row: i23 }), A6[i23][i23]) + ); + jStat3.sliceAssign( + A6, + { row: i23 }, + jStat3.divide(jStat3.slice(A6, { row: i23 }), A6[i23][i23]) + ); + jStat3.arange(i23).forEach(function(j3) { + var c12 = jStat3.multiply(A6[j3][i23], -1); + var Aj = jStat3.slice(A6, { row: j3 }); + var cAi = jStat3.multiply(jStat3.slice(A6, { row: i23 }), c12); + jStat3.sliceAssign(A6, { row: j3 }, jStat3.add(Aj, cAi)); + var Ij = jStat3.slice(I6, { row: j3 }); + var cIi = jStat3.multiply(jStat3.slice(I6, { row: i23 }), c12); + jStat3.sliceAssign(I6, { row: j3 }, jStat3.add(Ij, cIi)); + }); + }); + return I6; + } + function qr_solve(A6, b7) { + var array_mode = false; + if (b7[0].length === void 0) { + b7 = b7.map(function(x7) { + return [x7]; + }); + array_mode = true; + } + var QR = jStat3.QR(A6); + var Q = QR[0]; + var R6 = QR[1]; + var attrs = A6[0].length; + var Q1 = jStat3.slice(Q, { col: { end: attrs } }); + var R1 = jStat3.slice(R6, { row: { end: attrs } }); + var RI = R_I(R1); + var Q2 = jStat3.transpose(Q1); + if (Q2[0].length === void 0) { + Q2 = [Q2]; + } + var x6 = jStat3.multiply(jStat3.multiply(RI, Q2), b7); + if (x6.length === void 0) { + x6 = [[x6]]; + } + if (array_mode) + return x6.map(function(i23) { + return i23[0]; + }); + return x6; + } + return qr_solve; + }(), + jacobi: function jacobi(a11) { + var condition = 1; + var n31 = a11.length; + var e33 = jStat3.identity(n31, n31); + var ev = []; + var b7, i23, j3, p7, q, maxim, theta, s20; + while (condition === 1) { + maxim = a11[0][1]; + p7 = 0; + q = 1; + for (i23 = 0; i23 < n31; i23++) { + for (j3 = 0; j3 < n31; j3++) { + if (i23 != j3) { + if (maxim < Math2.abs(a11[i23][j3])) { + maxim = Math2.abs(a11[i23][j3]); + p7 = i23; + q = j3; + } + } + } + } + if (a11[p7][p7] === a11[q][q]) + theta = a11[p7][q] > 0 ? Math2.PI / 4 : -Math2.PI / 4; + else + theta = Math2.atan(2 * a11[p7][q] / (a11[p7][p7] - a11[q][q])) / 2; + s20 = jStat3.identity(n31, n31); + s20[p7][p7] = Math2.cos(theta); + s20[p7][q] = -Math2.sin(theta); + s20[q][p7] = Math2.sin(theta); + s20[q][q] = Math2.cos(theta); + e33 = jStat3.multiply(e33, s20); + b7 = jStat3.multiply(jStat3.multiply(jStat3.inv(s20), a11), s20); + a11 = b7; + condition = 0; + for (i23 = 1; i23 < n31; i23++) { + for (j3 = 1; j3 < n31; j3++) { + if (i23 != j3 && Math2.abs(a11[i23][j3]) > 1e-3) { + condition = 1; + } + } + } + } + for (i23 = 0; i23 < n31; i23++) + ev.push(a11[i23][i23]); + return [e33, ev]; + }, + rungekutta: function rungekutta(f7, h11, p7, t_j, u_j, order) { + var k12, k22, u_j1, k32, k42; + if (order === 2) { + while (t_j <= p7) { + k12 = h11 * f7(t_j, u_j); + k22 = h11 * f7(t_j + h11, u_j + k12); + u_j1 = u_j + (k12 + k22) / 2; + u_j = u_j1; + t_j = t_j + h11; + } + } + if (order === 4) { + while (t_j <= p7) { + k12 = h11 * f7(t_j, u_j); + k22 = h11 * f7(t_j + h11 / 2, u_j + k12 / 2); + k32 = h11 * f7(t_j + h11 / 2, u_j + k22 / 2); + k42 = h11 * f7(t_j + h11, u_j + k32); + u_j1 = u_j + (k12 + 2 * k22 + 2 * k32 + k42) / 6; + u_j = u_j1; + t_j = t_j + h11; + } + } + return u_j; + }, + romberg: function romberg(f7, a11, b7, order) { + var i23 = 0; + var h11 = (b7 - a11) / 2; + var x6 = []; + var h1 = []; + var g6 = []; + var m6, a1, j3, k8, I6; + while (i23 < order / 2) { + I6 = f7(a11); + for (j3 = a11, k8 = 0; j3 <= b7; j3 = j3 + h11, k8++) + x6[k8] = j3; + m6 = x6.length; + for (j3 = 1; j3 < m6 - 1; j3++) { + I6 += (j3 % 2 !== 0 ? 4 : 2) * f7(x6[j3]); + } + I6 = h11 / 3 * (I6 + f7(b7)); + g6[i23] = I6; + h11 /= 2; + i23++; + } + a1 = g6.length; + m6 = 1; + while (a1 !== 1) { + for (j3 = 0; j3 < a1 - 1; j3++) + h1[j3] = (Math2.pow(4, m6) * g6[j3 + 1] - g6[j3]) / (Math2.pow(4, m6) - 1); + a1 = h1.length; + g6 = h1; + h1 = []; + m6++; + } + return g6; + }, + richardson: function richardson(X, f7, x6, h11) { + function pos(X2, x7) { + var i24 = 0; + var n31 = X2.length; + var p7; + for (; i24 < n31; i24++) + if (X2[i24] === x7) + p7 = i24; + return p7; + } + var h_min = Math2.abs(x6 - X[pos(X, x6) + 1]); + var i23 = 0; + var g6 = []; + var h1 = []; + var y1, y22, m6, a11, j3; + while (h11 >= h_min) { + y1 = pos(X, x6 + h11); + y22 = pos(X, x6); + g6[i23] = (f7[y1] - 2 * f7[y22] + f7[2 * y22 - y1]) / (h11 * h11); + h11 /= 2; + i23++; + } + a11 = g6.length; + m6 = 1; + while (a11 != 1) { + for (j3 = 0; j3 < a11 - 1; j3++) + h1[j3] = (Math2.pow(4, m6) * g6[j3 + 1] - g6[j3]) / (Math2.pow(4, m6) - 1); + a11 = h1.length; + g6 = h1; + h1 = []; + m6++; + } + return g6; + }, + simpson: function simpson(f7, a11, b7, n31) { + var h11 = (b7 - a11) / n31; + var I6 = f7(a11); + var x6 = []; + var j3 = a11; + var k8 = 0; + var i23 = 1; + var m6; + for (; j3 <= b7; j3 = j3 + h11, k8++) + x6[k8] = j3; + m6 = x6.length; + for (; i23 < m6 - 1; i23++) { + I6 += (i23 % 2 !== 0 ? 4 : 2) * f7(x6[i23]); + } + return h11 / 3 * (I6 + f7(b7)); + }, + hermite: function hermite(X, F, dF, value) { + var n31 = X.length; + var p7 = 0; + var i23 = 0; + var l20 = []; + var dl = []; + var A6 = []; + var B5 = []; + var j3; + for (; i23 < n31; i23++) { + l20[i23] = 1; + for (j3 = 0; j3 < n31; j3++) { + if (i23 != j3) + l20[i23] *= (value - X[j3]) / (X[i23] - X[j3]); + } + dl[i23] = 0; + for (j3 = 0; j3 < n31; j3++) { + if (i23 != j3) + dl[i23] += 1 / (X[i23] - X[j3]); + } + A6[i23] = (1 - 2 * (value - X[i23]) * dl[i23]) * (l20[i23] * l20[i23]); + B5[i23] = (value - X[i23]) * (l20[i23] * l20[i23]); + p7 += A6[i23] * F[i23] + B5[i23] * dF[i23]; + } + return p7; + }, + lagrange: function lagrange(X, F, value) { + var p7 = 0; + var i23 = 0; + var j3, l20; + var n31 = X.length; + for (; i23 < n31; i23++) { + l20 = F[i23]; + for (j3 = 0; j3 < n31; j3++) { + if (i23 != j3) + l20 *= (value - X[j3]) / (X[i23] - X[j3]); + } + p7 += l20; + } + return p7; + }, + cubic_spline: function cubic_spline(X, F, value) { + var n31 = X.length; + var i23 = 0, j3; + var A6 = []; + var B5 = []; + var alpha = []; + var c12 = []; + var h11 = []; + var b7 = []; + var d11 = []; + for (; i23 < n31 - 1; i23++) + h11[i23] = X[i23 + 1] - X[i23]; + alpha[0] = 0; + for (i23 = 1; i23 < n31 - 1; i23++) { + alpha[i23] = 3 / h11[i23] * (F[i23 + 1] - F[i23]) - 3 / h11[i23 - 1] * (F[i23] - F[i23 - 1]); + } + for (i23 = 1; i23 < n31 - 1; i23++) { + A6[i23] = []; + B5[i23] = []; + A6[i23][i23 - 1] = h11[i23 - 1]; + A6[i23][i23] = 2 * (h11[i23 - 1] + h11[i23]); + A6[i23][i23 + 1] = h11[i23]; + B5[i23][0] = alpha[i23]; + } + c12 = jStat3.multiply(jStat3.inv(A6), B5); + for (j3 = 0; j3 < n31 - 1; j3++) { + b7[j3] = (F[j3 + 1] - F[j3]) / h11[j3] - h11[j3] * (c12[j3 + 1][0] + 2 * c12[j3][0]) / 3; + d11[j3] = (c12[j3 + 1][0] - c12[j3][0]) / (3 * h11[j3]); + } + for (j3 = 0; j3 < n31; j3++) { + if (X[j3] > value) + break; + } + j3 -= 1; + return F[j3] + (value - X[j3]) * b7[j3] + jStat3.sq(value - X[j3]) * c12[j3] + (value - X[j3]) * jStat3.sq(value - X[j3]) * d11[j3]; + }, + gauss_quadrature: function gauss_quadrature() { + throw new Error("gauss_quadrature not yet implemented"); + }, + PCA: function PCA(X) { + var m6 = X.length; + var n31 = X[0].length; + var i23 = 0; + var j3, temp1; + var u11 = []; + var D5 = []; + var result = []; + var temp2 = []; + var Y = []; + var Bt = []; + var B5 = []; + var C6 = []; + var V6 = []; + var Vt = []; + for (i23 = 0; i23 < m6; i23++) { + u11[i23] = jStat3.sum(X[i23]) / n31; + } + for (i23 = 0; i23 < n31; i23++) { + B5[i23] = []; + for (j3 = 0; j3 < m6; j3++) { + B5[i23][j3] = X[j3][i23] - u11[j3]; + } + } + B5 = jStat3.transpose(B5); + for (i23 = 0; i23 < m6; i23++) { + C6[i23] = []; + for (j3 = 0; j3 < m6; j3++) { + C6[i23][j3] = jStat3.dot([B5[i23]], [B5[j3]]) / (n31 - 1); + } + } + result = jStat3.jacobi(C6); + V6 = result[0]; + D5 = result[1]; + Vt = jStat3.transpose(V6); + for (i23 = 0; i23 < D5.length; i23++) { + for (j3 = i23; j3 < D5.length; j3++) { + if (D5[i23] < D5[j3]) { + temp1 = D5[i23]; + D5[i23] = D5[j3]; + D5[j3] = temp1; + temp2 = Vt[i23]; + Vt[i23] = Vt[j3]; + Vt[j3] = temp2; + } + } + } + Bt = jStat3.transpose(B5); + for (i23 = 0; i23 < m6; i23++) { + Y[i23] = []; + for (j3 = 0; j3 < Bt.length; j3++) { + Y[i23][j3] = jStat3.dot([Vt[i23]], [Bt[j3]]); + } + } + return [X, D5, Vt, Y]; + } + }); + (function(funcs) { + for (var i23 = 0; i23 < funcs.length; i23++) + (function(passfunc) { + jStat3.fn[passfunc] = function(arg, func) { + var tmpthis = this; + if (func) { + setTimeout(function() { + func.call(tmpthis, jStat3.fn[passfunc].call(tmpthis, arg)); + }, 15); + return this; + } + if (typeof jStat3[passfunc](this, arg) === "number") + return jStat3[passfunc](this, arg); + else + return jStat3(jStat3[passfunc](this, arg)); + }; + })(funcs[i23]); + })("add divide multiply subtract dot pow exp log abs norm angle".split(" ")); + })(jStat2, Math); + (function(jStat3, Math2) { + var slice = [].slice; + var isNumber = jStat3.utils.isNumber; + var isArray = jStat3.utils.isArray; + jStat3.extend({ + // 2 different parameter lists: + // (value, mean, sd) + // (value, array, flag) + zscore: function zscore() { + var args = slice.call(arguments); + if (isNumber(args[1])) { + return (args[0] - args[1]) / args[2]; + } + return (args[0] - jStat3.mean(args[1])) / jStat3.stdev(args[1], args[2]); + }, + // 3 different paramter lists: + // (value, mean, sd, sides) + // (zscore, sides) + // (value, array, sides, flag) + ztest: function ztest() { + var args = slice.call(arguments); + var z5; + if (isArray(args[1])) { + z5 = jStat3.zscore(args[0], args[1], args[3]); + return args[2] === 1 ? jStat3.normal.cdf(-Math2.abs(z5), 0, 1) : jStat3.normal.cdf(-Math2.abs(z5), 0, 1) * 2; + } else { + if (args.length > 2) { + z5 = jStat3.zscore(args[0], args[1], args[2]); + return args[3] === 1 ? jStat3.normal.cdf(-Math2.abs(z5), 0, 1) : jStat3.normal.cdf(-Math2.abs(z5), 0, 1) * 2; + } else { + z5 = args[0]; + return args[1] === 1 ? jStat3.normal.cdf(-Math2.abs(z5), 0, 1) : jStat3.normal.cdf(-Math2.abs(z5), 0, 1) * 2; + } + } + } + }); + jStat3.extend(jStat3.fn, { + zscore: function zscore(value, flag) { + return (value - this.mean()) / this.stdev(flag); + }, + ztest: function ztest(value, sides, flag) { + var zscore = Math2.abs(this.zscore(value, flag)); + return sides === 1 ? jStat3.normal.cdf(-zscore, 0, 1) : jStat3.normal.cdf(-zscore, 0, 1) * 2; + } + }); + jStat3.extend({ + // 2 parameter lists + // (value, mean, sd, n) + // (value, array) + tscore: function tscore() { + var args = slice.call(arguments); + return args.length === 4 ? (args[0] - args[1]) / (args[2] / Math2.sqrt(args[3])) : (args[0] - jStat3.mean(args[1])) / (jStat3.stdev(args[1], true) / Math2.sqrt(args[1].length)); + }, + // 3 different paramter lists: + // (value, mean, sd, n, sides) + // (tscore, n, sides) + // (value, array, sides) + ttest: function ttest() { + var args = slice.call(arguments); + var tscore; + if (args.length === 5) { + tscore = Math2.abs(jStat3.tscore(args[0], args[1], args[2], args[3])); + return args[4] === 1 ? jStat3.studentt.cdf(-tscore, args[3] - 1) : jStat3.studentt.cdf(-tscore, args[3] - 1) * 2; + } + if (isNumber(args[1])) { + tscore = Math2.abs(args[0]); + return args[2] == 1 ? jStat3.studentt.cdf(-tscore, args[1] - 1) : jStat3.studentt.cdf(-tscore, args[1] - 1) * 2; + } + tscore = Math2.abs(jStat3.tscore(args[0], args[1])); + return args[2] == 1 ? jStat3.studentt.cdf(-tscore, args[1].length - 1) : jStat3.studentt.cdf(-tscore, args[1].length - 1) * 2; + } + }); + jStat3.extend(jStat3.fn, { + tscore: function tscore(value) { + return (value - this.mean()) / (this.stdev(true) / Math2.sqrt(this.cols())); + }, + ttest: function ttest(value, sides) { + return sides === 1 ? 1 - jStat3.studentt.cdf(Math2.abs(this.tscore(value)), this.cols() - 1) : jStat3.studentt.cdf(-Math2.abs(this.tscore(value)), this.cols() - 1) * 2; + } + }); + jStat3.extend({ + // Paramter list is as follows: + // (array1, array2, array3, ...) + // or it is an array of arrays + // array of arrays conversion + anovafscore: function anovafscore() { + var args = slice.call(arguments), expVar, sample, sampMean, sampSampMean, tmpargs, unexpVar, i23, j3; + if (args.length === 1) { + tmpargs = new Array(args[0].length); + for (i23 = 0; i23 < args[0].length; i23++) { + tmpargs[i23] = args[0][i23]; + } + args = tmpargs; + } + sample = new Array(); + for (i23 = 0; i23 < args.length; i23++) { + sample = sample.concat(args[i23]); + } + sampMean = jStat3.mean(sample); + expVar = 0; + for (i23 = 0; i23 < args.length; i23++) { + expVar = expVar + args[i23].length * Math2.pow(jStat3.mean(args[i23]) - sampMean, 2); + } + expVar /= args.length - 1; + unexpVar = 0; + for (i23 = 0; i23 < args.length; i23++) { + sampSampMean = jStat3.mean(args[i23]); + for (j3 = 0; j3 < args[i23].length; j3++) { + unexpVar += Math2.pow(args[i23][j3] - sampSampMean, 2); + } + } + unexpVar /= sample.length - args.length; + return expVar / unexpVar; + }, + // 2 different paramter setups + // (array1, array2, array3, ...) + // (anovafscore, df1, df2) + anovaftest: function anovaftest() { + var args = slice.call(arguments), df1, df2, n31, i23; + if (isNumber(args[0])) { + return 1 - jStat3.centralF.cdf(args[0], args[1], args[2]); + } + var anovafscore = jStat3.anovafscore(args); + df1 = args.length - 1; + n31 = 0; + for (i23 = 0; i23 < args.length; i23++) { + n31 = n31 + args[i23].length; + } + df2 = n31 - df1 - 1; + return 1 - jStat3.centralF.cdf(anovafscore, df1, df2); + }, + ftest: function ftest(fscore, df1, df2) { + return 1 - jStat3.centralF.cdf(fscore, df1, df2); + } + }); + jStat3.extend(jStat3.fn, { + anovafscore: function anovafscore() { + return jStat3.anovafscore(this.toArray()); + }, + anovaftes: function anovaftes() { + var n31 = 0; + var i23; + for (i23 = 0; i23 < this.length; i23++) { + n31 = n31 + this[i23].length; + } + return jStat3.ftest(this.anovafscore(), this.length - 1, n31 - this.length); + } + }); + jStat3.extend({ + // 2 parameter lists + // (mean1, mean2, n1, n2, sd) + // (array1, array2, sd) + qscore: function qscore() { + var args = slice.call(arguments); + var mean1, mean2, n1, n210, sd; + if (isNumber(args[0])) { + mean1 = args[0]; + mean2 = args[1]; + n1 = args[2]; + n210 = args[3]; + sd = args[4]; + } else { + mean1 = jStat3.mean(args[0]); + mean2 = jStat3.mean(args[1]); + n1 = args[0].length; + n210 = args[1].length; + sd = args[2]; + } + return Math2.abs(mean1 - mean2) / (sd * Math2.sqrt((1 / n1 + 1 / n210) / 2)); + }, + // 3 different parameter lists: + // (qscore, n, k) + // (mean1, mean2, n1, n2, sd, n, k) + // (array1, array2, sd, n, k) + qtest: function qtest() { + var args = slice.call(arguments); + var qscore; + if (args.length === 3) { + qscore = args[0]; + args = args.slice(1); + } else if (args.length === 7) { + qscore = jStat3.qscore(args[0], args[1], args[2], args[3], args[4]); + args = args.slice(5); + } else { + qscore = jStat3.qscore(args[0], args[1], args[2]); + args = args.slice(3); + } + var n31 = args[0]; + var k8 = args[1]; + return 1 - jStat3.tukey.cdf(qscore, k8, n31 - k8); + }, + tukeyhsd: function tukeyhsd(arrays) { + var sd = jStat3.pooledstdev(arrays); + var means = arrays.map(function(arr) { + return jStat3.mean(arr); + }); + var n31 = arrays.reduce(function(n32, arr) { + return n32 + arr.length; + }, 0); + var results = []; + for (var i23 = 0; i23 < arrays.length; ++i23) { + for (var j3 = i23 + 1; j3 < arrays.length; ++j3) { + var p7 = jStat3.qtest(means[i23], means[j3], arrays[i23].length, arrays[j3].length, sd, n31, arrays.length); + results.push([[i23, j3], p7]); + } + } + return results; + } + }); + jStat3.extend({ + // 2 different parameter setups + // (value, alpha, sd, n) + // (value, alpha, array) + normalci: function normalci() { + var args = slice.call(arguments), ans = new Array(2), change2; + if (args.length === 4) { + change2 = Math2.abs(jStat3.normal.inv(args[1] / 2, 0, 1) * args[2] / Math2.sqrt(args[3])); + } else { + change2 = Math2.abs(jStat3.normal.inv(args[1] / 2, 0, 1) * jStat3.stdev(args[2]) / Math2.sqrt(args[2].length)); + } + ans[0] = args[0] - change2; + ans[1] = args[0] + change2; + return ans; + }, + // 2 different parameter setups + // (value, alpha, sd, n) + // (value, alpha, array) + tci: function tci() { + var args = slice.call(arguments), ans = new Array(2), change2; + if (args.length === 4) { + change2 = Math2.abs(jStat3.studentt.inv(args[1] / 2, args[3] - 1) * args[2] / Math2.sqrt(args[3])); + } else { + change2 = Math2.abs(jStat3.studentt.inv(args[1] / 2, args[2].length - 1) * jStat3.stdev(args[2], true) / Math2.sqrt(args[2].length)); + } + ans[0] = args[0] - change2; + ans[1] = args[0] + change2; + return ans; + }, + significant: function significant(pvalue, alpha) { + return pvalue < alpha; + } + }); + jStat3.extend(jStat3.fn, { + normalci: function normalci(value, alpha) { + return jStat3.normalci(value, alpha, this.toArray()); + }, + tci: function tci(value, alpha) { + return jStat3.tci(value, alpha, this.toArray()); + } + }); + function differenceOfProportions(p1, n1, p22, n210) { + if (p1 > 1 || p22 > 1 || p1 <= 0 || p22 <= 0) { + throw new Error("Proportions should be greater than 0 and less than 1"); + } + var pooled = (p1 * n1 + p22 * n210) / (n1 + n210); + var se = Math2.sqrt(pooled * (1 - pooled) * (1 / n1 + 1 / n210)); + return (p1 - p22) / se; + } + jStat3.extend(jStat3.fn, { + oneSidedDifferenceOfProportions: function oneSidedDifferenceOfProportions(p1, n1, p22, n210) { + var z5 = differenceOfProportions(p1, n1, p22, n210); + return jStat3.ztest(z5, 1); + }, + twoSidedDifferenceOfProportions: function twoSidedDifferenceOfProportions(p1, n1, p22, n210) { + var z5 = differenceOfProportions(p1, n1, p22, n210); + return jStat3.ztest(z5, 2); + } + }); + })(jStat2, Math); + jStat2.models = /* @__PURE__ */ function() { + function sub_regress(exog) { + var var_count = exog[0].length; + var modelList = jStat2.arange(var_count).map(function(endog_index) { + var exog_index = jStat2.arange(var_count).filter(function(i23) { + return i23 !== endog_index; + }); + return ols( + jStat2.col(exog, endog_index).map(function(x6) { + return x6[0]; + }), + jStat2.col(exog, exog_index) + ); + }); + return modelList; + } + function ols(endog, exog) { + var nobs = endog.length; + var df_model = exog[0].length - 1; + var df_resid = nobs - df_model - 1; + var coef = jStat2.lstsq(exog, endog); + var predict = jStat2.multiply(exog, coef.map(function(x6) { + return [x6]; + })).map(function(p7) { + return p7[0]; + }); + var resid = jStat2.subtract(endog, predict); + var ybar = jStat2.mean(endog); + var SSE = jStat2.sum(predict.map(function(f7) { + return Math.pow(f7 - ybar, 2); + })); + var SSR = jStat2.sum(endog.map(function(y7, i23) { + return Math.pow(y7 - predict[i23], 2); + })); + var SST = SSE + SSR; + var R22 = SSE / SST; + return { + exog, + endog, + nobs, + df_model, + df_resid, + coef, + predict, + resid, + ybar, + SST, + SSE, + SSR, + R2: R22 + }; + } + function t_test(model) { + var subModelList = sub_regress(model.exog); + var sigmaHat = Math.sqrt(model.SSR / model.df_resid); + var seBetaHat = subModelList.map(function(mod) { + var SST = mod.SST; + var R22 = mod.R2; + return sigmaHat / Math.sqrt(SST * (1 - R22)); + }); + var tStatistic = model.coef.map(function(coef, i23) { + return (coef - 0) / seBetaHat[i23]; + }); + var pValue = tStatistic.map(function(t17) { + var leftppf = jStat2.studentt.cdf(t17, model.df_resid); + return (leftppf > 0.5 ? 1 - leftppf : leftppf) * 2; + }); + var c12 = jStat2.studentt.inv(0.975, model.df_resid); + var interval95 = model.coef.map(function(coef, i23) { + var d11 = c12 * seBetaHat[i23]; + return [coef - d11, coef + d11]; + }); + return { + se: seBetaHat, + t: tStatistic, + p: pValue, + sigmaHat, + interval95 + }; + } + function F_test(model) { + var F_statistic = model.R2 / model.df_model / ((1 - model.R2) / model.df_resid); + var fcdf = function(x6, n1, n210) { + return jStat2.beta.cdf(x6 / (n210 / n1 + x6), n1 / 2, n210 / 2); + }; + var pvalue = 1 - fcdf(F_statistic, model.df_model, model.df_resid); + return { F_statistic, pvalue }; + } + function ols_wrap(endog, exog) { + var model = ols(endog, exog); + var ttest = t_test(model); + var ftest = F_test(model); + var adjust_R2 = 1 - (1 - model.R2) * ((model.nobs - 1) / model.df_resid); + model.t = ttest; + model.f = ftest; + model.adjust_R2 = adjust_R2; + return model; + } + return { ols: ols_wrap }; + }(); + jStat2.extend({ + buildxmatrix: function buildxmatrix() { + var matrixRows = new Array(arguments.length); + for (var i23 = 0; i23 < arguments.length; i23++) { + var array2 = [1]; + matrixRows[i23] = array2.concat(arguments[i23]); + } + return jStat2(matrixRows); + }, + builddxmatrix: function builddxmatrix() { + var matrixRows = new Array(arguments[0].length); + for (var i23 = 0; i23 < arguments[0].length; i23++) { + var array2 = [1]; + matrixRows[i23] = array2.concat(arguments[0][i23]); + } + return jStat2(matrixRows); + }, + buildjxmatrix: function buildjxmatrix(jMat) { + var pass = new Array(jMat.length); + for (var i23 = 0; i23 < jMat.length; i23++) { + pass[i23] = jMat[i23]; + } + return jStat2.builddxmatrix(pass); + }, + buildymatrix: function buildymatrix(array2) { + return jStat2(array2).transpose(); + }, + buildjymatrix: function buildjymatrix(jMat) { + return jMat.transpose(); + }, + matrixmult: function matrixmult(A6, B5) { + var i23, j3, k8, result, sum; + if (A6.cols() == B5.rows()) { + if (B5.rows() > 1) { + result = []; + for (i23 = 0; i23 < A6.rows(); i23++) { + result[i23] = []; + for (j3 = 0; j3 < B5.cols(); j3++) { + sum = 0; + for (k8 = 0; k8 < A6.cols(); k8++) { + sum += A6.toArray()[i23][k8] * B5.toArray()[k8][j3]; + } + result[i23][j3] = sum; + } + } + return jStat2(result); + } + result = []; + for (i23 = 0; i23 < A6.rows(); i23++) { + result[i23] = []; + for (j3 = 0; j3 < B5.cols(); j3++) { + sum = 0; + for (k8 = 0; k8 < A6.cols(); k8++) { + sum += A6.toArray()[i23][k8] * B5.toArray()[j3]; + } + result[i23][j3] = sum; + } + } + return jStat2(result); + } + }, + //regress and regresst to be fixed + regress: function regress(jMatX, jMatY) { + var innerinv = jStat2.xtranspxinv(jMatX); + var xtransp = jMatX.transpose(); + var next = jStat2.matrixmult(jStat2(innerinv), xtransp); + return jStat2.matrixmult(next, jMatY); + }, + regresst: function regresst(jMatX, jMatY, sides) { + var beta = jStat2.regress(jMatX, jMatY); + var compile = {}; + compile.anova = {}; + var jMatYBar = jStat2.jMatYBar(jMatX, beta); + compile.yBar = jMatYBar; + var yAverage = jMatY.mean(); + compile.anova.residuals = jStat2.residuals(jMatY, jMatYBar); + compile.anova.ssr = jStat2.ssr(jMatYBar, yAverage); + compile.anova.msr = compile.anova.ssr / (jMatX[0].length - 1); + compile.anova.sse = jStat2.sse(jMatY, jMatYBar); + compile.anova.mse = compile.anova.sse / (jMatY.length - (jMatX[0].length - 1) - 1); + compile.anova.sst = jStat2.sst(jMatY, yAverage); + compile.anova.mst = compile.anova.sst / (jMatY.length - 1); + compile.anova.r2 = 1 - compile.anova.sse / compile.anova.sst; + if (compile.anova.r2 < 0) + compile.anova.r2 = 0; + compile.anova.fratio = compile.anova.msr / compile.anova.mse; + compile.anova.pvalue = jStat2.anovaftest( + compile.anova.fratio, + jMatX[0].length - 1, + jMatY.length - (jMatX[0].length - 1) - 1 + ); + compile.anova.rmse = Math.sqrt(compile.anova.mse); + compile.anova.r2adj = 1 - compile.anova.mse / compile.anova.mst; + if (compile.anova.r2adj < 0) + compile.anova.r2adj = 0; + compile.stats = new Array(jMatX[0].length); + var covar = jStat2.xtranspxinv(jMatX); + var sds, ts, ps; + for (var i23 = 0; i23 < beta.length; i23++) { + sds = Math.sqrt(compile.anova.mse * Math.abs(covar[i23][i23])); + ts = Math.abs(beta[i23] / sds); + ps = jStat2.ttest(ts, jMatY.length - jMatX[0].length - 1, sides); + compile.stats[i23] = [beta[i23], sds, ts, ps]; + } + compile.regress = beta; + return compile; + }, + xtranspx: function xtranspx(jMatX) { + return jStat2.matrixmult(jMatX.transpose(), jMatX); + }, + xtranspxinv: function xtranspxinv(jMatX) { + var inner = jStat2.matrixmult(jMatX.transpose(), jMatX); + var innerinv = jStat2.inv(inner); + return innerinv; + }, + jMatYBar: function jMatYBar(jMatX, beta) { + var yBar = jStat2.matrixmult(jMatX, beta); + return new jStat2(yBar); + }, + residuals: function residuals(jMatY, jMatYBar) { + return jStat2.matrixsubtract(jMatY, jMatYBar); + }, + ssr: function ssr(jMatYBar, yAverage) { + var ssr2 = 0; + for (var i23 = 0; i23 < jMatYBar.length; i23++) { + ssr2 += Math.pow(jMatYBar[i23] - yAverage, 2); + } + return ssr2; + }, + sse: function sse(jMatY, jMatYBar) { + var sse2 = 0; + for (var i23 = 0; i23 < jMatY.length; i23++) { + sse2 += Math.pow(jMatY[i23] - jMatYBar[i23], 2); + } + return sse2; + }, + sst: function sst(jMatY, yAverage) { + var sst2 = 0; + for (var i23 = 0; i23 < jMatY.length; i23++) { + sst2 += Math.pow(jMatY[i23] - yAverage, 2); + } + return sst2; + }, + matrixsubtract: function matrixsubtract(A6, B5) { + var ans = new Array(A6.length); + for (var i23 = 0; i23 < A6.length; i23++) { + ans[i23] = new Array(A6[i23].length); + for (var j3 = 0; j3 < A6[i23].length; j3++) { + ans[i23][j3] = A6[i23][j3] - B5[i23][j3]; + } + } + return jStat2(ans); + } + }); + jStat2.jStat = jStat2; + return jStat2; + }); + } + }); + + // node_modules/@adobe/lit-mobx/lib/mixin-custom.js + var reaction = Symbol("LitMobxRenderReaction"); + var cachedRequestUpdate = Symbol("LitMobxRequestUpdate"); + function MobxReactionUpdateCustom(constructor, ReactionConstructor) { + var _a2, _b2; + return _b2 = class MobxReactingElement extends constructor { + constructor() { + super(...arguments); + this[_a2] = () => { + this.requestUpdate(); + }; + } + connectedCallback() { + super.connectedCallback(); + const name = this.constructor.name || this.nodeName; + this[reaction] = new ReactionConstructor(`${name}.update()`, this[cachedRequestUpdate]); + if (this.hasUpdated) + this.requestUpdate(); + } + disconnectedCallback() { + super.disconnectedCallback(); + if (this[reaction]) { + this[reaction].dispose(); + this[reaction] = void 0; + } + } + update(changedProperties) { + if (this[reaction]) { + this[reaction].track(super.update.bind(this, changedProperties)); + } else { + super.update(changedProperties); + } + } + }, _a2 = cachedRequestUpdate, _b2; + } + + // node_modules/mobx/dist/mobx.esm.js + var niceErrors = { + 0: "Invalid value for configuration 'enforceActions', expected 'never', 'always' or 'observed'", + 1: function _(annotationType, key) { + return "Cannot apply '" + annotationType + "' to '" + key.toString() + "': Field not found."; + }, + /* + 2(prop) { + return `invalid decorator for '${prop.toString()}'` + }, + 3(prop) { + return `Cannot decorate '${prop.toString()}': action can only be used on properties with a function value.` + }, + 4(prop) { + return `Cannot decorate '${prop.toString()}': computed can only be used on getter properties.` + }, + */ + 5: "'keys()' can only be used on observable objects, arrays, sets and maps", + 6: "'values()' can only be used on observable objects, arrays, sets and maps", + 7: "'entries()' can only be used on observable objects, arrays and maps", + 8: "'set()' can only be used on observable objects, arrays and maps", + 9: "'remove()' can only be used on observable objects, arrays and maps", + 10: "'has()' can only be used on observable objects, arrays and maps", + 11: "'get()' can only be used on observable objects, arrays and maps", + 12: "Invalid annotation", + 13: "Dynamic observable objects cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)", + 14: "Intercept handlers should return nothing or a change object", + 15: "Observable arrays cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)", + 16: "Modification exception: the internal structure of an observable array was changed.", + 17: function _2(index, length) { + return "[mobx.array] Index out of bounds, " + index + " is larger than " + length; + }, + 18: "mobx.map requires Map polyfill for the current browser. Check babel-polyfill or core-js/es6/map.js", + 19: function _3(other) { + return "Cannot initialize from classes that inherit from Map: " + other.constructor.name; + }, + 20: function _4(other) { + return "Cannot initialize map from " + other; + }, + 21: function _5(dataStructure) { + return "Cannot convert to map from '" + dataStructure + "'"; + }, + 22: "mobx.set requires Set polyfill for the current browser. Check babel-polyfill or core-js/es6/set.js", + 23: "It is not possible to get index atoms from arrays", + 24: function _6(thing) { + return "Cannot obtain administration from " + thing; + }, + 25: function _7(property, name) { + return "the entry '" + property + "' does not exist in the observable map '" + name + "'"; + }, + 26: "please specify a property", + 27: function _8(property, name) { + return "no observable property '" + property.toString() + "' found on the observable object '" + name + "'"; + }, + 28: function _9(thing) { + return "Cannot obtain atom from " + thing; + }, + 29: "Expecting some object", + 30: "invalid action stack. did you forget to finish an action?", + 31: "missing option for computed: get", + 32: function _10(name, derivation) { + return "Cycle detected in computation " + name + ": " + derivation; + }, + 33: function _11(name) { + return "The setter of computed value '" + name + "' is trying to update itself. Did you intend to update an _observable_ value, instead of the computed property?"; + }, + 34: function _12(name) { + return "[ComputedValue '" + name + "'] It is not possible to assign a new value to a computed value."; + }, + 35: "There are multiple, different versions of MobX active. Make sure MobX is loaded only once or use `configure({ isolateGlobalState: true })`", + 36: "isolateGlobalState should be called before MobX is running any reactions", + 37: function _13(method) { + return "[mobx] `observableArray." + method + "()` mutates the array in-place, which is not allowed inside a derivation. Use `array.slice()." + method + "()` instead"; + }, + 38: "'ownKeys()' can only be used on observable objects", + 39: "'defineProperty()' can only be used on observable objects" + }; + var errors = true ? niceErrors : {}; + function die(error) { + for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + if (true) { + var e33 = typeof error === "string" ? error : errors[error]; + if (typeof e33 === "function") + e33 = e33.apply(null, args); + throw new Error("[MobX] " + e33); + } + throw new Error(typeof error === "number" ? "[MobX] minified error nr: " + error + (args.length ? " " + args.map(String).join(",") : "") + ". Find the full error at: https://github.com/mobxjs/mobx/blob/main/packages/mobx/src/errors.ts" : "[MobX] " + error); + } + var mockGlobal = {}; + function getGlobal() { + if (typeof globalThis !== "undefined") { + return globalThis; + } + if (typeof window !== "undefined") { + return window; + } + if (typeof global !== "undefined") { + return global; + } + if (typeof self !== "undefined") { + return self; + } + return mockGlobal; + } + var assign = Object.assign; + var getDescriptor = Object.getOwnPropertyDescriptor; + var defineProperty = Object.defineProperty; + var objectPrototype = Object.prototype; + var EMPTY_ARRAY = []; + Object.freeze(EMPTY_ARRAY); + var EMPTY_OBJECT = {}; + Object.freeze(EMPTY_OBJECT); + var hasProxy = typeof Proxy !== "undefined"; + var plainObjectString = /* @__PURE__ */ Object.toString(); + function assertProxies() { + if (!hasProxy) { + die(true ? "`Proxy` objects are not available in the current environment. Please configure MobX to enable a fallback implementation.`" : "Proxy not available"); + } + } + function warnAboutProxyRequirement(msg) { + if (globalState.verifyProxies) { + die("MobX is currently configured to be able to run in ES5 mode, but in ES5 MobX won't be able to " + msg); + } + } + function getNextId() { + return ++globalState.mobxGuid; + } + function once(func) { + var invoked = false; + return function() { + if (invoked) { + return; + } + invoked = true; + return func.apply(this, arguments); + }; + } + var noop = function noop2() { + }; + function isFunction(fn2) { + return typeof fn2 === "function"; + } + function isStringish(value) { + var t17 = typeof value; + switch (t17) { + case "string": + case "symbol": + case "number": + return true; + } + return false; + } + function isObject(value) { + return value !== null && typeof value === "object"; + } + function isPlainObject(value) { + if (!isObject(value)) { + return false; + } + var proto = Object.getPrototypeOf(value); + if (proto == null) { + return true; + } + var protoConstructor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor; + return typeof protoConstructor === "function" && protoConstructor.toString() === plainObjectString; + } + function isGenerator(obj) { + var constructor = obj == null ? void 0 : obj.constructor; + if (!constructor) { + return false; + } + if ("GeneratorFunction" === constructor.name || "GeneratorFunction" === constructor.displayName) { + return true; + } + return false; + } + function addHiddenProp(object2, propName, value) { + defineProperty(object2, propName, { + enumerable: false, + writable: true, + configurable: true, + value + }); + } + function addHiddenFinalProp(object2, propName, value) { + defineProperty(object2, propName, { + enumerable: false, + writable: false, + configurable: true, + value + }); + } + function createInstanceofPredicate(name, theClass) { + var propName = "isMobX" + name; + theClass.prototype[propName] = true; + return function(x6) { + return isObject(x6) && x6[propName] === true; + }; + } + function isES6Map(thing) { + return thing instanceof Map; + } + function isES6Set(thing) { + return thing instanceof Set; + } + var hasGetOwnPropertySymbols = typeof Object.getOwnPropertySymbols !== "undefined"; + function getPlainObjectKeys(object2) { + var keys = Object.keys(object2); + if (!hasGetOwnPropertySymbols) { + return keys; + } + var symbols = Object.getOwnPropertySymbols(object2); + if (!symbols.length) { + return keys; + } + return [].concat(keys, symbols.filter(function(s20) { + return objectPrototype.propertyIsEnumerable.call(object2, s20); + })); + } + var ownKeys = typeof Reflect !== "undefined" && Reflect.ownKeys ? Reflect.ownKeys : hasGetOwnPropertySymbols ? function(obj) { + return Object.getOwnPropertyNames(obj).concat(Object.getOwnPropertySymbols(obj)); + } : ( + /* istanbul ignore next */ + Object.getOwnPropertyNames + ); + function stringifyKey(key) { + if (typeof key === "string") { + return key; + } + if (typeof key === "symbol") { + return key.toString(); + } + return new String(key).toString(); + } + function toPrimitive(value) { + return value === null ? null : typeof value === "object" ? "" + value : value; + } + function hasProp(target, prop) { + return objectPrototype.hasOwnProperty.call(target, prop); + } + var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || function getOwnPropertyDescriptors2(target) { + var res = {}; + ownKeys(target).forEach(function(key) { + res[key] = getDescriptor(target, key); + }); + return res; + }; + function _defineProperties(target, props) { + for (var i23 = 0; i23 < props.length; i23++) { + var descriptor = props[i23]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) + descriptor.writable = true; + Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); + } + } + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) + _defineProperties(Constructor.prototype, protoProps); + if (staticProps) + _defineProperties(Constructor, staticProps); + Object.defineProperty(Constructor, "prototype", { + writable: false + }); + return Constructor; + } + function _extends() { + _extends = Object.assign ? Object.assign.bind() : function(target) { + for (var i23 = 1; i23 < arguments.length; i23++) { + var source = arguments[i23]; + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + return target; + }; + return _extends.apply(this, arguments); + } + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + _setPrototypeOf(subClass, superClass); + } + function _setPrototypeOf(o29, p7) { + _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf2(o30, p8) { + o30.__proto__ = p8; + return o30; + }; + return _setPrototypeOf(o29, p7); + } + function _assertThisInitialized(self2) { + if (self2 === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + return self2; + } + function _unsupportedIterableToArray(o29, minLen) { + if (!o29) + return; + if (typeof o29 === "string") + return _arrayLikeToArray(o29, minLen); + var n31 = Object.prototype.toString.call(o29).slice(8, -1); + if (n31 === "Object" && o29.constructor) + n31 = o29.constructor.name; + if (n31 === "Map" || n31 === "Set") + return Array.from(o29); + if (n31 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n31)) + return _arrayLikeToArray(o29, minLen); + } + function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) + len = arr.length; + for (var i23 = 0, arr2 = new Array(len); i23 < len; i23++) + arr2[i23] = arr[i23]; + return arr2; + } + function _createForOfIteratorHelperLoose(o29, allowArrayLike) { + var it = typeof Symbol !== "undefined" && o29[Symbol.iterator] || o29["@@iterator"]; + if (it) + return (it = it.call(o29)).next.bind(it); + if (Array.isArray(o29) || (it = _unsupportedIterableToArray(o29)) || allowArrayLike && o29 && typeof o29.length === "number") { + if (it) + o29 = it; + var i23 = 0; + return function() { + if (i23 >= o29.length) + return { + done: true + }; + return { + done: false, + value: o29[i23++] + }; + }; + } + throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + function _toPrimitive(input, hint) { + if (typeof input !== "object" || input === null) + return input; + var prim = input[Symbol.toPrimitive]; + if (prim !== void 0) { + var res = prim.call(input, hint || "default"); + if (typeof res !== "object") + return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + return (hint === "string" ? String : Number)(input); + } + function _toPropertyKey(arg) { + var key = _toPrimitive(arg, "string"); + return typeof key === "symbol" ? key : String(key); + } + var storedAnnotationsSymbol = /* @__PURE__ */ Symbol("mobx-stored-annotations"); + function createDecoratorAnnotation(annotation) { + function decorator(target, property) { + if (is20223Decorator(property)) { + return annotation.decorate_20223_(target, property); + } else { + storeAnnotation(target, property, annotation); + } + } + return Object.assign(decorator, annotation); + } + function storeAnnotation(prototype, key, annotation) { + if (!hasProp(prototype, storedAnnotationsSymbol)) { + addHiddenProp(prototype, storedAnnotationsSymbol, _extends({}, prototype[storedAnnotationsSymbol])); + } + if (isOverride(annotation) && !hasProp(prototype[storedAnnotationsSymbol], key)) { + var fieldName = prototype.constructor.name + ".prototype." + key.toString(); + die("'" + fieldName + "' is decorated with 'override', but no such decorated member was found on prototype."); + } + assertNotDecorated(prototype, annotation, key); + if (!isOverride(annotation)) { + prototype[storedAnnotationsSymbol][key] = annotation; + } + } + function assertNotDecorated(prototype, annotation, key) { + if (!isOverride(annotation) && hasProp(prototype[storedAnnotationsSymbol], key)) { + var fieldName = prototype.constructor.name + ".prototype." + key.toString(); + var currentAnnotationType = prototype[storedAnnotationsSymbol][key].annotationType_; + var requestedAnnotationType = annotation.annotationType_; + die("Cannot apply '@" + requestedAnnotationType + "' to '" + fieldName + "':" + ("\nThe field is already decorated with '@" + currentAnnotationType + "'.") + "\nRe-decorating fields is not allowed.\nUse '@override' decorator for methods overridden by subclass."); + } + } + function collectStoredAnnotations(target) { + if (!hasProp(target, storedAnnotationsSymbol)) { + addHiddenProp(target, storedAnnotationsSymbol, _extends({}, target[storedAnnotationsSymbol])); + } + return target[storedAnnotationsSymbol]; + } + function is20223Decorator(context) { + return typeof context == "object" && typeof context["kind"] == "string"; + } + function assert20223DecoratorType(context, types) { + if (!types.includes(context.kind)) { + die("The decorator applied to '" + String(context.name) + "' cannot be used on a " + context.kind + " element"); + } + } + var $mobx = /* @__PURE__ */ Symbol("mobx administration"); + var Atom = /* @__PURE__ */ function() { + function Atom2(name_) { + if (name_ === void 0) { + name_ = true ? "Atom@" + getNextId() : "Atom"; + } + this.name_ = void 0; + this.isPendingUnobservation_ = false; + this.isBeingObserved_ = false; + this.observers_ = /* @__PURE__ */ new Set(); + this.diffValue_ = 0; + this.lastAccessedBy_ = 0; + this.lowestObserverState_ = IDerivationState_.NOT_TRACKING_; + this.onBOL = void 0; + this.onBUOL = void 0; + this.name_ = name_; + } + var _proto = Atom2.prototype; + _proto.onBO = function onBO() { + if (this.onBOL) { + this.onBOL.forEach(function(listener) { + return listener(); + }); + } + }; + _proto.onBUO = function onBUO() { + if (this.onBUOL) { + this.onBUOL.forEach(function(listener) { + return listener(); + }); + } + }; + _proto.reportObserved = function reportObserved$1() { + return reportObserved(this); + }; + _proto.reportChanged = function reportChanged() { + startBatch(); + propagateChanged(this); + endBatch(); + }; + _proto.toString = function toString2() { + return this.name_; + }; + return Atom2; + }(); + var isAtom = /* @__PURE__ */ createInstanceofPredicate("Atom", Atom); + function createAtom(name, onBecomeObservedHandler, onBecomeUnobservedHandler) { + if (onBecomeObservedHandler === void 0) { + onBecomeObservedHandler = noop; + } + if (onBecomeUnobservedHandler === void 0) { + onBecomeUnobservedHandler = noop; + } + var atom = new Atom(name); + if (onBecomeObservedHandler !== noop) { + onBecomeObserved(atom, onBecomeObservedHandler); + } + if (onBecomeUnobservedHandler !== noop) { + onBecomeUnobserved(atom, onBecomeUnobservedHandler); + } + return atom; + } + function identityComparer(a11, b7) { + return a11 === b7; + } + function structuralComparer(a11, b7) { + return deepEqual(a11, b7); + } + function shallowComparer(a11, b7) { + return deepEqual(a11, b7, 1); + } + function defaultComparer(a11, b7) { + if (Object.is) { + return Object.is(a11, b7); + } + return a11 === b7 ? a11 !== 0 || 1 / a11 === 1 / b7 : a11 !== a11 && b7 !== b7; + } + var comparer = { + identity: identityComparer, + structural: structuralComparer, + "default": defaultComparer, + shallow: shallowComparer + }; + function deepEnhancer(v6, _19, name) { + if (isObservable(v6)) { + return v6; + } + if (Array.isArray(v6)) { + return observable.array(v6, { + name + }); + } + if (isPlainObject(v6)) { + return observable.object(v6, void 0, { + name + }); + } + if (isES6Map(v6)) { + return observable.map(v6, { + name + }); + } + if (isES6Set(v6)) { + return observable.set(v6, { + name + }); + } + if (typeof v6 === "function" && !isAction(v6) && !isFlow(v6)) { + if (isGenerator(v6)) { + return flow(v6); + } else { + return autoAction(name, v6); + } + } + return v6; + } + function shallowEnhancer(v6, _19, name) { + if (v6 === void 0 || v6 === null) { + return v6; + } + if (isObservableObject(v6) || isObservableArray(v6) || isObservableMap(v6) || isObservableSet(v6)) { + return v6; + } + if (Array.isArray(v6)) { + return observable.array(v6, { + name, + deep: false + }); + } + if (isPlainObject(v6)) { + return observable.object(v6, void 0, { + name, + deep: false + }); + } + if (isES6Map(v6)) { + return observable.map(v6, { + name, + deep: false + }); + } + if (isES6Set(v6)) { + return observable.set(v6, { + name, + deep: false + }); + } + if (true) { + die("The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets"); + } + } + function referenceEnhancer(newValue) { + return newValue; + } + function refStructEnhancer(v6, oldValue) { + if (isObservable(v6)) { + die("observable.struct should not be used with observable values"); + } + if (deepEqual(v6, oldValue)) { + return oldValue; + } + return v6; + } + var OVERRIDE = "override"; + function isOverride(annotation) { + return annotation.annotationType_ === OVERRIDE; + } + function createActionAnnotation(name, options) { + return { + annotationType_: name, + options_: options, + make_: make_$1, + extend_: extend_$1, + decorate_20223_: decorate_20223_$1 + }; + } + function make_$1(adm, key, descriptor, source) { + var _this$options_; + if ((_this$options_ = this.options_) != null && _this$options_.bound) { + return this.extend_(adm, key, descriptor, false) === null ? 0 : 1; + } + if (source === adm.target_) { + return this.extend_(adm, key, descriptor, false) === null ? 0 : 2; + } + if (isAction(descriptor.value)) { + return 1; + } + var actionDescriptor = createActionDescriptor(adm, this, key, descriptor, false); + defineProperty(source, key, actionDescriptor); + return 2; + } + function extend_$1(adm, key, descriptor, proxyTrap) { + var actionDescriptor = createActionDescriptor(adm, this, key, descriptor); + return adm.defineProperty_(key, actionDescriptor, proxyTrap); + } + function decorate_20223_$1(mthd, context) { + if (true) { + assert20223DecoratorType(context, ["method", "field"]); + } + var kind = context.kind, name = context.name, addInitializer = context.addInitializer; + var ann = this; + var _createAction = function _createAction2(m6) { + var _ann$options_$name, _ann$options_, _ann$options_$autoAct, _ann$options_2; + return createAction((_ann$options_$name = (_ann$options_ = ann.options_) == null ? void 0 : _ann$options_.name) != null ? _ann$options_$name : name.toString(), m6, (_ann$options_$autoAct = (_ann$options_2 = ann.options_) == null ? void 0 : _ann$options_2.autoAction) != null ? _ann$options_$autoAct : false); + }; + if (kind == "field") { + addInitializer(function() { + storeAnnotation(this, name, ann); + }); + return; + } + if (kind == "method") { + var _this$options_2; + if (!isAction(mthd)) { + mthd = _createAction(mthd); + } + if ((_this$options_2 = this.options_) != null && _this$options_2.bound) { + addInitializer(function() { + var self2 = this; + var bound = self2[name].bind(self2); + bound.isMobxAction = true; + self2[name] = bound; + }); + } + return mthd; + } + die("Cannot apply '" + ann.annotationType_ + "' to '" + String(name) + "' (kind: " + kind + "):" + ("\n'" + ann.annotationType_ + "' can only be used on properties with a function value.")); + } + function assertActionDescriptor(adm, _ref, key, _ref2) { + var annotationType_ = _ref.annotationType_; + var value = _ref2.value; + if (!isFunction(value)) { + die("Cannot apply '" + annotationType_ + "' to '" + adm.name_ + "." + key.toString() + "':" + ("\n'" + annotationType_ + "' can only be used on properties with a function value.")); + } + } + function createActionDescriptor(adm, annotation, key, descriptor, safeDescriptors) { + var _annotation$options_, _annotation$options_$, _annotation$options_2, _annotation$options_$2, _annotation$options_3, _annotation$options_4, _adm$proxy_2; + if (safeDescriptors === void 0) { + safeDescriptors = globalState.safeDescriptors; + } + assertActionDescriptor(adm, annotation, key, descriptor); + var value = descriptor.value; + if ((_annotation$options_ = annotation.options_) != null && _annotation$options_.bound) { + var _adm$proxy_; + value = value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_); + } + return { + value: createAction( + (_annotation$options_$ = (_annotation$options_2 = annotation.options_) == null ? void 0 : _annotation$options_2.name) != null ? _annotation$options_$ : key.toString(), + value, + (_annotation$options_$2 = (_annotation$options_3 = annotation.options_) == null ? void 0 : _annotation$options_3.autoAction) != null ? _annotation$options_$2 : false, + // https://github.com/mobxjs/mobx/discussions/3140 + (_annotation$options_4 = annotation.options_) != null && _annotation$options_4.bound ? (_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_ : void 0 + ), + // Non-configurable for classes + // prevents accidental field redefinition in subclass + configurable: safeDescriptors ? adm.isPlainObject_ : true, + // https://github.com/mobxjs/mobx/pull/2641#issuecomment-737292058 + enumerable: false, + // Non-obsevable, therefore non-writable + // Also prevents rewriting in subclass constructor + writable: safeDescriptors ? false : true + }; + } + function createFlowAnnotation(name, options) { + return { + annotationType_: name, + options_: options, + make_: make_$2, + extend_: extend_$2, + decorate_20223_: decorate_20223_$2 + }; + } + function make_$2(adm, key, descriptor, source) { + var _this$options_; + if (source === adm.target_) { + return this.extend_(adm, key, descriptor, false) === null ? 0 : 2; + } + if ((_this$options_ = this.options_) != null && _this$options_.bound && (!hasProp(adm.target_, key) || !isFlow(adm.target_[key]))) { + if (this.extend_(adm, key, descriptor, false) === null) { + return 0; + } + } + if (isFlow(descriptor.value)) { + return 1; + } + var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, false, false); + defineProperty(source, key, flowDescriptor); + return 2; + } + function extend_$2(adm, key, descriptor, proxyTrap) { + var _this$options_2; + var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, (_this$options_2 = this.options_) == null ? void 0 : _this$options_2.bound); + return adm.defineProperty_(key, flowDescriptor, proxyTrap); + } + function decorate_20223_$2(mthd, context) { + var _this$options_3; + if (true) { + assert20223DecoratorType(context, ["method"]); + } + var name = context.name, addInitializer = context.addInitializer; + if (!isFlow(mthd)) { + mthd = flow(mthd); + } + if ((_this$options_3 = this.options_) != null && _this$options_3.bound) { + addInitializer(function() { + var self2 = this; + var bound = self2[name].bind(self2); + bound.isMobXFlow = true; + self2[name] = bound; + }); + } + return mthd; + } + function assertFlowDescriptor(adm, _ref, key, _ref2) { + var annotationType_ = _ref.annotationType_; + var value = _ref2.value; + if (!isFunction(value)) { + die("Cannot apply '" + annotationType_ + "' to '" + adm.name_ + "." + key.toString() + "':" + ("\n'" + annotationType_ + "' can only be used on properties with a generator function value.")); + } + } + function createFlowDescriptor(adm, annotation, key, descriptor, bound, safeDescriptors) { + if (safeDescriptors === void 0) { + safeDescriptors = globalState.safeDescriptors; + } + assertFlowDescriptor(adm, annotation, key, descriptor); + var value = descriptor.value; + if (!isFlow(value)) { + value = flow(value); + } + if (bound) { + var _adm$proxy_; + value = value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_); + value.isMobXFlow = true; + } + return { + value, + // Non-configurable for classes + // prevents accidental field redefinition in subclass + configurable: safeDescriptors ? adm.isPlainObject_ : true, + // https://github.com/mobxjs/mobx/pull/2641#issuecomment-737292058 + enumerable: false, + // Non-obsevable, therefore non-writable + // Also prevents rewriting in subclass constructor + writable: safeDescriptors ? false : true + }; + } + function createComputedAnnotation(name, options) { + return { + annotationType_: name, + options_: options, + make_: make_$3, + extend_: extend_$3, + decorate_20223_: decorate_20223_$3 + }; + } + function make_$3(adm, key, descriptor) { + return this.extend_(adm, key, descriptor, false) === null ? 0 : 1; + } + function extend_$3(adm, key, descriptor, proxyTrap) { + assertComputedDescriptor(adm, this, key, descriptor); + return adm.defineComputedProperty_(key, _extends({}, this.options_, { + get: descriptor.get, + set: descriptor.set + }), proxyTrap); + } + function decorate_20223_$3(get3, context) { + if (true) { + assert20223DecoratorType(context, ["getter"]); + } + var ann = this; + var key = context.name, addInitializer = context.addInitializer; + addInitializer(function() { + var adm = asObservableObject(this)[$mobx]; + var options = _extends({}, ann.options_, { + get: get3, + context: this + }); + options.name || (options.name = true ? adm.name_ + "." + key.toString() : "ObservableObject." + key.toString()); + adm.values_.set(key, new ComputedValue(options)); + }); + return function() { + return this[$mobx].getObservablePropValue_(key); + }; + } + function assertComputedDescriptor(adm, _ref, key, _ref2) { + var annotationType_ = _ref.annotationType_; + var get3 = _ref2.get; + if (!get3) { + die("Cannot apply '" + annotationType_ + "' to '" + adm.name_ + "." + key.toString() + "':" + ("\n'" + annotationType_ + "' can only be used on getter(+setter) properties.")); + } + } + function createObservableAnnotation(name, options) { + return { + annotationType_: name, + options_: options, + make_: make_$4, + extend_: extend_$4, + decorate_20223_: decorate_20223_$4 + }; + } + function make_$4(adm, key, descriptor) { + return this.extend_(adm, key, descriptor, false) === null ? 0 : 1; + } + function extend_$4(adm, key, descriptor, proxyTrap) { + var _this$options_$enhanc, _this$options_; + assertObservableDescriptor(adm, this, key, descriptor); + return adm.defineObservableProperty_(key, descriptor.value, (_this$options_$enhanc = (_this$options_ = this.options_) == null ? void 0 : _this$options_.enhancer) != null ? _this$options_$enhanc : deepEnhancer, proxyTrap); + } + function decorate_20223_$4(desc, context) { + if (true) { + if (context.kind === "field") { + throw die("Please use `@observable accessor " + String(context.name) + "` instead of `@observable " + String(context.name) + "`"); + } + assert20223DecoratorType(context, ["accessor"]); + } + var ann = this; + var kind = context.kind, name = context.name; + var initializedObjects = /* @__PURE__ */ new WeakSet(); + function initializeObservable(target, value) { + var _ann$options_$enhance, _ann$options_; + var adm = asObservableObject(target)[$mobx]; + var observable2 = new ObservableValue(value, (_ann$options_$enhance = (_ann$options_ = ann.options_) == null ? void 0 : _ann$options_.enhancer) != null ? _ann$options_$enhance : deepEnhancer, true ? adm.name_ + "." + name.toString() : "ObservableObject." + name.toString(), false); + adm.values_.set(name, observable2); + initializedObjects.add(target); + } + if (kind == "accessor") { + return { + get: function get3() { + if (!initializedObjects.has(this)) { + initializeObservable(this, desc.get.call(this)); + } + return this[$mobx].getObservablePropValue_(name); + }, + set: function set4(value) { + if (!initializedObjects.has(this)) { + initializeObservable(this, value); + } + return this[$mobx].setObservablePropValue_(name, value); + }, + init: function init(value) { + if (!initializedObjects.has(this)) { + initializeObservable(this, value); + } + return value; + } + }; + } + return; + } + function assertObservableDescriptor(adm, _ref, key, descriptor) { + var annotationType_ = _ref.annotationType_; + if (!("value" in descriptor)) { + die("Cannot apply '" + annotationType_ + "' to '" + adm.name_ + "." + key.toString() + "':" + ("\n'" + annotationType_ + "' cannot be used on getter/setter properties")); + } + } + var AUTO = "true"; + var autoAnnotation = /* @__PURE__ */ createAutoAnnotation(); + function createAutoAnnotation(options) { + return { + annotationType_: AUTO, + options_: options, + make_: make_$5, + extend_: extend_$5, + decorate_20223_: decorate_20223_$5 + }; + } + function make_$5(adm, key, descriptor, source) { + var _this$options_3, _this$options_4; + if (descriptor.get) { + return computed.make_(adm, key, descriptor, source); + } + if (descriptor.set) { + var set4 = createAction(key.toString(), descriptor.set); + if (source === adm.target_) { + return adm.defineProperty_(key, { + configurable: globalState.safeDescriptors ? adm.isPlainObject_ : true, + set: set4 + }) === null ? 0 : 2; + } + defineProperty(source, key, { + configurable: true, + set: set4 + }); + return 2; + } + if (source !== adm.target_ && typeof descriptor.value === "function") { + var _this$options_2; + if (isGenerator(descriptor.value)) { + var _this$options_; + var flowAnnotation2 = (_this$options_ = this.options_) != null && _this$options_.autoBind ? flow.bound : flow; + return flowAnnotation2.make_(adm, key, descriptor, source); + } + var actionAnnotation2 = (_this$options_2 = this.options_) != null && _this$options_2.autoBind ? autoAction.bound : autoAction; + return actionAnnotation2.make_(adm, key, descriptor, source); + } + var observableAnnotation2 = ((_this$options_3 = this.options_) == null ? void 0 : _this$options_3.deep) === false ? observable.ref : observable; + if (typeof descriptor.value === "function" && (_this$options_4 = this.options_) != null && _this$options_4.autoBind) { + var _adm$proxy_; + descriptor.value = descriptor.value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_); + } + return observableAnnotation2.make_(adm, key, descriptor, source); + } + function extend_$5(adm, key, descriptor, proxyTrap) { + var _this$options_5, _this$options_6; + if (descriptor.get) { + return computed.extend_(adm, key, descriptor, proxyTrap); + } + if (descriptor.set) { + return adm.defineProperty_(key, { + configurable: globalState.safeDescriptors ? adm.isPlainObject_ : true, + set: createAction(key.toString(), descriptor.set) + }, proxyTrap); + } + if (typeof descriptor.value === "function" && (_this$options_5 = this.options_) != null && _this$options_5.autoBind) { + var _adm$proxy_2; + descriptor.value = descriptor.value.bind((_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_); + } + var observableAnnotation2 = ((_this$options_6 = this.options_) == null ? void 0 : _this$options_6.deep) === false ? observable.ref : observable; + return observableAnnotation2.extend_(adm, key, descriptor, proxyTrap); + } + function decorate_20223_$5(desc, context) { + die("'" + this.annotationType_ + "' cannot be used as a decorator"); + } + var OBSERVABLE = "observable"; + var OBSERVABLE_REF = "observable.ref"; + var OBSERVABLE_SHALLOW = "observable.shallow"; + var OBSERVABLE_STRUCT = "observable.struct"; + var defaultCreateObservableOptions = { + deep: true, + name: void 0, + defaultDecorator: void 0, + proxy: true + }; + Object.freeze(defaultCreateObservableOptions); + function asCreateObservableOptions(thing) { + return thing || defaultCreateObservableOptions; + } + var observableAnnotation = /* @__PURE__ */ createObservableAnnotation(OBSERVABLE); + var observableRefAnnotation = /* @__PURE__ */ createObservableAnnotation(OBSERVABLE_REF, { + enhancer: referenceEnhancer + }); + var observableShallowAnnotation = /* @__PURE__ */ createObservableAnnotation(OBSERVABLE_SHALLOW, { + enhancer: shallowEnhancer + }); + var observableStructAnnotation = /* @__PURE__ */ createObservableAnnotation(OBSERVABLE_STRUCT, { + enhancer: refStructEnhancer + }); + var observableDecoratorAnnotation = /* @__PURE__ */ createDecoratorAnnotation(observableAnnotation); + function getEnhancerFromOptions(options) { + return options.deep === true ? deepEnhancer : options.deep === false ? referenceEnhancer : getEnhancerFromAnnotation(options.defaultDecorator); + } + function getAnnotationFromOptions(options) { + var _options$defaultDecor; + return options ? (_options$defaultDecor = options.defaultDecorator) != null ? _options$defaultDecor : createAutoAnnotation(options) : void 0; + } + function getEnhancerFromAnnotation(annotation) { + var _annotation$options_$, _annotation$options_; + return !annotation ? deepEnhancer : (_annotation$options_$ = (_annotation$options_ = annotation.options_) == null ? void 0 : _annotation$options_.enhancer) != null ? _annotation$options_$ : deepEnhancer; + } + function createObservable(v6, arg2, arg3) { + if (is20223Decorator(arg2)) { + return observableAnnotation.decorate_20223_(v6, arg2); + } + if (isStringish(arg2)) { + storeAnnotation(v6, arg2, observableAnnotation); + return; + } + if (isObservable(v6)) { + return v6; + } + if (isPlainObject(v6)) { + return observable.object(v6, arg2, arg3); + } + if (Array.isArray(v6)) { + return observable.array(v6, arg2); + } + if (isES6Map(v6)) { + return observable.map(v6, arg2); + } + if (isES6Set(v6)) { + return observable.set(v6, arg2); + } + if (typeof v6 === "object" && v6 !== null) { + return v6; + } + return observable.box(v6, arg2); + } + assign(createObservable, observableDecoratorAnnotation); + var observableFactories = { + box: function box(value, options) { + var o29 = asCreateObservableOptions(options); + return new ObservableValue(value, getEnhancerFromOptions(o29), o29.name, true, o29.equals); + }, + array: function array(initialValues, options) { + var o29 = asCreateObservableOptions(options); + return (globalState.useProxies === false || o29.proxy === false ? createLegacyArray : createObservableArray)(initialValues, getEnhancerFromOptions(o29), o29.name); + }, + map: function map(initialValues, options) { + var o29 = asCreateObservableOptions(options); + return new ObservableMap(initialValues, getEnhancerFromOptions(o29), o29.name); + }, + set: function set(initialValues, options) { + var o29 = asCreateObservableOptions(options); + return new ObservableSet(initialValues, getEnhancerFromOptions(o29), o29.name); + }, + object: function object(props, decorators, options) { + return initObservable(function() { + return extendObservable(globalState.useProxies === false || (options == null ? void 0 : options.proxy) === false ? asObservableObject({}, options) : asDynamicObservableObject({}, options), props, decorators); + }); + }, + ref: /* @__PURE__ */ createDecoratorAnnotation(observableRefAnnotation), + shallow: /* @__PURE__ */ createDecoratorAnnotation(observableShallowAnnotation), + deep: observableDecoratorAnnotation, + struct: /* @__PURE__ */ createDecoratorAnnotation(observableStructAnnotation) + }; + var observable = /* @__PURE__ */ assign(createObservable, observableFactories); + var COMPUTED = "computed"; + var COMPUTED_STRUCT = "computed.struct"; + var computedAnnotation = /* @__PURE__ */ createComputedAnnotation(COMPUTED); + var computedStructAnnotation = /* @__PURE__ */ createComputedAnnotation(COMPUTED_STRUCT, { + equals: comparer.structural + }); + var computed = function computed2(arg1, arg2) { + if (is20223Decorator(arg2)) { + return computedAnnotation.decorate_20223_(arg1, arg2); + } + if (isStringish(arg2)) { + return storeAnnotation(arg1, arg2, computedAnnotation); + } + if (isPlainObject(arg1)) { + return createDecoratorAnnotation(createComputedAnnotation(COMPUTED, arg1)); + } + if (true) { + if (!isFunction(arg1)) { + die("First argument to `computed` should be an expression."); + } + if (isFunction(arg2)) { + die("A setter as second argument is no longer supported, use `{ set: fn }` option instead"); + } + } + var opts = isPlainObject(arg2) ? arg2 : {}; + opts.get = arg1; + opts.name || (opts.name = arg1.name || ""); + return new ComputedValue(opts); + }; + Object.assign(computed, computedAnnotation); + computed.struct = /* @__PURE__ */ createDecoratorAnnotation(computedStructAnnotation); + var _getDescriptor$config; + var _getDescriptor; + var currentActionId = 0; + var nextActionId = 1; + var isFunctionNameConfigurable = (_getDescriptor$config = (_getDescriptor = /* @__PURE__ */ getDescriptor(function() { + }, "name")) == null ? void 0 : _getDescriptor.configurable) != null ? _getDescriptor$config : false; + var tmpNameDescriptor = { + value: "action", + configurable: true, + writable: false, + enumerable: false + }; + function createAction(actionName, fn2, autoAction2, ref) { + if (autoAction2 === void 0) { + autoAction2 = false; + } + if (true) { + if (!isFunction(fn2)) { + die("`action` can only be invoked on functions"); + } + if (typeof actionName !== "string" || !actionName) { + die("actions should have valid names, got: '" + actionName + "'"); + } + } + function res() { + return executeAction(actionName, autoAction2, fn2, ref || this, arguments); + } + res.isMobxAction = true; + res.toString = function() { + return fn2.toString(); + }; + if (isFunctionNameConfigurable) { + tmpNameDescriptor.value = actionName; + defineProperty(res, "name", tmpNameDescriptor); + } + return res; + } + function executeAction(actionName, canRunAsDerivation, fn2, scope, args) { + var runInfo = _startAction(actionName, canRunAsDerivation, scope, args); + try { + return fn2.apply(scope, args); + } catch (err) { + runInfo.error_ = err; + throw err; + } finally { + _endAction(runInfo); + } + } + function _startAction(actionName, canRunAsDerivation, scope, args) { + var notifySpy_ = isSpyEnabled() && !!actionName; + var startTime_ = 0; + if (notifySpy_) { + startTime_ = Date.now(); + var flattenedArgs = args ? Array.from(args) : EMPTY_ARRAY; + spyReportStart({ + type: ACTION, + name: actionName, + object: scope, + arguments: flattenedArgs + }); + } + var prevDerivation_ = globalState.trackingDerivation; + var runAsAction = !canRunAsDerivation || !prevDerivation_; + startBatch(); + var prevAllowStateChanges_ = globalState.allowStateChanges; + if (runAsAction) { + untrackedStart(); + prevAllowStateChanges_ = allowStateChangesStart(true); + } + var prevAllowStateReads_ = allowStateReadsStart(true); + var runInfo = { + runAsAction_: runAsAction, + prevDerivation_, + prevAllowStateChanges_, + prevAllowStateReads_, + notifySpy_, + startTime_, + actionId_: nextActionId++, + parentActionId_: currentActionId + }; + currentActionId = runInfo.actionId_; + return runInfo; + } + function _endAction(runInfo) { + if (currentActionId !== runInfo.actionId_) { + die(30); + } + currentActionId = runInfo.parentActionId_; + if (runInfo.error_ !== void 0) { + globalState.suppressReactionErrors = true; + } + allowStateChangesEnd(runInfo.prevAllowStateChanges_); + allowStateReadsEnd(runInfo.prevAllowStateReads_); + endBatch(); + if (runInfo.runAsAction_) { + untrackedEnd(runInfo.prevDerivation_); + } + if (runInfo.notifySpy_) { + spyReportEnd({ + time: Date.now() - runInfo.startTime_ + }); + } + globalState.suppressReactionErrors = false; + } + function allowStateChangesStart(allowStateChanges) { + var prev = globalState.allowStateChanges; + globalState.allowStateChanges = allowStateChanges; + return prev; + } + function allowStateChangesEnd(prev) { + globalState.allowStateChanges = prev; + } + var _Symbol$toPrimitive; + var CREATE = "create"; + _Symbol$toPrimitive = Symbol.toPrimitive; + var ObservableValue = /* @__PURE__ */ function(_Atom) { + _inheritsLoose(ObservableValue2, _Atom); + function ObservableValue2(value, enhancer, name_, notifySpy, equals) { + var _this; + if (name_ === void 0) { + name_ = true ? "ObservableValue@" + getNextId() : "ObservableValue"; + } + if (notifySpy === void 0) { + notifySpy = true; + } + if (equals === void 0) { + equals = comparer["default"]; + } + _this = _Atom.call(this, name_) || this; + _this.enhancer = void 0; + _this.name_ = void 0; + _this.equals = void 0; + _this.hasUnreportedChange_ = false; + _this.interceptors_ = void 0; + _this.changeListeners_ = void 0; + _this.value_ = void 0; + _this.dehancer = void 0; + _this.enhancer = enhancer; + _this.name_ = name_; + _this.equals = equals; + _this.value_ = enhancer(value, void 0, name_); + if (notifySpy && isSpyEnabled()) { + spyReport({ + type: CREATE, + object: _assertThisInitialized(_this), + observableKind: "value", + debugObjectName: _this.name_, + newValue: "" + _this.value_ + }); + } + return _this; + } + var _proto = ObservableValue2.prototype; + _proto.dehanceValue = function dehanceValue(value) { + if (this.dehancer !== void 0) { + return this.dehancer(value); + } + return value; + }; + _proto.set = function set4(newValue) { + var oldValue = this.value_; + newValue = this.prepareNewValue_(newValue); + if (newValue !== globalState.UNCHANGED) { + var notifySpy = isSpyEnabled(); + if (notifySpy) { + spyReportStart({ + type: UPDATE, + object: this, + observableKind: "value", + debugObjectName: this.name_, + newValue, + oldValue + }); + } + this.setNewValue_(newValue); + if (notifySpy) { + spyReportEnd(); + } + } + }; + _proto.prepareNewValue_ = function prepareNewValue_(newValue) { + checkIfStateModificationsAreAllowed(this); + if (hasInterceptors(this)) { + var change2 = interceptChange(this, { + object: this, + type: UPDATE, + newValue + }); + if (!change2) { + return globalState.UNCHANGED; + } + newValue = change2.newValue; + } + newValue = this.enhancer(newValue, this.value_, this.name_); + return this.equals(this.value_, newValue) ? globalState.UNCHANGED : newValue; + }; + _proto.setNewValue_ = function setNewValue_(newValue) { + var oldValue = this.value_; + this.value_ = newValue; + this.reportChanged(); + if (hasListeners(this)) { + notifyListeners(this, { + type: UPDATE, + object: this, + newValue, + oldValue + }); + } + }; + _proto.get = function get3() { + this.reportObserved(); + return this.dehanceValue(this.value_); + }; + _proto.intercept_ = function intercept_(handler) { + return registerInterceptor(this, handler); + }; + _proto.observe_ = function observe_(listener, fireImmediately) { + if (fireImmediately) { + listener({ + observableKind: "value", + debugObjectName: this.name_, + object: this, + type: UPDATE, + newValue: this.value_, + oldValue: void 0 + }); + } + return registerListener(this, listener); + }; + _proto.raw = function raw() { + return this.value_; + }; + _proto.toJSON = function toJSON2() { + return this.get(); + }; + _proto.toString = function toString2() { + return this.name_ + "[" + this.value_ + "]"; + }; + _proto.valueOf = function valueOf() { + return toPrimitive(this.get()); + }; + _proto[_Symbol$toPrimitive] = function() { + return this.valueOf(); + }; + return ObservableValue2; + }(Atom); + var _Symbol$toPrimitive$1; + _Symbol$toPrimitive$1 = Symbol.toPrimitive; + var ComputedValue = /* @__PURE__ */ function() { + function ComputedValue2(options) { + this.dependenciesState_ = IDerivationState_.NOT_TRACKING_; + this.observing_ = []; + this.newObserving_ = null; + this.isBeingObserved_ = false; + this.isPendingUnobservation_ = false; + this.observers_ = /* @__PURE__ */ new Set(); + this.diffValue_ = 0; + this.runId_ = 0; + this.lastAccessedBy_ = 0; + this.lowestObserverState_ = IDerivationState_.UP_TO_DATE_; + this.unboundDepsCount_ = 0; + this.value_ = new CaughtException(null); + this.name_ = void 0; + this.triggeredBy_ = void 0; + this.isComputing_ = false; + this.isRunningSetter_ = false; + this.derivation = void 0; + this.setter_ = void 0; + this.isTracing_ = TraceMode.NONE; + this.scope_ = void 0; + this.equals_ = void 0; + this.requiresReaction_ = void 0; + this.keepAlive_ = void 0; + this.onBOL = void 0; + this.onBUOL = void 0; + if (!options.get) { + die(31); + } + this.derivation = options.get; + this.name_ = options.name || (true ? "ComputedValue@" + getNextId() : "ComputedValue"); + if (options.set) { + this.setter_ = createAction(true ? this.name_ + "-setter" : "ComputedValue-setter", options.set); + } + this.equals_ = options.equals || (options.compareStructural || options.struct ? comparer.structural : comparer["default"]); + this.scope_ = options.context; + this.requiresReaction_ = options.requiresReaction; + this.keepAlive_ = !!options.keepAlive; + } + var _proto = ComputedValue2.prototype; + _proto.onBecomeStale_ = function onBecomeStale_() { + propagateMaybeChanged(this); + }; + _proto.onBO = function onBO() { + if (this.onBOL) { + this.onBOL.forEach(function(listener) { + return listener(); + }); + } + }; + _proto.onBUO = function onBUO() { + if (this.onBUOL) { + this.onBUOL.forEach(function(listener) { + return listener(); + }); + } + }; + _proto.get = function get3() { + if (this.isComputing_) { + die(32, this.name_, this.derivation); + } + if (globalState.inBatch === 0 && // !globalState.trackingDerivatpion && + this.observers_.size === 0 && !this.keepAlive_) { + if (shouldCompute(this)) { + this.warnAboutUntrackedRead_(); + startBatch(); + this.value_ = this.computeValue_(false); + endBatch(); + } + } else { + reportObserved(this); + if (shouldCompute(this)) { + var prevTrackingContext = globalState.trackingContext; + if (this.keepAlive_ && !prevTrackingContext) { + globalState.trackingContext = this; + } + if (this.trackAndCompute()) { + propagateChangeConfirmed(this); + } + globalState.trackingContext = prevTrackingContext; + } + } + var result = this.value_; + if (isCaughtException(result)) { + throw result.cause; + } + return result; + }; + _proto.set = function set4(value) { + if (this.setter_) { + if (this.isRunningSetter_) { + die(33, this.name_); + } + this.isRunningSetter_ = true; + try { + this.setter_.call(this.scope_, value); + } finally { + this.isRunningSetter_ = false; + } + } else { + die(34, this.name_); + } + }; + _proto.trackAndCompute = function trackAndCompute() { + var oldValue = this.value_; + var wasSuspended = ( + /* see #1208 */ + this.dependenciesState_ === IDerivationState_.NOT_TRACKING_ + ); + var newValue = this.computeValue_(true); + var changed = wasSuspended || isCaughtException(oldValue) || isCaughtException(newValue) || !this.equals_(oldValue, newValue); + if (changed) { + this.value_ = newValue; + if (isSpyEnabled()) { + spyReport({ + observableKind: "computed", + debugObjectName: this.name_, + object: this.scope_, + type: "update", + oldValue, + newValue + }); + } + } + return changed; + }; + _proto.computeValue_ = function computeValue_(track) { + this.isComputing_ = true; + var prev = allowStateChangesStart(false); + var res; + if (track) { + res = trackDerivedFunction(this, this.derivation, this.scope_); + } else { + if (globalState.disableErrorBoundaries === true) { + res = this.derivation.call(this.scope_); + } else { + try { + res = this.derivation.call(this.scope_); + } catch (e33) { + res = new CaughtException(e33); + } + } + } + allowStateChangesEnd(prev); + this.isComputing_ = false; + return res; + }; + _proto.suspend_ = function suspend_() { + if (!this.keepAlive_) { + clearObserving(this); + this.value_ = void 0; + if (this.isTracing_ !== TraceMode.NONE) { + console.log("[mobx.trace] Computed value '" + this.name_ + "' was suspended and it will recompute on the next access."); + } + } + }; + _proto.observe_ = function observe_(listener, fireImmediately) { + var _this = this; + var firstTime = true; + var prevValue = void 0; + return autorun(function() { + var newValue = _this.get(); + if (!firstTime || fireImmediately) { + var prevU = untrackedStart(); + listener({ + observableKind: "computed", + debugObjectName: _this.name_, + type: UPDATE, + object: _this, + newValue, + oldValue: prevValue + }); + untrackedEnd(prevU); + } + firstTime = false; + prevValue = newValue; + }); + }; + _proto.warnAboutUntrackedRead_ = function warnAboutUntrackedRead_() { + if (false) { + return; + } + if (this.isTracing_ !== TraceMode.NONE) { + console.log("[mobx.trace] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute."); + } + if (typeof this.requiresReaction_ === "boolean" ? this.requiresReaction_ : globalState.computedRequiresReaction) { + console.warn("[mobx] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute."); + } + }; + _proto.toString = function toString2() { + return this.name_ + "[" + this.derivation.toString() + "]"; + }; + _proto.valueOf = function valueOf() { + return toPrimitive(this.get()); + }; + _proto[_Symbol$toPrimitive$1] = function() { + return this.valueOf(); + }; + return ComputedValue2; + }(); + var isComputedValue = /* @__PURE__ */ createInstanceofPredicate("ComputedValue", ComputedValue); + var IDerivationState_; + (function(IDerivationState_2) { + IDerivationState_2[IDerivationState_2["NOT_TRACKING_"] = -1] = "NOT_TRACKING_"; + IDerivationState_2[IDerivationState_2["UP_TO_DATE_"] = 0] = "UP_TO_DATE_"; + IDerivationState_2[IDerivationState_2["POSSIBLY_STALE_"] = 1] = "POSSIBLY_STALE_"; + IDerivationState_2[IDerivationState_2["STALE_"] = 2] = "STALE_"; + })(IDerivationState_ || (IDerivationState_ = {})); + var TraceMode; + (function(TraceMode2) { + TraceMode2[TraceMode2["NONE"] = 0] = "NONE"; + TraceMode2[TraceMode2["LOG"] = 1] = "LOG"; + TraceMode2[TraceMode2["BREAK"] = 2] = "BREAK"; + })(TraceMode || (TraceMode = {})); + var CaughtException = function CaughtException2(cause) { + this.cause = void 0; + this.cause = cause; + }; + function isCaughtException(e33) { + return e33 instanceof CaughtException; + } + function shouldCompute(derivation) { + switch (derivation.dependenciesState_) { + case IDerivationState_.UP_TO_DATE_: + return false; + case IDerivationState_.NOT_TRACKING_: + case IDerivationState_.STALE_: + return true; + case IDerivationState_.POSSIBLY_STALE_: { + var prevAllowStateReads = allowStateReadsStart(true); + var prevUntracked = untrackedStart(); + var obs = derivation.observing_, l20 = obs.length; + for (var i23 = 0; i23 < l20; i23++) { + var obj = obs[i23]; + if (isComputedValue(obj)) { + if (globalState.disableErrorBoundaries) { + obj.get(); + } else { + try { + obj.get(); + } catch (e33) { + untrackedEnd(prevUntracked); + allowStateReadsEnd(prevAllowStateReads); + return true; + } + } + if (derivation.dependenciesState_ === IDerivationState_.STALE_) { + untrackedEnd(prevUntracked); + allowStateReadsEnd(prevAllowStateReads); + return true; + } + } + } + changeDependenciesStateTo0(derivation); + untrackedEnd(prevUntracked); + allowStateReadsEnd(prevAllowStateReads); + return false; + } + } + } + function checkIfStateModificationsAreAllowed(atom) { + if (false) { + return; + } + var hasObservers = atom.observers_.size > 0; + if (!globalState.allowStateChanges && (hasObservers || globalState.enforceActions === "always")) { + console.warn("[MobX] " + (globalState.enforceActions ? "Since strict-mode is enabled, changing (observed) observable values without using an action is not allowed. Tried to modify: " : "Side effects like changing state are not allowed at this point. Are you trying to modify state from, for example, a computed value or the render function of a React component? You can wrap side effects in 'runInAction' (or decorate functions with 'action') if needed. Tried to modify: ") + atom.name_); + } + } + function checkIfStateReadsAreAllowed(observable2) { + if (!globalState.allowStateReads && globalState.observableRequiresReaction) { + console.warn("[mobx] Observable '" + observable2.name_ + "' being read outside a reactive context."); + } + } + function trackDerivedFunction(derivation, f7, context) { + var prevAllowStateReads = allowStateReadsStart(true); + changeDependenciesStateTo0(derivation); + derivation.newObserving_ = new Array( + // Reserve constant space for initial dependencies, dynamic space otherwise. + // See https://github.com/mobxjs/mobx/pull/3833 + derivation.runId_ === 0 ? 100 : derivation.observing_.length + ); + derivation.unboundDepsCount_ = 0; + derivation.runId_ = ++globalState.runId; + var prevTracking = globalState.trackingDerivation; + globalState.trackingDerivation = derivation; + globalState.inBatch++; + var result; + if (globalState.disableErrorBoundaries === true) { + result = f7.call(context); + } else { + try { + result = f7.call(context); + } catch (e33) { + result = new CaughtException(e33); + } + } + globalState.inBatch--; + globalState.trackingDerivation = prevTracking; + bindDependencies(derivation); + warnAboutDerivationWithoutDependencies(derivation); + allowStateReadsEnd(prevAllowStateReads); + return result; + } + function warnAboutDerivationWithoutDependencies(derivation) { + if (false) { + return; + } + if (derivation.observing_.length !== 0) { + return; + } + if (typeof derivation.requiresObservable_ === "boolean" ? derivation.requiresObservable_ : globalState.reactionRequiresObservable) { + console.warn("[mobx] Derivation '" + derivation.name_ + "' is created/updated without reading any observable value."); + } + } + function bindDependencies(derivation) { + var prevObserving = derivation.observing_; + var observing = derivation.observing_ = derivation.newObserving_; + var lowestNewObservingDerivationState = IDerivationState_.UP_TO_DATE_; + var i0 = 0, l20 = derivation.unboundDepsCount_; + for (var i23 = 0; i23 < l20; i23++) { + var dep = observing[i23]; + if (dep.diffValue_ === 0) { + dep.diffValue_ = 1; + if (i0 !== i23) { + observing[i0] = dep; + } + i0++; + } + if (dep.dependenciesState_ > lowestNewObservingDerivationState) { + lowestNewObservingDerivationState = dep.dependenciesState_; + } + } + observing.length = i0; + derivation.newObserving_ = null; + l20 = prevObserving.length; + while (l20--) { + var _dep = prevObserving[l20]; + if (_dep.diffValue_ === 0) { + removeObserver(_dep, derivation); + } + _dep.diffValue_ = 0; + } + while (i0--) { + var _dep2 = observing[i0]; + if (_dep2.diffValue_ === 1) { + _dep2.diffValue_ = 0; + addObserver(_dep2, derivation); + } + } + if (lowestNewObservingDerivationState !== IDerivationState_.UP_TO_DATE_) { + derivation.dependenciesState_ = lowestNewObservingDerivationState; + derivation.onBecomeStale_(); + } + } + function clearObserving(derivation) { + var obs = derivation.observing_; + derivation.observing_ = []; + var i23 = obs.length; + while (i23--) { + removeObserver(obs[i23], derivation); + } + derivation.dependenciesState_ = IDerivationState_.NOT_TRACKING_; + } + function untracked(action2) { + var prev = untrackedStart(); + try { + return action2(); + } finally { + untrackedEnd(prev); + } + } + function untrackedStart() { + var prev = globalState.trackingDerivation; + globalState.trackingDerivation = null; + return prev; + } + function untrackedEnd(prev) { + globalState.trackingDerivation = prev; + } + function allowStateReadsStart(allowStateReads) { + var prev = globalState.allowStateReads; + globalState.allowStateReads = allowStateReads; + return prev; + } + function allowStateReadsEnd(prev) { + globalState.allowStateReads = prev; + } + function changeDependenciesStateTo0(derivation) { + if (derivation.dependenciesState_ === IDerivationState_.UP_TO_DATE_) { + return; + } + derivation.dependenciesState_ = IDerivationState_.UP_TO_DATE_; + var obs = derivation.observing_; + var i23 = obs.length; + while (i23--) { + obs[i23].lowestObserverState_ = IDerivationState_.UP_TO_DATE_; + } + } + var MobXGlobals = function MobXGlobals2() { + this.version = 6; + this.UNCHANGED = {}; + this.trackingDerivation = null; + this.trackingContext = null; + this.runId = 0; + this.mobxGuid = 0; + this.inBatch = 0; + this.pendingUnobservations = []; + this.pendingReactions = []; + this.isRunningReactions = false; + this.allowStateChanges = false; + this.allowStateReads = true; + this.enforceActions = true; + this.spyListeners = []; + this.globalReactionErrorHandlers = []; + this.computedRequiresReaction = false; + this.reactionRequiresObservable = false; + this.observableRequiresReaction = false; + this.disableErrorBoundaries = false; + this.suppressReactionErrors = false; + this.useProxies = true; + this.verifyProxies = false; + this.safeDescriptors = true; + }; + var canMergeGlobalState = true; + var isolateCalled = false; + var globalState = /* @__PURE__ */ function() { + var global2 = /* @__PURE__ */ getGlobal(); + if (global2.__mobxInstanceCount > 0 && !global2.__mobxGlobals) { + canMergeGlobalState = false; + } + if (global2.__mobxGlobals && global2.__mobxGlobals.version !== new MobXGlobals().version) { + canMergeGlobalState = false; + } + if (!canMergeGlobalState) { + setTimeout(function() { + if (!isolateCalled) { + die(35); + } + }, 1); + return new MobXGlobals(); + } else if (global2.__mobxGlobals) { + global2.__mobxInstanceCount += 1; + if (!global2.__mobxGlobals.UNCHANGED) { + global2.__mobxGlobals.UNCHANGED = {}; + } + return global2.__mobxGlobals; + } else { + global2.__mobxInstanceCount = 1; + return global2.__mobxGlobals = /* @__PURE__ */ new MobXGlobals(); + } + }(); + function addObserver(observable2, node) { + observable2.observers_.add(node); + if (observable2.lowestObserverState_ > node.dependenciesState_) { + observable2.lowestObserverState_ = node.dependenciesState_; + } + } + function removeObserver(observable2, node) { + observable2.observers_["delete"](node); + if (observable2.observers_.size === 0) { + queueForUnobservation(observable2); + } + } + function queueForUnobservation(observable2) { + if (observable2.isPendingUnobservation_ === false) { + observable2.isPendingUnobservation_ = true; + globalState.pendingUnobservations.push(observable2); + } + } + function startBatch() { + globalState.inBatch++; + } + function endBatch() { + if (--globalState.inBatch === 0) { + runReactions(); + var list = globalState.pendingUnobservations; + for (var i23 = 0; i23 < list.length; i23++) { + var observable2 = list[i23]; + observable2.isPendingUnobservation_ = false; + if (observable2.observers_.size === 0) { + if (observable2.isBeingObserved_) { + observable2.isBeingObserved_ = false; + observable2.onBUO(); + } + if (observable2 instanceof ComputedValue) { + observable2.suspend_(); + } + } + } + globalState.pendingUnobservations = []; + } + } + function reportObserved(observable2) { + checkIfStateReadsAreAllowed(observable2); + var derivation = globalState.trackingDerivation; + if (derivation !== null) { + if (derivation.runId_ !== observable2.lastAccessedBy_) { + observable2.lastAccessedBy_ = derivation.runId_; + derivation.newObserving_[derivation.unboundDepsCount_++] = observable2; + if (!observable2.isBeingObserved_ && globalState.trackingContext) { + observable2.isBeingObserved_ = true; + observable2.onBO(); + } + } + return observable2.isBeingObserved_; + } else if (observable2.observers_.size === 0 && globalState.inBatch > 0) { + queueForUnobservation(observable2); + } + return false; + } + function propagateChanged(observable2) { + if (observable2.lowestObserverState_ === IDerivationState_.STALE_) { + return; + } + observable2.lowestObserverState_ = IDerivationState_.STALE_; + observable2.observers_.forEach(function(d11) { + if (d11.dependenciesState_ === IDerivationState_.UP_TO_DATE_) { + if (d11.isTracing_ !== TraceMode.NONE) { + logTraceInfo(d11, observable2); + } + d11.onBecomeStale_(); + } + d11.dependenciesState_ = IDerivationState_.STALE_; + }); + } + function propagateChangeConfirmed(observable2) { + if (observable2.lowestObserverState_ === IDerivationState_.STALE_) { + return; + } + observable2.lowestObserverState_ = IDerivationState_.STALE_; + observable2.observers_.forEach(function(d11) { + if (d11.dependenciesState_ === IDerivationState_.POSSIBLY_STALE_) { + d11.dependenciesState_ = IDerivationState_.STALE_; + if (d11.isTracing_ !== TraceMode.NONE) { + logTraceInfo(d11, observable2); + } + } else if (d11.dependenciesState_ === IDerivationState_.UP_TO_DATE_) { + observable2.lowestObserverState_ = IDerivationState_.UP_TO_DATE_; + } + }); + } + function propagateMaybeChanged(observable2) { + if (observable2.lowestObserverState_ !== IDerivationState_.UP_TO_DATE_) { + return; + } + observable2.lowestObserverState_ = IDerivationState_.POSSIBLY_STALE_; + observable2.observers_.forEach(function(d11) { + if (d11.dependenciesState_ === IDerivationState_.UP_TO_DATE_) { + d11.dependenciesState_ = IDerivationState_.POSSIBLY_STALE_; + d11.onBecomeStale_(); + } + }); + } + function logTraceInfo(derivation, observable2) { + console.log("[mobx.trace] '" + derivation.name_ + "' is invalidated due to a change in: '" + observable2.name_ + "'"); + if (derivation.isTracing_ === TraceMode.BREAK) { + var lines = []; + printDepTree(getDependencyTree(derivation), lines, 1); + new Function("debugger;\n/*\nTracing '" + derivation.name_ + "'\n\nYou are entering this break point because derivation '" + derivation.name_ + "' is being traced and '" + observable2.name_ + "' is now forcing it to update.\nJust follow the stacktrace you should now see in the devtools to see precisely what piece of your code is causing this update\nThe stackframe you are looking for is at least ~6-8 stack-frames up.\n\n" + (derivation instanceof ComputedValue ? derivation.derivation.toString().replace(/[*]\//g, "/") : "") + "\n\nThe dependencies for this derivation are:\n\n" + lines.join("\n") + "\n*/\n ")(); + } + } + function printDepTree(tree, lines, depth) { + if (lines.length >= 1e3) { + lines.push("(and many more)"); + return; + } + lines.push("" + " ".repeat(depth - 1) + tree.name); + if (tree.dependencies) { + tree.dependencies.forEach(function(child) { + return printDepTree(child, lines, depth + 1); + }); + } + } + var Reaction = /* @__PURE__ */ function() { + function Reaction2(name_, onInvalidate_, errorHandler_, requiresObservable_) { + if (name_ === void 0) { + name_ = true ? "Reaction@" + getNextId() : "Reaction"; + } + this.name_ = void 0; + this.onInvalidate_ = void 0; + this.errorHandler_ = void 0; + this.requiresObservable_ = void 0; + this.observing_ = []; + this.newObserving_ = []; + this.dependenciesState_ = IDerivationState_.NOT_TRACKING_; + this.diffValue_ = 0; + this.runId_ = 0; + this.unboundDepsCount_ = 0; + this.isDisposed_ = false; + this.isScheduled_ = false; + this.isTrackPending_ = false; + this.isRunning_ = false; + this.isTracing_ = TraceMode.NONE; + this.name_ = name_; + this.onInvalidate_ = onInvalidate_; + this.errorHandler_ = errorHandler_; + this.requiresObservable_ = requiresObservable_; + } + var _proto = Reaction2.prototype; + _proto.onBecomeStale_ = function onBecomeStale_() { + this.schedule_(); + }; + _proto.schedule_ = function schedule_() { + if (!this.isScheduled_) { + this.isScheduled_ = true; + globalState.pendingReactions.push(this); + runReactions(); + } + }; + _proto.isScheduled = function isScheduled() { + return this.isScheduled_; + }; + _proto.runReaction_ = function runReaction_() { + if (!this.isDisposed_) { + startBatch(); + this.isScheduled_ = false; + var prev = globalState.trackingContext; + globalState.trackingContext = this; + if (shouldCompute(this)) { + this.isTrackPending_ = true; + try { + this.onInvalidate_(); + if (this.isTrackPending_ && isSpyEnabled()) { + spyReport({ + name: this.name_, + type: "scheduled-reaction" + }); + } + } catch (e33) { + this.reportExceptionInDerivation_(e33); + } + } + globalState.trackingContext = prev; + endBatch(); + } + }; + _proto.track = function track(fn2) { + if (this.isDisposed_) { + return; + } + startBatch(); + var notify = isSpyEnabled(); + var startTime; + if (notify) { + startTime = Date.now(); + spyReportStart({ + name: this.name_, + type: "reaction" + }); + } + this.isRunning_ = true; + var prevReaction = globalState.trackingContext; + globalState.trackingContext = this; + var result = trackDerivedFunction(this, fn2, void 0); + globalState.trackingContext = prevReaction; + this.isRunning_ = false; + this.isTrackPending_ = false; + if (this.isDisposed_) { + clearObserving(this); + } + if (isCaughtException(result)) { + this.reportExceptionInDerivation_(result.cause); + } + if (notify) { + spyReportEnd({ + time: Date.now() - startTime + }); + } + endBatch(); + }; + _proto.reportExceptionInDerivation_ = function reportExceptionInDerivation_(error) { + var _this = this; + if (this.errorHandler_) { + this.errorHandler_(error, this); + return; + } + if (globalState.disableErrorBoundaries) { + throw error; + } + var message = true ? "[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '" + this + "'" : "[mobx] uncaught error in '" + this + "'"; + if (!globalState.suppressReactionErrors) { + console.error(message, error); + } else if (true) { + console.warn("[mobx] (error in reaction '" + this.name_ + "' suppressed, fix error of causing action below)"); + } + if (isSpyEnabled()) { + spyReport({ + type: "error", + name: this.name_, + message, + error: "" + error + }); + } + globalState.globalReactionErrorHandlers.forEach(function(f7) { + return f7(error, _this); + }); + }; + _proto.dispose = function dispose() { + if (!this.isDisposed_) { + this.isDisposed_ = true; + if (!this.isRunning_) { + startBatch(); + clearObserving(this); + endBatch(); + } + } + }; + _proto.getDisposer_ = function getDisposer_(abortSignal) { + var _this2 = this; + var dispose = function dispose2() { + _this2.dispose(); + abortSignal == null ? void 0 : abortSignal.removeEventListener == null ? void 0 : abortSignal.removeEventListener("abort", dispose2); + }; + abortSignal == null ? void 0 : abortSignal.addEventListener == null ? void 0 : abortSignal.addEventListener("abort", dispose); + dispose[$mobx] = this; + return dispose; + }; + _proto.toString = function toString2() { + return "Reaction[" + this.name_ + "]"; + }; + _proto.trace = function trace$1(enterBreakPoint) { + if (enterBreakPoint === void 0) { + enterBreakPoint = false; + } + trace(this, enterBreakPoint); + }; + return Reaction2; + }(); + var MAX_REACTION_ITERATIONS = 100; + var reactionScheduler = function reactionScheduler2(f7) { + return f7(); + }; + function runReactions() { + if (globalState.inBatch > 0 || globalState.isRunningReactions) { + return; + } + reactionScheduler(runReactionsHelper); + } + function runReactionsHelper() { + globalState.isRunningReactions = true; + var allReactions = globalState.pendingReactions; + var iterations = 0; + while (allReactions.length > 0) { + if (++iterations === MAX_REACTION_ITERATIONS) { + console.error(true ? "Reaction doesn't converge to a stable state after " + MAX_REACTION_ITERATIONS + " iterations." + (" Probably there is a cycle in the reactive function: " + allReactions[0]) : "[mobx] cycle in reaction: " + allReactions[0]); + allReactions.splice(0); + } + var remainingReactions = allReactions.splice(0); + for (var i23 = 0, l20 = remainingReactions.length; i23 < l20; i23++) { + remainingReactions[i23].runReaction_(); + } + } + globalState.isRunningReactions = false; + } + var isReaction = /* @__PURE__ */ createInstanceofPredicate("Reaction", Reaction); + function isSpyEnabled() { + return !!globalState.spyListeners.length; + } + function spyReport(event) { + if (false) { + return; + } + if (!globalState.spyListeners.length) { + return; + } + var listeners = globalState.spyListeners; + for (var i23 = 0, l20 = listeners.length; i23 < l20; i23++) { + listeners[i23](event); + } + } + function spyReportStart(event) { + if (false) { + return; + } + var change2 = _extends({}, event, { + spyReportStart: true + }); + spyReport(change2); + } + var END_EVENT = { + type: "report-end", + spyReportEnd: true + }; + function spyReportEnd(change2) { + if (false) { + return; + } + if (change2) { + spyReport(_extends({}, change2, { + type: "report-end", + spyReportEnd: true + })); + } else { + spyReport(END_EVENT); + } + } + function spy(listener) { + if (false) { + console.warn("[mobx.spy] Is a no-op in production builds"); + return function() { + }; + } else { + globalState.spyListeners.push(listener); + return once(function() { + globalState.spyListeners = globalState.spyListeners.filter(function(l20) { + return l20 !== listener; + }); + }); + } + } + var ACTION = "action"; + var ACTION_BOUND = "action.bound"; + var AUTOACTION = "autoAction"; + var AUTOACTION_BOUND = "autoAction.bound"; + var DEFAULT_ACTION_NAME = ""; + var actionAnnotation = /* @__PURE__ */ createActionAnnotation(ACTION); + var actionBoundAnnotation = /* @__PURE__ */ createActionAnnotation(ACTION_BOUND, { + bound: true + }); + var autoActionAnnotation = /* @__PURE__ */ createActionAnnotation(AUTOACTION, { + autoAction: true + }); + var autoActionBoundAnnotation = /* @__PURE__ */ createActionAnnotation(AUTOACTION_BOUND, { + autoAction: true, + bound: true + }); + function createActionFactory(autoAction2) { + var res = function action2(arg1, arg2) { + if (isFunction(arg1)) { + return createAction(arg1.name || DEFAULT_ACTION_NAME, arg1, autoAction2); + } + if (isFunction(arg2)) { + return createAction(arg1, arg2, autoAction2); + } + if (is20223Decorator(arg2)) { + return (autoAction2 ? autoActionAnnotation : actionAnnotation).decorate_20223_(arg1, arg2); + } + if (isStringish(arg2)) { + return storeAnnotation(arg1, arg2, autoAction2 ? autoActionAnnotation : actionAnnotation); + } + if (isStringish(arg1)) { + return createDecoratorAnnotation(createActionAnnotation(autoAction2 ? AUTOACTION : ACTION, { + name: arg1, + autoAction: autoAction2 + })); + } + if (true) { + die("Invalid arguments for `action`"); + } + }; + return res; + } + var action = /* @__PURE__ */ createActionFactory(false); + Object.assign(action, actionAnnotation); + var autoAction = /* @__PURE__ */ createActionFactory(true); + Object.assign(autoAction, autoActionAnnotation); + action.bound = /* @__PURE__ */ createDecoratorAnnotation(actionBoundAnnotation); + autoAction.bound = /* @__PURE__ */ createDecoratorAnnotation(autoActionBoundAnnotation); + function isAction(thing) { + return isFunction(thing) && thing.isMobxAction === true; + } + function autorun(view, opts) { + var _opts$name, _opts, _opts2, _opts2$signal, _opts3; + if (opts === void 0) { + opts = EMPTY_OBJECT; + } + if (true) { + if (!isFunction(view)) { + die("Autorun expects a function as first argument"); + } + if (isAction(view)) { + die("Autorun does not accept actions since actions are untrackable"); + } + } + var name = (_opts$name = (_opts = opts) == null ? void 0 : _opts.name) != null ? _opts$name : true ? view.name || "Autorun@" + getNextId() : "Autorun"; + var runSync = !opts.scheduler && !opts.delay; + var reaction2; + if (runSync) { + reaction2 = new Reaction(name, function() { + this.track(reactionRunner); + }, opts.onError, opts.requiresObservable); + } else { + var scheduler = createSchedulerFromOptions(opts); + var isScheduled = false; + reaction2 = new Reaction(name, function() { + if (!isScheduled) { + isScheduled = true; + scheduler(function() { + isScheduled = false; + if (!reaction2.isDisposed_) { + reaction2.track(reactionRunner); + } + }); + } + }, opts.onError, opts.requiresObservable); + } + function reactionRunner() { + view(reaction2); + } + if (!((_opts2 = opts) != null && (_opts2$signal = _opts2.signal) != null && _opts2$signal.aborted)) { + reaction2.schedule_(); + } + return reaction2.getDisposer_((_opts3 = opts) == null ? void 0 : _opts3.signal); + } + var run = function run2(f7) { + return f7(); + }; + function createSchedulerFromOptions(opts) { + return opts.scheduler ? opts.scheduler : opts.delay ? function(f7) { + return setTimeout(f7, opts.delay); + } : run; + } + var ON_BECOME_OBSERVED = "onBO"; + var ON_BECOME_UNOBSERVED = "onBUO"; + function onBecomeObserved(thing, arg2, arg3) { + return interceptHook(ON_BECOME_OBSERVED, thing, arg2, arg3); + } + function onBecomeUnobserved(thing, arg2, arg3) { + return interceptHook(ON_BECOME_UNOBSERVED, thing, arg2, arg3); + } + function interceptHook(hook, thing, arg2, arg3) { + var atom = typeof arg3 === "function" ? getAtom(thing, arg2) : getAtom(thing); + var cb = isFunction(arg3) ? arg3 : arg2; + var listenersKey = hook + "L"; + if (atom[listenersKey]) { + atom[listenersKey].add(cb); + } else { + atom[listenersKey] = /* @__PURE__ */ new Set([cb]); + } + return function() { + var hookListeners = atom[listenersKey]; + if (hookListeners) { + hookListeners["delete"](cb); + if (hookListeners.size === 0) { + delete atom[listenersKey]; + } + } + }; + } + function extendObservable(target, properties, annotations, options) { + if (true) { + if (arguments.length > 4) { + die("'extendObservable' expected 2-4 arguments"); + } + if (typeof target !== "object") { + die("'extendObservable' expects an object as first argument"); + } + if (isObservableMap(target)) { + die("'extendObservable' should not be used on maps, use map.merge instead"); + } + if (!isPlainObject(properties)) { + die("'extendObservable' only accepts plain objects as second argument"); + } + if (isObservable(properties) || isObservable(annotations)) { + die("Extending an object with another observable (object) is not supported"); + } + } + var descriptors = getOwnPropertyDescriptors(properties); + initObservable(function() { + var adm = asObservableObject(target, options)[$mobx]; + ownKeys(descriptors).forEach(function(key) { + adm.extend_( + key, + descriptors[key], + // must pass "undefined" for { key: undefined } + !annotations ? true : key in annotations ? annotations[key] : true + ); + }); + }); + return target; + } + function getDependencyTree(thing, property) { + return nodeToDependencyTree(getAtom(thing, property)); + } + function nodeToDependencyTree(node) { + var result = { + name: node.name_ + }; + if (node.observing_ && node.observing_.length > 0) { + result.dependencies = unique(node.observing_).map(nodeToDependencyTree); + } + return result; + } + function unique(list) { + return Array.from(new Set(list)); + } + var generatorId = 0; + function FlowCancellationError() { + this.message = "FLOW_CANCELLED"; + } + FlowCancellationError.prototype = /* @__PURE__ */ Object.create(Error.prototype); + var flowAnnotation = /* @__PURE__ */ createFlowAnnotation("flow"); + var flowBoundAnnotation = /* @__PURE__ */ createFlowAnnotation("flow.bound", { + bound: true + }); + var flow = /* @__PURE__ */ Object.assign(function flow2(arg1, arg2) { + if (is20223Decorator(arg2)) { + return flowAnnotation.decorate_20223_(arg1, arg2); + } + if (isStringish(arg2)) { + return storeAnnotation(arg1, arg2, flowAnnotation); + } + if (arguments.length !== 1) { + die("Flow expects single argument with generator function"); + } + var generator = arg1; + var name = generator.name || ""; + var res = function res2() { + var ctx = this; + var args = arguments; + var runId = ++generatorId; + var gen = action(name + " - runid: " + runId + " - init", generator).apply(ctx, args); + var rejector; + var pendingPromise = void 0; + var promise = new Promise(function(resolve, reject) { + var stepId = 0; + rejector = reject; + function onFulfilled(res3) { + pendingPromise = void 0; + var ret; + try { + ret = action(name + " - runid: " + runId + " - yield " + stepId++, gen.next).call(gen, res3); + } catch (e33) { + return reject(e33); + } + next(ret); + } + function onRejected(err) { + pendingPromise = void 0; + var ret; + try { + ret = action(name + " - runid: " + runId + " - yield " + stepId++, gen["throw"]).call(gen, err); + } catch (e33) { + return reject(e33); + } + next(ret); + } + function next(ret) { + if (isFunction(ret == null ? void 0 : ret.then)) { + ret.then(next, reject); + return; + } + if (ret.done) { + return resolve(ret.value); + } + pendingPromise = Promise.resolve(ret.value); + return pendingPromise.then(onFulfilled, onRejected); + } + onFulfilled(void 0); + }); + promise.cancel = action(name + " - runid: " + runId + " - cancel", function() { + try { + if (pendingPromise) { + cancelPromise(pendingPromise); + } + var _res = gen["return"](void 0); + var yieldedPromise = Promise.resolve(_res.value); + yieldedPromise.then(noop, noop); + cancelPromise(yieldedPromise); + rejector(new FlowCancellationError()); + } catch (e33) { + rejector(e33); + } + }); + return promise; + }; + res.isMobXFlow = true; + return res; + }, flowAnnotation); + flow.bound = /* @__PURE__ */ createDecoratorAnnotation(flowBoundAnnotation); + function cancelPromise(promise) { + if (isFunction(promise.cancel)) { + promise.cancel(); + } + } + function isFlow(fn2) { + return (fn2 == null ? void 0 : fn2.isMobXFlow) === true; + } + function _isObservable(value, property) { + if (!value) { + return false; + } + if (property !== void 0) { + if (isObservableMap(value) || isObservableArray(value)) { + return die("isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead."); + } + if (isObservableObject(value)) { + return value[$mobx].values_.has(property); + } + return false; + } + return isObservableObject(value) || !!value[$mobx] || isAtom(value) || isReaction(value) || isComputedValue(value); + } + function isObservable(value) { + if (arguments.length !== 1) { + die("isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property"); + } + return _isObservable(value); + } + function trace() { + if (false) { + return; + } + var enterBreakPoint = false; + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + if (typeof args[args.length - 1] === "boolean") { + enterBreakPoint = args.pop(); + } + var derivation = getAtomFromArgs(args); + if (!derivation) { + return die("'trace(break?)' can only be used inside a tracked computed value or a Reaction. Consider passing in the computed value or reaction explicitly"); + } + if (derivation.isTracing_ === TraceMode.NONE) { + console.log("[mobx.trace] '" + derivation.name_ + "' tracing enabled"); + } + derivation.isTracing_ = enterBreakPoint ? TraceMode.BREAK : TraceMode.LOG; + } + function getAtomFromArgs(args) { + switch (args.length) { + case 0: + return globalState.trackingDerivation; + case 1: + return getAtom(args[0]); + case 2: + return getAtom(args[0], args[1]); + } + } + function transaction(action2, thisArg) { + if (thisArg === void 0) { + thisArg = void 0; + } + startBatch(); + try { + return action2.apply(thisArg); + } finally { + endBatch(); + } + } + function getAdm(target) { + return target[$mobx]; + } + var objectProxyTraps = { + has: function has(target, name) { + if (globalState.trackingDerivation) { + warnAboutProxyRequirement("detect new properties using the 'in' operator. Use 'has' from 'mobx' instead."); + } + return getAdm(target).has_(name); + }, + get: function get(target, name) { + return getAdm(target).get_(name); + }, + set: function set2(target, name, value) { + var _getAdm$set_; + if (!isStringish(name)) { + return false; + } + if (!getAdm(target).values_.has(name)) { + warnAboutProxyRequirement("add a new observable property through direct assignment. Use 'set' from 'mobx' instead."); + } + return (_getAdm$set_ = getAdm(target).set_(name, value, true)) != null ? _getAdm$set_ : true; + }, + deleteProperty: function deleteProperty(target, name) { + var _getAdm$delete_; + if (true) { + warnAboutProxyRequirement("delete properties from an observable object. Use 'remove' from 'mobx' instead."); + } + if (!isStringish(name)) { + return false; + } + return (_getAdm$delete_ = getAdm(target).delete_(name, true)) != null ? _getAdm$delete_ : true; + }, + defineProperty: function defineProperty2(target, name, descriptor) { + var _getAdm$definePropert; + if (true) { + warnAboutProxyRequirement("define property on an observable object. Use 'defineProperty' from 'mobx' instead."); + } + return (_getAdm$definePropert = getAdm(target).defineProperty_(name, descriptor)) != null ? _getAdm$definePropert : true; + }, + ownKeys: function ownKeys2(target) { + if (globalState.trackingDerivation) { + warnAboutProxyRequirement("iterate keys to detect added / removed properties. Use 'keys' from 'mobx' instead."); + } + return getAdm(target).ownKeys_(); + }, + preventExtensions: function preventExtensions(target) { + die(13); + } + }; + function asDynamicObservableObject(target, options) { + var _target$$mobx, _target$$mobx$proxy_; + assertProxies(); + target = asObservableObject(target, options); + return (_target$$mobx$proxy_ = (_target$$mobx = target[$mobx]).proxy_) != null ? _target$$mobx$proxy_ : _target$$mobx.proxy_ = new Proxy(target, objectProxyTraps); + } + function hasInterceptors(interceptable) { + return interceptable.interceptors_ !== void 0 && interceptable.interceptors_.length > 0; + } + function registerInterceptor(interceptable, handler) { + var interceptors = interceptable.interceptors_ || (interceptable.interceptors_ = []); + interceptors.push(handler); + return once(function() { + var idx = interceptors.indexOf(handler); + if (idx !== -1) { + interceptors.splice(idx, 1); + } + }); + } + function interceptChange(interceptable, change2) { + var prevU = untrackedStart(); + try { + var interceptors = [].concat(interceptable.interceptors_ || []); + for (var i23 = 0, l20 = interceptors.length; i23 < l20; i23++) { + change2 = interceptors[i23](change2); + if (change2 && !change2.type) { + die(14); + } + if (!change2) { + break; + } + } + return change2; + } finally { + untrackedEnd(prevU); + } + } + function hasListeners(listenable) { + return listenable.changeListeners_ !== void 0 && listenable.changeListeners_.length > 0; + } + function registerListener(listenable, handler) { + var listeners = listenable.changeListeners_ || (listenable.changeListeners_ = []); + listeners.push(handler); + return once(function() { + var idx = listeners.indexOf(handler); + if (idx !== -1) { + listeners.splice(idx, 1); + } + }); + } + function notifyListeners(listenable, change2) { + var prevU = untrackedStart(); + var listeners = listenable.changeListeners_; + if (!listeners) { + return; + } + listeners = listeners.slice(); + for (var i23 = 0, l20 = listeners.length; i23 < l20; i23++) { + listeners[i23](change2); + } + untrackedEnd(prevU); + } + function makeObservable(target, annotations, options) { + initObservable(function() { + var _annotations; + var adm = asObservableObject(target, options)[$mobx]; + if (annotations && target[storedAnnotationsSymbol]) { + die("makeObservable second arg must be nullish when using decorators. Mixing @decorator syntax with annotations is not supported."); + } + (_annotations = annotations) != null ? _annotations : annotations = collectStoredAnnotations(target); + ownKeys(annotations).forEach(function(key) { + return adm.make_(key, annotations[key]); + }); + }); + return target; + } + var SPLICE = "splice"; + var UPDATE = "update"; + var MAX_SPLICE_SIZE = 1e4; + var arrayTraps = { + get: function get2(target, name) { + var adm = target[$mobx]; + if (name === $mobx) { + return adm; + } + if (name === "length") { + return adm.getArrayLength_(); + } + if (typeof name === "string" && !isNaN(name)) { + return adm.get_(parseInt(name)); + } + if (hasProp(arrayExtensions, name)) { + return arrayExtensions[name]; + } + return target[name]; + }, + set: function set3(target, name, value) { + var adm = target[$mobx]; + if (name === "length") { + adm.setArrayLength_(value); + } + if (typeof name === "symbol" || isNaN(name)) { + target[name] = value; + } else { + adm.set_(parseInt(name), value); + } + return true; + }, + preventExtensions: function preventExtensions2() { + die(15); + } + }; + var ObservableArrayAdministration = /* @__PURE__ */ function() { + function ObservableArrayAdministration2(name, enhancer, owned_, legacyMode_) { + if (name === void 0) { + name = true ? "ObservableArray@" + getNextId() : "ObservableArray"; + } + this.owned_ = void 0; + this.legacyMode_ = void 0; + this.atom_ = void 0; + this.values_ = []; + this.interceptors_ = void 0; + this.changeListeners_ = void 0; + this.enhancer_ = void 0; + this.dehancer = void 0; + this.proxy_ = void 0; + this.lastKnownLength_ = 0; + this.owned_ = owned_; + this.legacyMode_ = legacyMode_; + this.atom_ = new Atom(name); + this.enhancer_ = function(newV, oldV) { + return enhancer(newV, oldV, true ? name + "[..]" : "ObservableArray[..]"); + }; + } + var _proto = ObservableArrayAdministration2.prototype; + _proto.dehanceValue_ = function dehanceValue_(value) { + if (this.dehancer !== void 0) { + return this.dehancer(value); + } + return value; + }; + _proto.dehanceValues_ = function dehanceValues_(values) { + if (this.dehancer !== void 0 && values.length > 0) { + return values.map(this.dehancer); + } + return values; + }; + _proto.intercept_ = function intercept_(handler) { + return registerInterceptor(this, handler); + }; + _proto.observe_ = function observe_(listener, fireImmediately) { + if (fireImmediately === void 0) { + fireImmediately = false; + } + if (fireImmediately) { + listener({ + observableKind: "array", + object: this.proxy_, + debugObjectName: this.atom_.name_, + type: "splice", + index: 0, + added: this.values_.slice(), + addedCount: this.values_.length, + removed: [], + removedCount: 0 + }); + } + return registerListener(this, listener); + }; + _proto.getArrayLength_ = function getArrayLength_() { + this.atom_.reportObserved(); + return this.values_.length; + }; + _proto.setArrayLength_ = function setArrayLength_(newLength) { + if (typeof newLength !== "number" || isNaN(newLength) || newLength < 0) { + die("Out of range: " + newLength); + } + var currentLength = this.values_.length; + if (newLength === currentLength) { + return; + } else if (newLength > currentLength) { + var newItems = new Array(newLength - currentLength); + for (var i23 = 0; i23 < newLength - currentLength; i23++) { + newItems[i23] = void 0; + } + this.spliceWithArray_(currentLength, 0, newItems); + } else { + this.spliceWithArray_(newLength, currentLength - newLength); + } + }; + _proto.updateArrayLength_ = function updateArrayLength_(oldLength, delta) { + if (oldLength !== this.lastKnownLength_) { + die(16); + } + this.lastKnownLength_ += delta; + if (this.legacyMode_ && delta > 0) { + reserveArrayBuffer(oldLength + delta + 1); + } + }; + _proto.spliceWithArray_ = function spliceWithArray_(index, deleteCount, newItems) { + var _this = this; + checkIfStateModificationsAreAllowed(this.atom_); + var length = this.values_.length; + if (index === void 0) { + index = 0; + } else if (index > length) { + index = length; + } else if (index < 0) { + index = Math.max(0, length + index); + } + if (arguments.length === 1) { + deleteCount = length - index; + } else if (deleteCount === void 0 || deleteCount === null) { + deleteCount = 0; + } else { + deleteCount = Math.max(0, Math.min(deleteCount, length - index)); + } + if (newItems === void 0) { + newItems = EMPTY_ARRAY; + } + if (hasInterceptors(this)) { + var change2 = interceptChange(this, { + object: this.proxy_, + type: SPLICE, + index, + removedCount: deleteCount, + added: newItems + }); + if (!change2) { + return EMPTY_ARRAY; + } + deleteCount = change2.removedCount; + newItems = change2.added; + } + newItems = newItems.length === 0 ? newItems : newItems.map(function(v6) { + return _this.enhancer_(v6, void 0); + }); + if (this.legacyMode_ || true) { + var lengthDelta = newItems.length - deleteCount; + this.updateArrayLength_(length, lengthDelta); + } + var res = this.spliceItemsIntoValues_(index, deleteCount, newItems); + if (deleteCount !== 0 || newItems.length !== 0) { + this.notifyArraySplice_(index, newItems, res); + } + return this.dehanceValues_(res); + }; + _proto.spliceItemsIntoValues_ = function spliceItemsIntoValues_(index, deleteCount, newItems) { + if (newItems.length < MAX_SPLICE_SIZE) { + var _this$values_; + return (_this$values_ = this.values_).splice.apply(_this$values_, [index, deleteCount].concat(newItems)); + } else { + var res = this.values_.slice(index, index + deleteCount); + var oldItems = this.values_.slice(index + deleteCount); + this.values_.length += newItems.length - deleteCount; + for (var i23 = 0; i23 < newItems.length; i23++) { + this.values_[index + i23] = newItems[i23]; + } + for (var _i = 0; _i < oldItems.length; _i++) { + this.values_[index + newItems.length + _i] = oldItems[_i]; + } + return res; + } + }; + _proto.notifyArrayChildUpdate_ = function notifyArrayChildUpdate_(index, newValue, oldValue) { + var notifySpy = !this.owned_ && isSpyEnabled(); + var notify = hasListeners(this); + var change2 = notify || notifySpy ? { + observableKind: "array", + object: this.proxy_, + type: UPDATE, + debugObjectName: this.atom_.name_, + index, + newValue, + oldValue + } : null; + if (notifySpy) { + spyReportStart(change2); + } + this.atom_.reportChanged(); + if (notify) { + notifyListeners(this, change2); + } + if (notifySpy) { + spyReportEnd(); + } + }; + _proto.notifyArraySplice_ = function notifyArraySplice_(index, added, removed) { + var notifySpy = !this.owned_ && isSpyEnabled(); + var notify = hasListeners(this); + var change2 = notify || notifySpy ? { + observableKind: "array", + object: this.proxy_, + debugObjectName: this.atom_.name_, + type: SPLICE, + index, + removed, + added, + removedCount: removed.length, + addedCount: added.length + } : null; + if (notifySpy) { + spyReportStart(change2); + } + this.atom_.reportChanged(); + if (notify) { + notifyListeners(this, change2); + } + if (notifySpy) { + spyReportEnd(); + } + }; + _proto.get_ = function get_(index) { + if (this.legacyMode_ && index >= this.values_.length) { + console.warn(true ? "[mobx.array] Attempt to read an array index (" + index + ") that is out of bounds (" + this.values_.length + "). Please check length first. Out of bound indices will not be tracked by MobX" : "[mobx] Out of bounds read: " + index); + return void 0; + } + this.atom_.reportObserved(); + return this.dehanceValue_(this.values_[index]); + }; + _proto.set_ = function set_(index, newValue) { + var values = this.values_; + if (this.legacyMode_ && index > values.length) { + die(17, index, values.length); + } + if (index < values.length) { + checkIfStateModificationsAreAllowed(this.atom_); + var oldValue = values[index]; + if (hasInterceptors(this)) { + var change2 = interceptChange(this, { + type: UPDATE, + object: this.proxy_, + index, + newValue + }); + if (!change2) { + return; + } + newValue = change2.newValue; + } + newValue = this.enhancer_(newValue, oldValue); + var changed = newValue !== oldValue; + if (changed) { + values[index] = newValue; + this.notifyArrayChildUpdate_(index, newValue, oldValue); + } + } else { + var newItems = new Array(index + 1 - values.length); + for (var i23 = 0; i23 < newItems.length - 1; i23++) { + newItems[i23] = void 0; + } + newItems[newItems.length - 1] = newValue; + this.spliceWithArray_(values.length, 0, newItems); + } + }; + return ObservableArrayAdministration2; + }(); + function createObservableArray(initialValues, enhancer, name, owned) { + if (name === void 0) { + name = true ? "ObservableArray@" + getNextId() : "ObservableArray"; + } + if (owned === void 0) { + owned = false; + } + assertProxies(); + return initObservable(function() { + var adm = new ObservableArrayAdministration(name, enhancer, owned, false); + addHiddenFinalProp(adm.values_, $mobx, adm); + var proxy = new Proxy(adm.values_, arrayTraps); + adm.proxy_ = proxy; + if (initialValues && initialValues.length) { + adm.spliceWithArray_(0, 0, initialValues); + } + return proxy; + }); + } + var arrayExtensions = { + clear: function clear() { + return this.splice(0); + }, + replace: function replace(newItems) { + var adm = this[$mobx]; + return adm.spliceWithArray_(0, adm.values_.length, newItems); + }, + // Used by JSON.stringify + toJSON: function toJSON() { + return this.slice(); + }, + /* + * functions that do alter the internal structure of the array, (based on lib.es6.d.ts) + * since these functions alter the inner structure of the array, the have side effects. + * Because the have side effects, they should not be used in computed function, + * and for that reason the do not call dependencyState.notifyObserved + */ + splice: function splice(index, deleteCount) { + for (var _len = arguments.length, newItems = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + newItems[_key - 2] = arguments[_key]; + } + var adm = this[$mobx]; + switch (arguments.length) { + case 0: + return []; + case 1: + return adm.spliceWithArray_(index); + case 2: + return adm.spliceWithArray_(index, deleteCount); + } + return adm.spliceWithArray_(index, deleteCount, newItems); + }, + spliceWithArray: function spliceWithArray(index, deleteCount, newItems) { + return this[$mobx].spliceWithArray_(index, deleteCount, newItems); + }, + push: function push() { + var adm = this[$mobx]; + for (var _len2 = arguments.length, items = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + items[_key2] = arguments[_key2]; + } + adm.spliceWithArray_(adm.values_.length, 0, items); + return adm.values_.length; + }, + pop: function pop() { + return this.splice(Math.max(this[$mobx].values_.length - 1, 0), 1)[0]; + }, + shift: function shift() { + return this.splice(0, 1)[0]; + }, + unshift: function unshift() { + var adm = this[$mobx]; + for (var _len3 = arguments.length, items = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + items[_key3] = arguments[_key3]; + } + adm.spliceWithArray_(0, 0, items); + return adm.values_.length; + }, + reverse: function reverse() { + if (globalState.trackingDerivation) { + die(37, "reverse"); + } + this.replace(this.slice().reverse()); + return this; + }, + sort: function sort() { + if (globalState.trackingDerivation) { + die(37, "sort"); + } + var copy = this.slice(); + copy.sort.apply(copy, arguments); + this.replace(copy); + return this; + }, + remove: function remove(value) { + var adm = this[$mobx]; + var idx = adm.dehanceValues_(adm.values_).indexOf(value); + if (idx > -1) { + this.splice(idx, 1); + return true; + } + return false; + } + }; + addArrayExtension("at", simpleFunc); + addArrayExtension("concat", simpleFunc); + addArrayExtension("flat", simpleFunc); + addArrayExtension("includes", simpleFunc); + addArrayExtension("indexOf", simpleFunc); + addArrayExtension("join", simpleFunc); + addArrayExtension("lastIndexOf", simpleFunc); + addArrayExtension("slice", simpleFunc); + addArrayExtension("toString", simpleFunc); + addArrayExtension("toLocaleString", simpleFunc); + addArrayExtension("toSorted", simpleFunc); + addArrayExtension("toSpliced", simpleFunc); + addArrayExtension("with", simpleFunc); + addArrayExtension("every", mapLikeFunc); + addArrayExtension("filter", mapLikeFunc); + addArrayExtension("find", mapLikeFunc); + addArrayExtension("findIndex", mapLikeFunc); + addArrayExtension("findLast", mapLikeFunc); + addArrayExtension("findLastIndex", mapLikeFunc); + addArrayExtension("flatMap", mapLikeFunc); + addArrayExtension("forEach", mapLikeFunc); + addArrayExtension("map", mapLikeFunc); + addArrayExtension("some", mapLikeFunc); + addArrayExtension("toReversed", mapLikeFunc); + addArrayExtension("reduce", reduceLikeFunc); + addArrayExtension("reduceRight", reduceLikeFunc); + function addArrayExtension(funcName, funcFactory) { + if (typeof Array.prototype[funcName] === "function") { + arrayExtensions[funcName] = funcFactory(funcName); + } + } + function simpleFunc(funcName) { + return function() { + var adm = this[$mobx]; + adm.atom_.reportObserved(); + var dehancedValues = adm.dehanceValues_(adm.values_); + return dehancedValues[funcName].apply(dehancedValues, arguments); + }; + } + function mapLikeFunc(funcName) { + return function(callback, thisArg) { + var _this2 = this; + var adm = this[$mobx]; + adm.atom_.reportObserved(); + var dehancedValues = adm.dehanceValues_(adm.values_); + return dehancedValues[funcName](function(element, index) { + return callback.call(thisArg, element, index, _this2); + }); + }; + } + function reduceLikeFunc(funcName) { + return function() { + var _this3 = this; + var adm = this[$mobx]; + adm.atom_.reportObserved(); + var dehancedValues = adm.dehanceValues_(adm.values_); + var callback = arguments[0]; + arguments[0] = function(accumulator, currentValue, index) { + return callback(accumulator, currentValue, index, _this3); + }; + return dehancedValues[funcName].apply(dehancedValues, arguments); + }; + } + var isObservableArrayAdministration = /* @__PURE__ */ createInstanceofPredicate("ObservableArrayAdministration", ObservableArrayAdministration); + function isObservableArray(thing) { + return isObject(thing) && isObservableArrayAdministration(thing[$mobx]); + } + var _Symbol$iterator; + var _Symbol$toStringTag; + var ObservableMapMarker = {}; + var ADD = "add"; + var DELETE = "delete"; + _Symbol$iterator = Symbol.iterator; + _Symbol$toStringTag = Symbol.toStringTag; + var ObservableMap = /* @__PURE__ */ function() { + function ObservableMap2(initialData, enhancer_, name_) { + var _this = this; + if (enhancer_ === void 0) { + enhancer_ = deepEnhancer; + } + if (name_ === void 0) { + name_ = true ? "ObservableMap@" + getNextId() : "ObservableMap"; + } + this.enhancer_ = void 0; + this.name_ = void 0; + this[$mobx] = ObservableMapMarker; + this.data_ = void 0; + this.hasMap_ = void 0; + this.keysAtom_ = void 0; + this.interceptors_ = void 0; + this.changeListeners_ = void 0; + this.dehancer = void 0; + this.enhancer_ = enhancer_; + this.name_ = name_; + if (!isFunction(Map)) { + die(18); + } + initObservable(function() { + _this.keysAtom_ = createAtom(true ? _this.name_ + ".keys()" : "ObservableMap.keys()"); + _this.data_ = /* @__PURE__ */ new Map(); + _this.hasMap_ = /* @__PURE__ */ new Map(); + if (initialData) { + _this.merge(initialData); + } + }); + } + var _proto = ObservableMap2.prototype; + _proto.has_ = function has_(key) { + return this.data_.has(key); + }; + _proto.has = function has2(key) { + var _this2 = this; + if (!globalState.trackingDerivation) { + return this.has_(key); + } + var entry = this.hasMap_.get(key); + if (!entry) { + var newEntry = entry = new ObservableValue(this.has_(key), referenceEnhancer, true ? this.name_ + "." + stringifyKey(key) + "?" : "ObservableMap.key?", false); + this.hasMap_.set(key, newEntry); + onBecomeUnobserved(newEntry, function() { + return _this2.hasMap_["delete"](key); + }); + } + return entry.get(); + }; + _proto.set = function set4(key, value) { + var hasKey = this.has_(key); + if (hasInterceptors(this)) { + var change2 = interceptChange(this, { + type: hasKey ? UPDATE : ADD, + object: this, + newValue: value, + name: key + }); + if (!change2) { + return this; + } + value = change2.newValue; + } + if (hasKey) { + this.updateValue_(key, value); + } else { + this.addValue_(key, value); + } + return this; + }; + _proto["delete"] = function _delete(key) { + var _this3 = this; + checkIfStateModificationsAreAllowed(this.keysAtom_); + if (hasInterceptors(this)) { + var change2 = interceptChange(this, { + type: DELETE, + object: this, + name: key + }); + if (!change2) { + return false; + } + } + if (this.has_(key)) { + var notifySpy = isSpyEnabled(); + var notify = hasListeners(this); + var _change = notify || notifySpy ? { + observableKind: "map", + debugObjectName: this.name_, + type: DELETE, + object: this, + oldValue: this.data_.get(key).value_, + name: key + } : null; + if (notifySpy) { + spyReportStart(_change); + } + transaction(function() { + var _this3$hasMap_$get; + _this3.keysAtom_.reportChanged(); + (_this3$hasMap_$get = _this3.hasMap_.get(key)) == null ? void 0 : _this3$hasMap_$get.setNewValue_(false); + var observable2 = _this3.data_.get(key); + observable2.setNewValue_(void 0); + _this3.data_["delete"](key); + }); + if (notify) { + notifyListeners(this, _change); + } + if (notifySpy) { + spyReportEnd(); + } + return true; + } + return false; + }; + _proto.updateValue_ = function updateValue_(key, newValue) { + var observable2 = this.data_.get(key); + newValue = observable2.prepareNewValue_(newValue); + if (newValue !== globalState.UNCHANGED) { + var notifySpy = isSpyEnabled(); + var notify = hasListeners(this); + var change2 = notify || notifySpy ? { + observableKind: "map", + debugObjectName: this.name_, + type: UPDATE, + object: this, + oldValue: observable2.value_, + name: key, + newValue + } : null; + if (notifySpy) { + spyReportStart(change2); + } + observable2.setNewValue_(newValue); + if (notify) { + notifyListeners(this, change2); + } + if (notifySpy) { + spyReportEnd(); + } + } + }; + _proto.addValue_ = function addValue_(key, newValue) { + var _this4 = this; + checkIfStateModificationsAreAllowed(this.keysAtom_); + transaction(function() { + var _this4$hasMap_$get; + var observable2 = new ObservableValue(newValue, _this4.enhancer_, true ? _this4.name_ + "." + stringifyKey(key) : "ObservableMap.key", false); + _this4.data_.set(key, observable2); + newValue = observable2.value_; + (_this4$hasMap_$get = _this4.hasMap_.get(key)) == null ? void 0 : _this4$hasMap_$get.setNewValue_(true); + _this4.keysAtom_.reportChanged(); + }); + var notifySpy = isSpyEnabled(); + var notify = hasListeners(this); + var change2 = notify || notifySpy ? { + observableKind: "map", + debugObjectName: this.name_, + type: ADD, + object: this, + name: key, + newValue + } : null; + if (notifySpy) { + spyReportStart(change2); + } + if (notify) { + notifyListeners(this, change2); + } + if (notifySpy) { + spyReportEnd(); + } + }; + _proto.get = function get3(key) { + if (this.has(key)) { + return this.dehanceValue_(this.data_.get(key).get()); + } + return this.dehanceValue_(void 0); + }; + _proto.dehanceValue_ = function dehanceValue_(value) { + if (this.dehancer !== void 0) { + return this.dehancer(value); + } + return value; + }; + _proto.keys = function keys() { + this.keysAtom_.reportObserved(); + return this.data_.keys(); + }; + _proto.values = function values() { + var self2 = this; + var keys = this.keys(); + return makeIterable({ + next: function next() { + var _keys$next = keys.next(), done = _keys$next.done, value = _keys$next.value; + return { + done, + value: done ? void 0 : self2.get(value) + }; + } + }); + }; + _proto.entries = function entries() { + var self2 = this; + var keys = this.keys(); + return makeIterable({ + next: function next() { + var _keys$next2 = keys.next(), done = _keys$next2.done, value = _keys$next2.value; + return { + done, + value: done ? void 0 : [value, self2.get(value)] + }; + } + }); + }; + _proto[_Symbol$iterator] = function() { + return this.entries(); + }; + _proto.forEach = function forEach(callback, thisArg) { + for (var _iterator = _createForOfIteratorHelperLoose(this), _step; !(_step = _iterator()).done; ) { + var _step$value = _step.value, key = _step$value[0], value = _step$value[1]; + callback.call(thisArg, value, key, this); + } + }; + _proto.merge = function merge(other) { + var _this5 = this; + if (isObservableMap(other)) { + other = new Map(other); + } + transaction(function() { + if (isPlainObject(other)) { + getPlainObjectKeys(other).forEach(function(key) { + return _this5.set(key, other[key]); + }); + } else if (Array.isArray(other)) { + other.forEach(function(_ref) { + var key = _ref[0], value = _ref[1]; + return _this5.set(key, value); + }); + } else if (isES6Map(other)) { + if (other.constructor !== Map) { + die(19, other); + } + other.forEach(function(value, key) { + return _this5.set(key, value); + }); + } else if (other !== null && other !== void 0) { + die(20, other); + } + }); + return this; + }; + _proto.clear = function clear2() { + var _this6 = this; + transaction(function() { + untracked(function() { + for (var _iterator2 = _createForOfIteratorHelperLoose(_this6.keys()), _step2; !(_step2 = _iterator2()).done; ) { + var key = _step2.value; + _this6["delete"](key); + } + }); + }); + }; + _proto.replace = function replace2(values) { + var _this7 = this; + transaction(function() { + var replacementMap = convertToMap(values); + var orderedData = /* @__PURE__ */ new Map(); + var keysReportChangedCalled = false; + for (var _iterator3 = _createForOfIteratorHelperLoose(_this7.data_.keys()), _step3; !(_step3 = _iterator3()).done; ) { + var key = _step3.value; + if (!replacementMap.has(key)) { + var deleted = _this7["delete"](key); + if (deleted) { + keysReportChangedCalled = true; + } else { + var value = _this7.data_.get(key); + orderedData.set(key, value); + } + } + } + for (var _iterator4 = _createForOfIteratorHelperLoose(replacementMap.entries()), _step4; !(_step4 = _iterator4()).done; ) { + var _step4$value = _step4.value, _key = _step4$value[0], _value = _step4$value[1]; + var keyExisted = _this7.data_.has(_key); + _this7.set(_key, _value); + if (_this7.data_.has(_key)) { + var _value2 = _this7.data_.get(_key); + orderedData.set(_key, _value2); + if (!keyExisted) { + keysReportChangedCalled = true; + } + } + } + if (!keysReportChangedCalled) { + if (_this7.data_.size !== orderedData.size) { + _this7.keysAtom_.reportChanged(); + } else { + var iter1 = _this7.data_.keys(); + var iter2 = orderedData.keys(); + var next1 = iter1.next(); + var next2 = iter2.next(); + while (!next1.done) { + if (next1.value !== next2.value) { + _this7.keysAtom_.reportChanged(); + break; + } + next1 = iter1.next(); + next2 = iter2.next(); + } + } + } + _this7.data_ = orderedData; + }); + return this; + }; + _proto.toString = function toString2() { + return "[object ObservableMap]"; + }; + _proto.toJSON = function toJSON2() { + return Array.from(this); + }; + _proto.observe_ = function observe_(listener, fireImmediately) { + if (fireImmediately === true) { + die("`observe` doesn't support fireImmediately=true in combination with maps."); + } + return registerListener(this, listener); + }; + _proto.intercept_ = function intercept_(handler) { + return registerInterceptor(this, handler); + }; + _createClass(ObservableMap2, [{ + key: "size", + get: function get3() { + this.keysAtom_.reportObserved(); + return this.data_.size; + } + }, { + key: _Symbol$toStringTag, + get: function get3() { + return "Map"; + } + }]); + return ObservableMap2; + }(); + var isObservableMap = /* @__PURE__ */ createInstanceofPredicate("ObservableMap", ObservableMap); + function convertToMap(dataStructure) { + if (isES6Map(dataStructure) || isObservableMap(dataStructure)) { + return dataStructure; + } else if (Array.isArray(dataStructure)) { + return new Map(dataStructure); + } else if (isPlainObject(dataStructure)) { + var map2 = /* @__PURE__ */ new Map(); + for (var key in dataStructure) { + map2.set(key, dataStructure[key]); + } + return map2; + } else { + return die(21, dataStructure); + } + } + var _Symbol$iterator$1; + var _Symbol$toStringTag$1; + var ObservableSetMarker = {}; + _Symbol$iterator$1 = Symbol.iterator; + _Symbol$toStringTag$1 = Symbol.toStringTag; + var ObservableSet = /* @__PURE__ */ function() { + function ObservableSet2(initialData, enhancer, name_) { + var _this = this; + if (enhancer === void 0) { + enhancer = deepEnhancer; + } + if (name_ === void 0) { + name_ = true ? "ObservableSet@" + getNextId() : "ObservableSet"; + } + this.name_ = void 0; + this[$mobx] = ObservableSetMarker; + this.data_ = /* @__PURE__ */ new Set(); + this.atom_ = void 0; + this.changeListeners_ = void 0; + this.interceptors_ = void 0; + this.dehancer = void 0; + this.enhancer_ = void 0; + this.name_ = name_; + if (!isFunction(Set)) { + die(22); + } + this.enhancer_ = function(newV, oldV) { + return enhancer(newV, oldV, name_); + }; + initObservable(function() { + _this.atom_ = createAtom(_this.name_); + if (initialData) { + _this.replace(initialData); + } + }); + } + var _proto = ObservableSet2.prototype; + _proto.dehanceValue_ = function dehanceValue_(value) { + if (this.dehancer !== void 0) { + return this.dehancer(value); + } + return value; + }; + _proto.clear = function clear2() { + var _this2 = this; + transaction(function() { + untracked(function() { + for (var _iterator = _createForOfIteratorHelperLoose(_this2.data_.values()), _step; !(_step = _iterator()).done; ) { + var value = _step.value; + _this2["delete"](value); + } + }); + }); + }; + _proto.forEach = function forEach(callbackFn, thisArg) { + for (var _iterator2 = _createForOfIteratorHelperLoose(this), _step2; !(_step2 = _iterator2()).done; ) { + var value = _step2.value; + callbackFn.call(thisArg, value, value, this); + } + }; + _proto.add = function add(value) { + var _this3 = this; + checkIfStateModificationsAreAllowed(this.atom_); + if (hasInterceptors(this)) { + var change2 = interceptChange(this, { + type: ADD, + object: this, + newValue: value + }); + if (!change2) { + return this; + } + } + if (!this.has(value)) { + transaction(function() { + _this3.data_.add(_this3.enhancer_(value, void 0)); + _this3.atom_.reportChanged(); + }); + var notifySpy = isSpyEnabled(); + var notify = hasListeners(this); + var _change = notify || notifySpy ? { + observableKind: "set", + debugObjectName: this.name_, + type: ADD, + object: this, + newValue: value + } : null; + if (notifySpy && true) { + spyReportStart(_change); + } + if (notify) { + notifyListeners(this, _change); + } + if (notifySpy && true) { + spyReportEnd(); + } + } + return this; + }; + _proto["delete"] = function _delete(value) { + var _this4 = this; + if (hasInterceptors(this)) { + var change2 = interceptChange(this, { + type: DELETE, + object: this, + oldValue: value + }); + if (!change2) { + return false; + } + } + if (this.has(value)) { + var notifySpy = isSpyEnabled(); + var notify = hasListeners(this); + var _change2 = notify || notifySpy ? { + observableKind: "set", + debugObjectName: this.name_, + type: DELETE, + object: this, + oldValue: value + } : null; + if (notifySpy && true) { + spyReportStart(_change2); + } + transaction(function() { + _this4.atom_.reportChanged(); + _this4.data_["delete"](value); + }); + if (notify) { + notifyListeners(this, _change2); + } + if (notifySpy && true) { + spyReportEnd(); + } + return true; + } + return false; + }; + _proto.has = function has2(value) { + this.atom_.reportObserved(); + return this.data_.has(this.dehanceValue_(value)); + }; + _proto.entries = function entries() { + var nextIndex = 0; + var keys = Array.from(this.keys()); + var values = Array.from(this.values()); + return makeIterable({ + next: function next() { + var index = nextIndex; + nextIndex += 1; + return index < values.length ? { + value: [keys[index], values[index]], + done: false + } : { + done: true + }; + } + }); + }; + _proto.keys = function keys() { + return this.values(); + }; + _proto.values = function values() { + this.atom_.reportObserved(); + var self2 = this; + var nextIndex = 0; + var observableValues = Array.from(this.data_.values()); + return makeIterable({ + next: function next() { + return nextIndex < observableValues.length ? { + value: self2.dehanceValue_(observableValues[nextIndex++]), + done: false + } : { + done: true + }; + } + }); + }; + _proto.replace = function replace2(other) { + var _this5 = this; + if (isObservableSet(other)) { + other = new Set(other); + } + transaction(function() { + if (Array.isArray(other)) { + _this5.clear(); + other.forEach(function(value) { + return _this5.add(value); + }); + } else if (isES6Set(other)) { + _this5.clear(); + other.forEach(function(value) { + return _this5.add(value); + }); + } else if (other !== null && other !== void 0) { + die("Cannot initialize set from " + other); + } + }); + return this; + }; + _proto.observe_ = function observe_(listener, fireImmediately) { + if (fireImmediately === true) { + die("`observe` doesn't support fireImmediately=true in combination with sets."); + } + return registerListener(this, listener); + }; + _proto.intercept_ = function intercept_(handler) { + return registerInterceptor(this, handler); + }; + _proto.toJSON = function toJSON2() { + return Array.from(this); + }; + _proto.toString = function toString2() { + return "[object ObservableSet]"; + }; + _proto[_Symbol$iterator$1] = function() { + return this.values(); + }; + _createClass(ObservableSet2, [{ + key: "size", + get: function get3() { + this.atom_.reportObserved(); + return this.data_.size; + } + }, { + key: _Symbol$toStringTag$1, + get: function get3() { + return "Set"; + } + }]); + return ObservableSet2; + }(); + var isObservableSet = /* @__PURE__ */ createInstanceofPredicate("ObservableSet", ObservableSet); + var descriptorCache = /* @__PURE__ */ Object.create(null); + var REMOVE = "remove"; + var ObservableObjectAdministration = /* @__PURE__ */ function() { + function ObservableObjectAdministration2(target_, values_, name_, defaultAnnotation_) { + if (values_ === void 0) { + values_ = /* @__PURE__ */ new Map(); + } + if (defaultAnnotation_ === void 0) { + defaultAnnotation_ = autoAnnotation; + } + this.target_ = void 0; + this.values_ = void 0; + this.name_ = void 0; + this.defaultAnnotation_ = void 0; + this.keysAtom_ = void 0; + this.changeListeners_ = void 0; + this.interceptors_ = void 0; + this.proxy_ = void 0; + this.isPlainObject_ = void 0; + this.appliedAnnotations_ = void 0; + this.pendingKeys_ = void 0; + this.target_ = target_; + this.values_ = values_; + this.name_ = name_; + this.defaultAnnotation_ = defaultAnnotation_; + this.keysAtom_ = new Atom(true ? this.name_ + ".keys" : "ObservableObject.keys"); + this.isPlainObject_ = isPlainObject(this.target_); + if (!isAnnotation(this.defaultAnnotation_)) { + die("defaultAnnotation must be valid annotation"); + } + if (true) { + this.appliedAnnotations_ = {}; + } + } + var _proto = ObservableObjectAdministration2.prototype; + _proto.getObservablePropValue_ = function getObservablePropValue_(key) { + return this.values_.get(key).get(); + }; + _proto.setObservablePropValue_ = function setObservablePropValue_(key, newValue) { + var observable2 = this.values_.get(key); + if (observable2 instanceof ComputedValue) { + observable2.set(newValue); + return true; + } + if (hasInterceptors(this)) { + var change2 = interceptChange(this, { + type: UPDATE, + object: this.proxy_ || this.target_, + name: key, + newValue + }); + if (!change2) { + return null; + } + newValue = change2.newValue; + } + newValue = observable2.prepareNewValue_(newValue); + if (newValue !== globalState.UNCHANGED) { + var notify = hasListeners(this); + var notifySpy = isSpyEnabled(); + var _change = notify || notifySpy ? { + type: UPDATE, + observableKind: "object", + debugObjectName: this.name_, + object: this.proxy_ || this.target_, + oldValue: observable2.value_, + name: key, + newValue + } : null; + if (notifySpy) { + spyReportStart(_change); + } + observable2.setNewValue_(newValue); + if (notify) { + notifyListeners(this, _change); + } + if (notifySpy) { + spyReportEnd(); + } + } + return true; + }; + _proto.get_ = function get_(key) { + if (globalState.trackingDerivation && !hasProp(this.target_, key)) { + this.has_(key); + } + return this.target_[key]; + }; + _proto.set_ = function set_(key, value, proxyTrap) { + if (proxyTrap === void 0) { + proxyTrap = false; + } + if (hasProp(this.target_, key)) { + if (this.values_.has(key)) { + return this.setObservablePropValue_(key, value); + } else if (proxyTrap) { + return Reflect.set(this.target_, key, value); + } else { + this.target_[key] = value; + return true; + } + } else { + return this.extend_(key, { + value, + enumerable: true, + writable: true, + configurable: true + }, this.defaultAnnotation_, proxyTrap); + } + }; + _proto.has_ = function has_(key) { + if (!globalState.trackingDerivation) { + return key in this.target_; + } + this.pendingKeys_ || (this.pendingKeys_ = /* @__PURE__ */ new Map()); + var entry = this.pendingKeys_.get(key); + if (!entry) { + entry = new ObservableValue(key in this.target_, referenceEnhancer, true ? this.name_ + "." + stringifyKey(key) + "?" : "ObservableObject.key?", false); + this.pendingKeys_.set(key, entry); + } + return entry.get(); + }; + _proto.make_ = function make_(key, annotation) { + if (annotation === true) { + annotation = this.defaultAnnotation_; + } + if (annotation === false) { + return; + } + assertAnnotable(this, annotation, key); + if (!(key in this.target_)) { + var _this$target_$storedA; + if ((_this$target_$storedA = this.target_[storedAnnotationsSymbol]) != null && _this$target_$storedA[key]) { + return; + } else { + die(1, annotation.annotationType_, this.name_ + "." + key.toString()); + } + } + var source = this.target_; + while (source && source !== objectPrototype) { + var descriptor = getDescriptor(source, key); + if (descriptor) { + var outcome = annotation.make_(this, key, descriptor, source); + if (outcome === 0) { + return; + } + if (outcome === 1) { + break; + } + } + source = Object.getPrototypeOf(source); + } + recordAnnotationApplied(this, annotation, key); + }; + _proto.extend_ = function extend_(key, descriptor, annotation, proxyTrap) { + if (proxyTrap === void 0) { + proxyTrap = false; + } + if (annotation === true) { + annotation = this.defaultAnnotation_; + } + if (annotation === false) { + return this.defineProperty_(key, descriptor, proxyTrap); + } + assertAnnotable(this, annotation, key); + var outcome = annotation.extend_(this, key, descriptor, proxyTrap); + if (outcome) { + recordAnnotationApplied(this, annotation, key); + } + return outcome; + }; + _proto.defineProperty_ = function defineProperty_(key, descriptor, proxyTrap) { + if (proxyTrap === void 0) { + proxyTrap = false; + } + checkIfStateModificationsAreAllowed(this.keysAtom_); + try { + startBatch(); + var deleteOutcome = this.delete_(key); + if (!deleteOutcome) { + return deleteOutcome; + } + if (hasInterceptors(this)) { + var change2 = interceptChange(this, { + object: this.proxy_ || this.target_, + name: key, + type: ADD, + newValue: descriptor.value + }); + if (!change2) { + return null; + } + var newValue = change2.newValue; + if (descriptor.value !== newValue) { + descriptor = _extends({}, descriptor, { + value: newValue + }); + } + } + if (proxyTrap) { + if (!Reflect.defineProperty(this.target_, key, descriptor)) { + return false; + } + } else { + defineProperty(this.target_, key, descriptor); + } + this.notifyPropertyAddition_(key, descriptor.value); + } finally { + endBatch(); + } + return true; + }; + _proto.defineObservableProperty_ = function defineObservableProperty_(key, value, enhancer, proxyTrap) { + if (proxyTrap === void 0) { + proxyTrap = false; + } + checkIfStateModificationsAreAllowed(this.keysAtom_); + try { + startBatch(); + var deleteOutcome = this.delete_(key); + if (!deleteOutcome) { + return deleteOutcome; + } + if (hasInterceptors(this)) { + var change2 = interceptChange(this, { + object: this.proxy_ || this.target_, + name: key, + type: ADD, + newValue: value + }); + if (!change2) { + return null; + } + value = change2.newValue; + } + var cachedDescriptor = getCachedObservablePropDescriptor(key); + var descriptor = { + configurable: globalState.safeDescriptors ? this.isPlainObject_ : true, + enumerable: true, + get: cachedDescriptor.get, + set: cachedDescriptor.set + }; + if (proxyTrap) { + if (!Reflect.defineProperty(this.target_, key, descriptor)) { + return false; + } + } else { + defineProperty(this.target_, key, descriptor); + } + var observable2 = new ObservableValue(value, enhancer, true ? this.name_ + "." + key.toString() : "ObservableObject.key", false); + this.values_.set(key, observable2); + this.notifyPropertyAddition_(key, observable2.value_); + } finally { + endBatch(); + } + return true; + }; + _proto.defineComputedProperty_ = function defineComputedProperty_(key, options, proxyTrap) { + if (proxyTrap === void 0) { + proxyTrap = false; + } + checkIfStateModificationsAreAllowed(this.keysAtom_); + try { + startBatch(); + var deleteOutcome = this.delete_(key); + if (!deleteOutcome) { + return deleteOutcome; + } + if (hasInterceptors(this)) { + var change2 = interceptChange(this, { + object: this.proxy_ || this.target_, + name: key, + type: ADD, + newValue: void 0 + }); + if (!change2) { + return null; + } + } + options.name || (options.name = true ? this.name_ + "." + key.toString() : "ObservableObject.key"); + options.context = this.proxy_ || this.target_; + var cachedDescriptor = getCachedObservablePropDescriptor(key); + var descriptor = { + configurable: globalState.safeDescriptors ? this.isPlainObject_ : true, + enumerable: false, + get: cachedDescriptor.get, + set: cachedDescriptor.set + }; + if (proxyTrap) { + if (!Reflect.defineProperty(this.target_, key, descriptor)) { + return false; + } + } else { + defineProperty(this.target_, key, descriptor); + } + this.values_.set(key, new ComputedValue(options)); + this.notifyPropertyAddition_(key, void 0); + } finally { + endBatch(); + } + return true; + }; + _proto.delete_ = function delete_(key, proxyTrap) { + if (proxyTrap === void 0) { + proxyTrap = false; + } + checkIfStateModificationsAreAllowed(this.keysAtom_); + if (!hasProp(this.target_, key)) { + return true; + } + if (hasInterceptors(this)) { + var change2 = interceptChange(this, { + object: this.proxy_ || this.target_, + name: key, + type: REMOVE + }); + if (!change2) { + return null; + } + } + try { + var _this$pendingKeys_, _this$pendingKeys_$ge; + startBatch(); + var notify = hasListeners(this); + var notifySpy = isSpyEnabled(); + var observable2 = this.values_.get(key); + var value = void 0; + if (!observable2 && (notify || notifySpy)) { + var _getDescriptor2; + value = (_getDescriptor2 = getDescriptor(this.target_, key)) == null ? void 0 : _getDescriptor2.value; + } + if (proxyTrap) { + if (!Reflect.deleteProperty(this.target_, key)) { + return false; + } + } else { + delete this.target_[key]; + } + if (true) { + delete this.appliedAnnotations_[key]; + } + if (observable2) { + this.values_["delete"](key); + if (observable2 instanceof ObservableValue) { + value = observable2.value_; + } + propagateChanged(observable2); + } + this.keysAtom_.reportChanged(); + (_this$pendingKeys_ = this.pendingKeys_) == null ? void 0 : (_this$pendingKeys_$ge = _this$pendingKeys_.get(key)) == null ? void 0 : _this$pendingKeys_$ge.set(key in this.target_); + if (notify || notifySpy) { + var _change2 = { + type: REMOVE, + observableKind: "object", + object: this.proxy_ || this.target_, + debugObjectName: this.name_, + oldValue: value, + name: key + }; + if (notifySpy) { + spyReportStart(_change2); + } + if (notify) { + notifyListeners(this, _change2); + } + if (notifySpy) { + spyReportEnd(); + } + } + } finally { + endBatch(); + } + return true; + }; + _proto.observe_ = function observe_(callback, fireImmediately) { + if (fireImmediately === true) { + die("`observe` doesn't support the fire immediately property for observable objects."); + } + return registerListener(this, callback); + }; + _proto.intercept_ = function intercept_(handler) { + return registerInterceptor(this, handler); + }; + _proto.notifyPropertyAddition_ = function notifyPropertyAddition_(key, value) { + var _this$pendingKeys_2, _this$pendingKeys_2$g; + var notify = hasListeners(this); + var notifySpy = isSpyEnabled(); + if (notify || notifySpy) { + var change2 = notify || notifySpy ? { + type: ADD, + observableKind: "object", + debugObjectName: this.name_, + object: this.proxy_ || this.target_, + name: key, + newValue: value + } : null; + if (notifySpy) { + spyReportStart(change2); + } + if (notify) { + notifyListeners(this, change2); + } + if (notifySpy) { + spyReportEnd(); + } + } + (_this$pendingKeys_2 = this.pendingKeys_) == null ? void 0 : (_this$pendingKeys_2$g = _this$pendingKeys_2.get(key)) == null ? void 0 : _this$pendingKeys_2$g.set(true); + this.keysAtom_.reportChanged(); + }; + _proto.ownKeys_ = function ownKeys_() { + this.keysAtom_.reportObserved(); + return ownKeys(this.target_); + }; + _proto.keys_ = function keys_() { + this.keysAtom_.reportObserved(); + return Object.keys(this.target_); + }; + return ObservableObjectAdministration2; + }(); + function asObservableObject(target, options) { + var _options$name; + if (options && isObservableObject(target)) { + die("Options can't be provided for already observable objects."); + } + if (hasProp(target, $mobx)) { + if (!(getAdministration(target) instanceof ObservableObjectAdministration)) { + die("Cannot convert '" + getDebugName(target) + "' into observable object:\nThe target is already observable of different type.\nExtending builtins is not supported."); + } + return target; + } + if (!Object.isExtensible(target)) { + die("Cannot make the designated object observable; it is not extensible"); + } + var name = (_options$name = options == null ? void 0 : options.name) != null ? _options$name : true ? (isPlainObject(target) ? "ObservableObject" : target.constructor.name) + "@" + getNextId() : "ObservableObject"; + var adm = new ObservableObjectAdministration(target, /* @__PURE__ */ new Map(), String(name), getAnnotationFromOptions(options)); + addHiddenProp(target, $mobx, adm); + return target; + } + var isObservableObjectAdministration = /* @__PURE__ */ createInstanceofPredicate("ObservableObjectAdministration", ObservableObjectAdministration); + function getCachedObservablePropDescriptor(key) { + return descriptorCache[key] || (descriptorCache[key] = { + get: function get3() { + return this[$mobx].getObservablePropValue_(key); + }, + set: function set4(value) { + return this[$mobx].setObservablePropValue_(key, value); + } + }); + } + function isObservableObject(thing) { + if (isObject(thing)) { + return isObservableObjectAdministration(thing[$mobx]); + } + return false; + } + function recordAnnotationApplied(adm, annotation, key) { + var _adm$target_$storedAn; + if (true) { + adm.appliedAnnotations_[key] = annotation; + } + (_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null ? true : delete _adm$target_$storedAn[key]; + } + function assertAnnotable(adm, annotation, key) { + if (!isAnnotation(annotation)) { + die("Cannot annotate '" + adm.name_ + "." + key.toString() + "': Invalid annotation."); + } + if (!isOverride(annotation) && hasProp(adm.appliedAnnotations_, key)) { + var fieldName = adm.name_ + "." + key.toString(); + var currentAnnotationType = adm.appliedAnnotations_[key].annotationType_; + var requestedAnnotationType = annotation.annotationType_; + die("Cannot apply '" + requestedAnnotationType + "' to '" + fieldName + "':" + ("\nThe field is already annotated with '" + currentAnnotationType + "'.") + "\nRe-annotating fields is not allowed.\nUse 'override' annotation for methods overridden by subclass."); + } + } + var ENTRY_0 = /* @__PURE__ */ createArrayEntryDescriptor(0); + var safariPrototypeSetterInheritanceBug = /* @__PURE__ */ function() { + var v6 = false; + var p7 = {}; + Object.defineProperty(p7, "0", { + set: function set4() { + v6 = true; + } + }); + Object.create(p7)["0"] = 1; + return v6 === false; + }(); + var OBSERVABLE_ARRAY_BUFFER_SIZE = 0; + var StubArray = function StubArray2() { + }; + function inherit(ctor, proto) { + if (Object.setPrototypeOf) { + Object.setPrototypeOf(ctor.prototype, proto); + } else if (ctor.prototype.__proto__ !== void 0) { + ctor.prototype.__proto__ = proto; + } else { + ctor.prototype = proto; + } + } + inherit(StubArray, Array.prototype); + var LegacyObservableArray = /* @__PURE__ */ function(_StubArray, _Symbol$toStringTag2, _Symbol$iterator2) { + _inheritsLoose(LegacyObservableArray2, _StubArray); + function LegacyObservableArray2(initialValues, enhancer, name, owned) { + var _this; + if (name === void 0) { + name = true ? "ObservableArray@" + getNextId() : "ObservableArray"; + } + if (owned === void 0) { + owned = false; + } + _this = _StubArray.call(this) || this; + initObservable(function() { + var adm = new ObservableArrayAdministration(name, enhancer, owned, true); + adm.proxy_ = _assertThisInitialized(_this); + addHiddenFinalProp(_assertThisInitialized(_this), $mobx, adm); + if (initialValues && initialValues.length) { + _this.spliceWithArray(0, 0, initialValues); + } + if (safariPrototypeSetterInheritanceBug) { + Object.defineProperty(_assertThisInitialized(_this), "0", ENTRY_0); + } + }); + return _this; + } + var _proto = LegacyObservableArray2.prototype; + _proto.concat = function concat() { + this[$mobx].atom_.reportObserved(); + for (var _len = arguments.length, arrays = new Array(_len), _key = 0; _key < _len; _key++) { + arrays[_key] = arguments[_key]; + } + return Array.prototype.concat.apply( + this.slice(), + //@ts-ignore + arrays.map(function(a11) { + return isObservableArray(a11) ? a11.slice() : a11; + }) + ); + }; + _proto[_Symbol$iterator2] = function() { + var self2 = this; + var nextIndex = 0; + return makeIterable({ + next: function next() { + return nextIndex < self2.length ? { + value: self2[nextIndex++], + done: false + } : { + done: true, + value: void 0 + }; + } + }); + }; + _createClass(LegacyObservableArray2, [{ + key: "length", + get: function get3() { + return this[$mobx].getArrayLength_(); + }, + set: function set4(newLength) { + this[$mobx].setArrayLength_(newLength); + } + }, { + key: _Symbol$toStringTag2, + get: function get3() { + return "Array"; + } + }]); + return LegacyObservableArray2; + }(StubArray, Symbol.toStringTag, Symbol.iterator); + Object.entries(arrayExtensions).forEach(function(_ref) { + var prop = _ref[0], fn2 = _ref[1]; + if (prop !== "concat") { + addHiddenProp(LegacyObservableArray.prototype, prop, fn2); + } + }); + function createArrayEntryDescriptor(index) { + return { + enumerable: false, + configurable: true, + get: function get3() { + return this[$mobx].get_(index); + }, + set: function set4(value) { + this[$mobx].set_(index, value); + } + }; + } + function createArrayBufferItem(index) { + defineProperty(LegacyObservableArray.prototype, "" + index, createArrayEntryDescriptor(index)); + } + function reserveArrayBuffer(max) { + if (max > OBSERVABLE_ARRAY_BUFFER_SIZE) { + for (var index = OBSERVABLE_ARRAY_BUFFER_SIZE; index < max + 100; index++) { + createArrayBufferItem(index); + } + OBSERVABLE_ARRAY_BUFFER_SIZE = max; + } + } + reserveArrayBuffer(1e3); + function createLegacyArray(initialValues, enhancer, name) { + return new LegacyObservableArray(initialValues, enhancer, name); + } + function getAtom(thing, property) { + if (typeof thing === "object" && thing !== null) { + if (isObservableArray(thing)) { + if (property !== void 0) { + die(23); + } + return thing[$mobx].atom_; + } + if (isObservableSet(thing)) { + return thing.atom_; + } + if (isObservableMap(thing)) { + if (property === void 0) { + return thing.keysAtom_; + } + var observable2 = thing.data_.get(property) || thing.hasMap_.get(property); + if (!observable2) { + die(25, property, getDebugName(thing)); + } + return observable2; + } + if (isObservableObject(thing)) { + if (!property) { + return die(26); + } + var _observable = thing[$mobx].values_.get(property); + if (!_observable) { + die(27, property, getDebugName(thing)); + } + return _observable; + } + if (isAtom(thing) || isComputedValue(thing) || isReaction(thing)) { + return thing; + } + } else if (isFunction(thing)) { + if (isReaction(thing[$mobx])) { + return thing[$mobx]; + } + } + die(28); + } + function getAdministration(thing, property) { + if (!thing) { + die(29); + } + if (property !== void 0) { + return getAdministration(getAtom(thing, property)); + } + if (isAtom(thing) || isComputedValue(thing) || isReaction(thing)) { + return thing; + } + if (isObservableMap(thing) || isObservableSet(thing)) { + return thing; + } + if (thing[$mobx]) { + return thing[$mobx]; + } + die(24, thing); + } + function getDebugName(thing, property) { + var named; + if (property !== void 0) { + named = getAtom(thing, property); + } else if (isAction(thing)) { + return thing.name; + } else if (isObservableObject(thing) || isObservableMap(thing) || isObservableSet(thing)) { + named = getAdministration(thing); + } else { + named = getAtom(thing); + } + return named.name_; + } + function initObservable(cb) { + var derivation = untrackedStart(); + var allowStateChanges = allowStateChangesStart(true); + startBatch(); + try { + return cb(); + } finally { + endBatch(); + allowStateChangesEnd(allowStateChanges); + untrackedEnd(derivation); + } + } + var toString = objectPrototype.toString; + function deepEqual(a11, b7, depth) { + if (depth === void 0) { + depth = -1; + } + return eq(a11, b7, depth); + } + function eq(a11, b7, depth, aStack, bStack) { + if (a11 === b7) { + return a11 !== 0 || 1 / a11 === 1 / b7; + } + if (a11 == null || b7 == null) { + return false; + } + if (a11 !== a11) { + return b7 !== b7; + } + var type = typeof a11; + if (type !== "function" && type !== "object" && typeof b7 != "object") { + return false; + } + var className = toString.call(a11); + if (className !== toString.call(b7)) { + return false; + } + switch (className) { + case "[object RegExp]": + case "[object String]": + return "" + a11 === "" + b7; + case "[object Number]": + if (+a11 !== +a11) { + return +b7 !== +b7; + } + return +a11 === 0 ? 1 / +a11 === 1 / b7 : +a11 === +b7; + case "[object Date]": + case "[object Boolean]": + return +a11 === +b7; + case "[object Symbol]": + return typeof Symbol !== "undefined" && Symbol.valueOf.call(a11) === Symbol.valueOf.call(b7); + case "[object Map]": + case "[object Set]": + if (depth >= 0) { + depth++; + } + break; + } + a11 = unwrap(a11); + b7 = unwrap(b7); + var areArrays = className === "[object Array]"; + if (!areArrays) { + if (typeof a11 != "object" || typeof b7 != "object") { + return false; + } + var aCtor = a11.constructor, bCtor = b7.constructor; + if (aCtor !== bCtor && !(isFunction(aCtor) && aCtor instanceof aCtor && isFunction(bCtor) && bCtor instanceof bCtor) && "constructor" in a11 && "constructor" in b7) { + return false; + } + } + if (depth === 0) { + return false; + } else if (depth < 0) { + depth = -1; + } + aStack = aStack || []; + bStack = bStack || []; + var length = aStack.length; + while (length--) { + if (aStack[length] === a11) { + return bStack[length] === b7; + } + } + aStack.push(a11); + bStack.push(b7); + if (areArrays) { + length = a11.length; + if (length !== b7.length) { + return false; + } + while (length--) { + if (!eq(a11[length], b7[length], depth - 1, aStack, bStack)) { + return false; + } + } + } else { + var keys = Object.keys(a11); + var key; + length = keys.length; + if (Object.keys(b7).length !== length) { + return false; + } + while (length--) { + key = keys[length]; + if (!(hasProp(b7, key) && eq(a11[key], b7[key], depth - 1, aStack, bStack))) { + return false; + } + } + } + aStack.pop(); + bStack.pop(); + return true; + } + function unwrap(a11) { + if (isObservableArray(a11)) { + return a11.slice(); + } + if (isES6Map(a11) || isObservableMap(a11)) { + return Array.from(a11.entries()); + } + if (isES6Set(a11) || isObservableSet(a11)) { + return Array.from(a11.entries()); + } + return a11; + } + function makeIterable(iterator) { + iterator[Symbol.iterator] = getSelf; + return iterator; + } + function getSelf() { + return this; + } + function isAnnotation(thing) { + return ( + // Can be function + thing instanceof Object && typeof thing.annotationType_ === "string" && isFunction(thing.make_) && isFunction(thing.extend_) + ); + } + ["Symbol", "Map", "Set"].forEach(function(m6) { + var g6 = getGlobal(); + if (typeof g6[m6] === "undefined") { + die("MobX requires global '" + m6 + "' to be available or polyfilled"); + } + }); + if (typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__ === "object") { + __MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({ + spy, + extras: { + getDebugName + }, + $mobx + }); + } + + // node_modules/@adobe/lit-mobx/lib/mixin.js + function MobxReactionUpdate(constructor) { + return MobxReactionUpdateCustom(constructor, Reaction); + } + + // node_modules/@lit/reactive-element/css-tag.js + var t = globalThis; + var e = t.ShadowRoot && (void 0 === t.ShadyCSS || t.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype; + var s = Symbol(); + var o = /* @__PURE__ */ new WeakMap(); + var n = class { + constructor(t17, e33, o29) { + if (this._$cssResult$ = true, o29 !== s) + throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); + this.cssText = t17, this.t = e33; + } + get styleSheet() { + let t17 = this.o; + const s20 = this.t; + if (e && void 0 === t17) { + const e33 = void 0 !== s20 && 1 === s20.length; + e33 && (t17 = o.get(s20)), void 0 === t17 && ((this.o = t17 = new CSSStyleSheet()).replaceSync(this.cssText), e33 && o.set(s20, t17)); + } + return t17; + } + toString() { + return this.cssText; + } + }; + var r = (t17) => new n("string" == typeof t17 ? t17 : t17 + "", void 0, s); + var i = (t17, ...e33) => { + const o29 = 1 === t17.length ? t17[0] : e33.reduce((e34, s20, o30) => e34 + ((t18) => { + if (true === t18._$cssResult$) + return t18.cssText; + if ("number" == typeof t18) + return t18; + throw Error("Value passed to 'css' function must be a 'css' function result: " + t18 + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security."); + })(s20) + t17[o30 + 1], t17[0]); + return new n(o29, t17, s); + }; + var S = (s20, o29) => { + if (e) + s20.adoptedStyleSheets = o29.map((t17) => t17 instanceof CSSStyleSheet ? t17 : t17.styleSheet); + else + for (const e33 of o29) { + const o30 = document.createElement("style"), n31 = t.litNonce; + void 0 !== n31 && o30.setAttribute("nonce", n31), o30.textContent = e33.cssText, s20.appendChild(o30); + } + }; + var c = e ? (t17) => t17 : (t17) => t17 instanceof CSSStyleSheet ? ((t18) => { + let e33 = ""; + for (const s20 of t18.cssRules) + e33 += s20.cssText; + return r(e33); + })(t17) : t17; + + // node_modules/@lit/reactive-element/reactive-element.js + var { is: i3, defineProperty: e2, getOwnPropertyDescriptor: r2, getOwnPropertyNames: h, getOwnPropertySymbols: o2, getPrototypeOf: n2 } = Object; + var a = globalThis; + var c2 = a.trustedTypes; + var l = c2 ? c2.emptyScript : ""; + var p = a.reactiveElementPolyfillSupport; + var d = (t17, s20) => t17; + var u = { toAttribute(t17, s20) { + switch (s20) { + case Boolean: + t17 = t17 ? l : null; + break; + case Object: + case Array: + t17 = null == t17 ? t17 : JSON.stringify(t17); + } + return t17; + }, fromAttribute(t17, s20) { + let i23 = t17; + switch (s20) { + case Boolean: + i23 = null !== t17; + break; + case Number: + i23 = null === t17 ? null : Number(t17); + break; + case Object: + case Array: + try { + i23 = JSON.parse(t17); + } catch (t18) { + i23 = null; + } + } + return i23; + } }; + var f = (t17, s20) => !i3(t17, s20); + var y = { attribute: true, type: String, converter: u, reflect: false, hasChanged: f }; + Symbol.metadata ??= Symbol("metadata"), a.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap(); + var b = class extends HTMLElement { + static addInitializer(t17) { + this._$Ei(), (this.l ??= []).push(t17); + } + static get observedAttributes() { + return this.finalize(), this._$Eh && [...this._$Eh.keys()]; + } + static createProperty(t17, s20 = y) { + if (s20.state && (s20.attribute = false), this._$Ei(), this.elementProperties.set(t17, s20), !s20.noAccessor) { + const i23 = Symbol(), r18 = this.getPropertyDescriptor(t17, i23, s20); + void 0 !== r18 && e2(this.prototype, t17, r18); + } + } + static getPropertyDescriptor(t17, s20, i23) { + const { get: e33, set: h11 } = r2(this.prototype, t17) ?? { get() { + return this[s20]; + }, set(t18) { + this[s20] = t18; + } }; + return { get() { + return e33?.call(this); + }, set(s21) { + const r18 = e33?.call(this); + h11.call(this, s21), this.requestUpdate(t17, r18, i23); + }, configurable: true, enumerable: true }; + } + static getPropertyOptions(t17) { + return this.elementProperties.get(t17) ?? y; + } + static _$Ei() { + if (this.hasOwnProperty(d("elementProperties"))) + return; + const t17 = n2(this); + t17.finalize(), void 0 !== t17.l && (this.l = [...t17.l]), this.elementProperties = new Map(t17.elementProperties); + } + static finalize() { + if (this.hasOwnProperty(d("finalized"))) + return; + if (this.finalized = true, this._$Ei(), this.hasOwnProperty(d("properties"))) { + const t18 = this.properties, s20 = [...h(t18), ...o2(t18)]; + for (const i23 of s20) + this.createProperty(i23, t18[i23]); + } + const t17 = this[Symbol.metadata]; + if (null !== t17) { + const s20 = litPropertyMetadata.get(t17); + if (void 0 !== s20) + for (const [t18, i23] of s20) + this.elementProperties.set(t18, i23); + } + this._$Eh = /* @__PURE__ */ new Map(); + for (const [t18, s20] of this.elementProperties) { + const i23 = this._$Eu(t18, s20); + void 0 !== i23 && this._$Eh.set(i23, t18); + } + this.elementStyles = this.finalizeStyles(this.styles); + } + static finalizeStyles(s20) { + const i23 = []; + if (Array.isArray(s20)) { + const e33 = new Set(s20.flat(1 / 0).reverse()); + for (const s21 of e33) + i23.unshift(c(s21)); + } else + void 0 !== s20 && i23.push(c(s20)); + return i23; + } + static _$Eu(t17, s20) { + const i23 = s20.attribute; + return false === i23 ? void 0 : "string" == typeof i23 ? i23 : "string" == typeof t17 ? t17.toLowerCase() : void 0; + } + constructor() { + super(), this._$Ep = void 0, this.isUpdatePending = false, this.hasUpdated = false, this._$Em = null, this._$Ev(); + } + _$Ev() { + this._$ES = new Promise((t17) => this.enableUpdating = t17), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach((t17) => t17(this)); + } + addController(t17) { + (this._$EO ??= /* @__PURE__ */ new Set()).add(t17), void 0 !== this.renderRoot && this.isConnected && t17.hostConnected?.(); + } + removeController(t17) { + this._$EO?.delete(t17); + } + _$E_() { + const t17 = /* @__PURE__ */ new Map(), s20 = this.constructor.elementProperties; + for (const i23 of s20.keys()) + this.hasOwnProperty(i23) && (t17.set(i23, this[i23]), delete this[i23]); + t17.size > 0 && (this._$Ep = t17); + } + createRenderRoot() { + const t17 = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions); + return S(t17, this.constructor.elementStyles), t17; + } + connectedCallback() { + this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(true), this._$EO?.forEach((t17) => t17.hostConnected?.()); + } + enableUpdating(t17) { + } + disconnectedCallback() { + this._$EO?.forEach((t17) => t17.hostDisconnected?.()); + } + attributeChangedCallback(t17, s20, i23) { + this._$AK(t17, i23); + } + _$EC(t17, s20) { + const i23 = this.constructor.elementProperties.get(t17), e33 = this.constructor._$Eu(t17, i23); + if (void 0 !== e33 && true === i23.reflect) { + const r18 = (void 0 !== i23.converter?.toAttribute ? i23.converter : u).toAttribute(s20, i23.type); + this._$Em = t17, null == r18 ? this.removeAttribute(e33) : this.setAttribute(e33, r18), this._$Em = null; + } + } + _$AK(t17, s20) { + const i23 = this.constructor, e33 = i23._$Eh.get(t17); + if (void 0 !== e33 && this._$Em !== e33) { + const t18 = i23.getPropertyOptions(e33), r18 = "function" == typeof t18.converter ? { fromAttribute: t18.converter } : void 0 !== t18.converter?.fromAttribute ? t18.converter : u; + this._$Em = e33, this[e33] = r18.fromAttribute(s20, t18.type), this._$Em = null; + } + } + requestUpdate(t17, s20, i23) { + if (void 0 !== t17) { + if (i23 ??= this.constructor.getPropertyOptions(t17), !(i23.hasChanged ?? f)(this[t17], s20)) + return; + this.P(t17, s20, i23); + } + false === this.isUpdatePending && (this._$ES = this._$ET()); + } + P(t17, s20, i23) { + this._$AL.has(t17) || this._$AL.set(t17, s20), true === i23.reflect && this._$Em !== t17 && (this._$Ej ??= /* @__PURE__ */ new Set()).add(t17); + } + async _$ET() { + this.isUpdatePending = true; + try { + await this._$ES; + } catch (t18) { + Promise.reject(t18); + } + const t17 = this.scheduleUpdate(); + return null != t17 && await t17, !this.isUpdatePending; + } + scheduleUpdate() { + return this.performUpdate(); + } + performUpdate() { + if (!this.isUpdatePending) + return; + if (!this.hasUpdated) { + if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) { + for (const [t19, s21] of this._$Ep) + this[t19] = s21; + this._$Ep = void 0; + } + const t18 = this.constructor.elementProperties; + if (t18.size > 0) + for (const [s21, i23] of t18) + true !== i23.wrapped || this._$AL.has(s21) || void 0 === this[s21] || this.P(s21, this[s21], i23); + } + let t17 = false; + const s20 = this._$AL; + try { + t17 = this.shouldUpdate(s20), t17 ? (this.willUpdate(s20), this._$EO?.forEach((t18) => t18.hostUpdate?.()), this.update(s20)) : this._$EU(); + } catch (s21) { + throw t17 = false, this._$EU(), s21; + } + t17 && this._$AE(s20); + } + willUpdate(t17) { + } + _$AE(t17) { + this._$EO?.forEach((t18) => t18.hostUpdated?.()), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t17)), this.updated(t17); + } + _$EU() { + this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = false; + } + get updateComplete() { + return this.getUpdateComplete(); + } + getUpdateComplete() { + return this._$ES; + } + shouldUpdate(t17) { + return true; + } + update(t17) { + this._$Ej &&= this._$Ej.forEach((t18) => this._$EC(t18, this[t18])), this._$EU(); + } + updated(t17) { + } + firstUpdated(t17) { + } + }; + b.elementStyles = [], b.shadowRootOptions = { mode: "open" }, b[d("elementProperties")] = /* @__PURE__ */ new Map(), b[d("finalized")] = /* @__PURE__ */ new Map(), p?.({ ReactiveElement: b }), (a.reactiveElementVersions ??= []).push("2.0.4"); + + // node_modules/lit-html/lit-html.js + var t2 = globalThis; + var i4 = t2.trustedTypes; + var s2 = i4 ? i4.createPolicy("lit-html", { createHTML: (t17) => t17 }) : void 0; + var e3 = "$lit$"; + var h2 = `lit$${Math.random().toFixed(9).slice(2)}$`; + var o3 = "?" + h2; + var n3 = `<${o3}>`; + var r3 = document; + var l2 = () => r3.createComment(""); + var c3 = (t17) => null === t17 || "object" != typeof t17 && "function" != typeof t17; + var a2 = Array.isArray; + var u2 = (t17) => a2(t17) || "function" == typeof t17?.[Symbol.iterator]; + var d2 = "[ \n\f\r]"; + var f2 = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g; + var v = /-->/g; + var _14 = />/g; + var m = RegExp(`>|${d2}(?:([^\\s"'>=/]+)(${d2}*=${d2}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`, "g"); + var p2 = /'/g; + var g = /"/g; + var $ = /^(?:script|style|textarea|title)$/i; + var y2 = (t17) => (i23, ...s20) => ({ _$litType$: t17, strings: i23, values: s20 }); + var x = y2(1); + var b2 = y2(2); + var w = Symbol.for("lit-noChange"); + var T = Symbol.for("lit-nothing"); + var A = /* @__PURE__ */ new WeakMap(); + var E = r3.createTreeWalker(r3, 129); + function C(t17, i23) { + if (!Array.isArray(t17) || !t17.hasOwnProperty("raw")) + throw Error("invalid template strings array"); + return void 0 !== s2 ? s2.createHTML(i23) : i23; + } + var P = (t17, i23) => { + const s20 = t17.length - 1, o29 = []; + let r18, l20 = 2 === i23 ? "" : "", c12 = f2; + for (let i24 = 0; i24 < s20; i24++) { + const s21 = t17[i24]; + let a11, u11, d11 = -1, y7 = 0; + for (; y7 < s21.length && (c12.lastIndex = y7, u11 = c12.exec(s21), null !== u11); ) + y7 = c12.lastIndex, c12 === f2 ? "!--" === u11[1] ? c12 = v : void 0 !== u11[1] ? c12 = _14 : void 0 !== u11[2] ? ($.test(u11[2]) && (r18 = RegExp("" === u11[0] ? (c12 = r18 ?? f2, d11 = -1) : void 0 === u11[1] ? d11 = -2 : (d11 = c12.lastIndex - u11[2].length, a11 = u11[1], c12 = void 0 === u11[3] ? m : '"' === u11[3] ? g : p2) : c12 === g || c12 === p2 ? c12 = m : c12 === v || c12 === _14 ? c12 = f2 : (c12 = m, r18 = void 0); + const x6 = c12 === m && t17[i24 + 1].startsWith("/>") ? " " : ""; + l20 += c12 === f2 ? s21 + n3 : d11 >= 0 ? (o29.push(a11), s21.slice(0, d11) + e3 + s21.slice(d11) + h2 + x6) : s21 + h2 + (-2 === d11 ? i24 : x6); + } + return [C(t17, l20 + (t17[s20] || "") + (2 === i23 ? "" : "")), o29]; + }; + var V = class _V { + constructor({ strings: t17, _$litType$: s20 }, n31) { + let r18; + this.parts = []; + let c12 = 0, a11 = 0; + const u11 = t17.length - 1, d11 = this.parts, [f7, v6] = P(t17, s20); + if (this.el = _V.createElement(f7, n31), E.currentNode = this.el.content, 2 === s20) { + const t18 = this.el.content.firstChild; + t18.replaceWith(...t18.childNodes); + } + for (; null !== (r18 = E.nextNode()) && d11.length < u11; ) { + if (1 === r18.nodeType) { + if (r18.hasAttributes()) + for (const t18 of r18.getAttributeNames()) + if (t18.endsWith(e3)) { + const i23 = v6[a11++], s21 = r18.getAttribute(t18).split(h2), e33 = /([.?@])?(.*)/.exec(i23); + d11.push({ type: 1, index: c12, name: e33[2], strings: s21, ctor: "." === e33[1] ? k3 : "?" === e33[1] ? H : "@" === e33[1] ? I : R }), r18.removeAttribute(t18); + } else + t18.startsWith(h2) && (d11.push({ type: 6, index: c12 }), r18.removeAttribute(t18)); + if ($.test(r18.tagName)) { + const t18 = r18.textContent.split(h2), s21 = t18.length - 1; + if (s21 > 0) { + r18.textContent = i4 ? i4.emptyScript : ""; + for (let i23 = 0; i23 < s21; i23++) + r18.append(t18[i23], l2()), E.nextNode(), d11.push({ type: 2, index: ++c12 }); + r18.append(t18[s21], l2()); + } + } + } else if (8 === r18.nodeType) + if (r18.data === o3) + d11.push({ type: 2, index: c12 }); + else { + let t18 = -1; + for (; -1 !== (t18 = r18.data.indexOf(h2, t18 + 1)); ) + d11.push({ type: 7, index: c12 }), t18 += h2.length - 1; + } + c12++; + } + } + static createElement(t17, i23) { + const s20 = r3.createElement("template"); + return s20.innerHTML = t17, s20; + } + }; + function N(t17, i23, s20 = t17, e33) { + if (i23 === w) + return i23; + let h11 = void 0 !== e33 ? s20._$Co?.[e33] : s20._$Cl; + const o29 = c3(i23) ? void 0 : i23._$litDirective$; + return h11?.constructor !== o29 && (h11?._$AO?.(false), void 0 === o29 ? h11 = void 0 : (h11 = new o29(t17), h11._$AT(t17, s20, e33)), void 0 !== e33 ? (s20._$Co ??= [])[e33] = h11 : s20._$Cl = h11), void 0 !== h11 && (i23 = N(t17, h11._$AS(t17, i23.values), h11, e33)), i23; + } + var S2 = class { + constructor(t17, i23) { + this._$AV = [], this._$AN = void 0, this._$AD = t17, this._$AM = i23; + } + get parentNode() { + return this._$AM.parentNode; + } + get _$AU() { + return this._$AM._$AU; + } + u(t17) { + const { el: { content: i23 }, parts: s20 } = this._$AD, e33 = (t17?.creationScope ?? r3).importNode(i23, true); + E.currentNode = e33; + let h11 = E.nextNode(), o29 = 0, n31 = 0, l20 = s20[0]; + for (; void 0 !== l20; ) { + if (o29 === l20.index) { + let i24; + 2 === l20.type ? i24 = new M(h11, h11.nextSibling, this, t17) : 1 === l20.type ? i24 = new l20.ctor(h11, l20.name, l20.strings, this, t17) : 6 === l20.type && (i24 = new L(h11, this, t17)), this._$AV.push(i24), l20 = s20[++n31]; + } + o29 !== l20?.index && (h11 = E.nextNode(), o29++); + } + return E.currentNode = r3, e33; + } + p(t17) { + let i23 = 0; + for (const s20 of this._$AV) + void 0 !== s20 && (void 0 !== s20.strings ? (s20._$AI(t17, s20, i23), i23 += s20.strings.length - 2) : s20._$AI(t17[i23])), i23++; + } + }; + var M = class _M { + get _$AU() { + return this._$AM?._$AU ?? this._$Cv; + } + constructor(t17, i23, s20, e33) { + this.type = 2, this._$AH = T, this._$AN = void 0, this._$AA = t17, this._$AB = i23, this._$AM = s20, this.options = e33, this._$Cv = e33?.isConnected ?? true; + } + get parentNode() { + let t17 = this._$AA.parentNode; + const i23 = this._$AM; + return void 0 !== i23 && 11 === t17?.nodeType && (t17 = i23.parentNode), t17; + } + get startNode() { + return this._$AA; + } + get endNode() { + return this._$AB; + } + _$AI(t17, i23 = this) { + t17 = N(this, t17, i23), c3(t17) ? t17 === T || null == t17 || "" === t17 ? (this._$AH !== T && this._$AR(), this._$AH = T) : t17 !== this._$AH && t17 !== w && this._(t17) : void 0 !== t17._$litType$ ? this.$(t17) : void 0 !== t17.nodeType ? this.T(t17) : u2(t17) ? this.k(t17) : this._(t17); + } + S(t17) { + return this._$AA.parentNode.insertBefore(t17, this._$AB); + } + T(t17) { + this._$AH !== t17 && (this._$AR(), this._$AH = this.S(t17)); + } + _(t17) { + this._$AH !== T && c3(this._$AH) ? this._$AA.nextSibling.data = t17 : this.T(r3.createTextNode(t17)), this._$AH = t17; + } + $(t17) { + const { values: i23, _$litType$: s20 } = t17, e33 = "number" == typeof s20 ? this._$AC(t17) : (void 0 === s20.el && (s20.el = V.createElement(C(s20.h, s20.h[0]), this.options)), s20); + if (this._$AH?._$AD === e33) + this._$AH.p(i23); + else { + const t18 = new S2(e33, this), s21 = t18.u(this.options); + t18.p(i23), this.T(s21), this._$AH = t18; + } + } + _$AC(t17) { + let i23 = A.get(t17.strings); + return void 0 === i23 && A.set(t17.strings, i23 = new V(t17)), i23; + } + k(t17) { + a2(this._$AH) || (this._$AH = [], this._$AR()); + const i23 = this._$AH; + let s20, e33 = 0; + for (const h11 of t17) + e33 === i23.length ? i23.push(s20 = new _M(this.S(l2()), this.S(l2()), this, this.options)) : s20 = i23[e33], s20._$AI(h11), e33++; + e33 < i23.length && (this._$AR(s20 && s20._$AB.nextSibling, e33), i23.length = e33); + } + _$AR(t17 = this._$AA.nextSibling, i23) { + for (this._$AP?.(false, true, i23); t17 && t17 !== this._$AB; ) { + const i24 = t17.nextSibling; + t17.remove(), t17 = i24; + } + } + setConnected(t17) { + void 0 === this._$AM && (this._$Cv = t17, this._$AP?.(t17)); + } + }; + var R = class { + get tagName() { + return this.element.tagName; + } + get _$AU() { + return this._$AM._$AU; + } + constructor(t17, i23, s20, e33, h11) { + this.type = 1, this._$AH = T, this._$AN = void 0, this.element = t17, this.name = i23, this._$AM = e33, this.options = h11, s20.length > 2 || "" !== s20[0] || "" !== s20[1] ? (this._$AH = Array(s20.length - 1).fill(new String()), this.strings = s20) : this._$AH = T; + } + _$AI(t17, i23 = this, s20, e33) { + const h11 = this.strings; + let o29 = false; + if (void 0 === h11) + t17 = N(this, t17, i23, 0), o29 = !c3(t17) || t17 !== this._$AH && t17 !== w, o29 && (this._$AH = t17); + else { + const e34 = t17; + let n31, r18; + for (t17 = h11[0], n31 = 0; n31 < h11.length - 1; n31++) + r18 = N(this, e34[s20 + n31], i23, n31), r18 === w && (r18 = this._$AH[n31]), o29 ||= !c3(r18) || r18 !== this._$AH[n31], r18 === T ? t17 = T : t17 !== T && (t17 += (r18 ?? "") + h11[n31 + 1]), this._$AH[n31] = r18; + } + o29 && !e33 && this.j(t17); + } + j(t17) { + t17 === T ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t17 ?? ""); + } + }; + var k3 = class extends R { + constructor() { + super(...arguments), this.type = 3; + } + j(t17) { + this.element[this.name] = t17 === T ? void 0 : t17; + } + }; + var H = class extends R { + constructor() { + super(...arguments), this.type = 4; + } + j(t17) { + this.element.toggleAttribute(this.name, !!t17 && t17 !== T); + } + }; + var I = class extends R { + constructor(t17, i23, s20, e33, h11) { + super(t17, i23, s20, e33, h11), this.type = 5; + } + _$AI(t17, i23 = this) { + if ((t17 = N(this, t17, i23, 0) ?? T) === w) + return; + const s20 = this._$AH, e33 = t17 === T && s20 !== T || t17.capture !== s20.capture || t17.once !== s20.once || t17.passive !== s20.passive, h11 = t17 !== T && (s20 === T || e33); + e33 && this.element.removeEventListener(this.name, this, s20), h11 && this.element.addEventListener(this.name, this, t17), this._$AH = t17; + } + handleEvent(t17) { + "function" == typeof this._$AH ? this._$AH.call(this.options?.host ?? this.element, t17) : this._$AH.handleEvent(t17); + } + }; + var L = class { + constructor(t17, i23, s20) { + this.element = t17, this.type = 6, this._$AN = void 0, this._$AM = i23, this.options = s20; + } + get _$AU() { + return this._$AM._$AU; + } + _$AI(t17) { + N(this, t17); + } + }; + var Z = t2.litHtmlPolyfillSupport; + Z?.(V, M), (t2.litHtmlVersions ??= []).push("3.1.3"); + var j = (t17, i23, s20) => { + const e33 = s20?.renderBefore ?? i23; + let h11 = e33._$litPart$; + if (void 0 === h11) { + const t18 = s20?.renderBefore ?? null; + e33._$litPart$ = h11 = new M(i23.insertBefore(l2(), t18), t18, void 0, s20 ?? {}); + } + return h11._$AI(t17), h11; + }; + + // node_modules/lit-element/lit-element.js + var s3 = class extends b { + constructor() { + super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0; + } + createRenderRoot() { + const t17 = super.createRenderRoot(); + return this.renderOptions.renderBefore ??= t17.firstChild, t17; + } + update(t17) { + const i23 = this.render(); + this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t17), this._$Do = j(i23, this.renderRoot, this.renderOptions); + } + connectedCallback() { + super.connectedCallback(), this._$Do?.setConnected(true); + } + disconnectedCallback() { + super.disconnectedCallback(), this._$Do?.setConnected(false); + } + render() { + return w; + } + }; + s3._$litElement$ = true, s3["finalized", "finalized"] = true, globalThis.litElementHydrateSupport?.({ LitElement: s3 }); + var r4 = globalThis.litElementPolyfillSupport; + r4?.({ LitElement: s3 }); + (globalThis.litElementVersions ??= []).push("4.0.5"); + + // node_modules/@adobe/lit-mobx/lit-mobx.js + var MobxLitElement = class extends MobxReactionUpdate(s3) { + }; + + // node_modules/@lit/reactive-element/decorators/custom-element.js + var t3 = (t17) => (e33, o29) => { + void 0 !== o29 ? o29.addInitializer(() => { + customElements.define(t17, e33); + }) : customElements.define(t17, e33); + }; + + // node_modules/@lit/reactive-element/decorators/property.js + var o4 = { attribute: true, type: String, converter: u, reflect: false, hasChanged: f }; + var r5 = (t17 = o4, e33, r18) => { + const { kind: n31, metadata: i23 } = r18; + let s20 = globalThis.litPropertyMetadata.get(i23); + if (void 0 === s20 && globalThis.litPropertyMetadata.set(i23, s20 = /* @__PURE__ */ new Map()), s20.set(r18.name, t17), "accessor" === n31) { + const { name: o29 } = r18; + return { set(r19) { + const n32 = e33.get.call(this); + e33.set.call(this, r19), this.requestUpdate(o29, n32, t17); + }, init(e34) { + return void 0 !== e34 && this.P(o29, void 0, t17), e34; + } }; + } + if ("setter" === n31) { + const { name: o29 } = r18; + return function(r19) { + const n32 = this[o29]; + e33.call(this, r19), this.requestUpdate(o29, n32, t17); + }; + } + throw Error("Unsupported decorator location: " + n31); + }; + function n4(t17) { + return (e33, o29) => "object" == typeof o29 ? r5(t17, e33, o29) : ((t18, e34, o30) => { + const r18 = e34.hasOwnProperty(o30); + return e34.constructor.createProperty(o30, r18 ? { ...t18, wrapped: true } : t18), r18 ? Object.getOwnPropertyDescriptor(e34, o30) : void 0; + })(t17, e33, o29); + } + + // node_modules/lit-html/directive.js + var t4 = { ATTRIBUTE: 1, CHILD: 2, PROPERTY: 3, BOOLEAN_ATTRIBUTE: 4, EVENT: 5, ELEMENT: 6 }; + var e5 = (t17) => (...e33) => ({ _$litDirective$: t17, values: e33 }); + var i5 = class { + constructor(t17) { + } + get _$AU() { + return this._$AM._$AU; + } + _$AT(t17, e33, i23) { + this._$Ct = t17, this._$AM = e33, this._$Ci = i23; + } + _$AS(t17, e33) { + return this.update(t17, e33); + } + update(t17, e33) { + return this.render(...e33); + } + }; + + // node_modules/lit-html/directives/class-map.js + var e6 = e5(class extends i5 { + constructor(t17) { + if (super(t17), t17.type !== t4.ATTRIBUTE || "class" !== t17.name || t17.strings?.length > 2) + throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute."); + } + render(t17) { + return " " + Object.keys(t17).filter((s20) => t17[s20]).join(" ") + " "; + } + update(s20, [i23]) { + if (void 0 === this.st) { + this.st = /* @__PURE__ */ new Set(), void 0 !== s20.strings && (this.nt = new Set(s20.strings.join(" ").split(/\s/).filter((t17) => "" !== t17))); + for (const t17 in i23) + i23[t17] && !this.nt?.has(t17) && this.st.add(t17); + return this.render(i23); + } + const r18 = s20.element.classList; + for (const t17 of this.st) + t17 in i23 || (r18.remove(t17), this.st.delete(t17)); + for (const t17 in i23) { + const s21 = !!i23[t17]; + s21 === this.st.has(t17) || this.nt?.has(t17) || (s21 ? (r18.add(t17), this.st.add(t17)) : (r18.remove(t17), this.st.delete(t17))); + } + return w; + } + }); + + // client/lib/shared_styles.css + var styles = i`:host { + color: #111; + font-family: 'Google Sans Text', 'Roboto', sans-serif; + /* LINT.IfChange */ + font-size: 12px; + /* LINT.ThenChange(./constants.ts) */ + scrollbar-width: thin; + + /* TODO(b/305091034): Clean up color variables */ + --comparator-model-a: #4684d7; + --comparator-model-b: #c78901; + --comparator-model-a-win: #2291df; + --comparator-model-b-win: #cb6a20; + --comparator-model-a-win-bg: #2291df10; + --comparator-model-b-win-bg: #cb6a2010; + --comparator-model-a-win-bg-darker: #2291df30; + --comparator-model-b-win-bg-darker: #cb6a2030; + + --comparator-grey-100: #f7f7f7; + --comparator-grey-150: #f3f3f3; + --comparator-grey-200: #eeeeee; + --comparator-grey-250: #dddddd; + --comparator-grey-300: #cccccc; + --comparator-grey-400: #aaaaaa; + --comparator-grey-450: #919191; + --comparator-grey-500: #777777; + --comparator-grey-600: #5c5c5c; + --comparator-grey-800: #333333; + + --comparator-greygreen-100: #f0f2f0; + --comparator-greygreen-200: #eaecea; + --comparator-greygreen-300: #d1eed1; + --comparator-greygreen-700: #335533; + + --comparator-greyblue-300: #828082; + + --comparator-green-100: #f8fff8; + --comparator-green-200: #f3f9f3; + --comparator-green-500: #339c33; + + --comparator-custom-func-100: #fbf7ff; + --comparator-custom-func-200: #f2e7f9; + --comparator-custom-func-500: #aa7fd1; + --comparator-custom-func-800: #8622df; + + --comparator-search-match-background: #ffff9d; + --comparator-search-match-foreground: #b73092; + + --comparator-popup-color: #db68cc; +} + +::-webkit-scrollbar { + background-color: transparent; + height: 10px; + width: 10px; +} + +::-webkit-scrollbar-thumb { + background-color: var(--comparator-grey-250); + border-radius: 5px; +} + +::-webkit-scrollbar-thumb:hover { + background-color: var(--comparator-grey-300); + border-radius: 5px; +} + +table { + border-collapse: collapse; + table-layout: fixed; +} + +ul { + margin: 0; + padding-left: 12px; +} + +.clickable { + cursor: pointer; +} + +#container { + display: flex; + flex-direction: column; + height: 100vh; +} + +#main { + display: flex; + flex-grow: 1; + height: calc(100vh - 50px); +} + +#main-panel { + display: flex; + flex-direction: column; + flex-grow: 1; + overflow-x: auto; +} + +#main-table { + flex: 1; +} + +#example-details { + border-top: 3px solid var(--comparator-grey-300); + height: 40%; + overflow-y: hidden; +} + +#example-details.expanded { + height: 80%; +} + +.table-panel { + overflow-y: scroll; + padding-left: 15px; +} + +/* Header */ +#header { + align-items: center; + background-color: white; + border-bottom: 2px solid var(--comparator-grey-250); + color: var(--comparator-grey-800); + display: flex; + height: 32px; + padding: 9px 12px 7px 28px; +} + +h1 { + font-size: 20px; + font-weight: 500; + margin: 0 25px 0 10px; +} + +.selected-dataset-path { + border-radius: 10px; + cursor: pointer; + font-family: monospace; + margin: 0 20px; + max-width: calc(100vw - 500px); + overflow-x: hidden; + padding: 5px 10px; + white-space: nowrap; +} + +.selected-dataset-path:hover { + background-color: var(--comparator-grey-150); +} + +.load-data-button { + background-color: var(--comparator-grey-150); + border: 0; + border-radius: 10px; + cursor: pointer; + font-size: 13px; + margin: 0 20px; + padding: 5px 10px; +} + +.load-data-button:hover { + background-color: var(--comparator-grey-250); +} + +.header-icon-container { + display: flex; + margin-left: auto; +} + +.link-icon { + padding: 0 6px; + position: relative; +} + +.icon { + border-radius: 24px; + color: var(--comparator-grey-500); + cursor: pointer; + padding: 6px; +} + +.icon:hover { + background-color: var(--comparator-grey-200); +} + +/* Status message */ +.status-message-container { + align-items: center; + background-color: #333; + border-radius: 5px; + color: #fff; + display: flex; + font-size: 13px; + font-weight: 500; + justify-content: space-between; + left: 0; + margin: 0 auto; + padding: 10px 15px; + position: absolute; + right: 0; + top: 10px; + width: 350px; + z-index: 20; +} + +.status-message-container .error-message { + font-weight: normal; +} + +.dismiss-button { + color: #a8c7fa; +} + +.popup-tooltip { + align-items: center; + background: var(--comparator-popup-color); + border-radius: 1px; + bottom: 0; + display: flex; + gap: 4px; + position: absolute; + left: 50%; + padding: 2px 4px; + transform: translate(-80%, 90%); + white-space: nowrap; +} + +.popup-tooltip:after { + border-color: transparent transparent var(--comparator-popup-color) transparent; + border-style: solid; + border-width: 4px; + bottom: 100%; + content: ""; + left: 80%; + position: absolute; + transform: translateX(-50%); +} + +.popup-tooltip a { + color: white; + text-decoration: none; +} + +.popup-tooltip .close-icon { + color: var(--comparator-grey-100); + cursor: pointer; + font-size: 11px; +} + +/* Sidebar */ +#sidebar { + background-color: #f3f3f3; + border-left: 2px solid #fff; + display: flex; + flex: 0 0 360px; + flex-direction: column; + height: 100%; + overflow-y: auto; + padding: 0 5px; +} + +.sidebar-component { + background-color: white; + border: 1px solid #ddd; + border-radius: 8px; + margin: 5px 5px 10px 5px; +} + +.sidebar-component-title { + align-items: center; + border-bottom: 1px solid #ddd; + cursor: pointer; + display: flex; + font-size: 1.2em; + justify-content: space-between; + padding: 5px 8px; +} + +.additional-note { + color: #999; + font-size: 11px; +} + +.sidebar-component-content { + padding: 8px 10px; +} + +.sidebar-component-content .description { + color: var(--comparator-grey-500); + font-size: 12px; + padding-bottom: 4px; +} + +.sidebar-component-content table { + width: 100%; +} + +.sidebar-component-content th { + background-color: var(--comparator-grey-200); + font-size: 11px; + font-weight: 200; + padding: 4px 0; +} + +.sidebar-component-content .sort-selected { + font-weight: 900; +} + +.sidebar-component-content td { + padding: 2px 4px; +} + +.sidebar-component-content tr.selected td { + background-color: var(--comparator-greygreen-100); + color: black; +} + +.sidebar-component-content tr:hover td { + background-color: var(--comparator-greygreen-200); +} + +.sidebar-component-footer { + background-color: var(--comparator-grey-100); + align-items: center; + cursor: pointer; + display: flex; + font-size: 11px; + justify-content: center; + padding: 1px 8px; +} + +/* Tables */ +tr.second-row .model-a { + background-color: var(--comparator-model-a); + border-radius: 15px; + padding: 0 15px; +} + +tr.second-row .model-b { + background-color: var(--comparator-model-b); + border-radius: 15px; + padding: 0 15px; +} + +/* Filter chips */ +.filter-chip { + align-items: center; + background-color: var(--comparator-greygreen-300); + border-radius: 10px; + color: var(--comparator-greygreen-700); + display: flex; + margin-left: 3px; + padding: 2px 3px 2px 7px; +} + +.chip-cancel-icon { + cursor: pointer; + font-size: 11px; + margin-left: 2px; + opacity: 0.7; +} + +.chip-cancel-icon:hover { + opacity: 1.0; +} + +/* Sort icons */ +.sort-icons-container { + padding: 0 0 16px 20px; + position: absolute; + right: -4px; + top: 10px; +} + +.sort-icon { + color: var(--comparator-grey-300); + cursor: pointer; + position: absolute; + right: 0; +} + +.sort-icon.up { + top: -12px; +} + +.sort-icon.down { + top: 6px; +} + +.sort-icon:hover { + color: var(--comparator-grey-50); +} + +.sort-icon.active { + color: #fff; +} + +.expand-icon { + color: var(--comparator-grey-500); + font-size: 13px; +} + +/* Charts */ +rect.clickable-transparent-area { + cursor: pointer; + fill: #fff; + opacity: 0.2; + stroke: none; +} + +rect.clickable-transparent-area.selected, +rect.clickable-transparent-area:hover { + opacity: 0.01; +} + +text.right-aligned { + text-anchor: end; +} + +rect.a-color, circle.a-color { + fill: var(--comparator-model-a); +} + +rect.b-color, circle.b-color { + fill: var(--comparator-model-b); +} + +rect.a-win-color, circle.a-win-color { + fill: var(--comparator-model-a-win); +} + +rect.b-win-color, circle.b-win-color { + fill: var(--comparator-model-b-win); +} + +div.a-color, span.a-color { + background-color: var(--comparator-model-a); +} + +div.b-color, span.b-color { + background-color: var(--comparator-model-b); +} + +div.a-win-color, span.a-win-color { + background-color: var(--comparator-model-a-win); +} + +div.b-win-color, span.b-win-color { + background-color: var(--comparator-model-b-win); +} + +.a-color-bg { + background-color: var(--comparator-model-a-background); +} + +.b-color-bg { + background-color: var(--comparator-model-b-background); +} + +.a-win-color-bg { + background-color: var(--comparator-model-a-win-bg); +} + +.b-win-color-bg { + background-color: var(--comparator-model-b-win-bg); +} + +.a-win-color-bg-darker { + background-color: var(--comparator-model-a-win-bg-darker); +} + +.b-win-color-bg-darker { + background-color: var(--comparator-model-b-win-bg-darker); +} +`; + + // client/components/bar_chart.css + var styles2 = i`.bar-chart { + display: block; + margin: 0; +} + +text { + alignment-baseline: middle; + fill: var(--comparator-grey-800); + font-size: 11px; + text-anchor: middle; +} + +.bar { + fill: var(--comparator-grey-400); + fill-opacity: 0.5; + stroke-width: 0; +} + +.bar.some-selected, +.bar-label.some-selected { + fill-opacity: 0.2; +} + +.bar.selected, +.bar-label.selected, +.bar:hover { + fill-opacity: 1.0; +} + +text.bar-label { + font-size: 10px; + text-anchor: start; +} + +.bar-chart .axis { + fill: none; + stroke: var(--comparator-grey-400); + stroke-width: 1; +} + +.bar-chart .axis-label { + text-anchor: end; +} + +text.highlighted { + font-weight: 600; +}`; + + // client/components/bar_chart.ts + var BarChartElement = class extends MobxLitElement { + constructor() { + super(); + this.getValueDomain = () => []; + this.groupCount = 1; + this.isNested = false; + this.getDataValues = () => []; + this.getGroupedDataValues = () => []; + this.getGroupedNestedDataValues = () => []; + this.handleClickBar = () => { + }; + this.isAnyBarSelected = () => false; + this.isThisBarSelected = () => false; + this.getHighlightedValues = () => []; + this.svgWidth = 280; + this.barHeight = 14; + this.verticalPaddingBetweenBarsWithinGroup = 1; + this.verticalPadding = 1; + this.leftAxisWidth = 110; + this.rightPaddingDefault = 25; + this.rightPaddingForNested = 55; + makeObservable(this); + } + get aggregatedData() { + const aggregatedCount = {}; + this.getValueDomain().forEach((value) => { + const entryPair = Array.from({ length: this.groupCount }, () => { + return { count: 0, weight: 0 }; + }); + aggregatedCount[value] = entryPair; + }); + if (this.isNested === true) { + const groupedNestedDataValues = this.getGroupedNestedDataValues(); + groupedNestedDataValues.forEach( + (nestedValues, groupIndex) => { + nestedValues.forEach((values) => { + const elementCount = values.length; + values.forEach((value) => { + aggregatedCount[value][groupIndex].weight += 1 / elementCount; + }); + new Set(values).forEach((value) => { + aggregatedCount[value][groupIndex].count += 1; + }); + }); + } + ); + } else { + const groupedDataValues = this.groupCount > 1 ? this.getGroupedDataValues() : [this.getDataValues()]; + groupedDataValues.forEach((values, groupIndex) => { + values.forEach((value) => { + aggregatedCount[value][groupIndex].count += 1; + aggregatedCount[value][groupIndex].weight += 1; + }); + }); + } + return aggregatedCount; + } + get verticalPaddingForGroup() { + return Math.ceil(this.barHeight / 2); + } + get rightPadding() { + return this.isNested === true ? this.rightPaddingForNested : this.rightPaddingDefault; + } + get binHeight() { + return (this.barHeight + this.verticalPaddingBetweenBarsWithinGroup) * this.groupCount + this.verticalPaddingForGroup * 2; + } + get svgHeight() { + return this.binHeight * this.getValueDomain().length + this.verticalPadding * 2; + } + get barMaxWidth() { + return this.svgWidth - this.rightPadding - this.leftAxisWidth; + } + renderLeftAxis() { + const paddingBetweenBarAndAxisLine = 1; + const tickLength = 2; + const paddingBetweenTickAndLabel = 2; + const renderAxis = b2` + `; + const styleAxisLabel = (value) => e6({ + "axis-label": true, + "highlighted": this.getHighlightedValues().includes(value) + }); + const renderTicks = this.getValueDomain().map( + (value, tickIndex) => b2` + + + + ${value} + ${value} + + ` + ); + return b2` + ${renderAxis} + ${renderTicks}`; + } + renderGroupedBar(value, entryPair, maxCount, index) { + const renderBars = entryPair.map( + (entry, groupIndex) => { + const barWidth = entry.weight * this.barMaxWidth / maxCount; + const binRectClass = (value2) => e6({ + "bar": true, + "some-selected": this.isAnyBarSelected(groupIndex), + "selected": this.isThisBarSelected(value2, groupIndex), + "a-color": this.groupCount === 2 && groupIndex === 0, + "b-color": this.groupCount === 2 && groupIndex === 1 + }); + const binTextClass = (value2) => e6({ + "bar-label": true, + "some-selected": this.isAnyBarSelected(groupIndex), + "selected": this.isThisBarSelected(value2, groupIndex) + }); + const barAreaHeight = this.barHeight + this.verticalPaddingBetweenBarsWithinGroup; + return b2` + + + + ${entry.weight > 0 ? this.isNested === true ? `${entry.weight.toFixed(1)} (${entry.count})` : entry.count : ""} + + void this.handleClickBar(value, groupIndex)} /> + `; + } + ); + return b2` + + ${renderBars} + `; + } + render() { + const aggregatedWeights = Object.values(this.aggregatedData).flat(2).map((entry) => entry.weight); + const maxWeight = Math.max(1, Math.max(...aggregatedWeights)); + const renderGroupedBars = this.getValueDomain().map( + (value, index) => { + const entryPair = this.aggregatedData[value]; + return this.renderGroupedBar(value, entryPair, maxWeight, index); + } + ); + return x` + + + ${this.renderLeftAxis()} + ${renderGroupedBars} + + `; + } + }; + BarChartElement.styles = [styles, styles2]; + __decorateClass([ + n4({ type: Object }) + ], BarChartElement.prototype, "getValueDomain", 2); + __decorateClass([ + n4({ type: Number }) + ], BarChartElement.prototype, "groupCount", 2); + __decorateClass([ + n4({ type: Boolean }) + ], BarChartElement.prototype, "isNested", 2); + __decorateClass([ + n4({ type: Object }) + ], BarChartElement.prototype, "getDataValues", 2); + __decorateClass([ + n4({ type: Object }) + ], BarChartElement.prototype, "getGroupedDataValues", 2); + __decorateClass([ + n4({ type: Object }) + ], BarChartElement.prototype, "getGroupedNestedDataValues", 2); + __decorateClass([ + n4({ type: Object }) + ], BarChartElement.prototype, "handleClickBar", 2); + __decorateClass([ + n4({ type: Object }) + ], BarChartElement.prototype, "isAnyBarSelected", 2); + __decorateClass([ + n4({ type: Object }) + ], BarChartElement.prototype, "isThisBarSelected", 2); + __decorateClass([ + n4({ type: Object }) + ], BarChartElement.prototype, "getHighlightedValues", 2); + __decorateClass([ + n4({ type: Number }) + ], BarChartElement.prototype, "svgWidth", 2); + __decorateClass([ + n4({ type: Number }) + ], BarChartElement.prototype, "barHeight", 2); + __decorateClass([ + n4({ type: Number }) + ], BarChartElement.prototype, "leftAxisWidth", 2); + __decorateClass([ + computed + ], BarChartElement.prototype, "aggregatedData", 1); + __decorateClass([ + computed + ], BarChartElement.prototype, "verticalPaddingForGroup", 1); + __decorateClass([ + computed + ], BarChartElement.prototype, "rightPadding", 1); + __decorateClass([ + computed + ], BarChartElement.prototype, "binHeight", 1); + __decorateClass([ + computed + ], BarChartElement.prototype, "svgHeight", 1); + __decorateClass([ + computed + ], BarChartElement.prototype, "barMaxWidth", 1); + BarChartElement = __decorateClass([ + t3("comparator-bar-chart") + ], BarChartElement); + + // client/lib/types.ts + var AOrB = /* @__PURE__ */ ((AOrB2) => { + AOrB2["A"] = "A"; + AOrB2["B"] = "B"; + return AOrB2; + })(AOrB || {}); + var FieldType = /* @__PURE__ */ ((FieldType2) => { + FieldType2["NUMBER"] = "number"; + FieldType2["STRING"] = "string"; + FieldType2["CATEGORY"] = "category"; + FieldType2["TEXT"] = "text"; + FieldType2["URL"] = "url"; + FieldType2["IMAGE_PATH"] = "image_path"; + FieldType2["IMAGE_BYTE"] = "image_byte"; + FieldType2["PER_MODEL_BOOLEAN"] = "per_model_boolean"; + FieldType2["PER_MODEL_NUMBER"] = "per_model_number"; + FieldType2["PER_MODEL_CATEGORY"] = "per_model_category"; + FieldType2["PER_MODEL_TEXT"] = "per_model_text"; + FieldType2["PER_RATING_STRING"] = "per_rating_string"; + FieldType2["PER_RATING_PER_MODEL_CATEGORY"] = "per_rating_per_model_category"; + FieldType2["BASE"] = "base"; + return FieldType2; + })(FieldType || {}); + var CustomFuncType = /* @__PURE__ */ ((CustomFuncType2) => { + CustomFuncType2["REGEXP"] = "Regular Expr."; + CustomFuncType2["PRECOMPUTED"] = "Precomputed"; + return CustomFuncType2; + })(CustomFuncType || {}); + var CustomFuncReturnType = /* @__PURE__ */ ((CustomFuncReturnType2) => { + CustomFuncReturnType2["BOOLEAN"] = "Boolean"; + CustomFuncReturnType2["NUMBER"] = "Number"; + return CustomFuncReturnType2; + })(CustomFuncReturnType || {}); + + // client/lib/constants.ts + var BASE_FIELD_ID_PREFIX = "base:"; + var FIELD_ID_FOR_INDEX = `${BASE_FIELD_ID_PREFIX}index`; + var FIELD_ID_FOR_INPUT = `${BASE_FIELD_ID_PREFIX}input_text`; + var FIELD_ID_FOR_OUTPUT_A = `${BASE_FIELD_ID_PREFIX}output_text_a`; + var FIELD_ID_FOR_OUTPUT_B = `${BASE_FIELD_ID_PREFIX}output_text_b`; + var FIELD_ID_FOR_TAGS = `${BASE_FIELD_ID_PREFIX}tags`; + var FIELD_ID_FOR_SCORE = `${BASE_FIELD_ID_PREFIX}score`; + var FIELD_ID_FOR_RATIONALES = `${BASE_FIELD_ID_PREFIX}rationales`; + var FIELD_ID_FOR_RATIONALE_LIST = `${BASE_FIELD_ID_PREFIX}rationale_list`; + var DEFAULT_COLUMN_LIST = [ + { id: FIELD_ID_FOR_INDEX, name: "Index", type: "base" /* BASE */, visible: true }, + { id: FIELD_ID_FOR_INPUT, name: "Prompt", type: "base" /* BASE */, visible: true }, + { + id: FIELD_ID_FOR_TAGS, + name: "Prompt Categories", + type: "base" /* BASE */, + visible: false + }, + { + id: FIELD_ID_FOR_OUTPUT_A, + name: "Response from Model A", + type: "base" /* BASE */, + visible: true + }, + { + id: FIELD_ID_FOR_OUTPUT_B, + name: "Response from Model B", + type: "base" /* BASE */, + visible: true + }, + { id: FIELD_ID_FOR_SCORE, name: "Score", type: "base" /* BASE */, visible: true }, + { + id: FIELD_ID_FOR_RATIONALES, + name: "Rationales", + type: "base" /* BASE */, + visible: false + }, + { + id: FIELD_ID_FOR_RATIONALE_LIST, + name: "Rationale List", + type: "base" /* BASE */, + visible: false + } + ]; + var DEFAULT_SORTING_CRITERIA = { + column: "None" /* NONE */, + customField: null, + modelIndex: null, + order: "None" /* NONE */ + }; + var LINE_HEIGHT_IN_CELL = 17; + var DEFAULT_NUM_EXAMPLES_TO_DISPLAY = 50; + var DEFAULT_CHART_HEIGHT_FOR_CUSTOM_FUNCS = 60; + var DEFAULT_SXS_HISTOGRAM_HEIGHT_FOR_CUSTOM_FUNCS = 40; + var HISTOGRAM_BOTTOM_AXIS_HEIGHT = 9; + var DEFAULT_HISTOGRAM_SPEC = { + rangeLeft: -1.75, + rangeRight: 1.75, + numberOfBins: 7, + isBounded: false, + isDivergingScheme: true + }; + var FIVE_POINT_LIKERT_HISTOGRAM_SPEC = { + rangeLeft: 1, + rangeRight: 5, + numberOfBins: 9, + isBounded: true, + isDivergingScheme: true + }; + var DEFAULT_WIN_RATE_THRESHOLD = 0.25; + var DEFAULT_RATIONALE_CLUSTER_SIMILARITY_THRESHOLD = 0.8; + var BUILT_IN_DEMO_FILES = [ + "https://pair-code.github.io/llm-comparator/data/example_tiny.json", + "https://pair-code.github.io/llm-comparator/data/example_arena.json" + ]; + var INITIAL_CUSTOM_FUNCTIONS = [ + { + id: -1, + // Will be overwritten. + name: "Word count", + functionType: "Regular Expr." /* REGEXP */, + functionBody: "\\w+", + returnType: "Number" /* NUMBER */, + precomputed: false + }, + { + id: -1, + name: "Contains bulleted lists", + functionType: "Regular Expr." /* REGEXP */, + functionBody: "\\n([*-])\\s", + returnType: "Boolean" /* BOOLEAN */, + precomputed: false + }, + { + id: -1, + name: "Contains headings", + functionType: "Regular Expr." /* REGEXP */, + functionBody: "#+\\s+.+", + returnType: "Boolean" /* BOOLEAN */, + precomputed: false + }, + { + id: -1, + name: "Contains URLs", + functionType: "Regular Expr." /* REGEXP */, + functionBody: "https?://[-a-zA-Z0-9&@#/%?=+~_|!:,.;]*[-a-zA-Z0-9&@#/%=+~_|]", + returnType: "Boolean" /* BOOLEAN */, + precomputed: false + }, + { + id: -1, + name: 'Starts with "Sure"', + functionType: "Regular Expr." /* REGEXP */, + functionBody: "^Sure", + returnType: "Boolean" /* BOOLEAN */, + precomputed: false + } + ]; + + // client/lib/utils.ts + var import_jsdifflib = __toESM(require_jsdifflib()); + var import_jstat = __toESM(require_jstat()); + function getTextDiff(textA, textB) { + const tokenize = (text) => text.match(/[\w\d'-]+|\W+/g); + const wordsA = tokenize(textA) || []; + const wordsB = tokenize(textB) || []; + const replaceTokensThatThrowErrors = (token) => token === "hasOwnProperty" ? "_hasOwnProperty_" : token; + const cleanedWordsA = [...wordsA].map(replaceTokensThatThrowErrors); + const cleanedWordsB = [...wordsB].map(replaceTokensThatThrowErrors); + const matcher = new import_jsdifflib.default.SequenceMatcher(cleanedWordsA, cleanedWordsB); + const opcodes = matcher.get_opcodes(); + const textDiff = { parsedA: [], parsedB: [], isEquals: [] }; + for (const opcode of opcodes) { + const changeType = opcode[0]; + const startA = Number(opcode[1]); + const endA = Number(opcode[2]); + const startB = Number(opcode[3]); + const endB = Number(opcode[4]); + textDiff.parsedA.push(wordsA.slice(startA, endA).join("")); + textDiff.parsedB.push(wordsB.slice(startB, endB).join("")); + textDiff.isEquals.push(changeType === "equal"); + } + return textDiff; + } + function renderDiffString(strings2, equal) { + const displaySpans = strings2.map((output, i23) => { + const classes = e6({ "highlighted-match": equal[i23] }); + return x`${output}`; + }); + return displaySpans; + } + function renderSearchedString(text, searchText2, caseInsensitive = true) { + const pattern = new RegExp(searchText2, caseInsensitive === true ? "gi" : "g"); + const matches3 = text.matchAll(pattern); + const matchList = [...matches3]; + if (!matchList.length) { + return x`${text}`; + } + const matchedResults = matchList.map((match) => { + return { + index: match.index, + text: match[0] + }; + }); + const annotatedText = []; + for (let j3 = 0; j3 < matchedResults.length; j3++) { + if (j3 === 0) { + annotatedText.push(x`${text.substring(0, matchedResults[j3].index)}`); + } + annotatedText.push( + x`${matchedResults[j3].text}` + ); + annotatedText.push( + x`${text.substring( + matchedResults[j3].index + matchedResults[j3].text.length, + j3 < matchedResults.length - 1 ? matchedResults[j3 + 1].index : text.length + )}` + ); + } + return annotatedText; + } + function searchText(text, stringToSearch, ignoreCase = true) { + const pattern = new RegExp( + stringToSearch, + ignoreCase === true ? "i" : void 0 + ); + return pattern.test(text); + } + function formatRateToPercentage(rate) { + return `${(rate * 100).toFixed(1)}%`; + } + function getWinRate(entry) { + const sum = entry.results["a"] + entry.results["b"] + entry.results["tie"]; + if (sum === 0) { + return 0; + } else { + return (entry.results["a"] + 0.5 * entry.results["tie"]) / sum; + } + } + function getAvgScore(entry) { + const count = entry.count; + return count === 0 ? null : entry.scoreSum / count; + } + function makeNewSliceWinRate(sliceName) { + const sliceWinRate = { + sliceName, + count: 0, + results: { "a": 0, "b": 0, "tie": 0, "unknown": 0 }, + scoreSum: 0, + scoreSqSum: 0 + }; + return sliceWinRate; + } + function getZScoreFromConfidenceLevel(confidenceLevel) { + if (confidenceLevel === 0.95) { + return 1.96; + } else if (confidenceLevel === 0.99) { + return 2.576; + } else if (confidenceLevel === 0.9) { + return 1.645; + } else { + throw new Error(`Use 0.9, 0.95, or 0.99 for confidence level.`); + } + } + function calculateErrorMargin(count, scoreSum, scoreSqSum, confidenceLevel = 0.95) { + if (count === 0) { + return 0; + } else if (count === 1) { + return 1e4; + } + const variance = scoreSqSum - scoreSum ** 2 / count; + const standardDeviation = Math.sqrt(variance / (count - 1)); + const standardError = standardDeviation / Math.sqrt(count); + const zScore = getZScoreFromConfidenceLevel(confidenceLevel); + const marginOfError = zScore * standardError; + return marginOfError; + } + function getConfidenceIntervalForMeanFromAggregatedStats(count, sum, squareSum, isAxisReversed = false, confidenceLevel = 0.95) { + if (count === 0) { + return [0, 0]; + } + const errorMargin = calculateErrorMargin( + count, + sum, + squareSum, + confidenceLevel + ); + const mean = sum / count; + const errorMarginLeft = mean - errorMargin * (isAxisReversed === true ? -1 : 1); + const errorMarginRight = mean + errorMargin * (isAxisReversed === true ? -1 : 1); + return [errorMarginLeft, errorMarginRight]; + } + function getConfidenceIntervalForRate(countTrue, countFalse, confidenceLevel = 0.95) { + const alpha = countTrue + 0.5; + const beta = countFalse + 0.5; + const left = import_jstat.default.beta.inv(1 - confidenceLevel, alpha, beta); + const right = import_jstat.default.beta.inv(confidenceLevel, alpha, beta); + return [left, right]; + } + function getHistogramStepSize(histogramSpec) { + return (histogramSpec.rangeRight - histogramSpec.rangeLeft) / histogramSpec.numberOfBins; + } + function getHistogramBinIndexFromValue(histogramSpec, value) { + const stepSize = getHistogramStepSize(histogramSpec); + const binPositionValue = (value - histogramSpec.rangeLeft) / stepSize; + const binIndex = histogramSpec.isDivergingScheme === true && binPositionValue > histogramSpec.numberOfBins * 0.5 ? Math.ceil(binPositionValue) - 1 : Math.floor(binPositionValue); + if (binIndex < 0) { + return 0; + } else if (binIndex > histogramSpec.numberOfBins - 1) { + return histogramSpec.numberOfBins - 1; + } else { + return binIndex; + } + } + function getHistogramRangeFromBinIndex(histogramSpec, binIndex) { + const stepSize = getHistogramStepSize(histogramSpec); + return { + left: histogramSpec.rangeLeft + binIndex * stepSize, + right: histogramSpec.rangeLeft + (binIndex + 1) * stepSize + }; + } + function getFloatPrecisionForHistogram(histogramSpec) { + if (Math.abs(histogramSpec.rangeRight - histogramSpec.rangeLeft) < histogramSpec.numberOfBins) { + return 2; + } else if (Math.abs(histogramSpec.rangeRight - histogramSpec.rangeLeft) < histogramSpec.numberOfBins * 2) { + return 1; + } else { + return 0; + } + } + function getRangeInclusionFromBinIndex(histogramSpec, binIndex) { + return { + left: histogramSpec.isDivergingScheme === false || binIndex <= (histogramSpec.numberOfBins - 1) * 0.5, + right: binIndex === histogramSpec.numberOfBins - 1 || histogramSpec.isDivergingScheme === true && binIndex >= (histogramSpec.numberOfBins - 1) * 0.5 + }; + } + function makeNewCustomFunc(id) { + const customFunc = { + id, + name: "", + functionType: "Regular Expr." /* REGEXP */, + functionBody: "", + returnType: "Boolean" /* BOOLEAN */, + precomputed: false + }; + return customFunc; + } + function initializeCustomFuncSelections() { + return { "A": null, "B": null, "A-B": null }; + } + function getFieldIdForCustomFunc(customFuncId) { + return `custom_function:${customFuncId}`; + } + function isPerModelFieldType(field) { + return field.type === "per_model_boolean" /* PER_MODEL_BOOLEAN */ || field.type === "per_model_number" /* PER_MODEL_NUMBER */ || field.type === "per_model_category" /* PER_MODEL_CATEGORY */ || field.type === "per_model_text" /* PER_MODEL_TEXT */; + } + function isPerRatingFieldType(field) { + return field.type === "per_rating_string" /* PER_RATING_STRING */ || field.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */; + } + function toFixedIfNeeded(num) { + if (num % 1 !== 0) { + return num.toFixed(2); + } else { + return num.toString(); + } + } + function constructImageSrcFromByte(imageByte, imageType = "jpeg") { + return `data:image/${imageType};base64,${imageByte}`; + } + function getMinAndMax(values) { + const notNullValues = values.filter((value) => value != null).map((value) => value); + const minValue = notNullValues.length > 0 ? Math.min(...notNullValues) : 0; + const maxValue = notNullValues.length > 0 ? Math.max(...notNullValues) : 0; + return { minValue, maxValue }; + } + function groupByValues(values) { + const aggregatedCount = {}; + values.forEach((value) => { + if (!aggregatedCount[value]) { + aggregatedCount[value] = 0; + } + aggregatedCount[value] += 1; + }); + return aggregatedCount; + } + function groupByAndSortKeys(values) { + const aggregatedCount = groupByValues(values); + return Object.entries(aggregatedCount).sort((a11, b7) => b7[1] - a11[1]).map(([key, count]) => key); + } + function mergeTwoArrays(baseValues, extendedValues) { + const baseValueSet = new Set(baseValues); + return [ + ...baseValues, + ...extendedValues.filter((value) => !baseValueSet.has(value)) + ]; + } + function printCustomFuncResultValue(value) { + if (value == null) { + return "NULL"; + } else if (typeof value === "boolean") { + return value === true ? "True" : "False"; + } else if (typeof value === "number" && !Number.isInteger(value)) { + return value.toFixed(3); + } else { + return value; + } + } + function convertToNumber(value) { + if (typeof value === "number") { + return value; + } else if (value === null) { + return null; + } else if (typeof value === "string") { + const parsedNumber = Number(value); + if (!isNaN(parsedNumber)) { + return parsedNumber; + } + } + return null; + } + function isEqualSorting(a11, b7) { + return a11.column === b7.column && (a11.customField == null && b7.customField == null || a11.customField != null && b7.customField != null && a11.customField.id === b7.customField.id) && a11.modelIndex === b7.modelIndex && a11.order === b7.order; + } + function compareStringsWithNulls(a11, b7) { + if (a11 == null && b7 == null) + return 0; + if (a11 == null) + return 1; + if (b7 == null) + return -1; + return a11.localeCompare(b7); + } + function compareNumbersWithNulls(a11, b7, isDescending) { + if (a11 === null && b7 === null) { + return 0; + } else if (a11 === null) { + return 1; + } else if (b7 === null) { + return -1; + } else { + return isDescending === true ? b7 - a11 : a11 - b7; + } + } + function replaceSpaceWithUnderscore(text) { + return text.replaceAll(" ", "_"); + } + function getHistogramFilterLabel(fieldName, histogramSpec, binIndex, model = null) { + if (histogramSpec == null || binIndex == null) { + return ""; + } else { + const fieldNameWithNoSpace = replaceSpaceWithUnderscore(fieldName); + const { left, right } = getHistogramRangeFromBinIndex( + histogramSpec, + binIndex + ); + const leftStr = histogramSpec.isBounded === false && binIndex === 0 ? null : left.toFixed(getFloatPrecisionForHistogram(histogramSpec)); + const rightStr = histogramSpec.isBounded === false && binIndex === histogramSpec.numberOfBins - 1 ? null : right.toFixed(getFloatPrecisionForHistogram(histogramSpec)); + const revisedFieldName = model == null ? fieldNameWithNoSpace : model === "A-B" ? `${fieldNameWithNoSpace}(A) - ${fieldNameWithNoSpace}(B)` : `${fieldNameWithNoSpace}(${model})`; + const operator = getHistogramStepSize(histogramSpec) > 0 ? "<" : ">"; + const rangeInclusion = getRangeInclusionFromBinIndex( + histogramSpec, + binIndex + ); + const leftEqual = rangeInclusion.left === true ? "=" : ""; + const rightEqual = rangeInclusion.right === true ? "=" : ""; + if (leftStr !== null && rightStr !== null) { + return `${leftStr} ${operator}${leftEqual} ${revisedFieldName} ${operator}${rightEqual} ${rightStr}`; + } else if (leftStr == null) { + return `${revisedFieldName} ${operator}${rightEqual} ${rightStr}`; + } else { + const flippedOperator = operator === ">" ? "<" : ">"; + return `${revisedFieldName} ${flippedOperator}${leftEqual} ${leftStr}`; + } + } + } + function getBarFilterLabel(customFuncName, model, value) { + return `${customFuncName}(${replaceSpaceWithUnderscore(model)}) = ${value}`; + } + function extractTextFromTextOrSequenceChunks(val) { + if (typeof val === "string") { + return val; + } else { + return val.filter((chunk) => chunk.type === "text" /* TEXT */).map((chunk) => chunk.data).join("\n"); + } + } + + // client/components/histogram.css + var styles3 = i`.histogram { + display: block; + margin: 0 auto; +} + +text { + fill: var(--comparator-grey-500); + font-size: 10px; + text-anchor: middle; +} + +text.left-aligned { + text-anchor: start; +} + +text.right-aligned { + text-anchor: end; +} + +.histogram .axis { + fill: none; + stroke: var(--comparator-grey-400); + stroke-width: 1; +} + +.histogram .axis-label { + alignment-baseline: hanging; + fill: var(--comparator-grey-400); + font-size: 9px; +} + +.axis-end-label-bg { + fill-opacity: 0.8; +} + +.axis-end-desc { + alignment-baseline: hanging; + fill: white; + font-size: 10px; +} + +line.mean-rule { + fill: none; + stroke: var(--comparator-greygreen-700); + stroke-width: 2; +} + +text.mean-rule-label { + alignment-baseline: hanging; + fill: var(--comparator-greygreen-700); + font-size: 9px; + text-anchor: start; + visibility: hidden; +} + +text.mean-rule-label.shown { + visibility: visible; +} + +.chart-title { + alignment-baseline: middle; + fill: var(--comparator-grey-500); + text-anchor: end; +} + +.histogram-bar-clip-area { + fill: var(--comparator-grey-450); +} + +rect.clickable-transparent-area { + opacity: 0.25; +} + +rect.clickable-transparent-area.some-selected { + opacity: 0.8; +} + +rect.clickable-transparent-area.selected { + opacity: 0.15; +} + +rect.clickable-transparent-area.some-selected:hover { + opacity: 0.6; +} + +rect.clickable-transparent-area:hover, +rect.clickable-transparent-area.selected:hover { + opacity: 0.05; +}`; + + // client/components/histogram.ts + var HistogramElement = class extends MobxLitElement { + constructor() { + super(); + this.getHistogramSpec = () => DEFAULT_HISTOGRAM_SPEC; + this.getRawDataValues = () => []; + this.handleClickHistogramBar = () => { + }; + this.isAnyBinSelected = () => false; + this.isThisBinSelected = () => false; + this.svgWidth = 220; + this.svgHeight = 70; + this.neutralColorThreshold = () => null; + this.specificColorScheme = null; + this.showBottomAxis = true; + this.showAxisEndDescription = false; + this.isSimplified = false; + this.isFlipXAxis = () => false; + this.titleOnLeft = null; + this.barSidePadding = 1; + this.topPaddingDefault = 10; + this.topPaddingForSimplified = 3; + this.rightPadding = 5; + this.titlePadding = 20; + this.bottomAxisHeight = 18; + this.bottomAxisEndDescriptionHeight = 12; + this.paddingBetweenBarAndAxisLine = 1; + this.showRuleLabel = false; + this.minHeightToAlwaysShowRuleLabel = 50; + makeObservable(this); + } + get leftPadding() { + return this.titleOnLeft == null ? this.rightPadding : this.titlePadding; + } + get topPadding() { + return this.isSimplified === true ? this.topPaddingForSimplified : this.topPaddingDefault; + } + get histogramAreaWidth() { + return this.svgWidth - this.leftPadding - this.rightPadding; + } + get binWidth() { + const numberOfBins = this.getHistogramSpec().numberOfBins; + if (numberOfBins === 0) { + return 0; + } else { + return Math.floor(this.histogramAreaWidth / numberOfBins); + } + } + get bottomAxisAreaHeight() { + return this.showAxisEndDescription === true ? this.bottomAxisHeight + this.bottomAxisEndDescriptionHeight : this.bottomAxisEndDescriptionHeight; + } + get barMaxHeight() { + return this.svgHeight - this.topPadding - this.bottomAxisAreaHeight; + } + get useDivergingColorScheme() { + return this.getHistogramSpec().isDivergingScheme === true; + } + get binnedData() { + const values = Array.from({ + length: this.getHistogramSpec().numberOfBins + }).fill(0); + this.getRawDataValues().forEach((value) => { + const binIndex = getHistogramBinIndexFromValue( + this.getHistogramSpec(), + value + ); + values[binIndex] += 1; + }); + return values; + } + get maxCount() { + return Math.max(1, Math.max(...this.binnedData)); + } + get mean() { + const rawDataValues = this.getRawDataValues(); + if (rawDataValues.length === 0) { + return 0; + } else { + return rawDataValues.reduce((a11, b7) => a11 + b7, 0) / rawDataValues.length; + } + } + renderBottomAxis() { + const tickLength = 2; + const paddingBetweenTickAndLabel = 1; + const renderAxis = b2` + `; + const axisEndLabelWidth = 50; + const axisEndLabelHeight = 11; + const styleAxisEndLabelBg = (isRightSide) => e6({ + "axis-end-label-bg": true, + "a-win-color": isRightSide === !this.isFlipXAxis(), + "b-win-color": isRightSide === this.isFlipXAxis() + }); + const renderAxisEndDescriptions = this.showAxisEndDescription === true ? b2` + + + + + ${this.isFlipXAxis() === true ? "A" : "B"} is better + + + ${this.isFlipXAxis() === true ? "B" : "A"} is better + ` : ""; + const numberOfBins = this.getHistogramSpec().numberOfBins; + const renderTickLabel = (tickIndex) => { + let value = null; + if (this.getHistogramSpec().isBounded === true) { + if (tickIndex === 0 || tickIndex === numberOfBins) { + value = getHistogramRangeFromBinIndex( + this.getHistogramSpec(), + tickIndex + ).left; + } + } else { + if (tickIndex > 0 && tickIndex < numberOfBins) { + value = getHistogramRangeFromBinIndex( + this.getHistogramSpec(), + tickIndex + ).left; + } + } + const styleAxisLabel = e6({ + "axis-label": true, + "left-aligned": this.getHistogramSpec().isBounded === true && (this.isFlipXAxis() === false && tickIndex === 0 || this.isFlipXAxis() === true && tickIndex === numberOfBins), + "right-aligned": this.getHistogramSpec().isBounded === true && (this.isFlipXAxis() === false && tickIndex === numberOfBins || this.isFlipXAxis() === true && tickIndex === 0) + }); + return b2` + + ${value != null ? value.toFixed( + getFloatPrecisionForHistogram(this.getHistogramSpec()) + ) : ""} + `; + }; + const renderTicks = Array.from({ + length: this.getHistogramSpec().numberOfBins + 1 + }).map((tick, tickIndex) => { + const xOffsetRatio = tickIndex / this.getHistogramSpec().numberOfBins; + const xOffset = this.histogramAreaWidth * (this.isFlipXAxis() === true ? 1 - xOffsetRatio : xOffsetRatio); + return b2` + + + ${renderTickLabel(tickIndex)} + `; + }); + return b2` + + ${renderAxis} + ${renderAxisEndDescriptions} + ${renderTicks} + `; + } + // Draw the shape of the bars for clipping. + clipShapeOfHistogramBar(count, maxCount, index) { + const barHeight = count * this.barMaxHeight / maxCount; + const xIndex = this.isFlipXAxis() === true ? this.binnedData.length - 1 - index : index; + return b2` + `; + } + // Specify fill colors of histogram bars and clip the shape. + renderColoredBarAreas() { + const histogramSpec = this.getHistogramSpec(); + const thresholdValue = this.neutralColorThreshold() != null ? this.neutralColorThreshold() : 0; + const thresholdPoint = (histogramSpec.rangeLeft + histogramSpec.rangeRight) * 0.5 - thresholdValue * Math.sign(histogramSpec.rangeRight - histogramSpec.rangeLeft); + const widthRatioOfColoredArea = (thresholdPoint - histogramSpec.rangeLeft) / (histogramSpec.rangeRight - histogramSpec.rangeLeft); + const thresholdWidth = this.histogramAreaWidth * widthRatioOfColoredArea; + const styleHistogramBarDefault = e6({ + "histogram-bar-clip-area": true, + "a-color": this.specificColorScheme === "A", + "b-color": this.specificColorScheme === "B" + }); + return b2` + + ${this.useDivergingColorScheme === true && this.neutralColorThreshold() != null ? b2` + + ` : ""}`; + } + // Render number labels above bars and clickable transparent areas. + renderHistogramBarElements(count, maxCount, index) { + if (this.isSimplified === true) { + return b2``; + } + const barHeight = count * this.barMaxHeight / maxCount; + const binTextClass = (binIndex) => e6({ + "histogram-bar-label": true, + "some-selected": this.isAnyBinSelected(), + "selected": this.isThisBinSelected(binIndex) + }); + const binClickableAreaClass = (binIndex) => e6({ + "clickable-transparent-area": true, + "clickable": true, + "some-selected": this.isAnyBinSelected(), + "selected": this.isThisBinSelected(binIndex) + }); + const xOffset = (binIndex) => this.binWidth * (this.isFlipXAxis() === true ? this.binnedData.length - 1 - binIndex : binIndex); + const renderCountLabel = b2` + + ${count > 0 ? count : ""} + `; + const renderClickableArea = b2` + void this.handleClickHistogramBar(index)} + />`; + return b2` + + ${renderCountLabel} + ${renderClickableArea} + `; + } + // Render a vertical bar (i.e., rule) that indicates the mean value. + renderMeanRule() { + if (this.isSimplified === true || this.getRawDataValues().length <= 1) { + return b2``; + } + const binIndex = getHistogramBinIndexFromValue( + this.getHistogramSpec(), + this.mean + ); + const binStartingPosition = binIndex * this.histogramAreaWidth / this.getHistogramSpec().numberOfBins + this.barSidePadding; + const { left, right } = getHistogramRangeFromBinIndex( + this.getHistogramSpec(), + binIndex + ); + const binProportion = (this.mean - left) / (right - left); + const binInsideOffset = binProportion * (this.binWidth - this.barSidePadding * 2); + const xPositionBeforeFlipConsidered = binStartingPosition + binInsideOffset; + const xPosition = this.isFlipXAxis() === true ? this.histogramAreaWidth - xPositionBeforeFlipConsidered : xPositionBeforeFlipConsidered; + const styleMeanRuleLabel = e6({ + "mean-rule-label": true, + "shown": this.svgHeight >= this.minHeightToAlwaysShowRuleLabel || this.showRuleLabel + }); + return b2` + + this.showRuleLabel = true} + @mouseleave=${() => this.showRuleLabel = false} + /> + + μ=${this.mean.toFixed(2)} + + `; + } + renderTitleOnLeft() { + const paddingBetweenAxisAndTitle = 3; + return this.titleOnLeft != null ? b2` + + + + ${this.titleOnLeft} + + ` : ""; + } + render() { + const histogramSpec = this.getHistogramSpec(); + if (histogramSpec === void 0) { + return x``; + } + const binnedData = this.binnedData; + const renderHistogramElementsForBars = binnedData.map( + (value, index) => this.renderHistogramBarElements(value, this.maxCount, index) + ); + const clipShapeOfHistogramBars = binnedData.map( + (value, index) => this.clipShapeOfHistogramBar(value, this.maxCount, index) + ); + const adjustedSvgHeight = this.showBottomAxis === true ? this.svgHeight : this.svgHeight - HISTOGRAM_BOTTOM_AXIS_HEIGHT; + return x` + + + ${this.renderTitleOnLeft()} + ${this.renderBottomAxis()} + + + ${clipShapeOfHistogramBars} + + ${this.renderColoredBarAreas()} + ${renderHistogramElementsForBars} + + ${this.renderMeanRule()} + + `; + } + }; + HistogramElement.styles = [styles, styles3]; + __decorateClass([ + n4({ type: Object }) + ], HistogramElement.prototype, "getHistogramSpec", 2); + __decorateClass([ + n4({ type: Object }) + ], HistogramElement.prototype, "getRawDataValues", 2); + __decorateClass([ + n4({ type: Object }) + ], HistogramElement.prototype, "handleClickHistogramBar", 2); + __decorateClass([ + n4({ type: Object }) + ], HistogramElement.prototype, "isAnyBinSelected", 2); + __decorateClass([ + n4({ type: Object }) + ], HistogramElement.prototype, "isThisBinSelected", 2); + __decorateClass([ + n4({ type: Number }) + ], HistogramElement.prototype, "svgWidth", 2); + __decorateClass([ + n4({ type: Number }) + ], HistogramElement.prototype, "svgHeight", 2); + __decorateClass([ + n4({ type: Object }) + ], HistogramElement.prototype, "neutralColorThreshold", 2); + __decorateClass([ + n4({ type: String }) + ], HistogramElement.prototype, "specificColorScheme", 2); + __decorateClass([ + n4({ type: Boolean }) + ], HistogramElement.prototype, "showBottomAxis", 2); + __decorateClass([ + n4({ type: Boolean }) + ], HistogramElement.prototype, "showAxisEndDescription", 2); + __decorateClass([ + n4({ type: Boolean }) + ], HistogramElement.prototype, "isSimplified", 2); + __decorateClass([ + n4({ type: Object }) + ], HistogramElement.prototype, "isFlipXAxis", 2); + __decorateClass([ + n4({ type: String }) + ], HistogramElement.prototype, "titleOnLeft", 2); + __decorateClass([ + observable + ], HistogramElement.prototype, "showRuleLabel", 2); + __decorateClass([ + computed + ], HistogramElement.prototype, "leftPadding", 1); + __decorateClass([ + computed + ], HistogramElement.prototype, "topPadding", 1); + __decorateClass([ + computed + ], HistogramElement.prototype, "histogramAreaWidth", 1); + __decorateClass([ + computed + ], HistogramElement.prototype, "binWidth", 1); + __decorateClass([ + computed + ], HistogramElement.prototype, "bottomAxisAreaHeight", 1); + __decorateClass([ + computed + ], HistogramElement.prototype, "barMaxHeight", 1); + __decorateClass([ + computed + ], HistogramElement.prototype, "useDivergingColorScheme", 1); + __decorateClass([ + computed + ], HistogramElement.prototype, "binnedData", 1); + __decorateClass([ + computed + ], HistogramElement.prototype, "maxCount", 1); + __decorateClass([ + computed + ], HistogramElement.prototype, "mean", 1); + HistogramElement = __decorateClass([ + t3("comparator-histogram") + ], HistogramElement); + + // client/services/service.ts + var Service = class { + initialize() { + } + }; + + // client/services/custom_function_service.ts + var CustomFunctionService = class extends Service { + // Use regular expression to find matches in output_text. + // If the return type is number, count the pattern. + executeCustomFunctionRegExp(outputText, expression, returnType) { + if (returnType === "Number" /* NUMBER */) { + const regExp = new RegExp(expression, "g"); + const matches3 = outputText.match(regExp); + return matches3 != null ? matches3.length : 0; + } else { + const regExp = new RegExp(expression); + const matches3 = outputText.match(regExp); + return matches3 != null ? true : false; + } + } + executeCustomFunction(outputText, example, customFunc) { + if (customFunc.functionType === "Regular Expr." /* REGEXP */) { + return this.executeCustomFunctionRegExp( + outputText, + customFunc.functionBody, + customFunc.returnType + ); + } else { + console.warning( + `Unsupported custom function type: ${customFunc.functionType}` + ); + return; + } + } + }; + + // client/services/state_service.ts + var AppState = class extends Service { + constructor(customFunctionService) { + super(); + this.customFunctionService = customFunctionService; + this.metadata = { + source_path: "", + custom_fields_schema: [], + sampling_step_size: 1 + }; + this.models = [{ name: "" }, { name: "" }]; + this.examples = []; + this.rationaleClusters = []; + this.datasetPath = null; + this.isDatasetPathUploadedFile = false; + this.isOpenDatasetSelectionPanel = true; + this.exampleDatasetPaths = BUILT_IN_DEMO_FILES; + this.selectedTag = null; + this.currentSorting = DEFAULT_SORTING_CRITERIA; + this.isExampleExpanded = {}; + this.selectedExample = null; + this.showSelectedExampleDetails = false; + this.exampleDetailsPanelExpanded = false; + this.hasRationaleClusters = false; + this.selectedRationaleClusterId = null; + this.hoveredRationaleClusterId = null; + this.matchedRationaleClusterIds = []; + this.rationaleClusterSimilarityThreshold = DEFAULT_RATIONALE_CLUSTER_SIMILARITY_THRESHOLD; + this.columns = DEFAULT_COLUMN_LIST; + this.showSidebarComponents = {}; + this.selectedBarChartValues = {}; + this.histogramSpecForScores = DEFAULT_HISTOGRAM_SPEC; + this.selectedHistogramBinForScores = null; + this.histogramSpecForCustomFields = {}; + this.selectedHistogramBinForCustomFields = {}; + this.selectedHistogramBinForRatingsForSelectedExample = null; + this.selectedBarChartValueForSelectedExample = null; + this.winRateThreshold = DEFAULT_WIN_RATE_THRESHOLD; + this.isFlipScoreHistogramAxis = true; + this.statusMessage = ""; + this.isOpenStatusMessage = false; + this.statusMessageTimeout = null; + this.searchFilters = {}; + this.searchFilterInputs = {}; + this.isOpenSettingsPanel = false; + this.isShowTextDiff = true; + this.useMonospace = false; + this.numExamplesToDisplay = DEFAULT_NUM_EXAMPLES_TO_DISPLAY; + this.isShowTagChips = true; + this.isShowSidebar = true; + this.numberOfLinesPerOutputCell = 7; + this.customFunctions = {}; + this.histogramSpecForCustomFuncs = {}; + this.histogramSpecForCustomFuncsOfDiff = {}; + this.selectedCustomFuncId = null; + this.selectionsFromCustomFuncResults = {}; + this.isShowCustomFuncEditor = false; + this.valueDomainsForCustomFields = {}; + makeObservable(this); + } + getIsExampleExpanded(index) { + return this.isExampleExpanded[index] ?? false; + } + resetSearchFilter(fieldId) { + this.searchFilters[fieldId] = ""; + this.searchFilterInputs[fieldId] = ""; + } + // Columns. + getFieldFromId(fieldId) { + return this.columns.find((field) => field.id === fieldId); + } + isColumnVisible(fieldId) { + const matchedField = this.getFieldFromId(fieldId); + return matchedField !== void 0 && matchedField.visible === true; + } + get numberOfShownTextColumns() { + return (this.isColumnVisible(FIELD_ID_FOR_INPUT) === true ? 1 : 0) + (this.isColumnVisible(FIELD_ID_FOR_OUTPUT_A) === true ? 1 : 0) + (this.isColumnVisible(FIELD_ID_FOR_OUTPUT_B) === true ? 1 : 0) + (this.isColumnVisible(FIELD_ID_FOR_RATIONALES) === true ? 1 : 0) + this.metadata.custom_fields_schema.filter( + (field) => field.type === "text" /* TEXT */ && this.isColumnVisible(field.name) + ).length; + } + get scoreMiddlePoint() { + return (this.histogramSpecForScores.rangeLeft + this.histogramSpecForScores.rangeRight) * 0.5; + } + // Check if A or B is a winner from a score. + isWinnerFromScore(model, score) { + if (score == null) { + return false; + } + if (model === "A") { + return score > this.scoreMiddlePoint + this.winRateThreshold; + } else if (model === "B") { + return score < this.scoreMiddlePoint - this.winRateThreshold; + } else { + return false; + } + } + get isScoreDivergingScheme() { + return this.scoreMiddlePoint === 0 || this.histogramSpecForScores.rangeLeft === FIVE_POINT_LIKERT_HISTOGRAM_SPEC.rangeLeft && this.histogramSpecForScores.rangeRight === FIVE_POINT_LIKERT_HISTOGRAM_SPEC.rangeRight; + } + get selectedCustomFunc() { + if (this.selectedCustomFuncId != null) { + return this.customFunctions[this.selectedCustomFuncId]; + } else { + return null; + } + } + get selectedCustomFuncName() { + if (this.selectedCustomFunc != null) { + return this.selectedCustomFunc.name; + } else { + return ""; + } + } + get newCustomFuncId() { + if (Object.keys(this.customFunctions).length === 0) { + return 0; + } else { + return Math.max(...Object.keys(this.customFunctions).map(Number)) + 1; + } + } + get customFieldsOfNumberType() { + return this.columns.filter( + (field) => field.type === "number" /* NUMBER */ + ); + } + get customFieldsOfCategoryType() { + return this.columns.filter( + (field) => field.type === "category" /* CATEGORY */ + ); + } + get customFieldsOfPerModelNumberType() { + return this.columns.filter((field) => field.type === "per_model_number" /* PER_MODEL_NUMBER */).filter((field) => field.id.startsWith("custom_field:")); + } + get customFieldsOfPerModelCategoryTypeIncludingPerRating() { + return this.columns.filter( + (field) => field.type === "per_model_category" /* PER_MODEL_CATEGORY */ || field.type === "per_model_boolean" /* PER_MODEL_BOOLEAN */ || field.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */ + ).filter((field) => field.id.startsWith("custom_field:")); + } + customFieldsOfPerRatingTypesWithNoAggregationSupport() { + return ["per_rating_string" /* PER_RATING_STRING */]; + } + // Fields for per-rating types. + get customFieldsOfPerRatingType() { + return this.columns.filter((field) => isPerRatingFieldType(field)); + } + // Fields without per-rating types. + get customFieldsWithoutPerRatingType() { + return this.columns.filter( + (field) => !isPerRatingFieldType(field) && field.type !== "base" /* BASE */ + ); + } + get visibleColumns() { + return this.columns.filter((field) => field.visible === true); + } + // Columns without per rating types. + get columnsWithoutPerRatingTypes() { + return this.columns.filter((field) => !isPerRatingFieldType(field)); + } + // Get the value domain for custom fields for side-by-side bar charts. + // We display all the axis values even when their counts are zero. + computeValueDomainForCustomField(field) { + const groupIndices = Array.from( + { length: this.models.length }, + (unused, i23) => i23 + ); + const values = groupIndices.map( + (groupIndex) => this.examples.map( + (ex) => ex.individual_rater_scores.map( + (rating) => rating.custom_fields[field.id][groupIndex] + ).flat() + ).flat() + ).flat(); + if (field.domain !== void 0) { + this.valueDomainsForCustomFields[field.id] = mergeTwoArrays( + field.domain, + groupByAndSortKeys(values) + ); + } else { + this.valueDomainsForCustomFields[field.id] = groupByAndSortKeys(values); + } + } + get individualRatingScoreValueDomain() { + const scores = /* @__PURE__ */ new Set(); + this.examples.forEach((ex) => { + ex.individual_rater_scores.filter((rating) => rating.score != null).forEach((rating) => { + scores.add(rating.score); + }); + }); + return Array.from(scores).sort((a11, b7) => b7 - a11).map((score) => score.toString()); + } + // Models. + getModelIndexFromAOrB(model) { + if (model === "A") { + return 0; + } else if (model === "B") { + return 1; + } else { + throw new Error(`Unknown model: ${model}`); + } + } + get filteredExamplesExceptChartSelections() { + let examples = this.examples; + Object.entries(this.searchFilters).filter(([fieldId, stringToSearch]) => stringToSearch !== "").forEach(([fieldId, stringToSearch]) => { + examples = examples.filter((ex) => { + if (fieldId === FIELD_ID_FOR_INPUT) { + return searchText( + extractTextFromTextOrSequenceChunks(ex.input_text), + stringToSearch + ); + } else if (fieldId === FIELD_ID_FOR_OUTPUT_A) { + return searchText( + extractTextFromTextOrSequenceChunks(ex.output_text_a), + stringToSearch + ); + } else if (fieldId === FIELD_ID_FOR_OUTPUT_B) { + return searchText( + extractTextFromTextOrSequenceChunks(ex.output_text_b), + stringToSearch + ); + } else if (fieldId === FIELD_ID_FOR_RATIONALES) { + return searchText( + ex.individual_rater_scores.map((rating) => rating.rationale).join("\n"), + stringToSearch + ); + } else if (fieldId === FIELD_ID_FOR_RATIONALE_LIST) { + return searchText( + ex.rationale_list.map((item) => item.rationale).join("\n"), + stringToSearch + ); + } else { + return ex.custom_fields[fieldId] != null && searchText(ex.custom_fields[fieldId], stringToSearch); + } + }); + }); + Object.values(this.customFunctions).filter( + (customFunc) => customFunc.returnType === "Boolean" /* BOOLEAN */ + ).forEach((customFunc) => { + const fieldId = getFieldIdForCustomFunc(customFunc.id); + const selections = this.selectionsFromCustomFuncResults[customFunc.id]; + Object.values(AOrB).forEach((model, modelIndex) => { + if (selections[model] != null) { + examples = examples.filter( + (ex) => ex.custom_fields[fieldId][modelIndex] === selections[model] + ); + } + }); + }); + return examples; + } + applyHistogramFilterForScores(examplesBeforeThisFilter) { + let examples = examplesBeforeThisFilter; + if (this.selectedHistogramBinForScores != null) { + examples = examples.filter((ex) => ex.score != null).filter( + (ex) => getHistogramBinIndexFromValue( + this.histogramSpecForScores, + ex.score + ) === this.selectedHistogramBinForScores + ); + } + return examples; + } + // TODO: Merge with the side-by-side histograms. + applyHistogramFilterForCustomFuncs(examplesBeforeThisFilter, excludeId = null, excludeModel = null) { + let examples = examplesBeforeThisFilter; + Object.values(this.customFunctions).filter( + (customFunc) => customFunc.returnType === "Number" /* NUMBER */ + ).forEach((customFunc) => { + const fieldId = getFieldIdForCustomFunc(customFunc.id); + const selections = this.selectionsFromCustomFuncResults[customFunc.id]; + Object.values(AOrB).filter( + (model) => excludeId == null || !(excludeId === customFunc.id && excludeModel === model) + ).forEach((model) => { + const modelIndex = this.getModelIndexFromAOrB(model); + if (selections[model] != null) { + examples = examples.filter( + (ex) => ex.custom_fields[fieldId][modelIndex] != null + ).filter( + (ex) => getHistogramBinIndexFromValue( + this.histogramSpecForCustomFuncs[customFunc.id], + ex.custom_fields[fieldId][modelIndex] + ) === selections[model] + ); + } + }); + if (selections["A-B"] != null && (excludeId == null || !(excludeId === customFunc.id && excludeModel === "A-B"))) { + examples = examples.filter((ex) => { + const valA = ex.custom_fields[fieldId][0]; + const valB = ex.custom_fields[fieldId][1]; + if (valA != null && valB != null && typeof valA === "number" && typeof valB === "number") { + return getHistogramBinIndexFromValue( + this.histogramSpecForCustomFuncsOfDiff[customFunc.id], + valA - valB + ) === selections["A-B"]; + } else { + return false; + } + }); + } + }); + return examples; + } + applyHistogramFilterForCustomFields(examplesBeforeThisFilter, excludeField = null, excludeModel = null) { + let examples = examplesBeforeThisFilter; + Object.keys(this.selectedHistogramBinForCustomFields).forEach((fieldId) => { + const selections = this.selectedHistogramBinForCustomFields[fieldId]; + if (selections != null && typeof selections === "object") { + Object.values(AOrB).filter( + (model) => excludeField == null || !(excludeField === fieldId && excludeModel === model) + ).forEach((model) => { + const modelIndex = this.getModelIndexFromAOrB(model); + if (selections[model] != null) { + examples = examples.filter( + (ex) => ex.custom_fields[fieldId][modelIndex] != null + ).filter( + (ex) => getHistogramBinIndexFromValue( + this.histogramSpecForCustomFields[fieldId], + ex.custom_fields[fieldId][modelIndex] + ) === selections[model] + ); + } + }); + } else { + if (selections != null && fieldId !== excludeField) { + examples = examples.filter((ex) => ex.custom_fields[fieldId] != null).filter( + (ex) => getHistogramBinIndexFromValue( + this.histogramSpecForCustomFields[fieldId], + ex.custom_fields[fieldId] + ) === selections + ); + } + } + }); + return examples; + } + applyBarChartFilterForCustomFields(examplesBeforeThisFilter, excludeField = null, excludeGroupIndex = null) { + let examples = examplesBeforeThisFilter; + Object.entries(this.selectedBarChartValues).forEach( + ([fieldId, selectionsForGroups]) => { + selectionsForGroups.map((selectionForGroup, groupIndex) => [ + selectionForGroup, + groupIndex + ]).filter( + ([selectionForGroup, groupIndex]) => selectionForGroup != null && !(excludeField != null && excludeField === fieldId && excludeGroupIndex != null && excludeGroupIndex === groupIndex) + ).forEach(([selectionForGroup, groupIndex]) => { + examples = examples.filter((ex) => { + const fieldValue = ex.custom_fields[fieldId]; + const value = fieldValue instanceof Array ? fieldValue[groupIndex] : fieldValue; + return value instanceof Object ? Object.keys(value).includes(selectionForGroup) : value != null && value.toString() === selectionForGroup; + }); + }); + } + ); + return examples; + } + applyTagFilter(examplesBeforeThisFilter) { + let examples = examplesBeforeThisFilter; + if (this.selectedTag != null) { + examples = examples.filter( + (example) => example.tags.includes(this.selectedTag) + ); + } + return examples; + } + applyRationaleClusterFilter(examplesBeforeThisFilter) { + let examples = examplesBeforeThisFilter; + if (this.selectedRationaleClusterId != null) { + examples = examples.filter((example) => { + const clusterIds = example.rationale_list.map((rationale) => rationale.assignedClusterIds).flat(); + return clusterIds.includes(this.selectedRationaleClusterId); + }); + } + return examples; + } + // Get the list of examples for cases when a particular bin selection is not + // applied. This is to render non-selected bars in histograms, which are not + // part of this.filteredExamples. + // e.g., If there exist two selections, bin_for_score=2 and bin_for_field_x=5, + // the table shows filteredExamples that apply both of the filters. + // However, for the score histogram, it will show data for bin_for_field_x=5, + // because we want to visualize other bars (bin_for_score != 2) too with + // opacity < 1. In this case, + // @computed this.filteredExamples has data only for the two filters applied. + // this.getFilteredExamplesExceptForParticularChart({histogram, score})] + // returns data for when the bin_for_score=2 filter is not applied. + // this.getFilteredExamplesExceptForParticularChart({histogram, x}) returns + // data for when the bin_for_field_x=5 filter is not applied. + getFilteredExamplesExceptForParticularChart(chartKey) { + let examples = this.filteredExamplesExceptChartSelections; + if (chartKey.chartType === "histogram" /* HISTOGRAM */ && chartKey.fieldId === FIELD_ID_FOR_SCORE) { + examples = this.applyHistogramFilterForCustomFuncs(examples); + examples = this.applyHistogramFilterForCustomFields(examples); + examples = this.applyBarChartFilterForCustomFields(examples); + examples = this.applyTagFilter(examples); + examples = this.applyRationaleClusterFilter(examples); + } else if (chartKey.chartType === "histogram" /* HISTOGRAM */) { + examples = this.applyHistogramFilterForScores(examples); + examples = this.applyHistogramFilterForCustomFuncs(examples); + examples = this.applyBarChartFilterForCustomFields(examples); + examples = this.applyTagFilter(examples); + examples = this.applyRationaleClusterFilter(examples); + examples = this.applyHistogramFilterForCustomFields( + examples, + chartKey.fieldId, + chartKey.model + ); + } else if (chartKey.chartType === "custom_function" /* CUSTOM_FUNCTION */) { + examples = this.applyHistogramFilterForScores(examples); + examples = this.applyHistogramFilterForCustomFields(examples); + examples = this.applyBarChartFilterForCustomFields(examples); + examples = this.applyTagFilter(examples); + examples = this.applyRationaleClusterFilter(examples); + const splitFieldId = chartKey.fieldId.split(":"); + const customFuncIdOfHistogramToIgnore = splitFieldId.length === 2 ? Number(splitFieldId[1]) : null; + const modelFromCustomFuncOfHistogramToIgnore = chartKey.model; + examples = this.applyHistogramFilterForCustomFuncs( + examples, + customFuncIdOfHistogramToIgnore, + modelFromCustomFuncOfHistogramToIgnore + ); + } else if (chartKey.chartType === "bar" /* BAR_CHART */) { + examples = this.applyHistogramFilterForScores(examples); + examples = this.applyHistogramFilterForCustomFuncs(examples); + examples = this.applyHistogramFilterForCustomFields(examples); + examples = this.applyTagFilter(examples); + examples = this.applyRationaleClusterFilter(examples); + const modelIndex = chartKey.model == null ? 0 : chartKey.model; + examples = this.applyBarChartFilterForCustomFields( + examples, + chartKey.fieldId, + modelIndex + ); + } else if (chartKey.chartType === "tag" /* TAG */) { + examples = this.applyHistogramFilterForScores(examples); + examples = this.applyHistogramFilterForCustomFuncs(examples); + examples = this.applyHistogramFilterForCustomFields(examples); + examples = this.applyBarChartFilterForCustomFields(examples); + examples = this.applyRationaleClusterFilter(examples); + } else if (chartKey.chartType === "rationale_cluster" /* RATIONALE_CLUSTER */) { + examples = this.applyHistogramFilterForScores(examples); + examples = this.applyHistogramFilterForCustomFuncs(examples); + examples = this.applyHistogramFilterForCustomFields(examples); + examples = this.applyBarChartFilterForCustomFields(examples); + examples = this.applyTagFilter(examples); + } + return examples; + } + get filteredExamples() { + let examples = this.filteredExamplesExceptChartSelections; + examples = this.applyHistogramFilterForScores(examples); + examples = this.applyHistogramFilterForCustomFuncs(examples); + examples = this.applyHistogramFilterForCustomFields(examples); + examples = this.applyBarChartFilterForCustomFields(examples); + examples = this.applyTagFilter(examples); + examples = this.applyRationaleClusterFilter(examples); + return examples; + } + get sortedExamples() { + let examples = this.filteredExamples; + const sorting = this.currentSorting; + if (sorting.column === "None" /* NONE */ || sorting.order === "None" /* NONE */) { + return examples; + } + if (sorting.column === "score" /* SCORE */) { + examples = examples.slice().sort( + (a11, b7) => compareNumbersWithNulls( + a11.score, + b7.score, + sorting.order === "desc" /* DESC */ + ) + ); + } else if (sorting.column === "tags" /* TAGS */) { + examples = examples.slice().sort( + (a11, b7) => sorting.order === "desc" /* DESC */ ? b7.tags.join(",").localeCompare(a11.tags.join(",")) : a11.tags.join(",").localeCompare(b7.tags.join(",")) + ); + } else if (sorting.column === "value from selected Custom Function for Output A" /* FUNC_A */ || sorting.column === "value from selected Custom Function for Output B" /* FUNC_B */) { + const selectedCustomFunc = this.selectedCustomFunc; + const modelIndex = sorting.column === "value from selected Custom Function for Output A" /* FUNC_A */ ? 0 : 1; + if (selectedCustomFunc != null && selectedCustomFunc.returnType === "Number" /* NUMBER */) { + const fieldId = getFieldIdForCustomFunc(selectedCustomFunc.id); + examples = examples.slice().sort( + (ex0, ex1) => sorting.order === "desc" /* DESC */ ? ex1.custom_fields[fieldId][modelIndex] - ex0.custom_fields[fieldId][modelIndex] : ex0.custom_fields[fieldId][modelIndex] - ex1.custom_fields[fieldId][modelIndex] + ); + } + } else if (sorting.column === "custom attribute" /* CUSTOM_ATTRIBUTE */ && sorting.customField != null) { + const fieldId = sorting.customField.id; + const fieldType = this.columns.filter((field) => field.id === fieldId)[0].type; + if (fieldType === "per_model_number" && sorting.modelIndex != null) { + const getValueForPerModelNumber = (ex) => ex.custom_fields[fieldId][sorting.modelIndex]; + examples = examples.slice().sort( + (a11, b7) => compareNumbersWithNulls( + getValueForPerModelNumber(a11), + getValueForPerModelNumber(b7), + sorting.order === "desc" /* DESC */ + ) + ); + } else if ((fieldType === "per_model_boolean" || fieldType === "per_model_category") && sorting.modelIndex != null) { + const castToString = (value) => typeof value === "boolean" ? String(value) : value; + const getValueForPerModelString = (ex) => ex.custom_fields[fieldId].map( + (value) => castToString(value) + )[sorting.modelIndex]; + examples = examples.slice().sort( + (a11, b7) => sorting.order === "desc" /* DESC */ ? compareStringsWithNulls( + getValueForPerModelString(b7), + getValueForPerModelString(a11) + ) : compareStringsWithNulls( + getValueForPerModelString(a11), + getValueForPerModelString(b7) + ) + ); + } else if (fieldType === "number") { + const getValueForNumber = (ex) => ex.custom_fields[fieldId]; + examples = examples.slice().sort( + (a11, b7) => compareNumbersWithNulls( + getValueForNumber(a11), + getValueForNumber(b7), + sorting.order === "desc" /* DESC */ + ) + ); + } else { + const getValueForString = (ex) => ex.custom_fields[fieldId]; + examples = examples.slice().sort( + (a11, b7) => sorting.order === "desc" /* DESC */ ? compareStringsWithNulls( + getValueForString(b7), + getValueForString(a11) + ) : compareStringsWithNulls( + getValueForString(a11), + getValueForString(b7) + ) + ); + } + } else if (sorting.column === "similarity between cluster label and the most similar rationale" /* RATIONALE_CLUSTER */) { + const maxSimilarityValueFromRationaleListItems = (rationaleListItems) => Math.max( + ...rationaleListItems.filter( + (rationaleItem) => (rationaleItem.assignedClusterIds || []).includes( + this.selectedRationaleClusterId + ) + ).map( + (rationaleItem) => rationaleItem.similarities[this.selectedRationaleClusterId] + ) + ); + examples = examples.slice().sort( + (a11, b7) => maxSimilarityValueFromRationaleListItems(b7.rationale_list) - maxSimilarityValueFromRationaleListItems(a11.rationale_list) + ); + } + return examples; + } + get examplesForMainTable() { + return this.sortedExamples.slice(0, this.numExamplesToDisplay); + } + // Reset state variables. + resetVariables() { + this.isShowTextDiff = true; + this.selectedExample = null; + this.selectedTag = null; + this.selectedCustomFuncId = null; + this.isExampleExpanded = {}; + this.selectedHistogramBinForScores = null; + this.selectedHistogramBinForCustomFields = {}; + this.selectedBarChartValues = {}; + this.selectionsFromCustomFuncResults = {}; + this.selectedRationaleClusterId = null; + this.searchFilters = {}; + this.searchFilterInputs = {}; + [ + FIELD_ID_FOR_INPUT, + FIELD_ID_FOR_OUTPUT_A, + FIELD_ID_FOR_OUTPUT_B, + FIELD_ID_FOR_RATIONALES, + FIELD_ID_FOR_RATIONALE_LIST + ].forEach((fieldId) => void this.resetSearchFilter(fieldId)); + this.currentSorting = DEFAULT_SORTING_CRITERIA; + this.numExamplesToDisplay = DEFAULT_NUM_EXAMPLES_TO_DISPLAY; + this.columns = DEFAULT_COLUMN_LIST; + this.customFunctions = {}; + this.histogramSpecForCustomFuncs = {}; + this.histogramSpecForCustomFuncsOfDiff = {}; + this.histogramSpecForCustomFields = {}; + this.winRateThreshold = DEFAULT_WIN_RATE_THRESHOLD; + this.hasRationaleClusters = false; + } + initialize() { + const urlSearchParams = new URLSearchParams(window.location.search); + const params = {}; + for (const [key, value] of urlSearchParams) { + params[key] = decodeURIComponent(value); + } + if (params.hasOwnProperty("results_path")) { + const datasetPath = params["results_path"]; + const maxExamplesToLoad = params.hasOwnProperty("max_examples") ? Number(params["max_examples"]) : null; + const samplingStepSize = params.hasOwnProperty("sampling_step_size") ? Number(params["sampling_step_size"]) : null; + const columnsToHide = params.hasOwnProperty("hide_columns") ? params["hide_columns"].split(",") : []; + this.loadData( + datasetPath, + null, + maxExamplesToLoad, + samplingStepSize, + columnsToHide + ); + } + } + // Update the sorting option. + updateSorting(sorting) { + this.currentSorting = sorting; + } + // Reset the sorting option. + resetSorting() { + this.currentSorting = DEFAULT_SORTING_CRITERIA; + } + // Update the status message. + updateStatusMessage(message, hasTimeout = false) { + this.statusMessage = message; + this.isOpenStatusMessage = true; + if (this.statusMessageTimeout != null) { + clearTimeout(this.statusMessageTimeout); + } + if (hasTimeout === true) { + this.statusMessageTimeout = setTimeout( + () => this.isOpenStatusMessage = false, + 5e3 + ); + } + } + get appLink() { + return `https://pair-code.github.io/llm-comparator/`; + } + determineHistogramSpecForScores() { + let minValue = 0; + let maxValue = 0; + const individualRaterScores = this.examples.flatMap( + (ex) => ex.individual_rater_scores.map((rating) => rating.score) + ); + if (individualRaterScores.length > 0) { + const minAndMaxFromIndividualScores = getMinAndMax(individualRaterScores); + minValue = minAndMaxFromIndividualScores.minValue; + maxValue = minAndMaxFromIndividualScores.maxValue; + } else { + const minAndMax = getMinAndMax(this.examples.map((ex) => ex.score)); + minValue = minAndMax.minValue; + maxValue = minAndMax.maxValue; + } + if (minValue === 1 && maxValue === 5) { + this.histogramSpecForScores = FIVE_POINT_LIKERT_HISTOGRAM_SPEC; + } else if (minValue >= 1) { + this.histogramSpecForScores = { + rangeLeft: minValue, + rangeRight: maxValue, + numberOfBins: 7, + isBounded: true, + isDivergingScheme: false + }; + } else { + this.histogramSpecForScores = DEFAULT_HISTOGRAM_SPEC; + } + } + // Add histogram spec for custom functions with return type number. + // TODO: Merge with the side-by-side histograms. + addHistogramSpecForCustomFunc(customFunc) { + if (customFunc.returnType === "Number" /* NUMBER */) { + const fieldId = getFieldIdForCustomFunc(customFunc.id); + const minAndMaxValues = getMinAndMax([ + ...this.examples.map( + (ex) => ex.custom_fields[fieldId][0] + ), + ...this.examples.map( + (ex) => ex.custom_fields[fieldId][1] + ) + ]); + const rangeLeft = minAndMaxValues.minValue; + const verySmallValue = 1e-8; + const rangeRight = minAndMaxValues.maxValue === rangeLeft ? minAndMaxValues.maxValue + verySmallValue : minAndMaxValues.maxValue; + this.histogramSpecForCustomFuncs[customFunc.id] = { + rangeLeft, + rangeRight, + numberOfBins: 6, + isBounded: true, + isDivergingScheme: false + }; + const minAndMaxDiff = getMinAndMax( + this.examples.filter( + (ex) => ex.custom_fields[fieldId][0] != null && ex.custom_fields[fieldId][1] != null + ).map( + (ex) => ex.custom_fields[fieldId][0] - ex.custom_fields[fieldId][1] + ) + ); + const absoluteMax = Math.max( + Math.abs(minAndMaxDiff.minValue), + Math.abs(minAndMaxDiff.maxValue) + ); + const rangeEnd = absoluteMax === 0 ? 1 : absoluteMax; + this.histogramSpecForCustomFuncsOfDiff[customFunc.id] = { + rangeLeft: -rangeEnd, + rangeRight: rangeEnd, + numberOfBins: 7, + isBounded: true, + isDivergingScheme: true + }; + } + } + // Add histogram spec for custom functions for custom fields. + addHistogramSpecForCustomFields(field) { + if (field.type === "number" /* NUMBER */) { + const { minValue, maxValue } = getMinAndMax( + this.examples.map( + (ex) => convertToNumber(ex.custom_fields[field.id]) + ) + ); + this.histogramSpecForCustomFields[field.id] = { + rangeLeft: minValue, + rangeRight: maxValue, + numberOfBins: 6, + isBounded: true, + isDivergingScheme: false + }; + this.selectedHistogramBinForCustomFields[field.id] = null; + } else if (field.type === "per_model_number" /* PER_MODEL_NUMBER */) { + const minAndMaxValues = getMinAndMax([ + ...this.examples.map( + (ex) => ex.custom_fields[field.id][0] + ), + ...this.examples.map( + (ex) => ex.custom_fields[field.id][1] + ) + ]); + const rangeLeft = minAndMaxValues.minValue; + const verySmallValue = 1e-8; + const rangeRight = minAndMaxValues.maxValue === rangeLeft ? minAndMaxValues.maxValue + verySmallValue : minAndMaxValues.maxValue; + this.histogramSpecForCustomFields[field.id] = { + rangeLeft, + rangeRight, + numberOfBins: 6, + isBounded: true, + isDivergingScheme: false + }; + this.selectedHistogramBinForCustomFields[field.id] = { + "A": null, + "B": null + }; + } + } + // Read an uploaded json file. + readFileContent(file) { + return new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.onload = (event) => { + if (event.target?.result) { + resolve(event.target.result.toString()); + } else { + reject(new Error("Failed to read file content.")); + } + }; + reader.readAsText(file); + }); + } + // Load data either from a specified path or uploaded file. + async loadData(datasetPath, fileObject = null, maxNumExamplesToDisplay = null, samplingStepSize = null, columnsToHide = []) { + this.isOpenDatasetSelectionPanel = false; + this.updateStatusMessage("Loading the dataset... Please wait..."); + let dataResponse; + if (fileObject != null) { + try { + const fileContent = await this.readFileContent(fileObject); + const jsonResponse = JSON.parse(fileContent); + dataResponse = jsonResponse; + } catch (error) { + console.error(error); + this.updateStatusMessage( + `Encountered an error while loading file "${datasetPath}": ${error}` + ); + this.isOpenDatasetSelectionPanel = true; + return; + } + } else { + try { + let response = new Response(); + if (datasetPath.startsWith("http")) { + response = await fetch(datasetPath, { + headers: { "Accept": "application/json" } + }); + } else { + const errorMessage = "Unsupported data loading method. Please provide a web URL or use the file uploader."; + throw new Error(errorMessage); + } + if (response.status === 502) { + const errorMessage = `Failed to load the dataset. The server may not exist anymore, possibly with updated URLs. Try opening this URL (${this.appLink}), rather than refreshing the page.`; + throw new Error(errorMessage); + } + const jsonResponse = await response.json(); + if (jsonResponse.hasOwnProperty("error")) { + throw new Error(jsonResponse.error); + } + dataResponse = jsonResponse; + } catch (error) { + console.error(error); + this.updateStatusMessage( + `Encountered an error while loading "${datasetPath}": ${error}` + ); + this.isOpenDatasetSelectionPanel = true; + return; + } + } + this.datasetPath = datasetPath; + this.isDatasetPathUploadedFile = fileObject != null; + this.metadata = dataResponse.metadata; + this.models = dataResponse.models; + this.examples = dataResponse.examples.map( + (example, index) => { + example.index = index; + example.individual_rater_scores.forEach( + (rating, ratingIndex) => { + rating.index = ratingIndex; + } + ); + return example; + } + ); + this.resetVariables(); + if (dataResponse.rationale_clusters) { + this.rationaleClusters = [ + { + id: -1, + title: "(others)", + aWinCount: 0, + bWinCount: 0 + }, + ...dataResponse.rationale_clusters.map( + (cluster, clusterIndex) => { + return { + id: clusterIndex, + title: cluster.title, + aWinCount: 0, + bWinCount: 0 + }; + } + ) + ]; + this.hasRationaleClusters = this.rationaleClusters.length > 1; + if (this.hasRationaleClusters === true) { + this.columns.filter( + (field) => field.id === FIELD_ID_FOR_RATIONALE_LIST + )[0].visible = true; + this.reassignClusters(); + } + } + this.determineHistogramSpecForScores(); + const fieldTypes = Object.values(FieldType); + this.metadata.custom_fields_schema.forEach( + (loadedField) => { + if (!fieldTypes.includes(loadedField.type)) { + this.updateStatusMessage( + `${loadedField.name} is not a valid field type. It should be one of [${fieldTypes.join( + ", " + )}].` + ); + } + const fieldId = `custom_field:${loadedField.name}`; + const field = { + id: fieldId, + name: loadedField.name, + type: loadedField.type, + visible: !columnsToHide.includes(loadedField.name) && !this.customFieldsOfPerRatingTypesWithNoAggregationSupport().includes( + loadedField.type + ), + domain: loadedField.domain || void 0 + }; + this.columns.push(field); + } + ); + this.customFieldsWithoutPerRatingType.forEach((field) => { + this.examples.forEach((ex) => { + const value = ex.custom_fields[field.name]; + ex.custom_fields[field.id] = value; + delete ex.custom_fields[field.name]; + }); + this.addHistogramSpecForCustomFields(field); + if (field.type === "category" /* CATEGORY */) { + this.selectedBarChartValues[field.id] = [null]; + } else if (field.type === "per_model_category" /* PER_MODEL_CATEGORY */ || field.type === "per_model_boolean" /* PER_MODEL_BOOLEAN */) { + this.selectedBarChartValues[field.id] = [null, null]; + } + if (field.type === "text" /* TEXT */) { + this.resetSearchFilter(field.id); + } + }); + this.customFieldsOfPerRatingType.forEach((ratingField) => { + this.examples.forEach((ex) => { + if (ratingField.type === "per_rating_string" /* PER_RATING_STRING */) { + ex.individual_rater_scores.forEach((rating) => { + const value = rating.custom_fields[ratingField.name]; + rating.custom_fields[ratingField.id] = value; + delete rating.custom_fields[ratingField.name]; + }); + } else if (ratingField.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */) { + ex.individual_rater_scores.forEach((rating) => { + const value = rating.custom_fields[ratingField.name] || [ + null, + null + ]; + rating.custom_fields[ratingField.id] = value; + delete rating.custom_fields[ratingField.name]; + }); + } + }); + this.examples.forEach((ex) => { + if (ratingField.type === "per_rating_string" /* PER_RATING_STRING */) { + ex.custom_fields[ratingField.id] = ex.individual_rater_scores.map( + (rating) => rating.custom_fields[ratingField.id] + ).join("\n"); + } else if (ratingField.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */) { + ex.custom_fields[ratingField.id] = this.models.map( + (unused, modelIndex) => { + const valuesAcrossRatings = ex.individual_rater_scores.map( + (rating) => rating.custom_fields[ratingField.id][modelIndex] + ); + return groupByValues(valuesAcrossRatings); + } + ); + } + }); + if (ratingField.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */) { + this.computeValueDomainForCustomField(ratingField); + this.selectedBarChartValues[ratingField.id] = [null, null]; + } + }); + if (this.columns.filter((field) => field.type !== "base" /* BASE */).length > 0) { + this.isOpenSettingsPanel = true; + } + for (let i23 = 0; i23 < this.examples.length; i23++) { + const ex = this.examples[i23]; + if (typeof ex.output_text_a !== "string" || typeof ex.output_text_b !== "string") { + this.isShowTextDiff = false; + break; + } + } + INITIAL_CUSTOM_FUNCTIONS.forEach((customFunc) => { + const newId = this.newCustomFuncId; + customFunc.id = newId; + this.customFunctions[newId] = customFunc; + this.selectionsFromCustomFuncResults[newId] = initializeCustomFuncSelections(); + this.runCustomFunction(this.examples, customFunc); + }); + const statusMessage = `Loaded the dataset of ${this.examples.length} examples.`; + this.updateStatusMessage(statusMessage, true); + const url = new URL(window.location.href); + if (this.isDatasetPathUploadedFile === false) { + url.searchParams.set("results_path", this.datasetPath); + if (columnsToHide.length > 0) { + url.searchParams.set("hide_columns", columnsToHide.join(",")); + } else { + if (url.searchParams.has("hide_columns")) { + url.searchParams.delete("hide_columns"); + } + } + if (maxNumExamplesToDisplay != null) { + url.searchParams.set( + "max_examples", + maxNumExamplesToDisplay.toString() + ); + } else { + if (url.searchParams.has("max_examples")) { + url.searchParams.delete("max_examples"); + } + } + } else { + url.searchParams.delete("results_path"); + } + window.history.pushState({}, "", url.toString()); + } + // Run a custom function over all examples. + runCustomFunction(examples, customFunc) { + try { + const results = { "A": {}, "B": {} }; + examples.forEach((example, index) => { + Object.values(AOrB).forEach((model) => { + const output = model === "A" /* A */ ? example.output_text_a : example.output_text_b; + const result = this.customFunctionService.executeCustomFunction( + extractTextFromTextOrSequenceChunks(output), + example, + customFunc + ); + if (index === 0 && result === void 0) { + throw new Error( + "Encountered an error while executing the function. See console for details." + ); + } else if (result === void 0) { + results[model][example.index] = null; + } else { + results[model][example.index] = result; + } + }); + }); + const fieldId = getFieldIdForCustomFunc(customFunc.id); + examples.forEach((example) => { + example.custom_fields[fieldId] = [ + results["A" /* A */][example.index], + results["B" /* B */][example.index] + ]; + }); + this.customFunctions[customFunc.id] = customFunc; + this.selectionsFromCustomFuncResults[customFunc.id] = initializeCustomFuncSelections(); + this.addHistogramSpecForCustomFunc(customFunc); + this.isShowCustomFuncEditor = false; + const fieldType = customFunc.returnType === "Boolean" /* BOOLEAN */ ? "per_model_boolean" /* PER_MODEL_BOOLEAN */ : customFunc.returnType === "Number" /* NUMBER */ ? "per_model_number" /* PER_MODEL_NUMBER */ : "per_model_category" /* PER_MODEL_CATEGORY */; + const existingField = this.columns.filter( + (field) => field.id === fieldId + ); + if (existingField.length > 0) { + existingField[0].name = customFunc.name; + existingField[0].type = fieldType; + } else { + this.columns.push({ + id: fieldId, + name: customFunc.name, + type: fieldType, + visible: false + }); + } + this.updateStatusMessage( + "Completed executing the function over examples.", + true + ); + } catch (error) { + console.error(error); + this.updateStatusMessage(error, false); + } + } + // Remove a rationale cluster row. + removeCluster(clusterId) { + if (clusterId === this.selectedRationaleClusterId) { + this.selectedRationaleClusterId = null; + } + this.rationaleClusters = this.rationaleClusters.filter( + (cluster) => cluster.id !== clusterId + ); + this.reassignClusters(); + } + // Check if the similarity between a rationale phrase (each bullet item) + // and a cluster title is above the threshold. + reassignClusters() { + this.examples.forEach((example) => { + example.rationale_list.forEach((rationaleItem) => { + rationaleItem.assignedClusterIds = this.rationaleClusters.map((cluster) => cluster.id).filter( + (clusterId) => clusterId >= 0 && rationaleItem.similarities[clusterId] >= this.rationaleClusterSimilarityThreshold + ); + if (rationaleItem.assignedClusterIds.length === 0) { + rationaleItem.assignedClusterIds = [-1]; + } + }); + }); + } + }; + __decorateClass([ + observable + ], AppState.prototype, "metadata", 2); + __decorateClass([ + observable + ], AppState.prototype, "models", 2); + __decorateClass([ + observable + ], AppState.prototype, "examples", 2); + __decorateClass([ + observable + ], AppState.prototype, "rationaleClusters", 2); + __decorateClass([ + observable + ], AppState.prototype, "datasetPath", 2); + __decorateClass([ + observable + ], AppState.prototype, "isDatasetPathUploadedFile", 2); + __decorateClass([ + observable + ], AppState.prototype, "isOpenDatasetSelectionPanel", 2); + __decorateClass([ + observable + ], AppState.prototype, "exampleDatasetPaths", 2); + __decorateClass([ + observable + ], AppState.prototype, "selectedTag", 2); + __decorateClass([ + observable + ], AppState.prototype, "currentSorting", 2); + __decorateClass([ + observable + ], AppState.prototype, "isExampleExpanded", 2); + __decorateClass([ + observable + ], AppState.prototype, "selectedExample", 2); + __decorateClass([ + observable + ], AppState.prototype, "showSelectedExampleDetails", 2); + __decorateClass([ + observable + ], AppState.prototype, "exampleDetailsPanelExpanded", 2); + __decorateClass([ + observable + ], AppState.prototype, "hasRationaleClusters", 2); + __decorateClass([ + observable + ], AppState.prototype, "selectedRationaleClusterId", 2); + __decorateClass([ + observable + ], AppState.prototype, "hoveredRationaleClusterId", 2); + __decorateClass([ + observable + ], AppState.prototype, "matchedRationaleClusterIds", 2); + __decorateClass([ + observable + ], AppState.prototype, "rationaleClusterSimilarityThreshold", 2); + __decorateClass([ + observable + ], AppState.prototype, "columns", 2); + __decorateClass([ + observable + ], AppState.prototype, "showSidebarComponents", 2); + __decorateClass([ + observable + ], AppState.prototype, "selectedBarChartValues", 2); + __decorateClass([ + observable + ], AppState.prototype, "histogramSpecForScores", 2); + __decorateClass([ + observable + ], AppState.prototype, "selectedHistogramBinForScores", 2); + __decorateClass([ + observable + ], AppState.prototype, "histogramSpecForCustomFields", 2); + __decorateClass([ + observable + ], AppState.prototype, "selectedHistogramBinForCustomFields", 2); + __decorateClass([ + observable + ], AppState.prototype, "selectedHistogramBinForRatingsForSelectedExample", 2); + __decorateClass([ + observable + ], AppState.prototype, "selectedBarChartValueForSelectedExample", 2); + __decorateClass([ + observable + ], AppState.prototype, "winRateThreshold", 2); + __decorateClass([ + observable + ], AppState.prototype, "isFlipScoreHistogramAxis", 2); + __decorateClass([ + observable + ], AppState.prototype, "statusMessage", 2); + __decorateClass([ + observable + ], AppState.prototype, "isOpenStatusMessage", 2); + __decorateClass([ + observable + ], AppState.prototype, "searchFilters", 2); + __decorateClass([ + observable + ], AppState.prototype, "searchFilterInputs", 2); + __decorateClass([ + observable + ], AppState.prototype, "isOpenSettingsPanel", 2); + __decorateClass([ + observable + ], AppState.prototype, "isShowTextDiff", 2); + __decorateClass([ + observable + ], AppState.prototype, "useMonospace", 2); + __decorateClass([ + observable + ], AppState.prototype, "numExamplesToDisplay", 2); + __decorateClass([ + observable + ], AppState.prototype, "isShowTagChips", 2); + __decorateClass([ + observable + ], AppState.prototype, "isShowSidebar", 2); + __decorateClass([ + observable + ], AppState.prototype, "numberOfLinesPerOutputCell", 2); + __decorateClass([ + computed + ], AppState.prototype, "numberOfShownTextColumns", 1); + __decorateClass([ + computed + ], AppState.prototype, "scoreMiddlePoint", 1); + __decorateClass([ + computed + ], AppState.prototype, "isScoreDivergingScheme", 1); + __decorateClass([ + observable + ], AppState.prototype, "customFunctions", 2); + __decorateClass([ + observable + ], AppState.prototype, "histogramSpecForCustomFuncs", 2); + __decorateClass([ + observable + ], AppState.prototype, "histogramSpecForCustomFuncsOfDiff", 2); + __decorateClass([ + observable + ], AppState.prototype, "selectedCustomFuncId", 2); + __decorateClass([ + observable + ], AppState.prototype, "selectionsFromCustomFuncResults", 2); + __decorateClass([ + computed + ], AppState.prototype, "selectedCustomFunc", 1); + __decorateClass([ + computed + ], AppState.prototype, "selectedCustomFuncName", 1); + __decorateClass([ + computed + ], AppState.prototype, "newCustomFuncId", 1); + __decorateClass([ + observable + ], AppState.prototype, "isShowCustomFuncEditor", 2); + __decorateClass([ + computed + ], AppState.prototype, "customFieldsOfNumberType", 1); + __decorateClass([ + computed + ], AppState.prototype, "customFieldsOfCategoryType", 1); + __decorateClass([ + computed + ], AppState.prototype, "customFieldsOfPerModelNumberType", 1); + __decorateClass([ + computed + ], AppState.prototype, "customFieldsOfPerModelCategoryTypeIncludingPerRating", 1); + __decorateClass([ + computed + ], AppState.prototype, "visibleColumns", 1); + __decorateClass([ + observable + ], AppState.prototype, "valueDomainsForCustomFields", 2); + __decorateClass([ + computed + ], AppState.prototype, "individualRatingScoreValueDomain", 1); + __decorateClass([ + computed + ], AppState.prototype, "filteredExamplesExceptChartSelections", 1); + __decorateClass([ + computed + ], AppState.prototype, "filteredExamples", 1); + __decorateClass([ + computed + ], AppState.prototype, "sortedExamples", 1); + __decorateClass([ + computed + ], AppState.prototype, "examplesForMainTable", 1); + __decorateClass([ + computed + ], AppState.prototype, "appLink", 1); + + // client/core.ts + var Core = class { + constructor() { + this.services = /* @__PURE__ */ new Map(); + this.buildServices(); + } + async initialize() { + const appState = this.getService(AppState); + appState.initialize(); + } + buildServices() { + const customFunctionService = new CustomFunctionService(); + const appState = new AppState(customFunctionService); + this.services.set(CustomFunctionService, customFunctionService); + this.services.set(AppState, appState); + } + getService(t17) { + const service = this.services.get(t17); + if (service === void 0) { + throw new Error(`Service is undefined: ${t17.name}`); + } + return service; + } + }; + var core = new Core(); + + // client/components/charts.ts + var ChartsElement = class extends MobxLitElement { + constructor() { + super(...arguments); + this.appState = core.getService(AppState); + this.svgWidth = 220; + this.svgHeight = 110; + } + renderCustomFieldHistogram(field) { + const chartSelectionKey = { + chartType: "histogram" /* HISTOGRAM */, + fieldId: field.id, + model: null + }; + const getHistogramRawDataValues = () => this.appState.getFilteredExamplesExceptForParticularChart(chartSelectionKey).filter((ex) => ex.custom_fields[field.id] != null).map((ex) => ex.custom_fields[field.id]); + const handleClickHistogramBar = (binIndex) => { + if (this.appState.selectedHistogramBinForCustomFields[field.id] === binIndex) { + this.appState.selectedHistogramBinForCustomFields[field.id] = null; + } else { + this.appState.selectedHistogramBinForCustomFields[field.id] = binIndex; + } + }; + const isAnyBinSelected = () => this.appState.selectedHistogramBinForCustomFields[field.id] !== null; + const isThisBinSelected = (binIndex) => binIndex === this.appState.selectedHistogramBinForCustomFields[field.id]; + return x` + this.appState.histogramSpecForCustomFields[field.id]} + .getRawDataValues=${getHistogramRawDataValues} + .handleClickHistogramBar=${handleClickHistogramBar} + .isAnyBinSelected=${isAnyBinSelected} + .isThisBinSelected=${isThisBinSelected} + .svgHeight=${60}> + `; + } + renderCustomFieldSideBySideHistogram(field) { + const getHistogramSpec = () => this.appState.histogramSpecForCustomFields[field.id]; + const chartSelectionKey = (model) => ({ + chartType: "histogram" /* HISTOGRAM */, + fieldId: field.id, + model + }); + const getHistogramDataForA = () => this.appState.getFilteredExamplesExceptForParticularChart(chartSelectionKey("A")).filter( + (ex) => ex.custom_fields[field.id][0] != null + ).map((ex) => ex.custom_fields[field.id][0]); + const getHistogramDataForB = () => this.appState.getFilteredExamplesExceptForParticularChart(chartSelectionKey("B")).filter( + (ex) => ex.custom_fields[field.id][1] != null + ).map((ex) => ex.custom_fields[field.id][1]); + const handleClickHistogramBar = (binIndex, model) => { + if (this.appState.selectedHistogramBinForCustomFields[field.id][model] === binIndex) { + this.appState.selectedHistogramBinForCustomFields[field.id][model] = null; + } else { + this.appState.selectedHistogramBinForCustomFields[field.id][model] = binIndex; + } + }; + const handleClickHistogramBarForA = (binIndex) => void handleClickHistogramBar(binIndex, "A" /* A */); + const handleClickHistogramBarForB = (binIndex) => void handleClickHistogramBar(binIndex, "B" /* B */); + const selections = this.appState.selectedHistogramBinForCustomFields[field.id]; + const isAnyBinSelectedForA = () => selections["A"] != null; + const isAnyBinSelectedForB = () => selections["B"] != null; + const isThisBinSelectedForA = (binIndex) => selections["A"] === binIndex; + const isThisBinSelectedForB = (binIndex) => selections["B"] === binIndex; + if (getHistogramSpec() !== void 0) { + return x` + + + `; + } else { + return x``; + } + } + renderCustomFieldBarChart(field) { + const getValueDomain = () => { + const values = this.appState.examples.filter((ex) => ex.custom_fields[field.id] != null).map((ex) => ex.custom_fields[field.id]); + if (field.domain !== void 0) { + return mergeTwoArrays(field.domain, groupByAndSortKeys(values)); + } else { + return groupByAndSortKeys(values); + } + }; + const chartSelectionKey = { + chartType: "bar" /* BAR_CHART */, + fieldId: field.id, + model: null + }; + const getBarChartData = () => this.appState.getFilteredExamplesExceptForParticularChart(chartSelectionKey).filter((ex) => ex.custom_fields[field.id] != null).map((ex) => ex.custom_fields[field.id]); + const handleClickBar = (value) => { + if (this.appState.selectedBarChartValues[field.id][0] === value) { + this.appState.selectedBarChartValues[field.id][0] = null; + } else { + this.appState.selectedBarChartValues[field.id][0] = value; + } + }; + const isAnyBarSelected = () => this.appState.selectedBarChartValues[field.id][0] !== null; + const isThisBarSelected = (value) => this.appState.selectedBarChartValues[field.id][0] === value; + return x` + + `; + } + renderCustomFieldSideBySideBarChart(field) { + const groupCount = this.appState.models.length; + const groupIndices = Array.from({ length: groupCount }, (unused, i23) => i23); + const getValueDomain = () => { + const getValue = (ex) => ex.custom_fields[field.id]; + const values = groupIndices.flatMap( + (groupIndex) => this.appState.examples.filter((ex) => getValue(ex)[groupIndex] != null).map((ex) => getValue(ex)[groupIndex].toString()) + ); + if (field.domain !== void 0) { + return mergeTwoArrays(field.domain, groupByAndSortKeys(values)); + } else { + return groupByAndSortKeys(values); + } + }; + const chartSelectionKey = (groupIndex) => ({ + chartType: "bar" /* BAR_CHART */, + fieldId: field.id, + model: groupIndex + }); + const getBarChartData = () => { + const getValue = (ex) => ex.custom_fields[field.id]; + return groupIndices.map( + (groupIndex) => this.appState.getFilteredExamplesExceptForParticularChart( + chartSelectionKey(groupIndex) + ).filter((ex) => getValue(ex)[groupIndex] != null).map((ex) => getValue(ex)[groupIndex].toString()) + ); + }; + const handleClickBar = (value, groupIndex) => { + if (this.appState.selectedBarChartValues[field.id][groupIndex] === value) { + this.appState.selectedBarChartValues[field.id][groupIndex] = null; + } else { + this.appState.selectedBarChartValues[field.id][groupIndex] = value; + } + }; + const isAnyBarSelected = (groupIndex) => this.appState.selectedBarChartValues[field.id][groupIndex] !== null; + const isThisBarSelected = (value, groupIndex) => this.appState.selectedBarChartValues[field.id][groupIndex] === value; + return x` + `; + } + // Side-by-side bar charts for per-rating-per-model type. + renderCustomFieldPerRatingSideBySideBarChart(field) { + const groupCount = this.appState.models.length; + const groupIndices = Array.from({ length: groupCount }, (unused, i23) => i23); + const getValueDomain = () => { + return this.appState.valueDomainsForCustomFields[field.id]; + }; + const chartSelectionKey = (groupIndex) => ({ + chartType: "bar" /* BAR_CHART */, + fieldId: field.id, + model: groupIndex + }); + const getBarChartNestedData = () => { + return groupIndices.map( + (groupIndex) => this.appState.getFilteredExamplesExceptForParticularChart( + chartSelectionKey(groupIndex) + ).map((ex) => { + return ex.individual_rater_scores.map( + (rating) => rating.custom_fields[field.id][groupIndex] + ); + }) + ); + }; + const handleClickBar = (value, groupIndex) => { + if (this.appState.selectedBarChartValues[field.id][groupIndex] === value) { + this.appState.selectedBarChartValues[field.id][groupIndex] = null; + } else { + this.appState.selectedBarChartValues[field.id][groupIndex] = value; + } + }; + const isAnyBarSelected = (groupIndex) => this.appState.selectedBarChartValues[field.id][groupIndex] !== null; + const isThisBarSelected = (value, groupIndex) => this.appState.selectedBarChartValues[field.id][groupIndex] === value; + return x` + `; + } + render() { + const renderChartsForCustomFields = this.appState.columns.filter((field) => field.id.startsWith("custom_field:")).filter( + (field) => field.type === "number" /* NUMBER */ || field.type === "category" /* CATEGORY */ || field.type === "per_model_boolean" /* PER_MODEL_BOOLEAN */ || field.type === "per_model_number" /* PER_MODEL_NUMBER */ || field.type === "per_model_category" /* PER_MODEL_CATEGORY */ || field.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */ + ).map((field) => { + if (field.type === "number" /* NUMBER */) { + return [field.name, this.renderCustomFieldHistogram(field)]; + } else if (field.type === "per_model_number" /* PER_MODEL_NUMBER */) { + return [ + field.name, + this.renderCustomFieldSideBySideHistogram(field) + ]; + } else if (field.type === "per_model_category" /* PER_MODEL_CATEGORY */ || field.type === "per_model_boolean" /* PER_MODEL_BOOLEAN */) { + return [ + field.name, + this.renderCustomFieldSideBySideBarChart(field) + ]; + } else if (field.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */) { + return [ + field.name, + this.renderCustomFieldPerRatingSideBySideBarChart(field) + ]; + } else { + return [field.name, this.renderCustomFieldBarChart(field)]; + } + }); + const handleClickTitleBar = (fieldName) => { + const key = `custom_field:${fieldName}`; + if (!this.appState.showSidebarComponents.hasOwnProperty(key)) { + this.appState.showSidebarComponents[key] = true; + } else if (this.appState.showSidebarComponents[key] === false) { + this.appState.showSidebarComponents[key] = true; + } else { + this.appState.showSidebarComponents[key] = false; + } + }; + const renderSidebarComponents = renderChartsForCustomFields.map((chart) => { + const [fieldName, renderChart] = chart; + const key = `custom_field:${fieldName}`; + return x` + `; + }); + return x`${renderSidebarComponents}`; + } + }; + ChartsElement.styles = styles; + ChartsElement = __decorateClass([ + t3("comparator-charts") + ], ChartsElement); + + // client/components/custom_functions.css + var styles4 = i`td { + border-bottom: 1px solid #eee; + height: 60px; + vertical-align: top; +} + +tr:first-child td { + border-top: 1px solid #eee; +} + +tr.selected td, +tr:hover td { + background-color: var(--comparator-custom-func-100); + color: #000; +} + +td.function-info { + padding: 6px 4px 2px 8px; +} + +td.results-chart { + padding-top: 2px; + width: 132px; +} + +td.edit-remove-icons { + width: 20px; + vertical-align: middle; +} + +.function-name { + padding: 3px 0; +} + +.function-type { + color: var(--comparator-grey-450); + font-size: 10px; +} + +.icon { + color: var(--comparator-grey-300); + margin: 2px 0; + font-size: 12px; +} + +.icon.disabled { + visibility: hidden; +} + +line.axis { + fill: none; + stroke: #ccc; + stroke-width: 1; +} + +.custom-func-results-bar { + cursor: pointer; + fill: #f3f3f3; + stroke-width: 0; +} + +.custom-func-results-bar.value-no.selected, +.custom-func-results-bar.value-no:hover { + fill: #e7e7e7; +} + +.model-a { + fill: var(--comparator-model-a); +} + +.model-b { + fill: var(--comparator-model-b); +} + +.custom-func-results-mean { + stroke-width: 0; +} + +.histogram-bar { + fill-opacity: 0.75; +} + +.model-label { + alignment-baseline: hanging; + fill: var(--comparator-grey-500); + font-size: 11px; + text-anchor: middle; +} + +.number-label { + fill: var(--comparator-grey-500); + font-size: 11px; + text-anchor: middle; +} + +.number-label-description { + fill: #bbb; + font-size: 7px; + text-anchor: end; +} + +.edit-custom-function { + background-color: var(--comparator-grey-100); + display: flex; + flex-direction: column; + margin-top: 5px; + padding: 5px 10px; +} + +.edit-custom-function-title { + display: flex; + font-size: 13px; + justify-content: space-between; + padding: 4px 0; +} + +.edit-custom-function-form { + display: flex; + flex-direction: column; + margin-top: 4px; +} + +.field-row { + display: flex; + gap: 4px; + margin: 2px 0; +} + +.field-row .field-row-label { + font-weight: 500; + padding: 4px 0; + width: 45px; +} + +.field-row .field-row-content { + align-items: center; + display: flex; + gap: 8px; +} + +.edit-custom-function .func-name-input { + border: 1px solid var(--comparator-grey-300); + font-family: monospace; + padding: 4px 8px; + width: 220px; +} + +.edit-custom-function textarea { + border: 1px solid var(--comparator-grey-300); + margin-top: 4px; + padding: 4px 6px; + width: 220px; +} + +.run-button { + align-self: end; + background-color: var(--comparator-custom-func-200); + border: 0; + border-radius: 12px; + color: var(--comparator-custom-func-800); + cursor: pointer; + margin-top: 8px; + padding: 6px 0; + width: 80px; +} +`; + + // client/components/custom_functions.ts + var BinaryStackedBarChart = class extends s3 { + constructor() { + super(); + this.svgWidth = 100; + this.svgHeight = 40; + this.customFuncId = -1; + this.countA = 0; + this.countB = 0; + this.numExamples = 0; + this.appState = core.getService(AppState); + this.topPadding = 10; + this.bottomPadding = 15; + this.barSidePadding = 10; + makeObservable(this); + } + get barAreaHeight() { + return this.svgHeight - this.topPadding - this.bottomPadding; + } + get barWidth() { + return this.svgWidth * 0.5 - this.barSidePadding * 2; + } + render() { + const trueRateA = this.numExamples === 0 ? 0 : this.countA / this.numExamples; + const trueRateB = this.numExamples === 0 ? 0 : this.countB / this.numExamples; + const yPositionA = this.barAreaHeight * (1 - trueRateA); + const yPositionB = this.barAreaHeight * (1 - trueRateB); + const selections = this.appState.selectionsFromCustomFuncResults[this.customFuncId]; + const styleBarForFalse = (model) => e6({ + "custom-func-results-bar": true, + "value-no": true, + "selected": selections[model] === false + }); + const styleBarForTrue = (model) => e6({ + "custom-func-results-bar": true, + "model-a": model === "A" /* A */, + "model-b": model === "B" /* B */ + }); + const styleClickableAreasForTrue = (model) => e6({ + "clickable-transparent-area": true, + "selected": selections[model] === true + }); + const handleClickBar = (customFuncId, model, isTrue) => { + const selections2 = this.appState.selectionsFromCustomFuncResults[customFuncId]; + if (selections2[model] === isTrue) { + selections2[model] = null; + } else { + selections2[model] = isTrue; + this.appState.selectedCustomFuncId = customFuncId; + } + }; + const renderBottomAxis = b2` + + + A + B + `; + const renderBarsForFalse = b2` + void handleClickBar(this.customFuncId, "A" /* A */, false)} /> + void handleClickBar(this.customFuncId, "B" /* B */, false)} />`; + const renderBarsForTrue = b2` + + `; + const renderNumberLabelsForTrueCount = b2` + + ${this.countA} + + + ${this.countB} + `; + const renderClickableAreasForTrue = b2` + ${trueRateA > 0 ? b2` + void handleClickBar( + this.customFuncId, + "A" /* A */, + true + )} />` : ""} + ${trueRateB > 0 ? b2` + void handleClickBar( + this.customFuncId, + "B" /* B */, + true + )} />` : ""}`; + return x` + + ${renderBottomAxis} ${renderBarsForFalse} ${renderBarsForTrue} + ${renderNumberLabelsForTrueCount} ${renderClickableAreasForTrue} + + `; + } + }; + BinaryStackedBarChart.styles = [styles, styles4]; + __decorateClass([ + n4({ type: Number }) + ], BinaryStackedBarChart.prototype, "svgWidth", 2); + __decorateClass([ + n4({ type: Number }) + ], BinaryStackedBarChart.prototype, "svgHeight", 2); + __decorateClass([ + n4({ type: Number }) + ], BinaryStackedBarChart.prototype, "customFuncId", 2); + __decorateClass([ + n4({ type: Number }) + ], BinaryStackedBarChart.prototype, "countA", 2); + __decorateClass([ + n4({ type: Number }) + ], BinaryStackedBarChart.prototype, "countB", 2); + __decorateClass([ + n4({ type: Number }) + ], BinaryStackedBarChart.prototype, "numExamples", 2); + __decorateClass([ + computed + ], BinaryStackedBarChart.prototype, "barAreaHeight", 1); + __decorateClass([ + computed + ], BinaryStackedBarChart.prototype, "barWidth", 1); + BinaryStackedBarChart = __decorateClass([ + t3("comparator-binary-stacked-bar-chart") + ], BinaryStackedBarChart); + var CustomFunctionsElement = class extends MobxLitElement { + constructor() { + super(...arguments); + this.appState = core.getService(AppState); + this.svgWidth = 130; + this.editedCustomFunc = makeNewCustomFunc( + this.appState.newCustomFuncId + ); + } + renderChartForBooleanType(customFunc) { + const svgHeight = DEFAULT_CHART_HEIGHT_FOR_CUSTOM_FUNCS; + const filteredExamples = this.appState.filteredExamples; + const aggregatedResults = { + "A": { "true": 0, "false": 0 }, + "B": { "true": 0, "false": 0 } + }; + const fieldId = getFieldIdForCustomFunc(customFunc.id); + filteredExamples.forEach((ex) => { + if (ex.custom_fields[fieldId][0] != null) { + aggregatedResults["A"][ex.custom_fields[fieldId][0].toString()] += 1; + } + if (ex.custom_fields[fieldId][1] != null) { + aggregatedResults["B"][ex.custom_fields[fieldId][1].toString()] += 1; + } + }); + return x` + `; + } + // TODO: Merge into the side-by-side histogram code in charts.ts. + renderChartForNumberType(customFunc) { + const getHistogramSpec = () => this.appState.histogramSpecForCustomFuncs[customFunc.id]; + const getHistogramSpecForDiff = () => this.appState.histogramSpecForCustomFuncsOfDiff[customFunc.id]; + const fieldId = getFieldIdForCustomFunc(customFunc.id); + const chartSelectionKey = (model) => ({ chartType: "custom_function" /* CUSTOM_FUNCTION */, fieldId, model }); + const getHistogramDataForA = () => this.appState.getFilteredExamplesExceptForParticularChart(chartSelectionKey("A")).filter( + (ex) => ex.custom_fields[fieldId][0] != null + ).map((ex) => ex.custom_fields[fieldId][0]); + const getHistogramDataForB = () => this.appState.getFilteredExamplesExceptForParticularChart(chartSelectionKey("B")).filter( + (ex) => ex.custom_fields[fieldId][1] != null + ).map((ex) => ex.custom_fields[fieldId][1]); + const getHistogramDataForDiff = () => this.appState.getFilteredExamplesExceptForParticularChart(chartSelectionKey("A-B")).filter( + (ex) => ex.custom_fields[fieldId][0] != null && ex.custom_fields[fieldId][1] != null + ).map( + (ex) => ex.custom_fields[fieldId][0] - ex.custom_fields[fieldId][1] + ); + const handleClickHistogramBar = (binIndex, model) => { + const selections2 = this.appState.selectionsFromCustomFuncResults[customFunc.id]; + if (selections2[model] === binIndex) { + selections2[model] = null; + } else { + selections2[model] = binIndex; + this.appState.selectedCustomFuncId = customFunc.id; + } + }; + const handleClickHistogramBarForA = (binIndex) => void handleClickHistogramBar(binIndex, "A" /* A */); + const handleClickHistogramBarForB = (binIndex) => void handleClickHistogramBar(binIndex, "B" /* B */); + const handleClickHistogramBarForDiff = (binIndex) => void handleClickHistogramBar(binIndex, "A-B"); + const selections = this.appState.selectionsFromCustomFuncResults[customFunc.id]; + const isAnyBinSelectedForA = () => selections["A"] != null; + const isAnyBinSelectedForB = () => selections["B"] != null; + const isAnyBinSelectedForDiff = () => selections["A-B"] != null; + const isThisBinSelectedForA = (binIndex) => selections["A"] === binIndex; + const isThisBinSelectedForB = (binIndex) => selections["B"] === binIndex; + const isThisBinSelectedForDiff = (binIndex) => selections["A-B"] === binIndex; + if (getHistogramSpec() !== void 0) { + return x` + + + + + `; + } else { + return ""; + } + } + renderCustomFunctionRow(customFunc) { + const handleClickTableRow = (customFuncId) => { + if (this.appState.selectedCustomFuncId === customFuncId) { + this.appState.selectedCustomFuncId = null; + } else { + this.appState.selectedCustomFuncId = customFuncId; + } + }; + const customFuncRowStyle = (customFuncId) => e6({ + "selected": customFuncId === this.appState.selectedCustomFuncId + }); + const renderChart = customFunc.returnType === "Boolean" /* BOOLEAN */ ? x` + + ${this.renderChartForBooleanType(customFunc)} + ` : x` + + ${this.renderChartForNumberType(customFunc)} + `; + const handleClickEditIcon = () => { + this.editedCustomFunc = { + ...this.appState.customFunctions[customFunc.id] + }; + this.appState.selectedCustomFuncId = customFunc.id; + this.appState.isShowCustomFuncEditor = true; + }; + const handleClickRemoveIcon = () => { + if (this.appState.customFunctions[customFunc.id] !== void 0) { + if (this.appState.selectedCustomFuncId === customFunc.id) { + this.appState.selectedCustomFuncId = null; + } + const fieldId = getFieldIdForCustomFunc(customFunc.id); + if (this.appState.currentSorting.customField != null && this.appState.currentSorting.customField.id === fieldId) { + this.appState.resetSorting(); + } + delete this.appState.selectionsFromCustomFuncResults[customFunc.id]; + delete this.appState.customFunctions[customFunc.id]; + this.appState.columns = this.appState.columns.filter( + (field) => field.id !== fieldId + ); + this.appState.updateStatusMessage("Removed the custom function.", true); + } + }; + const styleEditIcon = e6({ + "icon": true, + "clickable": true, + "disabled": customFunc.precomputed === true + }); + return x` + + void handleClickTableRow(customFunc.id)}> +
    ${customFunc.name}
    +
    ${customFunc.returnType}
    + + ${renderChart} + + + + edit + + + cancel + + + `; + } + renderCustomFunctionList() { + const customFuncRows = Object.values(this.appState.customFunctions).map( + (customFunc) => this.renderCustomFunctionRow(customFunc) + ); + return x` + ${customFuncRows} +
    `; + } + renderCustomFunctionEditor() { + const handleCustomFuncNameChange = (e33) => { + this.editedCustomFunc.name = e33.target.value; + }; + const handleCustomFuncBodyChange = (e33) => { + this.editedCustomFunc.functionBody = e33.target.value; + }; + const handleClickRun = () => { + if (this.editedCustomFunc.functionBody === "") { + this.appState.updateStatusMessage("Write an expression."); + return; + } + if (this.editedCustomFunc.name === "") { + this.editedCustomFunc.name = this.editedCustomFunc.functionBody; + } + this.appState.runCustomFunction( + this.appState.examples, + this.editedCustomFunc + ); + }; + const handleClickCreateNewFuncButton = () => { + if (this.appState.isShowCustomFuncEditor === false) { + this.editedCustomFunc = makeNewCustomFunc( + this.appState.newCustomFuncId + ); + this.appState.isShowCustomFuncEditor = true; + } else { + this.appState.isShowCustomFuncEditor = false; + } + }; + return x` +
    +
    +
    Create New Function
    +
    + ${this.appState.isShowCustomFuncEditor === false ? x`unfold_more` : x`close`} +
    +
    + ${this.appState.isShowCustomFuncEditor === true ? x` +
    +
    +
    Name
    + +
    + +
    +
    Syntax
    +
    + ${Object.values(CustomFuncType).filter((funcType) => funcType !== "Precomputed" /* PRECOMPUTED */).map( + (val) => x` +
    + this.editedCustomFunc.functionType = val} + /> + +
    ` + )} +
    +
    + +
    +
    Expr.
    + +
    + +
    +
    Return
    +
    + ${Object.values(CustomFuncReturnType).map( + (val) => x` +
    + this.editedCustomFunc.returnType = val} + /> + +
    ` + )} +
    +
    + + +
    + ` : x``} +
    `; + } + render() { + return x` `; + } + }; + CustomFunctionsElement.styles = [styles, styles4]; + __decorateClass([ + observable + ], CustomFunctionsElement.prototype, "editedCustomFunc", 2); + CustomFunctionsElement = __decorateClass([ + t3("comparator-custom-functions") + ], CustomFunctionsElement); + + // client/components/dataset_selection.css + var styles5 = i`.dataset-selection-container { + align-items: center; + background-color: rgba(0, 0, 0, 0.5); + display: flex; + height: calc(100vh - 57px); + justify-content: center; + position: absolute; + width: 100vw; + z-index: 10; +} + +.dataset-selection { + background-color: #fff; + border-radius: 10px; + font-size: 13px; + height: 520px; + overflow-y: auto; + padding: 40px; + position: relative; + width: 700px; +} + +.close-button { + padding: 20px; + position: absolute; + right: 0; + top: 0; +} + +.panel-title { + color: var(--comparator-grey-250); + font-size: 24px; + padding-bottom: 5px; +} + +.panel-title .selected { + color: var(--comparator-grey-800); +} + +.panel-instruction { + color: var(--comparator-grey-800); + line-height: 18px; + margin: 5px 0; + padding: 2px 0; +} + +.textarea-wrapper { + display: flex; + margin: 5px 0; +} + +.textarea-filepath { + border-radius: 5px; + font-family: monospace; + font-size: 14px; + margin-right: 5px; + padding: 5px; + width: calc(100% - 70px); + word-break: break-all; +} + +.filepath { + background-color: #f3f3f3; + font-family: monospace; + word-break: break-all; +} + +ul { + border-top: 1px solid #eee; + margin: 5px 0 25px 10px; + padding-left: 0; +} + +li { + background-color: #fff; + border-bottom: 1px solid #eee; + color: #777; + font-family: monospace; + list-style: none; + padding: 10px; + word-break: break-all; +} + +li:hover { + background-color: #eee; + color: #555; + text-decoration: underline; +} + +input, button { + font-size: 13px; + padding: 5px 7px; +} + +.file-upload { + font-size: 14px; + padding: 10px 0; +} +`; + + // client/components/dataset_selection.ts + var DatasetSelectionElement = class extends MobxLitElement { + constructor() { + super(); + this.appState = core.getService(AppState); + this.isShowFileUploadView = this.appState.isDatasetPathUploadedFile === true; + this.editedDatasetPath = ""; + makeObservable(this); + } + static get styles() { + return [styles, styles5]; + } + getDocumentationLinkString() { + const documentationLink = "https://github.com/PAIR-code/llm-comparator"; + return x` +
    + `; + } + renderViewForSpecifyingDataPath() { + if (this.appState.datasetPath != null && this.appState.isDatasetPathUploadedFile === false && this.editedDatasetPath === "") { + this.editedDatasetPath = this.appState.datasetPath; + } + const handleClickLoadButton = () => this.appState.loadData(this.editedDatasetPath, null); + const handleClickDatasetPath = (datasetPath) => { + this.appState.loadData(datasetPath, null); + }; + const handleChangeDatasetPath = (e33) => { + this.editedDatasetPath = e33.target.value; + }; + const selectedClassMap = (datasetPath) => e6({ + "clickable": true, + "selected": this.appState.datasetPath === datasetPath + }); + const textareaPlaceholder = "Enter a URL to load the json file from."; + const urlLoadPath = this.appState.appLink + "?results_path=https://.../...json"; + const panelIntro = x` + Enter the URL path of a json file prepared for LLM Comparator.`; + const panelOutro = x` + ${this.getDocumentationLinkString()}
    + Note that the server hosting the file must allow + Cross-Origin Resource Sharing.`; + const panelInstruction = x` + ${panelIntro} +
    + + +
    + ${panelOutro} + +


    + If you don't have your run, + click one of the following example runs. + +
      + ${this.appState.exampleDatasetPaths.map( + (path) => x`
    • void handleClickDatasetPath(path)}>${path}
    • ` + )} +
    + + Note: You can also directly load the tool with a path by + opening an URL like:
    + + ${urlLoadPath} + + `; + return panelInstruction; + } + renderViewForUploadingData() { + const handleFileUpload = (e33) => { + const input = e33.target; + if (input.files && input.files.length > 0) { + const file = input.files[0]; + this.appState.loadData(file.name, file); + } + }; + return x` +
    + + +
    + + ${this.getDocumentationLinkString()} + `; + } + render() { + if (this.appState.isOpenDatasetSelectionPanel === false) { + return x``; + } + const handleClickCloseButton = () => { + this.appState.isOpenDatasetSelectionPanel = false; + }; + const stylePanelTitle = (isUpload) => e6({ + "selected": isUpload === this.isShowFileUploadView, + "clickable": true + }); + const panelTitle = x` this.isShowFileUploadView = false}> + Select Data + + | + this.isShowFileUploadView = true}> + Upload File + `; + const panelInstruction = this.isShowFileUploadView === true ? this.renderViewForUploadingData() : this.renderViewForSpecifyingDataPath(); + return x`
    +
    + ${this.appState.datasetPath !== null ? x`
    + close +
    ` : ""} +
    ${panelTitle}
    +
    ${panelInstruction}
    +
    +
    `; + } + }; + __decorateClass([ + observable + ], DatasetSelectionElement.prototype, "isShowFileUploadView", 2); + __decorateClass([ + observable + ], DatasetSelectionElement.prototype, "editedDatasetPath", 2); + DatasetSelectionElement = __decorateClass([ + t3("comparator-dataset-selection") + ], DatasetSelectionElement); + + // client/components/example_details.css + var styles6 = i`.panel-container { + display: flex; + flex-direction: column; + height: 100%; + padding-left: 15px; +} + +.panel-header { + align-items: center; + border-bottom: 1px solid var(--comparator-grey-200); + display: flex; + height: 34px; + justify-content: space-between; +} + +.panel-title { + align-items: center; + display: flex; + gap: 10px; +} + +.panel-title h3 { + font-size: 16px; + font-weight: 200; +} + +.filter-chips { + display: flex; + gap: 2px; +} + +.panel-contents { + display: flex; + gap: 10px; + height: calc(100% - 35px); +} + +.score-distribution-chart { + display: flex; + padding: 5px 10px; +} + +.rating-table { + overflow-y: scroll; +} + +thead { + position: sticky; + top: 0; + z-index: 1; +} + +th { + background-color: var(--comparator-grey-200); + color: var(--comparator-grey-800); + font-weight: normal; + padding: 6px 4px; + position: relative; + vertical-align: top; +} + +td { + border-bottom: 1px solid #ddd; + line-height: 13px; + padding: 6px 8px; + vertical-align: top; +} + +th.index { + width: 25px; +} + +th.score { + width: 55px; +} + +th.flipped { + width: 45px; +} + +th.rationale { + min-width: 300px; +} + +tr.second-row th { + color: white; + padding: 0 4px 2px; +} + +td.center-aligned { + text-align: center; +} + +td.highlighted { + font-weight: 600; +} + +td.a-win { + background-color: var(--comparator-model-a-win-bg); +} + +td.b-win { + background-color: var(--comparator-model-b-win-bg); +} + +td.rationale { + overflow-wrap: anywhere; + white-space: break-spaces; +} + +.sort-icon { + color: var(--comparator-grey-100); +} + +.sort-icon.up { + top: -12px; +} + +.sort-icon.down { + top: -2px; +} + +.sort-icon:hover { + color: var(--comparator-grey-300); +} + +.sort-icon.active { + color: var(--comparator-grey-500); +} +`; + + // client/components/example_details.ts + var ExampleDetailsElement = class extends MobxLitElement { + constructor() { + super(); + this.appState = core.getService(AppState); + this.sortOrder = "None" /* NONE */; + makeObservable(this); + } + get selectedExample() { + return this.appState.selectedExample; + } + get filteredRatings() { + if (this.selectedExample == null) { + return []; + } + return this.selectedExample.individual_rater_scores.filter( + (rating) => this.appState.selectedHistogramBinForRatingsForSelectedExample == null || rating.score != null && getHistogramBinIndexFromValue( + this.appState.histogramSpecForScores, + rating.score + ) === this.appState.selectedHistogramBinForRatingsForSelectedExample + ).filter((rating) => { + const selection = this.appState.selectedBarChartValueForSelectedExample; + return selection == null || rating.custom_fields[selection.fieldId][selection.modelIndex] === selection.value; + }); + } + get sortedRatings() { + return this.filteredRatings.sort( + (a11, b7) => this.sortOrder === "None" /* NONE */ ? 1 : compareNumbersWithNulls( + a11.score, + b7.score, + this.sortOrder === "desc" /* DESC */ + ) + ); + } + // Score histogram for the individual ratings for a selected example. + renderScoreHistogram() { + const svgWidth = 220; + const svgHeight = 110; + const getHistogramRawDataValues = () => { + return this.filteredRatings.filter((rating) => rating.score != null).map((rating) => rating.score); + }; + const handleClickHistogramBar = (binIndex) => { + if (this.appState.selectedHistogramBinForRatingsForSelectedExample === binIndex) { + this.appState.selectedHistogramBinForRatingsForSelectedExample = null; + } else { + this.appState.selectedHistogramBinForRatingsForSelectedExample = binIndex; + } + }; + const isAnyBinSelected = () => this.appState.selectedHistogramBinForRatingsForSelectedExample !== null; + const isThisBinSelected = (binIndex) => binIndex === this.appState.selectedHistogramBinForRatingsForSelectedExample; + return x` this.appState.histogramSpecForScores} + .getRawDataValues=${getHistogramRawDataValues} + .handleClickHistogramBar=${handleClickHistogramBar} + .isAnyBinSelected=${isAnyBinSelected} + .isThisBinSelected=${isThisBinSelected} + .svgWidth=${svgWidth} + .svgHeight=${svgHeight} + .neutralColorThreshold=${() => this.appState.winRateThreshold} + .showAxisEndDescription=${true} + .isFlipXAxis=${() => this.appState.isFlipScoreHistogramAxis}> + `; + } + // TODO: Create a separate data-table component. + renderRaterTable() { + const selectedExample = this.selectedExample; + if (selectedExample == null) { + return x``; + } + const readableRating = (label, isFlipped) => { + if (label == null) { + return ""; + } else if (label.endsWith("Than") || label.endsWith("SameAs")) { + return isFlipped === true ? `B is ${label} A` : `A is ${label} B`; + } else { + return label; + } + }; + const styleScore = (score) => e6({ + "center-aligned": true, + "a-win": this.appState.isScoreDivergingScheme === true && score != null && score > this.appState.scoreMiddlePoint, + "b-win": this.appState.isScoreDivergingScheme === true && score != null && score < this.appState.scoreMiddlePoint + }); + const styleSortIcons = (order) => e6({ + "sort-icon": true, + "up": order === "asc" /* ASC */, + "down": order === "desc" /* DESC */, + "active": this.sortOrder === order + }); + const handleClickSortIcon = (order) => { + if (order === this.sortOrder) { + this.sortOrder = "None" /* NONE */; + } else { + this.sortOrder = order; + } + }; + const renderSortIcons = () => x`
    + void handleClickSortIcon("asc" /* ASC */)}> + arrow_drop_up + + void handleClickSortIcon("desc" /* DESC */)}> + arrow_drop_down + +
    `; + const renderCustomFieldHeaderCell = (field) => { + if (field.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */) { + return x` ${field.name}`; + } else { + return x` ${field.name}`; + } + }; + const renderCustomFieldHeaderCellSecondRow = (field) => { + if (field.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */) { + return x` A + B`; + } else { + return x``; + } + }; + const renderHeaderRow = x` + Index + Score ${renderSortIcons()} + Rating + Flipped? + Rationale + ${this.appState.customFieldsOfPerRatingType.map( + (field) => renderCustomFieldHeaderCell(field) + )} + + + ${this.appState.customFieldsOfPerRatingType.map( + (field) => renderCustomFieldHeaderCellSecondRow(field) + )} + `; + const selection = this.appState.selectedBarChartValueForSelectedExample; + const renderCustomField = (rating, field) => { + const styleCell = (modelIndex, value) => e6({ + "highlighted": selection != null && selection.fieldId === field.id && selection.modelIndex === modelIndex && selection.value === value + }); + if (field.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */) { + const value = rating.custom_fields[field.id] || [null, null]; + if (value.length !== 2) { + throw new Error(`Invalid value for field ${field.id}: ${value}`); + } + return x` ${value[0]} + ${value[1]}`; + } else { + return x` ${rating.custom_fields[field.id]}`; + } + }; + const renderRow = (rating) => { + return x` + ${rating.index} + ${rating.score} + ${readableRating(rating.rating_label, rating.is_flipped)} + + ${rating.is_flipped == null ? "Unknown" : rating.is_flipped === true ? "Y" : "N"} + + ${rating.rationale} + ${this.appState.customFieldsOfPerRatingType.map( + (field) => renderCustomField(rating, field) + )} + `; + }; + const renderSortedRatings = this.sortedRatings.map( + (rating) => renderRow(rating) + ); + return x` + ${renderHeaderRow} + ${renderSortedRatings} +
    `; + } + // Filter chips at the top of the panel. + renderFilterChip(label, handleClickCancelButton) { + return x`
    + ${label} + + cancel + +
    `; + } + renderFilterChips() { + const labelScore = getHistogramFilterLabel( + "score", + this.appState.histogramSpecForScores, + this.appState.selectedHistogramBinForRatingsForSelectedExample, + null + ); + const handleClickCancelButtonForScore = () => { + this.appState.selectedHistogramBinForRatingsForSelectedExample = null; + }; + const selection = this.appState.selectedBarChartValueForSelectedExample; + const selectionField = selection == null ? null : this.appState.getFieldFromId(selection.fieldId); + const labelCustomField = selection == null || selectionField == null ? "" : `${selectionField.name}(${Object.values(AOrB)[selection.modelIndex]}) = ${selection.value}`; + const handleClickCancelButtonForCustomField = () => { + this.appState.selectedBarChartValueForSelectedExample = null; + }; + return x` + ${this.appState.selectedHistogramBinForRatingsForSelectedExample != null ? this.renderFilterChip(labelScore, handleClickCancelButtonForScore) : x``} + ${this.appState.selectedBarChartValueForSelectedExample != null ? this.renderFilterChip( + labelCustomField, + handleClickCancelButtonForCustomField + ) : x``} + `; + } + render() { + const showSelectedExampleDetails = this.appState.showSelectedExampleDetails; + const selectedExample = this.appState.selectedExample; + if (showSelectedExampleDetails === false || selectedExample == null) { + return x``; + } + const handleClickCloseButton = () => { + this.appState.showSelectedExampleDetails = false; + this.appState.selectedExample = null; + this.appState.selectedHistogramBinForRatingsForSelectedExample = null; + this.appState.selectedBarChartValueForSelectedExample = null; + }; + const handleClickExpandButton = () => { + this.appState.exampleDetailsPanelExpanded = !this.appState.exampleDetailsPanelExpanded; + }; + return x` +
    +
    +
    +

    Individual Ratings for Selected Example

    +
    ${this.renderFilterChips()}
    +
    +
    + + ${this.appState.exampleDetailsPanelExpanded === true ? "expand_more" : "expand_less"} + + + close + +
    +
    +
    +
    + ${this.renderScoreHistogram()} +
    +
    + ${this.renderRaterTable()} +
    +
    +
    `; + } + }; + ExampleDetailsElement.styles = [styles, styles6]; + __decorateClass([ + observable + ], ExampleDetailsElement.prototype, "sortOrder", 2); + __decorateClass([ + computed + ], ExampleDetailsElement.prototype, "selectedExample", 1); + __decorateClass([ + computed + ], ExampleDetailsElement.prototype, "filteredRatings", 1); + __decorateClass([ + computed + ], ExampleDetailsElement.prototype, "sortedRatings", 1); + ExampleDetailsElement = __decorateClass([ + t3("comparator-example-details") + ], ExampleDetailsElement); + + // node_modules/tslib/tslib.es6.mjs + var extendStatics = function(d11, b7) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d12, b8) { + d12.__proto__ = b8; + } || function(d12, b8) { + for (var p7 in b8) + if (Object.prototype.hasOwnProperty.call(b8, p7)) + d12[p7] = b8[p7]; + }; + return extendStatics(d11, b7); + }; + function __extends(d11, b7) { + if (typeof b7 !== "function" && b7 !== null) + throw new TypeError("Class extends value " + String(b7) + " is not a constructor or null"); + extendStatics(d11, b7); + function __() { + this.constructor = d11; + } + d11.prototype = b7 === null ? Object.create(b7) : (__.prototype = b7.prototype, new __()); + } + var __assign = function() { + __assign = Object.assign || function __assign2(t17) { + for (var s20, i23 = 1, n31 = arguments.length; i23 < n31; i23++) { + s20 = arguments[i23]; + for (var p7 in s20) + if (Object.prototype.hasOwnProperty.call(s20, p7)) + t17[p7] = s20[p7]; + } + return t17; + }; + return __assign.apply(this, arguments); + }; + function __decorate(decorators, target, key, desc) { + var c12 = arguments.length, r18 = c12 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d11; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") + r18 = Reflect.decorate(decorators, target, key, desc); + else + for (var i23 = decorators.length - 1; i23 >= 0; i23--) + if (d11 = decorators[i23]) + r18 = (c12 < 3 ? d11(r18) : c12 > 3 ? d11(target, key, r18) : d11(target, key)) || r18; + return c12 > 3 && r18 && Object.defineProperty(target, key, r18), r18; + } + function __values(o29) { + var s20 = typeof Symbol === "function" && Symbol.iterator, m6 = s20 && o29[s20], i23 = 0; + if (m6) + return m6.call(o29); + if (o29 && typeof o29.length === "number") + return { + next: function() { + if (o29 && i23 >= o29.length) + o29 = void 0; + return { value: o29 && o29[i23++], done: !o29 }; + } + }; + throw new TypeError(s20 ? "Object is not iterable." : "Symbol.iterator is not defined."); + } + function __read(o29, n31) { + var m6 = typeof Symbol === "function" && o29[Symbol.iterator]; + if (!m6) + return o29; + var i23 = m6.call(o29), r18, ar = [], e33; + try { + while ((n31 === void 0 || n31-- > 0) && !(r18 = i23.next()).done) + ar.push(r18.value); + } catch (error) { + e33 = { error }; + } finally { + try { + if (r18 && !r18.done && (m6 = i23["return"])) + m6.call(i23); + } finally { + if (e33) + throw e33.error; + } + } + return ar; + } + function __spreadArray(to, from, pack) { + if (pack || arguments.length === 2) + for (var i23 = 0, l20 = from.length, ar; i23 < l20; i23++) { + if (ar || !(i23 in from)) { + if (!ar) + ar = Array.prototype.slice.call(from, 0, i23); + ar[i23] = from[i23]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); + } + + // node_modules/@material/mwc-icon/node_modules/@lit/reactive-element/css-tag.js + var t5 = window; + var e7 = t5.ShadowRoot && (void 0 === t5.ShadyCSS || t5.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype; + var s4 = Symbol(); + var n5 = /* @__PURE__ */ new WeakMap(); + var o5 = class { + constructor(t17, e33, n31) { + if (this._$cssResult$ = true, n31 !== s4) + throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); + this.cssText = t17, this.t = e33; + } + get styleSheet() { + let t17 = this.o; + const s20 = this.t; + if (e7 && void 0 === t17) { + const e33 = void 0 !== s20 && 1 === s20.length; + e33 && (t17 = n5.get(s20)), void 0 === t17 && ((this.o = t17 = new CSSStyleSheet()).replaceSync(this.cssText), e33 && n5.set(s20, t17)); + } + return t17; + } + toString() { + return this.cssText; + } + }; + var r6 = (t17) => new o5("string" == typeof t17 ? t17 : t17 + "", void 0, s4); + var i6 = (t17, ...e33) => { + const n31 = 1 === t17.length ? t17[0] : e33.reduce((e34, s20, n32) => e34 + ((t18) => { + if (true === t18._$cssResult$) + return t18.cssText; + if ("number" == typeof t18) + return t18; + throw Error("Value passed to 'css' function must be a 'css' function result: " + t18 + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security."); + })(s20) + t17[n32 + 1], t17[0]); + return new o5(n31, t17, s4); + }; + var S3 = (s20, n31) => { + e7 ? s20.adoptedStyleSheets = n31.map((t17) => t17 instanceof CSSStyleSheet ? t17 : t17.styleSheet) : n31.forEach((e33) => { + const n32 = document.createElement("style"), o29 = t5.litNonce; + void 0 !== o29 && n32.setAttribute("nonce", o29), n32.textContent = e33.cssText, s20.appendChild(n32); + }); + }; + var c4 = e7 ? (t17) => t17 : (t17) => t17 instanceof CSSStyleSheet ? ((t18) => { + let e33 = ""; + for (const s20 of t18.cssRules) + e33 += s20.cssText; + return r6(e33); + })(t17) : t17; + + // node_modules/@material/mwc-icon/node_modules/@lit/reactive-element/reactive-element.js + var s5; + var e8 = window; + var r7 = e8.trustedTypes; + var h3 = r7 ? r7.emptyScript : ""; + var o6 = e8.reactiveElementPolyfillSupport; + var n6 = { toAttribute(t17, i23) { + switch (i23) { + case Boolean: + t17 = t17 ? h3 : null; + break; + case Object: + case Array: + t17 = null == t17 ? t17 : JSON.stringify(t17); + } + return t17; + }, fromAttribute(t17, i23) { + let s20 = t17; + switch (i23) { + case Boolean: + s20 = null !== t17; + break; + case Number: + s20 = null === t17 ? null : Number(t17); + break; + case Object: + case Array: + try { + s20 = JSON.parse(t17); + } catch (t18) { + s20 = null; + } + } + return s20; + } }; + var a3 = (t17, i23) => i23 !== t17 && (i23 == i23 || t17 == t17); + var l3 = { attribute: true, type: String, converter: n6, reflect: false, hasChanged: a3 }; + var d3 = "finalized"; + var u3 = class extends HTMLElement { + constructor() { + super(), this._$Ei = /* @__PURE__ */ new Map(), this.isUpdatePending = false, this.hasUpdated = false, this._$El = null, this._$Eu(); + } + static addInitializer(t17) { + var i23; + this.finalize(), (null !== (i23 = this.h) && void 0 !== i23 ? i23 : this.h = []).push(t17); + } + static get observedAttributes() { + this.finalize(); + const t17 = []; + return this.elementProperties.forEach((i23, s20) => { + const e33 = this._$Ep(s20, i23); + void 0 !== e33 && (this._$Ev.set(e33, s20), t17.push(e33)); + }), t17; + } + static createProperty(t17, i23 = l3) { + if (i23.state && (i23.attribute = false), this.finalize(), this.elementProperties.set(t17, i23), !i23.noAccessor && !this.prototype.hasOwnProperty(t17)) { + const s20 = "symbol" == typeof t17 ? Symbol() : "__" + t17, e33 = this.getPropertyDescriptor(t17, s20, i23); + void 0 !== e33 && Object.defineProperty(this.prototype, t17, e33); + } + } + static getPropertyDescriptor(t17, i23, s20) { + return { get() { + return this[i23]; + }, set(e33) { + const r18 = this[t17]; + this[i23] = e33, this.requestUpdate(t17, r18, s20); + }, configurable: true, enumerable: true }; + } + static getPropertyOptions(t17) { + return this.elementProperties.get(t17) || l3; + } + static finalize() { + if (this.hasOwnProperty(d3)) + return false; + this[d3] = true; + const t17 = Object.getPrototypeOf(this); + if (t17.finalize(), void 0 !== t17.h && (this.h = [...t17.h]), this.elementProperties = new Map(t17.elementProperties), this._$Ev = /* @__PURE__ */ new Map(), this.hasOwnProperty("properties")) { + const t18 = this.properties, i23 = [...Object.getOwnPropertyNames(t18), ...Object.getOwnPropertySymbols(t18)]; + for (const s20 of i23) + this.createProperty(s20, t18[s20]); + } + return this.elementStyles = this.finalizeStyles(this.styles), true; + } + static finalizeStyles(i23) { + const s20 = []; + if (Array.isArray(i23)) { + const e33 = new Set(i23.flat(1 / 0).reverse()); + for (const i24 of e33) + s20.unshift(c4(i24)); + } else + void 0 !== i23 && s20.push(c4(i23)); + return s20; + } + static _$Ep(t17, i23) { + const s20 = i23.attribute; + return false === s20 ? void 0 : "string" == typeof s20 ? s20 : "string" == typeof t17 ? t17.toLowerCase() : void 0; + } + _$Eu() { + var t17; + this._$E_ = new Promise((t18) => this.enableUpdating = t18), this._$AL = /* @__PURE__ */ new Map(), this._$Eg(), this.requestUpdate(), null === (t17 = this.constructor.h) || void 0 === t17 || t17.forEach((t18) => t18(this)); + } + addController(t17) { + var i23, s20; + (null !== (i23 = this._$ES) && void 0 !== i23 ? i23 : this._$ES = []).push(t17), void 0 !== this.renderRoot && this.isConnected && (null === (s20 = t17.hostConnected) || void 0 === s20 || s20.call(t17)); + } + removeController(t17) { + var i23; + null === (i23 = this._$ES) || void 0 === i23 || i23.splice(this._$ES.indexOf(t17) >>> 0, 1); + } + _$Eg() { + this.constructor.elementProperties.forEach((t17, i23) => { + this.hasOwnProperty(i23) && (this._$Ei.set(i23, this[i23]), delete this[i23]); + }); + } + createRenderRoot() { + var t17; + const s20 = null !== (t17 = this.shadowRoot) && void 0 !== t17 ? t17 : this.attachShadow(this.constructor.shadowRootOptions); + return S3(s20, this.constructor.elementStyles), s20; + } + connectedCallback() { + var t17; + void 0 === this.renderRoot && (this.renderRoot = this.createRenderRoot()), this.enableUpdating(true), null === (t17 = this._$ES) || void 0 === t17 || t17.forEach((t18) => { + var i23; + return null === (i23 = t18.hostConnected) || void 0 === i23 ? void 0 : i23.call(t18); + }); + } + enableUpdating(t17) { + } + disconnectedCallback() { + var t17; + null === (t17 = this._$ES) || void 0 === t17 || t17.forEach((t18) => { + var i23; + return null === (i23 = t18.hostDisconnected) || void 0 === i23 ? void 0 : i23.call(t18); + }); + } + attributeChangedCallback(t17, i23, s20) { + this._$AK(t17, s20); + } + _$EO(t17, i23, s20 = l3) { + var e33; + const r18 = this.constructor._$Ep(t17, s20); + if (void 0 !== r18 && true === s20.reflect) { + const h11 = (void 0 !== (null === (e33 = s20.converter) || void 0 === e33 ? void 0 : e33.toAttribute) ? s20.converter : n6).toAttribute(i23, s20.type); + this._$El = t17, null == h11 ? this.removeAttribute(r18) : this.setAttribute(r18, h11), this._$El = null; + } + } + _$AK(t17, i23) { + var s20; + const e33 = this.constructor, r18 = e33._$Ev.get(t17); + if (void 0 !== r18 && this._$El !== r18) { + const t18 = e33.getPropertyOptions(r18), h11 = "function" == typeof t18.converter ? { fromAttribute: t18.converter } : void 0 !== (null === (s20 = t18.converter) || void 0 === s20 ? void 0 : s20.fromAttribute) ? t18.converter : n6; + this._$El = r18, this[r18] = h11.fromAttribute(i23, t18.type), this._$El = null; + } + } + requestUpdate(t17, i23, s20) { + let e33 = true; + void 0 !== t17 && (((s20 = s20 || this.constructor.getPropertyOptions(t17)).hasChanged || a3)(this[t17], i23) ? (this._$AL.has(t17) || this._$AL.set(t17, i23), true === s20.reflect && this._$El !== t17 && (void 0 === this._$EC && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(t17, s20))) : e33 = false), !this.isUpdatePending && e33 && (this._$E_ = this._$Ej()); + } + async _$Ej() { + this.isUpdatePending = true; + try { + await this._$E_; + } catch (t18) { + Promise.reject(t18); + } + const t17 = this.scheduleUpdate(); + return null != t17 && await t17, !this.isUpdatePending; + } + scheduleUpdate() { + return this.performUpdate(); + } + performUpdate() { + var t17; + if (!this.isUpdatePending) + return; + this.hasUpdated, this._$Ei && (this._$Ei.forEach((t18, i24) => this[i24] = t18), this._$Ei = void 0); + let i23 = false; + const s20 = this._$AL; + try { + i23 = this.shouldUpdate(s20), i23 ? (this.willUpdate(s20), null === (t17 = this._$ES) || void 0 === t17 || t17.forEach((t18) => { + var i24; + return null === (i24 = t18.hostUpdate) || void 0 === i24 ? void 0 : i24.call(t18); + }), this.update(s20)) : this._$Ek(); + } catch (t18) { + throw i23 = false, this._$Ek(), t18; + } + i23 && this._$AE(s20); + } + willUpdate(t17) { + } + _$AE(t17) { + var i23; + null === (i23 = this._$ES) || void 0 === i23 || i23.forEach((t18) => { + var i24; + return null === (i24 = t18.hostUpdated) || void 0 === i24 ? void 0 : i24.call(t18); + }), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t17)), this.updated(t17); + } + _$Ek() { + this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = false; + } + get updateComplete() { + return this.getUpdateComplete(); + } + getUpdateComplete() { + return this._$E_; + } + shouldUpdate(t17) { + return true; + } + update(t17) { + void 0 !== this._$EC && (this._$EC.forEach((t18, i23) => this._$EO(i23, this[i23], t18)), this._$EC = void 0), this._$Ek(); + } + updated(t17) { + } + firstUpdated(t17) { + } + }; + u3[d3] = true, u3.elementProperties = /* @__PURE__ */ new Map(), u3.elementStyles = [], u3.shadowRootOptions = { mode: "open" }, null == o6 || o6({ ReactiveElement: u3 }), (null !== (s5 = e8.reactiveElementVersions) && void 0 !== s5 ? s5 : e8.reactiveElementVersions = []).push("1.6.3"); + + // node_modules/@material/mwc-icon/node_modules/lit-html/lit-html.js + var t6; + var i7 = window; + var s6 = i7.trustedTypes; + var e9 = s6 ? s6.createPolicy("lit-html", { createHTML: (t17) => t17 }) : void 0; + var o7 = "$lit$"; + var n7 = `lit$${(Math.random() + "").slice(9)}$`; + var l4 = "?" + n7; + var h4 = `<${l4}>`; + var r8 = document; + var u4 = () => r8.createComment(""); + var d4 = (t17) => null === t17 || "object" != typeof t17 && "function" != typeof t17; + var c5 = Array.isArray; + var v2 = (t17) => c5(t17) || "function" == typeof (null == t17 ? void 0 : t17[Symbol.iterator]); + var a4 = "[ \n\f\r]"; + var f3 = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g; + var _15 = /-->/g; + var m2 = />/g; + var p3 = RegExp(`>|${a4}(?:([^\\s"'>=/]+)(${a4}*=${a4}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`, "g"); + var g2 = /'/g; + var $2 = /"/g; + var y3 = /^(?:script|style|textarea|title)$/i; + var w2 = (t17) => (i23, ...s20) => ({ _$litType$: t17, strings: i23, values: s20 }); + var x2 = w2(1); + var b3 = w2(2); + var T2 = Symbol.for("lit-noChange"); + var A2 = Symbol.for("lit-nothing"); + var E2 = /* @__PURE__ */ new WeakMap(); + var C2 = r8.createTreeWalker(r8, 129, null, false); + function P2(t17, i23) { + if (!Array.isArray(t17) || !t17.hasOwnProperty("raw")) + throw Error("invalid template strings array"); + return void 0 !== e9 ? e9.createHTML(i23) : i23; + } + var V2 = (t17, i23) => { + const s20 = t17.length - 1, e33 = []; + let l20, r18 = 2 === i23 ? "" : "", u11 = f3; + for (let i24 = 0; i24 < s20; i24++) { + const s21 = t17[i24]; + let d11, c12, v6 = -1, a11 = 0; + for (; a11 < s21.length && (u11.lastIndex = a11, c12 = u11.exec(s21), null !== c12); ) + a11 = u11.lastIndex, u11 === f3 ? "!--" === c12[1] ? u11 = _15 : void 0 !== c12[1] ? u11 = m2 : void 0 !== c12[2] ? (y3.test(c12[2]) && (l20 = RegExp("" === c12[0] ? (u11 = null != l20 ? l20 : f3, v6 = -1) : void 0 === c12[1] ? v6 = -2 : (v6 = u11.lastIndex - c12[2].length, d11 = c12[1], u11 = void 0 === c12[3] ? p3 : '"' === c12[3] ? $2 : g2) : u11 === $2 || u11 === g2 ? u11 = p3 : u11 === _15 || u11 === m2 ? u11 = f3 : (u11 = p3, l20 = void 0); + const w6 = u11 === p3 && t17[i24 + 1].startsWith("/>") ? " " : ""; + r18 += u11 === f3 ? s21 + h4 : v6 >= 0 ? (e33.push(d11), s21.slice(0, v6) + o7 + s21.slice(v6) + n7 + w6) : s21 + n7 + (-2 === v6 ? (e33.push(void 0), i24) : w6); + } + return [P2(t17, r18 + (t17[s20] || "") + (2 === i23 ? "" : "")), e33]; + }; + var N2 = class _N { + constructor({ strings: t17, _$litType$: i23 }, e33) { + let h11; + this.parts = []; + let r18 = 0, d11 = 0; + const c12 = t17.length - 1, v6 = this.parts, [a11, f7] = V2(t17, i23); + if (this.el = _N.createElement(a11, e33), C2.currentNode = this.el.content, 2 === i23) { + const t18 = this.el.content, i24 = t18.firstChild; + i24.remove(), t18.append(...i24.childNodes); + } + for (; null !== (h11 = C2.nextNode()) && v6.length < c12; ) { + if (1 === h11.nodeType) { + if (h11.hasAttributes()) { + const t18 = []; + for (const i24 of h11.getAttributeNames()) + if (i24.endsWith(o7) || i24.startsWith(n7)) { + const s20 = f7[d11++]; + if (t18.push(i24), void 0 !== s20) { + const t19 = h11.getAttribute(s20.toLowerCase() + o7).split(n7), i25 = /([.?@])?(.*)/.exec(s20); + v6.push({ type: 1, index: r18, name: i25[2], strings: t19, ctor: "." === i25[1] ? H2 : "?" === i25[1] ? L2 : "@" === i25[1] ? z : k4 }); + } else + v6.push({ type: 6, index: r18 }); + } + for (const i24 of t18) + h11.removeAttribute(i24); + } + if (y3.test(h11.tagName)) { + const t18 = h11.textContent.split(n7), i24 = t18.length - 1; + if (i24 > 0) { + h11.textContent = s6 ? s6.emptyScript : ""; + for (let s20 = 0; s20 < i24; s20++) + h11.append(t18[s20], u4()), C2.nextNode(), v6.push({ type: 2, index: ++r18 }); + h11.append(t18[i24], u4()); + } + } + } else if (8 === h11.nodeType) + if (h11.data === l4) + v6.push({ type: 2, index: r18 }); + else { + let t18 = -1; + for (; -1 !== (t18 = h11.data.indexOf(n7, t18 + 1)); ) + v6.push({ type: 7, index: r18 }), t18 += n7.length - 1; + } + r18++; + } + } + static createElement(t17, i23) { + const s20 = r8.createElement("template"); + return s20.innerHTML = t17, s20; + } + }; + function S4(t17, i23, s20 = t17, e33) { + var o29, n31, l20, h11; + if (i23 === T2) + return i23; + let r18 = void 0 !== e33 ? null === (o29 = s20._$Co) || void 0 === o29 ? void 0 : o29[e33] : s20._$Cl; + const u11 = d4(i23) ? void 0 : i23._$litDirective$; + return (null == r18 ? void 0 : r18.constructor) !== u11 && (null === (n31 = null == r18 ? void 0 : r18._$AO) || void 0 === n31 || n31.call(r18, false), void 0 === u11 ? r18 = void 0 : (r18 = new u11(t17), r18._$AT(t17, s20, e33)), void 0 !== e33 ? (null !== (l20 = (h11 = s20)._$Co) && void 0 !== l20 ? l20 : h11._$Co = [])[e33] = r18 : s20._$Cl = r18), void 0 !== r18 && (i23 = S4(t17, r18._$AS(t17, i23.values), r18, e33)), i23; + } + var M2 = class { + constructor(t17, i23) { + this._$AV = [], this._$AN = void 0, this._$AD = t17, this._$AM = i23; + } + get parentNode() { + return this._$AM.parentNode; + } + get _$AU() { + return this._$AM._$AU; + } + u(t17) { + var i23; + const { el: { content: s20 }, parts: e33 } = this._$AD, o29 = (null !== (i23 = null == t17 ? void 0 : t17.creationScope) && void 0 !== i23 ? i23 : r8).importNode(s20, true); + C2.currentNode = o29; + let n31 = C2.nextNode(), l20 = 0, h11 = 0, u11 = e33[0]; + for (; void 0 !== u11; ) { + if (l20 === u11.index) { + let i24; + 2 === u11.type ? i24 = new R2(n31, n31.nextSibling, this, t17) : 1 === u11.type ? i24 = new u11.ctor(n31, u11.name, u11.strings, this, t17) : 6 === u11.type && (i24 = new Z2(n31, this, t17)), this._$AV.push(i24), u11 = e33[++h11]; + } + l20 !== (null == u11 ? void 0 : u11.index) && (n31 = C2.nextNode(), l20++); + } + return C2.currentNode = r8, o29; + } + v(t17) { + let i23 = 0; + for (const s20 of this._$AV) + void 0 !== s20 && (void 0 !== s20.strings ? (s20._$AI(t17, s20, i23), i23 += s20.strings.length - 2) : s20._$AI(t17[i23])), i23++; + } + }; + var R2 = class _R { + constructor(t17, i23, s20, e33) { + var o29; + this.type = 2, this._$AH = A2, this._$AN = void 0, this._$AA = t17, this._$AB = i23, this._$AM = s20, this.options = e33, this._$Cp = null === (o29 = null == e33 ? void 0 : e33.isConnected) || void 0 === o29 || o29; + } + get _$AU() { + var t17, i23; + return null !== (i23 = null === (t17 = this._$AM) || void 0 === t17 ? void 0 : t17._$AU) && void 0 !== i23 ? i23 : this._$Cp; + } + get parentNode() { + let t17 = this._$AA.parentNode; + const i23 = this._$AM; + return void 0 !== i23 && 11 === (null == t17 ? void 0 : t17.nodeType) && (t17 = i23.parentNode), t17; + } + get startNode() { + return this._$AA; + } + get endNode() { + return this._$AB; + } + _$AI(t17, i23 = this) { + t17 = S4(this, t17, i23), d4(t17) ? t17 === A2 || null == t17 || "" === t17 ? (this._$AH !== A2 && this._$AR(), this._$AH = A2) : t17 !== this._$AH && t17 !== T2 && this._(t17) : void 0 !== t17._$litType$ ? this.g(t17) : void 0 !== t17.nodeType ? this.$(t17) : v2(t17) ? this.T(t17) : this._(t17); + } + k(t17) { + return this._$AA.parentNode.insertBefore(t17, this._$AB); + } + $(t17) { + this._$AH !== t17 && (this._$AR(), this._$AH = this.k(t17)); + } + _(t17) { + this._$AH !== A2 && d4(this._$AH) ? this._$AA.nextSibling.data = t17 : this.$(r8.createTextNode(t17)), this._$AH = t17; + } + g(t17) { + var i23; + const { values: s20, _$litType$: e33 } = t17, o29 = "number" == typeof e33 ? this._$AC(t17) : (void 0 === e33.el && (e33.el = N2.createElement(P2(e33.h, e33.h[0]), this.options)), e33); + if ((null === (i23 = this._$AH) || void 0 === i23 ? void 0 : i23._$AD) === o29) + this._$AH.v(s20); + else { + const t18 = new M2(o29, this), i24 = t18.u(this.options); + t18.v(s20), this.$(i24), this._$AH = t18; + } + } + _$AC(t17) { + let i23 = E2.get(t17.strings); + return void 0 === i23 && E2.set(t17.strings, i23 = new N2(t17)), i23; + } + T(t17) { + c5(this._$AH) || (this._$AH = [], this._$AR()); + const i23 = this._$AH; + let s20, e33 = 0; + for (const o29 of t17) + e33 === i23.length ? i23.push(s20 = new _R(this.k(u4()), this.k(u4()), this, this.options)) : s20 = i23[e33], s20._$AI(o29), e33++; + e33 < i23.length && (this._$AR(s20 && s20._$AB.nextSibling, e33), i23.length = e33); + } + _$AR(t17 = this._$AA.nextSibling, i23) { + var s20; + for (null === (s20 = this._$AP) || void 0 === s20 || s20.call(this, false, true, i23); t17 && t17 !== this._$AB; ) { + const i24 = t17.nextSibling; + t17.remove(), t17 = i24; + } + } + setConnected(t17) { + var i23; + void 0 === this._$AM && (this._$Cp = t17, null === (i23 = this._$AP) || void 0 === i23 || i23.call(this, t17)); + } + }; + var k4 = class { + constructor(t17, i23, s20, e33, o29) { + this.type = 1, this._$AH = A2, this._$AN = void 0, this.element = t17, this.name = i23, this._$AM = e33, this.options = o29, s20.length > 2 || "" !== s20[0] || "" !== s20[1] ? (this._$AH = Array(s20.length - 1).fill(new String()), this.strings = s20) : this._$AH = A2; + } + get tagName() { + return this.element.tagName; + } + get _$AU() { + return this._$AM._$AU; + } + _$AI(t17, i23 = this, s20, e33) { + const o29 = this.strings; + let n31 = false; + if (void 0 === o29) + t17 = S4(this, t17, i23, 0), n31 = !d4(t17) || t17 !== this._$AH && t17 !== T2, n31 && (this._$AH = t17); + else { + const e34 = t17; + let l20, h11; + for (t17 = o29[0], l20 = 0; l20 < o29.length - 1; l20++) + h11 = S4(this, e34[s20 + l20], i23, l20), h11 === T2 && (h11 = this._$AH[l20]), n31 || (n31 = !d4(h11) || h11 !== this._$AH[l20]), h11 === A2 ? t17 = A2 : t17 !== A2 && (t17 += (null != h11 ? h11 : "") + o29[l20 + 1]), this._$AH[l20] = h11; + } + n31 && !e33 && this.j(t17); + } + j(t17) { + t17 === A2 ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, null != t17 ? t17 : ""); + } + }; + var H2 = class extends k4 { + constructor() { + super(...arguments), this.type = 3; + } + j(t17) { + this.element[this.name] = t17 === A2 ? void 0 : t17; + } + }; + var I2 = s6 ? s6.emptyScript : ""; + var L2 = class extends k4 { + constructor() { + super(...arguments), this.type = 4; + } + j(t17) { + t17 && t17 !== A2 ? this.element.setAttribute(this.name, I2) : this.element.removeAttribute(this.name); + } + }; + var z = class extends k4 { + constructor(t17, i23, s20, e33, o29) { + super(t17, i23, s20, e33, o29), this.type = 5; + } + _$AI(t17, i23 = this) { + var s20; + if ((t17 = null !== (s20 = S4(this, t17, i23, 0)) && void 0 !== s20 ? s20 : A2) === T2) + return; + const e33 = this._$AH, o29 = t17 === A2 && e33 !== A2 || t17.capture !== e33.capture || t17.once !== e33.once || t17.passive !== e33.passive, n31 = t17 !== A2 && (e33 === A2 || o29); + o29 && this.element.removeEventListener(this.name, this, e33), n31 && this.element.addEventListener(this.name, this, t17), this._$AH = t17; + } + handleEvent(t17) { + var i23, s20; + "function" == typeof this._$AH ? this._$AH.call(null !== (s20 = null === (i23 = this.options) || void 0 === i23 ? void 0 : i23.host) && void 0 !== s20 ? s20 : this.element, t17) : this._$AH.handleEvent(t17); + } + }; + var Z2 = class { + constructor(t17, i23, s20) { + this.element = t17, this.type = 6, this._$AN = void 0, this._$AM = i23, this.options = s20; + } + get _$AU() { + return this._$AM._$AU; + } + _$AI(t17) { + S4(this, t17); + } + }; + var B = i7.litHtmlPolyfillSupport; + null == B || B(N2, R2), (null !== (t6 = i7.litHtmlVersions) && void 0 !== t6 ? t6 : i7.litHtmlVersions = []).push("2.8.0"); + var D = (t17, i23, s20) => { + var e33, o29; + const n31 = null !== (e33 = null == s20 ? void 0 : s20.renderBefore) && void 0 !== e33 ? e33 : i23; + let l20 = n31._$litPart$; + if (void 0 === l20) { + const t18 = null !== (o29 = null == s20 ? void 0 : s20.renderBefore) && void 0 !== o29 ? o29 : null; + n31._$litPart$ = l20 = new R2(i23.insertBefore(u4(), t18), t18, void 0, null != s20 ? s20 : {}); + } + return l20._$AI(t17), l20; + }; + + // node_modules/@material/mwc-icon/node_modules/lit-element/lit-element.js + var l5; + var o8; + var s7 = class extends u3 { + constructor() { + super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0; + } + createRenderRoot() { + var t17, e33; + const i23 = super.createRenderRoot(); + return null !== (t17 = (e33 = this.renderOptions).renderBefore) && void 0 !== t17 || (e33.renderBefore = i23.firstChild), i23; + } + update(t17) { + const i23 = this.render(); + this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t17), this._$Do = D(i23, this.renderRoot, this.renderOptions); + } + connectedCallback() { + var t17; + super.connectedCallback(), null === (t17 = this._$Do) || void 0 === t17 || t17.setConnected(true); + } + disconnectedCallback() { + var t17; + super.disconnectedCallback(), null === (t17 = this._$Do) || void 0 === t17 || t17.setConnected(false); + } + render() { + return T2; + } + }; + s7.finalized = true, s7._$litElement$ = true, null === (l5 = globalThis.litElementHydrateSupport) || void 0 === l5 || l5.call(globalThis, { LitElement: s7 }); + var n8 = globalThis.litElementPolyfillSupport; + null == n8 || n8({ LitElement: s7 }); + (null !== (o8 = globalThis.litElementVersions) && void 0 !== o8 ? o8 : globalThis.litElementVersions = []).push("3.3.3"); + + // node_modules/@material/mwc-icon/node_modules/@lit/reactive-element/decorators/custom-element.js + var e10 = (e33) => (n31) => "function" == typeof n31 ? ((e34, n32) => (customElements.define(e34, n32), n32))(e33, n31) : ((e34, n32) => { + const { kind: t17, elements: s20 } = n32; + return { kind: t17, elements: s20, finisher(n33) { + customElements.define(e34, n33); + } }; + })(e33, n31); + + // node_modules/@material/mwc-icon/node_modules/@lit/reactive-element/decorators/query-assigned-elements.js + var n10; + var e11 = null != (null === (n10 = window.HTMLSlotElement) || void 0 === n10 ? void 0 : n10.prototype.assignedElements) ? (o29, n31) => o29.assignedElements(n31) : (o29, n31) => o29.assignedNodes(n31).filter((o30) => o30.nodeType === Node.ELEMENT_NODE); + + // node_modules/@material/mwc-icon/mwc-icon-host.css.js + var styles7 = i6`:host{font-family:var(--mdc-icon-font, "Material Icons");font-weight:normal;font-style:normal;font-size:var(--mdc-icon-size, 24px);line-height:1;letter-spacing:normal;text-transform:none;display:inline-block;white-space:nowrap;word-wrap:normal;direction:ltr;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;-moz-osx-font-smoothing:grayscale;font-feature-settings:"liga"}`; + + // node_modules/@material/mwc-icon/mwc-icon.js + var Icon = class Icon2 extends s7 { + /** @soyTemplate */ + render() { + return x2``; + } + }; + Icon.styles = [styles7]; + Icon = __decorate([ + e10("mwc-icon") + ], Icon); + + // node_modules/lit-html/directives/style-map.js + var n11 = "important"; + var i8 = " !" + n11; + var o10 = e5(class extends i5 { + constructor(t17) { + if (super(t17), t17.type !== t4.ATTRIBUTE || "style" !== t17.name || t17.strings?.length > 2) + throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute."); + } + render(t17) { + return Object.keys(t17).reduce((e33, r18) => { + const s20 = t17[r18]; + return null == s20 ? e33 : e33 + `${r18 = r18.includes("-") ? r18 : r18.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g, "-$&").toLowerCase()}:${s20};`; + }, ""); + } + update(e33, [r18]) { + const { style: s20 } = e33.element; + if (void 0 === this.ft) + return this.ft = new Set(Object.keys(r18)), this.render(r18); + for (const t17 of this.ft) + null == r18[t17] && (this.ft.delete(t17), t17.includes("-") ? s20.removeProperty(t17) : s20[t17] = null); + for (const t17 in r18) { + const e34 = r18[t17]; + if (null != e34) { + this.ft.add(t17); + const r19 = "string" == typeof e34 && e34.endsWith(i8); + t17.includes("-") || r19 ? s20.setProperty(t17, r19 ? e34.slice(0, -11) : e34, r19 ? n11 : "") : s20[t17] = e34; + } + } + return w; + } + }); + + // client/components/example_table.css + var styles8 = i`thead { + height: 50px; + position: sticky; + top: 0; + z-index: 1; +} + +thead.search-box-shown { + height: 68px; +} + +th { + background-color: var(--comparator-greyblue-300); + color: white; + font-weight: normal; + line-height: 17px; + overflow: hidden; + padding: 8px 6px 2px 6px; + position: relative; + vertical-align: top; +} + +td { + border-bottom: 1px solid #ddd; + border-right: 1px solid var(--comparator-grey-200); + /* LINT.IfChange */ + line-height: 1.4em; + /* LINT.ThenChange(../lib/constants.ts) */ + padding: 8px 4px 2px 12px; + vertical-align: top; +} + +tr.selected td { + background-color: var(--comparator-green-100); +} + +/* Header row */ +th.example-index { + min-width: 25px; + width: 25px; +} + +th.input-text { + min-width: 300px; + width: 30%; +} + +th.output-text { + min-width: 300px; + overflow-x: hidden; + width: 35%; +} + +tr.one-text-column-hidden th.input-text, +tr.one-text-column-hidden th.output-text, +tr.one-text-column-hidden th.custom-text { + width: 50%; +} + +tr.two-text-columns-hidden th.input-text, +tr.two-text-columns-hidden th.output-text { + width: 100%; +} + +th.output-a { + background-color: var(--comparator-model-a); +} + +th.output-b { + background-color: var(--comparator-model-b); +} + +th.tags { + min-width: 60px; + width: 70px; +} + +th.score { + min-width: 70px; + padding-left: 2px; + padding-right: 10px; + width: 70px; +} + +th.rationales { + min-width: 250px; + width: 30%; +} + +th.rationale-list { + min-width: 200px; + width: 20%; +} + +th.custom-number { + min-width: 20px; + width: 50px; +} + +th.custom-string, +th.custom-category, +th.custom-url { + min-width: 100px; +} + +th.custom-text { + min-width: 250px; + width: 30%; +} + +th.custom-image { + width: 200px; +} + +th .custom-field-name { + max-width: 100px; +} + +th.custom-number .custom-field-name { + max-width: 50px; +} + +th.custom-per-model .custom-field-name { + max-width: 120px; +} + +th.custom-per-model-boolean { + min-width: 50px; +} + +th.custom-per-model-number { + min-width: 60px; +} + +th.custom-per-model-category { + min-width: 160px; +} + +th.custom-per-rating-string { + min-width: 100px; +} + +th.custom-per-rating-per-model-category { + min-width: 135px; +} + +tr.header-row th.custom-per-model { + height: auto; +} + +tr.second-row th { + height: 20px; + padding-top: 0; +} + +tr.second-row .sort-icons-container { + top: 1px; +} + +/* Change padding when holder exists */ +td.input-text, +td.output-text, +td.rationales, +td.custom-string, +td.custom-category, +td.custom-text, +td.custom-url, +td.custom-image, +td.custom-per-model-category, +td.custom-per-model-text, +td.custom-per-rating-string, +td.custom-per-rating-per-model-category { + padding: 0 0 0 12px; + position: relative; +} + +/* for list-holder */ +td.rationale-list { + padding: 0 0 0 8px; +} + +td.tags { + overflow-x: hidden; + word-break: break-word; +} + +td.score { + padding-left: 4px; + text-align: center; +} + +td.score.a-win { + background-color: var(--comparator-model-a-win-bg); +} + +td.score.b-win { + background-color: var(--comparator-model-b-win-bg); +} + +.score-number { + font-size: 14px; +} + +.score-description { + background-color: var(--comparator-grey-450); + border-radius: 5px; + color: white; + display: inline-block; + font-size: 11px; + margin: 2px 0; + opacity: 0.8; + padding: 0 3px; +} + +.rater-info-link { + color: var(--comparator-grey-600); + font-size: 11px; + padding: 4px 0; + text-decoration: underline; +} + +.selected .rater-info-link { + color: var(--comparator-grey-800); + font-weight: 600; +} + +td.score:hover .rater-info-link { + color: var(--comparator-grey-800); +} + +ul.rationale-list { + line-height: 1.3em; + padding-left: 15px; +} + +ul.rationale-list li { + border-radius: 5px; + margin: 0 2px 4px; + position: relative; +} + +/* for applying background-color also to the areas for the bulleted points */ +ul.rationale-list li::before { + border-radius: 5px; + content: ''; + height: 100%; + left: -16px; + position: absolute; + top: 0; + width: 35px; + z-index: -1; +} + +ul.rationale-list li.cluster-selected { + background-color: var(--comparator-greygreen-100); + color: #000; +} + +ul.rationale-list li:hover, +ul.rationale-list li:hover::before, +ul.rationale-list li.cluster-selected::before { + background-color: var(--comparator-greygreen-200); +} + +.text-holder, +.list-holder, +.sequence-chunks-holder, +.score-holder { + height: 119px; /* Set default as 17px x 7 rows */ + overflow-x: hidden; + overflow-y: scroll; + padding-top: 8px; +} + +.text-holder { + overflow-wrap: anywhere; + white-space: break-spaces; +} + +.custom-per-model-text +.text-holder { + width: 240px; +} + +.sequence-chunks-holder { + overflow-wrap: anywhere; +} + +.score-holder { + overflow-y: hidden; + padding-top: 0; +} + +tr.monospace .text-holder { + font-family: monospace; +} + +.text-chunk { + white-space: break-spaces; +} + +.highlighted-match { + color: var(--comparator-green-500); +} + +.highlighted-search-match { + background-color: var(--comparator-search-match-background); + color: var(--comparator-search-match-foreground); + font-weight: 600; +} + +/* For tag chips */ +.input-text { + overflow-x: hidden; +} + +.input-text .text-holder:after, +.input-text .sequence-chunks-holder:after { + content: ""; + display: block; + height: 28px; +} + +td .tag-chips { + bottom: 0; + display: flex; + margin: 3px 20px 3px 0; + padding-left: 0; + position: absolute; +} + +td .tag-chips .tag-chip { + background-color: var(--comparator-custom-func-200); + border: 1px solid var(--comparator-custom-func-500); + border-radius: 15px; + color: var(--comparator-custom-func-800); + list-style: none; + margin-right: 2px; + padding: 1px 10px; + white-space: nowrap; +} + +/* For custom function chips */ +.output-text .text-holder:after { + content: ""; + display: block; + height: 28px; +} + +td .custom-func-result-chip { + background-color: var(--comparator-custom-func-200); + border: 1px solid var(--comparator-custom-func-500); + bottom: 0; + border-radius: 15px; + color: var(--comparator-custom-func-800); + margin: 3px 20px 3px 0; + padding: 1px 15px; + position: absolute; +} + +td .custom-func-result-chip.greyscale { + background-color: var(--comparator-grey-100); + border: 1px solid var(--comparator-grey-200); + color: #aaa; +} + +/* Custom fields */ +td.custom-number { + text-align: right; +} + +td.custom-string, +td.custom-category { + word-break: break-word; +} + +td.custom-url { + word-break: break-all; +} + +/* Per-model fields */ +table.per-model-data { + width: 100%; +} + +table.per-model-data td { + min-width: 25px; + padding: 6px 4px; + width: 50%; +} + +td.custom-per-model-category td { + min-width: 50px; +} + +td.custom-per-model-first { + border-left: 1px solid var(--comparator-grey-300); +} + +td.custom-per-model-last { + border-right: 1px solid var(--comparator-grey-300); +} + +.chart-holder { + height: 119px; /* Set default as 17px x 7 rows */ + overflow-wrap: anywhere; + overflow-y: auto; + padding-top: 8px; +} + +/* Set scrollbar as optional */ +td.custom-string .text-holder, +td.custom-category .text-holder, +td.custom-url .text-holder, +td.custom-per-model-category .text-holder, +td.custom-per-model-text .text-holder { + overflow-y: auto; +} + +td.custom-image img { + max-height: 110px; + max-width: 180px; +} + +/* Sort icons */ +.sort-icons-container { + background-color: var(--comparator-greyblue-300); +} + +th.output-a .sort-icons-container { + background-color: var(--comparator-model-a); +} + +th.output-b .sort-icons-container { + background-color: var(--comparator-model-b); +} + +/* Search */ +.search-icon-container { + right: 14px; + position: absolute; + top: 10px; +} + +.search-icon-container .sort-icon { + font-size: 16px; +} + +th .search-field { + bottom: 3px; + display: flex; + font-size: 11px; + gap: 2px; + left: 5%; + position: absolute; + width: 90%; +} + +th .search-field input { + background: rgba(255, 255, 255, 0.5); + border: 0; + padding: 3px 5px; + width: 100%; +} + +th .search-field button { + border: 0; + color: var(--comparator-grey-500); +} + +/* Show more */ +.display-more-button { + background-color: var(--comparator-grey-100); + border: 0; + font-size: 13px; + margin: 10px 0; + text-align: center; + padding: 10px 0; + width: 100%; +} + +.display-more-button:hover { + background-color: var(--comparator-greygreen-100); +} +`; + + // client/components/example_table.ts + var ExampleTableElement = class extends MobxLitElement { + constructor() { + super(); + this.appState = core.getService(AppState); + this.showSearchBoxes = false; + makeObservable(this); + } + static get styles() { + return [styles, styles8]; + } + styleCustomField(field, modelIndex = null) { + return e6({ + "custom-number": field.type === "number" /* NUMBER */, + "custom-string": field.type === "string" /* STRING */, + "custom-category": field.type === "category" /* CATEGORY */, + "custom-text": field.type === "text" /* TEXT */, + "custom-url": field.type === "url" /* URL */, + "custom-image": field.type === "image_path" /* IMAGE_PATH */ || field.type === "image_byte" /* IMAGE_BYTE */, + "custom-per-model": isPerModelFieldType(field) === true, + "custom-per-model-boolean": field.type === "per_model_boolean" /* PER_MODEL_BOOLEAN */, + "custom-per-model-number": field.type === "per_model_number" /* PER_MODEL_NUMBER */, + "custom-per-model-category": field.type === "per_model_category" /* PER_MODEL_CATEGORY */, + "custom-per-model-text": field.type === "per_model_text" /* PER_MODEL_TEXT */, + "custom-per-model-first": modelIndex === 0, + "custom-per-model-last": modelIndex === this.appState.models.length - 1, + "custom-per-rating-string": field.type === "per_rating_string" /* PER_RATING_STRING */, + "custom-per-rating-per-model-category": field.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */ + }); + } + renderCustomFuncResultChip(value, customFunc) { + const customFuncResultChipStyle = e6({ + "custom-func-result-chip": true, + "greyscale": customFunc.returnType === "Boolean" /* BOOLEAN */ && value !== true + }); + return x`
    + ${customFunc.name}: + ${printCustomFuncResultValue(value)} +
    `; + } + styleHolder(exampleIndex) { + return o10({ + "height": this.appState.getIsExampleExpanded(exampleIndex) !== true ? `${this.appState.numberOfLinesPerOutputCell * LINE_HEIGHT_IN_CELL}px` : "auto", + "min-height": this.appState.getIsExampleExpanded(exampleIndex) === true ? `${this.appState.numberOfLinesPerOutputCell * LINE_HEIGHT_IN_CELL}px` : null + }); + } + renderPerModelField(values, field, exampleIndex) { + if (values.length !== 2) { + throw new Error("Per-model fields must have exactly 2 values."); + } else { + const cells = values.map((value, modelIndex) => { + const renderValue = () => { + if (field.type === "per_model_number" /* PER_MODEL_NUMBER */ || field.type === "per_model_boolean" /* PER_MODEL_BOOLEAN */ || field.type === "per_model_category" /* PER_MODEL_CATEGORY */) { + if (typeof value === "number") { + return toFixedIfNeeded(value); + } else { + return value; + } + } else { + const styleHolder = this.styleHolder(exampleIndex); + return x`
    ${value}
    `; + } + }; + return x` + ${renderValue()} + `; + }); + return x`${cells}`; + } + } + // Per-rating per-model-category case. + // (e.g., Quality: [['Awesome' (A), 'Bad' (B)] (Rater #0), ...]). + // We use rowIndex and columnIndex instead of example and field, to ensure + // the charts get updated when state variables get updated. + renderPerRatingPerModelCategoryField(rowIndex, columnIndex) { + const getValueDomain = () => { + const field = this.appState.visibleColumns[columnIndex]; + return this.appState.valueDomainsForCustomFields[field.id]; + }; + const getBarChartData = () => { + if (rowIndex >= this.appState.examplesForMainTable.length) { + return []; + } else { + const ex = this.appState.examplesForMainTable[rowIndex]; + const field = this.appState.visibleColumns[columnIndex]; + return [ + ex.individual_rater_scores.map( + (rating) => rating.custom_fields[field.id][0] + ), + ex.individual_rater_scores.map( + (rating) => rating.custom_fields[field.id][1] + ) + ]; + } + }; + const isAnyBarSelected = (groupIndex) => { + const field = this.appState.visibleColumns[columnIndex]; + return this.appState.selectedBarChartValueForSelectedExample != null && this.appState.selectedBarChartValueForSelectedExample.fieldId === field.id && this.appState.selectedBarChartValueForSelectedExample.modelIndex === groupIndex; + }; + const isThisBarSelected = (value, groupIndex) => { + const field = this.appState.visibleColumns[columnIndex]; + return this.appState.selectedBarChartValueForSelectedExample != null && this.appState.selectedBarChartValueForSelectedExample.fieldId === field.id && this.appState.selectedBarChartValueForSelectedExample.modelIndex === groupIndex && this.appState.selectedBarChartValueForSelectedExample.value === value; + }; + const handleClickBar = (value, groupIndex) => { + const field = this.appState.visibleColumns[columnIndex]; + const currentSelection = this.appState.selectedBarChartValueForSelectedExample; + if (currentSelection != null && currentSelection.fieldId === field.id && currentSelection.modelIndex === groupIndex && currentSelection.value === value) { + this.appState.selectedBarChartValueForSelectedExample = null; + } else { + this.appState.selectedExample = this.appState.examplesForMainTable[rowIndex]; + this.appState.showSelectedExampleDetails = true; + this.appState.selectedBarChartValueForSelectedExample = { + fieldId: field.id, + modelIndex: groupIndex, + value + }; + } + }; + const getHighlightedValues = () => { + const field = this.appState.visibleColumns[columnIndex]; + return this.appState.selectedBarChartValues[field.id].filter( + (value) => value != null + ); + }; + return x` +
    + + +
    + `; + } + renderRow(example, rowIndex) { + const handleDoubleClickRow = () => { + this.appState.isExampleExpanded[example.index] = this.appState.getIsExampleExpanded(example.index) === true ? false : true; + }; + const styleRow = e6({ + "selected": this.appState.selectedExample === example, + "monospace": this.appState.useMonospace === true + }); + const styleHolder = this.styleHolder(example.index); + const textDiff = typeof example.output_text_a === "string" && typeof example.output_text_b === "string" ? getTextDiff(example.output_text_a, example.output_text_b) : getTextDiff("", ""); + const renderTextString = (rawText, parsedText, searchQuery, selectedCustomFunc2) => { + if (searchQuery !== "") { + return renderSearchedString(rawText, searchQuery); + } else if (selectedCustomFunc2 != null && selectedCustomFunc2.functionType === "Regular Expr." /* REGEXP */) { + return renderSearchedString( + rawText, + selectedCustomFunc2.functionBody, + false + ); + } else if (parsedText != null && this.appState.isShowTextDiff === true) { + return renderDiffString(parsedText, textDiff.isEquals); + } else { + return rawText; + } + }; + const renderText = (rawText, parsedText, fieldId) => { + const searchQuery = this.appState.searchFilters[fieldId]; + if (typeof rawText === "string") { + const selectedCustomFunc2 = fieldId === FIELD_ID_FOR_OUTPUT_A || fieldId === FIELD_ID_FOR_OUTPUT_B ? this.appState.selectedCustomFunc : null; + return x`
    ${renderTextString( + rawText, + parsedText, + searchQuery, + selectedCustomFunc2 + )}
    `; + } else { + return x`
    + ${rawText.map( + (chunk) => chunk.type === "text" /* TEXT */ ? x`
    ${searchQuery !== "" ? renderSearchedString(chunk.data, searchQuery) : chunk.data}
    ` : x`
    + +
    ` + )} +
    `; + } + }; + const renderTag = (tag) => x`
  • ${tag}
  • `; + const renderTags = example.tags.length === 0 ? "" : example.tags.length === 1 ? example.tags[0] : x`
      ${example.tags.map((tag) => renderTag(tag))}
    `; + const handleClickRaterDetails = () => { + if (this.appState.selectedExample === example && this.appState.showSelectedExampleDetails === true) { + this.appState.selectedExample = null; + this.appState.showSelectedExampleDetails = false; + } else { + this.appState.selectedExample = example; + this.appState.showSelectedExampleDetails = true; + } + }; + const isABetter = this.appState.isWinnerFromScore("A", example.score); + const isBBetter = this.appState.isWinnerFromScore("B", example.score); + const isAAndBSame = example.score != null && example.score === this.appState.scoreMiddlePoint; + const getHistogramRawDataValues = () => { + if (rowIndex >= this.appState.examplesForMainTable.length) { + return []; + } else { + return this.appState.examplesForMainTable[rowIndex].individual_rater_scores.filter((rating) => rating.score != null).map((rating) => rating.score); + } + }; + const renderHistogram = x` this.appState.histogramSpecForScores} + .getRawDataValues=${getHistogramRawDataValues} + .svgWidth=${40} + .svgHeight=${35} + .showBottomAxis=${false} + .neutralColorThreshold=${() => this.appState.winRateThreshold} + .isSimplified=${true} + .isFlipXAxis=${() => this.appState.isFlipScoreHistogramAxis}> + `; + const scoreDescription = this.appState.isScoreDivergingScheme === true ? isABetter === true ? x`
    A is better
    ` : isBBetter === true ? x`
    B is better
    ` : isAAndBSame === true ? x`
    same
    ` : x`
    similar
    ` : ""; + const raterInfoLink = example.individual_rater_scores.length > 0 ? x` + ${renderHistogram}` : ""; + const renderScore = example.score == null ? "Null" : x` +
    +
    ${example.score.toFixed(2)}
    + ${scoreDescription} + ${raterInfoLink} +
    `; + const styleScore = e6({ + "score": true, + "clickable": true, + "a-win": this.appState.isScoreDivergingScheme === true && isABetter === true, + "b-win": this.appState.isScoreDivergingScheme === true && isBBetter === true + }); + const styleRationaleItem = (rationaleItem) => ( + // Check if there is a selected or hovered cluster from the sidebar. + e6({ + "cluster-selected": rationaleItem.assignedClusterIds != null && (this.appState.selectedRationaleClusterId != null && rationaleItem.assignedClusterIds.includes( + this.appState.selectedRationaleClusterId + ) || this.appState.hoveredRationaleClusterId != null && rationaleItem.assignedClusterIds.includes( + this.appState.hoveredRationaleClusterId + )) + }) + ); + const handleMouseenterRationaleItem = (rationaleItem) => { + this.appState.matchedRationaleClusterIds = rationaleItem.assignedClusterIds || []; + }; + const handleMouseleaveRationaleItem = () => { + this.appState.matchedRationaleClusterIds = []; + }; + const searchQueryForRationaleList = this.appState.searchFilters[FIELD_ID_FOR_RATIONALE_LIST]; + const renderRationaleList = example.rationale_list != null && (isABetter === true || isBBetter === true) ? x` +
    +
      + ${example.rationale_list.map( + (item) => x` +
    • void handleMouseenterRationaleItem(item)} + @mouseleave=${handleMouseleaveRationaleItem}> + ${searchQueryForRationaleList == null ? item.rationale : renderSearchedString( + item.rationale, + searchQueryForRationaleList + )} +
    • ` + )} +
    +
    ` : ""; + const renderTagChips = this.appState.isShowTagChips === true && example.tags.length > 0 ? x`
      ${example.tags.map( + (tag) => x`
    • ${tag}
    • ` + )}
    ` : x``; + const selectedCustomFunc = this.appState.selectedCustomFunc; + const renderCustomFuncResultChip = (modelIndex) => selectedCustomFunc != null ? this.renderCustomFuncResultChip( + (example.custom_fields[getFieldIdForCustomFunc( + selectedCustomFunc.id + )] || Array)[modelIndex], + selectedCustomFunc + ) : x``; + const renderCustomField = (field, columnIndex) => { + if (field.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */) { + return this.renderPerRatingPerModelCategoryField(rowIndex, columnIndex); + } else if (!(isPerModelFieldType(field) === true)) { + let content = x``; + if (example.custom_fields[field.id] == null) { + content = x``; + } else if (field.type === "number" /* NUMBER */) { + content = x` + ${toFixedIfNeeded(example.custom_fields[field.id])}`; + } else if (field.type === "string" /* STRING */ || field.type === "category" /* CATEGORY */) { + content = x` +
    ${example.custom_fields[field.id]}
    `; + } else if (field.type === "text" /* TEXT */) { + content = x`${renderText( + example.custom_fields[field.id], + null, + field.id + )}`; + } else if (field.type === "url" /* URL */) { + content = x` + `; + } else if (field.type === "image_path" /* IMAGE_PATH */) { + content = x` +
    `; + } else if (field.type === "image_byte" /* IMAGE_BYTE */) { + content = x` +
    `; + } else if (field.type === "per_rating_string" /* PER_RATING_STRING */) { + content = x` +
    ${example.individual_rater_scores.map( + (rating) => rating.custom_fields[field.id] + ).join("\n")}
    `; + } + return x`${content}`; + } else { + const values = example.custom_fields[field.id]; + return this.renderPerModelField(values, field, example.index); + } + }; + const rationalesText = example.individual_rater_scores.map((rating) => rating.rationale).join("\n__________\n\n"); + const columns = this.appState.visibleColumns; + const renderRow = columns.map((field, columnIndex) => { + if (field.id === FIELD_ID_FOR_INDEX) { + return x` ${example.index}`; + } else if (field.id === FIELD_ID_FOR_INPUT) { + return x` + ${renderText(example.input_text, null, field.id)} ${renderTagChips} + `; + } else if (field.id === FIELD_ID_FOR_OUTPUT_A) { + return x` + ${renderText(example.output_text_a, textDiff.parsedA, field.id)} + ${renderCustomFuncResultChip(0)} + `; + } else if (field.id === FIELD_ID_FOR_OUTPUT_B) { + return x` + ${renderText(example.output_text_b, textDiff.parsedB, field.id)} + ${renderCustomFuncResultChip(1)} + `; + } else if (field.id === FIELD_ID_FOR_TAGS) { + return x` ${renderTags} `; + } else if (field.id === FIELD_ID_FOR_SCORE) { + return x` 0 ? "Click to see individual ratings" : ""}> + ${renderScore} + `; + } else if (field.id === FIELD_ID_FOR_RATIONALES) { + return x` + ${renderText(rationalesText, null, field.id)} + `; + } else if (field.id === FIELD_ID_FOR_RATIONALE_LIST) { + return x` ${renderRationaleList} `; + } else { + return renderCustomField(field, columnIndex); + } + }); + return x` + ${renderRow} + `; + } + renderHeaderRow() { + const styleTextColumn = this.appState.numberOfShownTextColumns !== 3 ? o10({ + "width": `${(100 / this.appState.numberOfShownTextColumns).toFixed( + 1 + )}%` + }) : o10({}); + const handleClickSortIcon = (sorting) => { + const currentSorting2 = this.appState.currentSorting; + if (isEqualSorting(currentSorting2, sorting)) { + this.appState.resetSorting(); + } else { + this.appState.updateSorting(sorting); + } + }; + const currentSorting = this.appState.currentSorting; + const styleSortIcons = (sorting) => e6({ + "sort-icon": true, + "up": sorting.order === "asc" /* ASC */, + "down": sorting.order === "desc" /* DESC */, + "active": isEqualSorting(currentSorting, sorting) + }); + const isRenderSortIconsForFuncs = this.appState.selectedCustomFunc != null && this.appState.selectedCustomFunc.returnType === "Number" /* NUMBER */; + const renderSortIcons = (column, customField = null, modelIndex = null) => { + const sortingCriteria = (order) => ({ column, customField, modelIndex, order }); + return x`
    + void handleClickSortIcon(sortingCriteria("asc" /* ASC */))}> + arrow_drop_up + + void handleClickSortIcon(sortingCriteria("desc" /* DESC */))}> + arrow_drop_down + +
    `; + }; + const renderSearchIcon = x`
    + this.showSearchBoxes = !this.showSearchBoxes}> + search + +
    `; + const renderSearchInput = (fieldId) => { + const handleApplySearchFilter = () => { + this.appState.searchFilters[fieldId] = this.appState.searchFilterInputs[fieldId]; + }; + const handleChangeSearchFieldText = (e33) => { + this.appState.searchFilterInputs[fieldId] = e33.target.value; + if (this.appState.searchFilterInputs[fieldId].length === 0) { + handleApplySearchFilter(); + } + }; + return this.showSearchBoxes === true ? x`
    + + +
    ` : ""; + }; + const columns = this.appState.visibleColumns; + const firstRow = columns.filter((field) => field.visible === true).map((field) => { + if (field.id === FIELD_ID_FOR_INDEX) { + return x` #`; + } else if (field.id === FIELD_ID_FOR_INPUT) { + return x` + ${field.name} + ${renderSearchIcon} + ${renderSearchInput(FIELD_ID_FOR_INPUT)} + `; + } else if (field.id === FIELD_ID_FOR_OUTPUT_A) { + return x` + ${field.name} + ${renderSearchIcon} +
    (${this.appState.models[0].name}) + ${isRenderSortIconsForFuncs === true ? renderSortIcons("value from selected Custom Function for Output A" /* FUNC_A */) : ""} + ${renderSearchInput(FIELD_ID_FOR_OUTPUT_A)} + `; + } else if (field.id === FIELD_ID_FOR_OUTPUT_B) { + return x` + ${field.name} + ${renderSearchIcon} +
    (${this.appState.models[1].name}) + ${isRenderSortIconsForFuncs === true ? renderSortIcons("value from selected Custom Function for Output B" /* FUNC_B */) : ""} + ${renderSearchInput(FIELD_ID_FOR_OUTPUT_B)} + `; + } else if (field.id === FIELD_ID_FOR_TAGS) { + return x` + ${field.name} ${renderSortIcons("tags" /* TAGS */)} + `; + } else if (field.id === FIELD_ID_FOR_SCORE) { + return x` + ${field.name} ${renderSortIcons("score" /* SCORE */)} + `; + } else if (field.id === FIELD_ID_FOR_RATIONALES) { + return x` + ${field.name} +
    (Be careful! A and B might be flipped.) + ${renderSearchIcon} + ${renderSearchInput(FIELD_ID_FOR_RATIONALES)} + `; + } else if (field.id === FIELD_ID_FOR_RATIONALE_LIST) { + return x` + + ${field.name} + ${renderSearchIcon} + ${renderSearchInput(FIELD_ID_FOR_RATIONALE_LIST)} + `; + } else if (isPerModelFieldType(field) === true) { + return x` +
    + ${field.name} +
    + `; + } else if (field.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */) { + return x` +
    + ${field.name} +
    + `; + } else { + const sortIcons = field.type === "image_path" /* IMAGE_PATH */ || field.type === "image_byte" /* IMAGE_BYTE */ || field.type === "text" /* TEXT */ ? "" : renderSortIcons("custom attribute" /* CUSTOM_ATTRIBUTE */, field); + const searchIconAndInput = field.type === "text" /* TEXT */ ? x` + ${renderSearchIcon} + ${renderSearchInput(field.id)}` : ""; + return x` +
    + ${field.name} +
    + ${sortIcons} + ${searchIconAndInput} + `; + } + }); + const secondRow = columns.filter((field) => field.visible === true).filter((field) => isPerModelFieldType(field) === true).map( + (field) => x` + A + ${renderSortIcons("custom attribute" /* CUSTOM_ATTRIBUTE */, field, 0)} + + + B + ${renderSortIcons("custom attribute" /* CUSTOM_ATTRIBUTE */, field, 1)} + ` + ); + return x` ${firstRow} + ${secondRow}`; + } + // Render button for displaying 50 more examples. + renderDisplayMoreButton() { + const numFilteredExamples = this.appState.filteredExamples.length; + const numExamplesToShowMore = Math.min( + DEFAULT_NUM_EXAMPLES_TO_DISPLAY, + numFilteredExamples - this.appState.numExamplesToDisplay + ); + const handleClickMoreExamples = () => { + this.appState.numExamplesToDisplay += numExamplesToShowMore; + }; + return x` +
    + ${numFilteredExamples > this.appState.numExamplesToDisplay ? x` + ` : ""} +
    `; + } + render() { + const styleHeader = e6({ + "search-box-shown": this.showSearchBoxes + }); + try { + const renderRows = this.appState.examplesForMainTable.map( + (example, rowIndex) => this.renderRow(example, rowIndex) + ); + return x` + + + ${this.renderHeaderRow()} + + + ${renderRows} + +
    + ${this.renderDisplayMoreButton()} + `; + } catch (error) { + console.error(error); + this.appState.updateStatusMessage( + "Encountered an error while displaying the table." + ); + return; + } + } + }; + __decorateClass([ + observable + ], ExampleTableElement.prototype, "showSearchBoxes", 2); + ExampleTableElement = __decorateClass([ + t3("comparator-example-table") + ], ExampleTableElement); + + // client/components/metrics_by_slice.css + var styles9 = i`thead { + position: sticky; + top: 0; +} + +th.score-avg { + width: 98px; /* width sum for score-avg-number and score-avg-chart */ +} + +td.tag-and-count { + align-items: center; + display: flex; + white-space: nowrap; +} + +td.tag-and-count .tag { + overflow-x: hidden; + text-overflow: ellipsis; +} + +small { + color: var(--comparator-grey-300); + font-size: 9px; + min-width: 15px; + padding-left: 2px; +} + +.number, +small .number { + color: var(--comparator-grey-500); + font-family: Roboto; + font-size: 11px; +} + +.number span { + border-radius: 2px; + padding: 0 1px; +} + +.score-avg-container, +.win-rate-container { + align-items: center; + display: flex; + gap: 2px; + justify-content: center; +} + +.score-avg-container .number, +.win-rate-container .number { + text-align: right; + width: 36px; +} + +.score-avg-chart { + font-size: 0; + width: 62px; /* distributionAreaWidth + 2px padding */ +} + +svg { + background-color: var(--comparator-grey-100); +} + +.win-rate-chart { + font-family: Roboto; + width: 62px; /* barAreaWidth + 2px padding */ +} + +td.score-avg, +td.win-rate-percentage { + text-align: right; +} + +.win-rate-chart svg { + display: block; +} + +.win-rate-chart text { + fill: var(--comparator-grey-100); + font-size: 11px; +} + +.win-rate-vertical { + fill: none; + stroke: var(--comparator-grey-600); + stroke-width: 2; +} + +.win-rate-point { + fill: var(--comparator-grey-600); + stroke-width: 0; +} + +.win-rate-confidence-interval { + fill: none; + stroke: var(--comparator-grey-600); + stroke-width: 1; +} + +rect.bar { + fill-opacity: 0.75; +} + +tr.selected rect.bar { + fill-opacity: 1.0; +} + +rect.bar.win-rate-result-a { + fill: var(--comparator-model-a-win); +} + +rect.bar.win-rate-result-b { + fill: var(--comparator-model-b-win); +} + +rect.bar.win-rate-result-tie { + fill: var(--comparator-grey-400); +} + +.collapsed .table-container { + max-height: 220px; + overflow-y: scroll; +} + +line.middle-point-vertical { + fill: none; + stroke: var(--comparator-grey-300); + stroke-width: 1; +} + +line.error-bar { + fill: none; + stroke: var(--comparator-grey-600); + stroke-width: 1; +} + +line.error-bar.a-win-color, +line.win-rate-confidence-interval.a-win-color { + fill: none; + stroke: var(--comparator-model-a-win); +} + +line.error-bar.b-win-color, +line.win-rate-confidence-interval.b-win-color { + fill: none; + stroke: var(--comparator-model-b-win); +} + +circle { + fill: var(--comparator-grey-600); + stroke-width: 0; +}`; + + // client/components/metrics_by_slice.ts + var MetricsBySliceElement = class extends MobxLitElement { + constructor() { + super(); + this.appState = core.getService(AppState); + this.distributionAreaWidth = 60; + this.barAreaWidth = 60; + this.barHeight = 16; + this.numRowsDisplayedWhenCollapsed = 10; + this.sortColumn = "count" /* COUNT */; + this.sortOrder = "desc" /* DESC */; + this.isChartCollapsed = true; + this.winRateMiddlePoint = 0.5; + makeObservable(this); + } + get listTagValues() { + const valueSet = new Set( + this.appState.examples.map((ex) => ex.tags).flat() + ); + return [...valueSet]; + } + /** + * Determine the win rate for a score and accumulate to SliceWinRate. + */ + accumulateWinRateForExample(sliceWinRate, ex, threshold = this.appState.winRateThreshold) { + sliceWinRate.count += 1; + if (ex.score == null) { + sliceWinRate.results["unknown" /* Unknown */] += 1; + } else if (ex.score > this.appState.scoreMiddlePoint + threshold) { + sliceWinRate.results["a" /* A */] += 1; + } else if (ex.score < this.appState.scoreMiddlePoint - threshold) { + sliceWinRate.results["b" /* B */] += 1; + } else { + sliceWinRate.results["tie" /* Tie */] += 1; + } + if (ex.score != null) { + sliceWinRate.scoreSum += ex.score; + sliceWinRate.scoreSqSum += ex.score ** 2; + } + } + get computeWinRatesByTags() { + const chartSelectionKey = { + chartType: "tag" /* TAG */, + fieldId: "tag", + model: null + }; + const filteredExamples = this.appState.getFilteredExamplesExceptForParticularChart( + chartSelectionKey + ); + const aggregatedByTags = {}; + aggregatedByTags["All"] = makeNewSliceWinRate("All"); + this.listTagValues.forEach((tag) => { + aggregatedByTags[tag] = makeNewSliceWinRate(tag); + }); + filteredExamples.forEach((ex) => { + this.accumulateWinRateForExample(aggregatedByTags["All"], ex); + ex.tags.forEach((tag) => { + this.accumulateWinRateForExample(aggregatedByTags[tag], ex); + }); + }); + const smallNumber = 1e-4; + const rate = (winnerCount, tieCount, totalCount) => { + if (totalCount === 0) { + return 0; + } + return (winnerCount + 0.5 * tieCount + smallNumber) / totalCount; + }; + return Object.values(aggregatedByTags).sort((i23, j3) => { + if (this.sortColumn === "count" /* COUNT */) { + if (this.sortOrder === "desc" /* DESC */) { + return j3.count - i23.count; + } else { + return i23.count - j3.count; + } + } else if (this.sortColumn === "avg_score" /* AVG_SCORE */) { + return compareNumbersWithNulls( + getAvgScore(i23), + getAvgScore(j3), + this.sortOrder === "desc" /* DESC */ + ); + } else if (this.sortColumn === "win_rate" /* WIN_RATE */) { + if (this.sortOrder === "desc" /* DESC */) { + return rate(j3.results["a"], j3.results["tie"], j3.count) - rate(i23.results["a"], i23.results["tie"], i23.count); + } else { + return rate(j3.results["b"], j3.results["tie"], j3.count) - rate(i23.results["b"], i23.results["tie"], i23.count); + } + } else { + if (this.sortOrder === "desc" /* DESC */) { + return j3.sliceName.localeCompare(i23.sliceName); + } else { + return i23.sliceName.localeCompare(j3.sliceName); + } + } + }); + } + // Render one of the three bars (e.g., for a, b, or tie) in a row. + renderWinRateBar(entry, result) { + const results = entry.results; + const barCount = results[result]; + const barWidth = this.barAreaWidth * barCount / (entry.count - results["unknown"]); + const xOffset = this.barAreaWidth * (result === "b" ? results["a"] + results["tie"] : result === "tie" ? results["a"] : 0) / (entry.count - results["unknown"]); + const xTextOffset = result !== "b" ? 3 : barWidth - 3; + const textClass = e6({ "right-aligned": result === "b" }); + return b2` + + + ${result !== "tie" && barCount > 0 ? b2` + + ${barCount} + ` : ""} + `; + } + // Check if the value is significantly higher or lower than the base value. + isSignificantWinner(model, value, baseValue, intervalLeft, intervalRight) { + if (value == null) { + return false; + } + if (model === "A" /* A */) { + return value - baseValue > 0 && intervalLeft - baseValue > 0 && intervalRight - baseValue > 0; + } else { + return value - baseValue < 0 && intervalLeft - baseValue < 0 && intervalRight - baseValue < 0; + } + } + // Render a confidence interval chart for average scores. + renderScoreConfIntervalChart(avgScore, intervalLeft, intervalRight) { + if (avgScore == null) { + return x``; + } + const histogramSpec = this.appState.histogramSpecForScores; + const xValue = (score) => { + const ratio = (score - histogramSpec.rangeLeft) / (histogramSpec.rangeRight - histogramSpec.rangeLeft); + return this.distributionAreaWidth * (this.appState.isFlipScoreHistogramAxis === true ? 1 - ratio : ratio); + }; + const styleElement = (className) => e6({ + "avg-score-point": className === "avg-score-point", + "error-bar": className === "error-bar", + "a-win-color": this.isSignificantWinner( + "A" /* A */, + avgScore, + this.appState.scoreMiddlePoint, + intervalLeft, + intervalRight + ), + "b-win-color": this.isSignificantWinner( + "B" /* B */, + avgScore, + this.appState.scoreMiddlePoint, + intervalLeft, + intervalRight + ) + }); + const tooltipText = `${`95% CI: [${intervalLeft.toFixed( + 3 + )}, ${intervalRight.toFixed(3)}]`}`; + return x` + + + + + + ${tooltipText} + + + `; + } + renderAvgScoreCell(entry) { + const avgScore = getAvgScore(entry); + const histogramSpec = this.appState.histogramSpecForScores; + const [intervalLeft, intervalRight] = getConfidenceIntervalForMeanFromAggregatedStats( + entry.count, + entry.scoreSum, + entry.scoreSqSum, + histogramSpec.rangeLeft - histogramSpec.rangeRight > 0 + ); + const styleAvgScoreNumber = e6({ + "a-win-color-bg-darker": this.isSignificantWinner( + "A" /* A */, + avgScore, + this.appState.scoreMiddlePoint, + intervalLeft, + intervalRight + ), + "b-win-color-bg-darker": this.isSignificantWinner( + "B" /* B */, + avgScore, + this.appState.scoreMiddlePoint, + intervalLeft, + intervalRight + ) + }); + const renderScoreConfIntervalChart = this.renderScoreConfIntervalChart( + avgScore, + intervalLeft, + intervalRight + ); + return x`
    +
    + + ${avgScore == null ? "" : avgScore.toFixed(2)} + +
    +
    ${renderScoreConfIntervalChart}
    +
    `; + } + // Render a win rate chart using a stacked percentage bar chart. + renderWinRateChart(winRate, entry, intervalLeft, intervalRight) { + const styleElement = (className) => e6({ + "win-rate-point": className === "win-rate-point", + "win-rate-confidence-interval": className === "win-rate-confidence-interval", + "a-win-color": intervalLeft != null && intervalRight != null && this.isSignificantWinner( + "A" /* A */, + winRate, + this.winRateMiddlePoint, + intervalLeft, + intervalRight + ), + "b-win-color": intervalLeft != null && intervalRight != null && this.isSignificantWinner( + "B" /* B */, + winRate, + this.winRateMiddlePoint, + intervalLeft, + intervalRight + ) + }); + const renderConfidenceInterval = intervalLeft != null && intervalRight != null ? b2` + ` : b2``; + const tooltipText = intervalLeft != null && intervalRight != null ? `${`95% CI: [${intervalLeft.toFixed(3)}, ${intervalRight.toFixed( + 3 + )}]`}` : ""; + const renderWinRatePoint = b2` + + ${tooltipText} + `; + return x` + + + ${entry.count - entry.results["unknown" /* Unknown */] > 0 ? b2` + ${this.renderWinRateBar(entry, "tie" /* Tie */)} + ${this.renderWinRateBar(entry, "b" /* B */)} + ${this.renderWinRateBar(entry, "a" /* A */)} + + ${renderConfidenceInterval} + ${renderWinRatePoint}` : ""} + + `; + } + renderWinRateCell(entry) { + const winRate = getWinRate(entry); + const [winRateIntervalLeft, winRateIntervalRight] = getConfidenceIntervalForRate( + entry.results["a"] + entry.results["tie"] * 0.5, + entry.results["b"] + entry.results["tie"] * 0.5 + ); + const styleWinRateNumber = e6({ + "a-win-color-bg-darker": this.isSignificantWinner( + "A" /* A */, + winRate, + this.winRateMiddlePoint, + winRateIntervalLeft, + winRateIntervalRight + ), + "b-win-color-bg-darker": this.isSignificantWinner( + "B" /* B */, + winRate, + this.winRateMiddlePoint, + winRateIntervalLeft, + winRateIntervalRight + ) + }); + const renderWinRateChart = this.renderWinRateChart( + winRate, + entry, + winRateIntervalLeft, + winRateIntervalRight + ); + return x`
    +
    + + ${entry.count > 0 ? x`${formatRateToPercentage(winRate)}` : ""} + +
    +
    ${renderWinRateChart}
    +
    `; + } + // Render a stacked bar chart for a slice. + renderSliceRow(entry) { + const sliceName = entry.sliceName; + const handleClickSliceRow = () => { + if (sliceName === "All" || sliceName === this.appState.selectedTag) { + this.appState.selectedTag = null; + } else { + this.appState.selectedTag = sliceName; + } + }; + return x` + + ${entry.sliceName} + + (${entry.count}) + + + ${this.renderAvgScoreCell(entry)} + ${this.renderWinRateCell(entry)} + `; + } + // Render a list of stacked bar charts for slices. + renderWinRateBySliceChart() { + const renderSliceRows = this.computeWinRatesByTags.map( + (entry) => this.renderSliceRow(entry) + ); + const styleComponentContent = e6({ + "sidebar-component-content": true, + "collapsed": this.isChartCollapsed === true + }); + const handleClickSortHeader = (columnName) => { + if (this.sortColumn === columnName) { + this.sortOrder = this.sortOrder === "asc" /* ASC */ ? "desc" /* DESC */ : "asc" /* ASC */; + } else { + this.sortColumn = columnName; + } + }; + const styleHeaderCell = (columnName) => e6({ + "tag": columnName === "tag", + "example-count": columnName === "count", + "score-avg": columnName === "avg_score", + "win-rate": columnName === "win_rate", + "clickable": true, + "sort-selected": this.sortColumn === columnName + }); + return x` + `; + } + render() { + return x`${this.renderWinRateBySliceChart()}`; + } + }; + MetricsBySliceElement.styles = [styles, styles9]; + __decorateClass([ + observable + ], MetricsBySliceElement.prototype, "sortColumn", 2); + __decorateClass([ + observable + ], MetricsBySliceElement.prototype, "sortOrder", 2); + __decorateClass([ + observable + ], MetricsBySliceElement.prototype, "isChartCollapsed", 2); + __decorateClass([ + computed + ], MetricsBySliceElement.prototype, "listTagValues", 1); + __decorateClass([ + computed + ], MetricsBySliceElement.prototype, "computeWinRatesByTags", 1); + MetricsBySliceElement = __decorateClass([ + t3("comparator-metrics-by-slice") + ], MetricsBySliceElement); + + // client/components/rationale_summary.css + var styles10 = i`th.example-count { + cursor: pointer; + width: 50px; +} + +th.remove { + width: 26px; +} + +text.bar-count-text { + alignment-baseline: central; + fill: var(--comparator-grey-500); + font-size: 10px; + text-anchor: start; +} + +text.bar-count-text.right-aligned { + fill: var(--comparator-grey-100); + text-anchor: end; +} + +svg.bar-svg { + height: 16px; + width: 42px; +} + +td.remove { + pointer-events: none; +} + +.icon { + color: var(--comparator-grey-300); + font-size: 12px; + margin: 0; + padding: 3px; + pointer-events: auto; +}`; + + // client/components/rationale_summary.ts + var RationaleSummaryElement = class extends MobxLitElement { + constructor() { + super(); + this.appState = core.getService(AppState); + this.barMaxWidth = 40; + this.barHeight = 16; + this.widthOfNumberLabel = 10; + this.showOthers = false; + this.sortColumn = "A"; + makeObservable(this); + } + get filteredExamples() { + const chartSelectionKey = { + chartType: "rationale_cluster" /* RATIONALE_CLUSTER */, + fieldId: "rationale_cluster", + model: null + }; + return this.appState.getFilteredExamplesExceptForParticularChart( + chartSelectionKey + ); + } + get rationaleClustersWithCounts() { + const aWinExamples = this.filteredExamples.filter( + (example) => this.appState.isWinnerFromScore("A", example.score) + ); + const bWinExamples = this.filteredExamples.filter( + (example) => this.appState.isWinnerFromScore("B", example.score) + ); + return this.appState.rationaleClusters.filter( + (cluster) => this.showOthers === false ? cluster.id >= 0 : true + ).map((cluster) => { + const aWinCount = aWinExamples.filter((example) => { + const clusterIds = example.rationale_list.map( + (item) => item.assignedClusterIds + ).flat(); + return clusterIds.includes(cluster.id); + }).length; + const bWinCount = bWinExamples.filter((example) => { + const clusterIds = example.rationale_list.map( + (item) => item.assignedClusterIds + ).flat(); + return clusterIds.includes(cluster.id); + }).length; + return { + id: cluster.id, + title: cluster.title, + aWinCount, + bWinCount + }; + }); + } + get sortedClusters() { + return this.rationaleClustersWithCounts.filter( + (cluster) => cluster.aWinCount > 0 || cluster.bWinCount > 0 + ).sort((i23, j3) => { + if (i23.id === -1) { + return 1; + } else if (j3.id === -1) { + return -1; + } else if (this.sortColumn === "A") { + return j3.aWinCount - i23.aWinCount; + } else if (this.sortColumn === "B") { + return j3.bWinCount - i23.bWinCount; + } else { + return i23.title.localeCompare(j3.title); + } + }); + } + renderHeaderRow() { + const styleHeaderCell = (column) => e6({ + "cluster-title": column === "label", + "example-count": column === "A" || column === "B", + "sort-selected": this.sortColumn === column, + "clickable": true + }); + const handleClickSortHeader = (column) => { + this.sortColumn = column; + }; + return x` + void handleClickSortHeader("label")}> + Cluster Label + + void handleClickSortHeader("A")}> + A better + + void handleClickSortHeader("B")}> + B better + + + `; + } + // Render a row of the table on the Rationale Summary sidebar component. + renderClusterRow(cluster, maxCount) { + const handleClickClusterRow = (clusterId) => { + if (clusterId === this.appState.selectedRationaleClusterId) { + this.appState.selectedRationaleClusterId = null; + this.appState.currentSorting = DEFAULT_SORTING_CRITERIA; + } else { + this.appState.selectedRationaleClusterId = clusterId; + this.appState.currentSorting = { + column: "similarity between cluster label and the most similar rationale" /* RATIONALE_CLUSTER */, + customField: null, + modelIndex: null, + order: "desc" /* DESC */ + }; + } + }; + const renderBarCell = (count, maxCount2, model) => { + const barWidth = this.barMaxWidth * (count / maxCount2); + const styleBar = e6({ + "bar": true, + "a-win-color": model === "A", + "b-win-color": model === "B" + }); + const styleBarCountText = e6({ + "bar-count-text": true, + "right-aligned": this.barMaxWidth - barWidth < this.widthOfNumberLabel + }); + const textHorizontalPadding = this.barMaxWidth - barWidth < this.widthOfNumberLabel ? barWidth - 1 : barWidth + 1; + return x` + + + ${count} + + `; + }; + const handleMouseEnterRow = (clusterId) => this.appState.hoveredRationaleClusterId = clusterId; + const handleMouseLeaveRow = () => this.appState.hoveredRationaleClusterId = null; + return x` void handleMouseEnterRow(cluster.id)} + @mouseleave=${handleMouseLeaveRow}> + void handleClickClusterRow(cluster.id)}> + ${cluster.title} + + void handleClickClusterRow(cluster.id)}> + ${renderBarCell(cluster.aWinCount, maxCount, "A")} + + void handleClickClusterRow(cluster.id)}> + ${renderBarCell(cluster.bWinCount, maxCount, "B")} + + + void this.appState.removeCluster(cluster.id)}> + cancel + + + `; + } + render() { + if (this.appState.hasRationaleClusters === false) { + return x``; + } + const maxCount = Math.max( + 1, + ...this.sortedClusters.map( + (cluster) => cluster.aWinCount + ), + ...this.sortedClusters.map( + (cluster) => cluster.bWinCount + ) + ); + const renderClusters = this.sortedClusters.map( + (cluster) => this.renderClusterRow(cluster, maxCount) + ); + return x``; + } + }; + RationaleSummaryElement.styles = [styles, styles10]; + __decorateClass([ + observable + ], RationaleSummaryElement.prototype, "showOthers", 2); + __decorateClass([ + observable + ], RationaleSummaryElement.prototype, "sortColumn", 2); + __decorateClass([ + computed + ], RationaleSummaryElement.prototype, "filteredExamples", 1); + __decorateClass([ + computed + ], RationaleSummaryElement.prototype, "rationaleClustersWithCounts", 1); + __decorateClass([ + computed + ], RationaleSummaryElement.prototype, "sortedClusters", 1); + RationaleSummaryElement = __decorateClass([ + t3("comparator-rationale-summary") + ], RationaleSummaryElement); + + // client/components/score_histogram.css + var styles11 = i``; + + // client/components/score_histogram.ts + var ScoreHistogramElement = class extends MobxLitElement { + constructor() { + super(...arguments); + this.appState = core.getService(AppState); + this.svgWidth = 220; + this.svgHeight = 110; + } + renderScoreHistogram() { + const chartSelectionKey = { + chartType: "histogram" /* HISTOGRAM */, + fieldId: FIELD_ID_FOR_SCORE, + model: null + }; + const getHistogramRawDataValues = () => this.appState.getFilteredExamplesExceptForParticularChart(chartSelectionKey).filter((ex) => ex.score != null).map((ex) => ex.score); + const handleClickHistogramBar = (binIndex) => { + if (this.appState.selectedHistogramBinForScores === binIndex) { + this.appState.selectedHistogramBinForScores = null; + } else { + this.appState.selectedHistogramBinForScores = binIndex; + } + }; + const isAnyBinSelected = () => this.appState.selectedHistogramBinForScores !== null; + const isThisBinSelected = (binIndex) => binIndex === this.appState.selectedHistogramBinForScores; + return x` + `; + } + render() { + return x` ${this.renderScoreHistogram()}`; + } + }; + ScoreHistogramElement.styles = [styles, styles11]; + ScoreHistogramElement = __decorateClass([ + t3("comparator-score-histogram") + ], ScoreHistogramElement); + + // node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/decorators/custom-element.js + var e12 = (e33) => (n31) => "function" == typeof n31 ? ((e34, n32) => (customElements.define(e34, n32), n32))(e33, n31) : ((e34, n32) => { + const { kind: t17, elements: s20 } = n32; + return { kind: t17, elements: s20, finisher(n33) { + customElements.define(e34, n33); + } }; + })(e33, n31); + + // node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/decorators/property.js + var i9 = (i23, e33) => "method" === e33.kind && e33.descriptor && !("value" in e33.descriptor) ? { ...e33, finisher(n31) { + n31.createProperty(e33.key, i23); + } } : { kind: "field", key: Symbol(), placement: "own", descriptor: {}, originalKey: e33.key, initializer() { + "function" == typeof e33.initializer && (this[e33.key] = e33.initializer.call(this)); + }, finisher(n31) { + n31.createProperty(e33.key, i23); + } }; + var e13 = (i23, e33, n31) => { + e33.constructor.createProperty(n31, i23); + }; + function n12(n31) { + return (t17, o29) => void 0 !== o29 ? e13(n31, t17, o29) : i9(n31, t17); + } + + // node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/decorators/state.js + function t7(t17) { + return n12({ ...t17, state: true }); + } + + // node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/decorators/base.js + var o11 = ({ finisher: e33, descriptor: t17 }) => (o29, n31) => { + var r18; + if (void 0 === n31) { + const n32 = null !== (r18 = o29.originalKey) && void 0 !== r18 ? r18 : o29.key, i23 = null != t17 ? { kind: "method", placement: "prototype", key: n32, descriptor: t17(o29.key) } : { ...o29, key: n32 }; + return null != e33 && (i23.finisher = function(t18) { + e33(t18, n32); + }), i23; + } + { + const r19 = o29.constructor; + void 0 !== t17 && Object.defineProperty(o29, n31, t17(n31)), null == e33 || e33(r19, n31); + } + }; + + // node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/decorators/event-options.js + function e14(e33) { + return o11({ finisher: (r18, t17) => { + Object.assign(r18.prototype[t17], e33); + } }); + } + + // node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/decorators/query.js + function i10(i23, n31) { + return o11({ descriptor: (o29) => { + const t17 = { get() { + var o30, n32; + return null !== (n32 = null === (o30 = this.renderRoot) || void 0 === o30 ? void 0 : o30.querySelector(i23)) && void 0 !== n32 ? n32 : null; + }, enumerable: true, configurable: true }; + if (n31) { + const n32 = "symbol" == typeof o29 ? Symbol() : "__" + o29; + t17.get = function() { + var o30, t18; + return void 0 === this[n32] && (this[n32] = null !== (t18 = null === (o30 = this.renderRoot) || void 0 === o30 ? void 0 : o30.querySelector(i23)) && void 0 !== t18 ? t18 : null), this[n32]; + }; + } + return t17; + } }); + } + + // node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/decorators/query-async.js + function e15(e33) { + return o11({ descriptor: (r18) => ({ async get() { + var r19; + return await this.updateComplete, null === (r19 = this.renderRoot) || void 0 === r19 ? void 0 : r19.querySelector(e33); + }, enumerable: true, configurable: true }) }); + } + + // node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/decorators/query-assigned-elements.js + var n13; + var e16 = null != (null === (n13 = window.HTMLSlotElement) || void 0 === n13 ? void 0 : n13.prototype.assignedElements) ? (o29, n31) => o29.assignedElements(n31) : (o29, n31) => o29.assignedNodes(n31).filter((o30) => o30.nodeType === Node.ELEMENT_NODE); + + // node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/decorators/custom-element.js + var e17 = (e33) => (n31) => "function" == typeof n31 ? ((e34, n32) => (customElements.define(e34, n32), n32))(e33, n31) : ((e34, n32) => { + const { kind: t17, elements: s20 } = n32; + return { kind: t17, elements: s20, finisher(n33) { + customElements.define(e34, n33); + } }; + })(e33, n31); + + // node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/decorators/property.js + var i11 = (i23, e33) => "method" === e33.kind && e33.descriptor && !("value" in e33.descriptor) ? { ...e33, finisher(n31) { + n31.createProperty(e33.key, i23); + } } : { kind: "field", key: Symbol(), placement: "own", descriptor: {}, originalKey: e33.key, initializer() { + "function" == typeof e33.initializer && (this[e33.key] = e33.initializer.call(this)); + }, finisher(n31) { + n31.createProperty(e33.key, i23); + } }; + var e18 = (i23, e33, n31) => { + e33.constructor.createProperty(n31, i23); + }; + function n14(n31) { + return (t17, o29) => void 0 !== o29 ? e18(n31, t17, o29) : i11(n31, t17); + } + + // node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/decorators/state.js + function t8(t17) { + return n14({ ...t17, state: true }); + } + + // node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/decorators/base.js + var o12 = ({ finisher: e33, descriptor: t17 }) => (o29, n31) => { + var r18; + if (void 0 === n31) { + const n32 = null !== (r18 = o29.originalKey) && void 0 !== r18 ? r18 : o29.key, i23 = null != t17 ? { kind: "method", placement: "prototype", key: n32, descriptor: t17(o29.key) } : { ...o29, key: n32 }; + return null != e33 && (i23.finisher = function(t18) { + e33(t18, n32); + }), i23; + } + { + const r19 = o29.constructor; + void 0 !== t17 && Object.defineProperty(o29, n31, t17(n31)), null == e33 || e33(r19, n31); + } + }; + + // node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/decorators/query.js + function i12(i23, n31) { + return o12({ descriptor: (o29) => { + const t17 = { get() { + var o30, n32; + return null !== (n32 = null === (o30 = this.renderRoot) || void 0 === o30 ? void 0 : o30.querySelector(i23)) && void 0 !== n32 ? n32 : null; + }, enumerable: true, configurable: true }; + if (n31) { + const n32 = "symbol" == typeof o29 ? Symbol() : "__" + o29; + t17.get = function() { + var o30, t18; + return void 0 === this[n32] && (this[n32] = null !== (t18 = null === (o30 = this.renderRoot) || void 0 === o30 ? void 0 : o30.querySelector(i23)) && void 0 !== t18 ? t18 : null), this[n32]; + }; + } + return t17; + } }); + } + + // node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/decorators/query-assigned-elements.js + var n15; + var e19 = null != (null === (n15 = window.HTMLSlotElement) || void 0 === n15 ? void 0 : n15.prototype.assignedElements) ? (o29, n31) => o29.assignedElements(n31) : (o29, n31) => o29.assignedNodes(n31).filter((o30) => o30.nodeType === Node.ELEMENT_NODE); + + // node_modules/@material/dom/ponyfill.js + function matches2(element, selector) { + var nativeMatches = element.matches || element.webkitMatchesSelector || element.msMatchesSelector; + return nativeMatches.call(element, selector); + } + + // node_modules/@material/mwc-base/node_modules/@lit/reactive-element/css-tag.js + var t9 = window; + var e20 = t9.ShadowRoot && (void 0 === t9.ShadyCSS || t9.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype; + var s8 = Symbol(); + var n16 = /* @__PURE__ */ new WeakMap(); + var o13 = class { + constructor(t17, e33, n31) { + if (this._$cssResult$ = true, n31 !== s8) + throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); + this.cssText = t17, this.t = e33; + } + get styleSheet() { + let t17 = this.o; + const s20 = this.t; + if (e20 && void 0 === t17) { + const e33 = void 0 !== s20 && 1 === s20.length; + e33 && (t17 = n16.get(s20)), void 0 === t17 && ((this.o = t17 = new CSSStyleSheet()).replaceSync(this.cssText), e33 && n16.set(s20, t17)); + } + return t17; + } + toString() { + return this.cssText; + } + }; + var r9 = (t17) => new o13("string" == typeof t17 ? t17 : t17 + "", void 0, s8); + var S5 = (s20, n31) => { + e20 ? s20.adoptedStyleSheets = n31.map((t17) => t17 instanceof CSSStyleSheet ? t17 : t17.styleSheet) : n31.forEach((e33) => { + const n32 = document.createElement("style"), o29 = t9.litNonce; + void 0 !== o29 && n32.setAttribute("nonce", o29), n32.textContent = e33.cssText, s20.appendChild(n32); + }); + }; + var c6 = e20 ? (t17) => t17 : (t17) => t17 instanceof CSSStyleSheet ? ((t18) => { + let e33 = ""; + for (const s20 of t18.cssRules) + e33 += s20.cssText; + return r9(e33); + })(t17) : t17; + + // node_modules/@material/mwc-base/node_modules/@lit/reactive-element/reactive-element.js + var s9; + var e21 = window; + var r10 = e21.trustedTypes; + var h5 = r10 ? r10.emptyScript : ""; + var o14 = e21.reactiveElementPolyfillSupport; + var n17 = { toAttribute(t17, i23) { + switch (i23) { + case Boolean: + t17 = t17 ? h5 : null; + break; + case Object: + case Array: + t17 = null == t17 ? t17 : JSON.stringify(t17); + } + return t17; + }, fromAttribute(t17, i23) { + let s20 = t17; + switch (i23) { + case Boolean: + s20 = null !== t17; + break; + case Number: + s20 = null === t17 ? null : Number(t17); + break; + case Object: + case Array: + try { + s20 = JSON.parse(t17); + } catch (t18) { + s20 = null; + } + } + return s20; + } }; + var a5 = (t17, i23) => i23 !== t17 && (i23 == i23 || t17 == t17); + var l9 = { attribute: true, type: String, converter: n17, reflect: false, hasChanged: a5 }; + var d5 = "finalized"; + var u5 = class extends HTMLElement { + constructor() { + super(), this._$Ei = /* @__PURE__ */ new Map(), this.isUpdatePending = false, this.hasUpdated = false, this._$El = null, this._$Eu(); + } + static addInitializer(t17) { + var i23; + this.finalize(), (null !== (i23 = this.h) && void 0 !== i23 ? i23 : this.h = []).push(t17); + } + static get observedAttributes() { + this.finalize(); + const t17 = []; + return this.elementProperties.forEach((i23, s20) => { + const e33 = this._$Ep(s20, i23); + void 0 !== e33 && (this._$Ev.set(e33, s20), t17.push(e33)); + }), t17; + } + static createProperty(t17, i23 = l9) { + if (i23.state && (i23.attribute = false), this.finalize(), this.elementProperties.set(t17, i23), !i23.noAccessor && !this.prototype.hasOwnProperty(t17)) { + const s20 = "symbol" == typeof t17 ? Symbol() : "__" + t17, e33 = this.getPropertyDescriptor(t17, s20, i23); + void 0 !== e33 && Object.defineProperty(this.prototype, t17, e33); + } + } + static getPropertyDescriptor(t17, i23, s20) { + return { get() { + return this[i23]; + }, set(e33) { + const r18 = this[t17]; + this[i23] = e33, this.requestUpdate(t17, r18, s20); + }, configurable: true, enumerable: true }; + } + static getPropertyOptions(t17) { + return this.elementProperties.get(t17) || l9; + } + static finalize() { + if (this.hasOwnProperty(d5)) + return false; + this[d5] = true; + const t17 = Object.getPrototypeOf(this); + if (t17.finalize(), void 0 !== t17.h && (this.h = [...t17.h]), this.elementProperties = new Map(t17.elementProperties), this._$Ev = /* @__PURE__ */ new Map(), this.hasOwnProperty("properties")) { + const t18 = this.properties, i23 = [...Object.getOwnPropertyNames(t18), ...Object.getOwnPropertySymbols(t18)]; + for (const s20 of i23) + this.createProperty(s20, t18[s20]); + } + return this.elementStyles = this.finalizeStyles(this.styles), true; + } + static finalizeStyles(i23) { + const s20 = []; + if (Array.isArray(i23)) { + const e33 = new Set(i23.flat(1 / 0).reverse()); + for (const i24 of e33) + s20.unshift(c6(i24)); + } else + void 0 !== i23 && s20.push(c6(i23)); + return s20; + } + static _$Ep(t17, i23) { + const s20 = i23.attribute; + return false === s20 ? void 0 : "string" == typeof s20 ? s20 : "string" == typeof t17 ? t17.toLowerCase() : void 0; + } + _$Eu() { + var t17; + this._$E_ = new Promise((t18) => this.enableUpdating = t18), this._$AL = /* @__PURE__ */ new Map(), this._$Eg(), this.requestUpdate(), null === (t17 = this.constructor.h) || void 0 === t17 || t17.forEach((t18) => t18(this)); + } + addController(t17) { + var i23, s20; + (null !== (i23 = this._$ES) && void 0 !== i23 ? i23 : this._$ES = []).push(t17), void 0 !== this.renderRoot && this.isConnected && (null === (s20 = t17.hostConnected) || void 0 === s20 || s20.call(t17)); + } + removeController(t17) { + var i23; + null === (i23 = this._$ES) || void 0 === i23 || i23.splice(this._$ES.indexOf(t17) >>> 0, 1); + } + _$Eg() { + this.constructor.elementProperties.forEach((t17, i23) => { + this.hasOwnProperty(i23) && (this._$Ei.set(i23, this[i23]), delete this[i23]); + }); + } + createRenderRoot() { + var t17; + const s20 = null !== (t17 = this.shadowRoot) && void 0 !== t17 ? t17 : this.attachShadow(this.constructor.shadowRootOptions); + return S5(s20, this.constructor.elementStyles), s20; + } + connectedCallback() { + var t17; + void 0 === this.renderRoot && (this.renderRoot = this.createRenderRoot()), this.enableUpdating(true), null === (t17 = this._$ES) || void 0 === t17 || t17.forEach((t18) => { + var i23; + return null === (i23 = t18.hostConnected) || void 0 === i23 ? void 0 : i23.call(t18); + }); + } + enableUpdating(t17) { + } + disconnectedCallback() { + var t17; + null === (t17 = this._$ES) || void 0 === t17 || t17.forEach((t18) => { + var i23; + return null === (i23 = t18.hostDisconnected) || void 0 === i23 ? void 0 : i23.call(t18); + }); + } + attributeChangedCallback(t17, i23, s20) { + this._$AK(t17, s20); + } + _$EO(t17, i23, s20 = l9) { + var e33; + const r18 = this.constructor._$Ep(t17, s20); + if (void 0 !== r18 && true === s20.reflect) { + const h11 = (void 0 !== (null === (e33 = s20.converter) || void 0 === e33 ? void 0 : e33.toAttribute) ? s20.converter : n17).toAttribute(i23, s20.type); + this._$El = t17, null == h11 ? this.removeAttribute(r18) : this.setAttribute(r18, h11), this._$El = null; + } + } + _$AK(t17, i23) { + var s20; + const e33 = this.constructor, r18 = e33._$Ev.get(t17); + if (void 0 !== r18 && this._$El !== r18) { + const t18 = e33.getPropertyOptions(r18), h11 = "function" == typeof t18.converter ? { fromAttribute: t18.converter } : void 0 !== (null === (s20 = t18.converter) || void 0 === s20 ? void 0 : s20.fromAttribute) ? t18.converter : n17; + this._$El = r18, this[r18] = h11.fromAttribute(i23, t18.type), this._$El = null; + } + } + requestUpdate(t17, i23, s20) { + let e33 = true; + void 0 !== t17 && (((s20 = s20 || this.constructor.getPropertyOptions(t17)).hasChanged || a5)(this[t17], i23) ? (this._$AL.has(t17) || this._$AL.set(t17, i23), true === s20.reflect && this._$El !== t17 && (void 0 === this._$EC && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(t17, s20))) : e33 = false), !this.isUpdatePending && e33 && (this._$E_ = this._$Ej()); + } + async _$Ej() { + this.isUpdatePending = true; + try { + await this._$E_; + } catch (t18) { + Promise.reject(t18); + } + const t17 = this.scheduleUpdate(); + return null != t17 && await t17, !this.isUpdatePending; + } + scheduleUpdate() { + return this.performUpdate(); + } + performUpdate() { + var t17; + if (!this.isUpdatePending) + return; + this.hasUpdated, this._$Ei && (this._$Ei.forEach((t18, i24) => this[i24] = t18), this._$Ei = void 0); + let i23 = false; + const s20 = this._$AL; + try { + i23 = this.shouldUpdate(s20), i23 ? (this.willUpdate(s20), null === (t17 = this._$ES) || void 0 === t17 || t17.forEach((t18) => { + var i24; + return null === (i24 = t18.hostUpdate) || void 0 === i24 ? void 0 : i24.call(t18); + }), this.update(s20)) : this._$Ek(); + } catch (t18) { + throw i23 = false, this._$Ek(), t18; + } + i23 && this._$AE(s20); + } + willUpdate(t17) { + } + _$AE(t17) { + var i23; + null === (i23 = this._$ES) || void 0 === i23 || i23.forEach((t18) => { + var i24; + return null === (i24 = t18.hostUpdated) || void 0 === i24 ? void 0 : i24.call(t18); + }), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t17)), this.updated(t17); + } + _$Ek() { + this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = false; + } + get updateComplete() { + return this.getUpdateComplete(); + } + getUpdateComplete() { + return this._$E_; + } + shouldUpdate(t17) { + return true; + } + update(t17) { + void 0 !== this._$EC && (this._$EC.forEach((t18, i23) => this._$EO(i23, this[i23], t18)), this._$EC = void 0), this._$Ek(); + } + updated(t17) { + } + firstUpdated(t17) { + } + }; + u5[d5] = true, u5.elementProperties = /* @__PURE__ */ new Map(), u5.elementStyles = [], u5.shadowRootOptions = { mode: "open" }, null == o14 || o14({ ReactiveElement: u5 }), (null !== (s9 = e21.reactiveElementVersions) && void 0 !== s9 ? s9 : e21.reactiveElementVersions = []).push("1.6.3"); + + // node_modules/@material/mwc-base/node_modules/lit-html/lit-html.js + var t10; + var i14 = window; + var s10 = i14.trustedTypes; + var e22 = s10 ? s10.createPolicy("lit-html", { createHTML: (t17) => t17 }) : void 0; + var o15 = "$lit$"; + var n18 = `lit$${(Math.random() + "").slice(9)}$`; + var l10 = "?" + n18; + var h6 = `<${l10}>`; + var r11 = document; + var u6 = () => r11.createComment(""); + var d6 = (t17) => null === t17 || "object" != typeof t17 && "function" != typeof t17; + var c7 = Array.isArray; + var v3 = (t17) => c7(t17) || "function" == typeof (null == t17 ? void 0 : t17[Symbol.iterator]); + var a6 = "[ \n\f\r]"; + var f4 = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g; + var _16 = /-->/g; + var m3 = />/g; + var p4 = RegExp(`>|${a6}(?:([^\\s"'>=/]+)(${a6}*=${a6}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`, "g"); + var g3 = /'/g; + var $3 = /"/g; + var y4 = /^(?:script|style|textarea|title)$/i; + var w3 = (t17) => (i23, ...s20) => ({ _$litType$: t17, strings: i23, values: s20 }); + var x3 = w3(1); + var b4 = w3(2); + var T3 = Symbol.for("lit-noChange"); + var A3 = Symbol.for("lit-nothing"); + var E3 = /* @__PURE__ */ new WeakMap(); + var C3 = r11.createTreeWalker(r11, 129, null, false); + function P3(t17, i23) { + if (!Array.isArray(t17) || !t17.hasOwnProperty("raw")) + throw Error("invalid template strings array"); + return void 0 !== e22 ? e22.createHTML(i23) : i23; + } + var V3 = (t17, i23) => { + const s20 = t17.length - 1, e33 = []; + let l20, r18 = 2 === i23 ? "" : "", u11 = f4; + for (let i24 = 0; i24 < s20; i24++) { + const s21 = t17[i24]; + let d11, c12, v6 = -1, a11 = 0; + for (; a11 < s21.length && (u11.lastIndex = a11, c12 = u11.exec(s21), null !== c12); ) + a11 = u11.lastIndex, u11 === f4 ? "!--" === c12[1] ? u11 = _16 : void 0 !== c12[1] ? u11 = m3 : void 0 !== c12[2] ? (y4.test(c12[2]) && (l20 = RegExp("" === c12[0] ? (u11 = null != l20 ? l20 : f4, v6 = -1) : void 0 === c12[1] ? v6 = -2 : (v6 = u11.lastIndex - c12[2].length, d11 = c12[1], u11 = void 0 === c12[3] ? p4 : '"' === c12[3] ? $3 : g3) : u11 === $3 || u11 === g3 ? u11 = p4 : u11 === _16 || u11 === m3 ? u11 = f4 : (u11 = p4, l20 = void 0); + const w6 = u11 === p4 && t17[i24 + 1].startsWith("/>") ? " " : ""; + r18 += u11 === f4 ? s21 + h6 : v6 >= 0 ? (e33.push(d11), s21.slice(0, v6) + o15 + s21.slice(v6) + n18 + w6) : s21 + n18 + (-2 === v6 ? (e33.push(void 0), i24) : w6); + } + return [P3(t17, r18 + (t17[s20] || "") + (2 === i23 ? "" : "")), e33]; + }; + var N3 = class _N { + constructor({ strings: t17, _$litType$: i23 }, e33) { + let h11; + this.parts = []; + let r18 = 0, d11 = 0; + const c12 = t17.length - 1, v6 = this.parts, [a11, f7] = V3(t17, i23); + if (this.el = _N.createElement(a11, e33), C3.currentNode = this.el.content, 2 === i23) { + const t18 = this.el.content, i24 = t18.firstChild; + i24.remove(), t18.append(...i24.childNodes); + } + for (; null !== (h11 = C3.nextNode()) && v6.length < c12; ) { + if (1 === h11.nodeType) { + if (h11.hasAttributes()) { + const t18 = []; + for (const i24 of h11.getAttributeNames()) + if (i24.endsWith(o15) || i24.startsWith(n18)) { + const s20 = f7[d11++]; + if (t18.push(i24), void 0 !== s20) { + const t19 = h11.getAttribute(s20.toLowerCase() + o15).split(n18), i25 = /([.?@])?(.*)/.exec(s20); + v6.push({ type: 1, index: r18, name: i25[2], strings: t19, ctor: "." === i25[1] ? H3 : "?" === i25[1] ? L3 : "@" === i25[1] ? z2 : k5 }); + } else + v6.push({ type: 6, index: r18 }); + } + for (const i24 of t18) + h11.removeAttribute(i24); + } + if (y4.test(h11.tagName)) { + const t18 = h11.textContent.split(n18), i24 = t18.length - 1; + if (i24 > 0) { + h11.textContent = s10 ? s10.emptyScript : ""; + for (let s20 = 0; s20 < i24; s20++) + h11.append(t18[s20], u6()), C3.nextNode(), v6.push({ type: 2, index: ++r18 }); + h11.append(t18[i24], u6()); + } + } + } else if (8 === h11.nodeType) + if (h11.data === l10) + v6.push({ type: 2, index: r18 }); + else { + let t18 = -1; + for (; -1 !== (t18 = h11.data.indexOf(n18, t18 + 1)); ) + v6.push({ type: 7, index: r18 }), t18 += n18.length - 1; + } + r18++; + } + } + static createElement(t17, i23) { + const s20 = r11.createElement("template"); + return s20.innerHTML = t17, s20; + } + }; + function S6(t17, i23, s20 = t17, e33) { + var o29, n31, l20, h11; + if (i23 === T3) + return i23; + let r18 = void 0 !== e33 ? null === (o29 = s20._$Co) || void 0 === o29 ? void 0 : o29[e33] : s20._$Cl; + const u11 = d6(i23) ? void 0 : i23._$litDirective$; + return (null == r18 ? void 0 : r18.constructor) !== u11 && (null === (n31 = null == r18 ? void 0 : r18._$AO) || void 0 === n31 || n31.call(r18, false), void 0 === u11 ? r18 = void 0 : (r18 = new u11(t17), r18._$AT(t17, s20, e33)), void 0 !== e33 ? (null !== (l20 = (h11 = s20)._$Co) && void 0 !== l20 ? l20 : h11._$Co = [])[e33] = r18 : s20._$Cl = r18), void 0 !== r18 && (i23 = S6(t17, r18._$AS(t17, i23.values), r18, e33)), i23; + } + var M3 = class { + constructor(t17, i23) { + this._$AV = [], this._$AN = void 0, this._$AD = t17, this._$AM = i23; + } + get parentNode() { + return this._$AM.parentNode; + } + get _$AU() { + return this._$AM._$AU; + } + u(t17) { + var i23; + const { el: { content: s20 }, parts: e33 } = this._$AD, o29 = (null !== (i23 = null == t17 ? void 0 : t17.creationScope) && void 0 !== i23 ? i23 : r11).importNode(s20, true); + C3.currentNode = o29; + let n31 = C3.nextNode(), l20 = 0, h11 = 0, u11 = e33[0]; + for (; void 0 !== u11; ) { + if (l20 === u11.index) { + let i24; + 2 === u11.type ? i24 = new R3(n31, n31.nextSibling, this, t17) : 1 === u11.type ? i24 = new u11.ctor(n31, u11.name, u11.strings, this, t17) : 6 === u11.type && (i24 = new Z3(n31, this, t17)), this._$AV.push(i24), u11 = e33[++h11]; + } + l20 !== (null == u11 ? void 0 : u11.index) && (n31 = C3.nextNode(), l20++); + } + return C3.currentNode = r11, o29; + } + v(t17) { + let i23 = 0; + for (const s20 of this._$AV) + void 0 !== s20 && (void 0 !== s20.strings ? (s20._$AI(t17, s20, i23), i23 += s20.strings.length - 2) : s20._$AI(t17[i23])), i23++; + } + }; + var R3 = class _R { + constructor(t17, i23, s20, e33) { + var o29; + this.type = 2, this._$AH = A3, this._$AN = void 0, this._$AA = t17, this._$AB = i23, this._$AM = s20, this.options = e33, this._$Cp = null === (o29 = null == e33 ? void 0 : e33.isConnected) || void 0 === o29 || o29; + } + get _$AU() { + var t17, i23; + return null !== (i23 = null === (t17 = this._$AM) || void 0 === t17 ? void 0 : t17._$AU) && void 0 !== i23 ? i23 : this._$Cp; + } + get parentNode() { + let t17 = this._$AA.parentNode; + const i23 = this._$AM; + return void 0 !== i23 && 11 === (null == t17 ? void 0 : t17.nodeType) && (t17 = i23.parentNode), t17; + } + get startNode() { + return this._$AA; + } + get endNode() { + return this._$AB; + } + _$AI(t17, i23 = this) { + t17 = S6(this, t17, i23), d6(t17) ? t17 === A3 || null == t17 || "" === t17 ? (this._$AH !== A3 && this._$AR(), this._$AH = A3) : t17 !== this._$AH && t17 !== T3 && this._(t17) : void 0 !== t17._$litType$ ? this.g(t17) : void 0 !== t17.nodeType ? this.$(t17) : v3(t17) ? this.T(t17) : this._(t17); + } + k(t17) { + return this._$AA.parentNode.insertBefore(t17, this._$AB); + } + $(t17) { + this._$AH !== t17 && (this._$AR(), this._$AH = this.k(t17)); + } + _(t17) { + this._$AH !== A3 && d6(this._$AH) ? this._$AA.nextSibling.data = t17 : this.$(r11.createTextNode(t17)), this._$AH = t17; + } + g(t17) { + var i23; + const { values: s20, _$litType$: e33 } = t17, o29 = "number" == typeof e33 ? this._$AC(t17) : (void 0 === e33.el && (e33.el = N3.createElement(P3(e33.h, e33.h[0]), this.options)), e33); + if ((null === (i23 = this._$AH) || void 0 === i23 ? void 0 : i23._$AD) === o29) + this._$AH.v(s20); + else { + const t18 = new M3(o29, this), i24 = t18.u(this.options); + t18.v(s20), this.$(i24), this._$AH = t18; + } + } + _$AC(t17) { + let i23 = E3.get(t17.strings); + return void 0 === i23 && E3.set(t17.strings, i23 = new N3(t17)), i23; + } + T(t17) { + c7(this._$AH) || (this._$AH = [], this._$AR()); + const i23 = this._$AH; + let s20, e33 = 0; + for (const o29 of t17) + e33 === i23.length ? i23.push(s20 = new _R(this.k(u6()), this.k(u6()), this, this.options)) : s20 = i23[e33], s20._$AI(o29), e33++; + e33 < i23.length && (this._$AR(s20 && s20._$AB.nextSibling, e33), i23.length = e33); + } + _$AR(t17 = this._$AA.nextSibling, i23) { + var s20; + for (null === (s20 = this._$AP) || void 0 === s20 || s20.call(this, false, true, i23); t17 && t17 !== this._$AB; ) { + const i24 = t17.nextSibling; + t17.remove(), t17 = i24; + } + } + setConnected(t17) { + var i23; + void 0 === this._$AM && (this._$Cp = t17, null === (i23 = this._$AP) || void 0 === i23 || i23.call(this, t17)); + } + }; + var k5 = class { + constructor(t17, i23, s20, e33, o29) { + this.type = 1, this._$AH = A3, this._$AN = void 0, this.element = t17, this.name = i23, this._$AM = e33, this.options = o29, s20.length > 2 || "" !== s20[0] || "" !== s20[1] ? (this._$AH = Array(s20.length - 1).fill(new String()), this.strings = s20) : this._$AH = A3; + } + get tagName() { + return this.element.tagName; + } + get _$AU() { + return this._$AM._$AU; + } + _$AI(t17, i23 = this, s20, e33) { + const o29 = this.strings; + let n31 = false; + if (void 0 === o29) + t17 = S6(this, t17, i23, 0), n31 = !d6(t17) || t17 !== this._$AH && t17 !== T3, n31 && (this._$AH = t17); + else { + const e34 = t17; + let l20, h11; + for (t17 = o29[0], l20 = 0; l20 < o29.length - 1; l20++) + h11 = S6(this, e34[s20 + l20], i23, l20), h11 === T3 && (h11 = this._$AH[l20]), n31 || (n31 = !d6(h11) || h11 !== this._$AH[l20]), h11 === A3 ? t17 = A3 : t17 !== A3 && (t17 += (null != h11 ? h11 : "") + o29[l20 + 1]), this._$AH[l20] = h11; + } + n31 && !e33 && this.j(t17); + } + j(t17) { + t17 === A3 ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, null != t17 ? t17 : ""); + } + }; + var H3 = class extends k5 { + constructor() { + super(...arguments), this.type = 3; + } + j(t17) { + this.element[this.name] = t17 === A3 ? void 0 : t17; + } + }; + var I3 = s10 ? s10.emptyScript : ""; + var L3 = class extends k5 { + constructor() { + super(...arguments), this.type = 4; + } + j(t17) { + t17 && t17 !== A3 ? this.element.setAttribute(this.name, I3) : this.element.removeAttribute(this.name); + } + }; + var z2 = class extends k5 { + constructor(t17, i23, s20, e33, o29) { + super(t17, i23, s20, e33, o29), this.type = 5; + } + _$AI(t17, i23 = this) { + var s20; + if ((t17 = null !== (s20 = S6(this, t17, i23, 0)) && void 0 !== s20 ? s20 : A3) === T3) + return; + const e33 = this._$AH, o29 = t17 === A3 && e33 !== A3 || t17.capture !== e33.capture || t17.once !== e33.once || t17.passive !== e33.passive, n31 = t17 !== A3 && (e33 === A3 || o29); + o29 && this.element.removeEventListener(this.name, this, e33), n31 && this.element.addEventListener(this.name, this, t17), this._$AH = t17; + } + handleEvent(t17) { + var i23, s20; + "function" == typeof this._$AH ? this._$AH.call(null !== (s20 = null === (i23 = this.options) || void 0 === i23 ? void 0 : i23.host) && void 0 !== s20 ? s20 : this.element, t17) : this._$AH.handleEvent(t17); + } + }; + var Z3 = class { + constructor(t17, i23, s20) { + this.element = t17, this.type = 6, this._$AN = void 0, this._$AM = i23, this.options = s20; + } + get _$AU() { + return this._$AM._$AU; + } + _$AI(t17) { + S6(this, t17); + } + }; + var B2 = i14.litHtmlPolyfillSupport; + null == B2 || B2(N3, R3), (null !== (t10 = i14.litHtmlVersions) && void 0 !== t10 ? t10 : i14.litHtmlVersions = []).push("2.8.0"); + var D2 = (t17, i23, s20) => { + var e33, o29; + const n31 = null !== (e33 = null == s20 ? void 0 : s20.renderBefore) && void 0 !== e33 ? e33 : i23; + let l20 = n31._$litPart$; + if (void 0 === l20) { + const t18 = null !== (o29 = null == s20 ? void 0 : s20.renderBefore) && void 0 !== o29 ? o29 : null; + n31._$litPart$ = l20 = new R3(i23.insertBefore(u6(), t18), t18, void 0, null != s20 ? s20 : {}); + } + return l20._$AI(t17), l20; + }; + + // node_modules/@material/mwc-base/node_modules/lit-element/lit-element.js + var l11; + var o16; + var s11 = class extends u5 { + constructor() { + super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0; + } + createRenderRoot() { + var t17, e33; + const i23 = super.createRenderRoot(); + return null !== (t17 = (e33 = this.renderOptions).renderBefore) && void 0 !== t17 || (e33.renderBefore = i23.firstChild), i23; + } + update(t17) { + const i23 = this.render(); + this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t17), this._$Do = D2(i23, this.renderRoot, this.renderOptions); + } + connectedCallback() { + var t17; + super.connectedCallback(), null === (t17 = this._$Do) || void 0 === t17 || t17.setConnected(true); + } + disconnectedCallback() { + var t17; + super.disconnectedCallback(), null === (t17 = this._$Do) || void 0 === t17 || t17.setConnected(false); + } + render() { + return T3; + } + }; + s11.finalized = true, s11._$litElement$ = true, null === (l11 = globalThis.litElementHydrateSupport) || void 0 === l11 || l11.call(globalThis, { LitElement: s11 }); + var n19 = globalThis.litElementPolyfillSupport; + null == n19 || n19({ LitElement: s11 }); + (null !== (o16 = globalThis.litElementVersions) && void 0 !== o16 ? o16 : globalThis.litElementVersions = []).push("3.3.3"); + + // node_modules/@material/mwc-base/utils.js + var supportsPassive = false; + var fn = () => { + }; + var optionsBlock = { + get passive() { + supportsPassive = true; + return false; + } + }; + document.addEventListener("x", fn, optionsBlock); + document.removeEventListener("x", fn); + + // node_modules/@material/mwc-base/base-element.js + var BaseElement = class extends s11 { + click() { + if (this.mdcRoot) { + this.mdcRoot.focus(); + this.mdcRoot.click(); + return; + } + super.click(); + } + /** + * Create and attach the MDC Foundation to the instance + */ + createFoundation() { + if (this.mdcFoundation !== void 0) { + this.mdcFoundation.destroy(); + } + if (this.mdcFoundationClass) { + this.mdcFoundation = new this.mdcFoundationClass(this.createAdapter()); + this.mdcFoundation.init(); + } + } + firstUpdated() { + this.createFoundation(); + } + }; + + // node_modules/@material/base/foundation.js + var MDCFoundation = ( + /** @class */ + function() { + function MDCFoundation2(adapter) { + if (adapter === void 0) { + adapter = {}; + } + this.adapter = adapter; + } + Object.defineProperty(MDCFoundation2, "cssClasses", { + get: function() { + return {}; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(MDCFoundation2, "strings", { + get: function() { + return {}; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(MDCFoundation2, "numbers", { + get: function() { + return {}; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(MDCFoundation2, "defaultAdapter", { + get: function() { + return {}; + }, + enumerable: false, + configurable: true + }); + MDCFoundation2.prototype.init = function() { + }; + MDCFoundation2.prototype.destroy = function() { + }; + return MDCFoundation2; + }() + ); + + // node_modules/@material/ripple/constants.js + var cssClasses = { + // Ripple is a special case where the "root" component is really a "mixin" of sorts, + // given that it's an 'upgrade' to an existing component. That being said it is the root + // CSS class that all other CSS classes derive from. + BG_FOCUSED: "mdc-ripple-upgraded--background-focused", + FG_ACTIVATION: "mdc-ripple-upgraded--foreground-activation", + FG_DEACTIVATION: "mdc-ripple-upgraded--foreground-deactivation", + ROOT: "mdc-ripple-upgraded", + UNBOUNDED: "mdc-ripple-upgraded--unbounded" + }; + var strings = { + VAR_FG_SCALE: "--mdc-ripple-fg-scale", + VAR_FG_SIZE: "--mdc-ripple-fg-size", + VAR_FG_TRANSLATE_END: "--mdc-ripple-fg-translate-end", + VAR_FG_TRANSLATE_START: "--mdc-ripple-fg-translate-start", + VAR_LEFT: "--mdc-ripple-left", + VAR_TOP: "--mdc-ripple-top" + }; + var numbers = { + DEACTIVATION_TIMEOUT_MS: 225, + FG_DEACTIVATION_MS: 150, + INITIAL_ORIGIN_SCALE: 0.6, + PADDING: 10, + TAP_DELAY_MS: 300 + // Delay between touch and simulated mouse events on touch devices + }; + + // node_modules/@material/ripple/util.js + function getNormalizedEventCoords(evt, pageOffset, clientRect) { + if (!evt) { + return { x: 0, y: 0 }; + } + var x6 = pageOffset.x, y7 = pageOffset.y; + var documentX = x6 + clientRect.left; + var documentY = y7 + clientRect.top; + var normalizedX; + var normalizedY; + if (evt.type === "touchstart") { + var touchEvent = evt; + normalizedX = touchEvent.changedTouches[0].pageX - documentX; + normalizedY = touchEvent.changedTouches[0].pageY - documentY; + } else { + var mouseEvent = evt; + normalizedX = mouseEvent.pageX - documentX; + normalizedY = mouseEvent.pageY - documentY; + } + return { x: normalizedX, y: normalizedY }; + } + + // node_modules/@material/ripple/foundation.js + var ACTIVATION_EVENT_TYPES = [ + "touchstart", + "pointerdown", + "mousedown", + "keydown" + ]; + var POINTER_DEACTIVATION_EVENT_TYPES = [ + "touchend", + "pointerup", + "mouseup", + "contextmenu" + ]; + var activatedTargets = []; + var MDCRippleFoundation = ( + /** @class */ + function(_super) { + __extends(MDCRippleFoundation2, _super); + function MDCRippleFoundation2(adapter) { + var _this = _super.call(this, __assign(__assign({}, MDCRippleFoundation2.defaultAdapter), adapter)) || this; + _this.activationAnimationHasEnded = false; + _this.activationTimer = 0; + _this.fgDeactivationRemovalTimer = 0; + _this.fgScale = "0"; + _this.frame = { width: 0, height: 0 }; + _this.initialSize = 0; + _this.layoutFrame = 0; + _this.maxRadius = 0; + _this.unboundedCoords = { left: 0, top: 0 }; + _this.activationState = _this.defaultActivationState(); + _this.activationTimerCallback = function() { + _this.activationAnimationHasEnded = true; + _this.runDeactivationUXLogicIfReady(); + }; + _this.activateHandler = function(e33) { + _this.activateImpl(e33); + }; + _this.deactivateHandler = function() { + _this.deactivateImpl(); + }; + _this.focusHandler = function() { + _this.handleFocus(); + }; + _this.blurHandler = function() { + _this.handleBlur(); + }; + _this.resizeHandler = function() { + _this.layout(); + }; + return _this; + } + Object.defineProperty(MDCRippleFoundation2, "cssClasses", { + get: function() { + return cssClasses; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(MDCRippleFoundation2, "strings", { + get: function() { + return strings; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(MDCRippleFoundation2, "numbers", { + get: function() { + return numbers; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(MDCRippleFoundation2, "defaultAdapter", { + get: function() { + return { + addClass: function() { + return void 0; + }, + browserSupportsCssVars: function() { + return true; + }, + computeBoundingRect: function() { + return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 }; + }, + containsEventTarget: function() { + return true; + }, + deregisterDocumentInteractionHandler: function() { + return void 0; + }, + deregisterInteractionHandler: function() { + return void 0; + }, + deregisterResizeHandler: function() { + return void 0; + }, + getWindowPageOffset: function() { + return { x: 0, y: 0 }; + }, + isSurfaceActive: function() { + return true; + }, + isSurfaceDisabled: function() { + return true; + }, + isUnbounded: function() { + return true; + }, + registerDocumentInteractionHandler: function() { + return void 0; + }, + registerInteractionHandler: function() { + return void 0; + }, + registerResizeHandler: function() { + return void 0; + }, + removeClass: function() { + return void 0; + }, + updateCssVariable: function() { + return void 0; + } + }; + }, + enumerable: false, + configurable: true + }); + MDCRippleFoundation2.prototype.init = function() { + var _this = this; + var supportsPressRipple = this.supportsPressRipple(); + this.registerRootHandlers(supportsPressRipple); + if (supportsPressRipple) { + var _a2 = MDCRippleFoundation2.cssClasses, ROOT_1 = _a2.ROOT, UNBOUNDED_1 = _a2.UNBOUNDED; + requestAnimationFrame(function() { + _this.adapter.addClass(ROOT_1); + if (_this.adapter.isUnbounded()) { + _this.adapter.addClass(UNBOUNDED_1); + _this.layoutInternal(); + } + }); + } + }; + MDCRippleFoundation2.prototype.destroy = function() { + var _this = this; + if (this.supportsPressRipple()) { + if (this.activationTimer) { + clearTimeout(this.activationTimer); + this.activationTimer = 0; + this.adapter.removeClass(MDCRippleFoundation2.cssClasses.FG_ACTIVATION); + } + if (this.fgDeactivationRemovalTimer) { + clearTimeout(this.fgDeactivationRemovalTimer); + this.fgDeactivationRemovalTimer = 0; + this.adapter.removeClass(MDCRippleFoundation2.cssClasses.FG_DEACTIVATION); + } + var _a2 = MDCRippleFoundation2.cssClasses, ROOT_2 = _a2.ROOT, UNBOUNDED_2 = _a2.UNBOUNDED; + requestAnimationFrame(function() { + _this.adapter.removeClass(ROOT_2); + _this.adapter.removeClass(UNBOUNDED_2); + _this.removeCssVars(); + }); + } + this.deregisterRootHandlers(); + this.deregisterDeactivationHandlers(); + }; + MDCRippleFoundation2.prototype.activate = function(evt) { + this.activateImpl(evt); + }; + MDCRippleFoundation2.prototype.deactivate = function() { + this.deactivateImpl(); + }; + MDCRippleFoundation2.prototype.layout = function() { + var _this = this; + if (this.layoutFrame) { + cancelAnimationFrame(this.layoutFrame); + } + this.layoutFrame = requestAnimationFrame(function() { + _this.layoutInternal(); + _this.layoutFrame = 0; + }); + }; + MDCRippleFoundation2.prototype.setUnbounded = function(unbounded) { + var UNBOUNDED = MDCRippleFoundation2.cssClasses.UNBOUNDED; + if (unbounded) { + this.adapter.addClass(UNBOUNDED); + } else { + this.adapter.removeClass(UNBOUNDED); + } + }; + MDCRippleFoundation2.prototype.handleFocus = function() { + var _this = this; + requestAnimationFrame(function() { + return _this.adapter.addClass(MDCRippleFoundation2.cssClasses.BG_FOCUSED); + }); + }; + MDCRippleFoundation2.prototype.handleBlur = function() { + var _this = this; + requestAnimationFrame(function() { + return _this.adapter.removeClass(MDCRippleFoundation2.cssClasses.BG_FOCUSED); + }); + }; + MDCRippleFoundation2.prototype.supportsPressRipple = function() { + return this.adapter.browserSupportsCssVars(); + }; + MDCRippleFoundation2.prototype.defaultActivationState = function() { + return { + activationEvent: void 0, + hasDeactivationUXRun: false, + isActivated: false, + isProgrammatic: false, + wasActivatedByPointer: false, + wasElementMadeActive: false + }; + }; + MDCRippleFoundation2.prototype.registerRootHandlers = function(supportsPressRipple) { + var e_1, _a2; + if (supportsPressRipple) { + try { + for (var ACTIVATION_EVENT_TYPES_1 = __values(ACTIVATION_EVENT_TYPES), ACTIVATION_EVENT_TYPES_1_1 = ACTIVATION_EVENT_TYPES_1.next(); !ACTIVATION_EVENT_TYPES_1_1.done; ACTIVATION_EVENT_TYPES_1_1 = ACTIVATION_EVENT_TYPES_1.next()) { + var evtType = ACTIVATION_EVENT_TYPES_1_1.value; + this.adapter.registerInteractionHandler(evtType, this.activateHandler); + } + } catch (e_1_1) { + e_1 = { error: e_1_1 }; + } finally { + try { + if (ACTIVATION_EVENT_TYPES_1_1 && !ACTIVATION_EVENT_TYPES_1_1.done && (_a2 = ACTIVATION_EVENT_TYPES_1.return)) + _a2.call(ACTIVATION_EVENT_TYPES_1); + } finally { + if (e_1) + throw e_1.error; + } + } + if (this.adapter.isUnbounded()) { + this.adapter.registerResizeHandler(this.resizeHandler); + } + } + this.adapter.registerInteractionHandler("focus", this.focusHandler); + this.adapter.registerInteractionHandler("blur", this.blurHandler); + }; + MDCRippleFoundation2.prototype.registerDeactivationHandlers = function(evt) { + var e_2, _a2; + if (evt.type === "keydown") { + this.adapter.registerInteractionHandler("keyup", this.deactivateHandler); + } else { + try { + for (var POINTER_DEACTIVATION_EVENT_TYPES_1 = __values(POINTER_DEACTIVATION_EVENT_TYPES), POINTER_DEACTIVATION_EVENT_TYPES_1_1 = POINTER_DEACTIVATION_EVENT_TYPES_1.next(); !POINTER_DEACTIVATION_EVENT_TYPES_1_1.done; POINTER_DEACTIVATION_EVENT_TYPES_1_1 = POINTER_DEACTIVATION_EVENT_TYPES_1.next()) { + var evtType = POINTER_DEACTIVATION_EVENT_TYPES_1_1.value; + this.adapter.registerDocumentInteractionHandler(evtType, this.deactivateHandler); + } + } catch (e_2_1) { + e_2 = { error: e_2_1 }; + } finally { + try { + if (POINTER_DEACTIVATION_EVENT_TYPES_1_1 && !POINTER_DEACTIVATION_EVENT_TYPES_1_1.done && (_a2 = POINTER_DEACTIVATION_EVENT_TYPES_1.return)) + _a2.call(POINTER_DEACTIVATION_EVENT_TYPES_1); + } finally { + if (e_2) + throw e_2.error; + } + } + } + }; + MDCRippleFoundation2.prototype.deregisterRootHandlers = function() { + var e_3, _a2; + try { + for (var ACTIVATION_EVENT_TYPES_2 = __values(ACTIVATION_EVENT_TYPES), ACTIVATION_EVENT_TYPES_2_1 = ACTIVATION_EVENT_TYPES_2.next(); !ACTIVATION_EVENT_TYPES_2_1.done; ACTIVATION_EVENT_TYPES_2_1 = ACTIVATION_EVENT_TYPES_2.next()) { + var evtType = ACTIVATION_EVENT_TYPES_2_1.value; + this.adapter.deregisterInteractionHandler(evtType, this.activateHandler); + } + } catch (e_3_1) { + e_3 = { error: e_3_1 }; + } finally { + try { + if (ACTIVATION_EVENT_TYPES_2_1 && !ACTIVATION_EVENT_TYPES_2_1.done && (_a2 = ACTIVATION_EVENT_TYPES_2.return)) + _a2.call(ACTIVATION_EVENT_TYPES_2); + } finally { + if (e_3) + throw e_3.error; + } + } + this.adapter.deregisterInteractionHandler("focus", this.focusHandler); + this.adapter.deregisterInteractionHandler("blur", this.blurHandler); + if (this.adapter.isUnbounded()) { + this.adapter.deregisterResizeHandler(this.resizeHandler); + } + }; + MDCRippleFoundation2.prototype.deregisterDeactivationHandlers = function() { + var e_4, _a2; + this.adapter.deregisterInteractionHandler("keyup", this.deactivateHandler); + try { + for (var POINTER_DEACTIVATION_EVENT_TYPES_2 = __values(POINTER_DEACTIVATION_EVENT_TYPES), POINTER_DEACTIVATION_EVENT_TYPES_2_1 = POINTER_DEACTIVATION_EVENT_TYPES_2.next(); !POINTER_DEACTIVATION_EVENT_TYPES_2_1.done; POINTER_DEACTIVATION_EVENT_TYPES_2_1 = POINTER_DEACTIVATION_EVENT_TYPES_2.next()) { + var evtType = POINTER_DEACTIVATION_EVENT_TYPES_2_1.value; + this.adapter.deregisterDocumentInteractionHandler(evtType, this.deactivateHandler); + } + } catch (e_4_1) { + e_4 = { error: e_4_1 }; + } finally { + try { + if (POINTER_DEACTIVATION_EVENT_TYPES_2_1 && !POINTER_DEACTIVATION_EVENT_TYPES_2_1.done && (_a2 = POINTER_DEACTIVATION_EVENT_TYPES_2.return)) + _a2.call(POINTER_DEACTIVATION_EVENT_TYPES_2); + } finally { + if (e_4) + throw e_4.error; + } + } + }; + MDCRippleFoundation2.prototype.removeCssVars = function() { + var _this = this; + var rippleStrings = MDCRippleFoundation2.strings; + var keys = Object.keys(rippleStrings); + keys.forEach(function(key) { + if (key.indexOf("VAR_") === 0) { + _this.adapter.updateCssVariable(rippleStrings[key], null); + } + }); + }; + MDCRippleFoundation2.prototype.activateImpl = function(evt) { + var _this = this; + if (this.adapter.isSurfaceDisabled()) { + return; + } + var activationState = this.activationState; + if (activationState.isActivated) { + return; + } + var previousActivationEvent = this.previousActivationEvent; + var isSameInteraction = previousActivationEvent && evt !== void 0 && previousActivationEvent.type !== evt.type; + if (isSameInteraction) { + return; + } + activationState.isActivated = true; + activationState.isProgrammatic = evt === void 0; + activationState.activationEvent = evt; + activationState.wasActivatedByPointer = activationState.isProgrammatic ? false : evt !== void 0 && (evt.type === "mousedown" || evt.type === "touchstart" || evt.type === "pointerdown"); + var hasActivatedChild = evt !== void 0 && activatedTargets.length > 0 && activatedTargets.some(function(target) { + return _this.adapter.containsEventTarget(target); + }); + if (hasActivatedChild) { + this.resetActivationState(); + return; + } + if (evt !== void 0) { + activatedTargets.push(evt.target); + this.registerDeactivationHandlers(evt); + } + activationState.wasElementMadeActive = this.checkElementMadeActive(evt); + if (activationState.wasElementMadeActive) { + this.animateActivation(); + } + requestAnimationFrame(function() { + activatedTargets = []; + if (!activationState.wasElementMadeActive && evt !== void 0 && (evt.key === " " || evt.keyCode === 32)) { + activationState.wasElementMadeActive = _this.checkElementMadeActive(evt); + if (activationState.wasElementMadeActive) { + _this.animateActivation(); + } + } + if (!activationState.wasElementMadeActive) { + _this.activationState = _this.defaultActivationState(); + } + }); + }; + MDCRippleFoundation2.prototype.checkElementMadeActive = function(evt) { + return evt !== void 0 && evt.type === "keydown" ? this.adapter.isSurfaceActive() : true; + }; + MDCRippleFoundation2.prototype.animateActivation = function() { + var _this = this; + var _a2 = MDCRippleFoundation2.strings, VAR_FG_TRANSLATE_START = _a2.VAR_FG_TRANSLATE_START, VAR_FG_TRANSLATE_END = _a2.VAR_FG_TRANSLATE_END; + var _b2 = MDCRippleFoundation2.cssClasses, FG_DEACTIVATION = _b2.FG_DEACTIVATION, FG_ACTIVATION = _b2.FG_ACTIVATION; + var DEACTIVATION_TIMEOUT_MS = MDCRippleFoundation2.numbers.DEACTIVATION_TIMEOUT_MS; + this.layoutInternal(); + var translateStart = ""; + var translateEnd = ""; + if (!this.adapter.isUnbounded()) { + var _c = this.getFgTranslationCoordinates(), startPoint = _c.startPoint, endPoint = _c.endPoint; + translateStart = startPoint.x + "px, " + startPoint.y + "px"; + translateEnd = endPoint.x + "px, " + endPoint.y + "px"; + } + this.adapter.updateCssVariable(VAR_FG_TRANSLATE_START, translateStart); + this.adapter.updateCssVariable(VAR_FG_TRANSLATE_END, translateEnd); + clearTimeout(this.activationTimer); + clearTimeout(this.fgDeactivationRemovalTimer); + this.rmBoundedActivationClasses(); + this.adapter.removeClass(FG_DEACTIVATION); + this.adapter.computeBoundingRect(); + this.adapter.addClass(FG_ACTIVATION); + this.activationTimer = setTimeout(function() { + _this.activationTimerCallback(); + }, DEACTIVATION_TIMEOUT_MS); + }; + MDCRippleFoundation2.prototype.getFgTranslationCoordinates = function() { + var _a2 = this.activationState, activationEvent = _a2.activationEvent, wasActivatedByPointer = _a2.wasActivatedByPointer; + var startPoint; + if (wasActivatedByPointer) { + startPoint = getNormalizedEventCoords(activationEvent, this.adapter.getWindowPageOffset(), this.adapter.computeBoundingRect()); + } else { + startPoint = { + x: this.frame.width / 2, + y: this.frame.height / 2 + }; + } + startPoint = { + x: startPoint.x - this.initialSize / 2, + y: startPoint.y - this.initialSize / 2 + }; + var endPoint = { + x: this.frame.width / 2 - this.initialSize / 2, + y: this.frame.height / 2 - this.initialSize / 2 + }; + return { startPoint, endPoint }; + }; + MDCRippleFoundation2.prototype.runDeactivationUXLogicIfReady = function() { + var _this = this; + var FG_DEACTIVATION = MDCRippleFoundation2.cssClasses.FG_DEACTIVATION; + var _a2 = this.activationState, hasDeactivationUXRun = _a2.hasDeactivationUXRun, isActivated = _a2.isActivated; + var activationHasEnded = hasDeactivationUXRun || !isActivated; + if (activationHasEnded && this.activationAnimationHasEnded) { + this.rmBoundedActivationClasses(); + this.adapter.addClass(FG_DEACTIVATION); + this.fgDeactivationRemovalTimer = setTimeout(function() { + _this.adapter.removeClass(FG_DEACTIVATION); + }, numbers.FG_DEACTIVATION_MS); + } + }; + MDCRippleFoundation2.prototype.rmBoundedActivationClasses = function() { + var FG_ACTIVATION = MDCRippleFoundation2.cssClasses.FG_ACTIVATION; + this.adapter.removeClass(FG_ACTIVATION); + this.activationAnimationHasEnded = false; + this.adapter.computeBoundingRect(); + }; + MDCRippleFoundation2.prototype.resetActivationState = function() { + var _this = this; + this.previousActivationEvent = this.activationState.activationEvent; + this.activationState = this.defaultActivationState(); + setTimeout(function() { + return _this.previousActivationEvent = void 0; + }, MDCRippleFoundation2.numbers.TAP_DELAY_MS); + }; + MDCRippleFoundation2.prototype.deactivateImpl = function() { + var _this = this; + var activationState = this.activationState; + if (!activationState.isActivated) { + return; + } + var state = __assign({}, activationState); + if (activationState.isProgrammatic) { + requestAnimationFrame(function() { + _this.animateDeactivation(state); + }); + this.resetActivationState(); + } else { + this.deregisterDeactivationHandlers(); + requestAnimationFrame(function() { + _this.activationState.hasDeactivationUXRun = true; + _this.animateDeactivation(state); + _this.resetActivationState(); + }); + } + }; + MDCRippleFoundation2.prototype.animateDeactivation = function(_a2) { + var wasActivatedByPointer = _a2.wasActivatedByPointer, wasElementMadeActive = _a2.wasElementMadeActive; + if (wasActivatedByPointer || wasElementMadeActive) { + this.runDeactivationUXLogicIfReady(); + } + }; + MDCRippleFoundation2.prototype.layoutInternal = function() { + var _this = this; + this.frame = this.adapter.computeBoundingRect(); + var maxDim = Math.max(this.frame.height, this.frame.width); + var getBoundedRadius = function() { + var hypotenuse = Math.sqrt(Math.pow(_this.frame.width, 2) + Math.pow(_this.frame.height, 2)); + return hypotenuse + MDCRippleFoundation2.numbers.PADDING; + }; + this.maxRadius = this.adapter.isUnbounded() ? maxDim : getBoundedRadius(); + var initialSize = Math.floor(maxDim * MDCRippleFoundation2.numbers.INITIAL_ORIGIN_SCALE); + if (this.adapter.isUnbounded() && initialSize % 2 !== 0) { + this.initialSize = initialSize - 1; + } else { + this.initialSize = initialSize; + } + this.fgScale = "" + this.maxRadius / this.initialSize; + this.updateLayoutCssVars(); + }; + MDCRippleFoundation2.prototype.updateLayoutCssVars = function() { + var _a2 = MDCRippleFoundation2.strings, VAR_FG_SIZE = _a2.VAR_FG_SIZE, VAR_LEFT = _a2.VAR_LEFT, VAR_TOP = _a2.VAR_TOP, VAR_FG_SCALE = _a2.VAR_FG_SCALE; + this.adapter.updateCssVariable(VAR_FG_SIZE, this.initialSize + "px"); + this.adapter.updateCssVariable(VAR_FG_SCALE, this.fgScale); + if (this.adapter.isUnbounded()) { + this.unboundedCoords = { + left: Math.round(this.frame.width / 2 - this.initialSize / 2), + top: Math.round(this.frame.height / 2 - this.initialSize / 2) + }; + this.adapter.updateCssVariable(VAR_LEFT, this.unboundedCoords.left + "px"); + this.adapter.updateCssVariable(VAR_TOP, this.unboundedCoords.top + "px"); + } + }; + return MDCRippleFoundation2; + }(MDCFoundation) + ); + var foundation_default = MDCRippleFoundation; + + // node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/css-tag.js + var t11 = window; + var e23 = t11.ShadowRoot && (void 0 === t11.ShadyCSS || t11.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype; + var s12 = Symbol(); + var n20 = /* @__PURE__ */ new WeakMap(); + var o17 = class { + constructor(t17, e33, n31) { + if (this._$cssResult$ = true, n31 !== s12) + throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); + this.cssText = t17, this.t = e33; + } + get styleSheet() { + let t17 = this.o; + const s20 = this.t; + if (e23 && void 0 === t17) { + const e33 = void 0 !== s20 && 1 === s20.length; + e33 && (t17 = n20.get(s20)), void 0 === t17 && ((this.o = t17 = new CSSStyleSheet()).replaceSync(this.cssText), e33 && n20.set(s20, t17)); + } + return t17; + } + toString() { + return this.cssText; + } + }; + var r12 = (t17) => new o17("string" == typeof t17 ? t17 : t17 + "", void 0, s12); + var i15 = (t17, ...e33) => { + const n31 = 1 === t17.length ? t17[0] : e33.reduce((e34, s20, n32) => e34 + ((t18) => { + if (true === t18._$cssResult$) + return t18.cssText; + if ("number" == typeof t18) + return t18; + throw Error("Value passed to 'css' function must be a 'css' function result: " + t18 + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security."); + })(s20) + t17[n32 + 1], t17[0]); + return new o17(n31, t17, s12); + }; + var S7 = (s20, n31) => { + e23 ? s20.adoptedStyleSheets = n31.map((t17) => t17 instanceof CSSStyleSheet ? t17 : t17.styleSheet) : n31.forEach((e33) => { + const n32 = document.createElement("style"), o29 = t11.litNonce; + void 0 !== o29 && n32.setAttribute("nonce", o29), n32.textContent = e33.cssText, s20.appendChild(n32); + }); + }; + var c8 = e23 ? (t17) => t17 : (t17) => t17 instanceof CSSStyleSheet ? ((t18) => { + let e33 = ""; + for (const s20 of t18.cssRules) + e33 += s20.cssText; + return r12(e33); + })(t17) : t17; + + // node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/reactive-element.js + var s13; + var e24 = window; + var r13 = e24.trustedTypes; + var h7 = r13 ? r13.emptyScript : ""; + var o18 = e24.reactiveElementPolyfillSupport; + var n21 = { toAttribute(t17, i23) { + switch (i23) { + case Boolean: + t17 = t17 ? h7 : null; + break; + case Object: + case Array: + t17 = null == t17 ? t17 : JSON.stringify(t17); + } + return t17; + }, fromAttribute(t17, i23) { + let s20 = t17; + switch (i23) { + case Boolean: + s20 = null !== t17; + break; + case Number: + s20 = null === t17 ? null : Number(t17); + break; + case Object: + case Array: + try { + s20 = JSON.parse(t17); + } catch (t18) { + s20 = null; + } + } + return s20; + } }; + var a7 = (t17, i23) => i23 !== t17 && (i23 == i23 || t17 == t17); + var l12 = { attribute: true, type: String, converter: n21, reflect: false, hasChanged: a7 }; + var d7 = "finalized"; + var u7 = class extends HTMLElement { + constructor() { + super(), this._$Ei = /* @__PURE__ */ new Map(), this.isUpdatePending = false, this.hasUpdated = false, this._$El = null, this._$Eu(); + } + static addInitializer(t17) { + var i23; + this.finalize(), (null !== (i23 = this.h) && void 0 !== i23 ? i23 : this.h = []).push(t17); + } + static get observedAttributes() { + this.finalize(); + const t17 = []; + return this.elementProperties.forEach((i23, s20) => { + const e33 = this._$Ep(s20, i23); + void 0 !== e33 && (this._$Ev.set(e33, s20), t17.push(e33)); + }), t17; + } + static createProperty(t17, i23 = l12) { + if (i23.state && (i23.attribute = false), this.finalize(), this.elementProperties.set(t17, i23), !i23.noAccessor && !this.prototype.hasOwnProperty(t17)) { + const s20 = "symbol" == typeof t17 ? Symbol() : "__" + t17, e33 = this.getPropertyDescriptor(t17, s20, i23); + void 0 !== e33 && Object.defineProperty(this.prototype, t17, e33); + } + } + static getPropertyDescriptor(t17, i23, s20) { + return { get() { + return this[i23]; + }, set(e33) { + const r18 = this[t17]; + this[i23] = e33, this.requestUpdate(t17, r18, s20); + }, configurable: true, enumerable: true }; + } + static getPropertyOptions(t17) { + return this.elementProperties.get(t17) || l12; + } + static finalize() { + if (this.hasOwnProperty(d7)) + return false; + this[d7] = true; + const t17 = Object.getPrototypeOf(this); + if (t17.finalize(), void 0 !== t17.h && (this.h = [...t17.h]), this.elementProperties = new Map(t17.elementProperties), this._$Ev = /* @__PURE__ */ new Map(), this.hasOwnProperty("properties")) { + const t18 = this.properties, i23 = [...Object.getOwnPropertyNames(t18), ...Object.getOwnPropertySymbols(t18)]; + for (const s20 of i23) + this.createProperty(s20, t18[s20]); + } + return this.elementStyles = this.finalizeStyles(this.styles), true; + } + static finalizeStyles(i23) { + const s20 = []; + if (Array.isArray(i23)) { + const e33 = new Set(i23.flat(1 / 0).reverse()); + for (const i24 of e33) + s20.unshift(c8(i24)); + } else + void 0 !== i23 && s20.push(c8(i23)); + return s20; + } + static _$Ep(t17, i23) { + const s20 = i23.attribute; + return false === s20 ? void 0 : "string" == typeof s20 ? s20 : "string" == typeof t17 ? t17.toLowerCase() : void 0; + } + _$Eu() { + var t17; + this._$E_ = new Promise((t18) => this.enableUpdating = t18), this._$AL = /* @__PURE__ */ new Map(), this._$Eg(), this.requestUpdate(), null === (t17 = this.constructor.h) || void 0 === t17 || t17.forEach((t18) => t18(this)); + } + addController(t17) { + var i23, s20; + (null !== (i23 = this._$ES) && void 0 !== i23 ? i23 : this._$ES = []).push(t17), void 0 !== this.renderRoot && this.isConnected && (null === (s20 = t17.hostConnected) || void 0 === s20 || s20.call(t17)); + } + removeController(t17) { + var i23; + null === (i23 = this._$ES) || void 0 === i23 || i23.splice(this._$ES.indexOf(t17) >>> 0, 1); + } + _$Eg() { + this.constructor.elementProperties.forEach((t17, i23) => { + this.hasOwnProperty(i23) && (this._$Ei.set(i23, this[i23]), delete this[i23]); + }); + } + createRenderRoot() { + var t17; + const s20 = null !== (t17 = this.shadowRoot) && void 0 !== t17 ? t17 : this.attachShadow(this.constructor.shadowRootOptions); + return S7(s20, this.constructor.elementStyles), s20; + } + connectedCallback() { + var t17; + void 0 === this.renderRoot && (this.renderRoot = this.createRenderRoot()), this.enableUpdating(true), null === (t17 = this._$ES) || void 0 === t17 || t17.forEach((t18) => { + var i23; + return null === (i23 = t18.hostConnected) || void 0 === i23 ? void 0 : i23.call(t18); + }); + } + enableUpdating(t17) { + } + disconnectedCallback() { + var t17; + null === (t17 = this._$ES) || void 0 === t17 || t17.forEach((t18) => { + var i23; + return null === (i23 = t18.hostDisconnected) || void 0 === i23 ? void 0 : i23.call(t18); + }); + } + attributeChangedCallback(t17, i23, s20) { + this._$AK(t17, s20); + } + _$EO(t17, i23, s20 = l12) { + var e33; + const r18 = this.constructor._$Ep(t17, s20); + if (void 0 !== r18 && true === s20.reflect) { + const h11 = (void 0 !== (null === (e33 = s20.converter) || void 0 === e33 ? void 0 : e33.toAttribute) ? s20.converter : n21).toAttribute(i23, s20.type); + this._$El = t17, null == h11 ? this.removeAttribute(r18) : this.setAttribute(r18, h11), this._$El = null; + } + } + _$AK(t17, i23) { + var s20; + const e33 = this.constructor, r18 = e33._$Ev.get(t17); + if (void 0 !== r18 && this._$El !== r18) { + const t18 = e33.getPropertyOptions(r18), h11 = "function" == typeof t18.converter ? { fromAttribute: t18.converter } : void 0 !== (null === (s20 = t18.converter) || void 0 === s20 ? void 0 : s20.fromAttribute) ? t18.converter : n21; + this._$El = r18, this[r18] = h11.fromAttribute(i23, t18.type), this._$El = null; + } + } + requestUpdate(t17, i23, s20) { + let e33 = true; + void 0 !== t17 && (((s20 = s20 || this.constructor.getPropertyOptions(t17)).hasChanged || a7)(this[t17], i23) ? (this._$AL.has(t17) || this._$AL.set(t17, i23), true === s20.reflect && this._$El !== t17 && (void 0 === this._$EC && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(t17, s20))) : e33 = false), !this.isUpdatePending && e33 && (this._$E_ = this._$Ej()); + } + async _$Ej() { + this.isUpdatePending = true; + try { + await this._$E_; + } catch (t18) { + Promise.reject(t18); + } + const t17 = this.scheduleUpdate(); + return null != t17 && await t17, !this.isUpdatePending; + } + scheduleUpdate() { + return this.performUpdate(); + } + performUpdate() { + var t17; + if (!this.isUpdatePending) + return; + this.hasUpdated, this._$Ei && (this._$Ei.forEach((t18, i24) => this[i24] = t18), this._$Ei = void 0); + let i23 = false; + const s20 = this._$AL; + try { + i23 = this.shouldUpdate(s20), i23 ? (this.willUpdate(s20), null === (t17 = this._$ES) || void 0 === t17 || t17.forEach((t18) => { + var i24; + return null === (i24 = t18.hostUpdate) || void 0 === i24 ? void 0 : i24.call(t18); + }), this.update(s20)) : this._$Ek(); + } catch (t18) { + throw i23 = false, this._$Ek(), t18; + } + i23 && this._$AE(s20); + } + willUpdate(t17) { + } + _$AE(t17) { + var i23; + null === (i23 = this._$ES) || void 0 === i23 || i23.forEach((t18) => { + var i24; + return null === (i24 = t18.hostUpdated) || void 0 === i24 ? void 0 : i24.call(t18); + }), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t17)), this.updated(t17); + } + _$Ek() { + this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = false; + } + get updateComplete() { + return this.getUpdateComplete(); + } + getUpdateComplete() { + return this._$E_; + } + shouldUpdate(t17) { + return true; + } + update(t17) { + void 0 !== this._$EC && (this._$EC.forEach((t18, i23) => this._$EO(i23, this[i23], t18)), this._$EC = void 0), this._$Ek(); + } + updated(t17) { + } + firstUpdated(t17) { + } + }; + u7[d7] = true, u7.elementProperties = /* @__PURE__ */ new Map(), u7.elementStyles = [], u7.shadowRootOptions = { mode: "open" }, null == o18 || o18({ ReactiveElement: u7 }), (null !== (s13 = e24.reactiveElementVersions) && void 0 !== s13 ? s13 : e24.reactiveElementVersions = []).push("1.6.3"); + + // node_modules/@material/mwc-ripple/node_modules/lit-html/lit-html.js + var t12; + var i16 = window; + var s14 = i16.trustedTypes; + var e25 = s14 ? s14.createPolicy("lit-html", { createHTML: (t17) => t17 }) : void 0; + var o19 = "$lit$"; + var n22 = `lit$${(Math.random() + "").slice(9)}$`; + var l13 = "?" + n22; + var h8 = `<${l13}>`; + var r14 = document; + var u8 = () => r14.createComment(""); + var d8 = (t17) => null === t17 || "object" != typeof t17 && "function" != typeof t17; + var c9 = Array.isArray; + var v4 = (t17) => c9(t17) || "function" == typeof (null == t17 ? void 0 : t17[Symbol.iterator]); + var a8 = "[ \n\f\r]"; + var f5 = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g; + var _17 = /-->/g; + var m4 = />/g; + var p5 = RegExp(`>|${a8}(?:([^\\s"'>=/]+)(${a8}*=${a8}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`, "g"); + var g4 = /'/g; + var $4 = /"/g; + var y5 = /^(?:script|style|textarea|title)$/i; + var w4 = (t17) => (i23, ...s20) => ({ _$litType$: t17, strings: i23, values: s20 }); + var x4 = w4(1); + var b5 = w4(2); + var T4 = Symbol.for("lit-noChange"); + var A4 = Symbol.for("lit-nothing"); + var E4 = /* @__PURE__ */ new WeakMap(); + var C4 = r14.createTreeWalker(r14, 129, null, false); + function P4(t17, i23) { + if (!Array.isArray(t17) || !t17.hasOwnProperty("raw")) + throw Error("invalid template strings array"); + return void 0 !== e25 ? e25.createHTML(i23) : i23; + } + var V4 = (t17, i23) => { + const s20 = t17.length - 1, e33 = []; + let l20, r18 = 2 === i23 ? "" : "", u11 = f5; + for (let i24 = 0; i24 < s20; i24++) { + const s21 = t17[i24]; + let d11, c12, v6 = -1, a11 = 0; + for (; a11 < s21.length && (u11.lastIndex = a11, c12 = u11.exec(s21), null !== c12); ) + a11 = u11.lastIndex, u11 === f5 ? "!--" === c12[1] ? u11 = _17 : void 0 !== c12[1] ? u11 = m4 : void 0 !== c12[2] ? (y5.test(c12[2]) && (l20 = RegExp("" === c12[0] ? (u11 = null != l20 ? l20 : f5, v6 = -1) : void 0 === c12[1] ? v6 = -2 : (v6 = u11.lastIndex - c12[2].length, d11 = c12[1], u11 = void 0 === c12[3] ? p5 : '"' === c12[3] ? $4 : g4) : u11 === $4 || u11 === g4 ? u11 = p5 : u11 === _17 || u11 === m4 ? u11 = f5 : (u11 = p5, l20 = void 0); + const w6 = u11 === p5 && t17[i24 + 1].startsWith("/>") ? " " : ""; + r18 += u11 === f5 ? s21 + h8 : v6 >= 0 ? (e33.push(d11), s21.slice(0, v6) + o19 + s21.slice(v6) + n22 + w6) : s21 + n22 + (-2 === v6 ? (e33.push(void 0), i24) : w6); + } + return [P4(t17, r18 + (t17[s20] || "") + (2 === i23 ? "" : "")), e33]; + }; + var N4 = class _N { + constructor({ strings: t17, _$litType$: i23 }, e33) { + let h11; + this.parts = []; + let r18 = 0, d11 = 0; + const c12 = t17.length - 1, v6 = this.parts, [a11, f7] = V4(t17, i23); + if (this.el = _N.createElement(a11, e33), C4.currentNode = this.el.content, 2 === i23) { + const t18 = this.el.content, i24 = t18.firstChild; + i24.remove(), t18.append(...i24.childNodes); + } + for (; null !== (h11 = C4.nextNode()) && v6.length < c12; ) { + if (1 === h11.nodeType) { + if (h11.hasAttributes()) { + const t18 = []; + for (const i24 of h11.getAttributeNames()) + if (i24.endsWith(o19) || i24.startsWith(n22)) { + const s20 = f7[d11++]; + if (t18.push(i24), void 0 !== s20) { + const t19 = h11.getAttribute(s20.toLowerCase() + o19).split(n22), i25 = /([.?@])?(.*)/.exec(s20); + v6.push({ type: 1, index: r18, name: i25[2], strings: t19, ctor: "." === i25[1] ? H4 : "?" === i25[1] ? L4 : "@" === i25[1] ? z3 : k6 }); + } else + v6.push({ type: 6, index: r18 }); + } + for (const i24 of t18) + h11.removeAttribute(i24); + } + if (y5.test(h11.tagName)) { + const t18 = h11.textContent.split(n22), i24 = t18.length - 1; + if (i24 > 0) { + h11.textContent = s14 ? s14.emptyScript : ""; + for (let s20 = 0; s20 < i24; s20++) + h11.append(t18[s20], u8()), C4.nextNode(), v6.push({ type: 2, index: ++r18 }); + h11.append(t18[i24], u8()); + } + } + } else if (8 === h11.nodeType) + if (h11.data === l13) + v6.push({ type: 2, index: r18 }); + else { + let t18 = -1; + for (; -1 !== (t18 = h11.data.indexOf(n22, t18 + 1)); ) + v6.push({ type: 7, index: r18 }), t18 += n22.length - 1; + } + r18++; + } + } + static createElement(t17, i23) { + const s20 = r14.createElement("template"); + return s20.innerHTML = t17, s20; + } + }; + function S8(t17, i23, s20 = t17, e33) { + var o29, n31, l20, h11; + if (i23 === T4) + return i23; + let r18 = void 0 !== e33 ? null === (o29 = s20._$Co) || void 0 === o29 ? void 0 : o29[e33] : s20._$Cl; + const u11 = d8(i23) ? void 0 : i23._$litDirective$; + return (null == r18 ? void 0 : r18.constructor) !== u11 && (null === (n31 = null == r18 ? void 0 : r18._$AO) || void 0 === n31 || n31.call(r18, false), void 0 === u11 ? r18 = void 0 : (r18 = new u11(t17), r18._$AT(t17, s20, e33)), void 0 !== e33 ? (null !== (l20 = (h11 = s20)._$Co) && void 0 !== l20 ? l20 : h11._$Co = [])[e33] = r18 : s20._$Cl = r18), void 0 !== r18 && (i23 = S8(t17, r18._$AS(t17, i23.values), r18, e33)), i23; + } + var M4 = class { + constructor(t17, i23) { + this._$AV = [], this._$AN = void 0, this._$AD = t17, this._$AM = i23; + } + get parentNode() { + return this._$AM.parentNode; + } + get _$AU() { + return this._$AM._$AU; + } + u(t17) { + var i23; + const { el: { content: s20 }, parts: e33 } = this._$AD, o29 = (null !== (i23 = null == t17 ? void 0 : t17.creationScope) && void 0 !== i23 ? i23 : r14).importNode(s20, true); + C4.currentNode = o29; + let n31 = C4.nextNode(), l20 = 0, h11 = 0, u11 = e33[0]; + for (; void 0 !== u11; ) { + if (l20 === u11.index) { + let i24; + 2 === u11.type ? i24 = new R4(n31, n31.nextSibling, this, t17) : 1 === u11.type ? i24 = new u11.ctor(n31, u11.name, u11.strings, this, t17) : 6 === u11.type && (i24 = new Z4(n31, this, t17)), this._$AV.push(i24), u11 = e33[++h11]; + } + l20 !== (null == u11 ? void 0 : u11.index) && (n31 = C4.nextNode(), l20++); + } + return C4.currentNode = r14, o29; + } + v(t17) { + let i23 = 0; + for (const s20 of this._$AV) + void 0 !== s20 && (void 0 !== s20.strings ? (s20._$AI(t17, s20, i23), i23 += s20.strings.length - 2) : s20._$AI(t17[i23])), i23++; + } + }; + var R4 = class _R { + constructor(t17, i23, s20, e33) { + var o29; + this.type = 2, this._$AH = A4, this._$AN = void 0, this._$AA = t17, this._$AB = i23, this._$AM = s20, this.options = e33, this._$Cp = null === (o29 = null == e33 ? void 0 : e33.isConnected) || void 0 === o29 || o29; + } + get _$AU() { + var t17, i23; + return null !== (i23 = null === (t17 = this._$AM) || void 0 === t17 ? void 0 : t17._$AU) && void 0 !== i23 ? i23 : this._$Cp; + } + get parentNode() { + let t17 = this._$AA.parentNode; + const i23 = this._$AM; + return void 0 !== i23 && 11 === (null == t17 ? void 0 : t17.nodeType) && (t17 = i23.parentNode), t17; + } + get startNode() { + return this._$AA; + } + get endNode() { + return this._$AB; + } + _$AI(t17, i23 = this) { + t17 = S8(this, t17, i23), d8(t17) ? t17 === A4 || null == t17 || "" === t17 ? (this._$AH !== A4 && this._$AR(), this._$AH = A4) : t17 !== this._$AH && t17 !== T4 && this._(t17) : void 0 !== t17._$litType$ ? this.g(t17) : void 0 !== t17.nodeType ? this.$(t17) : v4(t17) ? this.T(t17) : this._(t17); + } + k(t17) { + return this._$AA.parentNode.insertBefore(t17, this._$AB); + } + $(t17) { + this._$AH !== t17 && (this._$AR(), this._$AH = this.k(t17)); + } + _(t17) { + this._$AH !== A4 && d8(this._$AH) ? this._$AA.nextSibling.data = t17 : this.$(r14.createTextNode(t17)), this._$AH = t17; + } + g(t17) { + var i23; + const { values: s20, _$litType$: e33 } = t17, o29 = "number" == typeof e33 ? this._$AC(t17) : (void 0 === e33.el && (e33.el = N4.createElement(P4(e33.h, e33.h[0]), this.options)), e33); + if ((null === (i23 = this._$AH) || void 0 === i23 ? void 0 : i23._$AD) === o29) + this._$AH.v(s20); + else { + const t18 = new M4(o29, this), i24 = t18.u(this.options); + t18.v(s20), this.$(i24), this._$AH = t18; + } + } + _$AC(t17) { + let i23 = E4.get(t17.strings); + return void 0 === i23 && E4.set(t17.strings, i23 = new N4(t17)), i23; + } + T(t17) { + c9(this._$AH) || (this._$AH = [], this._$AR()); + const i23 = this._$AH; + let s20, e33 = 0; + for (const o29 of t17) + e33 === i23.length ? i23.push(s20 = new _R(this.k(u8()), this.k(u8()), this, this.options)) : s20 = i23[e33], s20._$AI(o29), e33++; + e33 < i23.length && (this._$AR(s20 && s20._$AB.nextSibling, e33), i23.length = e33); + } + _$AR(t17 = this._$AA.nextSibling, i23) { + var s20; + for (null === (s20 = this._$AP) || void 0 === s20 || s20.call(this, false, true, i23); t17 && t17 !== this._$AB; ) { + const i24 = t17.nextSibling; + t17.remove(), t17 = i24; + } + } + setConnected(t17) { + var i23; + void 0 === this._$AM && (this._$Cp = t17, null === (i23 = this._$AP) || void 0 === i23 || i23.call(this, t17)); + } + }; + var k6 = class { + constructor(t17, i23, s20, e33, o29) { + this.type = 1, this._$AH = A4, this._$AN = void 0, this.element = t17, this.name = i23, this._$AM = e33, this.options = o29, s20.length > 2 || "" !== s20[0] || "" !== s20[1] ? (this._$AH = Array(s20.length - 1).fill(new String()), this.strings = s20) : this._$AH = A4; + } + get tagName() { + return this.element.tagName; + } + get _$AU() { + return this._$AM._$AU; + } + _$AI(t17, i23 = this, s20, e33) { + const o29 = this.strings; + let n31 = false; + if (void 0 === o29) + t17 = S8(this, t17, i23, 0), n31 = !d8(t17) || t17 !== this._$AH && t17 !== T4, n31 && (this._$AH = t17); + else { + const e34 = t17; + let l20, h11; + for (t17 = o29[0], l20 = 0; l20 < o29.length - 1; l20++) + h11 = S8(this, e34[s20 + l20], i23, l20), h11 === T4 && (h11 = this._$AH[l20]), n31 || (n31 = !d8(h11) || h11 !== this._$AH[l20]), h11 === A4 ? t17 = A4 : t17 !== A4 && (t17 += (null != h11 ? h11 : "") + o29[l20 + 1]), this._$AH[l20] = h11; + } + n31 && !e33 && this.j(t17); + } + j(t17) { + t17 === A4 ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, null != t17 ? t17 : ""); + } + }; + var H4 = class extends k6 { + constructor() { + super(...arguments), this.type = 3; + } + j(t17) { + this.element[this.name] = t17 === A4 ? void 0 : t17; + } + }; + var I4 = s14 ? s14.emptyScript : ""; + var L4 = class extends k6 { + constructor() { + super(...arguments), this.type = 4; + } + j(t17) { + t17 && t17 !== A4 ? this.element.setAttribute(this.name, I4) : this.element.removeAttribute(this.name); + } + }; + var z3 = class extends k6 { + constructor(t17, i23, s20, e33, o29) { + super(t17, i23, s20, e33, o29), this.type = 5; + } + _$AI(t17, i23 = this) { + var s20; + if ((t17 = null !== (s20 = S8(this, t17, i23, 0)) && void 0 !== s20 ? s20 : A4) === T4) + return; + const e33 = this._$AH, o29 = t17 === A4 && e33 !== A4 || t17.capture !== e33.capture || t17.once !== e33.once || t17.passive !== e33.passive, n31 = t17 !== A4 && (e33 === A4 || o29); + o29 && this.element.removeEventListener(this.name, this, e33), n31 && this.element.addEventListener(this.name, this, t17), this._$AH = t17; + } + handleEvent(t17) { + var i23, s20; + "function" == typeof this._$AH ? this._$AH.call(null !== (s20 = null === (i23 = this.options) || void 0 === i23 ? void 0 : i23.host) && void 0 !== s20 ? s20 : this.element, t17) : this._$AH.handleEvent(t17); + } + }; + var Z4 = class { + constructor(t17, i23, s20) { + this.element = t17, this.type = 6, this._$AN = void 0, this._$AM = i23, this.options = s20; + } + get _$AU() { + return this._$AM._$AU; + } + _$AI(t17) { + S8(this, t17); + } + }; + var B3 = i16.litHtmlPolyfillSupport; + null == B3 || B3(N4, R4), (null !== (t12 = i16.litHtmlVersions) && void 0 !== t12 ? t12 : i16.litHtmlVersions = []).push("2.8.0"); + var D3 = (t17, i23, s20) => { + var e33, o29; + const n31 = null !== (e33 = null == s20 ? void 0 : s20.renderBefore) && void 0 !== e33 ? e33 : i23; + let l20 = n31._$litPart$; + if (void 0 === l20) { + const t18 = null !== (o29 = null == s20 ? void 0 : s20.renderBefore) && void 0 !== o29 ? o29 : null; + n31._$litPart$ = l20 = new R4(i23.insertBefore(u8(), t18), t18, void 0, null != s20 ? s20 : {}); + } + return l20._$AI(t17), l20; + }; + + // node_modules/@material/mwc-ripple/node_modules/lit-element/lit-element.js + var l14; + var o20; + var s15 = class extends u7 { + constructor() { + super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0; + } + createRenderRoot() { + var t17, e33; + const i23 = super.createRenderRoot(); + return null !== (t17 = (e33 = this.renderOptions).renderBefore) && void 0 !== t17 || (e33.renderBefore = i23.firstChild), i23; + } + update(t17) { + const i23 = this.render(); + this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t17), this._$Do = D3(i23, this.renderRoot, this.renderOptions); + } + connectedCallback() { + var t17; + super.connectedCallback(), null === (t17 = this._$Do) || void 0 === t17 || t17.setConnected(true); + } + disconnectedCallback() { + var t17; + super.disconnectedCallback(), null === (t17 = this._$Do) || void 0 === t17 || t17.setConnected(false); + } + render() { + return T4; + } + }; + s15.finalized = true, s15._$litElement$ = true, null === (l14 = globalThis.litElementHydrateSupport) || void 0 === l14 || l14.call(globalThis, { LitElement: s15 }); + var n23 = globalThis.litElementPolyfillSupport; + null == n23 || n23({ LitElement: s15 }); + (null !== (o20 = globalThis.litElementVersions) && void 0 !== o20 ? o20 : globalThis.litElementVersions = []).push("3.3.3"); + + // node_modules/@material/mwc-ripple/node_modules/lit-html/directive.js + var t13 = { ATTRIBUTE: 1, CHILD: 2, PROPERTY: 3, BOOLEAN_ATTRIBUTE: 4, EVENT: 5, ELEMENT: 6 }; + var e26 = (t17) => (...e33) => ({ _$litDirective$: t17, values: e33 }); + var i17 = class { + constructor(t17) { + } + get _$AU() { + return this._$AM._$AU; + } + _$AT(t17, e33, i23) { + this._$Ct = t17, this._$AM = e33, this._$Ci = i23; + } + _$AS(t17, e33) { + return this.update(t17, e33); + } + update(t17, e33) { + return this.render(...e33); + } + }; + + // node_modules/@material/mwc-ripple/node_modules/lit-html/directives/class-map.js + var o21 = e26(class extends i17 { + constructor(t17) { + var i23; + if (super(t17), t17.type !== t13.ATTRIBUTE || "class" !== t17.name || (null === (i23 = t17.strings) || void 0 === i23 ? void 0 : i23.length) > 2) + throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute."); + } + render(t17) { + return " " + Object.keys(t17).filter((i23) => t17[i23]).join(" ") + " "; + } + update(i23, [s20]) { + var r18, o29; + if (void 0 === this.it) { + this.it = /* @__PURE__ */ new Set(), void 0 !== i23.strings && (this.nt = new Set(i23.strings.join(" ").split(/\s/).filter((t17) => "" !== t17))); + for (const t17 in s20) + s20[t17] && !(null === (r18 = this.nt) || void 0 === r18 ? void 0 : r18.has(t17)) && this.it.add(t17); + return this.render(s20); + } + const e33 = i23.element.classList; + this.it.forEach((t17) => { + t17 in s20 || (e33.remove(t17), this.it.delete(t17)); + }); + for (const t17 in s20) { + const i24 = !!s20[t17]; + i24 === this.it.has(t17) || (null === (o29 = this.nt) || void 0 === o29 ? void 0 : o29.has(t17)) || (i24 ? (e33.add(t17), this.it.add(t17)) : (e33.remove(t17), this.it.delete(t17))); + } + return T4; + } + }); + + // node_modules/@material/mwc-ripple/node_modules/lit-html/directives/style-map.js + var i18 = "important"; + var n24 = " !" + i18; + var o22 = e26(class extends i17 { + constructor(t17) { + var e33; + if (super(t17), t17.type !== t13.ATTRIBUTE || "style" !== t17.name || (null === (e33 = t17.strings) || void 0 === e33 ? void 0 : e33.length) > 2) + throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute."); + } + render(t17) { + return Object.keys(t17).reduce((e33, r18) => { + const s20 = t17[r18]; + return null == s20 ? e33 : e33 + `${r18 = r18.includes("-") ? r18 : r18.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g, "-$&").toLowerCase()}:${s20};`; + }, ""); + } + update(e33, [r18]) { + const { style: s20 } = e33.element; + if (void 0 === this.ht) { + this.ht = /* @__PURE__ */ new Set(); + for (const t17 in r18) + this.ht.add(t17); + return this.render(r18); + } + this.ht.forEach((t17) => { + null == r18[t17] && (this.ht.delete(t17), t17.includes("-") ? s20.removeProperty(t17) : s20[t17] = ""); + }); + for (const t17 in r18) { + const e34 = r18[t17]; + if (null != e34) { + this.ht.add(t17); + const r19 = "string" == typeof e34 && e34.endsWith(n24); + t17.includes("-") || r19 ? s20.setProperty(t17, r19 ? e34.slice(0, -11) : e34, r19 ? i18 : "") : s20[t17] = e34; + } + } + return T4; + } + }); + + // node_modules/@material/mwc-ripple/mwc-ripple-base.js + var RippleBase = class extends BaseElement { + constructor() { + super(...arguments); + this.primary = false; + this.accent = false; + this.unbounded = false; + this.disabled = false; + this.activated = false; + this.selected = false; + this.internalUseStateLayerCustomProperties = false; + this.hovering = false; + this.bgFocused = false; + this.fgActivation = false; + this.fgDeactivation = false; + this.fgScale = ""; + this.fgSize = ""; + this.translateStart = ""; + this.translateEnd = ""; + this.leftPos = ""; + this.topPos = ""; + this.mdcFoundationClass = foundation_default; + } + get isActive() { + return matches2(this.parentElement || this, ":active"); + } + createAdapter() { + return { + browserSupportsCssVars: () => true, + isUnbounded: () => this.unbounded, + isSurfaceActive: () => this.isActive, + isSurfaceDisabled: () => this.disabled, + addClass: (className) => { + switch (className) { + case "mdc-ripple-upgraded--background-focused": + this.bgFocused = true; + break; + case "mdc-ripple-upgraded--foreground-activation": + this.fgActivation = true; + break; + case "mdc-ripple-upgraded--foreground-deactivation": + this.fgDeactivation = true; + break; + default: + break; + } + }, + removeClass: (className) => { + switch (className) { + case "mdc-ripple-upgraded--background-focused": + this.bgFocused = false; + break; + case "mdc-ripple-upgraded--foreground-activation": + this.fgActivation = false; + break; + case "mdc-ripple-upgraded--foreground-deactivation": + this.fgDeactivation = false; + break; + default: + break; + } + }, + containsEventTarget: () => true, + registerInteractionHandler: () => void 0, + deregisterInteractionHandler: () => void 0, + registerDocumentInteractionHandler: () => void 0, + deregisterDocumentInteractionHandler: () => void 0, + registerResizeHandler: () => void 0, + deregisterResizeHandler: () => void 0, + updateCssVariable: (varName, value) => { + switch (varName) { + case "--mdc-ripple-fg-scale": + this.fgScale = value; + break; + case "--mdc-ripple-fg-size": + this.fgSize = value; + break; + case "--mdc-ripple-fg-translate-end": + this.translateEnd = value; + break; + case "--mdc-ripple-fg-translate-start": + this.translateStart = value; + break; + case "--mdc-ripple-left": + this.leftPos = value; + break; + case "--mdc-ripple-top": + this.topPos = value; + break; + default: + break; + } + }, + computeBoundingRect: () => (this.parentElement || this).getBoundingClientRect(), + getWindowPageOffset: () => ({ x: window.pageXOffset, y: window.pageYOffset }) + }; + } + startPress(ev) { + this.waitForFoundation(() => { + this.mdcFoundation.activate(ev); + }); + } + endPress() { + this.waitForFoundation(() => { + this.mdcFoundation.deactivate(); + }); + } + startFocus() { + this.waitForFoundation(() => { + this.mdcFoundation.handleFocus(); + }); + } + endFocus() { + this.waitForFoundation(() => { + this.mdcFoundation.handleBlur(); + }); + } + startHover() { + this.hovering = true; + } + endHover() { + this.hovering = false; + } + /** + * Wait for the MDCFoundation to be created by `firstUpdated` + */ + waitForFoundation(fn2) { + if (this.mdcFoundation) { + fn2(); + } else { + this.updateComplete.then(fn2); + } + } + update(changedProperties) { + if (changedProperties.has("disabled")) { + if (this.disabled) { + this.endHover(); + } + } + super.update(changedProperties); + } + /** @soyTemplate */ + render() { + const shouldActivateInPrimary = this.activated && (this.primary || !this.accent); + const shouldSelectInPrimary = this.selected && (this.primary || !this.accent); + const classes = { + "mdc-ripple-surface--accent": this.accent, + "mdc-ripple-surface--primary--activated": shouldActivateInPrimary, + "mdc-ripple-surface--accent--activated": this.accent && this.activated, + "mdc-ripple-surface--primary--selected": shouldSelectInPrimary, + "mdc-ripple-surface--accent--selected": this.accent && this.selected, + "mdc-ripple-surface--disabled": this.disabled, + "mdc-ripple-surface--hover": this.hovering, + "mdc-ripple-surface--primary": this.primary, + "mdc-ripple-surface--selected": this.selected, + "mdc-ripple-upgraded--background-focused": this.bgFocused, + "mdc-ripple-upgraded--foreground-activation": this.fgActivation, + "mdc-ripple-upgraded--foreground-deactivation": this.fgDeactivation, + "mdc-ripple-upgraded--unbounded": this.unbounded, + "mdc-ripple-surface--internal-use-state-layer-custom-properties": this.internalUseStateLayerCustomProperties + }; + return x4` +
    `; + } + }; + __decorate([ + i12(".mdc-ripple-surface") + ], RippleBase.prototype, "mdcRoot", void 0); + __decorate([ + n14({ type: Boolean }) + ], RippleBase.prototype, "primary", void 0); + __decorate([ + n14({ type: Boolean }) + ], RippleBase.prototype, "accent", void 0); + __decorate([ + n14({ type: Boolean }) + ], RippleBase.prototype, "unbounded", void 0); + __decorate([ + n14({ type: Boolean }) + ], RippleBase.prototype, "disabled", void 0); + __decorate([ + n14({ type: Boolean }) + ], RippleBase.prototype, "activated", void 0); + __decorate([ + n14({ type: Boolean }) + ], RippleBase.prototype, "selected", void 0); + __decorate([ + n14({ type: Boolean }) + ], RippleBase.prototype, "internalUseStateLayerCustomProperties", void 0); + __decorate([ + t8() + ], RippleBase.prototype, "hovering", void 0); + __decorate([ + t8() + ], RippleBase.prototype, "bgFocused", void 0); + __decorate([ + t8() + ], RippleBase.prototype, "fgActivation", void 0); + __decorate([ + t8() + ], RippleBase.prototype, "fgDeactivation", void 0); + __decorate([ + t8() + ], RippleBase.prototype, "fgScale", void 0); + __decorate([ + t8() + ], RippleBase.prototype, "fgSize", void 0); + __decorate([ + t8() + ], RippleBase.prototype, "translateStart", void 0); + __decorate([ + t8() + ], RippleBase.prototype, "translateEnd", void 0); + __decorate([ + t8() + ], RippleBase.prototype, "leftPos", void 0); + __decorate([ + t8() + ], RippleBase.prototype, "topPos", void 0); + + // node_modules/@material/mwc-ripple/mwc-ripple.css.js + var styles12 = i15`.mdc-ripple-surface{--mdc-ripple-fg-size: 0;--mdc-ripple-left: 0;--mdc-ripple-top: 0;--mdc-ripple-fg-scale: 1;--mdc-ripple-fg-translate-end: 0;--mdc-ripple-fg-translate-start: 0;-webkit-tap-highlight-color:rgba(0,0,0,0);will-change:transform,opacity;position:relative;outline:none;overflow:hidden}.mdc-ripple-surface::before,.mdc-ripple-surface::after{position:absolute;border-radius:50%;opacity:0;pointer-events:none;content:""}.mdc-ripple-surface::before{transition:opacity 15ms linear,background-color 15ms linear;z-index:1;z-index:var(--mdc-ripple-z-index, 1)}.mdc-ripple-surface::after{z-index:0;z-index:var(--mdc-ripple-z-index, 0)}.mdc-ripple-surface.mdc-ripple-upgraded::before{transform:scale(var(--mdc-ripple-fg-scale, 1))}.mdc-ripple-surface.mdc-ripple-upgraded::after{top:0;left:0;transform:scale(0);transform-origin:center center}.mdc-ripple-surface.mdc-ripple-upgraded--unbounded::after{top:var(--mdc-ripple-top, 0);left:var(--mdc-ripple-left, 0)}.mdc-ripple-surface.mdc-ripple-upgraded--foreground-activation::after{animation:mdc-ripple-fg-radius-in 225ms forwards,mdc-ripple-fg-opacity-in 75ms forwards}.mdc-ripple-surface.mdc-ripple-upgraded--foreground-deactivation::after{animation:mdc-ripple-fg-opacity-out 150ms;transform:translate(var(--mdc-ripple-fg-translate-end, 0)) scale(var(--mdc-ripple-fg-scale, 1))}.mdc-ripple-surface::before,.mdc-ripple-surface::after{top:calc(50% - 100%);left:calc(50% - 100%);width:200%;height:200%}.mdc-ripple-surface.mdc-ripple-upgraded::after{width:var(--mdc-ripple-fg-size, 100%);height:var(--mdc-ripple-fg-size, 100%)}.mdc-ripple-surface[data-mdc-ripple-is-unbounded],.mdc-ripple-upgraded--unbounded{overflow:visible}.mdc-ripple-surface[data-mdc-ripple-is-unbounded]::before,.mdc-ripple-surface[data-mdc-ripple-is-unbounded]::after,.mdc-ripple-upgraded--unbounded::before,.mdc-ripple-upgraded--unbounded::after{top:calc(50% - 50%);left:calc(50% - 50%);width:100%;height:100%}.mdc-ripple-surface[data-mdc-ripple-is-unbounded].mdc-ripple-upgraded::before,.mdc-ripple-surface[data-mdc-ripple-is-unbounded].mdc-ripple-upgraded::after,.mdc-ripple-upgraded--unbounded.mdc-ripple-upgraded::before,.mdc-ripple-upgraded--unbounded.mdc-ripple-upgraded::after{top:var(--mdc-ripple-top, calc(50% - 50%));left:var(--mdc-ripple-left, calc(50% - 50%));width:var(--mdc-ripple-fg-size, 100%);height:var(--mdc-ripple-fg-size, 100%)}.mdc-ripple-surface[data-mdc-ripple-is-unbounded].mdc-ripple-upgraded::after,.mdc-ripple-upgraded--unbounded.mdc-ripple-upgraded::after{width:var(--mdc-ripple-fg-size, 100%);height:var(--mdc-ripple-fg-size, 100%)}.mdc-ripple-surface::before,.mdc-ripple-surface::after{background-color:#000;background-color:var(--mdc-ripple-color, #000)}.mdc-ripple-surface:hover::before,.mdc-ripple-surface.mdc-ripple-surface--hover::before{opacity:0.04;opacity:var(--mdc-ripple-hover-opacity, 0.04)}.mdc-ripple-surface.mdc-ripple-upgraded--background-focused::before,.mdc-ripple-surface:not(.mdc-ripple-upgraded):focus::before{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-focus-opacity, 0.12)}.mdc-ripple-surface:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-ripple-surface:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-press-opacity, 0.12)}.mdc-ripple-surface.mdc-ripple-upgraded{--mdc-ripple-fg-opacity:var(--mdc-ripple-press-opacity, 0.12)}@keyframes mdc-ripple-fg-radius-in{from{animation-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transform:translate(var(--mdc-ripple-fg-translate-start, 0)) scale(1)}to{transform:translate(var(--mdc-ripple-fg-translate-end, 0)) scale(var(--mdc-ripple-fg-scale, 1))}}@keyframes mdc-ripple-fg-opacity-in{from{animation-timing-function:linear;opacity:0}to{opacity:var(--mdc-ripple-fg-opacity, 0)}}@keyframes mdc-ripple-fg-opacity-out{from{animation-timing-function:linear;opacity:var(--mdc-ripple-fg-opacity, 0)}to{opacity:0}}:host{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;display:block}:host .mdc-ripple-surface{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;will-change:unset}.mdc-ripple-surface--primary::before,.mdc-ripple-surface--primary::after{background-color:#6200ee;background-color:var(--mdc-ripple-color, var(--mdc-theme-primary, #6200ee))}.mdc-ripple-surface--primary:hover::before,.mdc-ripple-surface--primary.mdc-ripple-surface--hover::before{opacity:0.04;opacity:var(--mdc-ripple-hover-opacity, 0.04)}.mdc-ripple-surface--primary.mdc-ripple-upgraded--background-focused::before,.mdc-ripple-surface--primary:not(.mdc-ripple-upgraded):focus::before{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-focus-opacity, 0.12)}.mdc-ripple-surface--primary:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-ripple-surface--primary:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-press-opacity, 0.12)}.mdc-ripple-surface--primary.mdc-ripple-upgraded{--mdc-ripple-fg-opacity:var(--mdc-ripple-press-opacity, 0.12)}.mdc-ripple-surface--primary--activated::before{opacity:0.12;opacity:var(--mdc-ripple-activated-opacity, 0.12)}.mdc-ripple-surface--primary--activated::before,.mdc-ripple-surface--primary--activated::after{background-color:#6200ee;background-color:var(--mdc-ripple-color, var(--mdc-theme-primary, #6200ee))}.mdc-ripple-surface--primary--activated:hover::before,.mdc-ripple-surface--primary--activated.mdc-ripple-surface--hover::before{opacity:0.16;opacity:var(--mdc-ripple-hover-opacity, 0.16)}.mdc-ripple-surface--primary--activated.mdc-ripple-upgraded--background-focused::before,.mdc-ripple-surface--primary--activated:not(.mdc-ripple-upgraded):focus::before{transition-duration:75ms;opacity:0.24;opacity:var(--mdc-ripple-focus-opacity, 0.24)}.mdc-ripple-surface--primary--activated:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-ripple-surface--primary--activated:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:0.24;opacity:var(--mdc-ripple-press-opacity, 0.24)}.mdc-ripple-surface--primary--activated.mdc-ripple-upgraded{--mdc-ripple-fg-opacity:var(--mdc-ripple-press-opacity, 0.24)}.mdc-ripple-surface--primary--selected::before{opacity:0.08;opacity:var(--mdc-ripple-selected-opacity, 0.08)}.mdc-ripple-surface--primary--selected::before,.mdc-ripple-surface--primary--selected::after{background-color:#6200ee;background-color:var(--mdc-ripple-color, var(--mdc-theme-primary, #6200ee))}.mdc-ripple-surface--primary--selected:hover::before,.mdc-ripple-surface--primary--selected.mdc-ripple-surface--hover::before{opacity:0.12;opacity:var(--mdc-ripple-hover-opacity, 0.12)}.mdc-ripple-surface--primary--selected.mdc-ripple-upgraded--background-focused::before,.mdc-ripple-surface--primary--selected:not(.mdc-ripple-upgraded):focus::before{transition-duration:75ms;opacity:0.2;opacity:var(--mdc-ripple-focus-opacity, 0.2)}.mdc-ripple-surface--primary--selected:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-ripple-surface--primary--selected:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:0.2;opacity:var(--mdc-ripple-press-opacity, 0.2)}.mdc-ripple-surface--primary--selected.mdc-ripple-upgraded{--mdc-ripple-fg-opacity:var(--mdc-ripple-press-opacity, 0.2)}.mdc-ripple-surface--accent::before,.mdc-ripple-surface--accent::after{background-color:#018786;background-color:var(--mdc-ripple-color, var(--mdc-theme-secondary, #018786))}.mdc-ripple-surface--accent:hover::before,.mdc-ripple-surface--accent.mdc-ripple-surface--hover::before{opacity:0.04;opacity:var(--mdc-ripple-hover-opacity, 0.04)}.mdc-ripple-surface--accent.mdc-ripple-upgraded--background-focused::before,.mdc-ripple-surface--accent:not(.mdc-ripple-upgraded):focus::before{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-focus-opacity, 0.12)}.mdc-ripple-surface--accent:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-ripple-surface--accent:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-press-opacity, 0.12)}.mdc-ripple-surface--accent.mdc-ripple-upgraded{--mdc-ripple-fg-opacity:var(--mdc-ripple-press-opacity, 0.12)}.mdc-ripple-surface--accent--activated::before{opacity:0.12;opacity:var(--mdc-ripple-activated-opacity, 0.12)}.mdc-ripple-surface--accent--activated::before,.mdc-ripple-surface--accent--activated::after{background-color:#018786;background-color:var(--mdc-ripple-color, var(--mdc-theme-secondary, #018786))}.mdc-ripple-surface--accent--activated:hover::before,.mdc-ripple-surface--accent--activated.mdc-ripple-surface--hover::before{opacity:0.16;opacity:var(--mdc-ripple-hover-opacity, 0.16)}.mdc-ripple-surface--accent--activated.mdc-ripple-upgraded--background-focused::before,.mdc-ripple-surface--accent--activated:not(.mdc-ripple-upgraded):focus::before{transition-duration:75ms;opacity:0.24;opacity:var(--mdc-ripple-focus-opacity, 0.24)}.mdc-ripple-surface--accent--activated:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-ripple-surface--accent--activated:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:0.24;opacity:var(--mdc-ripple-press-opacity, 0.24)}.mdc-ripple-surface--accent--activated.mdc-ripple-upgraded{--mdc-ripple-fg-opacity:var(--mdc-ripple-press-opacity, 0.24)}.mdc-ripple-surface--accent--selected::before{opacity:0.08;opacity:var(--mdc-ripple-selected-opacity, 0.08)}.mdc-ripple-surface--accent--selected::before,.mdc-ripple-surface--accent--selected::after{background-color:#018786;background-color:var(--mdc-ripple-color, var(--mdc-theme-secondary, #018786))}.mdc-ripple-surface--accent--selected:hover::before,.mdc-ripple-surface--accent--selected.mdc-ripple-surface--hover::before{opacity:0.12;opacity:var(--mdc-ripple-hover-opacity, 0.12)}.mdc-ripple-surface--accent--selected.mdc-ripple-upgraded--background-focused::before,.mdc-ripple-surface--accent--selected:not(.mdc-ripple-upgraded):focus::before{transition-duration:75ms;opacity:0.2;opacity:var(--mdc-ripple-focus-opacity, 0.2)}.mdc-ripple-surface--accent--selected:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-ripple-surface--accent--selected:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:0.2;opacity:var(--mdc-ripple-press-opacity, 0.2)}.mdc-ripple-surface--accent--selected.mdc-ripple-upgraded{--mdc-ripple-fg-opacity:var(--mdc-ripple-press-opacity, 0.2)}.mdc-ripple-surface--disabled{opacity:0}.mdc-ripple-surface--internal-use-state-layer-custom-properties::before,.mdc-ripple-surface--internal-use-state-layer-custom-properties::after{background-color:#000;background-color:var(--mdc-ripple-hover-state-layer-color, #000)}.mdc-ripple-surface--internal-use-state-layer-custom-properties:hover::before,.mdc-ripple-surface--internal-use-state-layer-custom-properties.mdc-ripple-surface--hover::before{opacity:0.04;opacity:var(--mdc-ripple-hover-state-layer-opacity, 0.04)}.mdc-ripple-surface--internal-use-state-layer-custom-properties.mdc-ripple-upgraded--background-focused::before,.mdc-ripple-surface--internal-use-state-layer-custom-properties:not(.mdc-ripple-upgraded):focus::before{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-focus-state-layer-opacity, 0.12)}.mdc-ripple-surface--internal-use-state-layer-custom-properties:not(.mdc-ripple-upgraded)::after{transition:opacity 150ms linear}.mdc-ripple-surface--internal-use-state-layer-custom-properties:not(.mdc-ripple-upgraded):active::after{transition-duration:75ms;opacity:0.12;opacity:var(--mdc-ripple-pressed-state-layer-opacity, 0.12)}.mdc-ripple-surface--internal-use-state-layer-custom-properties.mdc-ripple-upgraded{--mdc-ripple-fg-opacity:var(--mdc-ripple-pressed-state-layer-opacity, 0.12)}`; + + // node_modules/@material/mwc-ripple/mwc-ripple.js + var Ripple = class Ripple2 extends RippleBase { + }; + Ripple.styles = [styles12]; + Ripple = __decorate([ + e17("mwc-ripple") + ], Ripple); + + // node_modules/@material/mwc-base/aria-property.js + function tsDecorator(prototype, name, descriptor) { + const constructor = prototype.constructor; + if (!descriptor) { + const litInternalPropertyKey = `__${name}`; + descriptor = constructor.getPropertyDescriptor(name, litInternalPropertyKey); + if (!descriptor) { + throw new Error("@ariaProperty must be used after a @property decorator"); + } + } + const propDescriptor = descriptor; + let attribute = ""; + if (!propDescriptor.set) { + throw new Error(`@ariaProperty requires a setter for ${name}`); + } + if (prototype.dispatchWizEvent) { + return descriptor; + } + const wrappedDescriptor = { + configurable: true, + enumerable: true, + set(value) { + if (attribute === "") { + const options = constructor.getPropertyOptions(name); + attribute = typeof options.attribute === "string" ? options.attribute : name; + } + if (this.hasAttribute(attribute)) { + this.removeAttribute(attribute); + } + propDescriptor.set.call(this, value); + } + }; + if (propDescriptor.get) { + wrappedDescriptor.get = function() { + return propDescriptor.get.call(this); + }; + } + return wrappedDescriptor; + } + function ariaProperty(protoOrDescriptor, name, descriptor) { + if (name !== void 0) { + return tsDecorator(protoOrDescriptor, name, descriptor); + } else { + throw new Error("@ariaProperty only supports TypeScript Decorators"); + } + } + + // node_modules/@material/mwc-base/node_modules/@lit/reactive-element/decorators/property.js + var i19 = (i23, e33) => "method" === e33.kind && e33.descriptor && !("value" in e33.descriptor) ? { ...e33, finisher(n31) { + n31.createProperty(e33.key, i23); + } } : { kind: "field", key: Symbol(), placement: "own", descriptor: {}, originalKey: e33.key, initializer() { + "function" == typeof e33.initializer && (this[e33.key] = e33.initializer.call(this)); + }, finisher(n31) { + n31.createProperty(e33.key, i23); + } }; + var e27 = (i23, e33, n31) => { + e33.constructor.createProperty(n31, i23); + }; + function n25(n31) { + return (t17, o29) => void 0 !== o29 ? e27(n31, t17, o29) : i19(n31, t17); + } + + // node_modules/@material/mwc-base/node_modules/@lit/reactive-element/decorators/query-assigned-elements.js + var n26; + var e28 = null != (null === (n26 = window.HTMLSlotElement) || void 0 === n26 ? void 0 : n26.prototype.assignedElements) ? (o29, n31) => o29.assignedElements(n31) : (o29, n31) => o29.assignedNodes(n31).filter((o30) => o30.nodeType === Node.ELEMENT_NODE); + + // node_modules/@material/mwc-base/form-element.js + var _a; + var _b; + var USING_SHADY_DOM = (_b = (_a = window.ShadyDOM) === null || _a === void 0 ? void 0 : _a.inUse) !== null && _b !== void 0 ? _b : false; + var FormElement = class extends BaseElement { + constructor() { + super(...arguments); + this.disabled = false; + this.containingForm = null; + this.formDataListener = (ev) => { + if (!this.disabled) { + this.setFormData(ev.formData); + } + }; + } + findFormElement() { + if (!this.shadowRoot || USING_SHADY_DOM) { + return null; + } + const root = this.getRootNode(); + const forms = root.querySelectorAll("form"); + for (const form of Array.from(forms)) { + if (form.contains(this)) { + return form; + } + } + return null; + } + connectedCallback() { + var _a2; + super.connectedCallback(); + this.containingForm = this.findFormElement(); + (_a2 = this.containingForm) === null || _a2 === void 0 ? void 0 : _a2.addEventListener("formdata", this.formDataListener); + } + disconnectedCallback() { + var _a2; + super.disconnectedCallback(); + (_a2 = this.containingForm) === null || _a2 === void 0 ? void 0 : _a2.removeEventListener("formdata", this.formDataListener); + this.containingForm = null; + } + click() { + if (this.formElement && !this.disabled) { + this.formElement.focus(); + this.formElement.click(); + } + } + firstUpdated() { + super.firstUpdated(); + if (this.shadowRoot) { + this.mdcRoot.addEventListener("change", (e33) => { + this.dispatchEvent(new Event("change", e33)); + }); + } + } + }; + FormElement.shadowRootOptions = { mode: "open", delegatesFocus: true }; + __decorate([ + n25({ type: Boolean }) + ], FormElement.prototype, "disabled", void 0); + + // node_modules/@material/mwc-ripple/ripple-handlers.js + var RippleHandlers = class { + constructor(rippleFn) { + this.startPress = (ev) => { + rippleFn().then((r18) => { + r18 && r18.startPress(ev); + }); + }; + this.endPress = () => { + rippleFn().then((r18) => { + r18 && r18.endPress(); + }); + }; + this.startFocus = () => { + rippleFn().then((r18) => { + r18 && r18.startFocus(); + }); + }; + this.endFocus = () => { + rippleFn().then((r18) => { + r18 && r18.endFocus(); + }); + }; + this.startHover = () => { + rippleFn().then((r18) => { + r18 && r18.startHover(); + }); + }; + this.endHover = () => { + rippleFn().then((r18) => { + r18 && r18.endHover(); + }); + }; + } + }; + + // node_modules/@material/base/observer.js + function observeProperty(target, property, observer) { + var targetObservers = installObserver(target, property); + var observers = targetObservers.getObservers(property); + observers.push(observer); + return function() { + observers.splice(observers.indexOf(observer), 1); + }; + } + var allTargetObservers = /* @__PURE__ */ new WeakMap(); + function installObserver(target, property) { + var observersMap = /* @__PURE__ */ new Map(); + if (!allTargetObservers.has(target)) { + allTargetObservers.set(target, { + isEnabled: true, + getObservers: function(key) { + var observers = observersMap.get(key) || []; + if (!observersMap.has(key)) { + observersMap.set(key, observers); + } + return observers; + }, + installedProperties: /* @__PURE__ */ new Set() + }); + } + var targetObservers = allTargetObservers.get(target); + if (targetObservers.installedProperties.has(property)) { + return targetObservers; + } + var descriptor = getDescriptor2(target, property) || { + configurable: true, + enumerable: true, + value: target[property], + writable: true + }; + var observedDescriptor = __assign({}, descriptor); + var descGet = descriptor.get, descSet = descriptor.set; + if ("value" in descriptor) { + delete observedDescriptor.value; + delete observedDescriptor.writable; + var value_1 = descriptor.value; + descGet = function() { + return value_1; + }; + if (descriptor.writable) { + descSet = function(newValue) { + value_1 = newValue; + }; + } + } + if (descGet) { + observedDescriptor.get = function() { + return descGet.call(this); + }; + } + if (descSet) { + observedDescriptor.set = function(newValue) { + var e_4, _a2; + var previous = descGet ? descGet.call(this) : newValue; + descSet.call(this, newValue); + if (targetObservers.isEnabled && (!descGet || newValue !== previous)) { + try { + for (var _b2 = __values(targetObservers.getObservers(property)), _c = _b2.next(); !_c.done; _c = _b2.next()) { + var observer = _c.value; + observer(newValue, previous); + } + } catch (e_4_1) { + e_4 = { error: e_4_1 }; + } finally { + try { + if (_c && !_c.done && (_a2 = _b2.return)) + _a2.call(_b2); + } finally { + if (e_4) + throw e_4.error; + } + } + } + }; + } + targetObservers.installedProperties.add(property); + Object.defineProperty(target, property, observedDescriptor); + return targetObservers; + } + function getDescriptor2(target, property) { + var descriptorTarget = target; + var descriptor; + while (descriptorTarget) { + descriptor = Object.getOwnPropertyDescriptor(descriptorTarget, property); + if (descriptor) { + break; + } + descriptorTarget = Object.getPrototypeOf(descriptorTarget); + } + return descriptor; + } + function setObserversEnabled(target, enabled) { + var targetObservers = allTargetObservers.get(target); + if (targetObservers) { + targetObservers.isEnabled = enabled; + } + } + + // node_modules/@material/base/observer-foundation.js + var MDCObserverFoundation = ( + /** @class */ + function(_super) { + __extends(MDCObserverFoundation2, _super); + function MDCObserverFoundation2(adapter) { + var _this = _super.call(this, adapter) || this; + _this.unobserves = /* @__PURE__ */ new Set(); + return _this; + } + MDCObserverFoundation2.prototype.destroy = function() { + _super.prototype.destroy.call(this); + this.unobserve(); + }; + MDCObserverFoundation2.prototype.observe = function(target, observers) { + var e_1, _a2; + var _this = this; + var cleanup = []; + try { + for (var _b2 = __values(Object.keys(observers)), _c = _b2.next(); !_c.done; _c = _b2.next()) { + var property = _c.value; + var observer = observers[property].bind(this); + cleanup.push(this.observeProperty(target, property, observer)); + } + } catch (e_1_1) { + e_1 = { error: e_1_1 }; + } finally { + try { + if (_c && !_c.done && (_a2 = _b2.return)) + _a2.call(_b2); + } finally { + if (e_1) + throw e_1.error; + } + } + var unobserve = function() { + var e_2, _a3; + try { + for (var cleanup_1 = __values(cleanup), cleanup_1_1 = cleanup_1.next(); !cleanup_1_1.done; cleanup_1_1 = cleanup_1.next()) { + var cleanupFn = cleanup_1_1.value; + cleanupFn(); + } + } catch (e_2_1) { + e_2 = { error: e_2_1 }; + } finally { + try { + if (cleanup_1_1 && !cleanup_1_1.done && (_a3 = cleanup_1.return)) + _a3.call(cleanup_1); + } finally { + if (e_2) + throw e_2.error; + } + } + _this.unobserves.delete(unobserve); + }; + this.unobserves.add(unobserve); + return unobserve; + }; + MDCObserverFoundation2.prototype.observeProperty = function(target, property, observer) { + return observeProperty(target, property, observer); + }; + MDCObserverFoundation2.prototype.setObserversEnabled = function(target, enabled) { + setObserversEnabled(target, enabled); + }; + MDCObserverFoundation2.prototype.unobserve = function() { + var e_3, _a2; + try { + for (var _b2 = __values(__spreadArray([], __read(this.unobserves))), _c = _b2.next(); !_c.done; _c = _b2.next()) { + var unobserve = _c.value; + unobserve(); + } + } catch (e_3_1) { + e_3 = { error: e_3_1 }; + } finally { + try { + if (_c && !_c.done && (_a2 = _b2.return)) + _a2.call(_b2); + } finally { + if (e_3) + throw e_3.error; + } + } + }; + return MDCObserverFoundation2; + }(MDCFoundation) + ); + + // node_modules/@material/switch/constants.js + var CssClasses; + (function(CssClasses2) { + CssClasses2["PROCESSING"] = "mdc-switch--processing"; + CssClasses2["SELECTED"] = "mdc-switch--selected"; + CssClasses2["UNSELECTED"] = "mdc-switch--unselected"; + })(CssClasses || (CssClasses = {})); + var Selectors; + (function(Selectors2) { + Selectors2["RIPPLE"] = ".mdc-switch__ripple"; + })(Selectors || (Selectors = {})); + + // node_modules/@material/switch/foundation.js + var MDCSwitchFoundation = ( + /** @class */ + function(_super) { + __extends(MDCSwitchFoundation2, _super); + function MDCSwitchFoundation2(adapter) { + var _this = _super.call(this, adapter) || this; + _this.handleClick = _this.handleClick.bind(_this); + return _this; + } + MDCSwitchFoundation2.prototype.init = function() { + this.observe(this.adapter.state, { + disabled: this.stopProcessingIfDisabled, + processing: this.stopProcessingIfDisabled + }); + }; + MDCSwitchFoundation2.prototype.handleClick = function() { + if (this.adapter.state.disabled) { + return; + } + this.adapter.state.selected = !this.adapter.state.selected; + }; + MDCSwitchFoundation2.prototype.stopProcessingIfDisabled = function() { + if (this.adapter.state.disabled) { + this.adapter.state.processing = false; + } + }; + return MDCSwitchFoundation2; + }(MDCObserverFoundation) + ); + var MDCSwitchRenderFoundation = ( + /** @class */ + function(_super) { + __extends(MDCSwitchRenderFoundation2, _super); + function MDCSwitchRenderFoundation2() { + return _super !== null && _super.apply(this, arguments) || this; + } + MDCSwitchRenderFoundation2.prototype.init = function() { + _super.prototype.init.call(this); + this.observe(this.adapter.state, { + disabled: this.onDisabledChange, + processing: this.onProcessingChange, + selected: this.onSelectedChange + }); + }; + MDCSwitchRenderFoundation2.prototype.initFromDOM = function() { + this.setObserversEnabled(this.adapter.state, false); + this.adapter.state.selected = this.adapter.hasClass(CssClasses.SELECTED); + this.onSelectedChange(); + this.adapter.state.disabled = this.adapter.isDisabled(); + this.adapter.state.processing = this.adapter.hasClass(CssClasses.PROCESSING); + this.setObserversEnabled(this.adapter.state, true); + this.stopProcessingIfDisabled(); + }; + MDCSwitchRenderFoundation2.prototype.onDisabledChange = function() { + this.adapter.setDisabled(this.adapter.state.disabled); + }; + MDCSwitchRenderFoundation2.prototype.onProcessingChange = function() { + this.toggleClass(this.adapter.state.processing, CssClasses.PROCESSING); + }; + MDCSwitchRenderFoundation2.prototype.onSelectedChange = function() { + this.adapter.setAriaChecked(String(this.adapter.state.selected)); + this.toggleClass(this.adapter.state.selected, CssClasses.SELECTED); + this.toggleClass(!this.adapter.state.selected, CssClasses.UNSELECTED); + }; + MDCSwitchRenderFoundation2.prototype.toggleClass = function(addClass, className) { + if (addClass) { + this.adapter.addClass(className); + } else { + this.adapter.removeClass(className); + } + }; + return MDCSwitchRenderFoundation2; + }(MDCSwitchFoundation) + ); + + // node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/css-tag.js + var t14 = window; + var e29 = t14.ShadowRoot && (void 0 === t14.ShadyCSS || t14.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype; + var s16 = Symbol(); + var n27 = /* @__PURE__ */ new WeakMap(); + var o24 = class { + constructor(t17, e33, n31) { + if (this._$cssResult$ = true, n31 !== s16) + throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); + this.cssText = t17, this.t = e33; + } + get styleSheet() { + let t17 = this.o; + const s20 = this.t; + if (e29 && void 0 === t17) { + const e33 = void 0 !== s20 && 1 === s20.length; + e33 && (t17 = n27.get(s20)), void 0 === t17 && ((this.o = t17 = new CSSStyleSheet()).replaceSync(this.cssText), e33 && n27.set(s20, t17)); + } + return t17; + } + toString() { + return this.cssText; + } + }; + var r15 = (t17) => new o24("string" == typeof t17 ? t17 : t17 + "", void 0, s16); + var i20 = (t17, ...e33) => { + const n31 = 1 === t17.length ? t17[0] : e33.reduce((e34, s20, n32) => e34 + ((t18) => { + if (true === t18._$cssResult$) + return t18.cssText; + if ("number" == typeof t18) + return t18; + throw Error("Value passed to 'css' function must be a 'css' function result: " + t18 + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security."); + })(s20) + t17[n32 + 1], t17[0]); + return new o24(n31, t17, s16); + }; + var S9 = (s20, n31) => { + e29 ? s20.adoptedStyleSheets = n31.map((t17) => t17 instanceof CSSStyleSheet ? t17 : t17.styleSheet) : n31.forEach((e33) => { + const n32 = document.createElement("style"), o29 = t14.litNonce; + void 0 !== o29 && n32.setAttribute("nonce", o29), n32.textContent = e33.cssText, s20.appendChild(n32); + }); + }; + var c10 = e29 ? (t17) => t17 : (t17) => t17 instanceof CSSStyleSheet ? ((t18) => { + let e33 = ""; + for (const s20 of t18.cssRules) + e33 += s20.cssText; + return r15(e33); + })(t17) : t17; + + // node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/reactive-element.js + var s17; + var e30 = window; + var r16 = e30.trustedTypes; + var h9 = r16 ? r16.emptyScript : ""; + var o25 = e30.reactiveElementPolyfillSupport; + var n28 = { toAttribute(t17, i23) { + switch (i23) { + case Boolean: + t17 = t17 ? h9 : null; + break; + case Object: + case Array: + t17 = null == t17 ? t17 : JSON.stringify(t17); + } + return t17; + }, fromAttribute(t17, i23) { + let s20 = t17; + switch (i23) { + case Boolean: + s20 = null !== t17; + break; + case Number: + s20 = null === t17 ? null : Number(t17); + break; + case Object: + case Array: + try { + s20 = JSON.parse(t17); + } catch (t18) { + s20 = null; + } + } + return s20; + } }; + var a9 = (t17, i23) => i23 !== t17 && (i23 == i23 || t17 == t17); + var l16 = { attribute: true, type: String, converter: n28, reflect: false, hasChanged: a9 }; + var d9 = "finalized"; + var u9 = class extends HTMLElement { + constructor() { + super(), this._$Ei = /* @__PURE__ */ new Map(), this.isUpdatePending = false, this.hasUpdated = false, this._$El = null, this._$Eu(); + } + static addInitializer(t17) { + var i23; + this.finalize(), (null !== (i23 = this.h) && void 0 !== i23 ? i23 : this.h = []).push(t17); + } + static get observedAttributes() { + this.finalize(); + const t17 = []; + return this.elementProperties.forEach((i23, s20) => { + const e33 = this._$Ep(s20, i23); + void 0 !== e33 && (this._$Ev.set(e33, s20), t17.push(e33)); + }), t17; + } + static createProperty(t17, i23 = l16) { + if (i23.state && (i23.attribute = false), this.finalize(), this.elementProperties.set(t17, i23), !i23.noAccessor && !this.prototype.hasOwnProperty(t17)) { + const s20 = "symbol" == typeof t17 ? Symbol() : "__" + t17, e33 = this.getPropertyDescriptor(t17, s20, i23); + void 0 !== e33 && Object.defineProperty(this.prototype, t17, e33); + } + } + static getPropertyDescriptor(t17, i23, s20) { + return { get() { + return this[i23]; + }, set(e33) { + const r18 = this[t17]; + this[i23] = e33, this.requestUpdate(t17, r18, s20); + }, configurable: true, enumerable: true }; + } + static getPropertyOptions(t17) { + return this.elementProperties.get(t17) || l16; + } + static finalize() { + if (this.hasOwnProperty(d9)) + return false; + this[d9] = true; + const t17 = Object.getPrototypeOf(this); + if (t17.finalize(), void 0 !== t17.h && (this.h = [...t17.h]), this.elementProperties = new Map(t17.elementProperties), this._$Ev = /* @__PURE__ */ new Map(), this.hasOwnProperty("properties")) { + const t18 = this.properties, i23 = [...Object.getOwnPropertyNames(t18), ...Object.getOwnPropertySymbols(t18)]; + for (const s20 of i23) + this.createProperty(s20, t18[s20]); + } + return this.elementStyles = this.finalizeStyles(this.styles), true; + } + static finalizeStyles(i23) { + const s20 = []; + if (Array.isArray(i23)) { + const e33 = new Set(i23.flat(1 / 0).reverse()); + for (const i24 of e33) + s20.unshift(c10(i24)); + } else + void 0 !== i23 && s20.push(c10(i23)); + return s20; + } + static _$Ep(t17, i23) { + const s20 = i23.attribute; + return false === s20 ? void 0 : "string" == typeof s20 ? s20 : "string" == typeof t17 ? t17.toLowerCase() : void 0; + } + _$Eu() { + var t17; + this._$E_ = new Promise((t18) => this.enableUpdating = t18), this._$AL = /* @__PURE__ */ new Map(), this._$Eg(), this.requestUpdate(), null === (t17 = this.constructor.h) || void 0 === t17 || t17.forEach((t18) => t18(this)); + } + addController(t17) { + var i23, s20; + (null !== (i23 = this._$ES) && void 0 !== i23 ? i23 : this._$ES = []).push(t17), void 0 !== this.renderRoot && this.isConnected && (null === (s20 = t17.hostConnected) || void 0 === s20 || s20.call(t17)); + } + removeController(t17) { + var i23; + null === (i23 = this._$ES) || void 0 === i23 || i23.splice(this._$ES.indexOf(t17) >>> 0, 1); + } + _$Eg() { + this.constructor.elementProperties.forEach((t17, i23) => { + this.hasOwnProperty(i23) && (this._$Ei.set(i23, this[i23]), delete this[i23]); + }); + } + createRenderRoot() { + var t17; + const s20 = null !== (t17 = this.shadowRoot) && void 0 !== t17 ? t17 : this.attachShadow(this.constructor.shadowRootOptions); + return S9(s20, this.constructor.elementStyles), s20; + } + connectedCallback() { + var t17; + void 0 === this.renderRoot && (this.renderRoot = this.createRenderRoot()), this.enableUpdating(true), null === (t17 = this._$ES) || void 0 === t17 || t17.forEach((t18) => { + var i23; + return null === (i23 = t18.hostConnected) || void 0 === i23 ? void 0 : i23.call(t18); + }); + } + enableUpdating(t17) { + } + disconnectedCallback() { + var t17; + null === (t17 = this._$ES) || void 0 === t17 || t17.forEach((t18) => { + var i23; + return null === (i23 = t18.hostDisconnected) || void 0 === i23 ? void 0 : i23.call(t18); + }); + } + attributeChangedCallback(t17, i23, s20) { + this._$AK(t17, s20); + } + _$EO(t17, i23, s20 = l16) { + var e33; + const r18 = this.constructor._$Ep(t17, s20); + if (void 0 !== r18 && true === s20.reflect) { + const h11 = (void 0 !== (null === (e33 = s20.converter) || void 0 === e33 ? void 0 : e33.toAttribute) ? s20.converter : n28).toAttribute(i23, s20.type); + this._$El = t17, null == h11 ? this.removeAttribute(r18) : this.setAttribute(r18, h11), this._$El = null; + } + } + _$AK(t17, i23) { + var s20; + const e33 = this.constructor, r18 = e33._$Ev.get(t17); + if (void 0 !== r18 && this._$El !== r18) { + const t18 = e33.getPropertyOptions(r18), h11 = "function" == typeof t18.converter ? { fromAttribute: t18.converter } : void 0 !== (null === (s20 = t18.converter) || void 0 === s20 ? void 0 : s20.fromAttribute) ? t18.converter : n28; + this._$El = r18, this[r18] = h11.fromAttribute(i23, t18.type), this._$El = null; + } + } + requestUpdate(t17, i23, s20) { + let e33 = true; + void 0 !== t17 && (((s20 = s20 || this.constructor.getPropertyOptions(t17)).hasChanged || a9)(this[t17], i23) ? (this._$AL.has(t17) || this._$AL.set(t17, i23), true === s20.reflect && this._$El !== t17 && (void 0 === this._$EC && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(t17, s20))) : e33 = false), !this.isUpdatePending && e33 && (this._$E_ = this._$Ej()); + } + async _$Ej() { + this.isUpdatePending = true; + try { + await this._$E_; + } catch (t18) { + Promise.reject(t18); + } + const t17 = this.scheduleUpdate(); + return null != t17 && await t17, !this.isUpdatePending; + } + scheduleUpdate() { + return this.performUpdate(); + } + performUpdate() { + var t17; + if (!this.isUpdatePending) + return; + this.hasUpdated, this._$Ei && (this._$Ei.forEach((t18, i24) => this[i24] = t18), this._$Ei = void 0); + let i23 = false; + const s20 = this._$AL; + try { + i23 = this.shouldUpdate(s20), i23 ? (this.willUpdate(s20), null === (t17 = this._$ES) || void 0 === t17 || t17.forEach((t18) => { + var i24; + return null === (i24 = t18.hostUpdate) || void 0 === i24 ? void 0 : i24.call(t18); + }), this.update(s20)) : this._$Ek(); + } catch (t18) { + throw i23 = false, this._$Ek(), t18; + } + i23 && this._$AE(s20); + } + willUpdate(t17) { + } + _$AE(t17) { + var i23; + null === (i23 = this._$ES) || void 0 === i23 || i23.forEach((t18) => { + var i24; + return null === (i24 = t18.hostUpdated) || void 0 === i24 ? void 0 : i24.call(t18); + }), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t17)), this.updated(t17); + } + _$Ek() { + this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = false; + } + get updateComplete() { + return this.getUpdateComplete(); + } + getUpdateComplete() { + return this._$E_; + } + shouldUpdate(t17) { + return true; + } + update(t17) { + void 0 !== this._$EC && (this._$EC.forEach((t18, i23) => this._$EO(i23, this[i23], t18)), this._$EC = void 0), this._$Ek(); + } + updated(t17) { + } + firstUpdated(t17) { + } + }; + u9[d9] = true, u9.elementProperties = /* @__PURE__ */ new Map(), u9.elementStyles = [], u9.shadowRootOptions = { mode: "open" }, null == o25 || o25({ ReactiveElement: u9 }), (null !== (s17 = e30.reactiveElementVersions) && void 0 !== s17 ? s17 : e30.reactiveElementVersions = []).push("1.6.3"); + + // node_modules/@material/mwc-switch/node_modules/lit-html/lit-html.js + var t15; + var i21 = window; + var s18 = i21.trustedTypes; + var e31 = s18 ? s18.createPolicy("lit-html", { createHTML: (t17) => t17 }) : void 0; + var o26 = "$lit$"; + var n29 = `lit$${(Math.random() + "").slice(9)}$`; + var l17 = "?" + n29; + var h10 = `<${l17}>`; + var r17 = document; + var u10 = () => r17.createComment(""); + var d10 = (t17) => null === t17 || "object" != typeof t17 && "function" != typeof t17; + var c11 = Array.isArray; + var v5 = (t17) => c11(t17) || "function" == typeof (null == t17 ? void 0 : t17[Symbol.iterator]); + var a10 = "[ \n\f\r]"; + var f6 = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g; + var _18 = /-->/g; + var m5 = />/g; + var p6 = RegExp(`>|${a10}(?:([^\\s"'>=/]+)(${a10}*=${a10}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`, "g"); + var g5 = /'/g; + var $5 = /"/g; + var y6 = /^(?:script|style|textarea|title)$/i; + var w5 = (t17) => (i23, ...s20) => ({ _$litType$: t17, strings: i23, values: s20 }); + var x5 = w5(1); + var b6 = w5(2); + var T5 = Symbol.for("lit-noChange"); + var A5 = Symbol.for("lit-nothing"); + var E5 = /* @__PURE__ */ new WeakMap(); + var C5 = r17.createTreeWalker(r17, 129, null, false); + function P5(t17, i23) { + if (!Array.isArray(t17) || !t17.hasOwnProperty("raw")) + throw Error("invalid template strings array"); + return void 0 !== e31 ? e31.createHTML(i23) : i23; + } + var V5 = (t17, i23) => { + const s20 = t17.length - 1, e33 = []; + let l20, r18 = 2 === i23 ? "" : "", u11 = f6; + for (let i24 = 0; i24 < s20; i24++) { + const s21 = t17[i24]; + let d11, c12, v6 = -1, a11 = 0; + for (; a11 < s21.length && (u11.lastIndex = a11, c12 = u11.exec(s21), null !== c12); ) + a11 = u11.lastIndex, u11 === f6 ? "!--" === c12[1] ? u11 = _18 : void 0 !== c12[1] ? u11 = m5 : void 0 !== c12[2] ? (y6.test(c12[2]) && (l20 = RegExp("" === c12[0] ? (u11 = null != l20 ? l20 : f6, v6 = -1) : void 0 === c12[1] ? v6 = -2 : (v6 = u11.lastIndex - c12[2].length, d11 = c12[1], u11 = void 0 === c12[3] ? p6 : '"' === c12[3] ? $5 : g5) : u11 === $5 || u11 === g5 ? u11 = p6 : u11 === _18 || u11 === m5 ? u11 = f6 : (u11 = p6, l20 = void 0); + const w6 = u11 === p6 && t17[i24 + 1].startsWith("/>") ? " " : ""; + r18 += u11 === f6 ? s21 + h10 : v6 >= 0 ? (e33.push(d11), s21.slice(0, v6) + o26 + s21.slice(v6) + n29 + w6) : s21 + n29 + (-2 === v6 ? (e33.push(void 0), i24) : w6); + } + return [P5(t17, r18 + (t17[s20] || "") + (2 === i23 ? "" : "")), e33]; + }; + var N5 = class _N { + constructor({ strings: t17, _$litType$: i23 }, e33) { + let h11; + this.parts = []; + let r18 = 0, d11 = 0; + const c12 = t17.length - 1, v6 = this.parts, [a11, f7] = V5(t17, i23); + if (this.el = _N.createElement(a11, e33), C5.currentNode = this.el.content, 2 === i23) { + const t18 = this.el.content, i24 = t18.firstChild; + i24.remove(), t18.append(...i24.childNodes); + } + for (; null !== (h11 = C5.nextNode()) && v6.length < c12; ) { + if (1 === h11.nodeType) { + if (h11.hasAttributes()) { + const t18 = []; + for (const i24 of h11.getAttributeNames()) + if (i24.endsWith(o26) || i24.startsWith(n29)) { + const s20 = f7[d11++]; + if (t18.push(i24), void 0 !== s20) { + const t19 = h11.getAttribute(s20.toLowerCase() + o26).split(n29), i25 = /([.?@])?(.*)/.exec(s20); + v6.push({ type: 1, index: r18, name: i25[2], strings: t19, ctor: "." === i25[1] ? H5 : "?" === i25[1] ? L5 : "@" === i25[1] ? z4 : k7 }); + } else + v6.push({ type: 6, index: r18 }); + } + for (const i24 of t18) + h11.removeAttribute(i24); + } + if (y6.test(h11.tagName)) { + const t18 = h11.textContent.split(n29), i24 = t18.length - 1; + if (i24 > 0) { + h11.textContent = s18 ? s18.emptyScript : ""; + for (let s20 = 0; s20 < i24; s20++) + h11.append(t18[s20], u10()), C5.nextNode(), v6.push({ type: 2, index: ++r18 }); + h11.append(t18[i24], u10()); + } + } + } else if (8 === h11.nodeType) + if (h11.data === l17) + v6.push({ type: 2, index: r18 }); + else { + let t18 = -1; + for (; -1 !== (t18 = h11.data.indexOf(n29, t18 + 1)); ) + v6.push({ type: 7, index: r18 }), t18 += n29.length - 1; + } + r18++; + } + } + static createElement(t17, i23) { + const s20 = r17.createElement("template"); + return s20.innerHTML = t17, s20; + } + }; + function S10(t17, i23, s20 = t17, e33) { + var o29, n31, l20, h11; + if (i23 === T5) + return i23; + let r18 = void 0 !== e33 ? null === (o29 = s20._$Co) || void 0 === o29 ? void 0 : o29[e33] : s20._$Cl; + const u11 = d10(i23) ? void 0 : i23._$litDirective$; + return (null == r18 ? void 0 : r18.constructor) !== u11 && (null === (n31 = null == r18 ? void 0 : r18._$AO) || void 0 === n31 || n31.call(r18, false), void 0 === u11 ? r18 = void 0 : (r18 = new u11(t17), r18._$AT(t17, s20, e33)), void 0 !== e33 ? (null !== (l20 = (h11 = s20)._$Co) && void 0 !== l20 ? l20 : h11._$Co = [])[e33] = r18 : s20._$Cl = r18), void 0 !== r18 && (i23 = S10(t17, r18._$AS(t17, i23.values), r18, e33)), i23; + } + var M5 = class { + constructor(t17, i23) { + this._$AV = [], this._$AN = void 0, this._$AD = t17, this._$AM = i23; + } + get parentNode() { + return this._$AM.parentNode; + } + get _$AU() { + return this._$AM._$AU; + } + u(t17) { + var i23; + const { el: { content: s20 }, parts: e33 } = this._$AD, o29 = (null !== (i23 = null == t17 ? void 0 : t17.creationScope) && void 0 !== i23 ? i23 : r17).importNode(s20, true); + C5.currentNode = o29; + let n31 = C5.nextNode(), l20 = 0, h11 = 0, u11 = e33[0]; + for (; void 0 !== u11; ) { + if (l20 === u11.index) { + let i24; + 2 === u11.type ? i24 = new R5(n31, n31.nextSibling, this, t17) : 1 === u11.type ? i24 = new u11.ctor(n31, u11.name, u11.strings, this, t17) : 6 === u11.type && (i24 = new Z5(n31, this, t17)), this._$AV.push(i24), u11 = e33[++h11]; + } + l20 !== (null == u11 ? void 0 : u11.index) && (n31 = C5.nextNode(), l20++); + } + return C5.currentNode = r17, o29; + } + v(t17) { + let i23 = 0; + for (const s20 of this._$AV) + void 0 !== s20 && (void 0 !== s20.strings ? (s20._$AI(t17, s20, i23), i23 += s20.strings.length - 2) : s20._$AI(t17[i23])), i23++; + } + }; + var R5 = class _R { + constructor(t17, i23, s20, e33) { + var o29; + this.type = 2, this._$AH = A5, this._$AN = void 0, this._$AA = t17, this._$AB = i23, this._$AM = s20, this.options = e33, this._$Cp = null === (o29 = null == e33 ? void 0 : e33.isConnected) || void 0 === o29 || o29; + } + get _$AU() { + var t17, i23; + return null !== (i23 = null === (t17 = this._$AM) || void 0 === t17 ? void 0 : t17._$AU) && void 0 !== i23 ? i23 : this._$Cp; + } + get parentNode() { + let t17 = this._$AA.parentNode; + const i23 = this._$AM; + return void 0 !== i23 && 11 === (null == t17 ? void 0 : t17.nodeType) && (t17 = i23.parentNode), t17; + } + get startNode() { + return this._$AA; + } + get endNode() { + return this._$AB; + } + _$AI(t17, i23 = this) { + t17 = S10(this, t17, i23), d10(t17) ? t17 === A5 || null == t17 || "" === t17 ? (this._$AH !== A5 && this._$AR(), this._$AH = A5) : t17 !== this._$AH && t17 !== T5 && this._(t17) : void 0 !== t17._$litType$ ? this.g(t17) : void 0 !== t17.nodeType ? this.$(t17) : v5(t17) ? this.T(t17) : this._(t17); + } + k(t17) { + return this._$AA.parentNode.insertBefore(t17, this._$AB); + } + $(t17) { + this._$AH !== t17 && (this._$AR(), this._$AH = this.k(t17)); + } + _(t17) { + this._$AH !== A5 && d10(this._$AH) ? this._$AA.nextSibling.data = t17 : this.$(r17.createTextNode(t17)), this._$AH = t17; + } + g(t17) { + var i23; + const { values: s20, _$litType$: e33 } = t17, o29 = "number" == typeof e33 ? this._$AC(t17) : (void 0 === e33.el && (e33.el = N5.createElement(P5(e33.h, e33.h[0]), this.options)), e33); + if ((null === (i23 = this._$AH) || void 0 === i23 ? void 0 : i23._$AD) === o29) + this._$AH.v(s20); + else { + const t18 = new M5(o29, this), i24 = t18.u(this.options); + t18.v(s20), this.$(i24), this._$AH = t18; + } + } + _$AC(t17) { + let i23 = E5.get(t17.strings); + return void 0 === i23 && E5.set(t17.strings, i23 = new N5(t17)), i23; + } + T(t17) { + c11(this._$AH) || (this._$AH = [], this._$AR()); + const i23 = this._$AH; + let s20, e33 = 0; + for (const o29 of t17) + e33 === i23.length ? i23.push(s20 = new _R(this.k(u10()), this.k(u10()), this, this.options)) : s20 = i23[e33], s20._$AI(o29), e33++; + e33 < i23.length && (this._$AR(s20 && s20._$AB.nextSibling, e33), i23.length = e33); + } + _$AR(t17 = this._$AA.nextSibling, i23) { + var s20; + for (null === (s20 = this._$AP) || void 0 === s20 || s20.call(this, false, true, i23); t17 && t17 !== this._$AB; ) { + const i24 = t17.nextSibling; + t17.remove(), t17 = i24; + } + } + setConnected(t17) { + var i23; + void 0 === this._$AM && (this._$Cp = t17, null === (i23 = this._$AP) || void 0 === i23 || i23.call(this, t17)); + } + }; + var k7 = class { + constructor(t17, i23, s20, e33, o29) { + this.type = 1, this._$AH = A5, this._$AN = void 0, this.element = t17, this.name = i23, this._$AM = e33, this.options = o29, s20.length > 2 || "" !== s20[0] || "" !== s20[1] ? (this._$AH = Array(s20.length - 1).fill(new String()), this.strings = s20) : this._$AH = A5; + } + get tagName() { + return this.element.tagName; + } + get _$AU() { + return this._$AM._$AU; + } + _$AI(t17, i23 = this, s20, e33) { + const o29 = this.strings; + let n31 = false; + if (void 0 === o29) + t17 = S10(this, t17, i23, 0), n31 = !d10(t17) || t17 !== this._$AH && t17 !== T5, n31 && (this._$AH = t17); + else { + const e34 = t17; + let l20, h11; + for (t17 = o29[0], l20 = 0; l20 < o29.length - 1; l20++) + h11 = S10(this, e34[s20 + l20], i23, l20), h11 === T5 && (h11 = this._$AH[l20]), n31 || (n31 = !d10(h11) || h11 !== this._$AH[l20]), h11 === A5 ? t17 = A5 : t17 !== A5 && (t17 += (null != h11 ? h11 : "") + o29[l20 + 1]), this._$AH[l20] = h11; + } + n31 && !e33 && this.j(t17); + } + j(t17) { + t17 === A5 ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, null != t17 ? t17 : ""); + } + }; + var H5 = class extends k7 { + constructor() { + super(...arguments), this.type = 3; + } + j(t17) { + this.element[this.name] = t17 === A5 ? void 0 : t17; + } + }; + var I5 = s18 ? s18.emptyScript : ""; + var L5 = class extends k7 { + constructor() { + super(...arguments), this.type = 4; + } + j(t17) { + t17 && t17 !== A5 ? this.element.setAttribute(this.name, I5) : this.element.removeAttribute(this.name); + } + }; + var z4 = class extends k7 { + constructor(t17, i23, s20, e33, o29) { + super(t17, i23, s20, e33, o29), this.type = 5; + } + _$AI(t17, i23 = this) { + var s20; + if ((t17 = null !== (s20 = S10(this, t17, i23, 0)) && void 0 !== s20 ? s20 : A5) === T5) + return; + const e33 = this._$AH, o29 = t17 === A5 && e33 !== A5 || t17.capture !== e33.capture || t17.once !== e33.once || t17.passive !== e33.passive, n31 = t17 !== A5 && (e33 === A5 || o29); + o29 && this.element.removeEventListener(this.name, this, e33), n31 && this.element.addEventListener(this.name, this, t17), this._$AH = t17; + } + handleEvent(t17) { + var i23, s20; + "function" == typeof this._$AH ? this._$AH.call(null !== (s20 = null === (i23 = this.options) || void 0 === i23 ? void 0 : i23.host) && void 0 !== s20 ? s20 : this.element, t17) : this._$AH.handleEvent(t17); + } + }; + var Z5 = class { + constructor(t17, i23, s20) { + this.element = t17, this.type = 6, this._$AN = void 0, this._$AM = i23, this.options = s20; + } + get _$AU() { + return this._$AM._$AU; + } + _$AI(t17) { + S10(this, t17); + } + }; + var B4 = i21.litHtmlPolyfillSupport; + null == B4 || B4(N5, R5), (null !== (t15 = i21.litHtmlVersions) && void 0 !== t15 ? t15 : i21.litHtmlVersions = []).push("2.8.0"); + var D4 = (t17, i23, s20) => { + var e33, o29; + const n31 = null !== (e33 = null == s20 ? void 0 : s20.renderBefore) && void 0 !== e33 ? e33 : i23; + let l20 = n31._$litPart$; + if (void 0 === l20) { + const t18 = null !== (o29 = null == s20 ? void 0 : s20.renderBefore) && void 0 !== o29 ? o29 : null; + n31._$litPart$ = l20 = new R5(i23.insertBefore(u10(), t18), t18, void 0, null != s20 ? s20 : {}); + } + return l20._$AI(t17), l20; + }; + + // node_modules/@material/mwc-switch/node_modules/lit-element/lit-element.js + var l18; + var o27; + var s19 = class extends u9 { + constructor() { + super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0; + } + createRenderRoot() { + var t17, e33; + const i23 = super.createRenderRoot(); + return null !== (t17 = (e33 = this.renderOptions).renderBefore) && void 0 !== t17 || (e33.renderBefore = i23.firstChild), i23; + } + update(t17) { + const i23 = this.render(); + this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t17), this._$Do = D4(i23, this.renderRoot, this.renderOptions); + } + connectedCallback() { + var t17; + super.connectedCallback(), null === (t17 = this._$Do) || void 0 === t17 || t17.setConnected(true); + } + disconnectedCallback() { + var t17; + super.disconnectedCallback(), null === (t17 = this._$Do) || void 0 === t17 || t17.setConnected(false); + } + render() { + return T5; + } + }; + s19.finalized = true, s19._$litElement$ = true, null === (l18 = globalThis.litElementHydrateSupport) || void 0 === l18 || l18.call(globalThis, { LitElement: s19 }); + var n30 = globalThis.litElementPolyfillSupport; + null == n30 || n30({ LitElement: s19 }); + (null !== (o27 = globalThis.litElementVersions) && void 0 !== o27 ? o27 : globalThis.litElementVersions = []).push("3.3.3"); + + // node_modules/@material/mwc-switch/node_modules/lit-html/directive.js + var t16 = { ATTRIBUTE: 1, CHILD: 2, PROPERTY: 3, BOOLEAN_ATTRIBUTE: 4, EVENT: 5, ELEMENT: 6 }; + var e32 = (t17) => (...e33) => ({ _$litDirective$: t17, values: e33 }); + var i22 = class { + constructor(t17) { + } + get _$AU() { + return this._$AM._$AU; + } + _$AT(t17, e33, i23) { + this._$Ct = t17, this._$AM = e33, this._$Ci = i23; + } + _$AS(t17, e33) { + return this.update(t17, e33); + } + update(t17, e33) { + return this.render(...e33); + } + }; + + // node_modules/@material/mwc-switch/node_modules/lit-html/directives/class-map.js + var o28 = e32(class extends i22 { + constructor(t17) { + var i23; + if (super(t17), t17.type !== t16.ATTRIBUTE || "class" !== t17.name || (null === (i23 = t17.strings) || void 0 === i23 ? void 0 : i23.length) > 2) + throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute."); + } + render(t17) { + return " " + Object.keys(t17).filter((i23) => t17[i23]).join(" ") + " "; + } + update(i23, [s20]) { + var r18, o29; + if (void 0 === this.it) { + this.it = /* @__PURE__ */ new Set(), void 0 !== i23.strings && (this.nt = new Set(i23.strings.join(" ").split(/\s/).filter((t17) => "" !== t17))); + for (const t17 in s20) + s20[t17] && !(null === (r18 = this.nt) || void 0 === r18 ? void 0 : r18.has(t17)) && this.it.add(t17); + return this.render(s20); + } + const e33 = i23.element.classList; + this.it.forEach((t17) => { + t17 in s20 || (e33.remove(t17), this.it.delete(t17)); + }); + for (const t17 in s20) { + const i24 = !!s20[t17]; + i24 === this.it.has(t17) || (null === (o29 = this.nt) || void 0 === o29 ? void 0 : o29.has(t17)) || (i24 ? (e33.add(t17), this.it.add(t17)) : (e33.remove(t17), this.it.delete(t17))); + } + return T5; + } + }); + + // node_modules/@material/mwc-switch/node_modules/lit-html/directives/if-defined.js + var l19 = (l20) => null != l20 ? l20 : A5; + + // node_modules/@material/mwc-switch/mwc-switch-base.js + var SwitchBase = class extends FormElement { + constructor() { + super(...arguments); + this.processing = false; + this.selected = false; + this.ariaLabel = ""; + this.ariaLabelledBy = ""; + this.shouldRenderRipple = false; + this.rippleHandlers = new RippleHandlers(() => { + this.shouldRenderRipple = true; + return this.ripple; + }); + this.name = ""; + this.value = "on"; + this.mdcFoundationClass = MDCSwitchFoundation; + } + setFormData(formData) { + if (this.name && this.selected) { + formData.append(this.name, this.value); + } + } + click() { + var _a2, _b2; + if (this.disabled) { + return; + } + (_a2 = this.mdcRoot) === null || _a2 === void 0 ? void 0 : _a2.focus(); + (_b2 = this.mdcRoot) === null || _b2 === void 0 ? void 0 : _b2.click(); + } + /** @soyTemplate */ + render() { + return x5` + + + + `; + } + /** @soyTemplate */ + getRenderClasses() { + return { + "mdc-switch--processing": this.processing, + "mdc-switch--selected": this.selected, + "mdc-switch--unselected": !this.selected + }; + } + /** @soyTemplate */ + renderHandle() { + return x5` +
    + ${this.renderShadow()} + ${this.renderRipple()} +
    + ${this.renderOnIcon()} + ${this.renderOffIcon()} +
    +
    + `; + } + /** @soyTemplate */ + renderShadow() { + return x5` +
    +
    +
    + `; + } + /** @soyTemplate */ + renderRipple() { + if (this.shouldRenderRipple) { + return x5` +
    + + +
    + `; + } else { + return x5``; + } + } + /** @soyTemplate */ + renderOnIcon() { + return x5` + + + + `; + } + /** @soyTemplate */ + renderOffIcon() { + return x5` + + + + `; + } + handleClick() { + var _a2; + (_a2 = this.mdcFoundation) === null || _a2 === void 0 ? void 0 : _a2.handleClick(); + } + handleFocus() { + this.rippleHandlers.startFocus(); + } + handleBlur() { + this.rippleHandlers.endFocus(); + } + handlePointerDown(event) { + event.target.setPointerCapture(event.pointerId); + this.rippleHandlers.startPress(event); + } + handlePointerUp() { + this.rippleHandlers.endPress(); + } + handlePointerEnter() { + this.rippleHandlers.startHover(); + } + handlePointerLeave() { + this.rippleHandlers.endHover(); + } + createAdapter() { + return { state: this }; + } + }; + __decorate([ + n12({ type: Boolean }) + ], SwitchBase.prototype, "processing", void 0); + __decorate([ + n12({ type: Boolean }) + ], SwitchBase.prototype, "selected", void 0); + __decorate([ + ariaProperty, + n12({ type: String, attribute: "aria-label" }) + ], SwitchBase.prototype, "ariaLabel", void 0); + __decorate([ + ariaProperty, + n12({ type: String, attribute: "aria-labelledby" }) + ], SwitchBase.prototype, "ariaLabelledBy", void 0); + __decorate([ + e15("mwc-ripple") + ], SwitchBase.prototype, "ripple", void 0); + __decorate([ + t7() + ], SwitchBase.prototype, "shouldRenderRipple", void 0); + __decorate([ + n12({ type: String, reflect: true }) + ], SwitchBase.prototype, "name", void 0); + __decorate([ + n12({ type: String }) + ], SwitchBase.prototype, "value", void 0); + __decorate([ + i10("input") + ], SwitchBase.prototype, "formElement", void 0); + __decorate([ + i10(".mdc-switch") + ], SwitchBase.prototype, "mdcRoot", void 0); + __decorate([ + e14({ passive: true }) + ], SwitchBase.prototype, "handlePointerDown", null); + + // node_modules/@material/mwc-switch/styles.css.js + var styles13 = i20`.mdc-elevation-overlay{position:absolute;border-radius:inherit;pointer-events:none;opacity:0;opacity:var(--mdc-elevation-overlay-opacity, 0);transition:opacity 280ms cubic-bezier(0.4, 0, 0.2, 1);background-color:#fff;background-color:var(--mdc-elevation-overlay-color, #fff)}.mdc-switch{align-items:center;background:none;border:none;cursor:pointer;display:inline-flex;flex-shrink:0;margin:0;outline:none;overflow:visible;padding:0;position:relative}.mdc-switch:disabled{cursor:default;pointer-events:none}.mdc-switch__track{overflow:hidden;position:relative;width:100%}.mdc-switch__track::before,.mdc-switch__track::after{border:1px solid transparent;border-radius:inherit;box-sizing:border-box;content:"";height:100%;left:0;position:absolute;width:100%}@media screen and (forced-colors: active){.mdc-switch__track::before,.mdc-switch__track::after{border-color:currentColor}}.mdc-switch__track::before{transition:transform 75ms 0ms cubic-bezier(0, 0, 0.2, 1);transform:translateX(0)}.mdc-switch__track::after{transition:transform 75ms 0ms cubic-bezier(0.4, 0, 0.6, 1);transform:translateX(-100%)}[dir=rtl] .mdc-switch__track::after,.mdc-switch__track[dir=rtl]::after{transform:translateX(100%)}.mdc-switch--selected .mdc-switch__track::before{transition:transform 75ms 0ms cubic-bezier(0.4, 0, 0.6, 1);transform:translateX(100%)}[dir=rtl] .mdc-switch--selected .mdc-switch__track::before,.mdc-switch--selected .mdc-switch__track[dir=rtl]::before{transform:translateX(-100%)}.mdc-switch--selected .mdc-switch__track::after{transition:transform 75ms 0ms cubic-bezier(0, 0, 0.2, 1);transform:translateX(0)}.mdc-switch__handle-track{height:100%;pointer-events:none;position:absolute;top:0;transition:transform 75ms 0ms cubic-bezier(0.4, 0, 0.2, 1);left:0;right:auto;transform:translateX(0)}[dir=rtl] .mdc-switch__handle-track,.mdc-switch__handle-track[dir=rtl]{left:auto;right:0}.mdc-switch--selected .mdc-switch__handle-track{transform:translateX(100%)}[dir=rtl] .mdc-switch--selected .mdc-switch__handle-track,.mdc-switch--selected .mdc-switch__handle-track[dir=rtl]{transform:translateX(-100%)}.mdc-switch__handle{display:flex;pointer-events:auto;position:absolute;top:50%;transform:translateY(-50%);left:0;right:auto}[dir=rtl] .mdc-switch__handle,.mdc-switch__handle[dir=rtl]{left:auto;right:0}.mdc-switch__handle::before,.mdc-switch__handle::after{border:1px solid transparent;border-radius:inherit;box-sizing:border-box;content:"";width:100%;height:100%;left:0;position:absolute;top:0;transition:background-color 75ms 0ms cubic-bezier(0.4, 0, 0.2, 1),border-color 75ms 0ms cubic-bezier(0.4, 0, 0.2, 1);z-index:-1}@media screen and (forced-colors: active){.mdc-switch__handle::before,.mdc-switch__handle::after{border-color:currentColor}}.mdc-switch__shadow{border-radius:inherit;bottom:0;left:0;position:absolute;right:0;top:0}.mdc-elevation-overlay{bottom:0;left:0;right:0;top:0}.mdc-switch__ripple{left:50%;position:absolute;top:50%;transform:translate(-50%, -50%);z-index:-1}.mdc-switch:disabled .mdc-switch__ripple{display:none}.mdc-switch__icons{height:100%;position:relative;width:100%;z-index:1}.mdc-switch__icon{bottom:0;left:0;margin:auto;position:absolute;right:0;top:0;opacity:0;transition:opacity 30ms 0ms cubic-bezier(0.4, 0, 1, 1)}.mdc-switch--selected .mdc-switch__icon--on,.mdc-switch--unselected .mdc-switch__icon--off{opacity:1;transition:opacity 45ms 30ms cubic-bezier(0, 0, 0.2, 1)}:host{display:inline-flex;outline:none}input{display:none}.mdc-switch{width:36px;width:var(--mdc-switch-track-width, 36px)}.mdc-switch.mdc-switch--selected:enabled .mdc-switch__handle::after{background:#6200ee;background:var(--mdc-switch-selected-handle-color, var(--mdc-theme-primary, #6200ee))}.mdc-switch.mdc-switch--selected:enabled:hover:not(:focus):not(:active) .mdc-switch__handle::after{background:#310077;background:var(--mdc-switch-selected-hover-handle-color, #310077)}.mdc-switch.mdc-switch--selected:enabled:focus:not(:active) .mdc-switch__handle::after{background:#310077;background:var(--mdc-switch-selected-focus-handle-color, #310077)}.mdc-switch.mdc-switch--selected:enabled:active .mdc-switch__handle::after{background:#310077;background:var(--mdc-switch-selected-pressed-handle-color, #310077)}.mdc-switch.mdc-switch--selected:disabled .mdc-switch__handle::after{background:#424242;background:var(--mdc-switch-disabled-selected-handle-color, #424242)}.mdc-switch.mdc-switch--unselected:enabled .mdc-switch__handle::after{background:#616161;background:var(--mdc-switch-unselected-handle-color, #616161)}.mdc-switch.mdc-switch--unselected:enabled:hover:not(:focus):not(:active) .mdc-switch__handle::after{background:#212121;background:var(--mdc-switch-unselected-hover-handle-color, #212121)}.mdc-switch.mdc-switch--unselected:enabled:focus:not(:active) .mdc-switch__handle::after{background:#212121;background:var(--mdc-switch-unselected-focus-handle-color, #212121)}.mdc-switch.mdc-switch--unselected:enabled:active .mdc-switch__handle::after{background:#212121;background:var(--mdc-switch-unselected-pressed-handle-color, #212121)}.mdc-switch.mdc-switch--unselected:disabled .mdc-switch__handle::after{background:#424242;background:var(--mdc-switch-disabled-unselected-handle-color, #424242)}.mdc-switch .mdc-switch__handle::before{background:#fff;background:var(--mdc-switch-handle-surface-color, var(--mdc-theme-surface, #fff))}.mdc-switch:enabled .mdc-switch__shadow{--mdc-elevation-box-shadow-for-gss:0px 2px 1px -1px rgba(0, 0, 0, 0.2), 0px 1px 1px 0px rgba(0, 0, 0, 0.14), 0px 1px 3px 0px rgba(0, 0, 0, 0.12);box-shadow:0px 2px 1px -1px rgba(0, 0, 0, 0.2), 0px 1px 1px 0px rgba(0, 0, 0, 0.14), 0px 1px 3px 0px rgba(0, 0, 0, 0.12);box-shadow:var(--mdc-switch-handle-elevation, var(--mdc-elevation-box-shadow-for-gss))}.mdc-switch:disabled .mdc-switch__shadow{--mdc-elevation-box-shadow-for-gss:0px 0px 0px 0px rgba(0, 0, 0, 0.2), 0px 0px 0px 0px rgba(0, 0, 0, 0.14), 0px 0px 0px 0px rgba(0, 0, 0, 0.12);box-shadow:0px 0px 0px 0px rgba(0, 0, 0, 0.2), 0px 0px 0px 0px rgba(0, 0, 0, 0.14), 0px 0px 0px 0px rgba(0, 0, 0, 0.12);box-shadow:var(--mdc-switch-disabled-handle-elevation, var(--mdc-elevation-box-shadow-for-gss))}.mdc-switch .mdc-switch__focus-ring-wrapper,.mdc-switch .mdc-switch__handle{height:20px;height:var(--mdc-switch-handle-height, 20px)}.mdc-switch:disabled .mdc-switch__handle::after{opacity:0.38;opacity:var(--mdc-switch-disabled-handle-opacity, 0.38)}.mdc-switch .mdc-switch__handle{border-radius:10px;border-radius:var(--mdc-switch-handle-shape, 10px)}.mdc-switch .mdc-switch__handle{width:20px;width:var(--mdc-switch-handle-width, 20px)}.mdc-switch .mdc-switch__handle-track{width:calc(100% - 20px);width:calc(100% - var(--mdc-switch-handle-width, 20px))}.mdc-switch.mdc-switch--selected:enabled .mdc-switch__icon{fill:#fff;fill:var(--mdc-switch-selected-icon-color, var(--mdc-theme-on-primary, #fff))}.mdc-switch.mdc-switch--selected:disabled .mdc-switch__icon{fill:#fff;fill:var(--mdc-switch-disabled-selected-icon-color, var(--mdc-theme-on-primary, #fff))}.mdc-switch.mdc-switch--unselected:enabled .mdc-switch__icon{fill:#fff;fill:var(--mdc-switch-unselected-icon-color, var(--mdc-theme-on-primary, #fff))}.mdc-switch.mdc-switch--unselected:disabled .mdc-switch__icon{fill:#fff;fill:var(--mdc-switch-disabled-unselected-icon-color, var(--mdc-theme-on-primary, #fff))}.mdc-switch.mdc-switch--selected:disabled .mdc-switch__icons{opacity:0.38;opacity:var(--mdc-switch-disabled-selected-icon-opacity, 0.38)}.mdc-switch.mdc-switch--unselected:disabled .mdc-switch__icons{opacity:0.38;opacity:var(--mdc-switch-disabled-unselected-icon-opacity, 0.38)}.mdc-switch.mdc-switch--selected .mdc-switch__icon{width:18px;width:var(--mdc-switch-selected-icon-size, 18px);height:18px;height:var(--mdc-switch-selected-icon-size, 18px)}.mdc-switch.mdc-switch--unselected .mdc-switch__icon{width:18px;width:var(--mdc-switch-unselected-icon-size, 18px);height:18px;height:var(--mdc-switch-unselected-icon-size, 18px)}.mdc-switch .mdc-switch__ripple{height:48px;height:var(--mdc-switch-state-layer-size, 48px);width:48px;width:var(--mdc-switch-state-layer-size, 48px)}.mdc-switch .mdc-switch__track{height:14px;height:var(--mdc-switch-track-height, 14px)}.mdc-switch:disabled .mdc-switch__track{opacity:0.12;opacity:var(--mdc-switch-disabled-track-opacity, 0.12)}.mdc-switch:enabled .mdc-switch__track::after{background:#d7bbff;background:var(--mdc-switch-selected-track-color, #d7bbff)}.mdc-switch:enabled:hover:not(:focus):not(:active) .mdc-switch__track::after{background:#d7bbff;background:var(--mdc-switch-selected-hover-track-color, #d7bbff)}.mdc-switch:enabled:focus:not(:active) .mdc-switch__track::after{background:#d7bbff;background:var(--mdc-switch-selected-focus-track-color, #d7bbff)}.mdc-switch:enabled:active .mdc-switch__track::after{background:#d7bbff;background:var(--mdc-switch-selected-pressed-track-color, #d7bbff)}.mdc-switch:disabled .mdc-switch__track::after{background:#424242;background:var(--mdc-switch-disabled-selected-track-color, #424242)}.mdc-switch:enabled .mdc-switch__track::before{background:#e0e0e0;background:var(--mdc-switch-unselected-track-color, #e0e0e0)}.mdc-switch:enabled:hover:not(:focus):not(:active) .mdc-switch__track::before{background:#e0e0e0;background:var(--mdc-switch-unselected-hover-track-color, #e0e0e0)}.mdc-switch:enabled:focus:not(:active) .mdc-switch__track::before{background:#e0e0e0;background:var(--mdc-switch-unselected-focus-track-color, #e0e0e0)}.mdc-switch:enabled:active .mdc-switch__track::before{background:#e0e0e0;background:var(--mdc-switch-unselected-pressed-track-color, #e0e0e0)}.mdc-switch:disabled .mdc-switch__track::before{background:#424242;background:var(--mdc-switch-disabled-unselected-track-color, #424242)}.mdc-switch .mdc-switch__track{border-radius:7px;border-radius:var(--mdc-switch-track-shape, 7px)}.mdc-switch.mdc-switch--selected{--mdc-ripple-focus-state-layer-color:var(--mdc-switch-selected-focus-state-layer-color, var(--mdc-theme-primary, #6200ee));--mdc-ripple-focus-state-layer-opacity:var(--mdc-switch-selected-focus-state-layer-opacity, 0.12);--mdc-ripple-hover-state-layer-color:var(--mdc-switch-selected-hover-state-layer-color, var(--mdc-theme-primary, #6200ee));--mdc-ripple-hover-state-layer-opacity:var(--mdc-switch-selected-hover-state-layer-opacity, 0.04);--mdc-ripple-pressed-state-layer-color:var(--mdc-switch-selected-pressed-state-layer-color, var(--mdc-theme-primary, #6200ee));--mdc-ripple-pressed-state-layer-opacity:var(--mdc-switch-selected-pressed-state-layer-opacity, 0.1)}.mdc-switch.mdc-switch--selected:enabled:focus:not(:active){--mdc-ripple-hover-state-layer-color:var(--mdc-switch-selected-focus-state-layer-color, var(--mdc-theme-primary, #6200ee))}.mdc-switch.mdc-switch--selected:enabled:active{--mdc-ripple-hover-state-layer-color:var(--mdc-switch-selected-pressed-state-layer-color, var(--mdc-theme-primary, #6200ee))}.mdc-switch.mdc-switch--unselected{--mdc-ripple-focus-state-layer-color:var(--mdc-switch-unselected-focus-state-layer-color, #424242);--mdc-ripple-focus-state-layer-opacity:var(--mdc-switch-unselected-focus-state-layer-opacity, 0.12);--mdc-ripple-hover-state-layer-color:var(--mdc-switch-unselected-hover-state-layer-color, #424242);--mdc-ripple-hover-state-layer-opacity:var(--mdc-switch-unselected-hover-state-layer-opacity, 0.04);--mdc-ripple-pressed-state-layer-color:var(--mdc-switch-unselected-pressed-state-layer-color, #424242);--mdc-ripple-pressed-state-layer-opacity:var(--mdc-switch-unselected-pressed-state-layer-opacity, 0.1)}.mdc-switch.mdc-switch--unselected:enabled:focus:not(:active){--mdc-ripple-hover-state-layer-color:var(--mdc-switch-unselected-focus-state-layer-color, #424242)}.mdc-switch.mdc-switch--unselected:enabled:active{--mdc-ripple-hover-state-layer-color:var(--mdc-switch-unselected-pressed-state-layer-color, #424242)}@media screen and (forced-colors: active),(-ms-high-contrast: active){.mdc-switch:disabled .mdc-switch__handle::after{opacity:1;opacity:var(--mdc-switch-disabled-handle-opacity, 1)}.mdc-switch.mdc-switch--selected:enabled .mdc-switch__icon{fill:ButtonText;fill:var(--mdc-switch-selected-icon-color, ButtonText)}.mdc-switch.mdc-switch--selected:disabled .mdc-switch__icon{fill:GrayText;fill:var(--mdc-switch-disabled-selected-icon-color, GrayText)}.mdc-switch.mdc-switch--unselected:enabled .mdc-switch__icon{fill:ButtonText;fill:var(--mdc-switch-unselected-icon-color, ButtonText)}.mdc-switch.mdc-switch--unselected:disabled .mdc-switch__icon{fill:GrayText;fill:var(--mdc-switch-disabled-unselected-icon-color, GrayText)}.mdc-switch.mdc-switch--selected:disabled .mdc-switch__icons{opacity:1;opacity:var(--mdc-switch-disabled-selected-icon-opacity, 1)}.mdc-switch.mdc-switch--unselected:disabled .mdc-switch__icons{opacity:1;opacity:var(--mdc-switch-disabled-unselected-icon-opacity, 1)}.mdc-switch:disabled .mdc-switch__track{opacity:1;opacity:var(--mdc-switch-disabled-track-opacity, 1)}}`; + + // node_modules/@material/mwc-switch/mwc-switch.js + var Switch = class Switch2 extends SwitchBase { + }; + Switch.styles = [styles13]; + Switch = __decorate([ + e12("mwc-switch") + ], Switch); + + // client/components/settings.css + var styles14 = i`#settings-panel { + background-color: var(--comparator-greygreen-100); + border-right: 2px solid var(--comparator-greygreen-200); + display: flex; + flex-direction: column; + height: 100%; + overflow-y: auto; + padding: 0 10px 0 20px; + width: 184px; +} + +.panel-title { + align-items: center; + display: flex; + font-size: 16px; + justify-content: space-between; + margin: 30px 0 20px; +} + +.section-title { + margin-top: 20px; + font-size: 13px; + padding: 5px 0; +} + +.settings-row { + display: flex; + gap: 5px; + padding: 10px 0; +} + +mwc-switch { + --mdc-switch-selected-handle-color: var(--comparator-greygreen-700); + --mdc-switch-selected-track-color: var(--comparator-greygreen-300); + --mdc-switch-selected-hover-handle-color: var(--comparator-greygreen-700); + --mdc-switch-selected-hover-track-color: var(--comparator-greygreen-300); + --mdc-switch-selected-focus-handle-color: var(--comparator-greygreen-700); + --mdc-switch-selected-focus-track-color: var(--comparator-greygreen-300); + --mdc-switch-selected-pressed-handle-color: var(--comparator-greygreen-700); + --mdc-switch-selected-pressed-track-color: var(--comparator-greygreen-300); + /* Hide the ripple effect. */ + --mdc-switch-selected-focus-state-layer-opacity: 0; + --mdc-switch-selected-hover-state-layer-opacity: 0; + --mdc-switch-selected-pressed-state-layer-opacity: 0; + --mdc-switch-unselected-focus-state-layer-opacity: 0; + --mdc-switch-unselected-hover-state-layer-opacity: 0; + --mdc-switch-unselected-pressed-state-layer-opacity: 0; +} +`; + + // client/components/settings.ts + var NumericInput = class extends s3 { + constructor() { + super(...arguments); + this.min = 1; + this.max = 20; + this.step = 1; + this.value = 5; + } + render() { + const onInputChange = (e33) => { + const { value } = e33.target; + const numberValue = Number(value); + if (numberValue < this.min) { + this.value = this.min; + } else if (numberValue > this.max) { + this.value = this.max; + } else { + this.value = numberValue; + } + this.dispatchEvent(new Event("change")); + }; + return x` `; + } + }; + NumericInput.styles = i` + input { + width: 40px; + } + `; + __decorateClass([ + n4({ type: Number }) + ], NumericInput.prototype, "min", 2); + __decorateClass([ + n4({ type: Number }) + ], NumericInput.prototype, "max", 2); + __decorateClass([ + n4({ type: Number }) + ], NumericInput.prototype, "step", 2); + __decorateClass([ + n4({ type: Number }) + ], NumericInput.prototype, "value", 2); + NumericInput = __decorateClass([ + t3("comparator-numeric-input") + ], NumericInput); + var ComparatorSettingsElement = class extends MobxLitElement { + constructor() { + super(...arguments); + this.appState = core.getService(AppState); + } + static get styles() { + return [styles, styles14]; + } + renderMainToggles() { + const handleChangeRationaleClusterSimilarityThreshold = (e33) => { + this.appState.rationaleClusterSimilarityThreshold = Number(e33.target.value); + this.appState.reassignClusters(); + }; + return x`
    + this.appState.isShowTextDiff = !this.appState.isShowTextDiff}> + + +
    + +
    + this.appState.useMonospace = !this.appState.useMonospace}> + + +
    + +
    + this.appState.numberOfLinesPerOutputCell = Number( + e33.target.value + )}> + + +
    + +
    + this.appState.numExamplesToDisplay = Number( + e33.target.value + )}> + + +
    + +
    + this.appState.isShowTagChips = !this.appState.isShowTagChips}> + + +
    + +
    + this.appState.isFlipScoreHistogramAxis = !this.appState.isFlipScoreHistogramAxis}> + + +
    + +
    + this.appState.winRateThreshold = Number( + e33.target.value + )}> + + +
    + + ${this.appState.hasRationaleClusters === true ? x` +
    + + + +
    ` : x``} + +
    + this.appState.isShowSidebar = !this.appState.isShowSidebar}> + + +
    `; + } + renderColumnVisibilityToggles() { + const renderColumnToggle = (field) => x`
    + field.visible = !field.visible}> + + +
    `; + return x`
    + ${this.appState.columns.map((field) => renderColumnToggle(field))} +
    `; + } + render() { + return x` +
    +
    + Settings + this.appState.isOpenSettingsPanel = false}> + close + +
    + +
    + ${this.renderMainToggles()} +
    + +
    +
    + Table Column Visibility +
    + ${this.renderColumnVisibilityToggles()} +
    +
    `; + } + }; + ComparatorSettingsElement = __decorateClass([ + t3("comparator-settings") + ], ComparatorSettingsElement); + + // client/components/toolbar.css + var styles15 = i`#toolbar { + align-items: center; + background-color: var(--comparator-green-200); + border-radius: 20px; + display: flex; + height: 18px; + justify-content: space-between; + margin: 7px 16px 8px 15px; + overflow-x: clip; + padding: 6px 12px 4px; +} + +.toolbar-item { + align-items: center; + display: flex; + flex: 0 0 auto; + margin: 0 15px; +} + +.toolbar-item input { + margin-bottom: 0; + margin-top: 0; +} + +.toolbar-item.example-count { + text-align: right; /* to make "(N total)" stay in the same pos */ + width: 240px; /* space for four-digit counts */ +} + +.toolbar-item.example-count span { + margin-left: auto; +} + +.toolbar-item.filters { + margin-right: auto; +} + +.toolbar-item label { + margin-right: 3px; +} +`; + + // client/components/toolbar.ts + var ToolbarElement = class extends MobxLitElement { + constructor() { + super(...arguments); + this.appState = core.getService(AppState); + } + static get styles() { + return [styles, styles15]; + } + renderFilterChip(label, handleClickCancel) { + return x`
    + ${label} + + cancel + +
    `; + } + renderFilterChips() { + const chipForTag = this.appState.selectedTag != null ? this.renderFilterChip( + `Categories contain "${this.appState.selectedTag}"`, + () => { + this.appState.selectedTag = null; + } + ) : ""; + const chipForSearch = Object.entries(this.appState.searchFilters).filter(([fieldId, stringToSearch]) => stringToSearch !== "").map(([fieldId, stringToSearch]) => { + const field = this.appState.getFieldFromId(fieldId); + return this.renderFilterChip( + `${field ? field.name : fieldId} matches "${stringToSearch}"`, + () => { + this.appState.resetSearchFilter(fieldId); + } + ); + }); + const chipForScore = this.appState.selectedHistogramBinForScores != null ? this.renderFilterChip( + `${getHistogramFilterLabel( + "score", + this.appState.histogramSpecForScores, + this.appState.selectedHistogramBinForScores + )}`, + () => { + this.appState.selectedHistogramBinForScores = null; + } + ) : ""; + const chipsForCustomFuncs = Object.values( + this.appState.customFunctions + ).flatMap((customFunc) => { + const selections = this.appState.selectionsFromCustomFuncResults[customFunc.id]; + return Object.entries(selections).filter(([key, value]) => value != null).map(([key, value]) => { + const histogramSpec = customFunc.returnType === "Number" /* NUMBER */ ? key === "A-B" ? this.appState.histogramSpecForCustomFuncsOfDiff[customFunc.id] : this.appState.histogramSpecForCustomFuncs[customFunc.id] : null; + const label = customFunc.returnType === "Boolean" /* BOOLEAN */ ? getBarFilterLabel( + customFunc.name, + key, + selections[key] + ) : getHistogramFilterLabel( + customFunc.name, + histogramSpec, + selections[key], + key + ); + const cancelCallback = () => { + selections[key] = null; + }; + return this.renderFilterChip(label, cancelCallback); + }); + }); + const chipsForHistogramsForCustomFields = this.appState.customFieldsOfNumberType.filter( + (field) => this.appState.selectedHistogramBinForCustomFields[field.id] != null + ).map( + (field) => this.renderFilterChip( + getHistogramFilterLabel( + field.name, + this.appState.histogramSpecForCustomFields[field.id], + this.appState.selectedHistogramBinForCustomFields[field.id] + ), + () => { + this.appState.selectedHistogramBinForCustomFields[field.id] = null; + } + ) + ); + const chipsForSideBySideHistograms = this.appState.customFieldsOfPerModelNumberType.flatMap((field) => { + const selections = this.appState.selectedHistogramBinForCustomFields[field.id]; + return Object.values(AOrB).filter((model) => selections[model] != null).map((model) => { + const label = getHistogramFilterLabel( + field.name, + this.appState.histogramSpecForCustomFields[field.id], + selections[model], + model + ); + const cancelCallback = () => { + selections[model] = null; + }; + return this.renderFilterChip(label, cancelCallback); + }); + }); + const chipsForBarChartsForCustomFields = this.appState.customFieldsOfCategoryType.filter( + (field) => this.appState.selectedBarChartValues[field.id][0] != null + ).map( + (field) => this.renderFilterChip( + `${field.name} = "${this.appState.selectedBarChartValues[field.id][0]}"`, + () => { + this.appState.selectedBarChartValues[field.id][0] = null; + } + ) + ); + const chipsForGroupedBarChartsForCustomFields = this.appState.customFieldsOfPerModelCategoryTypeIncludingPerRating.flatMap( + (field) => { + const selection = this.appState.selectedBarChartValues[field.id]; + return Object.values(AOrB).map((model, groupIndex) => [model, groupIndex]).filter( + ([model, groupIndex]) => selection[groupIndex] != null + ).map(([model, groupIndex]) => { + const isPerRating = field.type === "per_rating_per_model_category" /* PER_RATING_PER_MODEL_CATEGORY */; + const operator = isPerRating === true ? "has" : "="; + return this.renderFilterChip( + `${field.name}(${model}) ${operator} "${selection[groupIndex]}"`, + () => { + selection[groupIndex] = null; + } + ); + }); + } + ); + const chipForRationaleCluster = this.appState.selectedRationaleClusterId != null ? this.renderFilterChip( + `Rationale Cluster = "${this.appState.rationaleClusters.filter( + (cluster) => cluster.id === this.appState.selectedRationaleClusterId + )[0].title}"`, + () => { + this.appState.selectedRationaleClusterId = null; + } + ) : ""; + return x` ${chipForTag} ${chipForSearch} ${chipForScore} + ${chipsForCustomFuncs} ${chipForRationaleCluster} + ${chipsForHistogramsForCustomFields} ${chipsForSideBySideHistograms} + ${chipsForBarChartsForCustomFields} + ${chipsForGroupedBarChartsForCustomFields}`; + } + render() { + const totalNum = this.appState.examples.length; + const filteredNum = this.appState.filteredExamples.length; + const shownNum = this.appState.examplesForMainTable.length; + const renderFilterChips = this.renderFilterChips(); + const isAnyFilter = filteredNum < totalNum; + const currentSorting = this.appState.currentSorting; + return x` +
    +
    + + ${shownNum} displayed + ${filteredNum !== totalNum ? x` + of ${this.appState.filteredExamples.length} + filtered` : ""} + (${totalNum} total) + +
    + +
    + ${isAnyFilter === true ? x` ${renderFilterChips}` : ""} +
    + + ${currentSorting.column !== "None" /* NONE */ ? x` +
    + + + + ${currentSorting.column === "custom attribute" /* CUSTOM_ATTRIBUTE */ ? currentSorting.customField.name : currentSorting.column} + ${currentSorting.modelIndex != null ? ` for Response ${Object.values(AOrB)[currentSorting.modelIndex]}` : ""} + + ${currentSorting.order} + +
    ` : ""} +
    `; + } + }; + ToolbarElement = __decorateClass([ + t3("comparator-toolbar") + ], ToolbarElement); + + // client/app.ts + var LlmComparatorAppElement = class extends MobxLitElement { + constructor() { + super(); + this.appState = core.getService(AppState); + this.isShowFeedbackTooltip = false; + makeObservable(this); + } + static get styles() { + return [styles, i``]; + } + renderHeader() { + const toggleSettingsIcon = () => { + this.appState.isOpenSettingsPanel = !this.appState.isOpenSettingsPanel; + }; + const feedbackLink = "https://github.com/PAIR-code/llm-comparator/issues"; + const documentationLink = "https://github.com/PAIR-code/llm-comparator"; + const handleClickLoadData = () => { + this.appState.isOpenDatasetSelectionPanel = !this.appState.isOpenDatasetSelectionPanel; + }; + const renderLoadDataLink = x` + `; + return x` + `; + } + renderStatusMessage() { + return x` +
    +
    ${this.appState.statusMessage}
    +
    this.appState.isOpenStatusMessage = false}> + Dismiss +
    +
    `; + } + renderSidebar() { + const components = x` + + + + + `; + return x``; + } + render() { + const styleExampleDetailsPanel = e6({ + "expanded": this.appState.exampleDetailsPanelExpanded === true + }); + return x` +
    + ${this.renderHeader()} +
    + + ${this.appState.isOpenSettingsPanel === true ? x`` : ""} +
    + +
    + +
    + ${this.appState.showSelectedExampleDetails === true && this.appState.selectedExample != null ? x` +
    + +
    ` : ""} +
    + ${this.appState.isShowSidebar === true ? this.renderSidebar() : ""} +
    + ${this.appState.isOpenStatusMessage === true ? this.renderStatusMessage() : ""} +
    `; + } + }; + __decorateClass([ + observable + ], LlmComparatorAppElement.prototype, "isShowFeedbackTooltip", 2); + LlmComparatorAppElement = __decorateClass([ + t3("llm-comparator-app") + ], LlmComparatorAppElement); + + // client/index.ts + async function main() { + window.addEventListener("load", () => { + core.initialize(); + }); + j( + x``, + document.querySelector("#app-container") + ); + } + main(); +})(); +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*! Bundled license information: + +@lit/reactive-element/css-tag.js: + (** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/reactive-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/lit-html.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-element/lit-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/is-server.js: + (** + * @license + * Copyright 2022 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/custom-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/property.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/state.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/event-options.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/base.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-all.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-async.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-assigned-elements.js: + (** + * @license + * Copyright 2021 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-assigned-nodes.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/directive.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/directives/class-map.js: + (** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/css-tag.js: + (** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/reactive-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/lit-html.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-element/lit-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/is-server.js: + (** + * @license + * Copyright 2022 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/custom-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/property.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/state.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/base.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/event-options.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-all.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-async.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-assigned-elements.js: + (** + * @license + * Copyright 2021 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-assigned-nodes.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@material/mwc-icon/mwc-icon-host.css.js: + (** + * @license + * Copyright 2021 Google LLC + * SPDX-LIcense-Identifier: Apache-2.0 + *) + +@material/mwc-icon/mwc-icon.js: + (** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: Apache-2.0 + *) + +lit-html/directives/style-map.js: + (** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/custom-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/property.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/state.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/base.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/event-options.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-all.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-async.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-assigned-elements.js: + (** + * @license + * Copyright 2021 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-assigned-nodes.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/custom-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/property.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/state.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/base.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/event-options.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-all.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-async.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-assigned-elements.js: + (** + * @license + * Copyright 2021 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-assigned-nodes.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@material/dom/ponyfill.js: + (** + * @license + * Copyright 2018 Google Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + *) + +@lit/reactive-element/css-tag.js: + (** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/reactive-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/lit-html.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-element/lit-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/is-server.js: + (** + * @license + * Copyright 2022 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@material/mwc-base/utils.js: + (** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: Apache-2.0 + *) + +@material/mwc-base/base-element.js: + (** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: Apache-2.0 + *) + +@material/base/foundation.js: + (** + * @license + * Copyright 2016 Google Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + *) + +@material/ripple/constants.js: + (** + * @license + * Copyright 2016 Google Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + *) + +@material/ripple/foundation.js: + (** + * @license + * Copyright 2016 Google Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + *) + +@lit/reactive-element/css-tag.js: + (** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/reactive-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/lit-html.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-element/lit-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/is-server.js: + (** + * @license + * Copyright 2022 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/directive.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/directives/class-map.js: + (** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/directives/style-map.js: + (** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@material/mwc-ripple/mwc-ripple-base.js: + (** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: Apache-2.0 + *) + +@material/mwc-ripple/mwc-ripple.css.js: + (** + * @license + * Copyright 2021 Google LLC + * SPDX-LIcense-Identifier: Apache-2.0 + *) + +@material/mwc-ripple/mwc-ripple.js: + (** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: Apache-2.0 + *) + +@material/mwc-base/aria-property.js: + (** + * @license + * Copyright 2021 Google LLC + * SPDX-License-Identifier: Apache-2.0 + *) + +@lit/reactive-element/decorators/custom-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/property.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/state.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/base.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/event-options.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-all.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-async.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-assigned-elements.js: + (** + * @license + * Copyright 2021 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/decorators/query-assigned-nodes.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@material/mwc-base/form-element.js: + (** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: Apache-2.0 + *) + +@material/mwc-ripple/ripple-handlers.js: + (** + * @license + * Copyright 2020 Google LLC + * SPDX-License-Identifier: Apache-2.0 + *) + +@material/base/observer.js: + (** + * @license + * Copyright 2021 Google Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + *) + +@material/base/observer-foundation.js: + (** + * @license + * Copyright 2021 Google Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + *) + +@material/switch/constants.js: + (** + * @license + * Copyright 2021 Google Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + *) + +@material/switch/foundation.js: + (** + * @license + * Copyright 2021 Google Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + *) + +@lit/reactive-element/css-tag.js: + (** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@lit/reactive-element/reactive-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/lit-html.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-element/lit-element.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/is-server.js: + (** + * @license + * Copyright 2022 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/directive.js: + (** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/directives/class-map.js: + (** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +lit-html/directives/if-defined.js: + (** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + *) + +@material/mwc-switch/mwc-switch-base.js: + (** + * @license + * Copyright 2021 Google LLC + * SPDX-License-Identifier: Apache-2.0 + *) + +@material/mwc-switch/styles.css.js: + (** + * @license + * Copyright 2021 Google LLC + * SPDX-LIcense-Identifier: Apache-2.0 + *) + +@material/mwc-switch/mwc-switch.js: + (** + * @license + * Copyright 2021 Google LLC + * SPDX-License-Identifier: Apache-2.0 + *) +*/ +//# sourceMappingURL=dev_sources.concat.js.map diff --git a/python/src/llm_comparator/data/dev_sources.concat.js.map b/python/src/llm_comparator/data/dev_sources.concat.js.map new file mode 100644 index 0000000..f4541e8 --- /dev/null +++ b/python/src/llm_comparator/data/dev_sources.concat.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": ["../node_modules/jsdifflib/index.js", "../node_modules/jstat/dist/jstat.js", "../node_modules/@adobe/lit-mobx/src/lib/mixin-custom.ts", "../node_modules/mobx/src/errors.ts", "../node_modules/mobx/src/utils/global.ts", "../node_modules/mobx/src/utils/utils.ts", "../node_modules/mobx/src/api/decorators.ts", "../node_modules/mobx/src/core/atom.ts", "../node_modules/mobx/src/utils/comparer.ts", "../node_modules/mobx/src/types/modifiers.ts", "../node_modules/mobx/src/types/overrideannotation.ts", "../node_modules/mobx/src/types/actionannotation.ts", "../node_modules/mobx/src/types/flowannotation.ts", "../node_modules/mobx/src/types/computedannotation.ts", "../node_modules/mobx/src/types/observableannotation.ts", "../node_modules/mobx/src/types/autoannotation.ts", "../node_modules/mobx/src/api/observable.ts", "../node_modules/mobx/src/api/computed.ts", "../node_modules/mobx/src/core/action.ts", "../node_modules/mobx/src/types/observablevalue.ts", "../node_modules/mobx/src/core/computedvalue.ts", "../node_modules/mobx/src/core/derivation.ts", "../node_modules/mobx/src/core/globalstate.ts", "../node_modules/mobx/src/core/observable.ts", "../node_modules/mobx/src/core/reaction.ts", "../node_modules/mobx/src/core/spy.ts", "../node_modules/mobx/src/api/action.ts", "../node_modules/mobx/src/api/autorun.ts", "../node_modules/mobx/src/api/become-observed.ts", "../node_modules/mobx/src/api/configure.ts", "../node_modules/mobx/src/api/extendobservable.ts", "../node_modules/mobx/src/api/extras.ts", "../node_modules/mobx/src/api/flow.ts", "../node_modules/mobx/src/api/intercept-read.ts", "../node_modules/mobx/src/api/intercept.ts", "../node_modules/mobx/src/api/iscomputed.ts", "../node_modules/mobx/src/api/isobservable.ts", "../node_modules/mobx/src/api/object-api.ts", "../node_modules/mobx/src/api/observe.ts", "../node_modules/mobx/src/api/tojs.ts", "../node_modules/mobx/src/api/trace.ts", "../node_modules/mobx/src/api/transaction.ts", "../node_modules/mobx/src/api/when.ts", "../node_modules/mobx/src/types/dynamicobject.ts", "../node_modules/mobx/src/types/intercept-utils.ts", "../node_modules/mobx/src/types/listen-utils.ts", "../node_modules/mobx/src/api/makeObservable.ts", "../node_modules/mobx/src/types/observablearray.ts", "../node_modules/mobx/src/types/observablemap.ts", "../node_modules/mobx/src/types/observableset.ts", "../node_modules/mobx/src/types/observableobject.ts", "../node_modules/mobx/src/types/legacyobservablearray.ts", "../node_modules/mobx/src/types/type-utils.ts", "../node_modules/mobx/src/utils/eq.ts", "../node_modules/mobx/src/utils/iterable.ts", "../node_modules/mobx/src/api/annotation.ts", "../node_modules/mobx/src/mobx.ts", "../node_modules/@adobe/lit-mobx/src/lib/mixin.ts", "../node_modules/@lit/reactive-element/src/css-tag.ts", "../node_modules/@lit/reactive-element/src/reactive-element.ts", "../node_modules/lit-html/src/lit-html.ts", "../node_modules/lit-element/src/lit-element.ts", "../node_modules/@adobe/lit-mobx/src/lit-mobx.ts", "../node_modules/@lit/reactive-element/src/decorators/custom-element.ts", "../node_modules/@lit/reactive-element/src/decorators/property.ts", "../node_modules/lit-html/src/directive.ts", "../node_modules/lit-html/src/directives/class-map.ts", "../client/lib/shared_styles.css", "../client/components/bar_chart.css", "../client/components/bar_chart.ts", "../client/lib/types.ts", "../client/lib/constants.ts", "../client/lib/utils.ts", "../client/components/histogram.css", "../client/components/histogram.ts", "../client/services/service.ts", "../client/services/custom_function_service.ts", "../client/services/state_service.ts", "../client/core.ts", "../client/components/charts.ts", "../client/components/custom_functions.css", "../client/components/custom_functions.ts", "../client/components/dataset_selection.css", "../client/components/dataset_selection.ts", "../client/components/example_details.css", "../client/components/example_details.ts", "../node_modules/tslib/tslib.es6.mjs", "../node_modules/@material/mwc-icon/node_modules/@lit/reactive-element/src/css-tag.ts", "../node_modules/@material/mwc-icon/node_modules/@lit/reactive-element/src/reactive-element.ts", "../node_modules/@material/mwc-icon/node_modules/lit-html/src/lit-html.ts", "../node_modules/@material/mwc-icon/node_modules/lit-element/src/lit-element.ts", "../node_modules/@material/mwc-icon/node_modules/@lit/reactive-element/src/decorators/custom-element.ts", "../node_modules/@material/mwc-icon/node_modules/@lit/reactive-element/src/decorators/query-assigned-elements.ts", "../node_modules/@material/mwc-icon/mwc-icon-host.css.ts", "../node_modules/@material/mwc-icon/mwc-icon.ts", "../node_modules/lit-html/src/directives/style-map.ts", "../client/components/example_table.css", "../client/components/example_table.ts", "../client/components/metrics_by_slice.css", "../client/components/metrics_by_slice.ts", "../client/components/rationale_summary.css", "../client/components/rationale_summary.ts", "../client/components/score_histogram.css", "../client/components/score_histogram.ts", "../node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/src/decorators/custom-element.ts", "../node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/src/decorators/property.ts", "../node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/src/decorators/state.ts", "../node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/src/decorators/base.ts", "../node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/src/decorators/event-options.ts", "../node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/src/decorators/query.ts", "../node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/src/decorators/query-async.ts", "../node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/src/decorators/query-assigned-elements.ts", "../node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/src/decorators/custom-element.ts", "../node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/src/decorators/property.ts", "../node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/src/decorators/state.ts", "../node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/src/decorators/base.ts", "../node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/src/decorators/query.ts", "../node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/src/decorators/query-assigned-elements.ts", "../node_modules/@material/dom/ponyfill.ts", "../node_modules/@material/mwc-base/node_modules/@lit/reactive-element/src/css-tag.ts", "../node_modules/@material/mwc-base/node_modules/@lit/reactive-element/src/reactive-element.ts", "../node_modules/@material/mwc-base/node_modules/lit-html/src/lit-html.ts", "../node_modules/@material/mwc-base/node_modules/lit-element/src/lit-element.ts", "../node_modules/@material/mwc-base/utils.ts", "../node_modules/@material/mwc-base/base-element.ts", "../node_modules/@material/base/foundation.ts", "../node_modules/@material/ripple/constants.ts", "../node_modules/@material/ripple/util.ts", "../node_modules/@material/ripple/foundation.ts", "../node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/src/css-tag.ts", "../node_modules/@material/mwc-ripple/node_modules/@lit/reactive-element/src/reactive-element.ts", "../node_modules/@material/mwc-ripple/node_modules/lit-html/src/lit-html.ts", "../node_modules/@material/mwc-ripple/node_modules/lit-element/src/lit-element.ts", "../node_modules/@material/mwc-ripple/node_modules/lit-html/src/directive.ts", "../node_modules/@material/mwc-ripple/node_modules/lit-html/src/directives/class-map.ts", "../node_modules/@material/mwc-ripple/node_modules/lit-html/src/directives/style-map.ts", "../node_modules/@material/mwc-ripple/mwc-ripple-base.ts", "../node_modules/@material/mwc-ripple/mwc-ripple.css.ts", "../node_modules/@material/mwc-ripple/mwc-ripple.ts", "../node_modules/@material/mwc-base/aria-property.ts", "../node_modules/@material/mwc-base/node_modules/@lit/reactive-element/src/decorators/property.ts", "../node_modules/@material/mwc-base/node_modules/@lit/reactive-element/src/decorators/query-assigned-elements.ts", "../node_modules/@material/mwc-base/form-element.ts", "../node_modules/@material/mwc-ripple/ripple-handlers.ts", "../node_modules/@material/base/observer.ts", "../node_modules/@material/base/observer-foundation.ts", "../node_modules/@material/switch/constants.ts", "../node_modules/@material/switch/foundation.ts", "../node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/src/css-tag.ts", "../node_modules/@material/mwc-switch/node_modules/@lit/reactive-element/src/reactive-element.ts", "../node_modules/@material/mwc-switch/node_modules/lit-html/src/lit-html.ts", "../node_modules/@material/mwc-switch/node_modules/lit-element/src/lit-element.ts", "../node_modules/@material/mwc-switch/node_modules/lit-html/src/directive.ts", "../node_modules/@material/mwc-switch/node_modules/lit-html/src/directives/class-map.ts", "../node_modules/@material/mwc-switch/node_modules/lit-html/src/directives/if-defined.ts", "../node_modules/@material/mwc-switch/mwc-switch-base.ts", "../node_modules/@material/mwc-switch/styles.css.ts", "../node_modules/@material/mwc-switch/mwc-switch.ts", "../client/components/settings.css", "../client/components/settings.ts", "../client/components/toolbar.css", "../client/components/toolbar.ts", "../client/app.ts", "../client/index.ts"], + "sourcesContent": ["/***\r\nThis is part of jsdifflib v1.0. \r\n\r\nCopyright (c) 2007, Snowtide Informatics Systems, Inc.\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice, this\r\n list of conditions and the following disclaimer.\r\n * Redistributions in binary form must reproduce the above copyright notice,\r\n this list of conditions and the following disclaimer in the documentation\r\n and/or other materials provided with the distribution.\r\n * Neither the name of the Snowtide Informatics Systems nor the names of its\r\n contributors may be used to endorse or promote products derived from this\r\n software without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY\r\nEXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\r\nOF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT\r\nSHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\r\nTO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\r\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\nCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r\nANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH\r\nDAMAGE.\r\n***/\r\n/* Author: Chas Emerick */\r\n__whitespace = {\" \":true, \"\\t\":true, \"\\n\":true, \"\\f\":true, \"\\r\":true};\r\n\r\nvar difflib = module.exports = {\r\n defaultJunkFunction: function (c) {\r\n return __whitespace.hasOwnProperty(c);\r\n },\r\n \r\n stripLinebreaks: function (str) { return str.replace(/^[\\n\\r]*|[\\n\\r]*$/g, \"\"); },\r\n \r\n stringAsLines: function (str) {\r\n var lfpos = str.indexOf(\"\\n\");\r\n var crpos = str.indexOf(\"\\r\");\r\n var linebreak = ((lfpos > -1 && crpos > -1) || crpos < 0) ? \"\\n\" : \"\\r\";\r\n \r\n var lines = str.split(linebreak);\r\n for (var i = 0; i < lines.length; i++) {\r\n lines[i] = difflib.stripLinebreaks(lines[i]);\r\n }\r\n \r\n return lines;\r\n },\r\n \r\n // iteration-based reduce implementation\r\n __reduce: function (func, list, initial) {\r\n if (initial != null) {\r\n var value = initial;\r\n var idx = 0;\r\n } else if (list) {\r\n var value = list[0];\r\n var idx = 1;\r\n } else {\r\n return null;\r\n }\r\n \r\n for (; idx < list.length; idx++) {\r\n value = func(value, list[idx]);\r\n }\r\n \r\n return value;\r\n },\r\n \r\n // comparison function for sorting lists of numeric tuples\r\n __ntuplecomp: function (a, b) {\r\n var mlen = Math.max(a.length, b.length);\r\n for (var i = 0; i < mlen; i++) {\r\n if (a[i] < b[i]) return -1;\r\n if (a[i] > b[i]) return 1;\r\n }\r\n \r\n return a.length == b.length ? 0 : (a.length < b.length ? -1 : 1);\r\n },\r\n \r\n __calculate_ratio: function (matches, length) {\r\n return length ? 2.0 * matches / length : 1.0;\r\n },\r\n \r\n // returns a function that returns true if a key passed to the returned function\r\n // is in the dict (js object) provided to this function; replaces being able to\r\n // carry around dict.has_key in python...\r\n __isindict: function (dict) {\r\n return function (key) { return dict.hasOwnProperty(key); };\r\n },\r\n \r\n // replacement for python's dict.get function -- need easy default values\r\n __dictget: function (dict, key, defaultValue) {\r\n return dict.hasOwnProperty(key) ? dict[key] : defaultValue;\r\n }, \r\n \r\n SequenceMatcher: function (a, b, isjunk) {\r\n this.set_seqs = function (a, b) {\r\n this.set_seq1(a);\r\n this.set_seq2(b);\r\n }\r\n \r\n this.set_seq1 = function (a) {\r\n if (a == this.a) return;\r\n this.a = a;\r\n this.matching_blocks = this.opcodes = null;\r\n }\r\n \r\n this.set_seq2 = function (b) {\r\n if (b == this.b) return;\r\n this.b = b;\r\n this.matching_blocks = this.opcodes = this.fullbcount = null;\r\n this.__chain_b();\r\n }\r\n \r\n this.__chain_b = function () {\r\n var b = this.b;\r\n var n = b.length;\r\n var b2j = this.b2j = {};\r\n var populardict = {};\r\n for (var i = 0; i < b.length; i++) {\r\n var elt = b[i];\r\n if (b2j.hasOwnProperty(elt)) {\r\n var indices = b2j[elt];\r\n if (n >= 200 && indices.length * 100 > n) {\r\n populardict[elt] = 1;\r\n delete b2j[elt];\r\n } else {\r\n indices.push(i);\r\n }\r\n } else {\r\n b2j[elt] = [i];\r\n }\r\n }\r\n \r\n for (var elt in populardict) {\r\n if (populardict.hasOwnProperty(elt)) {\r\n delete b2j[elt];\r\n }\r\n }\r\n \r\n var isjunk = this.isjunk;\r\n var junkdict = {};\r\n if (isjunk) {\r\n for (var elt in populardict) {\r\n if (populardict.hasOwnProperty(elt) && isjunk(elt)) {\r\n junkdict[elt] = 1;\r\n delete populardict[elt];\r\n }\r\n }\r\n for (var elt in b2j) {\r\n if (b2j.hasOwnProperty(elt) && isjunk(elt)) {\r\n junkdict[elt] = 1;\r\n delete b2j[elt];\r\n }\r\n }\r\n }\r\n \r\n this.isbjunk = difflib.__isindict(junkdict);\r\n this.isbpopular = difflib.__isindict(populardict);\r\n }\r\n \r\n this.find_longest_match = function (alo, ahi, blo, bhi) {\r\n var a = this.a;\r\n var b = this.b;\r\n var b2j = this.b2j;\r\n var isbjunk = this.isbjunk;\r\n var besti = alo;\r\n var bestj = blo;\r\n var bestsize = 0;\r\n var j = null;\r\n \r\n var j2len = {};\r\n var nothing = [];\r\n for (var i = alo; i < ahi; i++) {\r\n var newj2len = {};\r\n var jdict = difflib.__dictget(b2j, a[i], nothing);\r\n for (var jkey in jdict) {\r\n if (jdict.hasOwnProperty(jkey)) {\r\n j = jdict[jkey];\r\n if (j < blo) continue;\r\n if (j >= bhi) break;\r\n newj2len[j] = k = difflib.__dictget(j2len, j - 1, 0) + 1;\r\n if (k > bestsize) {\r\n besti = i - k + 1;\r\n bestj = j - k + 1;\r\n bestsize = k;\r\n }\r\n }\r\n }\r\n j2len = newj2len;\r\n }\r\n \r\n while (besti > alo && bestj > blo && !isbjunk(b[bestj - 1]) && a[besti - 1] == b[bestj - 1]) {\r\n besti--;\r\n bestj--;\r\n bestsize++;\r\n }\r\n \r\n while (besti + bestsize < ahi && bestj + bestsize < bhi &&\r\n !isbjunk(b[bestj + bestsize]) &&\r\n a[besti + bestsize] == b[bestj + bestsize]) {\r\n bestsize++;\r\n }\r\n \r\n while (besti > alo && bestj > blo && isbjunk(b[bestj - 1]) && a[besti - 1] == b[bestj - 1]) {\r\n besti--;\r\n bestj--;\r\n bestsize++;\r\n }\r\n \r\n while (besti + bestsize < ahi && bestj + bestsize < bhi && isbjunk(b[bestj + bestsize]) &&\r\n a[besti + bestsize] == b[bestj + bestsize]) {\r\n bestsize++;\r\n }\r\n \r\n return [besti, bestj, bestsize];\r\n }\r\n \r\n this.get_matching_blocks = function () {\r\n if (this.matching_blocks != null) return this.matching_blocks;\r\n var la = this.a.length;\r\n var lb = this.b.length;\r\n \r\n var queue = [[0, la, 0, lb]];\r\n var matching_blocks = [];\r\n var alo, ahi, blo, bhi, qi, i, j, k, x;\r\n while (queue.length) {\r\n qi = queue.pop();\r\n alo = qi[0];\r\n ahi = qi[1];\r\n blo = qi[2];\r\n bhi = qi[3];\r\n x = this.find_longest_match(alo, ahi, blo, bhi);\r\n i = x[0];\r\n j = x[1];\r\n k = x[2];\r\n \r\n if (k) {\r\n matching_blocks.push(x);\r\n if (alo < i && blo < j)\r\n queue.push([alo, i, blo, j]);\r\n if (i+k < ahi && j+k < bhi)\r\n queue.push([i + k, ahi, j + k, bhi]);\r\n }\r\n }\r\n \r\n matching_blocks.sort(difflib.__ntuplecomp);\r\n \r\n var i1 = j1 = k1 = block = 0;\r\n var non_adjacent = [];\r\n for (var idx in matching_blocks) {\r\n if (matching_blocks.hasOwnProperty(idx)) {\r\n block = matching_blocks[idx];\r\n i2 = block[0];\r\n j2 = block[1];\r\n k2 = block[2];\r\n if (i1 + k1 == i2 && j1 + k1 == j2) {\r\n k1 += k2;\r\n } else {\r\n if (k1) non_adjacent.push([i1, j1, k1]);\r\n i1 = i2;\r\n j1 = j2;\r\n k1 = k2;\r\n }\r\n }\r\n }\r\n \r\n if (k1) non_adjacent.push([i1, j1, k1]);\r\n \r\n non_adjacent.push([la, lb, 0]);\r\n this.matching_blocks = non_adjacent;\r\n return this.matching_blocks;\r\n }\r\n \r\n this.get_opcodes = function () {\r\n if (this.opcodes != null) return this.opcodes;\r\n var i = 0;\r\n var j = 0;\r\n var answer = [];\r\n this.opcodes = answer;\r\n var block, ai, bj, size, tag;\r\n var blocks = this.get_matching_blocks();\r\n for (var idx in blocks) {\r\n if (blocks.hasOwnProperty(idx)) {\r\n block = blocks[idx];\r\n ai = block[0];\r\n bj = block[1];\r\n size = block[2];\r\n tag = '';\r\n if (i < ai && j < bj) {\r\n tag = 'replace';\r\n } else if (i < ai) {\r\n tag = 'delete';\r\n } else if (j < bj) {\r\n tag = 'insert';\r\n }\r\n if (tag) answer.push([tag, i, ai, j, bj]);\r\n i = ai + size;\r\n j = bj + size;\r\n \r\n if (size) answer.push(['equal', ai, i, bj, j]);\r\n }\r\n }\r\n \r\n return answer;\r\n }\r\n \r\n // this is a generator function in the python lib, which of course is not supported in javascript\r\n // the reimplementation builds up the grouped opcodes into a list in their entirety and returns that.\r\n this.get_grouped_opcodes = function (n) {\r\n if (!n) n = 3;\r\n var codes = this.get_opcodes();\r\n if (!codes) codes = [[\"equal\", 0, 1, 0, 1]];\r\n var code, tag, i1, i2, j1, j2;\r\n if (codes[0][0] == 'equal') {\r\n code = codes[0];\r\n tag = code[0];\r\n i1 = code[1];\r\n i2 = code[2];\r\n j1 = code[3];\r\n j2 = code[4];\r\n codes[0] = [tag, Math.max(i1, i2 - n), i2, Math.max(j1, j2 - n), j2];\r\n }\r\n if (codes[codes.length - 1][0] == 'equal') {\r\n code = codes[codes.length - 1];\r\n tag = code[0];\r\n i1 = code[1];\r\n i2 = code[2];\r\n j1 = code[3];\r\n j2 = code[4];\r\n codes[codes.length - 1] = [tag, i1, Math.min(i2, i1 + n), j1, Math.min(j2, j1 + n)];\r\n }\r\n \r\n var nn = n + n;\r\n var groups = [];\r\n for (var idx in codes) {\r\n if (codes.hasOwnProperty(idx)) {\r\n code = codes[idx];\r\n tag = code[0];\r\n i1 = code[1];\r\n i2 = code[2];\r\n j1 = code[3];\r\n j2 = code[4];\r\n if (tag == 'equal' && i2 - i1 > nn) {\r\n groups.push([tag, i1, Math.min(i2, i1 + n), j1, Math.min(j2, j1 + n)]);\r\n i1 = Math.max(i1, i2-n);\r\n j1 = Math.max(j1, j2-n);\r\n }\r\n \r\n groups.push([tag, i1, i2, j1, j2]);\r\n }\r\n }\r\n \r\n if (groups && groups[groups.length - 1][0] == 'equal') groups.pop();\r\n \r\n return groups;\r\n }\r\n \r\n this.ratio = function () {\r\n matches = difflib.__reduce(\r\n function (sum, triple) { return sum + triple[triple.length - 1]; },\r\n this.get_matching_blocks(), 0);\r\n return difflib.__calculate_ratio(matches, this.a.length + this.b.length);\r\n }\r\n \r\n this.quick_ratio = function () {\r\n var fullbcount, elt;\r\n if (this.fullbcount == null) {\r\n this.fullbcount = fullbcount = {};\r\n for (var i = 0; i < this.b.length; i++) {\r\n elt = this.b[i];\r\n fullbcount[elt] = difflib.__dictget(fullbcount, elt, 0) + 1;\r\n }\r\n }\r\n fullbcount = this.fullbcount;\r\n \r\n var avail = {};\r\n var availhas = difflib.__isindict(avail);\r\n var matches = numb = 0;\r\n for (var i = 0; i < this.a.length; i++) {\r\n elt = this.a[i];\r\n if (availhas(elt)) {\r\n numb = avail[elt];\r\n } else {\r\n numb = difflib.__dictget(fullbcount, elt, 0);\r\n }\r\n avail[elt] = numb - 1;\r\n if (numb > 0) matches++;\r\n }\r\n \r\n return difflib.__calculate_ratio(matches, this.a.length + this.b.length);\r\n }\r\n \r\n this.real_quick_ratio = function () {\r\n var la = this.a.length;\r\n var lb = this.b.length;\r\n return _calculate_ratio(Math.min(la, lb), la + lb);\r\n }\r\n \r\n this.isjunk = isjunk ? isjunk : difflib.defaultJunkFunction;\r\n this.a = this.b = null;\r\n this.set_seqs(a, b);\r\n },\r\n\r\n /**\r\n * Builds and returns a visual diff view. The single parameter, `params', should contain\r\n * the following values:\r\n *\r\n * - baseText: the string that will be used as the base input to SequenceMatcher\r\n * - nextText: the string that will be used as the new text input to SequenceMatcher\r\n *\r\n * or\r\n *\r\n * - baseTextLines: the array of strings that was used as the base text input to SequenceMatcher\r\n * - newTextLines: the array of strings that was used as the new text input to SequenceMatcher\r\n * - opcodes: the array of arrays returned by SequenceMatcher.get_opcodes()\r\n *\r\n * and:\r\n *\r\n * - baseTextName: the title to be displayed above the base text listing in the diff view; defaults\r\n * to \"Base Text\"\r\n * - newTextName: the title to be displayed above the new text listing in the diff view; defaults\r\n * to \"New Text\"\r\n * - contextSize: the number of lines of context to show around differences; by default, all lines\r\n * are shown\r\n * - inline: if false, a side-by-side diff view is generated (default); if true, an inline diff view is\r\n * generated\r\n */\r\n buildView: function (params) {\r\n var baseTextLines = params.baseTextLines === undefined ?\r\n difflib.stringAsLines(params.baseText) :\r\n params.baseTextLines;\r\n var newTextLines = params.newTextLines === undefined ?\r\n difflib.stringAsLines(params.newText) :\r\n params.newTextLines;\r\n var opcodes = params.opcodes === undefined ?\r\n (new difflib.SequenceMatcher(baseTextLines, newTextLines)).get_opcodes() :\r\n params.opcodes;\r\n var baseTextName = params.baseTextName ? params.baseTextName : \"Base Text\";\r\n var newTextName = params.newTextName ? params.newTextName : \"New Text\";\r\n var contextSize = params.contextSize;\r\n var inline = params.inline || false;\r\n\r\n if (baseTextLines == null)\r\n throw \"Cannot build diff view; baseTextLines is not defined.\";\r\n if (newTextLines == null)\r\n throw \"Cannot build diff view; newTextLines is not defined.\";\r\n if (!opcodes)\r\n throw \"Canno build diff view; opcodes is not defined.\";\r\n \r\n function celt (name, clazz) {\r\n var e = document.createElement(name);\r\n e.className = clazz;\r\n return e;\r\n }\r\n \r\n function telt (name, text) {\r\n var e = document.createElement(name);\r\n e.appendChild(document.createTextNode(text));\r\n return e;\r\n }\r\n \r\n function ctelt (name, clazz, text) {\r\n var e = document.createElement(name);\r\n e.className = clazz;\r\n e.appendChild(document.createTextNode(text));\r\n return e;\r\n }\r\n \r\n var tdata = document.createElement(\"thead\");\r\n var node = document.createElement(\"tr\");\r\n tdata.appendChild(node);\r\n if (inline) {\r\n node.appendChild(document.createElement(\"th\"));\r\n node.appendChild(document.createElement(\"th\"));\r\n node.appendChild(ctelt(\"th\", \"texttitle\", baseTextName + \" vs. \" + newTextName));\r\n } else {\r\n node.appendChild(document.createElement(\"th\"));\r\n node.appendChild(ctelt(\"th\", \"texttitle\", baseTextName));\r\n node.appendChild(document.createElement(\"th\"));\r\n node.appendChild(ctelt(\"th\", \"texttitle\", newTextName));\r\n }\r\n tdata = [tdata];\r\n \r\n var rows = [];\r\n var node2;\r\n \r\n /**\r\n * Adds two cells to the given row; if the given row corresponds to a real\r\n * line number (based on the line index tidx and the endpoint of the \r\n * range in question tend), then the cells will contain the line number\r\n * and the line of text from textLines at position tidx (with the class of\r\n * the second cell set to the name of the change represented), and tidx + 1 will\r\n * be returned. Otherwise, tidx is returned, and two empty cells are added\r\n * to the given row.\r\n */\r\n function addCells (row, tidx, tend, textLines, change) {\r\n if (tidx < tend) {\r\n row.appendChild(telt(\"th\", (tidx + 1).toString()));\r\n row.appendChild(ctelt(\"td\", change, textLines[tidx].replace(/\\t/g, \"\\u00a0\\u00a0\\u00a0\\u00a0\")));\r\n return tidx + 1;\r\n } else {\r\n row.appendChild(document.createElement(\"th\"));\r\n row.appendChild(celt(\"td\", \"empty\"));\r\n return tidx;\r\n }\r\n }\r\n \r\n function addCellsInline (row, tidx, tidx2, textLines, change) {\r\n row.className = change;\r\n row.appendChild(telt(\"th\", tidx == null ? \"\" : (tidx + 1).toString()));\r\n row.appendChild(telt(\"th\", tidx2 == null ? \"\" : (tidx2 + 1).toString()));\r\n row.appendChild(telt(\"td\", textLines[tidx != null ? tidx : tidx2].replace(/\\t/g, \"\\u00a0\\u00a0\\u00a0\\u00a0\")));\r\n }\r\n \r\n for (var idx = 0; idx < opcodes.length; idx++) {\r\n code = opcodes[idx];\r\n change = code[0];\r\n var b = code[1];\r\n var be = code[2];\r\n var n = code[3];\r\n var ne = code[4];\r\n var rowcnt = Math.max(be - b, ne - n);\r\n var toprows = [];\r\n var botrows = [];\r\n for (var i = 0; i < rowcnt; i++) {\r\n // jump ahead if we've alredy provided leading context or if this is the first range\r\n if (contextSize && opcodes.length > 1 && ((idx > 0 && i == contextSize) || (idx == 0 && i == 0)) && change==\"equal\") {\r\n var jump = rowcnt - ((idx == 0 ? 1 : 2) * contextSize);\r\n if (jump > 1) {\r\n toprows.push(node = document.createElement(\"tr\"));\r\n \r\n b += jump;\r\n n += jump;\r\n i += jump - 1;\r\n node.appendChild(telt(\"th\", \"...\"));\r\n if (!inline) node.appendChild(ctelt(\"td\", \"skip\", \"\"));\r\n node.appendChild(telt(\"th\", \"...\"));\r\n node.appendChild(ctelt(\"td\", \"skip\", \"\"));\r\n \r\n // skip last lines if they're all equal\r\n if (idx + 1 == opcodes.length) {\r\n break;\r\n } else {\r\n continue;\r\n }\r\n }\r\n }\r\n \r\n toprows.push(node = document.createElement(\"tr\"));\r\n if (inline) {\r\n if (change == \"insert\") {\r\n addCellsInline(node, null, n++, newTextLines, change);\r\n } else if (change == \"replace\") {\r\n botrows.push(node2 = document.createElement(\"tr\"));\r\n if (b < be) addCellsInline(node, b++, null, baseTextLines, \"delete\");\r\n if (n < ne) addCellsInline(node2, null, n++, newTextLines, \"insert\");\r\n } else if (change == \"delete\") {\r\n addCellsInline(node, b++, null, baseTextLines, change);\r\n } else {\r\n // equal\r\n addCellsInline(node, b++, n++, baseTextLines, change);\r\n }\r\n } else {\r\n b = addCells(node, b, be, baseTextLines, change);\r\n n = addCells(node, n, ne, newTextLines, change);\r\n }\r\n }\r\n\r\n for (var i = 0; i < toprows.length; i++) rows.push(toprows[i]);\r\n for (var i = 0; i < botrows.length; i++) rows.push(botrows[i]);\r\n }\r\n \r\n rows.push(node = ctelt(\"th\", \"author\", \"diff view generated by \"));\r\n node.setAttribute(\"colspan\", inline ? 3 : 4);\r\n node.appendChild(node2 = telt(\"a\", \"jsdifflib\"));\r\n node2.setAttribute(\"href\", \"http://github.com/cemerick/jsdifflib\");\r\n \r\n tdata.push(node = document.createElement(\"tbody\"));\r\n for (var idx in rows) node.appendChild(rows[idx]);\r\n \r\n node = celt(\"table\", \"diff\" + (inline ? \" inlinediff\" : \"\"));\r\n for (var idx in tdata) node.appendChild(tdata[idx]);\r\n return node;\r\n }\r\n}\r\n", "(function (window, factory) {\n if (typeof exports === 'object') {\n module.exports = factory();\n } else if (typeof define === 'function' && define.amd) {\n define(factory);\n } else {\n window.jStat = factory();\n }\n})(this, function () {\nvar jStat = (function(Math, undefined) {\n\n// For quick reference.\nvar concat = Array.prototype.concat;\nvar slice = Array.prototype.slice;\nvar toString = Object.prototype.toString;\n\n// Calculate correction for IEEE error\n// TODO: This calculation can be improved.\nfunction calcRdx(n, m) {\n var val = n > m ? n : m;\n return Math.pow(10,\n 17 - ~~(Math.log(((val > 0) ? val : -val)) * Math.LOG10E));\n}\n\n\nvar isArray = Array.isArray || function isArray(arg) {\n return toString.call(arg) === '[object Array]';\n};\n\n\nfunction isFunction(arg) {\n return toString.call(arg) === '[object Function]';\n}\n\n\nfunction isNumber(num) {\n return (typeof num === 'number') ? num - num === 0 : false;\n}\n\n\n// Converts the jStat matrix to vector.\nfunction toVector(arr) {\n return concat.apply([], arr);\n}\n\n\n// The one and only jStat constructor.\nfunction jStat() {\n return new jStat._init(arguments);\n}\n\n\n// TODO: Remove after all references in src files have been removed.\njStat.fn = jStat.prototype;\n\n\n// By separating the initializer from the constructor it's easier to handle\n// always returning a new instance whether \"new\" was used or not.\njStat._init = function _init(args) {\n // If first argument is an array, must be vector or matrix.\n if (isArray(args[0])) {\n // Check if matrix.\n if (isArray(args[0][0])) {\n // See if a mapping function was also passed.\n if (isFunction(args[1]))\n args[0] = jStat.map(args[0], args[1]);\n // Iterate over each is faster than this.push.apply(this, args[0].\n for (var i = 0; i < args[0].length; i++)\n this[i] = args[0][i];\n this.length = args[0].length;\n\n // Otherwise must be a vector.\n } else {\n this[0] = isFunction(args[1]) ? jStat.map(args[0], args[1]) : args[0];\n this.length = 1;\n }\n\n // If first argument is number, assume creation of sequence.\n } else if (isNumber(args[0])) {\n this[0] = jStat.seq.apply(null, args);\n this.length = 1;\n\n // Handle case when jStat object is passed to jStat.\n } else if (args[0] instanceof jStat) {\n // Duplicate the object and pass it back.\n return jStat(args[0].toArray());\n\n // Unexpected argument value, return empty jStat object.\n // TODO: This is strange behavior. Shouldn't this throw or some such to let\n // the user know they had bad arguments?\n } else {\n this[0] = [];\n this.length = 1;\n }\n\n return this;\n};\njStat._init.prototype = jStat.prototype;\njStat._init.constructor = jStat;\n\n\n// Utility functions.\n// TODO: for internal use only?\njStat.utils = {\n calcRdx: calcRdx,\n isArray: isArray,\n isFunction: isFunction,\n isNumber: isNumber,\n toVector: toVector\n};\n\n\njStat._random_fn = Math.random;\njStat.setRandom = function setRandom(fn) {\n if (typeof fn !== 'function')\n throw new TypeError('fn is not a function');\n jStat._random_fn = fn;\n};\n\n\n// Easily extend the jStat object.\n// TODO: is this seriously necessary?\njStat.extend = function extend(obj) {\n var i, j;\n\n if (arguments.length === 1) {\n for (j in obj)\n jStat[j] = obj[j];\n return this;\n }\n\n for (i = 1; i < arguments.length; i++) {\n for (j in arguments[i])\n obj[j] = arguments[i][j];\n }\n\n return obj;\n};\n\n\n// Returns the number of rows in the matrix.\njStat.rows = function rows(arr) {\n return arr.length || 1;\n};\n\n\n// Returns the number of columns in the matrix.\njStat.cols = function cols(arr) {\n return arr[0].length || 1;\n};\n\n\n// Returns the dimensions of the object { rows: i, cols: j }\njStat.dimensions = function dimensions(arr) {\n return {\n rows: jStat.rows(arr),\n cols: jStat.cols(arr)\n };\n};\n\n\n// Returns a specified row as a vector or return a sub matrix by pick some rows\njStat.row = function row(arr, index) {\n if (isArray(index)) {\n return index.map(function(i) {\n return jStat.row(arr, i);\n })\n }\n return arr[index];\n};\n\n\n// return row as array\n// rowa([[1,2],[3,4]],0) -> [1,2]\njStat.rowa = function rowa(arr, i) {\n return jStat.row(arr, i);\n};\n\n\n// Returns the specified column as a vector or return a sub matrix by pick some\n// columns\njStat.col = function col(arr, index) {\n if (isArray(index)) {\n var submat = jStat.arange(arr.length).map(function() {\n return new Array(index.length);\n });\n index.forEach(function(ind, i){\n jStat.arange(arr.length).forEach(function(j) {\n submat[j][i] = arr[j][ind];\n });\n });\n return submat;\n }\n var column = new Array(arr.length);\n for (var i = 0; i < arr.length; i++)\n column[i] = [arr[i][index]];\n return column;\n};\n\n\n// return column as array\n// cola([[1,2],[3,4]],0) -> [1,3]\njStat.cola = function cola(arr, i) {\n return jStat.col(arr, i).map(function(a){ return a[0] });\n};\n\n\n// Returns the diagonal of the matrix\njStat.diag = function diag(arr) {\n var nrow = jStat.rows(arr);\n var res = new Array(nrow);\n for (var row = 0; row < nrow; row++)\n res[row] = [arr[row][row]];\n return res;\n};\n\n\n// Returns the anti-diagonal of the matrix\njStat.antidiag = function antidiag(arr) {\n var nrow = jStat.rows(arr) - 1;\n var res = new Array(nrow);\n for (var i = 0; nrow >= 0; nrow--, i++)\n res[i] = [arr[i][nrow]];\n return res;\n};\n\n// Transpose a matrix or array.\njStat.transpose = function transpose(arr) {\n var obj = [];\n var objArr, rows, cols, j, i;\n\n // Make sure arr is in matrix format.\n if (!isArray(arr[0]))\n arr = [arr];\n\n rows = arr.length;\n cols = arr[0].length;\n\n for (i = 0; i < cols; i++) {\n objArr = new Array(rows);\n for (j = 0; j < rows; j++)\n objArr[j] = arr[j][i];\n obj.push(objArr);\n }\n\n // If obj is vector, return only single array.\n return obj.length === 1 ? obj[0] : obj;\n};\n\n\n// Map a function to an array or array of arrays.\n// \"toAlter\" is an internal variable.\njStat.map = function map(arr, func, toAlter) {\n var row, nrow, ncol, res, col;\n\n if (!isArray(arr[0]))\n arr = [arr];\n\n nrow = arr.length;\n ncol = arr[0].length;\n res = toAlter ? arr : new Array(nrow);\n\n for (row = 0; row < nrow; row++) {\n // if the row doesn't exist, create it\n if (!res[row])\n res[row] = new Array(ncol);\n for (col = 0; col < ncol; col++)\n res[row][col] = func(arr[row][col], row, col);\n }\n\n return res.length === 1 ? res[0] : res;\n};\n\n\n// Cumulatively combine the elements of an array or array of arrays using a function.\njStat.cumreduce = function cumreduce(arr, func, toAlter) {\n var row, nrow, ncol, res, col;\n\n if (!isArray(arr[0]))\n arr = [arr];\n\n nrow = arr.length;\n ncol = arr[0].length;\n res = toAlter ? arr : new Array(nrow);\n\n for (row = 0; row < nrow; row++) {\n // if the row doesn't exist, create it\n if (!res[row])\n res[row] = new Array(ncol);\n if (ncol > 0)\n res[row][0] = arr[row][0];\n for (col = 1; col < ncol; col++)\n res[row][col] = func(res[row][col-1], arr[row][col]);\n }\n return res.length === 1 ? res[0] : res;\n};\n\n\n// Destructively alter an array.\njStat.alter = function alter(arr, func) {\n return jStat.map(arr, func, true);\n};\n\n\n// Generate a rows x cols matrix according to the supplied function.\njStat.create = function create(rows, cols, func) {\n var res = new Array(rows);\n var i, j;\n\n if (isFunction(cols)) {\n func = cols;\n cols = rows;\n }\n\n for (i = 0; i < rows; i++) {\n res[i] = new Array(cols);\n for (j = 0; j < cols; j++)\n res[i][j] = func(i, j);\n }\n\n return res;\n};\n\n\nfunction retZero() { return 0; }\n\n\n// Generate a rows x cols matrix of zeros.\njStat.zeros = function zeros(rows, cols) {\n if (!isNumber(cols))\n cols = rows;\n return jStat.create(rows, cols, retZero);\n};\n\n\nfunction retOne() { return 1; }\n\n\n// Generate a rows x cols matrix of ones.\njStat.ones = function ones(rows, cols) {\n if (!isNumber(cols))\n cols = rows;\n return jStat.create(rows, cols, retOne);\n};\n\n\n// Generate a rows x cols matrix of uniformly random numbers.\njStat.rand = function rand(rows, cols) {\n if (!isNumber(cols))\n cols = rows;\n return jStat.create(rows, cols, jStat._random_fn);\n};\n\n\nfunction retIdent(i, j) { return i === j ? 1 : 0; }\n\n\n// Generate an identity matrix of size row x cols.\njStat.identity = function identity(rows, cols) {\n if (!isNumber(cols))\n cols = rows;\n return jStat.create(rows, cols, retIdent);\n};\n\n\n// Tests whether a matrix is symmetric\njStat.symmetric = function symmetric(arr) {\n var size = arr.length;\n var row, col;\n\n if (arr.length !== arr[0].length)\n return false;\n\n for (row = 0; row < size; row++) {\n for (col = 0; col < size; col++)\n if (arr[col][row] !== arr[row][col])\n return false;\n }\n\n return true;\n};\n\n\n// Set all values to zero.\njStat.clear = function clear(arr) {\n return jStat.alter(arr, retZero);\n};\n\n\n// Generate sequence.\njStat.seq = function seq(min, max, length, func) {\n if (!isFunction(func))\n func = false;\n\n var arr = [];\n var hival = calcRdx(min, max);\n var step = (max * hival - min * hival) / ((length - 1) * hival);\n var current = min;\n var cnt;\n\n // Current is assigned using a technique to compensate for IEEE error.\n // TODO: Needs better implementation.\n for (cnt = 0;\n current <= max && cnt < length;\n cnt++, current = (min * hival + step * hival * cnt) / hival) {\n arr.push((func ? func(current, cnt) : current));\n }\n\n return arr;\n};\n\n\n// arange(5) -> [0,1,2,3,4]\n// arange(1,5) -> [1,2,3,4]\n// arange(5,1,-1) -> [5,4,3,2]\njStat.arange = function arange(start, end, step) {\n var rl = [];\n var i;\n step = step || 1;\n if (end === undefined) {\n end = start;\n start = 0;\n }\n if (start === end || step === 0) {\n return [];\n }\n if (start < end && step < 0) {\n return [];\n }\n if (start > end && step > 0) {\n return [];\n }\n if (step > 0) {\n for (i = start; i < end; i += step) {\n rl.push(i);\n }\n } else {\n for (i = start; i > end; i += step) {\n rl.push(i);\n }\n }\n return rl;\n};\n\n\n// A=[[1,2,3],[4,5,6],[7,8,9]]\n// slice(A,{row:{end:2},col:{start:1}}) -> [[2,3],[5,6]]\n// slice(A,1,{start:1}) -> [5,6]\n// as numpy code A[:2,1:]\njStat.slice = (function(){\n function _slice(list, start, end, step) {\n // note it's not equal to range.map mode it's a bug\n var i;\n var rl = [];\n var length = list.length;\n if (start === undefined && end === undefined && step === undefined) {\n return jStat.copy(list);\n }\n\n start = start || 0;\n end = end || list.length;\n start = start >= 0 ? start : length + start;\n end = end >= 0 ? end : length + end;\n step = step || 1;\n if (start === end || step === 0) {\n return [];\n }\n if (start < end && step < 0) {\n return [];\n }\n if (start > end && step > 0) {\n return [];\n }\n if (step > 0) {\n for (i = start; i < end; i += step) {\n rl.push(list[i]);\n }\n } else {\n for (i = start; i > end;i += step) {\n rl.push(list[i]);\n }\n }\n return rl;\n }\n\n function slice(list, rcSlice) {\n var colSlice, rowSlice;\n rcSlice = rcSlice || {};\n if (isNumber(rcSlice.row)) {\n if (isNumber(rcSlice.col))\n return list[rcSlice.row][rcSlice.col];\n var row = jStat.rowa(list, rcSlice.row);\n colSlice = rcSlice.col || {};\n return _slice(row, colSlice.start, colSlice.end, colSlice.step);\n }\n\n if (isNumber(rcSlice.col)) {\n var col = jStat.cola(list, rcSlice.col);\n rowSlice = rcSlice.row || {};\n return _slice(col, rowSlice.start, rowSlice.end, rowSlice.step);\n }\n\n rowSlice = rcSlice.row || {};\n colSlice = rcSlice.col || {};\n var rows = _slice(list, rowSlice.start, rowSlice.end, rowSlice.step);\n return rows.map(function(row) {\n return _slice(row, colSlice.start, colSlice.end, colSlice.step);\n });\n }\n\n return slice;\n}());\n\n\n// A=[[1,2,3],[4,5,6],[7,8,9]]\n// sliceAssign(A,{row:{start:1},col:{start:1}},[[0,0],[0,0]])\n// A=[[1,2,3],[4,0,0],[7,0,0]]\njStat.sliceAssign = function sliceAssign(A, rcSlice, B) {\n var nl, ml;\n if (isNumber(rcSlice.row)) {\n if (isNumber(rcSlice.col))\n return A[rcSlice.row][rcSlice.col] = B;\n rcSlice.col = rcSlice.col || {};\n rcSlice.col.start = rcSlice.col.start || 0;\n rcSlice.col.end = rcSlice.col.end || A[0].length;\n rcSlice.col.step = rcSlice.col.step || 1;\n nl = jStat.arange(rcSlice.col.start,\n Math.min(A.length, rcSlice.col.end),\n rcSlice.col.step);\n var m = rcSlice.row;\n nl.forEach(function(n, i) {\n A[m][n] = B[i];\n });\n return A;\n }\n\n if (isNumber(rcSlice.col)) {\n rcSlice.row = rcSlice.row || {};\n rcSlice.row.start = rcSlice.row.start || 0;\n rcSlice.row.end = rcSlice.row.end || A.length;\n rcSlice.row.step = rcSlice.row.step || 1;\n ml = jStat.arange(rcSlice.row.start,\n Math.min(A[0].length, rcSlice.row.end),\n rcSlice.row.step);\n var n = rcSlice.col;\n ml.forEach(function(m, j) {\n A[m][n] = B[j];\n });\n return A;\n }\n\n if (B[0].length === undefined) {\n B = [B];\n }\n rcSlice.row.start = rcSlice.row.start || 0;\n rcSlice.row.end = rcSlice.row.end || A.length;\n rcSlice.row.step = rcSlice.row.step || 1;\n rcSlice.col.start = rcSlice.col.start || 0;\n rcSlice.col.end = rcSlice.col.end || A[0].length;\n rcSlice.col.step = rcSlice.col.step || 1;\n ml = jStat.arange(rcSlice.row.start,\n Math.min(A.length, rcSlice.row.end),\n rcSlice.row.step);\n nl = jStat.arange(rcSlice.col.start,\n Math.min(A[0].length, rcSlice.col.end),\n rcSlice.col.step);\n ml.forEach(function(m, i) {\n nl.forEach(function(n, j) {\n A[m][n] = B[i][j];\n });\n });\n return A;\n};\n\n\n// [1,2,3] ->\n// [[1,0,0],[0,2,0],[0,0,3]]\njStat.diagonal = function diagonal(diagArray) {\n var mat = jStat.zeros(diagArray.length, diagArray.length);\n diagArray.forEach(function(t, i) {\n mat[i][i] = t;\n });\n return mat;\n};\n\n\n// return copy of A\njStat.copy = function copy(A) {\n return A.map(function(row) {\n if (isNumber(row))\n return row;\n return row.map(function(t) {\n return t;\n });\n });\n};\n\n\n// TODO: Go over this entire implementation. Seems a tragic waste of resources\n// doing all this work. Instead, and while ugly, use new Function() to generate\n// a custom function for each static method.\n\n// Quick reference.\nvar jProto = jStat.prototype;\n\n// Default length.\njProto.length = 0;\n\n// For internal use only.\n// TODO: Check if they're actually used, and if they are then rename them\n// to _*\njProto.push = Array.prototype.push;\njProto.sort = Array.prototype.sort;\njProto.splice = Array.prototype.splice;\njProto.slice = Array.prototype.slice;\n\n\n// Return a clean array.\njProto.toArray = function toArray() {\n return this.length > 1 ? slice.call(this) : slice.call(this)[0];\n};\n\n\n// Map a function to a matrix or vector.\njProto.map = function map(func, toAlter) {\n return jStat(jStat.map(this, func, toAlter));\n};\n\n\n// Cumulatively combine the elements of a matrix or vector using a function.\njProto.cumreduce = function cumreduce(func, toAlter) {\n return jStat(jStat.cumreduce(this, func, toAlter));\n};\n\n\n// Destructively alter an array.\njProto.alter = function alter(func) {\n jStat.alter(this, func);\n return this;\n};\n\n\n// Extend prototype with methods that have no argument.\n(function(funcs) {\n for (var i = 0; i < funcs.length; i++) (function(passfunc) {\n jProto[passfunc] = function(func) {\n var self = this,\n results;\n // Check for callback.\n if (func) {\n setTimeout(function() {\n func.call(self, jProto[passfunc].call(self));\n });\n return this;\n }\n results = jStat[passfunc](this);\n return isArray(results) ? jStat(results) : results;\n };\n })(funcs[i]);\n})('transpose clear symmetric rows cols dimensions diag antidiag'.split(' '));\n\n\n// Extend prototype with methods that have one argument.\n(function(funcs) {\n for (var i = 0; i < funcs.length; i++) (function(passfunc) {\n jProto[passfunc] = function(index, func) {\n var self = this;\n // check for callback\n if (func) {\n setTimeout(function() {\n func.call(self, jProto[passfunc].call(self, index));\n });\n return this;\n }\n return jStat(jStat[passfunc](this, index));\n };\n })(funcs[i]);\n})('row col'.split(' '));\n\n\n// Extend prototype with simple shortcut methods.\n(function(funcs) {\n for (var i = 0; i < funcs.length; i++) (function(passfunc) {\n jProto[passfunc] = function() {\n return jStat(jStat[passfunc].apply(null, arguments));\n };\n })(funcs[i]);\n})('create zeros ones rand identity'.split(' '));\n\n\n// Exposing jStat.\nreturn jStat;\n\n}(Math));\n(function(jStat, Math) {\n\nvar isFunction = jStat.utils.isFunction;\n\n// Ascending functions for sort\nfunction ascNum(a, b) { return a - b; }\n\nfunction clip(arg, min, max) {\n return Math.max(min, Math.min(arg, max));\n}\n\n\n// sum of an array\njStat.sum = function sum(arr) {\n var sum = 0;\n var i = arr.length;\n while (--i >= 0)\n sum += arr[i];\n return sum;\n};\n\n\n// sum squared\njStat.sumsqrd = function sumsqrd(arr) {\n var sum = 0;\n var i = arr.length;\n while (--i >= 0)\n sum += arr[i] * arr[i];\n return sum;\n};\n\n\n// sum of squared errors of prediction (SSE)\njStat.sumsqerr = function sumsqerr(arr) {\n var mean = jStat.mean(arr);\n var sum = 0;\n var i = arr.length;\n var tmp;\n while (--i >= 0) {\n tmp = arr[i] - mean;\n sum += tmp * tmp;\n }\n return sum;\n};\n\n// sum of an array in each row\njStat.sumrow = function sumrow(arr) {\n var sum = 0;\n var i = arr.length;\n while (--i >= 0)\n sum += arr[i];\n return sum;\n};\n\n// product of an array\njStat.product = function product(arr) {\n var prod = 1;\n var i = arr.length;\n while (--i >= 0)\n prod *= arr[i];\n return prod;\n};\n\n\n// minimum value of an array\njStat.min = function min(arr) {\n var low = arr[0];\n var i = 0;\n while (++i < arr.length)\n if (arr[i] < low)\n low = arr[i];\n return low;\n};\n\n\n// maximum value of an array\njStat.max = function max(arr) {\n var high = arr[0];\n var i = 0;\n while (++i < arr.length)\n if (arr[i] > high)\n high = arr[i];\n return high;\n};\n\n\n// unique values of an array\njStat.unique = function unique(arr) {\n var hash = {}, _arr = [];\n for(var i = 0; i < arr.length; i++) {\n if (!hash[arr[i]]) {\n hash[arr[i]] = true;\n _arr.push(arr[i]);\n }\n }\n return _arr;\n};\n\n\n// mean value of an array\njStat.mean = function mean(arr) {\n return jStat.sum(arr) / arr.length;\n};\n\n\n// mean squared error (MSE)\njStat.meansqerr = function meansqerr(arr) {\n return jStat.sumsqerr(arr) / arr.length;\n};\n\n\n// geometric mean of an array\njStat.geomean = function geomean(arr) {\n var logs = arr.map(Math.log)\n var meanOfLogs = jStat.mean(logs)\n return Math.exp(meanOfLogs)\n};\n\n\n// median of an array\njStat.median = function median(arr) {\n var arrlen = arr.length;\n var _arr = arr.slice().sort(ascNum);\n // check if array is even or odd, then return the appropriate\n return !(arrlen & 1)\n ? (_arr[(arrlen / 2) - 1 ] + _arr[(arrlen / 2)]) / 2\n : _arr[(arrlen / 2) | 0 ];\n};\n\n\n// cumulative sum of an array\njStat.cumsum = function cumsum(arr) {\n return jStat.cumreduce(arr, function (a, b) { return a + b; });\n};\n\n\n// cumulative product of an array\njStat.cumprod = function cumprod(arr) {\n return jStat.cumreduce(arr, function (a, b) { return a * b; });\n};\n\n\n// successive differences of a sequence\njStat.diff = function diff(arr) {\n var diffs = [];\n var arrLen = arr.length;\n var i;\n for (i = 1; i < arrLen; i++)\n diffs.push(arr[i] - arr[i - 1]);\n return diffs;\n};\n\n\n// ranks of an array\njStat.rank = function (arr) {\n var i;\n var distinctNumbers = [];\n var numberCounts = {};\n for (i = 0; i < arr.length; i++) {\n var number = arr[i];\n if (numberCounts[number]) {\n numberCounts[number]++;\n } else {\n numberCounts[number] = 1;\n distinctNumbers.push(number);\n }\n }\n\n var sortedDistinctNumbers = distinctNumbers.sort(ascNum);\n var numberRanks = {};\n var currentRank = 1;\n for (i = 0; i < sortedDistinctNumbers.length; i++) {\n var number = sortedDistinctNumbers[i];\n var count = numberCounts[number];\n var first = currentRank;\n var last = currentRank + count - 1;\n var rank = (first + last) / 2;\n numberRanks[number] = rank;\n currentRank += count;\n }\n\n return arr.map(function (number) {\n return numberRanks[number];\n });\n};\n\n\n// mode of an array\n// if there are multiple modes of an array, return all of them\n// is this the appropriate way of handling it?\njStat.mode = function mode(arr) {\n var arrLen = arr.length;\n var _arr = arr.slice().sort(ascNum);\n var count = 1;\n var maxCount = 0;\n var numMaxCount = 0;\n var mode_arr = [];\n var i;\n\n for (i = 0; i < arrLen; i++) {\n if (_arr[i] === _arr[i + 1]) {\n count++;\n } else {\n if (count > maxCount) {\n mode_arr = [_arr[i]];\n maxCount = count;\n numMaxCount = 0;\n }\n // are there multiple max counts\n else if (count === maxCount) {\n mode_arr.push(_arr[i]);\n numMaxCount++;\n }\n // resetting count for new value in array\n count = 1;\n }\n }\n\n return numMaxCount === 0 ? mode_arr[0] : mode_arr;\n};\n\n\n// range of an array\njStat.range = function range(arr) {\n return jStat.max(arr) - jStat.min(arr);\n};\n\n// variance of an array\n// flag = true indicates sample instead of population\njStat.variance = function variance(arr, flag) {\n return jStat.sumsqerr(arr) / (arr.length - (flag ? 1 : 0));\n};\n\n// pooled variance of an array of arrays\njStat.pooledvariance = function pooledvariance(arr) {\n var sumsqerr = arr.reduce(function (a, samples) {return a + jStat.sumsqerr(samples);}, 0);\n var count = arr.reduce(function (a, samples) {return a + samples.length;}, 0);\n return sumsqerr / (count - arr.length);\n};\n\n// deviation of an array\njStat.deviation = function (arr) {\n var mean = jStat.mean(arr);\n var arrlen = arr.length;\n var dev = new Array(arrlen);\n for (var i = 0; i < arrlen; i++) {\n dev[i] = arr[i] - mean;\n }\n return dev;\n};\n\n// standard deviation of an array\n// flag = true indicates sample instead of population\njStat.stdev = function stdev(arr, flag) {\n return Math.sqrt(jStat.variance(arr, flag));\n};\n\n// pooled standard deviation of an array of arrays\njStat.pooledstdev = function pooledstdev(arr) {\n return Math.sqrt(jStat.pooledvariance(arr));\n};\n\n// mean deviation (mean absolute deviation) of an array\njStat.meandev = function meandev(arr) {\n var mean = jStat.mean(arr);\n var a = [];\n for (var i = arr.length - 1; i >= 0; i--) {\n a.push(Math.abs(arr[i] - mean));\n }\n return jStat.mean(a);\n};\n\n\n// median deviation (median absolute deviation) of an array\njStat.meddev = function meddev(arr) {\n var median = jStat.median(arr);\n var a = [];\n for (var i = arr.length - 1; i >= 0; i--) {\n a.push(Math.abs(arr[i] - median));\n }\n return jStat.median(a);\n};\n\n\n// coefficient of variation\njStat.coeffvar = function coeffvar(arr) {\n return jStat.stdev(arr) / jStat.mean(arr);\n};\n\n\n// quartiles of an array\njStat.quartiles = function quartiles(arr) {\n var arrlen = arr.length;\n var _arr = arr.slice().sort(ascNum);\n return [\n _arr[ Math.round((arrlen) / 4) - 1 ],\n _arr[ Math.round((arrlen) / 2) - 1 ],\n _arr[ Math.round((arrlen) * 3 / 4) - 1 ]\n ];\n};\n\n\n// Arbitary quantiles of an array. Direct port of the scipy.stats\n// implementation by Pierre GF Gerard-Marchant.\njStat.quantiles = function quantiles(arr, quantilesArray, alphap, betap) {\n var sortedArray = arr.slice().sort(ascNum);\n var quantileVals = [quantilesArray.length];\n var n = arr.length;\n var i, p, m, aleph, k, gamma;\n\n if (typeof alphap === 'undefined')\n alphap = 3 / 8;\n if (typeof betap === 'undefined')\n betap = 3 / 8;\n\n for (i = 0; i < quantilesArray.length; i++) {\n p = quantilesArray[i];\n m = alphap + p * (1 - alphap - betap);\n aleph = n * p + m;\n k = Math.floor(clip(aleph, 1, n - 1));\n gamma = clip(aleph - k, 0, 1);\n quantileVals[i] = (1 - gamma) * sortedArray[k - 1] + gamma * sortedArray[k];\n }\n\n return quantileVals;\n};\n\n// Return the k-th percentile of values in a range, where k is in the range 0..1, inclusive.\n// Passing true for the exclusive parameter excludes both endpoints of the range.\njStat.percentile = function percentile(arr, k, exclusive) {\n var _arr = arr.slice().sort(ascNum);\n var realIndex = k * (_arr.length + (exclusive ? 1 : -1)) + (exclusive ? 0 : 1);\n var index = parseInt(realIndex);\n var frac = realIndex - index;\n if (index + 1 < _arr.length) {\n return _arr[index - 1] + frac * (_arr[index] - _arr[index - 1]);\n } else {\n return _arr[index - 1];\n }\n}\n\n// The percentile rank of score in a given array. Returns the percentage\n// of all values in the input array that are less than (kind='strict') or\n// less or equal than (kind='weak') score. Default is weak.\njStat.percentileOfScore = function percentileOfScore(arr, score, kind) {\n var counter = 0;\n var len = arr.length;\n var strict = false;\n var value, i;\n\n if (kind === 'strict')\n strict = true;\n\n for (i = 0; i < len; i++) {\n value = arr[i];\n if ((strict && value < score) ||\n (!strict && value <= score)) {\n counter++;\n }\n }\n\n return counter / len;\n};\n\n\n// Histogram (bin count) data\njStat.histogram = function histogram(arr, binCnt) {\n binCnt = binCnt || 4;\n var first = jStat.min(arr);\n var binWidth = (jStat.max(arr) - first) / binCnt;\n var len = arr.length;\n var bins = [];\n var i;\n\n for (i = 0; i < binCnt; i++)\n bins[i] = 0;\n for (i = 0; i < len; i++)\n bins[Math.min(Math.floor(((arr[i] - first) / binWidth)), binCnt - 1)] += 1;\n\n return bins;\n};\n\n\n// covariance of two arrays\njStat.covariance = function covariance(arr1, arr2) {\n var u = jStat.mean(arr1);\n var v = jStat.mean(arr2);\n var arr1Len = arr1.length;\n var sq_dev = new Array(arr1Len);\n var i;\n\n for (i = 0; i < arr1Len; i++)\n sq_dev[i] = (arr1[i] - u) * (arr2[i] - v);\n\n return jStat.sum(sq_dev) / (arr1Len - 1);\n};\n\n\n// (pearson's) population correlation coefficient, rho\njStat.corrcoeff = function corrcoeff(arr1, arr2) {\n return jStat.covariance(arr1, arr2) /\n jStat.stdev(arr1, 1) /\n jStat.stdev(arr2, 1);\n};\n\n // (spearman's) rank correlation coefficient, sp\njStat.spearmancoeff = function (arr1, arr2) {\n arr1 = jStat.rank(arr1);\n arr2 = jStat.rank(arr2);\n //return pearson's correlation of the ranks:\n return jStat.corrcoeff(arr1, arr2);\n}\n\n\n// statistical standardized moments (general form of skew/kurt)\njStat.stanMoment = function stanMoment(arr, n) {\n var mu = jStat.mean(arr);\n var sigma = jStat.stdev(arr);\n var len = arr.length;\n var skewSum = 0;\n\n for (var i = 0; i < len; i++)\n skewSum += Math.pow((arr[i] - mu) / sigma, n);\n\n return skewSum / arr.length;\n};\n\n// (pearson's) moment coefficient of skewness\njStat.skewness = function skewness(arr) {\n return jStat.stanMoment(arr, 3);\n};\n\n// (pearson's) (excess) kurtosis\njStat.kurtosis = function kurtosis(arr) {\n return jStat.stanMoment(arr, 4) - 3;\n};\n\n\nvar jProto = jStat.prototype;\n\n\n// Extend jProto with method for calculating cumulative sums and products.\n// This differs from the similar extension below as cumsum and cumprod should\n// not be run again in the case fullbool === true.\n// If a matrix is passed, automatically assume operation should be done on the\n// columns.\n(function(funcs) {\n for (var i = 0; i < funcs.length; i++) (function(passfunc) {\n // If a matrix is passed, automatically assume operation should be done on\n // the columns.\n jProto[passfunc] = function(fullbool, func) {\n var arr = [];\n var i = 0;\n var tmpthis = this;\n // Assignment reassignation depending on how parameters were passed in.\n if (isFunction(fullbool)) {\n func = fullbool;\n fullbool = false;\n }\n // Check if a callback was passed with the function.\n if (func) {\n setTimeout(function() {\n func.call(tmpthis, jProto[passfunc].call(tmpthis, fullbool));\n });\n return this;\n }\n // Check if matrix and run calculations.\n if (this.length > 1) {\n tmpthis = fullbool === true ? this : this.transpose();\n for (; i < tmpthis.length; i++)\n arr[i] = jStat[passfunc](tmpthis[i]);\n return arr;\n }\n // Pass fullbool if only vector, not a matrix. for variance and stdev.\n return jStat[passfunc](this[0], fullbool);\n };\n })(funcs[i]);\n})(('cumsum cumprod').split(' '));\n\n\n// Extend jProto with methods which don't require arguments and work on columns.\n(function(funcs) {\n for (var i = 0; i < funcs.length; i++) (function(passfunc) {\n // If a matrix is passed, automatically assume operation should be done on\n // the columns.\n jProto[passfunc] = function(fullbool, func) {\n var arr = [];\n var i = 0;\n var tmpthis = this;\n // Assignment reassignation depending on how parameters were passed in.\n if (isFunction(fullbool)) {\n func = fullbool;\n fullbool = false;\n }\n // Check if a callback was passed with the function.\n if (func) {\n setTimeout(function() {\n func.call(tmpthis, jProto[passfunc].call(tmpthis, fullbool));\n });\n return this;\n }\n // Check if matrix and run calculations.\n if (this.length > 1) {\n if (passfunc !== 'sumrow')\n tmpthis = fullbool === true ? this : this.transpose();\n for (; i < tmpthis.length; i++)\n arr[i] = jStat[passfunc](tmpthis[i]);\n return fullbool === true\n ? jStat[passfunc](jStat.utils.toVector(arr))\n : arr;\n }\n // Pass fullbool if only vector, not a matrix. for variance and stdev.\n return jStat[passfunc](this[0], fullbool);\n };\n })(funcs[i]);\n})(('sum sumsqrd sumsqerr sumrow product min max unique mean meansqerr ' +\n 'geomean median diff rank mode range variance deviation stdev meandev ' +\n 'meddev coeffvar quartiles histogram skewness kurtosis').split(' '));\n\n\n// Extend jProto with functions that take arguments. Operations on matrices are\n// done on columns.\n(function(funcs) {\n for (var i = 0; i < funcs.length; i++) (function(passfunc) {\n jProto[passfunc] = function() {\n var arr = [];\n var i = 0;\n var tmpthis = this;\n var args = Array.prototype.slice.call(arguments);\n var callbackFunction;\n\n // If the last argument is a function, we assume it's a callback; we\n // strip the callback out and call the function again.\n if (isFunction(args[args.length - 1])) {\n callbackFunction = args[args.length - 1];\n var argsToPass = args.slice(0, args.length - 1);\n\n setTimeout(function() {\n callbackFunction.call(tmpthis,\n jProto[passfunc].apply(tmpthis, argsToPass));\n });\n return this;\n\n // Otherwise we curry the function args and call normally.\n } else {\n callbackFunction = undefined;\n var curriedFunction = function curriedFunction(vector) {\n return jStat[passfunc].apply(tmpthis, [vector].concat(args));\n }\n }\n\n // If this is a matrix, run column-by-column.\n if (this.length > 1) {\n tmpthis = tmpthis.transpose();\n for (; i < tmpthis.length; i++)\n arr[i] = curriedFunction(tmpthis[i]);\n return arr;\n }\n\n // Otherwise run on the vector.\n return curriedFunction(this[0]);\n };\n })(funcs[i]);\n})('quantiles percentileOfScore'.split(' '));\n\n}(jStat, Math));\n// Special functions //\n(function(jStat, Math) {\n\n// Log-gamma function\njStat.gammaln = function gammaln(x) {\n var j = 0;\n var cof = [\n 76.18009172947146, -86.50532032941677, 24.01409824083091,\n -1.231739572450155, 0.1208650973866179e-2, -0.5395239384953e-5\n ];\n var ser = 1.000000000190015;\n var xx, y, tmp;\n tmp = (y = xx = x) + 5.5;\n tmp -= (xx + 0.5) * Math.log(tmp);\n for (; j < 6; j++)\n ser += cof[j] / ++y;\n return Math.log(2.5066282746310005 * ser / xx) - tmp;\n};\n\n/*\n * log-gamma function to support poisson distribution sampling. The\n * algorithm comes from SPECFUN by Shanjie Zhang and Jianming Jin and their\n * book \"Computation of Special Functions\", 1996, John Wiley & Sons, Inc.\n */\njStat.loggam = function loggam(x) {\n var x0, x2, xp, gl, gl0;\n var k, n;\n\n var a = [8.333333333333333e-02, -2.777777777777778e-03,\n 7.936507936507937e-04, -5.952380952380952e-04,\n 8.417508417508418e-04, -1.917526917526918e-03,\n 6.410256410256410e-03, -2.955065359477124e-02,\n 1.796443723688307e-01, -1.39243221690590e+00];\n x0 = x;\n n = 0;\n if ((x == 1.0) || (x == 2.0)) {\n return 0.0;\n }\n if (x <= 7.0) {\n n = Math.floor(7 - x);\n x0 = x + n;\n }\n x2 = 1.0 / (x0 * x0);\n xp = 2 * Math.PI;\n gl0 = a[9];\n for (k = 8; k >= 0; k--) {\n gl0 *= x2;\n gl0 += a[k];\n }\n gl = gl0 / x0 + 0.5 * Math.log(xp) + (x0 - 0.5) * Math.log(x0) - x0;\n if (x <= 7.0) {\n for (k = 1; k <= n; k++) {\n gl -= Math.log(x0 - 1.0);\n x0 -= 1.0;\n }\n }\n return gl;\n}\n\n// gamma of x\njStat.gammafn = function gammafn(x) {\n var p = [-1.716185138865495, 24.76565080557592, -379.80425647094563,\n 629.3311553128184, 866.9662027904133, -31451.272968848367,\n -36144.413418691176, 66456.14382024054\n ];\n var q = [-30.8402300119739, 315.35062697960416, -1015.1563674902192,\n -3107.771671572311, 22538.118420980151, 4755.8462775278811,\n -134659.9598649693, -115132.2596755535];\n var fact = false;\n var n = 0;\n var xden = 0;\n var xnum = 0;\n var y = x;\n var i, z, yi, res;\n if (x > 171.6243769536076) {\n return Infinity;\n }\n if (y <= 0) {\n res = y % 1 + 3.6e-16;\n if (res) {\n fact = (!(y & 1) ? 1 : -1) * Math.PI / Math.sin(Math.PI * res);\n y = 1 - y;\n } else {\n return Infinity;\n }\n }\n yi = y;\n if (y < 1) {\n z = y++;\n } else {\n z = (y -= n = (y | 0) - 1) - 1;\n }\n for (i = 0; i < 8; ++i) {\n xnum = (xnum + p[i]) * z;\n xden = xden * z + q[i];\n }\n res = xnum / xden + 1;\n if (yi < y) {\n res /= yi;\n } else if (yi > y) {\n for (i = 0; i < n; ++i) {\n res *= y;\n y++;\n }\n }\n if (fact) {\n res = fact / res;\n }\n return res;\n};\n\n\n// lower incomplete gamma function, which is usually typeset with a\n// lower-case greek gamma as the function symbol\njStat.gammap = function gammap(a, x) {\n return jStat.lowRegGamma(a, x) * jStat.gammafn(a);\n};\n\n\n// The lower regularized incomplete gamma function, usually written P(a,x)\njStat.lowRegGamma = function lowRegGamma(a, x) {\n var aln = jStat.gammaln(a);\n var ap = a;\n var sum = 1 / a;\n var del = sum;\n var b = x + 1 - a;\n var c = 1 / 1.0e-30;\n var d = 1 / b;\n var h = d;\n var i = 1;\n // calculate maximum number of itterations required for a\n var ITMAX = -~(Math.log((a >= 1) ? a : 1 / a) * 8.5 + a * 0.4 + 17);\n var an;\n\n if (x < 0 || a <= 0) {\n return NaN;\n } else if (x < a + 1) {\n for (; i <= ITMAX; i++) {\n sum += del *= x / ++ap;\n }\n return (sum * Math.exp(-x + a * Math.log(x) - (aln)));\n }\n\n for (; i <= ITMAX; i++) {\n an = -i * (i - a);\n b += 2;\n d = an * d + b;\n c = b + an / c;\n d = 1 / d;\n h *= d * c;\n }\n\n return (1 - h * Math.exp(-x + a * Math.log(x) - (aln)));\n};\n\n// natural log factorial of n\njStat.factorialln = function factorialln(n) {\n return n < 0 ? NaN : jStat.gammaln(n + 1);\n};\n\n// factorial of n\njStat.factorial = function factorial(n) {\n return n < 0 ? NaN : jStat.gammafn(n + 1);\n};\n\n// combinations of n, m\njStat.combination = function combination(n, m) {\n // make sure n or m don't exceed the upper limit of usable values\n return (n > 170 || m > 170)\n ? Math.exp(jStat.combinationln(n, m))\n : (jStat.factorial(n) / jStat.factorial(m)) / jStat.factorial(n - m);\n};\n\n\njStat.combinationln = function combinationln(n, m){\n return jStat.factorialln(n) - jStat.factorialln(m) - jStat.factorialln(n - m);\n};\n\n\n// permutations of n, m\njStat.permutation = function permutation(n, m) {\n return jStat.factorial(n) / jStat.factorial(n - m);\n};\n\n\n// beta function\njStat.betafn = function betafn(x, y) {\n // ensure arguments are positive\n if (x <= 0 || y <= 0)\n return undefined;\n // make sure x + y doesn't exceed the upper limit of usable values\n return (x + y > 170)\n ? Math.exp(jStat.betaln(x, y))\n : jStat.gammafn(x) * jStat.gammafn(y) / jStat.gammafn(x + y);\n};\n\n\n// natural logarithm of beta function\njStat.betaln = function betaln(x, y) {\n return jStat.gammaln(x) + jStat.gammaln(y) - jStat.gammaln(x + y);\n};\n\n\n// Evaluates the continued fraction for incomplete beta function by modified\n// Lentz's method.\njStat.betacf = function betacf(x, a, b) {\n var fpmin = 1e-30;\n var m = 1;\n var qab = a + b;\n var qap = a + 1;\n var qam = a - 1;\n var c = 1;\n var d = 1 - qab * x / qap;\n var m2, aa, del, h;\n\n // These q's will be used in factors that occur in the coefficients\n if (Math.abs(d) < fpmin)\n d = fpmin;\n d = 1 / d;\n h = d;\n\n for (; m <= 100; m++) {\n m2 = 2 * m;\n aa = m * (b - m) * x / ((qam + m2) * (a + m2));\n // One step (the even one) of the recurrence\n d = 1 + aa * d;\n if (Math.abs(d) < fpmin)\n d = fpmin;\n c = 1 + aa / c;\n if (Math.abs(c) < fpmin)\n c = fpmin;\n d = 1 / d;\n h *= d * c;\n aa = -(a + m) * (qab + m) * x / ((a + m2) * (qap + m2));\n // Next step of the recurrence (the odd one)\n d = 1 + aa * d;\n if (Math.abs(d) < fpmin)\n d = fpmin;\n c = 1 + aa / c;\n if (Math.abs(c) < fpmin)\n c = fpmin;\n d = 1 / d;\n del = d * c;\n h *= del;\n if (Math.abs(del - 1.0) < 3e-7)\n break;\n }\n\n return h;\n};\n\n\n// Returns the inverse of the lower regularized inomplete gamma function\njStat.gammapinv = function gammapinv(p, a) {\n var j = 0;\n var a1 = a - 1;\n var EPS = 1e-8;\n var gln = jStat.gammaln(a);\n var x, err, t, u, pp, lna1, afac;\n\n if (p >= 1)\n return Math.max(100, a + 100 * Math.sqrt(a));\n if (p <= 0)\n return 0;\n if (a > 1) {\n lna1 = Math.log(a1);\n afac = Math.exp(a1 * (lna1 - 1) - gln);\n pp = (p < 0.5) ? p : 1 - p;\n t = Math.sqrt(-2 * Math.log(pp));\n x = (2.30753 + t * 0.27061) / (1 + t * (0.99229 + t * 0.04481)) - t;\n if (p < 0.5)\n x = -x;\n x = Math.max(1e-3,\n a * Math.pow(1 - 1 / (9 * a) - x / (3 * Math.sqrt(a)), 3));\n } else {\n t = 1 - a * (0.253 + a * 0.12);\n if (p < t)\n x = Math.pow(p / t, 1 / a);\n else\n x = 1 - Math.log(1 - (p - t) / (1 - t));\n }\n\n for(; j < 12; j++) {\n if (x <= 0)\n return 0;\n err = jStat.lowRegGamma(a, x) - p;\n if (a > 1)\n t = afac * Math.exp(-(x - a1) + a1 * (Math.log(x) - lna1));\n else\n t = Math.exp(-x + a1 * Math.log(x) - gln);\n u = err / t;\n x -= (t = u / (1 - 0.5 * Math.min(1, u * ((a - 1) / x - 1))));\n if (x <= 0)\n x = 0.5 * (x + t);\n if (Math.abs(t) < EPS * x)\n break;\n }\n\n return x;\n};\n\n\n// Returns the error function erf(x)\njStat.erf = function erf(x) {\n var cof = [-1.3026537197817094, 6.4196979235649026e-1, 1.9476473204185836e-2,\n -9.561514786808631e-3, -9.46595344482036e-4, 3.66839497852761e-4,\n 4.2523324806907e-5, -2.0278578112534e-5, -1.624290004647e-6,\n 1.303655835580e-6, 1.5626441722e-8, -8.5238095915e-8,\n 6.529054439e-9, 5.059343495e-9, -9.91364156e-10,\n -2.27365122e-10, 9.6467911e-11, 2.394038e-12,\n -6.886027e-12, 8.94487e-13, 3.13092e-13,\n -1.12708e-13, 3.81e-16, 7.106e-15,\n -1.523e-15, -9.4e-17, 1.21e-16,\n -2.8e-17];\n var j = cof.length - 1;\n var isneg = false;\n var d = 0;\n var dd = 0;\n var t, ty, tmp, res;\n\n if (x < 0) {\n x = -x;\n isneg = true;\n }\n\n t = 2 / (2 + x);\n ty = 4 * t - 2;\n\n for(; j > 0; j--) {\n tmp = d;\n d = ty * d - dd + cof[j];\n dd = tmp;\n }\n\n res = t * Math.exp(-x * x + 0.5 * (cof[0] + ty * d) - dd);\n return isneg ? res - 1 : 1 - res;\n};\n\n\n// Returns the complmentary error function erfc(x)\njStat.erfc = function erfc(x) {\n return 1 - jStat.erf(x);\n};\n\n\n// Returns the inverse of the complementary error function\njStat.erfcinv = function erfcinv(p) {\n var j = 0;\n var x, err, t, pp;\n if (p >= 2)\n return -100;\n if (p <= 0)\n return 100;\n pp = (p < 1) ? p : 2 - p;\n t = Math.sqrt(-2 * Math.log(pp / 2));\n x = -0.70711 * ((2.30753 + t * 0.27061) /\n (1 + t * (0.99229 + t * 0.04481)) - t);\n for (; j < 2; j++) {\n err = jStat.erfc(x) - pp;\n x += err / (1.12837916709551257 * Math.exp(-x * x) - x * err);\n }\n return (p < 1) ? x : -x;\n};\n\n\n// Returns the inverse of the incomplete beta function\njStat.ibetainv = function ibetainv(p, a, b) {\n var EPS = 1e-8;\n var a1 = a - 1;\n var b1 = b - 1;\n var j = 0;\n var lna, lnb, pp, t, u, err, x, al, h, w, afac;\n if (p <= 0)\n return 0;\n if (p >= 1)\n return 1;\n if (a >= 1 && b >= 1) {\n pp = (p < 0.5) ? p : 1 - p;\n t = Math.sqrt(-2 * Math.log(pp));\n x = (2.30753 + t * 0.27061) / (1 + t* (0.99229 + t * 0.04481)) - t;\n if (p < 0.5)\n x = -x;\n al = (x * x - 3) / 6;\n h = 2 / (1 / (2 * a - 1) + 1 / (2 * b - 1));\n w = (x * Math.sqrt(al + h) / h) - (1 / (2 * b - 1) - 1 / (2 * a - 1)) *\n (al + 5 / 6 - 2 / (3 * h));\n x = a / (a + b * Math.exp(2 * w));\n } else {\n lna = Math.log(a / (a + b));\n lnb = Math.log(b / (a + b));\n t = Math.exp(a * lna) / a;\n u = Math.exp(b * lnb) / b;\n w = t + u;\n if (p < t / w)\n x = Math.pow(a * w * p, 1 / a);\n else\n x = 1 - Math.pow(b * w * (1 - p), 1 / b);\n }\n afac = -jStat.gammaln(a) - jStat.gammaln(b) + jStat.gammaln(a + b);\n for(; j < 10; j++) {\n if (x === 0 || x === 1)\n return x;\n err = jStat.ibeta(x, a, b) - p;\n t = Math.exp(a1 * Math.log(x) + b1 * Math.log(1 - x) + afac);\n u = err / t;\n x -= (t = u / (1 - 0.5 * Math.min(1, u * (a1 / x - b1 / (1 - x)))));\n if (x <= 0)\n x = 0.5 * (x + t);\n if (x >= 1)\n x = 0.5 * (x + t + 1);\n if (Math.abs(t) < EPS * x && j > 0)\n break;\n }\n return x;\n};\n\n\n// Returns the incomplete beta function I_x(a,b)\njStat.ibeta = function ibeta(x, a, b) {\n // Factors in front of the continued fraction.\n var bt = (x === 0 || x === 1) ? 0 :\n Math.exp(jStat.gammaln(a + b) - jStat.gammaln(a) -\n jStat.gammaln(b) + a * Math.log(x) + b *\n Math.log(1 - x));\n if (x < 0 || x > 1)\n return false;\n if (x < (a + 1) / (a + b + 2))\n // Use continued fraction directly.\n return bt * jStat.betacf(x, a, b) / a;\n // else use continued fraction after making the symmetry transformation.\n return 1 - bt * jStat.betacf(1 - x, b, a) / b;\n};\n\n\n// Returns a normal deviate (mu=0, sigma=1).\n// If n and m are specified it returns a object of normal deviates.\njStat.randn = function randn(n, m) {\n var u, v, x, y, q;\n if (!m)\n m = n;\n if (n)\n return jStat.create(n, m, function() { return jStat.randn(); });\n do {\n u = jStat._random_fn();\n v = 1.7156 * (jStat._random_fn() - 0.5);\n x = u - 0.449871;\n y = Math.abs(v) + 0.386595;\n q = x * x + y * (0.19600 * y - 0.25472 * x);\n } while (q > 0.27597 && (q > 0.27846 || v * v > -4 * Math.log(u) * u * u));\n return v / u;\n};\n\n\n// Returns a gamma deviate by the method of Marsaglia and Tsang.\njStat.randg = function randg(shape, n, m) {\n var oalph = shape;\n var a1, a2, u, v, x, mat;\n if (!m)\n m = n;\n if (!shape)\n shape = 1;\n if (n) {\n mat = jStat.zeros(n,m);\n mat.alter(function() { return jStat.randg(shape); });\n return mat;\n }\n if (shape < 1)\n shape += 1;\n a1 = shape - 1 / 3;\n a2 = 1 / Math.sqrt(9 * a1);\n do {\n do {\n x = jStat.randn();\n v = 1 + a2 * x;\n } while(v <= 0);\n v = v * v * v;\n u = jStat._random_fn();\n } while(u > 1 - 0.331 * Math.pow(x, 4) &&\n Math.log(u) > 0.5 * x*x + a1 * (1 - v + Math.log(v)));\n // alpha > 1\n if (shape == oalph)\n return a1 * v;\n // alpha < 1\n do {\n u = jStat._random_fn();\n } while(u === 0);\n return Math.pow(u, 1 / oalph) * a1 * v;\n};\n\n\n// making use of static methods on the instance\n(function(funcs) {\n for (var i = 0; i < funcs.length; i++) (function(passfunc) {\n jStat.fn[passfunc] = function() {\n return jStat(\n jStat.map(this, function(value) { return jStat[passfunc](value); }));\n }\n })(funcs[i]);\n})('gammaln gammafn factorial factorialln'.split(' '));\n\n\n(function(funcs) {\n for (var i = 0; i < funcs.length; i++) (function(passfunc) {\n jStat.fn[passfunc] = function() {\n return jStat(jStat[passfunc].apply(null, arguments));\n };\n })(funcs[i]);\n})('randn'.split(' '));\n\n}(jStat, Math));\n(function(jStat, Math) {\n\n// generate all distribution instance methods\n(function(list) {\n for (var i = 0; i < list.length; i++) (function(func) {\n // distribution instance method\n jStat[func] = function f(a, b, c) {\n if (!(this instanceof f))\n return new f(a, b, c);\n this._a = a;\n this._b = b;\n this._c = c;\n return this;\n };\n // distribution method to be used on a jStat instance\n jStat.fn[func] = function(a, b, c) {\n var newthis = jStat[func](a, b, c);\n newthis.data = this;\n return newthis;\n };\n // sample instance method\n jStat[func].prototype.sample = function(arr) {\n var a = this._a;\n var b = this._b;\n var c = this._c;\n if (arr)\n return jStat.alter(arr, function() {\n return jStat[func].sample(a, b, c);\n });\n else\n return jStat[func].sample(a, b, c);\n };\n // generate the pdf, cdf and inv instance methods\n (function(vals) {\n for (var i = 0; i < vals.length; i++) (function(fnfunc) {\n jStat[func].prototype[fnfunc] = function(x) {\n var a = this._a;\n var b = this._b;\n var c = this._c;\n if (!x && x !== 0)\n x = this.data;\n if (typeof x !== 'number') {\n return jStat.fn.map.call(x, function(x) {\n return jStat[func][fnfunc](x, a, b, c);\n });\n }\n return jStat[func][fnfunc](x, a, b, c);\n };\n })(vals[i]);\n })('pdf cdf inv'.split(' '));\n // generate the mean, median, mode and variance instance methods\n (function(vals) {\n for (var i = 0; i < vals.length; i++) (function(fnfunc) {\n jStat[func].prototype[fnfunc] = function() {\n return jStat[func][fnfunc](this._a, this._b, this._c);\n };\n })(vals[i]);\n })('mean median mode variance'.split(' '));\n })(list[i]);\n})((\n 'beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy ' +\n 'laplace lognormal noncentralt normal pareto studentt weibull uniform ' +\n 'binomial negbin hypgeom poisson triangular tukey arcsine'\n).split(' '));\n\n\n\n// extend beta function with static methods\njStat.extend(jStat.beta, {\n pdf: function pdf(x, alpha, beta) {\n // PDF is zero outside the support\n if (x > 1 || x < 0)\n return 0;\n // PDF is one for the uniform case\n if (alpha == 1 && beta == 1)\n return 1;\n\n if (alpha < 512 && beta < 512) {\n return (Math.pow(x, alpha - 1) * Math.pow(1 - x, beta - 1)) /\n jStat.betafn(alpha, beta);\n } else {\n return Math.exp((alpha - 1) * Math.log(x) +\n (beta - 1) * Math.log(1 - x) -\n jStat.betaln(alpha, beta));\n }\n },\n\n cdf: function cdf(x, alpha, beta) {\n return (x > 1 || x < 0) ? (x > 1) * 1 : jStat.ibeta(x, alpha, beta);\n },\n\n inv: function inv(x, alpha, beta) {\n return jStat.ibetainv(x, alpha, beta);\n },\n\n mean: function mean(alpha, beta) {\n return alpha / (alpha + beta);\n },\n\n median: function median(alpha, beta) {\n return jStat.ibetainv(0.5, alpha, beta);\n },\n\n mode: function mode(alpha, beta) {\n return (alpha - 1 ) / ( alpha + beta - 2);\n },\n\n // return a random sample\n sample: function sample(alpha, beta) {\n var u = jStat.randg(alpha);\n return u / (u + jStat.randg(beta));\n },\n\n variance: function variance(alpha, beta) {\n return (alpha * beta) / (Math.pow(alpha + beta, 2) * (alpha + beta + 1));\n }\n});\n\n// extend F function with static methods\njStat.extend(jStat.centralF, {\n // This implementation of the pdf function avoids float overflow\n // See the way that R calculates this value:\n // https://svn.r-project.org/R/trunk/src/nmath/df.c\n pdf: function pdf(x, df1, df2) {\n var p, q, f;\n\n if (x < 0)\n return 0;\n\n if (df1 <= 2) {\n if (x === 0 && df1 < 2) {\n return Infinity;\n }\n if (x === 0 && df1 === 2) {\n return 1;\n }\n return (1 / jStat.betafn(df1 / 2, df2 / 2)) *\n Math.pow(df1 / df2, df1 / 2) *\n Math.pow(x, (df1/2) - 1) *\n Math.pow((1 + (df1 / df2) * x), -(df1 + df2) / 2);\n }\n\n p = (df1 * x) / (df2 + x * df1);\n q = df2 / (df2 + x * df1);\n f = df1 * q / 2.0;\n return f * jStat.binomial.pdf((df1 - 2) / 2, (df1 + df2 - 2) / 2, p);\n },\n\n cdf: function cdf(x, df1, df2) {\n if (x < 0)\n return 0;\n return jStat.ibeta((df1 * x) / (df1 * x + df2), df1 / 2, df2 / 2);\n },\n\n inv: function inv(x, df1, df2) {\n return df2 / (df1 * (1 / jStat.ibetainv(x, df1 / 2, df2 / 2) - 1));\n },\n\n mean: function mean(df1, df2) {\n return (df2 > 2) ? df2 / (df2 - 2) : undefined;\n },\n\n mode: function mode(df1, df2) {\n return (df1 > 2) ? (df2 * (df1 - 2)) / (df1 * (df2 + 2)) : undefined;\n },\n\n // return a random sample\n sample: function sample(df1, df2) {\n var x1 = jStat.randg(df1 / 2) * 2;\n var x2 = jStat.randg(df2 / 2) * 2;\n return (x1 / df1) / (x2 / df2);\n },\n\n variance: function variance(df1, df2) {\n if (df2 <= 4)\n return undefined;\n return 2 * df2 * df2 * (df1 + df2 - 2) /\n (df1 * (df2 - 2) * (df2 - 2) * (df2 - 4));\n }\n});\n\n\n// extend cauchy function with static methods\njStat.extend(jStat.cauchy, {\n pdf: function pdf(x, local, scale) {\n if (scale < 0) { return 0; }\n\n return (scale / (Math.pow(x - local, 2) + Math.pow(scale, 2))) / Math.PI;\n },\n\n cdf: function cdf(x, local, scale) {\n return Math.atan((x - local) / scale) / Math.PI + 0.5;\n },\n\n inv: function(p, local, scale) {\n return local + scale * Math.tan(Math.PI * (p - 0.5));\n },\n\n median: function median(local/*, scale*/) {\n return local;\n },\n\n mode: function mode(local/*, scale*/) {\n return local;\n },\n\n sample: function sample(local, scale) {\n return jStat.randn() *\n Math.sqrt(1 / (2 * jStat.randg(0.5))) * scale + local;\n }\n});\n\n\n\n// extend chisquare function with static methods\njStat.extend(jStat.chisquare, {\n pdf: function pdf(x, dof) {\n if (x < 0)\n return 0;\n return (x === 0 && dof === 2) ? 0.5 :\n Math.exp((dof / 2 - 1) * Math.log(x) - x / 2 - (dof / 2) *\n Math.log(2) - jStat.gammaln(dof / 2));\n },\n\n cdf: function cdf(x, dof) {\n if (x < 0)\n return 0;\n return jStat.lowRegGamma(dof / 2, x / 2);\n },\n\n inv: function(p, dof) {\n return 2 * jStat.gammapinv(p, 0.5 * dof);\n },\n\n mean : function(dof) {\n return dof;\n },\n\n // TODO: this is an approximation (is there a better way?)\n median: function median(dof) {\n return dof * Math.pow(1 - (2 / (9 * dof)), 3);\n },\n\n mode: function mode(dof) {\n return (dof - 2 > 0) ? dof - 2 : 0;\n },\n\n sample: function sample(dof) {\n return jStat.randg(dof / 2) * 2;\n },\n\n variance: function variance(dof) {\n return 2 * dof;\n }\n});\n\n\n\n// extend exponential function with static methods\njStat.extend(jStat.exponential, {\n pdf: function pdf(x, rate) {\n return x < 0 ? 0 : rate * Math.exp(-rate * x);\n },\n\n cdf: function cdf(x, rate) {\n return x < 0 ? 0 : 1 - Math.exp(-rate * x);\n },\n\n inv: function(p, rate) {\n return -Math.log(1 - p) / rate;\n },\n\n mean : function(rate) {\n return 1 / rate;\n },\n\n median: function (rate) {\n return (1 / rate) * Math.log(2);\n },\n\n mode: function mode(/*rate*/) {\n return 0;\n },\n\n sample: function sample(rate) {\n return -1 / rate * Math.log(jStat._random_fn());\n },\n\n variance : function(rate) {\n return Math.pow(rate, -2);\n }\n});\n\n\n\n// extend gamma function with static methods\njStat.extend(jStat.gamma, {\n pdf: function pdf(x, shape, scale) {\n if (x < 0)\n return 0;\n return (x === 0 && shape === 1) ? 1 / scale :\n Math.exp((shape - 1) * Math.log(x) - x / scale -\n jStat.gammaln(shape) - shape * Math.log(scale));\n },\n\n cdf: function cdf(x, shape, scale) {\n if (x < 0)\n return 0;\n return jStat.lowRegGamma(shape, x / scale);\n },\n\n inv: function(p, shape, scale) {\n return jStat.gammapinv(p, shape) * scale;\n },\n\n mean : function(shape, scale) {\n return shape * scale;\n },\n\n mode: function mode(shape, scale) {\n if(shape > 1) return (shape - 1) * scale;\n return undefined;\n },\n\n sample: function sample(shape, scale) {\n return jStat.randg(shape) * scale;\n },\n\n variance: function variance(shape, scale) {\n return shape * scale * scale;\n }\n});\n\n// extend inverse gamma function with static methods\njStat.extend(jStat.invgamma, {\n pdf: function pdf(x, shape, scale) {\n if (x <= 0)\n return 0;\n return Math.exp(-(shape + 1) * Math.log(x) - scale / x -\n jStat.gammaln(shape) + shape * Math.log(scale));\n },\n\n cdf: function cdf(x, shape, scale) {\n if (x <= 0)\n return 0;\n return 1 - jStat.lowRegGamma(shape, scale / x);\n },\n\n inv: function(p, shape, scale) {\n return scale / jStat.gammapinv(1 - p, shape);\n },\n\n mean : function(shape, scale) {\n return (shape > 1) ? scale / (shape - 1) : undefined;\n },\n\n mode: function mode(shape, scale) {\n return scale / (shape + 1);\n },\n\n sample: function sample(shape, scale) {\n return scale / jStat.randg(shape);\n },\n\n variance: function variance(shape, scale) {\n if (shape <= 2)\n return undefined;\n return scale * scale / ((shape - 1) * (shape - 1) * (shape - 2));\n }\n});\n\n\n// extend kumaraswamy function with static methods\njStat.extend(jStat.kumaraswamy, {\n pdf: function pdf(x, alpha, beta) {\n if (x === 0 && alpha === 1)\n return beta;\n else if (x === 1 && beta === 1)\n return alpha;\n return Math.exp(Math.log(alpha) + Math.log(beta) + (alpha - 1) *\n Math.log(x) + (beta - 1) *\n Math.log(1 - Math.pow(x, alpha)));\n },\n\n cdf: function cdf(x, alpha, beta) {\n if (x < 0)\n return 0;\n else if (x > 1)\n return 1;\n return (1 - Math.pow(1 - Math.pow(x, alpha), beta));\n },\n\n inv: function inv(p, alpha, beta) {\n return Math.pow(1 - Math.pow(1 - p, 1 / beta), 1 / alpha);\n },\n\n mean : function(alpha, beta) {\n return (beta * jStat.gammafn(1 + 1 / alpha) *\n jStat.gammafn(beta)) / (jStat.gammafn(1 + 1 / alpha + beta));\n },\n\n median: function median(alpha, beta) {\n return Math.pow(1 - Math.pow(2, -1 / beta), 1 / alpha);\n },\n\n mode: function mode(alpha, beta) {\n if (!(alpha >= 1 && beta >= 1 && (alpha !== 1 && beta !== 1)))\n return undefined;\n return Math.pow((alpha - 1) / (alpha * beta - 1), 1 / alpha);\n },\n\n variance: function variance(/*alpha, beta*/) {\n throw new Error('variance not yet implemented');\n // TODO: complete this\n }\n});\n\n\n\n// extend lognormal function with static methods\njStat.extend(jStat.lognormal, {\n pdf: function pdf(x, mu, sigma) {\n if (x <= 0)\n return 0;\n return Math.exp(-Math.log(x) - 0.5 * Math.log(2 * Math.PI) -\n Math.log(sigma) - Math.pow(Math.log(x) - mu, 2) /\n (2 * sigma * sigma));\n },\n\n cdf: function cdf(x, mu, sigma) {\n if (x < 0)\n return 0;\n return 0.5 +\n (0.5 * jStat.erf((Math.log(x) - mu) / Math.sqrt(2 * sigma * sigma)));\n },\n\n inv: function(p, mu, sigma) {\n return Math.exp(-1.41421356237309505 * sigma * jStat.erfcinv(2 * p) + mu);\n },\n\n mean: function mean(mu, sigma) {\n return Math.exp(mu + sigma * sigma / 2);\n },\n\n median: function median(mu/*, sigma*/) {\n return Math.exp(mu);\n },\n\n mode: function mode(mu, sigma) {\n return Math.exp(mu - sigma * sigma);\n },\n\n sample: function sample(mu, sigma) {\n return Math.exp(jStat.randn() * sigma + mu);\n },\n\n variance: function variance(mu, sigma) {\n return (Math.exp(sigma * sigma) - 1) * Math.exp(2 * mu + sigma * sigma);\n }\n});\n\n\n\n// extend noncentralt function with static methods\njStat.extend(jStat.noncentralt, {\n pdf: function pdf(x, dof, ncp) {\n var tol = 1e-14;\n if (Math.abs(ncp) < tol) // ncp approx 0; use student-t\n return jStat.studentt.pdf(x, dof)\n\n if (Math.abs(x) < tol) { // different formula for x == 0\n return Math.exp(jStat.gammaln((dof + 1) / 2) - ncp * ncp / 2 -\n 0.5 * Math.log(Math.PI * dof) - jStat.gammaln(dof / 2));\n }\n\n // formula for x != 0\n return dof / x *\n (jStat.noncentralt.cdf(x * Math.sqrt(1 + 2 / dof), dof+2, ncp) -\n jStat.noncentralt.cdf(x, dof, ncp));\n },\n\n cdf: function cdf(x, dof, ncp) {\n var tol = 1e-14;\n var min_iterations = 200;\n\n if (Math.abs(ncp) < tol) // ncp approx 0; use student-t\n return jStat.studentt.cdf(x, dof);\n\n // turn negative x into positive and flip result afterwards\n var flip = false;\n if (x < 0) {\n flip = true;\n ncp = -ncp;\n }\n\n var prob = jStat.normal.cdf(-ncp, 0, 1);\n var value = tol + 1;\n // use value at last two steps to determine convergence\n var lastvalue = value;\n var y = x * x / (x * x + dof);\n var j = 0;\n var p = Math.exp(-ncp * ncp / 2);\n var q = Math.exp(-ncp * ncp / 2 - 0.5 * Math.log(2) -\n jStat.gammaln(3 / 2)) * ncp;\n while (j < min_iterations || lastvalue > tol || value > tol) {\n lastvalue = value;\n if (j > 0) {\n p *= (ncp * ncp) / (2 * j);\n q *= (ncp * ncp) / (2 * (j + 1 / 2));\n }\n value = p * jStat.beta.cdf(y, j + 0.5, dof / 2) +\n q * jStat.beta.cdf(y, j+1, dof/2);\n prob += 0.5 * value;\n j++;\n }\n\n return flip ? (1 - prob) : prob;\n }\n});\n\n\n// extend normal function with static methods\njStat.extend(jStat.normal, {\n pdf: function pdf(x, mean, std) {\n return Math.exp(-0.5 * Math.log(2 * Math.PI) -\n Math.log(std) - Math.pow(x - mean, 2) / (2 * std * std));\n },\n\n cdf: function cdf(x, mean, std) {\n return 0.5 * (1 + jStat.erf((x - mean) / Math.sqrt(2 * std * std)));\n },\n\n inv: function(p, mean, std) {\n return -1.41421356237309505 * std * jStat.erfcinv(2 * p) + mean;\n },\n\n mean : function(mean/*, std*/) {\n return mean;\n },\n\n median: function median(mean/*, std*/) {\n return mean;\n },\n\n mode: function (mean/*, std*/) {\n return mean;\n },\n\n sample: function sample(mean, std) {\n return jStat.randn() * std + mean;\n },\n\n variance : function(mean, std) {\n return std * std;\n }\n});\n\n\n\n// extend pareto function with static methods\njStat.extend(jStat.pareto, {\n pdf: function pdf(x, scale, shape) {\n if (x < scale)\n return 0;\n return (shape * Math.pow(scale, shape)) / Math.pow(x, shape + 1);\n },\n\n cdf: function cdf(x, scale, shape) {\n if (x < scale)\n return 0;\n return 1 - Math.pow(scale / x, shape);\n },\n\n inv: function inv(p, scale, shape) {\n return scale / Math.pow(1 - p, 1 / shape);\n },\n\n mean: function mean(scale, shape) {\n if (shape <= 1)\n return undefined;\n return (shape * Math.pow(scale, shape)) / (shape - 1);\n },\n\n median: function median(scale, shape) {\n return scale * (shape * Math.SQRT2);\n },\n\n mode: function mode(scale/*, shape*/) {\n return scale;\n },\n\n variance : function(scale, shape) {\n if (shape <= 2)\n return undefined;\n return (scale*scale * shape) / (Math.pow(shape - 1, 2) * (shape - 2));\n }\n});\n\n\n\n// extend studentt function with static methods\njStat.extend(jStat.studentt, {\n pdf: function pdf(x, dof) {\n dof = dof > 1e100 ? 1e100 : dof;\n return (1/(Math.sqrt(dof) * jStat.betafn(0.5, dof/2))) *\n Math.pow(1 + ((x * x) / dof), -((dof + 1) / 2));\n },\n\n cdf: function cdf(x, dof) {\n var dof2 = dof / 2;\n return jStat.ibeta((x + Math.sqrt(x * x + dof)) /\n (2 * Math.sqrt(x * x + dof)), dof2, dof2);\n },\n\n inv: function(p, dof) {\n var x = jStat.ibetainv(2 * Math.min(p, 1 - p), 0.5 * dof, 0.5);\n x = Math.sqrt(dof * (1 - x) / x);\n return (p > 0.5) ? x : -x;\n },\n\n mean: function mean(dof) {\n return (dof > 1) ? 0 : undefined;\n },\n\n median: function median(/*dof*/) {\n return 0;\n },\n\n mode: function mode(/*dof*/) {\n return 0;\n },\n\n sample: function sample(dof) {\n return jStat.randn() * Math.sqrt(dof / (2 * jStat.randg(dof / 2)));\n },\n\n variance: function variance(dof) {\n return (dof > 2) ? dof / (dof - 2) : (dof > 1) ? Infinity : undefined;\n }\n});\n\n\n\n// extend weibull function with static methods\njStat.extend(jStat.weibull, {\n pdf: function pdf(x, scale, shape) {\n if (x < 0 || scale < 0 || shape < 0)\n return 0;\n return (shape / scale) * Math.pow((x / scale), (shape - 1)) *\n Math.exp(-(Math.pow((x / scale), shape)));\n },\n\n cdf: function cdf(x, scale, shape) {\n return x < 0 ? 0 : 1 - Math.exp(-Math.pow((x / scale), shape));\n },\n\n inv: function(p, scale, shape) {\n return scale * Math.pow(-Math.log(1 - p), 1 / shape);\n },\n\n mean : function(scale, shape) {\n return scale * jStat.gammafn(1 + 1 / shape);\n },\n\n median: function median(scale, shape) {\n return scale * Math.pow(Math.log(2), 1 / shape);\n },\n\n mode: function mode(scale, shape) {\n if (shape <= 1)\n return 0;\n return scale * Math.pow((shape - 1) / shape, 1 / shape);\n },\n\n sample: function sample(scale, shape) {\n return scale * Math.pow(-Math.log(jStat._random_fn()), 1 / shape);\n },\n\n variance: function variance(scale, shape) {\n return scale * scale * jStat.gammafn(1 + 2 / shape) -\n Math.pow(jStat.weibull.mean(scale, shape), 2);\n }\n});\n\n\n\n// extend uniform function with static methods\njStat.extend(jStat.uniform, {\n pdf: function pdf(x, a, b) {\n return (x < a || x > b) ? 0 : 1 / (b - a);\n },\n\n cdf: function cdf(x, a, b) {\n if (x < a)\n return 0;\n else if (x < b)\n return (x - a) / (b - a);\n return 1;\n },\n\n inv: function(p, a, b) {\n return a + (p * (b - a));\n },\n\n mean: function mean(a, b) {\n return 0.5 * (a + b);\n },\n\n median: function median(a, b) {\n return jStat.mean(a, b);\n },\n\n mode: function mode(/*a, b*/) {\n throw new Error('mode is not yet implemented');\n },\n\n sample: function sample(a, b) {\n return (a / 2 + b / 2) + (b / 2 - a / 2) * (2 * jStat._random_fn() - 1);\n },\n\n variance: function variance(a, b) {\n return Math.pow(b - a, 2) / 12;\n }\n});\n\n\n// Got this from http://www.math.ucla.edu/~tom/distributions/binomial.html\nfunction betinc(x, a, b, eps) {\n var a0 = 0;\n var b0 = 1;\n var a1 = 1;\n var b1 = 1;\n var m9 = 0;\n var a2 = 0;\n var c9;\n\n while (Math.abs((a1 - a2) / a1) > eps) {\n a2 = a1;\n c9 = -(a + m9) * (a + b + m9) * x / (a + 2 * m9) / (a + 2 * m9 + 1);\n a0 = a1 + c9 * a0;\n b0 = b1 + c9 * b0;\n m9 = m9 + 1;\n c9 = m9 * (b - m9) * x / (a + 2 * m9 - 1) / (a + 2 * m9);\n a1 = a0 + c9 * a1;\n b1 = b0 + c9 * b1;\n a0 = a0 / b1;\n b0 = b0 / b1;\n a1 = a1 / b1;\n b1 = 1;\n }\n\n return a1 / a;\n}\n\n\n// extend uniform function with static methods\njStat.extend(jStat.binomial, {\n pdf: function pdf(k, n, p) {\n return (p === 0 || p === 1) ?\n ((n * p) === k ? 1 : 0) :\n jStat.combination(n, k) * Math.pow(p, k) * Math.pow(1 - p, n - k);\n },\n\n cdf: function cdf(x, n, p) {\n var betacdf;\n var eps = 1e-10;\n\n if (x < 0)\n return 0;\n if (x >= n)\n return 1;\n if (p < 0 || p > 1 || n <= 0)\n return NaN;\n\n x = Math.floor(x);\n var z = p;\n var a = x + 1;\n var b = n - x;\n var s = a + b;\n var bt = Math.exp(jStat.gammaln(s) - jStat.gammaln(b) -\n jStat.gammaln(a) + a * Math.log(z) + b * Math.log(1 - z));\n\n if (z < (a + 1) / (s + 2))\n betacdf = bt * betinc(z, a, b, eps);\n else\n betacdf = 1 - bt * betinc(1 - z, b, a, eps);\n\n return Math.round((1 - betacdf) * (1 / eps)) / (1 / eps);\n }\n});\n\n\n\n// extend uniform function with static methods\njStat.extend(jStat.negbin, {\n pdf: function pdf(k, r, p) {\n if (k !== k >>> 0)\n return false;\n if (k < 0)\n return 0;\n return jStat.combination(k + r - 1, r - 1) *\n Math.pow(1 - p, k) * Math.pow(p, r);\n },\n\n cdf: function cdf(x, r, p) {\n var sum = 0,\n k = 0;\n if (x < 0) return 0;\n for (; k <= x; k++) {\n sum += jStat.negbin.pdf(k, r, p);\n }\n return sum;\n }\n});\n\n\n\n// extend uniform function with static methods\njStat.extend(jStat.hypgeom, {\n pdf: function pdf(k, N, m, n) {\n // Hypergeometric PDF.\n\n // A simplification of the CDF algorithm below.\n\n // k = number of successes drawn\n // N = population size\n // m = number of successes in population\n // n = number of items drawn from population\n\n if(k !== k | 0) {\n return false;\n } else if(k < 0 || k < m - (N - n)) {\n // It's impossible to have this few successes drawn.\n return 0;\n } else if(k > n || k > m) {\n // It's impossible to have this many successes drawn.\n return 0;\n } else if (m * 2 > N) {\n // More than half the population is successes.\n\n if(n * 2 > N) {\n // More than half the population is sampled.\n\n return jStat.hypgeom.pdf(N - m - n + k, N, N - m, N - n)\n } else {\n // Half or less of the population is sampled.\n\n return jStat.hypgeom.pdf(n - k, N, N - m, n);\n }\n\n } else if(n * 2 > N) {\n // Half or less is successes.\n\n return jStat.hypgeom.pdf(m - k, N, m, N - n);\n\n } else if(m < n) {\n // We want to have the number of things sampled to be less than the\n // successes available. So swap the definitions of successful and sampled.\n return jStat.hypgeom.pdf(k, N, n, m);\n } else {\n // If we get here, half or less of the population was sampled, half or\n // less of it was successes, and we had fewer sampled things than\n // successes. Now we can do this complicated iterative algorithm in an\n // efficient way.\n\n // The basic premise of the algorithm is that we partially normalize our\n // intermediate product to keep it in a numerically good region, and then\n // finish the normalization at the end.\n\n // This variable holds the scaled probability of the current number of\n // successes.\n var scaledPDF = 1;\n\n // This keeps track of how much we have normalized.\n var samplesDone = 0;\n\n for(var i = 0; i < k; i++) {\n // For every possible number of successes up to that observed...\n\n while(scaledPDF > 1 && samplesDone < n) {\n // Intermediate result is growing too big. Apply some of the\n // normalization to shrink everything.\n\n scaledPDF *= 1 - (m / (N - samplesDone));\n\n // Say we've normalized by this sample already.\n samplesDone++;\n }\n\n // Work out the partially-normalized hypergeometric PDF for the next\n // number of successes\n scaledPDF *= (n - i) * (m - i) / ((i + 1) * (N - m - n + i + 1));\n }\n\n for(; samplesDone < n; samplesDone++) {\n // Apply all the rest of the normalization\n scaledPDF *= 1 - (m / (N - samplesDone));\n }\n\n // Bound answer sanely before returning.\n return Math.min(1, Math.max(0, scaledPDF));\n }\n },\n\n cdf: function cdf(x, N, m, n) {\n // Hypergeometric CDF.\n\n // This algorithm is due to Prof. Thomas S. Ferguson, ,\n // and comes from his hypergeometric test calculator at\n // .\n\n // x = number of successes drawn\n // N = population size\n // m = number of successes in population\n // n = number of items drawn from population\n\n if(x < 0 || x < m - (N - n)) {\n // It's impossible to have this few successes drawn or fewer.\n return 0;\n } else if(x >= n || x >= m) {\n // We will always have this many successes or fewer.\n return 1;\n } else if (m * 2 > N) {\n // More than half the population is successes.\n\n if(n * 2 > N) {\n // More than half the population is sampled.\n\n return jStat.hypgeom.cdf(N - m - n + x, N, N - m, N - n)\n } else {\n // Half or less of the population is sampled.\n\n return 1 - jStat.hypgeom.cdf(n - x - 1, N, N - m, n);\n }\n\n } else if(n * 2 > N) {\n // Half or less is successes.\n\n return 1 - jStat.hypgeom.cdf(m - x - 1, N, m, N - n);\n\n } else if(m < n) {\n // We want to have the number of things sampled to be less than the\n // successes available. So swap the definitions of successful and sampled.\n return jStat.hypgeom.cdf(x, N, n, m);\n } else {\n // If we get here, half or less of the population was sampled, half or\n // less of it was successes, and we had fewer sampled things than\n // successes. Now we can do this complicated iterative algorithm in an\n // efficient way.\n\n // The basic premise of the algorithm is that we partially normalize our\n // intermediate sum to keep it in a numerically good region, and then\n // finish the normalization at the end.\n\n // Holds the intermediate, scaled total CDF.\n var scaledCDF = 1;\n\n // This variable holds the scaled probability of the current number of\n // successes.\n var scaledPDF = 1;\n\n // This keeps track of how much we have normalized.\n var samplesDone = 0;\n\n for(var i = 0; i < x; i++) {\n // For every possible number of successes up to that observed...\n\n while(scaledCDF > 1 && samplesDone < n) {\n // Intermediate result is growing too big. Apply some of the\n // normalization to shrink everything.\n\n var factor = 1 - (m / (N - samplesDone));\n\n scaledPDF *= factor;\n scaledCDF *= factor;\n\n // Say we've normalized by this sample already.\n samplesDone++;\n }\n\n // Work out the partially-normalized hypergeometric PDF for the next\n // number of successes\n scaledPDF *= (n - i) * (m - i) / ((i + 1) * (N - m - n + i + 1));\n\n // Add to the CDF answer.\n scaledCDF += scaledPDF;\n }\n\n for(; samplesDone < n; samplesDone++) {\n // Apply all the rest of the normalization\n scaledCDF *= 1 - (m / (N - samplesDone));\n }\n\n // Bound answer sanely before returning.\n return Math.min(1, Math.max(0, scaledCDF));\n }\n }\n});\n\n\n\n// extend uniform function with static methods\njStat.extend(jStat.poisson, {\n pdf: function pdf(k, l) {\n if (l < 0 || (k % 1) !== 0 || k < 0) {\n return 0;\n }\n\n return Math.pow(l, k) * Math.exp(-l) / jStat.factorial(k);\n },\n\n cdf: function cdf(x, l) {\n var sumarr = [],\n k = 0;\n if (x < 0) return 0;\n for (; k <= x; k++) {\n sumarr.push(jStat.poisson.pdf(k, l));\n }\n return jStat.sum(sumarr);\n },\n\n mean : function(l) {\n return l;\n },\n\n variance : function(l) {\n return l;\n },\n\n sampleSmall: function sampleSmall(l) {\n var p = 1, k = 0, L = Math.exp(-l);\n do {\n k++;\n p *= jStat._random_fn();\n } while (p > L);\n return k - 1;\n },\n\n sampleLarge: function sampleLarge(l) {\n var lam = l;\n var k;\n var U, V, slam, loglam, a, b, invalpha, vr, us;\n\n slam = Math.sqrt(lam);\n loglam = Math.log(lam);\n b = 0.931 + 2.53 * slam;\n a = -0.059 + 0.02483 * b;\n invalpha = 1.1239 + 1.1328 / (b - 3.4);\n vr = 0.9277 - 3.6224 / (b - 2);\n\n while (1) {\n U = Math.random() - 0.5;\n V = Math.random();\n us = 0.5 - Math.abs(U);\n k = Math.floor((2 * a / us + b) * U + lam + 0.43);\n if ((us >= 0.07) && (V <= vr)) {\n return k;\n }\n if ((k < 0) || ((us < 0.013) && (V > us))) {\n continue;\n }\n /* log(V) == log(0.0) ok here */\n /* if U==0.0 so that us==0.0, log is ok since always returns */\n if ((Math.log(V) + Math.log(invalpha) - Math.log(a / (us * us) + b)) <= (-lam + k * loglam - jStat.loggam(k + 1))) {\n return k;\n }\n }\n },\n\n sample: function sample(l) {\n if (l < 10)\n return this.sampleSmall(l);\n else\n return this.sampleLarge(l);\n }\n});\n\n// extend triangular function with static methods\njStat.extend(jStat.triangular, {\n pdf: function pdf(x, a, b, c) {\n if (b <= a || c < a || c > b) {\n return NaN;\n } else {\n if (x < a || x > b) {\n return 0;\n } else if (x < c) {\n return (2 * (x - a)) / ((b - a) * (c - a));\n } else if (x === c) {\n return (2 / (b - a));\n } else { // x > c\n return (2 * (b - x)) / ((b - a) * (b - c));\n }\n }\n },\n\n cdf: function cdf(x, a, b, c) {\n if (b <= a || c < a || c > b)\n return NaN;\n if (x <= a)\n return 0;\n else if (x >= b)\n return 1;\n if (x <= c)\n return Math.pow(x - a, 2) / ((b - a) * (c - a));\n else // x > c\n return 1 - Math.pow(b - x, 2) / ((b - a) * (b - c));\n },\n\n inv: function inv(p, a, b, c) {\n if (b <= a || c < a || c > b) {\n return NaN;\n } else {\n if (p <= ((c - a) / (b - a))) {\n return a + (b - a) * Math.sqrt(p * ((c - a) / (b - a)));\n } else { // p > ((c - a) / (b - a))\n return a + (b - a) * (1 - Math.sqrt((1 - p) * (1 - ((c - a) / (b - a)))));\n }\n }\n },\n\n mean: function mean(a, b, c) {\n return (a + b + c) / 3;\n },\n\n median: function median(a, b, c) {\n if (c <= (a + b) / 2) {\n return b - Math.sqrt((b - a) * (b - c)) / Math.sqrt(2);\n } else if (c > (a + b) / 2) {\n return a + Math.sqrt((b - a) * (c - a)) / Math.sqrt(2);\n }\n },\n\n mode: function mode(a, b, c) {\n return c;\n },\n\n sample: function sample(a, b, c) {\n var u = jStat._random_fn();\n if (u < ((c - a) / (b - a)))\n return a + Math.sqrt(u * (b - a) * (c - a))\n return b - Math.sqrt((1 - u) * (b - a) * (b - c));\n },\n\n variance: function variance(a, b, c) {\n return (a * a + b * b + c * c - a * b - a * c - b * c) / 18;\n }\n});\n\n\n// extend arcsine function with static methods\njStat.extend(jStat.arcsine, {\n pdf: function pdf(x, a, b) {\n if (b <= a) return NaN;\n\n return (x <= a || x >= b) ? 0 :\n (2 / Math.PI) *\n Math.pow(Math.pow(b - a, 2) -\n Math.pow(2 * x - a - b, 2), -0.5);\n },\n\n cdf: function cdf(x, a, b) {\n if (x < a)\n return 0;\n else if (x < b)\n return (2 / Math.PI) * Math.asin(Math.sqrt((x - a)/(b - a)));\n return 1;\n },\n\n inv: function(p, a, b) {\n return a + (0.5 - 0.5 * Math.cos(Math.PI * p)) * (b - a);\n },\n\n mean: function mean(a, b) {\n if (b <= a) return NaN;\n return (a + b) / 2;\n },\n\n median: function median(a, b) {\n if (b <= a) return NaN;\n return (a + b) / 2;\n },\n\n mode: function mode(/*a, b*/) {\n throw new Error('mode is not yet implemented');\n },\n\n sample: function sample(a, b) {\n return ((a + b) / 2) + ((b - a) / 2) *\n Math.sin(2 * Math.PI * jStat.uniform.sample(0, 1));\n },\n\n variance: function variance(a, b) {\n if (b <= a) return NaN;\n return Math.pow(b - a, 2) / 8;\n }\n});\n\n\nfunction laplaceSign(x) { return x / Math.abs(x); }\n\njStat.extend(jStat.laplace, {\n pdf: function pdf(x, mu, b) {\n return (b <= 0) ? 0 : (Math.exp(-Math.abs(x - mu) / b)) / (2 * b);\n },\n\n cdf: function cdf(x, mu, b) {\n if (b <= 0) { return 0; }\n\n if(x < mu) {\n return 0.5 * Math.exp((x - mu) / b);\n } else {\n return 1 - 0.5 * Math.exp(- (x - mu) / b);\n }\n },\n\n mean: function(mu/*, b*/) {\n return mu;\n },\n\n median: function(mu/*, b*/) {\n return mu;\n },\n\n mode: function(mu/*, b*/) {\n return mu;\n },\n\n variance: function(mu, b) {\n return 2 * b * b;\n },\n\n sample: function sample(mu, b) {\n var u = jStat._random_fn() - 0.5;\n\n return mu - (b * laplaceSign(u) * Math.log(1 - (2 * Math.abs(u))));\n }\n});\n\nfunction tukeyWprob(w, rr, cc) {\n var nleg = 12;\n var ihalf = 6;\n\n var C1 = -30;\n var C2 = -50;\n var C3 = 60;\n var bb = 8;\n var wlar = 3;\n var wincr1 = 2;\n var wincr2 = 3;\n var xleg = [\n 0.981560634246719250690549090149,\n 0.904117256370474856678465866119,\n 0.769902674194304687036893833213,\n 0.587317954286617447296702418941,\n 0.367831498998180193752691536644,\n 0.125233408511468915472441369464\n ];\n var aleg = [\n 0.047175336386511827194615961485,\n 0.106939325995318430960254718194,\n 0.160078328543346226334652529543,\n 0.203167426723065921749064455810,\n 0.233492536538354808760849898925,\n 0.249147045813402785000562436043\n ];\n\n var qsqz = w * 0.5;\n\n // if w >= 16 then the integral lower bound (occurs for c=20)\n // is 0.99999999999995 so return a value of 1.\n\n if (qsqz >= bb)\n return 1.0;\n\n // find (f(w/2) - 1) ^ cc\n // (first term in integral of hartley's form).\n\n var pr_w = 2 * jStat.normal.cdf(qsqz, 0, 1, 1, 0) - 1; // erf(qsqz / M_SQRT2)\n // if pr_w ^ cc < 2e-22 then set pr_w = 0\n if (pr_w >= Math.exp(C2 / cc))\n pr_w = Math.pow(pr_w, cc);\n else\n pr_w = 0.0;\n\n // if w is large then the second component of the\n // integral is small, so fewer intervals are needed.\n\n var wincr;\n if (w > wlar)\n wincr = wincr1;\n else\n wincr = wincr2;\n\n // find the integral of second term of hartley's form\n // for the integral of the range for equal-length\n // intervals using legendre quadrature. limits of\n // integration are from (w/2, 8). two or three\n // equal-length intervals are used.\n\n // blb and bub are lower and upper limits of integration.\n\n var blb = qsqz;\n var binc = (bb - qsqz) / wincr;\n var bub = blb + binc;\n var einsum = 0.0;\n\n // integrate over each interval\n\n var cc1 = cc - 1.0;\n for (var wi = 1; wi <= wincr; wi++) {\n var elsum = 0.0;\n var a = 0.5 * (bub + blb);\n\n // legendre quadrature with order = nleg\n\n var b = 0.5 * (bub - blb);\n\n for (var jj = 1; jj <= nleg; jj++) {\n var j, xx;\n if (ihalf < jj) {\n j = (nleg - jj) + 1;\n xx = xleg[j-1];\n } else {\n j = jj;\n xx = -xleg[j-1];\n }\n var c = b * xx;\n var ac = a + c;\n\n // if exp(-qexpo/2) < 9e-14,\n // then doesn't contribute to integral\n\n var qexpo = ac * ac;\n if (qexpo > C3)\n break;\n\n var pplus = 2 * jStat.normal.cdf(ac, 0, 1, 1, 0);\n var pminus= 2 * jStat.normal.cdf(ac, w, 1, 1, 0);\n\n // if rinsum ^ (cc-1) < 9e-14,\n // then doesn't contribute to integral\n\n var rinsum = (pplus * 0.5) - (pminus * 0.5);\n if (rinsum >= Math.exp(C1 / cc1)) {\n rinsum = (aleg[j-1] * Math.exp(-(0.5 * qexpo))) * Math.pow(rinsum, cc1);\n elsum += rinsum;\n }\n }\n elsum *= (((2.0 * b) * cc) / Math.sqrt(2 * Math.PI));\n einsum += elsum;\n blb = bub;\n bub += binc;\n }\n\n // if pr_w ^ rr < 9e-14, then return 0\n pr_w += einsum;\n if (pr_w <= Math.exp(C1 / rr))\n return 0;\n\n pr_w = Math.pow(pr_w, rr);\n if (pr_w >= 1) // 1 was iMax was eps\n return 1;\n return pr_w;\n}\n\nfunction tukeyQinv(p, c, v) {\n var p0 = 0.322232421088;\n var q0 = 0.993484626060e-01;\n var p1 = -1.0;\n var q1 = 0.588581570495;\n var p2 = -0.342242088547;\n var q2 = 0.531103462366;\n var p3 = -0.204231210125;\n var q3 = 0.103537752850;\n var p4 = -0.453642210148e-04;\n var q4 = 0.38560700634e-02;\n var c1 = 0.8832;\n var c2 = 0.2368;\n var c3 = 1.214;\n var c4 = 1.208;\n var c5 = 1.4142;\n var vmax = 120.0;\n\n var ps = 0.5 - 0.5 * p;\n var yi = Math.sqrt(Math.log(1.0 / (ps * ps)));\n var t = yi + (((( yi * p4 + p3) * yi + p2) * yi + p1) * yi + p0)\n / (((( yi * q4 + q3) * yi + q2) * yi + q1) * yi + q0);\n if (v < vmax) t += (t * t * t + t) / v / 4.0;\n var q = c1 - c2 * t;\n if (v < vmax) q += -c3 / v + c4 * t / v;\n return t * (q * Math.log(c - 1.0) + c5);\n}\n\njStat.extend(jStat.tukey, {\n cdf: function cdf(q, nmeans, df) {\n // Identical implementation as the R ptukey() function as of commit 68947\n var rr = 1;\n var cc = nmeans;\n\n var nlegq = 16;\n var ihalfq = 8;\n\n var eps1 = -30.0;\n var eps2 = 1.0e-14;\n var dhaf = 100.0;\n var dquar = 800.0;\n var deigh = 5000.0;\n var dlarg = 25000.0;\n var ulen1 = 1.0;\n var ulen2 = 0.5;\n var ulen3 = 0.25;\n var ulen4 = 0.125;\n var xlegq = [\n 0.989400934991649932596154173450,\n 0.944575023073232576077988415535,\n 0.865631202387831743880467897712,\n 0.755404408355003033895101194847,\n 0.617876244402643748446671764049,\n 0.458016777657227386342419442984,\n 0.281603550779258913230460501460,\n 0.950125098376374401853193354250e-1\n ];\n var alegq = [\n 0.271524594117540948517805724560e-1,\n 0.622535239386478928628438369944e-1,\n 0.951585116824927848099251076022e-1,\n 0.124628971255533872052476282192,\n 0.149595988816576732081501730547,\n 0.169156519395002538189312079030,\n 0.182603415044923588866763667969,\n 0.189450610455068496285396723208\n ];\n\n if (q <= 0)\n return 0;\n\n // df must be > 1\n // there must be at least two values\n\n if (df < 2 || rr < 1 || cc < 2) return NaN;\n\n if (!Number.isFinite(q))\n return 1;\n\n if (df > dlarg)\n return tukeyWprob(q, rr, cc);\n\n // calculate leading constant\n\n var f2 = df * 0.5;\n var f2lf = ((f2 * Math.log(df)) - (df * Math.log(2))) - jStat.gammaln(f2);\n var f21 = f2 - 1.0;\n\n // integral is divided into unit, half-unit, quarter-unit, or\n // eighth-unit length intervals depending on the value of the\n // degrees of freedom.\n\n var ff4 = df * 0.25;\n var ulen;\n if (df <= dhaf) ulen = ulen1;\n else if (df <= dquar) ulen = ulen2;\n else if (df <= deigh) ulen = ulen3;\n else ulen = ulen4;\n\n f2lf += Math.log(ulen);\n\n // integrate over each subinterval\n\n var ans = 0.0;\n\n for (var i = 1; i <= 50; i++) {\n var otsum = 0.0;\n\n // legendre quadrature with order = nlegq\n // nodes (stored in xlegq) are symmetric around zero.\n\n var twa1 = (2 * i - 1) * ulen;\n\n for (var jj = 1; jj <= nlegq; jj++) {\n var j, t1;\n if (ihalfq < jj) {\n j = jj - ihalfq - 1;\n t1 = (f2lf + (f21 * Math.log(twa1 + (xlegq[j] * ulen))))\n - (((xlegq[j] * ulen) + twa1) * ff4);\n } else {\n j = jj - 1;\n t1 = (f2lf + (f21 * Math.log(twa1 - (xlegq[j] * ulen))))\n + (((xlegq[j] * ulen) - twa1) * ff4);\n }\n\n // if exp(t1) < 9e-14, then doesn't contribute to integral\n var qsqz;\n if (t1 >= eps1) {\n if (ihalfq < jj) {\n qsqz = q * Math.sqrt(((xlegq[j] * ulen) + twa1) * 0.5);\n } else {\n qsqz = q * Math.sqrt(((-(xlegq[j] * ulen)) + twa1) * 0.5);\n }\n\n // call wprob to find integral of range portion\n\n var wprb = tukeyWprob(qsqz, rr, cc);\n var rotsum = (wprb * alegq[j]) * Math.exp(t1);\n otsum += rotsum;\n }\n // end legendre integral for interval i\n // L200:\n }\n\n // if integral for interval i < 1e-14, then stop.\n // However, in order to avoid small area under left tail,\n // at least 1 / ulen intervals are calculated.\n if (i * ulen >= 1.0 && otsum <= eps2)\n break;\n\n // end of interval i\n // L330:\n\n ans += otsum;\n }\n\n if (otsum > eps2) { // not converged\n throw new Error('tukey.cdf failed to converge');\n }\n if (ans > 1)\n ans = 1;\n return ans;\n },\n\n inv: function(p, nmeans, df) {\n // Identical implementation as the R qtukey() function as of commit 68947\n var rr = 1;\n var cc = nmeans;\n\n var eps = 0.0001;\n var maxiter = 50;\n\n // df must be > 1 ; there must be at least two values\n if (df < 2 || rr < 1 || cc < 2) return NaN;\n\n if (p < 0 || p > 1) return NaN;\n if (p === 0) return 0;\n if (p === 1) return Infinity;\n\n // Initial value\n\n var x0 = tukeyQinv(p, cc, df);\n\n // Find prob(value < x0)\n\n var valx0 = jStat.tukey.cdf(x0, nmeans, df) - p;\n\n // Find the second iterate and prob(value < x1).\n // If the first iterate has probability value\n // exceeding p then second iterate is 1 less than\n // first iterate; otherwise it is 1 greater.\n\n var x1;\n if (valx0 > 0.0)\n x1 = Math.max(0.0, x0 - 1.0);\n else\n x1 = x0 + 1.0;\n var valx1 = jStat.tukey.cdf(x1, nmeans, df) - p;\n\n // Find new iterate\n\n var ans;\n for(var iter = 1; iter < maxiter; iter++) {\n ans = x1 - ((valx1 * (x1 - x0)) / (valx1 - valx0));\n valx0 = valx1;\n\n // New iterate must be >= 0\n\n x0 = x1;\n if (ans < 0.0) {\n ans = 0.0;\n valx1 = -p;\n }\n // Find prob(value < new iterate)\n\n valx1 = jStat.tukey.cdf(ans, nmeans, df) - p;\n x1 = ans;\n\n // If the difference between two successive\n // iterates is less than eps, stop\n\n var xabs = Math.abs(x1 - x0);\n if (xabs < eps)\n return ans;\n }\n\n throw new Error('tukey.inv failed to converge');\n }\n});\n\n}(jStat, Math));\n/* Provides functions for the solution of linear system of equations, integration, extrapolation,\n * interpolation, eigenvalue problems, differential equations and PCA analysis. */\n\n(function(jStat, Math) {\n\nvar push = Array.prototype.push;\nvar isArray = jStat.utils.isArray;\n\nfunction isUsable(arg) {\n return isArray(arg) || arg instanceof jStat;\n}\n\njStat.extend({\n\n // add a vector/matrix to a vector/matrix or scalar\n add: function add(arr, arg) {\n // check if arg is a vector or scalar\n if (isUsable(arg)) {\n if (!isUsable(arg[0])) arg = [ arg ];\n return jStat.map(arr, function(value, row, col) {\n return value + arg[row][col];\n });\n }\n return jStat.map(arr, function(value) { return value + arg; });\n },\n\n // subtract a vector or scalar from the vector\n subtract: function subtract(arr, arg) {\n // check if arg is a vector or scalar\n if (isUsable(arg)) {\n if (!isUsable(arg[0])) arg = [ arg ];\n return jStat.map(arr, function(value, row, col) {\n return value - arg[row][col] || 0;\n });\n }\n return jStat.map(arr, function(value) { return value - arg; });\n },\n\n // matrix division\n divide: function divide(arr, arg) {\n if (isUsable(arg)) {\n if (!isUsable(arg[0])) arg = [ arg ];\n return jStat.multiply(arr, jStat.inv(arg));\n }\n return jStat.map(arr, function(value) { return value / arg; });\n },\n\n // matrix multiplication\n multiply: function multiply(arr, arg) {\n var row, col, nrescols, sum, nrow, ncol, res, rescols;\n // eg: arr = 2 arg = 3 -> 6 for res[0][0] statement closure\n if (arr.length === undefined && arg.length === undefined) {\n return arr * arg;\n }\n nrow = arr.length,\n ncol = arr[0].length,\n res = jStat.zeros(nrow, nrescols = (isUsable(arg)) ? arg[0].length : ncol),\n rescols = 0;\n if (isUsable(arg)) {\n for (; rescols < nrescols; rescols++) {\n for (row = 0; row < nrow; row++) {\n sum = 0;\n for (col = 0; col < ncol; col++)\n sum += arr[row][col] * arg[col][rescols];\n res[row][rescols] = sum;\n }\n }\n return (nrow === 1 && rescols === 1) ? res[0][0] : res;\n }\n return jStat.map(arr, function(value) { return value * arg; });\n },\n\n // outer([1,2,3],[4,5,6])\n // ===\n // [[1],[2],[3]] times [[4,5,6]]\n // ->\n // [[4,5,6],[8,10,12],[12,15,18]]\n outer:function outer(A, B) {\n return jStat.multiply(A.map(function(t){ return [t] }), [B]);\n },\n\n\n // Returns the dot product of two matricies\n dot: function dot(arr, arg) {\n if (!isUsable(arr[0])) arr = [ arr ];\n if (!isUsable(arg[0])) arg = [ arg ];\n // convert column to row vector\n var left = (arr[0].length === 1 && arr.length !== 1) ? jStat.transpose(arr) : arr,\n right = (arg[0].length === 1 && arg.length !== 1) ? jStat.transpose(arg) : arg,\n res = [],\n row = 0,\n nrow = left.length,\n ncol = left[0].length,\n sum, col;\n for (; row < nrow; row++) {\n res[row] = [];\n sum = 0;\n for (col = 0; col < ncol; col++)\n sum += left[row][col] * right[row][col];\n res[row] = sum;\n }\n return (res.length === 1) ? res[0] : res;\n },\n\n // raise every element by a scalar\n pow: function pow(arr, arg) {\n return jStat.map(arr, function(value) { return Math.pow(value, arg); });\n },\n\n // exponentiate every element\n exp: function exp(arr) {\n return jStat.map(arr, function(value) { return Math.exp(value); });\n },\n\n // generate the natural log of every element\n log: function exp(arr) {\n return jStat.map(arr, function(value) { return Math.log(value); });\n },\n\n // generate the absolute values of the vector\n abs: function abs(arr) {\n return jStat.map(arr, function(value) { return Math.abs(value); });\n },\n\n // computes the p-norm of the vector\n // In the case that a matrix is passed, uses the first row as the vector\n norm: function norm(arr, p) {\n var nnorm = 0,\n i = 0;\n // check the p-value of the norm, and set for most common case\n if (isNaN(p)) p = 2;\n // check if multi-dimensional array, and make vector correction\n if (isUsable(arr[0])) arr = arr[0];\n // vector norm\n for (; i < arr.length; i++) {\n nnorm += Math.pow(Math.abs(arr[i]), p);\n }\n return Math.pow(nnorm, 1 / p);\n },\n\n // computes the angle between two vectors in rads\n // In case a matrix is passed, this uses the first row as the vector\n angle: function angle(arr, arg) {\n return Math.acos(jStat.dot(arr, arg) / (jStat.norm(arr) * jStat.norm(arg)));\n },\n\n // augment one matrix by another\n // Note: this function returns a matrix, not a jStat object\n aug: function aug(a, b) {\n var newarr = [];\n var i;\n for (i = 0; i < a.length; i++) {\n newarr.push(a[i].slice());\n }\n for (i = 0; i < newarr.length; i++) {\n push.apply(newarr[i], b[i]);\n }\n return newarr;\n },\n\n // The inv() function calculates the inverse of a matrix\n // Create the inverse by augmenting the matrix by the identity matrix of the\n // appropriate size, and then use G-J elimination on the augmented matrix.\n inv: function inv(a) {\n var rows = a.length;\n var cols = a[0].length;\n var b = jStat.identity(rows, cols);\n var c = jStat.gauss_jordan(a, b);\n var result = [];\n var i = 0;\n var j;\n\n //We need to copy the inverse portion to a new matrix to rid G-J artifacts\n for (; i < rows; i++) {\n result[i] = [];\n for (j = cols; j < c[0].length; j++)\n result[i][j - cols] = c[i][j];\n }\n return result;\n },\n\n // calculate the determinant of a matrix\n det: function det(a) {\n if (a.length === 2) {\n return a[0][0] * a[1][1] - a[0][1] * a[1][0];\n }\n\n var determinant = 0;\n for (var i = 0; i < a.length; i++) {\n // build a sub matrix without column `i`\n var submatrix = [];\n for (var row = 1; row < a.length; row++) {\n submatrix[row - 1] = [];\n for (var col = 0; col < a.length; col++) {\n if (col < i) {\n submatrix[row - 1][col] = a[row][col];\n } else if (col > i) {\n submatrix[row - 1][col - 1] = a[row][col];\n }\n }\n }\n\n // alternate between + and - between determinants\n var sign = i % 2 ? -1 : 1;\n determinant += det(submatrix) * a[0][i] * sign;\n }\n\n return determinant\n },\n\n gauss_elimination: function gauss_elimination(a, b) {\n var i = 0,\n j = 0,\n n = a.length,\n m = a[0].length,\n factor = 1,\n sum = 0,\n x = [],\n maug, pivot, temp, k;\n a = jStat.aug(a, b);\n maug = a[0].length;\n for(i = 0; i < n; i++) {\n pivot = a[i][i];\n j = i;\n for (k = i + 1; k < m; k++) {\n if (pivot < Math.abs(a[k][i])) {\n pivot = a[k][i];\n j = k;\n }\n }\n if (j != i) {\n for(k = 0; k < maug; k++) {\n temp = a[i][k];\n a[i][k] = a[j][k];\n a[j][k] = temp;\n }\n }\n for (j = i + 1; j < n; j++) {\n factor = a[j][i] / a[i][i];\n for(k = i; k < maug; k++) {\n a[j][k] = a[j][k] - factor * a[i][k];\n }\n }\n }\n for (i = n - 1; i >= 0; i--) {\n sum = 0;\n for (j = i + 1; j<= n - 1; j++) {\n sum = sum + x[j] * a[i][j];\n }\n x[i] =(a[i][maug - 1] - sum) / a[i][i];\n }\n return x;\n },\n\n gauss_jordan: function gauss_jordan(a, b) {\n var m = jStat.aug(a, b);\n var h = m.length;\n var w = m[0].length;\n var c = 0;\n var x, y, y2;\n // find max pivot\n for (y = 0; y < h; y++) {\n var maxrow = y;\n for (y2 = y+1; y2 < h; y2++) {\n if (Math.abs(m[y2][y]) > Math.abs(m[maxrow][y]))\n maxrow = y2;\n }\n var tmp = m[y];\n m[y] = m[maxrow];\n m[maxrow] = tmp\n for (y2 = y+1; y2 < h; y2++) {\n c = m[y2][y] / m[y][y];\n for (x = y; x < w; x++) {\n m[y2][x] -= m[y][x] * c;\n }\n }\n }\n // backsubstitute\n for (y = h-1; y >= 0; y--) {\n c = m[y][y];\n for (y2 = 0; y2 < y; y2++) {\n for (x = w-1; x > y-1; x--) {\n m[y2][x] -= m[y][x] * m[y2][y] / c;\n }\n }\n m[y][y] /= c;\n for (x = h; x < w; x++) {\n m[y][x] /= c;\n }\n }\n return m;\n },\n\n // solve equation\n // Ax=b\n // A is upper triangular matrix\n // A=[[1,2,3],[0,4,5],[0,6,7]]\n // b=[1,2,3]\n // triaUpSolve(A,b) // -> [2.666,0.1666,1.666]\n // if you use matrix style\n // A=[[1,2,3],[0,4,5],[0,6,7]]\n // b=[[1],[2],[3]]\n // will return [[2.666],[0.1666],[1.666]]\n triaUpSolve: function triaUpSolve(A, b) {\n var size = A[0].length;\n var x = jStat.zeros(1, size)[0];\n var parts;\n var matrix_mode = false;\n\n if (b[0].length != undefined) {\n b = b.map(function(i){ return i[0] });\n matrix_mode = true;\n }\n\n jStat.arange(size - 1, -1, -1).forEach(function(i) {\n parts = jStat.arange(i + 1, size).map(function(j) {\n return x[j] * A[i][j];\n });\n x[i] = (b[i] - jStat.sum(parts)) / A[i][i];\n });\n\n if (matrix_mode)\n return x.map(function(i){ return [i] });\n return x;\n },\n\n triaLowSolve: function triaLowSolve(A, b) {\n // like to triaUpSolve but A is lower triangular matrix\n var size = A[0].length;\n var x = jStat.zeros(1, size)[0];\n var parts;\n\n var matrix_mode=false;\n if (b[0].length != undefined) {\n b = b.map(function(i){ return i[0] });\n matrix_mode = true;\n }\n\n jStat.arange(size).forEach(function(i) {\n parts = jStat.arange(i).map(function(j) {\n return A[i][j] * x[j];\n });\n x[i] = (b[i] - jStat.sum(parts)) / A[i][i];\n })\n\n if (matrix_mode)\n return x.map(function(i){ return [i] });\n return x;\n },\n\n\n // A -> [L,U]\n // A=LU\n // L is lower triangular matrix\n // U is upper triangular matrix\n lu: function lu(A) {\n var size = A.length;\n //var L=jStat.diagonal(jStat.ones(1,size)[0]);\n var L = jStat.identity(size);\n var R = jStat.zeros(A.length, A[0].length);\n var parts;\n jStat.arange(size).forEach(function(t) {\n R[0][t] = A[0][t];\n });\n jStat.arange(1, size).forEach(function(l) {\n jStat.arange(l).forEach(function(i) {\n parts = jStat.arange(i).map(function(jj) {\n return L[l][jj] * R[jj][i];\n });\n L[l][i] = (A[l][i] - jStat.sum(parts)) / R[i][i];\n });\n jStat.arange(l, size).forEach(function(j) {\n parts = jStat.arange(l).map(function(jj) {\n return L[l][jj] * R[jj][j];\n });\n R[l][j] = A[parts.length][j] - jStat.sum(parts);\n });\n });\n return [L, R];\n },\n\n // A -> T\n // A=TT'\n // T is lower triangular matrix\n cholesky: function cholesky(A) {\n var size = A.length;\n var T = jStat.zeros(A.length, A[0].length);\n var parts;\n jStat.arange(size).forEach(function(i) {\n parts = jStat.arange(i).map(function(t) {\n return Math.pow(T[i][t],2);\n });\n T[i][i] = Math.sqrt(A[i][i] - jStat.sum(parts));\n jStat.arange(i + 1, size).forEach(function(j) {\n parts = jStat.arange(i).map(function(t) {\n return T[i][t] * T[j][t];\n });\n T[j][i] = (A[i][j] - jStat.sum(parts)) / T[i][i];\n });\n });\n return T;\n },\n\n\n gauss_jacobi: function gauss_jacobi(a, b, x, r) {\n var i = 0;\n var j = 0;\n var n = a.length;\n var l = [];\n var u = [];\n var d = [];\n var xv, c, h, xk;\n for (; i < n; i++) {\n l[i] = [];\n u[i] = [];\n d[i] = [];\n for (j = 0; j < n; j++) {\n if (i > j) {\n l[i][j] = a[i][j];\n u[i][j] = d[i][j] = 0;\n } else if (i < j) {\n u[i][j] = a[i][j];\n l[i][j] = d[i][j] = 0;\n } else {\n d[i][j] = a[i][j];\n l[i][j] = u[i][j] = 0;\n }\n }\n }\n h = jStat.multiply(jStat.multiply(jStat.inv(d), jStat.add(l, u)), -1);\n c = jStat.multiply(jStat.inv(d), b);\n xv = x;\n xk = jStat.add(jStat.multiply(h, x), c);\n i = 2;\n while (Math.abs(jStat.norm(jStat.subtract(xk,xv))) > r) {\n xv = xk;\n xk = jStat.add(jStat.multiply(h, xv), c);\n i++;\n }\n return xk;\n },\n\n gauss_seidel: function gauss_seidel(a, b, x, r) {\n var i = 0;\n var n = a.length;\n var l = [];\n var u = [];\n var d = [];\n var j, xv, c, h, xk;\n for (; i < n; i++) {\n l[i] = [];\n u[i] = [];\n d[i] = [];\n for (j = 0; j < n; j++) {\n if (i > j) {\n l[i][j] = a[i][j];\n u[i][j] = d[i][j] = 0;\n } else if (i < j) {\n u[i][j] = a[i][j];\n l[i][j] = d[i][j] = 0;\n } else {\n d[i][j] = a[i][j];\n l[i][j] = u[i][j] = 0;\n }\n }\n }\n h = jStat.multiply(jStat.multiply(jStat.inv(jStat.add(d, l)), u), -1);\n c = jStat.multiply(jStat.inv(jStat.add(d, l)), b);\n xv = x;\n xk = jStat.add(jStat.multiply(h, x), c);\n i = 2;\n while (Math.abs(jStat.norm(jStat.subtract(xk, xv))) > r) {\n xv = xk;\n xk = jStat.add(jStat.multiply(h, xv), c);\n i = i + 1;\n }\n return xk;\n },\n\n SOR: function SOR(a, b, x, r, w) {\n var i = 0;\n var n = a.length;\n var l = [];\n var u = [];\n var d = [];\n var j, xv, c, h, xk;\n for (; i < n; i++) {\n l[i] = [];\n u[i] = [];\n d[i] = [];\n for (j = 0; j < n; j++) {\n if (i > j) {\n l[i][j] = a[i][j];\n u[i][j] = d[i][j] = 0;\n } else if (i < j) {\n u[i][j] = a[i][j];\n l[i][j] = d[i][j] = 0;\n } else {\n d[i][j] = a[i][j];\n l[i][j] = u[i][j] = 0;\n }\n }\n }\n h = jStat.multiply(jStat.inv(jStat.add(d, jStat.multiply(l, w))),\n jStat.subtract(jStat.multiply(d, 1 - w),\n jStat.multiply(u, w)));\n c = jStat.multiply(jStat.multiply(jStat.inv(jStat.add(d,\n jStat.multiply(l, w))), b), w);\n xv = x;\n xk = jStat.add(jStat.multiply(h, x), c);\n i = 2;\n while (Math.abs(jStat.norm(jStat.subtract(xk, xv))) > r) {\n xv = xk;\n xk = jStat.add(jStat.multiply(h, xv), c);\n i++;\n }\n return xk;\n },\n\n householder: function householder(a) {\n var m = a.length;\n var n = a[0].length;\n var i = 0;\n var w = [];\n var p = [];\n var alpha, r, k, j, factor;\n for (; i < m - 1; i++) {\n alpha = 0;\n for (j = i + 1; j < n; j++)\n alpha += (a[j][i] * a[j][i]);\n factor = (a[i + 1][i] > 0) ? -1 : 1;\n alpha = factor * Math.sqrt(alpha);\n r = Math.sqrt((((alpha * alpha) - a[i + 1][i] * alpha) / 2));\n w = jStat.zeros(m, 1);\n w[i + 1][0] = (a[i + 1][i] - alpha) / (2 * r);\n for (k = i + 2; k < m; k++) w[k][0] = a[k][i] / (2 * r);\n p = jStat.subtract(jStat.identity(m, n),\n jStat.multiply(jStat.multiply(w, jStat.transpose(w)), 2));\n a = jStat.multiply(p, jStat.multiply(a, p));\n }\n return a;\n },\n\n // A -> [Q,R]\n // Q is orthogonal matrix\n // R is upper triangular\n QR: (function() {\n // x -> Q\n // find a orthogonal matrix Q st.\n // Qx=y\n // y is [||x||,0,0,...]\n\n // quick ref\n var sum = jStat.sum;\n var range = jStat.arange;\n\n function qr2(x) {\n // quick impletation\n // https://www.stat.wisc.edu/~larget/math496/qr.html\n\n var n = x.length;\n var p = x[0].length;\n\n var r = jStat.zeros(p, p);\n x = jStat.copy(x);\n\n var i,j,k;\n for(j = 0; j < p; j++){\n r[j][j] = Math.sqrt(sum(range(n).map(function(i){\n return x[i][j] * x[i][j];\n })));\n for(i = 0; i < n; i++){\n x[i][j] = x[i][j] / r[j][j];\n }\n for(k = j+1; k < p; k++){\n r[j][k] = sum(range(n).map(function(i){\n return x[i][j] * x[i][k];\n }));\n for(i = 0; i < n; i++){\n x[i][k] = x[i][k] - x[i][j]*r[j][k];\n }\n }\n }\n return [x, r];\n }\n\n return qr2;\n }()),\n\n lstsq: (function() {\n // solve least squard problem for Ax=b as QR decomposition way if b is\n // [[b1],[b2],[b3]] form will return [[x1],[x2],[x3]] array form solution\n // else b is [b1,b2,b3] form will return [x1,x2,x3] array form solution\n function R_I(A) {\n A = jStat.copy(A);\n var size = A.length;\n var I = jStat.identity(size);\n jStat.arange(size - 1, -1, -1).forEach(function(i) {\n jStat.sliceAssign(\n I, { row: i }, jStat.divide(jStat.slice(I, { row: i }), A[i][i]));\n jStat.sliceAssign(\n A, { row: i }, jStat.divide(jStat.slice(A, { row: i }), A[i][i]));\n jStat.arange(i).forEach(function(j) {\n var c = jStat.multiply(A[j][i], -1);\n var Aj = jStat.slice(A, { row: j });\n var cAi = jStat.multiply(jStat.slice(A, { row: i }), c);\n jStat.sliceAssign(A, { row: j }, jStat.add(Aj, cAi));\n var Ij = jStat.slice(I, { row: j });\n var cIi = jStat.multiply(jStat.slice(I, { row: i }), c);\n jStat.sliceAssign(I, { row: j }, jStat.add(Ij, cIi));\n })\n });\n return I;\n }\n\n function qr_solve(A, b){\n var array_mode = false;\n if (b[0].length === undefined) {\n // [c1,c2,c3] mode\n b = b.map(function(x){ return [x] });\n array_mode = true;\n }\n var QR = jStat.QR(A);\n var Q = QR[0];\n var R = QR[1];\n var attrs = A[0].length;\n var Q1 = jStat.slice(Q,{col:{end:attrs}});\n var R1 = jStat.slice(R,{row:{end:attrs}});\n var RI = R_I(R1);\n var Q2 = jStat.transpose(Q1);\n\n if(Q2[0].length === undefined){\n Q2 = [Q2]; // The confusing jStat.multifly implementation threat nature process again.\n }\n\n var x = jStat.multiply(jStat.multiply(RI, Q2), b);\n\n if(x.length === undefined){\n x = [[x]]; // The confusing jStat.multifly implementation threat nature process again.\n }\n\n\n if (array_mode)\n return x.map(function(i){ return i[0] });\n return x;\n }\n\n return qr_solve;\n }()),\n\n jacobi: function jacobi(a) {\n var condition = 1;\n var n = a.length;\n var e = jStat.identity(n, n);\n var ev = [];\n var b, i, j, p, q, maxim, theta, s;\n // condition === 1 only if tolerance is not reached\n while (condition === 1) {\n maxim = a[0][1];\n p = 0;\n q = 1;\n for (i = 0; i < n; i++) {\n for (j = 0; j < n; j++) {\n if (i != j) {\n if (maxim < Math.abs(a[i][j])) {\n maxim = Math.abs(a[i][j]);\n p = i;\n q = j;\n }\n }\n }\n }\n if (a[p][p] === a[q][q])\n theta = (a[p][q] > 0) ? Math.PI / 4 : -Math.PI / 4;\n else\n theta = Math.atan(2 * a[p][q] / (a[p][p] - a[q][q])) / 2;\n s = jStat.identity(n, n);\n s[p][p] = Math.cos(theta);\n s[p][q] = -Math.sin(theta);\n s[q][p] = Math.sin(theta);\n s[q][q] = Math.cos(theta);\n // eigen vector matrix\n e = jStat.multiply(e, s);\n b = jStat.multiply(jStat.multiply(jStat.inv(s), a), s);\n a = b;\n condition = 0;\n for (i = 1; i < n; i++) {\n for (j = 1; j < n; j++) {\n if (i != j && Math.abs(a[i][j]) > 0.001) {\n condition = 1;\n }\n }\n }\n }\n for (i = 0; i < n; i++) ev.push(a[i][i]);\n //returns both the eigenvalue and eigenmatrix\n return [e, ev];\n },\n\n rungekutta: function rungekutta(f, h, p, t_j, u_j, order) {\n var k1, k2, u_j1, k3, k4;\n if (order === 2) {\n while (t_j <= p) {\n k1 = h * f(t_j, u_j);\n k2 = h * f(t_j + h, u_j + k1);\n u_j1 = u_j + (k1 + k2) / 2;\n u_j = u_j1;\n t_j = t_j + h;\n }\n }\n if (order === 4) {\n while (t_j <= p) {\n k1 = h * f(t_j, u_j);\n k2 = h * f(t_j + h / 2, u_j + k1 / 2);\n k3 = h * f(t_j + h / 2, u_j + k2 / 2);\n k4 = h * f(t_j +h, u_j + k3);\n u_j1 = u_j + (k1 + 2 * k2 + 2 * k3 + k4) / 6;\n u_j = u_j1;\n t_j = t_j + h;\n }\n }\n return u_j;\n },\n\n romberg: function romberg(f, a, b, order) {\n var i = 0;\n var h = (b - a) / 2;\n var x = [];\n var h1 = [];\n var g = [];\n var m, a1, j, k, I;\n while (i < order / 2) {\n I = f(a);\n for (j = a, k = 0; j <= b; j = j + h, k++) x[k] = j;\n m = x.length;\n for (j = 1; j < m - 1; j++) {\n I += (((j % 2) !== 0) ? 4 : 2) * f(x[j]);\n }\n I = (h / 3) * (I + f(b));\n g[i] = I;\n h /= 2;\n i++;\n }\n a1 = g.length;\n m = 1;\n while (a1 !== 1) {\n for (j = 0; j < a1 - 1; j++)\n h1[j] = ((Math.pow(4, m)) * g[j + 1] - g[j]) / (Math.pow(4, m) - 1);\n a1 = h1.length;\n g = h1;\n h1 = [];\n m++;\n }\n return g;\n },\n\n richardson: function richardson(X, f, x, h) {\n function pos(X, x) {\n var i = 0;\n var n = X.length;\n var p;\n for (; i < n; i++)\n if (X[i] === x) p = i;\n return p;\n }\n var h_min = Math.abs(x - X[pos(X, x) + 1]);\n var i = 0;\n var g = [];\n var h1 = [];\n var y1, y2, m, a, j;\n while (h >= h_min) {\n y1 = pos(X, x + h);\n y2 = pos(X, x);\n g[i] = (f[y1] - 2 * f[y2] + f[2 * y2 - y1]) / (h * h);\n h /= 2;\n i++;\n }\n a = g.length;\n m = 1;\n while (a != 1) {\n for (j = 0; j < a - 1; j++)\n h1[j] = ((Math.pow(4, m)) * g[j + 1] - g[j]) / (Math.pow(4, m) - 1);\n a = h1.length;\n g = h1;\n h1 = [];\n m++;\n }\n return g;\n },\n\n simpson: function simpson(f, a, b, n) {\n var h = (b - a) / n;\n var I = f(a);\n var x = [];\n var j = a;\n var k = 0;\n var i = 1;\n var m;\n for (; j <= b; j = j + h, k++)\n x[k] = j;\n m = x.length;\n for (; i < m - 1; i++) {\n I += ((i % 2 !== 0) ? 4 : 2) * f(x[i]);\n }\n return (h / 3) * (I + f(b));\n },\n\n hermite: function hermite(X, F, dF, value) {\n var n = X.length;\n var p = 0;\n var i = 0;\n var l = [];\n var dl = [];\n var A = [];\n var B = [];\n var j;\n for (; i < n; i++) {\n l[i] = 1;\n for (j = 0; j < n; j++) {\n if (i != j) l[i] *= (value - X[j]) / (X[i] - X[j]);\n }\n dl[i] = 0;\n for (j = 0; j < n; j++) {\n if (i != j) dl[i] += 1 / (X [i] - X[j]);\n }\n A[i] = (1 - 2 * (value - X[i]) * dl[i]) * (l[i] * l[i]);\n B[i] = (value - X[i]) * (l[i] * l[i]);\n p += (A[i] * F[i] + B[i] * dF[i]);\n }\n return p;\n },\n\n lagrange: function lagrange(X, F, value) {\n var p = 0;\n var i = 0;\n var j, l;\n var n = X.length;\n for (; i < n; i++) {\n l = F[i];\n for (j = 0; j < n; j++) {\n // calculating the lagrange polynomial L_i\n if (i != j) l *= (value - X[j]) / (X[i] - X[j]);\n }\n // adding the lagrange polynomials found above\n p += l;\n }\n return p;\n },\n\n cubic_spline: function cubic_spline(X, F, value) {\n var n = X.length;\n var i = 0, j;\n var A = [];\n var B = [];\n var alpha = [];\n var c = [];\n var h = [];\n var b = [];\n var d = [];\n for (; i < n - 1; i++)\n h[i] = X[i + 1] - X[i];\n alpha[0] = 0;\n for (i = 1; i < n - 1; i++) {\n alpha[i] = (3 / h[i]) * (F[i + 1] - F[i]) -\n (3 / h[i-1]) * (F[i] - F[i-1]);\n }\n for (i = 1; i < n - 1; i++) {\n A[i] = [];\n B[i] = [];\n A[i][i-1] = h[i-1];\n A[i][i] = 2 * (h[i - 1] + h[i]);\n A[i][i+1] = h[i];\n B[i][0] = alpha[i];\n }\n c = jStat.multiply(jStat.inv(A), B);\n for (j = 0; j < n - 1; j++) {\n b[j] = (F[j + 1] - F[j]) / h[j] - h[j] * (c[j + 1][0] + 2 * c[j][0]) / 3;\n d[j] = (c[j + 1][0] - c[j][0]) / (3 * h[j]);\n }\n for (j = 0; j < n; j++) {\n if (X[j] > value) break;\n }\n j -= 1;\n return F[j] + (value - X[j]) * b[j] + jStat.sq(value-X[j]) *\n c[j] + (value - X[j]) * jStat.sq(value - X[j]) * d[j];\n },\n\n gauss_quadrature: function gauss_quadrature() {\n throw new Error('gauss_quadrature not yet implemented');\n },\n\n PCA: function PCA(X) {\n var m = X.length;\n var n = X[0].length;\n var i = 0;\n var j, temp1;\n var u = [];\n var D = [];\n var result = [];\n var temp2 = [];\n var Y = [];\n var Bt = [];\n var B = [];\n var C = [];\n var V = [];\n var Vt = [];\n for (i = 0; i < m; i++) {\n u[i] = jStat.sum(X[i]) / n;\n }\n for (i = 0; i < n; i++) {\n B[i] = [];\n for(j = 0; j < m; j++) {\n B[i][j] = X[j][i] - u[j];\n }\n }\n B = jStat.transpose(B);\n for (i = 0; i < m; i++) {\n C[i] = [];\n for (j = 0; j < m; j++) {\n C[i][j] = (jStat.dot([B[i]], [B[j]])) / (n - 1);\n }\n }\n result = jStat.jacobi(C);\n V = result[0];\n D = result[1];\n Vt = jStat.transpose(V);\n for (i = 0; i < D.length; i++) {\n for (j = i; j < D.length; j++) {\n if(D[i] < D[j]) {\n temp1 = D[i];\n D[i] = D[j];\n D[j] = temp1;\n temp2 = Vt[i];\n Vt[i] = Vt[j];\n Vt[j] = temp2;\n }\n }\n }\n Bt = jStat.transpose(B);\n for (i = 0; i < m; i++) {\n Y[i] = [];\n for (j = 0; j < Bt.length; j++) {\n Y[i][j] = jStat.dot([Vt[i]], [Bt[j]]);\n }\n }\n return [X, D, Vt, Y];\n }\n});\n\n// extend jStat.fn with methods that require one argument\n(function(funcs) {\n for (var i = 0; i < funcs.length; i++) (function(passfunc) {\n jStat.fn[passfunc] = function(arg, func) {\n var tmpthis = this;\n // check for callback\n if (func) {\n setTimeout(function() {\n func.call(tmpthis, jStat.fn[passfunc].call(tmpthis, arg));\n }, 15);\n return this;\n }\n if (typeof jStat[passfunc](this, arg) === 'number')\n return jStat[passfunc](this, arg);\n else\n return jStat(jStat[passfunc](this, arg));\n };\n }(funcs[i]));\n}('add divide multiply subtract dot pow exp log abs norm angle'.split(' ')));\n\n}(jStat, Math));\n(function(jStat, Math) {\n\nvar slice = [].slice;\nvar isNumber = jStat.utils.isNumber;\nvar isArray = jStat.utils.isArray;\n\n// flag==true denotes use of sample standard deviation\n// Z Statistics\njStat.extend({\n // 2 different parameter lists:\n // (value, mean, sd)\n // (value, array, flag)\n zscore: function zscore() {\n var args = slice.call(arguments);\n if (isNumber(args[1])) {\n return (args[0] - args[1]) / args[2];\n }\n return (args[0] - jStat.mean(args[1])) / jStat.stdev(args[1], args[2]);\n },\n\n // 3 different paramter lists:\n // (value, mean, sd, sides)\n // (zscore, sides)\n // (value, array, sides, flag)\n ztest: function ztest() {\n var args = slice.call(arguments);\n var z;\n if (isArray(args[1])) {\n // (value, array, sides, flag)\n z = jStat.zscore(args[0],args[1],args[3]);\n return (args[2] === 1) ?\n (jStat.normal.cdf(-Math.abs(z), 0, 1)) :\n (jStat.normal.cdf(-Math.abs(z), 0, 1)*2);\n } else {\n if (args.length > 2) {\n // (value, mean, sd, sides)\n z = jStat.zscore(args[0],args[1],args[2]);\n return (args[3] === 1) ?\n (jStat.normal.cdf(-Math.abs(z),0,1)) :\n (jStat.normal.cdf(-Math.abs(z),0,1)* 2);\n } else {\n // (zscore, sides)\n z = args[0];\n return (args[1] === 1) ?\n (jStat.normal.cdf(-Math.abs(z),0,1)) :\n (jStat.normal.cdf(-Math.abs(z),0,1)*2);\n }\n }\n }\n});\n\njStat.extend(jStat.fn, {\n zscore: function zscore(value, flag) {\n return (value - this.mean()) / this.stdev(flag);\n },\n\n ztest: function ztest(value, sides, flag) {\n var zscore = Math.abs(this.zscore(value, flag));\n return (sides === 1) ?\n (jStat.normal.cdf(-zscore, 0, 1)) :\n (jStat.normal.cdf(-zscore, 0, 1) * 2);\n }\n});\n\n// T Statistics\njStat.extend({\n // 2 parameter lists\n // (value, mean, sd, n)\n // (value, array)\n tscore: function tscore() {\n var args = slice.call(arguments);\n return (args.length === 4) ?\n ((args[0] - args[1]) / (args[2] / Math.sqrt(args[3]))) :\n ((args[0] - jStat.mean(args[1])) /\n (jStat.stdev(args[1], true) / Math.sqrt(args[1].length)));\n },\n\n // 3 different paramter lists:\n // (value, mean, sd, n, sides)\n // (tscore, n, sides)\n // (value, array, sides)\n ttest: function ttest() {\n var args = slice.call(arguments);\n var tscore;\n if (args.length === 5) {\n tscore = Math.abs(jStat.tscore(args[0], args[1], args[2], args[3]));\n return (args[4] === 1) ?\n (jStat.studentt.cdf(-tscore, args[3]-1)) :\n (jStat.studentt.cdf(-tscore, args[3]-1)*2);\n }\n if (isNumber(args[1])) {\n tscore = Math.abs(args[0])\n return (args[2] == 1) ?\n (jStat.studentt.cdf(-tscore, args[1]-1)) :\n (jStat.studentt.cdf(-tscore, args[1]-1) * 2);\n }\n tscore = Math.abs(jStat.tscore(args[0], args[1]))\n return (args[2] == 1) ?\n (jStat.studentt.cdf(-tscore, args[1].length-1)) :\n (jStat.studentt.cdf(-tscore, args[1].length-1) * 2);\n }\n});\n\njStat.extend(jStat.fn, {\n tscore: function tscore(value) {\n return (value - this.mean()) / (this.stdev(true) / Math.sqrt(this.cols()));\n },\n\n ttest: function ttest(value, sides) {\n return (sides === 1) ?\n (1 - jStat.studentt.cdf(Math.abs(this.tscore(value)), this.cols()-1)) :\n (jStat.studentt.cdf(-Math.abs(this.tscore(value)), this.cols()-1)*2);\n }\n});\n\n// F Statistics\njStat.extend({\n // Paramter list is as follows:\n // (array1, array2, array3, ...)\n // or it is an array of arrays\n // array of arrays conversion\n anovafscore: function anovafscore() {\n var args = slice.call(arguments),\n expVar, sample, sampMean, sampSampMean, tmpargs, unexpVar, i, j;\n if (args.length === 1) {\n tmpargs = new Array(args[0].length);\n for (i = 0; i < args[0].length; i++) {\n tmpargs[i] = args[0][i];\n }\n args = tmpargs;\n }\n // Builds sample array\n sample = new Array();\n for (i = 0; i < args.length; i++) {\n sample = sample.concat(args[i]);\n }\n sampMean = jStat.mean(sample);\n // Computes the explained variance\n expVar = 0;\n for (i = 0; i < args.length; i++) {\n expVar = expVar + args[i].length * Math.pow(jStat.mean(args[i]) - sampMean, 2);\n }\n expVar /= (args.length - 1);\n // Computes unexplained variance\n unexpVar = 0;\n for (i = 0; i < args.length; i++) {\n sampSampMean = jStat.mean(args[i]);\n for (j = 0; j < args[i].length; j++) {\n unexpVar += Math.pow(args[i][j] - sampSampMean, 2);\n }\n }\n unexpVar /= (sample.length - args.length);\n return expVar / unexpVar;\n },\n\n // 2 different paramter setups\n // (array1, array2, array3, ...)\n // (anovafscore, df1, df2)\n anovaftest: function anovaftest() {\n var args = slice.call(arguments),\n df1, df2, n, i;\n if (isNumber(args[0])) {\n return 1 - jStat.centralF.cdf(args[0], args[1], args[2]);\n }\n var anovafscore = jStat.anovafscore(args);\n df1 = args.length - 1;\n n = 0;\n for (i = 0; i < args.length; i++) {\n n = n + args[i].length;\n }\n df2 = n - df1 - 1;\n return 1 - jStat.centralF.cdf(anovafscore, df1, df2);\n },\n\n ftest: function ftest(fscore, df1, df2) {\n return 1 - jStat.centralF.cdf(fscore, df1, df2);\n }\n});\n\njStat.extend(jStat.fn, {\n anovafscore: function anovafscore() {\n return jStat.anovafscore(this.toArray());\n },\n\n anovaftes: function anovaftes() {\n var n = 0;\n var i;\n for (i = 0; i < this.length; i++) {\n n = n + this[i].length;\n }\n return jStat.ftest(this.anovafscore(), this.length - 1, n - this.length);\n }\n});\n\n// Tukey's range test\njStat.extend({\n // 2 parameter lists\n // (mean1, mean2, n1, n2, sd)\n // (array1, array2, sd)\n qscore: function qscore() {\n var args = slice.call(arguments);\n var mean1, mean2, n1, n2, sd;\n if (isNumber(args[0])) {\n mean1 = args[0];\n mean2 = args[1];\n n1 = args[2];\n n2 = args[3];\n sd = args[4];\n } else {\n mean1 = jStat.mean(args[0]);\n mean2 = jStat.mean(args[1]);\n n1 = args[0].length;\n n2 = args[1].length;\n sd = args[2];\n }\n return Math.abs(mean1 - mean2) / (sd * Math.sqrt((1 / n1 + 1 / n2) / 2));\n },\n\n // 3 different parameter lists:\n // (qscore, n, k)\n // (mean1, mean2, n1, n2, sd, n, k)\n // (array1, array2, sd, n, k)\n qtest: function qtest() {\n var args = slice.call(arguments);\n\n var qscore;\n if (args.length === 3) {\n qscore = args[0];\n args = args.slice(1);\n } else if (args.length === 7) {\n qscore = jStat.qscore(args[0], args[1], args[2], args[3], args[4]);\n args = args.slice(5);\n } else {\n qscore = jStat.qscore(args[0], args[1], args[2]);\n args = args.slice(3);\n }\n\n var n = args[0];\n var k = args[1];\n\n return 1 - jStat.tukey.cdf(qscore, k, n - k);\n },\n\n tukeyhsd: function tukeyhsd(arrays) {\n var sd = jStat.pooledstdev(arrays);\n var means = arrays.map(function (arr) {return jStat.mean(arr);});\n var n = arrays.reduce(function (n, arr) {return n + arr.length;}, 0);\n\n var results = [];\n for (var i = 0; i < arrays.length; ++i) {\n for (var j = i + 1; j < arrays.length; ++j) {\n var p = jStat.qtest(means[i], means[j], arrays[i].length, arrays[j].length, sd, n, arrays.length);\n results.push([[i, j], p]);\n }\n }\n\n return results;\n }\n});\n\n// Error Bounds\njStat.extend({\n // 2 different parameter setups\n // (value, alpha, sd, n)\n // (value, alpha, array)\n normalci: function normalci() {\n var args = slice.call(arguments),\n ans = new Array(2),\n change;\n if (args.length === 4) {\n change = Math.abs(jStat.normal.inv(args[1] / 2, 0, 1) *\n args[2] / Math.sqrt(args[3]));\n } else {\n change = Math.abs(jStat.normal.inv(args[1] / 2, 0, 1) *\n jStat.stdev(args[2]) / Math.sqrt(args[2].length));\n }\n ans[0] = args[0] - change;\n ans[1] = args[0] + change;\n return ans;\n },\n\n // 2 different parameter setups\n // (value, alpha, sd, n)\n // (value, alpha, array)\n tci: function tci() {\n var args = slice.call(arguments),\n ans = new Array(2),\n change;\n if (args.length === 4) {\n change = Math.abs(jStat.studentt.inv(args[1] / 2, args[3] - 1) *\n args[2] / Math.sqrt(args[3]));\n } else {\n change = Math.abs(jStat.studentt.inv(args[1] / 2, args[2].length - 1) *\n jStat.stdev(args[2], true) / Math.sqrt(args[2].length));\n }\n ans[0] = args[0] - change;\n ans[1] = args[0] + change;\n return ans;\n },\n\n significant: function significant(pvalue, alpha) {\n return pvalue < alpha;\n }\n});\n\njStat.extend(jStat.fn, {\n normalci: function normalci(value, alpha) {\n return jStat.normalci(value, alpha, this.toArray());\n },\n\n tci: function tci(value, alpha) {\n return jStat.tci(value, alpha, this.toArray());\n }\n});\n\n// internal method for calculating the z-score for a difference of proportions test\nfunction differenceOfProportions(p1, n1, p2, n2) {\n if (p1 > 1 || p2 > 1 || p1 <= 0 || p2 <= 0) {\n throw new Error(\"Proportions should be greater than 0 and less than 1\")\n }\n var pooled = (p1 * n1 + p2 * n2) / (n1 + n2);\n var se = Math.sqrt(pooled * (1 - pooled) * ((1/n1) + (1/n2)));\n return (p1 - p2) / se;\n}\n\n// Difference of Proportions\njStat.extend(jStat.fn, {\n oneSidedDifferenceOfProportions: function oneSidedDifferenceOfProportions(p1, n1, p2, n2) {\n var z = differenceOfProportions(p1, n1, p2, n2);\n return jStat.ztest(z, 1);\n },\n\n twoSidedDifferenceOfProportions: function twoSidedDifferenceOfProportions(p1, n1, p2, n2) {\n var z = differenceOfProportions(p1, n1, p2, n2);\n return jStat.ztest(z, 2);\n }\n});\n\n}(jStat, Math));\njStat.models = (function(){\n function sub_regress(exog) {\n var var_count = exog[0].length;\n var modelList = jStat.arange(var_count).map(function(endog_index) {\n var exog_index =\n jStat.arange(var_count).filter(function(i){return i!==endog_index});\n return ols(jStat.col(exog, endog_index).map(function(x){ return x[0] }),\n jStat.col(exog, exog_index))\n });\n return modelList;\n }\n\n // do OLS model regress\n // exog have include const columns ,it will not generate it .In fact, exog is\n // \"design matrix\" look at\n //https://en.wikipedia.org/wiki/Design_matrix\n function ols(endog, exog) {\n var nobs = endog.length;\n var df_model = exog[0].length - 1;\n var df_resid = nobs-df_model - 1;\n var coef = jStat.lstsq(exog, endog);\n var predict =\n jStat.multiply(exog, coef.map(function(x) { return [x] }))\n .map(function(p) { return p[0] });\n var resid = jStat.subtract(endog, predict);\n var ybar = jStat.mean(endog);\n // constant cause problem\n // var SST = jStat.sum(endog.map(function(y) {\n // return Math.pow(y-ybar,2);\n // }));\n var SSE = jStat.sum(predict.map(function(f) {\n return Math.pow(f - ybar, 2);\n }));\n var SSR = jStat.sum(endog.map(function(y, i) {\n return Math.pow(y - predict[i], 2);\n }));\n var SST = SSE + SSR;\n var R2 = (SSE / SST);\n return {\n exog:exog,\n endog:endog,\n nobs:nobs,\n df_model:df_model,\n df_resid:df_resid,\n coef:coef,\n predict:predict,\n resid:resid,\n ybar:ybar,\n SST:SST,\n SSE:SSE,\n SSR:SSR,\n R2:R2\n };\n }\n\n // H0: b_I=0\n // H1: b_I!=0\n function t_test(model) {\n var subModelList = sub_regress(model.exog);\n //var sigmaHat=jStat.stdev(model.resid);\n var sigmaHat = Math.sqrt(model.SSR / (model.df_resid));\n var seBetaHat = subModelList.map(function(mod) {\n var SST = mod.SST;\n var R2 = mod.R2;\n return sigmaHat / Math.sqrt(SST * (1 - R2));\n });\n var tStatistic = model.coef.map(function(coef, i) {\n return (coef - 0) / seBetaHat[i];\n });\n var pValue = tStatistic.map(function(t) {\n var leftppf = jStat.studentt.cdf(t, model.df_resid);\n return (leftppf > 0.5 ? 1 - leftppf : leftppf) * 2;\n });\n var c = jStat.studentt.inv(0.975, model.df_resid);\n var interval95 = model.coef.map(function(coef, i) {\n var d = c * seBetaHat[i];\n return [coef - d, coef + d];\n })\n return {\n se: seBetaHat,\n t: tStatistic,\n p: pValue,\n sigmaHat: sigmaHat,\n interval95: interval95\n };\n }\n\n function F_test(model) {\n var F_statistic =\n (model.R2 / model.df_model) / ((1 - model.R2) / model.df_resid);\n var fcdf = function(x, n1, n2) {\n return jStat.beta.cdf(x / (n2 / n1 + x), n1 / 2, n2 / 2)\n }\n var pvalue = 1 - fcdf(F_statistic, model.df_model, model.df_resid);\n return { F_statistic: F_statistic, pvalue: pvalue };\n }\n\n function ols_wrap(endog, exog) {\n var model = ols(endog,exog);\n var ttest = t_test(model);\n var ftest = F_test(model);\n // Provide the Wherry / Ezekiel / McNemar / Cohen Adjusted R^2\n // Which matches the 'adjusted R^2' provided by R's lm package\n var adjust_R2 =\n 1 - (1 - model.R2) * ((model.nobs - 1) / (model.df_resid));\n model.t = ttest;\n model.f = ftest;\n model.adjust_R2 = adjust_R2;\n return model;\n }\n\n return { ols: ols_wrap };\n})();\n//To regress, simply build X matrix\n//(append column of 1's) using\n//buildxmatrix and build the Y\n//matrix using buildymatrix\n//(simply the transpose)\n//and run regress.\n\n\n\n//Regressions\n\njStat.extend({\n buildxmatrix: function buildxmatrix(){\n //Parameters will be passed in as such\n //(array1,array2,array3,...)\n //as (x1,x2,x3,...)\n //needs to be (1,x1,x2,x3,...)\n var matrixRows = new Array(arguments.length);\n for(var i=0;i1){\n result = [];\n for (i = 0; i < A.rows(); i++) {\n result[i] = [];\n for (j = 0; j < B.cols(); j++) {\n sum = 0;\n for (k = 0; k < A.cols(); k++) {\n sum += A.toArray()[i][k] * B.toArray()[k][j];\n }\n result[i][j] = sum;\n }\n }\n return jStat(result);\n }\n result = [];\n for (i = 0; i < A.rows(); i++) {\n result[i] = [];\n for (j = 0; j < B.cols(); j++) {\n sum = 0;\n for (k = 0; k < A.cols(); k++) {\n sum += A.toArray()[i][k] * B.toArray()[j];\n }\n result[i][j] = sum;\n }\n }\n return jStat(result);\n }\n },\n\n //regress and regresst to be fixed\n\n regress: function regress(jMatX,jMatY){\n //print(\"regressin!\");\n //print(jMatX.toArray());\n var innerinv = jStat.xtranspxinv(jMatX);\n //print(innerinv);\n var xtransp = jMatX.transpose();\n var next = jStat.matrixmult(jStat(innerinv),xtransp);\n return jStat.matrixmult(next,jMatY);\n\n },\n\n regresst: function regresst(jMatX,jMatY,sides){\n var beta = jStat.regress(jMatX,jMatY);\n\n var compile = {};\n compile.anova = {};\n var jMatYBar = jStat.jMatYBar(jMatX, beta);\n compile.yBar = jMatYBar;\n var yAverage = jMatY.mean();\n compile.anova.residuals = jStat.residuals(jMatY, jMatYBar);\n\n compile.anova.ssr = jStat.ssr(jMatYBar, yAverage);\n compile.anova.msr = compile.anova.ssr / (jMatX[0].length - 1);\n\n compile.anova.sse = jStat.sse(jMatY, jMatYBar);\n compile.anova.mse =\n compile.anova.sse / (jMatY.length - (jMatX[0].length - 1) - 1);\n\n compile.anova.sst = jStat.sst(jMatY, yAverage);\n compile.anova.mst = compile.anova.sst / (jMatY.length - 1);\n\n compile.anova.r2 = 1 - (compile.anova.sse / compile.anova.sst);\n if (compile.anova.r2 < 0) compile.anova.r2 = 0;\n\n compile.anova.fratio = compile.anova.msr / compile.anova.mse;\n compile.anova.pvalue =\n jStat.anovaftest(compile.anova.fratio,\n jMatX[0].length - 1,\n jMatY.length - (jMatX[0].length - 1) - 1);\n\n compile.anova.rmse = Math.sqrt(compile.anova.mse);\n\n compile.anova.r2adj = 1 - (compile.anova.mse / compile.anova.mst);\n if (compile.anova.r2adj < 0) compile.anova.r2adj = 0;\n\n compile.stats = new Array(jMatX[0].length);\n var covar = jStat.xtranspxinv(jMatX);\n var sds, ts, ps;\n\n for(var i=0; i ReactiveElement;\n\nexport interface ReactionConstructor {\n new (...args: any[]): Reaction;\n}\n\n/**\n * A class mixin which can be applied to lit-element's\n * [ReactiveElement](https://lit.dev/docs/api/ReactiveElement/)\n * derived classes. This mixin adds a mobx reaction which tracks the update method of ReactiveElement.\n *\n * Any observables used in the render template of the element will be tracked by a reaction\n * and cause an update of the element upon change.\n *\n * @param constructor the constructor to extend from to add the mobx reaction, must be derived from ReactiveElement.\n * @param reaction a constructor for the Reaction implementation from mobx, used to provide custom Reactions and\n * makes it easier to handle multiple versions of mobx within a single application.\n */\nexport function MobxReactionUpdateCustom(\n constructor: T,\n ReactionConstructor: ReactionConstructor\n): T {\n return class MobxReactingElement extends constructor {\n // NOTE: using a symbol here to avoid potential name collisions in derived classes\n private [reaction]: Reaction | undefined;\n\n private [cachedRequestUpdate] = () => {\n this.requestUpdate();\n };\n\n public connectedCallback(): void {\n super.connectedCallback();\n const name =\n this.constructor.name /* c8 ignore next */ || this.nodeName;\n this[reaction] = new ReactionConstructor(\n `${name}.update()`,\n this[cachedRequestUpdate]\n );\n if (this.hasUpdated) this.requestUpdate();\n }\n\n public disconnectedCallback(): void {\n super.disconnectedCallback();\n if (this[reaction]) {\n this[reaction]!.dispose();\n this[reaction] = undefined;\n }\n }\n\n protected update(changedProperties: PropertyValues): void {\n if (this[reaction]) {\n this[reaction]!.track(\n super.update.bind(this, changedProperties)\n );\n /* c8 ignore next 4 */\n } else {\n // this should never happen, but just in case\n super.update(changedProperties);\n }\n }\n };\n}\n", "const niceErrors = {\n 0: `Invalid value for configuration 'enforceActions', expected 'never', 'always' or 'observed'`,\n 1(annotationType, key: PropertyKey) {\n return `Cannot apply '${annotationType}' to '${key.toString()}': Field not found.`\n },\n /*\n 2(prop) {\n return `invalid decorator for '${prop.toString()}'`\n },\n 3(prop) {\n return `Cannot decorate '${prop.toString()}': action can only be used on properties with a function value.`\n },\n 4(prop) {\n return `Cannot decorate '${prop.toString()}': computed can only be used on getter properties.`\n },\n */\n 5: \"'keys()' can only be used on observable objects, arrays, sets and maps\",\n 6: \"'values()' can only be used on observable objects, arrays, sets and maps\",\n 7: \"'entries()' can only be used on observable objects, arrays and maps\",\n 8: \"'set()' can only be used on observable objects, arrays and maps\",\n 9: \"'remove()' can only be used on observable objects, arrays and maps\",\n 10: \"'has()' can only be used on observable objects, arrays and maps\",\n 11: \"'get()' can only be used on observable objects, arrays and maps\",\n 12: `Invalid annotation`,\n 13: `Dynamic observable objects cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)`,\n 14: \"Intercept handlers should return nothing or a change object\",\n 15: `Observable arrays cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)`,\n 16: `Modification exception: the internal structure of an observable array was changed.`,\n 17(index, length) {\n return `[mobx.array] Index out of bounds, ${index} is larger than ${length}`\n },\n 18: \"mobx.map requires Map polyfill for the current browser. Check babel-polyfill or core-js/es6/map.js\",\n 19(other) {\n return \"Cannot initialize from classes that inherit from Map: \" + other.constructor.name\n },\n 20(other) {\n return \"Cannot initialize map from \" + other\n },\n 21(dataStructure) {\n return `Cannot convert to map from '${dataStructure}'`\n },\n 22: \"mobx.set requires Set polyfill for the current browser. Check babel-polyfill or core-js/es6/set.js\",\n 23: \"It is not possible to get index atoms from arrays\",\n 24(thing) {\n return \"Cannot obtain administration from \" + thing\n },\n 25(property, name) {\n return `the entry '${property}' does not exist in the observable map '${name}'`\n },\n 26: \"please specify a property\",\n 27(property, name) {\n return `no observable property '${property.toString()}' found on the observable object '${name}'`\n },\n 28(thing) {\n return \"Cannot obtain atom from \" + thing\n },\n 29: \"Expecting some object\",\n 30: \"invalid action stack. did you forget to finish an action?\",\n 31: \"missing option for computed: get\",\n 32(name, derivation) {\n return `Cycle detected in computation ${name}: ${derivation}`\n },\n 33(name) {\n return `The setter of computed value '${name}' is trying to update itself. Did you intend to update an _observable_ value, instead of the computed property?`\n },\n 34(name) {\n return `[ComputedValue '${name}'] It is not possible to assign a new value to a computed value.`\n },\n 35: \"There are multiple, different versions of MobX active. Make sure MobX is loaded only once or use `configure({ isolateGlobalState: true })`\",\n 36: \"isolateGlobalState should be called before MobX is running any reactions\",\n 37(method) {\n return `[mobx] \\`observableArray.${method}()\\` mutates the array in-place, which is not allowed inside a derivation. Use \\`array.slice().${method}()\\` instead`\n },\n 38: \"'ownKeys()' can only be used on observable objects\",\n 39: \"'defineProperty()' can only be used on observable objects\"\n} as const\n\nconst errors: typeof niceErrors = __DEV__ ? niceErrors : ({} as any)\n\nexport function die(error: string | keyof typeof errors, ...args: any[]): never {\n if (__DEV__) {\n let e: any = typeof error === \"string\" ? error : errors[error]\n if (typeof e === \"function\") e = e.apply(null, args as any)\n throw new Error(`[MobX] ${e}`)\n }\n throw new Error(\n typeof error === \"number\"\n ? `[MobX] minified error nr: ${error}${\n args.length ? \" \" + args.map(String).join(\",\") : \"\"\n }. Find the full error at: https://github.com/mobxjs/mobx/blob/main/packages/mobx/src/errors.ts`\n : `[MobX] ${error}`\n )\n}\n", "declare const window: any\ndeclare const self: any\n\nconst mockGlobal = {}\n\nexport function getGlobal() {\n if (typeof globalThis !== \"undefined\") {\n return globalThis\n }\n if (typeof window !== \"undefined\") {\n return window\n }\n if (typeof global !== \"undefined\") {\n return global\n }\n if (typeof self !== \"undefined\") {\n return self\n }\n return mockGlobal\n}\n", "import { globalState, die } from \"../internal\"\n\n// We shorten anything used > 5 times\nexport const assign = Object.assign\nexport const getDescriptor = Object.getOwnPropertyDescriptor\nexport const defineProperty = Object.defineProperty\nexport const objectPrototype = Object.prototype\n\nexport const EMPTY_ARRAY = []\nObject.freeze(EMPTY_ARRAY)\n\nexport const EMPTY_OBJECT = {}\nObject.freeze(EMPTY_OBJECT)\n\nexport interface Lambda {\n (): void\n name?: string\n}\n\nconst hasProxy = typeof Proxy !== \"undefined\"\nconst plainObjectString = Object.toString()\n\nexport function assertProxies() {\n if (!hasProxy) {\n die(\n __DEV__\n ? \"`Proxy` objects are not available in the current environment. Please configure MobX to enable a fallback implementation.`\"\n : \"Proxy not available\"\n )\n }\n}\n\nexport function warnAboutProxyRequirement(msg: string) {\n if (__DEV__ && globalState.verifyProxies) {\n die(\n \"MobX is currently configured to be able to run in ES5 mode, but in ES5 MobX won't be able to \" +\n msg\n )\n }\n}\n\nexport function getNextId() {\n return ++globalState.mobxGuid\n}\n\n/**\n * Makes sure that the provided function is invoked at most once.\n */\nexport function once(func: Lambda): Lambda {\n let invoked = false\n return function () {\n if (invoked) {\n return\n }\n invoked = true\n return (func as any).apply(this, arguments)\n }\n}\n\nexport const noop = () => {}\n\nexport function isFunction(fn: any): fn is Function {\n return typeof fn === \"function\"\n}\n\nexport function isString(value: any): value is string {\n return typeof value === \"string\"\n}\n\nexport function isStringish(value: any): value is string | number | symbol {\n const t = typeof value\n switch (t) {\n case \"string\":\n case \"symbol\":\n case \"number\":\n return true\n }\n return false\n}\n\nexport function isObject(value: any): value is Object {\n return value !== null && typeof value === \"object\"\n}\n\nexport function isPlainObject(value: any) {\n if (!isObject(value)) {\n return false\n }\n const proto = Object.getPrototypeOf(value)\n if (proto == null) {\n return true\n }\n const protoConstructor = Object.hasOwnProperty.call(proto, \"constructor\") && proto.constructor\n return (\n typeof protoConstructor === \"function\" && protoConstructor.toString() === plainObjectString\n )\n}\n\n// https://stackoverflow.com/a/37865170\nexport function isGenerator(obj: any): boolean {\n const constructor = obj?.constructor\n if (!constructor) {\n return false\n }\n if (\n \"GeneratorFunction\" === constructor.name ||\n \"GeneratorFunction\" === constructor.displayName\n ) {\n return true\n }\n return false\n}\n\nexport function addHiddenProp(object: any, propName: PropertyKey, value: any) {\n defineProperty(object, propName, {\n enumerable: false,\n writable: true,\n configurable: true,\n value\n })\n}\n\nexport function addHiddenFinalProp(object: any, propName: PropertyKey, value: any) {\n defineProperty(object, propName, {\n enumerable: false,\n writable: false,\n configurable: true,\n value\n })\n}\n\nexport function createInstanceofPredicate(\n name: string,\n theClass: new (...args: any[]) => T\n): (x: any) => x is T {\n const propName = \"isMobX\" + name\n theClass.prototype[propName] = true\n return function (x) {\n return isObject(x) && x[propName] === true\n } as any\n}\n\nexport function isES6Map(thing: any): thing is Map {\n return thing instanceof Map\n}\n\nexport function isES6Set(thing: any): thing is Set {\n return thing instanceof Set\n}\n\nconst hasGetOwnPropertySymbols = typeof Object.getOwnPropertySymbols !== \"undefined\"\n\n/**\n * Returns the following: own enumerable keys and symbols.\n */\nexport function getPlainObjectKeys(object: any) {\n const keys = Object.keys(object)\n // Not supported in IE, so there are not going to be symbol props anyway...\n if (!hasGetOwnPropertySymbols) {\n return keys\n }\n const symbols = Object.getOwnPropertySymbols(object)\n if (!symbols.length) {\n return keys\n }\n return [...keys, ...symbols.filter(s => objectPrototype.propertyIsEnumerable.call(object, s))]\n}\n\n// From Immer utils\n// Returns all own keys, including non-enumerable and symbolic\nexport const ownKeys: (target: any) => Array =\n typeof Reflect !== \"undefined\" && Reflect.ownKeys\n ? Reflect.ownKeys\n : hasGetOwnPropertySymbols\n ? obj => Object.getOwnPropertyNames(obj).concat(Object.getOwnPropertySymbols(obj) as any)\n : /* istanbul ignore next */ Object.getOwnPropertyNames\n\nexport function stringifyKey(key: any): string {\n if (typeof key === \"string\") {\n return key\n }\n if (typeof key === \"symbol\") {\n return key.toString()\n }\n return new String(key).toString()\n}\n\nexport function toPrimitive(value: any) {\n return value === null ? null : typeof value === \"object\" ? \"\" + value : value\n}\n\nexport function hasProp(target: Object, prop: PropertyKey): boolean {\n return objectPrototype.hasOwnProperty.call(target, prop)\n}\n\n// From Immer utils\nexport const getOwnPropertyDescriptors =\n Object.getOwnPropertyDescriptors ||\n function getOwnPropertyDescriptors(target: any) {\n // Polyfill needed for Hermes and IE, see https://github.com/facebook/hermes/issues/274\n const res: any = {}\n // Note: without polyfill for ownKeys, symbols won't be picked up\n ownKeys(target).forEach(key => {\n res[key] = getDescriptor(target, key)\n })\n return res\n }\n", "import { Annotation, addHiddenProp, AnnotationsMap, hasProp, die, isOverride } from \"../internal\"\n\nimport type { Decorator } from \"../types/decorator_fills\"\n\nexport const storedAnnotationsSymbol = Symbol(\"mobx-stored-annotations\")\n\n/**\n * Creates a function that acts as\n * - decorator\n * - annotation object\n */\nexport function createDecoratorAnnotation(\n annotation: Annotation\n): PropertyDecorator & Annotation & D {\n function decorator(target, property) {\n if (is20223Decorator(property)) {\n return annotation.decorate_20223_(target, property)\n } else {\n storeAnnotation(target, property, annotation)\n }\n }\n return Object.assign(decorator, annotation) as any\n}\n\n/**\n * Stores annotation to prototype,\n * so it can be inspected later by `makeObservable` called from constructor\n */\nexport function storeAnnotation(prototype: any, key: PropertyKey, annotation: Annotation) {\n if (!hasProp(prototype, storedAnnotationsSymbol)) {\n addHiddenProp(prototype, storedAnnotationsSymbol, {\n // Inherit annotations\n ...prototype[storedAnnotationsSymbol]\n })\n }\n // @override must override something\n if (__DEV__ && isOverride(annotation) && !hasProp(prototype[storedAnnotationsSymbol], key)) {\n const fieldName = `${prototype.constructor.name}.prototype.${key.toString()}`\n die(\n `'${fieldName}' is decorated with 'override', ` +\n `but no such decorated member was found on prototype.`\n )\n }\n // Cannot re-decorate\n assertNotDecorated(prototype, annotation, key)\n\n // Ignore override\n if (!isOverride(annotation)) {\n prototype[storedAnnotationsSymbol][key] = annotation\n }\n}\n\nfunction assertNotDecorated(prototype: object, annotation: Annotation, key: PropertyKey) {\n if (__DEV__ && !isOverride(annotation) && hasProp(prototype[storedAnnotationsSymbol], key)) {\n const fieldName = `${prototype.constructor.name}.prototype.${key.toString()}`\n const currentAnnotationType = prototype[storedAnnotationsSymbol][key].annotationType_\n const requestedAnnotationType = annotation.annotationType_\n die(\n `Cannot apply '@${requestedAnnotationType}' to '${fieldName}':` +\n `\\nThe field is already decorated with '@${currentAnnotationType}'.` +\n `\\nRe-decorating fields is not allowed.` +\n `\\nUse '@override' decorator for methods overridden by subclass.`\n )\n }\n}\n\n/**\n * Collects annotations from prototypes and stores them on target (instance)\n */\nexport function collectStoredAnnotations(target): AnnotationsMap {\n if (!hasProp(target, storedAnnotationsSymbol)) {\n // if (__DEV__ && !target[storedAnnotationsSymbol]) {\n // die(\n // `No annotations were passed to makeObservable, but no decorated members have been found either`\n // )\n // }\n // We need a copy as we will remove annotation from the list once it's applied.\n addHiddenProp(target, storedAnnotationsSymbol, { ...target[storedAnnotationsSymbol] })\n }\n return target[storedAnnotationsSymbol]\n}\n\nexport function is20223Decorator(context): context is DecoratorContext {\n return typeof context == \"object\" && typeof context[\"kind\"] == \"string\"\n}\n\nexport function assert20223DecoratorType(\n context: DecoratorContext,\n types: DecoratorContext[\"kind\"][]\n) {\n if (__DEV__ && !types.includes(context.kind)) {\n die(\n `The decorator applied to '${String(context.name)}' cannot be used on a ${\n context.kind\n } element`\n )\n }\n}\n", "import {\n IDerivationState_,\n IObservable,\n IDerivation,\n createInstanceofPredicate,\n endBatch,\n getNextId,\n noop,\n onBecomeObserved,\n onBecomeUnobserved,\n propagateChanged,\n reportObserved,\n startBatch,\n Lambda\n} from \"../internal\"\n\nexport const $mobx = Symbol(\"mobx administration\")\n\nexport interface IAtom extends IObservable {\n reportObserved(): boolean\n reportChanged(): void\n}\n\nexport class Atom implements IAtom {\n isPendingUnobservation_ = false // for effective unobserving. BaseAtom has true, for extra optimization, so its onBecomeUnobserved never gets called, because it's not needed\n isBeingObserved_ = false\n observers_ = new Set()\n\n diffValue_ = 0\n lastAccessedBy_ = 0\n lowestObserverState_ = IDerivationState_.NOT_TRACKING_\n /**\n * Create a new atom. For debugging purposes it is recommended to give it a name.\n * The onBecomeObserved and onBecomeUnobserved callbacks can be used for resource management.\n */\n constructor(public name_ = __DEV__ ? \"Atom@\" + getNextId() : \"Atom\") {}\n\n // onBecomeObservedListeners\n public onBOL: Set | undefined\n // onBecomeUnobservedListeners\n public onBUOL: Set | undefined\n\n public onBO() {\n if (this.onBOL) {\n this.onBOL.forEach(listener => listener())\n }\n }\n\n public onBUO() {\n if (this.onBUOL) {\n this.onBUOL.forEach(listener => listener())\n }\n }\n\n /**\n * Invoke this method to notify mobx that your atom has been used somehow.\n * Returns true if there is currently a reactive context.\n */\n public reportObserved(): boolean {\n return reportObserved(this)\n }\n\n /**\n * Invoke this method _after_ this method has changed to signal mobx that all its observers should invalidate.\n */\n public reportChanged() {\n startBatch()\n propagateChanged(this)\n endBatch()\n }\n\n toString() {\n return this.name_\n }\n}\n\nexport const isAtom = createInstanceofPredicate(\"Atom\", Atom)\n\nexport function createAtom(\n name: string,\n onBecomeObservedHandler: () => void = noop,\n onBecomeUnobservedHandler: () => void = noop\n): IAtom {\n const atom = new Atom(name)\n // default `noop` listener will not initialize the hook Set\n if (onBecomeObservedHandler !== noop) {\n onBecomeObserved(atom, onBecomeObservedHandler)\n }\n\n if (onBecomeUnobservedHandler !== noop) {\n onBecomeUnobserved(atom, onBecomeUnobservedHandler)\n }\n return atom\n}\n", "import { deepEqual } from \"../internal\"\n\nexport interface IEqualsComparer {\n (a: T, b: T): boolean\n}\n\nfunction identityComparer(a: any, b: any): boolean {\n return a === b\n}\n\nfunction structuralComparer(a: any, b: any): boolean {\n return deepEqual(a, b)\n}\n\nfunction shallowComparer(a: any, b: any): boolean {\n return deepEqual(a, b, 1)\n}\n\nfunction defaultComparer(a: any, b: any): boolean {\n if (Object.is) {\n return Object.is(a, b)\n }\n\n return a === b ? a !== 0 || 1 / a === 1 / b : a !== a && b !== b\n}\n\nexport const comparer = {\n identity: identityComparer,\n structural: structuralComparer,\n default: defaultComparer,\n shallow: shallowComparer\n}\n", "import {\n deepEqual,\n isES6Map,\n isES6Set,\n isObservable,\n isObservableArray,\n isObservableMap,\n isObservableSet,\n isObservableObject,\n isPlainObject,\n observable,\n die,\n isAction,\n autoAction,\n flow,\n isFlow,\n isGenerator\n} from \"../internal\"\n\nexport interface IEnhancer {\n (newValue: T, oldValue: T | undefined, name: string): T\n}\n\nexport function deepEnhancer(v, _, name) {\n // it is an observable already, done\n if (isObservable(v)) {\n return v\n }\n\n // something that can be converted and mutated?\n if (Array.isArray(v)) {\n return observable.array(v, { name })\n }\n if (isPlainObject(v)) {\n return observable.object(v, undefined, { name })\n }\n if (isES6Map(v)) {\n return observable.map(v, { name })\n }\n if (isES6Set(v)) {\n return observable.set(v, { name })\n }\n if (typeof v === \"function\" && !isAction(v) && !isFlow(v)) {\n if (isGenerator(v)) {\n return flow(v)\n } else {\n return autoAction(name, v)\n }\n }\n return v\n}\n\nexport function shallowEnhancer(v, _, name): any {\n if (v === undefined || v === null) {\n return v\n }\n if (isObservableObject(v) || isObservableArray(v) || isObservableMap(v) || isObservableSet(v)) {\n return v\n }\n if (Array.isArray(v)) {\n return observable.array(v, { name, deep: false })\n }\n if (isPlainObject(v)) {\n return observable.object(v, undefined, { name, deep: false })\n }\n if (isES6Map(v)) {\n return observable.map(v, { name, deep: false })\n }\n if (isES6Set(v)) {\n return observable.set(v, { name, deep: false })\n }\n\n if (__DEV__) {\n die(\n \"The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets\"\n )\n }\n}\n\nexport function referenceEnhancer(newValue?) {\n // never turn into an observable\n return newValue\n}\n\nexport function refStructEnhancer(v, oldValue): any {\n if (__DEV__ && isObservable(v)) {\n die(`observable.struct should not be used with observable values`)\n }\n if (deepEqual(v, oldValue)) {\n return oldValue\n }\n return v\n}\n", "import {\n die,\n Annotation,\n hasProp,\n createDecoratorAnnotation,\n ObservableObjectAdministration,\n MakeResult\n} from \"../internal\"\n\nimport type { ClassMethodDecorator } from \"./decorator_fills\"\n\nconst OVERRIDE = \"override\"\n\nexport const override: Annotation & PropertyDecorator & ClassMethodDecorator =\n createDecoratorAnnotation({\n annotationType_: OVERRIDE,\n make_,\n extend_,\n decorate_20223_\n })\n\nexport function isOverride(annotation: Annotation): boolean {\n return annotation.annotationType_ === OVERRIDE\n}\n\nfunction make_(this: Annotation, adm: ObservableObjectAdministration, key): MakeResult {\n // Must not be plain object\n if (__DEV__ && adm.isPlainObject_) {\n die(\n `Cannot apply '${this.annotationType_}' to '${adm.name_}.${key.toString()}':` +\n `\\n'${this.annotationType_}' cannot be used on plain objects.`\n )\n }\n // Must override something\n if (__DEV__ && !hasProp(adm.appliedAnnotations_!, key)) {\n die(\n `'${adm.name_}.${key.toString()}' is annotated with '${this.annotationType_}', ` +\n `but no such annotated member was found on prototype.`\n )\n }\n return MakeResult.Cancel\n}\n\nfunction extend_(this: Annotation, adm, key, descriptor, proxyTrap): boolean {\n die(`'${this.annotationType_}' can only be used with 'makeObservable'`)\n}\n\nfunction decorate_20223_(this: Annotation, desc, context: DecoratorContext) {\n console.warn(`'${this.annotationType_}' cannot be used with decorators - this is a no-op`)\n}\n", "import {\n ObservableObjectAdministration,\n createAction,\n isAction,\n defineProperty,\n die,\n isFunction,\n Annotation,\n globalState,\n MakeResult,\n assert20223DecoratorType,\n storeAnnotation\n} from \"../internal\"\n\nexport function createActionAnnotation(name: string, options?: object): Annotation {\n return {\n annotationType_: name,\n options_: options,\n make_,\n extend_,\n decorate_20223_\n }\n}\n\nfunction make_(\n this: Annotation,\n adm: ObservableObjectAdministration,\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n source: object\n): MakeResult {\n // bound\n if (this.options_?.bound) {\n return this.extend_(adm, key, descriptor, false) === null\n ? MakeResult.Cancel\n : MakeResult.Break\n }\n // own\n if (source === adm.target_) {\n return this.extend_(adm, key, descriptor, false) === null\n ? MakeResult.Cancel\n : MakeResult.Continue\n }\n // prototype\n if (isAction(descriptor.value)) {\n // A prototype could have been annotated already by other constructor,\n // rest of the proto chain must be annotated already\n return MakeResult.Break\n }\n const actionDescriptor = createActionDescriptor(adm, this, key, descriptor, false)\n defineProperty(source, key, actionDescriptor)\n return MakeResult.Continue\n}\n\nfunction extend_(\n this: Annotation,\n adm: ObservableObjectAdministration,\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n proxyTrap: boolean\n): boolean | null {\n const actionDescriptor = createActionDescriptor(adm, this, key, descriptor)\n return adm.defineProperty_(key, actionDescriptor, proxyTrap)\n}\n\nfunction decorate_20223_(this: Annotation, mthd, context: DecoratorContext) {\n if (__DEV__) {\n assert20223DecoratorType(context, [\"method\", \"field\"])\n }\n const { kind, name, addInitializer } = context\n const ann = this\n\n const _createAction = m =>\n createAction(ann.options_?.name ?? name!.toString(), m, ann.options_?.autoAction ?? false)\n\n // Backwards/Legacy behavior, expects makeObservable(this)\n if (kind == \"field\") {\n addInitializer(function () {\n storeAnnotation(this, name, ann)\n })\n return\n }\n\n if (kind == \"method\") {\n if (!isAction(mthd)) {\n mthd = _createAction(mthd)\n }\n\n if (this.options_?.bound) {\n addInitializer(function () {\n const self = this as any\n const bound = self[name].bind(self)\n bound.isMobxAction = true\n self[name] = bound\n })\n }\n\n return mthd\n }\n\n die(\n `Cannot apply '${ann.annotationType_}' to '${String(name)}' (kind: ${kind}):` +\n `\\n'${ann.annotationType_}' can only be used on properties with a function value.`\n )\n}\n\nfunction assertActionDescriptor(\n adm: ObservableObjectAdministration,\n { annotationType_ }: Annotation,\n key: PropertyKey,\n { value }: PropertyDescriptor\n) {\n if (__DEV__ && !isFunction(value)) {\n die(\n `Cannot apply '${annotationType_}' to '${adm.name_}.${key.toString()}':` +\n `\\n'${annotationType_}' can only be used on properties with a function value.`\n )\n }\n}\n\nexport function createActionDescriptor(\n adm: ObservableObjectAdministration,\n annotation: Annotation,\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n // provides ability to disable safeDescriptors for prototypes\n safeDescriptors: boolean = globalState.safeDescriptors\n) {\n assertActionDescriptor(adm, annotation, key, descriptor)\n let { value } = descriptor\n if (annotation.options_?.bound) {\n value = value.bind(adm.proxy_ ?? adm.target_)\n }\n return {\n value: createAction(\n annotation.options_?.name ?? key.toString(),\n value,\n annotation.options_?.autoAction ?? false,\n // https://github.com/mobxjs/mobx/discussions/3140\n annotation.options_?.bound ? adm.proxy_ ?? adm.target_ : undefined\n ),\n // Non-configurable for classes\n // prevents accidental field redefinition in subclass\n configurable: safeDescriptors ? adm.isPlainObject_ : true,\n // https://github.com/mobxjs/mobx/pull/2641#issuecomment-737292058\n enumerable: false,\n // Non-obsevable, therefore non-writable\n // Also prevents rewriting in subclass constructor\n writable: safeDescriptors ? false : true\n }\n}\n", "import {\n ObservableObjectAdministration,\n Annotation,\n defineProperty,\n die,\n flow,\n isFlow,\n isFunction,\n globalState,\n MakeResult,\n hasProp,\n assert20223DecoratorType\n} from \"../internal\"\n\nexport function createFlowAnnotation(name: string, options?: object): Annotation {\n return {\n annotationType_: name,\n options_: options,\n make_,\n extend_,\n decorate_20223_\n }\n}\n\nfunction make_(\n this: Annotation,\n adm: ObservableObjectAdministration,\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n source: object\n): MakeResult {\n // own\n if (source === adm.target_) {\n return this.extend_(adm, key, descriptor, false) === null\n ? MakeResult.Cancel\n : MakeResult.Continue\n }\n // prototype\n // bound - must annotate protos to support super.flow()\n if (this.options_?.bound && (!hasProp(adm.target_, key) || !isFlow(adm.target_[key]))) {\n if (this.extend_(adm, key, descriptor, false) === null) {\n return MakeResult.Cancel\n }\n }\n if (isFlow(descriptor.value)) {\n // A prototype could have been annotated already by other constructor,\n // rest of the proto chain must be annotated already\n return MakeResult.Break\n }\n const flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, false, false)\n defineProperty(source, key, flowDescriptor)\n return MakeResult.Continue\n}\n\nfunction extend_(\n this: Annotation,\n adm: ObservableObjectAdministration,\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n proxyTrap: boolean\n): boolean | null {\n const flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, this.options_?.bound)\n return adm.defineProperty_(key, flowDescriptor, proxyTrap)\n}\n\nfunction decorate_20223_(this: Annotation, mthd, context: ClassMethodDecoratorContext) {\n if (__DEV__) {\n assert20223DecoratorType(context, [\"method\"])\n }\n const { name, addInitializer } = context\n\n if (!isFlow(mthd)) {\n mthd = flow(mthd)\n }\n\n if (this.options_?.bound) {\n addInitializer(function () {\n const self = this as any\n const bound = self[name].bind(self)\n bound.isMobXFlow = true\n self[name] = bound\n })\n }\n\n return mthd\n}\n\nfunction assertFlowDescriptor(\n adm: ObservableObjectAdministration,\n { annotationType_ }: Annotation,\n key: PropertyKey,\n { value }: PropertyDescriptor\n) {\n if (__DEV__ && !isFunction(value)) {\n die(\n `Cannot apply '${annotationType_}' to '${adm.name_}.${key.toString()}':` +\n `\\n'${annotationType_}' can only be used on properties with a generator function value.`\n )\n }\n}\n\nfunction createFlowDescriptor(\n adm: ObservableObjectAdministration,\n annotation: Annotation,\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n bound: boolean,\n // provides ability to disable safeDescriptors for prototypes\n safeDescriptors: boolean = globalState.safeDescriptors\n): PropertyDescriptor {\n assertFlowDescriptor(adm, annotation, key, descriptor)\n let { value } = descriptor\n // In case of flow.bound, the descriptor can be from already annotated prototype\n if (!isFlow(value)) {\n value = flow(value)\n }\n if (bound) {\n // We do not keep original function around, so we bind the existing flow\n value = value.bind(adm.proxy_ ?? adm.target_)\n // This is normally set by `flow`, but `bind` returns new function...\n value.isMobXFlow = true\n }\n return {\n value,\n // Non-configurable for classes\n // prevents accidental field redefinition in subclass\n configurable: safeDescriptors ? adm.isPlainObject_ : true,\n // https://github.com/mobxjs/mobx/pull/2641#issuecomment-737292058\n enumerable: false,\n // Non-obsevable, therefore non-writable\n // Also prevents rewriting in subclass constructor\n writable: safeDescriptors ? false : true\n }\n}\n", "import {\n ObservableObjectAdministration,\n die,\n Annotation,\n MakeResult,\n assert20223DecoratorType,\n $mobx,\n asObservableObject,\n ComputedValue\n} from \"../internal\"\n\nexport function createComputedAnnotation(name: string, options?: object): Annotation {\n return {\n annotationType_: name,\n options_: options,\n make_,\n extend_,\n decorate_20223_\n }\n}\n\nfunction make_(\n this: Annotation,\n adm: ObservableObjectAdministration,\n key: PropertyKey,\n descriptor: PropertyDescriptor\n): MakeResult {\n return this.extend_(adm, key, descriptor, false) === null ? MakeResult.Cancel : MakeResult.Break\n}\n\nfunction extend_(\n this: Annotation,\n adm: ObservableObjectAdministration,\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n proxyTrap: boolean\n): boolean | null {\n assertComputedDescriptor(adm, this, key, descriptor)\n return adm.defineComputedProperty_(\n key,\n {\n ...this.options_,\n get: descriptor.get,\n set: descriptor.set\n },\n proxyTrap\n )\n}\n\nfunction decorate_20223_(this: Annotation, get, context: ClassGetterDecoratorContext) {\n if (__DEV__) {\n assert20223DecoratorType(context, [\"getter\"])\n }\n const ann = this\n const { name: key, addInitializer } = context\n\n addInitializer(function () {\n const adm: ObservableObjectAdministration = asObservableObject(this)[$mobx]\n const options = {\n ...ann.options_,\n get,\n context: this\n }\n options.name ||= __DEV__\n ? `${adm.name_}.${key.toString()}`\n : `ObservableObject.${key.toString()}`\n adm.values_.set(key, new ComputedValue(options))\n })\n\n return function () {\n return this[$mobx].getObservablePropValue_(key)\n }\n}\n\nfunction assertComputedDescriptor(\n adm: ObservableObjectAdministration,\n { annotationType_ }: Annotation,\n key: PropertyKey,\n { get }: PropertyDescriptor\n) {\n if (__DEV__ && !get) {\n die(\n `Cannot apply '${annotationType_}' to '${adm.name_}.${key.toString()}':` +\n `\\n'${annotationType_}' can only be used on getter(+setter) properties.`\n )\n }\n}\n", "import {\n ObservableObjectAdministration,\n deepEnhancer,\n die,\n Annotation,\n MakeResult,\n assert20223DecoratorType,\n ObservableValue,\n asObservableObject,\n $mobx\n} from \"../internal\"\n\nexport function createObservableAnnotation(name: string, options?: object): Annotation {\n return {\n annotationType_: name,\n options_: options,\n make_,\n extend_,\n decorate_20223_\n }\n}\n\nfunction make_(\n this: Annotation,\n adm: ObservableObjectAdministration,\n key: PropertyKey,\n descriptor: PropertyDescriptor\n): MakeResult {\n return this.extend_(adm, key, descriptor, false) === null ? MakeResult.Cancel : MakeResult.Break\n}\n\nfunction extend_(\n this: Annotation,\n adm: ObservableObjectAdministration,\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n proxyTrap: boolean\n): boolean | null {\n assertObservableDescriptor(adm, this, key, descriptor)\n return adm.defineObservableProperty_(\n key,\n descriptor.value,\n this.options_?.enhancer ?? deepEnhancer,\n proxyTrap\n )\n}\n\nfunction decorate_20223_(\n this: Annotation,\n desc,\n context: ClassAccessorDecoratorContext | ClassFieldDecoratorContext\n) {\n if (__DEV__) {\n if (context.kind === \"field\") {\n throw die(\n `Please use \\`@observable accessor ${String(\n context.name\n )}\\` instead of \\`@observable ${String(context.name)}\\``\n )\n }\n assert20223DecoratorType(context, [\"accessor\"])\n }\n\n const ann = this\n const { kind, name } = context\n\n // The laziness here is not ideal... It's a workaround to how 2022.3 Decorators are implemented:\n // `addInitializer` callbacks are executed _before_ any accessors are defined (instead of the ideal-for-us right after each).\n // This means that, if we were to do our stuff in an `addInitializer`, we'd attempt to read a private slot\n // before it has been initialized. The runtime doesn't like that and throws a `Cannot read private member\n // from an object whose class did not declare it` error.\n // TODO: it seems that this will not be required anymore in the final version of the spec\n // See TODO: link\n const initializedObjects = new WeakSet()\n\n function initializeObservable(target, value) {\n const adm: ObservableObjectAdministration = asObservableObject(target)[$mobx]\n const observable = new ObservableValue(\n value,\n ann.options_?.enhancer ?? deepEnhancer,\n __DEV__ ? `${adm.name_}.${name.toString()}` : `ObservableObject.${name.toString()}`,\n false\n )\n adm.values_.set(name, observable)\n initializedObjects.add(target)\n }\n\n if (kind == \"accessor\") {\n return {\n get() {\n if (!initializedObjects.has(this)) {\n initializeObservable(this, desc.get.call(this))\n }\n return this[$mobx].getObservablePropValue_(name)\n },\n set(value) {\n if (!initializedObjects.has(this)) {\n initializeObservable(this, value)\n }\n return this[$mobx].setObservablePropValue_(name, value)\n },\n init(value) {\n if (!initializedObjects.has(this)) {\n initializeObservable(this, value)\n }\n return value\n }\n }\n }\n\n return\n}\n\nfunction assertObservableDescriptor(\n adm: ObservableObjectAdministration,\n { annotationType_ }: Annotation,\n key: PropertyKey,\n descriptor: PropertyDescriptor\n) {\n if (__DEV__ && !(\"value\" in descriptor)) {\n die(\n `Cannot apply '${annotationType_}' to '${adm.name_}.${key.toString()}':` +\n `\\n'${annotationType_}' cannot be used on getter/setter properties`\n )\n }\n}\n", "import {\n ObservableObjectAdministration,\n observable,\n Annotation,\n defineProperty,\n createAction,\n globalState,\n flow,\n computed,\n autoAction,\n isGenerator,\n MakeResult,\n die\n} from \"../internal\"\n\nconst AUTO = \"true\"\n\nexport const autoAnnotation: Annotation = createAutoAnnotation()\n\nexport function createAutoAnnotation(options?: object): Annotation {\n return {\n annotationType_: AUTO,\n options_: options,\n make_,\n extend_,\n decorate_20223_\n }\n}\n\nfunction make_(\n adm: ObservableObjectAdministration,\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n source: object\n): MakeResult {\n // getter -> computed\n if (descriptor.get) {\n return computed.make_(adm, key, descriptor, source)\n }\n // lone setter -> action setter\n if (descriptor.set) {\n // TODO make action applicable to setter and delegate to action.make_\n const set = createAction(key.toString(), descriptor.set) as (v: any) => void\n // own\n if (source === adm.target_) {\n return adm.defineProperty_(key, {\n configurable: globalState.safeDescriptors ? adm.isPlainObject_ : true,\n set\n }) === null\n ? MakeResult.Cancel\n : MakeResult.Continue\n }\n // proto\n defineProperty(source, key, {\n configurable: true,\n set\n })\n return MakeResult.Continue\n }\n // function on proto -> autoAction/flow\n if (source !== adm.target_ && typeof descriptor.value === \"function\") {\n if (isGenerator(descriptor.value)) {\n const flowAnnotation = this.options_?.autoBind ? flow.bound : flow\n return flowAnnotation.make_(adm, key, descriptor, source)\n }\n const actionAnnotation = this.options_?.autoBind ? autoAction.bound : autoAction\n return actionAnnotation.make_(adm, key, descriptor, source)\n }\n // other -> observable\n // Copy props from proto as well, see test:\n // \"decorate should work with Object.create\"\n let observableAnnotation = this.options_?.deep === false ? observable.ref : observable\n // if function respect autoBind option\n if (typeof descriptor.value === \"function\" && this.options_?.autoBind) {\n descriptor.value = descriptor.value.bind(adm.proxy_ ?? adm.target_)\n }\n return observableAnnotation.make_(adm, key, descriptor, source)\n}\n\nfunction extend_(\n adm: ObservableObjectAdministration,\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n proxyTrap: boolean\n): boolean | null {\n // getter -> computed\n if (descriptor.get) {\n return computed.extend_(adm, key, descriptor, proxyTrap)\n }\n // lone setter -> action setter\n if (descriptor.set) {\n // TODO make action applicable to setter and delegate to action.extend_\n return adm.defineProperty_(\n key,\n {\n configurable: globalState.safeDescriptors ? adm.isPlainObject_ : true,\n set: createAction(key.toString(), descriptor.set) as (v: any) => void\n },\n proxyTrap\n )\n }\n // other -> observable\n // if function respect autoBind option\n if (typeof descriptor.value === \"function\" && this.options_?.autoBind) {\n descriptor.value = descriptor.value.bind(adm.proxy_ ?? adm.target_)\n }\n let observableAnnotation = this.options_?.deep === false ? observable.ref : observable\n return observableAnnotation.extend_(adm, key, descriptor, proxyTrap)\n}\n\nfunction decorate_20223_(this: Annotation, desc, context: ClassGetterDecoratorContext) {\n die(`'${this.annotationType_}' cannot be used as a decorator`)\n}\n", "import {\n IEnhancer,\n IEqualsComparer,\n IObservableArray,\n IObservableMapInitialValues,\n IObservableSetInitialValues,\n IObservableValue,\n ObservableMap,\n ObservableSet,\n ObservableValue,\n asDynamicObservableObject,\n createObservableArray,\n deepEnhancer,\n extendObservable,\n isES6Map,\n isES6Set,\n isObservable,\n isPlainObject,\n referenceEnhancer,\n Annotation,\n shallowEnhancer,\n refStructEnhancer,\n AnnotationsMap,\n asObservableObject,\n storeAnnotation,\n createDecoratorAnnotation,\n createLegacyArray,\n globalState,\n assign,\n isStringish,\n createObservableAnnotation,\n createAutoAnnotation,\n is20223Decorator,\n initObservable\n} from \"../internal\"\n\nimport type { ClassAccessorDecorator, ClassFieldDecorator } from \"../types/decorator_fills\"\n\nexport const OBSERVABLE = \"observable\"\nexport const OBSERVABLE_REF = \"observable.ref\"\nexport const OBSERVABLE_SHALLOW = \"observable.shallow\"\nexport const OBSERVABLE_STRUCT = \"observable.struct\"\n\nexport type CreateObservableOptions = {\n name?: string\n equals?: IEqualsComparer\n deep?: boolean\n defaultDecorator?: Annotation\n proxy?: boolean\n autoBind?: boolean\n}\n\n// Predefined bags of create observable options, to avoid allocating temporarily option objects\n// in the majority of cases\nexport const defaultCreateObservableOptions: CreateObservableOptions = {\n deep: true,\n name: undefined,\n defaultDecorator: undefined,\n proxy: true\n}\nObject.freeze(defaultCreateObservableOptions)\n\nexport function asCreateObservableOptions(thing: any): CreateObservableOptions {\n return thing || defaultCreateObservableOptions\n}\n\nconst observableAnnotation = createObservableAnnotation(OBSERVABLE)\nconst observableRefAnnotation = createObservableAnnotation(OBSERVABLE_REF, {\n enhancer: referenceEnhancer\n})\nconst observableShallowAnnotation = createObservableAnnotation(OBSERVABLE_SHALLOW, {\n enhancer: shallowEnhancer\n})\nconst observableStructAnnotation = createObservableAnnotation(OBSERVABLE_STRUCT, {\n enhancer: refStructEnhancer\n})\nconst observableDecoratorAnnotation =\n createDecoratorAnnotation(observableAnnotation)\n\nexport function getEnhancerFromOptions(options: CreateObservableOptions): IEnhancer {\n return options.deep === true\n ? deepEnhancer\n : options.deep === false\n ? referenceEnhancer\n : getEnhancerFromAnnotation(options.defaultDecorator)\n}\n\nexport function getAnnotationFromOptions(\n options?: CreateObservableOptions\n): Annotation | undefined {\n return options ? options.defaultDecorator ?? createAutoAnnotation(options) : undefined\n}\n\nexport function getEnhancerFromAnnotation(annotation?: Annotation): IEnhancer {\n return !annotation ? deepEnhancer : annotation.options_?.enhancer ?? deepEnhancer\n}\n\n/**\n * Turns an object, array or function into a reactive structure.\n * @param v the value which should become observable.\n */\nfunction createObservable(v: any, arg2?: any, arg3?: any) {\n // @observable someProp; (2022.3 Decorators)\n if (is20223Decorator(arg2)) {\n return observableAnnotation.decorate_20223_(v, arg2)\n }\n\n // @observable someProp;\n if (isStringish(arg2)) {\n storeAnnotation(v, arg2, observableAnnotation)\n return\n }\n\n // already observable - ignore\n if (isObservable(v)) {\n return v\n }\n\n // plain object\n if (isPlainObject(v)) {\n return observable.object(v, arg2, arg3)\n }\n\n // Array\n if (Array.isArray(v)) {\n return observable.array(v, arg2)\n }\n\n // Map\n if (isES6Map(v)) {\n return observable.map(v, arg2)\n }\n\n // Set\n if (isES6Set(v)) {\n return observable.set(v, arg2)\n }\n\n // other object - ignore\n if (typeof v === \"object\" && v !== null) {\n return v\n }\n\n // anything else\n return observable.box(v, arg2)\n}\nassign(createObservable, observableDecoratorAnnotation)\n\nexport interface IObservableValueFactory {\n (value: T, options?: CreateObservableOptions): IObservableValue\n (value?: T, options?: CreateObservableOptions): IObservableValue\n}\n\nexport interface IObservableFactory\n extends Annotation,\n PropertyDecorator,\n ClassAccessorDecorator,\n ClassFieldDecorator {\n // TODO: remove ClassFieldDecorator, this is only temporarily support for legacy decorators\n (value: T[], options?: CreateObservableOptions): IObservableArray\n (value: Set, options?: CreateObservableOptions): ObservableSet\n (value: Map, options?: CreateObservableOptions): ObservableMap\n (\n value: T,\n decorators?: AnnotationsMap,\n options?: CreateObservableOptions\n ): T\n\n box: IObservableValueFactory\n array: (initialValues?: T[], options?: CreateObservableOptions) => IObservableArray\n set: (\n initialValues?: IObservableSetInitialValues,\n options?: CreateObservableOptions\n ) => ObservableSet\n map: (\n initialValues?: IObservableMapInitialValues,\n options?: CreateObservableOptions\n ) => ObservableMap\n object: (\n props: T,\n decorators?: AnnotationsMap,\n options?: CreateObservableOptions\n ) => T\n\n /**\n * Decorator that creates an observable that only observes the references, but doesn't try to turn the assigned value into an observable.ts.\n */\n ref: Annotation & PropertyDecorator & ClassAccessorDecorator & ClassFieldDecorator\n /**\n * Decorator that creates an observable converts its value (objects, maps or arrays) into a shallow observable structure\n */\n shallow: Annotation & PropertyDecorator & ClassAccessorDecorator & ClassFieldDecorator\n deep: Annotation & PropertyDecorator & ClassAccessorDecorator & ClassFieldDecorator\n struct: Annotation & PropertyDecorator & ClassAccessorDecorator & ClassFieldDecorator\n}\n\nconst observableFactories: IObservableFactory = {\n box(value: T, options?: CreateObservableOptions): IObservableValue {\n const o = asCreateObservableOptions(options)\n return new ObservableValue(value, getEnhancerFromOptions(o), o.name, true, o.equals)\n },\n array(initialValues?: T[], options?: CreateObservableOptions): IObservableArray {\n const o = asCreateObservableOptions(options)\n return (\n globalState.useProxies === false || o.proxy === false\n ? createLegacyArray\n : createObservableArray\n )(initialValues, getEnhancerFromOptions(o), o.name)\n },\n map(\n initialValues?: IObservableMapInitialValues,\n options?: CreateObservableOptions\n ): ObservableMap {\n const o = asCreateObservableOptions(options)\n return new ObservableMap(initialValues, getEnhancerFromOptions(o), o.name)\n },\n set(\n initialValues?: IObservableSetInitialValues,\n options?: CreateObservableOptions\n ): ObservableSet {\n const o = asCreateObservableOptions(options)\n return new ObservableSet(initialValues, getEnhancerFromOptions(o), o.name)\n },\n object(\n props: T,\n decorators?: AnnotationsMap,\n options?: CreateObservableOptions\n ): T {\n return initObservable(() =>\n extendObservable(\n globalState.useProxies === false || options?.proxy === false\n ? asObservableObject({}, options)\n : asDynamicObservableObject({}, options),\n props,\n decorators\n )\n )\n },\n ref: createDecoratorAnnotation(observableRefAnnotation),\n shallow: createDecoratorAnnotation(observableShallowAnnotation),\n deep: observableDecoratorAnnotation,\n struct: createDecoratorAnnotation(observableStructAnnotation)\n} as any\n\n// eslint-disable-next-line\nexport var observable: IObservableFactory = assign(createObservable, observableFactories)\n", "import {\n ComputedValue,\n IComputedValueOptions,\n Annotation,\n storeAnnotation,\n createDecoratorAnnotation,\n isStringish,\n isPlainObject,\n isFunction,\n die,\n IComputedValue,\n createComputedAnnotation,\n comparer,\n is20223Decorator\n} from \"../internal\"\n\nimport type { ClassGetterDecorator } from \"../types/decorator_fills\"\n\nexport const COMPUTED = \"computed\"\nexport const COMPUTED_STRUCT = \"computed.struct\"\n\nexport interface IComputedFactory extends Annotation, PropertyDecorator, ClassGetterDecorator {\n // @computed(opts)\n (options: IComputedValueOptions): Annotation & PropertyDecorator & ClassGetterDecorator\n // computed(fn, opts)\n (func: () => T, options?: IComputedValueOptions): IComputedValue\n\n struct: Annotation & PropertyDecorator & ClassGetterDecorator\n}\n\nconst computedAnnotation = createComputedAnnotation(COMPUTED)\nconst computedStructAnnotation = createComputedAnnotation(COMPUTED_STRUCT, {\n equals: comparer.structural\n})\n\n/**\n * Decorator for class properties: @computed get value() { return expr; }.\n * For legacy purposes also invokable as ES5 observable created: `computed(() => expr)`;\n */\nexport const computed: IComputedFactory = function computed(arg1, arg2) {\n if (is20223Decorator(arg2)) {\n // @computed (2022.3 Decorators)\n return computedAnnotation.decorate_20223_(arg1, arg2)\n }\n if (isStringish(arg2)) {\n // @computed\n return storeAnnotation(arg1, arg2, computedAnnotation)\n }\n if (isPlainObject(arg1)) {\n // @computed({ options })\n return createDecoratorAnnotation(createComputedAnnotation(COMPUTED, arg1))\n }\n\n // computed(expr, options?)\n if (__DEV__) {\n if (!isFunction(arg1)) {\n die(\"First argument to `computed` should be an expression.\")\n }\n if (isFunction(arg2)) {\n die(\n \"A setter as second argument is no longer supported, use `{ set: fn }` option instead\"\n )\n }\n }\n const opts: IComputedValueOptions = isPlainObject(arg2) ? arg2 : {}\n opts.get = arg1\n opts.name ||= arg1.name || \"\" /* for generated name */\n\n return new ComputedValue(opts)\n} as any\n\nObject.assign(computed, computedAnnotation)\n\ncomputed.struct = createDecoratorAnnotation(computedStructAnnotation)\n", "import {\n IDerivation,\n endBatch,\n globalState,\n isSpyEnabled,\n spyReportEnd,\n spyReportStart,\n startBatch,\n untrackedEnd,\n untrackedStart,\n isFunction,\n allowStateReadsStart,\n allowStateReadsEnd,\n ACTION,\n EMPTY_ARRAY,\n die,\n getDescriptor,\n defineProperty\n} from \"../internal\"\n\n// we don't use globalState for these in order to avoid possible issues with multiple\n// mobx versions\nlet currentActionId = 0\nlet nextActionId = 1\nconst isFunctionNameConfigurable = getDescriptor(() => {}, \"name\")?.configurable ?? false\n\n// we can safely recycle this object\nconst tmpNameDescriptor: PropertyDescriptor = {\n value: \"action\",\n configurable: true,\n writable: false,\n enumerable: false\n}\n\nexport function createAction(\n actionName: string,\n fn: Function,\n autoAction: boolean = false,\n ref?: Object\n): Function {\n if (__DEV__) {\n if (!isFunction(fn)) {\n die(\"`action` can only be invoked on functions\")\n }\n if (typeof actionName !== \"string\" || !actionName) {\n die(`actions should have valid names, got: '${actionName}'`)\n }\n }\n function res() {\n return executeAction(actionName, autoAction, fn, ref || this, arguments)\n }\n res.isMobxAction = true\n res.toString = () => fn.toString()\n if (isFunctionNameConfigurable) {\n tmpNameDescriptor.value = actionName\n defineProperty(res, \"name\", tmpNameDescriptor)\n }\n return res\n}\n\nexport function executeAction(\n actionName: string,\n canRunAsDerivation: boolean,\n fn: Function,\n scope?: any,\n args?: IArguments\n) {\n const runInfo = _startAction(actionName, canRunAsDerivation, scope, args)\n try {\n return fn.apply(scope, args)\n } catch (err) {\n runInfo.error_ = err\n throw err\n } finally {\n _endAction(runInfo)\n }\n}\n\nexport interface IActionRunInfo {\n prevDerivation_: IDerivation | null\n prevAllowStateChanges_: boolean\n prevAllowStateReads_: boolean\n notifySpy_: boolean\n startTime_: number\n error_?: any\n parentActionId_: number\n actionId_: number\n runAsAction_?: boolean\n}\n\nexport function _startAction(\n actionName: string,\n canRunAsDerivation: boolean, // true for autoAction\n scope: any,\n args?: IArguments\n): IActionRunInfo {\n const notifySpy_ = __DEV__ && isSpyEnabled() && !!actionName\n let startTime_: number = 0\n if (__DEV__ && notifySpy_) {\n startTime_ = Date.now()\n const flattenedArgs = args ? Array.from(args) : EMPTY_ARRAY\n spyReportStart({\n type: ACTION,\n name: actionName,\n object: scope,\n arguments: flattenedArgs\n })\n }\n const prevDerivation_ = globalState.trackingDerivation\n const runAsAction = !canRunAsDerivation || !prevDerivation_\n startBatch()\n let prevAllowStateChanges_ = globalState.allowStateChanges // by default preserve previous allow\n if (runAsAction) {\n untrackedStart()\n prevAllowStateChanges_ = allowStateChangesStart(true)\n }\n const prevAllowStateReads_ = allowStateReadsStart(true)\n const runInfo = {\n runAsAction_: runAsAction,\n prevDerivation_,\n prevAllowStateChanges_,\n prevAllowStateReads_,\n notifySpy_,\n startTime_,\n actionId_: nextActionId++,\n parentActionId_: currentActionId\n }\n currentActionId = runInfo.actionId_\n return runInfo\n}\n\nexport function _endAction(runInfo: IActionRunInfo) {\n if (currentActionId !== runInfo.actionId_) {\n die(30)\n }\n currentActionId = runInfo.parentActionId_\n\n if (runInfo.error_ !== undefined) {\n globalState.suppressReactionErrors = true\n }\n allowStateChangesEnd(runInfo.prevAllowStateChanges_)\n allowStateReadsEnd(runInfo.prevAllowStateReads_)\n endBatch()\n if (runInfo.runAsAction_) {\n untrackedEnd(runInfo.prevDerivation_)\n }\n if (__DEV__ && runInfo.notifySpy_) {\n spyReportEnd({ time: Date.now() - runInfo.startTime_ })\n }\n globalState.suppressReactionErrors = false\n}\n\nexport function allowStateChanges(allowStateChanges: boolean, func: () => T): T {\n const prev = allowStateChangesStart(allowStateChanges)\n try {\n return func()\n } finally {\n allowStateChangesEnd(prev)\n }\n}\n\nexport function allowStateChangesStart(allowStateChanges: boolean) {\n const prev = globalState.allowStateChanges\n globalState.allowStateChanges = allowStateChanges\n return prev\n}\n\nexport function allowStateChangesEnd(prev: boolean) {\n globalState.allowStateChanges = prev\n}\n", "import {\n Atom,\n IEnhancer,\n IInterceptable,\n IEqualsComparer,\n IInterceptor,\n IListenable,\n Lambda,\n checkIfStateModificationsAreAllowed,\n comparer,\n createInstanceofPredicate,\n getNextId,\n hasInterceptors,\n hasListeners,\n interceptChange,\n isSpyEnabled,\n notifyListeners,\n registerInterceptor,\n registerListener,\n spyReport,\n spyReportEnd,\n spyReportStart,\n toPrimitive,\n globalState,\n IUNCHANGED,\n UPDATE\n} from \"../internal\"\n\nexport interface IValueWillChange {\n object: IObservableValue\n type: \"update\"\n newValue: T\n}\n\nexport type IValueDidChange = {\n type: \"update\"\n observableKind: \"value\"\n object: IObservableValue\n debugObjectName: string\n newValue: T\n oldValue: T | undefined\n}\nexport type IBoxDidChange =\n | {\n type: \"create\"\n observableKind: \"value\"\n object: IObservableValue\n debugObjectName: string\n newValue: T\n }\n | IValueDidChange\n\nexport interface IObservableValue {\n get(): T\n set(value: T): void\n}\n\nconst CREATE = \"create\"\n\nexport class ObservableValue\n extends Atom\n implements IObservableValue, IInterceptable>, IListenable\n{\n hasUnreportedChange_ = false\n interceptors_\n changeListeners_\n value_\n dehancer: any\n\n constructor(\n value: T,\n public enhancer: IEnhancer,\n public name_ = __DEV__ ? \"ObservableValue@\" + getNextId() : \"ObservableValue\",\n notifySpy = true,\n private equals: IEqualsComparer = comparer.default\n ) {\n super(name_)\n this.value_ = enhancer(value, undefined, name_)\n if (__DEV__ && notifySpy && isSpyEnabled()) {\n // only notify spy if this is a stand-alone observable\n spyReport({\n type: CREATE,\n object: this,\n observableKind: \"value\",\n debugObjectName: this.name_,\n newValue: \"\" + this.value_\n })\n }\n }\n\n private dehanceValue(value: T): T {\n if (this.dehancer !== undefined) {\n return this.dehancer(value)\n }\n return value\n }\n\n public set(newValue: T) {\n const oldValue = this.value_\n newValue = this.prepareNewValue_(newValue) as any\n if (newValue !== globalState.UNCHANGED) {\n const notifySpy = isSpyEnabled()\n if (__DEV__ && notifySpy) {\n spyReportStart({\n type: UPDATE,\n object: this,\n observableKind: \"value\",\n debugObjectName: this.name_,\n newValue,\n oldValue\n })\n }\n this.setNewValue_(newValue)\n if (__DEV__ && notifySpy) {\n spyReportEnd()\n }\n }\n }\n\n private prepareNewValue_(newValue): T | IUNCHANGED {\n checkIfStateModificationsAreAllowed(this)\n if (hasInterceptors(this)) {\n const change = interceptChange>(this, {\n object: this,\n type: UPDATE,\n newValue\n })\n if (!change) {\n return globalState.UNCHANGED\n }\n newValue = change.newValue\n }\n // apply modifier\n newValue = this.enhancer(newValue, this.value_, this.name_)\n return this.equals(this.value_, newValue) ? globalState.UNCHANGED : newValue\n }\n\n setNewValue_(newValue: T) {\n const oldValue = this.value_\n this.value_ = newValue\n this.reportChanged()\n if (hasListeners(this)) {\n notifyListeners(this, {\n type: UPDATE,\n object: this,\n newValue,\n oldValue\n })\n }\n }\n\n public get(): T {\n this.reportObserved()\n return this.dehanceValue(this.value_)\n }\n\n intercept_(handler: IInterceptor>): Lambda {\n return registerInterceptor(this, handler)\n }\n\n observe_(listener: (change: IValueDidChange) => void, fireImmediately?: boolean): Lambda {\n if (fireImmediately) {\n listener({\n observableKind: \"value\",\n debugObjectName: this.name_,\n object: this,\n type: UPDATE,\n newValue: this.value_,\n oldValue: undefined\n })\n }\n return registerListener(this, listener)\n }\n\n raw() {\n // used by MST ot get undehanced value\n return this.value_\n }\n\n toJSON() {\n return this.get()\n }\n\n toString() {\n return `${this.name_}[${this.value_}]`\n }\n\n valueOf(): T {\n return toPrimitive(this.get())\n }\n\n [Symbol.toPrimitive]() {\n return this.valueOf()\n }\n}\n\nexport const isObservableValue = createInstanceofPredicate(\"ObservableValue\", ObservableValue) as (\n x: any\n) => x is IObservableValue\n", "import {\n CaughtException,\n IDerivation,\n IDerivationState_,\n IEqualsComparer,\n IObservable,\n Lambda,\n TraceMode,\n autorun,\n clearObserving,\n comparer,\n createAction,\n createInstanceofPredicate,\n endBatch,\n getNextId,\n globalState,\n isCaughtException,\n isSpyEnabled,\n propagateChangeConfirmed,\n propagateMaybeChanged,\n reportObserved,\n shouldCompute,\n spyReport,\n startBatch,\n toPrimitive,\n trackDerivedFunction,\n untrackedEnd,\n untrackedStart,\n UPDATE,\n die,\n allowStateChangesStart,\n allowStateChangesEnd\n} from \"../internal\"\n\nexport interface IComputedValue {\n get(): T\n set(value: T): void\n}\n\nexport interface IComputedValueOptions {\n get?: () => T\n set?: (value: T) => void\n name?: string\n equals?: IEqualsComparer\n context?: any\n requiresReaction?: boolean\n keepAlive?: boolean\n}\n\nexport type IComputedDidChange = {\n type: \"update\"\n observableKind: \"computed\"\n object: unknown\n debugObjectName: string\n newValue: T\n oldValue: T | undefined\n}\n\n/**\n * A node in the state dependency root that observes other nodes, and can be observed itself.\n *\n * ComputedValue will remember the result of the computation for the duration of the batch, or\n * while being observed.\n *\n * During this time it will recompute only when one of its direct dependencies changed,\n * but only when it is being accessed with `ComputedValue.get()`.\n *\n * Implementation description:\n * 1. First time it's being accessed it will compute and remember result\n * give back remembered result until 2. happens\n * 2. First time any deep dependency change, propagate POSSIBLY_STALE to all observers, wait for 3.\n * 3. When it's being accessed, recompute if any shallow dependency changed.\n * if result changed: propagate STALE to all observers, that were POSSIBLY_STALE from the last step.\n * go to step 2. either way\n *\n * If at any point it's outside batch and it isn't observed: reset everything and go to 1.\n */\nexport class ComputedValue implements IObservable, IComputedValue, IDerivation {\n dependenciesState_ = IDerivationState_.NOT_TRACKING_\n observing_: IObservable[] = [] // nodes we are looking at. Our value depends on these nodes\n newObserving_ = null // during tracking it's an array with new observed observers\n isBeingObserved_ = false\n isPendingUnobservation_: boolean = false\n observers_ = new Set()\n diffValue_ = 0\n runId_ = 0\n lastAccessedBy_ = 0\n lowestObserverState_ = IDerivationState_.UP_TO_DATE_\n unboundDepsCount_ = 0\n protected value_: T | undefined | CaughtException = new CaughtException(null)\n name_: string\n triggeredBy_?: string\n isComputing_: boolean = false // to check for cycles\n isRunningSetter_: boolean = false\n derivation: () => T // N.B: unminified as it is used by MST\n setter_?: (value: T) => void\n isTracing_: TraceMode = TraceMode.NONE\n scope_: Object | undefined\n private equals_: IEqualsComparer\n private requiresReaction_: boolean | undefined\n keepAlive_: boolean\n\n /**\n * Create a new computed value based on a function expression.\n *\n * The `name` property is for debug purposes only.\n *\n * The `equals` property specifies the comparer function to use to determine if a newly produced\n * value differs from the previous value. Two comparers are provided in the library; `defaultComparer`\n * compares based on identity comparison (===), and `structuralComparer` deeply compares the structure.\n * Structural comparison can be convenient if you always produce a new aggregated object and\n * don't want to notify observers if it is structurally the same.\n * This is useful for working with vectors, mouse coordinates etc.\n */\n constructor(options: IComputedValueOptions) {\n if (!options.get) {\n die(31)\n }\n this.derivation = options.get!\n this.name_ = options.name || (__DEV__ ? \"ComputedValue@\" + getNextId() : \"ComputedValue\")\n if (options.set) {\n this.setter_ = createAction(\n __DEV__ ? this.name_ + \"-setter\" : \"ComputedValue-setter\",\n options.set\n ) as any\n }\n this.equals_ =\n options.equals ||\n ((options as any).compareStructural || (options as any).struct\n ? comparer.structural\n : comparer.default)\n this.scope_ = options.context\n this.requiresReaction_ = options.requiresReaction\n this.keepAlive_ = !!options.keepAlive\n }\n\n onBecomeStale_() {\n propagateMaybeChanged(this)\n }\n\n public onBOL: Set | undefined\n public onBUOL: Set | undefined\n\n public onBO() {\n if (this.onBOL) {\n this.onBOL.forEach(listener => listener())\n }\n }\n\n public onBUO() {\n if (this.onBUOL) {\n this.onBUOL.forEach(listener => listener())\n }\n }\n\n /**\n * Returns the current value of this computed value.\n * Will evaluate its computation first if needed.\n */\n public get(): T {\n if (this.isComputing_) {\n die(32, this.name_, this.derivation)\n }\n if (\n globalState.inBatch === 0 &&\n // !globalState.trackingDerivatpion &&\n this.observers_.size === 0 &&\n !this.keepAlive_\n ) {\n if (shouldCompute(this)) {\n this.warnAboutUntrackedRead_()\n startBatch() // See perf test 'computed memoization'\n this.value_ = this.computeValue_(false)\n endBatch()\n }\n } else {\n reportObserved(this)\n if (shouldCompute(this)) {\n let prevTrackingContext = globalState.trackingContext\n if (this.keepAlive_ && !prevTrackingContext) {\n globalState.trackingContext = this\n }\n if (this.trackAndCompute()) {\n propagateChangeConfirmed(this)\n }\n globalState.trackingContext = prevTrackingContext\n }\n }\n const result = this.value_!\n\n if (isCaughtException(result)) {\n throw result.cause\n }\n return result\n }\n\n public set(value: T) {\n if (this.setter_) {\n if (this.isRunningSetter_) {\n die(33, this.name_)\n }\n this.isRunningSetter_ = true\n try {\n this.setter_.call(this.scope_, value)\n } finally {\n this.isRunningSetter_ = false\n }\n } else {\n die(34, this.name_)\n }\n }\n\n trackAndCompute(): boolean {\n // N.B: unminified as it is used by MST\n const oldValue = this.value_\n const wasSuspended =\n /* see #1208 */ this.dependenciesState_ === IDerivationState_.NOT_TRACKING_\n const newValue = this.computeValue_(true)\n\n const changed =\n wasSuspended ||\n isCaughtException(oldValue) ||\n isCaughtException(newValue) ||\n !this.equals_(oldValue, newValue)\n\n if (changed) {\n this.value_ = newValue\n\n if (__DEV__ && isSpyEnabled()) {\n spyReport({\n observableKind: \"computed\",\n debugObjectName: this.name_,\n object: this.scope_,\n type: \"update\",\n oldValue,\n newValue\n } as IComputedDidChange)\n }\n }\n\n return changed\n }\n\n computeValue_(track: boolean) {\n this.isComputing_ = true\n // don't allow state changes during computation\n const prev = allowStateChangesStart(false)\n let res: T | CaughtException\n if (track) {\n res = trackDerivedFunction(this, this.derivation, this.scope_)\n } else {\n if (globalState.disableErrorBoundaries === true) {\n res = this.derivation.call(this.scope_)\n } else {\n try {\n res = this.derivation.call(this.scope_)\n } catch (e) {\n res = new CaughtException(e)\n }\n }\n }\n allowStateChangesEnd(prev)\n this.isComputing_ = false\n return res\n }\n\n suspend_() {\n if (!this.keepAlive_) {\n clearObserving(this)\n this.value_ = undefined // don't hold on to computed value!\n if (__DEV__ && this.isTracing_ !== TraceMode.NONE) {\n console.log(\n `[mobx.trace] Computed value '${this.name_}' was suspended and it will recompute on the next access.`\n )\n }\n }\n }\n\n observe_(listener: (change: IComputedDidChange) => void, fireImmediately?: boolean): Lambda {\n let firstTime = true\n let prevValue: T | undefined = undefined\n return autorun(() => {\n // TODO: why is this in a different place than the spyReport() function? in all other observables it's called in the same place\n let newValue = this.get()\n if (!firstTime || fireImmediately) {\n const prevU = untrackedStart()\n listener({\n observableKind: \"computed\",\n debugObjectName: this.name_,\n type: UPDATE,\n object: this,\n newValue,\n oldValue: prevValue\n })\n untrackedEnd(prevU)\n }\n firstTime = false\n prevValue = newValue\n })\n }\n\n warnAboutUntrackedRead_() {\n if (!__DEV__) {\n return\n }\n if (this.isTracing_ !== TraceMode.NONE) {\n console.log(\n `[mobx.trace] Computed value '${this.name_}' is being read outside a reactive context. Doing a full recompute.`\n )\n }\n if (\n typeof this.requiresReaction_ === \"boolean\"\n ? this.requiresReaction_\n : globalState.computedRequiresReaction\n ) {\n console.warn(\n `[mobx] Computed value '${this.name_}' is being read outside a reactive context. Doing a full recompute.`\n )\n }\n }\n\n toString() {\n return `${this.name_}[${this.derivation.toString()}]`\n }\n\n valueOf(): T {\n return toPrimitive(this.get())\n }\n\n [Symbol.toPrimitive]() {\n return this.valueOf()\n }\n}\n\nexport const isComputedValue = createInstanceofPredicate(\"ComputedValue\", ComputedValue)\n", "import {\n IAtom,\n IDepTreeNode,\n IObservable,\n addObserver,\n globalState,\n isComputedValue,\n removeObserver\n} from \"../internal\"\n\nexport enum IDerivationState_ {\n // before being run or (outside batch and not being observed)\n // at this point derivation is not holding any data about dependency tree\n NOT_TRACKING_ = -1,\n // no shallow dependency changed since last computation\n // won't recalculate derivation\n // this is what makes mobx fast\n UP_TO_DATE_ = 0,\n // some deep dependency changed, but don't know if shallow dependency changed\n // will require to check first if UP_TO_DATE or POSSIBLY_STALE\n // currently only ComputedValue will propagate POSSIBLY_STALE\n //\n // having this state is second big optimization:\n // don't have to recompute on every dependency change, but only when it's needed\n POSSIBLY_STALE_ = 1,\n // A shallow dependency has changed since last computation and the derivation\n // will need to recompute when it's needed next.\n STALE_ = 2\n}\n\nexport enum TraceMode {\n NONE,\n LOG,\n BREAK\n}\n\n/**\n * A derivation is everything that can be derived from the state (all the atoms) in a pure manner.\n * See https://medium.com/@mweststrate/becoming-fully-reactive-an-in-depth-explanation-of-mobservable-55995262a254#.xvbh6qd74\n */\nexport interface IDerivation extends IDepTreeNode {\n observing_: IObservable[]\n newObserving_: null | IObservable[]\n dependenciesState_: IDerivationState_\n /**\n * Id of the current run of a derivation. Each time the derivation is tracked\n * this number is increased by one. This number is globally unique\n */\n runId_: number\n /**\n * amount of dependencies used by the derivation in this run, which has not been bound yet.\n */\n unboundDepsCount_: number\n onBecomeStale_(): void\n isTracing_: TraceMode\n\n /**\n * warn if the derivation has no dependencies after creation/update\n */\n requiresObservable_?: boolean\n}\n\nexport class CaughtException {\n constructor(public cause: any) {\n // Empty\n }\n}\n\nexport function isCaughtException(e: any): e is CaughtException {\n return e instanceof CaughtException\n}\n\n/**\n * Finds out whether any dependency of the derivation has actually changed.\n * If dependenciesState is 1 then it will recalculate dependencies,\n * if any dependency changed it will propagate it by changing dependenciesState to 2.\n *\n * By iterating over the dependencies in the same order that they were reported and\n * stopping on the first change, all the recalculations are only called for ComputedValues\n * that will be tracked by derivation. That is because we assume that if the first x\n * dependencies of the derivation doesn't change then the derivation should run the same way\n * up until accessing x-th dependency.\n */\nexport function shouldCompute(derivation: IDerivation): boolean {\n switch (derivation.dependenciesState_) {\n case IDerivationState_.UP_TO_DATE_:\n return false\n case IDerivationState_.NOT_TRACKING_:\n case IDerivationState_.STALE_:\n return true\n case IDerivationState_.POSSIBLY_STALE_: {\n // state propagation can occur outside of action/reactive context #2195\n const prevAllowStateReads = allowStateReadsStart(true)\n const prevUntracked = untrackedStart() // no need for those computeds to be reported, they will be picked up in trackDerivedFunction.\n const obs = derivation.observing_,\n l = obs.length\n for (let i = 0; i < l; i++) {\n const obj = obs[i]\n if (isComputedValue(obj)) {\n if (globalState.disableErrorBoundaries) {\n obj.get()\n } else {\n try {\n obj.get()\n } catch (e) {\n // we are not interested in the value *or* exception at this moment, but if there is one, notify all\n untrackedEnd(prevUntracked)\n allowStateReadsEnd(prevAllowStateReads)\n return true\n }\n }\n // if ComputedValue `obj` actually changed it will be computed and propagated to its observers.\n // and `derivation` is an observer of `obj`\n // invariantShouldCompute(derivation)\n if ((derivation.dependenciesState_ as any) === IDerivationState_.STALE_) {\n untrackedEnd(prevUntracked)\n allowStateReadsEnd(prevAllowStateReads)\n return true\n }\n }\n }\n changeDependenciesStateTo0(derivation)\n untrackedEnd(prevUntracked)\n allowStateReadsEnd(prevAllowStateReads)\n return false\n }\n }\n}\n\nexport function isComputingDerivation() {\n return globalState.trackingDerivation !== null // filter out actions inside computations\n}\n\nexport function checkIfStateModificationsAreAllowed(atom: IAtom) {\n if (!__DEV__) {\n return\n }\n const hasObservers = atom.observers_.size > 0\n // Should not be possible to change observed state outside strict mode, except during initialization, see #563\n if (\n !globalState.allowStateChanges &&\n (hasObservers || globalState.enforceActions === \"always\")\n ) {\n console.warn(\n \"[MobX] \" +\n (globalState.enforceActions\n ? \"Since strict-mode is enabled, changing (observed) observable values without using an action is not allowed. Tried to modify: \"\n : \"Side effects like changing state are not allowed at this point. Are you trying to modify state from, for example, a computed value or the render function of a React component? You can wrap side effects in 'runInAction' (or decorate functions with 'action') if needed. Tried to modify: \") +\n atom.name_\n )\n }\n}\n\nexport function checkIfStateReadsAreAllowed(observable: IObservable) {\n if (__DEV__ && !globalState.allowStateReads && globalState.observableRequiresReaction) {\n console.warn(\n `[mobx] Observable '${observable.name_}' being read outside a reactive context.`\n )\n }\n}\n\n/**\n * Executes the provided function `f` and tracks which observables are being accessed.\n * The tracking information is stored on the `derivation` object and the derivation is registered\n * as observer of any of the accessed observables.\n */\nexport function trackDerivedFunction(derivation: IDerivation, f: () => T, context: any) {\n const prevAllowStateReads = allowStateReadsStart(true)\n changeDependenciesStateTo0(derivation)\n // Preallocate array; will be trimmed by bindDependencies.\n derivation.newObserving_ = new Array(\n // Reserve constant space for initial dependencies, dynamic space otherwise.\n // See https://github.com/mobxjs/mobx/pull/3833\n derivation.runId_ === 0 ? 100 : derivation.observing_.length\n )\n derivation.unboundDepsCount_ = 0\n derivation.runId_ = ++globalState.runId\n const prevTracking = globalState.trackingDerivation\n globalState.trackingDerivation = derivation\n globalState.inBatch++\n let result\n if (globalState.disableErrorBoundaries === true) {\n result = f.call(context)\n } else {\n try {\n result = f.call(context)\n } catch (e) {\n result = new CaughtException(e)\n }\n }\n globalState.inBatch--\n globalState.trackingDerivation = prevTracking\n bindDependencies(derivation)\n\n warnAboutDerivationWithoutDependencies(derivation)\n allowStateReadsEnd(prevAllowStateReads)\n return result\n}\n\nfunction warnAboutDerivationWithoutDependencies(derivation: IDerivation) {\n if (!__DEV__) {\n return\n }\n\n if (derivation.observing_.length !== 0) {\n return\n }\n\n if (\n typeof derivation.requiresObservable_ === \"boolean\"\n ? derivation.requiresObservable_\n : globalState.reactionRequiresObservable\n ) {\n console.warn(\n `[mobx] Derivation '${derivation.name_}' is created/updated without reading any observable value.`\n )\n }\n}\n\n/**\n * diffs newObserving with observing.\n * update observing to be newObserving with unique observables\n * notify observers that become observed/unobserved\n */\nfunction bindDependencies(derivation: IDerivation) {\n // invariant(derivation.dependenciesState !== IDerivationState.NOT_TRACKING, \"INTERNAL ERROR bindDependencies expects derivation.dependenciesState !== -1\");\n const prevObserving = derivation.observing_\n const observing = (derivation.observing_ = derivation.newObserving_!)\n let lowestNewObservingDerivationState = IDerivationState_.UP_TO_DATE_\n\n // Go through all new observables and check diffValue: (this list can contain duplicates):\n // 0: first occurrence, change to 1 and keep it\n // 1: extra occurrence, drop it\n let i0 = 0,\n l = derivation.unboundDepsCount_\n for (let i = 0; i < l; i++) {\n const dep = observing[i]\n if (dep.diffValue_ === 0) {\n dep.diffValue_ = 1\n if (i0 !== i) {\n observing[i0] = dep\n }\n i0++\n }\n\n // Upcast is 'safe' here, because if dep is IObservable, `dependenciesState` will be undefined,\n // not hitting the condition\n if ((dep as any as IDerivation).dependenciesState_ > lowestNewObservingDerivationState) {\n lowestNewObservingDerivationState = (dep as any as IDerivation).dependenciesState_\n }\n }\n observing.length = i0\n\n derivation.newObserving_ = null // newObserving shouldn't be needed outside tracking (statement moved down to work around FF bug, see #614)\n\n // Go through all old observables and check diffValue: (it is unique after last bindDependencies)\n // 0: it's not in new observables, unobserve it\n // 1: it keeps being observed, don't want to notify it. change to 0\n l = prevObserving.length\n while (l--) {\n const dep = prevObserving[l]\n if (dep.diffValue_ === 0) {\n removeObserver(dep, derivation)\n }\n dep.diffValue_ = 0\n }\n\n // Go through all new observables and check diffValue: (now it should be unique)\n // 0: it was set to 0 in last loop. don't need to do anything.\n // 1: it wasn't observed, let's observe it. set back to 0\n while (i0--) {\n const dep = observing[i0]\n if (dep.diffValue_ === 1) {\n dep.diffValue_ = 0\n addObserver(dep, derivation)\n }\n }\n\n // Some new observed derivations may become stale during this derivation computation\n // so they have had no chance to propagate staleness (#916)\n if (lowestNewObservingDerivationState !== IDerivationState_.UP_TO_DATE_) {\n derivation.dependenciesState_ = lowestNewObservingDerivationState\n derivation.onBecomeStale_()\n }\n}\n\nexport function clearObserving(derivation: IDerivation) {\n // invariant(globalState.inBatch > 0, \"INTERNAL ERROR clearObserving should be called only inside batch\");\n const obs = derivation.observing_\n derivation.observing_ = []\n let i = obs.length\n while (i--) {\n removeObserver(obs[i], derivation)\n }\n\n derivation.dependenciesState_ = IDerivationState_.NOT_TRACKING_\n}\n\nexport function untracked(action: () => T): T {\n const prev = untrackedStart()\n try {\n return action()\n } finally {\n untrackedEnd(prev)\n }\n}\n\nexport function untrackedStart(): IDerivation | null {\n const prev = globalState.trackingDerivation\n globalState.trackingDerivation = null\n return prev\n}\n\nexport function untrackedEnd(prev: IDerivation | null) {\n globalState.trackingDerivation = prev\n}\n\nexport function allowStateReadsStart(allowStateReads: boolean) {\n const prev = globalState.allowStateReads\n globalState.allowStateReads = allowStateReads\n return prev\n}\n\nexport function allowStateReadsEnd(prev: boolean) {\n globalState.allowStateReads = prev\n}\n\n/**\n * needed to keep `lowestObserverState` correct. when changing from (2 or 1) to 0\n *\n */\nexport function changeDependenciesStateTo0(derivation: IDerivation) {\n if (derivation.dependenciesState_ === IDerivationState_.UP_TO_DATE_) {\n return\n }\n derivation.dependenciesState_ = IDerivationState_.UP_TO_DATE_\n\n const obs = derivation.observing_\n let i = obs.length\n while (i--) {\n obs[i].lowestObserverState_ = IDerivationState_.UP_TO_DATE_\n }\n}\n", "import { IDerivation, IObservable, Reaction, die, getGlobal } from \"../internal\"\nimport { ComputedValue } from \"./computedvalue\"\n\n/**\n * These values will persist if global state is reset\n */\nconst persistentKeys: (keyof MobXGlobals)[] = [\n \"mobxGuid\",\n \"spyListeners\",\n \"enforceActions\",\n \"computedRequiresReaction\",\n \"reactionRequiresObservable\",\n \"observableRequiresReaction\",\n \"allowStateReads\",\n \"disableErrorBoundaries\",\n \"runId\",\n \"UNCHANGED\",\n \"useProxies\"\n]\n\nexport type IUNCHANGED = {}\n\nexport class MobXGlobals {\n /**\n * MobXGlobals version.\n * MobX compatiblity with other versions loaded in memory as long as this version matches.\n * It indicates that the global state still stores similar information\n *\n * N.B: this version is unrelated to the package version of MobX, and is only the version of the\n * internal state storage of MobX, and can be the same across many different package versions\n */\n version = 6\n\n /**\n * globally unique token to signal unchanged\n */\n UNCHANGED: IUNCHANGED = {}\n\n /**\n * Currently running derivation\n */\n trackingDerivation: IDerivation | null = null\n\n /**\n * Currently running reaction. This determines if we currently have a reactive context.\n * (Tracking derivation is also set for temporal tracking of computed values inside actions,\n * but trackingReaction can only be set by a form of Reaction)\n */\n trackingContext: Reaction | ComputedValue | null = null\n\n /**\n * Each time a derivation is tracked, it is assigned a unique run-id\n */\n runId = 0\n\n /**\n * 'guid' for general purpose. Will be persisted amongst resets.\n */\n mobxGuid = 0\n\n /**\n * Are we in a batch block? (and how many of them)\n */\n inBatch: number = 0\n\n /**\n * Observables that don't have observers anymore, and are about to be\n * suspended, unless somebody else accesses it in the same batch\n *\n * @type {IObservable[]}\n */\n pendingUnobservations: IObservable[] = []\n\n /**\n * List of scheduled, not yet executed, reactions.\n */\n pendingReactions: Reaction[] = []\n\n /**\n * Are we currently processing reactions?\n */\n isRunningReactions = false\n\n /**\n * Is it allowed to change observables at this point?\n * In general, MobX doesn't allow that when running computations and React.render.\n * To ensure that those functions stay pure.\n */\n allowStateChanges = false\n\n /**\n * Is it allowed to read observables at this point?\n * Used to hold the state needed for `observableRequiresReaction`\n */\n allowStateReads = true\n\n /**\n * If strict mode is enabled, state changes are by default not allowed\n */\n enforceActions: boolean | \"always\" = true\n\n /**\n * Spy callbacks\n */\n spyListeners: { (change: any): void }[] = []\n\n /**\n * Globally attached error handlers that react specifically to errors in reactions\n */\n globalReactionErrorHandlers: ((error: any, derivation: IDerivation) => void)[] = []\n\n /**\n * Warn if computed values are accessed outside a reactive context\n */\n computedRequiresReaction = false\n\n /**\n * (Experimental)\n * Warn if you try to create to derivation / reactive context without accessing any observable.\n */\n reactionRequiresObservable = false\n\n /**\n * (Experimental)\n * Warn if observables are accessed outside a reactive context\n */\n observableRequiresReaction = false\n\n /*\n * Don't catch and rethrow exceptions. This is useful for inspecting the state of\n * the stack when an exception occurs while debugging.\n */\n disableErrorBoundaries = false\n\n /*\n * If true, we are already handling an exception in an action. Any errors in reactions should be suppressed, as\n * they are not the cause, see: https://github.com/mobxjs/mobx/issues/1836\n */\n suppressReactionErrors = false\n\n useProxies = true\n /*\n * print warnings about code that would fail if proxies weren't available\n */\n verifyProxies = false\n\n /**\n * False forces all object's descriptors to\n * writable: true\n * configurable: true\n */\n safeDescriptors = true\n}\n\nlet canMergeGlobalState = true\nlet isolateCalled = false\n\nexport let globalState: MobXGlobals = (function () {\n let global = getGlobal()\n if (global.__mobxInstanceCount > 0 && !global.__mobxGlobals) {\n canMergeGlobalState = false\n }\n if (global.__mobxGlobals && global.__mobxGlobals.version !== new MobXGlobals().version) {\n canMergeGlobalState = false\n }\n\n if (!canMergeGlobalState) {\n // Because this is a IIFE we need to let isolateCalled a chance to change\n // so we run it after the event loop completed at least 1 iteration\n setTimeout(() => {\n if (!isolateCalled) {\n die(35)\n }\n }, 1)\n return new MobXGlobals()\n } else if (global.__mobxGlobals) {\n global.__mobxInstanceCount += 1\n if (!global.__mobxGlobals.UNCHANGED) {\n global.__mobxGlobals.UNCHANGED = {}\n } // make merge backward compatible\n return global.__mobxGlobals\n } else {\n global.__mobxInstanceCount = 1\n return (global.__mobxGlobals = new MobXGlobals())\n }\n})()\n\nexport function isolateGlobalState() {\n if (\n globalState.pendingReactions.length ||\n globalState.inBatch ||\n globalState.isRunningReactions\n ) {\n die(36)\n }\n isolateCalled = true\n if (canMergeGlobalState) {\n let global = getGlobal()\n if (--global.__mobxInstanceCount === 0) {\n global.__mobxGlobals = undefined\n }\n globalState = new MobXGlobals()\n }\n}\n\nexport function getGlobalState(): any {\n return globalState\n}\n\n/**\n * For testing purposes only; this will break the internal state of existing observables,\n * but can be used to get back at a stable state after throwing errors\n */\nexport function resetGlobalState() {\n const defaultGlobals = new MobXGlobals()\n for (let key in defaultGlobals) {\n if (persistentKeys.indexOf(key as any) === -1) {\n globalState[key] = defaultGlobals[key]\n }\n }\n globalState.allowStateChanges = !globalState.enforceActions\n}\n", "import {\n Lambda,\n ComputedValue,\n IDependencyTree,\n IDerivation,\n IDerivationState_,\n TraceMode,\n getDependencyTree,\n globalState,\n runReactions,\n checkIfStateReadsAreAllowed\n} from \"../internal\"\n\nexport interface IDepTreeNode {\n name_: string\n observing_?: IObservable[]\n}\n\nexport interface IObservable extends IDepTreeNode {\n diffValue_: number\n /**\n * Id of the derivation *run* that last accessed this observable.\n * If this id equals the *run* id of the current derivation,\n * the dependency is already established\n */\n lastAccessedBy_: number\n isBeingObserved_: boolean\n\n lowestObserverState_: IDerivationState_ // Used to avoid redundant propagations\n isPendingUnobservation_: boolean // Used to push itself to global.pendingUnobservations at most once per batch.\n\n observers_: Set\n\n onBUO(): void\n onBO(): void\n\n onBUOL: Set | undefined\n onBOL: Set | undefined\n}\n\nexport function hasObservers(observable: IObservable): boolean {\n return observable.observers_ && observable.observers_.size > 0\n}\n\nexport function getObservers(observable: IObservable): Set {\n return observable.observers_\n}\n\n// function invariantObservers(observable: IObservable) {\n// const list = observable.observers\n// const map = observable.observersIndexes\n// const l = list.length\n// for (let i = 0; i < l; i++) {\n// const id = list[i].__mapid\n// if (i) {\n// invariant(map[id] === i, \"INTERNAL ERROR maps derivation.__mapid to index in list\") // for performance\n// } else {\n// invariant(!(id in map), \"INTERNAL ERROR observer on index 0 shouldn't be held in map.\") // for performance\n// }\n// }\n// invariant(\n// list.length === 0 || Object.keys(map).length === list.length - 1,\n// \"INTERNAL ERROR there is no junk in map\"\n// )\n// }\nexport function addObserver(observable: IObservable, node: IDerivation) {\n // invariant(node.dependenciesState !== -1, \"INTERNAL ERROR, can add only dependenciesState !== -1\");\n // invariant(observable._observers.indexOf(node) === -1, \"INTERNAL ERROR add already added node\");\n // invariantObservers(observable);\n\n observable.observers_.add(node)\n if (observable.lowestObserverState_ > node.dependenciesState_) {\n observable.lowestObserverState_ = node.dependenciesState_\n }\n\n // invariantObservers(observable);\n // invariant(observable._observers.indexOf(node) !== -1, \"INTERNAL ERROR didn't add node\");\n}\n\nexport function removeObserver(observable: IObservable, node: IDerivation) {\n // invariant(globalState.inBatch > 0, \"INTERNAL ERROR, remove should be called only inside batch\");\n // invariant(observable._observers.indexOf(node) !== -1, \"INTERNAL ERROR remove already removed node\");\n // invariantObservers(observable);\n observable.observers_.delete(node)\n if (observable.observers_.size === 0) {\n // deleting last observer\n queueForUnobservation(observable)\n }\n // invariantObservers(observable);\n // invariant(observable._observers.indexOf(node) === -1, \"INTERNAL ERROR remove already removed node2\");\n}\n\nexport function queueForUnobservation(observable: IObservable) {\n if (observable.isPendingUnobservation_ === false) {\n // invariant(observable._observers.length === 0, \"INTERNAL ERROR, should only queue for unobservation unobserved observables\");\n observable.isPendingUnobservation_ = true\n globalState.pendingUnobservations.push(observable)\n }\n}\n\n/**\n * Batch starts a transaction, at least for purposes of memoizing ComputedValues when nothing else does.\n * During a batch `onBecomeUnobserved` will be called at most once per observable.\n * Avoids unnecessary recalculations.\n */\nexport function startBatch() {\n globalState.inBatch++\n}\n\nexport function endBatch() {\n if (--globalState.inBatch === 0) {\n runReactions()\n // the batch is actually about to finish, all unobserving should happen here.\n const list = globalState.pendingUnobservations\n for (let i = 0; i < list.length; i++) {\n const observable = list[i]\n observable.isPendingUnobservation_ = false\n if (observable.observers_.size === 0) {\n if (observable.isBeingObserved_) {\n // if this observable had reactive observers, trigger the hooks\n observable.isBeingObserved_ = false\n observable.onBUO()\n }\n if (observable instanceof ComputedValue) {\n // computed values are automatically teared down when the last observer leaves\n // this process happens recursively, this computed might be the last observabe of another, etc..\n observable.suspend_()\n }\n }\n }\n globalState.pendingUnobservations = []\n }\n}\n\nexport function reportObserved(observable: IObservable): boolean {\n checkIfStateReadsAreAllowed(observable)\n\n const derivation = globalState.trackingDerivation\n if (derivation !== null) {\n /**\n * Simple optimization, give each derivation run an unique id (runId)\n * Check if last time this observable was accessed the same runId is used\n * if this is the case, the relation is already known\n */\n if (derivation.runId_ !== observable.lastAccessedBy_) {\n observable.lastAccessedBy_ = derivation.runId_\n // Tried storing newObserving, or observing, or both as Set, but performance didn't come close...\n derivation.newObserving_![derivation.unboundDepsCount_++] = observable\n if (!observable.isBeingObserved_ && globalState.trackingContext) {\n observable.isBeingObserved_ = true\n observable.onBO()\n }\n }\n return observable.isBeingObserved_\n } else if (observable.observers_.size === 0 && globalState.inBatch > 0) {\n queueForUnobservation(observable)\n }\n\n return false\n}\n\n// function invariantLOS(observable: IObservable, msg: string) {\n// // it's expensive so better not run it in produciton. but temporarily helpful for testing\n// const min = getObservers(observable).reduce((a, b) => Math.min(a, b.dependenciesState), 2)\n// if (min >= observable.lowestObserverState) return // <- the only assumption about `lowestObserverState`\n// throw new Error(\n// \"lowestObserverState is wrong for \" +\n// msg +\n// \" because \" +\n// min +\n// \" < \" +\n// observable.lowestObserverState\n// )\n// }\n\n/**\n * NOTE: current propagation mechanism will in case of self reruning autoruns behave unexpectedly\n * It will propagate changes to observers from previous run\n * It's hard or maybe impossible (with reasonable perf) to get it right with current approach\n * Hopefully self reruning autoruns aren't a feature people should depend on\n * Also most basic use cases should be ok\n */\n\n// Called by Atom when its value changes\nexport function propagateChanged(observable: IObservable) {\n // invariantLOS(observable, \"changed start\");\n if (observable.lowestObserverState_ === IDerivationState_.STALE_) {\n return\n }\n observable.lowestObserverState_ = IDerivationState_.STALE_\n\n // Ideally we use for..of here, but the downcompiled version is really slow...\n observable.observers_.forEach(d => {\n if (d.dependenciesState_ === IDerivationState_.UP_TO_DATE_) {\n if (__DEV__ && d.isTracing_ !== TraceMode.NONE) {\n logTraceInfo(d, observable)\n }\n d.onBecomeStale_()\n }\n d.dependenciesState_ = IDerivationState_.STALE_\n })\n // invariantLOS(observable, \"changed end\");\n}\n\n// Called by ComputedValue when it recalculate and its value changed\nexport function propagateChangeConfirmed(observable: IObservable) {\n // invariantLOS(observable, \"confirmed start\");\n if (observable.lowestObserverState_ === IDerivationState_.STALE_) {\n return\n }\n observable.lowestObserverState_ = IDerivationState_.STALE_\n\n observable.observers_.forEach(d => {\n if (d.dependenciesState_ === IDerivationState_.POSSIBLY_STALE_) {\n d.dependenciesState_ = IDerivationState_.STALE_\n if (__DEV__ && d.isTracing_ !== TraceMode.NONE) {\n logTraceInfo(d, observable)\n }\n } else if (\n d.dependenciesState_ === IDerivationState_.UP_TO_DATE_ // this happens during computing of `d`, just keep lowestObserverState up to date.\n ) {\n observable.lowestObserverState_ = IDerivationState_.UP_TO_DATE_\n }\n })\n // invariantLOS(observable, \"confirmed end\");\n}\n\n// Used by computed when its dependency changed, but we don't wan't to immediately recompute.\nexport function propagateMaybeChanged(observable: IObservable) {\n // invariantLOS(observable, \"maybe start\");\n if (observable.lowestObserverState_ !== IDerivationState_.UP_TO_DATE_) {\n return\n }\n observable.lowestObserverState_ = IDerivationState_.POSSIBLY_STALE_\n\n observable.observers_.forEach(d => {\n if (d.dependenciesState_ === IDerivationState_.UP_TO_DATE_) {\n d.dependenciesState_ = IDerivationState_.POSSIBLY_STALE_\n d.onBecomeStale_()\n }\n })\n // invariantLOS(observable, \"maybe end\");\n}\n\nfunction logTraceInfo(derivation: IDerivation, observable: IObservable) {\n console.log(\n `[mobx.trace] '${derivation.name_}' is invalidated due to a change in: '${observable.name_}'`\n )\n if (derivation.isTracing_ === TraceMode.BREAK) {\n const lines = []\n printDepTree(getDependencyTree(derivation), lines, 1)\n\n // prettier-ignore\n new Function(\n`debugger;\n/*\nTracing '${derivation.name_}'\n\nYou are entering this break point because derivation '${derivation.name_}' is being traced and '${observable.name_}' is now forcing it to update.\nJust follow the stacktrace you should now see in the devtools to see precisely what piece of your code is causing this update\nThe stackframe you are looking for is at least ~6-8 stack-frames up.\n\n${derivation instanceof ComputedValue ? derivation.derivation.toString().replace(/[*]\\//g, \"/\") : \"\"}\n\nThe dependencies for this derivation are:\n\n${lines.join(\"\\n\")}\n*/\n `)()\n }\n}\n\nfunction printDepTree(tree: IDependencyTree, lines: string[], depth: number) {\n if (lines.length >= 1000) {\n lines.push(\"(and many more)\")\n return\n }\n lines.push(`${\"\\t\".repeat(depth - 1)}${tree.name}`)\n if (tree.dependencies) {\n tree.dependencies.forEach(child => printDepTree(child, lines, depth + 1))\n }\n}\n", "import {\n $mobx,\n IDerivation,\n IDerivationState_,\n IObservable,\n Lambda,\n TraceMode,\n clearObserving,\n createInstanceofPredicate,\n endBatch,\n getNextId,\n globalState,\n isCaughtException,\n isSpyEnabled,\n shouldCompute,\n spyReport,\n spyReportEnd,\n spyReportStart,\n startBatch,\n trace,\n trackDerivedFunction,\n GenericAbortSignal\n} from \"../internal\"\n\n/**\n * Reactions are a special kind of derivations. Several things distinguishes them from normal reactive computations\n *\n * 1) They will always run, whether they are used by other computations or not.\n * This means that they are very suitable for triggering side effects like logging, updating the DOM and making network requests.\n * 2) They are not observable themselves\n * 3) They will always run after any 'normal' derivations\n * 4) They are allowed to change the state and thereby triggering themselves again, as long as they make sure the state propagates to a stable state in a reasonable amount of iterations.\n *\n * The state machine of a Reaction is as follows:\n *\n * 1) after creating, the reaction should be started by calling `runReaction` or by scheduling it (see also `autorun`)\n * 2) the `onInvalidate` handler should somehow result in a call to `this.track(someFunction)`\n * 3) all observables accessed in `someFunction` will be observed by this reaction.\n * 4) as soon as some of the dependencies has changed the Reaction will be rescheduled for another run (after the current mutation or transaction). `isScheduled` will yield true once a dependency is stale and during this period\n * 5) `onInvalidate` will be called, and we are back at step 1.\n *\n */\n\nexport interface IReactionPublic {\n dispose(): void\n trace(enterBreakPoint?: boolean): void\n}\n\nexport interface IReactionDisposer {\n (): void\n [$mobx]: Reaction\n}\n\nexport class Reaction implements IDerivation, IReactionPublic {\n observing_: IObservable[] = [] // nodes we are looking at. Our value depends on these nodes\n newObserving_: IObservable[] = []\n dependenciesState_ = IDerivationState_.NOT_TRACKING_\n diffValue_ = 0\n runId_ = 0\n unboundDepsCount_ = 0\n isDisposed_ = false\n isScheduled_ = false\n isTrackPending_ = false\n isRunning_ = false\n isTracing_: TraceMode = TraceMode.NONE\n\n constructor(\n public name_: string = __DEV__ ? \"Reaction@\" + getNextId() : \"Reaction\",\n private onInvalidate_: () => void,\n private errorHandler_?: (error: any, derivation: IDerivation) => void,\n public requiresObservable_?\n ) {}\n\n onBecomeStale_() {\n this.schedule_()\n }\n\n schedule_() {\n if (!this.isScheduled_) {\n this.isScheduled_ = true\n globalState.pendingReactions.push(this)\n runReactions()\n }\n }\n\n isScheduled() {\n return this.isScheduled_\n }\n\n /**\n * internal, use schedule() if you intend to kick off a reaction\n */\n runReaction_() {\n if (!this.isDisposed_) {\n startBatch()\n this.isScheduled_ = false\n const prev = globalState.trackingContext\n globalState.trackingContext = this\n if (shouldCompute(this)) {\n this.isTrackPending_ = true\n\n try {\n this.onInvalidate_()\n if (__DEV__ && this.isTrackPending_ && isSpyEnabled()) {\n // onInvalidate didn't trigger track right away..\n spyReport({\n name: this.name_,\n type: \"scheduled-reaction\"\n })\n }\n } catch (e) {\n this.reportExceptionInDerivation_(e)\n }\n }\n globalState.trackingContext = prev\n endBatch()\n }\n }\n\n track(fn: () => void) {\n if (this.isDisposed_) {\n return\n // console.warn(\"Reaction already disposed\") // Note: Not a warning / error in mobx 4 either\n }\n startBatch()\n const notify = isSpyEnabled()\n let startTime\n if (__DEV__ && notify) {\n startTime = Date.now()\n spyReportStart({\n name: this.name_,\n type: \"reaction\"\n })\n }\n this.isRunning_ = true\n const prevReaction = globalState.trackingContext // reactions could create reactions...\n globalState.trackingContext = this\n const result = trackDerivedFunction(this, fn, undefined)\n globalState.trackingContext = prevReaction\n this.isRunning_ = false\n this.isTrackPending_ = false\n if (this.isDisposed_) {\n // disposed during last run. Clean up everything that was bound after the dispose call.\n clearObserving(this)\n }\n if (isCaughtException(result)) {\n this.reportExceptionInDerivation_(result.cause)\n }\n if (__DEV__ && notify) {\n spyReportEnd({\n time: Date.now() - startTime\n })\n }\n endBatch()\n }\n\n reportExceptionInDerivation_(error: any) {\n if (this.errorHandler_) {\n this.errorHandler_(error, this)\n return\n }\n\n if (globalState.disableErrorBoundaries) {\n throw error\n }\n\n const message = __DEV__\n ? `[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '${this}'`\n : `[mobx] uncaught error in '${this}'`\n if (!globalState.suppressReactionErrors) {\n console.error(message, error)\n /** If debugging brought you here, please, read the above message :-). Tnx! */\n } else if (__DEV__) { console.warn(`[mobx] (error in reaction '${this.name_}' suppressed, fix error of causing action below)`) } // prettier-ignore\n\n if (__DEV__ && isSpyEnabled()) {\n spyReport({\n type: \"error\",\n name: this.name_,\n message,\n error: \"\" + error\n })\n }\n\n globalState.globalReactionErrorHandlers.forEach(f => f(error, this))\n }\n\n dispose() {\n if (!this.isDisposed_) {\n this.isDisposed_ = true\n if (!this.isRunning_) {\n // if disposed while running, clean up later. Maybe not optimal, but rare case\n startBatch()\n clearObserving(this)\n endBatch()\n }\n }\n }\n\n getDisposer_(abortSignal?: GenericAbortSignal): IReactionDisposer {\n const dispose = (() => {\n this.dispose()\n abortSignal?.removeEventListener?.(\"abort\", dispose)\n }) as IReactionDisposer\n abortSignal?.addEventListener?.(\"abort\", dispose)\n dispose[$mobx] = this\n\n return dispose\n }\n\n toString() {\n return `Reaction[${this.name_}]`\n }\n\n trace(enterBreakPoint: boolean = false) {\n trace(this, enterBreakPoint)\n }\n}\n\nexport function onReactionError(handler: (error: any, derivation: IDerivation) => void): Lambda {\n globalState.globalReactionErrorHandlers.push(handler)\n return () => {\n const idx = globalState.globalReactionErrorHandlers.indexOf(handler)\n if (idx >= 0) {\n globalState.globalReactionErrorHandlers.splice(idx, 1)\n }\n }\n}\n\n/**\n * Magic number alert!\n * Defines within how many times a reaction is allowed to re-trigger itself\n * until it is assumed that this is gonna be a never ending loop...\n */\nconst MAX_REACTION_ITERATIONS = 100\n\nlet reactionScheduler: (fn: () => void) => void = f => f()\n\nexport function runReactions() {\n // Trampolining, if runReactions are already running, new reactions will be picked up\n if (globalState.inBatch > 0 || globalState.isRunningReactions) {\n return\n }\n reactionScheduler(runReactionsHelper)\n}\n\nfunction runReactionsHelper() {\n globalState.isRunningReactions = true\n const allReactions = globalState.pendingReactions\n let iterations = 0\n\n // While running reactions, new reactions might be triggered.\n // Hence we work with two variables and check whether\n // we converge to no remaining reactions after a while.\n while (allReactions.length > 0) {\n if (++iterations === MAX_REACTION_ITERATIONS) {\n console.error(\n __DEV__\n ? `Reaction doesn't converge to a stable state after ${MAX_REACTION_ITERATIONS} iterations.` +\n ` Probably there is a cycle in the reactive function: ${allReactions[0]}`\n : `[mobx] cycle in reaction: ${allReactions[0]}`\n )\n allReactions.splice(0) // clear reactions\n }\n let remainingReactions = allReactions.splice(0)\n for (let i = 0, l = remainingReactions.length; i < l; i++) {\n remainingReactions[i].runReaction_()\n }\n }\n globalState.isRunningReactions = false\n}\n\nexport const isReaction = createInstanceofPredicate(\"Reaction\", Reaction)\n\nexport function setReactionScheduler(fn: (f: () => void) => void) {\n const baseScheduler = reactionScheduler\n reactionScheduler = f => fn(() => baseScheduler(f))\n}\n", "import { IComputedDidChange } from \"./computedvalue\"\nimport { IValueDidChange, IBoxDidChange } from \"./../types/observablevalue\"\nimport { IObjectDidChange } from \"./../types/observableobject\"\nimport { IArrayDidChange } from \"./../types/observablearray\"\nimport { Lambda, globalState, once, ISetDidChange, IMapDidChange } from \"../internal\"\n\nexport function isSpyEnabled() {\n return __DEV__ && !!globalState.spyListeners.length\n}\n\nexport type PureSpyEvent =\n | { type: \"action\"; name: string; object: unknown; arguments: unknown[] }\n | { type: \"scheduled-reaction\"; name: string }\n | { type: \"reaction\"; name: string }\n | { type: \"error\"; name: string; message: string; error: string }\n | IComputedDidChange\n | IObjectDidChange\n | IArrayDidChange\n | IMapDidChange\n | ISetDidChange\n | IValueDidChange\n | IBoxDidChange\n | { type: \"report-end\"; spyReportEnd: true; time?: number }\n\ntype SpyEvent = PureSpyEvent & { spyReportStart?: true }\n\nexport function spyReport(event: SpyEvent) {\n if (!__DEV__) {\n return\n } // dead code elimination can do the rest\n if (!globalState.spyListeners.length) {\n return\n }\n const listeners = globalState.spyListeners\n for (let i = 0, l = listeners.length; i < l; i++) {\n listeners[i](event)\n }\n}\n\nexport function spyReportStart(event: PureSpyEvent) {\n if (!__DEV__) {\n return\n }\n const change = { ...event, spyReportStart: true as const }\n spyReport(change)\n}\n\nconst END_EVENT: SpyEvent = { type: \"report-end\", spyReportEnd: true }\n\nexport function spyReportEnd(change?: { time?: number }) {\n if (!__DEV__) {\n return\n }\n if (change) {\n spyReport({ ...change, type: \"report-end\", spyReportEnd: true })\n } else {\n spyReport(END_EVENT)\n }\n}\n\nexport function spy(listener: (change: SpyEvent) => void): Lambda {\n if (!__DEV__) {\n console.warn(`[mobx.spy] Is a no-op in production builds`)\n return function () {}\n } else {\n globalState.spyListeners.push(listener)\n return once(() => {\n globalState.spyListeners = globalState.spyListeners.filter(l => l !== listener)\n })\n }\n}\n", "import {\n createAction,\n executeAction,\n Annotation,\n storeAnnotation,\n die,\n isFunction,\n isStringish,\n createDecoratorAnnotation,\n createActionAnnotation,\n is20223Decorator\n} from \"../internal\"\n\nimport type { ClassFieldDecorator, ClassMethodDecorator } from \"../types/decorator_fills\"\n\nexport const ACTION = \"action\"\nexport const ACTION_BOUND = \"action.bound\"\nexport const AUTOACTION = \"autoAction\"\nexport const AUTOACTION_BOUND = \"autoAction.bound\"\n\nconst DEFAULT_ACTION_NAME = \"\"\n\nconst actionAnnotation = createActionAnnotation(ACTION)\nconst actionBoundAnnotation = createActionAnnotation(ACTION_BOUND, {\n bound: true\n})\nconst autoActionAnnotation = createActionAnnotation(AUTOACTION, {\n autoAction: true\n})\nconst autoActionBoundAnnotation = createActionAnnotation(AUTOACTION_BOUND, {\n autoAction: true,\n bound: true\n})\n\nexport interface IActionFactory\n extends Annotation,\n PropertyDecorator,\n ClassMethodDecorator,\n ClassFieldDecorator {\n // nameless actions\n (fn: T): T\n // named actions\n (name: string, fn: T): T\n\n // named decorator\n (customName: string): PropertyDecorator &\n Annotation &\n ClassMethodDecorator &\n ClassFieldDecorator\n\n // decorator (name no longer supported)\n bound: Annotation & PropertyDecorator & ClassMethodDecorator & ClassFieldDecorator\n}\n\nfunction createActionFactory(autoAction: boolean): IActionFactory {\n const res: IActionFactory = function action(arg1, arg2?): any {\n // action(fn() {})\n if (isFunction(arg1)) {\n return createAction(arg1.name || DEFAULT_ACTION_NAME, arg1, autoAction)\n }\n // action(\"name\", fn() {})\n if (isFunction(arg2)) {\n return createAction(arg1, arg2, autoAction)\n }\n // @action (2022.3 Decorators)\n if (is20223Decorator(arg2)) {\n return (autoAction ? autoActionAnnotation : actionAnnotation).decorate_20223_(\n arg1,\n arg2\n )\n }\n // @action\n if (isStringish(arg2)) {\n return storeAnnotation(arg1, arg2, autoAction ? autoActionAnnotation : actionAnnotation)\n }\n // action(\"name\") & @action(\"name\")\n if (isStringish(arg1)) {\n return createDecoratorAnnotation(\n createActionAnnotation(autoAction ? AUTOACTION : ACTION, {\n name: arg1,\n autoAction\n })\n )\n }\n\n if (__DEV__) {\n die(\"Invalid arguments for `action`\")\n }\n } as IActionFactory\n return res\n}\n\nexport const action: IActionFactory = createActionFactory(false)\nObject.assign(action, actionAnnotation)\nexport const autoAction: IActionFactory = createActionFactory(true)\nObject.assign(autoAction, autoActionAnnotation)\n\naction.bound = createDecoratorAnnotation(actionBoundAnnotation)\nautoAction.bound = createDecoratorAnnotation(autoActionBoundAnnotation)\n\nexport function runInAction(fn: () => T): T {\n return executeAction(fn.name || DEFAULT_ACTION_NAME, false, fn, this, undefined)\n}\n\nexport function isAction(thing: any) {\n return isFunction(thing) && thing.isMobxAction === true\n}\n", "import {\n EMPTY_OBJECT,\n IEqualsComparer,\n IReactionDisposer,\n IReactionPublic,\n Lambda,\n Reaction,\n action,\n comparer,\n getNextId,\n isAction,\n isFunction,\n isPlainObject,\n die,\n allowStateChanges,\n GenericAbortSignal\n} from \"../internal\"\n\nexport interface IAutorunOptions {\n delay?: number\n name?: string\n /**\n * Experimental.\n * Warns if the view doesn't track observables\n */\n requiresObservable?: boolean\n scheduler?: (callback: () => void) => any\n onError?: (error: any) => void\n signal?: GenericAbortSignal\n}\n\n/**\n * Creates a named reactive view and keeps it alive, so that the view is always\n * updated if one of the dependencies changes, even when the view is not further used by something else.\n * @param view The reactive view\n * @returns disposer function, which can be used to stop the view from being updated in the future.\n */\nexport function autorun(\n view: (r: IReactionPublic) => any,\n opts: IAutorunOptions = EMPTY_OBJECT\n): IReactionDisposer {\n if (__DEV__) {\n if (!isFunction(view)) {\n die(\"Autorun expects a function as first argument\")\n }\n if (isAction(view)) {\n die(\"Autorun does not accept actions since actions are untrackable\")\n }\n }\n\n const name: string =\n opts?.name ?? (__DEV__ ? (view as any).name || \"Autorun@\" + getNextId() : \"Autorun\")\n const runSync = !opts.scheduler && !opts.delay\n let reaction: Reaction\n\n if (runSync) {\n // normal autorun\n reaction = new Reaction(\n name,\n function (this: Reaction) {\n this.track(reactionRunner)\n },\n opts.onError,\n opts.requiresObservable\n )\n } else {\n const scheduler = createSchedulerFromOptions(opts)\n // debounced autorun\n let isScheduled = false\n\n reaction = new Reaction(\n name,\n () => {\n if (!isScheduled) {\n isScheduled = true\n scheduler(() => {\n isScheduled = false\n if (!reaction.isDisposed_) {\n reaction.track(reactionRunner)\n }\n })\n }\n },\n opts.onError,\n opts.requiresObservable\n )\n }\n\n function reactionRunner() {\n view(reaction)\n }\n\n if(!opts?.signal?.aborted) {\n reaction.schedule_()\n }\n return reaction.getDisposer_(opts?.signal)\n}\n\nexport type IReactionOptions = IAutorunOptions & {\n fireImmediately?: FireImmediately\n equals?: IEqualsComparer\n}\n\nconst run = (f: Lambda) => f()\n\nfunction createSchedulerFromOptions(opts: IAutorunOptions) {\n return opts.scheduler\n ? opts.scheduler\n : opts.delay\n ? (f: Lambda) => setTimeout(f, opts.delay!)\n : run\n}\n\nexport function reaction(\n expression: (r: IReactionPublic) => T,\n effect: (\n arg: T,\n prev: FireImmediately extends true ? T | undefined : T,\n r: IReactionPublic\n ) => void,\n opts: IReactionOptions = EMPTY_OBJECT\n): IReactionDisposer {\n if (__DEV__) {\n if (!isFunction(expression) || !isFunction(effect)) {\n die(\"First and second argument to reaction should be functions\")\n }\n if (!isPlainObject(opts)) {\n die(\"Third argument of reactions should be an object\")\n }\n }\n const name = opts.name ?? (__DEV__ ? \"Reaction@\" + getNextId() : \"Reaction\")\n const effectAction = action(\n name,\n opts.onError ? wrapErrorHandler(opts.onError, effect) : effect\n )\n const runSync = !opts.scheduler && !opts.delay\n const scheduler = createSchedulerFromOptions(opts)\n\n let firstTime = true\n let isScheduled = false\n let value: T\n\n const equals: IEqualsComparer = (opts as any).compareStructural\n ? comparer.structural\n : opts.equals || comparer.default\n\n const r = new Reaction(\n name,\n () => {\n if (firstTime || runSync) {\n reactionRunner()\n } else if (!isScheduled) {\n isScheduled = true\n scheduler!(reactionRunner)\n }\n },\n opts.onError,\n opts.requiresObservable\n )\n\n function reactionRunner() {\n isScheduled = false\n if (r.isDisposed_) {\n return\n }\n let changed: boolean = false\n const oldValue = value\n r.track(() => {\n const nextValue = allowStateChanges(false, () => expression(r))\n changed = firstTime || !equals(value, nextValue)\n value = nextValue\n })\n\n // This casting is nesessary as TS cannot infer proper type in current function implementation\n type OldValue = FireImmediately extends true ? T | undefined : T\n if (firstTime && opts.fireImmediately!) {\n effectAction(value, oldValue as OldValue, r)\n } else if (!firstTime && changed) {\n effectAction(value, oldValue as OldValue, r)\n }\n firstTime = false\n }\n\n if(!opts?.signal?.aborted) {\n r.schedule_()\n }\n return r.getDisposer_(opts?.signal)\n}\n\nfunction wrapErrorHandler(errorHandler, baseFn) {\n return function () {\n try {\n return baseFn.apply(this, arguments)\n } catch (e) {\n errorHandler.call(this, e)\n }\n }\n}\n", "import {\n IComputedValue,\n IObservable,\n IObservableArray,\n Lambda,\n ObservableMap,\n getAtom,\n ObservableSet,\n isFunction,\n IObservableValue\n} from \"../internal\"\n\nconst ON_BECOME_OBSERVED = \"onBO\"\nconst ON_BECOME_UNOBSERVED = \"onBUO\"\n\nexport function onBecomeObserved(\n value:\n | IObservable\n | IComputedValue\n | IObservableArray\n | ObservableMap\n | ObservableSet\n | IObservableValue,\n listener: Lambda\n): Lambda\nexport function onBecomeObserved(\n value: ObservableMap | Object,\n property: K,\n listener: Lambda\n): Lambda\nexport function onBecomeObserved(thing, arg2, arg3?): Lambda {\n return interceptHook(ON_BECOME_OBSERVED, thing, arg2, arg3)\n}\n\nexport function onBecomeUnobserved(\n value:\n | IObservable\n | IComputedValue\n | IObservableArray\n | ObservableMap\n | ObservableSet\n | IObservableValue,\n listener: Lambda\n): Lambda\nexport function onBecomeUnobserved(\n value: ObservableMap | Object,\n property: K,\n listener: Lambda\n): Lambda\nexport function onBecomeUnobserved(thing, arg2, arg3?): Lambda {\n return interceptHook(ON_BECOME_UNOBSERVED, thing, arg2, arg3)\n}\n\nfunction interceptHook(hook: \"onBO\" | \"onBUO\", thing, arg2, arg3) {\n const atom: IObservable =\n typeof arg3 === \"function\" ? getAtom(thing, arg2) : (getAtom(thing) as any)\n const cb = isFunction(arg3) ? arg3 : arg2\n const listenersKey = `${hook}L` as \"onBOL\" | \"onBUOL\"\n\n if (atom[listenersKey]) {\n atom[listenersKey]!.add(cb)\n } else {\n atom[listenersKey] = new Set([cb])\n }\n\n return function () {\n const hookListeners = atom[listenersKey]\n if (hookListeners) {\n hookListeners.delete(cb)\n if (hookListeners.size === 0) {\n delete atom[listenersKey]\n }\n }\n }\n}\n", "import { globalState, isolateGlobalState, setReactionScheduler } from \"../internal\"\n\nconst NEVER = \"never\"\nconst ALWAYS = \"always\"\nconst OBSERVED = \"observed\"\n// const IF_AVAILABLE = \"ifavailable\"\n\nexport function configure(options: {\n enforceActions?: \"never\" | \"always\" | \"observed\"\n computedRequiresReaction?: boolean\n /**\n * Warn if you try to create to derivation / reactive context without accessing any observable.\n */\n reactionRequiresObservable?: boolean\n /**\n * Warn if observables are accessed outside a reactive context\n */\n observableRequiresReaction?: boolean\n isolateGlobalState?: boolean\n disableErrorBoundaries?: boolean\n safeDescriptors?: boolean\n reactionScheduler?: (f: () => void) => void\n useProxies?: \"always\" | \"never\" | \"ifavailable\"\n}): void {\n if (options.isolateGlobalState === true) {\n isolateGlobalState()\n }\n const { useProxies, enforceActions } = options\n if (useProxies !== undefined) {\n globalState.useProxies =\n useProxies === ALWAYS\n ? true\n : useProxies === NEVER\n ? false\n : typeof Proxy !== \"undefined\"\n }\n if (useProxies === \"ifavailable\") {\n globalState.verifyProxies = true\n }\n if (enforceActions !== undefined) {\n const ea = enforceActions === ALWAYS ? ALWAYS : enforceActions === OBSERVED\n globalState.enforceActions = ea\n globalState.allowStateChanges = ea === true || ea === ALWAYS ? false : true\n }\n ;[\n \"computedRequiresReaction\",\n \"reactionRequiresObservable\",\n \"observableRequiresReaction\",\n \"disableErrorBoundaries\",\n \"safeDescriptors\"\n ].forEach(key => {\n if (key in options) {\n globalState[key] = !!options[key]\n }\n })\n globalState.allowStateReads = !globalState.observableRequiresReaction\n if (__DEV__ && globalState.disableErrorBoundaries === true) {\n console.warn(\n \"WARNING: Debug feature only. MobX will NOT recover from errors when `disableErrorBoundaries` is enabled.\"\n )\n }\n if (options.reactionScheduler) {\n setReactionScheduler(options.reactionScheduler)\n }\n}\n", "import {\n CreateObservableOptions,\n isObservableMap,\n AnnotationsMap,\n asObservableObject,\n isPlainObject,\n ObservableObjectAdministration,\n isObservable,\n die,\n getOwnPropertyDescriptors,\n $mobx,\n ownKeys,\n initObservable\n} from \"../internal\"\n\nexport function extendObservable(\n target: A,\n properties: B,\n annotations?: AnnotationsMap,\n options?: CreateObservableOptions\n): A & B {\n if (__DEV__) {\n if (arguments.length > 4) {\n die(\"'extendObservable' expected 2-4 arguments\")\n }\n if (typeof target !== \"object\") {\n die(\"'extendObservable' expects an object as first argument\")\n }\n if (isObservableMap(target)) {\n die(\"'extendObservable' should not be used on maps, use map.merge instead\")\n }\n if (!isPlainObject(properties)) {\n die(`'extendObservable' only accepts plain objects as second argument`)\n }\n if (isObservable(properties) || isObservable(annotations)) {\n die(`Extending an object with another observable (object) is not supported`)\n }\n }\n // Pull descriptors first, so we don't have to deal with props added by administration ($mobx)\n const descriptors = getOwnPropertyDescriptors(properties)\n\n initObservable(() => {\n const adm: ObservableObjectAdministration = asObservableObject(target, options)[$mobx]\n ownKeys(descriptors).forEach(key => {\n adm.extend_(\n key,\n descriptors[key as any],\n // must pass \"undefined\" for { key: undefined }\n !annotations ? true : key in annotations ? annotations[key] : true\n )\n })\n })\n\n return target as any\n}\n", "import { IDepTreeNode, getAtom, getObservers, hasObservers } from \"../internal\"\n\nexport interface IDependencyTree {\n name: string\n dependencies?: IDependencyTree[]\n}\n\nexport interface IObserverTree {\n name: string\n observers?: IObserverTree[]\n}\n\nexport function getDependencyTree(thing: any, property?: string): IDependencyTree {\n return nodeToDependencyTree(getAtom(thing, property))\n}\n\nfunction nodeToDependencyTree(node: IDepTreeNode): IDependencyTree {\n const result: IDependencyTree = {\n name: node.name_\n }\n if (node.observing_ && node.observing_.length > 0) {\n result.dependencies = unique(node.observing_).map(nodeToDependencyTree)\n }\n return result\n}\n\nexport function getObserverTree(thing: any, property?: string): IObserverTree {\n return nodeToObserverTree(getAtom(thing, property))\n}\n\nfunction nodeToObserverTree(node: IDepTreeNode): IObserverTree {\n const result: IObserverTree = {\n name: node.name_\n }\n if (hasObservers(node as any)) {\n result.observers = Array.from(getObservers(node as any)).map(nodeToObserverTree)\n }\n return result\n}\n\nfunction unique(list: T[]): T[] {\n return Array.from(new Set(list))\n}\n", "import {\n action,\n noop,\n die,\n isFunction,\n Annotation,\n isStringish,\n storeAnnotation,\n createFlowAnnotation,\n createDecoratorAnnotation,\n is20223Decorator\n} from \"../internal\"\n\nimport type { ClassMethodDecorator } from \"../types/decorator_fills\"\n\nexport const FLOW = \"flow\"\n\nlet generatorId = 0\n\nexport function FlowCancellationError() {\n this.message = \"FLOW_CANCELLED\"\n}\nFlowCancellationError.prototype = Object.create(Error.prototype)\n\nexport function isFlowCancellationError(error: Error) {\n return error instanceof FlowCancellationError\n}\n\nexport type CancellablePromise = Promise & { cancel(): void }\n\ninterface Flow extends Annotation, PropertyDecorator, ClassMethodDecorator {\n (\n generator: (...args: Args) => Generator | AsyncGenerator\n ): (...args: Args) => CancellablePromise\n bound: Annotation & PropertyDecorator & ClassMethodDecorator\n}\n\nconst flowAnnotation = createFlowAnnotation(\"flow\")\nconst flowBoundAnnotation = createFlowAnnotation(\"flow.bound\", { bound: true })\n\nexport const flow: Flow = Object.assign(\n function flow(arg1, arg2?) {\n // @flow (2022.3 Decorators)\n if (is20223Decorator(arg2)) {\n return flowAnnotation.decorate_20223_(arg1, arg2)\n }\n // @flow\n if (isStringish(arg2)) {\n return storeAnnotation(arg1, arg2, flowAnnotation)\n }\n // flow(fn)\n if (__DEV__ && arguments.length !== 1) {\n die(`Flow expects single argument with generator function`)\n }\n const generator = arg1\n const name = generator.name || \"\"\n\n // Implementation based on https://github.com/tj/co/blob/master/index.js\n const res = function () {\n const ctx = this\n const args = arguments\n const runId = ++generatorId\n const gen = action(`${name} - runid: ${runId} - init`, generator).apply(ctx, args)\n let rejector: (error: any) => void\n let pendingPromise: CancellablePromise | undefined = undefined\n\n const promise = new Promise(function (resolve, reject) {\n let stepId = 0\n rejector = reject\n\n function onFulfilled(res: any) {\n pendingPromise = undefined\n let ret\n try {\n ret = action(\n `${name} - runid: ${runId} - yield ${stepId++}`,\n gen.next\n ).call(gen, res)\n } catch (e) {\n return reject(e)\n }\n\n next(ret)\n }\n\n function onRejected(err: any) {\n pendingPromise = undefined\n let ret\n try {\n ret = action(\n `${name} - runid: ${runId} - yield ${stepId++}`,\n gen.throw!\n ).call(gen, err)\n } catch (e) {\n return reject(e)\n }\n next(ret)\n }\n\n function next(ret: any) {\n if (isFunction(ret?.then)) {\n // an async iterator\n ret.then(next, reject)\n return\n }\n if (ret.done) {\n return resolve(ret.value)\n }\n pendingPromise = Promise.resolve(ret.value) as any\n return pendingPromise!.then(onFulfilled, onRejected)\n }\n\n onFulfilled(undefined) // kick off the process\n }) as any\n\n promise.cancel = action(`${name} - runid: ${runId} - cancel`, function () {\n try {\n if (pendingPromise) {\n cancelPromise(pendingPromise)\n }\n // Finally block can return (or yield) stuff..\n const res = gen.return!(undefined as any)\n // eat anything that promise would do, it's cancelled!\n const yieldedPromise = Promise.resolve(res.value)\n yieldedPromise.then(noop, noop)\n cancelPromise(yieldedPromise) // maybe it can be cancelled :)\n // reject our original promise\n rejector(new FlowCancellationError())\n } catch (e) {\n rejector(e) // there could be a throwing finally block\n }\n })\n return promise\n }\n res.isMobXFlow = true\n return res\n } as any,\n flowAnnotation\n)\n\nflow.bound = createDecoratorAnnotation(flowBoundAnnotation)\n\nfunction cancelPromise(promise) {\n if (isFunction(promise.cancel)) {\n promise.cancel()\n }\n}\n\nexport function flowResult(\n result: T\n): T extends Generator\n ? CancellablePromise\n : T extends CancellablePromise\n ? T\n : never {\n return result as any // just tricking TypeScript :)\n}\n\nexport function isFlow(fn: any): boolean {\n return fn?.isMobXFlow === true\n}\n", "import {\n IObservableArray,\n IObservableValue,\n Lambda,\n ObservableMap,\n getAdministration,\n isObservableArray,\n isObservableMap,\n isObservableObject,\n isObservableValue,\n ObservableSet,\n die,\n isStringish\n} from \"../internal\"\n\nexport type ReadInterceptor = (value: any) => T\n\n/** Experimental feature right now, tested indirectly via Mobx-State-Tree */\nexport function interceptReads(value: IObservableValue, handler: ReadInterceptor): Lambda\nexport function interceptReads(\n observableArray: IObservableArray,\n handler: ReadInterceptor\n): Lambda\nexport function interceptReads(\n observableMap: ObservableMap,\n handler: ReadInterceptor\n): Lambda\nexport function interceptReads(\n observableSet: ObservableSet,\n handler: ReadInterceptor\n): Lambda\nexport function interceptReads(\n object: Object,\n property: string,\n handler: ReadInterceptor\n): Lambda\nexport function interceptReads(thing, propOrHandler?, handler?): Lambda {\n let target\n if (isObservableMap(thing) || isObservableArray(thing) || isObservableValue(thing)) {\n target = getAdministration(thing)\n } else if (isObservableObject(thing)) {\n if (__DEV__ && !isStringish(propOrHandler)) {\n return die(\n `InterceptReads can only be used with a specific property, not with an object in general`\n )\n }\n target = getAdministration(thing, propOrHandler)\n } else if (__DEV__) {\n return die(`Expected observable map, object or array as first array`)\n }\n if (__DEV__ && target.dehancer !== undefined) {\n return die(`An intercept reader was already established`)\n }\n target.dehancer = typeof propOrHandler === \"function\" ? propOrHandler : handler\n return () => {\n target.dehancer = undefined\n }\n}\n", "import {\n IArrayWillChange,\n IArrayWillSplice,\n IInterceptor,\n IMapWillChange,\n IObjectWillChange,\n IObservableArray,\n IObservableValue,\n IValueWillChange,\n Lambda,\n ObservableMap,\n getAdministration,\n ObservableSet,\n ISetWillChange,\n isFunction\n} from \"../internal\"\n\nexport function intercept(\n value: IObservableValue,\n handler: IInterceptor>\n): Lambda\nexport function intercept(\n observableArray: IObservableArray | Array,\n handler: IInterceptor | IArrayWillSplice>\n): Lambda\nexport function intercept(\n observableMap: ObservableMap | Map,\n handler: IInterceptor>\n): Lambda\nexport function intercept(\n observableSet: ObservableSet | Set,\n handler: IInterceptor>\n): Lambda\nexport function intercept(\n observableMap: ObservableMap | Map,\n property: K,\n handler: IInterceptor>\n): Lambda\nexport function intercept(object: object, handler: IInterceptor): Lambda\nexport function intercept(\n object: T,\n property: K,\n handler: IInterceptor>\n): Lambda\nexport function intercept(thing, propOrHandler?, handler?): Lambda {\n if (isFunction(handler)) {\n return interceptProperty(thing, propOrHandler, handler)\n } else {\n return interceptInterceptable(thing, propOrHandler)\n }\n}\n\nfunction interceptInterceptable(thing, handler) {\n return getAdministration(thing).intercept_(handler)\n}\n\nfunction interceptProperty(thing, property, handler) {\n return getAdministration(thing, property).intercept_(handler)\n}\n", "import { $mobx, getAtom, isComputedValue, isObservableObject, die, isStringish } from \"../internal\"\n\nexport function _isComputed(value, property?: PropertyKey): boolean {\n if (property === undefined) {\n return isComputedValue(value)\n }\n if (isObservableObject(value) === false) {\n return false\n }\n if (!value[$mobx].values_.has(property)) {\n return false\n }\n const atom = getAtom(value, property)\n return isComputedValue(atom)\n}\n\nexport function isComputed(value: any): boolean {\n if (__DEV__ && arguments.length > 1) {\n return die(\n `isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property`\n )\n }\n return _isComputed(value)\n}\n\nexport function isComputedProp(value: any, propName: PropertyKey): boolean {\n if (__DEV__ && !isStringish(propName)) {\n return die(`isComputed expected a property name as second argument`)\n }\n return _isComputed(value, propName)\n}\n", "import {\n $mobx,\n isAtom,\n isComputedValue,\n isObservableArray,\n isObservableMap,\n isObservableObject,\n isReaction,\n die,\n isStringish\n} from \"../internal\"\n\nfunction _isObservable(value, property?: PropertyKey): boolean {\n if (!value) {\n return false\n }\n if (property !== undefined) {\n if (__DEV__ && (isObservableMap(value) || isObservableArray(value))) {\n return die(\n \"isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead.\"\n )\n }\n if (isObservableObject(value)) {\n return value[$mobx].values_.has(property)\n }\n return false\n }\n // For first check, see #701\n return (\n isObservableObject(value) ||\n !!value[$mobx] ||\n isAtom(value) ||\n isReaction(value) ||\n isComputedValue(value)\n )\n}\n\nexport function isObservable(value: any): boolean {\n if (__DEV__ && arguments.length !== 1) {\n die(\n `isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property`\n )\n }\n return _isObservable(value)\n}\n\nexport function isObservableProp(value: any, propName: PropertyKey): boolean {\n if (__DEV__ && !isStringish(propName)) {\n return die(`expected a property name as second argument`)\n }\n return _isObservable(value, propName)\n}\n", "import {\n $mobx,\n IIsObservableObject,\n IObservableArray,\n ObservableMap,\n ObservableSet,\n ObservableObjectAdministration,\n endBatch,\n isObservableArray,\n isObservableMap,\n isObservableSet,\n isObservableObject,\n startBatch,\n die\n} from \"../internal\"\n\nexport function keys(map: ObservableMap): ReadonlyArray\nexport function keys(ar: IObservableArray): ReadonlyArray\nexport function keys(set: ObservableSet): ReadonlyArray\nexport function keys(obj: T): ReadonlyArray\nexport function keys(obj: any): any {\n if (isObservableObject(obj)) {\n return (\n (obj as any as IIsObservableObject)[$mobx] as ObservableObjectAdministration\n ).keys_()\n }\n if (isObservableMap(obj) || isObservableSet(obj)) {\n return Array.from(obj.keys())\n }\n if (isObservableArray(obj)) {\n return obj.map((_, index) => index)\n }\n die(5)\n}\n\nexport function values(map: ObservableMap): ReadonlyArray\nexport function values(set: ObservableSet): ReadonlyArray\nexport function values(ar: IObservableArray): ReadonlyArray\nexport function values(obj: T): ReadonlyArray\nexport function values(obj: any): string[] {\n if (isObservableObject(obj)) {\n return keys(obj).map(key => obj[key])\n }\n if (isObservableMap(obj)) {\n return keys(obj).map(key => obj.get(key))\n }\n if (isObservableSet(obj)) {\n return Array.from(obj.values())\n }\n if (isObservableArray(obj)) {\n return obj.slice()\n }\n die(6)\n}\n\nexport function entries(map: ObservableMap): ReadonlyArray<[K, T]>\nexport function entries(set: ObservableSet): ReadonlyArray<[T, T]>\nexport function entries(ar: IObservableArray): ReadonlyArray<[number, T]>\nexport function entries(\n obj: T\n): ReadonlyArray<[string, T extends object ? T[keyof T] : any]>\nexport function entries(obj: any): any {\n if (isObservableObject(obj)) {\n return keys(obj).map(key => [key, obj[key]])\n }\n if (isObservableMap(obj)) {\n return keys(obj).map(key => [key, obj.get(key)])\n }\n if (isObservableSet(obj)) {\n return Array.from(obj.entries())\n }\n if (isObservableArray(obj)) {\n return obj.map((key, index) => [index, key])\n }\n die(7)\n}\n\nexport function set(obj: ObservableMap, values: { [key: string]: V })\nexport function set(obj: ObservableMap, key: K, value: V)\nexport function set(obj: ObservableSet, value: T)\nexport function set(obj: IObservableArray, index: number, value: T)\nexport function set(obj: T, values: { [key: string]: any })\nexport function set(obj: T, key: PropertyKey, value: any)\nexport function set(obj: any, key: any, value?: any): void {\n if (arguments.length === 2 && !isObservableSet(obj)) {\n startBatch()\n const values = key\n try {\n for (let key in values) {\n set(obj, key, values[key])\n }\n } finally {\n endBatch()\n }\n return\n }\n if (isObservableObject(obj)) {\n ;(obj as any as IIsObservableObject)[$mobx].set_(key, value)\n } else if (isObservableMap(obj)) {\n obj.set(key, value)\n } else if (isObservableSet(obj)) {\n obj.add(key)\n } else if (isObservableArray(obj)) {\n if (typeof key !== \"number\") {\n key = parseInt(key, 10)\n }\n if (key < 0) {\n die(`Invalid index: '${key}'`)\n }\n startBatch()\n if (key >= obj.length) {\n obj.length = key + 1\n }\n obj[key] = value\n endBatch()\n } else {\n die(8)\n }\n}\n\nexport function remove(obj: ObservableMap, key: K)\nexport function remove(obj: ObservableSet, key: T)\nexport function remove(obj: IObservableArray, index: number)\nexport function remove(obj: T, key: string)\nexport function remove(obj: any, key: any): void {\n if (isObservableObject(obj)) {\n ;(obj as any as IIsObservableObject)[$mobx].delete_(key)\n } else if (isObservableMap(obj)) {\n obj.delete(key)\n } else if (isObservableSet(obj)) {\n obj.delete(key)\n } else if (isObservableArray(obj)) {\n if (typeof key !== \"number\") {\n key = parseInt(key, 10)\n }\n obj.splice(key, 1)\n } else {\n die(9)\n }\n}\n\nexport function has(obj: ObservableMap, key: K): boolean\nexport function has(obj: ObservableSet, key: T): boolean\nexport function has(obj: IObservableArray, index: number): boolean\nexport function has(obj: T, key: string): boolean\nexport function has(obj: any, key: any): boolean {\n if (isObservableObject(obj)) {\n return (obj as any as IIsObservableObject)[$mobx].has_(key)\n } else if (isObservableMap(obj)) {\n return obj.has(key)\n } else if (isObservableSet(obj)) {\n return obj.has(key)\n } else if (isObservableArray(obj)) {\n return key >= 0 && key < obj.length\n }\n die(10)\n}\n\nexport function get(obj: ObservableMap, key: K): V | undefined\nexport function get(obj: IObservableArray, index: number): T | undefined\nexport function get(obj: T, key: string): any\nexport function get(obj: any, key: any): any {\n if (!has(obj, key)) {\n return undefined\n }\n if (isObservableObject(obj)) {\n return (obj as any as IIsObservableObject)[$mobx].get_(key)\n } else if (isObservableMap(obj)) {\n return obj.get(key)\n } else if (isObservableArray(obj)) {\n return obj[key]\n }\n die(11)\n}\n\nexport function apiDefineProperty(obj: Object, key: PropertyKey, descriptor: PropertyDescriptor) {\n if (isObservableObject(obj)) {\n return (obj as any as IIsObservableObject)[$mobx].defineProperty_(key, descriptor)\n }\n die(39)\n}\n\nexport function apiOwnKeys(obj: Object) {\n if (isObservableObject(obj)) {\n return (obj as any as IIsObservableObject)[$mobx].ownKeys_()\n }\n die(38)\n}\n", "import {\n IArrayDidChange,\n IComputedValue,\n IMapDidChange,\n IObjectDidChange,\n IObservableArray,\n IObservableValue,\n IValueDidChange,\n Lambda,\n ObservableMap,\n getAdministration,\n ObservableSet,\n ISetDidChange,\n isFunction\n} from \"../internal\"\n\nexport function observe(\n value: IObservableValue | IComputedValue,\n listener: (change: IValueDidChange) => void,\n fireImmediately?: boolean\n): Lambda\nexport function observe(\n observableArray: IObservableArray | Array,\n listener: (change: IArrayDidChange) => void,\n fireImmediately?: boolean\n): Lambda\nexport function observe(\n // ObservableSet/ObservableMap are required despite they implement Set/Map: https://github.com/mobxjs/mobx/pull/3180#discussion_r746542929\n observableSet: ObservableSet | Set,\n listener: (change: ISetDidChange) => void,\n fireImmediately?: boolean\n): Lambda\nexport function observe(\n observableMap: ObservableMap | Map,\n listener: (change: IMapDidChange) => void,\n fireImmediately?: boolean\n): Lambda\nexport function observe(\n observableMap: ObservableMap | Map,\n property: K,\n listener: (change: IValueDidChange) => void,\n fireImmediately?: boolean\n): Lambda\nexport function observe(\n object: Object,\n listener: (change: IObjectDidChange) => void,\n fireImmediately?: boolean\n): Lambda\nexport function observe(\n object: T,\n property: K,\n listener: (change: IValueDidChange) => void,\n fireImmediately?: boolean\n): Lambda\nexport function observe(thing, propOrCb?, cbOrFire?, fireImmediately?): Lambda {\n if (isFunction(cbOrFire)) {\n return observeObservableProperty(thing, propOrCb, cbOrFire, fireImmediately)\n } else {\n return observeObservable(thing, propOrCb, cbOrFire)\n }\n}\n\nfunction observeObservable(thing, listener, fireImmediately: boolean) {\n return getAdministration(thing).observe_(listener, fireImmediately)\n}\n\nfunction observeObservableProperty(thing, property, listener, fireImmediately: boolean) {\n return getAdministration(thing, property).observe_(listener, fireImmediately)\n}\n", "import {\n isObservable,\n isObservableArray,\n isObservableValue,\n isObservableMap,\n isObservableSet,\n isComputedValue,\n die,\n apiOwnKeys,\n objectPrototype\n} from \"../internal\"\n\nfunction cache(map: Map, key: K, value: V): V {\n map.set(key, value)\n return value\n}\n\nfunction toJSHelper(source, __alreadySeen: Map) {\n if (\n source == null ||\n typeof source !== \"object\" ||\n source instanceof Date ||\n !isObservable(source)\n ) {\n return source\n }\n\n if (isObservableValue(source) || isComputedValue(source)) {\n return toJSHelper(source.get(), __alreadySeen)\n }\n if (__alreadySeen.has(source)) {\n return __alreadySeen.get(source)\n }\n if (isObservableArray(source)) {\n const res = cache(__alreadySeen, source, new Array(source.length))\n source.forEach((value, idx) => {\n res[idx] = toJSHelper(value, __alreadySeen)\n })\n return res\n }\n if (isObservableSet(source)) {\n const res = cache(__alreadySeen, source, new Set())\n source.forEach(value => {\n res.add(toJSHelper(value, __alreadySeen))\n })\n return res\n }\n if (isObservableMap(source)) {\n const res = cache(__alreadySeen, source, new Map())\n source.forEach((value, key) => {\n res.set(key, toJSHelper(value, __alreadySeen))\n })\n return res\n } else {\n // must be observable object\n const res = cache(__alreadySeen, source, {})\n apiOwnKeys(source).forEach((key: any) => {\n if (objectPrototype.propertyIsEnumerable.call(source, key)) {\n res[key] = toJSHelper(source[key], __alreadySeen)\n }\n })\n return res\n }\n}\n\n/**\n * Recursively converts an observable to it's non-observable native counterpart.\n * It does NOT recurse into non-observables, these are left as they are, even if they contain observables.\n * Computed and other non-enumerable properties are completely ignored.\n * Complex scenarios require custom solution, eg implementing `toJSON` or using `serializr` lib.\n */\nexport function toJS(source: T, options?: any): T {\n if (__DEV__ && options) {\n die(\"toJS no longer supports options\")\n }\n return toJSHelper(source, new Map())\n}\n", "import { TraceMode, die, getAtom, globalState } from \"../internal\"\n\nexport function trace(thing?: any, prop?: string, enterBreakPoint?: boolean): void\nexport function trace(thing?: any, enterBreakPoint?: boolean): void\nexport function trace(enterBreakPoint?: boolean): void\nexport function trace(...args: any[]): void {\n if (!__DEV__) {\n return\n }\n let enterBreakPoint = false\n if (typeof args[args.length - 1] === \"boolean\") {\n enterBreakPoint = args.pop()\n }\n const derivation = getAtomFromArgs(args)\n if (!derivation) {\n return die(\n `'trace(break?)' can only be used inside a tracked computed value or a Reaction. Consider passing in the computed value or reaction explicitly`\n )\n }\n if (derivation.isTracing_ === TraceMode.NONE) {\n console.log(`[mobx.trace] '${derivation.name_}' tracing enabled`)\n }\n derivation.isTracing_ = enterBreakPoint ? TraceMode.BREAK : TraceMode.LOG\n}\n\nfunction getAtomFromArgs(args): any {\n switch (args.length) {\n case 0:\n return globalState.trackingDerivation\n case 1:\n return getAtom(args[0])\n case 2:\n return getAtom(args[0], args[1])\n }\n}\n", "import { endBatch, startBatch } from \"../internal\"\n\n/**\n * During a transaction no views are updated until the end of the transaction.\n * The transaction will be run synchronously nonetheless.\n *\n * @param action a function that updates some reactive state\n * @returns any value that was returned by the 'action' parameter.\n */\nexport function transaction(action: () => T, thisArg = undefined): T {\n startBatch()\n try {\n return action.apply(thisArg)\n } finally {\n endBatch()\n }\n}\n", "import {\n $mobx,\n IReactionDisposer,\n Lambda,\n autorun,\n createAction,\n getNextId,\n die,\n allowStateChanges,\n GenericAbortSignal\n} from \"../internal\"\n\nexport interface IWhenOptions {\n name?: string\n timeout?: number\n onError?: (error: any) => void\n signal?: GenericAbortSignal\n}\n\nexport function when(\n predicate: () => boolean,\n opts?: IWhenOptions\n): Promise & { cancel(): void }\nexport function when(\n predicate: () => boolean,\n effect: Lambda,\n opts?: IWhenOptions\n): IReactionDisposer\nexport function when(predicate: any, arg1?: any, arg2?: any): any {\n if (arguments.length === 1 || (arg1 && typeof arg1 === \"object\")) {\n return whenPromise(predicate, arg1)\n }\n return _when(predicate, arg1, arg2 || {})\n}\n\nfunction _when(predicate: () => boolean, effect: Lambda, opts: IWhenOptions): IReactionDisposer {\n let timeoutHandle: any\n if (typeof opts.timeout === \"number\") {\n const error = new Error(\"WHEN_TIMEOUT\")\n timeoutHandle = setTimeout(() => {\n if (!disposer[$mobx].isDisposed_) {\n disposer()\n if (opts.onError) {\n opts.onError(error)\n } else {\n throw error\n }\n }\n }, opts.timeout)\n }\n\n opts.name = __DEV__ ? opts.name || \"When@\" + getNextId() : \"When\"\n const effectAction = createAction(\n __DEV__ ? opts.name + \"-effect\" : \"When-effect\",\n effect as Function\n )\n // eslint-disable-next-line\n var disposer = autorun(r => {\n // predicate should not change state\n let cond = allowStateChanges(false, predicate)\n if (cond) {\n r.dispose()\n if (timeoutHandle) {\n clearTimeout(timeoutHandle)\n }\n effectAction()\n }\n }, opts)\n return disposer\n}\n\nfunction whenPromise(\n predicate: () => boolean,\n opts?: IWhenOptions\n): Promise & { cancel(): void } {\n if (__DEV__ && opts && opts.onError) {\n return die(`the options 'onError' and 'promise' cannot be combined`)\n }\n if (opts?.signal?.aborted) {\n return Object.assign(Promise.reject(new Error(\"WHEN_ABORTED\")), { cancel: () => null })\n }\n let cancel\n let abort\n const res = new Promise((resolve, reject) => {\n let disposer = _when(predicate, resolve as Lambda, { ...opts, onError: reject })\n cancel = () => {\n disposer()\n reject(new Error(\"WHEN_CANCELLED\"))\n }\n abort = () => {\n disposer()\n reject(new Error(\"WHEN_ABORTED\"))\n }\n opts?.signal?.addEventListener?.(\"abort\", abort)\n }).finally(() => opts?.signal?.removeEventListener?.(\"abort\", abort))\n ;(res as any).cancel = cancel\n return res as any\n}\n", "import {\n $mobx,\n IIsObservableObject,\n ObservableObjectAdministration,\n warnAboutProxyRequirement,\n assertProxies,\n die,\n isStringish,\n globalState,\n CreateObservableOptions,\n asObservableObject\n} from \"../internal\"\n\nfunction getAdm(target): ObservableObjectAdministration {\n return target[$mobx]\n}\n\n// Optimization: we don't need the intermediate objects and could have a completely custom administration for DynamicObjects,\n// and skip either the internal values map, or the base object with its property descriptors!\nconst objectProxyTraps: ProxyHandler = {\n has(target: IIsObservableObject, name: PropertyKey): boolean {\n if (__DEV__ && globalState.trackingDerivation) {\n warnAboutProxyRequirement(\n \"detect new properties using the 'in' operator. Use 'has' from 'mobx' instead.\"\n )\n }\n return getAdm(target).has_(name)\n },\n get(target: IIsObservableObject, name: PropertyKey): any {\n return getAdm(target).get_(name)\n },\n set(target: IIsObservableObject, name: PropertyKey, value: any): boolean {\n if (!isStringish(name)) {\n return false\n }\n if (__DEV__ && !getAdm(target).values_.has(name)) {\n warnAboutProxyRequirement(\n \"add a new observable property through direct assignment. Use 'set' from 'mobx' instead.\"\n )\n }\n // null (intercepted) -> true (success)\n return getAdm(target).set_(name, value, true) ?? true\n },\n deleteProperty(target: IIsObservableObject, name: PropertyKey): boolean {\n if (__DEV__) {\n warnAboutProxyRequirement(\n \"delete properties from an observable object. Use 'remove' from 'mobx' instead.\"\n )\n }\n if (!isStringish(name)) {\n return false\n }\n // null (intercepted) -> true (success)\n return getAdm(target).delete_(name, true) ?? true\n },\n defineProperty(\n target: IIsObservableObject,\n name: PropertyKey,\n descriptor: PropertyDescriptor\n ): boolean {\n if (__DEV__) {\n warnAboutProxyRequirement(\n \"define property on an observable object. Use 'defineProperty' from 'mobx' instead.\"\n )\n }\n // null (intercepted) -> true (success)\n return getAdm(target).defineProperty_(name, descriptor) ?? true\n },\n ownKeys(target: IIsObservableObject): ArrayLike {\n if (__DEV__ && globalState.trackingDerivation) {\n warnAboutProxyRequirement(\n \"iterate keys to detect added / removed properties. Use 'keys' from 'mobx' instead.\"\n )\n }\n return getAdm(target).ownKeys_()\n },\n preventExtensions(target) {\n die(13)\n }\n}\n\nexport function asDynamicObservableObject(\n target: any,\n options?: CreateObservableOptions\n): IIsObservableObject {\n assertProxies()\n target = asObservableObject(target, options)\n return (target[$mobx].proxy_ ??= new Proxy(target, objectProxyTraps))\n}\n", "import { Lambda, once, untrackedEnd, untrackedStart, die } from \"../internal\"\n\nexport type IInterceptor = (change: T) => T | null\n\nexport interface IInterceptable {\n interceptors_: IInterceptor[] | undefined\n}\n\nexport function hasInterceptors(interceptable: IInterceptable) {\n return interceptable.interceptors_ !== undefined && interceptable.interceptors_.length > 0\n}\n\nexport function registerInterceptor(\n interceptable: IInterceptable,\n handler: IInterceptor\n): Lambda {\n const interceptors = interceptable.interceptors_ || (interceptable.interceptors_ = [])\n interceptors.push(handler)\n return once(() => {\n const idx = interceptors.indexOf(handler)\n if (idx !== -1) {\n interceptors.splice(idx, 1)\n }\n })\n}\n\nexport function interceptChange(\n interceptable: IInterceptable,\n change: T | null\n): T | null {\n const prevU = untrackedStart()\n try {\n // Interceptor can modify the array, copy it to avoid concurrent modification, see #1950\n const interceptors = [...(interceptable.interceptors_ || [])]\n for (let i = 0, l = interceptors.length; i < l; i++) {\n change = interceptors[i](change)\n if (change && !(change as any).type) {\n die(14)\n }\n if (!change) {\n break\n }\n }\n return change\n } finally {\n untrackedEnd(prevU)\n }\n}\n", "import { Lambda, once, untrackedEnd, untrackedStart } from \"../internal\"\n\nexport interface IListenable {\n changeListeners_: Function[] | undefined\n}\n\nexport function hasListeners(listenable: IListenable) {\n return listenable.changeListeners_ !== undefined && listenable.changeListeners_.length > 0\n}\n\nexport function registerListener(listenable: IListenable, handler: Function): Lambda {\n const listeners = listenable.changeListeners_ || (listenable.changeListeners_ = [])\n listeners.push(handler)\n return once(() => {\n const idx = listeners.indexOf(handler)\n if (idx !== -1) {\n listeners.splice(idx, 1)\n }\n })\n}\n\nexport function notifyListeners(listenable: IListenable, change: T) {\n const prevU = untrackedStart()\n let listeners = listenable.changeListeners_\n if (!listeners) {\n return\n }\n listeners = listeners.slice()\n for (let i = 0, l = listeners.length; i < l; i++) {\n listeners[i](change)\n }\n untrackedEnd(prevU)\n}\n", "import {\n $mobx,\n asObservableObject,\n AnnotationsMap,\n CreateObservableOptions,\n ObservableObjectAdministration,\n collectStoredAnnotations,\n isPlainObject,\n isObservableObject,\n die,\n ownKeys,\n extendObservable,\n addHiddenProp,\n storedAnnotationsSymbol,\n initObservable\n} from \"../internal\"\n\n// Hack based on https://github.com/Microsoft/TypeScript/issues/14829#issuecomment-322267089\n// We need this, because otherwise, AdditionalKeys is going to be inferred to be any\n// set of superfluous keys. But, we rather want to get a compile error unless AdditionalKeys is\n// _explicity_ passed as generic argument\n// Fixes: https://github.com/mobxjs/mobx/issues/2325#issuecomment-691070022\ntype NoInfer = [T][T extends any ? 0 : never]\n\ntype MakeObservableOptions = Omit\n\nexport function makeObservable(\n target: T,\n annotations?: AnnotationsMap>,\n options?: MakeObservableOptions\n): T {\n initObservable(() => {\n const adm: ObservableObjectAdministration = asObservableObject(target, options)[$mobx]\n if (__DEV__ && annotations && target[storedAnnotationsSymbol]) {\n die(\n `makeObservable second arg must be nullish when using decorators. Mixing @decorator syntax with annotations is not supported.`\n )\n }\n // Default to decorators\n annotations ??= collectStoredAnnotations(target)\n\n // Annotate\n ownKeys(annotations).forEach(key => adm.make_(key, annotations![key]))\n })\n return target\n}\n\n// proto[keysSymbol] = new Set()\nconst keysSymbol = Symbol(\"mobx-keys\")\n\nexport function makeAutoObservable(\n target: T,\n overrides?: AnnotationsMap>,\n options?: MakeObservableOptions\n): T {\n if (__DEV__) {\n if (!isPlainObject(target) && !isPlainObject(Object.getPrototypeOf(target))) {\n die(`'makeAutoObservable' can only be used for classes that don't have a superclass`)\n }\n if (isObservableObject(target)) {\n die(`makeAutoObservable can only be used on objects not already made observable`)\n }\n }\n\n // Optimization: avoid visiting protos\n // Assumes that annotation.make_/.extend_ works the same for plain objects\n if (isPlainObject(target)) {\n return extendObservable(target, target, overrides, options)\n }\n\n initObservable(() => {\n const adm: ObservableObjectAdministration = asObservableObject(target, options)[$mobx]\n\n // Optimization: cache keys on proto\n // Assumes makeAutoObservable can be called only once per object and can't be used in subclass\n if (!target[keysSymbol]) {\n const proto = Object.getPrototypeOf(target)\n const keys = new Set([...ownKeys(target), ...ownKeys(proto)])\n keys.delete(\"constructor\")\n keys.delete($mobx)\n addHiddenProp(proto, keysSymbol, keys)\n }\n\n target[keysSymbol].forEach(key =>\n adm.make_(\n key,\n // must pass \"undefined\" for { key: undefined }\n !overrides ? true : key in overrides ? overrides[key] : true\n )\n )\n })\n\n return target\n}\n", "import {\n $mobx,\n Atom,\n EMPTY_ARRAY,\n IAtom,\n IEnhancer,\n IInterceptable,\n IInterceptor,\n IListenable,\n Lambda,\n addHiddenFinalProp,\n checkIfStateModificationsAreAllowed,\n createInstanceofPredicate,\n getNextId,\n hasInterceptors,\n hasListeners,\n interceptChange,\n isObject,\n isSpyEnabled,\n notifyListeners,\n registerInterceptor,\n registerListener,\n spyReportEnd,\n spyReportStart,\n assertProxies,\n reserveArrayBuffer,\n hasProp,\n die,\n globalState,\n initObservable\n} from \"../internal\"\n\nconst SPLICE = \"splice\"\nexport const UPDATE = \"update\"\nexport const MAX_SPLICE_SIZE = 10000 // See e.g. https://github.com/mobxjs/mobx/issues/859\n\nexport interface IObservableArray extends Array {\n spliceWithArray(index: number, deleteCount?: number, newItems?: T[]): T[]\n clear(): T[]\n replace(newItems: T[]): T[]\n remove(value: T): boolean\n toJSON(): T[]\n}\n\ninterface IArrayBaseChange {\n object: IObservableArray\n observableKind: \"array\"\n debugObjectName: string\n index: number\n}\n\nexport type IArrayDidChange = IArrayUpdate | IArraySplice\n\nexport interface IArrayUpdate extends IArrayBaseChange {\n type: \"update\"\n newValue: T\n oldValue: T\n}\n\nexport interface IArraySplice extends IArrayBaseChange {\n type: \"splice\"\n added: T[]\n addedCount: number\n removed: T[]\n removedCount: number\n}\n\nexport interface IArrayWillChange {\n object: IObservableArray\n index: number\n type: \"update\"\n newValue: T\n}\n\nexport interface IArrayWillSplice {\n object: IObservableArray\n index: number\n type: \"splice\"\n added: T[]\n removedCount: number\n}\n\nconst arrayTraps = {\n get(target, name) {\n const adm: ObservableArrayAdministration = target[$mobx]\n if (name === $mobx) {\n return adm\n }\n if (name === \"length\") {\n return adm.getArrayLength_()\n }\n if (typeof name === \"string\" && !isNaN(name as any)) {\n return adm.get_(parseInt(name))\n }\n if (hasProp(arrayExtensions, name)) {\n return arrayExtensions[name]\n }\n return target[name]\n },\n set(target, name, value): boolean {\n const adm: ObservableArrayAdministration = target[$mobx]\n if (name === \"length\") {\n adm.setArrayLength_(value)\n }\n if (typeof name === \"symbol\" || isNaN(name)) {\n target[name] = value\n } else {\n // numeric string\n adm.set_(parseInt(name), value)\n }\n return true\n },\n preventExtensions() {\n die(15)\n }\n}\n\nexport class ObservableArrayAdministration\n implements IInterceptable | IArrayWillSplice>, IListenable\n{\n atom_: IAtom\n readonly values_: any[] = [] // this is the prop that gets proxied, so can't replace it!\n interceptors_\n changeListeners_\n enhancer_: (newV: any, oldV: any | undefined) => any\n dehancer: any\n proxy_!: IObservableArray\n lastKnownLength_ = 0\n\n constructor(\n name = __DEV__ ? \"ObservableArray@\" + getNextId() : \"ObservableArray\",\n enhancer: IEnhancer,\n public owned_: boolean,\n public legacyMode_: boolean\n ) {\n this.atom_ = new Atom(name)\n this.enhancer_ = (newV, oldV) =>\n enhancer(newV, oldV, __DEV__ ? name + \"[..]\" : \"ObservableArray[..]\")\n }\n\n dehanceValue_(value: any): any {\n if (this.dehancer !== undefined) {\n return this.dehancer(value)\n }\n return value\n }\n\n dehanceValues_(values: any[]): any[] {\n if (this.dehancer !== undefined && values.length > 0) {\n return values.map(this.dehancer) as any\n }\n return values\n }\n\n intercept_(handler: IInterceptor | IArrayWillSplice>): Lambda {\n return registerInterceptor | IArrayWillSplice>(this, handler)\n }\n\n observe_(\n listener: (changeData: IArrayDidChange) => void,\n fireImmediately = false\n ): Lambda {\n if (fireImmediately) {\n listener(>{\n observableKind: \"array\",\n object: this.proxy_ as any,\n debugObjectName: this.atom_.name_,\n type: \"splice\",\n index: 0,\n added: this.values_.slice(),\n addedCount: this.values_.length,\n removed: [],\n removedCount: 0\n })\n }\n return registerListener(this, listener)\n }\n\n getArrayLength_(): number {\n this.atom_.reportObserved()\n return this.values_.length\n }\n\n setArrayLength_(newLength: number) {\n if (typeof newLength !== \"number\" || isNaN(newLength) || newLength < 0) {\n die(\"Out of range: \" + newLength)\n }\n let currentLength = this.values_.length\n if (newLength === currentLength) {\n return\n } else if (newLength > currentLength) {\n const newItems = new Array(newLength - currentLength)\n for (let i = 0; i < newLength - currentLength; i++) {\n newItems[i] = undefined\n } // No Array.fill everywhere...\n this.spliceWithArray_(currentLength, 0, newItems)\n } else {\n this.spliceWithArray_(newLength, currentLength - newLength)\n }\n }\n\n updateArrayLength_(oldLength: number, delta: number) {\n if (oldLength !== this.lastKnownLength_) {\n die(16)\n }\n this.lastKnownLength_ += delta\n if (this.legacyMode_ && delta > 0) {\n reserveArrayBuffer(oldLength + delta + 1)\n }\n }\n\n spliceWithArray_(index: number, deleteCount?: number, newItems?: any[]): any[] {\n checkIfStateModificationsAreAllowed(this.atom_)\n const length = this.values_.length\n\n if (index === undefined) {\n index = 0\n } else if (index > length) {\n index = length\n } else if (index < 0) {\n index = Math.max(0, length + index)\n }\n\n if (arguments.length === 1) {\n deleteCount = length - index\n } else if (deleteCount === undefined || deleteCount === null) {\n deleteCount = 0\n } else {\n deleteCount = Math.max(0, Math.min(deleteCount, length - index))\n }\n\n if (newItems === undefined) {\n newItems = EMPTY_ARRAY\n }\n\n if (hasInterceptors(this)) {\n const change = interceptChange>(this as any, {\n object: this.proxy_ as any,\n type: SPLICE,\n index,\n removedCount: deleteCount,\n added: newItems\n })\n if (!change) {\n return EMPTY_ARRAY\n }\n deleteCount = change.removedCount\n newItems = change.added\n }\n\n newItems =\n newItems.length === 0 ? newItems : newItems.map(v => this.enhancer_(v, undefined))\n if (this.legacyMode_ || __DEV__) {\n const lengthDelta = newItems.length - deleteCount\n this.updateArrayLength_(length, lengthDelta) // checks if internal array wasn't modified\n }\n const res = this.spliceItemsIntoValues_(index, deleteCount, newItems)\n\n if (deleteCount !== 0 || newItems.length !== 0) {\n this.notifyArraySplice_(index, newItems, res)\n }\n return this.dehanceValues_(res)\n }\n\n spliceItemsIntoValues_(index: number, deleteCount: number, newItems: any[]): any[] {\n if (newItems.length < MAX_SPLICE_SIZE) {\n return this.values_.splice(index, deleteCount, ...newItems)\n } else {\n // The items removed by the splice\n const res = this.values_.slice(index, index + deleteCount)\n // The items that that should remain at the end of the array\n let oldItems = this.values_.slice(index + deleteCount)\n // New length is the previous length + addition count - deletion count\n this.values_.length += newItems.length - deleteCount\n for (let i = 0; i < newItems.length; i++) {\n this.values_[index + i] = newItems[i]\n }\n for (let i = 0; i < oldItems.length; i++) {\n this.values_[index + newItems.length + i] = oldItems[i]\n }\n return res\n }\n }\n\n notifyArrayChildUpdate_(index: number, newValue: any, oldValue: any) {\n const notifySpy = !this.owned_ && isSpyEnabled()\n const notify = hasListeners(this)\n const change: IArrayDidChange | null =\n notify || notifySpy\n ? ({\n observableKind: \"array\",\n object: this.proxy_,\n type: UPDATE,\n debugObjectName: this.atom_.name_,\n index,\n newValue,\n oldValue\n } as const)\n : null\n\n // The reason why this is on right hand side here (and not above), is this way the uglifier will drop it, but it won't\n // cause any runtime overhead in development mode without NODE_ENV set, unless spying is enabled\n if (__DEV__ && notifySpy) {\n spyReportStart(change!)\n }\n this.atom_.reportChanged()\n if (notify) {\n notifyListeners(this, change)\n }\n if (__DEV__ && notifySpy) {\n spyReportEnd()\n }\n }\n\n notifyArraySplice_(index: number, added: any[], removed: any[]) {\n const notifySpy = !this.owned_ && isSpyEnabled()\n const notify = hasListeners(this)\n const change: IArraySplice | null =\n notify || notifySpy\n ? ({\n observableKind: \"array\",\n object: this.proxy_,\n debugObjectName: this.atom_.name_,\n type: SPLICE,\n index,\n removed,\n added,\n removedCount: removed.length,\n addedCount: added.length\n } as const)\n : null\n\n if (__DEV__ && notifySpy) {\n spyReportStart(change!)\n }\n this.atom_.reportChanged()\n // conform: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/observe\n if (notify) {\n notifyListeners(this, change)\n }\n if (__DEV__ && notifySpy) {\n spyReportEnd()\n }\n }\n\n get_(index: number): any | undefined {\n if (this.legacyMode_ && index >= this.values_.length) {\n console.warn(\n __DEV__\n ? `[mobx.array] Attempt to read an array index (${index}) that is out of bounds (${this.values_.length}). Please check length first. Out of bound indices will not be tracked by MobX`\n : `[mobx] Out of bounds read: ${index}`\n )\n return undefined\n }\n this.atom_.reportObserved()\n return this.dehanceValue_(this.values_[index])\n }\n\n set_(index: number, newValue: any) {\n const values = this.values_\n if (this.legacyMode_ && index > values.length) {\n // out of bounds\n die(17, index, values.length)\n }\n if (index < values.length) {\n // update at index in range\n checkIfStateModificationsAreAllowed(this.atom_)\n const oldValue = values[index]\n if (hasInterceptors(this)) {\n const change = interceptChange>(this as any, {\n type: UPDATE,\n object: this.proxy_ as any, // since \"this\" is the real array we need to pass its proxy\n index,\n newValue\n })\n if (!change) {\n return\n }\n newValue = change.newValue\n }\n newValue = this.enhancer_(newValue, oldValue)\n const changed = newValue !== oldValue\n if (changed) {\n values[index] = newValue\n this.notifyArrayChildUpdate_(index, newValue, oldValue)\n }\n } else {\n // For out of bound index, we don't create an actual sparse array,\n // but rather fill the holes with undefined (same as setArrayLength_).\n // This could be considered a bug.\n const newItems = new Array(index + 1 - values.length)\n for (let i = 0; i < newItems.length - 1; i++) {\n newItems[i] = undefined\n } // No Array.fill everywhere...\n newItems[newItems.length - 1] = newValue\n this.spliceWithArray_(values.length, 0, newItems)\n }\n }\n}\n\nexport function createObservableArray(\n initialValues: T[] | undefined,\n enhancer: IEnhancer,\n name = __DEV__ ? \"ObservableArray@\" + getNextId() : \"ObservableArray\",\n owned = false\n): IObservableArray {\n assertProxies()\n return initObservable(() => {\n const adm = new ObservableArrayAdministration(name, enhancer, owned, false)\n addHiddenFinalProp(adm.values_, $mobx, adm)\n const proxy = new Proxy(adm.values_, arrayTraps) as any\n adm.proxy_ = proxy\n if (initialValues && initialValues.length) {\n adm.spliceWithArray_(0, 0, initialValues)\n }\n return proxy\n })\n}\n\n// eslint-disable-next-line\nexport var arrayExtensions = {\n clear(): any[] {\n return this.splice(0)\n },\n\n replace(newItems: any[]) {\n const adm: ObservableArrayAdministration = this[$mobx]\n return adm.spliceWithArray_(0, adm.values_.length, newItems)\n },\n\n // Used by JSON.stringify\n toJSON(): any[] {\n return this.slice()\n },\n\n /*\n * functions that do alter the internal structure of the array, (based on lib.es6.d.ts)\n * since these functions alter the inner structure of the array, the have side effects.\n * Because the have side effects, they should not be used in computed function,\n * and for that reason the do not call dependencyState.notifyObserved\n */\n splice(index: number, deleteCount?: number, ...newItems: any[]): any[] {\n const adm: ObservableArrayAdministration = this[$mobx]\n switch (arguments.length) {\n case 0:\n return []\n case 1:\n return adm.spliceWithArray_(index)\n case 2:\n return adm.spliceWithArray_(index, deleteCount)\n }\n return adm.spliceWithArray_(index, deleteCount, newItems)\n },\n\n spliceWithArray(index: number, deleteCount?: number, newItems?: any[]): any[] {\n return (this[$mobx] as ObservableArrayAdministration).spliceWithArray_(\n index,\n deleteCount,\n newItems\n )\n },\n\n push(...items: any[]): number {\n const adm: ObservableArrayAdministration = this[$mobx]\n adm.spliceWithArray_(adm.values_.length, 0, items)\n return adm.values_.length\n },\n\n pop() {\n return this.splice(Math.max(this[$mobx].values_.length - 1, 0), 1)[0]\n },\n\n shift() {\n return this.splice(0, 1)[0]\n },\n\n unshift(...items: any[]): number {\n const adm: ObservableArrayAdministration = this[$mobx]\n adm.spliceWithArray_(0, 0, items)\n return adm.values_.length\n },\n\n reverse(): any[] {\n // reverse by default mutates in place before returning the result\n // which makes it both a 'derivation' and a 'mutation'.\n if (globalState.trackingDerivation) {\n die(37, \"reverse\")\n }\n this.replace(this.slice().reverse())\n return this\n },\n\n sort(): any[] {\n // sort by default mutates in place before returning the result\n // which goes against all good practices. Let's not change the array in place!\n if (globalState.trackingDerivation) {\n die(37, \"sort\")\n }\n const copy = this.slice()\n copy.sort.apply(copy, arguments)\n this.replace(copy)\n return this\n },\n\n remove(value: any): boolean {\n const adm: ObservableArrayAdministration = this[$mobx]\n const idx = adm.dehanceValues_(adm.values_).indexOf(value)\n if (idx > -1) {\n this.splice(idx, 1)\n return true\n }\n return false\n }\n}\n\n/**\n * Wrap function from prototype\n * Without this, everything works as well, but this works\n * faster as everything works on unproxied values\n */\naddArrayExtension(\"at\", simpleFunc)\naddArrayExtension(\"concat\", simpleFunc)\naddArrayExtension(\"flat\", simpleFunc)\naddArrayExtension(\"includes\", simpleFunc)\naddArrayExtension(\"indexOf\", simpleFunc)\naddArrayExtension(\"join\", simpleFunc)\naddArrayExtension(\"lastIndexOf\", simpleFunc)\naddArrayExtension(\"slice\", simpleFunc)\naddArrayExtension(\"toString\", simpleFunc)\naddArrayExtension(\"toLocaleString\", simpleFunc)\naddArrayExtension(\"toSorted\", simpleFunc)\naddArrayExtension(\"toSpliced\", simpleFunc)\naddArrayExtension(\"with\", simpleFunc)\n// map\naddArrayExtension(\"every\", mapLikeFunc)\naddArrayExtension(\"filter\", mapLikeFunc)\naddArrayExtension(\"find\", mapLikeFunc)\naddArrayExtension(\"findIndex\", mapLikeFunc)\naddArrayExtension(\"findLast\", mapLikeFunc)\naddArrayExtension(\"findLastIndex\", mapLikeFunc)\naddArrayExtension(\"flatMap\", mapLikeFunc)\naddArrayExtension(\"forEach\", mapLikeFunc)\naddArrayExtension(\"map\", mapLikeFunc)\naddArrayExtension(\"some\", mapLikeFunc)\naddArrayExtension(\"toReversed\", mapLikeFunc)\n// reduce\naddArrayExtension(\"reduce\", reduceLikeFunc)\naddArrayExtension(\"reduceRight\", reduceLikeFunc)\n\nfunction addArrayExtension(funcName, funcFactory) {\n if (typeof Array.prototype[funcName] === \"function\") {\n arrayExtensions[funcName] = funcFactory(funcName)\n }\n}\n\n// Report and delegate to dehanced array\nfunction simpleFunc(funcName) {\n return function () {\n const adm: ObservableArrayAdministration = this[$mobx]\n adm.atom_.reportObserved()\n const dehancedValues = adm.dehanceValues_(adm.values_)\n return dehancedValues[funcName].apply(dehancedValues, arguments)\n }\n}\n\n// Make sure callbacks receive correct array arg #2326\nfunction mapLikeFunc(funcName) {\n return function (callback, thisArg) {\n const adm: ObservableArrayAdministration = this[$mobx]\n adm.atom_.reportObserved()\n const dehancedValues = adm.dehanceValues_(adm.values_)\n return dehancedValues[funcName]((element, index) => {\n return callback.call(thisArg, element, index, this)\n })\n }\n}\n\n// Make sure callbacks receive correct array arg #2326\nfunction reduceLikeFunc(funcName) {\n return function () {\n const adm: ObservableArrayAdministration = this[$mobx]\n adm.atom_.reportObserved()\n const dehancedValues = adm.dehanceValues_(adm.values_)\n // #2432 - reduce behavior depends on arguments.length\n const callback = arguments[0]\n arguments[0] = (accumulator, currentValue, index) => {\n return callback(accumulator, currentValue, index, this)\n }\n return dehancedValues[funcName].apply(dehancedValues, arguments)\n }\n}\n\nconst isObservableArrayAdministration = createInstanceofPredicate(\n \"ObservableArrayAdministration\",\n ObservableArrayAdministration\n)\n\nexport function isObservableArray(thing): thing is IObservableArray {\n return isObject(thing) && isObservableArrayAdministration(thing[$mobx])\n}\n", "import {\n $mobx,\n IEnhancer,\n IInterceptable,\n IInterceptor,\n IListenable,\n Lambda,\n ObservableValue,\n checkIfStateModificationsAreAllowed,\n createAtom,\n createInstanceofPredicate,\n deepEnhancer,\n getNextId,\n getPlainObjectKeys,\n hasInterceptors,\n hasListeners,\n interceptChange,\n isES6Map,\n isPlainObject,\n isSpyEnabled,\n makeIterable,\n notifyListeners,\n referenceEnhancer,\n registerInterceptor,\n registerListener,\n spyReportEnd,\n spyReportStart,\n stringifyKey,\n transaction,\n untracked,\n onBecomeUnobserved,\n globalState,\n die,\n isFunction,\n UPDATE,\n IAtom,\n PureSpyEvent,\n initObservable\n} from \"../internal\"\n\nexport interface IKeyValueMap {\n [key: string]: V\n}\n\nexport type IMapEntry = [K, V]\nexport type IReadonlyMapEntry = readonly [K, V]\nexport type IMapEntries = IMapEntry[]\nexport type IReadonlyMapEntries = IReadonlyMapEntry[]\n\nexport type IMapDidChange = { observableKind: \"map\"; debugObjectName: string } & (\n | {\n object: ObservableMap\n name: K // actual the key or index, but this is based on the ancient .observe proposal for consistency\n type: \"update\"\n newValue: V\n oldValue: V\n }\n | {\n object: ObservableMap\n name: K\n type: \"add\"\n newValue: V\n }\n | {\n object: ObservableMap\n name: K\n type: \"delete\"\n oldValue: V\n }\n)\n\nexport interface IMapWillChange {\n object: ObservableMap\n type: \"update\" | \"add\" | \"delete\"\n name: K\n newValue?: V\n}\n\nconst ObservableMapMarker = {}\n\nexport const ADD = \"add\"\nexport const DELETE = \"delete\"\n\nexport type IObservableMapInitialValues =\n | IMapEntries\n | IReadonlyMapEntries\n | IKeyValueMap\n | Map\n\n// just extend Map? See also https://gist.github.com/nestharus/13b4d74f2ef4a2f4357dbd3fc23c1e54\n// But: https://github.com/mobxjs/mobx/issues/1556\nexport class ObservableMap\n implements Map, IInterceptable>, IListenable\n{\n [$mobx] = ObservableMapMarker\n data_!: Map>\n hasMap_!: Map> // hasMap, not hashMap >-).\n keysAtom_!: IAtom\n interceptors_\n changeListeners_\n dehancer: any\n\n constructor(\n initialData?: IObservableMapInitialValues,\n public enhancer_: IEnhancer = deepEnhancer,\n public name_ = __DEV__ ? \"ObservableMap@\" + getNextId() : \"ObservableMap\"\n ) {\n if (!isFunction(Map)) {\n die(18)\n }\n initObservable(() => {\n this.keysAtom_ = createAtom(__DEV__ ? `${this.name_}.keys()` : \"ObservableMap.keys()\")\n this.data_ = new Map()\n this.hasMap_ = new Map()\n if (initialData) {\n this.merge(initialData)\n }\n })\n }\n\n private has_(key: K): boolean {\n return this.data_.has(key)\n }\n\n has(key: K): boolean {\n if (!globalState.trackingDerivation) {\n return this.has_(key)\n }\n\n let entry = this.hasMap_.get(key)\n if (!entry) {\n const newEntry = (entry = new ObservableValue(\n this.has_(key),\n referenceEnhancer,\n __DEV__ ? `${this.name_}.${stringifyKey(key)}?` : \"ObservableMap.key?\",\n false\n ))\n this.hasMap_.set(key, newEntry)\n onBecomeUnobserved(newEntry, () => this.hasMap_.delete(key))\n }\n\n return entry.get()\n }\n\n set(key: K, value: V) {\n const hasKey = this.has_(key)\n if (hasInterceptors(this)) {\n const change = interceptChange>(this, {\n type: hasKey ? UPDATE : ADD,\n object: this,\n newValue: value,\n name: key\n })\n if (!change) {\n return this\n }\n value = change.newValue!\n }\n if (hasKey) {\n this.updateValue_(key, value)\n } else {\n this.addValue_(key, value)\n }\n return this\n }\n\n delete(key: K): boolean {\n checkIfStateModificationsAreAllowed(this.keysAtom_)\n if (hasInterceptors(this)) {\n const change = interceptChange>(this, {\n type: DELETE,\n object: this,\n name: key\n })\n if (!change) {\n return false\n }\n }\n if (this.has_(key)) {\n const notifySpy = isSpyEnabled()\n const notify = hasListeners(this)\n const change: IMapDidChange | null =\n notify || notifySpy\n ? {\n observableKind: \"map\",\n debugObjectName: this.name_,\n type: DELETE,\n object: this,\n oldValue: (this.data_.get(key)).value_,\n name: key\n }\n : null\n\n if (__DEV__ && notifySpy) {\n spyReportStart(change! as PureSpyEvent)\n } // TODO fix type\n transaction(() => {\n this.keysAtom_.reportChanged()\n this.hasMap_.get(key)?.setNewValue_(false)\n const observable = this.data_.get(key)!\n observable.setNewValue_(undefined as any)\n this.data_.delete(key)\n })\n if (notify) {\n notifyListeners(this, change)\n }\n if (__DEV__ && notifySpy) {\n spyReportEnd()\n }\n return true\n }\n return false\n }\n\n private updateValue_(key: K, newValue: V | undefined) {\n const observable = this.data_.get(key)!\n newValue = (observable as any).prepareNewValue_(newValue) as V\n if (newValue !== globalState.UNCHANGED) {\n const notifySpy = isSpyEnabled()\n const notify = hasListeners(this)\n const change: IMapDidChange | null =\n notify || notifySpy\n ? {\n observableKind: \"map\",\n debugObjectName: this.name_,\n type: UPDATE,\n object: this,\n oldValue: (observable as any).value_,\n name: key,\n newValue\n }\n : null\n if (__DEV__ && notifySpy) {\n spyReportStart(change! as PureSpyEvent)\n } // TODO fix type\n observable.setNewValue_(newValue as V)\n if (notify) {\n notifyListeners(this, change)\n }\n if (__DEV__ && notifySpy) {\n spyReportEnd()\n }\n }\n }\n\n private addValue_(key: K, newValue: V) {\n checkIfStateModificationsAreAllowed(this.keysAtom_)\n transaction(() => {\n const observable = new ObservableValue(\n newValue,\n this.enhancer_,\n __DEV__ ? `${this.name_}.${stringifyKey(key)}` : \"ObservableMap.key\",\n false\n )\n this.data_.set(key, observable)\n newValue = (observable as any).value_ // value might have been changed\n this.hasMap_.get(key)?.setNewValue_(true)\n this.keysAtom_.reportChanged()\n })\n const notifySpy = isSpyEnabled()\n const notify = hasListeners(this)\n const change: IMapDidChange | null =\n notify || notifySpy\n ? {\n observableKind: \"map\",\n debugObjectName: this.name_,\n type: ADD,\n object: this,\n name: key,\n newValue\n }\n : null\n if (__DEV__ && notifySpy) {\n spyReportStart(change! as PureSpyEvent)\n } // TODO fix type\n if (notify) {\n notifyListeners(this, change)\n }\n if (__DEV__ && notifySpy) {\n spyReportEnd()\n }\n }\n\n get(key: K): V | undefined {\n if (this.has(key)) {\n return this.dehanceValue_(this.data_.get(key)!.get())\n }\n return this.dehanceValue_(undefined)\n }\n\n private dehanceValue_(value: X): X {\n if (this.dehancer !== undefined) {\n return this.dehancer(value)\n }\n return value\n }\n\n keys(): IterableIterator {\n this.keysAtom_.reportObserved()\n return this.data_.keys()\n }\n\n values(): IterableIterator {\n const self = this\n const keys = this.keys()\n return makeIterable({\n next() {\n const { done, value } = keys.next()\n return {\n done,\n value: done ? (undefined as any) : self.get(value)\n }\n }\n })\n }\n\n entries(): IterableIterator> {\n const self = this\n const keys = this.keys()\n return makeIterable({\n next() {\n const { done, value } = keys.next()\n return {\n done,\n value: done ? (undefined as any) : ([value, self.get(value)!] as [K, V])\n }\n }\n })\n }\n\n [Symbol.iterator]() {\n return this.entries()\n }\n\n forEach(callback: (value: V, key: K, object: Map) => void, thisArg?) {\n for (const [key, value] of this) {\n callback.call(thisArg, value, key, this)\n }\n }\n\n /** Merge another object into this object, returns this. */\n merge(other?: IObservableMapInitialValues): ObservableMap {\n if (isObservableMap(other)) {\n other = new Map(other)\n }\n transaction(() => {\n if (isPlainObject(other)) {\n getPlainObjectKeys(other).forEach((key: any) =>\n this.set(key as K, (other as IKeyValueMap)[key])\n )\n } else if (Array.isArray(other)) {\n other.forEach(([key, value]) => this.set(key, value))\n } else if (isES6Map(other)) {\n if (other.constructor !== Map) {\n die(19, other)\n }\n other.forEach((value, key) => this.set(key, value))\n } else if (other !== null && other !== undefined) {\n die(20, other)\n }\n })\n return this\n }\n\n clear() {\n transaction(() => {\n untracked(() => {\n for (const key of this.keys()) {\n this.delete(key)\n }\n })\n })\n }\n\n replace(values: IObservableMapInitialValues): ObservableMap {\n // Implementation requirements:\n // - respect ordering of replacement map\n // - allow interceptors to run and potentially prevent individual operations\n // - don't recreate observables that already exist in original map (so we don't destroy existing subscriptions)\n // - don't _keysAtom.reportChanged if the keys of resulting map are indentical (order matters!)\n // - note that result map may differ from replacement map due to the interceptors\n transaction(() => {\n // Convert to map so we can do quick key lookups\n const replacementMap = convertToMap(values)\n const orderedData = new Map()\n // Used for optimization\n let keysReportChangedCalled = false\n // Delete keys that don't exist in replacement map\n // if the key deletion is prevented by interceptor\n // add entry at the beginning of the result map\n for (const key of this.data_.keys()) {\n // Concurrently iterating/deleting keys\n // iterator should handle this correctly\n if (!replacementMap.has(key)) {\n const deleted = this.delete(key)\n // Was the key removed?\n if (deleted) {\n // _keysAtom.reportChanged() was already called\n keysReportChangedCalled = true\n } else {\n // Delete prevented by interceptor\n const value = this.data_.get(key)\n orderedData.set(key, value)\n }\n }\n }\n // Merge entries\n for (const [key, value] of replacementMap.entries()) {\n // We will want to know whether a new key is added\n const keyExisted = this.data_.has(key)\n // Add or update value\n this.set(key, value)\n // The addition could have been prevent by interceptor\n if (this.data_.has(key)) {\n // The update could have been prevented by interceptor\n // and also we want to preserve existing values\n // so use value from _data map (instead of replacement map)\n const value = this.data_.get(key)\n orderedData.set(key, value)\n // Was a new key added?\n if (!keyExisted) {\n // _keysAtom.reportChanged() was already called\n keysReportChangedCalled = true\n }\n }\n }\n // Check for possible key order change\n if (!keysReportChangedCalled) {\n if (this.data_.size !== orderedData.size) {\n // If size differs, keys are definitely modified\n this.keysAtom_.reportChanged()\n } else {\n const iter1 = this.data_.keys()\n const iter2 = orderedData.keys()\n let next1 = iter1.next()\n let next2 = iter2.next()\n while (!next1.done) {\n if (next1.value !== next2.value) {\n this.keysAtom_.reportChanged()\n break\n }\n next1 = iter1.next()\n next2 = iter2.next()\n }\n }\n }\n // Use correctly ordered map\n this.data_ = orderedData\n })\n return this\n }\n\n get size(): number {\n this.keysAtom_.reportObserved()\n return this.data_.size\n }\n\n toString(): string {\n return \"[object ObservableMap]\"\n }\n\n toJSON(): [K, V][] {\n return Array.from(this)\n }\n\n get [Symbol.toStringTag]() {\n return \"Map\"\n }\n\n /**\n * Observes this object. Triggers for the events 'add', 'update' and 'delete'.\n * See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe\n * for callback details\n */\n observe_(listener: (changes: IMapDidChange) => void, fireImmediately?: boolean): Lambda {\n if (__DEV__ && fireImmediately === true) {\n die(\"`observe` doesn't support fireImmediately=true in combination with maps.\")\n }\n return registerListener(this, listener)\n }\n\n intercept_(handler: IInterceptor>): Lambda {\n return registerInterceptor(this, handler)\n }\n}\n\n// eslint-disable-next-line\nexport var isObservableMap = createInstanceofPredicate(\"ObservableMap\", ObservableMap) as (\n thing: any\n) => thing is ObservableMap\n\nfunction convertToMap(dataStructure: any): Map {\n if (isES6Map(dataStructure) || isObservableMap(dataStructure)) {\n return dataStructure\n } else if (Array.isArray(dataStructure)) {\n return new Map(dataStructure)\n } else if (isPlainObject(dataStructure)) {\n const map = new Map()\n for (const key in dataStructure) {\n map.set(key, dataStructure[key])\n }\n return map\n } else {\n return die(21, dataStructure)\n }\n}\n", "import {\n $mobx,\n createAtom,\n deepEnhancer,\n getNextId,\n IEnhancer,\n isSpyEnabled,\n hasListeners,\n IListenable,\n registerListener,\n Lambda,\n spyReportStart,\n notifyListeners,\n spyReportEnd,\n createInstanceofPredicate,\n hasInterceptors,\n interceptChange,\n IInterceptable,\n IInterceptor,\n registerInterceptor,\n checkIfStateModificationsAreAllowed,\n untracked,\n makeIterable,\n transaction,\n isES6Set,\n IAtom,\n DELETE,\n ADD,\n die,\n isFunction,\n initObservable\n} from \"../internal\"\n\nconst ObservableSetMarker = {}\n\nexport type IObservableSetInitialValues = Set | readonly T[]\n\nexport type ISetDidChange =\n | {\n object: ObservableSet\n observableKind: \"set\"\n debugObjectName: string\n type: \"add\"\n newValue: T\n }\n | {\n object: ObservableSet\n observableKind: \"set\"\n debugObjectName: string\n type: \"delete\"\n oldValue: T\n }\n\nexport type ISetWillChange =\n | {\n type: \"delete\"\n object: ObservableSet\n oldValue: T\n }\n | {\n type: \"add\"\n object: ObservableSet\n newValue: T\n }\n\nexport class ObservableSet implements Set, IInterceptable, IListenable {\n [$mobx] = ObservableSetMarker\n private data_: Set = new Set()\n atom_!: IAtom\n changeListeners_\n interceptors_\n dehancer: any\n enhancer_: (newV: any, oldV: any | undefined) => any\n\n constructor(\n initialData?: IObservableSetInitialValues,\n enhancer: IEnhancer = deepEnhancer,\n public name_ = __DEV__ ? \"ObservableSet@\" + getNextId() : \"ObservableSet\"\n ) {\n if (!isFunction(Set)) {\n die(22)\n }\n this.enhancer_ = (newV, oldV) => enhancer(newV, oldV, name_)\n initObservable(() => {\n this.atom_ = createAtom(this.name_)\n if (initialData) {\n this.replace(initialData)\n }\n })\n }\n\n private dehanceValue_(value: X): X {\n if (this.dehancer !== undefined) {\n return this.dehancer(value)\n }\n return value\n }\n\n clear() {\n transaction(() => {\n untracked(() => {\n for (const value of this.data_.values()) {\n this.delete(value)\n }\n })\n })\n }\n\n forEach(callbackFn: (value: T, value2: T, set: Set) => void, thisArg?: any) {\n for (const value of this) {\n callbackFn.call(thisArg, value, value, this)\n }\n }\n\n get size() {\n this.atom_.reportObserved()\n return this.data_.size\n }\n\n add(value: T) {\n checkIfStateModificationsAreAllowed(this.atom_)\n if (hasInterceptors(this)) {\n const change = interceptChange>(this, {\n type: ADD,\n object: this,\n newValue: value\n })\n if (!change) {\n return this\n }\n // ideally, value = change.value would be done here, so that values can be\n // changed by interceptor. Same applies for other Set and Map api's.\n }\n if (!this.has(value)) {\n transaction(() => {\n this.data_.add(this.enhancer_(value, undefined))\n this.atom_.reportChanged()\n })\n const notifySpy = __DEV__ && isSpyEnabled()\n const notify = hasListeners(this)\n const change =\n notify || notifySpy\n ? >{\n observableKind: \"set\",\n debugObjectName: this.name_,\n type: ADD,\n object: this,\n newValue: value\n }\n : null\n if (notifySpy && __DEV__) {\n spyReportStart(change!)\n }\n if (notify) {\n notifyListeners(this, change)\n }\n if (notifySpy && __DEV__) {\n spyReportEnd()\n }\n }\n\n return this\n }\n\n delete(value: T) {\n if (hasInterceptors(this)) {\n const change = interceptChange>(this, {\n type: DELETE,\n object: this,\n oldValue: value\n })\n if (!change) {\n return false\n }\n }\n if (this.has(value)) {\n const notifySpy = __DEV__ && isSpyEnabled()\n const notify = hasListeners(this)\n const change =\n notify || notifySpy\n ? >{\n observableKind: \"set\",\n debugObjectName: this.name_,\n type: DELETE,\n object: this,\n oldValue: value\n }\n : null\n\n if (notifySpy && __DEV__) {\n spyReportStart(change!)\n }\n transaction(() => {\n this.atom_.reportChanged()\n this.data_.delete(value)\n })\n if (notify) {\n notifyListeners(this, change)\n }\n if (notifySpy && __DEV__) {\n spyReportEnd()\n }\n return true\n }\n return false\n }\n\n has(value: T) {\n this.atom_.reportObserved()\n return this.data_.has(this.dehanceValue_(value))\n }\n\n entries() {\n let nextIndex = 0\n const keys = Array.from(this.keys())\n const values = Array.from(this.values())\n return makeIterable<[T, T]>({\n next() {\n const index = nextIndex\n nextIndex += 1\n return index < values.length\n ? { value: [keys[index], values[index]], done: false }\n : { done: true }\n }\n } as any)\n }\n\n keys(): IterableIterator {\n return this.values()\n }\n\n values(): IterableIterator {\n this.atom_.reportObserved()\n const self = this\n let nextIndex = 0\n const observableValues = Array.from(this.data_.values())\n return makeIterable({\n next() {\n return nextIndex < observableValues.length\n ? { value: self.dehanceValue_(observableValues[nextIndex++]), done: false }\n : { done: true }\n }\n } as any)\n }\n\n replace(other: ObservableSet | IObservableSetInitialValues): ObservableSet {\n if (isObservableSet(other)) {\n other = new Set(other)\n }\n\n transaction(() => {\n if (Array.isArray(other)) {\n this.clear()\n other.forEach(value => this.add(value))\n } else if (isES6Set(other)) {\n this.clear()\n other.forEach(value => this.add(value))\n } else if (other !== null && other !== undefined) {\n die(\"Cannot initialize set from \" + other)\n }\n })\n\n return this\n }\n observe_(listener: (changes: ISetDidChange) => void, fireImmediately?: boolean): Lambda {\n // ... 'fireImmediately' could also be true?\n if (__DEV__ && fireImmediately === true) {\n die(\"`observe` doesn't support fireImmediately=true in combination with sets.\")\n }\n return registerListener(this, listener)\n }\n\n intercept_(handler: IInterceptor>): Lambda {\n return registerInterceptor(this, handler)\n }\n\n toJSON(): T[] {\n return Array.from(this)\n }\n\n toString(): string {\n return \"[object ObservableSet]\"\n }\n\n [Symbol.iterator]() {\n return this.values()\n }\n\n get [Symbol.toStringTag]() {\n return \"Set\"\n }\n}\n\n// eslint-disable-next-line\nexport var isObservableSet = createInstanceofPredicate(\"ObservableSet\", ObservableSet) as (\n thing: any\n) => thing is ObservableSet\n", "import {\n CreateObservableOptions,\n getAnnotationFromOptions,\n propagateChanged,\n isAnnotation,\n $mobx,\n Atom,\n Annotation,\n ComputedValue,\n IAtom,\n IComputedValueOptions,\n IEnhancer,\n IInterceptable,\n IListenable,\n Lambda,\n ObservableValue,\n addHiddenProp,\n createInstanceofPredicate,\n endBatch,\n getNextId,\n hasInterceptors,\n hasListeners,\n interceptChange,\n isObject,\n isPlainObject,\n isSpyEnabled,\n notifyListeners,\n referenceEnhancer,\n registerInterceptor,\n registerListener,\n spyReportEnd,\n spyReportStart,\n startBatch,\n stringifyKey,\n globalState,\n ADD,\n UPDATE,\n die,\n hasProp,\n getDescriptor,\n storedAnnotationsSymbol,\n ownKeys,\n isOverride,\n defineProperty,\n autoAnnotation,\n getAdministration,\n getDebugName,\n objectPrototype,\n MakeResult,\n checkIfStateModificationsAreAllowed\n} from \"../internal\"\n\nconst descriptorCache = Object.create(null)\n\nexport type IObjectDidChange = {\n observableKind: \"object\"\n name: PropertyKey\n object: T\n debugObjectName: string\n} & (\n | {\n type: \"add\"\n newValue: any\n }\n | {\n type: \"update\"\n oldValue: any\n newValue: any\n }\n | {\n type: \"remove\"\n oldValue: any\n }\n)\n\nexport type IObjectWillChange =\n | {\n object: T\n type: \"update\" | \"add\"\n name: PropertyKey\n newValue: any\n }\n | {\n object: T\n type: \"remove\"\n name: PropertyKey\n }\n\nconst REMOVE = \"remove\"\n\nexport class ObservableObjectAdministration\n implements IInterceptable, IListenable\n{\n keysAtom_: IAtom\n changeListeners_\n interceptors_\n proxy_: any\n isPlainObject_: boolean\n appliedAnnotations_?: object\n private pendingKeys_: undefined | Map>\n\n constructor(\n public target_: any,\n public values_ = new Map | ComputedValue>(),\n public name_: string,\n // Used anytime annotation is not explicitely provided\n public defaultAnnotation_: Annotation = autoAnnotation\n ) {\n this.keysAtom_ = new Atom(__DEV__ ? `${this.name_}.keys` : \"ObservableObject.keys\")\n // Optimization: we use this frequently\n this.isPlainObject_ = isPlainObject(this.target_)\n if (__DEV__ && !isAnnotation(this.defaultAnnotation_)) {\n die(`defaultAnnotation must be valid annotation`)\n }\n if (__DEV__) {\n // Prepare structure for tracking which fields were already annotated\n this.appliedAnnotations_ = {}\n }\n }\n\n getObservablePropValue_(key: PropertyKey): any {\n return this.values_.get(key)!.get()\n }\n\n setObservablePropValue_(key: PropertyKey, newValue): boolean | null {\n const observable = this.values_.get(key)\n if (observable instanceof ComputedValue) {\n observable.set(newValue)\n return true\n }\n\n // intercept\n if (hasInterceptors(this)) {\n const change = interceptChange(this, {\n type: UPDATE,\n object: this.proxy_ || this.target_,\n name: key,\n newValue\n })\n if (!change) {\n return null\n }\n newValue = (change as any).newValue\n }\n newValue = (observable as any).prepareNewValue_(newValue)\n\n // notify spy & observers\n if (newValue !== globalState.UNCHANGED) {\n const notify = hasListeners(this)\n const notifySpy = __DEV__ && isSpyEnabled()\n const change: IObjectDidChange | null =\n notify || notifySpy\n ? {\n type: UPDATE,\n observableKind: \"object\",\n debugObjectName: this.name_,\n object: this.proxy_ || this.target_,\n oldValue: (observable as any).value_,\n name: key,\n newValue\n }\n : null\n\n if (__DEV__ && notifySpy) {\n spyReportStart(change!)\n }\n ;(observable as ObservableValue).setNewValue_(newValue)\n if (notify) {\n notifyListeners(this, change)\n }\n if (__DEV__ && notifySpy) {\n spyReportEnd()\n }\n }\n return true\n }\n\n get_(key: PropertyKey): any {\n if (globalState.trackingDerivation && !hasProp(this.target_, key)) {\n // Key doesn't exist yet, subscribe for it in case it's added later\n this.has_(key)\n }\n return this.target_[key]\n }\n\n /**\n * @param {PropertyKey} key\n * @param {any} value\n * @param {Annotation|boolean} annotation true - use default annotation, false - copy as is\n * @param {boolean} proxyTrap whether it's called from proxy trap\n * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor\n */\n set_(key: PropertyKey, value: any, proxyTrap: boolean = false): boolean | null {\n // Don't use .has(key) - we care about own\n if (hasProp(this.target_, key)) {\n // Existing prop\n if (this.values_.has(key)) {\n // Observable (can be intercepted)\n return this.setObservablePropValue_(key, value)\n } else if (proxyTrap) {\n // Non-observable - proxy\n return Reflect.set(this.target_, key, value)\n } else {\n // Non-observable\n this.target_[key] = value\n return true\n }\n } else {\n // New prop\n return this.extend_(\n key,\n { value, enumerable: true, writable: true, configurable: true },\n this.defaultAnnotation_,\n proxyTrap\n )\n }\n }\n\n // Trap for \"in\"\n has_(key: PropertyKey): boolean {\n if (!globalState.trackingDerivation) {\n // Skip key subscription outside derivation\n return key in this.target_\n }\n this.pendingKeys_ ||= new Map()\n let entry = this.pendingKeys_.get(key)\n if (!entry) {\n entry = new ObservableValue(\n key in this.target_,\n referenceEnhancer,\n __DEV__ ? `${this.name_}.${stringifyKey(key)}?` : \"ObservableObject.key?\",\n false\n )\n this.pendingKeys_.set(key, entry)\n }\n return entry.get()\n }\n\n /**\n * @param {PropertyKey} key\n * @param {Annotation|boolean} annotation true - use default annotation, false - ignore prop\n */\n make_(key: PropertyKey, annotation: Annotation | boolean): void {\n if (annotation === true) {\n annotation = this.defaultAnnotation_\n }\n if (annotation === false) {\n return\n }\n assertAnnotable(this, annotation, key)\n if (!(key in this.target_)) {\n // Throw on missing key, except for decorators:\n // Decorator annotations are collected from whole prototype chain.\n // When called from super() some props may not exist yet.\n // However we don't have to worry about missing prop,\n // because the decorator must have been applied to something.\n if (this.target_[storedAnnotationsSymbol]?.[key]) {\n return // will be annotated by subclass constructor\n } else {\n die(1, annotation.annotationType_, `${this.name_}.${key.toString()}`)\n }\n }\n let source = this.target_\n while (source && source !== objectPrototype) {\n const descriptor = getDescriptor(source, key)\n if (descriptor) {\n const outcome = annotation.make_(this, key, descriptor, source)\n if (outcome === MakeResult.Cancel) {\n return\n }\n if (outcome === MakeResult.Break) {\n break\n }\n }\n source = Object.getPrototypeOf(source)\n }\n recordAnnotationApplied(this, annotation, key)\n }\n\n /**\n * @param {PropertyKey} key\n * @param {PropertyDescriptor} descriptor\n * @param {Annotation|boolean} annotation true - use default annotation, false - copy as is\n * @param {boolean} proxyTrap whether it's called from proxy trap\n * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor\n */\n extend_(\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n annotation: Annotation | boolean,\n proxyTrap: boolean = false\n ): boolean | null {\n if (annotation === true) {\n annotation = this.defaultAnnotation_\n }\n if (annotation === false) {\n return this.defineProperty_(key, descriptor, proxyTrap)\n }\n assertAnnotable(this, annotation, key)\n const outcome = annotation.extend_(this, key, descriptor, proxyTrap)\n if (outcome) {\n recordAnnotationApplied(this, annotation, key)\n }\n return outcome\n }\n\n /**\n * @param {PropertyKey} key\n * @param {PropertyDescriptor} descriptor\n * @param {boolean} proxyTrap whether it's called from proxy trap\n * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor\n */\n defineProperty_(\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n proxyTrap: boolean = false\n ): boolean | null {\n checkIfStateModificationsAreAllowed(this.keysAtom_)\n try {\n startBatch()\n\n // Delete\n const deleteOutcome = this.delete_(key)\n if (!deleteOutcome) {\n // Failure or intercepted\n return deleteOutcome\n }\n\n // ADD interceptor\n if (hasInterceptors(this)) {\n const change = interceptChange(this, {\n object: this.proxy_ || this.target_,\n name: key,\n type: ADD,\n newValue: descriptor.value\n })\n if (!change) {\n return null\n }\n const { newValue } = change as any\n if (descriptor.value !== newValue) {\n descriptor = {\n ...descriptor,\n value: newValue\n }\n }\n }\n\n // Define\n if (proxyTrap) {\n if (!Reflect.defineProperty(this.target_, key, descriptor)) {\n return false\n }\n } else {\n defineProperty(this.target_, key, descriptor)\n }\n\n // Notify\n this.notifyPropertyAddition_(key, descriptor.value)\n } finally {\n endBatch()\n }\n return true\n }\n\n // If original descriptor becomes relevant, move this to annotation directly\n defineObservableProperty_(\n key: PropertyKey,\n value: any,\n enhancer: IEnhancer,\n proxyTrap: boolean = false\n ): boolean | null {\n checkIfStateModificationsAreAllowed(this.keysAtom_)\n try {\n startBatch()\n\n // Delete\n const deleteOutcome = this.delete_(key)\n if (!deleteOutcome) {\n // Failure or intercepted\n return deleteOutcome\n }\n\n // ADD interceptor\n if (hasInterceptors(this)) {\n const change = interceptChange(this, {\n object: this.proxy_ || this.target_,\n name: key,\n type: ADD,\n newValue: value\n })\n if (!change) {\n return null\n }\n value = (change as any).newValue\n }\n\n const cachedDescriptor = getCachedObservablePropDescriptor(key)\n const descriptor = {\n configurable: globalState.safeDescriptors ? this.isPlainObject_ : true,\n enumerable: true,\n get: cachedDescriptor.get,\n set: cachedDescriptor.set\n }\n\n // Define\n if (proxyTrap) {\n if (!Reflect.defineProperty(this.target_, key, descriptor)) {\n return false\n }\n } else {\n defineProperty(this.target_, key, descriptor)\n }\n\n const observable = new ObservableValue(\n value,\n enhancer,\n __DEV__ ? `${this.name_}.${key.toString()}` : \"ObservableObject.key\",\n false\n )\n\n this.values_.set(key, observable)\n\n // Notify (value possibly changed by ObservableValue)\n this.notifyPropertyAddition_(key, observable.value_)\n } finally {\n endBatch()\n }\n return true\n }\n\n // If original descriptor becomes relevant, move this to annotation directly\n defineComputedProperty_(\n key: PropertyKey,\n options: IComputedValueOptions,\n proxyTrap: boolean = false\n ): boolean | null {\n checkIfStateModificationsAreAllowed(this.keysAtom_)\n try {\n startBatch()\n\n // Delete\n const deleteOutcome = this.delete_(key)\n if (!deleteOutcome) {\n // Failure or intercepted\n return deleteOutcome\n }\n\n // ADD interceptor\n if (hasInterceptors(this)) {\n const change = interceptChange(this, {\n object: this.proxy_ || this.target_,\n name: key,\n type: ADD,\n newValue: undefined\n })\n if (!change) {\n return null\n }\n }\n options.name ||= __DEV__ ? `${this.name_}.${key.toString()}` : \"ObservableObject.key\"\n options.context = this.proxy_ || this.target_\n const cachedDescriptor = getCachedObservablePropDescriptor(key)\n const descriptor = {\n configurable: globalState.safeDescriptors ? this.isPlainObject_ : true,\n enumerable: false,\n get: cachedDescriptor.get,\n set: cachedDescriptor.set\n }\n\n // Define\n if (proxyTrap) {\n if (!Reflect.defineProperty(this.target_, key, descriptor)) {\n return false\n }\n } else {\n defineProperty(this.target_, key, descriptor)\n }\n\n this.values_.set(key, new ComputedValue(options))\n\n // Notify\n this.notifyPropertyAddition_(key, undefined)\n } finally {\n endBatch()\n }\n return true\n }\n\n /**\n * @param {PropertyKey} key\n * @param {PropertyDescriptor} descriptor\n * @param {boolean} proxyTrap whether it's called from proxy trap\n * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor\n */\n delete_(key: PropertyKey, proxyTrap: boolean = false): boolean | null {\n checkIfStateModificationsAreAllowed(this.keysAtom_)\n // No such prop\n if (!hasProp(this.target_, key)) {\n return true\n }\n\n // Intercept\n if (hasInterceptors(this)) {\n const change = interceptChange(this, {\n object: this.proxy_ || this.target_,\n name: key,\n type: REMOVE\n })\n // Cancelled\n if (!change) {\n return null\n }\n }\n\n // Delete\n try {\n startBatch()\n const notify = hasListeners(this)\n const notifySpy = __DEV__ && isSpyEnabled()\n const observable = this.values_.get(key)\n // Value needed for spies/listeners\n let value = undefined\n // Optimization: don't pull the value unless we will need it\n if (!observable && (notify || notifySpy)) {\n value = getDescriptor(this.target_, key)?.value\n }\n // delete prop (do first, may fail)\n if (proxyTrap) {\n if (!Reflect.deleteProperty(this.target_, key)) {\n return false\n }\n } else {\n delete this.target_[key]\n }\n // Allow re-annotating this field\n if (__DEV__) {\n delete this.appliedAnnotations_![key]\n }\n // Clear observable\n if (observable) {\n this.values_.delete(key)\n // for computed, value is undefined\n if (observable instanceof ObservableValue) {\n value = observable.value_\n }\n // Notify: autorun(() => obj[key]), see #1796\n propagateChanged(observable)\n }\n // Notify \"keys/entries/values\" observers\n this.keysAtom_.reportChanged()\n\n // Notify \"has\" observers\n // \"in\" as it may still exist in proto\n this.pendingKeys_?.get(key)?.set(key in this.target_)\n\n // Notify spies/listeners\n if (notify || notifySpy) {\n const change: IObjectDidChange = {\n type: REMOVE,\n observableKind: \"object\",\n object: this.proxy_ || this.target_,\n debugObjectName: this.name_,\n oldValue: value,\n name: key\n }\n if (__DEV__ && notifySpy) {\n spyReportStart(change!)\n }\n if (notify) {\n notifyListeners(this, change)\n }\n if (__DEV__ && notifySpy) {\n spyReportEnd()\n }\n }\n } finally {\n endBatch()\n }\n return true\n }\n\n /**\n * Observes this object. Triggers for the events 'add', 'update' and 'delete'.\n * See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe\n * for callback details\n */\n observe_(callback: (changes: IObjectDidChange) => void, fireImmediately?: boolean): Lambda {\n if (__DEV__ && fireImmediately === true) {\n die(\"`observe` doesn't support the fire immediately property for observable objects.\")\n }\n return registerListener(this, callback)\n }\n\n intercept_(handler): Lambda {\n return registerInterceptor(this, handler)\n }\n\n notifyPropertyAddition_(key: PropertyKey, value: any) {\n const notify = hasListeners(this)\n const notifySpy = __DEV__ && isSpyEnabled()\n if (notify || notifySpy) {\n const change: IObjectDidChange | null =\n notify || notifySpy\n ? ({\n type: ADD,\n observableKind: \"object\",\n debugObjectName: this.name_,\n object: this.proxy_ || this.target_,\n name: key,\n newValue: value\n } as const)\n : null\n\n if (__DEV__ && notifySpy) {\n spyReportStart(change!)\n }\n if (notify) {\n notifyListeners(this, change)\n }\n if (__DEV__ && notifySpy) {\n spyReportEnd()\n }\n }\n\n this.pendingKeys_?.get(key)?.set(true)\n\n // Notify \"keys/entries/values\" observers\n this.keysAtom_.reportChanged()\n }\n\n ownKeys_(): Array {\n this.keysAtom_.reportObserved()\n return ownKeys(this.target_)\n }\n\n keys_(): PropertyKey[] {\n // Returns enumerable && own, but unfortunately keysAtom will report on ANY key change.\n // There is no way to distinguish between Object.keys(object) and Reflect.ownKeys(object) - both are handled by ownKeys trap.\n // We can either over-report in Object.keys(object) or under-report in Reflect.ownKeys(object)\n // We choose to over-report in Object.keys(object), because:\n // - typically it's used with simple data objects\n // - when symbolic/non-enumerable keys are relevant Reflect.ownKeys works as expected\n this.keysAtom_.reportObserved()\n return Object.keys(this.target_)\n }\n}\n\nexport interface IIsObservableObject {\n [$mobx]: ObservableObjectAdministration\n}\n\nexport function asObservableObject(\n target: any,\n options?: CreateObservableOptions\n): IIsObservableObject {\n if (__DEV__ && options && isObservableObject(target)) {\n die(`Options can't be provided for already observable objects.`)\n }\n\n if (hasProp(target, $mobx)) {\n if (__DEV__ && !(getAdministration(target) instanceof ObservableObjectAdministration)) {\n die(\n `Cannot convert '${getDebugName(target)}' into observable object:` +\n `\\nThe target is already observable of different type.` +\n `\\nExtending builtins is not supported.`\n )\n }\n return target\n }\n\n if (__DEV__ && !Object.isExtensible(target)) {\n die(\"Cannot make the designated object observable; it is not extensible\")\n }\n\n const name =\n options?.name ??\n (__DEV__\n ? `${\n isPlainObject(target) ? \"ObservableObject\" : target.constructor.name\n }@${getNextId()}`\n : \"ObservableObject\")\n\n const adm = new ObservableObjectAdministration(\n target,\n new Map(),\n String(name),\n getAnnotationFromOptions(options)\n )\n\n addHiddenProp(target, $mobx, adm)\n\n return target\n}\n\nconst isObservableObjectAdministration = createInstanceofPredicate(\n \"ObservableObjectAdministration\",\n ObservableObjectAdministration\n)\n\nfunction getCachedObservablePropDescriptor(key) {\n return (\n descriptorCache[key] ||\n (descriptorCache[key] = {\n get() {\n return this[$mobx].getObservablePropValue_(key)\n },\n set(value) {\n return this[$mobx].setObservablePropValue_(key, value)\n }\n })\n )\n}\n\nexport function isObservableObject(thing: any): boolean {\n if (isObject(thing)) {\n return isObservableObjectAdministration((thing as any)[$mobx])\n }\n return false\n}\n\nexport function recordAnnotationApplied(\n adm: ObservableObjectAdministration,\n annotation: Annotation,\n key: PropertyKey\n) {\n if (__DEV__) {\n adm.appliedAnnotations_![key] = annotation\n }\n // Remove applied decorator annotation so we don't try to apply it again in subclass constructor\n delete adm.target_[storedAnnotationsSymbol]?.[key]\n}\n\nfunction assertAnnotable(\n adm: ObservableObjectAdministration,\n annotation: Annotation,\n key: PropertyKey\n) {\n // Valid annotation\n if (__DEV__ && !isAnnotation(annotation)) {\n die(`Cannot annotate '${adm.name_}.${key.toString()}': Invalid annotation.`)\n }\n\n /*\n // Configurable, not sealed, not frozen\n // Possibly not needed, just a little better error then the one thrown by engine.\n // Cases where this would be useful the most (subclass field initializer) are not interceptable by this.\n if (__DEV__) {\n const configurable = getDescriptor(adm.target_, key)?.configurable\n const frozen = Object.isFrozen(adm.target_)\n const sealed = Object.isSealed(adm.target_)\n if (!configurable || frozen || sealed) {\n const fieldName = `${adm.name_}.${key.toString()}`\n const requestedAnnotationType = annotation.annotationType_\n let error = `Cannot apply '${requestedAnnotationType}' to '${fieldName}':`\n if (frozen) {\n error += `\\nObject is frozen.`\n }\n if (sealed) {\n error += `\\nObject is sealed.`\n }\n if (!configurable) {\n error += `\\nproperty is not configurable.`\n // Mention only if caused by us to avoid confusion\n if (hasProp(adm.appliedAnnotations!, key)) {\n error += `\\nTo prevent accidental re-definition of a field by a subclass, `\n error += `all annotated fields of non-plain objects (classes) are not configurable.`\n }\n }\n die(error)\n }\n }\n */\n\n // Not annotated\n if (__DEV__ && !isOverride(annotation) && hasProp(adm.appliedAnnotations_!, key)) {\n const fieldName = `${adm.name_}.${key.toString()}`\n const currentAnnotationType = adm.appliedAnnotations_![key].annotationType_\n const requestedAnnotationType = annotation.annotationType_\n die(\n `Cannot apply '${requestedAnnotationType}' to '${fieldName}':` +\n `\\nThe field is already annotated with '${currentAnnotationType}'.` +\n `\\nRe-annotating fields is not allowed.` +\n `\\nUse 'override' annotation for methods overridden by subclass.`\n )\n }\n}\n", "import {\n getNextId,\n addHiddenFinalProp,\n makeIterable,\n addHiddenProp,\n ObservableArrayAdministration,\n $mobx,\n arrayExtensions,\n IEnhancer,\n isObservableArray,\n IObservableArray,\n defineProperty,\n initObservable\n} from \"../internal\"\n\n// Bug in safari 9.* (or iOS 9 safari mobile). See #364\nconst ENTRY_0 = createArrayEntryDescriptor(0)\n\nconst safariPrototypeSetterInheritanceBug = (() => {\n let v = false\n const p = {}\n Object.defineProperty(p, \"0\", {\n set: () => {\n v = true\n }\n })\n Object.create(p)[\"0\"] = 1\n return v === false\n})()\n\n/**\n * This array buffer contains two lists of properties, so that all arrays\n * can recycle their property definitions, which significantly improves performance of creating\n * properties on the fly.\n */\nlet OBSERVABLE_ARRAY_BUFFER_SIZE = 0\n\n// Typescript workaround to make sure ObservableArray extends Array\nclass StubArray {}\nfunction inherit(ctor, proto) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(ctor.prototype, proto)\n } else if (ctor.prototype.__proto__ !== undefined) {\n ctor.prototype.__proto__ = proto\n } else {\n ctor.prototype = proto\n }\n}\ninherit(StubArray, Array.prototype)\n\n// Weex proto freeze protection was here,\n// but it is unclear why the hack is need as MobX never changed the prototype\n// anyway, so removed it in V6\n\nexport class LegacyObservableArray extends StubArray {\n constructor(\n initialValues: T[] | undefined,\n enhancer: IEnhancer,\n name = __DEV__ ? \"ObservableArray@\" + getNextId() : \"ObservableArray\",\n owned = false\n ) {\n super()\n initObservable(() => {\n const adm = new ObservableArrayAdministration(name, enhancer, owned, true)\n adm.proxy_ = this as any\n addHiddenFinalProp(this, $mobx, adm)\n\n if (initialValues && initialValues.length) {\n // @ts-ignore\n this.spliceWithArray(0, 0, initialValues)\n }\n\n if (safariPrototypeSetterInheritanceBug) {\n // Seems that Safari won't use numeric prototype setter until any * numeric property is\n // defined on the instance. After that it works fine, even if this property is deleted.\n Object.defineProperty(this, \"0\", ENTRY_0)\n }\n })\n }\n\n concat(...arrays: T[][]): T[] {\n ;(this[$mobx] as ObservableArrayAdministration).atom_.reportObserved()\n return Array.prototype.concat.apply(\n (this as any).slice(),\n //@ts-ignore\n arrays.map(a => (isObservableArray(a) ? a.slice() : a))\n )\n }\n\n get length(): number {\n return (this[$mobx] as ObservableArrayAdministration).getArrayLength_()\n }\n\n set length(newLength: number) {\n ;(this[$mobx] as ObservableArrayAdministration).setArrayLength_(newLength)\n }\n\n get [Symbol.toStringTag]() {\n return \"Array\"\n }\n\n [Symbol.iterator]() {\n const self = this\n let nextIndex = 0\n return makeIterable({\n next() {\n return nextIndex < self.length\n ? { value: self[nextIndex++], done: false }\n : { done: true, value: undefined }\n }\n })\n }\n}\n\nObject.entries(arrayExtensions).forEach(([prop, fn]) => {\n if (prop !== \"concat\") {\n addHiddenProp(LegacyObservableArray.prototype, prop, fn)\n }\n})\n\nfunction createArrayEntryDescriptor(index: number) {\n return {\n enumerable: false,\n configurable: true,\n get: function () {\n return this[$mobx].get_(index)\n },\n set: function (value) {\n this[$mobx].set_(index, value)\n }\n }\n}\n\nfunction createArrayBufferItem(index: number) {\n defineProperty(LegacyObservableArray.prototype, \"\" + index, createArrayEntryDescriptor(index))\n}\n\nexport function reserveArrayBuffer(max: number) {\n if (max > OBSERVABLE_ARRAY_BUFFER_SIZE) {\n for (let index = OBSERVABLE_ARRAY_BUFFER_SIZE; index < max + 100; index++) {\n createArrayBufferItem(index)\n }\n OBSERVABLE_ARRAY_BUFFER_SIZE = max\n }\n}\n\nreserveArrayBuffer(1000)\n\nexport function createLegacyArray(\n initialValues: T[] | undefined,\n enhancer: IEnhancer,\n name?: string\n): IObservableArray {\n return new LegacyObservableArray(initialValues, enhancer, name) as any\n}\n", "import { isAction } from \"../api/action\"\nimport {\n $mobx,\n IDepTreeNode,\n isAtom,\n isComputedValue,\n isObservableArray,\n isObservableMap,\n isObservableObject,\n isReaction,\n isObservableSet,\n die,\n isFunction,\n allowStateChangesStart,\n untrackedStart,\n allowStateChangesEnd,\n untrackedEnd,\n startBatch,\n endBatch\n} from \"../internal\"\n\nexport function getAtom(thing: any, property?: PropertyKey): IDepTreeNode {\n if (typeof thing === \"object\" && thing !== null) {\n if (isObservableArray(thing)) {\n if (property !== undefined) {\n die(23)\n }\n return (thing as any)[$mobx].atom_\n }\n if (isObservableSet(thing)) {\n return thing.atom_\n }\n if (isObservableMap(thing)) {\n if (property === undefined) {\n return thing.keysAtom_\n }\n const observable = thing.data_.get(property) || thing.hasMap_.get(property)\n if (!observable) {\n die(25, property, getDebugName(thing))\n }\n return observable\n }\n if (property && !thing[$mobx]) {\n thing[property]\n } // See #1072\n if (isObservableObject(thing)) {\n if (!property) {\n return die(26)\n }\n const observable = (thing as any)[$mobx].values_.get(property)\n if (!observable) {\n die(27, property, getDebugName(thing))\n }\n return observable\n }\n if (isAtom(thing) || isComputedValue(thing) || isReaction(thing)) {\n return thing\n }\n } else if (isFunction(thing)) {\n if (isReaction(thing[$mobx])) {\n // disposer function\n return thing[$mobx]\n }\n }\n die(28)\n}\n\nexport function getAdministration(thing: any, property?: string) {\n if (!thing) {\n die(29)\n }\n if (property !== undefined) {\n return getAdministration(getAtom(thing, property))\n }\n if (isAtom(thing) || isComputedValue(thing) || isReaction(thing)) {\n return thing\n }\n if (isObservableMap(thing) || isObservableSet(thing)) {\n return thing\n }\n if (thing[$mobx]) {\n return thing[$mobx]\n }\n die(24, thing)\n}\n\nexport function getDebugName(thing: any, property?: string): string {\n let named\n if (property !== undefined) {\n named = getAtom(thing, property)\n } else if (isAction(thing)) {\n return thing.name\n } else if (isObservableObject(thing) || isObservableMap(thing) || isObservableSet(thing)) {\n named = getAdministration(thing)\n } else {\n // valid for arrays as well\n named = getAtom(thing)\n }\n return named.name_\n}\n\n/**\n * Helper function for initializing observable structures, it applies:\n * 1. allowStateChanges so we don't violate enforceActions.\n * 2. untracked so we don't accidentaly subscribe to anything observable accessed during init in case the observable is created inside derivation.\n * 3. batch to avoid state version updates\n */\nexport function initObservable(cb: () => T): T {\n const derivation = untrackedStart()\n const allowStateChanges = allowStateChangesStart(true)\n startBatch()\n try {\n return cb()\n } finally {\n endBatch()\n allowStateChangesEnd(allowStateChanges)\n untrackedEnd(derivation)\n }\n}\n", "import {\n isES6Map,\n isObservableArray,\n isObservableMap,\n isES6Set,\n isObservableSet,\n hasProp,\n isFunction,\n objectPrototype\n} from \"../internal\"\n\ndeclare const Symbol\nconst toString = objectPrototype.toString\n\nexport function deepEqual(a: any, b: any, depth: number = -1): boolean {\n return eq(a, b, depth)\n}\n\n// Copied from https://github.com/jashkenas/underscore/blob/5c237a7c682fb68fd5378203f0bf22dce1624854/underscore.js#L1186-L1289\n// Internal recursive comparison function for `isEqual`.\nfunction eq(a: any, b: any, depth: number, aStack?: any[], bStack?: any[]) {\n // Identical objects are equal. `0 === -0`, but they aren't identical.\n // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).\n if (a === b) {\n return a !== 0 || 1 / a === 1 / b\n }\n // `null` or `undefined` only equal to itself (strict comparison).\n if (a == null || b == null) {\n return false\n }\n // `NaN`s are equivalent, but non-reflexive.\n if (a !== a) {\n return b !== b\n }\n // Exhaust primitive checks\n const type = typeof a\n if (type !== \"function\" && type !== \"object\" && typeof b != \"object\") {\n return false\n }\n\n // Compare `[[Class]]` names.\n const className = toString.call(a)\n if (className !== toString.call(b)) {\n return false\n }\n switch (className) {\n // Strings, numbers, regular expressions, dates, and booleans are compared by value.\n case \"[object RegExp]\":\n // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i')\n case \"[object String]\":\n // Primitives and their corresponding object wrappers are equivalent; thus, `\"5\"` is\n // equivalent to `new String(\"5\")`.\n return \"\" + a === \"\" + b\n case \"[object Number]\":\n // `NaN`s are equivalent, but non-reflexive.\n // Object(NaN) is equivalent to NaN.\n if (+a !== +a) {\n return +b !== +b\n }\n // An `egal` comparison is performed for other numeric values.\n return +a === 0 ? 1 / +a === 1 / b : +a === +b\n case \"[object Date]\":\n case \"[object Boolean]\":\n // Coerce dates and booleans to numeric primitive values. Dates are compared by their\n // millisecond representations. Note that invalid dates with millisecond representations\n // of `NaN` are not equivalent.\n return +a === +b\n case \"[object Symbol]\":\n return (\n typeof Symbol !== \"undefined\" && Symbol.valueOf.call(a) === Symbol.valueOf.call(b)\n )\n case \"[object Map]\":\n case \"[object Set]\":\n // Maps and Sets are unwrapped to arrays of entry-pairs, adding an incidental level.\n // Hide this extra level by increasing the depth.\n if (depth >= 0) {\n depth++\n }\n break\n }\n // Unwrap any wrapped objects.\n a = unwrap(a)\n b = unwrap(b)\n\n const areArrays = className === \"[object Array]\"\n if (!areArrays) {\n if (typeof a != \"object\" || typeof b != \"object\") {\n return false\n }\n\n // Objects with different constructors are not equivalent, but `Object`s or `Array`s\n // from different frames are.\n const aCtor = a.constructor,\n bCtor = b.constructor\n if (\n aCtor !== bCtor &&\n !(\n isFunction(aCtor) &&\n aCtor instanceof aCtor &&\n isFunction(bCtor) &&\n bCtor instanceof bCtor\n ) &&\n \"constructor\" in a &&\n \"constructor\" in b\n ) {\n return false\n }\n }\n\n if (depth === 0) {\n return false\n } else if (depth < 0) {\n depth = -1\n }\n\n // Assume equality for cyclic structures. The algorithm for detecting cyclic\n // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.\n\n // Initializing stack of traversed objects.\n // It's done here since we only need them for objects and arrays comparison.\n aStack = aStack || []\n bStack = bStack || []\n let length = aStack.length\n while (length--) {\n // Linear search. Performance is inversely proportional to the number of\n // unique nested structures.\n if (aStack[length] === a) {\n return bStack[length] === b\n }\n }\n\n // Add the first object to the stack of traversed objects.\n aStack.push(a)\n bStack.push(b)\n\n // Recursively compare objects and arrays.\n if (areArrays) {\n // Compare array lengths to determine if a deep comparison is necessary.\n length = a.length\n if (length !== b.length) {\n return false\n }\n // Deep compare the contents, ignoring non-numeric properties.\n while (length--) {\n if (!eq(a[length], b[length], depth - 1, aStack, bStack)) {\n return false\n }\n }\n } else {\n // Deep compare objects.\n const keys = Object.keys(a)\n let key\n length = keys.length\n // Ensure that both objects contain the same number of properties before comparing deep equality.\n if (Object.keys(b).length !== length) {\n return false\n }\n while (length--) {\n // Deep compare each member\n key = keys[length]\n if (!(hasProp(b, key) && eq(a[key], b[key], depth - 1, aStack, bStack))) {\n return false\n }\n }\n }\n // Remove the first object from the stack of traversed objects.\n aStack.pop()\n bStack.pop()\n return true\n}\n\nfunction unwrap(a: any) {\n if (isObservableArray(a)) {\n return a.slice()\n }\n if (isES6Map(a) || isObservableMap(a)) {\n return Array.from(a.entries())\n }\n if (isES6Set(a) || isObservableSet(a)) {\n return Array.from(a.entries())\n }\n return a\n}\n", "export function makeIterable(iterator: Iterator): IterableIterator {\n iterator[Symbol.iterator] = getSelf\n return iterator as any\n}\n\nfunction getSelf() {\n return this\n}\n", "import { ObservableObjectAdministration, isFunction } from \"../internal\"\n\nexport const enum MakeResult {\n Cancel,\n Break,\n Continue\n}\n\nexport type Annotation = {\n annotationType_: string\n make_(\n adm: ObservableObjectAdministration,\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n source: object\n ): MakeResult\n extend_(\n adm: ObservableObjectAdministration,\n key: PropertyKey,\n descriptor: PropertyDescriptor,\n proxyTrap: boolean\n ): boolean | null\n decorate_20223_(value: any, context: DecoratorContext)\n options_?: any\n}\n\nexport type AnnotationMapEntry =\n | Annotation\n | true /* follow the default decorator, usually deep */\n | false /* don't decorate this property */\n\n// AdditionalFields can be used to declare additional keys that can be used, for example to be able to\n// declare annotations for private/ protected members, see #2339\nexport type AnnotationsMap = {\n [P in Exclude]?: AnnotationMapEntry\n} & Record\n\nexport function isAnnotation(thing: any) {\n return (\n // Can be function\n thing instanceof Object &&\n typeof thing.annotationType_ === \"string\" &&\n isFunction(thing.make_) &&\n isFunction(thing.extend_)\n )\n}\n\nexport function isAnnotationMapEntry(thing: any) {\n return typeof thing === \"boolean\" || isAnnotation(thing)\n}\n", "/**\n * (c) Michel Weststrate 2015 - 2020\n * MIT Licensed\n *\n * Welcome to the mobx sources! To get a global overview of how MobX internally works,\n * this is a good place to start:\n * https://medium.com/@mweststrate/becoming-fully-reactive-an-in-depth-explanation-of-mobservable-55995262a254#.xvbh6qd74\n *\n * Source folders:\n * ===============\n *\n * - api/ Most of the public static methods exposed by the module can be found here.\n * - core/ Implementation of the MobX algorithm; atoms, derivations, reactions, dependency trees, optimizations. Cool stuff can be found here.\n * - types/ All the magic that is need to have observable objects, arrays and values is in this folder. Including the modifiers like `asFlat`.\n * - utils/ Utility stuff.\n *\n */\nimport { die } from \"./errors\"\nimport { getGlobal } from \"./utils/global\"\n;[\"Symbol\", \"Map\", \"Set\"].forEach(m => {\n let g = getGlobal()\n if (typeof g[m] === \"undefined\") {\n die(`MobX requires global '${m}' to be available or polyfilled`)\n }\n})\n\nimport { spy, getDebugName, $mobx } from \"./internal\"\n\nexport {\n IObservable,\n IDepTreeNode,\n Reaction,\n IReactionPublic,\n IReactionDisposer,\n untracked,\n IAtom,\n createAtom,\n spy,\n IComputedValue,\n IEqualsComparer,\n comparer,\n IEnhancer,\n IInterceptable,\n IInterceptor,\n IListenable,\n IObjectWillChange,\n IObjectDidChange,\n isObservableObject,\n IValueDidChange,\n IValueWillChange,\n IObservableValue,\n isObservableValue as isBoxedObservable,\n IObservableArray,\n IArrayWillChange,\n IArrayWillSplice,\n IArraySplice,\n IArrayUpdate,\n IArrayDidChange,\n isObservableArray,\n IKeyValueMap,\n ObservableMap,\n IMapEntries,\n IMapEntry,\n IMapWillChange,\n IMapDidChange,\n isObservableMap,\n IObservableMapInitialValues,\n ObservableSet,\n isObservableSet,\n ISetDidChange,\n ISetWillChange,\n IObservableSetInitialValues,\n transaction,\n observable,\n IObservableFactory,\n CreateObservableOptions,\n computed,\n IComputedFactory,\n isObservable,\n isObservableProp,\n isComputed,\n isComputedProp,\n extendObservable,\n observe,\n intercept,\n autorun,\n IAutorunOptions,\n reaction,\n IReactionOptions,\n when,\n IWhenOptions,\n action,\n isAction,\n runInAction,\n IActionFactory,\n keys,\n values,\n entries,\n set,\n remove,\n has,\n get,\n apiOwnKeys as ownKeys,\n apiDefineProperty as defineProperty,\n configure,\n onBecomeObserved,\n onBecomeUnobserved,\n flow,\n isFlow,\n flowResult,\n FlowCancellationError,\n isFlowCancellationError,\n toJS,\n trace,\n IObserverTree,\n IDependencyTree,\n getDependencyTree,\n getObserverTree,\n resetGlobalState as _resetGlobalState,\n getGlobalState as _getGlobalState,\n getDebugName,\n getAtom,\n getAdministration as _getAdministration,\n allowStateChanges as _allowStateChanges,\n runInAction as _allowStateChangesInsideComputed, // This has become the default behavior in Mobx 6\n Lambda,\n $mobx,\n isComputingDerivation as _isComputingDerivation,\n onReactionError,\n interceptReads as _interceptReads,\n IComputedValueOptions,\n IActionRunInfo,\n _startAction,\n _endAction,\n allowStateReadsStart as _allowStateReadsStart,\n allowStateReadsEnd as _allowStateReadsEnd,\n makeObservable,\n makeAutoObservable,\n autoAction as _autoAction,\n AnnotationsMap,\n AnnotationMapEntry,\n override\n} from \"./internal\"\n\n// Devtools support\ndeclare const __MOBX_DEVTOOLS_GLOBAL_HOOK__: { injectMobx: (any) => void }\nif (typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__ === \"object\") {\n // See: https://github.com/andykog/mobx-devtools/\n __MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({\n spy,\n extras: {\n getDebugName\n },\n $mobx\n })\n}\n", "/*\nCopyright 2018 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n MobxReactionUpdateCustom,\n ReactiveElementConstructor,\n} from './mixin-custom.js';\nimport { Reaction } from 'mobx';\n\nexport { ReactiveElementConstructor } from './mixin-custom';\n\n/**\n * A class mixin which can be applied to lit-element's\n * [ReactiveElement](https://lit.dev/docs/api/ReactiveElement/)\n * derived classes. This mixin adds a mobx reaction which tracks the update method of ReactiveElement.\n *\n * Any observables used in the render template of the element will be tracked by a reaction\n * and cause an update of the element upon change.\n *\n * @param constructor the constructor to extend from to add the mobx reaction, must be derived from ReactiveElement.\n */\nexport function MobxReactionUpdate(\n constructor: T\n): T {\n return MobxReactionUpdateCustom(constructor, Reaction);\n}\n", "/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nconst NODE_MODE = false;\n\n// Allows minifiers to rename references to globalThis\nconst global = globalThis;\n\n/**\n * Whether the current browser supports `adoptedStyleSheets`.\n */\nexport const supportsAdoptingStyleSheets: boolean =\n global.ShadowRoot &&\n (global.ShadyCSS === undefined || global.ShadyCSS.nativeShadow) &&\n 'adoptedStyleSheets' in Document.prototype &&\n 'replace' in CSSStyleSheet.prototype;\n\n/**\n * A CSSResult or native CSSStyleSheet.\n *\n * In browsers that support constructible CSS style sheets, CSSStyleSheet\n * object can be used for styling along side CSSResult from the `css`\n * template tag.\n */\nexport type CSSResultOrNative = CSSResult | CSSStyleSheet;\n\nexport type CSSResultArray = Array;\n\n/**\n * A single CSSResult, CSSStyleSheet, or an array or nested arrays of those.\n */\nexport type CSSResultGroup = CSSResultOrNative | CSSResultArray;\n\nconst constructionToken = Symbol();\n\nconst cssTagCache = new WeakMap();\n\n/**\n * A container for a string of CSS text, that may be used to create a CSSStyleSheet.\n *\n * CSSResult is the return value of `css`-tagged template literals and\n * `unsafeCSS()`. In order to ensure that CSSResults are only created via the\n * `css` tag and `unsafeCSS()`, CSSResult cannot be constructed directly.\n */\nexport class CSSResult {\n // This property needs to remain unminified.\n ['_$cssResult$'] = true;\n readonly cssText: string;\n private _styleSheet?: CSSStyleSheet;\n private _strings: TemplateStringsArray | undefined;\n\n private constructor(\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ) {\n if (safeToken !== constructionToken) {\n throw new Error(\n 'CSSResult is not constructable. Use `unsafeCSS` or `css` instead.'\n );\n }\n this.cssText = cssText;\n this._strings = strings;\n }\n\n // This is a getter so that it's lazy. In practice, this means stylesheets\n // are not created until the first element instance is made.\n get styleSheet(): CSSStyleSheet | undefined {\n // If `supportsAdoptingStyleSheets` is true then we assume CSSStyleSheet is\n // constructable.\n let styleSheet = this._styleSheet;\n const strings = this._strings;\n if (supportsAdoptingStyleSheets && styleSheet === undefined) {\n const cacheable = strings !== undefined && strings.length === 1;\n if (cacheable) {\n styleSheet = cssTagCache.get(strings);\n }\n if (styleSheet === undefined) {\n (this._styleSheet = styleSheet = new CSSStyleSheet()).replaceSync(\n this.cssText\n );\n if (cacheable) {\n cssTagCache.set(strings, styleSheet);\n }\n }\n }\n return styleSheet;\n }\n\n toString(): string {\n return this.cssText;\n }\n}\n\ntype ConstructableCSSResult = CSSResult & {\n new (\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ): CSSResult;\n};\n\nconst textFromCSSResult = (value: CSSResultGroup | number) => {\n // This property needs to remain unminified.\n if ((value as CSSResult)['_$cssResult$'] === true) {\n return (value as CSSResult).cssText;\n } else if (typeof value === 'number') {\n return value;\n } else {\n throw new Error(\n `Value passed to 'css' function must be a 'css' function result: ` +\n `${value}. Use 'unsafeCSS' to pass non-literal values, but take care ` +\n `to ensure page security.`\n );\n }\n};\n\n/**\n * Wrap a value for interpolation in a {@linkcode css} tagged template literal.\n *\n * This is unsafe because untrusted CSS text can be used to phone home\n * or exfiltrate data to an attacker controlled site. Take care to only use\n * this with trusted input.\n */\nexport const unsafeCSS = (value: unknown) =>\n new (CSSResult as ConstructableCSSResult)(\n typeof value === 'string' ? value : String(value),\n undefined,\n constructionToken\n );\n\n/**\n * A template literal tag which can be used with LitElement's\n * {@linkcode LitElement.styles} property to set element styles.\n *\n * For security reasons, only literal string values and number may be used in\n * embedded expressions. To incorporate non-literal values {@linkcode unsafeCSS}\n * may be used inside an expression.\n */\nexport const css = (\n strings: TemplateStringsArray,\n ...values: (CSSResultGroup | number)[]\n): CSSResult => {\n const cssText =\n strings.length === 1\n ? strings[0]\n : values.reduce(\n (acc, v, idx) => acc + textFromCSSResult(v) + strings[idx + 1],\n strings[0]\n );\n return new (CSSResult as ConstructableCSSResult)(\n cssText,\n strings,\n constructionToken\n );\n};\n\n/**\n * Applies the given styles to a `shadowRoot`. When Shadow DOM is\n * available but `adoptedStyleSheets` is not, styles are appended to the\n * `shadowRoot` to [mimic spec behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).\n * Note, when shimming is used, any styles that are subsequently placed into\n * the shadowRoot should be placed *before* any shimmed adopted styles. This\n * will match spec behavior that gives adopted sheets precedence over styles in\n * shadowRoot.\n */\nexport const adoptStyles = (\n renderRoot: ShadowRoot,\n styles: Array\n) => {\n if (supportsAdoptingStyleSheets) {\n (renderRoot as ShadowRoot).adoptedStyleSheets = styles.map((s) =>\n s instanceof CSSStyleSheet ? s : s.styleSheet!\n );\n } else {\n for (const s of styles) {\n const style = document.createElement('style');\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nonce = (global as any)['litNonce'];\n if (nonce !== undefined) {\n style.setAttribute('nonce', nonce);\n }\n style.textContent = (s as CSSResult).cssText;\n renderRoot.appendChild(style);\n }\n }\n};\n\nconst cssResultFromStyleSheet = (sheet: CSSStyleSheet) => {\n let cssText = '';\n for (const rule of sheet.cssRules) {\n cssText += rule.cssText;\n }\n return unsafeCSS(cssText);\n};\n\nexport const getCompatibleStyle =\n supportsAdoptingStyleSheets ||\n (NODE_MODE && global.CSSStyleSheet === undefined)\n ? (s: CSSResultOrNative) => s\n : (s: CSSResultOrNative) =>\n s instanceof CSSStyleSheet ? cssResultFromStyleSheet(s) : s;\n", "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Use this module if you want to create your own base class extending\n * {@link ReactiveElement}.\n * @packageDocumentation\n */\n\nimport {\n getCompatibleStyle,\n adoptStyles,\n CSSResultGroup,\n CSSResultOrNative,\n} from './css-tag.js';\nimport type {\n ReactiveController,\n ReactiveControllerHost,\n} from './reactive-controller.js';\n\n// In the Node build, this import will be injected by Rollup:\n// import {HTMLElement, customElements} from '@lit-labs/ssr-dom-shim';\n\nexport * from './css-tag.js';\nexport type {\n ReactiveController,\n ReactiveControllerHost,\n} from './reactive-controller.js';\n\n/**\n * Removes the `readonly` modifier from properties in the union K.\n *\n * This is a safer way to cast a value to a type with a mutable version of a\n * readonly field, than casting to an interface with the field re-declared\n * because it preserves the type of all the fields and warns on typos.\n */\ntype Mutable = Omit & {\n -readonly [P in keyof Pick]: P extends K ? T[P] : never;\n};\n\n// TODO (justinfagnani): Add `hasOwn` here when we ship ES2022\nconst {\n is,\n defineProperty,\n getOwnPropertyDescriptor,\n getOwnPropertyNames,\n getOwnPropertySymbols,\n getPrototypeOf,\n} = Object;\n\nconst NODE_MODE = false;\n\n// Lets a minifier replace globalThis references with a minified name\nconst global = globalThis;\n\nif (NODE_MODE) {\n global.customElements ??= customElements;\n}\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nconst trustedTypes = (global as unknown as {trustedTypes?: {emptyScript: ''}})\n .trustedTypes;\n\n// Temporary workaround for https://crbug.com/993268\n// Currently, any attribute starting with \"on\" is considered to be a\n// TrustedScript source. Such boolean attributes must be set to the equivalent\n// trusted emptyScript value.\nconst emptyStringForBooleanAttribute = trustedTypes\n ? (trustedTypes.emptyScript as unknown as '')\n : '';\n\nconst polyfillSupport = DEV_MODE\n ? global.reactiveElementPolyfillSupportDevMode\n : global.reactiveElementPolyfillSupport;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n const issuedWarnings: Set = (global.litIssuedWarnings ??=\n new Set());\n\n // Issue a warning, if we haven't already.\n issueWarning = (code: string, warning: string) => {\n warning += ` See https://lit.dev/msg/${code} for more information.`;\n if (!issuedWarnings.has(warning)) {\n console.warn(warning);\n issuedWarnings.add(warning);\n }\n };\n\n issueWarning(\n 'dev-mode',\n `Lit is in dev mode. Not recommended for production!`\n );\n\n // Issue polyfill support warning.\n if (global.ShadyDOM?.inUse && polyfillSupport === undefined) {\n issueWarning(\n 'polyfill-support-missing',\n `Shadow DOM is being polyfilled via \\`ShadyDOM\\` but ` +\n `the \\`polyfill-support\\` module has not been loaded.`\n );\n }\n}\n\n/**\n * Contains types that are part of the unstable debug API.\n *\n * Everything in this API is not stable and may change or be removed in the future,\n * even on patch releases.\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace ReactiveUnstable {\n /**\n * When Lit is running in dev mode and `window.emitLitDebugLogEvents` is true,\n * we will emit 'lit-debug' events to window, with live details about the update and render\n * lifecycle. These can be useful for writing debug tooling and visualizations.\n *\n * Please be aware that running with window.emitLitDebugLogEvents has performance overhead,\n * making certain operations that are normally very cheap (like a no-op render) much slower,\n * because we must copy data and dispatch events.\n */\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace DebugLog {\n export type Entry = Update;\n export interface Update {\n kind: 'update';\n }\n }\n}\n\ninterface DebugLoggingWindow {\n // Even in dev mode, we generally don't want to emit these events, as that's\n // another level of cost, so only emit them when DEV_MODE is true _and_ when\n // window.emitLitDebugEvents is true.\n emitLitDebugLogEvents?: boolean;\n}\n\n/**\n * Useful for visualizing and logging insights into what the Lit template system is doing.\n *\n * Compiled out of prod mode builds.\n */\nconst debugLogEvent = DEV_MODE\n ? (event: ReactiveUnstable.DebugLog.Entry) => {\n const shouldEmit = (global as unknown as DebugLoggingWindow)\n .emitLitDebugLogEvents;\n if (!shouldEmit) {\n return;\n }\n global.dispatchEvent(\n new CustomEvent('lit-debug', {\n detail: event,\n })\n );\n }\n : undefined;\n\n/*\n * When using Closure Compiler, JSCompiler_renameProperty(property, object) is\n * replaced at compile time by the munged name for object[property]. We cannot\n * alias this function, so we have to use a small shim that has the same\n * behavior when not compiling.\n */\n/*@__INLINE__*/\nconst JSCompiler_renameProperty =

    (\n prop: P,\n _obj: unknown\n): P => prop;\n\n/**\n * Converts property values to and from attribute values.\n */\nexport interface ComplexAttributeConverter {\n /**\n * Called to convert an attribute value to a property\n * value.\n */\n fromAttribute?(value: string | null, type?: TypeHint): Type;\n\n /**\n * Called to convert a property value to an attribute\n * value.\n *\n * It returns unknown instead of string, to be compatible with\n * https://github.com/WICG/trusted-types (and similar efforts).\n */\n toAttribute?(value: Type, type?: TypeHint): unknown;\n}\n\ntype AttributeConverter =\n | ComplexAttributeConverter\n | ((value: string | null, type?: TypeHint) => Type);\n\n/**\n * Defines options for a property accessor.\n */\nexport interface PropertyDeclaration {\n /**\n * When set to `true`, indicates the property is internal private state. The\n * property should not be set by users. When using TypeScript, this property\n * should be marked as `private` or `protected`, and it is also a common\n * practice to use a leading `_` in the name. The property is not added to\n * `observedAttributes`.\n */\n readonly state?: boolean;\n\n /**\n * Indicates how and whether the property becomes an observed attribute.\n * If the value is `false`, the property is not added to `observedAttributes`.\n * If true or absent, the lowercased property name is observed (e.g. `fooBar`\n * becomes `foobar`). If a string, the string value is observed (e.g\n * `attribute: 'foo-bar'`).\n */\n readonly attribute?: boolean | string;\n\n /**\n * Indicates the type of the property. This is used only as a hint for the\n * `converter` to determine how to convert the attribute\n * to/from a property.\n */\n readonly type?: TypeHint;\n\n /**\n * Indicates how to convert the attribute to/from a property. If this value\n * is a function, it is used to convert the attribute value a the property\n * value. If it's an object, it can have keys for `fromAttribute` and\n * `toAttribute`. If no `toAttribute` function is provided and\n * `reflect` is set to `true`, the property value is set directly to the\n * attribute. A default `converter` is used if none is provided; it supports\n * `Boolean`, `String`, `Number`, `Object`, and `Array`. Note,\n * when a property changes and the converter is used to update the attribute,\n * the property is never updated again as a result of the attribute changing,\n * and vice versa.\n */\n readonly converter?: AttributeConverter;\n\n /**\n * Indicates if the property should reflect to an attribute.\n * If `true`, when the property is set, the attribute is set using the\n * attribute name determined according to the rules for the `attribute`\n * property option and the value of the property converted using the rules\n * from the `converter` property option.\n */\n readonly reflect?: boolean;\n\n /**\n * A function that indicates if a property should be considered changed when\n * it is set. The function should take the `newValue` and `oldValue` and\n * return `true` if an update should be requested.\n */\n hasChanged?(value: Type, oldValue: Type): boolean;\n\n /**\n * Indicates whether an accessor will be created for this property. By\n * default, an accessor will be generated for this property that requests an\n * update when set. If this flag is `true`, no accessor will be created, and\n * it will be the user's responsibility to call\n * `this.requestUpdate(propertyName, oldValue)` to request an update when\n * the property changes.\n */\n readonly noAccessor?: boolean;\n\n /**\n * Whether this property is wrapping accessors. This is set by `@property`\n * to control the initial value change and reflection logic.\n *\n * @internal\n */\n wrapped?: boolean;\n}\n\n/**\n * Map of properties to PropertyDeclaration options. For each property an\n * accessor is made, and the property is processed according to the\n * PropertyDeclaration options.\n */\nexport interface PropertyDeclarations {\n readonly [key: string]: PropertyDeclaration;\n}\n\ntype PropertyDeclarationMap = Map;\n\ntype AttributeMap = Map;\n\n/**\n * A Map of property keys to values.\n *\n * Takes an optional type parameter T, which when specified as a non-any,\n * non-unknown type, will make the Map more strongly-typed, associating the map\n * keys with their corresponding value type on T.\n *\n * Use `PropertyValues` when overriding ReactiveElement.update() and\n * other lifecycle methods in order to get stronger type-checking on keys\n * and values.\n */\n// This type is conditional so that if the parameter T is not specified, or\n// is `any`, the type will include `Map`. Since T is not\n// given in the uses of PropertyValues in this file, all uses here fallback to\n// meaning `Map`, but if a developer uses\n// `PropertyValues` (or any other value for T) they will get a\n// strongly-typed Map type.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type PropertyValues = T extends object\n ? PropertyValueMap\n : Map;\n\n/**\n * Do not use, instead prefer {@linkcode PropertyValues}.\n */\n// This type must be exported such that JavaScript generated by the Google\n// Closure Compiler can import a type reference.\nexport interface PropertyValueMap extends Map {\n get(k: K): T[K] | undefined;\n set(key: K, value: T[K]): this;\n has(k: K): boolean;\n delete(k: K): boolean;\n}\n\nexport const defaultConverter: ComplexAttributeConverter = {\n toAttribute(value: unknown, type?: unknown): unknown {\n switch (type) {\n case Boolean:\n value = value ? emptyStringForBooleanAttribute : null;\n break;\n case Object:\n case Array:\n // if the value is `null` or `undefined` pass this through\n // to allow removing/no change behavior.\n value = value == null ? value : JSON.stringify(value);\n break;\n }\n return value;\n },\n\n fromAttribute(value: string | null, type?: unknown) {\n let fromValue: unknown = value;\n switch (type) {\n case Boolean:\n fromValue = value !== null;\n break;\n case Number:\n fromValue = value === null ? null : Number(value);\n break;\n case Object:\n case Array:\n // Do *not* generate exception when invalid JSON is set as elements\n // don't normally complain on being mis-configured.\n // TODO(sorvell): Do generate exception in *dev mode*.\n try {\n // Assert to adhere to Bazel's \"must type assert JSON parse\" rule.\n fromValue = JSON.parse(value!) as unknown;\n } catch (e) {\n fromValue = null;\n }\n break;\n }\n return fromValue;\n },\n};\n\nexport interface HasChanged {\n (value: unknown, old: unknown): boolean;\n}\n\n/**\n * Change function that returns true if `value` is different from `oldValue`.\n * This method is used as the default for a property's `hasChanged` function.\n */\nexport const notEqual: HasChanged = (value: unknown, old: unknown): boolean =>\n !is(value, old);\n\nconst defaultPropertyDeclaration: PropertyDeclaration = {\n attribute: true,\n type: String,\n converter: defaultConverter,\n reflect: false,\n hasChanged: notEqual,\n};\n\n/**\n * A string representing one of the supported dev mode warning categories.\n */\nexport type WarningKind =\n | 'change-in-update'\n | 'migration'\n | 'async-perform-update';\n\nexport type Initializer = (element: ReactiveElement) => void;\n\n// Temporary, until google3 is on TypeScript 5.2\ndeclare global {\n interface SymbolConstructor {\n readonly metadata: unique symbol;\n }\n}\n\n// Ensure metadata is enabled. TypeScript does not polyfill\n// Symbol.metadata, so we must ensure that it exists.\n(Symbol as {metadata: symbol}).metadata ??= Symbol('metadata');\n\ndeclare global {\n // This is public global API, do not change!\n // eslint-disable-next-line no-var\n var litPropertyMetadata: WeakMap<\n object,\n Map\n >;\n}\n\n// Map from a class's metadata object to property options\n// Note that we must use nullish-coalescing assignment so that we only use one\n// map even if we load multiple version of this module.\nglobal.litPropertyMetadata ??= new WeakMap<\n object,\n Map\n>();\n\n/**\n * Base element class which manages element properties and attributes. When\n * properties change, the `update` method is asynchronously called. This method\n * should be supplied by subclasses to render updates as desired.\n * @noInheritDoc\n */\nexport abstract class ReactiveElement\n // In the Node build, this `extends` clause will be substituted with\n // `(globalThis.HTMLElement ?? HTMLElement)`.\n //\n // This way, we will first prefer any global `HTMLElement` polyfill that the\n // user has assigned, and then fall back to the `HTMLElement` shim which has\n // been imported (see note at the top of this file about how this import is\n // generated by Rollup). Note that the `HTMLElement` variable has been\n // shadowed by this import, so it no longer refers to the global.\n extends HTMLElement\n implements ReactiveControllerHost\n{\n // Note: these are patched in only in DEV_MODE.\n /**\n * Read or set all the enabled warning categories for this class.\n *\n * This property is only used in development builds.\n *\n * @nocollapse\n * @category dev-mode\n */\n static enabledWarnings?: WarningKind[];\n\n /**\n * Enable the given warning category for this class.\n *\n * This method only exists in development builds, so it should be accessed\n * with a guard like:\n *\n * ```ts\n * // Enable for all ReactiveElement subclasses\n * ReactiveElement.enableWarning?.('migration');\n *\n * // Enable for only MyElement and subclasses\n * MyElement.enableWarning?.('migration');\n * ```\n *\n * @nocollapse\n * @category dev-mode\n */\n static enableWarning?: (warningKind: WarningKind) => void;\n\n /**\n * Disable the given warning category for this class.\n *\n * This method only exists in development builds, so it should be accessed\n * with a guard like:\n *\n * ```ts\n * // Disable for all ReactiveElement subclasses\n * ReactiveElement.disableWarning?.('migration');\n *\n * // Disable for only MyElement and subclasses\n * MyElement.disableWarning?.('migration');\n * ```\n *\n * @nocollapse\n * @category dev-mode\n */\n static disableWarning?: (warningKind: WarningKind) => void;\n\n /**\n * Adds an initializer function to the class that is called during instance\n * construction.\n *\n * This is useful for code that runs against a `ReactiveElement`\n * subclass, such as a decorator, that needs to do work for each\n * instance, such as setting up a `ReactiveController`.\n *\n * ```ts\n * const myDecorator = (target: typeof ReactiveElement, key: string) => {\n * target.addInitializer((instance: ReactiveElement) => {\n * // This is run during construction of the element\n * new MyController(instance);\n * });\n * }\n * ```\n *\n * Decorating a field will then cause each instance to run an initializer\n * that adds a controller:\n *\n * ```ts\n * class MyElement extends LitElement {\n * @myDecorator foo;\n * }\n * ```\n *\n * Initializers are stored per-constructor. Adding an initializer to a\n * subclass does not add it to a superclass. Since initializers are run in\n * constructors, initializers will run in order of the class hierarchy,\n * starting with superclasses and progressing to the instance's class.\n *\n * @nocollapse\n */\n static addInitializer(initializer: Initializer) {\n this.__prepare();\n (this._initializers ??= []).push(initializer);\n }\n\n static _initializers?: Initializer[];\n\n /*\n * Due to closure compiler ES6 compilation bugs, @nocollapse is required on\n * all static methods and properties with initializers. Reference:\n * - https://github.com/google/closure-compiler/issues/1776\n */\n\n /**\n * Maps attribute names to properties; for example `foobar` attribute to\n * `fooBar` property. Created lazily on user subclasses when finalizing the\n * class.\n * @nocollapse\n */\n private static __attributeToPropertyMap: AttributeMap;\n\n /**\n * Marks class as having been finalized, which includes creating properties\n * from `static properties`, but does *not* include all properties created\n * from decorators.\n * @nocollapse\n */\n protected static finalized: true | undefined;\n\n /**\n * Memoized list of all element properties, including any superclass\n * properties. Created lazily on user subclasses when finalizing the class.\n *\n * @nocollapse\n * @category properties\n */\n static elementProperties: PropertyDeclarationMap;\n\n /**\n * User-supplied object that maps property names to `PropertyDeclaration`\n * objects containing options for configuring reactive properties. When\n * a reactive property is set the element will update and render.\n *\n * By default properties are public fields, and as such, they should be\n * considered as primarily settable by element users, either via attribute or\n * the property itself.\n *\n * Generally, properties that are changed by the element should be private or\n * protected fields and should use the `state: true` option. Properties\n * marked as `state` do not reflect from the corresponding attribute\n *\n * However, sometimes element code does need to set a public property. This\n * should typically only be done in response to user interaction, and an event\n * should be fired informing the user; for example, a checkbox sets its\n * `checked` property when clicked and fires a `changed` event. Mutating\n * public properties should typically not be done for non-primitive (object or\n * array) properties. In other cases when an element needs to manage state, a\n * private property set with the `state: true` option should be used. When\n * needed, state properties can be initialized via public properties to\n * facilitate complex interactions.\n * @nocollapse\n * @category properties\n */\n static properties: PropertyDeclarations;\n\n /**\n * Memoized list of all element styles.\n * Created lazily on user subclasses when finalizing the class.\n * @nocollapse\n * @category styles\n */\n static elementStyles: Array = [];\n\n /**\n * Array of styles to apply to the element. The styles should be defined\n * using the {@linkcode css} tag function, via constructible stylesheets, or\n * imported from native CSS module scripts.\n *\n * Note on Content Security Policy:\n *\n * Element styles are implemented with ` + + +

    + + + diff --git a/python/src/llm_comparator/data/static/favicon.svg b/python/src/llm_comparator/data/static/favicon.svg new file mode 100644 index 0000000..3ae1370 --- /dev/null +++ b/python/src/llm_comparator/data/static/favicon.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file