(function(){ "use strict"; var ρσ_iterator_symbol = (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") ? Symbol.iterator : "iterator-Symbol-5d0927e5554349048cf0e3762a228256"; var ρσ_kwargs_symbol = (typeof Symbol === "function") ? Symbol("kwargs-object") : "kwargs-object-Symbol-5d0927e5554349048cf0e3762a228256"; var ρσ_cond_temp, ρσ_expr_temp, ρσ_last_exception; var ρσ_object_counter = 0; if( typeof HTMLCollection !== "undefined" && typeof Symbol === "function") NodeList.prototype[Symbol.iterator] = HTMLCollection.prototype[Symbol.iterator] = NamedNodeMap.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator]; var ρσ_len; function ρσ_bool(val) { return !!val; }; if (!ρσ_bool.__argnames__) Object.defineProperties(ρσ_bool, { __argnames__ : {value: ["val"]}, __module__ : {value: "__main__"} }); function ρσ_print() { var parts; if (typeof console === "object") { parts = []; for (var i = 0; i < arguments.length; i++) { parts.push(ρσ_str(arguments[i])); } console.log(parts.join(" ")); } }; if (!ρσ_print.__module__) Object.defineProperties(ρσ_print, { __module__ : {value: "__main__"} }); function ρσ_int(val, base) { var ans; if (typeof val === "number") { ans = val | 0; } else { ans = parseInt(val, base || 10); } if (isNaN(ans)) { throw new ValueError("Invalid literal for int with base " + (base || 10) + ": " + val); } return ans; }; if (!ρσ_int.__argnames__) Object.defineProperties(ρσ_int, { __argnames__ : {value: ["val", "base"]}, __module__ : {value: "__main__"} }); function ρσ_float(val) { var ans; if (typeof val === "number") { ans = val; } else { ans = parseFloat(val); } if (isNaN(ans)) { throw new ValueError("Could not convert string to float: " + arguments[0]); } return ans; }; if (!ρσ_float.__argnames__) Object.defineProperties(ρσ_float, { __argnames__ : {value: ["val"]}, __module__ : {value: "__main__"} }); function ρσ_arraylike_creator() { var names; names = ("Int8Array Uint8Array Uint8ClampedArray Int16Array" + " Uint16Array Int32Array Uint32Array Float32Array" + " Float64Array").split(" "); if (typeof HTMLCollection === "function") { names = names.concat("HTMLCollection NodeList NamedNodeMap TouchList".split(" ")); } return (function() { var ρσ_anonfunc = function (x) { if (Array.isArray(x) || typeof x === "string" || names.indexOf(Object.prototype.toString.call(x).slice(8, -1)) > -1) { return true; } return false; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); }; if (!ρσ_arraylike_creator.__module__) Object.defineProperties(ρσ_arraylike_creator, { __module__ : {value: "__main__"} }); function options_object(f) { return (function() { var ρσ_anonfunc = function () { if (typeof arguments[arguments.length - 1] === "object") { arguments[ρσ_bound_index(arguments.length - 1, arguments)][ρσ_kwargs_symbol] = true; } return f.apply(this, arguments); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); }; if (!options_object.__argnames__) Object.defineProperties(options_object, { __argnames__ : {value: ["f"]}, __module__ : {value: "__main__"} }); function ρσ_id(x) { return x.ρσ_object_id; }; if (!ρσ_id.__argnames__) Object.defineProperties(ρσ_id, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); function ρσ_dir(item) { var arr; arr = []; for (var i in item) { arr.push(i); } return arr; }; if (!ρσ_dir.__argnames__) Object.defineProperties(ρσ_dir, { __argnames__ : {value: ["item"]}, __module__ : {value: "__main__"} }); function ρσ_ord(x) { var ans, second; ans = x.charCodeAt(0); if (55296 <= ans && ans <= 56319) { second = x.charCodeAt(1); if (56320 <= second && second <= 57343) { return (ans - 55296) * 1024 + second - 56320 + 65536; } throw new TypeError("string is missing the low surrogate char"); } return ans; }; if (!ρσ_ord.__argnames__) Object.defineProperties(ρσ_ord, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); function ρσ_chr(code) { if (code <= 65535) { return String.fromCharCode(code); } code -= 65536; return String.fromCharCode(55296 + (code >> 10), 56320 + (code & 1023)); }; if (!ρσ_chr.__argnames__) Object.defineProperties(ρσ_chr, { __argnames__ : {value: ["code"]}, __module__ : {value: "__main__"} }); function ρσ_callable(x) { return typeof x === "function"; }; if (!ρσ_callable.__argnames__) Object.defineProperties(ρσ_callable, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); function ρσ_bin(x) { var ans; if (typeof x !== "number" || x % 1 !== 0) { throw new TypeError("integer required"); } ans = x.toString(2); if (ans[0] === "-") { ans = "-" + "0b" + ans.slice(1); } else { ans = "0b" + ans; } return ans; }; if (!ρσ_bin.__argnames__) Object.defineProperties(ρσ_bin, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); function ρσ_hex(x) { var ans; if (typeof x !== "number" || x % 1 !== 0) { throw new TypeError("integer required"); } ans = x.toString(16); if (ans[0] === "-") { ans = "-" + "0x" + ans.slice(1); } else { ans = "0x" + ans; } return ans; }; if (!ρσ_hex.__argnames__) Object.defineProperties(ρσ_hex, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); function ρσ_enumerate(iterable) { var ans, iterator; ans = {"_i":-1}; ans[ρσ_iterator_symbol] = (function() { var ρσ_anonfunc = function () { return this; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); if (ρσ_arraylike(iterable)) { ans["next"] = (function() { var ρσ_anonfunc = function () { this._i += 1; if (this._i < iterable.length) { return {'done':false, 'value':[this._i, iterable[this._i]]}; } return {'done':true}; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ans; } if (typeof iterable[ρσ_iterator_symbol] === "function") { iterator = (typeof Map === "function" && iterable instanceof Map) ? iterable.keys() : iterable[ρσ_iterator_symbol](); ans["_iterator"] = iterator; ans["next"] = (function() { var ρσ_anonfunc = function () { var r; r = this._iterator.next(); if (r.done) { return {'done':true}; } this._i += 1; return {'done':false, 'value':[this._i, r.value]}; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ans; } return ρσ_enumerate(Object.keys(iterable)); }; if (!ρσ_enumerate.__argnames__) Object.defineProperties(ρσ_enumerate, { __argnames__ : {value: ["iterable"]}, __module__ : {value: "__main__"} }); function ρσ_reversed(iterable) { var ans; if (ρσ_arraylike(iterable)) { ans = {"_i": iterable.length}; ans["next"] = (function() { var ρσ_anonfunc = function () { this._i -= 1; if (this._i > -1) { return {'done':false, 'value':iterable[this._i]}; } return {'done':true}; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ans[ρσ_iterator_symbol] = (function() { var ρσ_anonfunc = function () { return this; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ans; } throw new TypeError("reversed() can only be called on arrays or strings"); }; if (!ρσ_reversed.__argnames__) Object.defineProperties(ρσ_reversed, { __argnames__ : {value: ["iterable"]}, __module__ : {value: "__main__"} }); function ρσ_iter(iterable) { var ans; if (typeof iterable[ρσ_iterator_symbol] === "function") { return (typeof Map === "function" && iterable instanceof Map) ? iterable.keys() : iterable[ρσ_iterator_symbol](); } if (ρσ_arraylike(iterable)) { ans = {"_i":-1}; ans[ρσ_iterator_symbol] = (function() { var ρσ_anonfunc = function () { return this; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ans["next"] = (function() { var ρσ_anonfunc = function () { this._i += 1; if (this._i < iterable.length) { return {'done':false, 'value':iterable[this._i]}; } return {'done':true}; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ans; } return ρσ_iter(Object.keys(iterable)); }; if (!ρσ_iter.__argnames__) Object.defineProperties(ρσ_iter, { __argnames__ : {value: ["iterable"]}, __module__ : {value: "__main__"} }); function ρσ_range_next(step, length) { var ρσ_unpack; this._i += step; this._idx += 1; if (this._idx >= length) { ρσ_unpack = [this.__i, -1]; this._i = ρσ_unpack[0]; this._idx = ρσ_unpack[1]; return {'done':true}; } return {'done':false, 'value':this._i}; }; if (!ρσ_range_next.__argnames__) Object.defineProperties(ρσ_range_next, { __argnames__ : {value: ["step", "length"]}, __module__ : {value: "__main__"} }); function ρσ_range(start, stop, step) { var length, ans; if (arguments.length <= 1) { stop = start || 0; start = 0; } step = arguments[2] || 1; length = Math.max(Math.ceil((stop - start) / step), 0); ans = {start:start, step:step, stop:stop}; ans[ρσ_iterator_symbol] = (function() { var ρσ_anonfunc = function () { var it; it = {"_i": start - step, "_idx": -1}; it.next = ρσ_range_next.bind(it, step, length); it[ρσ_iterator_symbol] = (function() { var ρσ_anonfunc = function () { return this; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return it; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ans.count = (function() { var ρσ_anonfunc = function (val) { if (!this._cached) { this._cached = list(this); } return this._cached.count(val); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["val"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ans.index = (function() { var ρσ_anonfunc = function (val) { if (!this._cached) { this._cached = list(this); } return this._cached.index(val); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["val"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ans.__len__ = (function() { var ρσ_anonfunc = function () { return length; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ans.__repr__ = (function() { var ρσ_anonfunc = function () { return "range(" + ρσ_str.format("{}", start) + ", " + ρσ_str.format("{}", stop) + ", " + ρσ_str.format("{}", step) + ")"; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ans.__str__ = ans.toString = ans.__repr__; if (typeof Proxy === "function") { ans = new Proxy(ans, (function(){ var ρσ_d = {}; ρσ_d["get"] = (function() { var ρσ_anonfunc = function (obj, prop) { var iprop; if (typeof prop === "string") { iprop = parseInt(prop); if (!isNaN(iprop)) { prop = iprop; } } if (typeof prop === "number") { if (!obj._cached) { obj._cached = list(obj); } return (ρσ_expr_temp = obj._cached)[(typeof prop === "number" && prop < 0) ? ρσ_expr_temp.length + prop : prop]; } return obj[(typeof prop === "number" && prop < 0) ? obj.length + prop : prop]; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["obj", "prop"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this)); } return ans; }; if (!ρσ_range.__argnames__) Object.defineProperties(ρσ_range, { __argnames__ : {value: ["start", "stop", "step"]}, __module__ : {value: "__main__"} }); function ρσ_getattr(obj, name, defval) { var ret; try { ret = obj[(typeof name === "number" && name < 0) ? obj.length + name : name]; } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; if (ρσ_Exception instanceof TypeError) { if (defval === undefined) { throw new AttributeError("The attribute " + name + " is not present"); } return defval; } else { throw ρσ_Exception; } } if (ret === undefined && !(name in obj)) { if (defval === undefined) { throw new AttributeError("The attribute " + name + " is not present"); } ret = defval; } return ret; }; if (!ρσ_getattr.__argnames__) Object.defineProperties(ρσ_getattr, { __argnames__ : {value: ["obj", "name", "defval"]}, __module__ : {value: "__main__"} }); function ρσ_setattr(obj, name, value) { obj[(typeof name === "number" && name < 0) ? obj.length + name : name] = value; }; if (!ρσ_setattr.__argnames__) Object.defineProperties(ρσ_setattr, { __argnames__ : {value: ["obj", "name", "value"]}, __module__ : {value: "__main__"} }); function ρσ_hasattr(obj, name) { return name in obj; }; if (!ρσ_hasattr.__argnames__) Object.defineProperties(ρσ_hasattr, { __argnames__ : {value: ["obj", "name"]}, __module__ : {value: "__main__"} }); ρσ_len = (function() { var ρσ_anonfunc = function () { function len(obj) { if (ρσ_arraylike(obj)) { return obj.length; } if (typeof obj.__len__ === "function") { return obj.__len__(); } if (obj instanceof Set || obj instanceof Map) { return obj.size; } return Object.keys(obj).length; }; if (!len.__argnames__) Object.defineProperties(len, { __argnames__ : {value: ["obj"]}, __module__ : {value: "__main__"} }); function len5(obj) { if (ρσ_arraylike(obj)) { return obj.length; } if (typeof obj.__len__ === "function") { return obj.__len__(); } return Object.keys(obj).length; }; if (!len5.__argnames__) Object.defineProperties(len5, { __argnames__ : {value: ["obj"]}, __module__ : {value: "__main__"} }); return (typeof Set === "function" && typeof Map === "function") ? len : len5; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()(); function ρσ_get_module(name) { return ρσ_modules[(typeof name === "number" && name < 0) ? ρσ_modules.length + name : name]; }; if (!ρσ_get_module.__argnames__) Object.defineProperties(ρσ_get_module, { __argnames__ : {value: ["name"]}, __module__ : {value: "__main__"} }); function ρσ_pow(x, y, z) { var ans; ans = Math.pow(x, y); if (z !== undefined) { ans %= z; } return ans; }; if (!ρσ_pow.__argnames__) Object.defineProperties(ρσ_pow, { __argnames__ : {value: ["x", "y", "z"]}, __module__ : {value: "__main__"} }); function ρσ_type(x) { return x.constructor; }; if (!ρσ_type.__argnames__) Object.defineProperties(ρσ_type, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); function ρσ_divmod(x, y) { var d; if (y === 0) { throw new ZeroDivisionError("integer division or modulo by zero"); } d = Math.floor(x / y); return [d, x - d * y]; }; if (!ρσ_divmod.__argnames__) Object.defineProperties(ρσ_divmod, { __argnames__ : {value: ["x", "y"]}, __module__ : {value: "__main__"} }); function ρσ_max() { var kwargs = arguments[arguments.length-1]; if (kwargs === null || typeof kwargs !== "object" || kwargs [ρσ_kwargs_symbol] !== true) kwargs = {}; var args = Array.prototype.slice.call(arguments, 0); if (kwargs !== null && typeof kwargs === "object" && kwargs [ρσ_kwargs_symbol] === true) args.pop(); var args, x; if (args.length === 0) { if (kwargs.defval !== undefined) { return kwargs.defval; } throw new TypeError("expected at least one argument"); } if (args.length === 1) { args = args[0]; } if (kwargs.key) { args = (function() { var ρσ_Iter = args, ρσ_Result = [], x; ρσ_Iter = ((typeof ρσ_Iter[Symbol.iterator] === "function") ? (ρσ_Iter instanceof Map ? ρσ_Iter.keys() : ρσ_Iter) : Object.keys(ρσ_Iter)); for (var ρσ_Index of ρσ_Iter) { x = ρσ_Index; ρσ_Result.push(kwargs.key(x)); } ρσ_Result = ρσ_list_constructor(ρσ_Result); return ρσ_Result; })(); } if (!Array.isArray(args)) { args = list(args); } if (args.length) { return this.apply(null, args); } if (kwargs.defval !== undefined) { return kwargs.defval; } throw new TypeError("expected at least one argument"); }; if (!ρσ_max.__handles_kwarg_interpolation__) Object.defineProperties(ρσ_max, { __handles_kwarg_interpolation__ : {value: true}, __module__ : {value: "__main__"} }); var abs = Math.abs, max = ρσ_max.bind(Math.max); var min = ρσ_max.bind(Math.min), bool = ρσ_bool, type = ρσ_type; var float = ρσ_float, int = ρσ_int, arraylike = ρσ_arraylike_creator(); var ρσ_arraylike = arraylike; var print = ρσ_print, id = ρσ_id, get_module = ρσ_get_module; var pow = ρσ_pow, divmod = ρσ_divmod; var dir = ρσ_dir, ord = ρσ_ord, chr = ρσ_chr, bin = ρσ_bin; var hex = ρσ_hex, callable = ρσ_callable; var enumerate = ρσ_enumerate, iter = ρσ_iter, reversed = ρσ_reversed; var len = ρσ_len; var range = ρσ_range, getattr = ρσ_getattr, setattr = ρσ_setattr; var hasattr = ρσ_hasattr;function ρσ_equals(a, b) { var ρσ_unpack, akeys, bkeys, key; if (a === b) { return true; } if (a && typeof a.__eq__ === "function") { return a.__eq__(b); } if (b && typeof b.__eq__ === "function") { return b.__eq__(a); } if (ρσ_arraylike(a) && ρσ_arraylike(b)) { if ((a.length !== b.length && (typeof a.length !== "object" || ρσ_not_equals(a.length, b.length)))) { return false; } for (var i=0; i < a.length; i++) { if (!(((a[(typeof i === "number" && i < 0) ? a.length + i : i] === b[(typeof i === "number" && i < 0) ? b.length + i : i] || typeof a[(typeof i === "number" && i < 0) ? a.length + i : i] === "object" && ρσ_equals(a[(typeof i === "number" && i < 0) ? a.length + i : i], b[(typeof i === "number" && i < 0) ? b.length + i : i]))))) { return false; } } return true; } if (typeof a === "object" && typeof b === "object" && a !== null && b !== null && (a.constructor === Object && b.constructor === Object || Object.getPrototypeOf(a) === null && Object.getPrototypeOf(b) === null)) { ρσ_unpack = [Object.keys(a), Object.keys(b)]; akeys = ρσ_unpack[0]; bkeys = ρσ_unpack[1]; if (akeys.length !== bkeys.length) { return false; } for (var j=0; j < akeys.length; j++) { key = akeys[(typeof j === "number" && j < 0) ? akeys.length + j : j]; if (!(((a[(typeof key === "number" && key < 0) ? a.length + key : key] === b[(typeof key === "number" && key < 0) ? b.length + key : key] || typeof a[(typeof key === "number" && key < 0) ? a.length + key : key] === "object" && ρσ_equals(a[(typeof key === "number" && key < 0) ? a.length + key : key], b[(typeof key === "number" && key < 0) ? b.length + key : key]))))) { return false; } } return true; } return false; }; if (!ρσ_equals.__argnames__) Object.defineProperties(ρσ_equals, { __argnames__ : {value: ["a", "b"]}, __module__ : {value: "__main__"} }); function ρσ_not_equals(a, b) { if (a === b) { return false; } if (a && typeof a.__ne__ === "function") { return a.__ne__(b); } if (b && typeof b.__ne__ === "function") { return b.__ne__(a); } return !ρσ_equals(a, b); }; if (!ρσ_not_equals.__argnames__) Object.defineProperties(ρσ_not_equals, { __argnames__ : {value: ["a", "b"]}, __module__ : {value: "__main__"} }); var equals = ρσ_equals; function ρσ_list_iterator(value) { var self; self = this; return (function(){ var ρσ_d = {}; ρσ_d["_i"] = -1; ρσ_d["_list"] = self; ρσ_d["next"] = (function() { var ρσ_anonfunc = function () { this._i += 1; if (this._i >= this._list.length) { return (function(){ var ρσ_d = {}; ρσ_d["done"] = true; return ρσ_d; }).call(this); } return (function(){ var ρσ_d = {}; ρσ_d["done"] = false; ρσ_d["value"] = (ρσ_expr_temp = this._list)[ρσ_bound_index(this._i, ρσ_expr_temp)]; return ρσ_d; }).call(this); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this); }; if (!ρσ_list_iterator.__argnames__) Object.defineProperties(ρσ_list_iterator, { __argnames__ : {value: ["value"]}, __module__ : {value: "__main__"} }); function ρσ_list_constructor(iterable) { var ans, iterator, result; if (iterable === undefined) { ans = []; } else if (ρσ_arraylike(iterable)) { ans = new Array(iterable.length); for (var i = 0; i < iterable.length; i++) { ans[(typeof i === "number" && i < 0) ? ans.length + i : i] = iterable[(typeof i === "number" && i < 0) ? iterable.length + i : i]; } } else if (typeof iterable[ρσ_iterator_symbol] === "function") { iterator = (typeof Map === "function" && iterable instanceof Map) ? iterable.keys() : iterable[ρσ_iterator_symbol](); ans = []; result = iterator.next(); while (!result.done) { ans.push(result.value); result = iterator.next(); } } else if (typeof iterable === "number") { ans = new Array(iterable); } else { ans = Object.keys(iterable); } return ans; }; if (!ρσ_list_constructor.__argnames__) Object.defineProperties(ρσ_list_constructor, { __argnames__ : {value: ["iterable"]}, __module__ : {value: "__main__"} }); ρσ_list_constructor.__name__ = "list"; if (typeof Array.prototype.append !== "function") { Object.defineProperty(Array.prototype, "append", (function(){ var ρσ_d = {}; ρσ_d["writable"] = false; ρσ_d["configurable"] = false; ρσ_d["enumerable"] = false; ρσ_d["value"] = Array.prototype.push; return ρσ_d; }).call(this)); Object.defineProperty(Array.prototype, "extend", (function(){ var ρσ_d = {}; ρσ_d["writable"] = false; ρσ_d["configurable"] = false; ρσ_d["enumerable"] = false; ρσ_d["value"] = (function() { var ρσ_anonfunc = function (iterable) { var start, iterator, result; if (Array.isArray(iterable) || typeof iterable === "string") { start = this.length; this.length += iterable.length; for (var i = 0; i < iterable.length; i++) { (ρσ_expr_temp = this)[ρσ_bound_index(start + i, ρσ_expr_temp)] = iterable[(typeof i === "number" && i < 0) ? iterable.length + i : i]; } } else { iterator = (typeof Map === "function" && iterable instanceof Map) ? iterable.keys() : iterable[ρσ_iterator_symbol](); result = iterator.next(); while (!result.done) { this.push(result.value); result = iterator.next(); } } }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["iterable"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this)); Object.defineProperty(Array.prototype, "index", (function(){ var ρσ_d = {}; ρσ_d["writable"] = false; ρσ_d["configurable"] = false; ρσ_d["enumerable"] = false; ρσ_d["value"] = (function() { var ρσ_anonfunc = function (val, start, stop) { start = start || 0; if (start < 0) { start = this.length + start; } if (start < 0) { throw new ValueError(val + " is not in list"); } if (stop === undefined) { stop = this.length; } if (stop < 0) { stop = this.length + stop; } for (var i = start; i < stop; i++) { if (((ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] === val || typeof (ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] === "object" && ρσ_equals((ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i], val))) { return i; } } throw new ValueError(val + " is not in list"); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["val", "start", "stop"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this)); Object.defineProperty(Array.prototype, "pypop", (function(){ var ρσ_d = {}; ρσ_d["writable"] = false; ρσ_d["configurable"] = false; ρσ_d["enumerable"] = false; ρσ_d["value"] = (function() { var ρσ_anonfunc = function (index) { var ans; if (this.length === 0) { throw new IndexError("list is empty"); } if (index === undefined) { index = -1; } ans = this.splice(index, 1); if (!ans.length) { throw new IndexError("pop index out of range"); } return ans[0]; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["index"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this)); Object.defineProperty(Array.prototype, "remove", (function(){ var ρσ_d = {}; ρσ_d["writable"] = false; ρσ_d["configurable"] = false; ρσ_d["enumerable"] = false; ρσ_d["value"] = (function() { var ρσ_anonfunc = function (value) { for (var i = 0; i < this.length; i++) { if (((ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] === value || typeof (ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] === "object" && ρσ_equals((ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i], value))) { this.splice(i, 1); return; } } throw new ValueError(value + " not in list"); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["value"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this)); Object.defineProperty(Array.prototype, "toString", (function(){ var ρσ_d = {}; ρσ_d["writable"] = false; ρσ_d["configurable"] = false; ρσ_d["enumerable"] = false; ρσ_d["value"] = (function() { var ρσ_anonfunc = function () { return "[" + this.join(", ") + "]"; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this)); Object.defineProperty(Array.prototype, "inspect", (function(){ var ρσ_d = {}; ρσ_d["writable"] = false; ρσ_d["configurable"] = false; ρσ_d["enumerable"] = false; ρσ_d["value"] = (function() { var ρσ_anonfunc = function () { return "[" + this.join(", ") + "]"; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this)); Object.defineProperty(Array.prototype, "insert", (function(){ var ρσ_d = {}; ρσ_d["writable"] = false; ρσ_d["configurable"] = false; ρσ_d["enumerable"] = false; ρσ_d["value"] = (function() { var ρσ_anonfunc = function (index, val) { if (index < 0) { index += this.length; } index = min(this.length, max(index, 0)); if (index === 0) { this.unshift(val); return; } for (var i = this.length; i > index; i--) { (ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] = (ρσ_expr_temp = this)[ρσ_bound_index(i - 1, ρσ_expr_temp)]; } (ρσ_expr_temp = this)[(typeof index === "number" && index < 0) ? ρσ_expr_temp.length + index : index] = val; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["index", "val"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this)); Object.defineProperty(Array.prototype, "copy", (function(){ var ρσ_d = {}; ρσ_d["writable"] = false; ρσ_d["configurable"] = false; ρσ_d["enumerable"] = false; ρσ_d["value"] = (function() { var ρσ_anonfunc = function () { return ρσ_list_constructor(this); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this)); Object.defineProperty(Array.prototype, "clear", (function(){ var ρσ_d = {}; ρσ_d["writable"] = false; ρσ_d["configurable"] = false; ρσ_d["enumerable"] = false; ρσ_d["value"] = (function() { var ρσ_anonfunc = function () { this.length = 0; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this)); Object.defineProperty(Array.prototype, "count", (function(){ var ρσ_d = {}; ρσ_d["writable"] = false; ρσ_d["configurable"] = false; ρσ_d["enumerable"] = false; ρσ_d["value"] = (function() { var ρσ_anonfunc = function (value) { return this.reduce((function() { var ρσ_anonfunc = function (n, val) { return n + (val === value); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["n", "val"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(), 0); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["value"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this)); Object.defineProperty(Array.prototype, "pysort", (function(){ var ρσ_d = {}; ρσ_d["writable"] = false; ρσ_d["configurable"] = false; ρσ_d["enumerable"] = false; ρσ_d["value"] = (function() { var ρσ_anonfunc = function () { var key = (arguments[0] === undefined || ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? ρσ_anonfunc.__defaults__.key : arguments[0]; var reverse = (arguments[1] === undefined || ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? ρσ_anonfunc.__defaults__.reverse : arguments[1]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "key")){ key = ρσ_kwargs_obj.key; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "reverse")){ reverse = ρσ_kwargs_obj.reverse; } var _sort_key, _sort_cmp, mult, keymap, posmap, k; _sort_key = (function() { var ρσ_anonfunc = function (value) { var t; t = typeof value; if (t === "string" || t === "number") { return value; } return value.toString(); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["value"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); _sort_cmp = (function() { var ρσ_anonfunc = function (a, b, ap, bp) { if (a < b) { return -1; } if (a > b) { return 1; } return ap - bp; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["a", "b", "ap", "bp"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); key = key || _sort_key; mult = (reverse) ? -1 : 1; keymap = dict(); posmap = dict(); for (var i=0; i < this.length; i++) { k = (ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i]; keymap.set(k, key(k)); posmap.set(k, i); } this.sort((function() { var ρσ_anonfunc = function (a, b) { return mult * _sort_cmp(keymap.get(a), keymap.get(b), posmap.get(a), posmap.get(b)); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["a", "b"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); }; if (!ρσ_anonfunc.__defaults__) Object.defineProperties(ρσ_anonfunc, { __defaults__ : {value: {key:null, reverse:false}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["key", "reverse"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this)); Object.defineProperty(Array.prototype, "as_array", (function(){ var ρσ_d = {}; ρσ_d["writable"] = false; ρσ_d["configurable"] = false; ρσ_d["enumerable"] = false; ρσ_d["value"] = (function() { var ρσ_anonfunc = function () { return Array.from(this); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this)); Object.defineProperty(Array.prototype, "__len__", (function(){ var ρσ_d = {}; ρσ_d["writable"] = false; ρσ_d["configurable"] = false; ρσ_d["enumerable"] = false; ρσ_d["value"] = (function() { var ρσ_anonfunc = function () { return this.length; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this)); Object.defineProperty(Array.prototype, "__contains__", (function(){ var ρσ_d = {}; ρσ_d["writable"] = false; ρσ_d["configurable"] = false; ρσ_d["enumerable"] = false; ρσ_d["value"] = (function() { var ρσ_anonfunc = function (val) { for (var i = 0; i < this.length; i++) { if (((ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] === val || typeof (ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] === "object" && ρσ_equals((ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i], val))) { return true; } } return false; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["val"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this)); Object.defineProperty(Array.prototype, "__eq__", (function(){ var ρσ_d = {}; ρσ_d["writable"] = false; ρσ_d["configurable"] = false; ρσ_d["enumerable"] = false; ρσ_d["value"] = (function() { var ρσ_anonfunc = function (other) { if (!ρσ_arraylike(other)) { return false; } if ((this.length !== other.length && (typeof this.length !== "object" || ρσ_not_equals(this.length, other.length)))) { return false; } for (var i = 0; i < this.length; i++) { if (!((((ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] === other[(typeof i === "number" && i < 0) ? other.length + i : i] || typeof (ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] === "object" && ρσ_equals((ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i], other[(typeof i === "number" && i < 0) ? other.length + i : i]))))) { return false; } } return true; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["other"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this)); Object.defineProperty(Array.prototype, "constructor", (function(){ var ρσ_d = {}; ρσ_d["writable"] = false; ρσ_d["configurable"] = false; ρσ_d["enumerable"] = false; ρσ_d["value"] = ρσ_list_constructor; return ρσ_d; }).call(this)); } function ρσ_list_decorate(ans) { return ans; }; if (!ρσ_list_decorate.__argnames__) Object.defineProperties(ρσ_list_decorate, { __argnames__ : {value: ["ans"]}, __module__ : {value: "__main__"} }); var list = ρσ_list_constructor, list_wrap = ρσ_list_decorate; function sorted() { var iterable = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var key = (arguments[1] === undefined || ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? sorted.__defaults__.key : arguments[1]; var reverse = (arguments[2] === undefined || ( 2 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? sorted.__defaults__.reverse : arguments[2]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "key")){ key = ρσ_kwargs_obj.key; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "reverse")){ reverse = ρσ_kwargs_obj.reverse; } var ans; ans = ρσ_list_constructor(iterable); ans.pysort(key, reverse); return ans; }; if (!sorted.__defaults__) Object.defineProperties(sorted, { __defaults__ : {value: {key:null, reverse:false}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["iterable", "key", "reverse"]}, __module__ : {value: "__main__"} }); var ρσ_global_object_id = 0, ρσ_set_implementation; function ρσ_set_keyfor(x) { var t, ans; t = typeof x; if (t === "string" || t === "number" || t === "boolean") { return "_" + t[0] + x; } if (x === null) { return "__!@#$0"; } ans = x.ρσ_hash_key_prop; if (ans === undefined) { ans = "_!@#$" + (++ρσ_global_object_id); Object.defineProperty(x, "ρσ_hash_key_prop", (function(){ var ρσ_d = {}; ρσ_d["value"] = ans; return ρσ_d; }).call(this)); } return ans; }; if (!ρσ_set_keyfor.__argnames__) Object.defineProperties(ρσ_set_keyfor, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); function ρσ_set_polyfill() { this._store = {}; this.size = 0; }; if (!ρσ_set_polyfill.__module__) Object.defineProperties(ρσ_set_polyfill, { __module__ : {value: "__main__"} }); ρσ_set_polyfill.prototype.add = (function() { var ρσ_anonfunc = function (x) { var key; key = ρσ_set_keyfor(x); if (!Object.prototype.hasOwnProperty.call(this._store, key)) { this.size += 1; (ρσ_expr_temp = this._store)[(typeof key === "number" && key < 0) ? ρσ_expr_temp.length + key : key] = x; } return this; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set_polyfill.prototype.clear = (function() { var ρσ_anonfunc = function (x) { this._store = {}; this.size = 0; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set_polyfill.prototype.delete = (function() { var ρσ_anonfunc = function (x) { var key; key = ρσ_set_keyfor(x); if (Object.prototype.hasOwnProperty.call(this._store, key)) { this.size -= 1; delete this._store[key]; return true; } return false; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set_polyfill.prototype.has = (function() { var ρσ_anonfunc = function (x) { return Object.prototype.hasOwnProperty.call(this._store, ρσ_set_keyfor(x)); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set_polyfill.prototype.values = (function() { var ρσ_anonfunc = function (x) { var ans; ans = {'_keys': Object.keys(this._store), '_i':-1, '_s':this._store}; ans[ρσ_iterator_symbol] = (function() { var ρσ_anonfunc = function () { return this; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ans["next"] = (function() { var ρσ_anonfunc = function () { this._i += 1; if (this._i >= this._keys.length) { return {'done': true}; } return {'done':false, 'value':this._s[this._keys[this._i]]}; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ans; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); if (typeof Set !== "function" || typeof Set.prototype.delete !== "function") { ρσ_set_implementation = ρσ_set_polyfill; } else { ρσ_set_implementation = Set; } function ρσ_set(iterable) { var ans, s, iterator, result, keys; if (this instanceof ρσ_set) { this.jsset = new ρσ_set_implementation; ans = this; if (iterable === undefined) { return ans; } s = ans.jsset; if (ρσ_arraylike(iterable)) { for (var i = 0; i < iterable.length; i++) { s.add(iterable[(typeof i === "number" && i < 0) ? iterable.length + i : i]); } } else if (typeof iterable[ρσ_iterator_symbol] === "function") { iterator = (typeof Map === "function" && iterable instanceof Map) ? iterable.keys() : iterable[ρσ_iterator_symbol](); result = iterator.next(); while (!result.done) { s.add(result.value); result = iterator.next(); } } else { keys = Object.keys(iterable); for (var j=0; j < keys.length; j++) { s.add(keys[(typeof j === "number" && j < 0) ? keys.length + j : j]); } } return ans; } else { return new ρσ_set(iterable); } }; if (!ρσ_set.__argnames__) Object.defineProperties(ρσ_set, { __argnames__ : {value: ["iterable"]}, __module__ : {value: "__main__"} }); ρσ_set.prototype.__name__ = "set"; Object.defineProperties(ρσ_set.prototype, (function(){ var ρσ_d = {}; ρσ_d["length"] = (function(){ var ρσ_d = {}; ρσ_d["get"] = (function() { var ρσ_anonfunc = function () { return this.jsset.size; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this); ρσ_d["size"] = (function(){ var ρσ_d = {}; ρσ_d["get"] = (function() { var ρσ_anonfunc = function () { return this.jsset.size; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this); return ρσ_d; }).call(this)); ρσ_set.prototype.__len__ = (function() { var ρσ_anonfunc = function () { return this.jsset.size; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set.prototype.has = ρσ_set.prototype.__contains__ = (function() { var ρσ_anonfunc = function (x) { return this.jsset.has(x); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set.prototype.add = (function() { var ρσ_anonfunc = function (x) { this.jsset.add(x); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set.prototype.clear = (function() { var ρσ_anonfunc = function () { this.jsset.clear(); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set.prototype.copy = (function() { var ρσ_anonfunc = function () { return ρσ_set(this); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set.prototype.discard = (function() { var ρσ_anonfunc = function (x) { this.jsset.delete(x); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set.prototype[ρσ_iterator_symbol] = (function() { var ρσ_anonfunc = function () { return this.jsset.values(); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set.prototype.difference = (function() { var ρσ_anonfunc = function () { var ans, s, iterator, r, x, has; ans = new ρσ_set; s = ans.jsset; iterator = this.jsset.values(); r = iterator.next(); while (!r.done) { x = r.value; has = false; for (var i = 0; i < arguments.length; i++) { if (arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i].has(x)) { has = true; break; } } if (!has) { s.add(x); } r = iterator.next(); } return ans; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set.prototype.difference_update = (function() { var ρσ_anonfunc = function () { var s, remove, iterator, r, x; s = this.jsset; remove = []; iterator = s.values(); r = iterator.next(); while (!r.done) { x = r.value; for (var i = 0; i < arguments.length; i++) { if (arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i].has(x)) { remove.push(x); break; } } r = iterator.next(); } for (var j = 0; j < remove.length; j++) { s.delete(remove[(typeof j === "number" && j < 0) ? remove.length + j : j]); } }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set.prototype.intersection = (function() { var ρσ_anonfunc = function () { var ans, s, iterator, r, x, has; ans = new ρσ_set; s = ans.jsset; iterator = this.jsset.values(); r = iterator.next(); while (!r.done) { x = r.value; has = true; for (var i = 0; i < arguments.length; i++) { if (!arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i].has(x)) { has = false; break; } } if (has) { s.add(x); } r = iterator.next(); } return ans; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set.prototype.intersection_update = (function() { var ρσ_anonfunc = function () { var s, remove, iterator, r, x; s = this.jsset; remove = []; iterator = s.values(); r = iterator.next(); while (!r.done) { x = r.value; for (var i = 0; i < arguments.length; i++) { if (!arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i].has(x)) { remove.push(x); break; } } r = iterator.next(); } for (var j = 0; j < remove.length; j++) { s.delete(remove[(typeof j === "number" && j < 0) ? remove.length + j : j]); } }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set.prototype.isdisjoint = (function() { var ρσ_anonfunc = function (other) { var iterator, r, x; iterator = this.jsset.values(); r = iterator.next(); while (!r.done) { x = r.value; if (other.has(x)) { return false; } r = iterator.next(); } return true; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["other"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set.prototype.issubset = (function() { var ρσ_anonfunc = function (other) { var iterator, r, x; iterator = this.jsset.values(); r = iterator.next(); while (!r.done) { x = r.value; if (!other.has(x)) { return false; } r = iterator.next(); } return true; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["other"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set.prototype.issuperset = (function() { var ρσ_anonfunc = function (other) { var s, iterator, r, x; s = this.jsset; iterator = other.jsset.values(); r = iterator.next(); while (!r.done) { x = r.value; if (!s.has(x)) { return false; } r = iterator.next(); } return true; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["other"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set.prototype.pop = (function() { var ρσ_anonfunc = function () { var iterator, r; iterator = this.jsset.values(); r = iterator.next(); if (r.done) { throw new KeyError("pop from an empty set"); } this.jsset.delete(r.value); return r.value; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set.prototype.remove = (function() { var ρσ_anonfunc = function (x) { if (!this.jsset.delete(x)) { throw new KeyError(x.toString()); } }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set.prototype.symmetric_difference = (function() { var ρσ_anonfunc = function (other) { return this.union(other).difference(this.intersection(other)); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["other"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set.prototype.symmetric_difference_update = (function() { var ρσ_anonfunc = function (other) { var common; common = this.intersection(other); this.update(other); this.difference_update(common); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["other"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set.prototype.union = (function() { var ρσ_anonfunc = function () { var ans; ans = ρσ_set(this); ans.update.apply(ans, arguments); return ans; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set.prototype.update = (function() { var ρσ_anonfunc = function () { var s, iterator, r; s = this.jsset; for (var i=0; i < arguments.length; i++) { iterator = arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i][ρσ_iterator_symbol](); r = iterator.next(); while (!r.done) { s.add(r.value); r = iterator.next(); } } }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set.prototype.toString = ρσ_set.prototype.__repr__ = ρσ_set.prototype.__str__ = ρσ_set.prototype.inspect = (function() { var ρσ_anonfunc = function () { return "{" + list(this).join(", ") + "}"; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_set.prototype.__eq__ = (function() { var ρσ_anonfunc = function (other) { var iterator, r; if (!other instanceof this.constructor) { return false; } if (other.size !== this.size) { return false; } if (other.size === 0) { return true; } iterator = other[ρσ_iterator_symbol](); r = iterator.next(); while (!r.done) { if (!this.has(r.value)) { return false; } r = iterator.next(); } return true; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["other"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); function ρσ_set_wrap(x) { var ans; ans = new ρσ_set; ans.jsset = x; return ans; }; if (!ρσ_set_wrap.__argnames__) Object.defineProperties(ρσ_set_wrap, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); var set = ρσ_set, set_wrap = ρσ_set_wrap; var ρσ_dict_implementation; function ρσ_dict_polyfill() { this._store = {}; this.size = 0; }; if (!ρσ_dict_polyfill.__module__) Object.defineProperties(ρσ_dict_polyfill, { __module__ : {value: "__main__"} }); ρσ_dict_polyfill.prototype.set = (function() { var ρσ_anonfunc = function (x, value) { var key; key = ρσ_set_keyfor(x); if (!Object.prototype.hasOwnProperty.call(this._store, key)) { this.size += 1; } (ρσ_expr_temp = this._store)[(typeof key === "number" && key < 0) ? ρσ_expr_temp.length + key : key] = [x, value]; return this; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["x", "value"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict_polyfill.prototype.clear = (function() { var ρσ_anonfunc = function (x) { this._store = {}; this.size = 0; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict_polyfill.prototype.delete = (function() { var ρσ_anonfunc = function (x) { var key; key = ρσ_set_keyfor(x); if (Object.prototype.hasOwnProperty.call(this._store, key)) { this.size -= 1; delete this._store[key]; return true; } return false; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict_polyfill.prototype.has = (function() { var ρσ_anonfunc = function (x) { return Object.prototype.hasOwnProperty.call(this._store, ρσ_set_keyfor(x)); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict_polyfill.prototype.get = (function() { var ρσ_anonfunc = function (x) { try { return (ρσ_expr_temp = this._store)[ρσ_bound_index(ρσ_set_keyfor(x), ρσ_expr_temp)][1]; } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; if (ρσ_Exception instanceof TypeError) { return undefined; } else { throw ρσ_Exception; } } }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict_polyfill.prototype.values = (function() { var ρσ_anonfunc = function (x) { var ans; ans = {'_keys': Object.keys(this._store), '_i':-1, '_s':this._store}; ans[ρσ_iterator_symbol] = (function() { var ρσ_anonfunc = function () { return this; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ans["next"] = (function() { var ρσ_anonfunc = function () { this._i += 1; if (this._i >= this._keys.length) { return {'done': true}; } return {'done':false, 'value':this._s[this._keys[this._i]][1]}; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ans; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict_polyfill.prototype.keys = (function() { var ρσ_anonfunc = function (x) { var ans; ans = {'_keys': Object.keys(this._store), '_i':-1, '_s':this._store}; ans[ρσ_iterator_symbol] = (function() { var ρσ_anonfunc = function () { return this; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ans["next"] = (function() { var ρσ_anonfunc = function () { this._i += 1; if (this._i >= this._keys.length) { return {'done': true}; } return {'done':false, 'value':this._s[this._keys[this._i]][0]}; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ans; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict_polyfill.prototype.entries = (function() { var ρσ_anonfunc = function (x) { var ans; ans = {'_keys': Object.keys(this._store), '_i':-1, '_s':this._store}; ans[ρσ_iterator_symbol] = (function() { var ρσ_anonfunc = function () { return this; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ans["next"] = (function() { var ρσ_anonfunc = function () { this._i += 1; if (this._i >= this._keys.length) { return {'done': true}; } return {'done':false, 'value':this._s[this._keys[this._i]]}; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ans; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); if (typeof Map !== "function" || typeof Map.prototype.delete !== "function") { ρσ_dict_implementation = ρσ_dict_polyfill; } else { ρσ_dict_implementation = Map; } function ρσ_dict() { var iterable = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var kw = arguments[arguments.length-1]; if (kw === null || typeof kw !== "object" || kw [ρσ_kwargs_symbol] !== true) kw = {}; if (this instanceof ρσ_dict) { this.jsmap = new ρσ_dict_implementation; if (iterable !== undefined) { this.update(iterable); } this.update(kw); return this; } else { return ρσ_interpolate_kwargs_constructor.call(Object.create(ρσ_dict.prototype), false, ρσ_dict, [iterable].concat([ρσ_desugar_kwargs(kw)])); } }; if (!ρσ_dict.__handles_kwarg_interpolation__) Object.defineProperties(ρσ_dict, { __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["iterable"]}, __module__ : {value: "__main__"} }); ρσ_dict.prototype.__name__ = "dict"; Object.defineProperties(ρσ_dict.prototype, (function(){ var ρσ_d = {}; ρσ_d["length"] = (function(){ var ρσ_d = {}; ρσ_d["get"] = (function() { var ρσ_anonfunc = function () { return this.jsmap.size; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this); ρσ_d["size"] = (function(){ var ρσ_d = {}; ρσ_d["get"] = (function() { var ρσ_anonfunc = function () { return this.jsmap.size; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this); return ρσ_d; }).call(this)); ρσ_dict.prototype.__len__ = (function() { var ρσ_anonfunc = function () { return this.jsmap.size; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict.prototype.has = ρσ_dict.prototype.__contains__ = (function() { var ρσ_anonfunc = function (x) { return this.jsmap.has(x); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict.prototype.set = ρσ_dict.prototype.__setitem__ = (function() { var ρσ_anonfunc = function (key, value) { this.jsmap.set(key, value); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["key", "value"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict.prototype.__delitem__ = (function() { var ρσ_anonfunc = function (key) { this.jsmap.delete(key); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["key"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict.prototype.clear = (function() { var ρσ_anonfunc = function () { this.jsmap.clear(); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict.prototype.copy = (function() { var ρσ_anonfunc = function () { return ρσ_dict(this); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict.prototype.keys = (function() { var ρσ_anonfunc = function () { return this.jsmap.keys(); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict.prototype.values = (function() { var ρσ_anonfunc = function () { return this.jsmap.values(); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict.prototype.items = ρσ_dict.prototype.entries = (function() { var ρσ_anonfunc = function () { return this.jsmap.entries(); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict.prototype[ρσ_iterator_symbol] = (function() { var ρσ_anonfunc = function () { return this.jsmap.keys(); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict.prototype.__getitem__ = (function() { var ρσ_anonfunc = function (key) { var ans; ans = this.jsmap.get(key); if (ans === undefined && !this.jsmap.has(key)) { throw new KeyError(key + ""); } return ans; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["key"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict.prototype.get = (function() { var ρσ_anonfunc = function (key, defval) { var ans; ans = this.jsmap.get(key); if (ans === undefined && !this.jsmap.has(key)) { return (defval === undefined) ? null : defval; } return ans; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["key", "defval"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict.prototype.set_default = ρσ_dict.prototype.setdefault = (function() { var ρσ_anonfunc = function (key, defval) { var j; j = this.jsmap; if (!j.has(key)) { j.set(key, defval); return defval; } return j.get(key); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["key", "defval"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict.fromkeys = ρσ_dict.prototype.fromkeys = (function() { var ρσ_anonfunc = function () { var iterable = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var value = (arguments[1] === undefined || ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? ρσ_anonfunc.__defaults__.value : arguments[1]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "value")){ value = ρσ_kwargs_obj.value; } var ans, iterator, r; ans = ρσ_dict(); iterator = iter(iterable); r = iterator.next(); while (!r.done) { ans.set(r.value, value); r = iterator.next(); } return ans; }; if (!ρσ_anonfunc.__defaults__) Object.defineProperties(ρσ_anonfunc, { __defaults__ : {value: {value:null}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["iterable", "value"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict.prototype.pop = (function() { var ρσ_anonfunc = function (key, defval) { var ans; ans = this.jsmap.get(key); if (ans === undefined && !this.jsmap.has(key)) { if (defval === undefined) { throw new KeyError(key); } return defval; } this.jsmap.delete(key); return ans; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["key", "defval"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict.prototype.popitem = (function() { var ρσ_anonfunc = function () { var last, e, r; last = null; e = this.jsmap.entries(); while (true) { r = e.next(); if (r.done) { if (last === null) { throw new KeyError("dict is empty"); } this.jsmap.delete(last.value[0]); return last.value; } last = r; } }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict.prototype.update = (function() { var ρσ_anonfunc = function () { var m, iterable, iterator, result, keys; if (arguments.length === 0) { return; } m = this.jsmap; iterable = arguments[0]; if (Array.isArray(iterable)) { for (var i = 0; i < iterable.length; i++) { m.set(iterable[(typeof i === "number" && i < 0) ? iterable.length + i : i][0], iterable[(typeof i === "number" && i < 0) ? iterable.length + i : i][1]); } } else if (iterable instanceof ρσ_dict) { iterator = iterable.items(); result = iterator.next(); while (!result.done) { m.set(result.value[0], result.value[1]); result = iterator.next(); } } else if (typeof Map === "function" && iterable instanceof Map) { iterator = iterable.entries(); result = iterator.next(); while (!result.done) { m.set(result.value[0], result.value[1]); result = iterator.next(); } } else if (typeof iterable[ρσ_iterator_symbol] === "function") { iterator = iterable[ρσ_iterator_symbol](); result = iterator.next(); while (!result.done) { m.set(result.value[0], result.value[1]); result = iterator.next(); } } else { keys = Object.keys(iterable); for (var j=0; j < keys.length; j++) { if (keys[(typeof j === "number" && j < 0) ? keys.length + j : j] !== ρσ_iterator_symbol) { m.set(keys[(typeof j === "number" && j < 0) ? keys.length + j : j], iterable[ρσ_bound_index(keys[(typeof j === "number" && j < 0) ? keys.length + j : j], iterable)]); } } } if (arguments.length > 1) { ρσ_dict.prototype.update.call(this, arguments[1]); } }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict.prototype.toString = ρσ_dict.prototype.inspect = ρσ_dict.prototype.__str__ = ρσ_dict.prototype.__repr__ = (function() { var ρσ_anonfunc = function () { var entries, iterator, r; entries = []; iterator = this.jsmap.entries(); r = iterator.next(); while (!r.done) { entries.push(ρσ_repr(r.value[0]) + ": " + ρσ_repr(r.value[1])); r = iterator.next(); } return "{" + entries.join(", ") + "}"; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict.prototype.__eq__ = (function() { var ρσ_anonfunc = function (other) { var iterator, r, x; if (!(other instanceof this.constructor)) { return false; } if (other.size !== this.size) { return false; } if (other.size === 0) { return true; } iterator = other.items(); r = iterator.next(); while (!r.done) { x = this.jsmap.get(r.value[0]); if (x === undefined && !this.jsmap.has(r.value[0]) || x !== r.value[1]) { return false; } r = iterator.next(); } return true; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["other"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_dict.prototype.as_object = (function() { var ρσ_anonfunc = function (other) { var ans, iterator, r; ans = {}; iterator = this.jsmap.entries(); r = iterator.next(); while (!r.done) { ans[ρσ_bound_index(r.value[0], ans)] = r.value[1]; r = iterator.next(); } return ans; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["other"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); function ρσ_dict_wrap(x) { var ans; ans = new ρσ_dict; ans.jsmap = x; return ans; }; if (!ρσ_dict_wrap.__argnames__) Object.defineProperties(ρσ_dict_wrap, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); var dict = ρσ_dict, dict_wrap = ρσ_dict_wrap;// }}} var NameError; NameError = ReferenceError; function Exception() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); Exception.prototype.__init__.apply(this, arguments); } ρσ_extends(Exception, Error); Exception.prototype.__init__ = function __init__(message) { var self = this; self.message = message; self.stack = (new Error).stack; self.name = self.constructor.name; }; if (!Exception.prototype.__init__.__argnames__) Object.defineProperties(Exception.prototype.__init__, { __argnames__ : {value: ["message"]}, __module__ : {value: "__main__"} }); Exception.__argnames__ = Exception.prototype.__init__.__argnames__; Exception.__handles_kwarg_interpolation__ = Exception.prototype.__init__.__handles_kwarg_interpolation__; Exception.prototype.__repr__ = function __repr__() { var self = this; return self.name + ": " + self.message; }; if (!Exception.prototype.__repr__.__module__) Object.defineProperties(Exception.prototype.__repr__, { __module__ : {value: "__main__"} }); Exception.prototype.__str__ = function __str__ () { if(Error.prototype.__str__) return Error.prototype.__str__.call(this); return this.__repr__(); }; Object.defineProperty(Exception.prototype, "__bases__", {value: [Error]}); function AttributeError() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); AttributeError.prototype.__init__.apply(this, arguments); } ρσ_extends(AttributeError, Exception); AttributeError.prototype.__init__ = function __init__ () { Exception.prototype.__init__ && Exception.prototype.__init__.apply(this, arguments); }; AttributeError.prototype.__repr__ = function __repr__ () { if(Exception.prototype.__repr__) return Exception.prototype.__repr__.call(this); return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; AttributeError.prototype.__str__ = function __str__ () { if(Exception.prototype.__str__) return Exception.prototype.__str__.call(this); return this.__repr__(); }; Object.defineProperty(AttributeError.prototype, "__bases__", {value: [Exception]}); function IndexError() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); IndexError.prototype.__init__.apply(this, arguments); } ρσ_extends(IndexError, Exception); IndexError.prototype.__init__ = function __init__ () { Exception.prototype.__init__ && Exception.prototype.__init__.apply(this, arguments); }; IndexError.prototype.__repr__ = function __repr__ () { if(Exception.prototype.__repr__) return Exception.prototype.__repr__.call(this); return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; IndexError.prototype.__str__ = function __str__ () { if(Exception.prototype.__str__) return Exception.prototype.__str__.call(this); return this.__repr__(); }; Object.defineProperty(IndexError.prototype, "__bases__", {value: [Exception]}); function KeyError() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); KeyError.prototype.__init__.apply(this, arguments); } ρσ_extends(KeyError, Exception); KeyError.prototype.__init__ = function __init__ () { Exception.prototype.__init__ && Exception.prototype.__init__.apply(this, arguments); }; KeyError.prototype.__repr__ = function __repr__ () { if(Exception.prototype.__repr__) return Exception.prototype.__repr__.call(this); return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; KeyError.prototype.__str__ = function __str__ () { if(Exception.prototype.__str__) return Exception.prototype.__str__.call(this); return this.__repr__(); }; Object.defineProperty(KeyError.prototype, "__bases__", {value: [Exception]}); function ValueError() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); ValueError.prototype.__init__.apply(this, arguments); } ρσ_extends(ValueError, Exception); ValueError.prototype.__init__ = function __init__ () { Exception.prototype.__init__ && Exception.prototype.__init__.apply(this, arguments); }; ValueError.prototype.__repr__ = function __repr__ () { if(Exception.prototype.__repr__) return Exception.prototype.__repr__.call(this); return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; ValueError.prototype.__str__ = function __str__ () { if(Exception.prototype.__str__) return Exception.prototype.__str__.call(this); return this.__repr__(); }; Object.defineProperty(ValueError.prototype, "__bases__", {value: [Exception]}); function UnicodeDecodeError() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); UnicodeDecodeError.prototype.__init__.apply(this, arguments); } ρσ_extends(UnicodeDecodeError, Exception); UnicodeDecodeError.prototype.__init__ = function __init__ () { Exception.prototype.__init__ && Exception.prototype.__init__.apply(this, arguments); }; UnicodeDecodeError.prototype.__repr__ = function __repr__ () { if(Exception.prototype.__repr__) return Exception.prototype.__repr__.call(this); return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; UnicodeDecodeError.prototype.__str__ = function __str__ () { if(Exception.prototype.__str__) return Exception.prototype.__str__.call(this); return this.__repr__(); }; Object.defineProperty(UnicodeDecodeError.prototype, "__bases__", {value: [Exception]}); function AssertionError() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); AssertionError.prototype.__init__.apply(this, arguments); } ρσ_extends(AssertionError, Exception); AssertionError.prototype.__init__ = function __init__ () { Exception.prototype.__init__ && Exception.prototype.__init__.apply(this, arguments); }; AssertionError.prototype.__repr__ = function __repr__ () { if(Exception.prototype.__repr__) return Exception.prototype.__repr__.call(this); return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; AssertionError.prototype.__str__ = function __str__ () { if(Exception.prototype.__str__) return Exception.prototype.__str__.call(this); return this.__repr__(); }; Object.defineProperty(AssertionError.prototype, "__bases__", {value: [Exception]}); function ZeroDivisionError() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); ZeroDivisionError.prototype.__init__.apply(this, arguments); } ρσ_extends(ZeroDivisionError, Exception); ZeroDivisionError.prototype.__init__ = function __init__ () { Exception.prototype.__init__ && Exception.prototype.__init__.apply(this, arguments); }; ZeroDivisionError.prototype.__repr__ = function __repr__ () { if(Exception.prototype.__repr__) return Exception.prototype.__repr__.call(this); return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; ZeroDivisionError.prototype.__str__ = function __str__ () { if(Exception.prototype.__str__) return Exception.prototype.__str__.call(this); return this.__repr__(); }; Object.defineProperty(ZeroDivisionError.prototype, "__bases__", {value: [Exception]}); var ρσ_in, ρσ_desugar_kwargs, ρσ_exists; function ρσ_eslice(arr, step, start, end) { var is_string; if (typeof arr === "string" || arr instanceof String) { is_string = true; arr = arr.split(""); } if (step < 0) { step = -step; arr = arr.slice().reverse(); if (typeof start !== "undefined") { start = arr.length - start - 1; } if (typeof end !== "undefined") { end = arr.length - end - 1; } } if (typeof start === "undefined") { start = 0; } if (typeof end === "undefined") { end = arr.length; } arr = arr.slice(start, end).filter((function() { var ρσ_anonfunc = function (e, i) { return i % step === 0; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["e", "i"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); if (is_string) { arr = arr.join(""); } return arr; }; if (!ρσ_eslice.__argnames__) Object.defineProperties(ρσ_eslice, { __argnames__ : {value: ["arr", "step", "start", "end"]}, __module__ : {value: "__main__"} }); function ρσ_delslice(arr, step, start, end) { var is_string, ρσ_unpack, indices; if (typeof arr === "string" || arr instanceof String) { is_string = true; arr = arr.split(""); } if (step < 0) { if (typeof start === "undefined") { start = arr.length; } if (typeof end === "undefined") { end = 0; } ρσ_unpack = [end, start, -step]; start = ρσ_unpack[0]; end = ρσ_unpack[1]; step = ρσ_unpack[2]; } if (typeof start === "undefined") { start = 0; } if (typeof end === "undefined") { end = arr.length; } if (step === 1) { arr.splice(start, end - start); } else { if (end > start) { indices = []; for (var i = start; i < end; i += step) { indices.push(i); } for (var i = indices.length - 1; i >= 0; i--) { arr.splice(indices[(typeof i === "number" && i < 0) ? indices.length + i : i], 1); } } } if (is_string) { arr = arr.join(""); } return arr; }; if (!ρσ_delslice.__argnames__) Object.defineProperties(ρσ_delslice, { __argnames__ : {value: ["arr", "step", "start", "end"]}, __module__ : {value: "__main__"} }); function ρσ_flatten(arr) { var ans, value; ans = []; for (var i=0; i < arr.length; i++) { value = arr[(typeof i === "number" && i < 0) ? arr.length + i : i]; if (Array.isArray(value)) { ans = ans.concat(ρσ_flatten(value)); } else { ans.push(value); } } return ans; }; if (!ρσ_flatten.__argnames__) Object.defineProperties(ρσ_flatten, { __argnames__ : {value: ["arr"]}, __module__ : {value: "__main__"} }); function ρσ_unpack_asarray(num, iterable) { var ans, iterator, result; if (ρσ_arraylike(iterable)) { return iterable; } ans = []; if (typeof iterable[ρσ_iterator_symbol] === "function") { iterator = (typeof Map === "function" && iterable instanceof Map) ? iterable.keys() : iterable[ρσ_iterator_symbol](); result = iterator.next(); while (!result.done && ans.length < num) { ans.push(result.value); result = iterator.next(); } } return ans; }; if (!ρσ_unpack_asarray.__argnames__) Object.defineProperties(ρσ_unpack_asarray, { __argnames__ : {value: ["num", "iterable"]}, __module__ : {value: "__main__"} }); function ρσ_extends(child, parent) { child.prototype = Object.create(parent.prototype); child.prototype.constructor = child; }; if (!ρσ_extends.__argnames__) Object.defineProperties(ρσ_extends, { __argnames__ : {value: ["child", "parent"]}, __module__ : {value: "__main__"} }); ρσ_in = (function() { var ρσ_anonfunc = function () { if (typeof Map === "function" && typeof Set === "function") { return (function() { var ρσ_anonfunc = function (val, arr) { if (typeof arr === "string") { return arr.indexOf(val) !== -1; } if (typeof arr.__contains__ === "function") { return arr.__contains__(val); } if (arr instanceof Map || arr instanceof Set) { return arr.has(val); } if (ρσ_arraylike(arr)) { return Array.prototype.__contains__.call(arr, val); } return Object.prototype.hasOwnProperty.call(arr, val); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["val", "arr"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); } return (function() { var ρσ_anonfunc = function (val, arr) { if (typeof arr === "string") { return arr.indexOf(val) !== -1; } if (typeof arr.__contains__ === "function") { return arr.__contains__(val); } if (ρσ_arraylike(arr)) { return Array.prototype.__contains__.call(arr, val); } return Object.prototype.hasOwnProperty.call(arr, val); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["val", "arr"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()(); function ρσ_Iterable(iterable) { var iterator, ans, result; if (ρσ_arraylike(iterable)) { return iterable; } if (typeof iterable[ρσ_iterator_symbol] === "function") { iterator = (typeof Map === "function" && iterable instanceof Map) ? iterable.keys() : iterable[ρσ_iterator_symbol](); ans = []; result = iterator.next(); while (!result.done) { ans.push(result.value); result = iterator.next(); } return ans; } return Object.keys(iterable); }; if (!ρσ_Iterable.__argnames__) Object.defineProperties(ρσ_Iterable, { __argnames__ : {value: ["iterable"]}, __module__ : {value: "__main__"} }); ρσ_desugar_kwargs = (function() { var ρσ_anonfunc = function () { if (typeof Object.assign === "function") { return (function() { var ρσ_anonfunc = function () { var ans; ans = Object.create(null); ans[ρσ_kwargs_symbol] = true; for (var i = 0; i < arguments.length; i++) { Object.assign(ans, arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i]); } return ans; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); } return (function() { var ρσ_anonfunc = function () { var ans, keys; ans = Object.create(null); ans[ρσ_kwargs_symbol] = true; for (var i = 0; i < arguments.length; i++) { keys = Object.keys(arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i]); for (var j = 0; j < keys.length; j++) { ans[ρσ_bound_index(keys[(typeof j === "number" && j < 0) ? keys.length + j : j], ans)] = (ρσ_expr_temp = arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i])[ρσ_bound_index(keys[(typeof j === "number" && j < 0) ? keys.length + j : j], ρσ_expr_temp)]; } } return ans; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()(); function ρσ_interpolate_kwargs(f, supplied_args) { var has_prop, kwobj, args, prop; if (!f.__argnames__) { return f.apply(this, supplied_args); } has_prop = Object.prototype.hasOwnProperty; kwobj = supplied_args.pop(); if (f.__handles_kwarg_interpolation__) { args = new Array(Math.max(supplied_args.length, f.__argnames__.length) + 1); args[args.length-1] = kwobj; for (var i = 0; i < args.length - 1; i++) { if (i < f.__argnames__.length) { prop = (ρσ_expr_temp = f.__argnames__)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i]; if (has_prop.call(kwobj, prop)) { args[(typeof i === "number" && i < 0) ? args.length + i : i] = kwobj[(typeof prop === "number" && prop < 0) ? kwobj.length + prop : prop]; delete kwobj[prop]; } else if (i < supplied_args.length) { args[(typeof i === "number" && i < 0) ? args.length + i : i] = supplied_args[(typeof i === "number" && i < 0) ? supplied_args.length + i : i]; } } else { args[(typeof i === "number" && i < 0) ? args.length + i : i] = supplied_args[(typeof i === "number" && i < 0) ? supplied_args.length + i : i]; } } return f.apply(this, args); } for (var i = 0; i < f.__argnames__.length; i++) { prop = (ρσ_expr_temp = f.__argnames__)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i]; if (has_prop.call(kwobj, prop)) { supplied_args[(typeof i === "number" && i < 0) ? supplied_args.length + i : i] = kwobj[(typeof prop === "number" && prop < 0) ? kwobj.length + prop : prop]; } } return f.apply(this, supplied_args); }; if (!ρσ_interpolate_kwargs.__argnames__) Object.defineProperties(ρσ_interpolate_kwargs, { __argnames__ : {value: ["f", "supplied_args"]}, __module__ : {value: "__main__"} }); function ρσ_interpolate_kwargs_constructor(apply, f, supplied_args) { if (apply) { f.apply(this, supplied_args); } else { ρσ_interpolate_kwargs.call(this, f, supplied_args); } return this; }; if (!ρσ_interpolate_kwargs_constructor.__argnames__) Object.defineProperties(ρσ_interpolate_kwargs_constructor, { __argnames__ : {value: ["apply", "f", "supplied_args"]}, __module__ : {value: "__main__"} }); function ρσ_getitem(obj, key) { if (obj.__getitem__) { return obj.__getitem__(key); } if (typeof key === "number" && key < 0) { key += obj.length; } return obj[(typeof key === "number" && key < 0) ? obj.length + key : key]; }; if (!ρσ_getitem.__argnames__) Object.defineProperties(ρσ_getitem, { __argnames__ : {value: ["obj", "key"]}, __module__ : {value: "__main__"} }); function ρσ_setitem(obj, key, val) { if (obj.__setitem__) { obj.__setitem__(key, val); } else { if (typeof key === "number" && key < 0) { key += obj.length; } obj[(typeof key === "number" && key < 0) ? obj.length + key : key] = val; } return val; }; if (!ρσ_setitem.__argnames__) Object.defineProperties(ρσ_setitem, { __argnames__ : {value: ["obj", "key", "val"]}, __module__ : {value: "__main__"} }); function ρσ_delitem(obj, key) { if (obj.__delitem__) { obj.__delitem__(key); } else if (typeof obj.splice === "function") { obj.splice(key, 1); } else { if (typeof key === "number" && key < 0) { key += obj.length; } delete obj[key]; } }; if (!ρσ_delitem.__argnames__) Object.defineProperties(ρσ_delitem, { __argnames__ : {value: ["obj", "key"]}, __module__ : {value: "__main__"} }); function ρσ_bound_index(idx, arr) { if (typeof idx === "number" && idx < 0) { idx += arr.length; } return idx; }; if (!ρσ_bound_index.__argnames__) Object.defineProperties(ρσ_bound_index, { __argnames__ : {value: ["idx", "arr"]}, __module__ : {value: "__main__"} }); function ρσ_splice(arr, val, start, end) { start = start || 0; if (start < 0) { start += arr.length; } if (end === undefined) { end = arr.length; } if (end < 0) { end += arr.length; } Array.prototype.splice.apply(arr, [start, end - start].concat(val)); }; if (!ρσ_splice.__argnames__) Object.defineProperties(ρσ_splice, { __argnames__ : {value: ["arr", "val", "start", "end"]}, __module__ : {value: "__main__"} }); ρσ_exists = (function(){ var ρσ_d = {}; ρσ_d["n"] = (function() { var ρσ_anonfunc = function (expr) { return expr !== undefined && expr !== null; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["expr"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_d["d"] = (function() { var ρσ_anonfunc = function (expr) { if (expr === undefined || expr === null) { return Object.create(null); } return expr; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["expr"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_d["c"] = (function() { var ρσ_anonfunc = function (expr) { if (typeof expr === "function") { return expr; } return (function() { var ρσ_anonfunc = function () { return undefined; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["expr"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_d["g"] = (function() { var ρσ_anonfunc = function (expr) { if (expr === undefined || expr === null || typeof expr.__getitem__ !== "function") { return (function(){ var ρσ_d = {}; ρσ_d["__getitem__"] = (function() { var ρσ_anonfunc = function () { return undefined; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this); } }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["expr"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_d["e"] = (function() { var ρσ_anonfunc = function (expr, alt) { return (expr === undefined || expr === null) ? alt : expr; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["expr", "alt"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this); function ρσ_mixin() { var seen, resolved_props, p, target, props, name; seen = Object.create(null); seen.__argnames__ = seen.__handles_kwarg_interpolation__ = seen.__init__ = seen.__annotations__ = seen.__doc__ = seen.__bind_methods__ = seen.__bases__ = seen.constructor = seen.__class__ = true; resolved_props = {}; p = target = arguments[0].prototype; while (p && p !== Object.prototype) { props = Object.getOwnPropertyNames(p); for (var i = 0; i < props.length; i++) { seen[ρσ_bound_index(props[(typeof i === "number" && i < 0) ? props.length + i : i], seen)] = true; } p = Object.getPrototypeOf(p); } for (var c = 1; c < arguments.length; c++) { p = arguments[(typeof c === "number" && c < 0) ? arguments.length + c : c].prototype; while (p && p !== Object.prototype) { props = Object.getOwnPropertyNames(p); for (var i = 0; i < props.length; i++) { name = props[(typeof i === "number" && i < 0) ? props.length + i : i]; if (seen[(typeof name === "number" && name < 0) ? seen.length + name : name]) { continue; } seen[(typeof name === "number" && name < 0) ? seen.length + name : name] = true; resolved_props[(typeof name === "number" && name < 0) ? resolved_props.length + name : name] = Object.getOwnPropertyDescriptor(p, name); } p = Object.getPrototypeOf(p); } } Object.defineProperties(target, resolved_props); }; if (!ρσ_mixin.__module__) Object.defineProperties(ρσ_mixin, { __module__ : {value: "__main__"} }); function ρσ_instanceof() { var obj, bases, q, cls, p; obj = arguments[0]; bases = ""; if (obj && obj.constructor && obj.constructor.prototype) { bases = obj.constructor.prototype.__bases__ || ""; } for (var i = 1; i < arguments.length; i++) { q = arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i]; if (obj instanceof q) { return true; } if ((q === Array || q === ρσ_list_constructor) && Array.isArray(obj)) { return true; } if (q === ρσ_str && (typeof obj === "string" || obj instanceof String)) { return true; } if (q === ρσ_int && typeof obj === "number" && Number.isInteger(obj)) { return true; } if (q === ρσ_float && typeof obj === "number" && !Number.isInteger(obj)) { return true; } if (bases.length > 1) { for (var c = 1; c < bases.length; c++) { cls = bases[(typeof c === "number" && c < 0) ? bases.length + c : c]; while (cls) { if (q === cls) { return true; } p = Object.getPrototypeOf(cls.prototype); if (!p) { break; } cls = p.constructor; } } } } return false; }; if (!ρσ_instanceof.__module__) Object.defineProperties(ρσ_instanceof, { __module__ : {value: "__main__"} }); function sum(iterable, start) { var ans, iterator, r; if (Array.isArray(iterable)) { return iterable.reduce((function() { var ρσ_anonfunc = function (prev, cur) { return prev + cur; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["prev", "cur"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(), start || 0); } ans = start || 0; iterator = iter(iterable); r = iterator.next(); while (!r.done) { ans += r.value; r = iterator.next(); } return ans; }; if (!sum.__argnames__) Object.defineProperties(sum, { __argnames__ : {value: ["iterable", "start"]}, __module__ : {value: "__main__"} }); function map() { var iterators, func, args, ans; iterators = new Array(arguments.length - 1); func = arguments[0]; args = new Array(arguments.length - 1); for (var i = 1; i < arguments.length; i++) { iterators[ρσ_bound_index(i - 1, iterators)] = iter(arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i]); } ans = {'_func':func, '_iterators':iterators, '_args':args}; ans[ρσ_iterator_symbol] = (function() { var ρσ_anonfunc = function () { return this; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ans["next"] = (function() { var ρσ_anonfunc = function () { var r; for (var i = 0; i < this._iterators.length; i++) { r = (ρσ_expr_temp = this._iterators)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i].next(); if (r.done) { return {'done':true}; } (ρσ_expr_temp = this._args)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] = r.value; } return {'done':false, 'value':this._func.apply(undefined, this._args)}; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ans; }; if (!map.__module__) Object.defineProperties(map, { __module__ : {value: "__main__"} }); function filter(func_or_none, iterable) { var func, ans; func = (func_or_none === null) ? ρσ_bool : func_or_none; ans = {'_func':func, '_iterator':ρσ_iter(iterable)}; ans[ρσ_iterator_symbol] = (function() { var ρσ_anonfunc = function () { return this; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ans["next"] = (function() { var ρσ_anonfunc = function () { var r; r = this._iterator.next(); while (!r.done) { if (this._func(r.value)) { return r; } r = this._iterator.next(); } return {'done':true}; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ans; }; if (!filter.__argnames__) Object.defineProperties(filter, { __argnames__ : {value: ["func_or_none", "iterable"]}, __module__ : {value: "__main__"} }); function zip() { var iterators, ans; iterators = new Array(arguments.length); for (var i = 0; i < arguments.length; i++) { iterators[(typeof i === "number" && i < 0) ? iterators.length + i : i] = iter(arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i]); } ans = {'_iterators':iterators}; ans[ρσ_iterator_symbol] = (function() { var ρσ_anonfunc = function () { return this; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ans["next"] = (function() { var ρσ_anonfunc = function () { var args, r; args = new Array(this._iterators.length); for (var i = 0; i < this._iterators.length; i++) { r = (ρσ_expr_temp = this._iterators)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i].next(); if (r.done) { return {'done':true}; } args[(typeof i === "number" && i < 0) ? args.length + i : i] = r.value; } return {'done':false, 'value':args}; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ans; }; if (!zip.__module__) Object.defineProperties(zip, { __module__ : {value: "__main__"} }); function any(iterable) { var i; var ρσ_Iter0 = iterable; ρσ_Iter0 = ((typeof ρσ_Iter0[Symbol.iterator] === "function") ? (ρσ_Iter0 instanceof Map ? ρσ_Iter0.keys() : ρσ_Iter0) : Object.keys(ρσ_Iter0)); for (var ρσ_Index0 of ρσ_Iter0) { i = ρσ_Index0; if (i) { return true; } } return false; }; if (!any.__argnames__) Object.defineProperties(any, { __argnames__ : {value: ["iterable"]}, __module__ : {value: "__main__"} }); function all(iterable) { var i; var ρσ_Iter1 = iterable; ρσ_Iter1 = ((typeof ρσ_Iter1[Symbol.iterator] === "function") ? (ρσ_Iter1 instanceof Map ? ρσ_Iter1.keys() : ρσ_Iter1) : Object.keys(ρσ_Iter1)); for (var ρσ_Index1 of ρσ_Iter1) { i = ρσ_Index1; if (!i) { return false; } } return true; }; if (!all.__argnames__) Object.defineProperties(all, { __argnames__ : {value: ["iterable"]}, __module__ : {value: "__main__"} }); var decimal_sep, define_str_func, ρσ_orig_split, ρσ_orig_replace; decimal_sep = 1.1.toLocaleString()[1]; function ρσ_repr_js_builtin(x, as_array) { var ans, b, keys, key; ans = []; b = "{}"; if (as_array) { b = "[]"; for (var i = 0; i < x.length; i++) { ans.push(ρσ_repr(x[(typeof i === "number" && i < 0) ? x.length + i : i])); } } else { keys = Object.keys(x); for (var k = 0; k < keys.length; k++) { key = keys[(typeof k === "number" && k < 0) ? keys.length + k : k]; ans.push(JSON.stringify(key) + ":" + ρσ_repr(x[(typeof key === "number" && key < 0) ? x.length + key : key])); } } return b[0] + ans.join(", ") + b[1]; }; if (!ρσ_repr_js_builtin.__argnames__) Object.defineProperties(ρσ_repr_js_builtin, { __argnames__ : {value: ["x", "as_array"]}, __module__ : {value: "__main__"} }); function ρσ_html_element_to_string(elem) { var attrs, val, attr, ans; attrs = []; var ρσ_Iter0 = elem.attributes; ρσ_Iter0 = ((typeof ρσ_Iter0[Symbol.iterator] === "function") ? (ρσ_Iter0 instanceof Map ? ρσ_Iter0.keys() : ρσ_Iter0) : Object.keys(ρσ_Iter0)); for (var ρσ_Index0 of ρσ_Iter0) { attr = ρσ_Index0; if (attr.specified) { val = attr.value; if (val.length > 10) { val = val.slice(0, 15) + "..."; } val = JSON.stringify(val); attrs.push("" + ρσ_str.format("{}", attr.name) + "=" + ρσ_str.format("{}", val) + ""); } } attrs = (attrs.length) ? " " + attrs.join(" ") : ""; ans = "<" + ρσ_str.format("{}", elem.tagName) + "" + ρσ_str.format("{}", attrs) + ">"; return ans; }; if (!ρσ_html_element_to_string.__argnames__) Object.defineProperties(ρσ_html_element_to_string, { __argnames__ : {value: ["elem"]}, __module__ : {value: "__main__"} }); function ρσ_repr(x) { var ans, name, mapped; if (x === null) { return "None"; } if (x === undefined) { return "undefined"; } ans = x; if (typeof x.__repr__ === "function") { ans = x.__repr__(); } else if (x === true || x === false) { ans = (x) ? "True" : "False"; } else if (Array.isArray(x)) { ans = ρσ_repr_js_builtin(x, true); } else if (typeof x === "function") { ans = x.toString(); } else if (typeof x === "object" && !x.toString) { ans = ρσ_repr_js_builtin(x); } else { name = Object.prototype.toString.call(x).slice(8, -1); if (ρσ_not_equals(("Int8Array Uint8Array Uint8ClampedArray Int16Array" + " Uint16Array Int32Array Uint32Array" + " Float32Array Float64Array").indexOf(name), -1)) { mapped = x.map((function() { var ρσ_anonfunc = function (i) { return str.format("0x{:02x}", i); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["i"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); return name + "([" + mapped.join(", ") + "])"; } if (typeof HTMLElement !== "undefined" && x instanceof HTMLElement) { ans = ρσ_html_element_to_string(x); } else { ans = (typeof x.toString === "function") ? x.toString() : x; } if (ans === "[object Object]") { return ρσ_repr_js_builtin(x); } try { ans = JSON.stringify(x); } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; { } } } return ans + ""; }; if (!ρσ_repr.__argnames__) Object.defineProperties(ρσ_repr, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); function ρσ_str(x) { var ans, name, mapped; if (x === null) { return "None"; } if (x === undefined) { return "undefined"; } ans = x; if (typeof x.__str__ === "function") { ans = x.__str__(); } else if (typeof x.__repr__ === "function") { ans = x.__repr__(); } else if (x === true || x === false) { ans = (x) ? "True" : "False"; } else if (Array.isArray(x)) { ans = ρσ_repr_js_builtin(x, true); } else if (typeof x.toString === "function") { name = Object.prototype.toString.call(x).slice(8, -1); if (ρσ_not_equals(("Int8Array Uint8Array Uint8ClampedArray Int16Array" + " Uint16Array Int32Array Uint32Array" + " Float32Array Float64Array").indexOf(name), -1)) { mapped = x.map((function() { var ρσ_anonfunc = function (i) { return str.format("0x{:02x}", i); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["i"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); return name + "([" + mapped.join(", ") + "])"; } if (typeof HTMLElement !== "undefined" && x instanceof HTMLElement) { ans = ρσ_html_element_to_string(x); } else { ans = x.toString(); } if (ans === "[object Object]") { ans = ρσ_repr_js_builtin(x); } } else if (typeof x === "object" && !x.toString) { ans = ρσ_repr_js_builtin(x); } return ans + ""; }; if (!ρσ_str.__argnames__) Object.defineProperties(ρσ_str, { __argnames__ : {value: ["x"]}, __module__ : {value: "__main__"} }); define_str_func = (function() { var ρσ_anonfunc = function (name, func) { var f; (ρσ_expr_temp = ρσ_str.prototype)[(typeof name === "number" && name < 0) ? ρσ_expr_temp.length + name : name] = func; ρσ_str[(typeof name === "number" && name < 0) ? ρσ_str.length + name : name] = f = func.call.bind(func); if (func.__argnames__) { Object.defineProperty(f, "__argnames__", (function(){ var ρσ_d = {}; ρσ_d["value"] = ['string'].concat(func.__argnames__); return ρσ_d; }).call(this)); } }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["name", "func"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_orig_split = String.prototype.split.call.bind(String.prototype.split); ρσ_orig_replace = String.prototype.replace.call.bind(String.prototype.replace); define_str_func("format", (function() { var ρσ_anonfunc = function () { var template, args, kwargs, explicit, implicit, idx, split, ans, pos, in_brace, markup, ch; template = this; if (template === undefined) { throw new TypeError("Template is required"); } args = Array.from(arguments); kwargs = {}; if (args[args.length-1] && args[args.length-1][ρσ_kwargs_symbol] !== undefined) { kwargs = args[args.length-1]; args = args.slice(0, -1); } explicit = implicit = false; idx = 0; split = ρσ_orig_split; if (ρσ_str.format._template_resolve_pat === undefined) { ρσ_str.format._template_resolve_pat = /[.\[]/; } function resolve(arg, object) { var ρσ_unpack, first, key, rest, ans; if (!arg) { return object; } ρσ_unpack = [arg[0], arg.slice(1)]; first = ρσ_unpack[0]; arg = ρσ_unpack[1]; key = split(arg, ρσ_str.format._template_resolve_pat, 1)[0]; rest = arg.slice(key.length); ans = (first === "[") ? object[ρσ_bound_index(key.slice(0, -1), object)] : getattr(object, key); if (ans === undefined) { throw new KeyError((first === "[") ? key.slice(0, -1) : key); } return resolve(rest, ans); }; if (!resolve.__argnames__) Object.defineProperties(resolve, { __argnames__ : {value: ["arg", "object"]}, __module__ : {value: "__main__"} }); function resolve_format_spec(format_spec) { var pat; if (ρσ_str.format._template_resolve_fs_pat === undefined) { ρσ_str.format._template_resolve_fs_pat = /[{]([a-zA-Z0-9_]+)[}]/g; } pat = ρσ_str.format._template_resolve_fs_pat; return format_spec.replace(pat, (function() { var ρσ_anonfunc = function (match, key) { if (!Object.prototype.hasOwnProperty.call(kwargs, key)) { return ""; } return "" + kwargs[(typeof key === "number" && key < 0) ? kwargs.length + key : key]; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["match", "key"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); }; if (!resolve_format_spec.__argnames__) Object.defineProperties(resolve_format_spec, { __argnames__ : {value: ["format_spec"]}, __module__ : {value: "__main__"} }); function set_comma(ans, comma) { var sep; if (comma !== ",") { sep = 1234; sep = sep.toLocaleString(undefined, {useGrouping: true})[1]; ans = str.replace(ans, sep, comma); } return ans; }; if (!set_comma.__argnames__) Object.defineProperties(set_comma, { __argnames__ : {value: ["ans", "comma"]}, __module__ : {value: "__main__"} }); function safe_comma(value, comma) { try { return set_comma(value.toLocaleString(undefined, {useGrouping: true}), comma); } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; { return value.toString(10); } } }; if (!safe_comma.__argnames__) Object.defineProperties(safe_comma, { __argnames__ : {value: ["value", "comma"]}, __module__ : {value: "__main__"} }); function safe_fixed(value, precision, comma) { var ufmt; if (!comma) { return value.toFixed(precision); } try { ufmt = (function(){ var ρσ_d = {}; ρσ_d["useGrouping"] = true; ρσ_d["minimumFractionDigits"] = precision; ρσ_d["maximumFractionDigits"] = precision; return ρσ_d; }).call(this); return set_comma(value.toLocaleString(undefined, ufmt), comma); } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; { return value.toFixed(precision); } } }; if (!safe_fixed.__argnames__) Object.defineProperties(safe_fixed, { __argnames__ : {value: ["value", "precision", "comma"]}, __module__ : {value: "__main__"} }); function apply_formatting(value, format_spec) { var m, ρσ_unpack, fill, align, sign, fhash, zeropad, width, comma, precision, ftype, is_numeric, is_int, lftype, code, prec, exp, nval, is_positive, left, right; if (format_spec.indexOf("{") !== -1) { format_spec = resolve_format_spec(format_spec); } if (ρσ_str.format._template_format_pat === undefined) { ρσ_str.format._template_format_pat = /([^{}](?=[<>=^]))?([<>=^])?([-+\x20])?(\#)?(0)?(\d+)?([,_])?(?:\.(\d+))?([bcdeEfFgGnosxX%])?/; } try { m = format_spec.match(ρσ_str.format._template_format_pat); ρσ_unpack = [m[1], m[2], m[3], m[4], m[5]]; fill = ρσ_unpack[0]; align = ρσ_unpack[1]; sign = ρσ_unpack[2]; fhash = ρσ_unpack[3]; zeropad = ρσ_unpack[4]; ρσ_unpack = [m[6], m[7], m[8], m[9]]; width = ρσ_unpack[0]; comma = ρσ_unpack[1]; precision = ρσ_unpack[2]; ftype = ρσ_unpack[3]; } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; if (ρσ_Exception instanceof TypeError) { return value; } else { throw ρσ_Exception; } } if (zeropad) { fill = fill || "0"; align = align || "="; } else { fill = fill || " "; align = align || ">"; } is_numeric = Number(value) === value; is_int = is_numeric && value % 1 === 0; precision = parseInt(precision, 10); lftype = (ftype || "").toLowerCase(); if (ftype === "n") { is_numeric = true; if (is_int) { if (comma) { throw new ValueError("Cannot specify ',' with 'n'"); } value = parseInt(value, 10).toLocaleString(); } else { value = parseFloat(value).toLocaleString(); } } else if (['b', 'c', 'd', 'o', 'x'].indexOf(lftype) !== -1) { value = parseInt(value, 10); is_numeric = true; if (!isNaN(value)) { if (ftype === "b") { value = (value >>> 0).toString(2); if (fhash) { value = "0b" + value; } } else if (ftype === "c") { if (value > 65535) { code = value - 65536; value = String.fromCharCode(55296 + (code >> 10), 56320 + (code & 1023)); } else { value = String.fromCharCode(value); } } else if (ftype === "d") { if (comma) { value = safe_comma(value, comma); } else { value = value.toString(10); } } else if (ftype === "o") { value = value.toString(8); if (fhash) { value = "0o" + value; } } else if (lftype === "x") { value = value.toString(16); value = (ftype === "x") ? value.toLowerCase() : value.toUpperCase(); if (fhash) { value = "0x" + value; } } } } else if (['e','f','g','%'].indexOf(lftype) !== -1) { is_numeric = true; value = parseFloat(value); prec = (isNaN(precision)) ? 6 : precision; if (lftype === "e") { value = value.toExponential(prec); value = (ftype === "E") ? value.toUpperCase() : value.toLowerCase(); } else if (lftype === "f") { value = safe_fixed(value, prec, comma); value = (ftype === "F") ? value.toUpperCase() : value.toLowerCase(); } else if (lftype === "%") { value *= 100; value = safe_fixed(value, prec, comma) + "%"; } else if (lftype === "g") { prec = max(1, prec); exp = parseInt(split(value.toExponential(prec - 1).toLowerCase(), "e")[1], 10); if (-4 <= exp && exp < prec) { value = safe_fixed(value, prec - 1 - exp, comma); } else { value = value.toExponential(prec - 1); } value = value.replace(/0+$/g, ""); if (value[value.length-1] === decimal_sep) { value = value.slice(0, -1); } if (ftype === "G") { value = value.toUpperCase(); } } } else { if (comma) { value = parseInt(value, 10); if (isNaN(value)) { throw new ValueError("Must use numbers with , or _"); } value = safe_comma(value, comma); } value += ""; if (!isNaN(precision)) { value = value.slice(0, precision); } } value += ""; if (is_numeric && sign) { nval = Number(value); is_positive = !isNaN(nval) && nval >= 0; if (is_positive && (sign === " " || sign === "+")) { value = sign + value; } } function repeat(char, num) { return (new Array(num+1)).join(char); }; if (!repeat.__argnames__) Object.defineProperties(repeat, { __argnames__ : {value: ["char", "num"]}, __module__ : {value: "__main__"} }); if (is_numeric && width && width[0] === "0") { width = width.slice(1); ρσ_unpack = ["0", "="]; fill = ρσ_unpack[0]; align = ρσ_unpack[1]; } width = parseInt(width || "-1", 10); if (isNaN(width)) { throw new ValueError("Invalid width specification: " + width); } if (fill && value.length < width) { if (align === "<") { value = value + repeat(fill, width - value.length); } else if (align === ">") { value = repeat(fill, width - value.length) + value; } else if (align === "^") { left = Math.floor((width - value.length) / 2); right = width - left - value.length; value = repeat(fill, left) + value + repeat(fill, right); } else if (align === "=") { if (ρσ_in(value[0], "+- ")) { value = value[0] + repeat(fill, width - value.length) + value.slice(1); } else { value = repeat(fill, width - value.length) + value; } } else { throw new ValueError("Unrecognized alignment: " + align); } } return value; }; if (!apply_formatting.__argnames__) Object.defineProperties(apply_formatting, { __argnames__ : {value: ["value", "format_spec"]}, __module__ : {value: "__main__"} }); function parse_markup(markup) { var key, transformer, format_spec, pos, state, ch; key = transformer = format_spec = ""; pos = 0; state = 0; while (pos < markup.length) { ch = markup[(typeof pos === "number" && pos < 0) ? markup.length + pos : pos]; if (state === 0) { if (ch === "!") { state = 1; } else if (ch === ":") { state = 2; } else { key += ch; } } else if (state === 1) { if (ch === ":") { state = 2; } else { transformer += ch; } } else { format_spec += ch; } pos += 1; } return [key, transformer, format_spec]; }; if (!parse_markup.__argnames__) Object.defineProperties(parse_markup, { __argnames__ : {value: ["markup"]}, __module__ : {value: "__main__"} }); function render_markup(markup) { var ρσ_unpack, key, transformer, format_spec, ends_with_equal, lkey, nvalue, object, ans; ρσ_unpack = parse_markup(markup); ρσ_unpack = ρσ_unpack_asarray(3, ρσ_unpack); key = ρσ_unpack[0]; transformer = ρσ_unpack[1]; format_spec = ρσ_unpack[2]; if (transformer && ['a', 'r', 's'].indexOf(transformer) === -1) { throw new ValueError("Unknown conversion specifier: " + transformer); } ends_with_equal = key.endsWith("="); if (ends_with_equal) { key = key.slice(0, -1); } lkey = key.length && split(key, /[.\[]/, 1)[0]; if (lkey) { explicit = true; if (implicit) { throw new ValueError("cannot switch from automatic field numbering" + " to manual field specification"); } nvalue = parseInt(lkey); object = (isNaN(nvalue)) ? kwargs[(typeof lkey === "number" && lkey < 0) ? kwargs.length + lkey : lkey] : args[(typeof nvalue === "number" && nvalue < 0) ? args.length + nvalue : nvalue]; if (object === undefined) { if (isNaN(nvalue)) { throw new KeyError(lkey); } throw new IndexError(lkey); } object = resolve(key.slice(lkey.length), object); } else { implicit = true; if (explicit) { throw new ValueError("cannot switch from manual field specification" + " to automatic field numbering"); } if (idx >= args.length) { throw new IndexError("Not enough arguments to match template: " + template); } object = args[(typeof idx === "number" && idx < 0) ? args.length + idx : idx]; idx += 1; } if (typeof object === "function") { object = object(); } ans = "" + object; if (format_spec) { ans = apply_formatting(ans, format_spec); } if (ends_with_equal) { ans = "" + ρσ_str.format("{}", key) + "=" + ρσ_str.format("{}", ans) + ""; } return ans; }; if (!render_markup.__argnames__) Object.defineProperties(render_markup, { __argnames__ : {value: ["markup"]}, __module__ : {value: "__main__"} }); ans = ""; pos = 0; in_brace = 0; markup = ""; while (pos < template.length) { ch = template[(typeof pos === "number" && pos < 0) ? template.length + pos : pos]; if (in_brace) { if (ch === "{") { in_brace += 1; markup += "{"; } else if (ch === "}") { in_brace -= 1; if (in_brace > 0) { markup += "}"; } else { ans += render_markup(markup); } } else { markup += ch; } } else { if (ch === "{") { if (template[ρσ_bound_index(pos + 1, template)] === "{") { pos += 1; ans += "{"; } else { in_brace = 1; markup = ""; } } else { ans += ch; if (ch === "}" && template[ρσ_bound_index(pos + 1, template)] === "}") { pos += 1; } } } pos += 1; } if (in_brace) { throw new ValueError("expected '}' before end of string"); } return ans; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("capitalize", (function() { var ρσ_anonfunc = function () { var string; string = this; if (string) { string = string[0].toUpperCase() + string.slice(1).toLowerCase(); } return string; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("center", (function() { var ρσ_anonfunc = function (width, fill) { var left, right, left_pad, right_pad; left = Math.floor((width - this.length) / 2); right = width - left - this.length; fill = fill || " "; left_pad = new Array(left+1).join(fill); right_pad = new Array(right+1).join(fill); return left_pad + this + right_pad; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["width", "fill"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("count", (function() { var ρσ_anonfunc = function (needle, start, end) { var string, ρσ_unpack, pos, step, ans; string = this; start = start || 0; end = end || string.length; if (start < 0 || end < 0) { string = string.slice(start, end); ρσ_unpack = [0, string.length]; start = ρσ_unpack[0]; end = ρσ_unpack[1]; } pos = start; step = needle.length; if (!step) { return 0; } ans = 0; while (pos !== -1) { pos = string.indexOf(needle, pos); if (pos !== -1) { ans += 1; pos += step; } } return ans; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["needle", "start", "end"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("endswith", (function() { var ρσ_anonfunc = function (suffixes, start, end) { var string, q; string = this; start = start || 0; if (typeof suffixes === "string") { suffixes = [suffixes]; } if (end !== undefined) { string = string.slice(0, end); } for (var i = 0; i < suffixes.length; i++) { q = suffixes[(typeof i === "number" && i < 0) ? suffixes.length + i : i]; if (string.indexOf(q, Math.max(start, string.length - q.length)) !== -1) { return true; } } return false; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["suffixes", "start", "end"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("startswith", (function() { var ρσ_anonfunc = function (prefixes, start, end) { var prefix; start = start || 0; if (typeof prefixes === "string") { prefixes = [prefixes]; } for (var i = 0; i < prefixes.length; i++) { prefix = prefixes[(typeof i === "number" && i < 0) ? prefixes.length + i : i]; end = (end === undefined) ? this.length : end; if (end - start >= prefix.length && prefix === this.slice(start, start + prefix.length)) { return true; } } return false; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["prefixes", "start", "end"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("find", (function() { var ρσ_anonfunc = function (needle, start, end) { var ans; while (start < 0) { start += this.length; } ans = this.indexOf(needle, start); if (end !== undefined && ans !== -1) { while (end < 0) { end += this.length; } if (ans >= end - needle.length) { return -1; } } return ans; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["needle", "start", "end"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("rfind", (function() { var ρσ_anonfunc = function (needle, start, end) { var ans; while (end < 0) { end += this.length; } ans = this.lastIndexOf(needle, end - 1); if (start !== undefined && ans !== -1) { while (start < 0) { start += this.length; } if (ans < start) { return -1; } } return ans; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["needle", "start", "end"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("index", (function() { var ρσ_anonfunc = function (needle, start, end) { var ans; ans = ρσ_str.prototype.find.apply(this, arguments); if (ans === -1) { throw new ValueError("substring not found"); } return ans; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["needle", "start", "end"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("rindex", (function() { var ρσ_anonfunc = function (needle, start, end) { var ans; ans = ρσ_str.prototype.rfind.apply(this, arguments); if (ans === -1) { throw new ValueError("substring not found"); } return ans; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["needle", "start", "end"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("islower", (function() { var ρσ_anonfunc = function () { return this.length > 0 && this.toLowerCase() === this.toString(); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("isupper", (function() { var ρσ_anonfunc = function () { return this.length > 0 && this.toUpperCase() === this.toString(); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("isspace", (function() { var ρσ_anonfunc = function () { return this.length > 0 && /^\s+$/.test(this); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("join", (function() { var ρσ_anonfunc = function (iterable) { var ans, r; if (Array.isArray(iterable)) { return iterable.join(this); } ans = ""; r = iterable.next(); while (!r.done) { if (ans) { ans += this; } ans += r.value; r = iterable.next(); } return ans; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["iterable"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("ljust", (function() { var ρσ_anonfunc = function (width, fill) { var string; string = this; if (width > string.length) { fill = fill || " "; string += new Array(width - string.length + 1).join(fill); } return string; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["width", "fill"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("rjust", (function() { var ρσ_anonfunc = function (width, fill) { var string; string = this; if (width > string.length) { fill = fill || " "; string = new Array(width - string.length + 1).join(fill) + string; } return string; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["width", "fill"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("lower", (function() { var ρσ_anonfunc = function () { return this.toLowerCase(); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("upper", (function() { var ρσ_anonfunc = function () { return this.toUpperCase(); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("lstrip", (function() { var ρσ_anonfunc = function (chars) { var string, pos; string = this; pos = 0; chars = chars || ρσ_str.whitespace; while (chars.indexOf(string[(typeof pos === "number" && pos < 0) ? string.length + pos : pos]) !== -1) { pos += 1; } if (pos) { string = string.slice(pos); } return string; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["chars"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("rstrip", (function() { var ρσ_anonfunc = function (chars) { var string, pos; string = this; pos = string.length - 1; chars = chars || ρσ_str.whitespace; while (chars.indexOf(string[(typeof pos === "number" && pos < 0) ? string.length + pos : pos]) !== -1) { pos -= 1; } if (pos < string.length - 1) { string = string.slice(0, pos + 1); } return string; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["chars"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("strip", (function() { var ρσ_anonfunc = function (chars) { return ρσ_str.prototype.lstrip.call(ρσ_str.prototype.rstrip.call(this, chars), chars); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["chars"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("partition", (function() { var ρσ_anonfunc = function (sep) { var idx; idx = this.indexOf(sep); if (idx === -1) { return [this, "", ""]; } return [this.slice(0, idx), sep, this.slice(idx + sep.length)]; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["sep"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("rpartition", (function() { var ρσ_anonfunc = function (sep) { var idx; idx = this.lastIndexOf(sep); if (idx === -1) { return ["", "", this]; } return [this.slice(0, idx), sep, this.slice(idx + sep.length)]; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["sep"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("replace", (function() { var ρσ_anonfunc = function (old, repl, count) { var string, pos, idx; string = this; if (count === 1) { return ρσ_orig_replace(string, old, repl); } if (count < 1) { return string; } count = count || Number.MAX_VALUE; pos = 0; while (count > 0) { count -= 1; idx = string.indexOf(old, pos); if (idx === -1) { break; } pos = idx + repl.length; string = string.slice(0, idx) + repl + string.slice(idx + old.length); } return string; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["old", "repl", "count"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("split", (function() { var ρσ_anonfunc = function (sep, maxsplit) { var split, ans, extra, parts; if (maxsplit === 0) { return [ this ]; } split = ρσ_orig_split; if (sep === undefined || sep === null) { if (maxsplit > 0) { ans = split(this, /(\s+)/); extra = ""; parts = []; for (var i = 0; i < ans.length; i++) { if (parts.length >= maxsplit + 1) { extra += ans[(typeof i === "number" && i < 0) ? ans.length + i : i]; } else if (i % 2 === 0) { parts.push(ans[(typeof i === "number" && i < 0) ? ans.length + i : i]); } } parts[parts.length-1] += extra; ans = parts; } else { ans = split(this, /\s+/); } } else { if (sep === "") { throw new ValueError("empty separator"); } ans = split(this, sep); if (maxsplit > 0 && ans.length > maxsplit) { extra = ans.slice(maxsplit).join(sep); ans = ans.slice(0, maxsplit); ans.push(extra); } } return ans; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["sep", "maxsplit"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("rsplit", (function() { var ρσ_anonfunc = function (sep, maxsplit) { var split, ans, is_space, pos, current, spc, ch, end, idx; if (!maxsplit) { return ρσ_str.prototype.split.call(this, sep); } split = ρσ_orig_split; if (sep === undefined || sep === null) { if (maxsplit > 0) { ans = []; is_space = /\s/; pos = this.length - 1; current = ""; while (pos > -1 && maxsplit > 0) { spc = false; ch = (ρσ_expr_temp = this)[(typeof pos === "number" && pos < 0) ? ρσ_expr_temp.length + pos : pos]; while (pos > -1 && is_space.test(ch)) { spc = true; ch = this[--pos]; } if (spc) { if (current) { ans.push(current); maxsplit -= 1; } current = ch; } else { current += ch; } pos -= 1; } ans.push(this.slice(0, pos + 1) + current); ans.reverse(); } else { ans = split(this, /\s+/); } } else { if (sep === "") { throw new ValueError("empty separator"); } ans = []; pos = end = this.length; while (pos > -1 && maxsplit > 0) { maxsplit -= 1; idx = this.lastIndexOf(sep, pos); if (idx === -1) { break; } ans.push(this.slice(idx + sep.length, end)); pos = idx - 1; end = idx; } ans.push(this.slice(0, end)); ans.reverse(); } return ans; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["sep", "maxsplit"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("splitlines", (function() { var ρσ_anonfunc = function (keepends) { var split, parts, ans; split = ρσ_orig_split; if (keepends) { parts = split(this, /((?:\r?\n)|\r)/); ans = []; for (var i = 0; i < parts.length; i++) { if (i % 2 === 0) { ans.push(parts[(typeof i === "number" && i < 0) ? parts.length + i : i]); } else { ans[ans.length-1] += parts[(typeof i === "number" && i < 0) ? parts.length + i : i]; } } } else { ans = split(this, /(?:\r?\n)|\r/); } return ans; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["keepends"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("swapcase", (function() { var ρσ_anonfunc = function () { var ans, a, b; ans = new Array(this.length); for (var i = 0; i < ans.length; i++) { a = (ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i]; b = a.toLowerCase(); if (a === b) { b = a.toUpperCase(); } ans[(typeof i === "number" && i < 0) ? ans.length + i : i] = b; } return ans.join(""); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); define_str_func("zfill", (function() { var ρσ_anonfunc = function (width) { var string; string = this; if (width > string.length) { string = new Array(width - string.length + 1).join("0") + string; } return string; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["width"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })()); ρσ_str.uchrs = (function() { var ρσ_anonfunc = function (string, with_positions) { return (function(){ var ρσ_d = {}; ρσ_d["_string"] = string; ρσ_d["_pos"] = 0; ρσ_d[ρσ_iterator_symbol] = (function() { var ρσ_anonfunc = function () { return this; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_d["next"] = (function() { var ρσ_anonfunc = function () { var length, pos, value, ans, extra; length = this._string.length; if (this._pos >= length) { return (function(){ var ρσ_d = {}; ρσ_d["done"] = true; return ρσ_d; }).call(this); } pos = this._pos; value = this._string.charCodeAt(this._pos++); ans = "\ufffd"; if (55296 <= value && value <= 56319) { if (this._pos < length) { extra = this._string.charCodeAt(this._pos++); if ((extra & 56320) === 56320) { ans = String.fromCharCode(value, extra); } } } else if ((value & 56320) !== 56320) { ans = String.fromCharCode(value); } if (with_positions) { return (function(){ var ρσ_d = {}; ρσ_d["done"] = false; ρσ_d["value"] = [ pos, ans ]; return ρσ_d; }).call(this); } else { return (function(){ var ρσ_d = {}; ρσ_d["done"] = false; ρσ_d["value"] = ans; return ρσ_d; }).call(this); } }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["string", "with_positions"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_str.uslice = (function() { var ρσ_anonfunc = function (string, start, end) { var items, iterator, r; items = []; iterator = ρσ_str.uchrs(string); r = iterator.next(); while (!r.done) { items.push(r.value); r = iterator.next(); } return items.slice(start || 0, (end === undefined) ? items.length : end).join(""); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["string", "start", "end"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_str.ulen = (function() { var ρσ_anonfunc = function (string) { var iterator, r, ans; iterator = ρσ_str.uchrs(string); r = iterator.next(); ans = 0; while (!r.done) { r = iterator.next(); ans += 1; } return ans; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["string"]}, __module__ : {value: "__main__"} }); return ρσ_anonfunc; })(); ρσ_str.ascii_lowercase = "abcdefghijklmnopqrstuvwxyz"; ρσ_str.ascii_uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; ρσ_str.ascii_letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; ρσ_str.digits = "0123456789"; ρσ_str.punctuation = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"; ρσ_str.printable = "0123456789abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\u000b\f"; ρσ_str.whitespace = " \t\n\r\u000b\f"; define_str_func = undefined; var str = ρσ_str, repr = ρσ_repr;; var ρσ_modules = {}; ρσ_modules.traceback = {}; ρσ_modules.elementmaker = {}; ρσ_modules.gettext = {}; ρσ_modules.pythonize = {}; ρσ_modules.initialize = {}; ρσ_modules.ajax = {}; ρσ_modules.book_list = {}; ρσ_modules["book_list.globals"] = {}; ρσ_modules.lru_cache = {}; ρσ_modules.encodings = {}; ρσ_modules.uuid = {}; ρσ_modules.session = {}; ρσ_modules.dom = {}; ρσ_modules["book_list.theme"] = {}; ρσ_modules.utils = {}; ρσ_modules["book_list.library_data"] = {}; ρσ_modules.date = {}; ρσ_modules.popups = {}; ρσ_modules.widgets = {}; ρσ_modules.modals = {}; ρσ_modules.qt = {}; ρσ_modules.read_book = {}; ρσ_modules["book_list.constants"] = {}; ρσ_modules.aes = {}; ρσ_modules["read_book.globals"] = {}; ρσ_modules["book_list.router"] = {}; ρσ_modules["read_book.viewport"] = {}; ρσ_modules["read_book.cfi"] = {}; ρσ_modules["read_book.annotations"] = {}; ρσ_modules["read_book.db"] = {}; ρσ_modules.iframe_comm = {}; ρσ_modules["read_book.settings"] = {}; ρσ_modules["read_book.resources"] = {}; ρσ_modules["read_book.footnotes"] = {}; ρσ_modules.range_utils = {}; ρσ_modules["read_book.find"] = {}; ρσ_modules.fs_images = {}; ρσ_modules.select = {}; ρσ_modules["read_book.anchor_visibility"] = {}; ρσ_modules["read_book.extract"] = {}; ρσ_modules["read_book.flow_mode"] = {}; ρσ_modules["read_book.mathjax"] = {}; ρσ_modules["read_book.referencing"] = {}; ρσ_modules["read_book.shortcuts"] = {}; ρσ_modules["read_book.smil"] = {}; ρσ_modules["read_book.hints"] = {}; ρσ_modules["read_book.touch"] = {}; ρσ_modules["read_book.paged_mode"] = {}; ρσ_modules["read_book.gestures"] = {}; ρσ_modules.complete = {}; ρσ_modules["read_book.highlights"] = {}; ρσ_modules["read_book.toc"] = {}; ρσ_modules["read_book.iframe"] = {}; ρσ_modules["book_list.item_list"] = {}; ρσ_modules["read_book.open_book"] = {}; ρσ_modules["read_book.prefs"] = {}; ρσ_modules.viewer = {}; ρσ_modules["read_book.prefs.utils"] = {}; ρσ_modules["viewer.constants"] = {}; ρσ_modules["read_book.prefs.head_foot"] = {}; ρσ_modules["read_book.selection_bar"] = {}; ρσ_modules["read_book.read_aloud"] = {}; ρσ_modules["book_list.ui"] = {}; ρσ_modules["read_book.bookmarks"] = {}; ρσ_modules["read_book.content_popup"] = {}; ρσ_modules["read_book.goto"] = {}; ρσ_modules["read_book.prefs.colors"] = {}; ρσ_modules["read_book.prefs.font_size"] = {}; ρσ_modules["read_book.prefs.fonts"] = {}; ρσ_modules["read_book.prefs.scrolling"] = {}; ρσ_modules["read_book.prefs.user_stylesheet"] = {}; ρσ_modules["read_book.read_audio_ebook"] = {}; ρσ_modules["read_book.scrollbar"] = {}; ρσ_modules["read_book.timers"] = {}; ρσ_modules["book_list.cover_grid"] = {}; ρσ_modules["book_list.top_bar"] = {}; ρσ_modules["read_book.chrome"] = {}; ρσ_modules["read_book.main_overlay_style"] = {}; ρσ_modules["read_book.profiles"] = {}; ρσ_modules["read_book.word_actions"] = {}; ρσ_modules["book_list.home"] = {}; ρσ_modules.worker = {}; ρσ_modules["read_book.search_worker"] = {}; ρσ_modules["read_book.search"] = {}; ρσ_modules["read_book.prefs.keyboard"] = {}; ρσ_modules["read_book.prefs.layout"] = {}; ρσ_modules["read_book.prefs.misc"] = {}; ρσ_modules["read_book.prefs.selection"] = {}; ρσ_modules["read_book.prefs.touch"] = {}; ρσ_modules["read_book.prefs.main"] = {}; ρσ_modules["book_list.add"] = {}; ρσ_modules["book_list.details_list"] = {}; ρσ_modules["book_list.delete_book"] = {}; ρσ_modules["book_list.custom_list"] = {}; ρσ_modules["book_list.search"] = {}; ρσ_modules["book_list.views"] = {}; ρσ_modules["book_list.book_details"] = {}; ρσ_modules["read_book.overlay"] = {}; ρσ_modules["read_book.view"] = {}; (function(){ var __name__ = "traceback"; var _traceback_state, _VLQ_BASE64; _traceback_state = (function(){ var ρσ_d = {}; ρσ_d["source_map"] = null; ρσ_d["decoded"] = null; return ρσ_d; }).call(this); _VLQ_BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; function set_source_map_data(data) { _traceback_state["source_map"] = data; _traceback_state["decoded"] = null; }; if (!set_source_map_data.__argnames__) Object.defineProperties(set_source_map_data, { __argnames__ : {value: ["data"]}, __module__ : {value: "traceback"} }); function serialize_error_for_formatting(err) { return (function(){ var ρσ_d = {}; ρσ_d["name"] = err.name || "Error"; ρσ_d["stack"] = err.stack || ""; ρσ_d["message"] = err.message || ""; return ρσ_d; }).call(this); }; if (!serialize_error_for_formatting.__argnames__) Object.defineProperties(serialize_error_for_formatting, { __argnames__ : {value: ["err"]}, __module__ : {value: "traceback"} }); function unserialize_error_for_formatting(err) { var ans; ans = new Error; ans.name = err.name; ans.stack = err.stack; ans.message = err.message; return ans; }; if (!unserialize_error_for_formatting.__argnames__) Object.defineProperties(unserialize_error_for_formatting, { __argnames__ : {value: ["err"]}, __module__ : {value: "traceback"} }); function _vlq_decode(encoded) { var result, i, n, value, shift, has_more, digit; result = []; i = 0; n = encoded.length; while (i < n) { value = 0; shift = 0; has_more = true; while (has_more) { digit = _VLQ_BASE64.indexOf(encoded[(typeof i === "number" && i < 0) ? encoded.length + i : i]); i += 1; has_more = ρσ_not_equals((digit & 32), 0); value += (digit & 31) << shift; shift += 5; } if (value & 1) { value = -((value >> 1)); } else { value = value >> 1; } result.push(value); } return result; }; if (!_vlq_decode.__argnames__) Object.defineProperties(_vlq_decode, { __argnames__ : {value: ["encoded"]}, __module__ : {value: "traceback"} }); function _decode_source_map(smap) { var sources, source_root, mappings_str, mapping_lines, decoded, prev_src_idx, prev_src_line, prev_src_col, line_str, line_entries, segments, prev_col, fields, gen_col, src_idx, src_line, src_col, src_file, seg_str, gen_line; sources = smap.sources || []; source_root = smap.sourceRoot || ""; mappings_str = smap.mappings || ""; mapping_lines = mappings_str.split(";"); decoded = []; prev_src_idx = 0; prev_src_line = 0; prev_src_col = 0; for (var ρσ_Index0 = 0; ρσ_Index0 < mapping_lines.length; ρσ_Index0++) { gen_line = ρσ_Index0; line_str = mapping_lines[(typeof gen_line === "number" && gen_line < 0) ? mapping_lines.length + gen_line : gen_line]; line_entries = []; if (line_str) { segments = line_str.split(","); prev_col = 0; var ρσ_Iter1 = segments; ρσ_Iter1 = ((typeof ρσ_Iter1[Symbol.iterator] === "function") ? (ρσ_Iter1 instanceof Map ? ρσ_Iter1.keys() : ρσ_Iter1) : Object.keys(ρσ_Iter1)); for (var ρσ_Index1 of ρσ_Iter1) { seg_str = ρσ_Index1; if (!seg_str) { continue; } fields = _vlq_decode(seg_str); if (fields.length >= 4) { gen_col = prev_col + fields[0]; prev_col = gen_col; src_idx = prev_src_idx + fields[1]; prev_src_idx = src_idx; src_line = prev_src_line + fields[2]; prev_src_line = src_line; src_col = prev_src_col + fields[3]; prev_src_col = src_col; src_file = (src_idx >= 0 && src_idx < sources.length) ? sources[(typeof src_idx === "number" && src_idx < 0) ? sources.length + src_idx : src_idx] : ""; if (source_root && src_file) { src_file = source_root + src_file; } line_entries.push((function(){ var ρσ_d = {}; ρσ_d["gen_col"] = gen_col; ρσ_d["src_file"] = src_file; ρσ_d["src_line"] = src_line; ρσ_d["src_col"] = src_col; return ρσ_d; }).call(this)); } else if (fields.length >= 1) { prev_col += fields[0]; } } } decoded.push(line_entries); } return decoded; }; if (!_decode_source_map.__argnames__) Object.defineProperties(_decode_source_map, { __argnames__ : {value: ["smap"]}, __module__ : {value: "traceback"} }); function _find_mapping(decoded, gen_line, gen_col) { var line_entries, best, entry; if (!decoded || gen_line < 0 || gen_line >= decoded.length) { return null; } line_entries = decoded[(typeof gen_line === "number" && gen_line < 0) ? decoded.length + gen_line : gen_line]; if (!line_entries || !line_entries.length) { return null; } best = null; var ρσ_Iter2 = line_entries; ρσ_Iter2 = ((typeof ρσ_Iter2[Symbol.iterator] === "function") ? (ρσ_Iter2 instanceof Map ? ρσ_Iter2.keys() : ρσ_Iter2) : Object.keys(ρσ_Iter2)); for (var ρσ_Index2 of ρσ_Iter2) { entry = ρσ_Index2; if (entry.gen_col <= gen_col) { if (best === null || entry.gen_col > best.gen_col) { best = entry; } } } return best; }; if (!_find_mapping.__argnames__) Object.defineProperties(_find_mapping, { __argnames__ : {value: ["decoded", "gen_line", "gen_col"]}, __module__ : {value: "traceback"} }); function _parse_stack_frame(line) { var m; m = /^\s*at\s+(.*?)\s+\((.+):(\d+):(\d+)\)/.exec(line); if (m) { return (function(){ var ρσ_d = {}; ρσ_d["func"] = m[1] || null; ρσ_d["file"] = m[2]; ρσ_d["line"] = parseInt(m[3], 10) - 1; ρσ_d["col"] = parseInt(m[4], 10) - 1; return ρσ_d; }).call(this); } m = /^\s*at (.+):(\d+):(\d+)$/.exec(line); if (m) { return (function(){ var ρσ_d = {}; ρσ_d["func"] = null; ρσ_d["file"] = m[1]; ρσ_d["line"] = parseInt(m[2], 10) - 1; ρσ_d["col"] = parseInt(m[3], 10) - 1; return ρσ_d; }).call(this); } m = /^(.*?)@(.+):(\d+):(\d+)$/.exec(line); if (m) { return (function(){ var ρσ_d = {}; ρσ_d["func"] = m[1] || null; ρσ_d["file"] = m[2]; ρσ_d["line"] = parseInt(m[3], 10) - 1; ρσ_d["col"] = parseInt(m[4], 10) - 1; return ρσ_d; }).call(this); } return null; }; if (!_parse_stack_frame.__argnames__) Object.defineProperties(_parse_stack_frame, { __argnames__ : {value: ["line"]}, __module__ : {value: "traceback"} }); function _get_decoded_map() { if (_traceback_state["decoded"] === null && _traceback_state["source_map"]) { _traceback_state["decoded"] = _decode_source_map(_traceback_state["source_map"]); } return _traceback_state["decoded"]; }; if (!_get_decoded_map.__module__) Object.defineProperties(_get_decoded_map, { __module__ : {value: "traceback"} }); function _get_internal_traceback(err) { var lines, final_lines, start_line_idx, line, ρσ_unpack, i, xline, frame_lines, decoded, mapped_lines, frame, mapping, loc, frame_line; lines = ρσ_str.splitlines(err.stack || ""); final_lines = []; start_line_idx = -1; var ρσ_Iter3 = enumerate(lines); ρσ_Iter3 = ((typeof ρσ_Iter3[Symbol.iterator] === "function") ? (ρσ_Iter3 instanceof Map ? ρσ_Iter3.keys() : ρσ_Iter3) : Object.keys(ρσ_Iter3)); for (var ρσ_Index3 of ρσ_Iter3) { ρσ_unpack = ρσ_Index3; i = ρσ_unpack[0]; line = ρσ_unpack[1]; if (i > 0) { line = line.trim(); if (line.startsWith("at new " + err.name) || line.startsWith(err.name + "@")) { start_line_idx = i + 1; break; } } } if (start_line_idx < 0) { start_line_idx = 1; var ρσ_Iter4 = enumerate(lines); ρσ_Iter4 = ((typeof ρσ_Iter4[Symbol.iterator] === "function") ? (ρσ_Iter4 instanceof Map ? ρσ_Iter4.keys() : ρσ_Iter4) : Object.keys(ρσ_Iter4)); for (var ρσ_Index4 of ρσ_Iter4) { ρσ_unpack = ρσ_Index4; i = ρσ_unpack[0]; xline = ρσ_unpack[1]; if (i > 0) { line = xline.trim(); if (line.startsWith('at ') || line.includes('@') || /:\d+:\d+$/.test(line)) { start_line_idx = i; break; } } } } frame_lines = lines.slice(start_line_idx); final_lines = final_lines.concat(frame_lines); decoded = _get_decoded_map(); mapped_lines = []; if (decoded) { var ρσ_Iter5 = frame_lines; ρσ_Iter5 = ((typeof ρσ_Iter5[Symbol.iterator] === "function") ? (ρσ_Iter5 instanceof Map ? ρσ_Iter5.keys() : ρσ_Iter5) : Object.keys(ρσ_Iter5)); for (var ρσ_Index5 of ρσ_Iter5) { frame_line = ρσ_Index5; frame = _parse_stack_frame(frame_line); if (frame) { mapping = _find_mapping(decoded, frame.line, frame.col); if (mapping) { loc = " File \"" + mapping.src_file + "\", line " + (mapping.src_line + 1) + ", col " + (mapping.src_col + 1); if (frame.func) { loc += ", in " + frame.func; } mapped_lines.push(loc); } } } } return [lines[0], final_lines, mapped_lines]; }; if (!_get_internal_traceback.__argnames__) Object.defineProperties(_get_internal_traceback, { __argnames__ : {value: ["err"]}, __module__ : {value: "traceback"} }); function format_exception(exc, limit) { var ρσ_unpack, e, js_lines, rs_lines; if (typeof exc === "undefined") { exc = ρσ_last_exception; } if (!(ρσ_instanceof(exc, Error))) { if (exc && exc.toString) { return [ exc.toString() ]; } return []; } ρσ_unpack = _get_internal_traceback(exc); ρσ_unpack = ρσ_unpack_asarray(3, ρσ_unpack); e = ρσ_unpack[0]; js_lines = ρσ_unpack[1]; rs_lines = ρσ_unpack[2]; if (js_lines.length > 0) { if (limit) { js_lines = (limit > 0) ? js_lines.slice(0, limit) : js_lines.slice(limit); rs_lines = (limit > 0) ? rs_lines.slice(0, limit) : rs_lines.slice(limit); } js_lines.reverse(); rs_lines.reverse(); js_lines.push(e); js_lines = ['Traceback (most recent call last):'].concat(js_lines); if (rs_lines.length > 0) { js_lines = js_lines.concat([ "", "Mapped Traceback (RapydScript):" ]).concat(rs_lines); } return (function() { var ρσ_Iter = js_lines, ρσ_Result = [], l; ρσ_Iter = ((typeof ρσ_Iter[Symbol.iterator] === "function") ? (ρσ_Iter instanceof Map ? ρσ_Iter.keys() : ρσ_Iter) : Object.keys(ρσ_Iter)); for (var ρσ_Index of ρσ_Iter) { l = ρσ_Index; ρσ_Result.push(l + "\n"); } ρσ_Result = ρσ_list_constructor(ρσ_Result); return ρσ_Result; })(); } return [ exc.toString() ]; }; if (!format_exception.__argnames__) Object.defineProperties(format_exception, { __argnames__ : {value: ["exc", "limit"]}, __module__ : {value: "traceback"} }); function format_exc(limit) { return format_exception(ρσ_last_exception, limit).join(""); }; if (!format_exc.__argnames__) Object.defineProperties(format_exc, { __argnames__ : {value: ["limit"]}, __module__ : {value: "traceback"} }); function print_exc(limit) { print(format_exc(limit)); }; if (!print_exc.__argnames__) Object.defineProperties(print_exc, { __argnames__ : {value: ["limit"]}, __module__ : {value: "traceback"} }); function format_stack(limit) { var stack, lines; stack = (new Error).stack; if (!stack) { return []; } lines = str.splitlines(stack).slice(2); lines.reverse(); if (limit) { lines = (limit > 0) ? lines.slice(0, limit + 1) : lines.slice(limit); } return (function() { var ρσ_Iter = lines, ρσ_Result = [], l; ρσ_Iter = ((typeof ρσ_Iter[Symbol.iterator] === "function") ? (ρσ_Iter instanceof Map ? ρσ_Iter.keys() : ρσ_Iter) : Object.keys(ρσ_Iter)); for (var ρσ_Index of ρσ_Iter) { l = ρσ_Index; ρσ_Result.push(l + "\n"); } ρσ_Result = ρσ_list_constructor(ρσ_Result); return ρσ_Result; })(); }; if (!format_stack.__argnames__) Object.defineProperties(format_stack, { __argnames__ : {value: ["limit"]}, __module__ : {value: "traceback"} }); function print_stack(limit) { print(format_stack(limit).join("")); }; if (!print_stack.__argnames__) Object.defineProperties(print_stack, { __argnames__ : {value: ["limit"]}, __module__ : {value: "traceback"} }); ρσ_modules.traceback._traceback_state = _traceback_state; ρσ_modules.traceback._VLQ_BASE64 = _VLQ_BASE64; ρσ_modules.traceback.set_source_map_data = set_source_map_data; ρσ_modules.traceback.serialize_error_for_formatting = serialize_error_for_formatting; ρσ_modules.traceback.unserialize_error_for_formatting = unserialize_error_for_formatting; ρσ_modules.traceback._vlq_decode = _vlq_decode; ρσ_modules.traceback._decode_source_map = _decode_source_map; ρσ_modules.traceback._find_mapping = _find_mapping; ρσ_modules.traceback._parse_stack_frame = _parse_stack_frame; ρσ_modules.traceback._get_decoded_map = _get_decoded_map; ρσ_modules.traceback._get_internal_traceback = _get_internal_traceback; ρσ_modules.traceback.format_exception = format_exception; ρσ_modules.traceback.format_exc = format_exc; ρσ_modules.traceback.print_exc = print_exc; ρσ_modules.traceback.format_stack = format_stack; ρσ_modules.traceback.print_stack = print_stack; })(); (function(){ var __name__ = "elementmaker"; var html_elements, mathml_elements, svg_elements, html5_tags, E; html_elements = (function(){ var s = ρσ_set(); s.jsset.add("a"); s.jsset.add("abbr"); s.jsset.add("acronym"); s.jsset.add("address"); s.jsset.add("area"); s.jsset.add("article"); s.jsset.add("aside"); s.jsset.add("audio"); s.jsset.add("b"); s.jsset.add("base"); s.jsset.add("big"); s.jsset.add("body"); s.jsset.add("blockquote"); s.jsset.add("br"); s.jsset.add("button"); s.jsset.add("canvas"); s.jsset.add("caption"); s.jsset.add("center"); s.jsset.add("cite"); s.jsset.add("code"); s.jsset.add("col"); s.jsset.add("colgroup"); s.jsset.add("command"); s.jsset.add("datagrid"); s.jsset.add("datalist"); s.jsset.add("dd"); s.jsset.add("del"); s.jsset.add("details"); s.jsset.add("dfn"); s.jsset.add("dialog"); s.jsset.add("dir"); s.jsset.add("div"); s.jsset.add("dl"); s.jsset.add("dt"); s.jsset.add("em"); s.jsset.add("event-source"); s.jsset.add("fieldset"); s.jsset.add("figcaption"); s.jsset.add("figure"); s.jsset.add("footer"); s.jsset.add("font"); s.jsset.add("form"); s.jsset.add("header"); s.jsset.add("h1"); s.jsset.add("h2"); s.jsset.add("h3"); s.jsset.add("h4"); s.jsset.add("h5"); s.jsset.add("h6"); s.jsset.add("hr"); s.jsset.add("head"); s.jsset.add("i"); s.jsset.add("iframe"); s.jsset.add("img"); s.jsset.add("input"); s.jsset.add("ins"); s.jsset.add("keygen"); s.jsset.add("kbd"); s.jsset.add("label"); s.jsset.add("legend"); s.jsset.add("li"); s.jsset.add("m"); s.jsset.add("map"); s.jsset.add("menu"); s.jsset.add("meter"); s.jsset.add("multicol"); s.jsset.add("nav"); s.jsset.add("nextid"); s.jsset.add("ol"); s.jsset.add("output"); s.jsset.add("optgroup"); s.jsset.add("option"); s.jsset.add("p"); s.jsset.add("pre"); s.jsset.add("progress"); s.jsset.add("q"); s.jsset.add("s"); s.jsset.add("samp"); s.jsset.add("script"); s.jsset.add("section"); s.jsset.add("select"); s.jsset.add("small"); s.jsset.add("sound"); s.jsset.add("source"); s.jsset.add("spacer"); s.jsset.add("span"); s.jsset.add("strike"); s.jsset.add("strong"); s.jsset.add("style"); s.jsset.add("sub"); s.jsset.add("sup"); s.jsset.add("table"); s.jsset.add("tbody"); s.jsset.add("td"); s.jsset.add("textarea"); s.jsset.add("time"); s.jsset.add("tfoot"); s.jsset.add("th"); s.jsset.add("thead"); s.jsset.add("tr"); s.jsset.add("tt"); s.jsset.add("u"); s.jsset.add("ul"); s.jsset.add("var"); s.jsset.add("video"); return s; })(); mathml_elements = (function(){ var s = ρσ_set(); s.jsset.add("maction"); s.jsset.add("math"); s.jsset.add("merror"); s.jsset.add("mfrac"); s.jsset.add("mi"); s.jsset.add("mmultiscripts"); s.jsset.add("mn"); s.jsset.add("mo"); s.jsset.add("mover"); s.jsset.add("mpadded"); s.jsset.add("mphantom"); s.jsset.add("mprescripts"); s.jsset.add("mroot"); s.jsset.add("mrow"); s.jsset.add("mspace"); s.jsset.add("msqrt"); s.jsset.add("mstyle"); s.jsset.add("msub"); s.jsset.add("msubsup"); s.jsset.add("msup"); s.jsset.add("mtable"); s.jsset.add("mtd"); s.jsset.add("mtext"); s.jsset.add("mtr"); s.jsset.add("munder"); s.jsset.add("munderover"); s.jsset.add("none"); return s; })(); svg_elements = (function(){ var s = ρσ_set(); s.jsset.add("a"); s.jsset.add("animate"); s.jsset.add("animateColor"); s.jsset.add("animateMotion"); s.jsset.add("animateTransform"); s.jsset.add("clipPath"); s.jsset.add("circle"); s.jsset.add("defs"); s.jsset.add("desc"); s.jsset.add("ellipse"); s.jsset.add("font-face"); s.jsset.add("font-face-name"); s.jsset.add("font-face-src"); s.jsset.add("g"); s.jsset.add("glyph"); s.jsset.add("hkern"); s.jsset.add("linearGradient"); s.jsset.add("line"); s.jsset.add("marker"); s.jsset.add("metadata"); s.jsset.add("missing-glyph"); s.jsset.add("mpath"); s.jsset.add("path"); s.jsset.add("polygon"); s.jsset.add("polyline"); s.jsset.add("radialGradient"); s.jsset.add("rect"); s.jsset.add("set"); s.jsset.add("stop"); s.jsset.add("svg"); s.jsset.add("switch"); s.jsset.add("text"); s.jsset.add("title"); s.jsset.add("tspan"); s.jsset.add("use"); return s; })(); html5_tags = html_elements.union(mathml_elements).union(svg_elements); function _makeelement() { var tag = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var kwargs = arguments[arguments.length-1]; if (kwargs === null || typeof kwargs !== "object" || kwargs [ρσ_kwargs_symbol] !== true) kwargs = {}; var args = Array.prototype.slice.call(arguments, 1); if (kwargs !== null && typeof kwargs === "object" && kwargs [ρσ_kwargs_symbol] === true) args.pop(); var ans, vattr, val, attr, arg; ans = this.createElement(tag); var ρσ_Iter6 = kwargs; ρσ_Iter6 = ((typeof ρσ_Iter6[Symbol.iterator] === "function") ? (ρσ_Iter6 instanceof Map ? ρσ_Iter6.keys() : ρσ_Iter6) : Object.keys(ρσ_Iter6)); for (var ρσ_Index6 of ρσ_Iter6) { attr = ρσ_Index6; vattr = str.replace(str.rstrip(attr, "_"), "_", "-"); val = kwargs[(typeof attr === "number" && attr < 0) ? kwargs.length + attr : attr]; if (callable(val)) { if (str.startswith(attr, "on")) { attr = attr.slice(2); } ans.addEventListener(attr, val); } else if (val === true) { ans.setAttribute(vattr, vattr); } else if (typeof val === "string") { ans.setAttribute(vattr, val); } } var ρσ_Iter7 = args; ρσ_Iter7 = ((typeof ρσ_Iter7[Symbol.iterator] === "function") ? (ρσ_Iter7 instanceof Map ? ρσ_Iter7.keys() : ρσ_Iter7) : Object.keys(ρσ_Iter7)); for (var ρσ_Index7 of ρσ_Iter7) { arg = ρσ_Index7; if (typeof arg === "string") { arg = this.createTextNode(arg); } ans.appendChild(arg); } return ans; }; if (!_makeelement.__handles_kwarg_interpolation__) Object.defineProperties(_makeelement, { __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["tag"]}, __module__ : {value: "elementmaker"} }); function maker_for_document(document) { var E; E = _makeelement.bind(document); Object.defineProperties(E, (function() { var ρσ_Iter = html5_tags, ρσ_Result = {}, tag; ρσ_Iter = ((typeof ρσ_Iter[Symbol.iterator] === "function") ? (ρσ_Iter instanceof Map ? ρσ_Iter.keys() : ρσ_Iter) : Object.keys(ρσ_Iter)); for (var ρσ_Index of ρσ_Iter) { tag = ρσ_Index; ρσ_Result[tag] = ((function(){ var ρσ_d = {}; ρσ_d["value"] = _makeelement.bind(document, tag); return ρσ_d; }).call(this)); } return ρσ_Result; })()); return E; }; if (!maker_for_document.__argnames__) Object.defineProperties(maker_for_document, { __argnames__ : {value: ["document"]}, __module__ : {value: "elementmaker"} }); if (typeof document === "undefined") { E = maker_for_document((function(){ var ρσ_d = {}; ρσ_d["createTextNode"] = (function() { var ρσ_anonfunc = function (value) { return value; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["value"]}, __module__ : {value: "elementmaker"} }); return ρσ_anonfunc; })(); ρσ_d["createElement"] = (function() { var ρσ_anonfunc = function (name) { return (function(){ var ρσ_d = {}; ρσ_d["name"] = name; ρσ_d["children"] = []; ρσ_d["attributes"] = {}; ρσ_d["setAttribute"] = (function() { var ρσ_anonfunc = function (name, val) { (ρσ_expr_temp = this.attributes)[(typeof name === "number" && name < 0) ? ρσ_expr_temp.length + name : name] = val; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["name", "val"]}, __module__ : {value: "elementmaker"} }); return ρσ_anonfunc; })(); ρσ_d["appendChild"] = (function() { var ρσ_anonfunc = function (child) { this.children.push(child); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["child"]}, __module__ : {value: "elementmaker"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["name"]}, __module__ : {value: "elementmaker"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this)); } else { E = maker_for_document(document); } ρσ_modules.elementmaker.html_elements = html_elements; ρσ_modules.elementmaker.mathml_elements = mathml_elements; ρσ_modules.elementmaker.svg_elements = svg_elements; ρσ_modules.elementmaker.html5_tags = html5_tags; ρσ_modules.elementmaker.E = E; ρσ_modules.elementmaker._makeelement = _makeelement; ρσ_modules.elementmaker.maker_for_document = maker_for_document; })(); (function(){ var __name__ = "gettext"; var Jed, plural_forms_parser, _gettext, _ngettext, has_prop, empty_translation_data; Jed = {}; Jed.PF = {}; Jed.PF.parse = function ( p ) { var plural_str = Jed.PF.extractPluralExpr( p ); return Jed.PF.parser.parse.call(Jed.PF.parser, plural_str); }; Jed.PF.compile = function ( p ) { // Handle trues and falses as 0 and 1 function imply( val ) { return (val === true ? 1 : val ? val : 0); } var ast = Jed.PF.parse( p ); return function ( n ) { return imply( Jed.PF.interpreter( ast )( n ) ); }; }; Jed.PF.interpreter = function ( ast ) { return function ( n ) { var res; switch ( ast.type ) { case 'GROUP': return Jed.PF.interpreter( ast.expr )( n ); case 'TERNARY': if ( Jed.PF.interpreter( ast.expr )( n ) ) { return Jed.PF.interpreter( ast.truthy )( n ); } return Jed.PF.interpreter( ast.falsey )( n ); case 'OR': return Jed.PF.interpreter( ast.left )( n ) || Jed.PF.interpreter( ast.right )( n ); case 'AND': return Jed.PF.interpreter( ast.left )( n ) && Jed.PF.interpreter( ast.right )( n ); case 'LT': return Jed.PF.interpreter( ast.left )( n ) < Jed.PF.interpreter( ast.right )( n ); case 'GT': return Jed.PF.interpreter( ast.left )( n ) > Jed.PF.interpreter( ast.right )( n ); case 'LTE': return Jed.PF.interpreter( ast.left )( n ) <= Jed.PF.interpreter( ast.right )( n ); case 'GTE': return Jed.PF.interpreter( ast.left )( n ) >= Jed.PF.interpreter( ast.right )( n ); case 'EQ': return Jed.PF.interpreter( ast.left )( n ) == Jed.PF.interpreter( ast.right )( n ); case 'NEQ': return Jed.PF.interpreter( ast.left )( n ) != Jed.PF.interpreter( ast.right )( n ); case 'MOD': return Jed.PF.interpreter( ast.left )( n ) % Jed.PF.interpreter( ast.right )( n ); case 'VAR': return n; case 'NUM': return ast.val; default: throw new Error("Invalid Token found."); } }; }; Jed.PF.extractPluralExpr = function ( p ) { // trim first p = p.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); if (! /;\s*$/.test(p)) { p = p.concat(';'); } var nplurals_re = /nplurals\=(\d+);/, plural_re = /plural\=(.*);/, nplurals_matches = p.match( nplurals_re ), res = {}, plural_matches; // Find the nplurals number if ( nplurals_matches.length > 1 ) { res.nplurals = nplurals_matches[1]; } else { throw new Error('nplurals not found in plural_forms string: ' + p ); } // remove that data to get to the formula p = p.replace( nplurals_re, "" ); plural_matches = p.match( plural_re ); if (!( plural_matches && plural_matches.length > 1 ) ) { throw new Error('`plural` expression not found: ' + p); } return plural_matches[ 1 ]; }; /* Jison generated parser */ Jed.PF.parser = (function(){ var parser = {trace: function trace() { }, yy: {}, symbols_: {"error":2,"expressions":3,"e":4,"EOF":5,"?":6,":":7,"||":8,"&&":9,"<":10,"<=":11,">":12,">=":13,"!=":14,"==":15,"%":16,"(":17,")":18,"n":19,"NUMBER":20,"$accept":0,"$end":1}, terminals_: {2:"error",5:"EOF",6:"?",7:":",8:"||",9:"&&",10:"<",11:"<=",12:">",13:">=",14:"!=",15:"==",16:"%",17:"(",18:")",19:"n",20:"NUMBER"}, productions_: [0,[3,2],[4,5],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,1],[4,1]], performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) { var $0 = $$.length - 1; switch (yystate) { case 1: return { type : 'GROUP', expr: $$[$0-1] }; case 2:this.$ = { type: 'TERNARY', expr: $$[$0-4], truthy : $$[$0-2], falsey: $$[$0] }; break; case 3:this.$ = { type: "OR", left: $$[$0-2], right: $$[$0] }; break; case 4:this.$ = { type: "AND", left: $$[$0-2], right: $$[$0] }; break; case 5:this.$ = { type: 'LT', left: $$[$0-2], right: $$[$0] }; break; case 6:this.$ = { type: 'LTE', left: $$[$0-2], right: $$[$0] }; break; case 7:this.$ = { type: 'GT', left: $$[$0-2], right: $$[$0] }; break; case 8:this.$ = { type: 'GTE', left: $$[$0-2], right: $$[$0] }; break; case 9:this.$ = { type: 'NEQ', left: $$[$0-2], right: $$[$0] }; break; case 10:this.$ = { type: 'EQ', left: $$[$0-2], right: $$[$0] }; break; case 11:this.$ = { type: 'MOD', left: $$[$0-2], right: $$[$0] }; break; case 12:this.$ = { type: 'GROUP', expr: $$[$0-1] }; break; case 13:this.$ = { type: 'VAR' }; break; case 14:this.$ = { type: 'NUM', val: Number(yytext) }; break; } }, table: [{3:1,4:2,17:[1,3],19:[1,4],20:[1,5]},{1:[3]},{5:[1,6],6:[1,7],8:[1,8],9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16]},{4:17,17:[1,3],19:[1,4],20:[1,5]},{5:[2,13],6:[2,13],7:[2,13],8:[2,13],9:[2,13],10:[2,13],11:[2,13],12:[2,13],13:[2,13],14:[2,13],15:[2,13],16:[2,13],18:[2,13]},{5:[2,14],6:[2,14],7:[2,14],8:[2,14],9:[2,14],10:[2,14],11:[2,14],12:[2,14],13:[2,14],14:[2,14],15:[2,14],16:[2,14],18:[2,14]},{1:[2,1]},{4:18,17:[1,3],19:[1,4],20:[1,5]},{4:19,17:[1,3],19:[1,4],20:[1,5]},{4:20,17:[1,3],19:[1,4],20:[1,5]},{4:21,17:[1,3],19:[1,4],20:[1,5]},{4:22,17:[1,3],19:[1,4],20:[1,5]},{4:23,17:[1,3],19:[1,4],20:[1,5]},{4:24,17:[1,3],19:[1,4],20:[1,5]},{4:25,17:[1,3],19:[1,4],20:[1,5]},{4:26,17:[1,3],19:[1,4],20:[1,5]},{4:27,17:[1,3],19:[1,4],20:[1,5]},{6:[1,7],8:[1,8],9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16],18:[1,28]},{6:[1,7],7:[1,29],8:[1,8],9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16]},{5:[2,3],6:[2,3],7:[2,3],8:[2,3],9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16],18:[2,3]},{5:[2,4],6:[2,4],7:[2,4],8:[2,4],9:[2,4],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16],18:[2,4]},{5:[2,5],6:[2,5],7:[2,5],8:[2,5],9:[2,5],10:[2,5],11:[2,5],12:[2,5],13:[2,5],14:[2,5],15:[2,5],16:[1,16],18:[2,5]},{5:[2,6],6:[2,6],7:[2,6],8:[2,6],9:[2,6],10:[2,6],11:[2,6],12:[2,6],13:[2,6],14:[2,6],15:[2,6],16:[1,16],18:[2,6]},{5:[2,7],6:[2,7],7:[2,7],8:[2,7],9:[2,7],10:[2,7],11:[2,7],12:[2,7],13:[2,7],14:[2,7],15:[2,7],16:[1,16],18:[2,7]},{5:[2,8],6:[2,8],7:[2,8],8:[2,8],9:[2,8],10:[2,8],11:[2,8],12:[2,8],13:[2,8],14:[2,8],15:[2,8],16:[1,16],18:[2,8]},{5:[2,9],6:[2,9],7:[2,9],8:[2,9],9:[2,9],10:[2,9],11:[2,9],12:[2,9],13:[2,9],14:[2,9],15:[2,9],16:[1,16],18:[2,9]},{5:[2,10],6:[2,10],7:[2,10],8:[2,10],9:[2,10],10:[2,10],11:[2,10],12:[2,10],13:[2,10],14:[2,10],15:[2,10],16:[1,16],18:[2,10]},{5:[2,11],6:[2,11],7:[2,11],8:[2,11],9:[2,11],10:[2,11],11:[2,11],12:[2,11],13:[2,11],14:[2,11],15:[2,11],16:[2,11],18:[2,11]},{5:[2,12],6:[2,12],7:[2,12],8:[2,12],9:[2,12],10:[2,12],11:[2,12],12:[2,12],13:[2,12],14:[2,12],15:[2,12],16:[2,12],18:[2,12]},{4:30,17:[1,3],19:[1,4],20:[1,5]},{5:[2,2],6:[1,7],7:[2,2],8:[1,8],9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16],18:[2,2]}], defaultActions: {6:[2,1]}, parseError: function parseError(str, hash) { throw new Error(str); }, parse: function parse(input) { var self = this, stack = [0], vstack = [null], // semantic value stack lstack = [], // location stack table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; //this.reductionCount = this.shiftCount = 0; this.lexer.setInput(input); this.lexer.yy = this.yy; this.yy.lexer = this.lexer; if (typeof this.lexer.yylloc == 'undefined') this.lexer.yylloc = {}; var yyloc = this.lexer.yylloc; lstack.push(yyloc); if (typeof this.yy.parseError === 'function') this.parseError = this.yy.parseError; function popStack (n) { stack.length = stack.length - 2*n; vstack.length = vstack.length - n; lstack.length = lstack.length - n; } function lex() { var token; token = self.lexer.lex() || 1; // $end = 1 // if token isn't its numeric value, convert if (typeof token !== 'number') { token = self.symbols_[token] || token; } return token; } var symbol, preErrorSymbol, state, action, a, r, yyval={},p,len,newState, expected, errStr; while (true) { // retreive state number from top of stack state = stack[stack.length-1]; // use default actions if available if (this.defaultActions[state]) { action = this.defaultActions[state]; } else { if (symbol === null || symbol === undefined) symbol = lex(); // read action for current state and first input action = table[state] && table[state][symbol]; } // handle parse error _handle_error: if (typeof action === 'undefined' || !action.length || !action[0]) { if (!recovering) { // Report error expected = []; for (p in table[state]) if (this.terminals_[p] && p > 2) { expected.push("'"+this.terminals_[p]+"'"); } errStr = ''; if (this.lexer.showPosition) { errStr = 'Parse error on line '+(yylineno+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+expected.join(', ') + ", got '" + this.terminals_[symbol]+ "'"; } else { errStr = 'Parse error on line '+(yylineno+1)+": Unexpected " + (symbol == 1 /*EOF*/ ? "end of input" : ("'"+(this.terminals_[symbol] || symbol)+"'")); } this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected}); } // just recovered from another error if (recovering == 3) { if (symbol == EOF) { throw new Error(errStr || 'Parsing halted.'); } // discard current lookahead and grab another yyleng = this.lexer.yyleng; yytext = this.lexer.yytext; yylineno = this.lexer.yylineno; yyloc = this.lexer.yylloc; symbol = lex(); } // try to recover from error while (1) { // check for error recovery rule in this state if ((TERROR.toString()) in table[state]) { break; } if (state === 0) { throw new Error(errStr || 'Parsing halted.'); } popStack(1); state = stack[stack.length-1]; } preErrorSymbol = symbol; // save the lookahead token symbol = TERROR; // insert generic error symbol as new lookahead state = stack[stack.length-1]; action = table[state] && table[state][TERROR]; recovering = 3; // allow 3 real symbols to be shifted before reporting a new error } // this shouldn't happen, unless resolve defaults are off if (action[0] instanceof Array && action.length > 1) { throw new Error('Parse Error: multiple actions possible at state: '+state+', token: '+symbol); } switch (action[0]) { case 1: // shift //this.shiftCount++; stack.push(symbol); vstack.push(this.lexer.yytext); lstack.push(this.lexer.yylloc); stack.push(action[1]); // push state symbol = null; if (!preErrorSymbol) { // normal execution/no error yyleng = this.lexer.yyleng; yytext = this.lexer.yytext; yylineno = this.lexer.yylineno; yyloc = this.lexer.yylloc; if (recovering > 0) recovering--; } else { // error just occurred, resume old lookahead f/ before error symbol = preErrorSymbol; preErrorSymbol = null; } break; case 2: // reduce //this.reductionCount++; len = this.productions_[action[1]][1]; // perform semantic action yyval.$ = vstack[vstack.length-len]; // default to $$ = $1 // default location, uses first token for firsts, last for lasts yyval._$ = { first_line: lstack[lstack.length-(len||1)].first_line, last_line: lstack[lstack.length-1].last_line, first_column: lstack[lstack.length-(len||1)].first_column, last_column: lstack[lstack.length-1].last_column }; r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack); if (typeof r !== 'undefined') { return r; } // pop off stack if (len) { stack = stack.slice(0,-1*len*2); vstack = vstack.slice(0, -1*len); lstack = lstack.slice(0, -1*len); } stack.push(this.productions_[action[1]][0]); // push nonterminal (reduce) vstack.push(yyval.$); lstack.push(yyval._$); // goto new state = table[STATE][NONTERMINAL] newState = table[stack[stack.length-2]][stack[stack.length-1]]; stack.push(newState); break; case 3: // accept return true; } } return true; }};/* Jison generated lexer */ var lexer = (function(){ var lexer = ({EOF:1, parseError:function parseError(str, hash) { if (this.yy.parseError) { this.yy.parseError(str, hash); } else { throw new Error(str); } }, setInput:function (input) { this._input = input; this._more = this._less = this.done = false; this.yylineno = this.yyleng = 0; this.yytext = this.matched = this.match = ''; this.conditionStack = ['INITIAL']; this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0}; return this; }, input:function () { var ch = this._input[0]; this.yytext+=ch; this.yyleng++; this.match+=ch; this.matched+=ch; var lines = ch.match(/\n/); if (lines) this.yylineno++; this._input = this._input.slice(1); return ch; }, unput:function (ch) { this._input = ch + this._input; return this; }, more:function () { this._more = true; return this; }, pastInput:function () { var past = this.matched.substr(0, this.matched.length - this.match.length); return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); }, upcomingInput:function () { var next = this.match; if (next.length < 20) { next += this._input.substr(0, 20-next.length); } return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, ""); }, showPosition:function () { var pre = this.pastInput(); var c = new Array(pre.length + 1).join("-"); return pre + this.upcomingInput() + "\n" + c+"^"; }, next:function () { if (this.done) { return this.EOF; } if (!this._input) this.done = true; var token, match, col, lines; if (!this._more) { this.yytext = ''; this.match = ''; } var rules = this._currentRules(); for (var i=0;i < rules.length; i++) { match = this._input.match(this.rules[rules[i]]); if (match) { lines = match[0].match(/\n.*/g); if (lines) this.yylineno += lines.length; this.yylloc = {first_line: this.yylloc.last_line, last_line: this.yylineno+1, first_column: this.yylloc.last_column, last_column: lines ? lines[lines.length-1].length-1 : this.yylloc.last_column + match[0].length}; this.yytext += match[0]; this.match += match[0]; this.matches = match; this.yyleng = this.yytext.length; this._more = false; this._input = this._input.slice(match[0].length); this.matched += match[0]; token = this.performAction.call(this, this.yy, this, rules[i],this.conditionStack[this.conditionStack.length-1]); if (token) return token; else return; } } if (this._input === "") { return this.EOF; } else { this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(), {text: "", token: null, line: this.yylineno}); } }, lex:function lex() { var r = this.next(); if (typeof r !== 'undefined') { return r; } else { return this.lex(); } }, begin:function begin(condition) { this.conditionStack.push(condition); }, popState:function popState() { return this.conditionStack.pop(); }, _currentRules:function _currentRules() { return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules; }, topState:function () { return this.conditionStack[this.conditionStack.length-2]; }, pushState:function begin(condition) { this.begin(condition); }}); lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { var YYSTATE=YY_START; switch($avoiding_name_collisions) { case 0:/* skip whitespace */ break; case 1:return 20 break; case 2:return 19 break; case 3:return 8 break; case 4:return 9 break; case 5:return 6 break; case 6:return 7 break; case 7:return 11 break; case 8:return 13 break; case 9:return 10 break; case 10:return 12 break; case 11:return 14 break; case 12:return 15 break; case 13:return 16 break; case 14:return 17 break; case 15:return 18 break; case 16:return 5 break; case 17:return 'INVALID' break; } }; lexer.rules = [/^\s+/,/^[0-9]+(\.[0-9]+)?\b/,/^n\b/,/^\|\|/,/^&&/,/^\?/,/^:/,/^<=/,/^>=/,/^/,/^!=/,/^==/,/^%/,/^\(/,/^\)/,/^$/,/^./]; lexer.conditions = {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],"inclusive":true}};return lexer;})() parser.lexer = lexer; return parser; })(); ; plural_forms_parser = Jed.PF; function _get_plural_forms_function(plural_forms_string) { return plural_forms_parser.compile(plural_forms_string || "nplurals=2; plural=(n != 1);"); }; if (!_get_plural_forms_function.__argnames__) Object.defineProperties(_get_plural_forms_function, { __argnames__ : {value: ["plural_forms_string"]}, __module__ : {value: "gettext"} }); _gettext = (function() { var ρσ_anonfunc = function (text) { return text; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["text"]}, __module__ : {value: "gettext"} }); return ρσ_anonfunc; })(); _ngettext = (function() { var ρσ_anonfunc = function (text, plural, n) { return (n === 1) ? text : plural; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["text", "plural", "n"]}, __module__ : {value: "gettext"} }); return ρσ_anonfunc; })(); function gettext(text) { return _gettext(text); }; if (!gettext.__argnames__) Object.defineProperties(gettext, { __argnames__ : {value: ["text"]}, __module__ : {value: "gettext"} }); function ngettext(text, plural, n) { return _ngettext(text, plural, n); }; if (!ngettext.__argnames__) Object.defineProperties(ngettext, { __argnames__ : {value: ["text", "plural", "n"]}, __module__ : {value: "gettext"} }); function install(translation_data) { var t, func; t = new Translations(translation_data); t.install(); var ρσ_Iter8 = register_callback.install_callbacks; ρσ_Iter8 = ((typeof ρσ_Iter8[Symbol.iterator] === "function") ? (ρσ_Iter8 instanceof Map ? ρσ_Iter8.keys() : ρσ_Iter8) : Object.keys(ρσ_Iter8)); for (var ρσ_Index8 of ρσ_Iter8) { func = ρσ_Index8; try { func(t); } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; { } } } return t; }; if (!install.__argnames__) Object.defineProperties(install, { __argnames__ : {value: ["translation_data"]}, __module__ : {value: "gettext"} }); has_prop = Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty); function register_callback(func) { register_callback.install_callbacks.push(func); }; if (!register_callback.__argnames__) Object.defineProperties(register_callback, { __argnames__ : {value: ["func"]}, __module__ : {value: "gettext"} }); register_callback.install_callbacks = []; empty_translation_data = (function(){ var ρσ_d = {}; ρσ_d["entries"] = {}; return ρσ_d; }).call(this); function Translations() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); Translations.prototype.__init__.apply(this, arguments); } Translations.prototype.__init__ = function __init__(translation_data) { var self = this; var func; translation_data = translation_data || empty_translation_data; func = _get_plural_forms_function(translation_data.plural_forms); self.translations = [ [ translation_data, func ] ]; self.language = translation_data["language"]; }; if (!Translations.prototype.__init__.__argnames__) Object.defineProperties(Translations.prototype.__init__, { __argnames__ : {value: ["translation_data"]}, __module__ : {value: "gettext"} }); Translations.__argnames__ = Translations.prototype.__init__.__argnames__; Translations.__handles_kwarg_interpolation__ = Translations.prototype.__init__.__handles_kwarg_interpolation__; Translations.prototype.add_fallback = function add_fallback(fallback) { var self = this; var func; fallback = fallback || empty_translation_data; func = _get_plural_forms_function(fallback.plural_forms); self.translations.push([ fallback, func ]); }; if (!Translations.prototype.add_fallback.__argnames__) Object.defineProperties(Translations.prototype.add_fallback, { __argnames__ : {value: ["fallback"]}, __module__ : {value: "gettext"} }); Translations.prototype.gettext = function gettext(text) { var self = this; var m, t; var ρσ_Iter9 = self.translations; ρσ_Iter9 = ((typeof ρσ_Iter9[Symbol.iterator] === "function") ? (ρσ_Iter9 instanceof Map ? ρσ_Iter9.keys() : ρσ_Iter9) : Object.keys(ρσ_Iter9)); for (var ρσ_Index9 of ρσ_Iter9) { t = ρσ_Index9; m = t[0].entries; if (has_prop(m, text)) { return m[(typeof text === "number" && text < 0) ? m.length + text : text][0]; } } return text; }; if (!Translations.prototype.gettext.__argnames__) Object.defineProperties(Translations.prototype.gettext, { __argnames__ : {value: ["text"]}, __module__ : {value: "gettext"} }); Translations.prototype.ngettext = function ngettext(text, plural, n) { var self = this; var m, idx, t; var ρσ_Iter10 = self.translations; ρσ_Iter10 = ((typeof ρσ_Iter10[Symbol.iterator] === "function") ? (ρσ_Iter10 instanceof Map ? ρσ_Iter10.keys() : ρσ_Iter10) : Object.keys(ρσ_Iter10)); for (var ρσ_Index10 of ρσ_Iter10) { t = ρσ_Index10; m = t[0].entries; if (has_prop(m, text)) { idx = t[1](n); return (ρσ_expr_temp = m[(typeof text === "number" && text < 0) ? m.length + text : text])[(typeof idx === "number" && idx < 0) ? ρσ_expr_temp.length + idx : idx] || ((n === 1) ? text : plural); } } return (n === 1) ? text : plural; }; if (!Translations.prototype.ngettext.__argnames__) Object.defineProperties(Translations.prototype.ngettext, { __argnames__ : {value: ["text", "plural", "n"]}, __module__ : {value: "gettext"} }); Translations.prototype.install = function install() { var self = this; _gettext = (function() { var ρσ_anonfunc = function () { return self.gettext.apply(self, arguments); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "gettext"} }); return ρσ_anonfunc; })(); _ngettext = (function() { var ρσ_anonfunc = function () { return self.ngettext.apply(self, arguments); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "gettext"} }); return ρσ_anonfunc; })(); }; if (!Translations.prototype.install.__module__) Object.defineProperties(Translations.prototype.install, { __module__ : {value: "gettext"} }); Translations.prototype.__repr__ = function __repr__ () { return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; Translations.prototype.__str__ = function __str__ () { return this.__repr__(); }; Object.defineProperty(Translations.prototype, "__bases__", {value: []}); ρσ_modules.gettext.Jed = Jed; ρσ_modules.gettext.plural_forms_parser = plural_forms_parser; ρσ_modules.gettext._gettext = _gettext; ρσ_modules.gettext._ngettext = _ngettext; ρσ_modules.gettext.has_prop = has_prop; ρσ_modules.gettext.empty_translation_data = empty_translation_data; ρσ_modules.gettext._get_plural_forms_function = _get_plural_forms_function; ρσ_modules.gettext.gettext = gettext; ρσ_modules.gettext.ngettext = ngettext; ρσ_modules.gettext.install = install; ρσ_modules.gettext.register_callback = register_callback; ρσ_modules.gettext.Translations = Translations; })(); (function(){ var __name__ = "pythonize"; function strings() { var string_funcs, exclude, name; string_funcs = set("capitalize strip lstrip rstrip islower isupper isspace lower upper swapcase center count endswith startswith find rfind index rindex format join ljust rjust partition rpartition replace split rsplit splitlines zfill".split(" ")); if (!arguments.length) { exclude = (function(){ var s = ρσ_set(); s.jsset.add("split"); s.jsset.add("replace"); return s; })(); } else if (arguments[0]) { exclude = Array.from(arguments); } else { exclude = null; } if (exclude) { string_funcs = string_funcs.difference(set(exclude)); } var ρσ_Iter11 = string_funcs; ρσ_Iter11 = ((typeof ρσ_Iter11[Symbol.iterator] === "function") ? (ρσ_Iter11 instanceof Map ? ρσ_Iter11.keys() : ρσ_Iter11) : Object.keys(ρσ_Iter11)); for (var ρσ_Index11 of ρσ_Iter11) { name = ρσ_Index11; (ρσ_expr_temp = String.prototype)[(typeof name === "number" && name < 0) ? ρσ_expr_temp.length + name : name] = (ρσ_expr_temp = ρσ_str.prototype)[(typeof name === "number" && name < 0) ? ρσ_expr_temp.length + name : name]; } }; if (!strings.__module__) Object.defineProperties(strings, { __module__ : {value: "pythonize"} }); ρσ_modules.pythonize.strings = strings; })(); (function(){ var __name__ = "initialize"; var strings = ρσ_modules.pythonize.strings; strings(); })(); (function(){ var __name__ = "ajax"; var default_timeout; var _ = ρσ_modules.gettext.gettext; default_timeout = 300; function encode_query_component(x) { var ans; ans = encodeURIComponent(x); ans = ans.replace(/%2[fF]/g, "/"); ans = ans.replace(/%40/g, "@"); ans = ans.replace(/%5[bB]/g, "["); ans = ans.replace(/%5[dD]/g, "]"); ans = ans.replace(/%5[eE]/g, "^"); ans = ans.replace(/%3[aA]/g, ":"); return ans; }; if (!encode_query_component.__argnames__) Object.defineProperties(encode_query_component, { __argnames__ : {value: ["x"]}, __module__ : {value: "ajax"} }); function encode_query(query, qchar) { var keys, ans, val, k; if (!query) { return ""; } qchar = qchar || "?"; keys = Object.keys(query).sort(); ans = ""; if (keys.length) { var ρσ_Iter12 = keys; ρσ_Iter12 = ((typeof ρσ_Iter12[Symbol.iterator] === "function") ? (ρσ_Iter12 instanceof Map ? ρσ_Iter12.keys() : ρσ_Iter12) : Object.keys(ρσ_Iter12)); for (var ρσ_Index12 of ρσ_Iter12) { k = ρσ_Index12; val = query[(typeof k === "number" && k < 0) ? query.length + k : k]; if (val === undefined || val === null || val === "") { continue; } ans += qchar + encodeURIComponent(k) + "=" + encode_query_component(val.toString()); qchar = "&"; } } return ans; }; if (!encode_query.__argnames__) Object.defineProperties(encode_query, { __argnames__ : {value: ["query", "qchar"]}, __module__ : {value: "ajax"} }); function absolute_path(path) { var slash; if (path[0] !== "/") { slash = ((ρσ_expr_temp = window.location.pathname)[ρσ_expr_temp.length-1] === "/") ? "" : "/"; path = window.location.pathname + slash + path; } return path; }; if (!absolute_path.__argnames__) Object.defineProperties(absolute_path, { __argnames__ : {value: ["path"]}, __module__ : {value: "ajax"} }); function workaround_qt_bug() { var xhr = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var end_type = ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[1]; var ok_code = (arguments[2] === undefined || ( 2 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? workaround_qt_bug.__defaults__.ok_code : arguments[2]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "ok_code")){ ok_code = ρσ_kwargs_obj.ok_code; } if (end_type === "error" && xhr.status === ok_code && window.navigator.userAgent.indexOf("calibre-viewer") === 0) { end_type = "load"; } return end_type; }; if (!workaround_qt_bug.__defaults__) Object.defineProperties(workaround_qt_bug, { __defaults__ : {value: {ok_code:200}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["xhr", "end_type", "ok_code"]}, __module__ : {value: "ajax"} }); function ajax() { var path = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var on_complete = ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[1]; var on_progress = (arguments[2] === undefined || ( 2 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? ajax.__defaults__.on_progress : arguments[2]; var bypass_cache = (arguments[3] === undefined || ( 3 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? ajax.__defaults__.bypass_cache : arguments[3]; var method = (arguments[4] === undefined || ( 4 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? ajax.__defaults__.method : arguments[4]; var query = (arguments[5] === undefined || ( 5 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? ajax.__defaults__.query : arguments[5]; var timeout = (arguments[6] === undefined || ( 6 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? ajax.__defaults__.timeout : arguments[6]; var ok_code = (arguments[7] === undefined || ( 7 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? ajax.__defaults__.ok_code : arguments[7]; var progress_totals_needed = (arguments[8] === undefined || ( 8 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? ajax.__defaults__.progress_totals_needed : arguments[8]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "on_progress")){ on_progress = ρσ_kwargs_obj.on_progress; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "bypass_cache")){ bypass_cache = ρσ_kwargs_obj.bypass_cache; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "method")){ method = ρσ_kwargs_obj.method; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "query")){ query = ρσ_kwargs_obj.query; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "timeout")){ timeout = ρσ_kwargs_obj.timeout; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "ok_code")){ ok_code = ρσ_kwargs_obj.ok_code; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "progress_totals_needed")){ progress_totals_needed = ρσ_kwargs_obj.progress_totals_needed; } var xhr, eq, has_query; if (timeout === null) { timeout = default_timeout; } query = query || Object.create(null); xhr = new XMLHttpRequest; eq = encode_query(query); has_query = eq.length > 0; path = absolute_path(path) + eq; if (bypass_cache) { path += ((has_query) ? "&" : "?") + (new Date).getTime(); } xhr.request_path = path; xhr.error_html = ""; function set_error(event, is_network_error) { var rtext; if (is_network_error) { xhr.error_html = str.format(_("Failed to communicate with \"{}\", network error. Is the server running and accessible?"), xhr.request_path); } else if (event === "timeout") { xhr.error_html = str.format(_("Failed to communicate with \"{}\", timed out after: {} seconds"), xhr.request_path, timeout); } else if (event === "abort") { xhr.error_html = str.format(_("Failed to communicate with \"{}\", aborted"), xhr.request_path); } else { try { rtext = xhr.responseText || ""; } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; { rtext = ""; } } xhr.error_html = str.format(_("Failed to communicate with \"{}\", with status: [{} ({})] {}

{}"), xhr.request_path, xhr.status, event, xhr.statusText, rtext.slice(0, 200)); } }; if (!set_error.__argnames__) Object.defineProperties(set_error, { __argnames__ : {value: ["event", "is_network_error"]}, __module__ : {value: "ajax"} }); function progress_callback(ev) { var ul; if (ev.lengthComputable) { on_progress(ev.loaded, ev.total, xhr); } else if (ev.loaded) { if (!progress_totals_needed) { on_progress(ev.loaded, undefined, xhr); return; } ul = xhr.getResponseHeader("Calibre-Uncompressed-Length"); if (ul) { try { ul = int(ul); } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; if (ρσ_Exception instanceof Error) { return; } else { throw ρσ_Exception; } } on_progress(ev.loaded, ul, xhr); } } }; if (!progress_callback.__argnames__) Object.defineProperties(progress_callback, { __argnames__ : {value: ["ev"]}, __module__ : {value: "ajax"} }); function complete_callback(end_type, ev) { var is_network_error; is_network_error = (end_type === "error") ? ev : false; if (xhr.status !== ok_code && end_type === "load") { end_type = "error"; } end_type = workaround_qt_bug(xhr, end_type, ok_code); if (end_type !== "load") { set_error(end_type, is_network_error); } on_complete(end_type, xhr, ev); }; if (!complete_callback.__argnames__) Object.defineProperties(complete_callback, { __argnames__ : {value: ["end_type", "ev"]}, __module__ : {value: "ajax"} }); if (on_progress) { xhr.addEventListener("progress", progress_callback); } xhr.addEventListener("abort", (function() { var ρσ_anonfunc = function (ev) { complete_callback("abort", ev); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["ev"]}, __module__ : {value: "ajax"} }); return ρσ_anonfunc; })()); xhr.addEventListener("error", (function() { var ρσ_anonfunc = function (ev) { complete_callback("error", ev); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["ev"]}, __module__ : {value: "ajax"} }); return ρσ_anonfunc; })()); xhr.addEventListener("load", (function() { var ρσ_anonfunc = function (ev) { complete_callback("load", ev); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["ev"]}, __module__ : {value: "ajax"} }); return ρσ_anonfunc; })()); xhr.addEventListener("timeout", (function() { var ρσ_anonfunc = function (ev) { complete_callback("timeout", ev); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["ev"]}, __module__ : {value: "ajax"} }); return ρσ_anonfunc; })()); xhr.open(method, path); xhr.timeout = timeout * 1e3; return xhr; }; if (!ajax.__defaults__) Object.defineProperties(ajax, { __defaults__ : {value: {on_progress:null, bypass_cache:true, method:"GET", query:null, timeout:null, ok_code:200, progress_totals_needed:true}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["path", "on_complete", "on_progress", "bypass_cache", "method", "query", "timeout", "ok_code", "progress_totals_needed"]}, __module__ : {value: "ajax"} }); function ajax_send() { var path = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var data = ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[1]; var on_complete = ( 2 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[2]; var on_progress = (arguments[3] === undefined || ( 3 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? ajax_send.__defaults__.on_progress : arguments[3]; var query = (arguments[4] === undefined || ( 4 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? ajax_send.__defaults__.query : arguments[4]; var timeout = (arguments[5] === undefined || ( 5 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? ajax_send.__defaults__.timeout : arguments[5]; var ok_code = (arguments[6] === undefined || ( 6 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? ajax_send.__defaults__.ok_code : arguments[6]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "on_progress")){ on_progress = ρσ_kwargs_obj.on_progress; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "query")){ query = ρσ_kwargs_obj.query; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "timeout")){ timeout = ρσ_kwargs_obj.timeout; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "ok_code")){ ok_code = ρσ_kwargs_obj.ok_code; } var xhr; xhr = ajax(path, on_complete, on_progress, false, "POST", query, timeout, ok_code); xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); xhr.send(JSON.stringify(data)); return xhr; }; if (!ajax_send.__defaults__) Object.defineProperties(ajax_send, { __defaults__ : {value: {on_progress:null, query:null, timeout:null, ok_code:200}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["path", "data", "on_complete", "on_progress", "query", "timeout", "ok_code"]}, __module__ : {value: "ajax"} }); ρσ_modules.ajax.default_timeout = default_timeout; ρσ_modules.ajax.encode_query_component = encode_query_component; ρσ_modules.ajax.encode_query = encode_query; ρσ_modules.ajax.absolute_path = absolute_path; ρσ_modules.ajax.workaround_qt_bug = workaround_qt_bug; ρσ_modules.ajax.ajax = ajax; ρσ_modules.ajax.ajax_send = ajax_send; })(); (function(){ var __name__ = "book_list"; })(); (function(){ var __name__ = "book_list.globals"; var session_data; session_data = null; function set_session_data(sd) { session_data = sd; return session_data; }; if (!set_session_data.__argnames__) Object.defineProperties(set_session_data, { __argnames__ : {value: ["sd"]}, __module__ : {value: "book_list.globals"} }); function get_session_data() { return session_data; }; if (!get_session_data.__module__) Object.defineProperties(get_session_data, { __module__ : {value: "book_list.globals"} }); function main_js(newval) { if (newval !== undefined) { main_js.ans = newval; } return main_js.ans; }; if (!main_js.__argnames__) Object.defineProperties(main_js, { __argnames__ : {value: ["newval"]}, __module__ : {value: "book_list.globals"} }); function get_current_query(newval) { if (newval) { get_current_query.ans = newval; } return get_current_query.ans; }; if (!get_current_query.__argnames__) Object.defineProperties(get_current_query, { __argnames__ : {value: ["newval"]}, __module__ : {value: "book_list.globals"} }); function get_translations(val) { if (val) { get_translations.ans = val; } return get_translations.ans; }; if (!get_translations.__argnames__) Object.defineProperties(get_translations, { __argnames__ : {value: ["val"]}, __module__ : {value: "book_list.globals"} }); ρσ_modules["book_list.globals"].session_data = session_data; ρσ_modules["book_list.globals"].set_session_data = set_session_data; ρσ_modules["book_list.globals"].get_session_data = get_session_data; ρσ_modules["book_list.globals"].main_js = main_js; ρσ_modules["book_list.globals"].get_current_query = get_current_query; ρσ_modules["book_list.globals"].get_translations = get_translations; })(); (function(){ var __name__ = "lru_cache"; function lru_node(key, val) { return (function(){ var ρσ_d = Object.create(null); ρσ_d["key"] = key; ρσ_d["val"] = val; ρσ_d["prev"] = null; ρσ_d["next"] = null; return ρσ_d; }).call(this); }; if (!lru_node.__argnames__) Object.defineProperties(lru_node, { __argnames__ : {value: ["key", "val"]}, __module__ : {value: "lru_cache"} }); function LRUCache() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); LRUCache.prototype.__bind_methods__.call(this); LRUCache.prototype.__init__.apply(this, arguments); } Object.defineProperty(LRUCache.prototype, "__bind_methods__", {value: function () { this.set_head = LRUCache.prototype.set_head.bind(this); this.pop = LRUCache.prototype.pop.bind(this); this.set = LRUCache.prototype.set.bind(this); this.get = LRUCache.prototype.get.bind(this); this.clear = LRUCache.prototype.clear.bind(this); }}); LRUCache.prototype.__init__ = function __init__(size) { var self = this; self.limit = 200; self.clear(size); }; if (!LRUCache.prototype.__init__.__argnames__) Object.defineProperties(LRUCache.prototype.__init__, { __argnames__ : {value: ["size"]}, __module__ : {value: "lru_cache"} }); LRUCache.__argnames__ = LRUCache.prototype.__init__.__argnames__; LRUCache.__handles_kwarg_interpolation__ = LRUCache.prototype.__init__.__handles_kwarg_interpolation__; LRUCache.prototype.set_head = function set_head(node) { var self = this; node.next = self.head; node.prev = null; if (self.head !== null) { self.head.prev = node; } self.head = node; if (self.tail === null) { self.tail = node; } self.size += 1; (ρσ_expr_temp = self.map)[ρσ_bound_index(node.key, ρσ_expr_temp)] = node; }; if (!LRUCache.prototype.set_head.__argnames__) Object.defineProperties(LRUCache.prototype.set_head, { __argnames__ : {value: ["node"]}, __module__ : {value: "lru_cache"} }); LRUCache.prototype.pop = function pop(key) { var self = this; var node; node = (ρσ_expr_temp = self.map)[(typeof key === "number" && key < 0) ? ρσ_expr_temp.length + key : key]; if (!node) { return; } if (node.prev !== null) { node.prev.next = node.next; } else { self.head = node.next; } if (node.next !== null) { node.next.prev = node.prev; } else { self.tail = node.prev; } delete self.map[key]; self.size -= 1; }; if (!LRUCache.prototype.pop.__argnames__) Object.defineProperties(LRUCache.prototype.pop, { __argnames__ : {value: ["key"]}, __module__ : {value: "lru_cache"} }); LRUCache.prototype.set = function set(key, val) { var self = this; var node, existing; node = lru_node(key, val); existing = (ρσ_expr_temp = self.map)[(typeof key === "number" && key < 0) ? ρσ_expr_temp.length + key : key]; if (existing) { existing.value = node.value; self.pop(node.key); } else if (self.size > self.limit) { delete self.map[self.tail.key]; self.size -= 1; self.tail = self.tail.prev; self.tail.next = null; } self.set_head(node); }; if (!LRUCache.prototype.set.__argnames__) Object.defineProperties(LRUCache.prototype.set, { __argnames__ : {value: ["key", "val"]}, __module__ : {value: "lru_cache"} }); LRUCache.prototype.get = function get(key, defval) { var self = this; var existing, val, node; existing = (ρσ_expr_temp = self.map)[(typeof key === "number" && key < 0) ? ρσ_expr_temp.length + key : key]; if (!existing) { return (defval === undefined) ? null : defval; } val = existing.value; node = lru_node(key, val); self.pop(key); self.set_head(node); return val; }; if (!LRUCache.prototype.get.__argnames__) Object.defineProperties(LRUCache.prototype.get, { __argnames__ : {value: ["key", "defval"]}, __module__ : {value: "lru_cache"} }); LRUCache.prototype.clear = function clear(size) { var self = this; self.size = 0; self.map = Object.create(null); self.head = self.tail = null; if (typeof size === "number") { self.limit = size; } }; if (!LRUCache.prototype.clear.__argnames__) Object.defineProperties(LRUCache.prototype.clear, { __argnames__ : {value: ["size"]}, __module__ : {value: "lru_cache"} }); LRUCache.prototype.__repr__ = function __repr__ () { return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; LRUCache.prototype.__str__ = function __str__ () { return this.__repr__(); }; Object.defineProperty(LRUCache.prototype, "__bases__", {value: []}); ρσ_modules.lru_cache.lru_node = lru_node; ρσ_modules.lru_cache.LRUCache = LRUCache; })(); (function(){ var __name__ = "encodings"; var utf8_decoder_table, _u8enc, utf8_encode; function base64encode(bytes, altchars, pad_char) { var l, remainder, main_length, encodings, ans, chunk; l = bytes.length; remainder = l % 3; main_length = l - remainder; encodings = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" + (altchars || "+/"); pad_char = (pad_char === undefined) ? "=" : pad_char; ans = []; for (var i = 0; i < main_length; i += 3) { chunk = bytes[(typeof i === "number" && i < 0) ? bytes.length + i : i] << 16 | bytes[ρσ_bound_index(i + 1, bytes)] << 8 | bytes[ρσ_bound_index(i + 2, bytes)]; ans.push(encodings[ρσ_bound_index((chunk & 16515072) >> 18, encodings)], encodings[ρσ_bound_index((chunk & 258048) >> 12, encodings)], encodings[ρσ_bound_index((chunk & 4032) >> 6, encodings)], encodings[ρσ_bound_index(chunk & 63, encodings)]); } if (remainder === 1) { chunk = bytes[(typeof main_length === "number" && main_length < 0) ? bytes.length + main_length : main_length]; ans.push(encodings[ρσ_bound_index((chunk & 252) >> 2, encodings)], encodings[ρσ_bound_index((chunk & 3) << 4, encodings)], pad_char, pad_char); } else if (remainder === 2) { chunk = bytes[(typeof main_length === "number" && main_length < 0) ? bytes.length + main_length : main_length] << 8 | bytes[ρσ_bound_index(main_length + 1, bytes)]; ans.push(encodings[ρσ_bound_index((chunk & 64512) >> 10, encodings)], encodings[ρσ_bound_index((chunk & 1008) >> 4, encodings)], encodings[ρσ_bound_index((chunk & 15) << 2, encodings)], pad_char); } return ans.join(""); }; if (!base64encode.__argnames__) Object.defineProperties(base64encode, { __argnames__ : {value: ["bytes", "altchars", "pad_char"]}, __module__ : {value: "encodings"} }); function base64decode(string) { var chars, ans, i; if (typeof window !== "undefined") { chars = window.atob(string); } else { chars = Buffer.from(string, "base64").toString("binary"); } ans = new Uint8Array(chars.length); for (var ρσ_Index13 = 0; ρσ_Index13 < ans.length; ρσ_Index13++) { i = ρσ_Index13; ans[(typeof i === "number" && i < 0) ? ans.length + i : i] = chars.charCodeAt(i); } return ans; }; if (!base64decode.__argnames__) Object.defineProperties(base64decode, { __argnames__ : {value: ["string"]}, __module__ : {value: "encodings"} }); function urlsafe_b64encode(bytes, pad_char) { return base64encode(bytes, "-_", pad_char); }; if (!urlsafe_b64encode.__argnames__) Object.defineProperties(urlsafe_b64encode, { __argnames__ : {value: ["bytes", "pad_char"]}, __module__ : {value: "encodings"} }); function hexlify(bytes) { var ans, x; ans = []; for (var i = 0; i < bytes.length; i++) { x = bytes[(typeof i === "number" && i < 0) ? bytes.length + i : i].toString(16); if (x.length === 1) { x = "0" + x; } ans.push(x); } return ans.join(""); }; if (!hexlify.__argnames__) Object.defineProperties(hexlify, { __argnames__ : {value: ["bytes"]}, __module__ : {value: "encodings"} }); utf8_decoder_table = [ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 00..1f 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 20..3f 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 40..5f 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 60..7f 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, // 80..9f 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, // a0..bf 8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // c0..df 0xa,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x3,0x4,0x3,0x3, // e0..ef 0xb,0x6,0x6,0x6,0x5,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8,0x8, // f0..ff 0x0,0x1,0x2,0x3,0x5,0x8,0x7,0x1,0x1,0x1,0x4,0x6,0x1,0x1,0x1,0x1, // s0..s0 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,0,1,0,1,1,1,1,1,1, // s1..s2 1,2,1,1,1,1,1,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1, // s3..s4 1,2,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1,3,1,1,1,1,1,1, // s5..s6 1,3,1,1,1,1,1,3,1,3,1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // s7..s8 ]; function _from_code_point(x) { if (x <= 65535) { return String.fromCharCode(x); } x -= 65536; return String.fromCharCode((x >> 10) + 55296, x % 1024 + 56320); }; if (!_from_code_point.__argnames__) Object.defineProperties(_from_code_point, { __argnames__ : {value: ["x"]}, __module__ : {value: "encodings"} }); function utf8_decode(bytes, errors, replacement) { var state, ans, byte, typ, codep; state = 0; ans = []; for (var i = 0, l = bytes.length; i < l; i++) { byte = bytes[(typeof i === "number" && i < 0) ? bytes.length + i : i]; typ = utf8_decoder_table[(typeof byte === "number" && byte < 0) ? utf8_decoder_table.length + byte : byte]; codep = (state !== 0) ? byte & 63 | codep << 6 : 255 >> typ & byte; state = utf8_decoder_table[ρσ_bound_index(256 + state * 16 + typ, utf8_decoder_table)]; if (state === 0) { ans.push(_from_code_point(codep)); } else if (state === 1) { if (!errors || errors === "strict") { throw new UnicodeDecodeError(str.format("The byte 0x{:02x} at position {} is not valid UTF-8", byte, i)); } else if (errors === "replace") { ans.push(replacement || "?"); } } } return ans.join(""); }; if (!utf8_decode.__argnames__) Object.defineProperties(utf8_decode, { __argnames__ : {value: ["bytes", "errors", "replacement"]}, __module__ : {value: "encodings"} }); function utf8_encode_js(string) { var escstr, ans, ch, i; escstr = encodeURIComponent(string); ans = []; for (var i = 0; i < escstr.length; i++) { ch = escstr[(typeof i === "number" && i < 0) ? escstr.length + i : i]; if (ch === "%") { ans.push(parseInt(escstr.slice(i + 1, i + 3), 16)); i += 2; } else { ans.push(ch.charCodeAt(0)); } } return new Uint8Array(ans); }; if (!utf8_encode_js.__argnames__) Object.defineProperties(utf8_encode_js, { __argnames__ : {value: ["string"]}, __module__ : {value: "encodings"} }); if (typeof TextEncoder === "function") { _u8enc = new TextEncoder("utf-8"); utf8_encode = _u8enc.encode.bind(_u8enc); _u8enc = undefined; } else { utf8_encode = utf8_encode_js; } ρσ_modules.encodings.utf8_decoder_table = utf8_decoder_table; ρσ_modules.encodings._u8enc = _u8enc; ρσ_modules.encodings.utf8_encode = utf8_encode; ρσ_modules.encodings.base64encode = base64encode; ρσ_modules.encodings.base64decode = base64decode; ρσ_modules.encodings.urlsafe_b64encode = urlsafe_b64encode; ρσ_modules.encodings.hexlify = hexlify; ρσ_modules.encodings._from_code_point = _from_code_point; ρσ_modules.encodings.utf8_decode = utf8_decode; ρσ_modules.encodings.utf8_encode_js = utf8_encode_js; })(); (function(){ var __name__ = "uuid"; var RFC_4122, random_bytes; var urlsafe_b64encode = ρσ_modules.encodings.urlsafe_b64encode; RFC_4122 = 1; if (typeof crypto === "object" && crypto.getRandomValues) { random_bytes = (function() { var ρσ_anonfunc = function (num) { var ans; ans = new Uint8Array(num || 16); crypto.getRandomValues(ans); return ans; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["num"]}, __module__ : {value: "uuid"} }); return ρσ_anonfunc; })(); } else { random_bytes = (function() { var ρσ_anonfunc = function (num) { var ans, i; ans = new Uint8Array(num || 16); for (var ρσ_Index14 = 0; ρσ_Index14 < ans.length; ρσ_Index14++) { i = ρσ_Index14; ans[(typeof i === "number" && i < 0) ? ans.length + i : i] = Math.floor(Math.random() * 256); } return ans; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["num"]}, __module__ : {value: "uuid"} }); return ρσ_anonfunc; })(); } function short_uuid() { return urlsafe_b64encode(random_bytes(), ""); }; if (!short_uuid.__module__) Object.defineProperties(short_uuid, { __module__ : {value: "uuid"} }); ρσ_modules.uuid.RFC_4122 = RFC_4122; ρσ_modules.uuid.random_bytes = random_bytes; ρσ_modules.uuid.short_uuid = short_uuid; })(); (function(){ var __name__ = "session"; var all_settings, defaults, x, standalone_reader_defaults, default_interface_data; var short_uuid = ρσ_modules.uuid.short_uuid; all_settings = (function(){ var ρσ_d = Object.create(null); ρσ_d["copy_to_library_dupes"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = "add;overwrite"; ρσ_d["category"] = "book_list"; return ρσ_d; }).call(this); ρσ_d["last_sort_order"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = Object.create(null); ρσ_d["category"] = "book_list"; return ρσ_d; }).call(this); ρσ_d["show_all_metadata"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = false; ρσ_d["category"] = "book_list"; return ρσ_d; }).call(this); ρσ_d["show_nav_list_book_count"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = true; ρσ_d["category"] = "book_list"; ρσ_d["is_local"] = false; return ρσ_d; }).call(this); ρσ_d["show_nav_list_avg_rating"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = true; ρσ_d["category"] = "book_list"; ρσ_d["is_local"] = false; return ρσ_d; }).call(this); ρσ_d["show_sidebar_in_book_viewer"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = false; ρσ_d["category"] = "book_list"; ρσ_d["is_local"] = false; return ρσ_d; }).call(this); ρσ_d["book_list_color_scheme"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = "auto"; ρσ_d["category"] = "book_list"; ρσ_d["is_local"] = false; return ρσ_d; }).call(this); ρσ_d["ui_highlight_colors"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["light"] = "#437000"; ρσ_d["dark"] = "#6cb4ee"; return ρσ_d; }).call(this); ρσ_d["category"] = "book_list"; ρσ_d["is_local"] = false; return ρσ_d; }).call(this); ρσ_d["series_nav_display_mode"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = "stack"; ρσ_d["category"] = "book_list"; ρσ_d["is_local"] = false; return ρσ_d; }).call(this); ρσ_d["saved_virtual_libraries"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = []; ρσ_d["category"] = "book_list"; ρσ_d["is_local"] = false; return ρσ_d; }).call(this); ρσ_d["browse_visible_fields"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = Object.create(null); ρσ_d["category"] = "book_list"; ρσ_d["is_local"] = false; return ρσ_d; }).call(this); ρσ_d["sort"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = "timestamp.desc"; ρσ_d["category"] = "book_list"; return ρσ_d; }).call(this); ρσ_d["view_mode"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = "cover_grid"; ρσ_d["category"] = "book_list"; return ρσ_d; }).call(this); ρσ_d["cover_grid_tile_pct"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = 17; ρσ_d["category"] = "book_list"; return ρσ_d; }).call(this); ρσ_d["fts_related_words"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = true; ρσ_d["category"] = "book_list"; return ρσ_d; }).call(this); ρσ_d["and_search_terms"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = false; ρσ_d["category"] = "tag_browser"; return ρσ_d; }).call(this); ρσ_d["collapse_at"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = 25; ρσ_d["category"] = "tag_browser"; return ρσ_d; }).call(this); ρσ_d["dont_collapse"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = ""; ρσ_d["category"] = "tag_browser"; return ρσ_d; }).call(this); ρσ_d["hide_empty_categories"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = "no"; ρσ_d["category"] = "tag_browser"; return ρσ_d; }).call(this); ρσ_d["partition_method"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = "first letter"; ρσ_d["category"] = "tag_browser"; return ρσ_d; }).call(this); ρσ_d["sort_tags_by"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = "name"; ρσ_d["category"] = "tag_browser"; return ρσ_d; }).call(this); ρσ_d["background_image_fade"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = 0; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["background_image_style"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = "scaled"; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["background_image"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = null; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["base_font_size"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = 16; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["book_scrollbar"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = false; ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["columns_per_screen"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["portrait"] = 0; ρσ_d["landscape"] = 0; return ρσ_d; }).call(this); ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["controls_help_shown_count"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = 0; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; ρσ_d["disallowed_in_profile"] = true; return ρσ_d; }).call(this); ρσ_d["controls_help_shown_count_rtl_page_progression"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = 0; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; ρσ_d["disallowed_in_profile"] = true; return ρσ_d; }).call(this); ρσ_d["cover_preserve_aspect_ratio"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = true; ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["current_color_scheme"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = "system"; ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["footer"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["left"] = "menu-icon-on-hover"; ρσ_d["right"] = "progress"; return ρσ_d; }).call(this); ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["header"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["right"] = "menu-icon-on-hover"; return ρσ_d; }).call(this); ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["controls_footer"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["right"] = "progress"; return ρσ_d; }).call(this); ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["left-margin"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = Object.create(null); ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["right-margin"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = Object.create(null); ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["hide_tooltips"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = false; ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["keyboard_shortcuts"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = Object.create(null); ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["lines_per_sec_auto"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = 1; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["lines_per_sec_smooth"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = 20; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["margin_bottom"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = 20; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["margin_left"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = 20; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["margin_right"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = 20; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["margin_top"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = 20; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["max_text_height"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = 0; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["max_text_width"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = 0; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["override_book_colors"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = "never"; ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["paged_margin_clicks_scroll_by_screen"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = true; ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["paged_wheel_scrolls_by_screen"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = false; ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["paged_wheel_section_jumps"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = true; ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["paged_pixel_scroll_threshold"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = 60; ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["read_mode"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = "paged"; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["scroll_auto_boundary_delay"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = 5; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["scroll_mouse_boundary_delay"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = .5; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["scroll_stop_boundaries"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = false; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["standalone_font_settings"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = Object.create(null); ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["standalone_misc_settings"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = Object.create(null); ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["standalone_recently_opened"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = []; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; ρσ_d["disallowed_in_profile"] = true; return ρσ_d; }).call(this); ρσ_d["user_color_schemes"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = Object.create(null); ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["user_stylesheet"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = ""; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["word_actions"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = []; ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["highlight_style"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = null; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["highlights_export_format"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = "text"; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["custom_highlight_styles"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = []; ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["show_selection_bar"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = true; ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["net_search_url"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = "https://google.com/search?q={q}"; ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["selection_bar_actions"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = [ "copy", "lookup", "highlight", "remove_highlight", "search_net", "clear" ]; ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["selection_bar_quick_highlights"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = []; ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["skipped_dialogs"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = {}; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; ρσ_d["disallowed_in_profile"] = true; return ρσ_d; }).call(this); ρσ_d["tts"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = {}; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; ρσ_d["disallowed_in_profile"] = true; return ρσ_d; }).call(this); ρσ_d["tts_backend"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = {}; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; ρσ_d["disallowed_in_profile"] = true; return ρσ_d; }).call(this); ρσ_d["fullscreen_when_opening"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = "auto"; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["book_search_mode"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = "contains"; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["book_search_case_sensitive"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = false; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["reverse_page_turn_zones"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = false; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = true; return ρσ_d; }).call(this); ρσ_d["gesture_overrides"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = Object.create(null); ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["cite_text_template"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = "[{text}]({url})"; ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["cite_hl_template"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = "[{text}]({url})"; ρσ_d["category"] = "read_book"; return ρσ_d; }).call(this); ρσ_d["tts_bar_position"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["default"] = "float"; ρσ_d["category"] = "read_book"; ρσ_d["is_local"] = false; ρσ_d["disallowed_in_profile"] = false; return ρσ_d; }).call(this); return ρσ_d; }).call(this); defaults = Object.create(null); var ρσ_Iter15 = Object.entries(all_settings); ρσ_Iter15 = ((typeof ρσ_Iter15[Symbol.iterator] === "function") ? (ρσ_Iter15 instanceof Map ? ρσ_Iter15.keys() : ρσ_Iter15) : Object.keys(ρσ_Iter15)); for (var ρσ_Index15 of ρσ_Iter15) { x = ρσ_Index15; defaults[ρσ_bound_index(x[0], defaults)] = x[1].default; } function session_defaults() { return defaults; }; if (!session_defaults.__module__) Object.defineProperties(session_defaults, { __module__ : {value: "session"} }); function storage_available(which) { var storage, x; which = which || "localStorage"; try { storage = window[(typeof which === "number" && which < 0) ? window.length + which : which]; x = "__storage__test__"; storage.setItem(x, x); storage.removeItem(x); return true; } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; { return false; } } }; if (!storage_available.__argnames__) Object.defineProperties(storage_available, { __argnames__ : {value: ["which"]}, __module__ : {value: "session"} }); function FakeStorage() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); FakeStorage.prototype.__bind_methods__.call(this); FakeStorage.prototype.__init__.apply(this, arguments); } Object.defineProperty(FakeStorage.prototype, "__bind_methods__", {value: function () { this.getItem = FakeStorage.prototype.getItem.bind(this); this.setItem = FakeStorage.prototype.setItem.bind(this); this.clear = FakeStorage.prototype.clear.bind(this); }}); FakeStorage.prototype.__init__ = function __init__() { var self = this; self.data = Object.create(null); }; if (!FakeStorage.prototype.__init__.__module__) Object.defineProperties(FakeStorage.prototype.__init__, { __module__ : {value: "session"} }); FakeStorage.__argnames__ = FakeStorage.prototype.__init__.__argnames__; FakeStorage.__handles_kwarg_interpolation__ = FakeStorage.prototype.__init__.__handles_kwarg_interpolation__; FakeStorage.prototype.getItem = function getItem(key) { var self = this; return (ρσ_expr_temp = self.data)[(typeof key === "number" && key < 0) ? ρσ_expr_temp.length + key : key]; }; if (!FakeStorage.prototype.getItem.__argnames__) Object.defineProperties(FakeStorage.prototype.getItem, { __argnames__ : {value: ["key"]}, __module__ : {value: "session"} }); FakeStorage.prototype.setItem = function setItem(key, value) { var self = this; if (typeof value !== "string") { value = JSON.stringify(value); } (ρσ_expr_temp = self.data)[(typeof key === "number" && key < 0) ? ρσ_expr_temp.length + key : key] = value; }; if (!FakeStorage.prototype.setItem.__argnames__) Object.defineProperties(FakeStorage.prototype.setItem, { __argnames__ : {value: ["key", "value"]}, __module__ : {value: "session"} }); FakeStorage.prototype.clear = function clear() { var self = this; self.data = Object.create(null); }; if (!FakeStorage.prototype.clear.__module__) Object.defineProperties(FakeStorage.prototype.clear, { __module__ : {value: "session"} }); FakeStorage.prototype.__repr__ = function __repr__ () { return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; FakeStorage.prototype.__str__ = function __str__ () { return this.__repr__(); }; Object.defineProperty(FakeStorage.prototype, "__bases__", {value: []}); function get_session_storage() { if (!get_session_storage.ans) { if (storage_available("localStorage")) { get_session_storage.ans = window.localStorage; } else if (storage_available("sessionStorage")) { get_session_storage.ans = window.sessionStorage; console.error("localStorage not available using sessionStorage instead"); } else { get_session_storage.ans = new FakeStorage; console.error("sessionStorage and localStorage not available using a temp cache instead"); } } return get_session_storage.ans; }; if (!get_session_storage.__module__) Object.defineProperties(get_session_storage, { __module__ : {value: "session"} }); function SessionData() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); SessionData.prototype.__bind_methods__.call(this); SessionData.prototype.__init__.apply(this, arguments); } Object.defineProperty(SessionData.prototype, "__bind_methods__", {value: function () { this.get = SessionData.prototype.get.bind(this); this.set = SessionData.prototype.set.bind(this); this.set_bulk = SessionData.prototype.set_bulk.bind(this); this.clear = SessionData.prototype.clear.bind(this); }}); SessionData.prototype.__init__ = function __init__() { var self = this; var global_prefix = (arguments[0] === undefined || ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? __init__.__defaults__.global_prefix : arguments[0]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "global_prefix")){ global_prefix = ρσ_kwargs_obj.global_prefix; } self.global_prefix = global_prefix || "calibre-session-"; self.storage = get_session_storage(); self.overflow_storage = Object.create(null); self.has_overflow = false; }; if (!SessionData.prototype.__init__.__defaults__) Object.defineProperties(SessionData.prototype.__init__, { __defaults__ : {value: {global_prefix:null}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["global_prefix"]}, __module__ : {value: "session"} }); SessionData.__argnames__ = SessionData.prototype.__init__.__argnames__; SessionData.__handles_kwarg_interpolation__ = SessionData.prototype.__init__.__handles_kwarg_interpolation__; SessionData.prototype.get = function get(key, defval) { var self = this; var ans; key = self.global_prefix + key; if (self.has_overflow) { ans = (ρσ_expr_temp = self.overflow_storage)[(typeof key === "number" && key < 0) ? ρσ_expr_temp.length + key : key]; if (ans === undefined) { ans = self.storage.getItem(key); } } else { ans = self.storage.getItem(key); } if (ans === undefined || ans === null) { if (defval === undefined) { defval = null; } return defval; } try { return JSON.parse(ans); } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; { if (defval === undefined) { defval = null; } return defval; } } }; if (!SessionData.prototype.get.__argnames__) Object.defineProperties(SessionData.prototype.get, { __argnames__ : {value: ["key", "defval"]}, __module__ : {value: "session"} }); SessionData.prototype.set = function set(key, value) { var self = this; key = self.global_prefix + key; if (value === null) { self.storage.removeItem(key); delete self.overflow_storage[key]; return true; } value = JSON.stringify(value); try { self.storage.setItem(key, value); delete self.overflow_storage[key]; return true; } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; { (ρσ_expr_temp = self.overflow_storage)[(typeof key === "number" && key < 0) ? ρσ_expr_temp.length + key : key] = value; self.has_overflow = true; console.error("session storage has overflowed, using a temp cache instead"); } } return false; }; if (!SessionData.prototype.set.__argnames__) Object.defineProperties(SessionData.prototype.set, { __argnames__ : {value: ["key", "value"]}, __module__ : {value: "session"} }); SessionData.prototype.set_bulk = function set_bulk(changes) { var self = this; var key; var ρσ_Iter16 = Object.keys(changes); ρσ_Iter16 = ((typeof ρσ_Iter16[Symbol.iterator] === "function") ? (ρσ_Iter16 instanceof Map ? ρσ_Iter16.keys() : ρσ_Iter16) : Object.keys(ρσ_Iter16)); for (var ρσ_Index16 of ρσ_Iter16) { key = ρσ_Index16; self.set(key, changes[(typeof key === "number" && key < 0) ? changes.length + key : key]); } }; if (!SessionData.prototype.set_bulk.__argnames__) Object.defineProperties(SessionData.prototype.set_bulk, { __argnames__ : {value: ["changes"]}, __module__ : {value: "session"} }); SessionData.prototype.clear = function clear() { var self = this; self.storage.clear(); self.overflow_storage = Object.create(null); self.has_overflow = false; }; if (!SessionData.prototype.clear.__module__) Object.defineProperties(SessionData.prototype.clear, { __module__ : {value: "session"} }); SessionData.prototype.__repr__ = function __repr__ () { return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; SessionData.prototype.__str__ = function __str__ () { return this.__repr__(); }; Object.defineProperty(SessionData.prototype, "__bases__", {value: []}); function local_storage() { if (!local_storage.storage) { local_storage.storage = new SessionData("calibre-local-"); } return local_storage.storage; }; if (!local_storage.__module__) Object.defineProperties(local_storage, { __module__ : {value: "session"} }); function get_device_uuid() { var s, ans; if (!get_device_uuid.ans) { s = local_storage(); ans = s.get("device_uuid"); if (!ans) { ans = short_uuid(); s.set("device_uuid", ans); } get_device_uuid.ans = ans; } return get_device_uuid.ans; }; if (!get_device_uuid.__module__) Object.defineProperties(get_device_uuid, { __module__ : {value: "session"} }); function deep_eq(a, b) { var i, ka, key; if (a === b) { return true; } if (Array.isArray(a) && Array.isArray(b)) { if (a.length !== b.length) { return false; } for (var ρσ_Index17 = 0; ρσ_Index17 < a.length; ρσ_Index17++) { i = ρσ_Index17; if (!deep_eq(a[(typeof i === "number" && i < 0) ? a.length + i : i], b[(typeof i === "number" && i < 0) ? b.length + i : i])) { return false; } } return true; } if (a === null || b === null || a === undefined || b === undefined) { return false; } if (typeof a !== "object" || typeof b !== "object") { return false; } ka = Object.keys(a); if (ka.length !== Object.keys(b).length) { return false; } var ρσ_Iter18 = ka; ρσ_Iter18 = ((typeof ρσ_Iter18[Symbol.iterator] === "function") ? (ρσ_Iter18 instanceof Map ? ρσ_Iter18.keys() : ρσ_Iter18) : Object.keys(ρσ_Iter18)); for (var ρσ_Index18 of ρσ_Iter18) { key = ρσ_Index18; if (!deep_eq(a[(typeof key === "number" && key < 0) ? a.length + key : key], b[(typeof key === "number" && key < 0) ? b.length + key : key])) { return false; } } return true; }; if (!deep_eq.__argnames__) Object.defineProperties(deep_eq, { __argnames__ : {value: ["a", "b"]}, __module__ : {value: "session"} }); function get_subset_of_settings(sd, filter_func) { var ans, curval, metadata, is_set, setting_name; ans = Object.create(null); var ρσ_Iter19 = Object.keys(all_settings); ρσ_Iter19 = ((typeof ρσ_Iter19[Symbol.iterator] === "function") ? (ρσ_Iter19 instanceof Map ? ρσ_Iter19.keys() : ρσ_Iter19) : Object.keys(ρσ_Iter19)); for (var ρσ_Index19 of ρσ_Iter19) { setting_name = ρσ_Index19; curval = sd.get(setting_name, ans); metadata = all_settings[(typeof setting_name === "number" && setting_name < 0) ? all_settings.length + setting_name : setting_name]; is_set = curval !== ans; if (filter_func(setting_name, metadata, is_set, curval)) { ans[(typeof setting_name === "number" && setting_name < 0) ? ans.length + setting_name : setting_name] = window.structuredClone((is_set) ? curval : metadata.default); } } return ans; }; if (!get_subset_of_settings.__argnames__) Object.defineProperties(get_subset_of_settings, { __argnames__ : {value: ["sd", "filter_func"]}, __module__ : {value: "session"} }); function apply_profile(sd, profile, filter_func) { var changes, metadata, curval, is_set, newval, setting_name; changes = Object.create(null); var ρσ_Iter20 = Object.keys(all_settings); ρσ_Iter20 = ((typeof ρσ_Iter20[Symbol.iterator] === "function") ? (ρσ_Iter20 instanceof Map ? ρσ_Iter20.keys() : ρσ_Iter20) : Object.keys(ρσ_Iter20)); for (var ρσ_Index20 of ρσ_Iter20) { setting_name = ρσ_Index20; metadata = all_settings[(typeof setting_name === "number" && setting_name < 0) ? all_settings.length + setting_name : setting_name]; curval = sd.get(setting_name, changes); is_set = curval !== changes; if (filter_func(setting_name, metadata, is_set, curval)) { newval = null; if (Object.prototype.hasOwnProperty.call(profile, setting_name)) { newval = profile[(typeof setting_name === "number" && setting_name < 0) ? profile.length + setting_name : setting_name]; if (deep_eq(newval, metadata.default)) { newval = null; } } changes[(typeof setting_name === "number" && setting_name < 0) ? changes.length + setting_name : setting_name] = window.structuredClone(newval); } } sd.set_bulk(changes); return changes; }; if (!apply_profile.__argnames__) Object.defineProperties(apply_profile, { __argnames__ : {value: ["sd", "profile", "filter_func"]}, __module__ : {value: "session"} }); standalone_reader_defaults = (function(){ var ρσ_d = Object.create(null); ρσ_d["remember_window_geometry"] = false; ρσ_d["remember_last_read"] = true; ρσ_d["show_actions_toolbar"] = false; ρσ_d["show_actions_toolbar_in_fullscreen"] = false; ρσ_d["save_annotations_in_ebook"] = false; ρσ_d["sync_annots_user"] = ""; ρσ_d["singleinstance"] = false; ρσ_d["auto_hide_mouse"] = true; ρσ_d["restore_docks"] = true; return ρσ_d; }).call(this); function settings_for_reader_profile(sd) { var margin_text_settings; margin_text_settings = (function(){ var ρσ_d = Object.create(null); ρσ_d["footer"] = true; ρσ_d["header"] = true; ρσ_d["controls_footer"] = true; ρσ_d["left-margin"] = true; ρσ_d["right-margin"] = true; return ρσ_d; }).call(this); function filter_func(setting_name, metadata, is_set, curval) { var x, key; if (margin_text_settings[(typeof setting_name === "number" && setting_name < 0) ? margin_text_settings.length + setting_name : setting_name]) { curval = window.structuredClone(curval); var ρσ_Iter21 = [ "left", "right", "middle" ]; ρσ_Iter21 = ((typeof ρσ_Iter21[Symbol.iterator] === "function") ? (ρσ_Iter21 instanceof Map ? ρσ_Iter21.keys() : ρσ_Iter21) : Object.keys(ρσ_Iter21)); for (var ρσ_Index21 of ρσ_Iter21) { x = ρσ_Index21; if (curval[(typeof x === "number" && x < 0) ? curval.length + x : x] === "empty") { delete curval[x]; } } } else if (setting_name === "standalone_misc_settings") { curval = window.structuredClone(curval); var ρσ_Iter22 = Object.keys(curval); ρσ_Iter22 = ((typeof ρσ_Iter22[Symbol.iterator] === "function") ? (ρσ_Iter22 instanceof Map ? ρσ_Iter22.keys() : ρσ_Iter22) : Object.keys(ρσ_Iter22)); for (var ρσ_Index22 of ρσ_Iter22) { key = ρσ_Index22; if (curval[(typeof key === "number" && key < 0) ? curval.length + key : key] === standalone_reader_defaults[(typeof key === "number" && key < 0) ? standalone_reader_defaults.length + key : key]) { delete curval[key]; } } } if (!is_set || metadata.category !== "read_book" || metadata.disallowed_in_profile || deep_eq(curval, metadata.default)) { return false; } return true; }; if (!filter_func.__argnames__) Object.defineProperties(filter_func, { __argnames__ : {value: ["setting_name", "metadata", "is_set", "curval"]}, __module__ : {value: "session"} }); return get_subset_of_settings(sd, filter_func); }; if (!settings_for_reader_profile.__argnames__) Object.defineProperties(settings_for_reader_profile, { __argnames__ : {value: ["sd"]}, __module__ : {value: "session"} }); function apply_reader_profile(sd, profile) { function filter_func(setting_name, metadata, is_set, curval) { return metadata.category === "read_book" && !metadata.disallowed_in_profile; }; if (!filter_func.__argnames__) Object.defineProperties(filter_func, { __argnames__ : {value: ["setting_name", "metadata", "is_set", "curval"]}, __module__ : {value: "session"} }); apply_profile(sd, profile, filter_func); }; if (!apply_reader_profile.__argnames__) Object.defineProperties(apply_reader_profile, { __argnames__ : {value: ["sd", "profile"]}, __module__ : {value: "session"} }); default_interface_data = (function(){ var ρσ_d = Object.create(null); ρσ_d["username"] = null; ρσ_d["output_format"] = "EPUB"; ρσ_d["input_formats"] = (function(){ var s = ρσ_set(); s.jsset.add("EPUB"); s.jsset.add("MOBI"); s.jsset.add("AZW3"); return s; })(); ρσ_d["gui_pubdate_display_format"] = "MMM yyyy"; ρσ_d["gui_timestamp_display_format"] = "dd MMM yyyy"; ρσ_d["gui_last_modified_display_format"] = "dd MMM yyyy"; ρσ_d["use_roman_numerals_for_series_number"] = true; ρσ_d["default_library_id"] = null; ρσ_d["default_book_list_mode"] = session_defaults().view_mode; ρσ_d["library_map"] = null; ρσ_d["search_the_net_urls"] = []; ρσ_d["donate_link"] = "https://calibre-ebook.com/donate"; ρσ_d["default_author_link"] = ""; ρσ_d["icon_map"] = Object.create(null); ρσ_d["icon_path"] = ""; ρσ_d["custom_list_template"] = null; ρσ_d["num_per_page"] = 50; ρσ_d["lang_code_for_user_manual"] = ""; return ρσ_d; }).call(this); function get_interface_data() { var ans, k; if (!get_interface_data.storage) { get_interface_data.storage = new SessionData("calibre-interface-data-"); } ans = get_interface_data.storage.get("current"); if (ans) { ans.is_default = false; } else { ans = (function(){ var ρσ_d = Object.create(null); ρσ_d["is_default"] = true; return ρσ_d; }).call(this); var ρσ_Iter23 = default_interface_data; ρσ_Iter23 = ((typeof ρσ_Iter23[Symbol.iterator] === "function") ? (ρσ_Iter23 instanceof Map ? ρσ_Iter23.keys() : ρσ_Iter23) : Object.keys(ρσ_Iter23)); for (var ρσ_Index23 of ρσ_Iter23) { k = ρσ_Index23; ans[(typeof k === "number" && k < 0) ? ans.length + k : k] = default_interface_data[(typeof k === "number" && k < 0) ? default_interface_data.length + k : k]; } } return ans; }; if (!get_interface_data.__module__) Object.defineProperties(get_interface_data, { __module__ : {value: "session"} }); ρσ_modules.session.all_settings = all_settings; ρσ_modules.session.defaults = defaults; ρσ_modules.session.x = x; ρσ_modules.session.standalone_reader_defaults = standalone_reader_defaults; ρσ_modules.session.default_interface_data = default_interface_data; ρσ_modules.session.session_defaults = session_defaults; ρσ_modules.session.storage_available = storage_available; ρσ_modules.session.FakeStorage = FakeStorage; ρσ_modules.session.get_session_storage = get_session_storage; ρσ_modules.session.SessionData = SessionData; ρσ_modules.session.local_storage = local_storage; ρσ_modules.session.get_device_uuid = get_device_uuid; ρσ_modules.session.deep_eq = deep_eq; ρσ_modules.session.get_subset_of_settings = get_subset_of_settings; ρσ_modules.session.apply_profile = apply_profile; ρσ_modules.session.settings_for_reader_profile = settings_for_reader_profile; ρσ_modules.session.apply_reader_profile = apply_reader_profile; ρσ_modules.session.get_interface_data = get_interface_data; })(); (function(){ var __name__ = "dom"; var simple_vendor_prefixes, extra_css, add_extra_css; simple_vendor_prefixes = (function(){ var ρσ_d = Object.create(null); ρσ_d["animation"] = [ "webkit", "moz", "o" ]; ρσ_d["animation-name"] = [ "webkit", "moz", "o" ]; ρσ_d["animation-duration"] = [ "webkit", "moz", "o" ]; ρσ_d["animation-timing-function"] = [ "webkit", "moz", "o" ]; ρσ_d["animation-delay"] = [ "webkit", "moz", "o" ]; ρσ_d["animation-iteration-count"] = [ "webkit", "moz", "o" ]; ρσ_d["animation-direction"] = [ "webkit", "moz", "o" ]; ρσ_d["animation-fill-mode"] = [ "webkit", "moz", "o" ]; ρσ_d["animation-play-state"] = [ "webkit", "moz", "o" ]; ρσ_d["hyphens"] = [ "webkit", "moz", "ms" ]; ρσ_d["transform"] = [ "webkit", "ms", "moz", "o" ]; ρσ_d["transform-origin"] = [ "webkit", "ms", "moz", "o" ]; ρσ_d["transition"] = [ "webkit", "moz", "o" ]; ρσ_d["filter"] = [ "webkit" ]; ρσ_d["user-select"] = [ "webkit", "moz", "ms" ]; ρσ_d["break-before"] = [ "webkit-column" ]; ρσ_d["break-after"] = [ "webkit-column" ]; ρσ_d["break-inside"] = [ "webkit-column" ]; ρσ_d["column-gap"] = [ "webkit", "moz" ]; ρσ_d["column-width"] = [ "webkit", "moz" ]; ρσ_d["column-rule"] = [ "webkit", "moz" ]; ρσ_d["column-fill"] = [ "moz" ]; return ρσ_d; }).call(this); function set_css() { var elem = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var kw = arguments[arguments.length-1]; if (kw === null || typeof kw !== "object" || kw [ρσ_kwargs_symbol] !== true) kw = {}; var s, ρσ_unpack, name, val, prefixes, prefix, prop; if (typeof elem === "string") { elem = document.querySelector(elem); } s = elem.style; if (s) { var ρσ_Iter24 = kw; ρσ_Iter24 = ((typeof ρσ_Iter24[Symbol.iterator] === "function") ? (ρσ_Iter24 instanceof Map ? ρσ_Iter24.keys() : ρσ_Iter24) : Object.keys(ρσ_Iter24)); for (var ρσ_Index24 of ρσ_Iter24) { prop = ρσ_Index24; ρσ_unpack = [str.replace(str.rstrip(prop, "_"), "_", "-"), kw[(typeof prop === "number" && prop < 0) ? kw.length + prop : prop]]; name = ρσ_unpack[0]; val = ρσ_unpack[1]; if (val === null || val === undefined) { s.removeProperty(name); } else { s.setProperty(name, val); } prefixes = simple_vendor_prefixes[(typeof name === "number" && name < 0) ? simple_vendor_prefixes.length + name : name]; if (prefixes) { var ρσ_Iter25 = prefixes; ρσ_Iter25 = ((typeof ρσ_Iter25[Symbol.iterator] === "function") ? (ρσ_Iter25 instanceof Map ? ρσ_Iter25.keys() : ρσ_Iter25) : Object.keys(ρσ_Iter25)); for (var ρσ_Index25 of ρσ_Iter25) { prefix = ρσ_Index25; if (val === null || val === undefined) { s.removeProperty("-" + prefix + "-" + name); } else { s.setProperty("-" + prefix + "-" + name, val); } } } } } return elem; }; if (!set_css.__handles_kwarg_interpolation__) Object.defineProperties(set_css, { __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["elem"]}, __module__ : {value: "dom"} }); function set_important_css() { var elem = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var kw = arguments[arguments.length-1]; if (kw === null || typeof kw !== "object" || kw [ρσ_kwargs_symbol] !== true) kw = {}; var s, ρσ_unpack, name, val, prefixes, prefix, prop; if (typeof elem === "string") { elem = document.querySelector(elem); } s = elem.style; if (s) { var ρσ_Iter26 = kw; ρσ_Iter26 = ((typeof ρσ_Iter26[Symbol.iterator] === "function") ? (ρσ_Iter26 instanceof Map ? ρσ_Iter26.keys() : ρσ_Iter26) : Object.keys(ρσ_Iter26)); for (var ρσ_Index26 of ρσ_Iter26) { prop = ρσ_Index26; ρσ_unpack = [str.replace(str.rstrip(prop, "_"), "_", "-"), kw[(typeof prop === "number" && prop < 0) ? kw.length + prop : prop]]; name = ρσ_unpack[0]; val = ρσ_unpack[1]; if (val === null || val === undefined) { s.removeProperty(name); } else { s.setProperty(name, val, "important"); } prefixes = simple_vendor_prefixes[(typeof name === "number" && name < 0) ? simple_vendor_prefixes.length + name : name]; if (prefixes) { var ρσ_Iter27 = prefixes; ρσ_Iter27 = ((typeof ρσ_Iter27[Symbol.iterator] === "function") ? (ρσ_Iter27 instanceof Map ? ρσ_Iter27.keys() : ρσ_Iter27) : Object.keys(ρσ_Iter27)); for (var ρσ_Index27 of ρσ_Iter27) { prefix = ρσ_Index27; if (val === null || val === undefined) { s.removeProperty("-" + prefix + "-" + name); } else { s.setProperty("-" + prefix + "-" + name, val, "important"); } } } } } return elem; }; if (!set_important_css.__handles_kwarg_interpolation__) Object.defineProperties(set_important_css, { __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["elem"]}, __module__ : {value: "dom"} }); function build_rule() { var selector = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var kw = arguments[arguments.length-1]; if (kw === null || typeof kw !== "object" || kw [ρσ_kwargs_symbol] !== true) kw = {}; var ans, ρσ_unpack, name, val, prefixes, prefix, prop; ans = [ selector + " { " ]; var ρσ_Iter28 = kw; ρσ_Iter28 = ((typeof ρσ_Iter28[Symbol.iterator] === "function") ? (ρσ_Iter28 instanceof Map ? ρσ_Iter28.keys() : ρσ_Iter28) : Object.keys(ρσ_Iter28)); for (var ρσ_Index28 of ρσ_Iter28) { prop = ρσ_Index28; ρσ_unpack = [str.replace(str.rstrip(prop, "_"), "_", "-"), kw[(typeof prop === "number" && prop < 0) ? kw.length + prop : prop]]; name = ρσ_unpack[0]; val = ρσ_unpack[1]; ans.push(name + ":" + val + ";"); prefixes = simple_vendor_prefixes[(typeof name === "number" && name < 0) ? simple_vendor_prefixes.length + name : name]; if (prefixes) { var ρσ_Iter29 = prefixes; ρσ_Iter29 = ((typeof ρσ_Iter29[Symbol.iterator] === "function") ? (ρσ_Iter29 instanceof Map ? ρσ_Iter29.keys() : ρσ_Iter29) : Object.keys(ρσ_Iter29)); for (var ρσ_Index29 of ρσ_Iter29) { prefix = ρσ_Index29; ans.push("-" + prefix + "-" + name + ":" + val + ";"); } } } ans.push("}"); return ans.join("\n") + "\n"; }; if (!build_rule.__handles_kwarg_interpolation__) Object.defineProperties(build_rule, { __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["selector"]}, __module__ : {value: "dom"} }); function clear() { var node; for (var i = 0; i < arguments.length; i++) { node = arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i]; while (node.firstChild) { node.removeChild(node.firstChild); } } }; if (!clear.__module__) Object.defineProperties(clear, { __module__ : {value: "dom"} }); function remove_all_attributes() { var node; for (var i = 0; i < arguments.length; i++) { node = arguments[(typeof i === "number" && i < 0) ? arguments.length + i : i]; while (node.attributes.length > 0) { node.removeAttributeNode(node.attributes[0]); } } }; if (!remove_all_attributes.__module__) Object.defineProperties(remove_all_attributes, { __module__ : {value: "dom"} }); function create_keyframes() { var animation_name = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var frames = Array.prototype.slice.call(arguments, 1); if (arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) frames.pop(); var ans, frame, prefix; ans = []; var ρσ_Iter30 = [ "-webkit-", "-moz-", "-o-", "" ]; ρσ_Iter30 = ((typeof ρσ_Iter30[Symbol.iterator] === "function") ? (ρσ_Iter30 instanceof Map ? ρσ_Iter30.keys() : ρσ_Iter30) : Object.keys(ρσ_Iter30)); for (var ρσ_Index30 of ρσ_Iter30) { prefix = ρσ_Index30; ans.push("@" + prefix + "keyframes " + animation_name + " {"); var ρσ_Iter31 = frames; ρσ_Iter31 = ((typeof ρσ_Iter31[Symbol.iterator] === "function") ? (ρσ_Iter31 instanceof Map ? ρσ_Iter31.keys() : ρσ_Iter31) : Object.keys(ρσ_Iter31)); for (var ρσ_Index31 of ρσ_Iter31) { frame = ρσ_Index31; ans.push(frame); } ans.push("}"); } return ans.join("\n") + "\n"; }; if (!create_keyframes.__handles_kwarg_interpolation__) Object.defineProperties(create_keyframes, { __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["animation_name"]}, __module__ : {value: "dom"} }); function change_icon_image(icon_element, new_name, tooltip) { var x, tt; if (new_name) { icon_element.firstChild.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "#icon-" + new_name); } else { icon_element.firstChild.removeAttributeNS("http://www.w3.org/1999/xlink", "xlink:href"); } if ((typeof tooltip !== "undefined" && tooltip !== null)) { x = icon_element.getElementsByTagNameNS("http://www.w3.org/2000/svg", "title"); if (!x.length) { tt = document.createElementNS("http://www.w3.org/2000/svg", "title"); icon_element.appendChild(tt); x = [ tt ]; } x[0].textContent = tooltip; } }; if (!change_icon_image.__argnames__) Object.defineProperties(change_icon_image, { __argnames__ : {value: ["icon_element", "new_name", "tooltip"]}, __module__ : {value: "dom"} }); function svgicon(name, height, width, tooltip) { var ans, u, tt; ans = document.createElementNS("http://www.w3.org/2000/svg", "svg"); ans.setAttribute("style", "fill: currentColor; height: {}; width: {}; vertical-align: text-top".format((typeof height !== "undefined" && height !== null ? height : "2ex"), (typeof width !== "undefined" && width !== null ? width : "2ex"))); u = document.createElementNS("http://www.w3.org/2000/svg", "use"); ans.appendChild(u); if (name) { ans.firstChild.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "#icon-" + name); } if (tooltip) { tt = document.createElementNS("http://www.w3.org/2000/svg", "title"); tt.textContent = tooltip; ans.appendChild(tt); } return ans; }; if (!svgicon.__argnames__) Object.defineProperties(svgicon, { __argnames__ : {value: ["name", "height", "width", "tooltip"]}, __module__ : {value: "dom"} }); function element(elem_id, child_selector) { var ans; ans = (elem_id) ? document.getElementById(elem_id) : document.body; if (child_selector) { ans = ans.querySelector(child_selector); } return ans; }; if (!element.__argnames__) Object.defineProperties(element, { __argnames__ : {value: ["elem_id", "child_selector"]}, __module__ : {value: "dom"} }); function selector() { var id_selector = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var args = Array.prototype.slice.call(arguments, 1); if (arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) args.pop(); var ans, x; ans = "#" + id_selector; var ρσ_Iter32 = args; ρσ_Iter32 = ((typeof ρσ_Iter32[Symbol.iterator] === "function") ? (ρσ_Iter32 instanceof Map ? ρσ_Iter32.keys() : ρσ_Iter32) : Object.keys(ρσ_Iter32)); for (var ρσ_Index32 of ρσ_Iter32) { x = ρσ_Index32; ans += " " + x; } return ans; }; if (!selector.__handles_kwarg_interpolation__) Object.defineProperties(selector, { __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["id_selector"]}, __module__ : {value: "dom"} }); function rule() { var id_selector = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var kw = arguments[arguments.length-1]; if (kw === null || typeof kw !== "object" || kw [ρσ_kwargs_symbol] !== true) kw = {}; var args = Array.prototype.slice.call(arguments, 1); if (kw !== null && typeof kw === "object" && kw [ρσ_kwargs_symbol] === true) args.pop(); return ρσ_interpolate_kwargs.call(this, build_rule, [selector.apply(this, [id_selector].concat(args))].concat([ρσ_desugar_kwargs(kw)])); }; if (!rule.__handles_kwarg_interpolation__) Object.defineProperties(rule, { __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["id_selector"]}, __module__ : {value: "dom"} }); function unique_id(prefix) { var num; prefix = prefix || "auto-id"; (ρσ_expr_temp = unique_id.counts)[(typeof prefix === "number" && prefix < 0) ? ρσ_expr_temp.length + prefix : prefix] = num = ((ρσ_expr_temp = unique_id.counts)[(typeof prefix === "number" && prefix < 0) ? ρσ_expr_temp.length + prefix : prefix] || 0) + 1; return prefix + "-" + num; }; if (!unique_id.__argnames__) Object.defineProperties(unique_id, { __argnames__ : {value: ["prefix"]}, __module__ : {value: "dom"} }); unique_id.counts = Object.create(null); function ensure_id(w, prefix) { var ans; ans = w.getAttribute("id"); if (!ans) { ans = unique_id(prefix); w.setAttribute("id", ans); } return ans; }; if (!ensure_id.__argnames__) Object.defineProperties(ensure_id, { __argnames__ : {value: ["w", "prefix"]}, __module__ : {value: "dom"} }); extra_css = []; add_extra_css = extra_css.push.bind(extra_css); function get_widget_css() { var ans, func; ans = []; var ρσ_Iter33 = extra_css; ρσ_Iter33 = ((typeof ρσ_Iter33[Symbol.iterator] === "function") ? (ρσ_Iter33 instanceof Map ? ρσ_Iter33.keys() : ρσ_Iter33) : Object.keys(ρσ_Iter33)); for (var ρσ_Index33 of ρσ_Iter33) { func = ρσ_Index33; ans.push(func()); } return ans.join("\n"); }; if (!get_widget_css.__module__) Object.defineProperties(get_widget_css, { __module__ : {value: "dom"} }); function set_radio_group_value(parent, name, val) { var changed, inp; changed = false; var ρσ_Iter34 = parent.querySelectorAll("input[name=" + ρσ_str.format("{}", name) + "]"); ρσ_Iter34 = ((typeof ρσ_Iter34[Symbol.iterator] === "function") ? (ρσ_Iter34 instanceof Map ? ρσ_Iter34.keys() : ρσ_Iter34) : Object.keys(ρσ_Iter34)); for (var ρσ_Index34 of ρσ_Iter34) { inp = ρσ_Index34; inp.checked = inp.value === val; changed = true; } if (!changed) { throw new KeyError("No radio group with name=" + ρσ_str.format("{}", name) + " found"); } }; if (!set_radio_group_value.__argnames__) Object.defineProperties(set_radio_group_value, { __argnames__ : {value: ["parent", "name", "val"]}, __module__ : {value: "dom"} }); ρσ_modules.dom.simple_vendor_prefixes = simple_vendor_prefixes; ρσ_modules.dom.extra_css = extra_css; ρσ_modules.dom.add_extra_css = add_extra_css; ρσ_modules.dom.set_css = set_css; ρσ_modules.dom.set_important_css = set_important_css; ρσ_modules.dom.build_rule = build_rule; ρσ_modules.dom.clear = clear; ρσ_modules.dom.remove_all_attributes = remove_all_attributes; ρσ_modules.dom.create_keyframes = create_keyframes; ρσ_modules.dom.change_icon_image = change_icon_image; ρσ_modules.dom.svgicon = svgicon; ρσ_modules.dom.element = element; ρσ_modules.dom.selector = selector; ρσ_modules.dom.rule = rule; ρσ_modules.dom.unique_id = unique_id; ρσ_modules.dom.ensure_id = ensure_id; ρσ_modules.dom.get_widget_css = get_widget_css; ρσ_modules.dom.set_radio_group_value = set_radio_group_value; })(); (function(){ var __name__ = "book_list.theme"; var DARK, LIGHT, LIGHT_DARKER, DT_DARK, DT_DARK_DARKER, DT_DARK_LIGHTER, DT_DARK_LIGTHER_CONTRAST, DT_LIGHT, DEFAULT_COLORS, DEFAULT_SIZES, DEFAULT_FONTS; var get_session_data = ρσ_modules["book_list.globals"].get_session_data; var all_settings = ρσ_modules.session.all_settings; DARK = "#39322B"; LIGHT = "#F6F3E9"; LIGHT_DARKER = "#b6b3a8"; DT_DARK = "#2d2d2d"; DT_DARK_DARKER = "black"; DT_DARK_LIGHTER = "#777"; DT_DARK_LIGTHER_CONTRAST = "#1d1d1d"; DT_LIGHT = "#ddd"; function c(light, dark) { return (function(){ var ρσ_d = Object.create(null); ρσ_d["light"] = light; ρσ_d["dark"] = dark || light; return ρσ_d; }).call(this); }; if (!c.__argnames__) Object.defineProperties(c, { __argnames__ : {value: ["light", "dark"]}, __module__ : {value: "book_list.theme"} }); function _byte(n) { if (n < 0) { return 0; } if (n > 255) { return 255; } return int(n); }; if (!_byte.__argnames__) Object.defineProperties(_byte, { __argnames__ : {value: ["n"]}, __module__ : {value: "book_list.theme"} }); function parse_hex_color(s) { var v; if (!s) { return null; } v = (s + "").strip(); if (v.startsWith("#")) { v = v.slice(1); } if (v.length === 3) { v = v[0] + v[0] + v[1] + v[1] + v[2] + v[2]; } if (v.length !== 6) { return null; } try { return [ int(v.slice(0, 2), 16), int(v.slice(2, 4), 16), int(v.slice(4, 6), 16) ]; } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; if (ρσ_Exception instanceof Error) { return null; } else { throw ρσ_Exception; } } }; if (!parse_hex_color.__argnames__) Object.defineProperties(parse_hex_color, { __argnames__ : {value: ["s"]}, __module__ : {value: "book_list.theme"} }); function hex_as_rgba() { var s = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var opacity = (arguments[1] === undefined || ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? hex_as_rgba.__defaults__.opacity : arguments[1]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "opacity")){ opacity = ρσ_kwargs_obj.opacity; } var v; v = parse_hex_color(s); return "rgba(" + ρσ_str.format("{}", v[0]) + "," + ρσ_str.format("{}", v[1]) + "," + ρσ_str.format("{}", v[2]) + "," + ρσ_str.format("{}", opacity) + ")"; }; if (!hex_as_rgba.__defaults__) Object.defineProperties(hex_as_rgba, { __defaults__ : {value: {opacity:"1"}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["s", "opacity"]}, __module__ : {value: "book_list.theme"} }); function mix_rgb_channel(a, b, t) { return _byte(Math.round(a * (1 - t) + b * t)); }; if (!mix_rgb_channel.__argnames__) Object.defineProperties(mix_rgb_channel, { __argnames__ : {value: ["a", "b", "t"]}, __module__ : {value: "book_list.theme"} }); function mix_rgb(a, b, t) { var r0, r1, r2; r0 = mix_rgb_channel(a[0], b[0], t); r1 = mix_rgb_channel(a[1], b[1], t); r2 = mix_rgb_channel(a[2], b[2], t); return [ r0, r1, r2 ]; }; if (!mix_rgb.__argnames__) Object.defineProperties(mix_rgb, { __argnames__ : {value: ["a", "b", "t"]}, __module__ : {value: "book_list.theme"} }); function rgb_to_hex(rgb) { var r, g, b; r = rgb[0]; g = rgb[1]; b = rgb[2]; function h(n) { var s; s = n.toString(16); if (s.length < 2) { s = "0" + s; } return s; }; if (!h.__argnames__) Object.defineProperties(h, { __argnames__ : {value: ["n"]}, __module__ : {value: "book_list.theme"} }); return "#" + h(r) + h(g) + h(b); }; if (!rgb_to_hex.__argnames__) Object.defineProperties(rgb_to_hex, { __argnames__ : {value: ["rgb"]}, __module__ : {value: "book_list.theme"} }); function light_mode_primary_tints(primary_rgb) { var W, wb, wb2, tree, dlg, lh_bg, inp, bar_bg, btn_base, btn_base2, btn_s, btn_e; W = [ 255, 255, 255 ]; wb = rgb_to_hex(mix_rgb(W, primary_rgb, .055)); wb2 = rgb_to_hex(mix_rgb(W, primary_rgb, .115)); tree = rgb_to_hex(mix_rgb(W, primary_rgb, .095)); dlg = wb; lh_bg = rgb_to_hex(mix_rgb(W, primary_rgb, .168)); inp = rgb_to_hex(mix_rgb(W, primary_rgb, .068)); bar_bg = rgb_to_hex(mix_rgb(W, primary_rgb, .052)); btn_base = [ 36, 38, 40 ]; btn_base2 = [ 52, 54, 58 ]; btn_s = rgb_to_hex(mix_rgb(btn_base, primary_rgb, .4)); btn_e = rgb_to_hex(mix_rgb(btn_base2, primary_rgb, .36)); return (function(){ var ρσ_d = Object.create(null); ρσ_d["--calibre-color-window-background"] = wb; ρσ_d["--calibre-color-window-background2"] = wb2; ρσ_d["--calibre-color-tree-highlight-item"] = tree; ρσ_d["--calibre-color-dialog-background"] = dlg; ρσ_d["--calibre-color-list-hover-background"] = lh_bg; ρσ_d["--calibre-color-list-hover-foreground"] = DARK; ρσ_d["--calibre-color-input-background"] = inp; ρσ_d["--calibre-color-bar-background"] = bar_bg; ρσ_d["--calibre-color-bar-foreground"] = DARK; ρσ_d["--calibre-color-button-start"] = btn_s; ρσ_d["--calibre-color-button-end"] = btn_e; return ρσ_d; }).call(this); }; if (!light_mode_primary_tints.__argnames__) Object.defineProperties(light_mode_primary_tints, { __argnames__ : {value: ["primary_rgb"]}, __module__ : {value: "book_list.theme"} }); function apply_theme_variables(variables) { var s, k; s = document.documentElement.style; var ρσ_Iter35 = Object.keys(variables); ρσ_Iter35 = ((typeof ρσ_Iter35[Symbol.iterator] === "function") ? (ρσ_Iter35 instanceof Map ? ρσ_Iter35.keys() : ρσ_Iter35) : Object.keys(ρσ_Iter35)); for (var ρσ_Index35 of ρσ_Iter35) { k = ρσ_Index35; s.setProperty(k, variables[(typeof k === "number" && k < 0) ? variables.length + k : k]); } get_color_as_rgba.cache = Object.create(null); cached_color_to_rgba.cache = Object.create(null); }; if (!apply_theme_variables.__argnames__) Object.defineProperties(apply_theme_variables, { __argnames__ : {value: ["variables"]}, __module__ : {value: "book_list.theme"} }); DEFAULT_COLORS = (function(){ var ρσ_d = Object.create(null); ρσ_d["window-background"] = c(LIGHT, DT_DARK); ρσ_d["window-background2"] = c(LIGHT_DARKER, DT_DARK_LIGHTER); ρσ_d["window-foreground"] = c(DARK, DT_LIGHT); ρσ_d["window-error-foreground"] = c("red", "#C40233"); ρσ_d["window-hover-foreground"] = c("red", "#C40233"); ρσ_d["link-foreground"] = c("blue", "#6cb4ee"); ρσ_d["faded-text"] = c("#666", "#7f7f7f"); ρσ_d["border"] = c("rgba(0,0,0,0.12)", "rgba(255,255,255,0.12)"); ρσ_d["border-subtle"] = c("rgba(0,0,0,0.08)", "rgba(255,255,255,0.08)"); ρσ_d["scrollbar-thumb"] = c("rgba(0,0,0,0.26)", "rgba(255,255,255,0.34)"); ρσ_d["scrollbar-thumb-hover"] = c("rgba(0,0,0,0.38)", "rgba(255,255,255,0.48)"); ρσ_d["surface-1"] = c(hex_as_rgba(LIGHT, "0.08"), hex_as_rgba(DT_DARK, "0.08")); ρσ_d["surface-2"] = c(hex_as_rgba(LIGHT, "0.04"), hex_as_rgba(DT_DARK, "0.04")); ρσ_d["surface-3"] = c(hex_as_rgba(LIGHT, "0.02"), hex_as_rgba(DT_DARK, "0.02")); ρσ_d["bar-background"] = c(DARK, DT_DARK_LIGHTER); ρσ_d["bar-foreground"] = c(LIGHT, DT_DARK_LIGTHER_CONTRAST); ρσ_d["bar-highlight"] = c("yellow"); ρσ_d["heart"] = c("#B92111"); ρσ_d["list-hover-background"] = c(DARK, DT_DARK_LIGHTER); ρσ_d["list-hover-foreground"] = c(LIGHT, DT_DARK_LIGTHER_CONTRAST); ρσ_d["tree-highlight-item"] = c(LIGHT_DARKER, DT_DARK_LIGHTER); ρσ_d["button-start"] = c(DARK, DT_LIGHT); ρσ_d["button-end"] = c("#49423B", "#666"); ρσ_d["button-text"] = c(LIGHT, DT_DARK); ρσ_d["dialog-background"] = c(LIGHT, DT_DARK); ρσ_d["dialog-background-image"] = c("none", "none"); ρσ_d["dialog-foreground"] = c(DARK, DT_LIGHT); ρσ_d["input-background"] = c("field", DT_DARK_DARKER); ρσ_d["input-foreground"] = c("fieldtext", DT_LIGHT); ρσ_d["input-focus-outline-color"] = c("#4D90FE", DT_LIGHT); return ρσ_d; }).call(this); DEFAULT_SIZES = (function(){ var ρσ_d = Object.create(null); ρσ_d["title"] = "1.4rem"; ρσ_d["item-list-title"] = "1.1rem"; ρσ_d["item-list-subtitle"] = "0.8rem"; return ρσ_d; }).call(this); DEFAULT_FONTS = (function(){ var ρσ_d = Object.create(null); ρσ_d["main"] = "sans-serif"; return ρσ_d; }).call(this); function theme_variables(is_dark_theme, primary_color) { var attr, default_colors, rgb, ρσ_unpack, r, g, b, ans, k, tints; attr = (is_dark_theme) ? "dark" : "light"; default_colors = all_settings.ui_highlight_colors.default; if (!primary_color) { primary_color = (is_dark_theme) ? default_colors.dark : default_colors.light; } if (!primary_color.startswith("#")) { primary_color = "#" + primary_color; } rgb = parse_hex_color(primary_color); if (!rgb) { primary_color = (is_dark_theme) ? default_colors.dark : default_colors.light; rgb = parse_hex_color(primary_color); } ρσ_unpack = rgb; ρσ_unpack = ρσ_unpack_asarray(3, ρσ_unpack); r = ρσ_unpack[0]; g = ρσ_unpack[1]; b = ρσ_unpack[2]; ans = (function(){ var ρσ_d = Object.create(null); ρσ_d["--calibre-color-primary"] = primary_color; ρσ_d["--calibre-color-primary-light"] = "rgba(" + ρσ_str.format("{}", r) + "," + ρσ_str.format("{}", g) + "," + ρσ_str.format("{}", b) + ",0.18)"; ρσ_d["--calibre-color-primary-light-2"] = "rgba(" + ρσ_str.format("{}", r) + "," + ρσ_str.format("{}", g) + "," + ρσ_str.format("{}", b) + ",0.28)"; return ρσ_d; }).call(this); var ρσ_Iter36 = DEFAULT_COLORS; ρσ_Iter36 = ((typeof ρσ_Iter36[Symbol.iterator] === "function") ? (ρσ_Iter36 instanceof Map ? ρσ_Iter36.keys() : ρσ_Iter36) : Object.keys(ρσ_Iter36)); for (var ρσ_Index36 of ρσ_Iter36) { k = ρσ_Index36; ans[ρσ_bound_index("--calibre-color-" + k, ans)] = (ρσ_expr_temp = DEFAULT_COLORS[(typeof k === "number" && k < 0) ? DEFAULT_COLORS.length + k : k])[(typeof attr === "number" && attr < 0) ? ρσ_expr_temp.length + attr : attr]; } if (!is_dark_theme) { tints = light_mode_primary_tints(rgb); var ρσ_Iter37 = Object.keys(tints); ρσ_Iter37 = ((typeof ρσ_Iter37[Symbol.iterator] === "function") ? (ρσ_Iter37 instanceof Map ? ρσ_Iter37.keys() : ρσ_Iter37) : Object.keys(ρσ_Iter37)); for (var ρσ_Index37 of ρσ_Iter37) { k = ρσ_Index37; ans[(typeof k === "number" && k < 0) ? ans.length + k : k] = tints[(typeof k === "number" && k < 0) ? tints.length + k : k]; } } return ans; }; if (!theme_variables.__argnames__) Object.defineProperties(theme_variables, { __argnames__ : {value: ["is_dark_theme", "primary_color"]}, __module__ : {value: "book_list.theme"} }); function set_ui_colors(is_dark_theme, primary_color) { apply_theme_variables(theme_variables(is_dark_theme, primary_color)); document.documentElement.style.colorScheme = (is_dark_theme) ? "dark" : "light"; }; if (!set_ui_colors.__argnames__) Object.defineProperties(set_ui_colors, { __argnames__ : {value: ["is_dark_theme", "primary_color"]}, __module__ : {value: "book_list.theme"} }); function browser_in_dark_mode() { return window.matchMedia("(prefers-color-scheme: dark)").matches; }; if (!browser_in_dark_mode.__module__) Object.defineProperties(browser_in_dark_mode, { __module__ : {value: "book_list.theme"} }); function effective_book_list_is_dark() { var sd, pref; try { sd = get_session_data(); if (!sd) { return browser_in_dark_mode(); } pref = (sd.get("book_list_color_scheme", "auto") || "auto") + ""; } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; if (ρσ_Exception instanceof Error) { return browser_in_dark_mode(); } else { throw ρσ_Exception; } } if (pref === "dark") { return true; } if (pref === "light") { return false; } return browser_in_dark_mode(); }; if (!effective_book_list_is_dark.__module__) Object.defineProperties(effective_book_list_is_dark, { __module__ : {value: "book_list.theme"} }); function get_saved_color_settings() { var is_dark, sd, colors, primary_color, default_colors; is_dark = effective_book_list_is_dark(); try { sd = get_session_data(); } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; if (ρσ_Exception instanceof Error) { sd = null; } else { throw ρσ_Exception; } } colors = (sd) ? sd.get("ui_highlight_colors") : all_settings.ui_highlight_colors.default; primary_color = (is_dark) ? (typeof colors !== "undefined" && colors !== null ? colors : Object.create(null)).dark : (typeof colors !== "undefined" && colors !== null ? colors : Object.create(null)).light; if (!primary_color) { default_colors = all_settings.ui_highlight_colors.default; primary_color = (is_dark) ? default_colors.dark : default_colors.light; } return (function(){ var ρσ_d = Object.create(null); ρσ_d["primary_color"] = primary_color; ρσ_d["is_dark"] = is_dark; return ρσ_d; }).call(this); }; if (!get_saved_color_settings.__module__) Object.defineProperties(get_saved_color_settings, { __module__ : {value: "book_list.theme"} }); function color_scheme() { return (effective_book_list_is_dark()) ? "dark" : "light"; }; if (!color_scheme.__module__) Object.defineProperties(color_scheme, { __module__ : {value: "book_list.theme"} }); function css_for_variables() { var s, attr, ans, variables, k; s = get_saved_color_settings(); attr = (s.is_dark) ? "dark" : "light"; ans = []; variables = theme_variables(s.is_dark, s.primary_color); var ρσ_Iter38 = Object.keys(variables); ρσ_Iter38 = ((typeof ρσ_Iter38[Symbol.iterator] === "function") ? (ρσ_Iter38 instanceof Map ? ρσ_Iter38.keys() : ρσ_Iter38) : Object.keys(ρσ_Iter38)); for (var ρσ_Index38 of ρσ_Iter38) { k = ρσ_Index38; ans.push("" + ρσ_str.format("{}", k) + ": " + ρσ_str.format("{}", variables[(typeof k === "number" && k < 0) ? variables.length + k : k]) + ";"); } return ":root { color-scheme: " + ρσ_str.format("{}", attr) + "; " + ans.join("\n") + "}\n\n"; }; if (!css_for_variables.__module__) Object.defineProperties(css_for_variables, { __module__ : {value: "book_list.theme"} }); function get_color(name) { return "var(--calibre-color-" + ρσ_str.format("{}", name) + ")"; }; if (!get_color.__argnames__) Object.defineProperties(get_color, { __argnames__ : {value: ["name"]}, __module__ : {value: "book_list.theme"} }); function color_to_rgba(color) { var cvs, ctx; cvs = document.createElement("canvas"); cvs.height = 1; cvs.width = 1; if (color.startsWith("var(")) { color = window.getComputedStyle(document.documentElement).getPropertyValue(color.slice(4, -1)); } ctx = cvs.getContext("2d"); ctx.fillStyle = color; ctx.fillRect(0, 0, 1, 1); return ctx.getImageData(0, 0, 1, 1).data; }; if (!color_to_rgba.__argnames__) Object.defineProperties(color_to_rgba, { __argnames__ : {value: ["color"]}, __module__ : {value: "book_list.theme"} }); function cached_color_to_rgba(color) { var cache; cache = cached_color_to_rgba.cache; if (!cache[(typeof color === "number" && color < 0) ? cache.length + color : color]) { cache[(typeof color === "number" && color < 0) ? cache.length + color : color] = color_to_rgba(color); } return cache[(typeof color === "number" && color < 0) ? cache.length + color : color]; }; if (!cached_color_to_rgba.__argnames__) Object.defineProperties(cached_color_to_rgba, { __argnames__ : {value: ["color"]}, __module__ : {value: "book_list.theme"} }); cached_color_to_rgba.cache = Object.create(null); function get_color_as_rgba(name) { var cache; cache = get_color_as_rgba.cache; if (!cache[(typeof name === "number" && name < 0) ? cache.length + name : name]) { cache[(typeof name === "number" && name < 0) ? cache.length + name : name] = color_to_rgba(get_color(name)); } return cache[(typeof name === "number" && name < 0) ? cache.length + name : name]; }; if (!get_color_as_rgba.__argnames__) Object.defineProperties(get_color_as_rgba, { __argnames__ : {value: ["name"]}, __module__ : {value: "book_list.theme"} }); get_color_as_rgba.cache = Object.create(null); function get_font_size(name) { return DEFAULT_SIZES[(typeof name === "number" && name < 0) ? DEFAULT_SIZES.length + name : name]; }; if (!get_font_size.__argnames__) Object.defineProperties(get_font_size, { __argnames__ : {value: ["name"]}, __module__ : {value: "book_list.theme"} }); function get_font_family(name) { name = name || "main"; return DEFAULT_FONTS[(typeof name === "number" && name < 0) ? DEFAULT_FONTS.length + name : name]; }; if (!get_font_family.__argnames__) Object.defineProperties(get_font_family, { __argnames__ : {value: ["name"]}, __module__ : {value: "book_list.theme"} }); ρσ_modules["book_list.theme"].DARK = DARK; ρσ_modules["book_list.theme"].LIGHT = LIGHT; ρσ_modules["book_list.theme"].LIGHT_DARKER = LIGHT_DARKER; ρσ_modules["book_list.theme"].DT_DARK = DT_DARK; ρσ_modules["book_list.theme"].DT_DARK_DARKER = DT_DARK_DARKER; ρσ_modules["book_list.theme"].DT_DARK_LIGHTER = DT_DARK_LIGHTER; ρσ_modules["book_list.theme"].DT_DARK_LIGTHER_CONTRAST = DT_DARK_LIGTHER_CONTRAST; ρσ_modules["book_list.theme"].DT_LIGHT = DT_LIGHT; ρσ_modules["book_list.theme"].DEFAULT_COLORS = DEFAULT_COLORS; ρσ_modules["book_list.theme"].DEFAULT_SIZES = DEFAULT_SIZES; ρσ_modules["book_list.theme"].DEFAULT_FONTS = DEFAULT_FONTS; ρσ_modules["book_list.theme"].c = c; ρσ_modules["book_list.theme"]._byte = _byte; ρσ_modules["book_list.theme"].parse_hex_color = parse_hex_color; ρσ_modules["book_list.theme"].hex_as_rgba = hex_as_rgba; ρσ_modules["book_list.theme"].mix_rgb_channel = mix_rgb_channel; ρσ_modules["book_list.theme"].mix_rgb = mix_rgb; ρσ_modules["book_list.theme"].rgb_to_hex = rgb_to_hex; ρσ_modules["book_list.theme"].light_mode_primary_tints = light_mode_primary_tints; ρσ_modules["book_list.theme"].apply_theme_variables = apply_theme_variables; ρσ_modules["book_list.theme"].theme_variables = theme_variables; ρσ_modules["book_list.theme"].set_ui_colors = set_ui_colors; ρσ_modules["book_list.theme"].browser_in_dark_mode = browser_in_dark_mode; ρσ_modules["book_list.theme"].effective_book_list_is_dark = effective_book_list_is_dark; ρσ_modules["book_list.theme"].get_saved_color_settings = get_saved_color_settings; ρσ_modules["book_list.theme"].color_scheme = color_scheme; ρσ_modules["book_list.theme"].css_for_variables = css_for_variables; ρσ_modules["book_list.theme"].get_color = get_color; ρσ_modules["book_list.theme"].color_to_rgba = color_to_rgba; ρσ_modules["book_list.theme"].cached_color_to_rgba = cached_color_to_rgba; ρσ_modules["book_list.theme"].get_color_as_rgba = get_color_as_rgba; ρσ_modules["book_list.theme"].get_font_size = get_font_size; ρσ_modules["book_list.theme"].get_font_family = get_font_family; })(); (function(){ var __name__ = "utils"; var is_ios, ios_major_version, v, copy_hash, _roman, _data_ns; var hexlify = ρσ_modules.encodings.hexlify; var encode_query = ρσ_modules.ajax.encode_query; var get_font_family = ρσ_modules["book_list.theme"].get_font_family; is_ios = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform); ios_major_version = 0; if (!is_ios && !!navigator.platform && (typeof window !== "undefined" && window !== null) && window.navigator.platform === "MacIntel" && window.navigator.maxTouchPoints > 1) { is_ios = true; } if (is_ios) { v = navigator.appVersion.match(/OS (\d+)/); if (v && v[1]) { ios_major_version = parseInt(v[1], 10) || 0; } } function default_context_menu_should_be_allowed(evt) { if (evt.target && evt.target.tagName && ρσ_in(evt.target.tagName.toLowerCase(), ["input", "textarea"])) { return true; } return false; }; if (!default_context_menu_should_be_allowed.__argnames__) Object.defineProperties(default_context_menu_should_be_allowed, { __argnames__ : {value: ["evt"]}, __module__ : {value: "utils"} }); function debounce() { var func = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var wait = ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[1]; var immediate = (arguments[2] === undefined || ( 2 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? debounce.__defaults__.immediate : arguments[2]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "immediate")){ immediate = ρσ_kwargs_obj.immediate; } var timeout; timeout = null; return (function() { var ρσ_anonfunc = function debounce_inner() { var ρσ_unpack, context, args, call_now; ρσ_unpack = [this, arguments]; context = ρσ_unpack[0]; args = ρσ_unpack[1]; function later() { timeout = null; if (!immediate) { func.apply(context, args); } }; if (!later.__module__) Object.defineProperties(later, { __module__ : {value: "utils"} }); call_now = immediate && !timeout; window.clearTimeout(timeout); timeout = window.setTimeout(later, wait); if (call_now) { func.apply(context, args); } }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "utils"} }); return ρσ_anonfunc; })(); }; if (!debounce.__defaults__) Object.defineProperties(debounce, { __defaults__ : {value: {immediate:false}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["func", "wait", "immediate"]}, __module__ : {value: "utils"} }); if (Object.assign) { copy_hash = (function() { var ρσ_anonfunc = function (obj) { return Object.assign(Object.create(null), obj); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["obj"]}, __module__ : {value: "utils"} }); return ρσ_anonfunc; })(); } else { copy_hash = (function() { var ρσ_anonfunc = function (obj) { return (function() { var ρσ_Iter = Object.keys(obj), ρσ_Result = Object.create(null), k; ρσ_Iter = ((typeof ρσ_Iter[Symbol.iterator] === "function") ? (ρσ_Iter instanceof Map ? ρσ_Iter.keys() : ρσ_Iter) : Object.keys(ρσ_Iter)); for (var ρσ_Index of ρσ_Iter) { k = ρσ_Index; ρσ_Result[k] = (obj[(typeof k === "number" && k < 0) ? obj.length + k : k]); } return ρσ_Result; })(); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["obj"]}, __module__ : {value: "utils"} }); return ρσ_anonfunc; })(); } function parse_url_params() { var url = (arguments[0] === undefined || ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? parse_url_params.__defaults__.url : arguments[0]; var allow_multiple = (arguments[1] === undefined || ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? parse_url_params.__defaults__.allow_multiple : arguments[1]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "url")){ url = ρσ_kwargs_obj.url; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "allow_multiple")){ allow_multiple = ρσ_kwargs_obj.allow_multiple; } var cache, qs, ans, q, pairs, ρσ_unpack, key, val, pair; cache = parse_url_params.cache; url = url || window.location.href; if (cache[(typeof url === "number" && url < 0) ? cache.length + url : url]) { return copy_hash((ρσ_expr_temp = parse_url_params.cache)[(typeof url === "number" && url < 0) ? ρσ_expr_temp.length + url : url]); } qs = url.indexOf("#"); ans = Object.create(null); if (qs < 0) { cache[(typeof url === "number" && url < 0) ? cache.length + url : url] = ans; return copy_hash(ans); } q = url.slice(qs + 1, url.length + 1); if (!q) { cache[(typeof url === "number" && url < 0) ? cache.length + url : url] = ans; return copy_hash(ans); } pairs = q.replace(/\+/g, " ").split("&"); var ρσ_Iter39 = pairs; ρσ_Iter39 = ((typeof ρσ_Iter39[Symbol.iterator] === "function") ? (ρσ_Iter39 instanceof Map ? ρσ_Iter39.keys() : ρσ_Iter39) : Object.keys(ρσ_Iter39)); for (var ρσ_Index39 of ρσ_Iter39) { pair = ρσ_Index39; ρσ_unpack = ρσ_eslice(pair.partition("="), 2); ρσ_unpack = ρσ_unpack_asarray(2, ρσ_unpack); key = ρσ_unpack[0]; val = ρσ_unpack[1]; ρσ_unpack = [decodeURIComponent(key), decodeURIComponent(val)]; key = ρσ_unpack[0]; val = ρσ_unpack[1]; if (allow_multiple) { if (ans[(typeof key === "number" && key < 0) ? ans.length + key : key] === undefined) { ans[(typeof key === "number" && key < 0) ? ans.length + key : key] = []; } ans[(typeof key === "number" && key < 0) ? ans.length + key : key].append(val); } else { ans[(typeof key === "number" && key < 0) ? ans.length + key : key] = val; } } cache[(typeof url === "number" && url < 0) ? cache.length + url : url] = ans; return copy_hash(ans); }; if (!parse_url_params.__defaults__) Object.defineProperties(parse_url_params, { __defaults__ : {value: {url:null, allow_multiple:false}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["url", "allow_multiple"]}, __module__ : {value: "utils"} }); parse_url_params.cache = Object.create(null); function encode_query_with_path(query, path) { path = path || window.location.pathname; return path + encode_query(query, "#"); }; if (!encode_query_with_path.__argnames__) Object.defineProperties(encode_query_with_path, { __argnames__ : {value: ["query", "path"]}, __module__ : {value: "utils"} }); function full_screen_supported(elem) { elem = elem || document.documentElement; if (elem.requestFullScreen || elem.webkitRequestFullScreen || elem.mozRequestFullScreen) { return true; } return false; }; if (!full_screen_supported.__argnames__) Object.defineProperties(full_screen_supported, { __argnames__ : {value: ["elem"]}, __module__ : {value: "utils"} }); function request_full_screen(elem) { var options; elem = elem || document.documentElement; options = (function(){ var ρσ_d = Object.create(null); ρσ_d["navigationUI"] = "hide"; return ρσ_d; }).call(this); if (elem.requestFullScreen) { elem.requestFullScreen(options); } else if (elem.webkitRequestFullScreen) { elem.webkitRequestFullScreen(); } else if (elem.mozRequestFullScreen) { elem.mozRequestFullScreen(); } }; if (!request_full_screen.__argnames__) Object.defineProperties(request_full_screen, { __argnames__ : {value: ["elem"]}, __module__ : {value: "utils"} }); function full_screen_element() { return document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement; }; if (!full_screen_element.__module__) Object.defineProperties(full_screen_element, { __module__ : {value: "utils"} }); _roman = list(zip([ 1e3, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 ], [ "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" ])); function roman(num) { var result, ρσ_unpack, d, r; if (num <= 0 || num >= 4e3 || int(num) !== num) { return num + ""; } result = []; var ρσ_Iter40 = _roman; ρσ_Iter40 = ((typeof ρσ_Iter40[Symbol.iterator] === "function") ? (ρσ_Iter40 instanceof Map ? ρσ_Iter40.keys() : ρσ_Iter40) : Object.keys(ρσ_Iter40)); for (var ρσ_Index40 of ρσ_Iter40) { ρσ_unpack = ρσ_Index40; d = ρσ_unpack[0]; r = ρσ_unpack[1]; while (num >= d) { result.append(r); num -= d; } } return result.join(""); }; if (!roman.__argnames__) Object.defineProperties(roman, { __argnames__ : {value: ["num"]}, __module__ : {value: "utils"} }); function fmt_sidx() { var val = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var fmt = (arguments[1] === undefined || ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? fmt_sidx.__defaults__.fmt : arguments[1]; var use_roman = (arguments[2] === undefined || ( 2 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? fmt_sidx.__defaults__.use_roman : arguments[2]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "fmt")){ fmt = ρσ_kwargs_obj.fmt; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "use_roman")){ use_roman = ρσ_kwargs_obj.use_roman; } if (val === undefined || val === null || val === "") { return "1"; } if (int(val) === float(val)) { if (use_roman) { return roman(val); } return int(val) + ""; } return fmt.format(float(val)); }; if (!fmt_sidx.__defaults__) Object.defineProperties(fmt_sidx, { __defaults__ : {value: {fmt:"{:.2f}", use_roman:true}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["val", "fmt", "use_roman"]}, __module__ : {value: "utils"} }); function human_readable() { var size = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var sep = (arguments[1] === undefined || ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? human_readable.__defaults__.sep : arguments[1]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "sep")){ sep = ρσ_kwargs_obj.sep; } var i, suffix; if (size <= 0) { return "0" + ρσ_str.format("{}", sep) + "B"; } i = Math.floor(Math.log(size) / Math.log(1024)); size = (size / Math.pow(1024, i)).toFixed(1); if (size.endswith(".0")) { size = size.slice(0, -2); } suffix = (ρσ_expr_temp = [ "B", "KB", "MB", "GB", "TB", "PB", "EB" ])[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i]; return size + sep + suffix; }; if (!human_readable.__defaults__) Object.defineProperties(human_readable, { __defaults__ : {value: {sep:" "}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["size", "sep"]}, __module__ : {value: "utils"} }); function document_height() { var html; html = document.documentElement; return max(document.body.scrollHeight, document.body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight); }; if (!document_height.__module__) Object.defineProperties(document_height, { __module__ : {value: "utils"} }); function document_width() { var html; html = document.documentElement; return max(document.body.scrollWidth, document.body.offsetWidth, html.clientWidth, html.scrollWidth, html.offsetWidth); }; if (!document_width.__module__) Object.defineProperties(document_width, { __module__ : {value: "utils"} }); _data_ns = null; function data_ns(name) { var rand; if (_data_ns === null) { rand = new Uint8Array(12); window.crypto.getRandomValues(rand); _data_ns = "data-" + hexlify(rand) + "-"; } return _data_ns + name; }; if (!data_ns.__argnames__) Object.defineProperties(data_ns, { __argnames__ : {value: ["name"]}, __module__ : {value: "utils"} }); function get_elem_data(elem, name, defval) { var ans; ans = elem.getAttribute(data_ns(name)); if (ans === null) { return (typeof defval !== "undefined" && defval !== null ? defval : null); } return JSON.parse(ans); }; if (!get_elem_data.__argnames__) Object.defineProperties(get_elem_data, { __argnames__ : {value: ["elem", "name", "defval"]}, __module__ : {value: "utils"} }); function set_elem_data(elem, name, val) { elem.setAttribute(data_ns(name), JSON.stringify(val)); }; if (!set_elem_data.__argnames__) Object.defineProperties(set_elem_data, { __argnames__ : {value: ["elem", "name", "val"]}, __module__ : {value: "utils"} }); function username_key(username) { return ((username) ? "u" : "n") + username; }; if (!username_key.__argnames__) Object.defineProperties(username_key, { __argnames__ : {value: ["username"]}, __module__ : {value: "utils"} }); function html_escape(text) { var repl; repl = (function(){ var ρσ_d = Object.create(null); ρσ_d["&"] = "&"; ρσ_d["\""] = """; ρσ_d["<"] = "<"; ρσ_d[">"] = ">"; return ρσ_d; }).call(this); return String.prototype.replace.call(text, /[&"<>]/g, (function() { var ρσ_anonfunc = function (c) { return repl[(typeof c === "number" && c < 0) ? repl.length + c : c]; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["c"]}, __module__ : {value: "utils"} }); return ρσ_anonfunc; })()); }; if (!html_escape.__argnames__) Object.defineProperties(html_escape, { __argnames__ : {value: ["text"]}, __module__ : {value: "utils"} }); function uniq(vals) { var ans, seen, x; ans = []; seen = Object.create(null); var ρσ_Iter41 = vals; ρσ_Iter41 = ((typeof ρσ_Iter41[Symbol.iterator] === "function") ? (ρσ_Iter41 instanceof Map ? ρσ_Iter41.keys() : ρσ_Iter41) : Object.keys(ρσ_Iter41)); for (var ρσ_Index41 of ρσ_Iter41) { x = ρσ_Index41; if (!seen[(typeof x === "number" && x < 0) ? seen.length + x : x]) { seen[(typeof x === "number" && x < 0) ? seen.length + x : x] = true; ans.push(x); } } return ans; }; if (!uniq.__argnames__) Object.defineProperties(uniq, { __argnames__ : {value: ["vals"]}, __module__ : {value: "utils"} }); function simple_markup(html) { var div; html = (html || "").replace(/\uffff/g, "").replace(/<\s*(\/?[a-zA-Z1-6]+)[^>]*>/g, (function() { var ρσ_anonfunc = function (match, tag) { var is_closing; tag = tag.toLowerCase(); is_closing = (tag[0] === "/") ? "/" : ""; if (is_closing) { tag = tag.slice(1); } if (simple_markup.allowed_tags.indexOf(tag) < 0) { tag = "span"; } return "\uffff" + ρσ_str.format("{}", is_closing) + "" + ρσ_str.format("{}", tag) + "\uffff"; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["match", "tag"]}, __module__ : {value: "utils"} }); return ρσ_anonfunc; })()); div = document.createElement("b"); div.textContent = html; html = div.innerHTML; return html.replace(/\uffff(\/?[a-z1-6]+)\uffff/g, "<$1>"); }; if (!simple_markup.__argnames__) Object.defineProperties(simple_markup, { __argnames__ : {value: ["html"]}, __module__ : {value: "utils"} }); simple_markup.allowed_tags = 'a|b|i|br|hr|h1|h2|h3|h4|h5|h6|div|em|strong|span'.split('|'); function safe_set_inner_html(elem, html) { elem.innerHTML = simple_markup(html); return elem; }; if (!safe_set_inner_html.__argnames__) Object.defineProperties(safe_set_inner_html, { __argnames__ : {value: ["elem", "html"]}, __module__ : {value: "utils"} }); function sandboxed_html(html, style, sandbox) { var ans, css, final_html; ans = document.createElement("iframe"); ans.setAttribute("sandbox", sandbox || ""); ans.setAttribute("seamless", ""); ans.style.width = "100%"; html = html || ""; css = "html, body { margin: 0; padding: 0; font-family: __FONT__ } p:first-child { margin-top: 0; padding-top: 0; -webkit-margin-before: 0 }".replace("__FONT__", get_font_family()); css += style || ""; final_html = "" + ρσ_str.format("{}", html) + ""; ans.srcdoc = final_html; return ans; }; if (!sandboxed_html.__argnames__) Object.defineProperties(sandboxed_html, { __argnames__ : {value: ["html", "style", "sandbox"]}, __module__ : {value: "utils"} }); ρσ_modules.utils.is_ios = is_ios; ρσ_modules.utils.ios_major_version = ios_major_version; ρσ_modules.utils.v = v; ρσ_modules.utils.copy_hash = copy_hash; ρσ_modules.utils._roman = _roman; ρσ_modules.utils._data_ns = _data_ns; ρσ_modules.utils.default_context_menu_should_be_allowed = default_context_menu_should_be_allowed; ρσ_modules.utils.debounce = debounce; ρσ_modules.utils.parse_url_params = parse_url_params; ρσ_modules.utils.encode_query_with_path = encode_query_with_path; ρσ_modules.utils.full_screen_supported = full_screen_supported; ρσ_modules.utils.request_full_screen = request_full_screen; ρσ_modules.utils.full_screen_element = full_screen_element; ρσ_modules.utils.roman = roman; ρσ_modules.utils.fmt_sidx = fmt_sidx; ρσ_modules.utils.human_readable = human_readable; ρσ_modules.utils.document_height = document_height; ρσ_modules.utils.document_width = document_width; ρσ_modules.utils.data_ns = data_ns; ρσ_modules.utils.get_elem_data = get_elem_data; ρσ_modules.utils.set_elem_data = set_elem_data; ρσ_modules.utils.username_key = username_key; ρσ_modules.utils.html_escape = html_escape; ρσ_modules.utils.uniq = uniq; ρσ_modules.utils.simple_markup = simple_markup; ρσ_modules.utils.safe_set_inner_html = safe_set_inner_html; ρσ_modules.utils.sandboxed_html = sandboxed_html; })(); (function(){ var __name__ = "book_list.library_data"; var load_status, library_data, BROWSE_VISIBLE_FIELDS_SETTING, thumbnail_cache; var absolute_path = ρσ_modules.ajax.absolute_path; var ajax = ρσ_modules.ajax.ajax; var LRUCache = ρσ_modules.lru_cache.LRUCache; var get_interface_data = ρσ_modules.session.get_interface_data; var parse_url_params = ρσ_modules.utils.parse_url_params; load_status = (function(){ var ρσ_d = Object.create(null); ρσ_d["loading"] = true; ρσ_d["ok"] = false; ρσ_d["error_html"] = null; ρσ_d["current_fetch"] = null; ρσ_d["http_error_code"] = 0; return ρσ_d; }).call(this); library_data = (function(){ var ρσ_d = Object.create(null); ρσ_d["metadata"] = Object.create(null); ρσ_d["previous_book_ids"] = []; ρσ_d["force_refresh"] = false; ρσ_d["bools_are_tristate"] = true; ρσ_d["field_names"] = Object.create(null); ρσ_d["available_browse_fields"] = []; ρσ_d["browse_fields"] = []; return ρσ_d; }).call(this); BROWSE_VISIBLE_FIELDS_SETTING = "browse_visible_fields"; function current_library_id() { var q; q = parse_url_params(); return q.library_id || get_interface_data().default_library_id; }; if (!current_library_id.__module__) Object.defineProperties(current_library_id, { __module__ : {value: "book_list.library_data"} }); function current_virtual_library() { var q; q = parse_url_params(); return q.vl || ""; }; if (!current_virtual_library.__module__) Object.defineProperties(current_virtual_library, { __module__ : {value: "book_list.library_data"} }); function loaded_books_query() { var sr, sort; sr = library_data.search_result; sort = null; if (sr) { sort = (function() { var ρσ_Iter = zip(sr.sort.split(","), sr.sort_order.split(",")), ρσ_Result = [], ρσ_unpack, s, o; ρσ_Iter = ((typeof ρσ_Iter[Symbol.iterator] === "function") ? (ρσ_Iter instanceof Map ? ρσ_Iter.keys() : ρσ_Iter) : Object.keys(ρσ_Iter)); for (var ρσ_Index of ρσ_Iter) { ρσ_unpack = ρσ_Index; s = ρσ_unpack[0]; o = ρσ_unpack[1]; ρσ_Result.push(s + "." + o); } ρσ_Result = ρσ_list_constructor(ρσ_Result); return ρσ_Result; })().join(","); } return (function(){ var ρσ_d = Object.create(null); ρσ_d["library_id"] = (sr) ? sr.library_id : null; ρσ_d["sort"] = sort; ρσ_d["search"] = (typeof sr !== "undefined" && sr !== null ? sr : Object.create(null)).query; ρσ_d["vl"] = (typeof sr !== "undefined" && sr !== null ? sr : Object.create(null)).vl; return ρσ_d; }).call(this); }; if (!loaded_books_query.__module__) Object.defineProperties(loaded_books_query, { __module__ : {value: "book_list.library_data"} }); function current_book_ids() { return library_data.previous_book_ids.concat(library_data.search_result.book_ids); }; if (!current_book_ids.__module__) Object.defineProperties(current_book_ids, { __module__ : {value: "book_list.library_data"} }); function remove_from_array(array, item) { var idx; while (true) { idx = array.indexOf(item); if (idx < 0) { break; } array.splice(idx, 1); } }; if (!remove_from_array.__argnames__) Object.defineProperties(remove_from_array, { __argnames__ : {value: ["array", "item"]}, __module__ : {value: "book_list.library_data"} }); function remove_book(book_id) { book_id = int(book_id); if (library_data.previous_book_ids) { remove_from_array(library_data.previous_book_ids, book_id); } if (ρσ_exists.d(library_data.search_result).book_ids) { remove_from_array(library_data.search_result.book_ids, book_id); } }; if (!remove_book.__argnames__) Object.defineProperties(remove_book, { __argnames__ : {value: ["book_id"]}, __module__ : {value: "book_list.library_data"} }); function book_after(book_id, delta) { var ids, idx, new_idx; if (!delta) { delta = 1; } ids = current_book_ids(); idx = ids.indexOf(int(book_id)); if (idx > -1) { new_idx = (idx + ids.length + delta) % ids.length; return ids[(typeof new_idx === "number" && new_idx < 0) ? ids.length + new_idx : new_idx]; } }; if (!book_after.__argnames__) Object.defineProperties(book_after, { __argnames__ : {value: ["book_id", "delta"]}, __module__ : {value: "book_list.library_data"} }); function thumbnail_url(book_id, width, height) { var query, prefix, lid; query = "sz=" + ρσ_str.format("{}", Math.ceil(width * window.devicePixelRatio)) + "x" + ρσ_str.format("{}", Math.ceil(height * window.devicePixelRatio)) + ""; prefix = "get/thumb/" + ρσ_str.format("{}", book_id) + ""; lid = loaded_books_query().library_id || current_library_id(); if (lid) { prefix += "/" + ρσ_str.format("{}", lid) + ""; } return absolute_path("" + ρσ_str.format("{}", prefix) + "?" + ρσ_str.format("{}", query) + ""); }; if (!thumbnail_url.__argnames__) Object.defineProperties(thumbnail_url, { __argnames__ : {value: ["book_id", "width", "height"]}, __module__ : {value: "book_list.library_data"} }); function cover_url(book_id) { var lid; lid = current_library_id(); return absolute_path("get/cover/" + ρσ_str.format("{}", book_id) + "/" + ρσ_str.format("{}", lid) + ""); }; if (!cover_url.__argnames__) Object.defineProperties(cover_url, { __argnames__ : {value: ["book_id"]}, __module__ : {value: "book_list.library_data"} }); function download_url(book_id, fmt, content_disposition) { var lid, ans; lid = current_library_id(); ans = absolute_path("get/" + ρσ_str.format("{}", fmt) + "/" + ρσ_str.format("{}", book_id) + "/" + ρσ_str.format("{}", lid) + ""); if (content_disposition) { ans += "?content_disposition=" + ρσ_str.format("{}", content_disposition) + ""; } return ans; }; if (!download_url.__argnames__) Object.defineProperties(download_url, { __argnames__ : {value: ["book_id", "fmt", "content_disposition"]}, __module__ : {value: "book_list.library_data"} }); function web_search_url(book_id, field, item_val) { return absolute_path("web-search/" + ρσ_str.format("{}", book_id) + "/" + ρσ_str.format("{}", encodeURIComponent(field)) + "/" + ρσ_str.format("{}", encodeURIComponent(item_val)) + "" + ("?library_id=" + ρσ_str.format("{}", encodeURIComponent(current_library_id())) + "")); }; if (!web_search_url.__argnames__) Object.defineProperties(web_search_url, { __argnames__ : {value: ["book_id", "field", "item_val"]}, __module__ : {value: "book_list.library_data"} }); function book_metadata(book_id) { return (ρσ_expr_temp = library_data.metadata)[(typeof book_id === "number" && book_id < 0) ? ρσ_expr_temp.length + book_id : book_id]; }; if (!book_metadata.__argnames__) Object.defineProperties(book_metadata, { __argnames__ : {value: ["book_id"]}, __module__ : {value: "book_list.library_data"} }); function set_book_metadata(book_id, value) { (ρσ_expr_temp = library_data.metadata)[(typeof book_id === "number" && book_id < 0) ? ρσ_expr_temp.length + book_id : book_id] = value; }; if (!set_book_metadata.__argnames__) Object.defineProperties(set_book_metadata, { __argnames__ : {value: ["book_id", "value"]}, __module__ : {value: "book_list.library_data"} }); function force_refresh_on_next_load() { library_data.force_refresh = true; }; if (!force_refresh_on_next_load.__module__) Object.defineProperties(force_refresh_on_next_load, { __module__ : {value: "book_list.library_data"} }); function ThumbnailCache() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); ThumbnailCache.prototype.__bind_methods__.call(this); ThumbnailCache.prototype.__init__.apply(this, arguments); } Object.defineProperty(ThumbnailCache.prototype, "__bind_methods__", {value: function () { this.get = ThumbnailCache.prototype.get.bind(this); this.load_finished = ThumbnailCache.prototype.load_finished.bind(this); }}); ThumbnailCache.prototype.__init__ = function __init__() { var self = this; var size = (arguments[0] === undefined || ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? __init__.__defaults__.size : arguments[0]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "size")){ size = ρσ_kwargs_obj.size; } self.cache = new LRUCache(size); }; if (!ThumbnailCache.prototype.__init__.__defaults__) Object.defineProperties(ThumbnailCache.prototype.__init__, { __defaults__ : {value: {size:256}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["size"]}, __module__ : {value: "book_list.library_data"} }); ThumbnailCache.__argnames__ = ThumbnailCache.prototype.__init__.__argnames__; ThumbnailCache.__handles_kwarg_interpolation__ = ThumbnailCache.prototype.__init__.__handles_kwarg_interpolation__; ThumbnailCache.prototype.get = function get(book_id, width, height, callback) { var self = this; var url, item, img; url = thumbnail_url(book_id, width, height); item = self.cache.get(url); if (!item) { img = new Image; item = (function(){ var ρσ_d = Object.create(null); ρσ_d["img"] = img; ρσ_d["load_type"] = null; ρσ_d["callbacks"] = [ callback ]; return ρσ_d; }).call(this); img.onerror = self.load_finished.bind(null, item, "error"); img.onload = self.load_finished.bind(null, item, "load"); img.onabort = self.load_finished.bind(null, item, "abort"); img.dataset.bookId = book_id + ""; img.src = url; self.cache.set(url, item); return img; } if (item.load_type === null) { if (item.callbacks.indexOf(callback) < 0) { item.callbacks.push(callback); } } else { callback(item.img, item.load_type); } return item.img; }; if (!ThumbnailCache.prototype.get.__argnames__) Object.defineProperties(ThumbnailCache.prototype.get, { __argnames__ : {value: ["book_id", "width", "height", "callback"]}, __module__ : {value: "book_list.library_data"} }); ThumbnailCache.prototype.load_finished = function load_finished(item, load_type) { var self = this; var img, callback; item.load_type = load_type; img = item.img; img.onload = img.onerror = img.onabort = null; var ρσ_Iter42 = item.callbacks; ρσ_Iter42 = ((typeof ρσ_Iter42[Symbol.iterator] === "function") ? (ρσ_Iter42 instanceof Map ? ρσ_Iter42.keys() : ρσ_Iter42) : Object.keys(ρσ_Iter42)); for (var ρσ_Index42 of ρσ_Iter42) { callback = ρσ_Index42; callback(img, load_type); } }; if (!ThumbnailCache.prototype.load_finished.__argnames__) Object.defineProperties(ThumbnailCache.prototype.load_finished, { __argnames__ : {value: ["item", "load_type"]}, __module__ : {value: "book_list.library_data"} }); ThumbnailCache.prototype.__repr__ = function __repr__ () { return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; ThumbnailCache.prototype.__str__ = function __str__ () { return this.__repr__(); }; Object.defineProperty(ThumbnailCache.prototype, "__bases__", {value: []}); thumbnail_cache = new ThumbnailCache; function sync_library_books(library_id, to_sync, callback) { var url, which, lrmap, ρσ_unpack, book_id, fmt, key, last_read; url = "book-get-annotations/" + ρσ_str.format("{}", library_id) + "/"; which = []; lrmap = Object.create(null); var ρσ_Iter43 = to_sync; ρσ_Iter43 = ((typeof ρσ_Iter43[Symbol.iterator] === "function") ? (ρσ_Iter43 instanceof Map ? ρσ_Iter43.keys() : ρσ_Iter43) : Object.keys(ρσ_Iter43)); for (var ρσ_Index43 of ρσ_Iter43) { ρσ_unpack = ρσ_Index43; key = ρσ_unpack[0]; last_read = ρσ_unpack[1]; ρσ_unpack = key; ρσ_unpack = ρσ_unpack_asarray(3, ρσ_unpack); library_id = ρσ_unpack[0]; book_id = ρσ_unpack[1]; fmt = ρσ_unpack[2]; fmt = fmt.upper(); which.push("" + ρσ_str.format("{}", book_id) + "-" + ρσ_str.format("{}", fmt) + ""); lrmap[ρσ_bound_index("" + ρσ_str.format("{}", book_id) + ":" + ρσ_str.format("{}", fmt) + "", lrmap)] = last_read; } url += which.join("_"); ajax(url, callback.bind(null, library_id, lrmap)).send(); }; if (!sync_library_books.__argnames__) Object.defineProperties(sync_library_books, { __argnames__ : {value: ["library_id", "to_sync", "callback"]}, __module__ : {value: "book_list.library_data"} }); ρσ_modules["book_list.library_data"].load_status = load_status; ρσ_modules["book_list.library_data"].library_data = library_data; ρσ_modules["book_list.library_data"].BROWSE_VISIBLE_FIELDS_SETTING = BROWSE_VISIBLE_FIELDS_SETTING; ρσ_modules["book_list.library_data"].thumbnail_cache = thumbnail_cache; ρσ_modules["book_list.library_data"].current_library_id = current_library_id; ρσ_modules["book_list.library_data"].current_virtual_library = current_virtual_library; ρσ_modules["book_list.library_data"].loaded_books_query = loaded_books_query; ρσ_modules["book_list.library_data"].current_book_ids = current_book_ids; ρσ_modules["book_list.library_data"].remove_from_array = remove_from_array; ρσ_modules["book_list.library_data"].remove_book = remove_book; ρσ_modules["book_list.library_data"].book_after = book_after; ρσ_modules["book_list.library_data"].thumbnail_url = thumbnail_url; ρσ_modules["book_list.library_data"].cover_url = cover_url; ρσ_modules["book_list.library_data"].download_url = download_url; ρσ_modules["book_list.library_data"].web_search_url = web_search_url; ρσ_modules["book_list.library_data"].book_metadata = book_metadata; ρσ_modules["book_list.library_data"].set_book_metadata = set_book_metadata; ρσ_modules["book_list.library_data"].force_refresh_on_next_load = force_refresh_on_next_load; ρσ_modules["book_list.library_data"].ThumbnailCache = ThumbnailCache; ρσ_modules["book_list.library_data"].sync_library_books = sync_library_books; })(); (function(){ var __name__ = "date"; var UNDEFINED_DATE_ISO, UNDEFINED_DATE, lcdata, supports_locales, fd_function_index; UNDEFINED_DATE_ISO = "0101-01-01T00:00:00+00:00"; UNDEFINED_DATE = new Date(UNDEFINED_DATE_ISO); function is_date_undefined(date) { var ρσ_unpack, dy, uy; ρσ_unpack = [date.getUTCFullYear(), UNDEFINED_DATE.getUTCFullYear()]; dy = ρσ_unpack[0]; uy = ρσ_unpack[1]; return dy < uy || dy === uy && date.getUTCMonth() === UNDEFINED_DATE.getUTCMonth() && date.getUTCDate() <= UNDEFINED_DATE.getUTCDate() + 1; }; if (!is_date_undefined.__argnames__) Object.defineProperties(is_date_undefined, { __argnames__ : {value: ["date"]}, __module__ : {value: "date"} }); lcdata = (function(){ var ρσ_d = Object.create(null); ρσ_d["abday"] = [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ]; ρσ_d["abmon"] = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]; ρσ_d["day"] = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]; ρσ_d["mon"] = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]; return ρσ_d; }).call(this); supports_locales = false; try { (new Date).toLocaleString("dfkjghdfkgj"); } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; if (ρσ_Exception instanceof RangeError) { supports_locales = true; } else { } } function fmt_date_pat() { var ans; ans = fmt_date_pat.ans; if (!(typeof ans !== "undefined" && ans !== null)) { ans = fmt_date_pat.ans = /(s{1,2})|(m{1,2})|(h{1,2})|(H{1,2})|(zzz)|(z)|(ap)|(AP)|(Ap)|(aP)|(a)|(A)|(t)|(d{1,4}|M{1,4}|(?:yyyy|yy))/g; } return ans; }; if (!fmt_date_pat.__module__) Object.defineProperties(fmt_date_pat, { __module__ : {value: "date"} }); function fd_format_hour(dt, ampm, hr, as_utc) { var h; h = (as_utc) ? dt.getUTCHours() : dt.getHours(); if (ampm) { h %= 12; if (h === 0) { h = 12; } } return (hr.length === 1) ? h.toString() : str.format("{:02d}", h); }; if (!fd_format_hour.__argnames__) Object.defineProperties(fd_format_hour, { __argnames__ : {value: ["dt", "ampm", "hr", "as_utc"]}, __module__ : {value: "date"} }); function fd_format_hour24(dt, ampm, hr, as_utc) { return fd_format_hour(dt, false, hr, as_utc); }; if (!fd_format_hour24.__argnames__) Object.defineProperties(fd_format_hour24, { __argnames__ : {value: ["dt", "ampm", "hr", "as_utc"]}, __module__ : {value: "date"} }); function fd_format_minute(dt, ampm, min, as_utc) { var m; m = (as_utc) ? dt.getUTCMinutes() : dt.getMinutes(); return (min.length === 1) ? m.toString() : str.format("{:02d}", m); }; if (!fd_format_minute.__argnames__) Object.defineProperties(fd_format_minute, { __argnames__ : {value: ["dt", "ampm", "min", "as_utc"]}, __module__ : {value: "date"} }); function fd_format_second(dt, ampm, min, as_utc) { var s; s = (as_utc) ? dt.getUTCSeconds() : dt.getSeconds(); return (min.length === 1) ? s.toString() : str.format("{:02d}", s); }; if (!fd_format_second.__argnames__) Object.defineProperties(fd_format_second, { __argnames__ : {value: ["dt", "ampm", "min", "as_utc"]}, __module__ : {value: "date"} }); function fd_format_ms(dt, ampm, min, as_utc) { var s; s = (as_utc) ? dt.getUTCMilliseconds() : dt.getSeconds(); return (min.length === 1) ? s.toString() : str.format("{:03d}", s); }; if (!fd_format_ms.__argnames__) Object.defineProperties(fd_format_ms, { __argnames__ : {value: ["dt", "ampm", "min", "as_utc"]}, __module__ : {value: "date"} }); function fd_format_timezone(dt, ampm, t, as_utc) { var short, full, idx; short = dt.toLocaleTimeString(); full = dt.toLocaleTimeString([], (function(){ var ρσ_d = Object.create(null); ρσ_d["timeZoneName"] = "long"; return ρσ_d; }).call(this)); idx = full.indexOf(short); if (idx > -1) { return full.slice(idx + short.length).strip(); } return window.Intl.DateTimeFormat().resolvedOptions().timeZone; }; if (!fd_format_timezone.__argnames__) Object.defineProperties(fd_format_timezone, { __argnames__ : {value: ["dt", "ampm", "t", "as_utc"]}, __module__ : {value: "date"} }); function get_ampm_text(which) { var ans, d, x; ans = get_ampm_text[(typeof which === "number" && which < 0) ? get_ampm_text.length + which : which]; if (!ans) { try { d = new Date; if (which === "am") { d.setHours(1, 0, 0, 0); } else { d.setHours(13, 0, 0, 0); } x = window.Intl.DateTimeFormat("default", (function(){ var ρσ_d = Object.create(null); ρσ_d["hour"] = "numeric"; ρσ_d["hour12"] = true; return ρσ_d; }).call(this)).format(d); ans = x.replace(/\d+/g, "").trim() || which.toUpperCase(); } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; { ans = which.toUpperCase(); } } get_ampm_text[(typeof which === "number" && which < 0) ? get_ampm_text.length + which : which] = ans; } return ans; }; if (!get_ampm_text.__argnames__) Object.defineProperties(get_ampm_text, { __argnames__ : {value: ["which"]}, __module__ : {value: "date"} }); function fd_format_ampm(dt, ampm, ap, as_utc) { var h, ans; h = (as_utc) ? dt.getUTCHours() : dt.getHours(); ans = (h < 12) ? "am" : "pm"; ans = get_ampm_text(ans); if (ans === "Ap" || ans === "aP") { return ans; } return (ap === "ap" || ap === "a") ? ans.toLowerCase() : ans.toUpperCase(); }; if (!fd_format_ampm.__argnames__) Object.defineProperties(fd_format_ampm, { __argnames__ : {value: ["dt", "ampm", "ap", "as_utc"]}, __module__ : {value: "date"} }); function fd_format_day(dt, ampm, dy, as_utc) { var d, options, w; d = (as_utc) ? dt.getUTCDate() : dt.getDate(); if (dy.length === 1) { return d.toString(); } if (dy.length === 2) { return str.format("{:02d}", d); } if (supports_locales) { options = (function(){ var ρσ_d = Object.create(null); ρσ_d["weekday"] = (dy.length === 3) ? "short" : "long"; return ρσ_d; }).call(this); if (as_utc) { options["timeZone"] = "UTC"; } return dt.toLocaleString(window.navigator.language, options); } w = (as_utc) ? dt.getUTCDay() : dt.getDay(); return (ρσ_expr_temp = lcdata[ρσ_bound_index((dy.length === 3) ? "abday" : "day", lcdata)])[ρσ_bound_index((w + 1) % 7, ρσ_expr_temp)]; }; if (!fd_format_day.__argnames__) Object.defineProperties(fd_format_day, { __argnames__ : {value: ["dt", "ampm", "dy", "as_utc"]}, __module__ : {value: "date"} }); function fd_format_month(dt, ampm, mo, as_utc) { var m, options; m = (as_utc) ? dt.getUTCMonth() : dt.getMonth(); if (mo.length === 1) { return (m + 1).toString(); } if (mo.length === 2) { return str.format("{:02d}", m + 1); } if (supports_locales) { options = (function(){ var ρσ_d = Object.create(null); ρσ_d["month"] = (ρσ_expr_temp = (function(){ var ρσ_d = Object.create(null); ρσ_d[1] = "numeric"; ρσ_d[2] = "2-digit"; ρσ_d[3] = "short"; ρσ_d[4] = "long"; return ρσ_d; }).call(this))[ρσ_bound_index(mo.length, ρσ_expr_temp)] || "long"; return ρσ_d; }).call(this); if (as_utc) { options["timeZone"] = "UTC"; } return dt.toLocaleString(window.navigator.language, options); } return (ρσ_expr_temp = lcdata[ρσ_bound_index((mo.length === 3) ? "abmon" : "mon", lcdata)])[(typeof m === "number" && m < 0) ? ρσ_expr_temp.length + m : m]; }; if (!fd_format_month.__argnames__) Object.defineProperties(fd_format_month, { __argnames__ : {value: ["dt", "ampm", "mo", "as_utc"]}, __module__ : {value: "date"} }); function fd_format_year(dt, ampm, yr, as_utc) { var y; y = (as_utc) ? dt.getUTCFullYear() : dt.getFullYear(); if (yr.length === 2) { return str.format("{:02d}", y % 100); } return str.format("{:04d}", y); }; if (!fd_format_year.__argnames__) Object.defineProperties(fd_format_year, { __argnames__ : {value: ["dt", "ampm", "yr", "as_utc"]}, __module__ : {value: "date"} }); fd_function_index = (function(){ var ρσ_d = Object.create(null); ρσ_d["d"] = fd_format_day; ρσ_d["M"] = fd_format_month; ρσ_d["y"] = fd_format_year; ρσ_d["h"] = fd_format_hour; ρσ_d["H"] = fd_format_hour24; ρσ_d["m"] = fd_format_minute; ρσ_d["s"] = fd_format_second; ρσ_d["a"] = fd_format_ampm; ρσ_d["A"] = fd_format_ampm; ρσ_d["ap"] = fd_format_ampm; ρσ_d["AP"] = fd_format_ampm; ρσ_d["Ap"] = fd_format_ampm; ρσ_d["aP"] = fd_format_ampm; ρσ_d["z"] = fd_format_ms; ρσ_d["t"] = fd_format_timezone; return ρσ_d; }).call(this); function am_pm_pat() { var ans; ans = am_pm_pat.ans; if (!(typeof ans !== "undefined" && ans !== null)) { ans = am_pm_pat.ans = /(ap)|(AP)|(Ap)|(aP)|(a)|(A)/; } return ans; }; if (!am_pm_pat.__module__) Object.defineProperties(am_pm_pat, { __module__ : {value: "date"} }); function as_iso(date) { var tzo, dif; tzo = -date.getTimezoneOffset(); dif = (tzo >= 0) ? "+" : "-"; function pad(num) { return ((num < 10) ? "0" : "") + num; }; if (!pad.__argnames__) Object.defineProperties(pad, { __argnames__ : {value: ["num"]}, __module__ : {value: "date"} }); return date.getFullYear() + "-" + pad(date.getMonth() + 1) + "-" + pad(date.getDate()) + " " + pad(date.getHours()) + ":" + pad(date.getMinutes()) + ":" + pad(date.getSeconds()) + dif + pad(Math.floor(Math.abs(tzo) / 60)) + ":" + pad(Math.abs(tzo) % 60); }; if (!as_iso.__argnames__) Object.defineProperties(as_iso, { __argnames__ : {value: ["date"]}, __module__ : {value: "date"} }); function format_date() { var date = (arguments[0] === undefined || ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? format_date.__defaults__.date : arguments[0]; var fmt = (arguments[1] === undefined || ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? format_date.__defaults__.fmt : arguments[1]; var as_utc = (arguments[2] === undefined || ( 2 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? format_date.__defaults__.as_utc : arguments[2]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "date")){ date = ρσ_kwargs_obj.date; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "fmt")){ fmt = ρσ_kwargs_obj.fmt; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "as_utc")){ as_utc = ρσ_kwargs_obj.as_utc; } var ampm; fmt = fmt || "dd MMM yyyy"; ampm = am_pm_pat().test(fmt); if (typeof date === "string") { date = new Date(date); } date = date || new Date; if (is_date_undefined(date)) { return ""; } if (fmt === "iso") { return as_iso(date); } return fmt.replace(fmt_date_pat(), (function() { var ρσ_anonfunc = function (match) { if (!match) { return ""; } try { return fd_function_index[ρσ_bound_index(match[0], fd_function_index)](date, ampm, match, as_utc); } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; if (ρσ_Exception instanceof Error) { print(str.format("Failed to format date with format: {} and match: {}", fmt, match)); return ""; } else { throw ρσ_Exception; } } }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["match"]}, __module__ : {value: "date"} }); return ρσ_anonfunc; })()); }; if (!format_date.__defaults__) Object.defineProperties(format_date, { __defaults__ : {value: {date:null, fmt:"dd MMM yyyy", as_utc:false}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["date", "fmt", "as_utc"]}, __module__ : {value: "date"} }); ρσ_modules.date.UNDEFINED_DATE_ISO = UNDEFINED_DATE_ISO; ρσ_modules.date.UNDEFINED_DATE = UNDEFINED_DATE; ρσ_modules.date.lcdata = lcdata; ρσ_modules.date.supports_locales = supports_locales; ρσ_modules.date.fd_function_index = fd_function_index; ρσ_modules.date.is_date_undefined = is_date_undefined; ρσ_modules.date.fmt_date_pat = fmt_date_pat; ρσ_modules.date.fd_format_hour = fd_format_hour; ρσ_modules.date.fd_format_hour24 = fd_format_hour24; ρσ_modules.date.fd_format_minute = fd_format_minute; ρσ_modules.date.fd_format_second = fd_format_second; ρσ_modules.date.fd_format_ms = fd_format_ms; ρσ_modules.date.fd_format_timezone = fd_format_timezone; ρσ_modules.date.get_ampm_text = get_ampm_text; ρσ_modules.date.fd_format_ampm = fd_format_ampm; ρσ_modules.date.fd_format_day = fd_format_day; ρσ_modules.date.fd_format_month = fd_format_month; ρσ_modules.date.fd_format_year = fd_format_year; ρσ_modules.date.am_pm_pat = am_pm_pat; ρσ_modules.date.as_iso = as_iso; ρσ_modules.date.format_date = format_date; })(); (function(){ var __name__ = "popups"; var MODAL_Z_INDEX, POPUP_Z_INDEX, popup_count, shown_popups, associated_widgets; var E = ρσ_modules.elementmaker.E; var get_color = ρσ_modules["book_list.theme"].get_color; var set_css = ρσ_modules.dom.set_css; var ensure_id = ρσ_modules.dom.ensure_id; var clear = ρσ_modules.dom.clear; var build_rule = ρσ_modules.dom.build_rule; var add_extra_css = ρσ_modules.dom.add_extra_css; MODAL_Z_INDEX = 1e3; POPUP_Z_INDEX = MODAL_Z_INDEX + 1; popup_count = 0; shown_popups = set(); associated_widgets = Object.create(null); function create_popup(parent, idprefix) { var pid, div; popup_count += 1; pid = (idprefix || "popup") + "-" + popup_count; div = ρσ_interpolate_kwargs.call(E, E.div, [ρσ_desugar_kwargs({id: pid, style: "display: none; position: fixed; z-index: {}".format(POPUP_Z_INDEX)})]); parent = parent || document.body; parent.appendChild(div); return div; }; if (!create_popup.__argnames__) Object.defineProperties(create_popup, { __argnames__ : {value: ["parent", "idprefix"]}, __module__ : {value: "popups"} }); function show_popup() { var popup_id = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var associated_widget_ids = (arguments[1] === undefined || ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? show_popup.__defaults__.associated_widget_ids : arguments[1]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "associated_widget_ids")){ associated_widget_ids = ρσ_kwargs_obj.associated_widget_ids; } var elem; elem = document.getElementById(popup_id); elem.style.display = "block"; shown_popups.add(popup_id); associated_widgets[(typeof popup_id === "number" && popup_id < 0) ? associated_widgets.length + popup_id : popup_id] = associated_widget_ids; }; if (!show_popup.__defaults__) Object.defineProperties(show_popup, { __defaults__ : {value: {associated_widget_ids:null}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["popup_id", "associated_widget_ids"]}, __module__ : {value: "popups"} }); function CompletionPopup() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); CompletionPopup.prototype.__bind_methods__.call(this); CompletionPopup.prototype.__init__.apply(this, arguments); } Object.defineProperty(CompletionPopup.prototype, "__bind_methods__", {value: function () { this.set_all_items = CompletionPopup.prototype.set_all_items.bind(this); this.add_associated_widget = CompletionPopup.prototype.add_associated_widget.bind(this); this.popup = CompletionPopup.prototype.popup.bind(this); this.show_at_widget = CompletionPopup.prototype.show_at_widget.bind(this); this.set_query = CompletionPopup.prototype.set_query.bind(this); this.hide = CompletionPopup.prototype.hide.bind(this); this.handle_keydown = CompletionPopup.prototype.handle_keydown.bind(this); this.move_highlight = CompletionPopup.prototype.move_highlight.bind(this); this._show_at = CompletionPopup.prototype._show_at.bind(this); this._apply_query = CompletionPopup.prototype._apply_query.bind(this); this._render_matches = CompletionPopup.prototype._render_matches.bind(this); this.onmouseenter = CompletionPopup.prototype.onmouseenter.bind(this); this.onclick = CompletionPopup.prototype.onclick.bind(this); }}); Object.defineProperties(CompletionPopup.prototype, { "container": { "enumerable": true, "get": function container() { var self = this; return document.getElementById(self.container_id); }, "set": function () { throw new AttributeError("can't set attribute") } }, "is_visible": { "enumerable": true, "get": function is_visible() { var self = this; return self.container.style.display !== "none"; }, "set": function () { throw new AttributeError("can't set attribute") } }, "current_item": { "enumerable": true, "get": function current_item() { var self = this; var c; c = self.container; return c.querySelector("div.{} > div.{}".format(self.CLASS, self.CURRENT_ITEM_CLASS)); }, "set": function () { throw new AttributeError("can't set attribute") } }, "current_text": { "enumerable": true, "get": function current_text() { var self = this; return ρσ_exists.d(self.current_item).textContent; }, "set": function () { throw new AttributeError("can't set attribute") } }, }); CompletionPopup.prototype.__init__ = function __init__() { var self = this; var parent = (arguments[0] === undefined || ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? __init__.__defaults__.parent : arguments[0]; var max_items = (arguments[1] === undefined || ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? __init__.__defaults__.max_items : arguments[1]; var onselect = (arguments[2] === undefined || ( 2 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? __init__.__defaults__.onselect : arguments[2]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "parent")){ parent = ρσ_kwargs_obj.parent; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "max_items")){ max_items = ρσ_kwargs_obj.max_items; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "onselect")){ onselect = ρσ_kwargs_obj.onselect; } var c, ρσ_unpack; self.max_items = max_items; c = create_popup(parent); ρσ_interpolate_kwargs.call(this, set_css, [c].concat([ρσ_desugar_kwargs({user_select: "none"})])); self.container_id = c.getAttribute("id"); self.onselect = onselect; self.items = []; self.matches = []; c.appendChild(ρσ_interpolate_kwargs.call(E, E.div, [ρσ_desugar_kwargs({class_: self.CLASS})])); self.associated_widget_ids = set(); ρσ_unpack = ["", false]; self.current_query = ρσ_unpack[0]; self.is_upwards = ρσ_unpack[1]; self.applied_query = self.current_query; }; if (!CompletionPopup.prototype.__init__.__defaults__) Object.defineProperties(CompletionPopup.prototype.__init__, { __defaults__ : {value: {parent:null, max_items:25, onselect:null}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["parent", "max_items", "onselect"]}, __module__ : {value: "popups"} }); CompletionPopup.__argnames__ = CompletionPopup.prototype.__init__.__argnames__; CompletionPopup.__handles_kwarg_interpolation__ = CompletionPopup.prototype.__init__.__handles_kwarg_interpolation__; CompletionPopup.prototype.set_all_items = function set_all_items(items) { var self = this; self.items = list(items); self.matches = []; self.applied_query = null; }; if (!CompletionPopup.prototype.set_all_items.__argnames__) Object.defineProperties(CompletionPopup.prototype.set_all_items, { __argnames__ : {value: ["items"]}, __module__ : {value: "popups"} }); CompletionPopup.prototype.add_associated_widget = function add_associated_widget(widget_or_id) { var self = this; if (typeof widget_or_id !== "string") { widget_or_id = ensure_id(widget_or_id); } self.associated_widget_ids.add(widget_or_id); }; if (!CompletionPopup.prototype.add_associated_widget.__argnames__) Object.defineProperties(CompletionPopup.prototype.add_associated_widget, { __argnames__ : {value: ["widget_or_id"]}, __module__ : {value: "popups"} }); CompletionPopup.prototype.popup = function popup(widget) { var self = this; if (!self.is_visible) { if (self.applied_query !== self.current_query) { self._apply_query(); } if (self.matches.length) { self.show_at_widget(widget); } } }; if (!CompletionPopup.prototype.popup.__argnames__) Object.defineProperties(CompletionPopup.prototype.popup, { __argnames__ : {value: ["widget"]}, __module__ : {value: "popups"} }); CompletionPopup.prototype.show_at_widget = function show_at_widget(w) { var self = this; var br, ρσ_unpack, y, upwards; br = w.getBoundingClientRect(); if (br.top > window.innerHeight - br.bottom) { ρσ_unpack = [br.top, true]; y = ρσ_unpack[0]; upwards = ρσ_unpack[1]; } else { ρσ_unpack = [br.bottom, false]; y = ρσ_unpack[0]; upwards = ρσ_unpack[1]; } self._show_at(br.left, y, br.width, upwards); }; if (!CompletionPopup.prototype.show_at_widget.__argnames__) Object.defineProperties(CompletionPopup.prototype.show_at_widget, { __argnames__ : {value: ["w"]}, __module__ : {value: "popups"} }); CompletionPopup.prototype.set_query = function set_query(query) { var self = this; self.current_query = query; if (self.is_visible && self.applied_query !== self.current_query) { self._apply_query(); if (!self.matches.length) { self.hide(); } } }; if (!CompletionPopup.prototype.set_query.__argnames__) Object.defineProperties(CompletionPopup.prototype.set_query, { __argnames__ : {value: ["query"]}, __module__ : {value: "popups"} }); CompletionPopup.prototype.hide = function hide() { var self = this; var c; self.container.style.display = "none"; c = self.current_item; if (c) { c.classList.remove(self.CURRENT_ITEM_CLASS); } }; if (!CompletionPopup.prototype.hide.__module__) Object.defineProperties(CompletionPopup.prototype.hide, { __module__ : {value: "popups"} }); CompletionPopup.prototype.handle_keydown = function handle_keydown(event) { var self = this; var key; key = event.key; if (key === "Escape" || key === "Esc") { self.hide(); return true; } if (key === "ArrowUp") { self.move_highlight(true); return true; } if (key === "ArrowDown") { self.move_highlight(false); return true; } return false; }; if (!CompletionPopup.prototype.handle_keydown.__argnames__) Object.defineProperties(CompletionPopup.prototype.handle_keydown, { __argnames__ : {value: ["event"]}, __module__ : {value: "popups"} }); CompletionPopup.prototype.move_highlight = function move_highlight() { var self = this; var up = (arguments[0] === undefined || ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? move_highlight.__defaults__.up : arguments[0]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "up")){ up = ρσ_kwargs_obj.up; } var ans, div, c; if (up === null) { up = self.is_upwards; } ans = null; div = self.current_item; if (div) { div.classList.remove(self.CURRENT_ITEM_CLASS); ans = (up) ? div.previousSibling : div.nextSibling; } if (!ans) { c = self.container.firstChild; ans = (up) ? c.lastChild : c.firstChild; } if (ans) { ans.classList.add(self.CURRENT_ITEM_CLASS); } }; if (!CompletionPopup.prototype.move_highlight.__defaults__) Object.defineProperties(CompletionPopup.prototype.move_highlight, { __defaults__ : {value: {up:null}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["up"]}, __module__ : {value: "popups"} }); CompletionPopup.prototype._show_at = function _show_at(x, y, width, upwards) { var self = this; var c, cs; self.is_upwards = upwards; c = self.container; cs = c.style; cs.left = x + "px"; cs.top = (upwards) ? "auto" : y + "px"; cs.bottom = (upwards) ? window.innerHeight - y + "px" : "auto"; cs.width = width + "px"; cs.maxHeight = ((upwards) ? y : window.innerHeight - y) - 10 + "px"; show_popup(self.container_id, self.associated_widget_ids); }; if (!CompletionPopup.prototype._show_at.__argnames__) Object.defineProperties(CompletionPopup.prototype._show_at, { __argnames__ : {value: ["x", "y", "width", "upwards"]}, __module__ : {value: "popups"} }); CompletionPopup.prototype._apply_query = function _apply_query() { var self = this; var q, i; q = self.current_query.toLowerCase(); self.matches.clear(); self.applied_query = self.current_query; if (!q) { self.matches = list(self.items.slice(0, self.max_items + 1)); } else { i = 0; while (self.matches.length < self.max_items && i < self.items.length) { if ((ρσ_expr_temp = self.items)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i].toLowerCase().startswith(q)) { self.matches.push((ρσ_expr_temp = self.items)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i]); } i += 1; } } self._render_matches(); }; if (!CompletionPopup.prototype._apply_query.__module__) Object.defineProperties(CompletionPopup.prototype._apply_query, { __module__ : {value: "popups"} }); CompletionPopup.prototype._render_matches = function _render_matches() { var self = this; var c, items, m; c = self.container; clear(c.firstChild); items = self.matches; if (self.is_upwards) { items = reversed(items); } var ρσ_Iter44 = items; ρσ_Iter44 = ((typeof ρσ_Iter44[Symbol.iterator] === "function") ? (ρσ_Iter44 instanceof Map ? ρσ_Iter44.keys() : ρσ_Iter44) : Object.keys(ρσ_Iter44)); for (var ρσ_Index44 of ρσ_Iter44) { m = ρσ_Index44; c.firstChild.appendChild(ρσ_interpolate_kwargs.call(E, E.div, [m].concat([ρσ_desugar_kwargs({onmouseenter: self.onmouseenter, onclick: self.onclick})]))); } }; if (!CompletionPopup.prototype._render_matches.__module__) Object.defineProperties(CompletionPopup.prototype._render_matches, { __module__ : {value: "popups"} }); CompletionPopup.prototype.onmouseenter = function onmouseenter(event) { var self = this; var div; div = self.current_item; if (div) { div.classList.remove(self.CURRENT_ITEM_CLASS); } event.currentTarget.classList.add(self.CURRENT_ITEM_CLASS); }; if (!CompletionPopup.prototype.onmouseenter.__argnames__) Object.defineProperties(CompletionPopup.prototype.onmouseenter, { __argnames__ : {value: ["event"]}, __module__ : {value: "popups"} }); CompletionPopup.prototype.onclick = function onclick(event) { var self = this; self.onmouseenter(event); try { if (self.onselect) { self.onselect(self.current_text); } } finally { self.hide(); } }; if (!CompletionPopup.prototype.onclick.__argnames__) Object.defineProperties(CompletionPopup.prototype.onclick, { __argnames__ : {value: ["event"]}, __module__ : {value: "popups"} }); CompletionPopup.prototype.__repr__ = function __repr__ () { return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; CompletionPopup.prototype.__str__ = function __str__ () { return this.__repr__(); }; Object.defineProperty(CompletionPopup.prototype, "__bases__", {value: []}); CompletionPopup.prototype.CLASS = "popup-completion-items"; CompletionPopup.prototype.CURRENT_ITEM_CLASS = "popup-completion-current-item"; add_extra_css((function() { var ρσ_anonfunc = function () { var sel, style; sel = "div." + CompletionPopup.prototype.CLASS; style = ρσ_interpolate_kwargs.call(this, build_rule, [sel].concat([ρσ_desugar_kwargs({overflow: "hidden", text_align: "left", background_color: get_color("window-background"), border: "solid 1px " + get_color("window-foreground")})])); sel += " > div"; style += ρσ_interpolate_kwargs.call(this, build_rule, [sel].concat([ρσ_desugar_kwargs({cursor: "pointer", padding: "1ex 1rem", white_space: "nowrap", text_overflow: "ellipsis", overflow: "hidden"})])); sel += "." + CompletionPopup.prototype.CURRENT_ITEM_CLASS; style += ρσ_interpolate_kwargs.call(this, build_rule, [sel].concat([ρσ_desugar_kwargs({color: get_color("list-hover-foreground"), background_color: get_color("list-hover-background")})])); return style; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "popups"} }); return ρσ_anonfunc; })()); ρσ_modules.popups.MODAL_Z_INDEX = MODAL_Z_INDEX; ρσ_modules.popups.POPUP_Z_INDEX = POPUP_Z_INDEX; ρσ_modules.popups.popup_count = popup_count; ρσ_modules.popups.shown_popups = shown_popups; ρσ_modules.popups.associated_widgets = associated_widgets; ρσ_modules.popups.create_popup = create_popup; ρσ_modules.popups.show_popup = show_popup; ρσ_modules.popups.CompletionPopup = CompletionPopup; })(); (function(){ var __name__ = "widgets"; var E = ρσ_modules.elementmaker.E; var _ = ρσ_modules.gettext.gettext; var get_color = ρσ_modules["book_list.theme"].get_color; var build_rule = ρσ_modules.dom.build_rule; var clear = ρσ_modules.dom.clear; var svgicon = ρσ_modules.dom.svgicon; var create_keyframes = ρσ_modules.dom.create_keyframes; var set_css = ρσ_modules.dom.set_css; var change_icon_image = ρσ_modules.dom.change_icon_image; var add_extra_css = ρσ_modules.dom.add_extra_css; var ensure_id = ρσ_modules.dom.ensure_id; function create_button() { var text = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var icon = (arguments[1] === undefined || ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? create_button.__defaults__.icon : arguments[1]; var action = (arguments[2] === undefined || ( 2 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? create_button.__defaults__.action : arguments[2]; var tooltip = (arguments[3] === undefined || ( 3 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? create_button.__defaults__.tooltip : arguments[3]; var highlight = (arguments[4] === undefined || ( 4 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? create_button.__defaults__.highlight : arguments[4]; var download_filename = (arguments[5] === undefined || ( 5 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? create_button.__defaults__.download_filename : arguments[5]; var class_ = (arguments[6] === undefined || ( 6 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? create_button.__defaults__.class_ : arguments[6]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "icon")){ icon = ρσ_kwargs_obj.icon; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "action")){ action = ρσ_kwargs_obj.action; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "tooltip")){ tooltip = ρσ_kwargs_obj.tooltip; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "highlight")){ highlight = ρσ_kwargs_obj.highlight; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "download_filename")){ download_filename = ρσ_kwargs_obj.download_filename; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "class_")){ class_ = ρσ_kwargs_obj.class_; } var ic, cls, ans; ic = ""; if (icon) { ic = svgicon(icon); if (text) { text = " " + text; } } cls = ("calibre-push-button " + (class_ || "")).strip(); if (highlight) { cls = (cls + " calibre-primary-button").strip(); } ans = ρσ_interpolate_kwargs.call(E, E.a, [ic, E.span(text)].concat([ρσ_desugar_kwargs({class_: cls, href: "javascript: void(0)", role: "button", title: tooltip || ""})])); if (download_filename && "download" in ans) { ans.setAttribute("download", download_filename); } if (action !== null) { if (typeof action === "string") { ans.setAttribute("href", action); } else { ans.addEventListener("click", (function() { var ρσ_anonfunc = function (event) { [event.preventDefault(), action(event)]; }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "widgets"} }); return ρσ_anonfunc; })()); } } return ans; }; if (!create_button.__defaults__) Object.defineProperties(create_button, { __defaults__ : {value: {icon:null, action:null, tooltip:null, highlight:false, download_filename:null, class_:""}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["text", "icon", "action", "tooltip", "highlight", "download_filename", "class_"]}, __module__ : {value: "widgets"} }); create_button.style += "\n@media (max-width: 420px) {\n #modal-container .button-box { flex-direction: column; align-items: stretch; }\n #modal-container .button-box > a.calibre-push-button { width: 100%; flex: 1 1 auto; justify-content: center; }\n #modal-container .button-box > a.calibre-push-button:only-of-type { margin-left: 0; }\n}\n"; function create_pager_widget(on_prev, on_next) { var prev_btn, next_btn, buttons_container, top_row, middle_row, container; function create_pager_button(is_prev, label, icon, onclick) { var a; a = ρσ_interpolate_kwargs.call(E, E.a, [svgicon(icon), E.span(label)].concat([ρσ_desugar_kwargs({href: "javascript:void(0)", class_: "calibre-push-button"})])); if (!is_prev) { a.insertBefore(a.firstChild.nextSibling, a.firstChild); } a.addEventListener("click", (function() { var ρσ_anonfunc = function (evt) { evt.preventDefault(); onclick(); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["evt"]}, __module__ : {value: "widgets"} }); return ρσ_anonfunc; })()); return a; }; if (!create_pager_button.__argnames__) Object.defineProperties(create_pager_button, { __argnames__ : {value: ["is_prev", "label", "icon", "onclick"]}, __module__ : {value: "widgets"} }); prev_btn = create_pager_button(true, _("Prev"), "chevron-left", on_prev); next_btn = create_pager_button(false, _("Next"), "chevron-right", on_next); buttons_container = ρσ_interpolate_kwargs.call(E, E.div, [prev_btn, E.div(), next_btn].concat([ρσ_desugar_kwargs({class_: "bottom-row"})])); top_row = ρσ_interpolate_kwargs.call(E, E.div, [ρσ_desugar_kwargs({class_: "top-row hidden"})]); middle_row = ρσ_interpolate_kwargs.call(E, E.div, [ρσ_desugar_kwargs({class_: "middle-row hidden"})]); container = ρσ_interpolate_kwargs.call(E, E.div, [top_row, E.hr(), middle_row, E.hr(), buttons_container].concat([ρσ_desugar_kwargs({class_: "calibre-pager-widget calibre-group-box"})])); function update_container_visibility() { container.style.display = (buttons_container.classList.contains("hidden") && top_row.classList.contains("hidden") && middle_row.classList.contains("hidden")) ? "none" : ""; }; if (!update_container_visibility.__module__) Object.defineProperties(update_container_visibility, { __module__ : {value: "widgets"} }); function set_enabled(has_prev, has_next) { prev_btn.setAttribute("aria-disabled", (has_prev) ? "false" : "true"); next_btn.setAttribute("aria-disabled", (has_next) ? "false" : "true"); if (has_prev || has_next) { buttons_container.classList.remove("hidden"); } else { buttons_container.classList.add("hidden"); } update_container_visibility(); }; if (!set_enabled.__argnames__) Object.defineProperties(set_enabled, { __argnames__ : {value: ["has_prev", "has_next"]}, __module__ : {value: "widgets"} }); function set_visible(which, visible) { if (visible) { which.classList.remove("hidden"); } else { which.classList.add("hidden"); } update_container_visibility(); }; if (!set_visible.__argnames__) Object.defineProperties(set_visible, { __argnames__ : {value: ["which", "visible"]}, __module__ : {value: "widgets"} }); return (function(){ var ρσ_d = Object.create(null); ρσ_d["container"] = container; ρσ_d["count_msg"] = buttons_container.firstChild.nextSibling; ρσ_d["prev_btn"] = prev_btn; ρσ_d["next_btn"] = next_btn; ρσ_d["set_enabled"] = set_enabled; ρσ_d["top_row"] = top_row; ρσ_d["middle_row"] = middle_row; ρσ_d["set_top_row_visibility"] = (function() { var ρσ_anonfunc = function (visible) { set_visible(top_row, visible); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["visible"]}, __module__ : {value: "widgets"} }); return ρσ_anonfunc; })(); ρσ_d["set_middle_row_visibility"] = (function() { var ρσ_anonfunc = function (visible) { set_visible(middle_row, visible); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["visible"]}, __module__ : {value: "widgets"} }); return ρσ_anonfunc; })(); return ρσ_d; }).call(this); }; if (!create_pager_widget.__argnames__) Object.defineProperties(create_pager_widget, { __argnames__ : {value: ["on_prev", "on_next"]}, __module__ : {value: "widgets"} }); create_pager_widget.style = "\ndiv.calibre-pager-widget {\n display: flex;\n flex-direction: column;\n\n & > hr {\n margin-top: 0.9ex; margin-bottom: 0.9ex;\n }\n\n & > .top-row {\n display: flex;\n overflow: hidden;\n gap: 0.75rem;\n }\n\n & > .middle-row {\n display: flex;\n overflow: hidden;\n flex-wrap: wrap;\n gap: 0.75rem;\n }\n\n & > .bottom-row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 0.75rem;\n flex-wrap: wrap;\n min-width: 0;\n width: 100%;\n box-sizing: border-box;\n\n & > :first-child, & > :last-child {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n flex: 1 1 auto;\n min-width: 0;\n max-width: 100%;\n }\n\n & > :first-child { justify-content: flex-start; }\n & > :last-child { justify-content: flex-end; }\n & > :nth-child(2) {\n text-align: center;\n display: block;\n text-overflow: ellipsis;\n }\n }\n\n & > .hidden {\n display: none;\n & + hr { display: none; }\n }\n & > hr:has(+ .hidden) { display: none; }\n\n}\n"; function create_select() { var title = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var current_value = ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[1]; var options = arguments[arguments.length-1]; if (options === null || typeof options !== "object" || options [ρσ_kwargs_symbol] !== true) options = {}; var sel, ρσ_unpack, value, text, container; sel = ρσ_interpolate_kwargs.call(E, E.select, [ρσ_desugar_kwargs({title: title})]); var ρσ_Iter45 = Object.entries(options); ρσ_Iter45 = ((typeof ρσ_Iter45[Symbol.iterator] === "function") ? (ρσ_Iter45 instanceof Map ? ρσ_Iter45.keys() : ρσ_Iter45) : Object.keys(ρσ_Iter45)); for (var ρσ_Index45 of ρσ_Iter45) { ρσ_unpack = ρσ_Index45; value = ρσ_unpack[0]; text = ρσ_unpack[1]; sel.appendChild(ρσ_interpolate_kwargs.call(E, E.option, [text].concat([ρσ_desugar_kwargs({value: value})]))); } sel.value = current_value; container = ρσ_interpolate_kwargs.call(E, E.div, [sel, E.span(svgicon("angle-down"))].concat([ρσ_desugar_kwargs({data_component: "select"})])); return [container, sel]; }; if (!create_select.__handles_kwarg_interpolation__) Object.defineProperties(create_select, { __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["title", "current_value"]}, __module__ : {value: "widgets"} }); create_select.style = "\ndiv[data-component=select] {\n display: inline-flex;\n position: relative;\n align-items: center;\n flex-shrink: 0;\n\n & > select {\n appearance: none;\n margin: 0;\n padding: 0.35rem 2.0em 0.35rem 0.65rem;\n border-radius: 999px;\n border: var(--calibre-border-style-subtle);\n background-color: var(--calibre-color-window-background);\n color: var(--calibre-color-window-foreground);\n align-self: center;\n box-sizing: border-box;\n\n &:hover {\n background-color: var(--calibre-color-primary-light);\n border: var(--calibre-border-style);\n }\n &:focus {\n outline: none;\n border: var(--calibre-border-style-subtle);\n }\n\n & > option {\n background-color: var(--calibre-color-window-background);\n color: var(--calibre-color-input-foreground);\n &:checked { outline-color: var(--calibre-color-primary); }\n &:hover {\n background-color: var(--calibre-color-window-background);\n color: var(--calibre-color-primary);\n }\n }\n }\n & > span {\n position: absolute;\n right: 0.65em;\n top: 50%;\n transform: translateY(-50%);\n pointer-events: none;\n opacity: 0.75;\n color: currentColor;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n\n & > svg {\n width: 1em;\n height: 1em;\n flex-shrink: 0;\n }\n }\n}\n"; function create_spinner(height, width) { var ans; ans = svgicon("cog", height, width); ans.classList.add("spin"); return ans; }; if (!create_spinner.__argnames__) Object.defineProperties(create_spinner, { __argnames__ : {value: ["height", "width"]}, __module__ : {value: "widgets"} }); create_spinner.style = ρσ_interpolate_kwargs.call(this, build_rule, [".spin"].concat([ρσ_desugar_kwargs({animation: "spin 2s infinite linear"})])); create_spinner.style += create_keyframes("spin", "from { transform: rotate(0deg); } to { transform: rotate(359deg);}"); function Breadcrumbs() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); Breadcrumbs.prototype.__init__.apply(this, arguments); } Object.defineProperties(Breadcrumbs.prototype, { "container": { "enumerable": true, "get": function container() { var self = this; return document.getElementById(self.container_id); }, "set": function () { throw new AttributeError("can't set attribute") } }, }); Breadcrumbs.prototype.__init__ = function __init__(container) { var self = this; self.container_id = ensure_id(container, "calibre-breadcrumbs-"); container.classList.add("calibre-breadcrumbs"); clear(container); }; if (!Breadcrumbs.prototype.__init__.__argnames__) Object.defineProperties(Breadcrumbs.prototype.__init__, { __argnames__ : {value: ["container"]}, __module__ : {value: "widgets"} }); Breadcrumbs.__argnames__ = Breadcrumbs.prototype.__init__.__argnames__; Breadcrumbs.__handles_kwarg_interpolation__ = Breadcrumbs.prototype.__init__.__handles_kwarg_interpolation__; Breadcrumbs.prototype.reset = function reset() { var self = this; clear(self.container); }; if (!Breadcrumbs.prototype.reset.__module__) Object.defineProperties(Breadcrumbs.prototype.reset, { __module__ : {value: "widgets"} }); Breadcrumbs.prototype.add_crumb = function add_crumb(callback) { var self = this; var li; li = E.li(); if (callback) { li.addEventListener("click", callback); } self.container.appendChild(li); return li; }; if (!Breadcrumbs.prototype.add_crumb.__argnames__) Object.defineProperties(Breadcrumbs.prototype.add_crumb, { __argnames__ : {value: ["callback"]}, __module__ : {value: "widgets"} }); Breadcrumbs.prototype.__repr__ = function __repr__ () { return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; Breadcrumbs.prototype.__str__ = function __str__ () { return this.__repr__(); }; Object.defineProperty(Breadcrumbs.prototype, "__bases__", {value: []}); Breadcrumbs.prototype.STYLE_RULES = ρσ_interpolate_kwargs.call(this, build_rule, [".calibre-breadcrumbs"].concat([ρσ_desugar_kwargs({user_select: "none", white_space: "nowrap", background_color: get_color("window-background2"), z_index: "-1", border_radius: "10px", margin: "1ex 1em", margin_bottom: "0"})])); Breadcrumbs.prototype.STYLE_RULES += ρσ_interpolate_kwargs.call(this, build_rule, [".calibre-breadcrumbs > li"].concat([ρσ_desugar_kwargs({cursor: "pointer", display: "inline-block", line_height: "26px", margin: "0 9px 0 -10px", padding: "0.5ex 1rem", position: "relative"})])); Breadcrumbs.prototype.STYLE_RULES += ρσ_interpolate_kwargs.call(this, build_rule, [".calibre-breadcrumbs > li:hover"].concat([ρσ_desugar_kwargs({color: get_color("window-hover-foreground")})])); Breadcrumbs.prototype.STYLE_RULES += ρσ_interpolate_kwargs.call(this, build_rule, [".calibre-breadcrumbs > li:active"].concat([ρσ_desugar_kwargs({color: get_color("window-hover-foreground"), transform: "scale(1.5)"})])); Breadcrumbs.prototype.STYLE_RULES += ρσ_interpolate_kwargs.call(this, build_rule, [".calibre-breadcrumbs > li:before, .calibre-breadcrumbs > li:after"].concat([ρσ_desugar_kwargs({border_right: "2px solid currentColor", content: "\"\"", display: "block", height: "50%", position: "absolute", left: "0", top: "0", right: "0", transform: "skewX(45deg)"})])); Breadcrumbs.prototype.STYLE_RULES += ρσ_interpolate_kwargs.call(this, build_rule, [".calibre-breadcrumbs > li:after"].concat([ρσ_desugar_kwargs({bottom: "0", top: "auto", transform: "skewX(-45deg)"})])); Breadcrumbs.prototype.STYLE_RULES += ρσ_interpolate_kwargs.call(this, build_rule, [".calibre-breadcrumbs > li:last-of-type:before, .calibre-breadcrumbs > li:last-of-type:after"].concat([ρσ_desugar_kwargs({display: "none"})])); function create_tree(root, populate_data, onclick) { var container; container = ρσ_interpolate_kwargs.call(E, E.div, [ρσ_desugar_kwargs({class_: "simple-tree"})]); ρσ_interpolate_kwargs.call(this, set_css, [container].concat([ρσ_desugar_kwargs({overflow: "auto"})])); function toggle_node(li) { if (li.dataset.treeState === "closed") { li.dataset.treeState = "open"; li.lastChild.style.display = "block"; change_icon_image(li.firstChild.firstChild, "caret-down"); } else { li.dataset.treeState = "closed"; li.lastChild.style.display = "none"; change_icon_image(li.firstChild.firstChild, "caret-right"); } }; if (!toggle_node.__argnames__) Object.defineProperties(toggle_node, { __argnames__ : {value: ["li"]}, __module__ : {value: "widgets"} }); function bullet(icon) { var ans; ans = svgicon(icon, "2ex", "2ex"); ans.style.minWidth = "2ex"; ans.style.minHeight = "2ex"; return ans; }; if (!bullet.__argnames__) Object.defineProperties(bullet, { __argnames__ : {value: ["icon"]}, __module__ : {value: "widgets"} }); function process_node(node, parent_container, level) { var ul, icon, li, child; if (ρσ_exists.d(node.children).length) { ul = E.div(); parent_container.appendChild(ul); var ρσ_Iter46 = node.children; ρσ_Iter46 = ((typeof ρσ_Iter46[Symbol.iterator] === "function") ? (ρσ_Iter46 instanceof Map ? ρσ_Iter46.keys() : ρσ_Iter46) : Object.keys(ρσ_Iter46)); for (var ρσ_Index46 of ρσ_Iter46) { child = ρσ_Index46; icon = (ρσ_exists.d(child.children).length) ? "caret-right" : null; li = ρσ_interpolate_kwargs.call(E, E.div, [ρσ_interpolate_kwargs.call(E, E.div, [bullet(icon), E.span(" "), ρσ_interpolate_kwargs.call(E, E.a, [ρσ_desugar_kwargs({href: "javascript: void(0)", class_: "tree-item-title", onclick: (function() { var ρσ_anonfunc = function (event) { if (onclick) { if (event.button === 0) { [event.preventDefault(), event.stopPropagation()]; } onclick(event, event.currentTarget.parentNode.parentNode); } }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "widgets"} }); return ρσ_anonfunc; })()})])].concat([ρσ_desugar_kwargs({style: "display:flex; align-items: center"})])), ρσ_interpolate_kwargs.call(E, E.div, [ρσ_desugar_kwargs({style: "display:none", data_tree_subtree_container: "1"})])].concat([ρσ_desugar_kwargs({style: "display:flex; flex-direction:column; margin: 1ex 1em; margin-left: {}em".format(level + 1), data_tree_state: "closed"})])); ul.appendChild(li); populate_data(child, li, li.firstChild.lastChild); if (icon) { ρσ_interpolate_kwargs.call(this, set_css, [li.firstChild.firstChild].concat([ρσ_desugar_kwargs({cursor: "pointer"})])); li.firstChild.firstChild.addEventListener("click", (function() { var ρσ_anonfunc = function (event) { toggle_node(event.currentTarget.parentNode.parentNode); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "widgets"} }); return ρσ_anonfunc; })()); process_node(child, li.lastChild, level + 1); } } } }; if (!process_node.__argnames__) Object.defineProperties(process_node, { __argnames__ : {value: ["node", "parent_container", "level"]}, __module__ : {value: "widgets"} }); if (root) { process_node(root, container, 0); } return container; }; if (!create_tree.__argnames__) Object.defineProperties(create_tree, { __argnames__ : {value: ["root", "populate_data", "onclick"]}, __module__ : {value: "widgets"} }); function find_text_in_tree(container, q) { var last_match, lm, before, seen, ans, a; q = q.lower(); last_match = container.querySelector("a[data-tree-last-match]"); if (last_match) { last_match.parentNode.style.backgroundColor = "transparent"; last_match.parentNode.style.borderRadius = "0"; lm = last_match.getAttribute("data-tree-last-match"); last_match.removeAttribute("data-tree-last-match"); if (lm !== q) { last_match = null; } } if (!q) { return; } before = []; seen = false; ans = null; var ρσ_Iter47 = container.querySelectorAll("a.tree-item-title"); ρσ_Iter47 = ((typeof ρσ_Iter47[Symbol.iterator] === "function") ? (ρσ_Iter47 instanceof Map ? ρσ_Iter47.keys() : ρσ_Iter47) : Object.keys(ρσ_Iter47)); for (var ρσ_Index47 of ρσ_Iter47) { a = ρσ_Index47; if (a === last_match) { seen = true; } else { if (ρσ_not_equals(a.textContent.lower().indexOf(q), -1)) { if (seen) { ans = a; break; } if (last_match === null) { ans = a; break; } before.push(a); } } } if (!ans && before.length) { ans = before[0]; } ans = ans || last_match; if (ans) { ans.dataset.treeLastMatch = q; } if (ans) { ans.parentNode.style.backgroundColor = get_color("tree-highlight-item"); ans.parentNode.style.borderRadius = "5px"; ans = ans.parentNode.parentNode; } return ans; }; if (!find_text_in_tree.__argnames__) Object.defineProperties(find_text_in_tree, { __argnames__ : {value: ["container", "q"]}, __module__ : {value: "widgets"} }); function scroll_tree_item_into_view(item) { var p; p = ρσ_exists.d(item.parentNode).parentNode; while (p && p.getAttribute("data-tree-subtree-container")) { p.style.display = "block"; p = ρσ_exists.d(ρσ_exists.d(p.parentNode).parentNode).parentNode; } item.scrollIntoView(); }; if (!scroll_tree_item_into_view.__argnames__) Object.defineProperties(scroll_tree_item_into_view, { __argnames__ : {value: ["item"]}, __module__ : {value: "widgets"} }); add_extra_css((function() { var ρσ_anonfunc = function () { var ans; ans = "a, button:focus { outline: none }; a, button::-moz-focus-inner { border: 0 }\n"; ans += ".simple-link { cursor: pointer } .simple-link:hover { color: HC } .simple-link:active { transform: scale(1.5) }\n".replace("HC", get_color("window-hover-foreground")); ans += "\n a.tree-item-title {\n color: currentColor;\n cursor: pointer;\n text-decoration: none;\n &:hover, &:active {\n color: var(--calibre-color-primary);\n text-decoration: none;\n }\n }\n "; ans += ".blue-link { cursor: pointer; color: var(--calibre-color-primary) } .blue-link:visited { color: var(--calibre-color-primary)} .blue-link:hover { color: var(--calibre-color-primary) } .blue-link:active { transform: scale(1.5) }\n"; ans += create_button.style + "\n"; ans += create_pager_widget.style + "\n"; ans += create_spinner.style + "\n"; ans += Breadcrumbs.prototype.STYLE_RULES + "\n"; ans += create_select.style + "\n"; ans += "\n select, textarea, input[type=\"text\"], input[type=\"password\"],\n input[type=\"datetime\"], input[type=\"datetime-local\"],\n input[type=\"date\"], input[type=\"month\"], input[type=\"time\"],\n input[type=\"week\"], input[type=\"number\"], input[type=\"email\"],\n input[type=\"url\"], input[type=\"search\"] { font-size: 1em }\n "; return ans; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "widgets"} }); return ρσ_anonfunc; })()); ρσ_modules.widgets.create_button = create_button; ρσ_modules.widgets.create_pager_widget = create_pager_widget; ρσ_modules.widgets.create_select = create_select; ρσ_modules.widgets.create_spinner = create_spinner; ρσ_modules.widgets.Breadcrumbs = Breadcrumbs; ρσ_modules.widgets.create_tree = create_tree; ρσ_modules.widgets.find_text_in_tree = find_text_in_tree; ρσ_modules.widgets.scroll_tree_item_into_view = scroll_tree_item_into_view; })(); (function(){ var __name__ = "modals"; var modal_container, modal_count; var E = ρσ_modules.elementmaker.E; var _ = ρσ_modules.gettext.gettext; var get_session_data = ρσ_modules["book_list.globals"].get_session_data; var get_color = ρσ_modules["book_list.theme"].get_color; var get_font_size = ρσ_modules["book_list.theme"].get_font_size; var add_extra_css = ρσ_modules.dom.add_extra_css; var build_rule = ρσ_modules.dom.build_rule; var clear = ρσ_modules.dom.clear; var set_css = ρσ_modules.dom.set_css; var svgicon = ρσ_modules.dom.svgicon; var unique_id = ρσ_modules.dom.unique_id; var MODAL_Z_INDEX = ρσ_modules.popups.MODAL_Z_INDEX; var safe_set_inner_html = ρσ_modules.utils.safe_set_inner_html; var create_button = ρσ_modules.widgets.create_button; modal_container = null; modal_count = 0; add_extra_css((function() { var ρσ_anonfunc = function () { var modal_max, style; modal_max = "min(48rem, calc(100vw - 2rem))"; style = ρσ_interpolate_kwargs.call(this, build_rule, ["#modal-container > div > a:hover"].concat([ρσ_desugar_kwargs({color: get_color("dialog-foreground") + " !important", background_color: get_color("dialog-background") + " !important"})])); style += ρσ_interpolate_kwargs.call(this, build_rule, ["#modal-container"].concat([ρσ_desugar_kwargs({overflow_x: "auto", overflow_y: "auto", overscroll_behavior_x: "none", overscroll_behavior_y: "contain", touch_action: "pan-x pan-y", padding: "max(1rem, env(safe-area-inset-top, 0px)) max(1rem, env(safe-area-inset-right, 0px)) max(1rem, env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px))", box_sizing: "border-box"})])); style += ρσ_interpolate_kwargs.call(this, build_rule, ["#modal-container > div"].concat([ρσ_desugar_kwargs({overflow_x: "visible", overflow_y: "visible", width: "max-content", min_width: "0", max_width: modal_max, box_sizing: "border-box"})])); style += ρσ_interpolate_kwargs.call(this, build_rule, [".modal_height_container"].concat([ρσ_desugar_kwargs({min_width: "0", max_width: "100%", overflow_wrap: "anywhere", word_break: "break-word", overflow_x: "auto", overflow_y: "auto", overscroll_behavior_x: "none", touch_action: "pan-x pan-y"})])); style += ρσ_interpolate_kwargs.call(this, build_rule, ["#modal-container .modal_height_container pre, #modal-container .modal_height_container code"].concat([ρσ_desugar_kwargs({white_space: "pre-wrap", overflow_wrap: "anywhere", word_break: "break-word"})])); style += ρσ_interpolate_kwargs.call(this, build_rule, ["#modal-container .modal_height_container img, #modal-container .modal_height_container iframe"].concat([ρσ_desugar_kwargs({max_width: "100%", height: "auto"})])); style += ρσ_interpolate_kwargs.call(this, build_rule, ["#modal-container .modal_height_container table"].concat([ρσ_desugar_kwargs({max_width: "100%", box_sizing: "border-box"})])); style += ρσ_interpolate_kwargs.call(this, build_rule, ["#modal-container .modal_height_container th, #modal-container .modal_height_container td"].concat([ρσ_desugar_kwargs({overflow_wrap: "anywhere", word_break: "break-word"})])); style += ρσ_interpolate_kwargs.call(this, build_rule, ["#modal-container .modal_height_container input:not([type=\"checkbox\"]):not([type=\"radio\"]):not([type=\"color\"]):not([type=\"file\"])," + "#modal-container .modal_height_container textarea, #modal-container .modal_height_container select"].concat([ρσ_desugar_kwargs({max_width: "100%", box_sizing: "border-box"})])); style += ρσ_interpolate_kwargs.call(this, build_rule, ["#modal-container .button-box"].concat([ρσ_desugar_kwargs({display: "flex", justify_content: "space-between", align_items: "stretch", flex_wrap: "wrap", gap: "0.5rem", padding: "1rem 0rem", min_width: "0"})])); style += ρσ_interpolate_kwargs.call(this, build_rule, ["#modal-container .button-box > a.calibre-push-button"].concat([ρσ_desugar_kwargs({flex: "1 1 0", min_width: "0", justify_content: "center"})])); style += ρσ_interpolate_kwargs.call(this, build_rule, ["#modal-container .button-box > a.calibre-push-button:only-of-type"].concat([ρσ_desugar_kwargs({flex: "0 1 auto", margin_left: "auto"})])); style += ρσ_interpolate_kwargs.call(this, build_rule, ["#modal-container .button-box.button-box--wrap-chips"].concat([ρσ_desugar_kwargs({justify_content: "flex-start"})])); style += ρσ_interpolate_kwargs.call(this, build_rule, ["#modal-container .button-box.button-box--wrap-chips > a.calibre-push-button"].concat([ρσ_desugar_kwargs({flex: "0 1 auto"})])); style += ρσ_interpolate_kwargs.call(this, build_rule, ["#modal-container > div > a:last-child"].concat([ρσ_desugar_kwargs({z_index: "2"})])); return style; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "modals"} }); return ρσ_anonfunc; })()); function Modal() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); Modal.prototype.__init__.apply(this, arguments); } Modal.prototype.__init__ = function __init__(create_func, on_close, show_close, onkeydown) { var self = this; var ρσ_unpack; ρσ_unpack = [create_func, on_close, show_close]; self.create_func = ρσ_unpack[0]; self.on_close = ρσ_unpack[1]; self.show_close = ρσ_unpack[2]; self.onkeydown = onkeydown; modal_count += 1; self.id = modal_count; }; if (!Modal.prototype.__init__.__argnames__) Object.defineProperties(Modal.prototype.__init__, { __argnames__ : {value: ["create_func", "on_close", "show_close", "onkeydown"]}, __module__ : {value: "modals"} }); Modal.__argnames__ = Modal.prototype.__init__.__argnames__; Modal.__handles_kwarg_interpolation__ = Modal.prototype.__init__.__handles_kwarg_interpolation__; Modal.prototype.__repr__ = function __repr__ () { return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; Modal.prototype.__str__ = function __str__ () { return this.__repr__(); }; Object.defineProperty(Modal.prototype, "__bases__", {value: []}); function ModalContainer() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); ModalContainer.prototype.__init__.apply(this, arguments); } Object.defineProperties(ModalContainer.prototype, { "modal_container": { "enumerable": true, "get": function modal_container() { var self = this; return document.getElementById("modal-container"); }, "set": function () { throw new AttributeError("can't set attribute") } }, }); ModalContainer.prototype.__init__ = function __init__() { var self = this; var div, popup_max; div = ρσ_interpolate_kwargs.call(E, E.div, [E.div(ρσ_interpolate_kwargs.call(E, E.div, [ρσ_desugar_kwargs({class_: "modal_height_container"})]), ρσ_interpolate_kwargs.call(E, E.a, [svgicon("close")].concat([ρσ_desugar_kwargs({title: _("Close"), onclick: self.close_current_modal.bind(self)})])))].concat([ρσ_desugar_kwargs({id: "modal-container", tabindex: "0"})])); div.addEventListener("keydown", self.onkeydown.bind(self), (function(){ var ρσ_d = Object.create(null); ρσ_d["passive"] = false; return ρσ_d; }).call(this)); document.body.appendChild(div); ρσ_interpolate_kwargs.call(this, set_css, [div].concat([ρσ_desugar_kwargs({position: "fixed", top: "0", right: "0", bottom: "0", left: "0", background_color: "rgba(0,0,0,0.5)", backdrop_filter: "blur(2px)", webkit_backdrop_filter: "blur(2px)", z_index: MODAL_Z_INDEX + "", display: "none", user_select: "none", justify_content: "center", align_items: "center", overscroll_behavior_x: "none", overscroll_behavior_y: "contain"})])); popup_max = "min(48rem, calc(100vw - 2rem))"; ρσ_interpolate_kwargs.call(this, set_css, [div.firstChild].concat([ρσ_desugar_kwargs({position: "relative", display: "inline-block", min_width: "min(16rem, calc(100vw - 2rem))", max_width: popup_max, overflow_x: "visible", overflow_y: "visible", box_sizing: "border-box", border_radius: "1em", padding: "1em 2em", margin_right: "1em", margin_left: "1em", background_color: get_color("dialog-background"), color: get_color("dialog-foreground"), background_image: get_color("dialog-background-image"), box_shadow: "0 12px 40px rgba(0,0,0,0.2)", border: "var(--calibre-border-style)"})])); ρσ_interpolate_kwargs.call(this, set_css, [div.firstChild.lastChild].concat([ρσ_desugar_kwargs({font_size: "1.5em", line_height: "100%", cursor: "pointer", position: "absolute", right: "-0.5em", top: "-0.5em", width: "1em", height: "1em", background_color: get_color("window-foreground"), color: get_color("window-background"), display: "inline-box", border_radius: "50%", padding: "4px", text_align: "center", box_shadow: "1px 1px 3px black", z_index: "2"})])); ρσ_interpolate_kwargs.call(this, set_css, [div.firstChild.firstChild].concat([ρσ_desugar_kwargs({user_select: "text", max_height: "min(60vh, calc(100vh - 6rem))", overflow_x: "auto", overflow_y: "auto", overscroll_behavior_x: "none", padding: "1px", min_width: "0", max_width: "100%"})])); self.modals = []; self.current_modal = null; self.hide = self.close_current_modal.bind(self); }; if (!ModalContainer.prototype.__init__.__module__) Object.defineProperties(ModalContainer.prototype.__init__, { __module__ : {value: "modals"} }); ModalContainer.__argnames__ = ModalContainer.prototype.__init__.__argnames__; ModalContainer.__handles_kwarg_interpolation__ = ModalContainer.prototype.__init__.__handles_kwarg_interpolation__; ModalContainer.prototype.show_modal = function show_modal() { var self = this; var create_func = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var on_close = (arguments[1] === undefined || ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? show_modal.__defaults__.on_close : arguments[1]; var show_close = (arguments[2] === undefined || ( 2 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? show_modal.__defaults__.show_close : arguments[2]; var onkeydown = (arguments[3] === undefined || ( 3 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? show_modal.__defaults__.onkeydown : arguments[3]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "on_close")){ on_close = ρσ_kwargs_obj.on_close; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "show_close")){ show_close = ρσ_kwargs_obj.show_close; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "onkeydown")){ onkeydown = ρσ_kwargs_obj.onkeydown; } var modal_id; self.modals.push(new Modal(create_func, on_close, show_close, onkeydown)); modal_id = (ρσ_expr_temp = self.modals)[ρσ_expr_temp.length-1].id; self.update(); window.setTimeout((function() { var ρσ_anonfunc = function () { self.modal_container.focus(); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "modals"} }); return ρσ_anonfunc; })(), 0); return modal_id; }; if (!ModalContainer.prototype.show_modal.__defaults__) Object.defineProperties(ModalContainer.prototype.show_modal, { __defaults__ : {value: {on_close:null, show_close:true, onkeydown:null}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["create_func", "on_close", "show_close", "onkeydown"]}, __module__ : {value: "modals"} }); ModalContainer.prototype.hide_modal = function hide_modal(modal_id) { var self = this; var doomed_modal, ρσ_unpack, i, modal; if (self.current_modal !== null && self.current_modal.id === modal_id) { self.clear_current_modal(); } else { doomed_modal = null; var ρσ_Iter48 = enumerate(self.modals); ρσ_Iter48 = ((typeof ρσ_Iter48[Symbol.iterator] === "function") ? (ρσ_Iter48 instanceof Map ? ρσ_Iter48.keys() : ρσ_Iter48) : Object.keys(ρσ_Iter48)); for (var ρσ_Index48 of ρσ_Iter48) { ρσ_unpack = ρσ_Index48; i = ρσ_unpack[0]; modal = ρσ_unpack[1]; if (modal.id === modal_id) { doomed_modal = i; break; } } if (doomed_modal !== null) { self.modals.splice(doomed_modal, 1); } } }; if (!ModalContainer.prototype.hide_modal.__argnames__) Object.defineProperties(ModalContainer.prototype.hide_modal, { __argnames__ : {value: ["modal_id"]}, __module__ : {value: "modals"} }); ModalContainer.prototype.update = function update() { var self = this; var c; if (self.current_modal === null && self.modals) { self.current_modal = self.modals.shift(); c = self.modal_container; try { self.current_modal.create_func(c.firstChild.firstChild, self.hide); } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; { self.current_modal = null; throw ρσ_Exception; } } if (c.style.display === "none") { c.style.display = "flex"; } c.firstChild.lastChild.style.visibility = (self.current_modal.show_close) ? "visible" : "hidden"; } }; if (!ModalContainer.prototype.update.__module__) Object.defineProperties(ModalContainer.prototype.update, { __module__ : {value: "modals"} }); ModalContainer.prototype.clear_current_modal = function clear_current_modal() { var self = this; var c; self.current_modal = null; c = self.modal_container; clear(c.firstChild.firstChild); if (self.modals.length === 0) { ρσ_interpolate_kwargs.call(this, set_css, [c].concat([ρσ_desugar_kwargs({display: "none"})])); } else { self.update(); } }; if (!ModalContainer.prototype.clear_current_modal.__module__) Object.defineProperties(ModalContainer.prototype.clear_current_modal, { __module__ : {value: "modals"} }); ModalContainer.prototype.close_current_modal = function close_current_modal(event) { var self = this; if (self.current_modal !== null) { if (self.current_modal.on_close !== null && self.current_modal.on_close(event) === true) { return; } self.clear_current_modal(); } }; if (!ModalContainer.prototype.close_current_modal.__argnames__) Object.defineProperties(ModalContainer.prototype.close_current_modal, { __argnames__ : {value: ["event"]}, __module__ : {value: "modals"} }); ModalContainer.prototype.close_all_modals = function close_all_modals() { var self = this; while (self.current_modal !== null) { self.close_current_modal(); } }; if (!ModalContainer.prototype.close_all_modals.__module__) Object.defineProperties(ModalContainer.prototype.close_all_modals, { __module__ : {value: "modals"} }); ModalContainer.prototype.onkeydown = function onkeydown(event) { var self = this; if (self.current_modal !== null && self.current_modal.onkeydown) { return self.current_modal.onkeydown(event, self.clear_current_modal.bind(self)); } if ((event.key === "Escape" || event.key === "Esc") && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) { [event.preventDefault(), event.stopPropagation()]; self.close_current_modal(event); } }; if (!ModalContainer.prototype.onkeydown.__argnames__) Object.defineProperties(ModalContainer.prototype.onkeydown, { __argnames__ : {value: ["event"]}, __module__ : {value: "modals"} }); ModalContainer.prototype.__repr__ = function __repr__ () { return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; ModalContainer.prototype.__str__ = function __str__ () { return this.__repr__(); }; Object.defineProperty(ModalContainer.prototype, "__bases__", {value: []}); function create_simple_dialog_markup(title, msg, details, icon, prefix, icon_color, parent) { var show_details, is_html_msg, html_container, details_container; details = details || ""; show_details = ρσ_interpolate_kwargs.call(E, E.a, [_("Show details")].concat([ρσ_desugar_kwargs({class_: "blue-link", style: "padding-top:1em; display:inline-block; margin-left: auto"})])); show_details.addEventListener("click", (function() { var ρσ_anonfunc = function () { show_details.style.display = "none"; show_details.nextSibling.style.display = "block"; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "modals"} }); return ρσ_anonfunc; })()); is_html_msg = /<[a-zA-Z]/.test(msg); html_container = E.div(); if (is_html_msg) { safe_set_inner_html(html_container, msg); } details_container = E.span(); if (/<[a-zA-Z]/.test(details)) { safe_set_inner_html(details_container, details); } else { details_container.textContent = details; } if (prefix) { prefix = ρσ_interpolate_kwargs.call(E, E.span, [" " + prefix + " "].concat([ρσ_desugar_kwargs({style: "white-space:pre; font-variant: small-caps"})])); } else { prefix = " "; } parent.appendChild(ρσ_interpolate_kwargs.call(E, E.div, [ρσ_interpolate_kwargs.call(E, E.h2, [ρσ_interpolate_kwargs.call(E, E.span, [svgicon(icon)].concat([ρσ_desugar_kwargs({style: "color:" + ρσ_str.format("{}", icon_color) + ""})])), prefix, title].concat([ρσ_desugar_kwargs({style: "font-weight: bold; font-size: " + get_font_size("title") + "; overflow-wrap:anywhere; word-break:break-word"})])), ρσ_interpolate_kwargs.call(E, E.div, [(is_html_msg) ? html_container : msg].concat([ρσ_desugar_kwargs({style: "padding-top: 1em; margin-top: 1em; border-top: 1px solid currentColor; min-width:0; overflow-wrap:anywhere; word-break:break-word"})])), ρσ_interpolate_kwargs.call(E, E.div, [show_details, ρσ_interpolate_kwargs.call(E, E.div, [details_container].concat([ρσ_desugar_kwargs({style: "display:none; white-space:pre-wrap; font-size: smaller; margin-top: 1em; border-top: solid 1px currentColor; padding-top: 1em"})]))].concat([ρσ_desugar_kwargs({style: "display: " + ((details) ? "block" : "none")})]))].concat([ρσ_desugar_kwargs({style: "max-width:100%; min-width:0; box-sizing:border-box; text-align:left; overflow-wrap:anywhere; word-break:break-word"})]))); }; if (!create_simple_dialog_markup.__argnames__) Object.defineProperties(create_simple_dialog_markup, { __argnames__ : {value: ["title", "msg", "details", "icon", "prefix", "icon_color", "parent"]}, __module__ : {value: "modals"} }); function create_simple_dialog() { var title = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var msg = ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[1]; var details = ( 2 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[2]; var icon = ( 3 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[3]; var prefix = ( 4 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[4]; var on_close = (arguments[5] === undefined || ( 5 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? create_simple_dialog.__defaults__.on_close : arguments[5]; var icon_color = (arguments[6] === undefined || ( 6 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? create_simple_dialog.__defaults__.icon_color : arguments[6]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "on_close")){ on_close = ρσ_kwargs_obj.on_close; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "icon_color")){ icon_color = ρσ_kwargs_obj.icon_color; } ρσ_interpolate_kwargs.call(this, show_modal, [create_simple_dialog_markup.bind(null, title, msg, details, icon, prefix, icon_color)].concat([ρσ_desugar_kwargs({on_close: on_close})])); }; if (!create_simple_dialog.__defaults__) Object.defineProperties(create_simple_dialog, { __defaults__ : {value: {on_close:null, icon_color:"red"}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["title", "msg", "details", "icon", "prefix", "on_close", "icon_color"]}, __module__ : {value: "modals"} }); function create_custom_dialog() { var title = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var content_generator_func = ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[1]; var on_close = (arguments[2] === undefined || ( 2 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? create_custom_dialog.__defaults__.on_close : arguments[2]; var onkeydown = (arguments[3] === undefined || ( 3 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? create_custom_dialog.__defaults__.onkeydown : arguments[3]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "on_close")){ on_close = ρσ_kwargs_obj.on_close; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "onkeydown")){ onkeydown = ρσ_kwargs_obj.onkeydown; } function create_func(parent, close_modal) { var content_div; content_div = E.div(); parent.appendChild(ρσ_interpolate_kwargs.call(E, E.div, [ρσ_interpolate_kwargs.call(E, E.h2, [title].concat([ρσ_desugar_kwargs({style: "font-weight: bold; font-size: " + get_font_size("title") + "; overflow-wrap:anywhere; word-break:break-word"})])), ρσ_interpolate_kwargs.call(E, E.div, [content_div].concat([ρσ_desugar_kwargs({style: "padding-top: 1em; margin-top: 1em; border-top: 1px solid currentColor; min-width:0"})]))].concat([ρσ_desugar_kwargs({style: "max-width:100%; min-width:0; box-sizing:border-box; text-align:left; overflow-wrap:anywhere; word-break:break-word"})]))); content_generator_func(content_div, close_modal); }; if (!create_func.__argnames__) Object.defineProperties(create_func, { __argnames__ : {value: ["parent", "close_modal"]}, __module__ : {value: "modals"} }); ρσ_interpolate_kwargs.call(this, show_modal, [create_func].concat([ρσ_desugar_kwargs({on_close: on_close, onkeydown: onkeydown})])); }; if (!create_custom_dialog.__defaults__) Object.defineProperties(create_custom_dialog, { __defaults__ : {value: {on_close:null, onkeydown:null}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["title", "content_generator_func", "on_close", "onkeydown"]}, __module__ : {value: "modals"} }); function get_text_dialog() { var title = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var callback = ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[1]; var initial_text = (arguments[2] === undefined || ( 2 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? get_text_dialog.__defaults__.initial_text : arguments[2]; var msg = (arguments[3] === undefined || ( 3 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? get_text_dialog.__defaults__.msg : arguments[3]; var rows = (arguments[4] === undefined || ( 4 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? get_text_dialog.__defaults__.rows : arguments[4]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "initial_text")){ initial_text = ρσ_kwargs_obj.initial_text; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "msg")){ msg = ρσ_kwargs_obj.msg; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "rows")){ rows = ρσ_kwargs_obj.rows; } var called, cid; called = Object.create(null); cid = unique_id(); function keyaction(ok, close_modal) { var text; if (called.done) { return; } called.done = true; text = document.getElementById(cid).value || ""; if (close_modal) { close_modal(); } callback(ok, text); }; if (!keyaction.__argnames__) Object.defineProperties(keyaction, { __argnames__ : {value: ["ok", "close_modal"]}, __module__ : {value: "modals"} }); function on_keydown(event, close_modal) { if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) { return; } if (event.key === "Escape" || event.key === "Esc") { [event.preventDefault(), event.stopPropagation()]; keyaction(false, close_modal); } }; if (!on_keydown.__argnames__) Object.defineProperties(on_keydown, { __argnames__ : {value: ["event", "close_modal"]}, __module__ : {value: "modals"} }); ρσ_interpolate_kwargs.call(this, create_custom_dialog, [title, (function() { var ρσ_anonfunc = function (parent, close_modal) { parent.appendChild(E.div(ρσ_interpolate_kwargs.call(E, E.textarea, [initial_text || ""].concat([ρσ_desugar_kwargs({placeholder: msg || "", id: cid, rows: rows + "", style: "width:100%; max-width:100%; min-width:0; box-sizing:border-box; resize:vertical"})])), ρσ_interpolate_kwargs.call(E, E.div, [create_button(_("Cancel"), "close", keyaction.bind(null, false, close_modal)), ρσ_interpolate_kwargs.call(this, create_button, [_("OK"), "check", keyaction.bind(null, true, close_modal)].concat([ρσ_desugar_kwargs({highlight: true})]))].concat([ρσ_desugar_kwargs({class_: "button-box"})])))); window.setTimeout((function() { var ρσ_anonfunc = function () { parent.querySelector("textarea").focus(); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "modals"} }); return ρσ_anonfunc; })(), 10); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["parent", "close_modal"]}, __module__ : {value: "modals"} }); return ρσ_anonfunc; })()].concat([ρσ_desugar_kwargs({on_close: keyaction.bind(null, false, null), onkeydown: on_keydown})])); }; if (!get_text_dialog.__defaults__) Object.defineProperties(get_text_dialog, { __defaults__ : {value: {initial_text:null, msg:null, rows:12}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["title", "callback", "initial_text", "msg", "rows"]}, __module__ : {value: "modals"} }); function question_dialog() { var title = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var msg = ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[1]; var callback = ( 2 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[2]; var yes_text = (arguments[3] === undefined || ( 3 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? question_dialog.__defaults__.yes_text : arguments[3]; var no_text = (arguments[4] === undefined || ( 4 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? question_dialog.__defaults__.no_text : arguments[4]; var skip_dialog_name = (arguments[5] === undefined || ( 5 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? question_dialog.__defaults__.skip_dialog_name : arguments[5]; var skip_dialog_msg = (arguments[6] === undefined || ( 6 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? question_dialog.__defaults__.skip_dialog_msg : arguments[6]; var skip_dialog_skipped_value = (arguments[7] === undefined || ( 7 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? question_dialog.__defaults__.skip_dialog_skipped_value : arguments[7]; var skip_dialog_skip_precheck = (arguments[8] === undefined || ( 8 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? question_dialog.__defaults__.skip_dialog_skip_precheck : arguments[8]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "yes_text")){ yes_text = ρσ_kwargs_obj.yes_text; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "no_text")){ no_text = ρσ_kwargs_obj.no_text; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "skip_dialog_name")){ skip_dialog_name = ρσ_kwargs_obj.skip_dialog_name; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "skip_dialog_msg")){ skip_dialog_msg = ρσ_kwargs_obj.skip_dialog_msg; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "skip_dialog_skipped_value")){ skip_dialog_skipped_value = ρσ_kwargs_obj.skip_dialog_skipped_value; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "skip_dialog_skip_precheck")){ skip_dialog_skip_precheck = ρσ_kwargs_obj.skip_dialog_skip_precheck; } var called, skip_box, sd, skipped_dialogs; yes_text = yes_text || _("Yes"); no_text = no_text || _("No"); called = Object.create(null); function keyaction(yes, close_modal) { var sd, skipped_dialogs; if (called.done) { return; } called.done = true; if (skip_dialog_name) { if (!skip_box.querySelector("input").checked) { sd = get_session_data(); skipped_dialogs = Object.assign({}, sd.get("skipped_dialogs", {})); skipped_dialogs[(typeof skip_dialog_name === "number" && skip_dialog_name < 0) ? skipped_dialogs.length + skip_dialog_name : skip_dialog_name] = (new Date).toISOString(); sd.set("skipped_dialogs", skipped_dialogs); } } if (close_modal) { close_modal(); } callback(yes); }; if (!keyaction.__argnames__) Object.defineProperties(keyaction, { __argnames__ : {value: ["yes", "close_modal"]}, __module__ : {value: "modals"} }); function on_keydown(event, close_modal) { if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) { return; } if (event.key === "Escape" || event.key === "Esc") { [event.preventDefault(), event.stopPropagation()]; keyaction(false, close_modal); } if (event.key === "Enter" || event.key === "Return" || event.key === "Space") { [event.preventDefault(), event.stopPropagation()]; keyaction(true, close_modal); } }; if (!on_keydown.__argnames__) Object.defineProperties(on_keydown, { __argnames__ : {value: ["event", "close_modal"]}, __module__ : {value: "modals"} }); skip_box = ρσ_interpolate_kwargs.call(E, E.div, [ρσ_desugar_kwargs({style: "margin-top: 2ex;"})]); if (skip_dialog_name) { sd = get_session_data(); skipped_dialogs = sd.get("skipped_dialogs", {}); if (skipped_dialogs[(typeof skip_dialog_name === "number" && skip_dialog_name < 0) ? skipped_dialogs.length + skip_dialog_name : skip_dialog_name]) { return callback(skip_dialog_skipped_value); } skip_dialog_msg = skip_dialog_msg || _("Show this confirmation again"); skip_box.appendChild(E.label(ρσ_interpolate_kwargs.call(E, E.input, [ρσ_desugar_kwargs({type: "checkbox", name: "skip_dialog"})]), " ", skip_dialog_msg)); if (skip_dialog_skip_precheck) { skip_box.querySelector("input").checked = true; } } else { skip_box.style.display = "none"; } ρσ_interpolate_kwargs.call(this, create_custom_dialog, [title, (function() { var ρσ_anonfunc = function (parent, close_modal) { parent.appendChild(E.div(E.div(msg), skip_box, ρσ_interpolate_kwargs.call(E, E.div, [create_button(no_text, "close", keyaction.bind(null, false, close_modal)), ρσ_interpolate_kwargs.call(this, create_button, [yes_text, "check", keyaction.bind(null, true, close_modal)].concat([ρσ_desugar_kwargs({highlight: true})]))].concat([ρσ_desugar_kwargs({class_: "button-box"})])))); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["parent", "close_modal"]}, __module__ : {value: "modals"} }); return ρσ_anonfunc; })()].concat([ρσ_desugar_kwargs({on_close: keyaction.bind(null, false, null), onkeydown: on_keydown})])); }; if (!question_dialog.__defaults__) Object.defineProperties(question_dialog, { __defaults__ : {value: {yes_text:null, no_text:null, skip_dialog_name:null, skip_dialog_msg:null, skip_dialog_skipped_value:true, skip_dialog_skip_precheck:true}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["title", "msg", "callback", "yes_text", "no_text", "skip_dialog_name", "skip_dialog_msg", "skip_dialog_skipped_value", "skip_dialog_skip_precheck"]}, __module__ : {value: "modals"} }); function create_modal_container() { if (modal_container === null) { modal_container = new ModalContainer; } return modal_container; }; if (!create_modal_container.__module__) Object.defineProperties(create_modal_container, { __module__ : {value: "modals"} }); function show_modal() { var create_func = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var on_close = (arguments[1] === undefined || ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? show_modal.__defaults__.on_close : arguments[1]; var show_close = (arguments[2] === undefined || ( 2 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? show_modal.__defaults__.show_close : arguments[2]; var onkeydown = (arguments[3] === undefined || ( 3 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? show_modal.__defaults__.onkeydown : arguments[3]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "on_close")){ on_close = ρσ_kwargs_obj.on_close; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "show_close")){ show_close = ρσ_kwargs_obj.show_close; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "onkeydown")){ onkeydown = ρσ_kwargs_obj.onkeydown; } return modal_container.show_modal(create_func, on_close, show_close, onkeydown); }; if (!show_modal.__defaults__) Object.defineProperties(show_modal, { __defaults__ : {value: {on_close:null, show_close:true, onkeydown:null}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["create_func", "on_close", "show_close", "onkeydown"]}, __module__ : {value: "modals"} }); function close_all_modals() { return modal_container.close_all_modals(); }; if (!close_all_modals.__module__) Object.defineProperties(close_all_modals, { __module__ : {value: "modals"} }); function error_dialog() { var title = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var msg = ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[1]; var details = (arguments[2] === undefined || ( 2 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? error_dialog.__defaults__.details : arguments[2]; var on_close = (arguments[3] === undefined || ( 3 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? error_dialog.__defaults__.on_close : arguments[3]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "details")){ details = ρσ_kwargs_obj.details; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "on_close")){ on_close = ρσ_kwargs_obj.on_close; } create_simple_dialog(title, msg, details, "bug", _("Error:"), on_close); }; if (!error_dialog.__defaults__) Object.defineProperties(error_dialog, { __defaults__ : {value: {details:null, on_close:null}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["title", "msg", "details", "on_close"]}, __module__ : {value: "modals"} }); function warning_dialog() { var title = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var msg = ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[1]; var details = (arguments[2] === undefined || ( 2 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? warning_dialog.__defaults__.details : arguments[2]; var on_close = (arguments[3] === undefined || ( 3 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? warning_dialog.__defaults__.on_close : arguments[3]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "details")){ details = ρσ_kwargs_obj.details; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "on_close")){ on_close = ρσ_kwargs_obj.on_close; } create_simple_dialog(title, msg, details, "warning", _("Warning:"), on_close); }; if (!warning_dialog.__defaults__) Object.defineProperties(warning_dialog, { __defaults__ : {value: {details:null, on_close:null}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["title", "msg", "details", "on_close"]}, __module__ : {value: "modals"} }); ρσ_modules.modals.modal_container = modal_container; ρσ_modules.modals.modal_count = modal_count; ρσ_modules.modals.Modal = Modal; ρσ_modules.modals.ModalContainer = ModalContainer; ρσ_modules.modals.create_simple_dialog_markup = create_simple_dialog_markup; ρσ_modules.modals.create_simple_dialog = create_simple_dialog; ρσ_modules.modals.create_custom_dialog = create_custom_dialog; ρσ_modules.modals.get_text_dialog = get_text_dialog; ρσ_modules.modals.question_dialog = question_dialog; ρσ_modules.modals.create_modal_container = create_modal_container; ρσ_modules.modals.show_modal = show_modal; ρσ_modules.modals.close_all_modals = close_all_modals; ρσ_modules.modals.error_dialog = error_dialog; ρσ_modules.modals.warning_dialog = warning_dialog; })(); (function(){ var __name__ = "qt"; var special_title, slots, to_python; special_title = "__webengine_messages_pending__"; slots = Object.create(null); function ping(suffix) { document.title = special_title + suffix; }; if (!ping.__argnames__) Object.defineProperties(ping, { __argnames__ : {value: ["suffix"]}, __module__ : {value: "qt"} }); function signal() { var args; args = Array.from(arguments); to_python._queue_message((function(){ var ρσ_d = Object.create(null); ρσ_d["type"] = "signal"; ρσ_d["name"] = this; ρσ_d["args"] = args; return ρσ_d; }).call(this)); }; if (!signal.__module__) Object.defineProperties(signal, { __module__ : {value: "qt"} }); function ToPython() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); ToPython.prototype.__bind_methods__.call(this); ToPython.prototype.__init__.apply(this, arguments); } Object.defineProperty(ToPython.prototype, "__bind_methods__", {value: function () { this._ping = ToPython.prototype._ping.bind(this); this._queue_message = ToPython.prototype._queue_message.bind(this); this._register_signals = ToPython.prototype._register_signals.bind(this); this._poll = ToPython.prototype._poll.bind(this); this._from_python = ToPython.prototype._from_python.bind(this); }}); ToPython.prototype.__init__ = function __init__() { var self = this; self._messages = []; self._last_ping_value = 0; self._ping_timer_id = -1; self._queue_message((function(){ var ρσ_d = Object.create(null); ρσ_d["type"] = "qt-ready"; return ρσ_d; }).call(this)); }; if (!ToPython.prototype.__init__.__module__) Object.defineProperties(ToPython.prototype.__init__, { __module__ : {value: "qt"} }); ToPython.__argnames__ = ToPython.prototype.__init__.__argnames__; ToPython.__handles_kwarg_interpolation__ = ToPython.prototype.__init__.__handles_kwarg_interpolation__; ToPython.prototype._ping = function _ping() { var self = this; if (self._ping_timer_id < 0) { self._last_ping_value = (self._last_ping_value) ? 0 : 1; self._ping_timer_id = setTimeout((function() { var ρσ_anonfunc = function () { ping(self._last_ping_value); self._ping_timer_id = -1; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "qt"} }); return ρσ_anonfunc; })(), 0); } }; if (!ToPython.prototype._ping.__module__) Object.defineProperties(ToPython.prototype._ping, { __module__ : {value: "qt"} }); ToPython.prototype._queue_message = function _queue_message(msg) { var self = this; self._messages.push(msg); self._ping(); }; if (!ToPython.prototype._queue_message.__argnames__) Object.defineProperties(ToPython.prototype._queue_message, { __argnames__ : {value: ["msg"]}, __module__ : {value: "qt"} }); ToPython.prototype._register_signals = function _register_signals(signals) { var self = this; var signal_name; var ρσ_Iter49 = signals; ρσ_Iter49 = ((typeof ρσ_Iter49[Symbol.iterator] === "function") ? (ρσ_Iter49 instanceof Map ? ρσ_Iter49.keys() : ρσ_Iter49) : Object.keys(ρσ_Iter49)); for (var ρσ_Index49 of ρσ_Iter49) { signal_name = ρσ_Index49; self[(typeof signal_name === "number" && signal_name < 0) ? self.length + signal_name : signal_name] = signal.bind(signal_name); } }; if (!ToPython.prototype._register_signals.__argnames__) Object.defineProperties(ToPython.prototype._register_signals, { __argnames__ : {value: ["signals"]}, __module__ : {value: "qt"} }); ToPython.prototype._poll = function _poll() { var self = this; var ans; ans = self._messages; self._messages = []; return ans; }; if (!ToPython.prototype._poll.__module__) Object.defineProperties(ToPython.prototype._poll, { __module__ : {value: "qt"} }); ToPython.prototype._from_python = function _from_python(name, args) { var self = this; var callback; callback = slots[(typeof name === "number" && name < 0) ? slots.length + name : name]; if (callback) { callback.apply(null, args); } else { console.warn("Attempt to call non-existent python-to-js slot named: " + ρσ_str.format("{}", name) + ""); } }; if (!ToPython.prototype._from_python.__argnames__) Object.defineProperties(ToPython.prototype._from_python, { __argnames__ : {value: ["name", "args"]}, __module__ : {value: "qt"} }); ToPython.prototype.__repr__ = function __repr__ () { return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; ToPython.prototype.__str__ = function __str__ () { return this.__repr__(); }; Object.defineProperty(ToPython.prototype, "__bases__", {value: []}); to_python = null; if (window === window.top) { window.python_comm = to_python = new ToPython; } function from_python(func) { slots[ρσ_bound_index(func.name, slots)] = func; return func; }; if (!from_python.__argnames__) Object.defineProperties(from_python, { __argnames__ : {value: ["func"]}, __module__ : {value: "qt"} }); ρσ_modules.qt.special_title = special_title; ρσ_modules.qt.slots = slots; ρσ_modules.qt.to_python = to_python; ρσ_modules.qt.ping = ping; ρσ_modules.qt.signal = signal; ρσ_modules.qt.ToPython = ToPython; ρσ_modules.qt.from_python = from_python; })(); (function(){ var __name__ = "read_book"; })(); (function(){ var __name__ = "book_list.constants"; var book_list_container_id, read_book_container_id, cs_top_bar_host_id, INIT_ENDPOINT; book_list_container_id = "book-list-container"; read_book_container_id = "read-book-container"; cs_top_bar_host_id = "cs-top-bar-host"; INIT_ENDPOINT = "interface-data/init"; ρσ_modules["book_list.constants"].book_list_container_id = book_list_container_id; ρσ_modules["book_list.constants"].read_book_container_id = read_book_container_id; ρσ_modules["book_list.constants"].cs_top_bar_host_id = cs_top_bar_host_id; ρσ_modules["book_list.constants"].INIT_ENDPOINT = INIT_ENDPOINT; })(); (function(){ var __name__ = "aes"; var string_to_bytes, bytes_to_string, number_of_rounds, rcon, S, Si, T1, T2, T3, T4, T5, T6, T7, T8, U1, U2, U3, U4, random_bytes, noderandom; function string_to_bytes_encoder(string) { return new TextEncoder("utf-8").encode(string + ""); }; if (!string_to_bytes_encoder.__argnames__) Object.defineProperties(string_to_bytes_encoder, { __argnames__ : {value: ["string"]}, __module__ : {value: "aes"} }); function string_to_bytes_slow(string) { var escstr, binstr, ua, ρσ_unpack, i, ch; escstr = encodeURIComponent(string); binstr = escstr.replace(/%([0-9A-F]{2})/g, (function() { var ρσ_anonfunc = function (match, p1) { return String.fromCharCode("0x" + p1); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["match", "p1"]}, __module__ : {value: "aes"} }); return ρσ_anonfunc; })()); ua = new Uint8Array(binstr.length); var ρσ_Iter50 = enumerate(binstr); ρσ_Iter50 = ((typeof ρσ_Iter50[Symbol.iterator] === "function") ? (ρσ_Iter50 instanceof Map ? ρσ_Iter50.keys() : ρσ_Iter50) : Object.keys(ρσ_Iter50)); for (var ρσ_Index50 of ρσ_Iter50) { ρσ_unpack = ρσ_Index50; i = ρσ_unpack[0]; ch = ρσ_unpack[1]; ua[(typeof i === "number" && i < 0) ? ua.length + i : i] = ch.charCodeAt(0); } return ua; }; if (!string_to_bytes_slow.__argnames__) Object.defineProperties(string_to_bytes_slow, { __argnames__ : {value: ["string"]}, __module__ : {value: "aes"} }); function bytes_to_string_decoder(bytes, offset) { offset = offset || 0; if (offset) { bytes = bytes.subarray(offset); } return new TextDecoder("utf-8").decode(bytes); }; if (!bytes_to_string_decoder.__argnames__) Object.defineProperties(bytes_to_string_decoder, { __argnames__ : {value: ["bytes", "offset"]}, __module__ : {value: "aes"} }); function bytes_to_string_slow(bytes, offset) { var ans, i, c; ans = []; i = offset || 0; while (i < bytes.length) { c = bytes[(typeof i === "number" && i < 0) ? bytes.length + i : i]; if (c < 128) { ans.push(String.fromCharCode(c)); i += 1; } else if (191 < c && c < 224) { ans.push(String.fromCharCode((c & 31) << 6 | bytes[ρσ_bound_index(i + 1, bytes)] & 63)); i += 2; } else { ans.push(String.fromCharCode((c & 15) << 12 | (bytes[ρσ_bound_index(i + 1, bytes)] & 63) << 6 | bytes[ρσ_bound_index(i + 2, bytes)] & 63)); i += 3; } } return ans.join(""); }; if (!bytes_to_string_slow.__argnames__) Object.defineProperties(bytes_to_string_slow, { __argnames__ : {value: ["bytes", "offset"]}, __module__ : {value: "aes"} }); string_to_bytes = (typeof TextEncoder === "function") ? string_to_bytes_encoder : string_to_bytes_slow; bytes_to_string = (typeof TextDecoder === "function") ? bytes_to_string_decoder : bytes_to_string_slow; function convert_to_int32(bytes, output, offset, length) { offset = offset || 0; length = length || bytes.length; for (var i = offset, j = 0; i < offset + length; i += 4, j++) { output[(typeof j === "number" && j < 0) ? output.length + j : j] = bytes[(typeof i === "number" && i < 0) ? bytes.length + i : i] << 24 | bytes[ρσ_bound_index(i + 1, bytes)] << 16 | bytes[ρσ_bound_index(i + 2, bytes)] << 8 | bytes[ρσ_bound_index(i + 3, bytes)]; } }; if (!convert_to_int32.__argnames__) Object.defineProperties(convert_to_int32, { __argnames__ : {value: ["bytes", "output", "offset", "length"]}, __module__ : {value: "aes"} }); function convert_to_int32_pad(bytes) { var extra, t, ans; extra = bytes.length % 4; if (extra) { t = new Uint8Array(bytes.length + 4 - extra); t.set(bytes); bytes = t; } ans = new Uint32Array(bytes.length / 4); convert_to_int32(bytes, ans); return ans; }; if (!convert_to_int32_pad.__argnames__) Object.defineProperties(convert_to_int32_pad, { __argnames__ : {value: ["bytes"]}, __module__ : {value: "aes"} }); if (!Uint8Array.prototype.fill) { Uint32Array.prototype.fill = (function() { var ρσ_anonfunc = function (val, start, end) { start = start || 0; if (end === undefined) { end = this.length; } if (start < 0) { start += this.length; } if (end < 0) { end += this.length; } for (var i = start; i < end; i++) { (ρσ_expr_temp = this)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] = val; } }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["val", "start", "end"]}, __module__ : {value: "aes"} }); return ρσ_anonfunc; })(); Uint8Array.prototype.fill = Uint32Array.prototype.fill; } function from_64_to_32(num) { var ans; ans = new Uint32Array(2); ans[0] = num / 4294967296 | 0; ans[1] = num & 4294967295; return ans; }; if (!from_64_to_32.__argnames__) Object.defineProperties(from_64_to_32, { __argnames__ : {value: ["num"]}, __module__ : {value: "aes"} }); number_of_rounds = (function(){ var ρσ_d = {}; ρσ_d[16] = 10; ρσ_d[24] = 12; ρσ_d[32] = 14; return ρσ_d; }).call(this); rcon = new Uint32Array([ 1, 2, 4, 8, 16, 32, 64, 128, 27, 54, 108, 216, 171, 77, 154, 47, 94, 188, 99, 198, 151, 53, 106, 212, 179, 125, 250, 239, 197, 145 ]); S = new Uint32Array([ 99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171, 118, 202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114, 192, 183, 253, 147, 38, 54, 63, 247, 204, 52, 165, 229, 241, 113, 216, 49, 21, 4, 199, 35, 195, 24, 150, 5, 154, 7, 18, 128, 226, 235, 39, 178, 117, 9, 131, 44, 26, 27, 110, 90, 160, 82, 59, 214, 179, 41, 227, 47, 132, 83, 209, 0, 237, 32, 252, 177, 91, 106, 203, 190, 57, 74, 76, 88, 207, 208, 239, 170, 251, 67, 77, 51, 133, 69, 249, 2, 127, 80, 60, 159, 168, 81, 163, 64, 143, 146, 157, 56, 245, 188, 182, 218, 33, 16, 255, 243, 210, 205, 12, 19, 236, 95, 151, 68, 23, 196, 167, 126, 61, 100, 93, 25, 115, 96, 129, 79, 220, 34, 42, 144, 136, 70, 238, 184, 20, 222, 94, 11, 219, 224, 50, 58, 10, 73, 6, 36, 92, 194, 211, 172, 98, 145, 149, 228, 121, 231, 200, 55, 109, 141, 213, 78, 169, 108, 86, 244, 234, 101, 122, 174, 8, 186, 120, 37, 46, 28, 166, 180, 198, 232, 221, 116, 31, 75, 189, 139, 138, 112, 62, 181, 102, 72, 3, 246, 14, 97, 53, 87, 185, 134, 193, 29, 158, 225, 248, 152, 17, 105, 217, 142, 148, 155, 30, 135, 233, 206, 85, 40, 223, 140, 161, 137, 13, 191, 230, 66, 104, 65, 153, 45, 15, 176, 84, 187, 22 ]); Si = new Uint32Array([ 82, 9, 106, 213, 48, 54, 165, 56, 191, 64, 163, 158, 129, 243, 215, 251, 124, 227, 57, 130, 155, 47, 255, 135, 52, 142, 67, 68, 196, 222, 233, 203, 84, 123, 148, 50, 166, 194, 35, 61, 238, 76, 149, 11, 66, 250, 195, 78, 8, 46, 161, 102, 40, 217, 36, 178, 118, 91, 162, 73, 109, 139, 209, 37, 114, 248, 246, 100, 134, 104, 152, 22, 212, 164, 92, 204, 93, 101, 182, 146, 108, 112, 72, 80, 253, 237, 185, 218, 94, 21, 70, 87, 167, 141, 157, 132, 144, 216, 171, 0, 140, 188, 211, 10, 247, 228, 88, 5, 184, 179, 69, 6, 208, 44, 30, 143, 202, 63, 15, 2, 193, 175, 189, 3, 1, 19, 138, 107, 58, 145, 17, 65, 79, 103, 220, 234, 151, 242, 207, 206, 240, 180, 230, 115, 150, 172, 116, 34, 231, 173, 53, 133, 226, 249, 55, 232, 28, 117, 223, 110, 71, 241, 26, 113, 29, 41, 197, 137, 111, 183, 98, 14, 170, 24, 190, 27, 252, 86, 62, 75, 198, 210, 121, 32, 154, 219, 192, 254, 120, 205, 90, 244, 31, 221, 168, 51, 136, 7, 199, 49, 177, 18, 16, 89, 39, 128, 236, 95, 96, 81, 127, 169, 25, 181, 74, 13, 45, 229, 122, 159, 147, 201, 156, 239, 160, 224, 59, 77, 174, 42, 245, 176, 200, 235, 187, 60, 131, 83, 153, 97, 23, 43, 4, 126, 186, 119, 214, 38, 225, 105, 20, 99, 85, 33, 12, 125 ]); T1 = new Uint32Array([ 3328402341, 4168907908, 4000806809, 4135287693, 4294111757, 3597364157, 3731845041, 2445657428, 1613770832, 33620227, 3462883241, 1445669757, 3892248089, 3050821474, 1303096294, 3967186586, 2412431941, 528646813, 2311702848, 4202528135, 4026202645, 2992200171, 2387036105, 4226871307, 1101901292, 3017069671, 1604494077, 1169141738, 597466303, 1403299063, 3832705686, 2613100635, 1974974402, 3791519004, 1033081774, 1277568618, 1815492186, 2118074177, 4126668546, 2211236943, 1748251740, 1369810420, 3521504564, 4193382664, 3799085459, 2883115123, 1647391059, 706024767, 134480908, 2512897874, 1176707941, 2646852446, 806885416, 932615841, 168101135, 798661301, 235341577, 605164086, 461406363, 3756188221, 3454790438, 1311188841, 2142417613, 3933566367, 302582043, 495158174, 1479289972, 874125870, 907746093, 3698224818, 3025820398, 1537253627, 2756858614, 1983593293, 3084310113, 2108928974, 1378429307, 3722699582, 1580150641, 327451799, 2790478837, 3117535592, 0, 3253595436, 1075847264, 3825007647, 2041688520, 3059440621, 3563743934, 2378943302, 1740553945, 1916352843, 2487896798, 2555137236, 2958579944, 2244988746, 3151024235, 3320835882, 1336584933, 3992714006, 2252555205, 2588757463, 1714631509, 293963156, 2319795663, 3925473552, 67240454, 4269768577, 2689618160, 2017213508, 631218106, 1269344483, 2723238387, 1571005438, 2151694528, 93294474, 1066570413, 563977660, 1882732616, 4059428100, 1673313503, 2008463041, 2950355573, 1109467491, 537923632, 3858759450, 4260623118, 3218264685, 2177748300, 403442708, 638784309, 3287084079, 3193921505, 899127202, 2286175436, 773265209, 2479146071, 1437050866, 4236148354, 2050833735, 3362022572, 3126681063, 840505643, 3866325909, 3227541664, 427917720, 2655997905, 2749160575, 1143087718, 1412049534, 999329963, 193497219, 2353415882, 3354324521, 1807268051, 672404540, 2816401017, 3160301282, 369822493, 2916866934, 3688947771, 1681011286, 1949973070, 336202270, 2454276571, 201721354, 1210328172, 3093060836, 2680341085, 3184776046, 1135389935, 3294782118, 965841320, 831886756, 3554993207, 4068047243, 3588745010, 2345191491, 1849112409, 3664604599, 26054028, 2983581028, 2622377682, 1235855840, 3630984372, 2891339514, 4092916743, 3488279077, 3395642799, 4101667470, 1202630377, 268961816, 1874508501, 4034427016, 1243948399, 1546530418, 941366308, 1470539505, 1941222599, 2546386513, 3421038627, 2715671932, 3899946140, 1042226977, 2521517021, 1639824860, 227249030, 260737669, 3765465232, 2084453954, 1907733956, 3429263018, 2420656344, 100860677, 4160157185, 470683154, 3261161891, 1781871967, 2924959737, 1773779408, 394692241, 2579611992, 974986535, 664706745, 3655459128, 3958962195, 731420851, 571543859, 3530123707, 2849626480, 126783113, 865375399, 765172662, 1008606754, 361203602, 3387549984, 2278477385, 2857719295, 1344809080, 2782912378, 59542671, 1503764984, 160008576, 437062935, 1707065306, 3622233649, 2218934982, 3496503480, 2185314755, 697932208, 1512910199, 504303377, 2075177163, 2824099068, 1841019862, 739644986 ]); T2 = new Uint32Array([ 2781242211, 2230877308, 2582542199, 2381740923, 234877682, 3184946027, 2984144751, 1418839493, 1348481072, 50462977, 2848876391, 2102799147, 434634494, 1656084439, 3863849899, 2599188086, 1167051466, 2636087938, 1082771913, 2281340285, 368048890, 3954334041, 3381544775, 201060592, 3963727277, 1739838676, 4250903202, 3930435503, 3206782108, 4149453988, 2531553906, 1536934080, 3262494647, 484572669, 2923271059, 1783375398, 1517041206, 1098792767, 49674231, 1334037708, 1550332980, 4098991525, 886171109, 150598129, 2481090929, 1940642008, 1398944049, 1059722517, 201851908, 1385547719, 1699095331, 1587397571, 674240536, 2704774806, 252314885, 3039795866, 151914247, 908333586, 2602270848, 1038082786, 651029483, 1766729511, 3447698098, 2682942837, 454166793, 2652734339, 1951935532, 775166490, 758520603, 3000790638, 4004797018, 4217086112, 4137964114, 1299594043, 1639438038, 3464344499, 2068982057, 1054729187, 1901997871, 2534638724, 4121318227, 1757008337, 0, 750906861, 1614815264, 535035132, 3363418545, 3988151131, 3201591914, 1183697867, 3647454910, 1265776953, 3734260298, 3566750796, 3903871064, 1250283471, 1807470800, 717615087, 3847203498, 384695291, 3313910595, 3617213773, 1432761139, 2484176261, 3481945413, 283769337, 100925954, 2180939647, 4037038160, 1148730428, 3123027871, 3813386408, 4087501137, 4267549603, 3229630528, 2315620239, 2906624658, 3156319645, 1215313976, 82966005, 3747855548, 3245848246, 1974459098, 1665278241, 807407632, 451280895, 251524083, 1841287890, 1283575245, 337120268, 891687699, 801369324, 3787349855, 2721421207, 3431482436, 959321879, 1469301956, 4065699751, 2197585534, 1199193405, 2898814052, 3887750493, 724703513, 2514908019, 2696962144, 2551808385, 3516813135, 2141445340, 1715741218, 2119445034, 2872807568, 2198571144, 3398190662, 700968686, 3547052216, 1009259540, 2041044702, 3803995742, 487983883, 1991105499, 1004265696, 1449407026, 1316239930, 504629770, 3683797321, 168560134, 1816667172, 3837287516, 1570751170, 1857934291, 4014189740, 2797888098, 2822345105, 2754712981, 936633572, 2347923833, 852879335, 1133234376, 1500395319, 3084545389, 2348912013, 1689376213, 3533459022, 3762923945, 3034082412, 4205598294, 133428468, 634383082, 2949277029, 2398386810, 3913789102, 403703816, 3580869306, 2297460856, 1867130149, 1918643758, 607656988, 4049053350, 3346248884, 1368901318, 600565992, 2090982877, 2632479860, 557719327, 3717614411, 3697393085, 2249034635, 2232388234, 2430627952, 1115438654, 3295786421, 2865522278, 3633334344, 84280067, 33027830, 303828494, 2747425121, 1600795957, 4188952407, 3496589753, 2434238086, 1486471617, 658119965, 3106381470, 953803233, 334231800, 3005978776, 857870609, 3151128937, 1890179545, 2298973838, 2805175444, 3056442267, 574365214, 2450884487, 550103529, 1233637070, 4289353045, 2018519080, 2057691103, 2399374476, 4166623649, 2148108681, 387583245, 3664101311, 836232934, 3330556482, 3100665960, 3280093505, 2955516313, 2002398509, 287182607, 3413881008, 4238890068, 3597515707, 975967766 ]); T3 = new Uint32Array([ 1671808611, 2089089148, 2006576759, 2072901243, 4061003762, 1807603307, 1873927791, 3310653893, 810573872, 16974337, 1739181671, 729634347, 4263110654, 3613570519, 2883997099, 1989864566, 3393556426, 2191335298, 3376449993, 2106063485, 4195741690, 1508618841, 1204391495, 4027317232, 2917941677, 3563566036, 2734514082, 2951366063, 2629772188, 2767672228, 1922491506, 3227229120, 3082974647, 4246528509, 2477669779, 644500518, 911895606, 1061256767, 4144166391, 3427763148, 878471220, 2784252325, 3845444069, 4043897329, 1905517169, 3631459288, 827548209, 356461077, 67897348, 3344078279, 593839651, 3277757891, 405286936, 2527147926, 84871685, 2595565466, 118033927, 305538066, 2157648768, 3795705826, 3945188843, 661212711, 2999812018, 1973414517, 152769033, 2208177539, 745822252, 439235610, 455947803, 1857215598, 1525593178, 2700827552, 1391895634, 994932283, 3596728278, 3016654259, 695947817, 3812548067, 795958831, 2224493444, 1408607827, 3513301457, 0, 3979133421, 543178784, 4229948412, 2982705585, 1542305371, 1790891114, 3410398667, 3201918910, 961245753, 1256100938, 1289001036, 1491644504, 3477767631, 3496721360, 4012557807, 2867154858, 4212583931, 1137018435, 1305975373, 861234739, 2241073541, 1171229253, 4178635257, 33948674, 2139225727, 1357946960, 1011120188, 2679776671, 2833468328, 1374921297, 2751356323, 1086357568, 2408187279, 2460827538, 2646352285, 944271416, 4110742005, 3168756668, 3066132406, 3665145818, 560153121, 271589392, 4279952895, 4077846003, 3530407890, 3444343245, 202643468, 322250259, 3962553324, 1608629855, 2543990167, 1154254916, 389623319, 3294073796, 2817676711, 2122513534, 1028094525, 1689045092, 1575467613, 422261273, 1939203699, 1621147744, 2174228865, 1339137615, 3699352540, 577127458, 712922154, 2427141008, 2290289544, 1187679302, 3995715566, 3100863416, 339486740, 3732514782, 1591917662, 186455563, 3681988059, 3762019296, 844522546, 978220090, 169743370, 1239126601, 101321734, 611076132, 1558493276, 3260915650, 3547250131, 2901361580, 1655096418, 2443721105, 2510565781, 3828863972, 2039214713, 3878868455, 3359869896, 928607799, 1840765549, 2374762893, 3580146133, 1322425422, 2850048425, 1823791212, 1459268694, 4094161908, 3928346602, 1706019429, 2056189050, 2934523822, 135794696, 3134549946, 2022240376, 628050469, 779246638, 472135708, 2800834470, 3032970164, 3327236038, 3894660072, 3715932637, 1956440180, 522272287, 1272813131, 3185336765, 2340818315, 2323976074, 1888542832, 1044544574, 3049550261, 1722469478, 1222152264, 50660867, 4127324150, 236067854, 1638122081, 895445557, 1475980887, 3117443513, 2257655686, 3243809217, 489110045, 2662934430, 3778599393, 4162055160, 2561878936, 288563729, 1773916777, 3648039385, 2391345038, 2493985684, 2612407707, 505560094, 2274497927, 3911240169, 3460925390, 1442818645, 678973480, 3749357023, 2358182796, 2717407649, 2306869641, 219617805, 3218761151, 3862026214, 1120306242, 1756942440, 1103331905, 2578459033, 762796589, 252780047, 2966125488, 1425844308, 3151392187, 372911126 ]); T4 = new Uint32Array([ 1667474886, 2088535288, 2004326894, 2071694838, 4075949567, 1802223062, 1869591006, 3318043793, 808472672, 16843522, 1734846926, 724270422, 4278065639, 3621216949, 2880169549, 1987484396, 3402253711, 2189597983, 3385409673, 2105378810, 4210693615, 1499065266, 1195886990, 4042263547, 2913856577, 3570689971, 2728590687, 2947541573, 2627518243, 2762274643, 1920112356, 3233831835, 3082273397, 4261223649, 2475929149, 640051788, 909531756, 1061110142, 4160160501, 3435941763, 875846760, 2779116625, 3857003729, 4059105529, 1903268834, 3638064043, 825316194, 353713962, 67374088, 3351728789, 589522246, 3284360861, 404236336, 2526454071, 84217610, 2593830191, 117901582, 303183396, 2155911963, 3806477791, 3958056653, 656894286, 2998062463, 1970642922, 151591698, 2206440989, 741110872, 437923380, 454765878, 1852748508, 1515908788, 2694904667, 1381168804, 993742198, 3604373943, 3014905469, 690584402, 3823320797, 791638366, 2223281939, 1398011302, 3520161977, 0, 3991743681, 538992704, 4244381667, 2981218425, 1532751286, 1785380564, 3419096717, 3200178535, 960056178, 1246420628, 1280103576, 1482221744, 3486468741, 3503319995, 4025428677, 2863326543, 4227536621, 1128514950, 1296947098, 859002214, 2240123921, 1162203018, 4193849577, 33687044, 2139062782, 1347481760, 1010582648, 2678045221, 2829640523, 1364325282, 2745433693, 1077985408, 2408548869, 2459086143, 2644360225, 943212656, 4126475505, 3166494563, 3065430391, 3671750063, 555836226, 269496352, 4294908645, 4092792573, 3537006015, 3452783745, 202118168, 320025894, 3974901699, 1600119230, 2543297077, 1145359496, 387397934, 3301201811, 2812801621, 2122220284, 1027426170, 1684319432, 1566435258, 421079858, 1936954854, 1616945344, 2172753945, 1330631070, 3705438115, 572679748, 707427924, 2425400123, 2290647819, 1179044492, 4008585671, 3099120491, 336870440, 3739122087, 1583276732, 185277718, 3688593069, 3772791771, 842159716, 976899700, 168435220, 1229577106, 101059084, 606366792, 1549591736, 3267517855, 3553849021, 2897014595, 1650632388, 2442242105, 2509612081, 3840161747, 2038008818, 3890688725, 3368567691, 926374254, 1835907034, 2374863873, 3587531953, 1313788572, 2846482505, 1819063512, 1448540844, 4109633523, 3941213647, 1701162954, 2054852340, 2930698567, 134748176, 3132806511, 2021165296, 623210314, 774795868, 471606328, 2795958615, 3031746419, 3334885783, 3907527627, 3722280097, 1953799400, 522133822, 1263263126, 3183336545, 2341176845, 2324333839, 1886425312, 1044267644, 3048588401, 1718004428, 1212733584, 50529542, 4143317495, 235803164, 1633788866, 892690282, 1465383342, 3115962473, 2256965911, 3250673817, 488449850, 2661202215, 3789633753, 4177007595, 2560144171, 286339874, 1768537042, 3654906025, 2391705863, 2492770099, 2610673197, 505291324, 2273808917, 3924369609, 3469625735, 1431699370, 673740880, 3755965093, 2358021891, 2711746649, 2307489801, 218961690, 3217021541, 3873845719, 1111672452, 1751693520, 1094828930, 2576986153, 757954394, 252645662, 2964376443, 1414855848, 3149649517, 370555436 ]); T5 = new Uint32Array([ 1374988112, 2118214995, 437757123, 975658646, 1001089995, 530400753, 2902087851, 1273168787, 540080725, 2910219766, 2295101073, 4110568485, 1340463100, 3307916247, 641025152, 3043140495, 3736164937, 632953703, 1172967064, 1576976609, 3274667266, 2169303058, 2370213795, 1809054150, 59727847, 361929877, 3211623147, 2505202138, 3569255213, 1484005843, 1239443753, 2395588676, 1975683434, 4102977912, 2572697195, 666464733, 3202437046, 4035489047, 3374361702, 2110667444, 1675577880, 3843699074, 2538681184, 1649639237, 2976151520, 3144396420, 4269907996, 4178062228, 1883793496, 2403728665, 2497604743, 1383856311, 2876494627, 1917518562, 3810496343, 1716890410, 3001755655, 800440835, 2261089178, 3543599269, 807962610, 599762354, 33778362, 3977675356, 2328828971, 2809771154, 4077384432, 1315562145, 1708848333, 101039829, 3509871135, 3299278474, 875451293, 2733856160, 92987698, 2767645557, 193195065, 1080094634, 1584504582, 3178106961, 1042385657, 2531067453, 3711829422, 1306967366, 2438237621, 1908694277, 67556463, 1615861247, 429456164, 3602770327, 2302690252, 1742315127, 2968011453, 126454664, 3877198648, 2043211483, 2709260871, 2084704233, 4169408201, 0, 159417987, 841739592, 504459436, 1817866830, 4245618683, 260388950, 1034867998, 908933415, 168810852, 1750902305, 2606453969, 607530554, 202008497, 2472011535, 3035535058, 463180190, 2160117071, 1641816226, 1517767529, 470948374, 3801332234, 3231722213, 1008918595, 303765277, 235474187, 4069246893, 766945465, 337553864, 1475418501, 2943682380, 4003061179, 2743034109, 4144047775, 1551037884, 1147550661, 1543208500, 2336434550, 3408119516, 3069049960, 3102011747, 3610369226, 1113818384, 328671808, 2227573024, 2236228733, 3535486456, 2935566865, 3341394285, 496906059, 3702665459, 226906860, 2009195472, 733156972, 2842737049, 294930682, 1206477858, 2835123396, 2700099354, 1451044056, 573804783, 2269728455, 3644379585, 2362090238, 2564033334, 2801107407, 2776292904, 3669462566, 1068351396, 742039012, 1350078989, 1784663195, 1417561698, 4136440770, 2430122216, 775550814, 2193862645, 2673705150, 1775276924, 1876241833, 3475313331, 3366754619, 270040487, 3902563182, 3678124923, 3441850377, 1851332852, 3969562369, 2203032232, 3868552805, 2868897406, 566021896, 4011190502, 3135740889, 1248802510, 3936291284, 699432150, 832877231, 708780849, 3332740144, 899835584, 1951317047, 4236429990, 3767586992, 866637845, 4043610186, 1106041591, 2144161806, 395441711, 1984812685, 1139781709, 3433712980, 3835036895, 2664543715, 1282050075, 3240894392, 1181045119, 2640243204, 25965917, 4203181171, 4211818798, 3009879386, 2463879762, 3910161971, 1842759443, 2597806476, 933301370, 1509430414, 3943906441, 3467192302, 3076639029, 3776767469, 2051518780, 2631065433, 1441952575, 404016761, 1942435775, 1408749034, 1610459739, 3745345300, 2017778566, 3400528769, 3110650942, 941896748, 3265478751, 371049330, 3168937228, 675039627, 4279080257, 967311729, 135050206, 3635733660, 1683407248, 2076935265, 3576870512, 1215061108, 3501741890 ]); T6 = new Uint32Array([ 1347548327, 1400783205, 3273267108, 2520393566, 3409685355, 4045380933, 2880240216, 2471224067, 1428173050, 4138563181, 2441661558, 636813900, 4233094615, 3620022987, 2149987652, 2411029155, 1239331162, 1730525723, 2554718734, 3781033664, 46346101, 310463728, 2743944855, 3328955385, 3875770207, 2501218972, 3955191162, 3667219033, 768917123, 3545789473, 692707433, 1150208456, 1786102409, 2029293177, 1805211710, 3710368113, 3065962831, 401639597, 1724457132, 3028143674, 409198410, 2196052529, 1620529459, 1164071807, 3769721975, 2226875310, 486441376, 2499348523, 1483753576, 428819965, 2274680428, 3075636216, 598438867, 3799141122, 1474502543, 711349675, 129166120, 53458370, 2592523643, 2782082824, 4063242375, 2988687269, 3120694122, 1559041666, 730517276, 2460449204, 4042459122, 2706270690, 3446004468, 3573941694, 533804130, 2328143614, 2637442643, 2695033685, 839224033, 1973745387, 957055980, 2856345839, 106852767, 1371368976, 4181598602, 1033297158, 2933734917, 1179510461, 3046200461, 91341917, 1862534868, 4284502037, 605657339, 2547432937, 3431546947, 2003294622, 3182487618, 2282195339, 954669403, 3682191598, 1201765386, 3917234703, 3388507166, 0, 2198438022, 1211247597, 2887651696, 1315723890, 4227665663, 1443857720, 507358933, 657861945, 1678381017, 560487590, 3516619604, 975451694, 2970356327, 261314535, 3535072918, 2652609425, 1333838021, 2724322336, 1767536459, 370938394, 182621114, 3854606378, 1128014560, 487725847, 185469197, 2918353863, 3106780840, 3356761769, 2237133081, 1286567175, 3152976349, 4255350624, 2683765030, 3160175349, 3309594171, 878443390, 1988838185, 3704300486, 1756818940, 1673061617, 3403100636, 272786309, 1075025698, 545572369, 2105887268, 4174560061, 296679730, 1841768865, 1260232239, 4091327024, 3960309330, 3497509347, 1814803222, 2578018489, 4195456072, 575138148, 3299409036, 446754879, 3629546796, 4011996048, 3347532110, 3252238545, 4270639778, 915985419, 3483825537, 681933534, 651868046, 2755636671, 3828103837, 223377554, 2607439820, 1649704518, 3270937875, 3901806776, 1580087799, 4118987695, 3198115200, 2087309459, 2842678573, 3016697106, 1003007129, 2802849917, 1860738147, 2077965243, 164439672, 4100872472, 32283319, 2827177882, 1709610350, 2125135846, 136428751, 3874428392, 3652904859, 3460984630, 3572145929, 3593056380, 2939266226, 824852259, 818324884, 3224740454, 930369212, 2801566410, 2967507152, 355706840, 1257309336, 4148292826, 243256656, 790073846, 2373340630, 1296297904, 1422699085, 3756299780, 3818836405, 457992840, 3099667487, 2135319889, 77422314, 1560382517, 1945798516, 788204353, 1521706781, 1385356242, 870912086, 325965383, 2358957921, 2050466060, 2388260884, 2313884476, 4006521127, 901210569, 3990953189, 1014646705, 1503449823, 1062597235, 2031621326, 3212035895, 3931371469, 1533017514, 350174575, 2256028891, 2177544179, 1052338372, 741876788, 1606591296, 1914052035, 213705253, 2334669897, 1107234197, 1899603969, 3725069491, 2631447780, 2422494913, 1635502980, 1893020342, 1950903388, 1120974935 ]); T7 = new Uint32Array([ 2807058932, 1699970625, 2764249623, 1586903591, 1808481195, 1173430173, 1487645946, 59984867, 4199882800, 1844882806, 1989249228, 1277555970, 3623636965, 3419915562, 1149249077, 2744104290, 1514790577, 459744698, 244860394, 3235995134, 1963115311, 4027744588, 2544078150, 4190530515, 1608975247, 2627016082, 2062270317, 1507497298, 2200818878, 567498868, 1764313568, 3359936201, 2305455554, 2037970062, 1047239e3, 1910319033, 1337376481, 2904027272, 2892417312, 984907214, 1243112415, 830661914, 861968209, 2135253587, 2011214180, 2927934315, 2686254721, 731183368, 1750626376, 4246310725, 1820824798, 4172763771, 3542330227, 48394827, 2404901663, 2871682645, 671593195, 3254988725, 2073724613, 145085239, 2280796200, 2779915199, 1790575107, 2187128086, 472615631, 3029510009, 4075877127, 3802222185, 4107101658, 3201631749, 1646252340, 4270507174, 1402811438, 1436590835, 3778151818, 3950355702, 3963161475, 4020912224, 2667994737, 273792366, 2331590177, 104699613, 95345982, 3175501286, 2377486676, 1560637892, 3564045318, 369057872, 4213447064, 3919042237, 1137477952, 2658625497, 1119727848, 2340947849, 1530455833, 4007360968, 172466556, 266959938, 516552836, 0, 2256734592, 3980931627, 1890328081, 1917742170, 4294704398, 945164165, 3575528878, 958871085, 3647212047, 2787207260, 1423022939, 775562294, 1739656202, 3876557655, 2530391278, 2443058075, 3310321856, 547512796, 1265195639, 437656594, 3121275539, 719700128, 3762502690, 387781147, 218828297, 3350065803, 2830708150, 2848461854, 428169201, 122466165, 3720081049, 1627235199, 648017665, 4122762354, 1002783846, 2117360635, 695634755, 3336358691, 4234721005, 4049844452, 3704280881, 2232435299, 574624663, 287343814, 612205898, 1039717051, 840019705, 2708326185, 793451934, 821288114, 1391201670, 3822090177, 376187827, 3113855344, 1224348052, 1679968233, 2361698556, 1058709744, 752375421, 2431590963, 1321699145, 3519142200, 2734591178, 188127444, 2177869557, 3727205754, 2384911031, 3215212461, 2648976442, 2450346104, 3432737375, 1180849278, 331544205, 3102249176, 4150144569, 2952102595, 2159976285, 2474404304, 766078933, 313773861, 2570832044, 2108100632, 1668212892, 3145456443, 2013908262, 418672217, 3070356634, 2594734927, 1852171925, 3867060991, 3473416636, 3907448597, 2614737639, 919489135, 164948639, 2094410160, 2997825956, 590424639, 2486224549, 1723872674, 3157750862, 3399941250, 3501252752, 3625268135, 2555048196, 3673637356, 1343127501, 4130281361, 3599595085, 2957853679, 1297403050, 81781910, 3051593425, 2283490410, 532201772, 1367295589, 3926170974, 895287692, 1953757831, 1093597963, 492483431, 3528626907, 1446242576, 1192455638, 1636604631, 209336225, 344873464, 1015671571, 669961897, 3375740769, 3857572124, 2973530695, 3747192018, 1933530610, 3464042516, 935293895, 3454686199, 2858115069, 1863638845, 3683022916, 4085369519, 3292445032, 875313188, 1080017571, 3279033885, 621591778, 1233856572, 2504130317, 24197544, 3017672716, 3835484340, 3247465558, 2220981195, 3060847922, 1551124588, 1463996600 ]); T8 = new Uint32Array([ 4104605777, 1097159550, 396673818, 660510266, 2875968315, 2638606623, 4200115116, 3808662347, 821712160, 1986918061, 3430322568, 38544885, 3856137295, 718002117, 893681702, 1654886325, 2975484382, 3122358053, 3926825029, 4274053469, 796197571, 1290801793, 1184342925, 3556361835, 2405426947, 2459735317, 1836772287, 1381620373, 3196267988, 1948373848, 3764988233, 3385345166, 3263785589, 2390325492, 1480485785, 3111247143, 3780097726, 2293045232, 548169417, 3459953789, 3746175075, 439452389, 1362321559, 1400849762, 1685577905, 1806599355, 2174754046, 137073913, 1214797936, 1174215055, 3731654548, 2079897426, 1943217067, 1258480242, 529487843, 1437280870, 3945269170, 3049390895, 3313212038, 923313619, 679998e3, 3215307299, 57326082, 377642221, 3474729866, 2041877159, 133361907, 1776460110, 3673476453, 96392454, 878845905, 2801699524, 777231668, 4082475170, 2330014213, 4142626212, 2213296395, 1626319424, 1906247262, 1846563261, 562755902, 3708173718, 1040559837, 3871163981, 1418573201, 3294430577, 114585348, 1343618912, 2566595609, 3186202582, 1078185097, 3651041127, 3896688048, 2307622919, 425408743, 3371096953, 2081048481, 1108339068, 2216610296, 0, 2156299017, 736970802, 292596766, 1517440620, 251657213, 2235061775, 2933202493, 758720310, 265905162, 1554391400, 1532285339, 908999204, 174567692, 1474760595, 4002861748, 2610011675, 3234156416, 3693126241, 2001430874, 303699484, 2478443234, 2687165888, 585122620, 454499602, 151849742, 2345119218, 3064510765, 514443284, 4044981591, 1963412655, 2581445614, 2137062819, 19308535, 1928707164, 1715193156, 4219352155, 1126790795, 600235211, 3992742070, 3841024952, 836553431, 1669664834, 2535604243, 3323011204, 1243905413, 3141400786, 4180808110, 698445255, 2653899549, 2989552604, 2253581325, 3252932727, 3004591147, 1891211689, 2487810577, 3915653703, 4237083816, 4030667424, 2100090966, 865136418, 1229899655, 953270745, 3399679628, 3557504664, 4118925222, 2061379749, 3079546586, 2915017791, 983426092, 2022837584, 1607244650, 2118541908, 2366882550, 3635996816, 972512814, 3283088770, 1568718495, 3499326569, 3576539503, 621982671, 2895723464, 410887952, 2623762152, 1002142683, 645401037, 1494807662, 2595684844, 1335535747, 2507040230, 4293295786, 3167684641, 367585007, 3885750714, 1865862730, 2668221674, 2960971305, 2763173681, 1059270954, 2777952454, 2724642869, 1320957812, 2194319100, 2429595872, 2815956275, 77089521, 3973773121, 3444575871, 2448830231, 1305906550, 4021308739, 2857194700, 2516901860, 3518358430, 1787304780, 740276417, 1699839814, 1592394909, 2352307457, 2272556026, 188821243, 1729977011, 3687994002, 274084841, 3594982253, 3613494426, 2701949495, 4162096729, 322734571, 2837966542, 1640576439, 484830689, 1202797690, 3537852828, 4067639125, 349075736, 3342319475, 4157467219, 4255800159, 1030690015, 1155237496, 2951971274, 1757691577, 607398968, 2738905026, 499347990, 3794078908, 1011452712, 227885567, 2818666809, 213114376, 3034881240, 1455525988, 3414450555, 850817237, 1817998408, 3092726480 ]); U1 = new Uint32Array([ 0, 235474187, 470948374, 303765277, 941896748, 908933415, 607530554, 708780849, 1883793496, 2118214995, 1817866830, 1649639237, 1215061108, 1181045119, 1417561698, 1517767529, 3767586992, 4003061179, 4236429990, 4069246893, 3635733660, 3602770327, 3299278474, 3400528769, 2430122216, 2664543715, 2362090238, 2193862645, 2835123396, 2801107407, 3035535058, 3135740889, 3678124923, 3576870512, 3341394285, 3374361702, 3810496343, 3977675356, 4279080257, 4043610186, 2876494627, 2776292904, 3076639029, 3110650942, 2472011535, 2640243204, 2403728665, 2169303058, 1001089995, 899835584, 666464733, 699432150, 59727847, 226906860, 530400753, 294930682, 1273168787, 1172967064, 1475418501, 1509430414, 1942435775, 2110667444, 1876241833, 1641816226, 2910219766, 2743034109, 2976151520, 3211623147, 2505202138, 2606453969, 2302690252, 2269728455, 3711829422, 3543599269, 3240894392, 3475313331, 3843699074, 3943906441, 4178062228, 4144047775, 1306967366, 1139781709, 1374988112, 1610459739, 1975683434, 2076935265, 1775276924, 1742315127, 1034867998, 866637845, 566021896, 800440835, 92987698, 193195065, 429456164, 395441711, 1984812685, 2017778566, 1784663195, 1683407248, 1315562145, 1080094634, 1383856311, 1551037884, 101039829, 135050206, 437757123, 337553864, 1042385657, 807962610, 573804783, 742039012, 2531067453, 2564033334, 2328828971, 2227573024, 2935566865, 2700099354, 3001755655, 3168937228, 3868552805, 3902563182, 4203181171, 4102977912, 3736164937, 3501741890, 3265478751, 3433712980, 1106041591, 1340463100, 1576976609, 1408749034, 2043211483, 2009195472, 1708848333, 1809054150, 832877231, 1068351396, 766945465, 599762354, 159417987, 126454664, 361929877, 463180190, 2709260871, 2943682380, 3178106961, 3009879386, 2572697195, 2538681184, 2236228733, 2336434550, 3509871135, 3745345300, 3441850377, 3274667266, 3910161971, 3877198648, 4110568485, 4211818798, 2597806476, 2497604743, 2261089178, 2295101073, 2733856160, 2902087851, 3202437046, 2968011453, 3936291284, 3835036895, 4136440770, 4169408201, 3535486456, 3702665459, 3467192302, 3231722213, 2051518780, 1951317047, 1716890410, 1750902305, 1113818384, 1282050075, 1584504582, 1350078989, 168810852, 67556463, 371049330, 404016761, 841739592, 1008918595, 775550814, 540080725, 3969562369, 3801332234, 4035489047, 4269907996, 3569255213, 3669462566, 3366754619, 3332740144, 2631065433, 2463879762, 2160117071, 2395588676, 2767645557, 2868897406, 3102011747, 3069049960, 202008497, 33778362, 270040487, 504459436, 875451293, 975658646, 675039627, 641025152, 2084704233, 1917518562, 1615861247, 1851332852, 1147550661, 1248802510, 1484005843, 1451044056, 933301370, 967311729, 733156972, 632953703, 260388950, 25965917, 328671808, 496906059, 1206477858, 1239443753, 1543208500, 1441952575, 2144161806, 1908694277, 1675577880, 1842759443, 3610369226, 3644379585, 3408119516, 3307916247, 4011190502, 3776767469, 4077384432, 4245618683, 2809771154, 2842737049, 3144396420, 3043140495, 2673705150, 2438237621, 2203032232, 2370213795 ]); U2 = new Uint32Array([ 0, 185469197, 370938394, 487725847, 741876788, 657861945, 975451694, 824852259, 1483753576, 1400783205, 1315723890, 1164071807, 1950903388, 2135319889, 1649704518, 1767536459, 2967507152, 3152976349, 2801566410, 2918353863, 2631447780, 2547432937, 2328143614, 2177544179, 3901806776, 3818836405, 4270639778, 4118987695, 3299409036, 3483825537, 3535072918, 3652904859, 2077965243, 1893020342, 1841768865, 1724457132, 1474502543, 1559041666, 1107234197, 1257309336, 598438867, 681933534, 901210569, 1052338372, 261314535, 77422314, 428819965, 310463728, 3409685355, 3224740454, 3710368113, 3593056380, 3875770207, 3960309330, 4045380933, 4195456072, 2471224067, 2554718734, 2237133081, 2388260884, 3212035895, 3028143674, 2842678573, 2724322336, 4138563181, 4255350624, 3769721975, 3955191162, 3667219033, 3516619604, 3431546947, 3347532110, 2933734917, 2782082824, 3099667487, 3016697106, 2196052529, 2313884476, 2499348523, 2683765030, 1179510461, 1296297904, 1347548327, 1533017514, 1786102409, 1635502980, 2087309459, 2003294622, 507358933, 355706840, 136428751, 53458370, 839224033, 957055980, 605657339, 790073846, 2373340630, 2256028891, 2607439820, 2422494913, 2706270690, 2856345839, 3075636216, 3160175349, 3573941694, 3725069491, 3273267108, 3356761769, 4181598602, 4063242375, 4011996048, 3828103837, 1033297158, 915985419, 730517276, 545572369, 296679730, 446754879, 129166120, 213705253, 1709610350, 1860738147, 1945798516, 2029293177, 1239331162, 1120974935, 1606591296, 1422699085, 4148292826, 4233094615, 3781033664, 3931371469, 3682191598, 3497509347, 3446004468, 3328955385, 2939266226, 2755636671, 3106780840, 2988687269, 2198438022, 2282195339, 2501218972, 2652609425, 1201765386, 1286567175, 1371368976, 1521706781, 1805211710, 1620529459, 2105887268, 1988838185, 533804130, 350174575, 164439672, 46346101, 870912086, 954669403, 636813900, 788204353, 2358957921, 2274680428, 2592523643, 2441661558, 2695033685, 2880240216, 3065962831, 3182487618, 3572145929, 3756299780, 3270937875, 3388507166, 4174560061, 4091327024, 4006521127, 3854606378, 1014646705, 930369212, 711349675, 560487590, 272786309, 457992840, 106852767, 223377554, 1678381017, 1862534868, 1914052035, 2031621326, 1211247597, 1128014560, 1580087799, 1428173050, 32283319, 182621114, 401639597, 486441376, 768917123, 651868046, 1003007129, 818324884, 1503449823, 1385356242, 1333838021, 1150208456, 1973745387, 2125135846, 1673061617, 1756818940, 2970356327, 3120694122, 2802849917, 2887651696, 2637442643, 2520393566, 2334669897, 2149987652, 3917234703, 3799141122, 4284502037, 4100872472, 3309594171, 3460984630, 3545789473, 3629546796, 2050466060, 1899603969, 1814803222, 1730525723, 1443857720, 1560382517, 1075025698, 1260232239, 575138148, 692707433, 878443390, 1062597235, 243256656, 91341917, 409198410, 325965383, 3403100636, 3252238545, 3704300486, 3620022987, 3874428392, 3990953189, 4042459122, 4227665663, 2460449204, 2578018489, 2226875310, 2411029155, 3198115200, 3046200461, 2827177882, 2743944855 ]); U3 = new Uint32Array([ 0, 218828297, 437656594, 387781147, 875313188, 958871085, 775562294, 590424639, 1750626376, 1699970625, 1917742170, 2135253587, 1551124588, 1367295589, 1180849278, 1265195639, 3501252752, 3720081049, 3399941250, 3350065803, 3835484340, 3919042237, 4270507174, 4085369519, 3102249176, 3051593425, 2734591178, 2952102595, 2361698556, 2177869557, 2530391278, 2614737639, 3145456443, 3060847922, 2708326185, 2892417312, 2404901663, 2187128086, 2504130317, 2555048196, 3542330227, 3727205754, 3375740769, 3292445032, 3876557655, 3926170974, 4246310725, 4027744588, 1808481195, 1723872674, 1910319033, 2094410160, 1608975247, 1391201670, 1173430173, 1224348052, 59984867, 244860394, 428169201, 344873464, 935293895, 984907214, 766078933, 547512796, 1844882806, 1627235199, 2011214180, 2062270317, 1507497298, 1423022939, 1137477952, 1321699145, 95345982, 145085239, 532201772, 313773861, 830661914, 1015671571, 731183368, 648017665, 3175501286, 2957853679, 2807058932, 2858115069, 2305455554, 2220981195, 2474404304, 2658625497, 3575528878, 3625268135, 3473416636, 3254988725, 3778151818, 3963161475, 4213447064, 4130281361, 3599595085, 3683022916, 3432737375, 3247465558, 3802222185, 4020912224, 4172763771, 4122762354, 3201631749, 3017672716, 2764249623, 2848461854, 2331590177, 2280796200, 2431590963, 2648976442, 104699613, 188127444, 472615631, 287343814, 840019705, 1058709744, 671593195, 621591778, 1852171925, 1668212892, 1953757831, 2037970062, 1514790577, 1463996600, 1080017571, 1297403050, 3673637356, 3623636965, 3235995134, 3454686199, 4007360968, 3822090177, 4107101658, 4190530515, 2997825956, 3215212461, 2830708150, 2779915199, 2256734592, 2340947849, 2627016082, 2443058075, 172466556, 122466165, 273792366, 492483431, 1047239e3, 861968209, 612205898, 695634755, 1646252340, 1863638845, 2013908262, 1963115311, 1446242576, 1530455833, 1277555970, 1093597963, 1636604631, 1820824798, 2073724613, 1989249228, 1436590835, 1487645946, 1337376481, 1119727848, 164948639, 81781910, 331544205, 516552836, 1039717051, 821288114, 669961897, 719700128, 2973530695, 3157750862, 2871682645, 2787207260, 2232435299, 2283490410, 2667994737, 2450346104, 3647212047, 3564045318, 3279033885, 3464042516, 3980931627, 3762502690, 4150144569, 4199882800, 3070356634, 3121275539, 2904027272, 2686254721, 2200818878, 2384911031, 2570832044, 2486224549, 3747192018, 3528626907, 3310321856, 3359936201, 3950355702, 3867060991, 4049844452, 4234721005, 1739656202, 1790575107, 2108100632, 1890328081, 1402811438, 1586903591, 1233856572, 1149249077, 266959938, 48394827, 369057872, 418672217, 1002783846, 919489135, 567498868, 752375421, 209336225, 24197544, 376187827, 459744698, 945164165, 895287692, 574624663, 793451934, 1679968233, 1764313568, 2117360635, 1933530610, 1343127501, 1560637892, 1243112415, 1192455638, 3704280881, 3519142200, 3336358691, 3419915562, 3907448597, 3857572124, 4075877127, 4294704398, 3029510009, 3113855344, 2927934315, 2744104290, 2159976285, 2377486676, 2594734927, 2544078150 ]); U4 = new Uint32Array([ 0, 151849742, 303699484, 454499602, 607398968, 758720310, 908999204, 1059270954, 1214797936, 1097159550, 1517440620, 1400849762, 1817998408, 1699839814, 2118541908, 2001430874, 2429595872, 2581445614, 2194319100, 2345119218, 3034881240, 3186202582, 2801699524, 2951971274, 3635996816, 3518358430, 3399679628, 3283088770, 4237083816, 4118925222, 4002861748, 3885750714, 1002142683, 850817237, 698445255, 548169417, 529487843, 377642221, 227885567, 77089521, 1943217067, 2061379749, 1640576439, 1757691577, 1474760595, 1592394909, 1174215055, 1290801793, 2875968315, 2724642869, 3111247143, 2960971305, 2405426947, 2253581325, 2638606623, 2487810577, 3808662347, 3926825029, 4044981591, 4162096729, 3342319475, 3459953789, 3576539503, 3693126241, 1986918061, 2137062819, 1685577905, 1836772287, 1381620373, 1532285339, 1078185097, 1229899655, 1040559837, 923313619, 740276417, 621982671, 439452389, 322734571, 137073913, 19308535, 3871163981, 4021308739, 4104605777, 4255800159, 3263785589, 3414450555, 3499326569, 3651041127, 2933202493, 2815956275, 3167684641, 3049390895, 2330014213, 2213296395, 2566595609, 2448830231, 1305906550, 1155237496, 1607244650, 1455525988, 1776460110, 1626319424, 2079897426, 1928707164, 96392454, 213114376, 396673818, 514443284, 562755902, 679998e3, 865136418, 983426092, 3708173718, 3557504664, 3474729866, 3323011204, 4180808110, 4030667424, 3945269170, 3794078908, 2507040230, 2623762152, 2272556026, 2390325492, 2975484382, 3092726480, 2738905026, 2857194700, 3973773121, 3856137295, 4274053469, 4157467219, 3371096953, 3252932727, 3673476453, 3556361835, 2763173681, 2915017791, 3064510765, 3215307299, 2156299017, 2307622919, 2459735317, 2610011675, 2081048481, 1963412655, 1846563261, 1729977011, 1480485785, 1362321559, 1243905413, 1126790795, 878845905, 1030690015, 645401037, 796197571, 274084841, 425408743, 38544885, 188821243, 3613494426, 3731654548, 3313212038, 3430322568, 4082475170, 4200115116, 3780097726, 3896688048, 2668221674, 2516901860, 2366882550, 2216610296, 3141400786, 2989552604, 2837966542, 2687165888, 1202797690, 1320957812, 1437280870, 1554391400, 1669664834, 1787304780, 1906247262, 2022837584, 265905162, 114585348, 499347990, 349075736, 736970802, 585122620, 972512814, 821712160, 2595684844, 2478443234, 2293045232, 2174754046, 3196267988, 3079546586, 2895723464, 2777952454, 3537852828, 3687994002, 3234156416, 3385345166, 4142626212, 4293295786, 3841024952, 3992742070, 174567692, 57326082, 410887952, 292596766, 777231668, 660510266, 1011452712, 893681702, 1108339068, 1258480242, 1343618912, 1494807662, 1715193156, 1865862730, 1948373848, 2100090966, 2701949495, 2818666809, 3004591147, 3122358053, 2235061775, 2352307457, 2535604243, 2653899549, 3915653703, 3764988233, 4219352155, 4067639125, 3444575871, 3294430577, 3746175075, 3594982253, 836553431, 953270745, 600235211, 718002117, 367585007, 484830689, 133361907, 251657213, 2041877159, 1891211689, 1806599355, 1654886325, 1568718495, 1418573201, 1335535747, 1184342925 ]); function AES() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); AES.prototype.__init__.apply(this, arguments); } AES.prototype.__init__ = function __init__(key) { var self = this; var rounds, round_key_count, KC, tk, index, rconpointer, t, tt, i, r, c; self.working_mem = [ new Uint32Array(4), new Uint32Array(4) ]; rounds = number_of_rounds[ρσ_bound_index(key.length, number_of_rounds)]; if (!rounds) { throw new ValueError("invalid key size (must be length 16, 24 or 32)"); } self._Ke = []; self._Kd = []; for (var i = 0; i <= rounds; i++) { self._Ke.push(new Uint32Array(4)); self._Kd.push(new Uint32Array(4)); } round_key_count = (rounds + 1) * 4; KC = key.length / 4; tk = new Uint32Array(KC); convert_to_int32(key, tk); index = 0; for (var i = 0; i < KC; i++) { index = i >> 2; (ρσ_expr_temp = (ρσ_expr_temp = self._Ke)[(typeof index === "number" && index < 0) ? ρσ_expr_temp.length + index : index])[ρσ_bound_index(i % 4, ρσ_expr_temp)] = tk[(typeof i === "number" && i < 0) ? tk.length + i : i]; (ρσ_expr_temp = (ρσ_expr_temp = self._Kd)[ρσ_bound_index(rounds - index, ρσ_expr_temp)])[ρσ_bound_index(i % 4, ρσ_expr_temp)] = tk[(typeof i === "number" && i < 0) ? tk.length + i : i]; } rconpointer = 0; t = KC; while (t < round_key_count) { tt = tk[ρσ_bound_index(KC - 1, tk)]; tk[0] ^= S[ρσ_bound_index(tt >> 16 & 255, S)] << 24 ^ S[ρσ_bound_index(tt >> 8 & 255, S)] << 16 ^ S[ρσ_bound_index(tt & 255, S)] << 8 ^ S[ρσ_bound_index(tt >> 24 & 255, S)] ^ rcon[(typeof rconpointer === "number" && rconpointer < 0) ? rcon.length + rconpointer : rconpointer] << 24; rconpointer += 1; if ((KC !== 8 && (typeof KC !== "object" || ρσ_not_equals(KC, 8)))) { for (var i = 1; i < KC; i++) { tk[(typeof i === "number" && i < 0) ? tk.length + i : i] ^= tk[ρσ_bound_index(i - 1, tk)]; } } else { for (var i = 1; i < (KC / 2); i++) { tk[(typeof i === "number" && i < 0) ? tk.length + i : i] ^= tk[ρσ_bound_index(i - 1, tk)]; } tt = tk[ρσ_bound_index(KC / 2 - 1, tk)]; tk[ρσ_bound_index(KC / 2, tk)] ^= S[ρσ_bound_index(tt & 255, S)] ^ S[ρσ_bound_index(tt >> 8 & 255, S)] << 8 ^ S[ρσ_bound_index(tt >> 16 & 255, S)] << 16 ^ S[ρσ_bound_index(tt >> 24 & 255, S)] << 24; for (var i = (KC / 2) + 1; i < KC; i++) { tk[(typeof i === "number" && i < 0) ? tk.length + i : i] ^= tk[ρσ_bound_index(i - 1, tk)]; } } i = 0; while (i < KC && t < round_key_count) { r = t >> 2; c = t % 4; (ρσ_expr_temp = (ρσ_expr_temp = self._Ke)[(typeof r === "number" && r < 0) ? ρσ_expr_temp.length + r : r])[(typeof c === "number" && c < 0) ? ρσ_expr_temp.length + c : c] = tk[(typeof i === "number" && i < 0) ? tk.length + i : i]; (ρσ_expr_temp = (ρσ_expr_temp = self._Kd)[ρσ_bound_index(rounds - r, ρσ_expr_temp)])[(typeof c === "number" && c < 0) ? ρσ_expr_temp.length + c : c] = tk[ρσ_bound_index(i++, tk)]; t += 1; } } for (var r = 1; r < rounds; r++) { for (var c = 0; c < 4; c++) { tt = (ρσ_expr_temp = (ρσ_expr_temp = self._Kd)[(typeof r === "number" && r < 0) ? ρσ_expr_temp.length + r : r])[(typeof c === "number" && c < 0) ? ρσ_expr_temp.length + c : c]; (ρσ_expr_temp = (ρσ_expr_temp = self._Kd)[(typeof r === "number" && r < 0) ? ρσ_expr_temp.length + r : r])[(typeof c === "number" && c < 0) ? ρσ_expr_temp.length + c : c] = U1[ρσ_bound_index(tt >> 24 & 255, U1)] ^ U2[ρσ_bound_index(tt >> 16 & 255, U2)] ^ U3[ρσ_bound_index(tt >> 8 & 255, U3)] ^ U4[ρσ_bound_index(tt & 255, U4)]; } } }; if (!AES.prototype.__init__.__argnames__) Object.defineProperties(AES.prototype.__init__, { __argnames__ : {value: ["key"]}, __module__ : {value: "aes"} }); AES.__argnames__ = AES.prototype.__init__.__argnames__; AES.__handles_kwarg_interpolation__ = AES.prototype.__init__.__handles_kwarg_interpolation__; AES.prototype._crypt = function _crypt(ciphertext, offset, encrypt) { var self = this; var R1, R2, R3, R4, o1, o3, SB, K, rounds, a, t, tt; if (encrypt) { R1 = T1; R2 = T2; R3 = T3; R4 = T4; o1 = 1; o3 = 3; SB = S; K = self._Ke; } else { R1 = T5; R2 = T6; R3 = T7; R4 = T8; o1 = 3; o3 = 1; SB = Si; K = self._Kd; } rounds = K.length - 1; a = self.working_mem[0]; t = self.working_mem[1]; for (var i = 0; i < 4; i++) { t[(typeof i === "number" && i < 0) ? t.length + i : i] ^= (ρσ_expr_temp = K[0])[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i]; } for (var r = 1; r < rounds; r++) { for (var i = 0; i < 4; i++) { a[(typeof i === "number" && i < 0) ? a.length + i : i] = R1[ρσ_bound_index(t[(typeof i === "number" && i < 0) ? t.length + i : i] >> 24 & 255, R1)] ^ R2[ρσ_bound_index(t[ρσ_bound_index((i + o1) % 4, t)] >> 16 & 255, R2)] ^ R3[ρσ_bound_index(t[ρσ_bound_index((i + 2) % 4, t)] >> 8 & 255, R3)] ^ R4[ρσ_bound_index(t[ρσ_bound_index((i + o3) % 4, t)] & 255, R4)] ^ (ρσ_expr_temp = K[(typeof r === "number" && r < 0) ? K.length + r : r])[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i]; } t.set(a); } for (var i = 0; i < 4; i++) { tt = (ρσ_expr_temp = K[(typeof rounds === "number" && rounds < 0) ? K.length + rounds : rounds])[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i]; ciphertext[ρσ_bound_index(offset + 4 * i, ciphertext)] = (SB[ρσ_bound_index(t[(typeof i === "number" && i < 0) ? t.length + i : i] >> 24 & 255, SB)] ^ tt >> 24) & 255; ciphertext[ρσ_bound_index(offset + 4 * i + 1, ciphertext)] = (SB[ρσ_bound_index(t[ρσ_bound_index((i + o1) % 4, t)] >> 16 & 255, SB)] ^ tt >> 16) & 255; ciphertext[ρσ_bound_index(offset + 4 * i + 2, ciphertext)] = (SB[ρσ_bound_index(t[ρσ_bound_index((i + 2) % 4, t)] >> 8 & 255, SB)] ^ tt >> 8) & 255; ciphertext[ρσ_bound_index(offset + 4 * i + 3, ciphertext)] = (SB[ρσ_bound_index(t[ρσ_bound_index((i + o3) % 4, t)] & 255, SB)] ^ tt) & 255; } }; if (!AES.prototype._crypt.__argnames__) Object.defineProperties(AES.prototype._crypt, { __argnames__ : {value: ["ciphertext", "offset", "encrypt"]}, __module__ : {value: "aes"} }); AES.prototype.encrypt = function encrypt(plaintext, ciphertext, offset) { var self = this; convert_to_int32(plaintext, self.working_mem[1], offset, 16); return self._crypt(ciphertext, offset, true); }; if (!AES.prototype.encrypt.__argnames__) Object.defineProperties(AES.prototype.encrypt, { __argnames__ : {value: ["plaintext", "ciphertext", "offset"]}, __module__ : {value: "aes"} }); AES.prototype.encrypt32 = function encrypt32(plaintext, ciphertext, offset) { var self = this; self.working_mem[1].set(plaintext); return self._crypt(ciphertext, offset, true); }; if (!AES.prototype.encrypt32.__argnames__) Object.defineProperties(AES.prototype.encrypt32, { __argnames__ : {value: ["plaintext", "ciphertext", "offset"]}, __module__ : {value: "aes"} }); AES.prototype.decrypt = function decrypt(ciphertext, plaintext, offset) { var self = this; convert_to_int32(ciphertext, self.working_mem[1], offset, 16); return self._crypt(plaintext, offset, false); }; if (!AES.prototype.decrypt.__argnames__) Object.defineProperties(AES.prototype.decrypt, { __argnames__ : {value: ["ciphertext", "plaintext", "offset"]}, __module__ : {value: "aes"} }); AES.prototype.decrypt32 = function decrypt32(ciphertext, plaintext, offset) { var self = this; self.working_mem[1].set(ciphertext); return self._crypt(plaintext, offset, false); }; if (!AES.prototype.decrypt32.__argnames__) Object.defineProperties(AES.prototype.decrypt32, { __argnames__ : {value: ["ciphertext", "plaintext", "offset"]}, __module__ : {value: "aes"} }); AES.prototype.__repr__ = function __repr__ () { return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; AES.prototype.__str__ = function __str__ () { return this.__repr__(); }; Object.defineProperty(AES.prototype, "__bases__", {value: []}); function random_bytes_insecure(sz) { var ans; ans = new Uint8Array(sz); for (var i = 0; i < sz; i++) { ans[(typeof i === "number" && i < 0) ? ans.length + i : i] = Math.floor(Math.random() * 256); } return ans; }; if (!random_bytes_insecure.__argnames__) Object.defineProperties(random_bytes_insecure, { __argnames__ : {value: ["sz"]}, __module__ : {value: "aes"} }); function random_bytes_secure(sz) { var ans; ans = new Uint8Array(sz); crypto.getRandomValues(ans); return ans; }; if (!random_bytes_secure.__argnames__) Object.defineProperties(random_bytes_secure, { __argnames__ : {value: ["sz"]}, __module__ : {value: "aes"} }); random_bytes = (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function") ? random_bytes_secure : random_bytes_insecure; if (random_bytes === random_bytes_insecure) { try { noderandom = require("crypto").randomBytes; random_bytes = (function() { var ρσ_anonfunc = function (sz) { return new Uint8Array(noderandom(sz)); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["sz"]}, __module__ : {value: "aes"} }); return ρσ_anonfunc; })(); } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; { print("WARNING: Using insecure RNG for AES"); } } } function ModeOfOperation() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); ModeOfOperation.prototype.__init__.apply(this, arguments); } Object.defineProperties(ModeOfOperation.prototype, { "key_as_js": { "enumerable": true, "get": function key_as_js() { var self = this; return typed_array_as_js(self.key); }, "set": function () { throw new AttributeError("can't set attribute") } }, }); ModeOfOperation.prototype.__init__ = function __init__(key) { var self = this; self.key = key || generate_key(32); self.aes = new AES(self.key); }; if (!ModeOfOperation.prototype.__init__.__argnames__) Object.defineProperties(ModeOfOperation.prototype.__init__, { __argnames__ : {value: ["key"]}, __module__ : {value: "aes"} }); ModeOfOperation.__argnames__ = ModeOfOperation.prototype.__init__.__argnames__; ModeOfOperation.__handles_kwarg_interpolation__ = ModeOfOperation.prototype.__init__.__handles_kwarg_interpolation__; ModeOfOperation.prototype.tag_as_bytes = function tag_as_bytes(tag) { var self = this; if (ρσ_instanceof(tag, Uint8Array)) { return tag; } if (!tag) { return new Uint8Array(0); } if (typeof tag === "string") { return string_to_bytes(tag); } throw new TypeError("Invalid tag, must be a string or a Uint8Array"); }; if (!ModeOfOperation.prototype.tag_as_bytes.__argnames__) Object.defineProperties(ModeOfOperation.prototype.tag_as_bytes, { __argnames__ : {value: ["tag"]}, __module__ : {value: "aes"} }); ModeOfOperation.prototype.__repr__ = function __repr__ () { return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; ModeOfOperation.prototype.__str__ = function __str__ () { return this.__repr__(); }; Object.defineProperty(ModeOfOperation.prototype, "__bases__", {value: []}); function GaloisField() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); GaloisField.prototype.__init__.apply(this, arguments); } GaloisField.prototype.__init__ = function __init__(sub_key) { var self = this; var k32; k32 = new Uint32Array(4); convert_to_int32(sub_key, k32, 0); self.m = self.generate_hash_table(k32); self.wmem = new Uint32Array(4); }; if (!GaloisField.prototype.__init__.__argnames__) Object.defineProperties(GaloisField.prototype.__init__, { __argnames__ : {value: ["sub_key"]}, __module__ : {value: "aes"} }); GaloisField.__argnames__ = GaloisField.prototype.__init__.__argnames__; GaloisField.__handles_kwarg_interpolation__ = GaloisField.prototype.__init__.__handles_kwarg_interpolation__; GaloisField.prototype.power = function power(x, out) { var self = this; var lsb; lsb = x[3] & 1; for (var i = 3; i > 0; --i) { out[(typeof i === "number" && i < 0) ? out.length + i : i] = x[(typeof i === "number" && i < 0) ? x.length + i : i] >>> 1 | (x[ρσ_bound_index(i - 1, x)] & 1) << 31; } out[0] = x[0] >>> 1; if (lsb) { out[0] ^= 3774873600; } }; if (!GaloisField.prototype.power.__argnames__) Object.defineProperties(GaloisField.prototype.power, { __argnames__ : {value: ["x", "out"]}, __module__ : {value: "aes"} }); GaloisField.prototype.multiply = function multiply(x, y) { var self = this; var z_i, v_i, x_i; z_i = new Uint32Array(4); v_i = new Uint32Array(y); for (var i = 0; i < 128; ++i) { x_i = x[ρσ_bound_index(i / 32 | 0, x)] & 1 << 31 - i % 32; if (x_i) { z_i[0] ^= v_i[0]; z_i[1] ^= v_i[1]; z_i[2] ^= v_i[2]; z_i[3] ^= v_i[3]; } self.power(v_i, v_i); } return z_i; }; if (!GaloisField.prototype.multiply.__argnames__) Object.defineProperties(GaloisField.prototype.multiply, { __argnames__ : {value: ["x", "y"]}, __module__ : {value: "aes"} }); GaloisField.prototype.generate_sub_hash_table = function generate_sub_hash_table(mid) { var self = this; var bits, size, half, m, i, m_i, m_j, x, y; bits = mid.length; size = 1 << bits; half = size >>> 1; m = new Array(size); m[(typeof half === "number" && half < 0) ? m.length + half : half] = new Uint32Array(mid); i = half >>> 1; while (i > 0) { m[(typeof i === "number" && i < 0) ? m.length + i : i] = new Uint32Array(4); self.power(m[ρσ_bound_index(2 * i, m)], m[(typeof i === "number" && i < 0) ? m.length + i : i]); i >>= 1; } i = 2; while (i < half) { for (var j = 1; j < i; ++j) { m_i = m[(typeof i === "number" && i < 0) ? m.length + i : i]; m_j = m[(typeof j === "number" && j < 0) ? m.length + j : j]; m[ρσ_bound_index(i + j, m)] = x = new Uint32Array(4); for (var c = 0; c < 4; c++) { x[(typeof c === "number" && c < 0) ? x.length + c : c] = m_i[(typeof c === "number" && c < 0) ? m_i.length + c : c] ^ m_j[(typeof c === "number" && c < 0) ? m_j.length + c : c]; } } i *= 2; } m[0] = new Uint32Array(4); for (i = half + 1; i < size; ++i) { x = m[ρσ_bound_index(i ^ half, m)]; m[(typeof i === "number" && i < 0) ? m.length + i : i] = y = new Uint32Array(4); for (var c = 0; c < 4; c++) { y[(typeof c === "number" && c < 0) ? y.length + c : c] = mid[(typeof c === "number" && c < 0) ? mid.length + c : c] ^ x[(typeof c === "number" && c < 0) ? x.length + c : c]; } } return m; }; if (!GaloisField.prototype.generate_sub_hash_table.__argnames__) Object.defineProperties(GaloisField.prototype.generate_sub_hash_table, { __argnames__ : {value: ["mid"]}, __module__ : {value: "aes"} }); GaloisField.prototype.generate_hash_table = function generate_hash_table(key_as_int32_array) { var self = this; var bits, multiplier, per_int, size, ans, tmp, idx, shft; bits = key_as_int32_array.length; multiplier = 8 / bits; per_int = 4 * multiplier; size = 16 * multiplier; ans = new Array(size); for (var i =0; i < size; ++i) { tmp = new Uint32Array(4); idx = i / per_int | 0; shft = (per_int - 1 - i % per_int) * bits; tmp[(typeof idx === "number" && idx < 0) ? tmp.length + idx : idx] = 1 << bits - 1 << shft; ans[(typeof i === "number" && i < 0) ? ans.length + i : i] = self.generate_sub_hash_table(self.multiply(tmp, key_as_int32_array)); } return ans; }; if (!GaloisField.prototype.generate_hash_table.__argnames__) Object.defineProperties(GaloisField.prototype.generate_hash_table, { __argnames__ : {value: ["key_as_int32_array"]}, __module__ : {value: "aes"} }); GaloisField.prototype.table_multiply = function table_multiply(x) { var self = this; var z, idx, x_i, ah; z = new Uint32Array(4); for (var i = 0; i < 32; ++i) { idx = i / 8 | 0; x_i = x[(typeof idx === "number" && idx < 0) ? x.length + idx : idx] >>> (7 - i % 8) * 4 & 15; ah = (ρσ_expr_temp = (ρσ_expr_temp = self.m)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i])[(typeof x_i === "number" && x_i < 0) ? ρσ_expr_temp.length + x_i : x_i]; z[0] ^= ah[0]; z[1] ^= ah[1]; z[2] ^= ah[2]; z[3] ^= ah[3]; } return z; }; if (!GaloisField.prototype.table_multiply.__argnames__) Object.defineProperties(GaloisField.prototype.table_multiply, { __argnames__ : {value: ["x"]}, __module__ : {value: "aes"} }); GaloisField.prototype.ghash = function ghash(x, y) { var self = this; var z; z = self.wmem; z[0] = y[0] ^ x[0]; z[1] = y[1] ^ x[1]; z[2] = y[2] ^ x[2]; z[3] = y[3] ^ x[3]; return self.table_multiply(z); }; if (!GaloisField.prototype.ghash.__argnames__) Object.defineProperties(GaloisField.prototype.ghash, { __argnames__ : {value: ["x", "y"]}, __module__ : {value: "aes"} }); GaloisField.prototype.__repr__ = function __repr__ () { return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; GaloisField.prototype.__str__ = function __str__ () { return this.__repr__(); }; Object.defineProperty(GaloisField.prototype, "__bases__", {value: []}); function generate_key(sz) { if (!number_of_rounds[(typeof sz === "number" && sz < 0) ? number_of_rounds.length + sz : sz]) { throw new ValueError("Invalid key size, must be: 16, 24 or 32"); } return random_bytes(sz); }; if (!generate_key.__argnames__) Object.defineProperties(generate_key, { __argnames__ : {value: ["sz"]}, __module__ : {value: "aes"} }); function typed_array_as_js(x) { var name; name = x.constructor.name || "Uint8Array"; return "(new " + name + "(" + JSON.stringify(Array.from(x)) + "))"; }; if (!typed_array_as_js.__argnames__) Object.defineProperties(typed_array_as_js, { __argnames__ : {value: ["x"]}, __module__ : {value: "aes"} }); function GCM() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); GCM.prototype.__init__.apply(this, arguments); } ρσ_extends(GCM, ModeOfOperation); GCM.prototype.__init__ = function __init__() { var self = this; var key = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var random_iv = (arguments[1] === undefined || ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? __init__.__defaults__.random_iv : arguments[1]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "random_iv")){ random_iv = ρσ_kwargs_obj.random_iv; } var H; ModeOfOperation.prototype.__init__.call(self, key); self.random_iv = random_iv; if (!random_iv) { self.current_iv = new Uint8Array(12); } H = new Uint8Array(16); self.aes.encrypt(new Uint8Array(16), H, 0); self.galois = new GaloisField(H); self.J0 = new Uint32Array(4); self.wmem = new Uint32Array(4); self.byte_block = new Uint8Array(16); }; if (!GCM.prototype.__init__.__defaults__) Object.defineProperties(GCM.prototype.__init__, { __defaults__ : {value: {random_iv:false}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["key", "random_iv"]}, __module__ : {value: "aes"} }); GCM.__argnames__ = GCM.prototype.__init__.__argnames__; GCM.__handles_kwarg_interpolation__ = GCM.prototype.__init__.__handles_kwarg_interpolation__; GCM.prototype.increment_iv = function increment_iv() { var self = this; var c; c = self.current_iv; for (var i = 11; i >=0; i--) { if (c[(typeof i === "number" && i < 0) ? c.length + i : i] === 255) { if (i === 0) { throw new ValueError("The GCM IV space is exhausted, cannot" + " encrypt anymore messages with this key" + " as doing so would cause the IV to repeat"); } c[(typeof i === "number" && i < 0) ? c.length + i : i] = 0; } else { c[(typeof i === "number" && i < 0) ? c.length + i : i] += 1; break; } } }; if (!GCM.prototype.increment_iv.__module__) Object.defineProperties(GCM.prototype.increment_iv, { __module__ : {value: "aes"} }); GCM.prototype._create_j0 = function _create_j0(iv) { var self = this; var J0, tmp; J0 = self.J0; if (iv.length === 12) { convert_to_int32(iv, J0); J0[3] = 1; } else { J0.fill(0); tmp = convert_to_int32_pad(iv); while (tmp.length) { J0 = self.galois.ghash(J0, tmp); tmp = tmp.subarray(4); } tmp = new Uint32Array(4); tmp.set(from_64_to_32(iv.length * 8), 2); J0 = self.galois.ghash(J0, tmp); } return J0; }; if (!GCM.prototype._create_j0.__argnames__) Object.defineProperties(GCM.prototype._create_j0, { __argnames__ : {value: ["iv"]}, __module__ : {value: "aes"} }); GCM.prototype._start = function _start(iv, additional_data) { var self = this; var J0, in_block, S, overflow; J0 = self._create_j0(iv); in_block = new Uint32Array(J0); in_block[3] = in_block[3] + 1 & 4294967295; S = new Uint32Array(4); overflow = additional_data.length % 16; for (var i = 0; i < additional_data.length - overflow; i += 16) { convert_to_int32(additional_data, self.wmem, i, 16); S = self.galois.ghash(S, self.wmem); } if (overflow) { self.byte_block.fill(0); self.byte_block.set(additional_data.subarray(additional_data.length - overflow)); convert_to_int32(self.byte_block, self.wmem); S = self.galois.ghash(S, self.wmem); } return [J0, in_block, S]; }; if (!GCM.prototype._start.__argnames__) Object.defineProperties(GCM.prototype._start, { __argnames__ : {value: ["iv", "additional_data"]}, __module__ : {value: "aes"} }); GCM.prototype._finish = function _finish(iv, J0, adata_len, S, outbytes) { var self = this; var lengths, tag; lengths = new Uint32Array(4); lengths.set(from_64_to_32(adata_len * 8)); lengths.set(from_64_to_32(outbytes.length * 8), 2); S = self.galois.ghash(S, lengths); self.aes.encrypt32(J0, self.byte_block, 0); convert_to_int32(self.byte_block, self.wmem); tag = new Uint32Array(4); for (var i = 0; i < S.length; i++) { tag[(typeof i === "number" && i < 0) ? tag.length + i : i] = S[(typeof i === "number" && i < 0) ? S.length + i : i] ^ (ρσ_expr_temp = self.wmem)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i]; } return (function(){ var ρσ_d = {}; ρσ_d["iv"] = iv; ρσ_d["cipherbytes"] = outbytes; ρσ_d["tag"] = tag; return ρσ_d; }).call(this); }; if (!GCM.prototype._finish.__argnames__) Object.defineProperties(GCM.prototype._finish, { __argnames__ : {value: ["iv", "J0", "adata_len", "S", "outbytes"]}, __module__ : {value: "aes"} }); GCM.prototype._crypt = function _crypt(iv, bytes, additional_data, decrypt) { var self = this; var ghash, outbytes, ρσ_unpack, J0, in_block, S, bb, enc, hash_bytes, counter_index, overflow; ghash = self.galois.ghash.bind(self.galois); outbytes = new Uint8Array(bytes.length); ρσ_unpack = self._start(iv, additional_data); ρσ_unpack = ρσ_unpack_asarray(3, ρσ_unpack); J0 = ρσ_unpack[0]; in_block = ρσ_unpack[1]; S = ρσ_unpack[2]; bb = self.byte_block; enc = self.aes.encrypt32.bind(self.aes); hash_bytes = (decrypt) ? bytes : outbytes; counter_index = 16; for (var i = 0; i < bytes.length; i++, counter_index++) { if (counter_index === 16) { enc(in_block, bb, 0); in_block[3] = in_block[3] + 1 & 4294967295; counter_index = 0; } outbytes[(typeof i === "number" && i < 0) ? outbytes.length + i : i] = bytes[(typeof i === "number" && i < 0) ? bytes.length + i : i] ^ bb[(typeof counter_index === "number" && counter_index < 0) ? bb.length + counter_index : counter_index]; if (counter_index === 15) { convert_to_int32(hash_bytes, self.wmem, i - 15, 16); S = ghash(S, self.wmem); } } overflow = outbytes.length % 16; if (overflow) { bb.fill(0); bb.set(hash_bytes.subarray(hash_bytes.length - overflow)); convert_to_int32(bb, self.wmem); S = ghash(S, self.wmem); } return self._finish(iv, J0, additional_data.length, S, outbytes); }; if (!GCM.prototype._crypt.__argnames__) Object.defineProperties(GCM.prototype._crypt, { __argnames__ : {value: ["iv", "bytes", "additional_data", "decrypt"]}, __module__ : {value: "aes"} }); GCM.prototype.encrypt = function encrypt(plaintext, tag) { var self = this; var iv; if (self.random_iv) { iv = random_bytes(12); } else { self.increment_iv(); iv = self.current_iv; } return self._crypt(iv, string_to_bytes(plaintext), self.tag_as_bytes(tag), false); }; if (!GCM.prototype.encrypt.__argnames__) Object.defineProperties(GCM.prototype.encrypt, { __argnames__ : {value: ["plaintext", "tag"]}, __module__ : {value: "aes"} }); GCM.prototype.decrypt = function decrypt(output_from_encrypt, tag) { var self = this; var ans; if ((output_from_encrypt.tag.length !== 4 && (typeof output_from_encrypt.tag.length !== "object" || ρσ_not_equals(output_from_encrypt.tag.length, 4)))) { throw new ValueError("Corrupted message"); } ans = self._crypt(output_from_encrypt.iv, output_from_encrypt.cipherbytes, self.tag_as_bytes(tag), true); if ((ans.tag !== output_from_encrypt.tag && (typeof ans.tag !== "object" || ρσ_not_equals(ans.tag, output_from_encrypt.tag)))) { throw new ValueError("Corrupted message"); } return bytes_to_string(ans.cipherbytes); }; if (!GCM.prototype.decrypt.__argnames__) Object.defineProperties(GCM.prototype.decrypt, { __argnames__ : {value: ["output_from_encrypt", "tag"]}, __module__ : {value: "aes"} }); GCM.prototype.__repr__ = function __repr__ () { if(ModeOfOperation.prototype.__repr__) return ModeOfOperation.prototype.__repr__.call(this); return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; GCM.prototype.__str__ = function __str__ () { if(ModeOfOperation.prototype.__str__) return ModeOfOperation.prototype.__str__.call(this); return this.__repr__(); }; Object.defineProperty(GCM.prototype, "__bases__", {value: [ModeOfOperation]}); ρσ_modules.aes.string_to_bytes = string_to_bytes; ρσ_modules.aes.bytes_to_string = bytes_to_string; ρσ_modules.aes.number_of_rounds = number_of_rounds; ρσ_modules.aes.rcon = rcon; ρσ_modules.aes.S = S; ρσ_modules.aes.Si = Si; ρσ_modules.aes.T1 = T1; ρσ_modules.aes.T2 = T2; ρσ_modules.aes.T3 = T3; ρσ_modules.aes.T4 = T4; ρσ_modules.aes.T5 = T5; ρσ_modules.aes.T6 = T6; ρσ_modules.aes.T7 = T7; ρσ_modules.aes.T8 = T8; ρσ_modules.aes.U1 = U1; ρσ_modules.aes.U2 = U2; ρσ_modules.aes.U3 = U3; ρσ_modules.aes.U4 = U4; ρσ_modules.aes.random_bytes = random_bytes; ρσ_modules.aes.noderandom = noderandom; ρσ_modules.aes.string_to_bytes_encoder = string_to_bytes_encoder; ρσ_modules.aes.string_to_bytes_slow = string_to_bytes_slow; ρσ_modules.aes.bytes_to_string_decoder = bytes_to_string_decoder; ρσ_modules.aes.bytes_to_string_slow = bytes_to_string_slow; ρσ_modules.aes.convert_to_int32 = convert_to_int32; ρσ_modules.aes.convert_to_int32_pad = convert_to_int32_pad; ρσ_modules.aes.from_64_to_32 = from_64_to_32; ρσ_modules.aes.AES = AES; ρσ_modules.aes.random_bytes_insecure = random_bytes_insecure; ρσ_modules.aes.random_bytes_secure = random_bytes_secure; ρσ_modules.aes.ModeOfOperation = ModeOfOperation; ρσ_modules.aes.GaloisField = GaloisField; ρσ_modules.aes.generate_key = generate_key; ρσ_modules.aes.typed_array_as_js = typed_array_as_js; ρσ_modules.aes.GCM = GCM; })(); (function(){ var __name__ = "read_book.globals"; var _boss, dark_link_color, uid, default_color_schemes, runtime, ui_operations, annot_id_uuid_map; var random_bytes = ρσ_modules.aes.random_bytes; var hexlify = ρσ_modules.encodings.hexlify; var _ = ρσ_modules.gettext.gettext; var register_callback = ρσ_modules.gettext.register_callback; var gt = ρσ_modules.gettext.gettext; _boss = null; dark_link_color = "#6cb4ee"; function set_boss(b) { _boss = b; }; if (!set_boss.__argnames__) Object.defineProperties(set_boss, { __argnames__ : {value: ["b"]}, __module__ : {value: "read_book.globals"} }); function get_boss() { return _boss; }; if (!get_boss.__module__) Object.defineProperties(get_boss, { __module__ : {value: "read_book.globals"} }); function current_book() { return current_book.book; }; if (!current_book.__module__) Object.defineProperties(current_book, { __module__ : {value: "read_book.globals"} }); current_book.book = null; function rtl_page_progression() { return (current_book().manifest.page_progression_direction === "rtl" || typeof current_book().manifest.page_progression_direction === "object" && ρσ_equals(current_book().manifest.page_progression_direction, "rtl")); }; if (!rtl_page_progression.__module__) Object.defineProperties(rtl_page_progression, { __module__ : {value: "read_book.globals"} }); function ltr_page_progression() { return !rtl_page_progression(); }; if (!ltr_page_progression.__module__) Object.defineProperties(ltr_page_progression, { __module__ : {value: "read_book.globals"} }); uid = "calibre-" + hexlify(random_bytes(12)); function viewport_mode_changer(val) { if (val) { viewport_mode_changer.val = val; } return viewport_mode_changer.val; }; if (!viewport_mode_changer.__argnames__) Object.defineProperties(viewport_mode_changer, { __argnames__ : {value: ["val"]}, __module__ : {value: "read_book.globals"} }); function current_layout_mode() { return current_layout_mode.value; }; if (!current_layout_mode.__module__) Object.defineProperties(current_layout_mode, { __module__ : {value: "read_book.globals"} }); current_layout_mode.value = "flow"; function set_layout_mode(val) { current_layout_mode.value = val; viewport_mode_changer()(val); }; if (!set_layout_mode.__argnames__) Object.defineProperties(set_layout_mode, { __argnames__ : {value: ["val"]}, __module__ : {value: "read_book.globals"} }); function current_spine_item() { return current_spine_item.value; }; if (!current_spine_item.__module__) Object.defineProperties(current_spine_item, { __module__ : {value: "read_book.globals"} }); current_spine_item.value = null; function set_current_spine_item(val) { current_spine_item.value = val; }; if (!set_current_spine_item.__argnames__) Object.defineProperties(set_current_spine_item, { __argnames__ : {value: ["val"]}, __module__ : {value: "read_book.globals"} }); function toc_anchor_map() { return toc_anchor_map.value; }; if (!toc_anchor_map.__module__) Object.defineProperties(toc_anchor_map, { __module__ : {value: "read_book.globals"} }); function set_toc_anchor_map(val) { toc_anchor_map.value = val; }; if (!set_toc_anchor_map.__argnames__) Object.defineProperties(set_toc_anchor_map, { __argnames__ : {value: ["val"]}, __module__ : {value: "read_book.globals"} }); default_color_schemes = (function(){ var ρσ_d = Object.create(null); ρσ_d["system"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["foreground"] = "#000000"; ρσ_d["background"] = "#ffffff"; ρσ_d["name"] = _("System"); return ρσ_d; }).call(this); ρσ_d["white"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["foreground"] = "#000000"; ρσ_d["background"] = "#ffffff"; ρσ_d["name"] = _("White"); return ρσ_d; }).call(this); ρσ_d["black"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["foreground"] = "#ffffff"; ρσ_d["background"] = "#000000"; ρσ_d["link"] = "#4f81bd"; ρσ_d["name"] = _("Black"); return ρσ_d; }).call(this); ρσ_d["sepia-light"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["foreground"] = "#39322B"; ρσ_d["background"] = "#F6F3E9"; ρσ_d["name"] = _("Sepia light"); return ρσ_d; }).call(this); ρσ_d["sepia-dark"] = (function(){ var ρσ_d = Object.create(null); ρσ_d["background"] = "#39322B"; ρσ_d["foreground"] = "#F6F3E9"; ρσ_d["link"] = "#4f81bd"; ρσ_d["name"] = _("Sepia dark"); return ρσ_d; }).call(this); return ρσ_d; }).call(this); function set_system_colors(spec) { var c; c = default_color_schemes.system; c.foreground = spec.foreground; c.background = spec.background; delete c.link; if (spec.link) { c.link = spec.link; } }; if (!set_system_colors.__argnames__) Object.defineProperties(set_system_colors, { __argnames__ : {value: ["spec"]}, __module__ : {value: "read_book.globals"} }); register_callback((function() { var ρσ_anonfunc = function () { var scheme, key; var ρσ_Iter51 = default_color_schemes; ρσ_Iter51 = ((typeof ρσ_Iter51[Symbol.iterator] === "function") ? (ρσ_Iter51 instanceof Map ? ρσ_Iter51.keys() : ρσ_Iter51) : Object.keys(ρσ_Iter51)); for (var ρσ_Index51 of ρσ_Iter51) { key = ρσ_Index51; scheme = default_color_schemes[(typeof key === "number" && key < 0) ? default_color_schemes.length + key : key]; scheme.name = gt(scheme.name); } if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) { set_system_colors((function(){ var ρσ_d = Object.create(null); ρσ_d["background"] = "#111"; ρσ_d["foreground"] = "#ddd"; ρσ_d["link"] = dark_link_color; return ρσ_d; }).call(this)); } }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "read_book.globals"} }); return ρσ_anonfunc; })()); runtime = (function(){ var ρσ_d = Object.create(null); ρσ_d["is_standalone_viewer"] = false; ρσ_d["viewer_in_full_screen"] = false; ρσ_d["in_develop_mode"] = (typeof window !== "undefined") && !!window.calibre_in_develop_mode; ρσ_d["QT_VERSION"] = 0; return ρσ_d; }).call(this); ui_operations = (function(){ var ρσ_d = Object.create(null); ρσ_d["get_file"] = null; ρσ_d["get_mathjax_files"] = null; ρσ_d["update_url_state"] = null; ρσ_d["update_last_read_time"] = null; ρσ_d["show_error"] = null; ρσ_d["redisplay_book"] = null; ρσ_d["reload_book"] = null; ρσ_d["forward_gesture"] = null; ρσ_d["update_color_scheme"] = null; ρσ_d["update_font_size"] = null; ρσ_d["goto_cfi"] = null; ρσ_d["delete_book"] = null; ρσ_d["focus_iframe"] = null; ρσ_d["toggle_toc"] = null; ρσ_d["toggle_full_screen"] = null; ρσ_d["reset_reading_rates"] = null; ρσ_d["has_unsynced_changes"] = null; ρσ_d["upload_pending_annotations"] = null; return ρσ_d; }).call(this); annot_id_uuid_map = Object.create(null); function clear_annot_id_uuid_map() { var key; var ρσ_Iter52 = Object.keys(annot_id_uuid_map); ρσ_Iter52 = ((typeof ρσ_Iter52[Symbol.iterator] === "function") ? (ρσ_Iter52 instanceof Map ? ρσ_Iter52.keys() : ρσ_Iter52) : Object.keys(ρσ_Iter52)); for (var ρσ_Index52 of ρσ_Iter52) { key = ρσ_Index52; delete annot_id_uuid_map[key]; } }; if (!clear_annot_id_uuid_map.__module__) Object.defineProperties(clear_annot_id_uuid_map, { __module__ : {value: "read_book.globals"} }); function is_dark_theme(set_val) { if ((typeof set_val !== "undefined" && set_val !== null)) { is_dark_theme.ans = set_val; } return !!is_dark_theme.ans; }; if (!is_dark_theme.__argnames__) Object.defineProperties(is_dark_theme, { __argnames__ : {value: ["set_val"]}, __module__ : {value: "read_book.globals"} }); ρσ_modules["read_book.globals"]._boss = _boss; ρσ_modules["read_book.globals"].dark_link_color = dark_link_color; ρσ_modules["read_book.globals"].uid = uid; ρσ_modules["read_book.globals"].default_color_schemes = default_color_schemes; ρσ_modules["read_book.globals"].runtime = runtime; ρσ_modules["read_book.globals"].ui_operations = ui_operations; ρσ_modules["read_book.globals"].annot_id_uuid_map = annot_id_uuid_map; ρσ_modules["read_book.globals"].set_boss = set_boss; ρσ_modules["read_book.globals"].get_boss = get_boss; ρσ_modules["read_book.globals"].current_book = current_book; ρσ_modules["read_book.globals"].rtl_page_progression = rtl_page_progression; ρσ_modules["read_book.globals"].ltr_page_progression = ltr_page_progression; ρσ_modules["read_book.globals"].viewport_mode_changer = viewport_mode_changer; ρσ_modules["read_book.globals"].current_layout_mode = current_layout_mode; ρσ_modules["read_book.globals"].set_layout_mode = set_layout_mode; ρσ_modules["read_book.globals"].current_spine_item = current_spine_item; ρσ_modules["read_book.globals"].set_current_spine_item = set_current_spine_item; ρσ_modules["read_book.globals"].toc_anchor_map = toc_anchor_map; ρσ_modules["read_book.globals"].set_toc_anchor_map = set_toc_anchor_map; ρσ_modules["read_book.globals"].set_system_colors = set_system_colors; ρσ_modules["read_book.globals"].clear_annot_id_uuid_map = clear_annot_id_uuid_map; ρσ_modules["read_book.globals"].is_dark_theme = is_dark_theme; })(); (function(){ var __name__ = "book_list.router"; var mode_handlers, default_mode_handler, read_book_mode; var absolute_path = ρσ_modules.ajax.absolute_path; var encode_query = ρσ_modules.ajax.encode_query; var book_list_container_id = ρσ_modules["book_list.constants"].book_list_container_id; var read_book_container_id = ρσ_modules["book_list.constants"].read_book_container_id; var cs_top_bar_host_id = ρσ_modules["book_list.constants"].cs_top_bar_host_id; var get_current_query = ρσ_modules["book_list.globals"].get_current_query; var get_session_data = ρσ_modules["book_list.globals"].get_session_data; var current_library_id = ρσ_modules["book_list.library_data"].current_library_id; var clear = ρσ_modules.dom.clear; var close_all_modals = ρσ_modules.modals.close_all_modals; var ui_operations = ρσ_modules["read_book.globals"].ui_operations; var encode_query_with_path = ρσ_modules.utils.encode_query_with_path; var parse_url_params = ρσ_modules.utils.parse_url_params; var request_full_screen = ρσ_modules.utils.request_full_screen; mode_handlers = Object.create(null); default_mode_handler = null; read_book_mode = "read_book"; function is_reading_book() { var cq; cq = get_current_query(); return cq && cq.mode === read_book_mode; }; if (!is_reading_book.__module__) Object.defineProperties(is_reading_book, { __module__ : {value: "book_list.router"} }); function apply_mode() { var divid, div, host; divid = (is_reading_book()) ? read_book_container_id : book_list_container_id; var ρσ_Iter53 = document.getElementById(divid).parentNode.childNodes; ρσ_Iter53 = ((typeof ρσ_Iter53[Symbol.iterator] === "function") ? (ρσ_Iter53 instanceof Map ? ρσ_Iter53.keys() : ρσ_Iter53) : Object.keys(ρσ_Iter53)); for (var ρσ_Index53 of ρσ_Iter53) { div = ρσ_Index53; div.style.display = (div.id === divid) ? "block" : "none"; } if (is_reading_book()) { host = document.getElementById(cs_top_bar_host_id); if (host) { clear(host); } } }; if (!apply_mode.__module__) Object.defineProperties(apply_mode, { __module__ : {value: "book_list.router"} }); function apply_url(ignore_handler) { var prev, data, cb, handler; try { if (!((window.history.state && ρσ_exists.n(window.history.state.cs_url_state)))) { window.history.replaceState((function(){ var ρσ_d = Object.create(null); ρσ_d["cs_url_state"] = true; ρσ_d["cs_idx"] = 0; return ρσ_d; }).call(this), "", window.location.href); } } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; if (ρσ_Exception instanceof Error) { } else { throw ρσ_Exception; } } close_all_modals(); prev = get_current_query(); data = parse_url_params(); data.mode = data.mode || "book_list"; if ((typeof prev !== "undefined" && prev !== null ? prev : Object.create(null)).mode === read_book_mode && data.mode !== read_book_mode) { try { if (ui_operations.close_book) { ui_operations.close_book(); } } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; if (ρσ_Exception instanceof Error) { } else { throw ρσ_Exception; } } } get_current_query(data); apply_mode(); try { cb = window.cs_update_sidebar_active; } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; if (ρσ_Exception instanceof Error) { cb = null; } else { throw ρσ_Exception; } } if (cb) { try { cb(); } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; if (ρσ_Exception instanceof Error) { } else { throw ρσ_Exception; } } } if (!ignore_handler) { handler = mode_handlers[ρσ_bound_index(data.mode, mode_handlers)] || default_mode_handler; handler(data); } }; if (!apply_url.__argnames__) Object.defineProperties(apply_url, { __argnames__ : {value: ["ignore_handler"]}, __module__ : {value: "book_list.router"} }); function request_full_screen_if_wanted() { var opt, has_touch, at_left, likely_wants_fullscreen; opt = get_session_data().get("fullscreen_when_opening"); has_touch = "ontouchstart" in window; at_left = window.screenLeft === 0; likely_wants_fullscreen = has_touch && at_left; if (opt === "auto" && likely_wants_fullscreen || opt === "always") { request_full_screen(); } }; if (!request_full_screen_if_wanted.__module__) Object.defineProperties(request_full_screen_if_wanted, { __module__ : {value: "book_list.router"} }); function open_book() { var book_id = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var fmt = ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[1]; var library_id = (arguments[2] === undefined || ( 2 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? open_book.__defaults__.library_id : arguments[2]; var replace = (arguments[3] === undefined || ( 3 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? open_book.__defaults__.replace : arguments[3]; var extra_query = (arguments[4] === undefined || ( 4 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? open_book.__defaults__.extra_query : arguments[4]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "library_id")){ library_id = ρσ_kwargs_obj.library_id; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "replace")){ replace = ρσ_kwargs_obj.replace; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "extra_query")){ extra_query = ρσ_kwargs_obj.extra_query; } var q; request_full_screen_if_wanted(); library_id = library_id || current_library_id(); q = (function(){ var ρσ_d = Object.create(null); ρσ_d["book_id"] = book_id; ρσ_d["fmt"] = fmt; ρσ_d["library_id"] = library_id; return ρσ_d; }).call(this); if (extra_query && typeof extra_query === "object") { Object.assign(q, extra_query); } ρσ_interpolate_kwargs.call(this, push_state, [q].concat([ρσ_desugar_kwargs({replace: replace, mode: read_book_mode})])); }; if (!open_book.__defaults__) Object.defineProperties(open_book, { __defaults__ : {value: {library_id:null, replace:false, extra_query:null}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["book_id", "fmt", "library_id", "replace", "extra_query"]}, __module__ : {value: "book_list.router"} }); function open_book_url_in_library(library_id, book_id, fmt, extra_query) { var ans, q; ans = absolute_path(""); q = (function(){ var ρσ_d = Object.create(null); ρσ_d["book_id"] = book_id; ρσ_d["fmt"] = fmt; ρσ_d["mode"] = read_book_mode; return ρσ_d; }).call(this); if (library_id) { q.library_id = library_id; } if (extra_query) { Object.assign(q, extra_query); } return ans + encode_query(q, "#"); }; if (!open_book_url_in_library.__argnames__) Object.defineProperties(open_book_url_in_library, { __argnames__ : {value: ["library_id", "book_id", "fmt", "extra_query"]}, __module__ : {value: "book_list.router"} }); function search_url_in_library(library_id, search, vl, sort) { var ans, q; ans = absolute_path(""); q = (function(){ var ρσ_d = Object.create(null); ρσ_d["mode"] = "book_list"; ρσ_d["search"] = search; ρσ_d["panel"] = "book_list"; return ρσ_d; }).call(this); if (library_id) { q.library_id = library_id; } if (vl) { q.vl = vl; } if (sort) { q.sort = sort; } return ans + encode_query(q, "#"); }; if (!search_url_in_library.__argnames__) Object.defineProperties(search_url_in_library, { __argnames__ : {value: ["library_id", "search", "vl", "sort"]}, __module__ : {value: "book_list.router"} }); function show_note() { var field = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var item_id = ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[1]; var item_value = ( 2 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[2]; var replace = (arguments[3] === undefined || ( 3 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? show_note.__defaults__.replace : arguments[3]; var library_id = (arguments[4] === undefined || ( 4 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? show_note.__defaults__.library_id : arguments[4]; var close_action = (arguments[5] === undefined || ( 5 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? show_note.__defaults__.close_action : arguments[5]; var panel = (arguments[6] === undefined || ( 6 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? show_note.__defaults__.panel : arguments[6]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "replace")){ replace = ρσ_kwargs_obj.replace; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "library_id")){ library_id = ρσ_kwargs_obj.library_id; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "close_action")){ close_action = ρσ_kwargs_obj.close_action; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "panel")){ panel = ρσ_kwargs_obj.panel; } var lid, q; lid = library_id || current_library_id(); q = (function(){ var ρσ_d = Object.create(null); ρσ_d["field"] = field; ρσ_d["item"] = item_value + ""; ρσ_d["item_id"] = (item_id || "") + ""; ρσ_d["panel"] = panel; return ρσ_d; }).call(this); if (panel === "show_note") { q.close_action = close_action; } if (lid) { q.library_id = lid; } ρσ_interpolate_kwargs.call(this, push_state, [q].concat([ρσ_desugar_kwargs({replace: replace})])); }; if (!show_note.__defaults__) Object.defineProperties(show_note, { __defaults__ : {value: {replace:false, library_id:null, close_action:"back", panel:"show_note"}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["field", "item_id", "item_value", "replace", "library_id", "close_action", "panel"]}, __module__ : {value: "book_list.router"} }); function push_state() { var query = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var replace = (arguments[1] === undefined || ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? push_state.__defaults__.replace : arguments[1]; var mode = (arguments[2] === undefined || ( 2 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? push_state.__defaults__.mode : arguments[2]; var call_handler = (arguments[3] === undefined || ( 3 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? push_state.__defaults__.call_handler : arguments[3]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "replace")){ replace = ρσ_kwargs_obj.replace; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "mode")){ mode = ρσ_kwargs_obj.mode; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "call_handler")){ call_handler = ρσ_kwargs_obj.call_handler; } var k, cur, cur_idx; query = (function() { var ρσ_Iter = query, ρσ_Result = Object.create(null), k; ρσ_Iter = ((typeof ρσ_Iter[Symbol.iterator] === "function") ? (ρσ_Iter instanceof Map ? ρσ_Iter.keys() : ρσ_Iter) : Object.keys(ρσ_Iter)); for (var ρσ_Index of ρσ_Iter) { k = ρσ_Index; if (query[(typeof k === "number" && k < 0) ? query.length + k : k]) { ρσ_Result[k] = (query[(typeof k === "number" && k < 0) ? query.length + k : k]); } } return ρσ_Result; })(); if (mode !== "book_list") { query.mode = mode; } query = encode_query_with_path(query); try { cur = window.history.state || Object.create(null); cur_idx = cur.cs_idx || 0; if (replace) { window.history.replaceState((function(){ var ρσ_d = Object.create(null); ρσ_d["cs_url_state"] = true; ρσ_d["cs_idx"] = cur_idx; return ρσ_d; }).call(this), "", query); } else { window.history.pushState((function(){ var ρσ_d = Object.create(null); ρσ_d["cs_url_state"] = true; ρσ_d["cs_idx"] = cur_idx + 1; return ρσ_d; }).call(this), "", query); } } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; if (ρσ_Exception instanceof Error) { if (replace) { window.history.replaceState(null, "", query); } else { window.history.pushState(null, "", query); } } else { throw ρσ_Exception; } } apply_url(!call_handler); }; if (!push_state.__defaults__) Object.defineProperties(push_state, { __defaults__ : {value: {replace:false, mode:"book_list", call_handler:true}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["query", "replace", "mode", "call_handler"]}, __module__ : {value: "book_list.router"} }); function back() { var idx, cq, handler, q; try { idx = window.history.state && window.history.state.cs_idx || 0; } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; if (ρσ_Exception instanceof Error) { idx = 0; } else { throw ρσ_Exception; } } if (idx > 0) { window.history.back(); } else { cq = get_current_query(); handler = mode_handlers[ρσ_bound_index(cq.mode, mode_handlers)] || default_mode_handler; if (handler.back_from_current) { q = handler.back_from_current(cq); } else { q = Object.create(null); } ρσ_interpolate_kwargs.call(this, push_state, [q].concat([ρσ_desugar_kwargs({replace: true})])); } }; if (!back.__module__) Object.defineProperties(back, { __module__ : {value: "book_list.router"} }); function home() { var replace = (arguments[0] === undefined || ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? home.__defaults__.replace : arguments[0]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "replace")){ replace = ρσ_kwargs_obj.replace; } push_state(Object.create(null)); }; if (!home.__defaults__) Object.defineProperties(home, { __defaults__ : {value: {replace:false}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["replace"]}, __module__ : {value: "book_list.router"} }); ρσ_modules["book_list.router"].mode_handlers = mode_handlers; ρσ_modules["book_list.router"].default_mode_handler = default_mode_handler; ρσ_modules["book_list.router"].read_book_mode = read_book_mode; ρσ_modules["book_list.router"].is_reading_book = is_reading_book; ρσ_modules["book_list.router"].apply_mode = apply_mode; ρσ_modules["book_list.router"].apply_url = apply_url; ρσ_modules["book_list.router"].request_full_screen_if_wanted = request_full_screen_if_wanted; ρσ_modules["book_list.router"].open_book = open_book; ρσ_modules["book_list.router"].open_book_url_in_library = open_book_url_in_library; ρσ_modules["book_list.router"].search_url_in_library = search_url_in_library; ρσ_modules["book_list.router"].show_note = show_note; ρσ_modules["book_list.router"].push_state = push_state; ρσ_modules["book_list.router"].back = back; ρσ_modules["book_list.router"].home = home; })(); (function(){ var __name__ = "read_book.viewport"; var FUNCTIONS, scroll_viewport, attr; FUNCTIONS = "x y scroll_to scroll_into_view reset_globals __reset_transforms window_scroll_pos content_size".split(" "); var get_boss = ρσ_modules["read_book.globals"].get_boss; var viewport_mode_changer = ρσ_modules["read_book.globals"].viewport_mode_changer; var document_height = ρσ_modules.utils.document_height; var document_width = ρσ_modules.utils.document_width; var ios_major_version = ρσ_modules.utils.ios_major_version; function ScrollViewport() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); ScrollViewport.prototype.__bind_methods__.call(this); ScrollViewport.prototype.__init__.apply(this, arguments); } Object.defineProperty(ScrollViewport.prototype, "__bind_methods__", {value: function () { this.set_mode = ScrollViewport.prototype.set_mode.bind(this); this.initialize_on_layout = ScrollViewport.prototype.initialize_on_layout.bind(this); this.flow_x = ScrollViewport.prototype.flow_x.bind(this); this.flow_y = ScrollViewport.prototype.flow_y.bind(this); this.flow_window_scroll_pos = ScrollViewport.prototype.flow_window_scroll_pos.bind(this); this.inline_pos = ScrollViewport.prototype.inline_pos.bind(this); this.block_pos = ScrollViewport.prototype.block_pos.bind(this); this.flow_scroll_to = ScrollViewport.prototype.flow_scroll_to.bind(this); this.scroll_to_in_inline_direction = ScrollViewport.prototype.scroll_to_in_inline_direction.bind(this); this.scroll_to_in_block_direction = ScrollViewport.prototype.scroll_to_in_block_direction.bind(this); this.flow_scroll_into_view = ScrollViewport.prototype.flow_scroll_into_view.bind(this); this.scroll_by = ScrollViewport.prototype.scroll_by.bind(this); this.scroll_by_in_inline_direction = ScrollViewport.prototype.scroll_by_in_inline_direction.bind(this); this.scroll_by_in_block_direction = ScrollViewport.prototype.scroll_by_in_block_direction.bind(this); this.flow_reset_globals = ScrollViewport.prototype.flow_reset_globals.bind(this); this.flow___reset_transforms = ScrollViewport.prototype.flow___reset_transforms.bind(this); this.flow_content_size = ScrollViewport.prototype.flow_content_size.bind(this); this.paged_content_inline_size = ScrollViewport.prototype.paged_content_inline_size.bind(this); this.paged_content_block_size = ScrollViewport.prototype.paged_content_block_size.bind(this); this.inline_size = ScrollViewport.prototype.inline_size.bind(this); this.block_size = ScrollViewport.prototype.block_size.bind(this); this.update_window_size = ScrollViewport.prototype.update_window_size.bind(this); this.width = ScrollViewport.prototype.width.bind(this); this.height = ScrollViewport.prototype.height.bind(this); this.document_inline_size = ScrollViewport.prototype.document_inline_size.bind(this); this.document_block_size = ScrollViewport.prototype.document_block_size.bind(this); this.viewport_to_document = ScrollViewport.prototype.viewport_to_document.bind(this); this.rect_inline_start = ScrollViewport.prototype.rect_inline_start.bind(this); this.rect_inline_end = ScrollViewport.prototype.rect_inline_end.bind(this); this.rect_block_start = ScrollViewport.prototype.rect_block_start.bind(this); this.rect_block_end = ScrollViewport.prototype.rect_block_end.bind(this); this.rect_inline_size = ScrollViewport.prototype.rect_inline_size.bind(this); this.rect_block_size = ScrollViewport.prototype.rect_block_size.bind(this); this.viewport_to_document_inline = ScrollViewport.prototype.viewport_to_document_inline.bind(this); this.viewport_to_document_block = ScrollViewport.prototype.viewport_to_document_block.bind(this); this.viewport_to_document_inline_block = ScrollViewport.prototype.viewport_to_document_inline_block.bind(this); }}); ScrollViewport.prototype.__init__ = function __init__() { var self = this; self.set_mode("flow"); self.window_width_from_parent = self.window_height_from_parent = null; self.rtl = false; self.ltr = true; self.vertical_writing_mode = false; self.horizontal_writing_mode = true; }; if (!ScrollViewport.prototype.__init__.__module__) Object.defineProperties(ScrollViewport.prototype.__init__, { __module__ : {value: "read_book.viewport"} }); ScrollViewport.__argnames__ = ScrollViewport.prototype.__init__.__argnames__; ScrollViewport.__handles_kwarg_interpolation__ = ScrollViewport.prototype.__init__.__handles_kwarg_interpolation__; ScrollViewport.prototype.set_mode = function set_mode(mode) { var self = this; var prefix, attr; prefix = ((mode === "flow") ? "flow" : "paged") + "_"; var ρσ_Iter54 = FUNCTIONS; ρσ_Iter54 = ((typeof ρσ_Iter54[Symbol.iterator] === "function") ? (ρσ_Iter54 instanceof Map ? ρσ_Iter54.keys() : ρσ_Iter54) : Object.keys(ρσ_Iter54)); for (var ρσ_Index54 of ρσ_Iter54) { attr = ρσ_Index54; self[(typeof attr === "number" && attr < 0) ? self.length + attr : attr] = self[ρσ_bound_index(prefix + attr, self)]; } }; if (!ScrollViewport.prototype.set_mode.__argnames__) Object.defineProperties(ScrollViewport.prototype.set_mode, { __argnames__ : {value: ["mode"]}, __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.initialize_on_layout = function initialize_on_layout(body_style) { var self = this; var css_vertical_rl, css_vertical_lr; self.horizontal_writing_mode = true; self.vertical_writing_mode = false; self.ltr = true; self.rtl = false; if (body_style.direction === "rtl") { self.rtl = true; self.ltr = false; } css_vertical_rl = body_style.getPropertyValue("writing-mode") === "vertical-rl"; if (css_vertical_rl) { self.vertical_writing_mode = true; self.horizontal_writing_mode = false; self.rtl = true; self.ltr = false; } else { css_vertical_lr = body_style.getPropertyValue("writing-mode") === "vertical-lr"; if (css_vertical_lr) { self.vertical_writing_mode = true; self.horizontal_writing_mode = false; self.ltr = true; self.rtl = false; } } }; if (!ScrollViewport.prototype.initialize_on_layout.__argnames__) Object.defineProperties(ScrollViewport.prototype.initialize_on_layout, { __argnames__ : {value: ["body_style"]}, __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.flow_x = function flow_x() { var self = this; if (self.rtl) { return -window.pageXOffset; } return window.pageXOffset; }; if (!ScrollViewport.prototype.flow_x.__module__) Object.defineProperties(ScrollViewport.prototype.flow_x, { __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.flow_y = function flow_y() { var self = this; return window.pageYOffset; }; if (!ScrollViewport.prototype.flow_y.__module__) Object.defineProperties(ScrollViewport.prototype.flow_y, { __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.flow_window_scroll_pos = function flow_window_scroll_pos() { var self = this; return [window.pageXOffset, window.pageYOffset]; }; if (!ScrollViewport.prototype.flow_window_scroll_pos.__module__) Object.defineProperties(ScrollViewport.prototype.flow_window_scroll_pos, { __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.inline_pos = function inline_pos() { var self = this; if (self.vertical_writing_mode) { return self.y(); } return self.x(); }; if (!ScrollViewport.prototype.inline_pos.__module__) Object.defineProperties(ScrollViewport.prototype.inline_pos, { __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.block_pos = function block_pos() { var self = this; if (self.horizontal_writing_mode) { return self.y(); } return self.x(); }; if (!ScrollViewport.prototype.block_pos.__module__) Object.defineProperties(ScrollViewport.prototype.block_pos, { __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.flow_scroll_to = function flow_scroll_to(x, y) { var self = this; if (self.rtl) { window.scrollTo(-x, y); } else { window.scrollTo(x, y); } }; if (!ScrollViewport.prototype.flow_scroll_to.__argnames__) Object.defineProperties(ScrollViewport.prototype.flow_scroll_to, { __argnames__ : {value: ["x", "y"]}, __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.scroll_to_in_inline_direction = function scroll_to_in_inline_direction(pos, preserve_other) { var self = this; if (self.vertical_writing_mode) { self.scroll_to((preserve_other) ? self.x() : 0, pos); } else { self.scroll_to(pos, (preserve_other) ? self.y() : 0); } }; if (!ScrollViewport.prototype.scroll_to_in_inline_direction.__argnames__) Object.defineProperties(ScrollViewport.prototype.scroll_to_in_inline_direction, { __argnames__ : {value: ["pos", "preserve_other"]}, __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.scroll_to_in_block_direction = function scroll_to_in_block_direction(pos, preserve_other) { var self = this; if (self.horizontal_writing_mode) { self.scroll_to((preserve_other) ? self.x() : 0, pos); } else { self.scroll_to(pos, (preserve_other) ? self.y() : 0); } }; if (!ScrollViewport.prototype.scroll_to_in_block_direction.__argnames__) Object.defineProperties(ScrollViewport.prototype.scroll_to_in_block_direction, { __argnames__ : {value: ["pos", "preserve_other"]}, __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.flow_scroll_into_view = function flow_scroll_into_view(elem) { var self = this; elem.scrollIntoView(); }; if (!ScrollViewport.prototype.flow_scroll_into_view.__argnames__) Object.defineProperties(ScrollViewport.prototype.flow_scroll_into_view, { __argnames__ : {value: ["elem"]}, __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.scroll_by = function scroll_by(x, y) { var self = this; if (self.ltr) { window.scrollBy(x, y); } else { window.scrollBy(-x, y); } }; if (!ScrollViewport.prototype.scroll_by.__argnames__) Object.defineProperties(ScrollViewport.prototype.scroll_by, { __argnames__ : {value: ["x", "y"]}, __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.scroll_by_in_inline_direction = function scroll_by_in_inline_direction(offset) { var self = this; if (self.vertical_writing_mode) { self.scroll_by(0, offset); } else { self.scroll_by(offset, 0); } }; if (!ScrollViewport.prototype.scroll_by_in_inline_direction.__argnames__) Object.defineProperties(ScrollViewport.prototype.scroll_by_in_inline_direction, { __argnames__ : {value: ["offset"]}, __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.scroll_by_in_block_direction = function scroll_by_in_block_direction(offset) { var self = this; if (self.horizontal_writing_mode) { self.scroll_by(0, offset); } else { self.scroll_by(offset, 0); } }; if (!ScrollViewport.prototype.scroll_by_in_block_direction.__argnames__) Object.defineProperties(ScrollViewport.prototype.scroll_by_in_block_direction, { __argnames__ : {value: ["offset"]}, __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.flow_reset_globals = function flow_reset_globals() { var self = this; }; if (!ScrollViewport.prototype.flow_reset_globals.__module__) Object.defineProperties(ScrollViewport.prototype.flow_reset_globals, { __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.flow___reset_transforms = function flow___reset_transforms() { var self = this; }; if (!ScrollViewport.prototype.flow___reset_transforms.__module__) Object.defineProperties(ScrollViewport.prototype.flow___reset_transforms, { __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.flow_content_size = function flow_content_size() { var self = this; return [document.documentElement.scrollWidth, document.documentElement.scrollHeight]; }; if (!ScrollViewport.prototype.flow_content_size.__module__) Object.defineProperties(ScrollViewport.prototype.flow_content_size, { __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.paged_content_inline_size = function paged_content_inline_size() { var self = this; var ρσ_unpack, w, h; ρσ_unpack = self.content_size(); ρσ_unpack = ρσ_unpack_asarray(2, ρσ_unpack); w = ρσ_unpack[0]; h = ρσ_unpack[1]; return (self.horizontal_writing_mode) ? w : h; }; if (!ScrollViewport.prototype.paged_content_inline_size.__module__) Object.defineProperties(ScrollViewport.prototype.paged_content_inline_size, { __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.paged_content_block_size = function paged_content_block_size() { var self = this; var ρσ_unpack, w, h; ρσ_unpack = self.content_size(); ρσ_unpack = ρσ_unpack_asarray(2, ρσ_unpack); w = ρσ_unpack[0]; h = ρσ_unpack[1]; return (self.horizontal_writing_mode) ? h : w; }; if (!ScrollViewport.prototype.paged_content_block_size.__module__) Object.defineProperties(ScrollViewport.prototype.paged_content_block_size, { __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.inline_size = function inline_size() { var self = this; if (self.horizontal_writing_mode) { return self.width(); } return self.height(); }; if (!ScrollViewport.prototype.inline_size.__module__) Object.defineProperties(ScrollViewport.prototype.inline_size, { __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.block_size = function block_size() { var self = this; if (self.horizontal_writing_mode) { return self.height(); } return self.width(); }; if (!ScrollViewport.prototype.block_size.__module__) Object.defineProperties(ScrollViewport.prototype.block_size, { __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.update_window_size = function update_window_size(w, h) { var self = this; self.window_width_from_parent = w; self.window_height_from_parent = h; }; if (!ScrollViewport.prototype.update_window_size.__argnames__) Object.defineProperties(ScrollViewport.prototype.update_window_size, { __argnames__ : {value: ["w", "h"]}, __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.width = function width() { var self = this; return window.innerWidth; }; if (!ScrollViewport.prototype.width.__module__) Object.defineProperties(ScrollViewport.prototype.width, { __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.height = function height() { var self = this; return window.innerHeight; }; if (!ScrollViewport.prototype.height.__module__) Object.defineProperties(ScrollViewport.prototype.height, { __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.document_inline_size = function document_inline_size() { var self = this; if (self.horizontal_writing_mode) { return document_width(); } return document_height(); }; if (!ScrollViewport.prototype.document_inline_size.__module__) Object.defineProperties(ScrollViewport.prototype.document_inline_size, { __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.document_block_size = function document_block_size() { var self = this; if (self.horizontal_writing_mode) { return document_height(); } return document_width(); }; if (!ScrollViewport.prototype.document_block_size.__module__) Object.defineProperties(ScrollViewport.prototype.document_block_size, { __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.viewport_to_document = function viewport_to_document(x, y, doc) { var self = this; var topdoc, frame, rect, ρσ_unpack, wx, wy; doc = doc || window.document; topdoc = window.document; while (doc !== topdoc && doc.defaultView) { frame = doc.defaultView.frameElement; rect = frame.getBoundingClientRect(); x += rect.left; y += rect.top; doc = frame.ownerDocument; } ρσ_unpack = self.window_scroll_pos(); ρσ_unpack = ρσ_unpack_asarray(2, ρσ_unpack); wx = ρσ_unpack[0]; wy = ρσ_unpack[1]; x += wx; y += wy; if (self.rtl) { x *= -1; } return [x, y]; }; if (!ScrollViewport.prototype.viewport_to_document.__argnames__) Object.defineProperties(ScrollViewport.prototype.viewport_to_document, { __argnames__ : {value: ["x", "y", "doc"]}, __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.rect_inline_start = function rect_inline_start(rect) { var self = this; if (self.horizontal_writing_mode) { return (self.ltr) ? rect.left : rect.right; } return rect.top; }; if (!ScrollViewport.prototype.rect_inline_start.__argnames__) Object.defineProperties(ScrollViewport.prototype.rect_inline_start, { __argnames__ : {value: ["rect"]}, __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.rect_inline_end = function rect_inline_end(rect) { var self = this; if (self.horizontal_writing_mode) { return (self.ltr) ? rect.right : rect.left; } return rect.bottom; }; if (!ScrollViewport.prototype.rect_inline_end.__argnames__) Object.defineProperties(ScrollViewport.prototype.rect_inline_end, { __argnames__ : {value: ["rect"]}, __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.rect_block_start = function rect_block_start(rect) { var self = this; if (self.horizontal_writing_mode) { return rect.top; } return (self.ltr) ? rect.left : rect.right; }; if (!ScrollViewport.prototype.rect_block_start.__argnames__) Object.defineProperties(ScrollViewport.prototype.rect_block_start, { __argnames__ : {value: ["rect"]}, __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.rect_block_end = function rect_block_end(rect) { var self = this; if (self.horizontal_writing_mode) { return rect.bottom; } return (self.ltr) ? rect.right : rect.left; }; if (!ScrollViewport.prototype.rect_block_end.__argnames__) Object.defineProperties(ScrollViewport.prototype.rect_block_end, { __argnames__ : {value: ["rect"]}, __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.rect_inline_size = function rect_inline_size(rect) { var self = this; if (self.horizontal_writing_mode) { return rect.width; } return rect.height; }; if (!ScrollViewport.prototype.rect_inline_size.__argnames__) Object.defineProperties(ScrollViewport.prototype.rect_inline_size, { __argnames__ : {value: ["rect"]}, __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.rect_block_size = function rect_block_size(rect) { var self = this; if (self.horizontal_writing_mode) { return rect.height; } return rect.width; }; if (!ScrollViewport.prototype.rect_block_size.__argnames__) Object.defineProperties(ScrollViewport.prototype.rect_block_size, { __argnames__ : {value: ["rect"]}, __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.viewport_to_document_inline = function viewport_to_document_inline(pos, doc) { var self = this; if (self.horizontal_writing_mode) { return self.viewport_to_document(pos, 0, doc)[0]; } return self.viewport_to_document(0, pos, doc)[1]; }; if (!ScrollViewport.prototype.viewport_to_document_inline.__argnames__) Object.defineProperties(ScrollViewport.prototype.viewport_to_document_inline, { __argnames__ : {value: ["pos", "doc"]}, __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.viewport_to_document_block = function viewport_to_document_block(pos, doc) { var self = this; if (self.horizontal_writing_mode) { return self.viewport_to_document(0, pos, doc)[1]; } return self.viewport_to_document(pos, 0, doc)[0]; }; if (!ScrollViewport.prototype.viewport_to_document_block.__argnames__) Object.defineProperties(ScrollViewport.prototype.viewport_to_document_block, { __argnames__ : {value: ["pos", "doc"]}, __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.viewport_to_document_inline_block = function viewport_to_document_inline_block(inline, block, doc) { var self = this; if (self.horizontal_writing_mode) { return self.viewport_to_document(inline, block, doc); } return self.viewport_to_document(block, inline, doc); }; if (!ScrollViewport.prototype.viewport_to_document_inline_block.__argnames__) Object.defineProperties(ScrollViewport.prototype.viewport_to_document_inline_block, { __argnames__ : {value: ["inline", "block", "doc"]}, __module__ : {value: "read_book.viewport"} }); ScrollViewport.prototype.__repr__ = function __repr__ () { return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; ScrollViewport.prototype.__str__ = function __str__ () { return this.__repr__(); }; Object.defineProperty(ScrollViewport.prototype, "__bases__", {value: []}); function IOSScrollViewport() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); IOSScrollViewport.prototype.__bind_methods__.call(this); IOSScrollViewport.prototype.__init__.apply(this, arguments); } ρσ_extends(IOSScrollViewport, ScrollViewport); Object.defineProperty(IOSScrollViewport.prototype, "__bind_methods__", {value: function () { ScrollViewport.prototype.__bind_methods__ && ScrollViewport.prototype.__bind_methods__.call(this); this.width = IOSScrollViewport.prototype.width.bind(this); this.height = IOSScrollViewport.prototype.height.bind(this); this._scroll_implementation = IOSScrollViewport.prototype._scroll_implementation.bind(this); this.paged_scroll_to = IOSScrollViewport.prototype.paged_scroll_to.bind(this); this.transform_val = IOSScrollViewport.prototype.transform_val.bind(this); this.paged_x = IOSScrollViewport.prototype.paged_x.bind(this); this.paged_y = IOSScrollViewport.prototype.paged_y.bind(this); this.paged_scroll_into_view = IOSScrollViewport.prototype.paged_scroll_into_view.bind(this); this.paged_window_scroll_pos = IOSScrollViewport.prototype.paged_window_scroll_pos.bind(this); this.paged_content_size = IOSScrollViewport.prototype.paged_content_size.bind(this); this.paged___reset_transforms = IOSScrollViewport.prototype.paged___reset_transforms.bind(this); this.paged_reset_globals = IOSScrollViewport.prototype.paged_reset_globals.bind(this); }}); IOSScrollViewport.prototype.__init__ = function __init__ () { ScrollViewport.prototype.__init__ && ScrollViewport.prototype.__init__.apply(this, arguments); }; IOSScrollViewport.prototype.width = function width() { var self = this; return self.window_width_from_parent || window.innerWidth; }; if (!IOSScrollViewport.prototype.width.__module__) Object.defineProperties(IOSScrollViewport.prototype.width, { __module__ : {value: "read_book.viewport"} }); IOSScrollViewport.prototype.height = function height() { var self = this; return self.window_height_from_parent || window.innerHeight; }; if (!IOSScrollViewport.prototype.height.__module__) Object.defineProperties(IOSScrollViewport.prototype.height, { __module__ : {value: "read_book.viewport"} }); IOSScrollViewport.prototype._scroll_implementation = function _scroll_implementation(x, y) { var self = this; if (x === 0 && y === 0) { document.documentElement.style.transform = "none"; } else { x *= -1; y *= -1; document.documentElement.style.transform = "translateX(" + ρσ_str.format("{}", x) + "px) translateY(" + ρσ_str.format("{}", y) + "px)"; } }; if (!IOSScrollViewport.prototype._scroll_implementation.__argnames__) Object.defineProperties(IOSScrollViewport.prototype._scroll_implementation, { __argnames__ : {value: ["x", "y"]}, __module__ : {value: "read_book.viewport"} }); IOSScrollViewport.prototype.paged_scroll_to = function paged_scroll_to(x, y) { var self = this; var boss; x = x || 0; y = y || 0; if (self.ltr) { self._scroll_implementation(x, y); } else { self._scroll_implementation(-x, y); } boss = get_boss(); if (boss) { boss.onscroll(); } }; if (!IOSScrollViewport.prototype.paged_scroll_to.__argnames__) Object.defineProperties(IOSScrollViewport.prototype.paged_scroll_to, { __argnames__ : {value: ["x", "y"]}, __module__ : {value: "read_book.viewport"} }); IOSScrollViewport.prototype.transform_val = function transform_val(y) { var self = this; var raw, idx, ans; raw = document.documentElement.style.transform; if (!raw || raw === "none") { return 0; } idx = (y) ? raw.lastIndexOf("(") : raw.indexOf("("); raw = raw.slice(idx + 1); ans = parseInt(raw); if (isNaN(ans)) { ans = 0; } return ans; }; if (!IOSScrollViewport.prototype.transform_val.__argnames__) Object.defineProperties(IOSScrollViewport.prototype.transform_val, { __argnames__ : {value: ["y"]}, __module__ : {value: "read_book.viewport"} }); IOSScrollViewport.prototype.paged_x = function paged_x() { var self = this; var ans; ans = self.transform_val(); if (self.ltr) { ans *= -1; } return ans; }; if (!IOSScrollViewport.prototype.paged_x.__module__) Object.defineProperties(IOSScrollViewport.prototype.paged_x, { __module__ : {value: "read_book.viewport"} }); IOSScrollViewport.prototype.paged_y = function paged_y() { var self = this; return -1 * self.transform_val(true); }; if (!IOSScrollViewport.prototype.paged_y.__module__) Object.defineProperties(IOSScrollViewport.prototype.paged_y, { __module__ : {value: "read_book.viewport"} }); IOSScrollViewport.prototype.paged_scroll_into_view = function paged_scroll_into_view(elem) { var self = this; var left, p; left = elem.offsetLeft; if (left === null) { return; } elem.scrollIntoView(); window.scrollTo(0, 0); p = elem.offsetParent; while (p) { left += p.offsetLeft; p = p.offsetParent; } self._scroll_implementation(max(0, left), 0); }; if (!IOSScrollViewport.prototype.paged_scroll_into_view.__argnames__) Object.defineProperties(IOSScrollViewport.prototype.paged_scroll_into_view, { __argnames__ : {value: ["elem"]}, __module__ : {value: "read_book.viewport"} }); IOSScrollViewport.prototype.paged_window_scroll_pos = function paged_window_scroll_pos() { var self = this; return [self.transform_val(), self.transform_val(true)]; }; if (!IOSScrollViewport.prototype.paged_window_scroll_pos.__module__) Object.defineProperties(IOSScrollViewport.prototype.paged_window_scroll_pos, { __module__ : {value: "read_book.viewport"} }); IOSScrollViewport.prototype.paged_content_size = function paged_content_size() { var self = this; var w, h; w = document.documentElement.scrollWidth; h = document.documentElement.scrollHeight; return [w - self.transform_val(), h - self.transform_val(true)]; }; if (!IOSScrollViewport.prototype.paged_content_size.__module__) Object.defineProperties(IOSScrollViewport.prototype.paged_content_size, { __module__ : {value: "read_book.viewport"} }); IOSScrollViewport.prototype.paged___reset_transforms = function paged___reset_transforms() { var self = this; var s; s = document.documentElement.style; if (s.transform !== "none") { s.transform = "none"; } }; if (!IOSScrollViewport.prototype.paged___reset_transforms.__module__) Object.defineProperties(IOSScrollViewport.prototype.paged___reset_transforms, { __module__ : {value: "read_book.viewport"} }); IOSScrollViewport.prototype.paged_reset_globals = function paged_reset_globals() { var self = this; self.__reset_transforms(); }; if (!IOSScrollViewport.prototype.paged_reset_globals.__module__) Object.defineProperties(IOSScrollViewport.prototype.paged_reset_globals, { __module__ : {value: "read_book.viewport"} }); IOSScrollViewport.prototype.__repr__ = function __repr__ () { if(ScrollViewport.prototype.__repr__) return ScrollViewport.prototype.__repr__.call(this); return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; IOSScrollViewport.prototype.__str__ = function __str__ () { if(ScrollViewport.prototype.__str__) return ScrollViewport.prototype.__str__.call(this); return this.__repr__(); }; Object.defineProperty(IOSScrollViewport.prototype, "__bases__", {value: [ScrollViewport]}); if (1 < ios_major_version && ios_major_version < 15) { scroll_viewport = new IOSScrollViewport; } else { scroll_viewport = new ScrollViewport; } var ρσ_Iter55 = FUNCTIONS; ρσ_Iter55 = ((typeof ρσ_Iter55[Symbol.iterator] === "function") ? (ρσ_Iter55 instanceof Map ? ρσ_Iter55.keys() : ρσ_Iter55) : Object.keys(ρσ_Iter55)); for (var ρσ_Index55 of ρσ_Iter55) { attr = ρσ_Index55; if (!scroll_viewport[ρσ_bound_index("paged_" + attr, scroll_viewport)]) { scroll_viewport[ρσ_bound_index("paged_" + attr, scroll_viewport)] = scroll_viewport[(typeof attr === "number" && attr < 0) ? scroll_viewport.length + attr : attr]; } } viewport_mode_changer(scroll_viewport.set_mode); function get_unit_size_in_pixels(unit) { var d, ans; d = document.createElement("span"); d.style.position = "absolute"; d.style.visibility = "hidden"; d.style.width = "1" + ρσ_str.format("{}", unit) + ""; d.style.fontSize = "1" + ρσ_str.format("{}", unit) + ""; d.style.paddingTop = d.style.paddingBottom = d.style.paddingLeft = d.style.paddingRight = "0"; d.style.marginTop = d.style.marginBottom = d.style.marginLeft = d.style.marginRight = "0"; d.style.borderStyle = "none"; document.body.appendChild(d); ans = d.clientWidth; document.body.removeChild(d); return ans; }; if (!get_unit_size_in_pixels.__argnames__) Object.defineProperties(get_unit_size_in_pixels, { __argnames__ : {value: ["unit"]}, __module__ : {value: "read_book.viewport"} }); function rem_size(reset) { var d; if (reset) { rem_size.ans = null; return; } if (!rem_size.ans) { d = document.createElement("span"); d.style.position = "absolute"; d.style.visibility = "hidden"; d.style.width = "1rem"; d.style.fontSize = "1rem"; d.style.paddingTop = d.style.paddingBottom = d.style.paddingLeft = d.style.paddingRight = "0"; d.style.marginTop = d.style.marginBottom = d.style.marginLeft = d.style.marginRight = "0"; d.style.borderStyle = "none"; document.body.appendChild(d); rem_size.ans = max(2, d.clientWidth); document.body.removeChild(d); } return rem_size.ans; }; if (!rem_size.__argnames__) Object.defineProperties(rem_size, { __argnames__ : {value: ["reset"]}, __module__ : {value: "read_book.viewport"} }); function line_height(reset) { var ds, lh; if (reset) { line_height.ans = null; return; } if (!line_height.ans) { ds = window.getComputedStyle(document.body); try { lh = float(ds.lineHeight); } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; { try { lh = 1.2 * float(ds.fontSize); } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; { lh = 15; } } } } line_height.ans = max(5, lh); } return line_height.ans; }; if (!line_height.__argnames__) Object.defineProperties(line_height, { __argnames__ : {value: ["reset"]}, __module__ : {value: "read_book.viewport"} }); ρσ_modules["read_book.viewport"].FUNCTIONS = FUNCTIONS; ρσ_modules["read_book.viewport"].scroll_viewport = scroll_viewport; ρσ_modules["read_book.viewport"].attr = attr; ρσ_modules["read_book.viewport"].ScrollViewport = ScrollViewport; ρσ_modules["read_book.viewport"].IOSScrollViewport = IOSScrollViewport; ρσ_modules["read_book.viewport"].get_unit_size_in_pixels = get_unit_size_in_pixels; ρσ_modules["read_book.viewport"].rem_size = rem_size; ρσ_modules["read_book.viewport"].line_height = line_height; })(); (function(){ var __name__ = "read_book.cfi"; var escape_pat, unescape_pat; var scroll_viewport = ρσ_modules["read_book.viewport"].scroll_viewport; var rem_size = ρσ_modules["read_book.viewport"].rem_size; escape_pat = /[\[\],^();~@!]/g; unescape_pat = /[\^](.)/g; function escape_for_cfi(raw) { return (raw || "").replace(escape_pat, "^$&"); }; if (!escape_for_cfi.__argnames__) Object.defineProperties(escape_for_cfi, { __argnames__ : {value: ["raw"]}, __module__ : {value: "read_book.cfi"} }); function unescape_from_cfi(raw) { return (raw || "").replace(unescape_pat, "$1"); }; if (!unescape_from_cfi.__argnames__) Object.defineProperties(unescape_from_cfi, { __argnames__ : {value: ["raw"]}, __module__ : {value: "read_book.cfi"} }); function fstr(d) { var ans, n; ans = ""; if (d < 0) { ans = "-"; d = -d; } n = Math.floor(d); ans += n; n = Math.round((d - n) * 100); if (n !== 0) { ans += "." + ((n % 10 === 0) ? n / 10 : n); } return ans; }; if (!fstr.__argnames__) Object.defineProperties(fstr, { __argnames__ : {value: ["d"]}, __module__ : {value: "read_book.cfi"} }); function get_current_time(target) { return fstr(target.currentTime || 0); }; if (!get_current_time.__argnames__) Object.defineProperties(get_current_time, { __argnames__ : {value: ["target"]}, __module__ : {value: "read_book.cfi"} }); function id_is_unique(idval) { var multiples; try { multiples = document.querySelectorAll("[id=" + window.CSS.escape(idval) + "]"); } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; { return false; } } if (multiples && multiples.length < 2) { return true; } return false; }; if (!id_is_unique.__argnames__) Object.defineProperties(id_is_unique, { __argnames__ : {value: ["idval"]}, __module__ : {value: "read_book.cfi"} }); function range_has_point(range_, x, y) { var rects, rect; rects = range_.getClientRects(); for (var i = 0; i < rects.length; i++) { rect = rects[(typeof i === "number" && i < 0) ? rects.length + i : i]; if (rect.left <= x && x <= rect.right && rect.top <= y && y <= rect.bottom) { return true; } } return false; }; if (!range_has_point.__argnames__) Object.defineProperties(range_has_point, { __argnames__ : {value: ["range_", "x", "y"]}, __module__ : {value: "read_book.cfi"} }); function offset_in_text_node(node, range_, x, y) { var limits, pivot, lr, rr; limits = [ 0, node.nodeValue.length ]; while (limits[0] !== limits[1]) { pivot = Math.floor((limits[0] + limits[1]) / 2); lr = [ limits[0], pivot ]; rr = [ pivot + 1, limits[1] ]; range_.setStart(node, pivot); range_.setEnd(node, pivot + 1); if (range_has_point(range_, x, y)) { return pivot; } range_.setStart(node, rr[0]); range_.setEnd(node, rr[1]); if (range_has_point(range_, x, y)) { limits = rr; continue; } range_.setStart(node, lr[0]); range_.setEnd(node, lr[1]); if (range_has_point(range_, x, y)) { limits = lr; continue; } break; } return limits[0]; }; if (!offset_in_text_node.__argnames__) Object.defineProperties(offset_in_text_node, { __argnames__ : {value: ["node", "range_", "x", "y"]}, __module__ : {value: "read_book.cfi"} }); function find_offset_for_point(x, y, node, cdoc) { var range_, child; range_ = cdoc.createRange(); child = node.firstChild; while (child) { if (Node.TEXT_NODE <= (ρσ_cond_temp = child.nodeType) && ρσ_cond_temp <= Node.ENTITY_NODE && child.nodeValue && child.nodeValue.length) { range_.setStart(child, 0); range_.setEnd(child, child.nodeValue.length); if (range_has_point(range_, x, y)) { return [ child, offset_in_text_node(child, range_, x, y) ]; } } child = child.nextSibling; } return [null, null]; }; if (!find_offset_for_point.__argnames__) Object.defineProperties(find_offset_for_point, { __argnames__ : {value: ["x", "y", "node", "cdoc"]}, __module__ : {value: "read_book.cfi"} }); function set_current_time(target, val) { if (target.currentTime === undefined) { return; } if (target.readyState === 4 || target.readyState === "complete") { target.currentTime = val + 0; } else { target.addEventListener("canplay", (function() { var ρσ_anonfunc = function () { target.currentTime = val; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "read_book.cfi"} }); return ρσ_anonfunc; })(), false); } }; if (!set_current_time.__argnames__) Object.defineProperties(set_current_time, { __argnames__ : {value: ["target", "val"]}, __module__ : {value: "read_book.cfi"} }); function is_text_node(node) { return node.nodeType === Node.TEXT_NODE || node.nodeType === Node.CDATA_SECTION_NODE; }; if (!is_text_node.__argnames__) Object.defineProperties(is_text_node, { __argnames__ : {value: ["node"]}, __module__ : {value: "read_book.cfi"} }); function text_length_in_range_wrapper(node) { var p, ans; p = node.firstChild; ans = 0; while (p) { if (is_text_node(p)) { ans += p.nodeValue.length; } else if (p.nodeType === Node.ELEMENT_NODE && ρσ_exists.d(p.dataset).calibreRangeWrapper) { ans += text_length_in_range_wrapper(p); } p = p.nextSibling; } return ans; }; if (!text_length_in_range_wrapper.__argnames__) Object.defineProperties(text_length_in_range_wrapper, { __argnames__ : {value: ["node"]}, __module__ : {value: "read_book.cfi"} }); function adjust_node_for_text_offset(node) { var offset, adjusted, p; if (node.parentNode && ρσ_exists.d(node.parentNode.dataset).calibreRangeWrapper) { node = node.parentNode; } offset = 0; adjusted = false; while (true) { p = node.previousSibling; if (!p || p.nodeType > Node.COMMENT_NODE) { break; } if (is_text_node(p)) { offset += p.nodeValue.length; } else if (p.nodeType === Node.ELEMENT_NODE && ρσ_exists.d(p.dataset).calibreRangeWrapper) { offset += text_length_in_range_wrapper(p); } node = p; adjusted = true; } if (adjusted && node.nodeType === Node.ELEMENT_NODE && ρσ_exists.d(node.dataset).calibreRangeWrapper) { if (!node.firstChild || node.firstChild.nodeType !== Node.TEXT_NODE) { node.insertBefore(document.createTextNode(""), node.firstChild || null); } node = node.firstChild; } return [node, offset, adjusted]; }; if (!adjust_node_for_text_offset.__argnames__) Object.defineProperties(adjust_node_for_text_offset, { __argnames__ : {value: ["node"]}, __module__ : {value: "read_book.cfi"} }); function unwrapped_nodes(range_wrapper) { var ans, child; ans = []; var ρσ_Iter56 = range_wrapper.childNodes; ρσ_Iter56 = ((typeof ρσ_Iter56[Symbol.iterator] === "function") ? (ρσ_Iter56 instanceof Map ? ρσ_Iter56.keys() : ρσ_Iter56) : Object.keys(ρσ_Iter56)); for (var ρσ_Index56 of ρσ_Iter56) { child = ρσ_Index56; if (child.nodeType === Node.ELEMENT_NODE && ρσ_exists.d(child.dataset).calibreRangeWrapper) { ans = ans.concat(unwrapped_nodes(child)); } else { ans.push(child); } } return ans; }; if (!unwrapped_nodes.__argnames__) Object.defineProperties(unwrapped_nodes, { __argnames__ : {value: ["range_wrapper"]}, __module__ : {value: "read_book.cfi"} }); function increment_index_for_child(child, index, sentinel) { var is_element, nodes; is_element = child.nodeType === Node.ELEMENT_NODE; if (is_element && ρσ_exists.d(child.dataset).calibreRangeWrapper) { nodes = unwrapped_nodes(child); index = increment_index_for_children(nodes, index, sentinel); } else { index |= 1; if (is_element) { index += 1; } } return index; }; if (!increment_index_for_child.__argnames__) Object.defineProperties(increment_index_for_child, { __argnames__ : {value: ["child", "index", "sentinel"]}, __module__ : {value: "read_book.cfi"} }); function increment_index_for_children(children, index, sentinel) { var child, i; for (var ρσ_Index57 = 0; ρσ_Index57 < children.length; ρσ_Index57++) { i = ρσ_Index57; child = children[(typeof i === "number" && i < 0) ? children.length + i : i]; index = increment_index_for_child(child, index, sentinel); if (child === sentinel) { break; } } return index; }; if (!increment_index_for_children.__argnames__) Object.defineProperties(increment_index_for_children, { __argnames__ : {value: ["children", "index", "sentinel"]}, __module__ : {value: "read_book.cfi"} }); function non_range_wrapper_parent(node) { var p, child; p = node.parentNode; child = node; while (ρσ_exists.d(p.dataset).calibreRangeWrapper) { child = p; p = p.parentNode; } return [p, child]; }; if (!non_range_wrapper_parent.__argnames__) Object.defineProperties(non_range_wrapper_parent, { __argnames__ : {value: ["node"]}, __module__ : {value: "read_book.cfi"} }); function encode(doc, node, offset, tail) { var cfi, q, ρσ_unpack, adjusted_node, additional_offset, adjusted, is_first, p, sentinel, win, index, id, idspec; cfi = tail || ""; if (node.nodeType === Node.ELEMENT_NODE) { if (typeof offset === "number") { q = node.childNodes.item(offset); if (q) { if (q.nodeType === Node.ELEMENT_NODE) { node = q; if (ρσ_exists.d(node.dataset).calibreRangeWrapper) { if (!node.firstChild) { node.appendChild(document.createTextNode("")); } node = node.firstChild; } } } } else if (ρσ_exists.d(node.dataset).calibreRangeWrapper) { if (!node.firstChild) { node.appendChild(document.createTextNode("")); } node = node.firstChild; } } if (is_text_node(node)) { offset = offset || 0; ρσ_unpack = adjust_node_for_text_offset(node); ρσ_unpack = ρσ_unpack_asarray(3, ρσ_unpack); adjusted_node = ρσ_unpack[0]; additional_offset = ρσ_unpack[1]; adjusted = ρσ_unpack[2]; if (adjusted) { node = adjusted_node; offset += additional_offset; } cfi = ":" + offset + cfi; } else if (node.nodeType !== Node.ELEMENT_NODE) { print("Offsets for nodes of type " + ρσ_str.format("{}", node.nodeType) + " are not handled"); } is_first = true; while (node !== doc) { ρσ_unpack = non_range_wrapper_parent(node); ρσ_unpack = ρσ_unpack_asarray(2, ρσ_unpack); p = ρσ_unpack[0]; sentinel = ρσ_unpack[1]; if (!p) { if ((node.nodeType === Node.DOCUMENT_NODE || typeof node.nodeType === "object" && ρσ_equals(node.nodeType, Node.DOCUMENT_NODE))) { win = node.defaultView; if (win.frameElement) { node = win.frameElement; cfi = "!" + cfi; continue; } } break; } index = increment_index_for_children(p.childNodes, 0, sentinel); if (is_first) { is_first = false; if (node.nodeType === Node.ELEMENT_NODE && ρσ_exists.d(node.dataset).calibreRangeWrapper) { index -= 1; } } id = node.id; idspec = ""; if (id && id_is_unique(id)) { idspec = "[" + escape_for_cfi(id) + "]"; } cfi = "/" + index + idspec + cfi; node = p; } return cfi; }; if (!encode.__argnames__) Object.defineProperties(encode, { __argnames__ : {value: ["doc", "node", "offset", "tail"]}, __module__ : {value: "read_book.cfi"} }); function node_at_index(nodes, target, index, iter_text_nodes) { var node, is_element, ρσ_unpack, q, i; for (var ρσ_Index58 = 0; ρσ_Index58 < nodes.length; ρσ_Index58++) { i = ρσ_Index58; node = nodes[(typeof i === "number" && i < 0) ? nodes.length + i : i]; is_element = node.nodeType === Node.ELEMENT_NODE; if (is_element && ρσ_exists.d(node.dataset).calibreRangeWrapper) { ρσ_unpack = node_at_index(unwrapped_nodes(node), target, index, iter_text_nodes); ρσ_unpack = ρσ_unpack_asarray(2, ρσ_unpack); q = ρσ_unpack[0]; index = ρσ_unpack[1]; if (q) { return [q, index]; } continue; } if (iter_text_nodes && !is_text_node(node) || !iter_text_nodes && !is_element) { continue; } if (index === target) { return [node, index]; } index += 1; } return [null, index]; }; if (!node_at_index.__argnames__) Object.defineProperties(node_at_index, { __argnames__ : {value: ["nodes", "target", "index", "iter_text_nodes"]}, __module__ : {value: "read_book.cfi"} }); function node_for_path_step(parent, target, assertion) { var q, is_element; if (assertion) { q = document.getElementById(assertion); if (q && id_is_unique(assertion)) { return q; } } is_element = ρσ_equals(target % 2, 0); target = Math.floor(target / 2); if (is_element && target > 0) { target -= 1; } return node_at_index(parent.childNodes, target, 0, !is_element)[0]; }; if (!node_for_path_step.__argnames__) Object.defineProperties(node_for_path_step, { __argnames__ : {value: ["parent", "target", "assertion"]}, __module__ : {value: "read_book.cfi"} }); function node_for_text_offset(nodes, offset, first_node) { var last_text_node, seen_first, node, l, ρσ_unpack, qn, ok, i; last_text_node = null; seen_first = false; for (var ρσ_Index59 = 0; ρσ_Index59 < nodes.length; ρσ_Index59++) { i = ρσ_Index59; node = nodes[(typeof i === "number" && i < 0) ? nodes.length + i : i]; if (!seen_first) { if (!first_node || node.isSameNode(first_node)) { seen_first = true; } else { continue; } } if (is_text_node(node)) { l = node.nodeValue.length; if (offset <= l) { return [node, offset, true]; } last_text_node = node; offset -= l; } else if (node.nodeType === Node.ELEMENT_NODE && ρσ_exists.d(node.dataset).calibreRangeWrapper) { ρσ_unpack = node_for_text_offset(unwrapped_nodes(node), offset); ρσ_unpack = ρσ_unpack_asarray(3, ρσ_unpack); qn = ρσ_unpack[0]; offset = ρσ_unpack[1]; ok = ρσ_unpack[2]; if (ok) { return [qn, offset, true]; } } } return [last_text_node, offset, false]; }; if (!node_for_text_offset.__argnames__) Object.defineProperties(node_for_text_offset, { __argnames__ : {value: ["nodes", "offset", "first_node"]}, __module__ : {value: "read_book.cfi"} }); function decode(cfi, doc) { var simple_node_regex, error, node, orig_cfi, r, target, assertion, q, decoded, offset, orig_offset, ρσ_unpack, qnode, ok; doc = doc || window.document; simple_node_regex = /^\/(\d+)(\[[^\]]*\])?/; error = null; node = doc; orig_cfi = cfi; while (cfi.length > 0 && !error) { r = cfi.match(simple_node_regex); if (r) { target = parseInt(r[1]); assertion = r[2]; if (assertion) { assertion = unescape_from_cfi(assertion.slice(1, assertion.length - 1)); } q = node_for_path_step(node, target, assertion); if (q) { node = q; cfi = cfi.substr(r[0].length); } else { if (target) { error = "No matching child found for CFI: " + ρσ_str.format("{}", orig_cfi) + " leftover: " + ρσ_str.format("{}", cfi) + ""; break; } else { cfi = cfi.substr(r[0].length); } } } else if (cfi[0] === "!") { if (node.contentDocument) { node = node.contentDocument; cfi = cfi.substr(1); } else { error = "Cannot reference " + node.nodeName + "'s content: " + cfi; } } else { break; } } if (error) { print(error); return null; } decoded = Object.create(null); error = null; offset = null; r = cfi.match(/^:(\d+)/); if (r) { offset = parseInt(r[1]); cfi = cfi.substr(r[0].length); } r = cfi.match(/^~(-?\d+(\.\d+)?)/); if (r) { decoded.time = r[1] - 0; cfi = cfi.substr(r[0].length); } r = cfi.match(/^@(-?\d+(\.\d+)?):(-?\d+(\.\d+)?)/); if (r) { decoded.x = r[1] - 0; decoded.y = r[3] - 0; cfi = cfi.substr(r[0].length); } r = cfi.match(/^\[([^\]]+)\]/); if (r) { assertion = r[1]; cfi = cfi.substr(r[0].length); r = assertion.match(/;s=([ab])$/); if (r) { if (r.index > 0 && assertion[ρσ_bound_index(r.index - 1, assertion)] !== "^") { assertion = assertion.substr(0, r.index); decoded.forward = r[1] === "a"; } assertion = unescape_from_cfi(assertion); } } if (offset !== null) { orig_offset = offset; if (ρσ_exists.d(node.parentNode).nodeType === Node.ELEMENT_NODE && ρσ_exists.d(node.parentNode.dataset).calibreRangeWrapper) { node = node.parentNode; } ρσ_unpack = node_for_text_offset(node.parentNode.childNodes, offset, node); ρσ_unpack = ρσ_unpack_asarray(3, ρσ_unpack); qnode = ρσ_unpack[0]; offset = ρσ_unpack[1]; ok = ρσ_unpack[2]; if (!ok) { error = "Offset out of range: " + orig_offset; } if (qnode) { node = qnode; } decoded.offset = offset; } decoded.node = node; if (error) { decoded.error = error; } else if (cfi.length > 0) { decoded.error = "Undecoded CFI: " + cfi; } if (decoded.error) { print(decoded.error); } return decoded; }; if (!decode.__argnames__) Object.defineProperties(decode, { __argnames__ : {value: ["cfi", "doc"]}, __module__ : {value: "read_book.cfi"} }); function cfi_sort_key(cfi) { var simple_node_regex, steps, r, target, ans, offset; simple_node_regex = /^\/(\d+)(\[[^\]]*\])?/; steps = []; while (cfi.length > 0) { r = cfi.match(simple_node_regex); if (r) { target = parseInt(r[1]); cfi = cfi.substr(r[0].length); steps.push(target); } else if (cfi[0] === "!") { cfi = cfi.substr(1); } else { break; } } ans = (function(){ var ρσ_d = Object.create(null); ρσ_d["steps"] = steps; ρσ_d["text_offset"] = 0; ρσ_d["temporal_offset"] = 0; ρσ_d["spatial_offset"] = [ 0, 0 ]; return ρσ_d; }).call(this); r = cfi.match(/^:(\d+)/); if (r) { offset = parseInt(r[1]); ans["text_offset"] = offset; cfi = cfi.substr(r[0].length); } r = cfi.match(/^~(-?\d+(\.\d+)?)/); if (r) { ans["temporal_offset"] = r[1] - 0; cfi = cfi.substr(r[0].length); } r = cfi.match(/^@(-?\d+(\.\d+)?):(-?\d+(\.\d+)?)/); if (r) { ans["spatial_offset"] = [ r[1] - 0, r[3] - 0 ]; cfi = cfi.substr(r[0].length); } return ans; }; if (!cfi_sort_key.__argnames__) Object.defineProperties(cfi_sort_key, { __argnames__ : {value: ["cfi"]}, __module__ : {value: "read_book.cfi"} }); function create_cfi_cmp(key_map) { if (!key_map) { key_map = Object.create(null); } function cfi_cmp(a_cfi, b_cfi) { var a, b, diff, i; a = key_map[(typeof a_cfi === "number" && a_cfi < 0) ? key_map.length + a_cfi : a_cfi]; if (!a) { a = key_map[(typeof a_cfi === "number" && a_cfi < 0) ? key_map.length + a_cfi : a_cfi] = cfi_sort_key(a_cfi); } b = key_map[(typeof b_cfi === "number" && b_cfi < 0) ? key_map.length + b_cfi : b_cfi]; if (!b) { b = key_map[(typeof b_cfi === "number" && b_cfi < 0) ? key_map.length + b_cfi : b_cfi] = cfi_sort_key(b_cfi); } var ρσ_Iter60 = range(min(a.steps.length, b.steps.length)); ρσ_Iter60 = ((typeof ρσ_Iter60[Symbol.iterator] === "function") ? (ρσ_Iter60 instanceof Map ? ρσ_Iter60.keys() : ρσ_Iter60) : Object.keys(ρσ_Iter60)); for (var ρσ_Index60 of ρσ_Iter60) { i = ρσ_Index60; diff = (ρσ_expr_temp = a.steps)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i] - (ρσ_expr_temp = b.steps)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i]; if (diff !== 0) { return diff; } } diff = a.steps.length - b.steps.length; if (diff !== 0) { return diff; } if (a.temporal_offset !== b.temporal_offset) { return a.temporal_offset - b.temporal_offset; } if (a.spatial_offset[0] !== b.spatial_offset[0]) { return a.spatial_offset[0] - b.spatial_offset[0]; } if (a.spatial_offset[1] !== b.spatial_offset[1]) { return a.spatial_offset[1] - b.spatial_offset[1]; } if (a.text_offset !== b.text_offset) { return a.text_offset - b.text_offset; } return 0; }; if (!cfi_cmp.__argnames__) Object.defineProperties(cfi_cmp, { __argnames__ : {value: ["a_cfi", "b_cfi"]}, __module__ : {value: "read_book.cfi"} }); return cfi_cmp; }; if (!create_cfi_cmp.__argnames__) Object.defineProperties(create_cfi_cmp, { __argnames__ : {value: ["key_map"]}, __module__ : {value: "read_book.cfi"} }); function at(x, y, doc) { var cdoc, target, tail, offset, name, cd, rect, px, py, ρσ_unpack; doc = doc || window.document; cdoc = doc; target = null; tail = ""; offset = null; name = null; while (true) { target = cdoc.elementFromPoint(x, y); if (!target || target === cdoc.documentElement || target === cdoc.body) { return null; } name = target.localName; if (!ρσ_in(name, (function(){ var s = ρσ_set(); s.jsset.add("iframe"); s.jsset.add("embed"); s.jsset.add("object"); return s; })())) { break; } cd = target.contentDocument; if (!cd) { break; } rect = target.getBoundingClientRect(); x -= rect.left; y -= rect.top; cdoc = cd; } (target.parentNode || target).normalize(); if (ρσ_in(name, (function(){ var s = ρσ_set(); s.jsset.add("audio"); s.jsset.add("video"); return s; })())) { tail = "~" + get_current_time(target); } if (ρσ_in(name, (function(){ var s = ρσ_set(); s.jsset.add("img"); s.jsset.add("video"); return s; })())) { rect = target.getBoundingClientRect(); px = (x - rect.left) * 100 / target.offsetWidth; py = (y - rect.top) * 100 / target.offsetHeight; tail = str.format("{}@{}:{}", tail, fstr(px), fstr(py)); } else if (name !== "audio") { ρσ_unpack = find_offset_for_point(x, y, target, cdoc); ρσ_unpack = ρσ_unpack_asarray(2, ρσ_unpack); target = ρσ_unpack[0]; offset = ρσ_unpack[1]; if (target === null) { return null; } } return encode(doc, target, offset, tail); }; if (!at.__argnames__) Object.defineProperties(at, { __argnames__ : {value: ["x", "y", "doc"]}, __module__ : {value: "read_book.cfi"} }); function decode_with_range(cfi, doc) { var decoded, node, ndoc, range_, position_at_end_of_range, node_len, offset, rect; doc = doc || window.document; decoded = decode(cfi, doc); if (!decoded || !decoded.node) { return null; } node = decoded.node; ndoc = node.ownerDocument; if (!ndoc) { print(str.format("CFI node has no owner document: {} {}", cfi, node)); return null; } range_ = null; position_at_end_of_range = null; if (typeof decoded.offset === "number") { node_len = (node.nodeValue) ? node.nodeValue.length : 0; if (!node_len && ρσ_exists.d(ρσ_exists.d(node.nextSibling).dataset).calibreRangeWrapper && ρσ_exists.d(node.nextSibling.firstChild).nodeType === Node.TEXT_NODE) { node = node.nextSibling.firstChild; node_len = (node.nodeValue) ? node.nodeValue.length : 0; } if (node_len) { range_ = ndoc.createRange(); offset = decoded.offset; position_at_end_of_range = false; if (offset >= node_len) { offset = node_len - 1; position_at_end_of_range = true; } range_.setStart(node, offset); range_.setEnd(node, offset + 1); rect = range_.getBoundingClientRect(); if (!rect) { print(str.format("Could not find caret position for {} (offset: {})", cfi, decoded.offset)); range_ = null; } } else { print("Caret offset pointed to an empty text node or a non-text node for " + ρσ_str.format("{}", cfi) + ", (offset: " + ρσ_str.format("{}", decoded.offset) + ")"); range_ = null; } } decoded.range = range_; decoded.use_range_end_pos = position_at_end_of_range; return decoded; }; if (!decode_with_range.__argnames__) Object.defineProperties(decode_with_range, { __argnames__ : {value: ["cfi", "doc"]}, __module__ : {value: "read_book.cfi"} }); function decoded_range_to_document_position(decoded) { var rect, inserted_node, inline_vs_pos, block_vs_pos; rect = decoded.range.getBoundingClientRect(); inserted_node = null; if (!rect.width && !rect.height && !rect.left && !rect.right) { inserted_node = document.createTextNode(" "); decoded.range.insertNode(inserted_node); rect = decoded.range.getBoundingClientRect(); } if (decoded.use_range_end_pos) { inline_vs_pos = scroll_viewport.rect_inline_end(rect); } else { inline_vs_pos = scroll_viewport.rect_inline_start(rect); } if (decoded.forward) { block_vs_pos = scroll_viewport.rect_block_end(rect); } else { block_vs_pos = scroll_viewport.rect_block_start(rect); } if (inserted_node) { inserted_node.parentNode.removeChild(inserted_node); } return scroll_viewport.viewport_to_document_inline_block(inline_vs_pos, block_vs_pos, decoded.node.ownerDocument); }; if (!decoded_range_to_document_position.__argnames__) Object.defineProperties(decoded_range_to_document_position, { __argnames__ : {value: ["decoded"]}, __module__ : {value: "read_book.cfi"} }); function decoded_node_or_spatial_offset_to_document_position(decoded) { var node, rect, ρσ_unpack, percentx, percenty, viewx, viewy, doc_left, doc_top, block_vs_pos, inline_vs_pos; node = decoded.node; rect = node.getBoundingClientRect(); ρσ_unpack = [decoded.x, decoded.y]; percentx = ρσ_unpack[0]; percenty = ρσ_unpack[1]; if (typeof percentx === "number" && node.offsetWidth && typeof percenty === "number" && node.offsetHeight) { viewx = rect.left + percentx * node.offsetWidth / 100; viewy = rect.top + percenty * node.offsetHeight / 100; ρσ_unpack = scroll_viewport.viewport_to_document(viewx, viewy, node.ownerDocument); ρσ_unpack = ρσ_unpack_asarray(2, ρσ_unpack); doc_left = ρσ_unpack[0]; doc_top = ρσ_unpack[1]; return [doc_left, doc_top]; } else { if (decoded.forward) { block_vs_pos = scroll_viewport.rect_block_end(rect); } else { block_vs_pos = scroll_viewport.rect_block_start(rect); } inline_vs_pos = scroll_viewport.rect_inline_start(rect); return scroll_viewport.viewport_to_document_inline_block(inline_vs_pos, block_vs_pos, node.ownerDocument); } }; if (!decoded_node_or_spatial_offset_to_document_position.__argnames__) Object.defineProperties(decoded_node_or_spatial_offset_to_document_position, { __argnames__ : {value: ["decoded"]}, __module__ : {value: "read_book.cfi"} }); function decoded_to_document_position(decoded) { var node; node = decoded.node; if (decoded.range !== null) { return decoded_range_to_document_position(decoded); } else if (node !== null && node.getBoundingClientRect) { return decoded_node_or_spatial_offset_to_document_position(decoded); } return [null, null]; }; if (!decoded_to_document_position.__argnames__) Object.defineProperties(decoded_to_document_position, { __argnames__ : {value: ["decoded"]}, __module__ : {value: "read_book.cfi"} }); function scroll_to(cfi, callback, doc) { var decoded, fn; decoded = decode_with_range(cfi, doc); if (!decoded) { print("No location information found for cfi: " + cfi); return; } if (typeof decoded.time === "number") { set_current_time(decoded.node, decoded.time); } function handle_text_node() { var r, ρσ_unpack, so, eo, original_node, node_parent, original_node_index, ndoc, span; r = decoded.range; ρσ_unpack = [r.startOffset, r.endOffset]; so = ρσ_unpack[0]; eo = ρσ_unpack[1]; original_node = r.startContainer; node_parent = original_node.parentNode; original_node_index = 0; for (var i = 0; i < node_parent.childNodes.length; i++) { if ((ρσ_expr_temp = node_parent.childNodes)[(typeof i === "number" && i < 0) ? ρσ_expr_temp.length + i : i].isSameNode(original_node)) { original_node_index = i; break; } } ndoc = original_node.ownerDocument || document; span = ndoc.createElement("span"); span.setAttribute("style", "border-width: 0; padding: 0; margin: 0"); r.surroundContents(span); scroll_viewport.scroll_into_view(span); return (function() { var ρσ_anonfunc = function () { var p, node, offset, ρσ_unpack, doc_x, doc_y; p = span.parentNode; var ρσ_Iter61 = span.childNodes; ρσ_Iter61 = ((typeof ρσ_Iter61[Symbol.iterator] === "function") ? (ρσ_Iter61 instanceof Map ? ρσ_Iter61.keys() : ρσ_Iter61) : Object.keys(ρσ_Iter61)); for (var ρσ_Index61 of ρσ_Iter61) { node = ρσ_Index61; span.removeChild(node); p.insertBefore(node, span); } p.removeChild(span); p.normalize(); original_node = (ρσ_expr_temp = node_parent.childNodes)[(typeof original_node_index === "number" && original_node_index < 0) ? ρσ_expr_temp.length + original_node_index : original_node_index]; if (!original_node) { return; } offset = so; while (offset > -1) { try { r.setStart(original_node, offset); break; } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; { offset -= 1; } } } offset = eo; while (offset > -1) { try { r.setEnd(original_node, offset); break; } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; { offset -= 1; } } } ρσ_unpack = decoded_range_to_document_position(decoded); ρσ_unpack = ρσ_unpack_asarray(2, ρσ_unpack); doc_x = ρσ_unpack[0]; doc_y = ρσ_unpack[1]; if (doc_x === null || doc_y === null) { return; } if (scroll_viewport.rtl) { doc_x += scroll_viewport.width(); } if (callback) { callback(doc_x, doc_y); } }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "read_book.cfi"} }); return ρσ_anonfunc; })(); }; if (!handle_text_node.__module__) Object.defineProperties(handle_text_node, { __module__ : {value: "read_book.cfi"} }); function handle_element_node() { var node; node = decoded.node; if (node.nodeType === Node.TEXT_NODE) { node = decoded.node = node.parentNode; } if (!node.scrollIntoView) { return; } scroll_viewport.scroll_into_view(node); return (function() { var ρσ_anonfunc = function () { var ρσ_unpack, doc_x, doc_y; ρσ_unpack = decoded_node_or_spatial_offset_to_document_position(decoded); ρσ_unpack = ρσ_unpack_asarray(2, ρσ_unpack); doc_x = ρσ_unpack[0]; doc_y = ρσ_unpack[1]; if (doc_x === null || doc_y === null) { return; } if (scroll_viewport.rtl) { doc_x += scroll_viewport.width(); } if (callback) { callback(doc_x, doc_y); } }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "read_book.cfi"} }); return ρσ_anonfunc; })(); }; if (!handle_element_node.__module__) Object.defineProperties(handle_element_node, { __module__ : {value: "read_book.cfi"} }); if (decoded.range !== null) { fn = handle_text_node(); } else { fn = handle_element_node(); } setTimeout(fn, 10); }; if (!scroll_to.__argnames__) Object.defineProperties(scroll_to, { __argnames__ : {value: ["cfi", "callback", "doc"]}, __module__ : {value: "read_book.cfi"} }); function at_point(x, y) { var cfi, decoded, ρσ_unpack, cfix, cfiy; function dist(p1, p2) { Math.sqrt(Math.pow(p1[0] - p2[0], 2), Math.pow(p1[1] - p2[1], 2)); }; if (!dist.__argnames__) Object.defineProperties(dist, { __argnames__ : {value: ["p1", "p2"]}, __module__ : {value: "read_book.cfi"} }); try { cfi = at(x, y); } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; { cfi = null; } } if (cfi === null) { return null; } try { decoded = decode_with_range(cfi); } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; { decoded = null; } } if (!decoded) { return null; } if (cfi) { try { ρσ_unpack = decoded_to_document_position(decoded); ρσ_unpack = ρσ_unpack_asarray(2, ρσ_unpack); cfix = ρσ_unpack[0]; cfiy = ρσ_unpack[1]; } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; { cfix = cfiy = null; } } if (cfix === null || cfiy === null || dist(scroll_viewport.viewport_to_document(x, y), [ cfix, cfiy ]) > 50) { cfi = null; } } return cfi; }; if (!at_point.__argnames__) Object.defineProperties(at_point, { __argnames__ : {value: ["x", "y"]}, __module__ : {value: "read_book.cfi"} }); function at_current() { var ρσ_unpack, wini, winb, deltai, deltab, startb, endb, starti, endi, up_boundb, up_boundi, low_boundb, low_boundi, at_point_conditional, curb, cfi, x, y, de, rect, px, py; ρσ_unpack = [scroll_viewport.inline_size() - 1, scroll_viewport.block_size() - 1]; wini = ρσ_unpack[0]; winb = ρσ_unpack[1]; deltai = deltab = max(8, min(Math.ceil(rem_size() / 2), 32)); if (scroll_viewport.horizontal_writing_mode) { startb = 0; endb = winb; if (scroll_viewport.ltr) { starti = 0; endi = wini; } else { starti = wini; endi = 0; deltai = -deltai; } } else { starti = 0; endi = winb; if (scroll_viewport.rtl) { startb = winb; endb = 0; deltab = -deltab; } else { startb = 0; endb = winb; } } up_boundb = max(startb, endb); up_boundi = max(starti, endi); low_boundb = min(startb, endb); low_boundi = min(starti, endi); function at_point_vertical_mode(i, b) { return at_point(b, i); }; if (!at_point_vertical_mode.__argnames__) Object.defineProperties(at_point_vertical_mode, { __argnames__ : {value: ["i", "b"]}, __module__ : {value: "read_book.cfi"} }); at_point_conditional = (scroll_viewport.vertical_writing_mode) ? at_point_vertical_mode : at_point; function i_loop(curb) { var curi, cfi; curi = starti; while (low_boundi <= curi && curi <= up_boundi) { cfi = at_point_conditional(curi, curb); if (cfi) { return cfi; } curi += deltai; } }; if (!i_loop.__argnames__) Object.defineProperties(i_loop, { __argnames__ : {value: ["curb"]}, __module__ : {value: "read_book.cfi"} }); curb = startb; cfi = null; while (low_boundb <= curb && curb <= up_boundb && !cfi) { cfi = i_loop(curb); curb += deltab; } if (cfi) { return cfi; } ρσ_unpack = [scroll_viewport.x() + ((scroll_viewport.ltr) ? 0 : scroll_viewport.width()), scroll_viewport.y()]; x = ρσ_unpack[0]; y = ρσ_unpack[1]; de = document.documentElement; rect = de.getBoundingClientRect(); px = x * 100 / rect.width; py = y * 100 / rect.height; cfi = str.format("/2@{}:{}", fstr(px), fstr(py)); return cfi; }; if (!at_current.__module__) Object.defineProperties(at_current, { __module__ : {value: "read_book.cfi"} }); function cfi_for_selection(r) { if (!r) { r = window.getSelection().getRangeAt(0); } function pos(container, offset) { var nt; nt = container.nodeType; if (nt === Node.TEXT_NODE || nt === Node.CDATA_SECTION_NODE || nt === Node.COMMENT_NODE) { return [container, offset]; } if (nt === Node.ELEMENT_NODE && offset && container.childNodes.length > offset) { return [(ρσ_expr_temp = container.childNodes)[(typeof offset === "number" && offset < 0) ? ρσ_expr_temp.length + offset : offset], 0]; } return [container, offset]; }; if (!pos.__argnames__) Object.defineProperties(pos, { __argnames__ : {value: ["container", "offset"]}, __module__ : {value: "read_book.cfi"} }); return (function(){ var ρσ_d = Object.create(null); ρσ_d["start"] = encode.apply(this, [r.startContainer.ownerDocument].concat(pos(r.startContainer, r.startOffset))); ρσ_d["end"] = encode.apply(this, [r.endContainer.ownerDocument].concat(pos(r.endContainer, r.endOffset))); return ρσ_d; }).call(this); }; if (!cfi_for_selection.__argnames__) Object.defineProperties(cfi_for_selection, { __argnames__ : {value: ["r"]}, __module__ : {value: "read_book.cfi"} }); function range_from_cfi(start, end) { var r; start = decode(start); end = decode(end); if (!start || start.error || !end || end.error) { return; } r = document.createRange(); r.setStart(start.node, start.offset); r.setEnd(end.node, end.offset); return r; }; if (!range_from_cfi.__argnames__) Object.defineProperties(range_from_cfi, { __argnames__ : {value: ["start", "end"]}, __module__ : {value: "read_book.cfi"} }); ρσ_modules["read_book.cfi"].escape_pat = escape_pat; ρσ_modules["read_book.cfi"].unescape_pat = unescape_pat; ρσ_modules["read_book.cfi"].escape_for_cfi = escape_for_cfi; ρσ_modules["read_book.cfi"].unescape_from_cfi = unescape_from_cfi; ρσ_modules["read_book.cfi"].fstr = fstr; ρσ_modules["read_book.cfi"].get_current_time = get_current_time; ρσ_modules["read_book.cfi"].id_is_unique = id_is_unique; ρσ_modules["read_book.cfi"].range_has_point = range_has_point; ρσ_modules["read_book.cfi"].offset_in_text_node = offset_in_text_node; ρσ_modules["read_book.cfi"].find_offset_for_point = find_offset_for_point; ρσ_modules["read_book.cfi"].set_current_time = set_current_time; ρσ_modules["read_book.cfi"].is_text_node = is_text_node; ρσ_modules["read_book.cfi"].text_length_in_range_wrapper = text_length_in_range_wrapper; ρσ_modules["read_book.cfi"].adjust_node_for_text_offset = adjust_node_for_text_offset; ρσ_modules["read_book.cfi"].unwrapped_nodes = unwrapped_nodes; ρσ_modules["read_book.cfi"].increment_index_for_child = increment_index_for_child; ρσ_modules["read_book.cfi"].increment_index_for_children = increment_index_for_children; ρσ_modules["read_book.cfi"].non_range_wrapper_parent = non_range_wrapper_parent; ρσ_modules["read_book.cfi"].encode = encode; ρσ_modules["read_book.cfi"].node_at_index = node_at_index; ρσ_modules["read_book.cfi"].node_for_path_step = node_for_path_step; ρσ_modules["read_book.cfi"].node_for_text_offset = node_for_text_offset; ρσ_modules["read_book.cfi"].decode = decode; ρσ_modules["read_book.cfi"].cfi_sort_key = cfi_sort_key; ρσ_modules["read_book.cfi"].create_cfi_cmp = create_cfi_cmp; ρσ_modules["read_book.cfi"].at = at; ρσ_modules["read_book.cfi"].decode_with_range = decode_with_range; ρσ_modules["read_book.cfi"].decoded_range_to_document_position = decoded_range_to_document_position; ρσ_modules["read_book.cfi"].decoded_node_or_spatial_offset_to_document_position = decoded_node_or_spatial_offset_to_document_position; ρσ_modules["read_book.cfi"].decoded_to_document_position = decoded_to_document_position; ρσ_modules["read_book.cfi"].scroll_to = scroll_to; ρσ_modules["read_book.cfi"].at_point = at_point; ρσ_modules["read_book.cfi"].at_current = at_current; ρσ_modules["read_book.cfi"].cfi_for_selection = cfi_for_selection; ρσ_modules["read_book.cfi"].range_from_cfi = range_from_cfi; })(); (function(){ var __name__ = "read_book.annotations"; var no_cfi, field_map, getter_map; var _ = ρσ_modules.gettext.gettext; var create_cfi_cmp = ρσ_modules["read_book.cfi"].create_cfi_cmp; var cfi_sort_key = ρσ_modules["read_book.cfi"].cfi_sort_key; var ui_operations = ρσ_modules["read_book.globals"].ui_operations; no_cfi = "/99999999"; function bookmark_get_cfi(b) { if (b.pos_type === "epubcfi") { return b.pos.slice(8, -1); } return no_cfi; }; if (!bookmark_get_cfi.__argnames__) Object.defineProperties(bookmark_get_cfi, { __argnames__ : {value: ["b"]}, __module__ : {value: "read_book.annotations"} }); function highlight_get_cfi(hl) { var cfi, si; cfi = hl.start_cfi; if (cfi) { si = (ρσ_exists.n(hl.spine_index)) ? "/" + ρσ_str.format("{}", hl.spine_index) + "" : no_cfi; return si + cfi; } return no_cfi; }; if (!highlight_get_cfi.__argnames__) Object.defineProperties(highlight_get_cfi, { __argnames__ : {value: ["hl"]}, __module__ : {value: "read_book.annotations"} }); function sort_annot_list(annots, get_cfi_func) { var key_map, cfi, annot, cfi_cmp; key_map = (function(){ var ρσ_d = Object.create(null); ρσ_d[no_cfi] = cfi_sort_key(no_cfi); return ρσ_d; }).call(this); var ρσ_Iter62 = annots; ρσ_Iter62 = ((typeof ρσ_Iter62[Symbol.iterator] === "function") ? (ρσ_Iter62 instanceof Map ? ρσ_Iter62.keys() : ρσ_Iter62) : Object.keys(ρσ_Iter62)); for (var ρσ_Index62 of ρσ_Iter62) { annot = ρσ_Index62; cfi = get_cfi_func(annot); if (cfi && !key_map[(typeof cfi === "number" && cfi < 0) ? key_map.length + cfi : cfi]) { key_map[(typeof cfi === "number" && cfi < 0) ? key_map.length + cfi : cfi] = cfi_sort_key(cfi); } } cfi_cmp = create_cfi_cmp(key_map); annots.sort((function() { var ρσ_anonfunc = function (a, b) { var acfi, bcfi; acfi = get_cfi_func(a); bcfi = get_cfi_func(b); return cfi_cmp(acfi, bcfi); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["a", "b"]}, __module__ : {value: "read_book.annotations"} }); return ρσ_anonfunc; })()); }; if (!sort_annot_list.__argnames__) Object.defineProperties(sort_annot_list, { __argnames__ : {value: ["annots", "get_cfi_func"]}, __module__ : {value: "read_book.annotations"} }); function annots_descending_cmp(a, b) { return (a.timestamp > b.timestamp) ? -1 : (a.timestamp < b.timestamp) ? 1 : 0; }; if (!annots_descending_cmp.__argnames__) Object.defineProperties(annots_descending_cmp, { __argnames__ : {value: ["a", "b"]}, __module__ : {value: "read_book.annotations"} }); function merge_annots_with_identical_field(annots_a, annots_b, field, cfi_getter_func) { var title_groups, changed, all_annots, q, a, tg, seen, ans, title, candidates; title_groups = Object.create(null); changed = false; all_annots = annots_a.concat(annots_b); var ρσ_Iter63 = all_annots; ρσ_Iter63 = ((typeof ρσ_Iter63[Symbol.iterator] === "function") ? (ρσ_Iter63 instanceof Map ? ρσ_Iter63.keys() : ρσ_Iter63) : Object.keys(ρσ_Iter63)); for (var ρσ_Index63 of ρσ_Iter63) { a = ρσ_Index63; q = title_groups[ρσ_bound_index(a[(typeof field === "number" && field < 0) ? a.length + field : field], title_groups)]; if (!q) { q = title_groups[ρσ_bound_index(a[(typeof field === "number" && field < 0) ? a.length + field : field], title_groups)] = []; } q.push(a); } var ρσ_Iter64 = Object.values(title_groups); ρσ_Iter64 = ((typeof ρσ_Iter64[Symbol.iterator] === "function") ? (ρσ_Iter64 instanceof Map ? ρσ_Iter64.keys() : ρσ_Iter64) : Object.keys(ρσ_Iter64)); for (var ρσ_Index64 of ρσ_Iter64) { tg = ρσ_Index64; tg.sort(annots_descending_cmp); } seen = Object.create(null); ans = []; var ρσ_Iter65 = all_annots; ρσ_Iter65 = ((typeof ρσ_Iter65[Symbol.iterator] === "function") ? (ρσ_Iter65 instanceof Map ? ρσ_Iter65.keys() : ρσ_Iter65) : Object.keys(ρσ_Iter65)); for (var ρσ_Index65 of ρσ_Iter65) { a = ρσ_Index65; title = a[(typeof field === "number" && field < 0) ? a.length + field : field]; if (!seen[(typeof title === "number" && title < 0) ? seen.length + title : title]) { seen[(typeof title === "number" && title < 0) ? seen.length + title : title] = true; candidates = title_groups[(typeof title === "number" && title < 0) ? title_groups.length + title : title]; if (!changed && candidates.length > 1 && candidates[0].timestamp !== candidates[1].timestamp) { changed = true; } ans.push(title_groups[(typeof title === "number" && title < 0) ? title_groups.length + title : title][0]); } } if (ans.length !== annots_a.length || ans.length !== annots_b.length) { changed = true; } if (changed) { sort_annot_list(ans, cfi_getter_func); } return [changed, ans]; }; if (!merge_annots_with_identical_field.__argnames__) Object.defineProperties(merge_annots_with_identical_field, { __argnames__ : {value: ["annots_a", "annots_b", "field", "cfi_getter_func"]}, __module__ : {value: "read_book.annotations"} }); field_map = (function(){ var ρσ_d = Object.create(null); ρσ_d["bookmark"] = "title"; ρσ_d["highlight"] = "uuid"; return ρσ_d; }).call(this); getter_map = (function(){ var ρσ_d = Object.create(null); ρσ_d["bookmark"] = bookmark_get_cfi; ρσ_d["highlight"] = highlight_get_cfi; return ρσ_d; }).call(this); function merge_annot_lists(a, b, field) { var key_field; key_field = field_map[(typeof field === "number" && field < 0) ? field_map.length + field : field]; return merge_annots_with_identical_field(a, b, key_field, getter_map[(typeof field === "number" && field < 0) ? getter_map.length + field : field]); }; if (!merge_annot_lists.__argnames__) Object.defineProperties(merge_annot_lists, { __argnames__ : {value: ["a", "b", "field"]}, __module__ : {value: "read_book.annotations"} }); function merge_annotation_maps(a, b) { var updated, ans, a_items, b_items, ρσ_unpack, changed, field; updated = false; ans = Object.create(null); var ρσ_Iter66 = field_map; ρσ_Iter66 = ((typeof ρσ_Iter66[Symbol.iterator] === "function") ? (ρσ_Iter66 instanceof Map ? ρσ_Iter66.keys() : ρσ_Iter66) : Object.keys(ρσ_Iter66)); for (var ρσ_Index66 of ρσ_Iter66) { field = ρσ_Index66; a_items = a[(typeof field === "number" && field < 0) ? a.length + field : field] || []; b_items = b[(typeof field === "number" && field < 0) ? b.length + field : field] || []; if (!a_items.length) { ans[(typeof field === "number" && field < 0) ? ans.length + field : field] = b_items; updated = true; continue; } if (!b_items.length) { ans[(typeof field === "number" && field < 0) ? ans.length + field : field] = a_items; continue; } ρσ_unpack = merge_annot_lists(a_items, b_items, field); ρσ_unpack = ρσ_unpack_asarray(2, ρσ_unpack); changed = ρσ_unpack[0]; ans[(typeof field === "number" && field < 0) ? ans.length + field : field] = ρσ_unpack[1]; if (changed) { updated = true; } } return [updated, ans]; }; if (!merge_annotation_maps.__argnames__) Object.defineProperties(merge_annotation_maps, { __argnames__ : {value: ["a", "b"]}, __module__ : {value: "read_book.annotations"} }); function AnnotationsManager() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); AnnotationsManager.prototype.__bind_methods__.call(this); AnnotationsManager.prototype.__init__.apply(this, arguments); } Object.defineProperty(AnnotationsManager.prototype, "__bind_methods__", {value: function () { this.sync_annots_to_server = AnnotationsManager.prototype.sync_annots_to_server.bind(this); this.set_bookmarks = AnnotationsManager.prototype.set_bookmarks.bind(this); this.all_bookmarks = AnnotationsManager.prototype.all_bookmarks.bind(this); this.add_bookmark = AnnotationsManager.prototype.add_bookmark.bind(this); this.remove_bookmark = AnnotationsManager.prototype.remove_bookmark.bind(this); this.edit_bookmark = AnnotationsManager.prototype.edit_bookmark.bind(this); this.default_bookmark_title = AnnotationsManager.prototype.default_bookmark_title.bind(this); this.set_highlights = AnnotationsManager.prototype.set_highlights.bind(this); this.all_highlights = AnnotationsManager.prototype.all_highlights.bind(this); this.merge_highlights = AnnotationsManager.prototype.merge_highlights.bind(this); this.remove_highlight = AnnotationsManager.prototype.remove_highlight.bind(this); this.delete_highlight = AnnotationsManager.prototype.delete_highlight.bind(this); this.notes_for_highlight = AnnotationsManager.prototype.notes_for_highlight.bind(this); this.text_for_highlight = AnnotationsManager.prototype.text_for_highlight.bind(this); this.set_notes_for_highlight = AnnotationsManager.prototype.set_notes_for_highlight.bind(this); this.set_style_for_highlights = AnnotationsManager.prototype.set_style_for_highlights.bind(this); this.style_for_highlight = AnnotationsManager.prototype.style_for_highlight.bind(this); this.data_for_highlight = AnnotationsManager.prototype.data_for_highlight.bind(this); this.spine_index_for_highlight = AnnotationsManager.prototype.spine_index_for_highlight.bind(this); this.cfi_for_highlight = AnnotationsManager.prototype.cfi_for_highlight.bind(this); this.add_highlight = AnnotationsManager.prototype.add_highlight.bind(this); this.highlights_for_currently_showing = AnnotationsManager.prototype.highlights_for_currently_showing.bind(this); }}); AnnotationsManager.prototype.__init__ = function __init__(view) { var self = this; self.view = view; self.set_highlights(); self.set_bookmarks(); }; if (!AnnotationsManager.prototype.__init__.__argnames__) Object.defineProperties(AnnotationsManager.prototype.__init__, { __argnames__ : {value: ["view"]}, __module__ : {value: "read_book.annotations"} }); AnnotationsManager.__argnames__ = AnnotationsManager.prototype.__init__.__argnames__; AnnotationsManager.__handles_kwarg_interpolation__ = AnnotationsManager.prototype.__init__.__handles_kwarg_interpolation__; AnnotationsManager.prototype.sync_annots_to_server = function sync_annots_to_server(which) { var self = this; var amap; if (ui_operations.annots_changed) { amap = Object.create(null); if (!which || which === "bookmarks") { amap.bookmark = self.bookmarks.as_array(); } if (!which || which === "highlights") { amap.highlight = Object.values(self.highlights); } ui_operations.annots_changed(amap); } }; if (!AnnotationsManager.prototype.sync_annots_to_server.__argnames__) Object.defineProperties(AnnotationsManager.prototype.sync_annots_to_server, { __argnames__ : {value: ["which"]}, __module__ : {value: "read_book.annotations"} }); AnnotationsManager.prototype.set_bookmarks = function set_bookmarks(bookmarks) { var self = this; bookmarks = bookmarks || []; self.bookmarks = list(bookmarks); }; if (!AnnotationsManager.prototype.set_bookmarks.__argnames__) Object.defineProperties(AnnotationsManager.prototype.set_bookmarks, { __argnames__ : {value: ["bookmarks"]}, __module__ : {value: "read_book.annotations"} }); AnnotationsManager.prototype.all_bookmarks = function all_bookmarks() { var self = this; return self.bookmarks; }; if (!AnnotationsManager.prototype.all_bookmarks.__module__) Object.defineProperties(AnnotationsManager.prototype.all_bookmarks, { __module__ : {value: "read_book.annotations"} }); AnnotationsManager.prototype.add_bookmark = function add_bookmark(title, cfi) { var self = this; var b; if (!title || !cfi) { return; } self.bookmarks = (function() { var ρσ_Iter = self.bookmarks, ρσ_Result = [], b; ρσ_Iter = ((typeof ρσ_Iter[Symbol.iterator] === "function") ? (ρσ_Iter instanceof Map ? ρσ_Iter.keys() : ρσ_Iter) : Object.keys(ρσ_Iter)); for (var ρσ_Index of ρσ_Iter) { b = ρσ_Index; if (b.title !== title) { ρσ_Result.push(b); } } ρσ_Result = ρσ_list_constructor(ρσ_Result); return ρσ_Result; })(); self.bookmarks.push((function(){ var ρσ_d = Object.create(null); ρσ_d["type"] = "bookmark"; ρσ_d["timestamp"] = (new Date).toISOString(); ρσ_d["pos_type"] = "epubcfi"; ρσ_d["pos"] = cfi; ρσ_d["title"] = title; return ρσ_d; }).call(this)); sort_annot_list(self.bookmarks, bookmark_get_cfi); self.sync_annots_to_server("bookmarks"); }; if (!AnnotationsManager.prototype.add_bookmark.__argnames__) Object.defineProperties(AnnotationsManager.prototype.add_bookmark, { __argnames__ : {value: ["title", "cfi"]}, __module__ : {value: "read_book.annotations"} }); AnnotationsManager.prototype.remove_bookmark = function remove_bookmark(title) { var self = this; var changed, b; changed = false; var ρσ_Iter67 = self.bookmarks; ρσ_Iter67 = ((typeof ρσ_Iter67[Symbol.iterator] === "function") ? (ρσ_Iter67 instanceof Map ? ρσ_Iter67.keys() : ρσ_Iter67) : Object.keys(ρσ_Iter67)); for (var ρσ_Index67 of ρσ_Iter67) { b = ρσ_Index67; if (b.title === title) { b.removed = true; b.timestamp = (new Date).toISOString(); changed = true; } } if (changed) { self.sync_annots_to_server("bookmarks"); } return changed; }; if (!AnnotationsManager.prototype.remove_bookmark.__argnames__) Object.defineProperties(AnnotationsManager.prototype.remove_bookmark, { __argnames__ : {value: ["title"]}, __module__ : {value: "read_book.annotations"} }); AnnotationsManager.prototype.edit_bookmark = function edit_bookmark(title, new_title) { var self = this; var changed, b; changed = false; var ρσ_Iter68 = self.bookmarks; ρσ_Iter68 = ((typeof ρσ_Iter68[Symbol.iterator] === "function") ? (ρσ_Iter68 instanceof Map ? ρσ_Iter68.keys() : ρσ_Iter68) : Object.keys(ρσ_Iter68)); for (var ρσ_Index68 of ρσ_Iter68) { b = ρσ_Index68; if (b.title === title) { b.title = new_title; b.timestamp = (new Date).toISOString(); changed = true; } } if (changed) { self.sync_annots_to_server("bookmarks"); } return changed; }; if (!AnnotationsManager.prototype.edit_bookmark.__argnames__) Object.defineProperties(AnnotationsManager.prototype.edit_bookmark, { __argnames__ : {value: ["title", "new_title"]}, __module__ : {value: "read_book.annotations"} }); AnnotationsManager.prototype.default_bookmark_title = function default_bookmark_title(base_default_title) { var self = this; var all_titles, bm, c, default_title; all_titles = (function() { var ρσ_Iter = self.bookmarks, ρσ_Result = Object.create(null), bm; ρσ_Iter = ((typeof ρσ_Iter[Symbol.iterator] === "function") ? (ρσ_Iter instanceof Map ? ρσ_Iter.keys() : ρσ_Iter) : Object.keys(ρσ_Iter)); for (var ρσ_Index of ρσ_Iter) { bm = ρσ_Index; if (!bm.removed) { ρσ_Result[bm.title] = (true); } } return ρσ_Result; })(); base_default_title = base_default_title || _("Bookmark"); c = 0; while (true) { c += 1; default_title = "" + ρσ_str.format("{}", base_default_title) + " #" + ρσ_str.format("{}", c) + ""; if (!all_titles[(typeof default_title === "number" && default_title < 0) ? all_titles.length + default_title : default_title]) { return default_title; } } }; if (!AnnotationsManager.prototype.default_bookmark_title.__argnames__) Object.defineProperties(AnnotationsManager.prototype.default_bookmark_title, { __argnames__ : {value: ["base_default_title"]}, __module__ : {value: "read_book.annotations"} }); AnnotationsManager.prototype.set_highlights = function set_highlights(highlights) { var self = this; var h; highlights = highlights || []; self.highlights = (function() { var ρσ_Iter = highlights, ρσ_Result = Object.create(null), h; ρσ_Iter = ((typeof ρσ_Iter[Symbol.iterator] === "function") ? (ρσ_Iter instanceof Map ? ρσ_Iter.keys() : ρσ_Iter) : Object.keys(ρσ_Iter)); for (var ρσ_Index of ρσ_Iter) { h = ρσ_Index; ρσ_Result[h.uuid] = (h); } return ρσ_Result; })(); }; if (!AnnotationsManager.prototype.set_highlights.__argnames__) Object.defineProperties(AnnotationsManager.prototype.set_highlights, { __argnames__ : {value: ["highlights"]}, __module__ : {value: "read_book.annotations"} }); AnnotationsManager.prototype.all_highlights = function all_highlights() { var self = this; var ans; ans = (function() { var ρσ_Iter = Object.values(self.highlights), ρσ_Result = [], h; ρσ_Iter = ((typeof ρσ_Iter[Symbol.iterator] === "function") ? (ρσ_Iter instanceof Map ? ρσ_Iter.keys() : ρσ_Iter) : Object.keys(ρσ_Iter)); for (var ρσ_Index of ρσ_Iter) { h = ρσ_Index; if (!h.removed) { ρσ_Result.push(h); } } ρσ_Result = ρσ_list_constructor(ρσ_Result); return ρσ_Result; })().as_array(); sort_annot_list(ans, highlight_get_cfi); return ans; }; if (!AnnotationsManager.prototype.all_highlights.__module__) Object.defineProperties(AnnotationsManager.prototype.all_highlights, { __module__ : {value: "read_book.annotations"} }); AnnotationsManager.prototype.merge_highlights = function merge_highlights(highlights) { var self = this; var updated, base, newvals, ρσ_unpack, ans; highlights = highlights || []; updated = false; if (highlights.length) { base = (function(){ var ρσ_d = Object.create(null); ρσ_d["highlight"] = Object.values(self.highlights); return ρσ_d; }).call(this); newvals = (function(){ var ρσ_d = Object.create(null); ρσ_d["highlight"] = highlights; return ρσ_d; }).call(this); ρσ_unpack = merge_annotation_maps(base, newvals); ρσ_unpack = ρσ_unpack_asarray(2, ρσ_unpack); updated = ρσ_unpack[0]; ans = ρσ_unpack[1]; if (updated) { self.set_highlights(ans.highlight); } } return updated; }; if (!AnnotationsManager.prototype.merge_highlights.__argnames__) Object.defineProperties(AnnotationsManager.prototype.merge_highlights, { __argnames__ : {value: ["highlights"]}, __module__ : {value: "read_book.annotations"} }); AnnotationsManager.prototype.remove_highlight = function remove_highlight(uuid) { var self = this; var h; h = (ρσ_expr_temp = self.highlights)[(typeof uuid === "number" && uuid < 0) ? ρσ_expr_temp.length + uuid : uuid]; if (h) { h.timestamp = (new Date).toISOString(); h.removed = true; delete h.style; delete h.highlighted_text; delete h.start_cfi; delete h.end_cfi; delete h.notes; delete h.spine_name; delete h.spine_index; delete h.toc_family_titles; return true; } }; if (!AnnotationsManager.prototype.remove_highlight.__argnames__) Object.defineProperties(AnnotationsManager.prototype.remove_highlight, { __argnames__ : {value: ["uuid"]}, __module__ : {value: "read_book.annotations"} }); AnnotationsManager.prototype.delete_highlight = function delete_highlight(uuid) { var self = this; if (self.remove_highlight(uuid)) { self.sync_annots_to_server("highlights"); } }; if (!AnnotationsManager.prototype.delete_highlight.__argnames__) Object.defineProperties(AnnotationsManager.prototype.delete_highlight, { __argnames__ : {value: ["uuid"]}, __module__ : {value: "read_book.annotations"} }); AnnotationsManager.prototype.notes_for_highlight = function notes_for_highlight(uuid) { var self = this; var h; h = (uuid) ? (ρσ_expr_temp = self.highlights)[(typeof uuid === "number" && uuid < 0) ? ρσ_expr_temp.length + uuid : uuid] : null; if (h) { return h.notes; } }; if (!AnnotationsManager.prototype.notes_for_highlight.__argnames__) Object.defineProperties(AnnotationsManager.prototype.notes_for_highlight, { __argnames__ : {value: ["uuid"]}, __module__ : {value: "read_book.annotations"} }); AnnotationsManager.prototype.text_for_highlight = function text_for_highlight(uuid) { var self = this; var h; h = (uuid) ? (ρσ_expr_temp = self.highlights)[(typeof uuid === "number" && uuid < 0) ? ρσ_expr_temp.length + uuid : uuid] : null; if (h) { return h.highlighted_text; } }; if (!AnnotationsManager.prototype.text_for_highlight.__argnames__) Object.defineProperties(AnnotationsManager.prototype.text_for_highlight, { __argnames__ : {value: ["uuid"]}, __module__ : {value: "read_book.annotations"} }); AnnotationsManager.prototype.set_notes_for_highlight = function set_notes_for_highlight(uuid, notes) { var self = this; var h; h = (ρσ_expr_temp = self.highlights)[(typeof uuid === "number" && uuid < 0) ? ρσ_expr_temp.length + uuid : uuid]; if (h) { if (notes) { h.notes = notes; } else { delete h.notes; } self.sync_annots_to_server("highlights"); return true; } return false; }; if (!AnnotationsManager.prototype.set_notes_for_highlight.__argnames__) Object.defineProperties(AnnotationsManager.prototype.set_notes_for_highlight, { __argnames__ : {value: ["uuid", "notes"]}, __module__ : {value: "read_book.annotations"} }); AnnotationsManager.prototype.set_style_for_highlights = function set_style_for_highlights(updates) { var self = this; var now, changed, h, item; now = (new Date).toISOString(); changed = false; var ρσ_Iter69 = updates; ρσ_Iter69 = ((typeof ρσ_Iter69[Symbol.iterator] === "function") ? (ρσ_Iter69 instanceof Map ? ρσ_Iter69.keys() : ρσ_Iter69) : Object.keys(ρσ_Iter69)); for (var ρσ_Index69 of ρσ_Iter69) { item = ρσ_Index69; h = (ρσ_expr_temp = self.highlights)[ρσ_bound_index(item.uuid, ρσ_expr_temp)]; if (h) { h.style = item.style; h.timestamp = now; changed = true; } } if (changed) { self.sync_annots_to_server("highlights"); } return changed; }; if (!AnnotationsManager.prototype.set_style_for_highlights.__argnames__) Object.defineProperties(AnnotationsManager.prototype.set_style_for_highlights, { __argnames__ : {value: ["updates"]}, __module__ : {value: "read_book.annotations"} }); AnnotationsManager.prototype.style_for_highlight = function style_for_highlight(uuid) { var self = this; var h; h = (ρσ_expr_temp = self.highlights)[(typeof uuid === "number" && uuid < 0) ? ρσ_expr_temp.length + uuid : uuid]; if (h) { return h.style; } }; if (!AnnotationsManager.prototype.style_for_highlight.__argnames__) Object.defineProperties(AnnotationsManager.prototype.style_for_highlight, { __argnames__ : {value: ["uuid"]}, __module__ : {value: "read_book.annotations"} }); AnnotationsManager.prototype.data_for_highlight = function data_for_highlight(uuid) { var self = this; return (ρσ_expr_temp = self.highlights)[(typeof uuid === "number" && uuid < 0) ? ρσ_expr_temp.length + uuid : uuid]; }; if (!AnnotationsManager.prototype.data_for_highlight.__argnames__) Object.defineProperties(AnnotationsManager.prototype.data_for_highlight, { __argnames__ : {value: ["uuid"]}, __module__ : {value: "read_book.annotations"} }); AnnotationsManager.prototype.spine_index_for_highlight = function spine_index_for_highlight(uuid, spine) { var self = this; var h, ans, name, idx; h = (ρσ_expr_temp = self.highlights)[(typeof uuid === "number" && uuid < 0) ? ρσ_expr_temp.length + uuid : uuid]; if (!h) { return -1; } ans = h.spine_index; name = h.spine_name; if (name) { idx = spine.indexOf(name); if (idx > -1) { ans = idx; } } return ans; }; if (!AnnotationsManager.prototype.spine_index_for_highlight.__argnames__) Object.defineProperties(AnnotationsManager.prototype.spine_index_for_highlight, { __argnames__ : {value: ["uuid", "spine"]}, __module__ : {value: "read_book.annotations"} }); AnnotationsManager.prototype.cfi_for_highlight = function cfi_for_highlight(uuid, spine_index) { var self = this; var h, x; h = (ρσ_expr_temp = self.highlights)[(typeof uuid === "number" && uuid < 0) ? ρσ_expr_temp.length + uuid : uuid]; if (h) { x = 2 * (spine_index + 1); return "epubcfi(/" + ρσ_str.format("{}", x) + "" + ρσ_str.format("{}", h.start_cfi) + ")"; } }; if (!AnnotationsManager.prototype.cfi_for_highlight.__argnames__) Object.defineProperties(AnnotationsManager.prototype.cfi_for_highlight, { __argnames__ : {value: ["uuid", "spine_index"]}, __module__ : {value: "read_book.annotations"} }); AnnotationsManager.prototype.add_highlight = function add_highlight(msg, style, notes, toc_family) { var self = this; var now, uuid, annot, toc_family_titles, x; now = (new Date).toISOString(); var ρσ_Iter70 = msg.removed_highlights; ρσ_Iter70 = ((typeof ρσ_Iter70[Symbol.iterator] === "function") ? (ρσ_Iter70 instanceof Map ? ρσ_Iter70.keys() : ρσ_Iter70) : Object.keys(ρσ_Iter70)); for (var ρσ_Index70 of ρσ_Iter70) { uuid = ρσ_Index70; self.remove_highlight(uuid); } annot = (ρσ_expr_temp = self.highlights)[ρσ_bound_index(msg.uuid, ρσ_expr_temp)] = (function(){ var ρσ_d = Object.create(null); ρσ_d["type"] = "highlight"; ρσ_d["timestamp"] = now; ρσ_d["uuid"] = msg.uuid; ρσ_d["highlighted_text"] = msg.highlighted_text; ρσ_d["start_cfi"] = msg.bounds.start; ρσ_d["end_cfi"] = msg.bounds.end; ρσ_d["style"] = style; ρσ_d["spine_name"] = self.view.currently_showing.name; ρσ_d["spine_index"] = self.view.currently_showing.spine_index; return ρσ_d; }).call(this); if (notes) { annot.notes = notes; } if ((typeof toc_family !== "undefined" && toc_family !== null ? toc_family : Object.create(null)).length) { toc_family_titles = []; var ρσ_Iter71 = toc_family; ρσ_Iter71 = ((typeof ρσ_Iter71[Symbol.iterator] === "function") ? (ρσ_Iter71 instanceof Map ? ρσ_Iter71.keys() : ρσ_Iter71) : Object.keys(ρσ_Iter71)); for (var ρσ_Index71 of ρσ_Iter71) { x = ρσ_Index71; if (x.title) { toc_family_titles.push(x.title); } } annot.toc_family_titles = toc_family_titles; } self.sync_annots_to_server("highlights"); }; if (!AnnotationsManager.prototype.add_highlight.__argnames__) Object.defineProperties(AnnotationsManager.prototype.add_highlight, { __argnames__ : {value: ["msg", "style", "notes", "toc_family"]}, __module__ : {value: "read_book.annotations"} }); AnnotationsManager.prototype.highlights_for_currently_showing = function highlights_for_currently_showing() { var self = this; var name, ans, h; name = self.view.currently_showing.name; ans = []; var ρσ_Iter72 = Object.values(self.highlights); ρσ_Iter72 = ((typeof ρσ_Iter72[Symbol.iterator] === "function") ? (ρσ_Iter72 instanceof Map ? ρσ_Iter72.keys() : ρσ_Iter72) : Object.keys(ρσ_Iter72)); for (var ρσ_Index72 of ρσ_Iter72) { h = ρσ_Index72; if (h.spine_name === name && !h.removed && h.start_cfi) { ans.push(h); } } return ans; }; if (!AnnotationsManager.prototype.highlights_for_currently_showing.__module__) Object.defineProperties(AnnotationsManager.prototype.highlights_for_currently_showing, { __module__ : {value: "read_book.annotations"} }); AnnotationsManager.prototype.__repr__ = function __repr__ () { return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; AnnotationsManager.prototype.__str__ = function __str__ () { return this.__repr__(); }; Object.defineProperty(AnnotationsManager.prototype, "__bases__", {value: []}); ρσ_modules["read_book.annotations"].no_cfi = no_cfi; ρσ_modules["read_book.annotations"].field_map = field_map; ρσ_modules["read_book.annotations"].getter_map = getter_map; ρσ_modules["read_book.annotations"].bookmark_get_cfi = bookmark_get_cfi; ρσ_modules["read_book.annotations"].highlight_get_cfi = highlight_get_cfi; ρσ_modules["read_book.annotations"].sort_annot_list = sort_annot_list; ρσ_modules["read_book.annotations"].annots_descending_cmp = annots_descending_cmp; ρσ_modules["read_book.annotations"].merge_annots_with_identical_field = merge_annots_with_identical_field; ρσ_modules["read_book.annotations"].merge_annot_lists = merge_annot_lists; ρσ_modules["read_book.annotations"].merge_annotation_maps = merge_annotation_maps; ρσ_modules["read_book.annotations"].AnnotationsManager = AnnotationsManager; })(); (function(){ var __name__ = "read_book.db"; var DB_NAME, DB_VERSION; var base64decode = ρσ_modules.encodings.base64decode; var base64encode = ρσ_modules.encodings.base64encode; var _ = ρσ_modules.gettext.gettext; var is_reading_book = ρσ_modules["book_list.router"].is_reading_book; var error_dialog = ρσ_modules.modals.error_dialog; var merge_annotation_maps = ρσ_modules["read_book.annotations"].merge_annotation_maps; var get_interface_data = ρσ_modules.session.get_interface_data; var username_key = ρσ_modules.utils.username_key; function upgrade_schema(idb, old_version, new_version, transaction) { var books_store; print("upgrade_schema:", old_version, new_version); if (!idb.objectStoreNames.contains("books")) { idb.createObjectStore("books", (function(){ var ρσ_d = Object.create(null); ρσ_d["keyPath"] = "key"; return ρσ_d; }).call(this)); } if (!idb.objectStoreNames.contains("files")) { idb.createObjectStore("files"); } if (!idb.objectStoreNames.contains("mathjax")) { idb.createObjectStore("mathjax"); } if (!idb.objectStoreNames.contains("objects")) { idb.createObjectStore("objects", (function(){ var ρσ_d = Object.create(null); ρσ_d["keyPath"] = "key"; return ρσ_d; }).call(this)); } books_store = transaction.objectStore("books"); if (!books_store.indexNames.contains("recent_index")) { books_store.createIndex("recent_index", "recent_date"); } }; if (!upgrade_schema.__argnames__) Object.defineProperties(upgrade_schema, { __argnames__ : {value: ["idb", "old_version", "new_version", "transaction"]}, __module__ : {value: "read_book.db"} }); function file_store_name(book, name) { return book.book_hash + " " + name; }; if (!file_store_name.__argnames__) Object.defineProperties(file_store_name, { __argnames__ : {value: ["book", "name"]}, __module__ : {value: "read_book.db"} }); function get_error_details(event) { var desc; desc = event.target; if (desc.error && desc.error.toString) { desc = desc.error.toString(); } else if (desc.errorCode) { desc = desc.errorCode; } else if (desc.error) { desc = desc.error; if (desc.name === "QuotaExceededError") { desc = _("Offline storage quota exceeded! Try deleting some stored books first."); } else if (desc.name) { desc = desc.name; } } return desc || "Unknown Error"; }; if (!get_error_details.__argnames__) Object.defineProperties(get_error_details, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); function new_book(key, metadata) { return (function(){ var ρσ_d = Object.create(null); ρσ_d["key"] = key; ρσ_d["is_complete"] = false; ρσ_d["stored_files"] = Object.create(null); ρσ_d["book_hash"] = null; ρσ_d["metadata"] = metadata; ρσ_d["manifest"] = null; ρσ_d["cover_width"] = null; ρσ_d["cover_height"] = null; ρσ_d["cover_name"] = null; ρσ_d["recent_date"] = new Date; ρσ_d["last_read"] = Object.create(null); ρσ_d["last_read_position"] = Object.create(null); ρσ_d["saved_reading_rates"] = Object.create(null); ρσ_d["annotations_map"] = Object.create(null); return ρσ_d; }).call(this); }; if (!new_book.__argnames__) Object.defineProperties(new_book, { __argnames__ : {value: ["key", "metadata"]}, __module__ : {value: "read_book.db"} }); DB_NAME = "calibre"; DB_VERSION = 1; function indexed_db_api() { if ((typeof window !== "undefined" && window !== null)) { return window.indexedDB; } if ((typeof self !== "undefined" && self !== null)) { return self.indexedDB; } }; if (!indexed_db_api.__module__) Object.defineProperties(indexed_db_api, { __module__ : {value: "read_book.db"} }); function DB() { if (this.ρσ_object_id === undefined) Object.defineProperty(this, "ρσ_object_id", {"value":++ρσ_object_counter}); DB.prototype.__bind_methods__.call(this); DB.prototype.__init__.apply(this, arguments); } Object.defineProperty(DB.prototype, "__bind_methods__", {value: function () { this.show_error = DB.prototype.show_error.bind(this); this.initialize_stage1 = DB.prototype.initialize_stage1.bind(this); this.initialize_stage2 = DB.prototype.initialize_stage2.bind(this); this.display_error = DB.prototype.display_error.bind(this); this.do_op = DB.prototype.do_op.bind(this); this.set_pending_annot_upload = DB.prototype.set_pending_annot_upload.bind(this); this.get_all_pending_annot_uploads = DB.prototype.get_all_pending_annot_uploads.bind(this); this.clear_pending_annot_upload = DB.prototype.clear_pending_annot_upload.bind(this); this.get_book = DB.prototype.get_book.bind(this); this.get_mathjax_info = DB.prototype.get_mathjax_info.bind(this); this.save_manifest = DB.prototype.save_manifest.bind(this); this.store_file = DB.prototype.store_file.bind(this); this.store_cover = DB.prototype.store_cover.bind(this); this.store_file_stage2 = DB.prototype.store_file_stage2.bind(this); this.clear_mathjax = DB.prototype.clear_mathjax.bind(this); this.store_mathjax_file = DB.prototype.store_mathjax_file.bind(this); this.finish_book = DB.prototype.finish_book.bind(this); this.finish_mathjax = DB.prototype.finish_mathjax.bind(this); this.update_last_read_time = DB.prototype.update_last_read_time.bind(this); this.update_metadata = DB.prototype.update_metadata.bind(this); this.save_reading_rates = DB.prototype.save_reading_rates.bind(this); this.update_annotations_data_from_key = DB.prototype.update_annotations_data_from_key.bind(this); this.get_file = DB.prototype.get_file.bind(this); this.get_book_file = DB.prototype.get_book_file.bind(this); this.get_mathjax_files = DB.prototype.get_mathjax_files.bind(this); this.get_books_by_recent_date = DB.prototype.get_books_by_recent_date.bind(this); this.get_recently_read_books = DB.prototype.get_recently_read_books.bind(this); this.get_downloaded_books = DB.prototype.get_downloaded_books.bind(this); this.has_book_matching = DB.prototype.has_book_matching.bind(this); this.delete_book = DB.prototype.delete_book.bind(this); this.delete_books_matching = DB.prototype.delete_books_matching.bind(this); }}); DB.prototype.__init__ = function __init__(callback, show_read_book_error) { var self = this; self.initialized = false; self.is_ok = false; self.initialize_error_msg = null; self.callback = callback; self.show_read_book_error = show_read_book_error; self.initialize_stage1(); }; if (!DB.prototype.__init__.__argnames__) Object.defineProperties(DB.prototype.__init__, { __argnames__ : {value: ["callback", "show_read_book_error"]}, __module__ : {value: "read_book.db"} }); DB.__argnames__ = DB.prototype.__init__.__argnames__; DB.__handles_kwarg_interpolation__ = DB.prototype.__init__.__handles_kwarg_interpolation__; DB.prototype.show_error = function show_error(title, msg, det_msg) { var self = this; if (!(typeof window !== "undefined" && window !== null) || is_reading_book()) { self.show_read_book_error(title, msg, det_msg); } else { error_dialog(title, msg, det_msg); } }; if (!DB.prototype.show_error.__argnames__) Object.defineProperties(DB.prototype.show_error, { __argnames__ : {value: ["title", "msg", "det_msg"]}, __module__ : {value: "read_book.db"} }); DB.prototype.initialize_stage1 = function initialize_stage1() { var self = this; var idb, request; idb = indexed_db_api(); if (!idb) { self.initialize_error_msg = _("Your browser does not support IndexedDB. Cannot read books. Consider using a modern browser, such as Chrome or Firefox."); self.initialized = true; setTimeout(self.callback, 0); return; } request = idb.open(DB_NAME, DB_VERSION); request.onupgradeneeded = (function() { var ρσ_anonfunc = function (event) { upgrade_schema(event.target.result, event.oldVersion, event.newVersion, event.target.transaction); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); request.onblocked = (function() { var ρσ_anonfunc = function (event) { self.initialize_error_msg = _("Please close all other browser tabs with calibre open"); self.initialized = true; console.log(event); self.callback(); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); request.onerror = (function() { var ρσ_anonfunc = function (event) { self.initialize_error_msg = _("You must allow calibre to use IndexedDB storage in your browser to read books"); self.initialized = true; console.log(event); self.callback(); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); request.onsuccess = (function() { var ρσ_anonfunc = function (event) { var blob, idb, store, req; blob = new Blob([ "test" ], (function(){ var ρσ_d = Object.create(null); ρσ_d["type"] = "text/plain"; return ρσ_d; }).call(this)); idb = event.target.result; store = idb.transaction([ "files" ], "readwrite").objectStore("files"); try { req = store.put(blob, ":-test-blob-:"); } catch (ρσ_Exception) { ρσ_last_exception = ρσ_Exception; { self.initialize_stage2(idb, false); return; } } req.onsuccess = (function() { var ρσ_anonfunc = function (event) { self.initialize_stage2(idb, true); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); req.onerror = (function() { var ρσ_anonfunc = function (event) { setTimeout(self.initialize_stage2.bind(null, idb, false), 0); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); }; if (!DB.prototype.initialize_stage1.__module__) Object.defineProperties(DB.prototype.initialize_stage1, { __module__ : {value: "read_book.db"} }); DB.prototype.initialize_stage2 = function initialize_stage2(idb, supports_blobs) { var self = this; self.idb = idb; self.supports_blobs = supports_blobs; self.initialized = true; self.is_ok = true; if (!supports_blobs) { print("WARNING: browser does not support blob storage, calibre falling back to base64 encoding"); } idb.onerror = (function() { var ρσ_anonfunc = function (event) { self.display_error(null, event); if (console.dir) { console.dir(event); } else { console.log(event); } }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); idb.onversionchange = (function() { var ρσ_anonfunc = function (event) { idb.close(); self.show_error(_("Database upgraded!"), _("A newer version of calibre is available, please click the Reload button in your browser.")); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); function try_persist(lock) { if (!lock) { return; } return window.navigator.storage.persisted().then((function() { var ρσ_anonfunc = function (already_persistent) { if (!already_persistent) { return window.navigator.storage.persist(); } }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["already_persistent"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })()); }; if (!try_persist.__argnames__) Object.defineProperties(try_persist, { __argnames__ : {value: ["lock"]}, __module__ : {value: "read_book.db"} }); if (ρσ_exists.d(ρσ_exists.d((typeof window !== "undefined" && window !== null ? window : Object.create(null)).navigator).storage).persist) { if (window.navigator.locks) { window.navigator.locks.request("calibre-storage-persist", (function(){ var ρσ_d = Object.create(null); ρσ_d["ifAvailable"] = true; return ρσ_d; }).call(this), try_persist); } else { window.navigator.storage.persisted().then((function() { var ρσ_anonfunc = function (already_persistent) { if (!already_persistent) { window.navigator.storage.persist(); } }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["already_persistent"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })()); } } self.callback(); }; if (!DB.prototype.initialize_stage2.__argnames__) Object.defineProperties(DB.prototype.initialize_stage2, { __argnames__ : {value: ["idb", "supports_blobs"]}, __module__ : {value: "read_book.db"} }); DB.prototype.display_error = function display_error(msg, event) { var self = this; if (event.already_displayed_by_calibre) { return; } event.already_displayed_by_calibre = true; msg = msg || _("There was an error while interacting with the database used to store books for offline reading. Click \"Show details\" for more information."); self.show_error(_("Cannot read book"), msg, get_error_details(event)); }; if (!DB.prototype.display_error.__argnames__) Object.defineProperties(DB.prototype.display_error, { __argnames__ : {value: ["msg", "event"]}, __module__ : {value: "read_book.db"} }); DB.prototype.do_op = function do_op() { var self = this; var stores = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var data = ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[1]; var error_msg = ( 2 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[2]; var proceed = ( 3 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[3]; var op = (arguments[4] === undefined || ( 4 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? do_op.__defaults__.op : arguments[4]; var store = (arguments[5] === undefined || ( 5 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? do_op.__defaults__.store : arguments[5]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "op")){ op = ρσ_kwargs_obj.op; } if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "store")){ store = ρσ_kwargs_obj.store; } var transaction, req; store = store || stores[0]; if (op === "get") { transaction = self.idb.transaction(stores); req = transaction.objectStore(store).get(data); req.onsuccess = (function() { var ρσ_anonfunc = function (event) { if (proceed) { proceed(req.result); } }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); } else if (op === "put") { transaction = self.idb.transaction(stores, "readwrite"); req = transaction.objectStore(store).put(data); if (proceed) { req.onsuccess = proceed; } } else if (op === "delete") { transaction = self.idb.transaction(stores, "readwrite"); req = transaction.objectStore(store).delete(data); if (proceed) { req.onsuccess = proceed; } } req.onerror = (function() { var ρσ_anonfunc = function (event) { self.display_error(error_msg, event); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); }; if (!DB.prototype.do_op.__defaults__) Object.defineProperties(DB.prototype.do_op, { __defaults__ : {value: {op:"get", store:null}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["stores", "data", "error_msg", "proceed", "op", "store"]}, __module__ : {value: "read_book.db"} }); DB.prototype.set_pending_annot_upload = function set_pending_annot_upload(library_id, book_id, fmt, amap) { var self = this; var key, entry; key = "pending-annot-upload:" + ρσ_str.format("{}", library_id) + "/" + ρσ_str.format("{}", book_id) + "/" + ρσ_str.format("{}", fmt) + ""; entry = (function(){ var ρσ_d = Object.create(null); ρσ_d["key"] = key; ρσ_d["library_id"] = library_id; ρσ_d["book_id"] = book_id; ρσ_d["fmt"] = fmt; ρσ_d["amap"] = amap; return ρσ_d; }).call(this); ρσ_interpolate_kwargs.call(self, self.do_op, [[ "objects" ], entry, _("Failed to save pending annotation upload"), (function() { var ρσ_anonfunc = function () { null; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })()].concat([ρσ_desugar_kwargs({op: "put"})])); }; if (!DB.prototype.set_pending_annot_upload.__argnames__) Object.defineProperties(DB.prototype.set_pending_annot_upload, { __argnames__ : {value: ["library_id", "book_id", "fmt", "amap"]}, __module__ : {value: "read_book.db"} }); DB.prototype.get_all_pending_annot_uploads = function get_all_pending_annot_uploads(proceed) { var self = this; var transaction, store, key_range, entries, req; transaction = self.idb.transaction([ "objects" ]); store = transaction.objectStore("objects"); key_range = IDBKeyRange.bound("pending-annot-upload:", "pending-annot-upload:\uffff"); entries = []; req = store.openCursor(key_range); req.onsuccess = (function() { var ρσ_anonfunc = function (event) { var cursor; cursor = event.target.result; if (cursor) { entries.push(cursor.value); cursor.continue(); } else { proceed(entries); } }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); req.onerror = (function() { var ρσ_anonfunc = function (event) { self.display_error(_("Failed to read pending annotation uploads"), event); proceed([]); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); }; if (!DB.prototype.get_all_pending_annot_uploads.__argnames__) Object.defineProperties(DB.prototype.get_all_pending_annot_uploads, { __argnames__ : {value: ["proceed"]}, __module__ : {value: "read_book.db"} }); DB.prototype.clear_pending_annot_upload = function clear_pending_annot_upload(library_id, book_id, fmt, proceed) { var self = this; var key; key = "pending-annot-upload:" + ρσ_str.format("{}", library_id) + "/" + ρσ_str.format("{}", book_id) + "/" + ρσ_str.format("{}", fmt) + ""; ρσ_interpolate_kwargs.call(self, self.do_op, [[ "objects" ], key, _("Failed to clear pending annotation upload"), proceed || (function() { var ρσ_anonfunc = function () { null; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })()].concat([ρσ_desugar_kwargs({op: "delete"})])); }; if (!DB.prototype.clear_pending_annot_upload.__argnames__) Object.defineProperties(DB.prototype.clear_pending_annot_upload, { __argnames__ : {value: ["library_id", "book_id", "fmt", "proceed"]}, __module__ : {value: "read_book.db"} }); DB.prototype.get_book = function get_book(library_id, book_id, fmt, metadata, proceed) { var self = this; var key; fmt = fmt.toUpperCase(); book_id = int(book_id); key = [ library_id, book_id, fmt ]; self.do_op([ "books" ], key, _("Failed to read from the books database"), (function() { var ρσ_anonfunc = function (result) { if (result && !result.annotations_map) { result.annotations_map = Object.create(null); } proceed(result || new_book(key, metadata)); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["result"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })()); }; if (!DB.prototype.get_book.__argnames__) Object.defineProperties(DB.prototype.get_book, { __argnames__ : {value: ["library_id", "book_id", "fmt", "metadata", "proceed"]}, __module__ : {value: "read_book.db"} }); DB.prototype.get_mathjax_info = function get_mathjax_info(proceed) { var self = this; self.do_op([ "objects" ], "mathjax-info", _("Failed to read from the objects database"), (function() { var ρσ_anonfunc = function (result) { proceed(result || (function(){ var ρσ_d = Object.create(null); ρσ_d["key"] = "mathjax-info"; return ρσ_d; }).call(this)); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["result"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })()); }; if (!DB.prototype.get_mathjax_info.__argnames__) Object.defineProperties(DB.prototype.get_mathjax_info, { __argnames__ : {value: ["proceed"]}, __module__ : {value: "read_book.db"} }); DB.prototype.save_manifest = function save_manifest(book, manifest, proceed) { var self = this; var newest_epoch, newest_pos, pos, username, unkey; book.manifest = manifest; book.metadata = manifest.metadata; book.book_hash = manifest.book_hash.hash; book.stored_files = Object.create(null); book.is_complete = false; newest_epoch = newest_pos = null; var ρσ_Iter73 = manifest.last_read_positions; ρσ_Iter73 = ((typeof ρσ_Iter73[Symbol.iterator] === "function") ? (ρσ_Iter73 instanceof Map ? ρσ_Iter73.keys() : ρσ_Iter73) : Object.keys(ρσ_Iter73)); for (var ρσ_Index73 of ρσ_Iter73) { pos = ρσ_Index73; if (newest_epoch === null || pos.epoch > newest_epoch) { newest_epoch = pos.epoch; newest_pos = pos.cfi; } } username = get_interface_data().username; unkey = username_key(username); if (newest_pos && username) { (ρσ_expr_temp = book.last_read)[(typeof unkey === "number" && unkey < 0) ? ρσ_expr_temp.length + unkey : unkey] = new Date(newest_epoch * 1e3); (ρσ_expr_temp = book.last_read_position)[(typeof unkey === "number" && unkey < 0) ? ρσ_expr_temp.length + unkey : unkey] = newest_pos; } if (manifest.annotations_map) { (ρσ_expr_temp = book.annotations_map)[(typeof unkey === "number" && unkey < 0) ? ρσ_expr_temp.length + unkey : unkey] = manifest.annotations_map; } delete manifest.metadata; delete manifest.last_read_positions; delete manifest.annotations_map; ρσ_interpolate_kwargs.call(self, self.do_op, [[ "books" ], book, _("Failed to write to the books database"), proceed].concat([ρσ_desugar_kwargs({op: "put"})])); }; if (!DB.prototype.save_manifest.__argnames__) Object.defineProperties(DB.prototype.save_manifest, { __argnames__ : {value: ["book", "manifest", "proceed"]}, __module__ : {value: "read_book.db"} }); DB.prototype.store_file = function store_file(book, name, xhr, proceed, is_cover) { var self = this; var store_as_text, fname, needs_encoding, mt; store_as_text = xhr.responseType === "text" || !xhr.responseType; fname = file_store_name(book, name); needs_encoding = !store_as_text && !self.supports_blobs; mt = ρσ_exists.d((ρσ_expr_temp = book.manifest.files)[(typeof name === "number" && name < 0) ? ρσ_expr_temp.length + name : name]).mimetype; if (!mt && is_cover) { mt = "image/jpeg"; } (ρσ_expr_temp = book.stored_files)[(typeof fname === "number" && fname < 0) ? ρσ_expr_temp.length + fname : fname] = (function(){ var ρσ_d = Object.create(null); ρσ_d["encoded"] = needs_encoding; ρσ_d["mimetype"] = mt; ρσ_d["store_as_text"] = store_as_text; return ρσ_d; }).call(this); if (is_cover) { self.store_cover(book, needs_encoding, xhr.response, name, fname, proceed); } else { self.store_file_stage2(needs_encoding, xhr.response, name, fname, proceed); } }; if (!DB.prototype.store_file.__argnames__) Object.defineProperties(DB.prototype.store_file, { __argnames__ : {value: ["book", "name", "xhr", "proceed", "is_cover"]}, __module__ : {value: "read_book.db"} }); DB.prototype.store_cover = function store_cover(book, needs_encoding, data, name, fname, proceed) { var self = this; var blob, url, img, proceeded; blob = data; if (needs_encoding) { blob = new Blob([ data ], (function(){ var ρσ_d = Object.create(null); ρσ_d["type"] = "image/jpeg"; return ρσ_d; }).call(this)); } url = window.URL.createObjectURL(blob); img = new Image; book.cover_name = name; proceeded = false; function done() { if (!proceeded) { proceeded = true; window.URL.revokeObjectURL(url); self.store_file_stage2(needs_encoding, data, name, fname, proceed); } }; if (!done.__module__) Object.defineProperties(done, { __module__ : {value: "read_book.db"} }); img.onload = (function() { var ρσ_anonfunc = function () { book.cover_width = this.width; book.cover_height = this.height; done(); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); img.onerror = (function() { var ρσ_anonfunc = function () { print("WARNING: Failed to read dimensions of cover"); done(); }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); img.src = url; }; if (!DB.prototype.store_cover.__argnames__) Object.defineProperties(DB.prototype.store_cover, { __argnames__ : {value: ["book", "needs_encoding", "data", "name", "fname", "proceed"]}, __module__ : {value: "read_book.db"} }); DB.prototype.store_file_stage2 = function store_file_stage2(needs_encoding, data, name, fname, proceed) { var self = this; var req; if (needs_encoding) { data = base64encode(new Uint8Array(data)); } req = self.idb.transaction([ "files" ], "readwrite").objectStore("files").put(data, fname); req.onsuccess = (function() { var ρσ_anonfunc = function (event) { proceed(); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); req.onerror = (function() { var ρσ_anonfunc = function (event) { proceed(_("Failed to store book data ({0}) with error: {1}").format(name, get_error_details(event))); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); }; if (!DB.prototype.store_file_stage2.__argnames__) Object.defineProperties(DB.prototype.store_file_stage2, { __argnames__ : {value: ["needs_encoding", "data", "name", "fname", "proceed"]}, __module__ : {value: "read_book.db"} }); DB.prototype.clear_mathjax = function clear_mathjax(proceed) { var self = this; self.idb.transaction([ "mathjax" ], "readwrite").objectStore("mathjax").clear().onsuccess = proceed; }; if (!DB.prototype.clear_mathjax.__argnames__) Object.defineProperties(DB.prototype.clear_mathjax, { __argnames__ : {value: ["proceed"]}, __module__ : {value: "read_book.db"} }); DB.prototype.store_mathjax_file = function store_mathjax_file(name, xhr, proceed) { var self = this; var data, req; data = xhr.response; if (!self.supports_blobs) { data = base64encode(new Uint8Array(data)); } req = self.idb.transaction([ "mathjax" ], "readwrite").objectStore("mathjax").put(data, name); req.onsuccess = (function() { var ρσ_anonfunc = function (event) { proceed(); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); req.onerror = (function() { var ρσ_anonfunc = function (event) { proceed(_("Failed to store mathjax file ({0}) with error: {1}").format(name, get_error_details(event))); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); }; if (!DB.prototype.store_mathjax_file.__argnames__) Object.defineProperties(DB.prototype.store_mathjax_file, { __argnames__ : {value: ["name", "xhr", "proceed"]}, __module__ : {value: "read_book.db"} }); DB.prototype.finish_book = function finish_book(book, proceed) { var self = this; book.is_complete = true; ρσ_interpolate_kwargs.call(self, self.do_op, [[ "books" ], book, _("Failed to write to the books database"), proceed].concat([ρσ_desugar_kwargs({op: "put"})])); }; if (!DB.prototype.finish_book.__argnames__) Object.defineProperties(DB.prototype.finish_book, { __argnames__ : {value: ["book", "proceed"]}, __module__ : {value: "read_book.db"} }); DB.prototype.finish_mathjax = function finish_mathjax(mathjax_info, proceed) { var self = this; ρσ_interpolate_kwargs.call(self, self.do_op, [[ "objects" ], mathjax_info, _("Failed to write to the objects database"), proceed].concat([ρσ_desugar_kwargs({op: "put"})])); }; if (!DB.prototype.finish_mathjax.__argnames__) Object.defineProperties(DB.prototype.finish_mathjax, { __argnames__ : {value: ["mathjax_info", "proceed"]}, __module__ : {value: "read_book.db"} }); DB.prototype.update_last_read_time = function update_last_read_time(book) { var self = this; var unkey, now; unkey = username_key(get_interface_data().username); now = new Date; (ρσ_expr_temp = book.last_read)[(typeof unkey === "number" && unkey < 0) ? ρσ_expr_temp.length + unkey : unkey] = book.recent_date = now; ρσ_interpolate_kwargs.call(self, self.do_op, [[ "books" ], book, _("Failed to write to the books database")].concat([ρσ_desugar_kwargs({op: "put"})])); }; if (!DB.prototype.update_last_read_time.__argnames__) Object.defineProperties(DB.prototype.update_last_read_time, { __argnames__ : {value: ["book"]}, __module__ : {value: "read_book.db"} }); DB.prototype.update_metadata = function update_metadata(book, new_metadata) { var self = this; var key; if (book.metadata) { var ρσ_Iter74 = Object.keys(new_metadata); ρσ_Iter74 = ((typeof ρσ_Iter74[Symbol.iterator] === "function") ? (ρσ_Iter74 instanceof Map ? ρσ_Iter74.keys() : ρσ_Iter74) : Object.keys(ρσ_Iter74)); for (var ρσ_Index74 of ρσ_Iter74) { key = ρσ_Index74; (ρσ_expr_temp = book.metadata)[(typeof key === "number" && key < 0) ? ρσ_expr_temp.length + key : key] = new_metadata[(typeof key === "number" && key < 0) ? new_metadata.length + key : key]; } ρσ_interpolate_kwargs.call(self, self.do_op, [[ "books" ], book, _("Failed to write to the books database"), (function() { var ρσ_anonfunc = function () { null; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })()].concat([ρσ_desugar_kwargs({op: "put"})])); } }; if (!DB.prototype.update_metadata.__argnames__) Object.defineProperties(DB.prototype.update_metadata, { __argnames__ : {value: ["book", "new_metadata"]}, __module__ : {value: "read_book.db"} }); DB.prototype.save_reading_rates = function save_reading_rates(book, rates) { var self = this; book.saved_reading_rates = rates; ρσ_interpolate_kwargs.call(self, self.do_op, [[ "books" ], book, _("Failed to write to the books database"), (function() { var ρσ_anonfunc = function () { null; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })()].concat([ρσ_desugar_kwargs({op: "put"})])); }; if (!DB.prototype.save_reading_rates.__argnames__) Object.defineProperties(DB.prototype.save_reading_rates, { __argnames__ : {value: ["book", "rates"]}, __module__ : {value: "read_book.db"} }); DB.prototype.update_annotations_data_from_key = function update_annotations_data_from_key(library_id, book_id, fmt, new_data) { var self = this; var unkey; unkey = username_key(get_interface_data().username); self.get_book(library_id, book_id, fmt, null, (function() { var ρσ_anonfunc = function (book) { var changed, existing, ρσ_unpack, updated, merged; if (book.metadata) { changed = false; if (new_data.last_read_position) { (ρσ_expr_temp = book.last_read)[(typeof unkey === "number" && unkey < 0) ? ρσ_expr_temp.length + unkey : unkey] = book.recent_date = new_data.last_read; (ρσ_expr_temp = book.last_read_position)[(typeof unkey === "number" && unkey < 0) ? ρσ_expr_temp.length + unkey : unkey] = new_data.last_read_position; changed = true; } if (!book.annotations_map) { book.annotations_map = {}; } if (new_data.annotations_map) { existing = (ρσ_expr_temp = book.annotations_map)[(typeof unkey === "number" && unkey < 0) ? ρσ_expr_temp.length + unkey : unkey]; if (!existing) { changed = true; (ρσ_expr_temp = book.annotations_map)[(typeof unkey === "number" && unkey < 0) ? ρσ_expr_temp.length + unkey : unkey] = new_data.annotations_map; } else { ρσ_unpack = merge_annotation_maps(existing, new_data.annotations_map); ρσ_unpack = ρσ_unpack_asarray(2, ρσ_unpack); updated = ρσ_unpack[0]; merged = ρσ_unpack[1]; if (updated) { changed = true; (ρσ_expr_temp = book.annotations_map)[(typeof unkey === "number" && unkey < 0) ? ρσ_expr_temp.length + unkey : unkey] = merged; } } } if (changed) { ρσ_interpolate_kwargs.call(self, self.do_op, [[ "books" ], book, _("Failed to write to the books database"), (function() { var ρσ_anonfunc = function () { null; }; if (!ρσ_anonfunc.__module__) Object.defineProperties(ρσ_anonfunc, { __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })()].concat([ρσ_desugar_kwargs({op: "put"})])); } } }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["book"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })()); }; if (!DB.prototype.update_annotations_data_from_key.__argnames__) Object.defineProperties(DB.prototype.update_annotations_data_from_key, { __argnames__ : {value: ["library_id", "book_id", "fmt", "new_data"]}, __module__ : {value: "read_book.db"} }); DB.prototype.get_file = function get_file(book, name, proceed) { var self = this; var key, err; key = file_store_name(book, name); err = _("Failed to read the file {0} for the book {1} from the browser offline cache.").format(name, book.metadata.title); self.do_op([ "files" ], key, err, (function() { var ρσ_anonfunc = function (result) { var bad, fdata, mt; if (!result) { bad = err + _(" This usually means the cache is close to full. Clear the browser cache from the browser settings."); self.show_error(_("Cannot read file from book"), bad); return; } fdata = (ρσ_expr_temp = book.stored_files)[(typeof key === "number" && key < 0) ? ρσ_expr_temp.length + key : key]; mt = fdata.mimetype || "application/octet-stream"; if (fdata.encoded) { result = new Blob([ base64decode(result) ], (function(){ var ρσ_d = Object.create(null); ρσ_d["type"] = mt; return ρσ_d; }).call(this)); } proceed(result, name, mt, book); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["result"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })()); }; if (!DB.prototype.get_file.__argnames__) Object.defineProperties(DB.prototype.get_file, { __argnames__ : {value: ["book", "name", "proceed"]}, __module__ : {value: "read_book.db"} }); DB.prototype.get_book_file = function get_book_file(book_hash, stored_files, name, proceed) { var self = this; var stores, key, transaction, req; stores = [ "files" ]; key = file_store_name((function(){ var ρσ_d = Object.create(null); ρσ_d["book_hash"] = book_hash; return ρσ_d; }).call(this), name); transaction = self.idb.transaction(stores); req = transaction.objectStore(stores[0]).get(key); req.onsuccess = (function() { var ρσ_anonfunc = function (event) { var fdata, mt, result; if (!req.result) { proceed((function(){ var ρσ_d = Object.create(null); ρσ_d["ok"] = false; ρσ_d["name"] = name; ρσ_d["details"] = "ENOENT"; return ρσ_d; }).call(this)); return; } fdata = stored_files[(typeof key === "number" && key < 0) ? stored_files.length + key : key]; mt = fdata.mimetype || "application/octet-stream"; if (fdata.encoded) { result = new Blob([ base64decode(result) ], (function(){ var ρσ_d = Object.create(null); ρσ_d["type"] = mt; return ρσ_d; }).call(this)); } proceed((function(){ var ρσ_d = Object.create(null); ρσ_d["ok"] = true; ρσ_d["result"] = req.result; ρσ_d["name"] = name; ρσ_d["mt"] = mt; return ρσ_d; }).call(this)); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); req.onerror = (function() { var ρσ_anonfunc = function (event) { var details; details = get_error_details(event); proceed((function(){ var ρσ_d = Object.create(null); ρσ_d["ok"] = false; ρσ_d["name"] = name; ρσ_d["details"] = details; return ρσ_d; }).call(this)); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); }; if (!DB.prototype.get_book_file.__argnames__) Object.defineProperties(DB.prototype.get_book_file, { __argnames__ : {value: ["book_hash", "stored_files", "name", "proceed"]}, __module__ : {value: "read_book.db"} }); DB.prototype.get_mathjax_files = function get_mathjax_files(proceed) { var self = this; var c, data; c = self.idb.transaction("mathjax").objectStore("mathjax").openCursor(); c.onerror = (function() { var ρσ_anonfunc = function (event) { var err; err = _("Failed to read the MathJax files from the browser offline cache."); self.display_error(err, event); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); data = Object.create(null); c.onsuccess = (function() { var ρσ_anonfunc = function (event) { var cursor, ρσ_unpack, name, result, mt; cursor = event.target.result; if (cursor) { ρσ_unpack = [cursor.key, cursor.value]; name = ρσ_unpack[0]; result = ρσ_unpack[1]; if (!(ρσ_instanceof(result, Blob))) { mt = (name.endswith(".woff")) ? "application/x-font-woff" : "text/javascript"; result = new Blob([ base64decode(result) ], (function(){ var ρσ_d = Object.create(null); ρσ_d["type"] = mt; return ρσ_d; }).call(this)); } data[(typeof name === "number" && name < 0) ? data.length + name : name] = result; cursor.continue(); } else { proceed(data); } }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); }; if (!DB.prototype.get_mathjax_files.__argnames__) Object.defineProperties(DB.prototype.get_mathjax_files, { __argnames__ : {value: ["proceed"]}, __module__ : {value: "read_book.db"} }); DB.prototype.get_books_by_recent_date = function get_books_by_recent_date() { var self = this; var proceed = ( 0 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true) ? undefined : arguments[0]; var limit = (arguments[1] === undefined || ( 1 === arguments.length-1 && arguments[arguments.length-1] !== null && typeof arguments[arguments.length-1] === "object" && arguments[arguments.length-1] [ρσ_kwargs_symbol] === true)) ? get_books_by_recent_date.__defaults__.limit : arguments[1]; var ρσ_kwargs_obj = arguments[arguments.length-1]; if (ρσ_kwargs_obj === null || typeof ρσ_kwargs_obj !== "object" || ρσ_kwargs_obj [ρσ_kwargs_symbol] !== true) ρσ_kwargs_obj = {}; if (Object.prototype.hasOwnProperty.call(ρσ_kwargs_obj, "limit")){ limit = ρσ_kwargs_obj.limit; } var c, books; c = self.idb.transaction([ "books" ], "readonly").objectStore("books").index("recent_index").openCursor(null, "prev"); books = []; c.onerror = (function() { var ρσ_anonfunc = function (event) { var err; err = _("Failed to read recent books from local storage"); self.display_error(err, event); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); c.onsuccess = (function() { var ρσ_anonfunc = function (ev) { var cursor; cursor = ev.target.result; if (cursor) { books.push(cursor.value); } if (limit !== null && books.length >= limit || !cursor) { proceed(books); return; } if (cursor) { cursor.continue(); } }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["ev"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); }; if (!DB.prototype.get_books_by_recent_date.__defaults__) Object.defineProperties(DB.prototype.get_books_by_recent_date, { __defaults__ : {value: {limit:null}}, __handles_kwarg_interpolation__ : {value: true}, __argnames__ : {value: ["proceed", "limit"]}, __module__ : {value: "read_book.db"} }); DB.prototype.get_recently_read_books = function get_recently_read_books(proceed, limit) { var self = this; self.get_books_by_recent_date(proceed, limit || 3); }; if (!DB.prototype.get_recently_read_books.__argnames__) Object.defineProperties(DB.prototype.get_recently_read_books, { __argnames__ : {value: ["proceed", "limit"]}, __module__ : {value: "read_book.db"} }); DB.prototype.get_downloaded_books = function get_downloaded_books(proceed) { var self = this; self.get_books_by_recent_date(proceed); }; if (!DB.prototype.get_downloaded_books.__argnames__) Object.defineProperties(DB.prototype.get_downloaded_books, { __argnames__ : {value: ["proceed"]}, __module__ : {value: "read_book.db"} }); DB.prototype.has_book_matching = function has_book_matching(library_id, book_id, proceed) { var self = this; var c; c = self.idb.transaction([ "books" ], "readonly").objectStore("books").index("recent_index").openCursor(null, "prev"); c.onerror = (function() { var ρσ_anonfunc = function (event) { proceed(false); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); book_id = int(book_id); c.onsuccess = (function() { var ρσ_anonfunc = function (ev) { var cursor, book; cursor = ev.target.result; if (cursor) { book = cursor.value; if (book.key[0] === library_id && book.key[1] === book_id) { proceed(true); return; } cursor.continue(); } else { proceed(false); } }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["ev"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); }; if (!DB.prototype.has_book_matching.__argnames__) Object.defineProperties(DB.prototype.has_book_matching, { __argnames__ : {value: ["library_id", "book_id", "proceed"]}, __module__ : {value: "read_book.db"} }); DB.prototype.delete_book = function delete_book(book, proceed) { var self = this; var c, files, books, filenames; c = self.idb.transaction([ "books", "files" ], "readwrite"); files = c.objectStore("files"); books = c.objectStore("books"); filenames = Object.keys(book.stored_files); c.oncomplete = (function() { var ρσ_anonfunc = function (event) { proceed(book); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); c.onerror = (function() { var ρσ_anonfunc = function (event) { proceed(book, c.error.toString()); }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); function next_step() { var r; if (filenames.length) { r = files.delete(filenames.pop()); r.onsuccess = next_step; } else { books.delete(book.key); } }; if (!next_step.__module__) Object.defineProperties(next_step, { __module__ : {value: "read_book.db"} }); next_step(); }; if (!DB.prototype.delete_book.__argnames__) Object.defineProperties(DB.prototype.delete_book, { __argnames__ : {value: ["book", "proceed"]}, __module__ : {value: "read_book.db"} }); DB.prototype.delete_books_matching = function delete_books_matching(library_id, book_id, proceed) { var self = this; var c, matches; c = self.idb.transaction([ "books" ], "readonly").objectStore("books").index("recent_index").openCursor(null, "prev"); c.onerror = (function() { var ρσ_anonfunc = function (event) { }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["event"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); book_id = int(book_id); matches = []; function delete_all() { var book; if (matches.length) { book = matches.pop(); self.delete_book(book, delete_all); } else { if (proceed) { proceed(); } } }; if (!delete_all.__module__) Object.defineProperties(delete_all, { __module__ : {value: "read_book.db"} }); c.onsuccess = (function() { var ρσ_anonfunc = function (ev) { var cursor, book; cursor = ev.target.result; if (cursor) { book = cursor.value; if (book.key[0] === library_id && book.key[1] === book_id) { matches.push(book); } cursor.continue(); } else { delete_all(); } }; if (!ρσ_anonfunc.__argnames__) Object.defineProperties(ρσ_anonfunc, { __argnames__ : {value: ["ev"]}, __module__ : {value: "read_book.db"} }); return ρσ_anonfunc; })(); }; if (!DB.prototype.delete_books_matching.__argnames__) Object.defineProperties(DB.prototype.delete_books_matching, { __argnames__ : {value: ["library_id", "book_id", "proceed"]}, __module__ : {value: "read_book.db"} }); DB.prototype.__repr__ = function __repr__ () { return "<" + __name__ + "." + this.constructor.name + " #" + this.ρσ_object_id + ">"; }; DB.prototype.__str__ = function __str__ () { return this.__repr__(); }; Object.defineProperty(DB.prototype, "__bases__", {value: []}); function get_db(callback, show_read_book_error) { if (!get_db.ans) { get_db.ans = new DB(callback, show_read_book_error); } return get_db.ans; }; if (!get_db.__argnames__) Object.defineProperties(get_db, { __argnames__ : {value: ["callback", "show_read_book_error"]}, __module__ : {value: "read_book.db"} }); ρσ_modules["read_book.db"].DB_NAME = DB_NAME; ρσ_modules["read_book.db"].DB_VERSION = DB_VERSION; ρσ_modules["read_book.db"].upgrade_schema = upgrade_schema; ρσ_modules["read_book.db"].file_store_name = file_store_name; ρσ_modules["read_book.db"].get_error_details = get_error_details; ρσ_modules["read_book.db"].new_book = new_book; ρσ_modules["read_book.db"].indexed_db_api = indexed_db_api; ρσ_modules["read_book.db"].DB = DB; ρσ_modules["read_book.db"].get_db = get_db; })(); (function(){ var __name__ = "iframe_comm"; var LOADING_DOC, instance_numbers; var traceback = ρσ_modules.traceback; var GCM = ρσ_modules.aes.GCM; var E = ρσ_modules.elementmaker.E; var install = ρσ_modules.gettext.install; var get_translations = ρσ_modules["book_list.globals"].get_translations; var main_js = ρσ_modules["book_list.globals"].main_js; var get_font_family = ρσ_modules["book_list.theme"].get_font_family; var ensure_id = ρσ_modules.dom.ensure_id; LOADING_DOC = "\n\n\n\n\n\n\n